Bob’s Notebook: Printer Interfaces

See all articles from Sinc-Link v6 n2
Author(s): Bob Mitchell
Publication: Sinc-Link
Pub Details: Sinc-Link v6 n2 (Volume 6, Issue 2)
Date: March/April 1988
Pages: 5-6

PRINTER INTERFACES

Here is a table of features etc for two printer interface software programs which I have used with my printer interface board. One is Peter Hacksel‘s LPRINT which came with my board and the other is one called PRCODE.

                          LPRINT     PRCODE
Start address..........   65000      64256
Length.................     500       1111
Pokes (to set up) 26703       0          5
                  26704     254        251
                  65535       0         --
Line Length set........      --      64259
TAB n .............. n spaces       as for
                       added        TS2068
Printer Control Codes    note a     note b
**************************************
note a: Use POKE 65535,1*;then standard
        codes for printer;then POKE
        65535,0&
note b: Use POKE 64256,0*;then standard
        codes for printer;then POKE
        64256,1&
        * true ASCII character set
        & 2068 character set

LPRINT Disadvantages: Cannot set line length;
                      TAB is non standard &
                      awkward to use.
       Advantages:    Will ignore INVERSE,
                      PAPER etc in listings.

PRCODE Disadvantages: Only one I can see;
                      During LLIST it will
                      stop working properly
                      when it comes across
                      INVERSE, PAPER etc
                      (even if they are
                      imbedded in a string)
       Advantages:    Line Length can be set;
                      TAB seems to work OK.

Both programs are relocatable. I use my reloc8.Cc program to do this (copy in club library). Note that PRCODE runs at 5 bytes after the start address (ie, 64261 with a start address of 64256). So when you relocate it to a new address, you may want it to start running at an address which is a multiple of 256 (so that you only have to rePOKE 26704 to change from 2040 to PRCODE); in that case make the code start address 5 less than the “run” address.


MORE PEEKING AND POKING ABOUT

In my earlier article on PEEKING and POKING, I mentioned the difficulty in peeking out variable data when it exists in floating point notation. If you had not forced your numeric variables into the INT (integer) mode when you used TIMACHINE, you ended up with these floating point numbers. Then, if you wanted to use these values in some other program, you had to use a routine to convert them to decimal numbers. For example, the decimal number 6524 = 141 75 224 0 0 in floating point. The application that presented itself came about when I wanted to print the data in my BUDGET program onto the big printer. I found that the data was (and had to be) in floating point because the dollars AND cents had to be conserved for calculation. Without going into the theory then, here is the routine that I used to do the job. It will work with the TIMACHINE compiled code version of Budget which I have provided to the club library. This routine will print four different spreadsheets onto the big printer using Condensed type mode. I used LPRINT (see above) and the sheets took almost the full width of the printer paper , ie, 8-1/2 inches. Without condensed mode, you would have to print each sheet in two or more parts and this would really defeat the purpose of the routine as it would be simpler to just use the 2040 printer with the orginal Budget program.

7000 RESTORE 7050
7010 DIM t$(19,10): FOR i=1 TO 19: READ t$(i): NEXT i
7030 RETURN
7050 DATA "GROCERIES","CLOTHING","VACATION","HOUSING","TAXES","HYDRO","GAS","PHONE","HIS","HERS","TRANSPORT","GIFTS","LEISURE","CAPITAL","DENTAL","MEDICAL","LIQUOR","MISC."
7060 DATA "TOTALS>>"
8000 OUT 127,15: POKE 23658,8: INPUT "Select Spreadsheet..."''"P=Planned A=Actuals"'"Q=Planned YTD B=Actuals YTD"; LINE i$
8002 POKE 26704,254: POKE 65535,0
8003 LET tflag=0
8010 OPEN #2,"p"
8015 PRINT ("PLANNED" AND i$="P")+("ACTUALS" AND i$="A")+("PLANNED YTD" AND i$="Q")+("ACTUALS YTD" AND i$="B")
8020 PRINT " JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC TOTAL"
8030 IF i$="P" THEN LET first=50987: LET last=52066
8035 IF i$="Q" THEN LET first=54497: LET last=55517
8040 IF i$="A" THEN LET first=52067: LET last=53146
8043 IF i$="B" THEN LET first=55577: LET last=56597
8045 LET cat=1
8050 FOR i=first TO last STEP 60
8060 PRINT t$(cat);: LET tot=0: FOR j=0 TO 55 STEP 5
8070 LET a=PEEK (i+j)
8080 LET e=PEEK (i+j+1)
8090 LET d=PEEK (i+j+2)
8100 LET c=PEEK (i+j+3)
8110 LET b=PEEK (i+j+4)
8120 GO SUB 8190
8130 LET tot=tot+VAL n$
8140 PRINT n$;" ";
8150 NEXT j
8160 IF i$="P" OR i$="A" THEN PRINT tot
8162 IF i$="Q" OR i$="B" THEN PRINT " "
8163 IF tflag THEN RETURN
8165 LET cat=cat+1
8170 NEXT i
8172 LET tflag=1
8175 LET i=(54257 AND i$="P")+(57767 AND i$="A")
8177 LET cat=19: GO SUB 8060
8178 PRINT
8180 POKE 26704,5: GO TO 200
8190 IF a<>0 THEN GO TO 8240
8200 DIM n$(8)
8210 LET num=256*c+d
8220 IF e=255 THEN LET num=num-65536
8230 GO TO 8290
8240 LET exp=a-128
8250 LET sign=-1
8260 IF e<128 THEN LET sign=1: LET e=e+128
8270 LET mant=e/256+d/65536+c/16777216+b/4294967296
8280 LET num=sign*2^exp*mant
8290 LET n$=STR$ num
8300 RETURN

SOME EXPLANATORY NOTES

1. This is to be added to the the tail end of a “budget boot” program which appears with “budget.CC” on the library copy.

2. The boot should be modified to allow the user to select this “printout” routine which starts at line 8000.

3. Line 8000>>OUT 127,15 switches print mode to condensed; POKE 23658,8 turns on caps; there are four choices of spreadsheets as shown.

4. Line 8002 sets up “lprint.C1”

5. Line 8003 sets variable “tflag” used later.

6. Line 8010 opens the print stream and channel.

7. Lines 8030 to 9043 set variables “first” and “last” to values determined from the TIMACHINE listing of runtimes and variables.

8. Line 8045 sets variable “cat” to 1 (This is used to print the categories).

9. Lines 8050 to 8110 and 8190 to 8300 are the heart of the conversion routine to make decimal numbers out of the floating point numbers.

Bob Mitchell
871012

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.