Prev: 58945 Up: Map Next: 59130
59033: UP/DOWN controls pressed while in spell menu
Used by the routine at 58945.
This routine cycles through the spell list at 28156, printing any spells that have been collected.
If the first byte of a spell's data set is 16, it means the spell has been collected and is available for display/selection.
scrolling through spells
Check whether it's up or down that's been pressed:
59033 LD C,A Temp store for up/down flag: 1 = up, -1 (255) = down
59034 LD A,(60070) Retrieve the counter flag set in the previous routine, used to create the incremental pitch sound effects as the player scrolls through the spells
59037 CP 0 Skip next two instructions if zero (reached max pitch)
59039 JR Z,59045
59041 DEC A Otherwise decrement...
59042 LD (60070),A ...and re-store.
59045 LD A,C Retrieve the up/down flag value from C register
59046 CP 1 Check if UP pressed. If not, run the following routine for DOWN.
59048 JR Z,59089
DOWN pressed while in spell menu:
59050 LD A,(60130) Spell counter (up to 27 spells) for current spell
59053 LD HL,(60131) Address pointer for the current position in the spell list (spells at 28156)
59056 LD DE,65520
59059 CP 0 If we don't currently have a counter position (byte at 60130 is zero), then start at the end of the spell list ready to move up it
59061 JR NZ,59070
59063 LD HL,(60263) Address pointer for the end of the spell list texts at 28604
59066 LD A,(60265) Total number of spells (27)
59069 INC A Incremented ready for decrement at the start of the following loop
59070 ADD HL,DE Subtracts 16 from HL - first check is the data set for the last spell (MESSAGE) at 28588
59071 DEC A Decrement spell number counter (starts at 27)
59072 LD C,A Store temporarily
59073 LD A,(HL) Get 'spell collected' data byte
59074 CP 16 Has the spell been collected (byte value = 16)?
59076 LD A,C (Retrieve spell number counter)
59077 JR NZ,59059 If it hasn't been collected, keep checking the rest of the spells
59079 LD (60130),A Spell is available, so store the spell counter...
59082 LD (60131),HL ...and the spell list address pointer
59085 CALL 57139 Print the spell names on the scroll
59088 RET
UP pressed while in spell menu:
59089 LD A,(60130) Spell counter (up to 27 spells) for current spell
59092 LD C,A
59093 LD HL,(60131) Address pointer for the current position in the spell list (spells at 28156)
59096 LD DE,16 Offset for the spell address pointer to move down to the next spell
59099 LD A,(60265) Total number of spells
59102 CP C Check if we've reached the end of the list...
59103 JR NZ,59112
59105 LD HL,(60261) ...If so, switch to the start of the spell list
59108 LD C,0 ...and set the spell counter to zero
59110 JR 59114
59112 ADD HL,DE Move down to next spell
59113 INC C Increment the spell counter
59114 LD A,(HL) Get 'spell collected' data byte
59115 CP 16 Has the spell been collected (byte value = 16)?
59117 JR NZ,59099 If it hasn't been collected, keep checking the rest of the spells
59119 LD A,C Spell is available, so store the spell counter...
59120 LD (60130),A
59123 LD (60131),HL ...and the spell list address pointer
59126 CALL 57139 Print the spell names on the scroll
59129 RET
Prev: 58945 Up: Map Next: 59130