|
|
;----------------------------------------------------
; Return
;----------------------------------------------------
RET ; Return
;----------------------------------------------------
; Return
;----------------------------------------------------
RET ; Return
;----------------------------------------------------
; Compact High Score Tables and Reset Data
;----------------------------------------------------
L0FF9: CALL L1003 ; Compact All-Time High Score Table
CALL L1074 ; Compact Today's High Score Table
CALL L1627 ; Reset Bookkeeping Data
RET ; Return
;----------------------------------------------------
; Remove empty slots from All-Time High Score Table
;----------------------------------------------------
L1003: LD HL,0E000h ; HL = Start of All-Time High Scores
LD IY,0E000h ; IY = Start of All-Time High Scores
LD DE,00008h ; Number of bytes in High Score
LD C,00Ah ; Loop = 10 scores
L100F: LD B,008h ; 8 bytes to sum
CALL L110C ; Calculate Sum of bytes
CP 0FFh ; Check if slot is blank
JR NZ,L101E ; Blank slot found so remove it
ADD IY,DE ; Point to next score
DEC C ; Decrement Loop
JR NZ,L100F ; Loop until all scores checked
RET ; Return
;----------------------------------------------------
; Remove empty slot
;----------------------------------------------------
L101E: CALL L1023 ; Erase empty slot
JR L1003 ; Recheck all slots
;----------------------------------------------------
; Initials
;----------------------------------------------------
; IY Pointer within High Score
;----------------------------------------------------
L1023: PUSH BC ; Save BC Register
PUSH DE ; Save DE Register
PUSH HL ; Save HL Register
PUSH IY ; Save IY Register
PUSH IY ; Copy IY
POP DE ; DE = High Score pointer
LD HL,0E050h ; HL = Start of Initials
AND A ; Clear carry
SBC HL,DE ;
LD DE,00008h ;
SBC HL,DE ;
INC HL ;
LD B,H ;
LD C,L ;
PUSH IY ;
POP HL ; Restore HL Register
ADD HL,DE ;
PUSH IY ;
POP DE ;
LDIR ;
LD IY,0E048h ; 10th High Score
LD A,055h ; "U"
LD (IY+000h),A ;
LD A,052h ; "R"
LD (IY+001h),A ;
LD A,04Ch ; "L"
LD (IY+002h),A ;
XOR A ; A = 00
LD (IY+003h),A ;
LD (IY+004h),A ;
LD (IY+005h),A ;
LD (IY+006h),A ;
LD B,007h ; 7 bytes to sum
LD HL,0E048h ; Sum 10th High Score
CALL L110C ; Calculate Sum of bytes
CPL ;
LD (IY+007h),A ;
POP IY ; Restore IY Register
POP HL ; Restore HL Register
POP DE ; Restore DE Register
POP BC ; Restore BC Register
RET ; Return
;----------------------------------------------------
; Remove empty slots from Today's High Score Table
;----------------------------------------------------
L1074: LD HL,0E050h ; HL = Start of Today's High Scores
LD IY,0E050h ; IY = Start of Today's High Scores;
LD DE,00008 ; Number of bytes in High Score
LD C,00Ah ; 10 slots to check
L1080: LD B,008h ; 8 bytes in each slot to sum
CALL L110C ; Calculate Sum of bytes
CP 0FFh ; Check if slot is blank
JR NZ,L108F ; Blank slot found so remove it
ADD IY,DE ; Point to next score
DEC C ; Decrement Loop
JR NZ,L1080 ; Loop until all scores checked
RET ; Return
;----------------------------------------------------
; Remove empty slot
;----------------------------------------------------
L108F: CALL L1094 ; Remove empty slot
JR L1074 ; Continue checking scores
;----------------------------------------------------
; Move all High Scores up one notch
;----------------------------------------------------
; IY = High Score to change (E050,E058,...)
;----------------------------------------------------
L1094: PUSH BC ; Save BC Register
PUSH DE ; Save DE Register
PUSH HL ; Save HL Register
PUSH IY ; Save IY Register
PUSH IY ; Move IY...
POP DE ; ...into DE
LD HL,0E0A0h ; Point to last high score
AND A ; Clear carry
SBC HL,DE ; Subtract back from last score
LD DE,00008h ;
SBC HL,DE
INC HL
LD B,H
LD C,L
PUSH IY
POP HL ; Restore HL Register
ADD HL,DE
PUSH IY
POP DE
LDIR
;----------------------------------------------------
; Save "URL 00000" into last high score position
;----------------------------------------------------
LD IY,0E098h ; Point to last position
LD A,055h ; "U"
LD (IY+000h),A
LD A,052h ; "R"
LD (IY+001h),A
LD A,04Ch ; "L"
LD (IY+002h),A
XOR A ; A = 00
LD (IY+003h),A
LD (IY+004h),A
LD (IY+005h),A
LD (IY+006h),A
LD B,007h ; 7 bytes to sum
LD HL,0E098h
CALL L110C ; Calculate Sum of bytes
CPL
LD (IY+007h),A
POP IY ; Restore IY Register
POP HL ; Restore HL Register
POP DE ; Restore DE Register
POP BC ; Restore BC Register
RET ; Return
;----------------------------------------------------
; Calculate Sum of Plays:
;----------------------------------------------------
; E0A0 - E0A2 Total Plays
; E0A3 - E0A4 Left Coin Slot Total
; E0A5 - E0A6 Right Coin Slot Total
;----------------------------------------------------
L10E5: LD B,007h ; 7 bytes to sum
LD HL,0E0A0h ; Sum bytes E0A0 - E0A6
JR L1106 ; Calculate sum of bytes
;----------------------------------------------------
; Calculate Sum of Play Times:
;----------------------------------------------------
; E0A8 - E0AA Total Play Time Seconds
; E0AB - E0AD Longest Game Seconds
; E0AE Shortest Game Seconds
; E0AF Highest Scene
;----------------------------------------------------
L10EC: LD B,008h ; 8 bytes to sum
LD HL,0E0A8h ; Sum bytes E0A8 thru E0AF
JR L1106 ; Calculate sum of bytes
;----------------------------------------------------
; Calculate Sum of ----
;----------------------------------------------------
L10F3: LD B,01Eh ; Sum 30 values
LD HL,0E0B1h ;
JR L1106 ;
L10FA: LD B,01Eh ; Sum 30 values
LD HL,0E0D0h ;
JR L1106 ;
L1101: LD B,01Eh
LD HL,0E0EFh
;----------------------------------------------------
; Calculate Sum of HL + (HL+1) + ... + (HL+B)
;----------------------------------------------------
; B = Number of bytes to sum
; HL = Starting Location of byte
;----------------------------------------------------
L1106: CALL L110C ; Call Calculate sum
CPL ; Reverse all bits
LD (HL),A ; Store sum (HL+B)
RET ; Return
;----------------------------------------------------
; Calculate Sum of Data Series
;----------------------------------------------------
; B = Number of bytes to sum
; HL = Starting Location of byte
; A = Return Total
;----------------------------------------------------
L110C: XOR A ; Clear total
L110D: ADD A,(HL) ; Add contents of HL
INC HL ; Point to next location
DJNZ L110D ; Loop until all bytes summed
RET ; Return
;----------------------------------------------------
; Top Ten High Scores and Initials at startup
;----------------------------------------------------
L1112: .TEXT "JMH"
.DB 0,1,0,0,0
L111A: .TEXT "PMR"
.DB 0,0,9,0,0
L1122: .TEXT "EJM"
.DB 0,0,8,0,0
L112A: .TEXT "APH"
.DB 0,0,7,0,0
L1132: .TEXT "VAV"
.DB 0,0,6,0,0
L113A: .TEXT "MAS"
.DB 0,0,5,0,0
L1142: .TEXT "JON"
.DB 0,0,4,0,0
L114A: .TEXT "WHO"
.DB 0,0,3,0,0
L1152: .TEXT "HP?"
.DB 0,0,2,0,0
L115A: .TEXT "JIM"
.DB 0,0,1,0,0
;----------------------------------------------------
; Check Coin Slots
;----------------------------------------------------
L1162: LD HL,(0E127h) ; Get temp Add/Subtract location
PUSH HL ; Save it before entering this routine
LD DE,(0E129h) ; Get temp Add/Subtract location
PUSH DE ; Save it before entering this routine
LD DE,L0000 ; DE = 00000h
LD (0E127h),DE ; Erase Temp Add/Subtract location
LD (0E129h),DE ; Erase Temp Add/Subtract location
LD HL,0E1A1h ; HL = Coins Inserted Left
LD A,(0E192h) ; Get Button Data
;----------------------------------------------------
; Check Left Coin Slot
;----------------------------------------------------
BIT 0,A ; Test Left Coin Slot
JR Z,L1193 ; No Coins so skip ahead
;----------------------------------------------------
; Coin Inserted in Left Slot
;----------------------------------------------------
RES 0,A ; Clear Left Coin Slot
EX AF,AF' ; Save Button Data
INC (HL) ; Increment Coins Inserted Left
LD DE,0E0A4h ; Get Left Coin Count (Ones)
LD A,001h ; A = 1
LD (0E12Ah),A ; Put 1 Coin
CALL L0FB0 ; Call 2-digit BCD Addition
RET ; Return
CALL L10E5 ; Sum Total Coins
EX AF,AF' ; Recall Button Data
L1193: LD HL,0E1A2h ; HL = Get Coins Inserted Right
;----------------------------------------------------
; Check Right Coin Slot
;----------------------------------------------------
BIT 1,A ; Test Right Coin Slot
JR Z,L11AD ; No Coins so skip ahead
;----------------------------------------------------
; Coin Inserted in Right Slot
;----------------------------------------------------
RES 1,A ; Clear Right Coin Slot
EX AF,AF' ; Save Button Data
INC (HL) ; Increment Coins Inserted Right
LD DE,0E0A6h ; Get Right Coin Count (Ones)
LD A,001h ; A = 1
LD (0E12Ah),A ; Put 1 Coin
CALL L0FB0 ; Call 2-digit BCD Addition
CALL L10E5 ; Sum Total Coins
EX AF,AF' ; Recall Button Data
L11AD: LD (0E192h),A ; Save Button Data
CALL L11C0 ; Award Credits for Coins
CALL L1254 ;
POP DE ; Get temp Add/Subtract location
LD (0E129h),DE ; Restore Add/Subtract location
POP HL ; Get temp Add/Subtract location
LD (0E127h),HL ; Restore Add/Subtract location
RET ; Return
;----------------------------------------------------
; Check DIP Settings and Award Credits for Coins
;----------------------------------------------------
; 24 25 Right
; 20 21 Left
; -------------------
; OFF OFF 2 Coins
; ON OFF 2 Coins
; OFF ON 3 Coins
; ON ON 4 Coins
;----------------------------------------------------
L11C0: LD DE,0E1A1h ; DE = Coins Inserted Left
LD A,(0E1A3h) ; Get x
LD C,A ; C = x
LD A,(0E189h) ; Get DIP Switches 20-27
RRCA ; Get Coin Settings
RRCA ; Get Coin Settings
RRCA ; Get Coin Settings
RRCA ; Get Coin Settings
AND 003h ; Isolate Right Coin/Credit Setting 24-25
LD B,A ; B = Right Coins/Credit Setting
LD A,(0E189h) ; Get DIP Switches 20-27
AND 003h ; Isolate Left Coin/Credit Settings 20-21
CP B ; Compare Left settings to Right Settings
JR NZ,L11E6 ; Coin/Credit settings differ so jump ahead
;----------------------------------------------------
; Total both Coins into Left Coin
;----------------------------------------------------
; IF BOTH COIN CHUTES ARE ADJUSTED THE SAME FOR MULTIPLE
; COINS, CREDITS WILL INCREASE AS IF DROPPED IN SAME CHUTE
;----------------------------------------------------
EX AF,AF' ; Save Coin/Credit Setting
EX DE,HL ; HL = Coins Inserted Left
LD A,(0E1A2h) ; A = Coins Inserted Right
ADD A,(HL) ; Add Right Coins to Left Coins
LD (HL),A ; Store Total into Left Coins Inserted
EX DE,HL ; Restore HL Register
XOR A ; A = 0
LD (0E1A2h),A ; Zero Coins Inserted Right
EX AF,AF' ; Recall Coin/Credit Settings
L11E6: CALL L1205 ; ??
LD A,C ; A = x
LD (0E1A3h),A ; Save x
LD DE,0E1A2h ; DE = Coins Inserted Right
LD A,(0E1A4h) ;
LD C,A ;
LD A,(0E189h) ; Get DIP Switches 20-27
RRCA ;
RRCA ;
RRCA ;
RRCA ;
AND 003h ;
CALL L1205 ;
LD A,C ;
LD (0E1A4h),A ;
RET ; Return
;----------------------------------------------------
; Coins per Credit
;----------------------------------------------------
; A = Coins/Settings (0,1,2,3)
; DE = Coins Inserted Left
;----------------------------------------------------
L1205: LD HL,0129Dh ; HL = Pointer to Bank12 table
LD B,A ; B = Coin Setting (0,1,2,3)
OR A ; Is Coin Setting 0?
JR Z,L1214 ; Yes, so use Award Cycle 1
PUSH DE ; Save DE Register
LD DE,0000Ch ; DE = 12 Bytes per Award Cycle
L1210: ADD HL,DE ; HL = Correct Award Cycle
DJNZ L1210 ; Loop until correct Award Cycle
POP DE ; Restore DE Register
L1214: LD A,(DE) ; A = Coins Inserted Left
OR A ; Are there any coins?
RET Z ; No coins so return
ADD HL,BC ; Add BC index into Award Cycle
XOR A ; A = 0
;----------------------------------------------------
; Award Credits while there are Coins in Left Slot
;----------------------------------------------------
L1219: ADD A,(HL) ; Add Number of Coins in Table
EX AF,AF' ; Save table total
LD A,C ; A = x
CP 00Bh ; Is x = 11?
JR NZ,L122A ; No, so skip ahead
PUSH DE ; Save DE Register
LD DE,0000Ch ; BE = 12 bytes per Award Cycle
XOR A ; Clear Carry
SBC HL,DE ; Go to previous bank
LD C,0FFh ; C = 255
POP DE ; Recall DE Register
L122A: INC C
INC HL ; Point to next spot in table
PUSH HL ; Save table Pointer
LD HL,0E1A5h ;
INC (HL)
POP HL ; Recall table Pointer
EX AF,AF'
EX DE,HL ; Get Coins Inserted Left
DEC (HL) ; Subtract 1 coin
EX DE,HL ; Restore Registers
JR NZ,L1219 ; More coins left so keep looping
CALL L123C ; Award Credits and Beep
RET ; Return
;----------------------------------------------------
; Award Credits and Beep
;----------------------------------------------------
; A = Number of credits to award
;----------------------------------------------------
L123C: LD B,A ; B = Number of Credits to award
OR A ; Is it zero?
RET Z ; Yes, no credits to award so return
LD A,(0E1A8h) ; A = Number of Credits
CP 099h ; Are there 99 credits?
RET Z ; Yes, so just return
ADD A,B ; Add to Number of Credits
DAA ; Make BCD
JR NC,L124B ; Still less than 99 so skip ahead
LD A,099h ; Set Number of Credits = 99
L124B: LD (0E1A8h),A ; Store Number of Credits
LD A,002h ; ?
CALL GoodBeep ; Sound GoodBeep
RET ; Return
;----------------------------------------------------
; Unknown
;----------------------------------------------------
L1254: LD A,(0E1A6h)
BIT 0,A
JR Z,L1282
LD A,(0E1A7h)
OR A
JR Z,L1266
DEC A
LD (0E1A7h),A
RET
L1266: LD A,(0E1A6h)
BIT 1,A
JR Z,L127C
RES 1,A
LD (0E1A6h),A
RES 6,A
OUT (068h),A
LD A,00Ch
LD (0E1A7h),A
RET
L127C: RES 0,A
LD (0E1A6h),A
RET
L1282: LD A,(0E1A5h)
OR A
RET Z
DEC A
LD (0E1A5h),A
XOR A
SET 0,A
SET 1,A
LD (0E1A6h),A
SET 6,A
OUT (068h),A
LD A,004h
LD (0E1A7h),A
RET
;----------------------------------------------------
; Award Cycles
;----------------------------------------------------
; 1 Coin per Credit
;----------------------------------------------------
L129D: .DB 001h
.DB 001h
.DB 001h
.DB 001h
.DB 001h
.DB 001h
.DB 001h
.DB 001h
.DB 001h
.DB 001h
.DB 001h
.DB 001h
;----------------------------------------------------
; 2 Coins per Credit
;----------------------------------------------------
.DB 000h, 001h
.DB 000h, 001h
.DB 000h, 001h
.DB 000h, 001h
.DB 000h, 001h
.DB 000h, 001h
;----------------------------------------------------
; 3 Coins per Credit
;----------------------------------------------------
.DB 000h, 000h, 001h
.DB 000h, 000h, 001h
.DB 000h, 000h, 001h
.DB 000h, 000h, 001h
;----------------------------------------------------
; 4 Coins per Credit
;----------------------------------------------------
.DB 000h, 000h, 000h, 001h
.DB 000h, 000h, 000h, 001h
.DB 000h, 000h, 000h, 001h
;----------------------------------------------------
; ROM0 Copyright
;----------------------------------------------------
L12CD: .DB 010h
L12CE: .TEXT "COPYRIGHT STERN ELECTRONICS, INC."
;----------------------------------------------------
; Check Buy-In Feature
;----------------------------------------------------
L12F0: LD A,(0E18Ch) ; Get DIP Switches 12-19
BIT 7,A ; Check BUY-IN feature
RET Z ; No BUY-IN so just return
L12F6: LD A,(0E126h) ; Get Control Register ;
BIT 1,A ;
JR NZ,L12F6 ;
LD A,(0E126h) ; Get Control Register
BIT 4,A ;
JR NZ,L1311 ;
;----------------------------------------------------
; Send PAUSE Command
;----------------------------------------------------
LD A,00Ah ; Command = PAUSE (0Ah)
CALL L207F ; Send Message to LDPlayer DI
LD A,(0E126h) ; Get Control Register
SET 4,A ; Set PAUSE Bit
LD (0E126h),A ; Save Control Register
L1311: PUSH IY ;
PUSH DE ;
PUSH BC ;
CALL L2392 ;
CALL L22F5 ; Program Graphics Chip
LD A,0FDh ; Text = WHITE, Bkgnd = PURPLE
CALL L20CA ; Setup Graphics Chip for Text
CALL L21FF ; Clear Text Display
LD C,000h ; Loop = 0
L1325: LD A,C ; A = Rectangle #
CALL L575D ; Draw programmed rectangle
LD B,005h ; Loop = 5
L132B: CALL L2353 ; Wait for Comm Ready
DJNZ L132B ; Loop for 5 Comm's
INC C ; Increment loop
LD A,C ; Check loop
CP 005h ; Is loop at 5 yet?
JR C,L1325 ; No, continue with loop
L1336: PUSH HL ; Save HL Register
LD HL,00127h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L133D: .TEXT "PLAYER # "
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
LD A,(0E1A9h) ; Get Player Number
AND 003h ; Decode number
OR 030h ; Create printable character A
CALL L2256 ; Print A to Text Display
PUSH HL ; Save HL Register
LD HL,00170h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L135A: .TEXT "If you wish to continue"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
PUSH HL ; Save HL Register
LD HL,0019Bh ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L137A: .TEXT "playing this level"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
LD A,(0E1A8h) ; Get Number of Credits
OR A ; Check if any credits left
JR NZ,L13B6 ; Credits left so skip ahead
PUSH HL ; Save HL Register
LD HL,001E7h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L139B: .TEXT "Insert required coins and"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
L13B6: PUSH HL ; Save HL Register
LD HL,00239h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L13BD: .TEXT "Press Player 1 button"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
PUSH HL ; Save HL Register
LD HL,002B0h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L13DB: .TEXT "Time left to buy-in : 9"
.DB 000h
;----------------------------------------------------
L13F4: POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538 ;
PUSH HL ; Save HL Register
L13FC: LD HL,002B0h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1402: .TEXT "Time left to buy-in : 8"
.DB 000h
;----------------------------------------------------
L141B: POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538 ;
PUSH HL ; Save HL Register
LD HL,002B0h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1429: .TEXT "Time left to buy-in : 7"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538 ;
PUSH HL ; Save HL Register
LD HL,002B0h ; Cursor Position
L144D: CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1450: .TEXT "Time left to buy-in : 6"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538 ;
PUSH HL ; Save HL Register
LD HL,002B0h ; Cursor Position
L1474: CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1476: .TEXT "Time left to buy-in : 5"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538
PUSH HL ; Save HL Register
LD HL,002B0h ; Cursor Position
L149B: CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L149E: .TEXT "Time left to buy-in : 4"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538
PUSH HL ; Save HL Register
LD HL,002B0h ; Cursor Position
L14C2: CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L14C5: .TEXT "Time left to buy-in : 3"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538 ;
PUSH HL ; Save HL Register
LD HL,002B0h ; Cursor Position
L14E9: CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L14EC: .TEXT "Time left to buy-in : 2"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538 ;
PUSH HL ; Save HL Register
LD HL,002B0h ; Cursor Position
L1510: CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1513: .TEXT "Time left to buy-in : 1"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay100000 ; Call Delay 100,000
CALL L1538 ;
L1533: POP BC ; Restore BC Register
POP DE ; Restore DE Register
L1535: POP IY ; Restore IY Register
L1537: RET ; Return
;----------------------------------------------------
; Buy-In Timer
;----------------------------------------------------
L1538: LD A,(0E18Ch) ; Get DIP Switches 12-19
L153B: BIT 2,A ; Check FREE PLAY (sw 14)
JR NZ,L1544 ; FREE PLAY set so skip credit check
;----------------------------------------------------
; Check if there are any credits
;----------------------------------------------------
LD A,(0E1A8h) ; Get Number of Credits
OR A ; Check Number of Credits
RET Z ; No credits so return
L1544: LD A,(0E192h) ; Get Button Data
;----------------------------------------------------
; Check for Player1 Button
;----------------------------------------------------
BIT 2,A ; Check PLAYER1 Button pressed
RET Z ; Not pressed so return
L154A: RES 2,A ; Clear PLAYER1 Button press
LD (0E192h),A ; Save modified Button Data
LD DE,00000h ;
LD (0E127h),DE ;
LD DE,0E0A2h ;
LD A,001h ;
LD (0E12Ah),A ;
L155E: CALL L0FA1 ; Call 3-Digit Addition
CALL L10E5 ; Sum Total Coins
CALL L1F55 ;
CALL L1F70 ; Add Number of Lives per Credit
INC SP ;
L156B: INC SP ;
JP L1533 ;
;----------------------------------------------------
; Update Bookkeeping Data
;----------------------------------------------------
; Add Game Timer to Total Play Time
;----------------------------------------------------
L156F: XOR A ; A = 0
LD (0E127h),A ; Store zero in thousands
LD HL,(0E1C4h) ; Get Game Play Timer
LD (0E128h),HL ; Store in temp add location
LD A,(0E1C6h) ; Get Game Play Timer
LD (0E12Ah),A ; Store in temp add location
LD DE,0E0AAh ; DE = Bookkeeping Total Play Time (ones)
CALL L0FA1 ; Call 3-Digit Addition
;----------------------------------------------------
; Check for Longest Game Play Time
;----------------------------------------------------
L1585: LD B,003h ; 3 digits to check
LD DE,0E1C4h ; DE = Game Play Time
LD HL,0E0ABh ; HL = Longest Time
L158D: LD A,(DE) ; Get Game Play Time digit
CP (HL) ; Compare it to Longest
JR C,L15A7 ; Less than longest, so check shortest
JR Z,L1596 ; Digits equal check next digit
JP NC,L159C ; Time is longest, so save it
L1596: INC DE ; Compare next digit - Game Play Time
INC HL ; Compare next digit - Longest Time
DJNZ L158D ; Loop until all digits compared
JR L15A7 ; Compare complete, check for shortest
;----------------------------------------------------
; Recored the new Longest Game Play Time
;----------------------------------------------------
L159C: LD BC,00003h ; 3 bytes to copy
LD DE,0E0ABh ; Destination = Longest Time
LD HL,0E1C4h ; Source = Game Play Time
LDIR ; Copy all bytes
;----------------------------------------------------
; Check for Shortest Game Play Time
;----------------------------------------------------
L15A7: LD DE,0E1C4h ; DE = Game Play Time
LD HL,0E0AEh ; DL = Shortest Time
LD A,(DE) ; Get digit Game Play Time
CP 000h ; Is hundreds digit zero?
JR NZ,L15C4 ; No, so check scene
INC DE ; Next digit
LD A,(DE) ; Get digit Game Play Time
CP 000h ; Is tens digit zero?
JR NZ,L15C4 ; No, so check scene
INC DE ; Next digit
LD A,(DE) ; Get digit Game Play Time
CP 000h ; Is ones digit zero?
JR Z,L15C4 ; Yes so check scene
CP (HL) ; Compare digit to shortest time
JR Z,L15C3 ; Equal times so save
JR NC,L15C4 ; Time not shorter than shorts so check scene
L15C3: LD (HL),A ; Save shortest time
;----------------------------------------------------
; Check for Highest Scene Reached
;----------------------------------------------------
L15C4: LD HL,0E0AFh ; HL = Highest Scene
LD A,(0E1B6h) ; Get current scene reached
CP (HL) ; Compare to the highest
JR C,L15CE ; Not greater than highest so jump ahead
LD (HL),A ; Save as new high scene
;----------------------------------------------------
; Update Range of Times
;----------------------------------------------------
L15CE: CALL L10EC ; Calculate Sum of Play Times
LD B,00Eh ; Loop = 14 ranges
LD HL,0E0D1h ; First Range = 0 - 1 Minutes
L15D6: LD A,060h ; A = 60 seconds (1 minute)
LD (0E12Ah),A ; Store in temporary subtraction location
LD DE,0E1C6h ; DE = Play Time Minutes
;----------------------------------------------------
; Find range of time by subtracting 1 minute from
; Game Timer until timer goes negative.
;----------------------------------------------------
PUSH HL ; Save HL Register
PUSH BC ; Save BC Register
CALL L0FCC ; Call 3-Digit Subtraction (1 minute)
POP BC ; Restore BC Register
POP HL ; Restore HL Register
JR C,L15EB ; Time range found so skip ahead
INC HL ; Next range of times
INC HL ; Next range of times
DJNZ L15D6 ; Loop until all 14 time ranges checked
;----------------------------------------------------
; Increment count for Time Range
;----------------------------------------------------
L15EB: LD A,001h ; Add 1
LD (0E12Ah),A ; Put 1 in temporary addition location
EX DE,HL ;
PUSH DE ;
CALL L0FB0 ; Call 2-digit BCD Addition
POP HL ; Restore HL Register
JR NC,L15FD ;
LD (HL),099h ;
DEC HL ;
LD (HL),099h ;
L15FD: CALL L10FA ;
LD B,00Eh ;
LD HL,0E0F0h ;
LD A,(0E1B6h) ;
L1608: SUB 001h ;
DAA ;
JR Z,L1611 ;
INC HL ;
INC HL ;
DJNZ L1608 ;
L1611: LD A,001h ;
LD (0E12Ah),A ;
EX DE,HL ;
PUSH DE ;
CALL L0FB0 ; Call 2-digit BCD Addition
POP HL ; Restore HL Register
JR NC,L1623 ;
LD (HL),099h ;
DEC HL ;
LD (HL),099h ;
L1623: CALL L1101 ;
RET ; Return
;----------------------------------------------------
; Reset Bookkeeping Data
;----------------------------------------------------
; Reset Bookkeeping Game Play Totals
;----------------------------------------------------
L1627: LD B,008h ; 8 bytest to sum
LD HL,0E0A0h ; HL = Total Play Count
CALL L110C ; Calculate Sum of bytes
INC A ; Check sum
JR Z,L163A ; Bytes already zero so skip ahead
LD B,008h ; 8 bytes to erase
LD HL,0E0A0h ; HL = Total Play Count
CALL L1687 ; Call Erase Bytes
;----------------------------------------------------
; Reset Play Times Data
;----------------------------------------------------
L163A: LD B,009h ; 9 bytes to sum
LD HL,0E0A8h ; HL = Play Times
CALL L110C ; Calculate Sum of bytes
INC A ; Check sum
JR Z,L1652 ; Bytes already zero so skip ahead
LD B,009h ; 9 bytes to erase
LD HL,0E0A8h ; HL = Play Times
CALL L1687 ; Call Erase Bytes
LD HL,0E0AEh ; Get Shortest Game Time
LD (HL),099h ; Shortest Game Time = 99sec
;----------------------------------------------------
; Reset Range of Scores Data
;----------------------------------------------------
L1652: LD B,01Fh ; 31 bytes to sum
LD HL,0E0B1h ; HL = Range of Scores
CALL L110C ; Calculate Sum of bytes
INC A ; Check the sum
JR Z,L1665 ; Bytes already zero so skip ahead
LD B,01Fh ; 31 bytes to erase
LD HL,0E0B1h ; HL = Range of Scores
CALL L1687 ; Call Erase Bytes
;----------------------------------------------------
; Reset Range of Times Data
;----------------------------------------------------
L1665: LD B,01Fh ; 31 bytes to sum
LD HL,0E0D0h ; HL = Range of Times
CALL L110C ; Calculate Sum of bytes
INC A ; Check the sum
JR Z,L1678 ; Bytes already zero so skip ahead
LD B,01Fh ; 31 bytes to erase
LD HL,0E0D0h ; HL = Range of Times
CALL L1687 ; Call Erase Bytes
;----------------------------------------------------
; Reset Range of Scenes Data
;----------------------------------------------------
L1678: LD B,01Fh ; 30 bytes to sum
LD HL,0E0EFh ; HL = Range of Scenes
CALL L110C ; Calculate Sum of bytes
INC A ; Check the sum
RET Z ; Bytes already zero so return
LD B,01Fh ; 31 bytes to erase
LD HL,0E0EFh ; HL = Range of Scenes
;----------------------------------------------------
; Reset Bookkeeping bytes to zero
;----------------------------------------------------
L1687: XOR A ; A = 0
L1688: LD (HL),A ; Reset Bookkeeping byte
INC HL ; Point to next Bookkeeping byte
DJNZ L1688 ; Loop until all bytes reset
RET ; Return
;----------------------------------------------------
; unknown
;----------------------------------------------------
L168D: PUSH IY ; Save IY Register
PUSH DE ; Save DE Register
PUSH BC ; Save BC Register
CALL L2392 ;
CALL L22F5 ; Program Graphics Chip
LD A,0F4h ; Text = WHITE, Bkgnd = DK_BLUE
CALL L20CA ; Setup Graphics Chip for Text
CALL L21FF ; Clear Text Display
LD A,(0E126h) ; Get Control Register
BIT 0,A ;
CALL NZ,L16BF ; Yes, so show Gameplay Instructions
LD C,000h ;
L16A9: LD A,C ;
CALL L575D ; Draw programmed rectangle
LD B,005h ; Loop = 5
L16AF: CALL L2353 ; Wait for Comm Ready
DJNZ L16AF ; Loop for 5 Comm's
INC C ;
LD A,C ;
CP 002h ;
JR C,L16A9 ;
POP BC ; Restore BC Register
POP DE ; Restore DE Register
POP IY ; Restore IY Register
RET ; Return
;----------------------------------------------------
; Show Gameplay Instructions
;----------------------------------------------------
L16BF: CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,00080h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L16C9: .TEXT "Move the joystick in the"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,000A7h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L16ED: .TEXT "direction Cliff or his car"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,000D2h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1713: .TEXT "moves on the screen"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay10000 ; Call Delay 10,000
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,0016Eh ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1735: .TEXT "Stick right if object moves"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,00196h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L175C: .TEXT "toward right edge of screen"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay10000 ; Call Delay 10,000
CALL Delay10000 ; Call Delay 10,000
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,001E7h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1789: .TEXT "Stick left if object moves"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,0020Fh ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L17AF: .TEXT "toward left edge of screen"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay10000 ; Call Delay 10,000
CALL Delay10000 ; Call Delay 10,000
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,00260h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L17DB: .TEXT "Stick up if object moves"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,00286h ; Cursor Position
L17FC: CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L17FF: .TEXT "toward upper edge of screen"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay10000 ; Call Delay 10,000
CALL Delay10000 ; Call Delay 10,000
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,002D7h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L182C: .TEXT "Stick down if object moves"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL L2353 ; Wait for Comm Ready
PUSH HL ; Save HL Register
LD HL,002FEh ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1852: .TEXT "toward bottom edge of screen"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
CALL Delay10000 ; Call Delay 10,000
CALL Delay10000 ; Call Delay 10,000
RET ; Return
;----------------------------------------------------
; Check for High Score
;----------------------------------------------------
L1877: LD IX,0E137h ;
LD IY,0E050h ; IY = Pointer to High Score Table
LD DE,00008h ; DE = 8 digits to check in score
LD B,00Ah ; B = 10 High scores to check
L1884: LD HL,0E1AAh ; HL = Score
LD A,(HL) ; Get Score digit
L1888: INC HL ; Point to next score digit
CP (IY+003h) ; Compare to High Score
JR C,L18B6
JR Z,L1893 ; Digits equal, check next digit
JP NC,L18BD
L1893: LD A,(HL)
INC HL
CP (IY+004h)
JR C,L18B6 ;
JR Z,L189F ; Digits equal, check next digit
JP NC,L18BD
L189F: LD A,(HL)
INC HL
L18A1: CP (IY+005h)
JR C,L18B6
JR Z,L18AB ; Digits equal, check next digit
JP NC,L18BD
L18AB: LD A,(HL)
CP (IY+006h)
L18AF: JR C,L18B6 ; Score , check next score
JR Z,L18B6 ; Scores are equal, check next score
JP NC,L18BD
L18B6: ADD IY,DE
DJNZ L1884
JP L1C00
L18BD: LD HL,0E192h ; Get Button Data
RES 4,(HL) ; Clear HAND-Right press
RES 5,(HL) ; Clear HAND-Left press
LD HL,0E098h
LD A,020h
LD (HL),A
INC HL
LD (HL),A
INC HL
LD (HL),A
LD BC,00004h
LD DE,0E09Bh
LD HL,0E1AAh
LDIR
CALL L1BB0
L18DC: JP NZ,L1BC3
CALL L21FF ; Clear Text Display
LD A,(0E1A9h) ; Get Player Number
CP 001h ; Is it Player 1?
LD A,060h ; Player1, Text = DK_RED, Bkgnd = TRANS
JR Z,L18ED ; Skip ahead
LD A,040h ; Player2, Text = BLUE, Bkgnd = TRANS
L18ED: CALL L20CA ; Setup Graphics Chip for Text
PUSH HL ; Save HL Register
LD HL,00030h ; Cursor Location
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L18F7: .TEXT "CONGRATULATIONS PLAYER "
.DB 000h
;----------------------------------------------------
L190F: POP HL ; Restore HL Register
LD A,(0E1A9h) ; Get Player Number
AND 003h ; Decode number
OR 030h ; Create printable character A
CALL L2256 ; Print A to Text Display
PUSH HL ; Save HL Register
LD HL,00081h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1921: .TEXT "YOUR SCORE "
.DB 000h
;----------------------------------------------------
L192D: POP HL ; Restore HL Register
LD BC,00400h ;
LD DE,01403h ; Location X = 20, Y = 3
LD HL,0E1AAh ; Number = Score
CALL L2269 ; Print 8-digit number
PUSH HL ; Save HL Register
LD HL,000D0h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1941: .TEXT "IS IN THE TOP TEN SCORES"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
PUSH HL ; Save HL Register
LD HL,00147h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1962: .TEXT "PLEASE ENTER YOUR INITIALS"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
LD HL,01B83h ; HL = Pointer to alphabet
PUSH DE
EX DE,HL
LD HL,001BDh
LD A,01Eh
CALL L2224
POP DE
LD HL,01BA1h
PUSH DE
EX DE,HL
LD HL,0021Ah
LD A,005h
CALL L2224
POP DE
LD HL,01BA6h
PUSH DE
EX DE,HL
LD HL,00242h
LD A,005h
L19A4: CALL L2224
L19A7: POP DE
LD HL,01BABh
PUSH DE
EX DE,HL
LD HL,0026Ah
LD A,005h
CALL L2224
POP DE
PUSH HL ; Save HL Register
LD HL,002B6h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L19BD: .TEXT "YOU CAN USE"
.DB 000h
;----------------------------------------------------
L19C9: POP HL ; Restore HL Register
PUSH HL ; Save HL Register
LD HL,002FDh ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L19D1: .TEXT "THE JOYSTICK TO SELECT LETTERS"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
PUSH HL ; Save HL Register
LD HL,00354h ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L19F8: .TEXT "BUT YOU MUST USE"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
PUSH HL ; Save HL Register
LD HL,0039Fh ; Cursor Position
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1A11: .TEXT "YOUR HANDS TO ENTER THEM."
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
LD (IX+001h),0FFh ;
LD (IX+002h),001h ;
LD (IX+000h),00Fh ;
L1A38: LD B,00Ah ; Loop = 10
L1A3A: CALL L2353 ; Wait for Comm Ready
DJNZ L1A3A ; Loop for 10 Comm's
CALL L1BB0 ;
JP NZ,L1BC3 ;
DEC (IX+001h) ;
JP Z,L1BC3 ;
LD A,(0E196h) ; Get Joystick Input
L1A4E: BIT 3,A ; Is Joystick LEFT pressed?
JP NZ,L1A5B ; Yes, so move left
BIT 1,A ; Is Joystick RIGHT pressed?
JP NZ,L1A7C ; Yes, so move right
JP L1A9B
L1A5B: LD (IX+001),05Ah
L1A5F: LD A,(IX+000)
OR A
JR NZ,L1A71
L1A65: LD A,020h
CALL L1B75
LD (IX+000),01Dh
JP L1A9B
L1A71: LD A,020
CALL L1B75
DEC (IX+000)
JP L1A9B
L1A7C: LD (IX+001),05A
LD A,(IX+000)
CP 01D
JR C,L1A93
LD A,020
CALL L1B75
LD (IX+000),001
JP L1A9B
L1A93: LD A,020
CALL L1B75
INC (IX+000)
L1A9B: LD A,05Eh
CALL L1B75
CALL L1B30
;----------------------------------------------------
; Check if HAND button is pressed
;----------------------------------------------------
LD HL,0E192h ; Get Button Data
BIT 4,(HL) ; Is HAND-Right pressed?
RES 4,(HL) ; Clear HAND-Right press
JP NZ,L1AB4 ; Yes, pressed so skip ahead
BIT 5,(HL) ; Is HAND-Left pressed?
RES 5,(HL) ; Clear HAND-Left press
JP Z,L1A38 ; No, so loop back
L1AB4: LD HL,01B83h ; HL = Pointer to alphabet
LD D,000h
LD E,(IX+000h)
ADD HL,DE
LD A,(HL)
CP 05F
JP Z,L1ACD
INC (IX+002)
LD (IX+001),05A
JP L1A38
L1ACD: LD (IX+001),078
LD A,(IX+002)
CP 001
JP Z,L1A38
DEC A
LD (IX+002),A
LD A,020
CALL L1B75
LD (IX+000),000
LD A,05E
CALL L1B75
LD A,(IX+002)
CP 003
JP Z,L1B1E
CP 002
JP Z,L1B0F
CP 001
JP Z,L1B00
JP L1A38
L1B00: PUSH HL ; Save HL Register
LD HL,00243h
CALL L2212 ; Set Cursor and Print Text
JR NZ,L1B09
L1B09: POP HL
LD A,020h
LD (0E098h),A
L1B0F: PUSH HL ; Save HL Register
LD HL,00244h
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
.TEXT " "
.DB 000h
;----------------------------------------------------
L1B18: POP HL
LD A,020
LD (0E099),A
L1B1E: PUSH HL ; Save HL Register
LD HL,00245
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
.TEXT " "
.DB 000h
;----------------------------------------------------
L1B27: POP HL
LD A,020h
LD (0E09Ah),A
JP L1A38
L1B30: LD D,000h
LD E,(IX+000h)
LD HL,01B83h ; HL = Pointer to alphabet
ADD HL,DE
LD B,(HL)
LD DE,0120Eh
LD A,(IX+002)
ADD A,D
LD D,A
LD A,(IX+002)
CP 000h
JP Z,L1B5D
CP 001h
JP Z,L1B61
CP 002h
JP Z,L1B67
CP 003h
JP Z,L1B6D
POP AF
JP L1BC3
L1B5D: POP AF
JP L1A38
L1B61: LD A,B
LD (0E098h),A
JR L1B71
L1B67: LD A,B
LD (0E099h),A
JR L1B71
L1B6D: LD A,B
LD (0E09Ah),A
L1B71: CALL L2233 ; Print one Character to Text Display
RET ; Return
L1B75: PUSH AF ;
LD DE,0050Ch ;
LD A,(IX+000h) ;
ADD A,D ;
LD D,A ;
POP AF ;
CALL L2233 ; Print one Character to Text Display
RET ; Return
;----------------------------------------------------
; Alphabet text
;----------------------------------------------------
L1B83: .TEXT "abcdefghijklmnopqrstuvwxyz"
.DB 020h, 02Ah, 03Fh, 05Fh
;----------------------------------------------------
; Rectangle Characters
; --------------------
; | |
; --------------------
;----------------------------------------------------
.DB 083h, 080h, 080h, 080h, 082h
.DB 081h, 020h, 020h, 020h, 081h
.DB 085h, 080h, 080h, 080h, 084h
;----------------------------------------------------
; unknown
;----------------------------------------------------
L1BB0: LD A,(0E15Ah) ;
OR A ;
LD A,000h ;
LD (0E15Ah),A ;
RET NZ ;
LD HL,0E193h ; Get Button Data
BIT 2,(HL) ; Is PLAYER1/Feet pressed?
RET NZ ; Yes, so return
BIT 3,(HL) ; Is PLAYER2/Feet pressed?
RET ; Return
;----------------------------------------------------
; unknown
;----------------------------------------------------
L1BC3: LD A,011h ; Text = BLACK, Bkgnd = BLACK
LD (0E136h),A ; Set Color
CALL L22F5 ; Program Graphics Chip
CALL L21FF ; Clear Text Display
LD HL,0E098h
LD B,007h ; 7 bytes to sum
CALL L110C ; Calculate Sum of bytes
CPL
LD (HL),A
LD HL,0E09Bh
LD DE,0E04Bh
LD B,004h ; Loop = 4
L1BE0: LD A,(DE)
CP (HL)
JP C,L1BEF
JR Z,L1BE9
JR NC,L1BFD
L1BE9: INC HL
INC DE
DJNZ L1BE0
JR L1BFD
L1BEF: LD HL,0E098h ;
LD DE,0E048h ;
LD BC,00008h ;
LDIR ;
CALL L1C30 ;
L1BFD: CALL L1C94 ;
L1C00: LD B,00Eh ; Loop = 14
LD HL,0E0B2h ;
L1C05: LD A,010h ; Bonus = 100,000?
LD (0E12Ah),A ; S
LD DE,0E1ABh ; Score
PUSH HL ; Save HL Register
PUSH BC ; Save BC Register
CALL L0FDB ; Call 2-Digit Subtraction
POP BC ; Restore BC Register
POP HL ; Restore HL Register
JR C,L1C1A
INC HL
INC HL
DJNZ L1C05
L1C1A: LD A,001h
LD (0E12Ah),A
EX DE,HL
PUSH DE
CALL L0FB0 ; Call 2-digit BCD Addition
POP HL ; Restore HL Register
JR NC,L1C2C ;
LD (HL),099h ;
DEC HL ;
LD (HL),099h ;
L1C2C: CALL L10F3 ;
RET ; Return
L1C30: PUSH IX
LD DE,00008
LD IX,0E000
LD B,009
L1C3B: LD C,B
PUSH IX
POP IY
L1C40: ADD IY,DE
LD A,(IX+003)
CP (IY+003)
JR C,L1C78
JR Z,L1C4E
JR NC,L1C6E
L1C4E: LD A,(IX+004)
CP (IY+004)
JR C,L1C78
JR Z,L1C5A
JR NC,L1C6E
L1C5A: LD A,(IX+005)
CP (IY+005)
JR C,L1C78
JR Z,L1C66
JR NC,L1C6E
L1C66: LD A,(IX+006)
CP (IY+006)
JR C,L1C78
L1C6E: DEC C
JR NZ,L1C40
ADD IX,DE
DJNZ L1C3B
POP IX
RET
L1C78: PUSH BC
LD B,008
PUSH IX
POP HL ; Restore HL Register
PUSH IY
EXX
POP HL ; Restore HL Register
EXX
L1C83: LD A,(HL)
EX AF,AF'
EXX
LD A,(HL)
EX AF,AF'
LD (HL),A
INC HL
EXX
EX AF,AF'
LD (HL),A
INC HL
DJNZ L1C83
POP BC
JP L1C6E
L1C94: PUSH IX
LD DE,00008
LD IX,0E050
LD B,009
L1C9F: LD C,B
PUSH IX
POP IY
L1CA4: ADD IY,DE
LD A,(IX+003)
CP (IY+003)
JR C,L1CDC
JR Z,L1CB2
JR NC,L1CD2
L1CB2: LD A,(IX+004)
CP (IY+004)
JR C,L1CDC
JR Z,L1CBE
JR NC,L1CD2
L1CBE: LD A,(IX+005)
CP (IY+005)
JR C,L1CDC
JR Z,L1CCA
JR NC,L1CD2
L1CCA: LD A,(IX+006)
CP (IY+006)
JR C,L1CDC
L1CD2: DEC C
JR NZ,L1CA4
ADD IX,DE
DJNZ L1C9F
POP IX
RET
L1CDC: PUSH BC
LD B,008
PUSH IX
POP HL ; Restore HL Register
PUSH IY
EXX
POP HL ; Restore HL Register
EXX
L1CE7: LD A,(HL)
EX AF,AF'
EXX
LD A,(HL)
EX AF,AF'
LD (HL),A
INC HL
EXX
EX AF,AF'
LD (HL),A
INC HL
DJNZ L1CE7
POP BC
JP L1CD2
;----------------------------------------------------
; Show High Scores
;----------------------------------------------------
L1CF8: CALL L21FF ; Clear Text Display
CALL L1D83
LD A,0FDh ; Text = WHITE, Bkgnd = PURPLE
CALL L20CA ; Setup Graphics Chip for Text
CALL L0FF9 ; Compact High Score Tables
PUSH HL ; Save HL Register
LD HL,0002Ah
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1D0D: .TEXT "The Highest Scores"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
LD B,00Ah ; Loop = 10 scores
LD HL,0E000h ;
LD D,002h ;
LD E,004h ;
CALL L1D57 ;
PUSH HL ; Save HL Register
LD HL,0003Eh ;
CALL L2212 ; Set Cursor and Print Text
;----------------------------------------------------
L1D34: .TEXT "High Scores Today"
.DB 000h
;----------------------------------------------------
POP HL ; Restore HL Register
LD B,00Ah ; Loop = 10 Scores
LD HL,0E050h ;
LD DE,01603h ;
LD D,016h ;
LD E,004h ;
CALL L1D57 ;
RET ; Return
L1D57: PUSH BC
LD A,(HL)
INC HL
L1D5A: CALL L2233 ; Print one Character to Text Display
PUSH DE
INC D
LD A,(HL)
INC HL
CALL L2256 ; Print A to Text Display
INC D ;
LD A,(HL) ;
INC HL ;
CALL L2256 ; Print A to Text Display
INC D ;
INC D ;
INC D ;
L1D6D: INC D ;
CALL L2269 ; Print 8-digit number
INC HL ;
CALL Delay10000 ; Call Delay 10,000
LD B,001h ; Loop = 1
L1D77: CALL L2353 ; Wait for Comm Ready
DJNZ L1D77 ; Loop for 1 Comm
POP DE
INC E
INC E
POP BC
DJNZ L1D57
RET
;----------------------------------------------------
; DE = Cursor Position
;----------------------------------------------------
L1D83: LD HL,023A0h ; Setup Text Pointer
PUSH DE ; Save pointer
EX DE,HL ; DE = Pointer to Text
LD HL,00000h ; HL = 0000
LD A,028h ; A = 40 Characters to print
L1D8D: CALL L2224 ; Print text of length A
POP DE ;
LD HL,023A0h ;
PUSH DE ;
L1D95: EX DE,HL ;
LD HL,00398h ;
LD A,028h ;
CALL L2224 ; Print text of length A
POP DE ;
LD B,001h ; Loop = 1
L1DA1: CALL L2353 ; Wait for Comm Ready
DJNZ L1DA1 ; Loop for 1 Comm
LD D,000h ; Verticle line at X = 0
CALL L1DED ; Draw Verticle Line
LD D,014h ; Verticle line at X = 20
CALL L1DED ; Draw Verticle Line
LD B,001h ; Loop = 1
L1DB2: CALL L2353 ; Wait for Comm Ready
DJNZ L1DB2 ; Loop for 1 Comm
LD D,027h ; Verticle line at X = 39
CALL L1DED ; Draw Verticle Line
LD DE,00000h ; Location X = 0, Y = 0
LD A,083h ; A = Character Upper Left Corner
CALL L2233 ; Print one Character to Text Display
LD DE,02700h ; Location X = 39, Y = 0
LD A,082h ; A = Character Upper Right Corner
CALL L2233 ; Print one Character to Text Display
LD DE,00017h ; Location X = 0, Y = 23
LD A,085h ; A = Character Lower Left Corner
CALL L2233 ; Print one Character to Text Display
LD DE,02717h ; Location X = 39, Y = 23
LD A,084h ; A = Character Lower Right Corner
CALL L2233 ; Print one Character to Text Display
LD A,087h ; A = Character
LD DE,01400h ; Location X = 0, Y = 0
CALL L2233 ; Print one Character to Text Display
LD A,088h ; A = Character
LD DE,01417h ; Location X = 0, Y = 0
CALL L2233 ; Print one Character to Text Display
RET ; Return
;----------------------------------------------------
; Draw Verticle Line 24 characters long
; D = X location of verticle line
;----------------------------------------------------
L1DED: LD E,000h ; Y = 0
LD B,018h ; Loop = 24
L1DF1: LD A,081h ; A = Character Verticle Line
CALL L2233 ; Print one Character to Text Display
INC E ; Y = Y + 1
DJNZ L1DF1 ; Print all 24 characters
RET ; Return
;----------------------------------------------------
; unknown
;----------------------------------------------------
L1DFA: LD A,(0E18Ch) ; Get DIP Switches 12-19
BIT 0,A ; Check Service Mode Switch
RET NZ
BIT 1,A ; Check if Switch Test is enabled
RET NZ
BIT 4,A ; Check if Disc Test is enabled
RET NZ
LD A,(0E1A8h) ; Get Number of Credits
CP 001h ; Is there one credit?
CALL NC,L1E5B
LD A,(0E1A8h) ; Get Number of Credits
CP 002h ; Are there two credits?
CALL NC,L1E2B
LD A,(0E18Ch) ; Get DIP Switches 12-19
BIT 2,A ; Check if FREE PLAY set
JR Z,L1E23
CALL L1E5B
CALL L1E2B
L1E23: LD HL,0E192h ; HL = Button Data
RES 2,(HL) ; Clear PLAYER1/FEET
RES 3,(HL) ; Clear PLAYER2/FEET
RET ; Return
L1E2B: LD HL,0E192h ; HL = Button Data
BIT 3,(HL) ; Is PLAYER2/FEET pressed?
RET Z ; Not pressed so return
RES 3,(HL) ; Clear PLAYER2/FEET press
LD A,(0E126h) ; Get Control Register
RES 0,A
LD (0E126h),A
LD DE,00000h
LD (0E127h),DE
LD DE,0E0A2h
LD A,002h
LD (0E12Ah),A
CALL L0FA1 ; Call 3-Digit Addition
CALL L10E5 ; Sum Total Coins
CALL L1F37 ; Exchange players
;----------------------------------------------------
; Set Player 2
;----------------------------------------------------
LD A,002h ; Player Number 2
LD (0E1A9h),A ; Save Player Number
JP L1E8A ;
L1E5B: LD HL,0E192h ; HL = Button Data
BIT 2,(HL) ; Is PLAYER1/FEET pressed?
RET Z ; Not pressed, so return
RES 2,(HL) ; Clear PLAYER1/FEET press
LD A,(0E126h) ; Get Control Register
RES 0,A
LD (0E126h),A
LD DE,00000h
LD (0E127h),DE
LD DE,0E0A2h
LD A,001
LD (0E12Ah),A
CALL L0FA1 ; Call 3-Digit Addition
CALL L10E5 ; Sum Total Coins
;----------------------------------------------------
; Clear Player Data, E1A9-E1C6
;----------------------------------------------------
XOR A ; A = 0
LD HL,0E1A9h ; HL = Start Clear Address
LD B,01Eh ; Loop = 30
L1E86: LD (HL),A ; Clear location
INC HL ; Point to next location
DJNZ L1E86 ; Loop until all locations cleared
L1E8A: LD HL,L0000
LD (0E1A1h),HL
CALL L1F37 ; Reset Player Variables?
LD A,001h ; Player Number 1
LD (0E1A9h),A ; Save Player Number
LD SP,0F000h ; Set Stack Pointer
LD HL,L072A ; HL = Address
PUSH HL ; Save Address
EI ; Enable Interrupts
RETN ; Return from NMI
;----------------------------------------------------
; Check for Next Player
;----------------------------------------------------
L1EA2: CALL L1F14 ; Swap player data
LD A,(0E1AEh) ; Get Number of Lives Remaining
OR A ; Check if any lives left
JR NZ,L1EB4 ; Yes, continue game
CALL L1F14 ; Swap player data
LD A,(0E1AEh) ; Get Number of Lives Remaining
OR A ; Check if any lives left
JR Z,L1EB7 ; No lives left either, skip ahead
L1EB4: JP L0772 ; Continue game
;----------------------------------------------------
; Both Players GAME OVER
;----------------------------------------------------
L1EB7: LD A,(0E126h) ; Get Control Register
BIT 1,A ;
JR NZ,L1EB7 ;
LD A,(0E126h) ; Get Control Register
BIT 4,A ;
JR NZ,L1ED2 ;
;----------------------------------------------------
; Send PAUSE Command
;----------------------------------------------------
LD A,00Ah ; Command = PAUSE (0Ah)
CALL L207F ; Send Message to LDPlayer DI
LD A,(0E126h) ; Get Control Register
SET 4,A ; Set PAUSE Bit
LD (0E126h),A ; Save Control Register
;----------------------------------------------------
; Check final statistics against Bookkeeping Data
;----------------------------------------------------
L1ED2: LD HL,0E192h ; Get Button Data
RES 2,(HL) ; Clear PLAYER1/FEET
RES 3,(HL) ; Clear PLAYER2/FEET
CALL L156F ; Update Bookkeeping Data
CALL L1877 ; Check High Scores/Initials
LD A,(0E1C7h) ; Check if Players2 was playing
OR A ; Was it a 2 player game?
JR Z,L1EEE ; No, so don't check player2 data
CALL L1F14 ; Swap player data
CALL L156F ; Update Bookkeeping Data
CALL L1877 ; Check High Scores/Initials
;----------------------------------------------------
; Show GAME OVER and then go to beginning
;----------------------------------------------------
L1EEE: CALL L1F05 ; Clear out Player Data
LD A,(0E126h) ; Get Control Register
SET 0,A
LD (0E126h),A
CALL L3B39 ; Flash GAME OVER
CALL L1CF8 ; Show High Scores
CALL Delay500000 ; Call Delay 500,000
JP L0604 ; Begin game
;----------------------------------------------------
; Clear out Player Data, E1A9-E1E5h
;----------------------------------------------------
L1F05: LD HL,0E1A9h ; Point to start of Player Data
LD BC,0003Ch ; BC = Number of bytes
L1F0B: LD (HL),000h ; Clear Data location
INC HL ; Point to next Data location
DEC BC ; Decrement loop couter
LD A,B ; Get loop counter
OR C ; Check if loop counter is zero
JR NZ,L1F0B ; Loop until all Data locations cleared
RET ; Return
;----------------------------------------------------
; Swap locations E1A9-E1C6 and E1C7-E1E4
;----------------------------------------------------
L1F14: PUSH AF ; Save AF Register
PUSH BC ; Save BC Register
PUSH DE ; Save DE Register
PUSH HL ; Save HL Register
XOR A ; A = 0
LD (0E17Ah),A ; Clear Seconds Counter
LD HL,0E1A9h ; HL = Player Number
L1F1F: LD DE,0E1C7h ; DE = Player Data
LD BC,0001Eh ; Loop = 30
L1F25: LD A,(DE) ; Get player data
EX AF,AF' ; save it
LD A,(HL) ; Get Player 1 number
LD (DE),A ; put ??
EX AF,AF' ;
LD (HL),A ;
INC HL ;
INC DE ;
DEC BC ; Decrement Loop
LD A,B ; Get Loop
OR C ; Check loop
JR NZ,L1F25 ; Loop back until zero
POP HL ; Restore HL Register
POP DE ; Restore DE Register
POP BC ; Restore BC Register
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; unknown
;----------------------------------------------------
L1F37: CALL L1F14 ; Swap player data
CALL L1F55 ;
CALL L1F70 ; Add number of lives per credit
LD HL,00000h ; HL = 00000h
LD (0E1AAh),HL ; Clear score
LD (0E1ACh),HL ; Clear score
LD (0E1C4h),HL ; Clear Game Timer
LD (0E1C5h),HL ; Clear Game Timer
LD A,01Eh ; A = 30 seconds
LD (0E1C3h),A ; Store 30 counter?
RET ; Return
;----------------------------------------------------
; Check for FREE PLAY
;----------------------------------------------------
L1F55: LD A,(0E18Dh) ; Get DIP Switches 12-19
BIT 2,A ; Check FREE PLAY setting
RET NZ ; FREE PLAY not set so return
LD A,(0E126h) ; Get Control Register
BIT 0,A ;
RET NZ ;
DI ; Disable Interrupts
LD A,(0E1A8h) ; Get Number of Credits
OR A ; Check if any credits left
JR Z,L1F6E ; No credits left so skip ahead
ADD A,099h ; Add 99 Credits
DAA ; Convert to decimal
LD (0E1A8h),A ; Save Number of Credits
L1F6E: EI ; Enable Interrupts
RET ; Return
;----------------------------------------------------
; Add Number of Lives per Credit
;----------------------------------------------------
L1F70: LD A,(0E186h) ; Get DIP Switches 28-35
AND 003h ; Get Number of lives per game (0,1,2,3)
ADD A,003h ; Add 3 Lives (3,4,5,6)
LD (0E1AEh),A ; Save Number of Lives
LD (0E157h),A ; Save Number of Lives
RET ; Return
RET
;----------------------------------------------------
; Transmit Comm Data Burst with Double Delay
;----------------------------------------------------
L1F7F: CALL L1F86 ; Comm Data Burst with Delay 3Ch
CALL L241D ; Call Delay for 64h
RET ; Return
;----------------------------------------------------
; Transmit Comm Data Burst with Delay = 3Ch
;----------------------------------------------------
L1F86: PUSH AF ; Save AF Register
CALL L1F8F ; Write Comm Data Burst
CALL L240B ; Delay for 3Ch
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; Write ten HIGH/LOW transitions to LDPlayer Comm
;----------------------------------------------------
L1F8F: PUSH AF ; Save AF Register
PUSH BC ; Save BC Register
PUSH DE ; Save DE Register
PUSH HL ; Save HL Register
LD C,06Ah ; C = LDPlayer Port
LD D,030h ;
LD E,000h ;
LD A,(0E113h) ; Get LDPlayer Register
OR 001h ; Set Comm bit HIGH
LD H,A ; H = A High
AND 0FEh ; Set Comm bit LOW
LD L,A ; L = A Low
LD A,H ; A = High
OUT (066h),A ; Output HIGH signal
;----------------------------------------------------
; (1) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H ; A = High
OUT (064h),A ; Output HIGH signal
OUT (064h),A ; Output HIGH signal
OUT (C),D
NOP ; Pause
LD A,L ; A = LOW
OUT (064),A ; Output LOW signal
OUT (064),A ; Output LOW signal
OUT (C),E
NOP ; Pause
;----------------------------------------------------
; (2) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H ;
OUT (064),A ;
OUT (064),A ;
OUT (C),D ;
NOP ;
LD A,L ;
OUT (064),A ;
OUT (064),A ;
OUT (C),E ;
NOP ;
;----------------------------------------------------
; (3) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H
OUT (064),A
OUT (064),A
OUT (C),D
NOP
LD A,L
OUT (064),A
OUT (064),A
OUT (C),E
NOP
;----------------------------------------------------
; (4) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H
OUT (064),A
OUT (064),A
OUT (C),D
NOP
LD A,L
OUT (064),A
OUT (064),A
OUT (C),E
NOP
;----------------------------------------------------
; (5) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H
OUT (064),A
OUT (064),A
OUT (C),D
NOP
LD A,L
OUT (064),A
OUT (064),A
OUT (C),E
NOP
;----------------------------------------------------
; (6) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H
OUT (064),A
OUT (064),A
OUT (C),D
NOP
LD A,L
OUT (064),A
OUT (064),A
OUT (C),E
NOP
;----------------------------------------------------
; (7) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H
OUT (064),A
OUT (064),A
OUT (C),D
NOP
LD A,L
OUT (064),A
OUT (064),A
OUT (C),E
NOP
;----------------------------------------------------
; (8) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H
OUT (064),A
OUT (064),A
OUT (C),D
NOP
LD A,L
OUT (064),A
OUT (064),A
OUT (C),E
NOP
;----------------------------------------------------
; (9) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H
OUT (064),A
OUT (064),A
OUT (C),D
NOP
LD A,L
OUT (064),A
OUT (064),A
OUT (C),E
NOP
;----------------------------------------------------
; (10) Write HIGH/LOW transition to LDPlayer Comm
;----------------------------------------------------
LD A,H
OUT (064),A
OUT (064),A
OUT (C),D
NOP
LD A,L
OUT (064),A
OUT (064),A
OUT (C),E
NOP
LD A,L
OUT (066),A
POP HL ; Restore HL Regiser
POP DE ; Restore DE Register
POP BC ; Restore BC Register
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; Send Command out on LDPlayer Comm
; Command is 5 bits long
;----------------------------------------------------
; A = Command
;----------------------------------------------------
#define FORWARD_3X 001h
#define SCAN_FWD 002h
#define SLOW_FWD 003h
#define STEP_FWD 004h
#define PLAY 005h
#define REVERSE_3X 006h
#define SCAN_REV 007h
#define SLOW_REV 008h
#define STEP_REV 009h
#define PAUSE 00Ah
#define SEARCH 00Bh
#define CHAPTER 00Ch
#define AUDIO_RIGHT 00Dh
#define AUDIO_LEFT 00Eh
#define REJECT 00Fh
#define NUM_0 010h
#define NUM_1 011h
#define NUM_2 012h
#define NUM_3 013h
#define NUM_4 014h
#define NUM_5 015h
#define NUM_6 016h
#define NUM_7 017h
#define NUM_8 018h
#define NUM_9 019h
#define POWER_UP 01Ah
;----------------------------------------------------
L204D: PUSH AF ; Save AF Register
PUSH BC ; Save BC Register
LD B,005h ; Bit to send = 5
L2051: RRA ; Rotate bit
JR NC,L2059 ; Bit is zero, so send "0"
CALL L1F7F ; Comm Data = 1
JR L205C ; Check loop
L2059: CALL L1F86 ; Comm Data = 0
L205C: DJNZ L2051 ; Loop until all bits are sent
POP BC ; Restore BC Register
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; Write HEADER to LDPlayer Comm, HEADER = 001
;----------------------------------------------------
L2061: CALL L1F86 ; Comm Data = 0
CALL L1F86 ; Comm Data = 0
CALL L1F7F ; Comm Data = 1
RET ; Return
;----------------------------------------------------
; Write FOOTER to LDPlayer Comm, FOOTER = 001
;----------------------------------------------------
L206B: CALL L1F86 ; Comm Data = 0
CALL L1F86 ; Comm Data = 0
CALL L1F8F ; Comm Data = End 1
RET ; Return
;----------------------------------------------------
; Write entire Message: HEADER + COMMAND + FOOTER
;----------------------------------------------------
L2075: CALL L2061 ; Write HEADER to Comm
CALL L204D ; Write COMMAND to Comm
CALL L206B ; Write FOOTER to Comm
RET ; Return
;----------------------------------------------------
; Disable Interrupt then send Message
;----------------------------------------------------
L207F: DI ; Disable Interrupts
CALL L2085 ; Issue Command to LDPlayer
EI ; Enable Interrupts
RET ; Return
;----------------------------------------------------
; Repeat Message to LDPlayer Comm 3x times
; A = Command
;----------------------------------------------------
L2085: PUSH AF ; Save AF Register
PUSH BC ; Save BC Register
CALL L2353 ; Wait for Comm Ready
CALL L2075 ; Send Message to Comm
CALL L2353 ; Wait for Comm Ready
CALL L2353 ; Wait for Comm Ready
CALL L2075 ; Send Message to Comm
CALL L2353 ; Wait for Comm Ready
CALL L2353 ; Wait for Comm Ready
CALL L2075 ; Send Message to Comm
CALL L2353 ; Wait for Comm Ready
POP BC ; Restore BC Register
LD (0E15Ch),A
IN A,(039h)
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; LDPlayer Command Table Lookup (Digits)
;----------------------------------------------------
L20AA:
.DB 010h ; Zero
.DB 011h ; One
.DB 012h ; Two
.DB 013h ; Three
.DB 014h ; Four
.DB 015h ; Five
.DB 016h ; Six
.DB 017h ; Seven
.DB 018h ; Eight
.DB 019h ; Nine
;----------------------------------------------------
; Clear Frame Number area and
; set Frame Count Wait bit
;----------------------------------------------------
L20B4: PUSH AF ; Save AF Register
LD A,000h ; A = 0
LD (0E116h),A ; Clear Frame Count area
LD (0E117h),A ; Clear Frame Count area
L20BD: LD (0E118h),A ; Clear Frame Count area
LD A,(0E126h) ; Get Control Register
SET 1,A ; Set Frame Count Wait bit
LD (0E126h),A ; Save Control Register
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; Setup Graphics Chip for Text
;----------------------------------------------------
; A = Text/Background Color
;----------------------------------------------------
L20CA: PUSH IX ; Save IX Register
PUSH AF ; Save AF Register
L20CD: LD IX,0E12Fh ; Start of Registers
LD (IX+000h),000h ;
LD (IX+001h),0F0h ; 8x8 sprites Mode 1
LD (IX+002h),000h ;
LD (IX+003h),010h ; Color Table = 2000h
LD (IX+004h),007h ; Char Pattern Table = 3800h
LD (IX+005h),004h ; SA = 200h
LD (IX+006h),007h ;
LD (IX+007h),000h ; Text = TRANS, Bkgnd = TRANS
CALL L22F5 ; Program Graphics Chip
;----------------------------------------------------
; Display transparent while being drawn
;----------------------------------------------------
; Load in Text Character Patterns
;----------------------------------------------------
LD HL,0584Fh ; HL = Text Character Patterns
LD DE,03800h ; Copy Character Patterns to 3800h
LD BC,00400h ; BC = 128 character x 8 bytes
CALL L22D9 ; Write Data Block to Graphics Address
POP AF ; Restore color assignment
;----------------------------------------------------
; Restore original colors after display is drawn
;----------------------------------------------------
LD IX,0E12Fh ; Color Register
LD (IX+007h),A ; Write color
L2108: CALL L2392 ;
CALL L22F5 ; Program Graphics Chip
POP IX ; Restore IX Register
RET ; Return
;----------------------------------------------------
; Setup Graphics Chip
;----------------------------------------------------
; A = Text/Background Color
;----------------------------------------------------
L2111: PUSH IX ; Save IX Register
PUSH AF ; Save Color Code
LD IX,0E12Fh ; Start of Graphics Registers
LD (IX+000h),001h ;
LD (IX+001h),0F0h ; Mode 1, Black & White Mode
LD (IX+002h),000h ;
LD (IX+003h),010h ; Color Table = 2000h
LD (IX+004h),007h ; Char Pattern Table = 3800h
LD (IX+005h),004h ;
LD (IX+006h),007h ;
LD (IX+007h),000h ;
CALL L22F5 ; Program Graphics Chip
;----------------------------------------------------
; Make display transparent while being drawn
;----------------------------------------------------
LD HL,0584Fh ; HL = Text Character Patterns
LD DE,03800h ; Copy Character Patterns to 3800h
LD BC,00400h ; BC = 128 character x 8 bytes
CALL L22D9 ; Write Data Block to Graphics Address
POP AF ; Get Color Code
;----------------------------------------------------
; Restore original colors after display is drawn
;----------------------------------------------------
LD IX,0E12Fh ; Point to Color Register
LD (IX+007h),A ; Set Color
CALL L22F5 ; Program Graphics Chip
POP IX ; Restore IX Register
RET ; Return
;----------------------------------------------------
; Clear Graphics Areas, Fill Screen with Characters
;----------------------------------------------------
L2155: PUSH AF ; Save AF Register
PUSH BC ; Save BC Register
PUSH DE ; Save DE Register
PUSH HL ; Save HL Register
PUSH IX ; Save IX Register
LD HL,0E130h ;
RES 6,(HL) ;
CALL L22F5 ; Program Graphics Chip
LD A,000h ; First Character = 00h
CALL L21E9 ; Fill Screen with incremental character
;----------------------------------------------------
; Clear Graphics Area 00000h-017FFh
;----------------------------------------------------
LD HL,00000h ; Graphics Address 00000h
CALL L2334 ; Set Graphic Address
LD BC,01800h ; Setup loop BC = 1800h
L2171: XOR A ; A = 00
OUT (044h),A ; Write to graphics address
DEC BC ; Decrement loop
LD A,B ; Get loop
OR C ; Check if loop is finished
JR NZ,L2171 ; Loop until all locations cleared
;----------------------------------------------------
; Clear Graphics Area 01800h-1BFFh
;----------------------------------------------------
LD HL,01800h ; Graphics Address 01800h
CALL L2334 ; Set Graphics Address
LD BC,00400h ; Setup loop BC = 0400h
L2182: XOR A ; A = 00
OUT (044h),A ; Write to Graphics address
DEC BC ; Decrement loop
LD A,B ; Get loop
OR C ; Check if loop is finished
JR NZ,L2182 ; Loop until all locations cleared
;----------------------------------------------------
; Reset Graphics Area 02000h-037FFh
;----------------------------------------------------
LD HL,02000h ; Graphics Address 02000h
CALL L2334 ; Set Graphics Address
LD BC,01800h ; Setup loop BC = 1800h
L2193: LD A,041h ; A = 41h
OUT (044h),A ; Write to Graphics address
DEC BC ; Decrement loop
LD A,B ; Get loop
OR C ; Check if loop is complete
JR NZ,L2193 ; Loop until all locations reset
;----------------------------------------------------
; Program Text Character Patterns
;----------------------------------------------------
LD HL,0584Fh ; HL = Text Character Patterns
LD DE,01000h ; Copy Character Patterns to 1000h
LD BC,00400h ; BC = 128 character x 8 bytes
CALL L22D9 ; Write Data Block to Graphics Address
LD HL,03E00h ; Graphics Addres = 3E00h
CALL L2334 ; Set Graphics Address
LD B,000h ;
L21B0: LD A,000h ;
OUT (044h),A ;
PUSH AF ;
POP AF ;
DJNZ L21B0 ;
LD IX,0E12Fh ;
LD (IX+000h),002h ; Mode 3 Graphics Mode
LD (IX+001h),0A0h ;
LD (IX+002h),00Fh ;
LD (IX+003h),0FFh ;
LD (IX+004h),003h ; Pattern Generator 0000h
LD (IX+005h),070h ;
LD (IX+006h),003h ;
LD (IX+007h),000h ;
CALL L2392 ;
CALL L22F5 ; Program Graphics Chip
POP IX ; Restore IX Register
POP HL ; Restore HL Register
POP DE ; Restore DE Register
POP BC ; Restore BC Register
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; Fill Screen with Incremental Character
;----------------------------------------------------
; A = Starting Character
; 3C00-3DFF filled with A, A + 1, A + 2,...
;----------------------------------------------------
L21E9: PUSH AF ; Save AF Register
LD HL,3C00h ; Graphics Location = 3C00h
CALL L2334 ; Set Graphics Location
POP AF ; Restore AF Register
LD L,A ; L = Starting character
LD BC,00200h ; BC = number of characters
L21F5: LD A,L ; A = Character to print
OUT (044h),A ; Print character
INC L ; Next character (L=L+1)
DEC BC ; Decrement loop
LD A,B ; Get loop
OR C ; Check loop
JR NZ,L21F5 ; Loop not zero so continue fill
RET ; Return
;----------------------------------------------------
; Clear Text Display 0-960 (0000-03C0h)
;----------------------------------------------------
L21FF: LD HL,00000h ; Cursor Position (X=0,Y=0)
CALL L2334 ; Set Text Cursor Position
LD BC,003C0h ; Loop = Number of Text Locations
L2208: LD A,000h ; A = Blank (00h)
OUT (044h),A ; Send blank to Text Display
DEC BC ; Decrement Loop
LD A,B ; Check Loop
OR C ; Is Loop at zero?
JR NZ,L2208 ; No, so continue
RET ; Finished so return
;----------------------------------------------------
; Print to Text Display
;----------------------------------------------------
; HL = Cursor Position 0 - 960 (0000-03C0h)
; PC = Text Location (on stack)
;----------------------------------------------------
L2212: CALL L2334 ; Set Text Cursor Position
POP HL ; Grab Text Pointer from stack
L2216: LD A,(HL) ; Get character
INC HL ; Point to next character
SUB 020h ; Make into printable character
JP M,L2223 ; Last character, so leave
OUT (044h),A ; Output character to display
PUSH AF ; Quick pause
POP AF ; Quick pause
JR L2216 ; Continue until all characters are printed
L2223: JP (HL) ; Jump back to address after text
;----------------------------------------------------
; Print to Text Display
;----------------------------------------------------
; A = Number of characters to print
; DE = Pointer to start of text
;----------------------------------------------------
L2224: LD B,A ; B = Number of characters
CALL L2334 ; Set Text Cursor Position
L2228: LD A,(DE) ; Get character
SUB 020h ; Make into printable character
INC DE ; Point to next character
OUT (044h),A ; Output character to display
PUSH AF ; Quick pause
POP AF ; Quick pause
DJNZ L2228 ; Loop until all characters printed
RET ; Return
;----------------------------------------------------
; Print one Character to Text Display
;----------------------------------------------------
; A = Character to print
; D = X Cursor Position
; E = Y Cursor Position
;----------------------------------------------------
L2233: PUSH AF ; Save AF Register
PUSH HL ; Save HL Register
PUSH DE ; Save DE Register
PUSH AF ; Save character
;----------------------------------------------------
; Cursor Position = 40 * E + D
;----------------------------------------------------
LD A,E ; A = E
ADD A,A ; A = A * 2
LD L,A ; L = A
ADD A,A ; A = A * 2
ADD A,A ; A = A * 2
ADD A,L ; A = A + L
LD L,A ; L = A
LD H,000h ; HL = L
ADD HL,HL ; HL = HL * 2
ADD HL,HL ; HL = HL * 2
LD E,D ; E = D
LD D,000h ; DE = E
ADD HL,DE ; HL = HL + DE
LD DE,0000h ; Zero offset
ADD HL,DE ; Add offset
CALL L2334 ; Set Text Cursor Position
POP AF ; Recall saved character
SUB 020h ; Make into printable character
OUT (044),A ; Output character to display
POP DE ; Restore DE Register
POP HL ; Restore HL Register
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; Print to Text Display
;----------------------------------------------------
; A = Character to print
;----------------------------------------------------
L2256: PUSH AF ; Save AF Register
SUB 020h ; Make into printable character
OUT (044h),A ; Output character to display
POP AF ; Restore AF Register
RET ; Return
;----------------------------------------------------
; Print 2-Digit Number (1 byte)
;----------------------------------------------------
; HL = Number Location
;----------------------------------------------------
L225D: LD A,001h ; 1 byte in number
JR L226B ; Print Number
;----------------------------------------------------
; Print 4-Digit Number (2 bytes)
;----------------------------------------------------
; HL = Number Location
;----------------------------------------------------
L2261: LD A,002h ; 2 bytes in number
JR L226B ; Print Number
;----------------------------------------------------
; Print 6-Digit Number (3 bytes)
;----------------------------------------------------
; HL = Number Location
;----------------------------------------------------
L2265: LD A,003h ; 3 bytes in number
JR L226B ; Print Number
;----------------------------------------------------
; Convert Number to String and Print
;----------------------------------------------------
; HL = Number Location
; A = Number of Character Bytes (L226B)
; Two digits per byte
;----------------------------------------------------
L2269: LD A,004h ; 8-Digit number (4 bytes)
L226B: PUSH BC ; Save BC Register
PUSH DE ; Save X,Y Location
LD B,A ; B = Number of characters to print
LD C,000h ; C = Leading Zeros
L2270: LD A,(HL) ; Get character byte
RRC A ; Shift bits right
RRC A ; Shift bits right
RRC A ; Shift bits right
RRC A ; Shift bits right
AND 00Fh ; Isolate upper nibble
JR NZ,L2283 ; Number not zero, so print it
;----------------------------------------------------
; Don't print leading zeros
;----------------------------------------------------
LD A,C ; Check for Leading Zero
OR A ; Is this a leading zero?
JR Z,L2289 ; Yes, so don't print it
LD A,000h ; Number = 0
L2283: OR 030h ; Make digit into character
LD C,A ; Finished with leading zeros
CALL L2233 ; Print one Character to Text Display
L2289: INC D ; X = X + 1
LD A,(HL) ; Get character
AND 00Fh ; Isolate lower nibble
JR NZ,L229D ; Number not zero, so print it
;----------------------------------------------------
; Only print leading zero if it's the last digit
;----------------------------------------------------
LD A,B ; Get loop number
CP 001h ; Is this the last character?
LD A,000h ; Number = 0
JP Z,L229D ; Last character so print final zero
LD A,C ; Check for Leading Zero
OR A ; Is this a leading zero?
JR Z,L22A3 ; Yes, so don't print it
LD A,000h ; Number = 0
L229D: OR 030h ; Make digit into character
LD C,A ; Finished with leading zeros
CALL L2233 ; Print one Character to Text Display
L22A3: INC D ; Increment Cursor Position
INC HL ; Next character spot
DJNZ L2270 ; Loop until all characters printed
POP DE ; Restore X,Y Location
POP BC ; Restore BC Register
RET ; Return
NEXT PAGE
|
|