Routines |
Prev: 57081 | Up: Map | Next: 57276 |
Checks each spell in the spell index at 28156, to see if Maroc has it.
For each spell found (up to 5), prints the spell name text on the scroll, and plays a short sound effect.
|
||||
57139 | LD A,(60130) | Spell list index | ||
57142 | LD (60133),A | Copy spell list index into spell list counter | ||
57145 | LD DE,(60131) | Address pointer to the start of spell list text at 28156 | ||
57149 | LD A,1 | Scroll text line counter (1-5) | ||
57151 | LD (60103),A | |||
57154 | LD HL,20554 | Screen address of top text line of scroll, 3 characters from the left hand side | ||
57157 | LD (60126),HL | Put screen display address in temp store for retrieving later | ||
57160 | LD B,8 | Move address pointer along 8 bytes to get to the first/next spell text (e.g. "MOVE" at 28164) | ||
57162 | INC DE | |||
57163 | DJNZ 57162 | |||
57165 | LD (60065),DE | Store spell text address pointer | ||
57169 | LD (60068),HL | Store the screen display address | ||
57172 | LD A,8 | Store length of text string to print - spell texts at 28156 are padded with spaces to make them all 8 characters long | ||
57174 | LD (60067),A | |||
57177 | CALL 58080 | Print the spell text on the scroll | ||
57180 | LD HL,(60065) | Retrieve the spell text address pointer - this is now pointing at the data after the spell text, e.g. 28172. | ||
This section runs through each spell and checks to see if the player has collected it. If so, the text can be printed on the scroll.
Five spells are always displayed on the scroll in a wraparound vertical scrolling list. If the player has fewer than five spells, one or more will show at least once.
At the start of the game the player only has the 'MOVE' spell, so this appears five times.
|
||||
57183 | LD A,(60265) | Total number of spells to check - 27 | ||
57186 | LD C,A | |||
57187 | LD A,(60133) | Spell list counter | ||
57190 | CP C | Check if at the end (spell #27) | ||
57191 | JR NZ,57200 | |||
57193 | LD A,0 | If so, reset counter to zero... | ||
57195 | LD HL,(60261) | ...and return the spell name text address pointer to the start of the list, e.g. 28156. | ||
57198 | JR 57201 | |||
57200 | INC A | If we're not at the end of the list, increment the spell list counter. | ||
57201 | LD (60133),A | |||
57204 | LD A,(HL) | Get the the first byte (after the spell name). | ||
57205 | CP 16 | Check if this byte = 16, which indicates the player has collected the spell | ||
57207 | JR Z,57215 | If so, jump out and print the spell name | ||
57209 | LD BC,16 | The player hasn't collected this spell, so move the spell text address pointer along 16 bytes to the next spell and repeat the checking loop. | ||
57212 | ADD HL,BC | |||
57213 | JR 57183 | |||
Spell name to print found (Maroc has this spell).
First, play a short sound as the player scrolls through the spell list:
|
||||
57215 | OUT (254),A | The 'A' register is 16 from previous routine (bit 4 is set), so it's used here to switch the speaker on | ||
57217 | LD A,(60070) | Counter (initialized at 5) which is used to determine an incremental series of 5 tones, while the player holds down a key to scroll through the spell list | ||
57220 | CP 0 | Counter = 0? | ||
57222 | JR Z,57237 | If so, skip next routine (this keeps the tone at its highest pitch) | ||
57224 | RLA | Take counter and x 2 | ||
57225 | RLA | 5 rotates to shift bits 0-2 of the counter into bits 5-7 | ||
57226 | RLA | |||
57227 | RLA | |||
57228 | RLA | |||
57229 | AND 224 | Filter out unwanted bits 0-4 | ||
57231 | LD B,A | Store in B to act as a second counter | ||
57232 | CALL 56070 | Routine that generates a pseudo-random number. | ||
57235 | DJNZ 57232 | ...The output from the CALLed routine isn't used, it's just called multiple times to provide a handy short delay for the speaker toggle effect/sound. | ||
Spell text line print checks
|
||||
57237 | LD A,(60103) | Continue to check the spell index (at 28156) to see which spells Maroc has, and print them on the scroll | ||
57240 | CP 5 | 5 spells can be printed on the scroll. Have they all been done? | ||
57242 | JR Z,57275 | If so, jump straight to RET at the end of this routine | ||
57244 | INC A | Otherwise, increment the scroll text line counter | ||
57245 | LD (60103),A | ...and re-store. | ||
57248 | CP 3 | Are we on spell text line number 3? | ||
57250 | JR NZ,57261 | |||
57252 | LD A,(60133) | If so, this is the spell in the middle of the scroll, that the selection arrow is pointing at | ||
57255 | LD (60134),A | So set the 'currently highlighted' spell as this one | ||
57258 | LD (60135),HL | ...and also store the address pointer to this spell's data (28156). | ||
Prep for printing next line of text:
|
||||
57261 | EX DE,HL | Put the current spell index list address pointer into the DE register, ready for checking/printing any other spells the Maroc might have (from 57157) | ||
57262 | LD HL,(60126) | Retrieve the screen display address | ||
57265 | LD BC,288 | Move the screen display address down 9 pixels ready for the next line of spell text. 288 is 256 (one pixel line down) plus 32 (8 pixel lines down). | ||
57268 | ADD HL,BC | |||
57269 | LD A,0 | Toggle speaker (bit 4) off | ||
57271 | OUT (254),A | |||
57273 | JR 57157 | Keep checking for spells to print | ||
57275 | RET | RETurn after 5 spells printed |
Prev: 57081 | Up: Map | Next: 57276 |