Prev: 9167 Up: Map Next: 92AA
9168: CAST_S
Used by the routine at main_routine.
Loop through each player to select their spell to cast, then jump into routine06.
CAST_S 9168 LD HL,cast_table Clear cast_table and illusion_table to zeros.
916B LD (HL),$00
916D LD DE,$9157
9170 LD BC,$000F
9173 LDIR
9175 LD HL,s_cursor_sprite set UDG system variable to point to S cursor sprite data
9178 LD ($5C7B),HL
917B LD A,(NO_PLA) load NO_PLA into B as player loop counter
917E LD B,A
917F LD A,$00 set current_player to zero
9181 LD (current_player),A
9184 DI disable interrupts
cast_s_players_loop 9185 PUSH BC stack BC
9186 LD HL,unknown_table_3 set HL to address of unknown_table_3
9189 LD A,(current_player) load current_player into A
918C LD D,$00 add current player as offset in unknown_table_3
918E LD E,A
918F ADD HL,DE
9190 BIT 4,(HL) if bit 4 of address is not zero jump to cast_s_continue ???
9192 JP NZ,cast_s_continue
9195 CALL get_player_controlled_flag call get_player_controlled_flag to check if player is computer controlled
9198 OR A jump to cast_s_continue if current player is computer controlled
9199 JP NZ,cast_s_continue
This entry point is used by the routine at examine_board.
cast_s_menu_loop 919C LD HL,sound_effect_23 set HL to address of sound effect data at sound_effect_23. This overlaps the sound effect playback data memory with the result that when copied the same 5 bytes are repeated.
919F CALL play_sound_effect_in_HL call play_sound_effect_in_HL
91A2 CALL wait_no_key_seed wait for no key to be pressed
91A5 CALL CLS call CLS
91A8 LD A,$72 set ATTR-T to $72 (bright red on yellow) and draw border.
91AA LD ($5C8F),A
91AD CALL ZRDR_P
91B0 LD A,(CH_LAW) jump forwards to cast_s_ch_law_done if CH_LAW is zero
91B3 OR A
91B4 JR Z,cast_s_ch_law_done
91B6 LD BC,$0707 set BC to coordinates (7,7)
91B9 JP M,cast_s_chaotic jump forwards to cast_s_chaotic if CH_LAW is positive
91BC LD A,$46 set ATTR-T to $46 (bright yellow on black)
91BE LD ($5C8F),A
91C1 LD A,$47 Print law_string
91C3 CALL MPRINT
91C6 LD A,(CH_LAW) load CH_LAW into A and divide by four
91C9 SRA A
91CB SRA A
91CD OR A jump forwards to cast_s_end_law if result is zero
91CE JR Z,cast_s_end_law
91D0 LD (POSPRI),BC set POSPRI to coordinates (7,7)
91D4 LD B,A copy CH_LAW/4 into B
cast_s_law_loop 91D5 PUSH BC preserve BC (loop counter)
91D6 LD A,$5E call DH_P with character '^'
91D8 LD BC,(POSPRI)
91DC CALL DH_P
91DF LD BC,(POSPRI) move POSPRI one character right
91E3 INC C
91E4 LD (POSPRI),BC
91E8 POP BC restore BC (loop counter)
91E9 DJNZ cast_s_law_loop loop back to cast_s_law_loop CH_LAW/4 - 1 times
91EB LD BC,(POSPRI) load POSPRI into BC
cast_s_end_law 91EF LD A,$29 call DH_P with ')' character and jump forwards to cast_s_ch_law_done
91F1 CALL DH_P
91F4 JR cast_s_ch_law_done
cast_s_chaotic 91F6 LD A,$45 set ATTR-T to $45 (bright cyan on black)
91F8 LD ($5C8F),A
91FB LD A,$46 Print chaos_string
91FD CALL MPRINT
9200 LD A,(CH_LAW) load CH_LAW into A
9203 LD (POSPRI),BC store BC in POSPRI
9207 NEG negate A
9209 SRA A divide by 4
920B SRA A
920D OR A jump forwards to cast_s_end_chaos if -CH_LAW/4 is zero
920E JR Z,cast_s_end_chaos
9210 LD B,A copy -CH_LAW/4 into B and stack BC
cast_s_chaos_loop 9211 PUSH BC
9212 LD A,$2A call DH_P with character '*'
9214 LD BC,(POSPRI)
9218 CALL DH_P
921B LD BC,(POSPRI) move POSPRI one character right
921F INC C
9220 LD (POSPRI),BC
9224 POP BC restore loop counter and loop back to cast_s_chaos_loop -CH_LAW/4 - 1 times
9225 DJNZ cast_s_chaos_loop
9227 LD BC,(POSPRI) load POSPRI into BC
cast_s_end_chaos 922B LD A,$29 call DH_P with character ')'
922D CALL DH_P
cast_s_ch_law_done 9230 LD A,$46 set ATTR-T to $46 (bright yellow on black)
9232 LD ($5C8F),A
9235 LD A,(current_player) load current_player into A
9238 ADD A,$29 add $29 (first wizard name string in game messages table 1)
923A LD BC,$0507 Print wizard_0 at coordinates (7,5)
923D CALL MPRINT
9240 LD A,$45 set ATTR-T to $45 (bright cyan on black)
9242 LD ($5C8F),A
9245 LD A,$59 Print examine_spells_string at coordinates (7,9)
9247 LD BC,$0907
924A CALL MPRINT
924D LD A,$5A Print select_spell_string at coordinates (7,11)
924F LD BC,$0B07
9252 CALL MPRINT
9255 LD A,$5B Print examine_board_string at coordinates (7,13)
9257 LD BC,$0D07
925A CALL MPRINT
925D LD A,$5C Print continue_game_string at coordinates (7,15)
925F LD BC,$0F07
9262 CALL MPRINT
9265 LD A,$56 set ATTR-T to $56 (bright yellow on red)
9267 LD ($5C8F),A
926A LD A,$57 Print press_1_to_4_string at coordinates (0,22)
926C LD BC,$1600
926F CALL MPRINT
9272 CALL GETHIS call GETHIS
cast_s_key_loop 9275 CALL $02BF call KEYBOARD routine in ROM returning character code in A
9278 LD HL,cast_spell_flag Clear cast_spell_flag.
927B LD (HL),$00
927D CP $31 if A equals '1' then display spells then jump back to cast_s_menu_loop
927F JR NZ,cast_s_not_1
9281 CALL select_spell
9284 JP cast_s_menu_loop
cast_s_not_1 9287 CP $34 else if A equals '4' then jump to cast_s_continue
9289 JR Z,cast_s_continue
928B CP $33 else if A equals '3' then jump to examine_board
928D JR Z,examine_board
928F CP $32 else if A does not equal '2' then loop back to cast_s_key_loop
9291 JR NZ,cast_s_key_loop
9293 LD A,$01 '2' key was pressed, set cast_spell_flag.
9295 LD (cast_spell_flag),A
9298 CALL select_spell Select spell then jump back to cast_s_menu_loop
929B JP cast_s_menu_loop
cast_s_continue 929E POP BC '4' key was pressed, restore BC (player loop counter)
929F LD HL,current_player increment current_player variable
92A2 INC (HL)
92A3 DEC B decrement B
92A4 JP NZ,cast_s_players_loop jump back to cast_s_players_loop if there are still players to process
92A7 JP routine06 else jump to routine06 ???
Prev: 9167 Up: Map Next: 92AA