Routines |
Prev: E46C | Up: Map | Next: E58C |
See Trivia: Maroc's rank for information about how this is determined.
|
||||
E4E7 | CALL $DEF9 | Clear the scroll status panel at the bottom of the screen | ||
E4EA | LD A,$22 | Message number 34 (message texts start from 7172) - #34 is the "YOUR RANK IS NOW" text at 72E8. | ||
E4EC | CALL $E5A5 | Identify address pointer for message text | ||
E4EF | LD ($EAA1),HL | ...and store | ||
E4F2 | LD HL,$5068 | Set the screen display address pointer for top left of scroll, one character line down | ||
E4F5 | LD ($EAA4),HL | ..and store. | ||
E4F8 | CALL $E2D0 | Print the message text on the scroll | ||
GET MAROC'S RANK
This next routine looks through the spells and checks which ones have been collected (first byte of the spell data = 16).
For each spell collected, the C register is incremented by 3, so it looks as if this will play a part in increasing Maroc's rank.
HOWEVER, the routine after this resets the C register to 0 at E51B before it's stored anywhere, so will effectively nullify any increments calculated here. So collecting spells doesn't have an effect on Maroc's rank after all.
|
||||
E4FB | LD DE,$0010 | |||
E4FE | LD HL,($EB65) | Address pointer to start of message texts at 6DFC, starting with spell names | ||
E501 | LD A,($EB69) | Number of spells (27) | ||
E504 | LD B,A | Store in B register as a counter | ||
E505 | LD C,$00 | C seems to be a counter for spells collected | ||
E507 | LD A,$10 | Check if Maroc has collected this spell | ||
E509 | CP (HL) | |||
E50A | JR NZ,$E50F | |||
E50C | INC C | If so, increment score by 3 | ||
E50D | INC C | |||
E50E | INC C | |||
E50F | ADD HL,DE | Move onto the next spell | ||
E510 | DJNZ $E509 | Check for all 27 spells | ||
ADD RANK SCORE FOR WARLOCKS DESTROYED
Maroc can gain rank points by destroying any/all of the 7 warlocks, which appear on walls on various game levels. Warlock attributes are stored at 6C7C.
Score for destroying a warlock is warlock number * 4. So warlock #1 is worth 4, warlock #7 is worth 28.
|
||||
E512 | LD HL,($EBC3) | Address pointer to warlock information at 6C7C | ||
E515 | INC HL | If the second byte in each warlock's data set >0, it means Maroc has destroyed this warlock. | ||
E516 | LD DE,$0008 | 8 bytes for each set of warlock data | ||
E519 | LD B,$07 | 7 warlocks to check | ||
E51B | LD C,$00 | The C register will contain the total score | ||
E51D | LD A,(HL) | Get byte | ||
E51E | ADD HL,DE | (Move pointer to the next warlock data set ready for next check) | ||
E51F | CP $00 | Check if it's 0 | ||
E521 | JR Z,$E52A | If so, this warlock has not been destroyed. Continue to the next one. | ||
E523 | LD A,$08 | If the warlock has been destroyed, calculate which of the warlocks it is by starting with 8... | ||
E525 | SUB B | ...and subtracting the (reversed) warlock number (1-7) | ||
E526 | ADD A,A | A now contains the warlock number that has been destroyed (1-7). Multiply this by 4 | ||
E527 | ADD A,A | |||
E528 | ADD A,C | ...and add it to the total score. | ||
E529 | LD C,A | |||
E52A | DJNZ $E51D | Continue to check all 7 warlocks, adding score for each one that has been destroyed | ||
ADD RANK SCORE BASED ON OTHER CREATURES DESTROYED
Maroc's ranks points are increased by 1 for every 2 creatures destroyed (creature data at 6CB4)
Rank points are halved in the final calculation, meaning Maroc's rank will increase by 1 for every 4 creatures he destroys.
|
||||
E52C | LD B,$04 | 4 types of creature to check | ||
E52E | LD A,(HL) | Get (2nd) byte of set, which indicates number of creatures destroyed | ||
E52F | ADD HL,DE | (Move pointer to the next creature set ready for next check) | ||
E530 | SRA A | Halve the score value | ||
E532 | ADD A,C | ...and add it to the score | ||
E533 | LD C,A | |||
E534 | DJNZ $E52E | Continue to check the 4 types of creature, adding score for numbers destroyed | ||
ADD RANK SCORE BASED ON DEMONS DESTROYED
Maroc receives 32 points at the point he destroys his first (but not every) demon in the High Temple of Chaos.
The reason for this score being is a one-off increment is because unlike other creatures, demons respawn indefinitely.
|
||||
E536 | LD A,(HL) | Get (2nd) byte of set | ||
E537 | CP $00 | |||
E539 | JR Z,$E53F | If zero, nothing to add | ||
E53B | LD A,$20 | Otherwise, add a (set) score of 32 | ||
E53D | ADD A,C | |||
E53E | LD C,A | |||
The next check looks at Maroc's dungeon level, when he ran out of energy (or finishes the game). The second paired byte in the table at C6A4 is doubled, then added to the rank/score.
Using 'current' level vs 'achieved' level means Maroc receives a higher rank for running out of energy on deeper levels (e.g. by casting the SUMMON spell), but will lose ranks if he dies on the Gatehouse level, for instance.
The score is added to using paired byte x 2 (e.g. running out of energy in the Chambers of Chaos is worth 8 x 2 = 16 points)
|
||||
E53F | LD A,($EAC9) | Byte relating to level number in reference table at C6A4 | ||
E542 | ADD A,A | Double it | ||
E543 | ADD A,C | ...and add to the score | ||
E544 | LD C,A | |||
Now a rank demotion. The byte at EAC8 counts how many times Maroc has died (i.e. run out of energy).
His score is reduced by 1 for every 4 occurences of this (score reduction = byte value / 4).
|
||||
E545 | LD A,($EAC8) | Get Maroc's current 'death count' | ||
E548 | INC A | ...and increase by 1 | ||
E549 | JR C,$E54E | Avoid re-storing the increased amount if it would mean a wrap around to 0 (if Maroc has already died 255 times!) | ||
E54B | LD ($EAC8),A | Re-store | ||
E54E | RRA | Divide by 4 | ||
E54F | RRA | |||
E550 | AND $3F | Filter out any unnecesary carry bits caused by the RRAs | ||
E552 | LD B,A | Subtract value from calculated rank score | ||
E553 | LD A,C | |||
E554 | SUB B | |||
E555 | JR NC,$E559 | |||
E557 | LD A,$00 | If this subtraction brings down the total rank to less than 0, set it at 0 (APPRENTICE LORE SEEKER). | ||
Halve the score before using it to calculate the rank:
|
||||
E559 | RRA | Halve the score value | ||
E55A | LD C,A | And store in the C register | ||
Use the calculated score to identify Maroc's rank:
|
||||
E55B | RRA | Divide the already-halved-score by 8 to move the score into the lowest 4 bits of the byte | ||
E55C | RRA | |||
E55D | RRA | |||
E55E | AND $0F | Keep bits 0-3 (values 0-15) - this gives 16 options, which relate to the 16 titles | ||
E560 | ADD A,$12 | The rank title texts start at 7250, which is message #18 from the start of the message texts (BF92), so add this. | ||
E562 | LD ($EAC7),A | Store this value | ||
Calculate and print the 'descriptor' part of the rank text (one of the 8 texts at 7216).
|
||||
E565 | LD A,C | Retrieve the original score (halved so will be in the range 0-127) | ||
E566 | AND $07 | Keep bits 0-2 (values 0-7) - this gives 8 options, which relate to the 8 descriptors | ||
E568 | ADD A,$0A | The rank descriptor texts start at 7216, which is message #10 from the start of the message texts (7172), so add this. | ||
E56A | CALL $E5A5 | Identify the address pointer for the descriptor text | ||
E56D | LD ($EAA1),HL | ...and store. | ||
E570 | LD HL,$50A8 | Screen display address to the start of where the descriptor text will be printed on the scroll | ||
E573 | LD ($EAA4),HL | ...and store | ||
E576 | CALL $E2D0 | Print the text on the scroll | ||
Print the 'title' part of the rank text (one of the 16 texts at 7250):
|
||||
E579 | LD A,($EAC7) | Retrieve the calculated text message number | ||
E57C | CALL $E5A5 | Identify the address pointer for the text to print | ||
E57F | LD ($EAA1),HL | ...and store. | ||
E582 | LD HL,$50C8 | Screen display address to the start of where the descriptor text will be printed on the scroll, just below where the descriptor was printed | ||
E585 | LD ($EAA4),HL | |||
E588 | CALL $E2D0 | Print the text on the scroll | ||
E58B | RET |
Prev: E46C | Up: Map | Next: E58C |