Prev: 9384 Up: Map Next: 94A7
9385: Display list of possessed spells.
Used by the routine at CAST_S.
select_spell 9385 LD HL,sound_effect_23 Play sound_effect_23 and clear the screen.
9388 CALL play_sound_effect_in_HL
938B CALL CLS Set ATTR-T to bright yellow on black.
938E LD A,$46
9390 LD ($5C8F),A
9393 LD A,(current_player) Print current player name at coordinates (0,0).
9396 ADD A,$29
9398 LD BC,$0000
939B CALL MPRINT
939E LD A,$53 Print s_spells_string.
93A0 CALL MPRINT
93A3 LD B,$14 Set B to 20 as loop counter.
93A5 LD A,$40 Set spell_letter to '@'. This is incremented to 'A' before printing in the first iteration of the loop.
93A7 LD (spell_letter),A
93AA LD HL,$0010 Set temp_coordinates to coordinates (0,16).
93AD LD (temp_coordinates),HL
93B0 LD HL,(HISPEL) Copy HISPEL to temp_spell_pointer.
93B3 LD (temp_spell_pointer),HL
spells_loop 93B6 PUSH BC Preserve loop counter.
93B7 LD HL,(temp_spell_pointer) Load spell number from address in temp_spell_pointer.
93BA LD A,(HL)
93BB OR A If spell number is zero jump to skip_spell.
93BC JR Z,skip_spell
93BE LD A,(temp_coordinates) Else load the column value from temp_coordinates.
93C1 LD C,A
93C2 LD A,$10 Subtract value from 16 and store back in temp_coordinates. This causes the value to toggle between 0 and 16.
93C4 SUB C
93C5 LD (temp_coordinates),A
93C8 OR A If the new column value is zero, add 2 to row value of temp_coordinates.
93C9 JR NZ,skip_new_row
93CB LD A,($937D)
93CE ADD A,$02
93D0 LD ($937D),A
skip_new_row 93D3 LD HL,(temp_spell_pointer) Copy spell number from address in temp_spell_pointer into CURSP.
93D6 LD A,(HL)
93D7 LD (CURSP),A
93DA CALL CHAN_C Call CHAN_C to get casting chance of spell between 0 and 9 which also sets current_spell_pointer.
93DD LD A,(casting_chance)
93E0 INC A Add 1 and divide by 2, giving a value between 0 and 5.
93E1 SRL A
93E3 ADD A,$42 Add $42 to give a bright colour between red and white with black background.
93E5 LD ($5C8F),A Store in ATTR-T.
93E8 LD A,(spell_letter) Increment spell_letter.
93EB INC A
93EC LD (spell_letter),A
93EF LD BC,(temp_coordinates) Load temp_coordinates into BC.
93F3 PUSH BC Print spell letter.
93F4 CALL DH_P
93F7 POP BC
93F8 INC C Increment column.
93F9 LD A,(spell_chaos_law) If spell_chaos_law is zero (neutral) set A to '-'.
93FC OR A
93FD JR NZ,spell_not_neutral
93FF LD A,$2D
9401 JR print_symbol
spell_not_neutral 9403 JP P,spell_not_chaotic Else if negative (chaos) set A to '*'.
9406 LD A,$2A
9408 JR print_symbol
spell_not_chaotic 940A LD A,$5E Else positive (law) set A to '↑'.
print_symbol 940C PUSH BC Print the symbol.
940D CALL DH_P
9410 POP BC
9411 INC C Print name of current spell.
9412 LD HL,(current_spell_pointer)
9415 LD A,(HL)
9416 CALL MPRINT
skip_spell 9419 LD HL,(temp_spell_pointer) Move temp_spell_pointer forward to next entry in possesssed_spell_tables.
941C INC HL
941D INC HL
941E LD (temp_spell_pointer),HL
9421 POP BC Restore loop counter.
9422 DJNZ spells_loop Jump back to spells_loop for 20 iterations.
9424 LD BC,$1600 Set coordinates to (0,22)
9427 LD A,$46 Set ATTR-T to bright yellow on black.
9429 LD ($5C8F),A
942C LD A,$58
942E CALL MPRINT Print press_0_to_return_string and wait for no key to be pressed.
9431 CALL wait_no_key_seed
get_spell_key 9434 CALL $02BF Call KEYBOARD in ROM.
9437 CP $30 If '0' is pressed return.
9439 JR NZ,not_0
943B RET
not_0 943C LD HL,spell_letter Decrement key code and compare with last spell letter.
943F DEC A
9440 CP (HL)
9441 JP P,get_spell_key If greater than last spell ignore keypress and loop back to get_spell_key.
9444 SUB $3F If key code is less than '?' ignore keypress and loop back to get_spell_key.
9446 JP M,get_spell_key
9449 LD B,A Else copy choice to B as loop counter.
944A LD HL,(HISPEL) Load HISPEL pointer into HL.
944D LD DE,$0002 Set DE to 2.
9450 AND A Clear carry flag and subtract 2 to compensate for addition in first iteration of loop.
9451 SBC HL,DE
find_spell_loop 9453 ADD HL,DE Add 2 to address.
9454 LD A,(HL) Load the spell number.
9455 OR A
9456 JR Z,find_spell_loop If spell number at address is zero loop back to find_spell_loop.
9458 DJNZ find_spell_loop Loop the number of iterations selected by the keypress.
945A LD (CURSP),A A now holds the spell number for the selected spell, store in CURSP.
945D LD A,(cast_spell_flag) If cast_spell_flag is set jump to cast_spell.
9460 OR A
9461 JR NZ,cast_spell
9463 CALL display_spell_info Else Display information about the selected spell.
9466 JP select_spell On return jump back to select_spell.
cast_spell 9469 LD A,(current_player) Set HL to address of current player's spell in cast_table.
946C LD D,$00
946E LD E,A
946F LD HL,cast_table
9472 ADD HL,DE
9473 LD A,(CURSP) Store CURSP in casting table.
9476 LD (HL),A
9477 CP $02 If spell number is less than 2 or greater than 33 return.
9479 RET M
947A CP $22
947C RET P
947D CALL clear_bottom_row Else clear bottom row and set ATTR-T to $47 (bright white on black).
9480 LD A,$47
9482 LD ($5C8F),A
9485 LD A,$5E Print illusion_string at coordinates (0,22).
9487 LD BC,$1600
948A CALL MPRINT
948D CALL wait_no_key_seed Wait for no key to be pressed.
get_illusion_key 9490 CALL $02BF Call KEYBOARD in ROM.
9493 CP $4E If key code is 'N' return.
9495 RET Z
9496 CP $59 If key code is not 'Y' loop back and get another keypress.
9498 JR NZ,get_illusion_key
949A LD HL,illusion_table Else set HL to address of current player's spell in illusion_table.
949D LD D,$00
949F LD A,(current_player)
94A2 LD E,A
94A3 ADD HL,DE
94A4 LD (HL),$01 Set illusion flag and return.
94A6 RET
Prev: 9384 Up: Map Next: 94A7