Prev: AB78 Up: Map Next: AC3C
AB7C: Main handler for moving Wally around.
Used by the routines at Game_Start and Invaders_Loop.
Input
Output
Wally_Handler AB7C LD A,(Wally_CharAligned) See if Wally is aligned with the character cell row at current position.
AB7F OR A
AB80 JR NZ,Wally_Handler_0
AB82 LD HL,(Wally_X) Get current position, shift to 1 cell across and 3 rows down. Under the feet of Wally.
AB85 LD A,L
AB86 ADD A,$08
AB88 LD L,A
AB89 LD A,H
AB8A ADD A,$20
AB8C LD H,A
AB8D CALL A=ATTR(pixel_HY, pixel_LX) Get the background colour at that point and store.
AB90 LD (Wally_ATTR),A
AB93 LD A,($AE35) Get ATTR of row below that an store.
AB96 LD (Wally_ATTRAlt),A
AB99 JR Wally_Handler_1
Wally_Handler_0 AB9B LD A,($AE38) If Wally is not cell aligned get the last background colour found when drawn, at offset position.
AB9E LD (Wally_ATTRAlt),A Store this for both flags.
ABA1 LD (Wally_ATTR),A
Check Wally's state
Wally_Handler_1 ABA4 LD A,(IsArcadeMode) See if game is in Arcade mode, which means no jumping or falling.
ABA7 OR A
ABA8 JR NZ,Wally_Handler_2
ABAA LD A,(Wally_JumpDir) See if Wally is currently in a jump.
ABAD OR A
ABAE JP NZ,Wally_JumpHandlerEntry
Wally_Handler_2 ABB1 LD A,(Wally_Falling) See if Wally is falling.
ABB4 OR A
ABB5 JP NZ,Wally_CheckFall
ABB8 LD A,(Wally_ATTR) See if Wally is not on a platform and needs to start falling.
ABBB CP $45
ABBD JR Z,Wally_Handler_3
ABBF CP $42
ABC1 JR Z,Wally_Handler_3
ABC3 LD A,$01
ABC5 LD (Wally_Falling),A
ABC8 JP Wally_CheckFall
Check User's Input
Wally_Handler_3 ABCB LD A,(Input_Flag)
ABCE OR A
ABCF JR Z,Wally_Handler_4
ABD1 IN A,($1F)
ABD3 BIT 4,A
ABD5 JP NZ,Wally_Jump
ABD8 JR Wally_Handler_5
Wally_Handler_4 ABDA LD A,(Game_InputJumpAddr)
ABDD IN A,($FE)
ABDF OR $E0
ABE1 LD HL,Game_InputJump
ABE4 OR (HL)
ABE5 CP $FF
ABE7 JP NZ,Wally_Jump
This entry point is used by the routine at Wally_ShootCreate.
Wally_Handler_5 ABEA XOR A
ABEB LD (Wally_Dir),A
ABEE LD A,(Input_Flag)
ABF1 OR A
ABF2 JR Z,Wally_Handler_6
ABF4 IN A,($1F)
ABF6 BIT 0,A
ABF8 JR NZ,Wally_Handler_7
ABFA JR Wally_Handler_8
Wally_Handler_6 ABFC LD A,(Game_InputRightAddr)
ABFF IN A,($FE)
AC01 OR $E0
AC03 LD HL,Game_InputRight
AC06 OR (HL)
AC07 CP $FF
AC09 JR Z,Wally_Handler_8
Wally_Handler_7 AC0B LD A,$01
AC0D LD (Wally_Dir),A
AC10 LD (Wall_LastDir),A
AC13 JP Wally_Move
Wally_Handler_8 AC16 LD A,(Input_Flag)
AC19 OR A
AC1A JR Z,Wally_Handler_9
AC1C IN A,($1F)
AC1E BIT 1,A
AC20 JR NZ,Wally_Handler_10
AC22 RET
Wally_Handler_9 AC23 LD A,(Game_InputLeftAddr)
AC26 IN A,($FE)
AC28 OR $E0
AC2A LD HL,Game_InputLeft
AC2D OR (HL)
AC2E CP $FF
AC30 RET Z
Wally_Handler_10 AC31 LD A,$FF
AC33 LD (Wally_Dir),A
AC36 LD (Wall_LastDir),A
AC39 JP Wally_Move
Prev: AB78 Up: Map Next: AC3C