jetpac | Routines |
Prev: 6966 | Up: Map | Next: 6a2d |
Depending on the self-modifying code state, this routine either generates a new item/alien, or updates the item drop game timer.
|
||||||||
6971 | ld hl,$5dce | Increment random number | ||||||
6974 | inc (hl) | |||||||
6975 | ld de,$0008 | Set offset | ||||||
6978 | add ix,de | Set IX to next group of bytes | ||||||
697a | push ix | Copy IX to HL | ||||||
697c | pop hl | |||||||
The self-modifying code routines change the address here to be either the inactive player (5d88) or the rocket object (5d30).
|
||||||||
697d | ld bc,$5d88 | BC=inactive player or rocket object | ||||||
6980 | and a | Clear the Carry flag | ||||||
6981 | sbc hl,bc | If object pointed to by IX is before BC object, then jump back to the main loop | ||||||
6983 | jp c,$631c | |||||||
Read the keyboard to introduce a slight pause?
|
||||||||
6986 | ld a,$fe | Row: Shift,Z,X,C,V | ||||||
6988 | out ($fd),a | Set port for reading keyboard | ||||||
698a | in a,($fe) | ...and read that row of keys | ||||||
698c | bit 0,a | Check if SHIFT key pressed | ||||||
698e | jr z,$6986 | Jump if pressed | ||||||
Now increment timer and get new random number.
|
||||||||
6990 | ld hl,($5dcc) | Increment the game timer | ||||||
6993 | inc hl | |||||||
6994 | ld ($5dcc),hl | |||||||
6997 | ld h,$00 | Make sure HL remains <= $00FF | ||||||
6999 | ld a,r | Get a RANDOM number? | ||||||
699b | ld c,a | |||||||
The self-modifying code routine changes this to `JP 6966`. That routine resets the interrupts, before changing instruction here to `LD A,(0244)` - an address in the ROM which always returns $C1.
|
||||||||
699c | ld a,($5dce) | A=$C1, from 0244, because 5DCE is never used! | ||||||
699f | add a,(hl) | A=byte from address $0000 - $00FF | ||||||
69a0 | add a,c | Add R to the number | ||||||
69a1 | ld ($5dce),a | Update random number | ||||||
69a4 | ex af,af' | Jump if current alien number < 3 | ||||||
69a5 | ld a,($5dcb) | |||||||
69a8 | cp $03 | |||||||
69aa | jr c,$69b8 | |||||||
69ac | ex af,af' | |||||||
69ad | and $1f | |||||||
69af | jr nz,$69d9 | Drop fuel/collectible if RND is < 32 | ||||||
69b1 | ld a,($5dcb) | Drop fuel/collectible if current alien number >= 6 | ||||||
69b4 | cp $06 | |||||||
69b6 | jr nc,$69d9 | |||||||
69b8 | ld a,($5dd7) | Drop fuel/collectible if begin play delay counter > zero | ||||||
69bb | and a | |||||||
69bc | jr nz,$69d9 | |||||||
69be | ld a,($5d00) | Get jetman direction | ||||||
69c1 | and $3f | |||||||
69c3 | dec a | |||||||
69c4 | jr z,$69c9 | If direction is zero, then find unused alien slot | ||||||
69c6 | dec a | |||||||
69c7 | jr nz,$69d9 | Drop fuel/collectible if direction is still > zero | ||||||
Find first unused alien slot.
|
||||||||
69c9 | ld hl,$5d50 | Alien state objects | ||||||
69cc | ld b,$06 | Loop counter (6 aliens) | ||||||
69ce | ld de,$0008 | |||||||
69d1 | ld a,(hl) | Generate new alien if the slot is unused | ||||||
69d2 | and a | |||||||
69d3 | jp z,$69e2 | |||||||
69d6 | add hl,de | else increment to the next alien object | ||||||
69d7 | djnz $69d1 | ...and try again | ||||||
Drop either a fuel pod or collectible item.
|
||||||||
69d9 | call $65f9 | New fuel pod item | ||||||
69dc | call $65a8 | New collectible item | ||||||
69df | jp $6310 | Run main loop after resetting SP and EI | ||||||
Generate new alien in the given state slot (HL).
|
||||||||
69e2 | push hl | Push current alien to stack (will be copied to IX) | ||||||
69e3 | ex de,hl | |||||||
69e4 | ld hl,$6d94 | Copy default alien state to current alien slot | ||||||
69e7 | ld bc,$0008 | |||||||
69ea | ldir | |||||||
69ec | pop ix | Restore IX to point to current item object | ||||||
69ee | ld a,($5dcc) | Game timer | ||||||
69f1 | ld e,a | Backup to E | ||||||
69f2 | and $40 | A=either 0 or 64 | ||||||
69f4 | ld (ix+$04),a | Set item "direction" | ||||||
69f7 | ld (ix+$00),a | Set item "movement" | ||||||
69fa | ld a,e | Restore A to original game timer value | ||||||
69fb | and $7f | |||||||
69fd | add a,$28 | |||||||
69ff | ld (ix+$02),a | Update item Y position | ||||||
6a02 | push ix | Copy current item object address to BC | ||||||
6a04 | pop bc | |||||||
Calculate and update new colour attribute.
|
||||||||
6a05 | ld a,c | Example: if BC = 5D78, C = $78 = 01111000 | ||||||
6a06 | rra | 00111100 | ||||||
6a07 | rra | 00011110 | ||||||
6a08 | rra | 00001111 | ||||||
6a09 | and $03 | 00000011 <- result of AND $03 | ||||||
6a0b | inc a | 00000100 | ||||||
6a0c | inc a | 00000101 = $05 | ||||||
6a0d | ld (ix+$03),a | Update colour with value: $02, $03, $04, or $05 | ||||||
6a10 | and $01 | |||||||
6a12 | ld (ix+$06),a | Update jump table offset to either 0 or 1 | ||||||
6a15 | ld hl,$6a2d | HL=item level object types | ||||||
6a18 | ld a,($5df0) | Using the current player level, pull a value from the item level params table | ||||||
6a1b | and $07 | |||||||
6a1d | ld e,a | |||||||
6a1e | ld d,$00 | |||||||
6a20 | add hl,de | |||||||
6a21 | ld a,(ix+$00) | |||||||
6a24 | and $c0 | |||||||
6a26 | or (hl) | |||||||
6a27 | ld (ix+$00),a | Update item type to this value | ||||||
6a2a | jp $69d9 | Drop fuel/collectible then execute the main loop |
Prev: 6966 | Up: Map | Next: 6a2d |