Prev: E3FD Up: Map Next: E4E7
E46C: Animation routine for when Maroc is out of energy
Routine called from DA4D when Maroc is out of energy. He spins towards the top of the screen, with a decreasing pitch sound.
Maroc animation when drained of energy
E46C LD A,($EAC1) Maroc's vertical (Y-axis) screen position, in pixels
E46F LD ($EAD2),A Copy into data buffer
E472 LD HL,($EAC2) Maroc's sprite address pointer in table at 97C3
E475 LD ($EACD),HL Copy into data buffer
E478 LD A,($EAC0) Get Maroc's horizontal (X-axis) screen position, in half character (4-pixel) steps
E47B RLA Multiply by 4 to convert to horizontal pixel position
E47C RLA
E47D AND $FC Filter out any carry bits that may have appeared from the SLA
E47F LD ($EAD3),A ...and store horizontal pixel position in data buffer
E482 LD A,$00 Set high byte of horizontal graphic position to indicate that it's within the current screen (viewport) rather than to the left (255) or right (1)
E484 LD ($EAD4),A
Play sound:
E487 LD A,($EAD2) Get vertical graphic (pixel) position
E48A NEG The sound pitch/speed is based on Maroc's vertical position as he spins upwards, so would naturally increase in pitch. By using NEG this decreases the pitch instead, as Maroc ascends.
E48C SRA A Halve the value to reduce the pitch change slightly
E48E LD C,A Store in C register as a loop counter
E48F LD E,$40
E491 LD A,$00 Start loop with speaker off
E493 XOR $10 Toggle the speaker bit
E495 OUT ($FE),A Play sound
E497 LD B,C Inner loop - short pause
E498 DJNZ $E498
E49A DEC E Outer loop - short pause
E49B JR NZ,$E493
Erase Maroc's graphic:
E49D LD A,$00 Set draw/erase flag to ERASE
E49F LD ($EACF),A
E4A2 LD HL,($EACD) Get graphic address pointer
E4A5 CALL $DB98 Erase Maroc's sprite
Rotate Maroc's sprite clockwise
E4A8 LD A,($EB03) Rotation value - for 8 different directions, in increments of 32
E4AB ADD A,$20 Rotate Maroc's sprite clockwise one graphics frame
E4AD LD ($EB03),A Re-store new graphics frame
E4B0 RRA Rotate rotation bits into bits 1-3
E4B1 RRA
E4B2 RRA
E4B3 RRA
E4B4 AND $0E ...and filter out other unwanted bits caused by the rotate. Value is now an even number and in the range 0-14.
E4B6 LD E,A This corresponds to Maroc's frame (0-7) x 2. Transfer this offset to DE
E4B7 LD D,$00
E4B9 LD HL,($EB6A) Get sprite graphic address pointer
E4BC ADD HL,DE Add the offset, which now points to Maroc's new frame (from 97C3)
E4BD LD ($EACD),HL ...and store as address pointer in graphic data buffer.
The following code sets Maroc's attribute colours. Maroc's INK attribute colour is supposed to change as he spins upwards.
However, the attribute print routine at E220 references the byte at EAC1 for Maroc's normal vertical screen position, rather than the one at EAA7, which changes as Maroc ascends.
This means that the colour change/rotation is only applied at Maroc's base screen position, so once he starts rising he retains the standard screen colour. You can see this in the animated image at the top of this page.
E4C0 LD A,($EAA7) Get Maroc's attribute colour (usually 71 - bright white)
E4C3 DEC A Decrement (Maroc is supposed to change colour as he rises)
E4C4 AND $07 Only need INK colour so filter out PAPER, BRIGHT and FLASH bits
E4C6 LD ($EAA7),A ...and store.
E4C9 LD A,($EAD2) Get Maroc's vertical position (in pixels)
E4CC SUB $04 Reduce by 4 (Maroc moves upwards in half character squares)
E4CE LD ($EAD2),A
E4D1 CALL $E220 Set/change Maroc's attributes (INK colour)
Draw Maroc at his new screen position:
E4D4 LD A,$01 Set draw/erase flag to DRAW
E4D6 LD ($EACF),A
E4D9 LD HL,($EACD) Get sprite graphics address pointer
E4DC CALL $DB98 Draw Maroc sprite
E4DF LD A,($EAD5) Flag indicating whether (any part of) graphic is visible on screen
E4E2 CP $00 Check if Maroc has disappeared off the top of the screen
E4E4 JR NZ,$E487 If not, continue to spin him upwards and play sound.
E4E6 RET
Prev: E3FD Up: Map Next: E4E7