Routines |
Prev: 58365 | Up: Map | Next: 58599 |
Routine called from 55885 when Maroc is out of energy. He spins towards the top of the screen, with a decreasing pitch sound.
|
||||
|
||||
58476 | LD A,(60097) | Maroc's vertical (Y-axis) screen position, in pixels | ||
58479 | LD (60114),A | Copy into data buffer | ||
58482 | LD HL,(60098) | Maroc's sprite address pointer in table at 38851 | ||
58485 | LD (60109),HL | Copy into data buffer | ||
58488 | LD A,(60096) | Get Maroc's horizontal (X-axis) screen position, in half character (4-pixel) steps | ||
58491 | RLA | Multiply by 4 to convert to horizontal pixel position | ||
58492 | RLA | |||
58493 | AND 252 | Filter out any carry bits that may have appeared from the SLA | ||
58495 | LD (60115),A | ...and store horizontal pixel position in data buffer | ||
58498 | LD A,0 | 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) | ||
58500 | LD (60116),A | |||
Play sound:
|
||||
58503 | LD A,(60114) | Get vertical graphic (pixel) position | ||
58506 | 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. | ||
58508 | SRA A | Halve the value to reduce the pitch change slightly | ||
58510 | LD C,A | Store in C register as a loop counter | ||
58511 | LD E,64 | |||
58513 | LD A,0 | Start loop with speaker off | ||
58515 | XOR 16 | Toggle the speaker bit | ||
58517 | OUT (254),A | Play sound | ||
58519 | LD B,C | Inner loop - short pause | ||
58520 | DJNZ 58520 | |||
58522 | DEC E | Outer loop - short pause | ||
58523 | JR NZ,58515 | |||
Erase Maroc's graphic:
|
||||
58525 | LD A,0 | Set draw/erase flag to ERASE | ||
58527 | LD (60111),A | |||
58530 | LD HL,(60109) | Get graphic address pointer | ||
58533 | CALL 56216 | Erase Maroc's sprite | ||
Rotate Maroc's sprite clockwise
|
||||
58536 | LD A,(60163) | Rotation value - for 8 different directions, in increments of 32 | ||
58539 | ADD A,32 | Rotate Maroc's sprite clockwise one graphics frame | ||
58541 | LD (60163),A | Re-store new graphics frame | ||
58544 | RRA | Rotate rotation bits into bits 1-3 | ||
58545 | RRA | |||
58546 | RRA | |||
58547 | RRA | |||
58548 | AND 14 | ...and filter out other unwanted bits caused by the rotate. Value is now an even number and in the range 0-14. | ||
58550 | LD E,A | This corresponds to Maroc's frame (0-7) x 2. Transfer this offset to DE | ||
58551 | LD D,0 | |||
58553 | LD HL,(60266) | Get sprite graphic address pointer | ||
58556 | ADD HL,DE | Add the offset, which now points to Maroc's new frame (from 38851) | ||
58557 | LD (60109),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 57888 references the byte at 60097 for Maroc's normal vertical screen position, rather than the one at 60071, 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.
|
||||
58560 | LD A,(60071) | Get Maroc's attribute colour (usually 71 - bright white) | ||
58563 | DEC A | Decrement (Maroc is supposed to change colour as he rises) | ||
58564 | AND 7 | Only need INK colour so filter out PAPER, BRIGHT and FLASH bits | ||
58566 | LD (60071),A | ...and store. | ||
58569 | LD A,(60114) | Get Maroc's vertical position (in pixels) | ||
58572 | SUB 4 | Reduce by 4 (Maroc moves upwards in half character squares) | ||
58574 | LD (60114),A | |||
58577 | CALL 57888 | Set/change Maroc's attributes (INK colour) | ||
Draw Maroc at his new screen position:
|
||||
58580 | LD A,1 | Set draw/erase flag to DRAW | ||
58582 | LD (60111),A | |||
58585 | LD HL,(60109) | Get sprite graphics address pointer | ||
58588 | CALL 56216 | Draw Maroc sprite | ||
58591 | LD A,(60117) | Flag indicating whether (any part of) graphic is visible on screen | ||
58594 | CP 0 | Check if Maroc has disappeared off the top of the screen | ||
58596 | JR NZ,58503 | If not, continue to spin him upwards and play sound. | ||
58598 | RET |
Prev: 58365 | Up: Map | Next: 58599 |