Classic Computer Magazine Archive PROGRAM LISTING: 88-10a/XEPRINT.M65


0100 ;XEPRINT SOURCE CODE
0110 ;XEP-PRINT USR ROUTINE
0120 ; FUNCTION:
0130 ; A=USR(XEPRINT, X, Y, ADR(A$),
0140 ;       LEN(A$) )
0150 ;
0160 ; Using direct screen RAM access,
0170 ;write the string pointed to
0180 ;on the graphics mode 0 display.
0190 ; Handle CHR$(125), clear screen
0200 ;properly, but all other chars
0210 ;are printed. No editing, etc.
0220 ; 30 A=USR(XEPFREAD, "D:PIC.GR8", ADR(BUF$))
0230 SAVMSC = 88     ;Screen RAM pointer
0240 RETURN = 155    ;Carraige Return
0250 CLEAR = 125     ;clear screen
0260 STRING = $D0    ; String pointer
0270 STRLEN = STRING+2 ; String counter, 2 bytes
0280 XPOS =  STRLEN+2 ; xpos of cursor
0290 YPOS =  XPOS+1  ;ypos of cursor
0300 PUTADR = YPOS+1 ;2byte screen pointer
0310 ORGADR = PUTADR+2 ; Save original PUTADR here
0320 CLRADR = ORGADR+2 ; Working register to clear screen
0330 TEMP =  CLRADR+2 ; Work, convert ASCII to internal
0340     *=  $0600
0350     PLA 
0360     CMP #$04
0370     BEQ BEG1
0380 ;
0390     TAX 
0400     BEQ LEAVE
0410 ;
0420 LOOPEM
0430     PLA 
0440     PLA 
0450     DEX 
0460     BNE LOOPEM
0470 ;
0480 LEAVE
0490     RTS 
0500 BEG1
0510     LDA #$00
0520     STA PUTADR
0530     STA PUTADR+1
0540     PLA 
0550     PLA 
0560     STA XPOS
0570     PLA 
0580     PLA 
0590     STA YPOS
0600     TAX 
0610     BEQ NOADD
0620 ;
0630 BY40
0640     LDA #40
0650     CLC 
0660     ADC PUTADR
0670     STA PUTADR
0680     BCC BY40A
0690 ;
0700     INC PUTADR+1
0710 BY40A
0720     DEX 
0730     BNE BY40
0740 ;
0750 NOADD
0760     LDA XPOS
0770     CLC 
0780     ADC PUTADR
0790     STA PUTADR
0800     BCC SAVEIT
0810 ;
0820     INC PUTADR+1
0830 SAVEIT ;        Save orig. put addr
0840 ;
0850 ; Save start PUT address
0860 ;
0870     CLC 
0880     LDA SAVMSC
0890     ADC PUTADR
0900     STA PUTADR
0910     STA ORGADR
0920     LDA SAVMSC+1
0930     ADC PUTADR+1
0940     STA PUTADR+1
0950     STA ORGADR+1
0960 ;
0970 ; Get string address
0980 ;
0990     PLA 
1000     STA STRING+1
1010     PLA 
1020     STA STRING
1030     PLA         ; get string len
1040     STA STRLEN+1
1050     PLA 
1060     STA STRLEN
1070 ;
1080 ; All inits complete, now
1090 ;get the string handling
1100 ;RETURN and CLEAR screen
1110 ;chars. properly.
1120 ;
1130 PRINT
1140     LDY #$00    ;Always zero here
1150     SEC         ;DECREMENT, DONE TEST FIRST
1160     LDA STRLEN
1170     SBC #$01
1180     STA STRLEN
1190     BCS PRINT1
1200 ;
1210     LDA STRLEN+1 ;ALL DONE?
1220     BEQ EXITNOW
1230 ;
1240     DEC STRLEN+1
1250 PRINT1
1260     LDA (STRING),Y
1270     CMP #RETURN
1280     BEQ RETURNIT
1290 ;
1300     CMP #CLEAR
1310     BEQ CLEARIT
1320 ;
1330     STA TEMP
1340     AND #$7F    ; Forget invid
1350     TAX         ; Convert to screen
1360     CPX #$60
1370     BCS PUTNOW
1380 ;
1390     LDA #$40
1400     CPX #$20    ; ASC<32 THEN ADD 64
1410     BCC ADCV
1420 ;
1430     LDA #$E0    ; $E0 = -32 32<ASC<96
1440 ADCV
1450     CLC 
1460     ADC TEMP
1470     STA TEMP
1480 PUTNOW ;        Store converted
1490     LDA TEMP
1500     STA (PUTADR),Y ;char on
1510     INC PUTADR  ; screen
1520     BNE NEXCHAR
1530 ;
1540     INC PUTADR+1
1550 NEXCHAR ;       NEXT SCREEN CHARACTER
1560     INC STRING
1570     BNE PRINT
1580 ;
1590     INC STRING+1
1600     BNE PRINT   ;CONTINUE
1610 ;
1620 EXITNOW ;       Go home
1630     RTS 
1640 ;
1650 CLEARIT
1660     LDA SAVMSC
1670     STA CLRADR
1680     LDA SAVMSC+1
1690     STA CLRADR+1
1700     LDX #$03    ; 3*256 = 768 OF 960
1710     LDA #$00
1720 CLEAR3
1730     STA (CLRADR),Y
1740     INY 
1750     BNE CLEAR3
1760 ;
1770     INC CLRADR+1
1780     DEX 
1790     BNE CLEAR3
1800 ;
1810 CLEAR4
1820     STA (CLRADR),Y
1830     INY 
1840     CPY #192    ; Last 192 bytes
1850     BNE CLEAR4
1860 ;
1870     LDY #$00
1880     BEQ NEXCHAR ; Continue
1890 ;
1900 RETURNIT ;      Use xpos for column
1910     CLC 
1920     LDA #40
1930     ADC ORGADR
1940     STA ORGADR
1950     BCC RET1
1960 ;
1970     INC ORGADR+1
1980 RET1
1990     LDA ORGADR
2000     STA PUTADR
2010     LDA ORGADR+1
2020     STA PUTADR+1
2030     CLC 
2040     BCC NEXCHAR
2050 ;
2060     .END 


Back to previous page