[net.micro.ti] Forth code for screen dump

mj@myriasb.UUCP (Michal Jaegermann) (04/27/85)

Recently I posted some anouncement about availability of a decent screen
dump for TI. I wa asked to post a code. This would be quite difficult
for many reasons.  To substitute I am posting a TI Forth code for a
screen dump for all bit-map modes. This is not as fast as the machine
language one but still quite decent.
----------------------------- CUT HERE ---------------------------------
( Bit-map Screen Dump - shadow screen * M. Jaegermann 21APR85 )
  -->
This program dumps a whole bit-map screen in double size - 8 in
across - double density graphics on every Epson-like printer
with graphics capabilities. Changing values of of LASTCOL and
1STCOL ( n ' LASTCOL ! will do ) and using .PICT with proper
addresses one may dump only part of a screen. LMSET sets a left
margin for a printout and is for people with wide printers or
for dumping part of the screen ( I know that Gemini has left
margin option - but some others printers don't ). Playing with
the program is easy to adapt it to work in single size, print
white on black and so on. In particular the word H>V - horizon-
tal to vertical accepts any bit pattern to substitute for a
single bit. To test use the following
HEX  : DEMO GRAPHICS2 0 BF FF BF LINE C0 0 DO 0 I I 4 3 */ BF
           LINE 8 +LOOP SCREEN/DUMP ;  DEMO
( Bit-map Screen Dump 1st scn   * Michal Jaegermann 21APR85 )
BASE->R   -PRINT -GRAPH -TEXT -GRAPH2             HEX
20 CONSTANT LASTCOL        0 CONSTANT 1STCOL
0  VARIABLE OBUF FE ALLOT  O VARIABLE OPNTR   O VARIABLE BLFLG
0  VARIABLE CHR#           0 VARIABLE LMAR
2000 VARIABLE SCRNS 3800 , 2000 , 3000 , 3800 , 2400 ,
: LMSET ( n -- )  SWCH 1B EMIT 40 EMIT DUP IF 1B EMIT 44 EMIT
  DUP EMIT 0 EMIT ENDIF CR UNSWCH LMAR ! ;
: H>V ( pattern,b -- pattern ) 8 SLA BEGIN DUP WHILE DUP 0<
   IF OVER OPNTR @ C@ XOR OPNTR @ C! 1 BLFLG ! ENDIF
                                         1 OPNTR +! 1 SLA
                                     REPEAT DROP ;
: TRBITS ( addr,source -- f )  0 BLFLG !    C0  ( pattern )
    4 0 DO >R >R DUP OPNTR ! R> R> OVER I + VSBR     H>V
           2 SRA LOOP    DROP DROP DROP BLFLG @ ;
-->
( Bit-map Screen Dump 2nd scn   * Michal Jaegermann 21APR85 )
: HFLINE ( vaddr -- vaddr )  0 CHR# !   OBUF 100 ERASE
  LASTCOL 1STCOL - 0 DO OBUF I 3 SLA + OVER I 1STCOL + 3 SLA
  TRBITS       IF I 1+ CHR# ! ENDIF       LOOP ;
: GCODE ( count -- )  LMAR @ IF 9 EMIT ENDIF  ( printer code )
  1B EMIT 4C EMIT  DUP FF AND EMIT8   8 SRL EMIT8  ;
: GRPH  ( count -- ) DUP 1E * GCODE 3 SLA OBUF + OBUF
  DO I C@    4 I 3 AND 0= - 0 DO DUP EMIT8 LOOP DROP   LOOP ;
: .GLINE ( vaddr -- )  2 0  DO I 2 SLA +   HLFLINE CHR# @
   -DUP IF GRPH ENDIF   CR LOOP   DROP ;
: .PICT ( vaddr1,vaddr2 -- ) SWCH CR 1B EMIT 41 EMIT 8 EMIT
   DO I .GLINE ?TERMINAL IF LEAVE ENDIF 100 +LOOP CR UNSWCH ;

: SCREEN/DUMP VDPMDE @ 4 - DUP 0< IF DROP CR           ." Error
-- wrong vmode" ELSE 4 * SCRNS + DUP 2 + @ SWAP @ .PICT ENDIF ;
     R->BASE
------------------------ CUT HERE -----------------------------

Now use your beloved utility to copy that onto Forth screens and happy
dumping. If you have a code for a nice picture please post it to the
net.
                                  Michal Jaegermann
                                  ...ihnp4!alberta!myrias!mj