Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;#SECTION "MAIN", CODE
- ; A port of the Atari 2600
- ; game Fast Eddie for TI-83+
- ; by NovaSquirrel
- ;
- ; refer to the X11 license
- ; for sourcecode usage info
- VARS equ appData ; Unprotected vars
- PROT equ appData + 130 ; Vars protected from new levels
- FCA equ PROT ; Frame counter
- PLX equ FCA + 1 ; Player position X
- PLY equ PLX + 2 ; Player position Y
- VLX equ VARS + 2 ; Player velocity X, unused
- VLY equ VLX + 2 ; Player velocity Y
- LAD equ VLY + 2 ; Ladder movement
- SCR equ LAD + 2 ; Was gonna be for scroll amount
- INSXY equ SCR + 2 ; Insulin X and Y, two entries
- InsOK equ INSXY + 8 ; Okay row for insulin to be sent to
- TMP equ InsOK + 1 ; Temporary scratchpad
- InsGot equ TMP + 8 ; How many insulin have been gotten already
- TitlPt equ InsGot + 2 ; Pointer to the instructional text on the title
- InsKey equ PLY + 2 ; How many insulin before the key?
- Score equ InsKey + 1 ; Current score
- Lives equ Score + 3 ; Current lives
- Level equ Lives + 1 ; Current level number
- SugSP equ Level + 1 ; Sugar troop speed, increases
- SavSP equ SugSP + 2 ; Just me trying to save Stack Pointer
- Sdat equ saveSScreen + 256 ; Data table for sugar troops
- org userMem - 2
- db 0BBh, 6Dh ; mark this as an ASM program
- ; Mirage header
- ret ; "Return" so Asm( doesn't crash
- ; interpreting the icon as code
- db 1 ; This is a MirageOS program
- db 00000000b, 00000000b ; 15x15 icon
- db 00001110b, 00000000b
- db 00001011b, 11100000b
- db 00001110b, 10100000b
- db 00000000b, 00000000b
- db 00000000b, 00000000b
- db 00000111b, 11000000b
- db 00001111b, 11100000b
- db 00011011b, 10110000b
- db 00011011b, 10110000b
- db 00011111b, 11110000b
- db 00011111b, 11110000b
- db 00000100b, 01000000b
- db 00000100b, 01000000b
- db 00011100b, 01110000b
- db "Fast Eddie 83+", 0 ; Zero terminated description
- Start:
- ld (SavSP), sp
- call DoTitl ; Display the title and let player read instructions
- call ClrScrn ; Clear screen again
- ld hl, appData ; Clear out the place we're storing variables
- ld bc, 256 ; said place is 256 bytes big
- B_CALL _MemClear
- ld hl, saveSScreen ; Clear most of SaveSScreen out
- ld bc, 768 ; For playfield and Sugar Troop data
- B_CALL _MemClear
- ld hl, 40 ; Start with the sugar troops moving at a speed
- ld (SugSP), hl ; of 40
- xor a ; Quick way to set A to zero
- ld (Level), a ; First level
- ld a, 4 ; Original game starts with 4 lives
- ld (Lives), a
- call NeLVL
- ld a, 5 ; 5 insulin required for a key
- ld (InsKey), a
- call MainLoop
- ; Clean up
- Exit: ; Clean up
- call ClrScrn ; Clear the screen
- call SafeCopy ;
- B_CALL _HomeUp ; Move the cursor back up
- set 2, (iy + 0Dh) ; The OS screws up when autoscroll is off
- ret
- ; Create level
- NeLVL:
- ; Update stats
- ld a, 0 ; Reset player X position to zero
- ld (PLX + 1), a
- ld hl, (SugSP) ; Add 10 to Sugar Troop speed
- ld bc, 10
- add hl, bc
- ld (SugSP), hl
- ld a, (Level) ; Next level, so increment level count
- inc a
- ld (Level), a
- ld a, (InsKey) ; One more key needed each level
- inc a
- ld (InsKey), a
- call DoStatLvl ; Show stats on what level it is, how many lives...
- ; Clear temp
- ld hl, appData ; Clear the first half of AppData
- ld bc, 128
- B_CALL _MemClear
- call ClrScrn
- ld bc, 768 ; Also clear SaveSScreen because it stores the
- ld hl, saveSScreen ; playfield
- B_CALL _MemClear
- ; Generate level
- ld d, 0 ; X position for floor
- ld e, 60 ; Y position for floor
- ld b, 12 ; Number of blocks to place
- call MkFL ; Make floor
- ld d, 0 ; X position for floor
- ld e, 60 - 4 * 10 ; Y position for floor
- ld b, 12 ; Number of blocks to place
- call MkFL ; Make floor
- ld e, 60 - 4 * 10 ; Only specify Y position
- ld b, 5 ; 5 blocks tall
- call MkRLD ; Make two random ladders
- ld d, 0 ; X position for floor
- ld e, 60 - 4 * 5 ; Y position for floor
- ld b, 12 ; Number of blocks to place
- call MkFL ; Make floor
- ld e, 60 - 4 * 5 ; Only specify Y position
- ld b, 5 ; Number of blocks to place
- call MkRLD ; Make two random ladders
- ; Place prizes
- call Rand ; Random X pos
- and 31
- ld b, a
- ld a, 90
- sub b
- ld d, a ; load X position
- ld e, 60 - 4 * 4 ; preset Y position
- ld (INSXY), de ; insulin slot 1
- call Rand ; Random X pos
- and 31
- add a, 5
- ld d, a ; load X position
- ld e, 60 - 4 * 9 ; preset Y position
- ld (INSXY + 2), de ; insulin slot 2
- ; Place Sneakers
- call Rand ; Random X pos
- and 63
- add a, 16
- ld d, a
- ld e, 60 - 4 * 2 ; Fixed Y Pos
- ld (Sdat + 0 + 0), de ; Store X,Y
- call Rand ; Random X pos
- and 63
- add a, 16
- ld d, a
- ld e, 60 - 4 * 7 ; Fixed Y pos
- ld (Sdat + 0 + 8), de ; Store X,Y
- call Rand ; Random X pos
- and 63
- add a, 16
- ld d, a
- ld e, 12 ; Fixed Y pos
- ld (Sdat + 0 + 16), de ; Store X,Y
- ; Available row
- ld a, 4 ; First row is okay
- ld (InsOK), a
- ; Set speeds
- ld hl, (SugSP) ; Take current speed
- ld (Sdat + 3 + 0), hl ; Write to first enemy
- ld (Sdat + 3 + 16), hl ; Write to third enemy
- call NegHL
- ld (Sdat + 3 + 8), hl ; Write negative version to second enemy
- ret
- ; Player died
- Ganon:
- xor a ; Reset X position
- ld (PLX + 1), a
- ld a, (Lives) ; one less life
- or a
- ret z ; all out of lives?
- dec a
- ld (Lives), a
- call DoStatLvl ; tell player how many lives are left
- ret
- NegHL:
- xor a
- sub l
- ld l, a
- sbc a, a
- sub h
- ld h, a
- ret
- NegDE:
- xor a
- sub e
- ld e, a
- sbc a, a
- sub d
- ld d, a
- ret
- ; Scroll down
- SCRD:
- ld hl, plotSScreen + 768 - 12
- ld de, plotSScreen + 768
- ld bc, 768 - 12
- lddr
- ret
- ; Randomly set to other side of the field
- LDSi:
- bit 0, c ; Bit zero of random flag set?
- ret z ; if not, return. We want a 1 in 2 chance
- ld ixl, a
- ld a, 11
- sub ixl
- ret
- ; Make 2 random ladders
- MkRLD:
- call Rand ; Other side maybe?
- ld c, a
- call Rand
- and 7
- call LDSi
- sla a ; Multiply by 8
- sla a
- sla a
- ld d, a
- push de
- push bc
- call MkLD2 ; Place one ladder
- pop bc
- pop de
- call Rand
- and 3
- add a, 8
- call LDSi
- sla a ; Multiply by 8
- sla a
- sla a
- ld d, a
- call MkLD2 ; Place one ladder
- ret
- ; Make 1 ladder
- MkLD2:
- ; Mark in field bytes
- push de ; Save DE
- push bc ; Save BC
- ld ix, Pla + 8 ; Load platform graphic
- ld b, 4 ; 4 pixels high
- call Spr8b ; Cancel platform graphic out with XOR
- pop bc
- pop de
- MkLD:
- call bmDE ; Find block index
- ld a, 4 ; Block type 4 is ladder
- ld (hl), a ; Put it in the index
- push bc
- push de
- ; Draw
- ld ix, Pla + 16 ; Load ladder graphic
- ld b, 4
- call Spr8b ; XOR draw it
- pop de
- pop bc
- ld a, e ; Move down 4 pixels
- add a, 4
- ld e, a
- djnz MkLD ; Make another ladder block
- ret
- MkFL: ; Make floor
- call bmDE ; Calculate block index
- ld a, 3 ; Block type 3 is floor
- ld (hl), a
- push bc
- push de
- ld ix, Pla + 8
- ld b, 4
- call Spr8b ;XOR draw it
- pop de
- pop bc
- ld a, 8 ; Move right 8 pixels
- add a, d
- ld d, a
- djnz MkFL ; Make more floor blocks
- ret
- ; D(X) E(Y) - HL(Ptr)
- bmDE:
- push de
- ld a, d
- add a, 4
- and 01111000b
- sla a
- srl e
- srl e
- or e
- ld e, a
- ld hl, saveSScreen
- ld d, 0
- add hl, de
- ld a, (hl)
- pop de
- ret
- ; Ion random
- Rand:
- push hl
- push de
- ld hl, (seed1)
- ld a, r
- ld d, a
- ld e, (hl)
- add hl, de
- ld a, l
- xor h
- ld (seed1), hl
- pop de
- pop hl
- ret
- ;#SECTION "Loop", CODE
- ; Game logic here
- MainLoop:
- ld a, (FCA) ; Update frame counter
- inc a
- ld (FCA), a
- call ChL ; On ladder?
- call CoB ; Touching block?
- call KIL ; Kill ladder movement if needed
- call VML ;Move vertically for ladder if needed
- call Fal ;Try to fall
- call DoSTs ; Draw+Move sugar troops
- call DrP ; Draw player
- call DoIN ; Draw insulin
- call DrKey ; Draw key if needed
- call SafeCopy ; Copy PlotSScreen to the LCD display
- call DrKey ; Draw key again to erase
- call DrIN ; Draw insulin again to erase
- call DrP ; Draw player again to erase
- call DrSTs ; Draw sugar troops again to erase
- ld b, 0FEh ; Read cursor keys!
- call ReadGrp
- ld c, a ; 'A' gets altered a lot. Let's put it in C!
- bit 1, c ; Left key
- call z, MovL
- bit 2, c ; Right key
- call z, MovR
- ld b, 0FDh ; Key group with Clear as part of it
- call ReadGrp
- cp 0BFh ; ... was Clear pressed?
- ret z ; Exit the game if so!
- ; Game over
- ld a, (Lives) ; Okay, so are we out of lives?
- or a ; Quick way to check against zero
- ret z ; Exit if out of lives
- jp MainLoop ; Othewise, KEEP GOING
- ; check stop ladder
- KIL:
- ld a, (LAD) ; Check ladder status
- or a ; if it's zero, this check is not needed
- ret z ; exit
- call bmDE ; Are we still on a ladder?
- cp 4 ; ( 4 is the ladder code )
- ret z ; Return if we are still on a ladder
- ld a, 0 ; Otherwise, kill ladder state
- ld (LAD), a
- ret
- ; Do ladder moving
- VML:
- ld a, (LAD) ; Are we moving on a ladder?
- or a ; Quick way to check against zero
- ret z
- ld b, a ; Move ladder speed to B so we can do this:
- ld a, (PLY + 1) ; Offset Y position by ladder speed
- add a, b ;
- ld (PLY + 1), a ;
- ret
- ; Climb up
- ClU:
- ld a, (PLX + 1) ; Snap to the ladder so it doesn't look funky
- add a, 4
- and 11111000b
- ld (PLX + 1), a
- ld a, -1 ; Upwards
- ld (LAD), a
- ret
- ; Climb down
- ClD:
- ld a, (PLX + 1) ; Snap to the ladder so it doesn't look funky
- add a, 4
- and 11111000b
- ld (PLX + 1), a
- ld a, 1 ; Downwards
- ld (LAD), a
- ret
- ; Check if on ladder
- ChL:
- ld a, (PLX + 1) ; Load DE for bmDE
- ld d, a
- ld a, (PLY + 1)
- ld e, a
- call bmDE ; Calculate index and read
- cp 4 ; Ladder object?
- jp nz, ChL2 ; Okay, can we climb down?
- ld b, 0FEh ; Read cursor keys
- call ReadGrp
- bit 3, a ; Check for up
- jp z, ClU ; Climb up
- ChL2: ; Check four tiles BELOW player
- ld a, (PLX + 1) ; Load DE for bmDE ( plus four below )
- ld d, a
- ld a, (PLY + 1)
- add a, 4
- ld e, a
- call bmDE
- cp 4 ; is THAT a ladder?
- ret nz ; NO
- ld b, 0FEh ; Read cursor keys
- call ReadGrp
- bit 0, a ; Pressing down?
- jp z, ClD ; Climb down!
- ret
- ; Check touching block
- CoB:
- ld a, (LAD) ; Ignore if on a ladder, moving
- or a ; Quick way to check against zero
- ret nz
- ld a, (VLY + 1) ; Ignore if moving upwards
- bit 7, a
- ret nz
- ld a, (PLX + 1) ; Load DE for bmDE
- ld d, a
- ld a, (PLY + 1)
- add a, 4
- ld e, a
- call bmDE
- cp 0 ; Empty space?
- call nz, Sol ; if not, stop falling
- ret
- ; Check solid
- Sol:
- ld a, 0
- ld (PLY), a ; NO partial Y positioning
- ld (VLY), a ; NO partial vertical movement
- ld (VLY + 1), a ; NO complete vertical movement
- ld a, (PLY + 1)
- and 01111100b ; SNAP vertically
- ld (PLY + 1), a
- ; If we're on solid ground, we can jump, so check here
- ld b, 0BFh ; Button group with 2nd
- call ReadGrp ; read
- cp 0DFh ; is 2nd pressed?
- call z, DoJmp
- ret
- ; Vert velocity
- DoJmp:
- ld de, -150
- ld (VLY), de
- ret
- ; Player move left
- MovL:
- ld a, (FCA) ; Can only move every other frame
- bit 0, a
- ret z
- ld a, (PLX + 1)
- dec a
- cp -1 ; Can't move off the screen
- ret z
- ld (PLX + 1), a
- ret
- ; Player move right
- MovR:
- ld a, (FCA) ; Can only move every other frame
- bit 0, a
- ret z
- ld a, (PLX + 1)
- inc a
- cp 97 - 8 ; Can't move off the screen
- ret z
- ld (PLX + 1), a
- ret
- ; Draw player
- DrP:
- ld a, (PLX + 1) ; Load DE with player position for Spr8b
- ld d, a
- ld a, (PLY + 1)
- sub 4
- ld e, a
- ld ix, PLS ; Player sprite
- ld b, 8 ; 8 pixels tall
- call Spr8b ; XOR draw
- ret
- ; Fall due to gravity
- Fal:
- ld a, (LAD) ; DON'T fall if moving on a ladder
- or a ; Quick way to check against zero
- ret nz ;
- ld bc, 4 ; Gravity increment
- ld de, (PLY)
- ld hl, (VLY) ; Increase the amount of gravity
- add hl, bc
- ld (VLY), hl
- add hl, de ; Increase player Y by amount of gravity
- ld (PLY), hl
- ret
- ;#SECTION "Data", DATA
- Pla: ; Block graphics
- db 0, 0, 0, 0
- db 255, 129, 129, 255 ; UNUSED
- db 255, 213, 171, 255 ; UNUSED
- db 255, 143, 241, 255 ; Platform
- db 195, 255, 255, 195 ; Ladder
- KeyS:
- db 00000000b ; Key graphic
- db 01000000b
- db 10111110b
- db 01001010b
- SugS:
- db 00111100b ; Sugar Troop graphic
- db 01111110b
- db 11011011b
- db 11011011b
- db 11111111b
- db 00100100b
- db 00100110b
- db 01100000b
- db 00111100b
- db 01111110b
- db 11011011b
- db 11011011b
- db 11111111b
- db 00100100b
- db 01100100
- db 00000110b
- InsS: ; Insulin graphic
- db 10101010b
- db 01010101b
- db 10101010b
- db 01010101b
- db 01010101b
- db 10101010b
- db 01010101b
- db 10101010b
- PLS: ; Player sprite
- db 00111100b
- db 01000010b
- db 10100101b
- db 10100101b
- db 10000001b
- db 10011001b
- db 01000010b
- db 00111100b
- Titl: ; Title name
- db " FastEddie 83+ ", 0
- Auth: ; Author (ME)
- db "Written by Wahovipab, 2010", 0
- CLSign: ; ... copyleft?
- db 01111100b
- db 10110010b
- db 10001010b
- db 10001010b
- db 10110010b
- db 01111100b
- Stry: ; WOW STORY TIME
- db "Help Fast Eddie "
- db " collect enough "
- db " prizes to reach"
- db " the next level ", 0
- Stry2: ; PAGE TWO OF STORY
- db "After enough "
- db " prizes, a key "
- db " appears. Grab "
- db " it to continue ", 0
- Ctrls: ; PAGE THREE OF STORY
- db "2nd: Jump "
- db "\xcf/\x05: Walk "
- db "\x1e/\x1f: Climb "
- db "Clear: Exit ", 0
- ScoreT:
- db "Score: ", 0
- LevelT:
- db "Level: ", 0
- LivesT:
- db "Lives: ", 0
- Pressakey:
- db "Press a key...", 0
- InstrTxt:
- db "\xcf/\x05: Turn Page "
- db "2nd: Start ", 0
- InstrTbl: ; Table of pointers to story pages
- word 0, Ctrls, Stry, Stry2, 0
- InstrTen:
- ;#SECTION "Sugar", CODE
- DoSTr: ; Do one sugar troop
- push ix
- push de
- push hl
- ld d, (ix + 1)
- ld e, (ix + 0)
- call ColS ; Touching sugar troop? If so, die
- pop hl
- pop de
- pop ix
- ld h, (ix + 1) ; Load horizontal position
- ld l, (ix + 2)
- ld d, (ix + 4) ; Load speed
- ld e, (ix + 3)
- add hl, de ; Move sideways by speed amount
- ld (ix + 1), h
- ld (ix + 2), l
- ld d, (ix + 4) ; load again for no reason
- ld e, (ix + 3) ; kinda illegal
- ld a, (ix + 1) ; very illegal please don't sue me
- or a ; Quick way to check against zero
- call z, NegDE ; reverse direction if touching left edge
- ld a, (ix + 1) ; Reloading why?
- cp 96 - 8
- call z, NegDE ; reverse direction if touching right edge
- ld (ix + 4), d ; WRITE BACK
- ld (ix + 3), e
- DrSTr: ; darling we don't simply draw the sugar troop
- ld b, 8 ; 8 height
- ld d, (ix + 1) ; X position
- ld e, (ix + 0) ; Y position
- push ix ; preserve IX
- ld ix, SugS ; Load sugar troop image
- ld a, (FCA) ;
- bit 3, a
- call z, FlpS ; Animate between two frames
- call Spr8b ; draw
- pop ix ; Next sugar troop!
- ld bc, 8 ; 'nother register
- add ix, bc
- ret
- DrKey: ; Draw key
- ld a, (InsGot) ; Do we even have enough insulin for a key to appear
- ld b, a ; move
- ld a, (InsKey)
- cp b ; Keys Gotten >= Keys Needed
- ret nc ; No?
- ld hl, (Sdat + 0 + 16) ; load sugar troop Y
- ld de, -8 ; minus 8
- add hl, de
- push hl ; Save HL
- push hl ; Make another copy for DE
- pop de ; Copy to DE
- call Col8b ; Touching player?
- jp c, NNeLVL ; NEW LEVEL BECAUSE KEY IS TOUCHED
- pop de ; ... huh? OH! For Spr8b
- ld ix, KeyS ; Key sprite
- ld b, 4 ; 4 tall
- call Spr8b ; XOR draw it
- ret
- NNeLVL:
- pop hl ; die
- pop hl ; die
- call NeLVL ; New Level
- jp MainLoop ; Return to main loop
- ret
- DoSTs: ; Do all 3 sugar troops
- ld ix, Sdat
- call DoSTr
- call DoSTr
- call DoSTr
- ret
- DrSTs: ; Draw all 3 sugar troops
- ld ix, Sdat
- call DrSTr
- call DrSTr
- call DrSTr
- ret
- FlpS: ; IX += B
- push bc ; Save BC
- ld c, b
- ld b, 0
- add ix, bc
- pop bc ; Restore BC
- ret
- ;#SECTION "Insulin", CODE
- DoIN: ; Do both insulins
- ld a, (FCA) ; only move insulin 1 in 8 frames
- and 7
- jp nz, DrIN
- ld a, (INSXY + 1) ; MOVE FORWARD
- inc a
- ld (INSXY + 1), a
- ld a, (INSXY + 3) ; MOVE BACKWARD
- dec a
- ld (INSXY + 3), a
- ld ix, INSXY + 2 ; Move if on the edge
- ld a, (ix + 1)
- or a
- call z, NeIP ; new position
- ld ix, INSXY ; Move if on the edge
- ld a, (ix + 1)
- cp 96 - 8
- call z, NeIP ; new position
- ld ix, INSXY ; React to getting the insulin
- ld de, (INSXY)
- call Col8b
- call c, GotI
- ld ix, INSXY + 2 ; React to getting the insulin
- ld de, (INSXY + 2)
- call Col8b
- call c, GotI
- DrIN:
- ld a, (INSXY + 4) ; Insulin 1 ENABLED?
- or a ; Check if not zero very quickly
- jp nz, DrInS ; skip first insulin
- ld ix, InsS ; insulin graphic
- ld de, (INSXY)
- ld b, 4
- ld a, (FCA) ; framecounter
- bit 0, a ; every other frame in framecounter results
- call z, FlpS ; in other frame for GRAYSCALE EFFECT
- call Spr8b ; draw
- DrInS:
- ld a, (INSXY + 5) ; Insulin 2 ENABLED?
- or a ; Check if not zero very quickly
- ret nz ; skip rest
- ld ix, InsS ; insulin graphic
- ld b, 4
- ld a, (FCA) ; framecounter
- bit 0, a ; every other frame in framecounter results
- call z, FlpS ; in other frame for GRAYSCALE EFFECT
- ld de, (INSXY + 2) ; load XY for drawing
- call Spr8b ; draw
- ret
- GotI: ; Got one insulin
- ld de, 15 ; add 15 to score
- ld hl, (Score)
- add hl, de
- ld (Score), hl
- ld a, (InsGot) ; Mark one more insulin gotten
- inc a
- ld (InsGot), a
- push ix ; why am I smashing my hand with this hammer
- ld d, a
- ld e, 0
- call GetPixel ; Mark in the meter of how many insulins gotten
- or (hl) ; OR the dot in
- ld (hl), a ; update
- pop ix
- call NeIP ; New row and position
- ret
- PCom: ; load player XY into HL
- ld a, (PLX + 1)
- ld h, a
- ld a, (PLY + 1)
- ld l, a
- ret
- NeIP: ; New position and row
- ld b, (ix + 0) ; take the new avaliable row
- ld a, (InsOK) ; fetch good Y
- ld (ix + 0), a ; update Y
- ld a, b ; restore bad Y
- ld (InsOK), a ; set it to old row
- call Rand ; Make random X position
- and 63
- add a, 16
- ld (ix + 1), a ; Load in
- call Rand ; 50% chance of other side
- bit 0, a
- ret z
- ld a, 95 - 8 ; Other side...
- sub (ix + 1)
- ld (ix + 1), a ; Update
- ret
- DecA: ; Useless
- dec a
- ret
- ;#SECTION "Utility", CODE
- ColS: ; Collide with sugar troop?
- ld a, (LAD)
- or a
- ret nz
- ld a, (PLX + 1) ; Load my X
- add a, 4
- ld h, a
- ld a, (PLY + 1) ; Load my Y
- add a, 4
- ld l, a
- ld a, (ix + 1) ; Load sugar X
- add a, 4
- ld d, a
- ld a, (ix + 0) ; Load sugar Y
- add a, 4
- ld e, a
- call ColS2 ; COLLIDE?
- ex de, hl ; okay maybe not
- call ColS2 ; COLLIDE???
- ret
- ColS2:
- ld a, h ; not outside
- cp d
- ret c
- ld a, l ; not outside
- cp e
- ret c
- ld a, d ; not outside
- add a, 8
- cp h
- ret c
- ld a, e ; not outside
- add a, 4
- cp l
- ret c
- pop af ; garbage pop
- jp Ganon ; you must die
- ChCT:
- ld a, h
- cp d
- ret c
- ld a, l
- cp e
- ret c
- ld a, d
- add a, 7
- cp h
- ret c
- ld a, e
- add a, 7
- cp l
- ret c
- pop af ; Garbage pop
- pop de
- pop hl
- scf ; collision has occured
- ret
- Col8b: ; Collision?
- push hl
- push de
- dec d
- dec d
- dec d
- dec d
- ld a, (PLX + 1) ; load player XY into HL
- ld h, a
- ld a, (PLY + 1)
- ld l, a
- call ChCT ; HL inside DE
- ex de, hl
- call ChCT ; DE inside HL
- pop de
- pop hl
- ccf ; I used to think CCF was "clear carry flag"
- ret
- ;#SECTION "Menu", CODE
- DrTitl: ; draw title at the top
- B_CALL _HomeUp
- set textInverse, (iy + textFlags)
- ld hl, Titl
- B_CALL _PutS
- res textInverse, (iy + textFlags)
- ret
- DoStatLvl: ; lives and level
- ld hl, plotSScreen ; COPY SCREEN TO BACK IT UP
- ld de, appBackUpScreen
- ld bc, 768
- ldir
- call ClrScrn ; Clear screen
- call SafeCopy ; copy to screen
- call DrTitl ; draw title
- ld hl, LevelT ; display level
- B_CALL _PutS
- ld a, (Level)
- call NDspA
- ld hl, LivesT ; display lives
- B_CALL _PutS
- ld a, (Lives)
- call NDspA
- ld hl, ScoreT ; display score
- B_CALL _PutS
- ld hl, (Score)
- call NDspHL
- ld a, 7
- ld (curRow), a
- ld hl, Pressakey
- B_CALL _PutS
- call AnyKey ; wait for key
- ld hl, appBackUpScreen
- ld de, plotSScreen ; copy back
- ld bc, 768
- ldir
- ret
- NDspA: ; Display A, newline
- ld h, 0
- ld l, a
- NDspHL: ; Display HL, newline
- B_CALL _DispHL
- B_CALL _NewLine
- ret
- DoTitl: ; Draw title
- res 2, (iy + 0Dh)
- res 5, (iy + 0)
- ld hl, InstrTbl + 2
- ld (TitlPt), hl
- call ClrScrn
- call DrTitl
- ; put instructions for reading instructions
- ld a, 5 * 8 + 6
- ld (penRow), a
- xor a
- ld (penCol), a
- ld hl, InstrTxt
- B_CALL _VPutS
- ; credit myself
- ld a, 7 * 8
- ld (penRow), a
- xor a
- ld (penCol), a
- ld hl, Auth
- B_CALL _VPutS
- res textInverse, (iy + textFlags)
- call TitlCtrl
- ret
- TitlCtrl:
- ld a, 1
- ld (curRow), a
- xor a
- ld (curCol), a
- ld hl, (TitlPt)
- B_CALL _LdHLind
- B_CALL _PutS
- .gk:
- B_CALL _GetCSC
- or a
- jp z, .gk
- cp skLeft
- jp z, .mL
- cp skRight
- jp z, .mR
- cp skClear
- jp z, .Exit2
- ret
- .Exit2:
- pop hl
- pop hl
- ret
- .mL:
- ld hl, (TitlPt)
- dec hl
- dec hl
- ld (TitlPt), hl
- B_CALL _LdHLind ; get current pointed data
- ld a, h
- or a ; going to inalid page?
- jp nz, TitlCtrl
- ld hl, InstrTbl + 2
- ld (TitlPt), hl
- jp TitlCtrl
- .mR:
- ld hl, (TitlPt)
- inc hl
- inc hl
- ld (TitlPt), hl
- B_CALL _LdHLind ; get current pointed data
- ld a, h
- or a ; going to invalid page?
- jp nz, TitlCtrl
- ld hl, InstrTen - 4
- ld (TitlPt), hl
- jp TitlCtrl
- AnyKey: ; wait for any key
- ld b, 0FEh ; but wait for cursor keys to be release first
- call ReadGrp
- or a
- cp 0FFh
- jp nz, AnyKey
- .L: ; wait until a key is pressed
- B_CALL _GetCSC
- or a
- jp z, .L
- ret
- Nput: ; put, also newline
- B_CALL _PutS
- B_CALL _NewLine
- ret
- ;#IMPORT "LCDLIB"
- ; doesn't define much. I can include it if you like
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement