Prev: CE1E 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 CE1E by one.
CE24 LD A,(HL)
CE25 DEC A
CE26 LD (HL),A
CE27 RET NZ Return if not zero.
CE28 LD A,($CE1B) Copies CE1B into CE1E.
CE2B LD (HL),A
CE2C LD A,(IX+$09) Decrease ????? 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 not zero.
f
Chooser CE34 CALL Random_Number Call Random_Number.
CE37 AND $1F Keep bits 0-4 (so 0-31).
CE39 OR $08 Set bit 3 and write the resulting value to;
Address Door
D16E Door 1
D17C Door 2
D18A Door 3
CE3B LD (IX+$09),A
CE3E LD HL,($CE1F) Jump to the memory address 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 Call DAEF.
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
00 Init_Bandit_Open
01 Init_Bowie
02 Init_Customer_Close
03 Init_Customer_Open
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 3 and above.
Choose_Julius CE55 CALL Random_Number Call 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 Call 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 Call 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 4 and above.
Choose_Bandit_04 CE7E CALL Random_Number Call 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 5 and above.
Choose_Bandit_05 CE8D CALL Random_Number Call 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 6 and above.
Choose_Bandit_06 CE9C CALL Random_Number Call 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 $D019 Jump to D019.
Prev: CE1E Up: Map Next: CEB8