Prev: CE1F Up: Map Next: CEB8
CE21: Choose Door Character
Used by the routine at CAE7.
The characters available on a particular level are determined by Chooser_Routine_Buffer.
Initialisation Routine Door
Choose_Default_Set Door 1
Choose_Bandit_05 Door 2
D18A Door 3
Character_Chooser CE21 LD HL,$CE1E Decrease the current door timer value at CE1E by one.
CE24 LD A,(HL)
CE25 DEC A
CE26 LD (HL),A
CE27 RET NZ Return if it not time to open a door yet.
CE28 LD A,($CE1B) Restore the basic timer value from CE1B into CE1E.
CE2B LD (HL),A
CE2C LD A,(IX+$09) Decrease the timer to open this door by one.
Address Door
D16E Door 1
D17C Door 2
D18A Door 3
CE2F DEC A
CE30 LD (IX+$09),A
CE33 RET NZ Return if it is not time to open a door yet.
It's time to open this door. Choose a character and put them in it.
Chooser CE34 CALL Random_Number Generate a random number.
CE37 AND $1F Keep bits 0-4 (so 0-31).
CE39 OR $08 Set bit 3 and write the new wait time on this door to;
Address Door
D16E Door 1
D17C Door 2
D18A Door 3
CE3B LD (IX+$09),A
CE3E LD HL,($CE1F) Jump to the current character action routine for this phase contained at Chooser_Routine_Buffer.
CE41 JP (HL)
Handles choosing one of the initial "default" characters. A character is always chosen here, so this is the end of the choosing routine.
Choose_Default_Set CE42 CALL $DAEF Generate a random number.
CE45 AND $03 Keep only bits 0 and 1 (which determine the type of character).
CE47 JR Z,Init_Bandit_Open Determines which character initialisation to run;
A Initialisation Routine Character
00 Init_Bandit_Open Jack Vicious
01 Init_Bowie Bowie
02 Init_Customer_Close Daisy
03 Init_Customer_Open Green Jordan
CE49 DEC A
CE4A JP Z,Init_Bowie
CE4D DEC A
CE4E JP Z,Init_Customer_Close
CE51 DEC A
CE52 JP Init_Customer_Open
Handles whether or not to choose Julius. Only active on phase 4 and above.
Choose_Julius CE55 CALL Random_Number Generate a random number.
CE58 AND $0C Keep only bits 2 and 3. Jump to the next character "test" if this is a non-zero number at Choose_Bandit_02.
CE5A JR NZ,Choose_Bandit_02
CE5C JP Init_Julius_Open Jump to Init_Julius_Open.
Handles whether or not to choose Bandit 2. Only active on phase 3 and above.
Choose_Bandit_02 CE5F CALL Random_Number Generate a random number.
CE62 AND $98 Keep only bits 3, 4 and 7. Jump to the next character "test" if this is a non-zero number at Choose_Bandit_03.
CE64 JR NZ,Choose_Bandit_03
CE66 LD HL,$D119 Set source character data to D119.
CE69 LD DE,$D124 Set target character buffer to D124.
CE6C JP Choose_Action Jump to Choose_Action.
Handles whether or not to choose Bandit 3. Only active on phase 2 and above.
Choose_Bandit_03 CE6F CALL Random_Number Generate a random number.
CE72 AND $31 Keep only bits 0, 4 and 5. Jump to the next character "test" if this is a non-zero number then jump back to the Choose_Default_Set.
CE74 JR NZ,Choose_Default_Set
CE76 LD HL,$D0C1 Set source character data to D0C1.
CE79 LD DE,$D0CC Set target character buffer to D0CC.
CE7C JR Choose_Action Jump to Choose_Action.
Handles whether or not to choose Bandit 4. Only active on phase 5 and above.
Choose_Bandit_04 CE7E CALL Random_Number Generate a random number.
CE81 AND $83 Keep only bits 0, 1 and 7. Jump to the next character "test" if this is a non-zero number Choose_Julius.
CE83 JR NZ,Choose_Julius
CE85 LD HL,$D0D7 Set source character data to D0D7.
CE88 LD DE,$D0E2 Set target character buffer to D0E2.
CE8B JR Choose_Action Jump to Choose_Action.
Handles whether or not to choose Bandit 5. Only active on phase 6 and above.
Choose_Bandit_05 CE8D CALL Random_Number Generate a random number.
CE90 AND $58 Keep only bits 3, 4 and 6. Jump to the next character "test" if this is a non-zero number Choose_Bandit_04.
CE92 JR NZ,Choose_Bandit_04
CE94 LD HL,$D0ED Set source character data to D0ED.
CE97 LD DE,$D0F8 Set target character buffer to D0F8.
CE9A JR Choose_Action Jump to Choose_Action.
Handles whether or not to choose Bandit 6. Only active on phase 7 and above.
Choose_Bandit_06 CE9C CALL Random_Number Generate a random number.
CE9F AND $71 Keep only bits 0, 4, 5 and 6. Jump to the next character "test" if this is a non-zero number Choose_Bandit_05.
CEA1 JR NZ,Choose_Bandit_05
CEA3 LD HL,$D103 Set source character data to D103.
CEA6 LD DE,$D10E Set target character buffer to D10E.
Stashes the chosen character source/ buffer to the door state buffer.
Choose_Action CEA9 LD (IX+$0C),L Writes the character source memory address to one of the following (depending on which door is currently being actioned);
Address Door
Door_Char_Source_01 Door 1
Door_Char_Source_02 Door 2
Door_Char_Source_03 Door 3
CEAC LD (IX+$0D),H
CEAF LD (IX+$0A),E Writes the character target/ buffer memory address to one of the following (depending on which door is currently being actioned);
Address Door
Door_Char_Buffer_01 Door 1
Door_Char_Buffer_02 Door 2
Door_Char_Buffer_03 Door 3
CEB2 LD (IX+$0B),D
CEB5 JP Init_Bandit_Draw_Open Put the bandit in the door.
Prev: CE1F Up: Map Next: CEB8