Prev: D8B0 Up: Map Next: DA0C
D8E5: Julius logic
Handles all the logic around drawing Julius and handling his "special" logic.
Julius_Good_Bad D8E5 DEFB $00 If this is $00 then Julius is "good". If this is $01 then he is "bad" (i.e. will draw on you).
D8E6 DEFB $00
Julius_State_Reference D8E7 DEFB $04 The current character state.
Julius_Timer_01 D8E8 DEFB $00 Character timer 1.
Julius_Timer_02 D8E9 DEFB $00 Character timer 2.
Julius_Timer_03 D8EA DEFB $00 Character timer 3.
Julius_Timer_04 D8EB DEFB $1B Character timer 4.
Julius_Timer_05 D8EC DEFB $08 Character timer 5.
Julius_Timer_06 D8ED DEFB $08 Character timer 6.
Julius_Timer_07 D8EE DEFB $80 Character timer 7.
This routine looks at the current character state and routes to the correct subroutine.
Julius_Open_Routing D8EF LD HL,$D8E7 A=Julius_State_Reference.
D8F2 LD A,(HL)
D8F3 DEC A Work out which routine to use based on the current state.
A Routine
01 Julius_Open_01
02 Julius_Open_02
03 Julius_Open_03
04 Julius_Open_04
05 Julius_Open_05
06 Julius_Open_06
07 Julius_Open_07
D8F4 JR Z,Julius_Open_01
D8F6 DEC A
D8F7 JR Z,Julius_Open_02
D8F9 DEC A
D8FA JR Z,Julius_Open_03
D8FC DEC A
D8FD JR Z,Julius_Open_04
D8FF DEC A
D900 JR Z,Julius_Open_05
D902 DEC A
D903 JR Z,Julius_Open_06
D905 JR Julius_Open_07
Handle door frame 1 countdown/ transition to door frame 2.
Julius_Open_01 D907 LD A,($D8E8) Decrease Julius_Timer_01 by one, return if result is not zero.
D90A DEC A
D90B LD ($D8E8),A
D90E RET NZ
D90F INC (HL) Move onto next character state.
D910 LD A,$24 Pass character index (stand off | 24) to Draw_DoorFrame02 and return.
D912 CALL Draw_DoorFrame02
D915 RET
Handle door frame 2 countdown/ transition to door frame 3.
Julius_Open_02 D916 LD A,($D8E9) Decrease Julius_Timer_02 by one, return if result is not zero.
D919 DEC A
D91A LD ($D8E9),A
D91D RET NZ
D91E INC (HL) Move onto next character state.
D91F LD A,$24 Pass character index (stand off | 24) to Draw_DoorFrame03 and return.
D921 CALL Draw_DoorFrame03
D924 RET
Handle door frame 3 countdown/ transition to door frame 4.
Julius_Open_03 D925 LD A,($D8EA) Decrease Julius_Timer_03 by one, return if result is not zero.
D928 DEC A
D929 LD ($D8EA),A
D92C RET NZ
D92D INC (HL) Move onto next character state.
D92E LD A,$24 Pass character index (stand off | 24) to Draw_DoorFrame04 and return.
D930 CALL Draw_DoorFrame04
D933 RET
Handle door frame 4 countdown.
Julius_Open_04 D934 LD DE,$CFDD Call Hit_Detection with a callback to Init_Julius_Close.
D937 CALL Hit_Detection
D93A LD A,($D8EB) Decrease Julius_Timer_04 by one, return if result is not zero.
D93D DEC A
D93E LD ($D8EB),A
D941 RET NZ
D942 INC (HL) Move onto next character state.
D943 LD A,($D8E5) Jump to Julius_State_04_Close if Julius_Good_Bad is zero (Julius is "good").
D946 AND A
D947 JR Z,Julius_State_04_Close
Changes the frame to show Julius drawing his pistol.
D949 LD (HL),$07 Writes "07" to Julius_State_Reference.
D94B LD A,$25 Pass character index (draw | 25) to Draw_DoorFrame04 and return.
D94D CALL Draw_DoorFrame04
D950 RET
Set up (and begin) closing the door.
Julius_State_04_Close D951 LD A,$24 Pass character index (stand off | 24) to Draw_DoorFrame03.
D953 CALL Draw_DoorFrame03
D956 LD A,$01 Writes $01 to D190 and IX+8. Writes $05 to IX+6 and return.
D958 LD ($D190),A
D95B LD (IX+$08),A
D95E LD (IX+$06),$05
D962 RET
Handle door frame 3 countdown/ transition to door frame 2.
Julius_Open_05 D963 LD A,($D8EC) Decrease Julius_Timer_05 by one, return if result is not zero.
D966 DEC A
D967 LD ($D8EC),A
D96A RET NZ
D96B INC (HL) Move onto next character state.
D96C LD A,$24 Pass character index (stand off | 24) to Draw_DoorFrame02 and return.
D96E CALL Draw_DoorFrame02
D971 RET
Handle door frame 2 countdown/ transition to door frame 1.
Julius_Open_06 D972 LD A,($D8ED) Decrease Julius_Timer_06 by one, return if result is not zero.
D975 DEC A
D976 LD ($D8ED),A
D979 RET NZ
D97A CALL Draw_DoorFrame1 Call Draw_DoorFrame1 (i.e. no character/ door is shut).
D97D CALL Reset___ Call Reset___.
D980 RET Return.
???
Julius_Open_07 D981 LD DE,$CFE2 Call Hit_Detection with a callback to CFE2.
D984 CALL Hit_Detection
D987 LD A,($D8EE) Decrease Julius_Timer_07 by one, return if result is not zero.
D98A DEC A
D98B LD ($D8EE),A
D98E RET NZ
D98F INC A Move onto next character state.
D990 LD ($D2FE),A Write $01 to D2FE.
D993 CALL Reset___ Call Reset___.
D996 RET Return.
This routine looks at the current character state and routes to the correct subroutine.
Julius_Close_Routing D997 LD HL,$D8E7 A=Julius_State_Reference.
D99A LD A,(HL)
D99B DEC A Work out which routine to use based on the current state.
A Routine
01 Julius_Close_01
02 Julius_Close_02
03 Julius_Close_03
04 Julius_Close_04
05 Julius_Close_05
D99C JR Z,Julius_Close_01
D99E DEC A
D99F JR Z,Julius_Close_02
D9A1 DEC A
D9A2 JR Z,Julius_Close_03
D9A4 DEC A
D9A5 JR Z,Julius_Close_04
D9A7 JR Julius_Close_05
Handles state countdown/ transition to character frame $26.
Julius_Close_01 D9A9 LD A,($D8E8) Decrease Julius_Timer_01 by one, return if result is not zero.
D9AC DEC A
D9AD LD ($D8E8),A
D9B0 RET NZ
D9B1 INC (HL) Move onto next character state.
D9B2 LD A,$26 Pass character index shot | 26 to Draw_DoorFrame04 and return.
D9B4 CALL Draw_DoorFrame04
D9B7 RET
Handles state countdown/ transition to character frame $27.
Julius_Close_02 D9B8 LD A,($D8E9) Decrease Julius_Timer_02 by one, return if result is not zero.
D9BB DEC A
D9BC LD ($D8E9),A
D9BF RET NZ
D9C0 INC (HL) Move onto next character state.
D9C1 LD A,$27 Pass character index floor | 27 to Draw_DoorFrame04.
D9C3 CALL Draw_DoorFrame04
D9C6 LD A,($D8E6) Return if D8E6 is zero.
D9C9 AND A
D9CA RET Z
D9CB INC A Else write D8E6+1 to D2FE, call Reset___ and return.
D9CC LD ($D2FE),A
D9CF CALL Reset___
D9D2 RET
Handle door frame 4 countdown/ transition to door frame 3.
Julius_Close_03 D9D3 LD A,($D8EA) Decrease Julius_Timer_03 by one, return if result is not zero.
D9D6 DEC A
D9D7 LD ($D8EA),A
D9DA RET NZ
D9DB INC (HL) Move onto next character state.
D9DC LD A,$27 Pass character index floor | 27 to Draw_DoorFrame03 and return.
D9DE CALL Draw_DoorFrame03
D9E1 RET
Handle door frame 3 countdown/ transition to door frame 2.
Julius_Close_04 D9E2 LD A,($D8EB) Decrease Julius_Timer_04 by one, return if result is not zero.
D9E5 DEC A
D9E6 LD ($D8EB),A
D9E9 RET NZ
D9EA INC (HL) Move onto next character state.
D9EB LD A,$27 Pass character index floor | 27 to Draw_DoorFrame02 and return.
D9ED CALL Draw_DoorFrame02
D9F0 RET
Handle door frame 2 countdown/ transition to door frame 1.
Julius_Close_05 D9F1 LD A,($D8EC) Decrease Julius_Timer_05 by one, return if result is not zero.
D9F4 DEC A
D9F5 LD ($D8EC),A
D9F8 RET NZ
D9F9 CALL Draw_DoorFrame1 Call Draw_DoorFrame1 (i.e. no character/ door is shut).
D9FC CALL Reset___ Call Reset___.
D9FF LD A,$01 Writes $01 to D190 and IX+8. Writes $05 to IX+6 and return.
DA01 LD ($D190),A
DA04 LD (IX+$08),A
DA07 LD (IX+$06),$05
DA0B RET
Prev: D8B0 Up: Map Next: DA0C