
PROGRAM LISTING: 85-11/FASTMOVE.M65
10 ; FAST MOVES, LISTING 2
20 ; BY PATRICK DELL'ERA
30 ; (c) 1985, ANTIC PUBLISHING
40 ;
0100 ; EQUATES
0110 ;
0120 RUNAD = $02E0 ;Auto run addr
0130 MEMLO = $02E7 ;Lower limit of
0140 ; ; free memory
0150 DOSVEC = $0A ;Addr jumped to
0160 ; ; when DOS called
0170 DOSINI = $0C ;Initialization
0180 ; ; addr for DOS
0190 VVBLKD = $0224 ;dlyd vbi vctr
0200 SETVBV = $E45C ;set vbi
0210 VKEYBD = $0208 ;Keyboard vctr
0220 SKSTAT = $D20F ;Keyboard status
0230 KBCODE = $D209 ;Pokey rgstr
0240 CH = $02FC ;Current key--
0250 ; ; KBCODE shadow
0260 CH1 = $02F2 ;Previous key
0270 ATTRACT = $4D ;Atct mode flag
0280 SRTIMR = $022B ;Auto-Repeat tmr
0290 UP = $8E ;Hardware codes
0300 DOWN = $8F ; for key
0310 LEFT = $86 ; pressed
0320 RIGHT = $87 ;
0330 DUMMY = $FF ;Variable byte
0340 ADDR = $FFFF ;Variable word
0350 ;
0380 ;
0390 *= $1D7C ;End of resident
0420 ;
0430 ;
0440 DBOUNCE .BYTE 1
0450 FASTFLG .BYTE $FF
0460 TABLE
0470 .BYTE UP,DOWN,LEFT,RIGHT
0480 FAST.MOVES
0490 TXA ;OS has already
0500 PHA ; saved reg A,
0510 ; ; we also save X
0520 LDA KBCODE ;Get key pressed
0530 LDX #4 ;Then search
0540 ; ; TABLE for a
0550 ; ; match
0560 SEARCH
0570 DEX
0580 STX FASTFLG ;Save index into
0590 ; ; TABLE
0600 BMI NONE ;End of table...
0610 CMP TABLE,X ;Found a match?
0620 BNE SEARCH ;No,keep looking
0630 STA CH1 ;Key is a cursor
0640 STA CH ; control, so
0650 LDA #$0F ; update current
0660 STA DBOUNCE ; and previous
0670 STA ATTRACT ; key pressed,
0680 PLA ; set our delay
0690 TAX ; timer, reset
0700 PLA ; attract mode
0710 RTI ; and go back
0720 NONE
0730 PLA ;No matches so
0740 TAX ; let OS have key
0750 VKEYBD.SAVE = *+1
0760 JMP ADDR ;Addr is modi-
0770 ; ; fied by INIT
0780 ; ; to point to
0790 ; ; OS's handler
0800 ;
0810 ;
0820 ;The addr for REINIT is stored
0830 ;in DOSINI. SYSTEM RESET will
0840 ;come through here and then
0850 ;through INIT2 to re-establish
0860 ;Fast Moves.
0870 ;
0880 REINIT
0890 JSR ADDR ;Address is
0900 ; ; changed to
0910 ; ; DOSINI vector
0920 ; ; by INIT
0930 ;
0940 ;After returning from the
0950 ;DOS initialization, we have to
0960 ;re-establish the vectors in
0970 ;DOSINI, and DOSVEC. In this way
0980 ;we make Fast Moves "persistent".
0990 ;
1000 INIT2
1010 LDA # <REINIT
1020 STA DOSINI
1030 LDA # >REINIT
1040 STA DOSINI+1
1050 LDA # <CALL.DOS
1060 STA DOSVEC
1070 LDA # >CALL.DOS
1080 STA DOSVEC+1
1090 ;
1100 ;Move lo mem up to create safe
1110 ;place for Fast Moves.
1120 ;
1130 LDA # <FINIS
1140 STA MEMLO
1150 LDA # >FINIS
1160 STA MEMLO+1
1170 ;
1180 ;Insert Fast Moves into the
1190 ;keyboard service routines.
1200 ;
1210 LDA # <FAST.MOVES
1220 STA VKEYBD
1230 LDA # >FAST.MOVES
1240 STA VKEYBD+1
1250 ;
1260 ;Install our vertical blank
1270 ;routine the safe way, through
1280 ;the OS routine for setting
1290 ;vertical blank routines!
1300 ;
1310 LDA #7
1320 LDX # >VBLANK
1330 LDY # <VBLANK
1340 JMP SETVBV
1350 ;
1360 ;Any call to DOS will vector
1370 ;through here.
1380 ;
1390 CALL.DOS
1400 ;
1410 ;Fisrt, replace the OS keyboard
1420 ;routine.
1430 ;
1440 LDA #DUMMY ;This value is
1450 ; ; is set by INIT
1460 VKEYBD.L = *-1
1470 STA VKEYBD
1480 LDA #DUMMY ;So is this one!
1490 VKEYBD.H = *-1
1500 STA VKEYBD+1
1510 ;
1520 ;Then, re-establish the original
1530 ;vertical blank routine.
1540 ;
1550 LDA #7
1560 LDX VBLANK.1+2
1570 LDY VBLANK.1+1
1580 JSR SETVBV
1590 ;
1600 ;Then DOS initialization and
1601 ;start addresses.
1610 ;
1620 DOSREINI
1630 DOS1 = *+1
1640 LDA #DUMMY ;Dummy values
1650 STA DOSINI ; are changed by
1660 DOS2 = *+1
1670 LDA #DUMMY ; INIT to
1680 STA DOSINI+1 ; restore
1685 DOS3 = *+1
1690 LDA #DUMMY ; DOSINI and
1700 STA DOSVEC ; DOSVEC
1705 DOS4 = *+1
1710 LDA #DUMMY ;
1720 STA DOSVEC+1
1730 ;
1740 ;Now we can go safely to DOS.
1750 ;
1760 DO.DOS.V
1770 JMP ADDR ;Addr changed by
1780 ; ; INIT to show
1790 ; ; DOSVEC
1800 ;
1810 ;Vertical Blank Interrupts
1820 ;vector through here. We check
1830 ;to see if a key is being held
1840 ;down. If so, then we determine
1850 ;if it is a cursor control key.
1860 ;If so, then we make it repeat
1870 ;more quickly than OS does.
1880 ;
1890 VBLANK
1900 LDA DBOUNCE ;Debounce logic
1910 ; ; in use?
1920 BEQ VBLANK.3 ;No, make next
1930 ; ; test
1940 DEC DBOUNCE ;Yes, subtract 1
1950 ; ; from timer
1960 BNE VBLANK.1 ;If DBOUNCE<>0,
1970 ; ; all done
1980 VBLANK.3
1990 LDA FASTFLG ;Equals $FF if
2000 BMI VBLANK.1 ; not cursor ctl
2010 LDA SKSTAT ;Bit 3 is on if
2020 AND #4 ; key is still
2030 BNE VBLANK.1 ; held down
2040 LDA #6 ;If timer has
2050 CMP SRTIMR ; already been
2060 ; ; set with 6
2070 ; ; (Fast Moves'
2080 BCS VBLANK.2 ; speed),branch
2090 STA SRTIMR ;Else, set timer
2100 VBLANK.2
2110 DEC SRTIMR ;Subtract 1
2120 VBLANK.1
2130 JMP ADDR ;Addr is changed
2140 ; ; to OS's VBI
2150 ; ; routine by INIT
2160 ;
2170 ;FINIS marks the end of pro-
2180 ;tected memory.
2190 ;
2200 FINIS
2210 ;
2220 ;DOS jumps here after auto load-
2230 ;loading Fast Moves. Several
2240 ;addresses within Fast Moves are
2250 ;modified. This routine is not
2260 ;protected as it is needed only
2270 ;once.
2280 ;
2290 INIT
2300 LDA DOSVEC ;Save DOS vector
2310 STA DO.DOS.V+1
2320 STA DOS3
2330 LDA DOSVEC+1
2340 STA DO.DOS.V+2
2350 STA DOS4
2360 ;
2370 LDA DOSINI ;Save DOS initi-
2380 STA REINIT+1 ; alization
2390 STA DOS1 ; vector
2400 LDA DOSINI+1
2410 STA REINIT+2
2420 STA DOS2
2430 ;
2440 LDA VKEYBD ;Save keyboard
2450 STA VKEYBD.SAVE ; handler
2460 STA VKEYBD.L ; vector
2470 LDA VKEYBD+1
2480 STA VKEYBD.SAVE+1
2490 STA VKEYBD.H
2500 ;
2510 LDA VVBLKD ;Save VBI
2520 STA VBLANK.1+1 ; routine
2530 LDA VVBLKD+1 ; vector
2540 STA VBLANK.1+2
2550 ;
2560 JMP INIT2 ;Continue initi-
2570 ; ; alization
2580 ;Autorun
2590 ;
2600 *= RUNAD
2610 .WORD INIT
2620 ;
2630 .END
Back to previous page