
 1000         .TI 60,VIDEX mods TO S-C Macro Assembler by Rip Toren             
 1010  *==========================================================
 1020  * Modifications to the S-C Macro Assembler to interface   *
 1030  * with the VIDEX 80 col. display board.                   *
 1040  *                                                         *
 1050  *      BY                                                 *
 1060  * Richard P. Toren                                        *
 1070  *  July 1982                                              *
 1080  *                                                         *
 1090  *==========================================================
 1095    
 1096     
 1100  *  .FN "ASAVE&VIDEX 
 1101   
 1102   
 1110  *==========================================================
 1120  * AUTO-SAVE
 1125  *   
 1130  * from AAL Apr 1982 
 1140  * The mod to the version number was not implemented.
 1150  *
 1160  * I have included this since this is one of the best mods
 1165  * for the assembler
 1166  *
 1170  * My file name is in a comment:
 1180  *
 1190  * .FN "filename 
 1200  *
 1210  * LENGTH OF $141
 1220  * A$3200,-$3341
 1225  *==========================================================
 1230  MON.COUT   .EQ $FDED
 1240  MON.CROUT  .EQ $FD8E
 1250  MON.BELL1  .EQ $FBDD
 1260  IN.BUF     .EQ $200
 1270  SCR.END    .EQ $4C,4D
 1280  SCR.START  .EQ $CA,CB
 1290  NEXT       .EQ $1D
 1300  SEARCH     .EQ $1E,1F
 1310    
 1320         .OR $3200
 1330         .TF AUTOSAVE&VIDEX
 1340    
 1350  AUTO.SAVE
 1360         LDA SCR.START
 1370         STA SEARCH
 1380         LDA SCR.START+1
 1390         STA SEARCH+1
 1400         CLD
 1410  ADDRESS.END.CMP
 1420         LDA SEARCH
 1430         CMP SCR.END
 1440         BNE .1
 1450         LDA SEARCH+1
 1460         CMP SCR.END+1
 1470         BEQ ERROR1
 1480    
 1490  .1     LDY #0
 1500         LDA (SEARCH),Y
 1510         STA NEXT
 1520         LDY #3
 1530         LDA (SEARCH),Y
 1540         CMP #'*
 1550         BNE NEW.LINE  MINE IN COM
 1560  .5     CMP #$C0
 1570         BNE .2
 1580  .4     INY
 1590         INY
 1600         CLV
 1610         BVC .3
 1620  .2     CMP #$80
 1630         BCS OPCHK
 1640  .3     INY
 1650         LDA (SEARCH),Y
 1660         BEQ NEW.LINE
 1670         BNE .5
 1700    
 1710  NEW.LINE
 1720         CLC
 1730         LDA SEARCH
 1740         ADC NEXT
 1750         STA SEARCH
 1760         BCC ADDRESS.END.CMP
 1770         INC SEARCH+1
 1780         BNE ADDRESS.END.CMP
 1810    
 1820  ERROR1
 1830         LDY #0
 1840  PRTERR LDA NO.TTL,Y
 1850         BMI ERREND
 1860         ORA #$80
 1870         JSR MON.COUT
 1880         INY
 1890         BNE PRTERR
 1900  ERREND JSR MON.COUT
 1910         JSR MON.BELL1
 1920         JSR MON.BELL1
 1930         JSR MON.CROUT
 1940         RTS
 1950  ERROR2
 1960         LDY #18
 1970         BNE PRTERR
 1980    
 2000   
 2010  OPCHK  LDX #0
 2020  .1     INY
 2030         LDA (SEARCH),Y
 2040         BEQ NEW.LINE
 2050         CMP OPS,X
 2060         BNE NEW.LINE
 2070         INX
 2080         CPX #3
 2090         BNE .1
 2120    
 2130  TITLE  INY
 2140         LDA (SEARCH),Y
 2150         BEQ ERROR1
 2160         CMP#'"       "FILE NAME"
 2170         BNE TITLE
 2180  .1     INY
 2190         LDA (SEARCH),Y
 2200         BEQ ERROR1
 2210         CMP #$C0
 2220         BEQ COMP.CODE1
 2230         CMP #$80
 2240         BCS .1
 2250         CMP #'A
 2260         BCC ERROR2
 2270         CMP $58
 2280         BCS ERROR2
 2320   
 2330         PHA
 2340         LDX #0
 2350  .2     LDA SAVE,X
 2360         JSR MON.COUT
 2370         INX
 2380         CPX #5
 2390         BNE .2
 2400         PLA
 2410  NEXT.CHAR1
 2420         ORA #$80
 2430         JSR MON.COUT
 2440         INX
 2450  NEXT.CHAR2
 2460         INY
 2470         LDA (SEARCH),Y
 2480         BEQ DOS.OP
 2490         CMP #',
 2500         BNE .1
 2510         LDA #'/
 2520         BNE NEXT.CHAR1
 2530  .1     CMP #$C0
 2540         BEQ COMP.CODE2
 2550         CMP #$80
 2560         BCC NEXT.CHAR1
 2570         INY
 2580         LDA (SEARCH),Y
 2590         BEQ DOS.OP
 2600         DEY
 2610         LDA #$20
 2620         BNE NEXT.CHAR1
 2650   
 2660  COMP.CODE1
 2670         INY
 2680         LDA (SEARCH),Y
 2690         STA NEXT
 2700         INY
 2710         LDA (SEARCH),Y
 2720         CMP #'A
 2730         BCC ERROR2
 2740         CMP #$5B
 2750         BCS ERROR2
 2760         PHA
 2770         LDX #0
 2780  .1     LDA SAVE,X
 2790         JSR MON.COUT
 2800         INX
 2810         CPX #5
 2820         BNE .1
 2830         PLA
 2840         BNE STORE
 2850  COMP.CODE2
 2860         INY
 2870         LDA (SEARCH),Y
 2880         STA NEXT
 2890         INY
 2900         LDA (SEARCH),Y
 2910         CMP #',
 2920         BNE STORE
 2930         LDA #'/
 2940  STORE
 2950         ORA #$80
 2960         JSR MON.COUT
 2970         INX
 2980         DEC NEXT
 2990         BNE STORE
 3000         BEQ NEXT.CHAR2
 3005   
 3010  *
 3020  * Skip the version update for the moment
 3030  *    
 3040  DOS.OP
 3050         JSR MON.CROUT
 3060  END    RTS
 3090    
 3100  OPS    .AS /.FN/
 3110  SAVE   .HS 84       ctl D
 3120         .AS -/SAVE/
 3130  NO.TTL .AT /!! NO TITLE ERROR / 
 3140         .AT /!! ILLEGAL TITLE /
 3150   
 3160   
 3170   
 3180  *==========================================================
 3190  * The following are the commands that are issued to the
 3200  * VIDEX to perform the given function.
 3210  *==========================================================
 3220   
 3260  COUT   .EQ $FDED
 3270   
 3280  * This routine will position cursor at CH,CV 
 3290  GOTOXY JSR SAVEREG 
 3300         LDA $25      save CV
 3310         PHA
 3320         LDA $24      save CH
 3330         PHA
 3340         LDA #30
 3350         JSR COUT     goto leadin
 3360         PLA          get CH
 3370         CLC
 3380         ADC #$20
 3390         JSR COUT
 3400         PLA          get CV
 3410         ADC #$20
 3420         JSR COUT
 3430         JMP RESTREG
 3440  ADVANCE
 3450         LDA #28
 3460         JMP SAFEOUT
 3470  BS
 3480         LDA #8
 3490         JMP SAFEOUT
 3500  UP
 3510         LDA #31
 3520         JMP SAFEOUT
 3530  DOWN
 3540         LDA #10
 3550         JMP SAFEOUT
 3560  CLREOP
 3570         LDA #11
 3580         JMP SAFEOUT
 3590  CLEAR
 3600         LDA #12
 3610         JMP SAFEOUT
 3620  CLREOL 
 3630         LDA #29
 3640         JMP SAFEOUT
 3650  *
 3660  SAFEOUT
 3670         JSR SAVEREG
 3680         JSR COUT
 3690         JSR RESTREG
 3700         RTS
 3710  *
 3720  SAVEREG
 3730         STX SX          don't distrurb the regs
 3740         STY SY
 3750         RTS
 3760  RESTREG
 3770         LDX SX          get them back
 3780         LDY SY
 3790         RTS
 3800  SX     .DA #0
 3810  SY     .DA #0
 3820    
 3830  *************************************************************
 3840  * The following is the warm start patch that will initialize the
 3850  * the VIDEX board, and set the cursor to an underline. This routine
 3860  * is also used by "NEW".
 3870  *************************************************************
 3880    
 3890   
 3900  *   !!!!!!!!!!!!
 3910  *  SET THE SLOT VALUE FOR YOUR VIDEX BOARD
 3920   
 3930  SLOT   .EQ $3            slot#     
 3940  SLOT16 .EQ SLOT*16
 3950  V.DEV0 .EQ $C080         addresses the CRTC internal regs
 3960  V.DEV1 .EQ $C081         content of specified reg
 3970  *==========================================================
 3980  VID.ON LDA #SLOT
 3990         JSR $FE95         simulate PR#3
 4000  V.CRSON
 4010         LDA #$0A          CRTC reg 10
 4020         STA V.DEV0+SLOT16
 4030         LDA #$88          non-flashing underline
 4040         STA V.DEV1+SLOT16
 4050  * self modification for automatic shift to lower case.
 4060         LDA $1011         second tab
 4070         SBC #1            offset for initial blank
 4080         STA VT1+1         target of self-modification
 4090         JSR CLEAR         clear screen
 4100         JMP $101C           SCM warm-start
 4110  *
 4120  *==========================================================
 4130  * This routine will shift you from upper to lower case at
 4140  * the second TAB stop. I use this for the comments.
 4145  *==========================================================
 4150  RDKEY  .EQ $FD0C
 4160  AUTOSHIFT
 4170  VT1    CPX #0            will be modified with 2nd tab value
 4180         BNE .1            no action
 4190         LDA $205
 4200         CMP #$AA          "*" this is a comment  
 4210         BEQ .1            no conversion on comments
 4220         LDA #$40          force lower case 
 4230         STA $7F8+SLOT
 4240  .1     JSR RDKEY         now get the input key
 4250         CMP #$8D          on carriage return, flip back
 4260         BEQ VT2
 4270         CMP #$98          ^X  same here
 4280         BEQ VT2
 4290         RTS               stay in current case
 4300  VT2    PHA
 4310         LDA #$00          force upper case
 4320         STA $7F8+SLOT
 4330         PLA
 4340         RTS
 4350   
 4360  *==========================================================
 4370  * The following are needed since my EDIT wants $A0 for space,
 4380  * while everyone else is looking for a $20.
 4390  *==========================================================
 4400  ZAP.A0 PHA
 4410         LDA #$A0
 4420         STA $127A
 4430         PLA
 4440         JMP $185D    GET.KEY.STRING
 4450  ZAP.20 PHA
 4460         LDA #$20
 4470         STA $127A
 4480         PLA
 4490         JMP $1D94    CHO
 4500    
 4510  *==========================================================
 4520  * RDL.OVERRIDE is needed because of the $2C trick and I
 4530  * must read '->' characters from buffer.
 4535  *==========================================================
 4540  RDL.OVERRIDE
 4550         JSR $14CA         read.key.with.case
 4560         ORA #$80          assure sign bit on
 4570         JMP $139B         rdl.add.char
 4580    
 4590  ZZZEND .EQ *
 4600  ZZZLEN .EQ ZZZEND-AUTO.SAVE
 4610  *==========================================================
 4620  * Replace the jump addres in the ESC handler routine.
 4630  *==========================================================
 4635   
 4640         .OR $1467
 4650         .TF JMP.OBJ
 4660         .DA CLEAR-1       videx routinee
 4670         .DA ADVANCE-1     videx routine
 4680         .DA BS-1          videx routine
 4690         .DA DOWN-1        videx routine
 4700         .DA UP-1          videx routine
 4710         .DA CLREOL-1      videx routine
 4720         .DA CLREOP-1      videx routine
 4730         .DA $FC2A         no change
 4740         .DA $FC2A         no change
 4750         .DA UP-1          videx routine
 4760         .DA BS-1          videx routine
 4770         .DA ADVANCE-1     videx routine
 4780         .DA $1482         no change
 4790         .DA DOWN-1        videx routine

