Classic Computer Magazine Archive PROGRAM LISTING: 85-02/SAMHANDL.ASM


50       .OPT LIST
60 ;EQUATES
70 BUFFO =   $CB     ;BUFFER OFFSET IS A SAFE PAGE 0 LOCATION
80 BUFF  =   $2014   ;LOCATION OF SAM BUFFER
90 EOL   =   $9B     ;END OF LINE CHARACTER CODE
0100 SAYIT = $200B   ;RECITER ENTRY POINT
0110 HATABS = $031A  ;START OF HANDLER TABLE
0120 ;THIS IS IT
0130 ;INSTALLATION ROUTINE
0140 ;LOCATED IN PAGE 6
0150     *=  $0600
0160 HANDLOAD
0170     PLA         ;REMOVE UNUSED BASIC ARGUMENT
0180     LDX #0      ;START AT THE BEGINNING
0190     STX BUFFO   ;MARK BUFFER EMPTY
0200 SEARCH
0210     LDA HATABS,X ;CHECK DEVICE NAME
0220     BEQ NOMORE  ;LAST ENTRY?
0230     CMP #'V     ;IS HANDLER ALREADY INSTALLED?
0240     BEQ END     ;YES, SO QUIT
0250     INX 
0260     INX 
0270     INX         ;NEXT ENTRY
0280     BNE SEARCH
0290 NOMORE ;        LOAD HANDLER
0300     LDA #'V     ;DEVICE NAME, "V:"(VOICE)
0310     STA HATABS,X ;TO HANDLER TABLE
0320     LDA # <SAMHAND ;LSB OF VECTOR ADDRESS
0330     STA HATABS+1,X
0340     LDA # >SAMHAND ;MSB OF VECTOR ADDRESS
0350     STA HATABS+2,X
0360     LDA #0
0370     STA HATABS+3,X ;ENSURE CORRECT END OF TABLE
0380 END RTS 
0390 ;HANDLER TABLE UPDATED
0400 ;IN ORDER TO USE, AFTER RESET SAY,
0410 ;USE "A=USR(1536)"
0420     .PAGE "THIS IS SAM HANDLER"
0430 SAMHAND
0440     .WORD VOPEN-1
0450     .WORD VCLOSE-1
0460     .WORD VGETB-1 ;IMPOSSIBLE, BUT A VECTOR IS REQUIRED
0470     .WORD VPUTB-1
0480     .WORD VSTATUS-1
0490     .WORD VXIO-1
0500     JMP VXIO    ;FOR SAFETY!
0510 VXIO ;          ERROR IT
0520 VGETB RTS       ;CANNOT BE DONE
0530 VOPEN ;         DO NOTHING BUT TELL
0540 VSTATUS ;       O.S. THAT EVERYTHING O.K.
0550     LDY #1      ;IF THEY ARE CALLED
0560     RTS         ;THEY SIGNAL SUCCESS!
0570 VPUTB
0580     PHA         ;SAVE DATA BYTE
0590     LDA BUFFO
0600     TAX         ;BUFFER OFFSET IN X
0610     PLA 
0620     CMP #EOL    ;IS IT AN END OF LINE
0630     BNE NEXT    ;NO
0640     LDA #'.     ;YES, SO SEND A
0650     STA BUFF,X  ;PERIOD FOR INFLECTION
0660     INX 
0670     LDA #EOL    ;AND THEN SEND THE
0680     STA BUFF,X  ;END OF LINE
0690     JMP SPEAK   ;AND SAY IT
0700     STA BUFF,X
0710 NEXT CMP #',    ;IS IT A COMMA?
0720     BNE NEXT1   ;NO
0730     STA BUFF,X  ;YES SO SEND IT,
0740     INX 
0750     LDA #$20    ;AND A SPACE.
0760 NEXT1 STA BUFF,X
0770     INX 
0780     TXA 
0790     STA BUFFO   ;INCREMENT BUFFER OFFSET
0800     CMP #$FE    ;BUFFER FULL?
0810     BNE NOTFULL
0820     LDA #EOL    ;BUFFER FULL SO SEND EOL
0830     STA BUFF,X  ;TO BUFFER AND SAY IT.
0840 SPEAK
0850     JSR SAYIT
0860     LDA #EOL
0870     STA BUFF    ;EMPTY BUFFER
0880     LDA #0
0890     STA BUFFO   ;MARK BUFFER EMPTY
0900 NOTFULL LDY $01 ;MARK SUCCESS
0910     RTS 
0920 ;AND THAT'S IT!
0930 VCLOSE
0940     LDA #EOL
0950     STA BUFF,X
0960     JSR SAYIT   ;ON CLOSE, SPEAK WHAT ID IN BUFFER
0970     LDA #EOL
0980     STA BUFF    ;EMPTY BUFFER
0990     LDA #0
1000     STA BUFFO   ;MARK BUFFER EMPTY
1010     LDY #1      ;SIGNAL SUCCESS
1020     RTS 

Back to previous page