Prev: 27464 Up: Map Next: 27606
27509: Draw the current maze
Used by the routine at 24576.
Input
BC 768
DE 16384
HL Address of the maze layout data (28663, 29431, 30199 or 30967)
27509 PUSH BC Save the tile counter.
27510 PUSH HL Save the maze layout data address.
27511 EX DE,HL Transfer the display file address to HL.
27512 CALL 27663 Set HL' to the corresponding attribute file address (always 22528).
27515 EX DE,HL Transfer the display file address back to DE.
27516 EXX Exchange registers.
27517 POP DE Restore the maze layout data address to DE'.
27518 POP BC Restore the tile counter to BC'.
27519 LD A,(DE) Pick up a tile identifier.
27520 INC DE Point DE' at the next tile identifier.
27521 CP 0 Is the current tile blank?
27523 JR Z,27549 Jump if so.
27525 CP 2 Is the current tile a flower?
27527 JR Z,27553 Jump if so.
27529 CP 3 Is the current tile an arrow (entrance or exit)?
27531 JR Z,27541 Jump if so.
27533 CP 9 Is the current tile a tunnel entrance?
27535 JR Z,27545 Jump if so.
27537 LD A,61 Wall tile (INK 5).
27539 JR 27555
27541 LD A,56 Arrow tile (INK 0).
27543 JR 27555
27545 LD A,63 Tunnel entrance (INK 7).
27547 JR 27555
27549 LD A,62 Blank tile (INK 6).
27551 JR 27555
27553 LD A,60 Flower (INK 4).
27555 LD (HL),A Set the attribute byte.
27556 INC HL Move HL' along the attribute file.
27557 DEC BC Decrement the tile counter.
27558 LD A,B Have we finished setting the attribute bytes yet?
27559 OR C
27560 JR NZ,27519 Jump back if not.
27562 EXX Exchange registers.
The attribute bytes have been set. Time to draw the maze tiles.
27563 PUSH HL Save the maze layout pointer.
27564 LD A,(HL) Pick up a tile identifier in A.
27565 LD H,0 Point IX at the graphic data for the corresponding tile (at 31735+8*A).
27567 LD L,A
27568 ADD HL,HL
27569 ADD HL,HL
27570 ADD HL,HL
27571 LD IX,31735
27575 EX DE,HL
27576 ADD IX,DE
27578 EX DE,HL
27579 LD L,8 Draw the tile.
27581 LD A,(IX+0)
27584 LD (DE),A
27585 INC D
27586 INC IX
27588 DEC L
27589 JR NZ,27581
27591 INC E Point DE at the display file address for the next tile.
27592 JR Z,27598
27594 LD A,D
27595 SUB 8
27597 LD D,A
27598 POP HL Restore the maze layout pointer to HL.
27599 INC HL Move along to the next maze tile identifier.
27600 DEC BC Decrement the tile counter.
27601 LD A,B Have we drawn all the tiles yet?
27602 OR C
27603 JR NZ,27563 Jump back if not.
27605 RET
Prev: 27464 Up: Map Next: 27606