![]() |
Routines |
| Prev: C497 | Up: Map | Next: C54B |
|
Used by the routines at DrawScenery and DrawStrip.
Draws an image which is sixteen pixels wide into PlayfieldBuffer, combining it with what is already there. The image starts with a byte for the number of rows, followed by two bytes for each row. It is drawn from the bottom row up, and is cut off at the bottom and top of the buffer. The position is in ScreenHorizontalPosition and the image is moved to the right by 00, 02, 04 or 06 pixels, using ShiftTables and ReversedShiftTables. The image is flipped if FlipFlag is not zero.
|
||||||||||||
|
Clip the image to the buffer.
|
||||||||||||
| DrawStripGraphic | C4A7 | LD A,D | Subtract 48 from the vertical position. | |||||||||
| C4A8 | SUB $48 | |||||||||||
| C4AA | JR C,ClipEdgeStripTop | Jump to ClipEdgeStripTop if it is below the bottom. | ||||||||||
| C4AC | SUB $70 | Subtract 70. | ||||||||||
| C4AE | RET NC | Return if it is above the top. | ||||||||||
| C4AF | NEG | Make it the number of rows in the buffer. | ||||||||||
| C4B1 | CP (HL) | Jump to DrawStripGraphic_FirstRow if it is fewer. | ||||||||||
| C4B2 | JR C,DrawStripGraphic_FirstRow | |||||||||||
| C4B4 | LD A,(HL) | Use the height of the image. | ||||||||||
|
Draw the rows that are in the buffer.
|
||||||||||||
| DrawStripGraphic_FirstRow | C4B5 | INC HL | Move on to the first row of the image. | |||||||||
|
This entry point is used by the routine at ClipEdgeStripTop.
|
||||||||||||
| DrawStripGraphic_Draw | C4B6 | EX AF,AF' | Keep the number of rows in A'. | |||||||||
| C4B7 | EX DE,HL | Put the position in HL. | ||||||||||
| C4B8 | CALL CalculateBufferAddress | Call CalculateBufferAddress. | ||||||||||
| C4BB | EX DE,HL | Switch the buffer and the image. | ||||||||||
| C4BC | LD ($A21D),SP | Set SavedStackPointer. | ||||||||||
| C4C0 | LD SP,HL | Point the stack at the image. | ||||||||||
|
Choose the draw path.
|
||||||||||||
| C4C1 | LD A,($A24E) | Fetch ScreenHorizontalPosition. | ||||||||||
| C4C4 | AND %00000110 | Keep bits 1 and 2. | ||||||||||
| C4C6 | JR Z,DrawStripGraphic_Aligned | Jump to DrawStripGraphic_Aligned if the image is aligned. | ||||||||||
| C4C8 | OR %11110000 | Set the high bits of the page. | ||||||||||
| C4CA | LD H,A | Set H. | ||||||||||
| C4CB | LD A,($A252) | Fetch FlipFlag. | ||||||||||
| C4CE | AND A | Jump to DrawStripGraphic_MirroredShifted if it is set. | ||||||||||
| C4CF | JR NZ,DrawStripGraphic_MirroredShifted | |||||||||||
| C4D1 | SET 3,H | Set bit 3 of H. | ||||||||||
| C4D3 | EX AF,AF' | Switch in the number of rows. | ||||||||||
|
Draw a shifted row.
|
||||||||||||
| DrawStripGraphic_Shifted | C4D4 | EX AF,AF' | Keep the number of rows in A'. | |||||||||
| C4D5 | POP BC | Fetch a row and point at the first byte. | ||||||||||
| C4D6 | LD L,C | |||||||||||
| C4D7 | LD A,(DE) | Combine the bits which stay with the first byte of the buffer. | ||||||||||
| C4D8 | OR (HL) | |||||||||||
| C4D9 | LD (DE),A | |||||||||||
| C4DA | INC DE | Move on to the next byte and page. | ||||||||||
| C4DB | INC H | |||||||||||
| C4DC | LD A,(DE) | Combine the bits which moved on from the first byte. | ||||||||||
| C4DD | OR (HL) | |||||||||||
| C4DE | DEC H | Point at the second byte of the image. | ||||||||||
| C4DF | LD L,B | |||||||||||
| C4E0 | OR (HL) | Combine its bits which stay and store the byte. | ||||||||||
| C4E1 | LD (DE),A | |||||||||||
| C4E2 | INC DE | Move on to the next byte and page. | ||||||||||
| C4E3 | INC H | |||||||||||
| C4E4 | LD A,(DE) | Combine the bits which moved on with the next byte of the buffer. | ||||||||||
| C4E5 | OR (HL) | |||||||||||
| C4E6 | LD (DE),A | |||||||||||
| C4E7 | DEC H | Go back to the first page. | ||||||||||
| C4E8 | EX DE,HL | Move on to the next row of the buffer. | ||||||||||
| C4E9 | LD BC,$0016 | |||||||||||
| C4EC | ADD HL,BC | |||||||||||
| C4ED | EX DE,HL | |||||||||||
| C4EE | EX AF,AF' | Switch in the number of rows. | ||||||||||
| C4EF | DEC A | Count it down. | ||||||||||
| C4F0 | JR NZ,DrawStripGraphic_Shifted | Jump to DrawStripGraphic_Shifted until the rows are done. | ||||||||||
|
Put the stack back.
|
||||||||||||
| DrawStrip_Finish | C4F2 | LD SP,($A21D) | Fetch SavedStackPointer and return. | |||||||||
| C4F6 | RET | |||||||||||
|
Draw a shifted row that is flipped.
|
||||||||||||
| DrawStripGraphic_MirroredShifted | C4F7 | EX AF,AF' | Switch in the number of rows. | |||||||||
| DrawStripGraphic_MirroredLoop | C4F8 | EX AF,AF' | Keep the number of rows in A'. | |||||||||
| C4F9 | POP BC | Fetch a row and point at the second byte. | ||||||||||
| C4FA | LD L,B | |||||||||||
| C4FB | LD A,(DE) | Combine the bits which stay with the first byte of the buffer. | ||||||||||
| C4FC | OR (HL) | |||||||||||
| C4FD | LD (DE),A | |||||||||||
| C4FE | INC DE | Move on to the next byte and page. | ||||||||||
| C4FF | INC H | |||||||||||
| C500 | LD A,(DE) | Combine the bits which moved on. | ||||||||||
| C501 | OR (HL) | |||||||||||
| C502 | DEC H | Point at the first byte of the image. | ||||||||||
| C503 | LD L,C | |||||||||||
| C504 | OR (HL) | Combine its bits which stay and store the byte. | ||||||||||
| C505 | LD (DE),A | |||||||||||
| C506 | INC DE | Move on to the next byte and page. | ||||||||||
| C507 | INC H | |||||||||||
| C508 | LD A,(DE) | Combine the bits which moved on with the next byte of the buffer. | ||||||||||
| C509 | OR (HL) | |||||||||||
| C50A | LD (DE),A | |||||||||||
| C50B | DEC H | Go back to the first page. | ||||||||||
| C50C | EX DE,HL | Move on to the next row of the buffer. | ||||||||||
| C50D | LD BC,$0016 | |||||||||||
| C510 | ADD HL,BC | |||||||||||
| C511 | EX DE,HL | |||||||||||
| C512 | EX AF,AF' | Switch in the number of rows. | ||||||||||
| C513 | DEC A | Count it down. | ||||||||||
| C514 | JR NZ,DrawStripGraphic_MirroredLoop | Jump to DrawStripGraphic_MirroredLoop until the rows are done. | ||||||||||
| C516 | JR DrawStrip_Finish | Jump to DrawStrip_Finish. | ||||||||||
|
Draw an aligned image.
|
||||||||||||
| DrawStripGraphic_Aligned | C518 | EX DE,HL | Put the buffer address in HL. | |||||||||
| C519 | LD A,($A252) | Fetch FlipFlag and test it. | ||||||||||
| C51C | AND A | |||||||||||
| C51D | JR NZ,DrawStripGraphic_AlignedMirrored | Jump to DrawStripGraphic_AlignedMirrored if it is set. | ||||||||||
| C51F | LD BC,$0017 | Set BC to 17. | ||||||||||
| C522 | EX AF,AF' | Switch in the number of rows. | ||||||||||
| DrawStripGraphic_AlignedLoop | C523 | EX AF,AF' | Keep the number of rows in A'. | |||||||||
| C524 | POP DE | Fetch a row of the image. | ||||||||||
| C525 | LD A,(HL) | Combine the first byte with the buffer. | ||||||||||
| C526 | OR E | |||||||||||
| C527 | LD (HL),A | |||||||||||
| C528 | INC HL | Move on to the next byte of the buffer. | ||||||||||
| C529 | LD A,(HL) | Combine the second byte with the buffer. | ||||||||||
| C52A | OR D | |||||||||||
| C52B | LD (HL),A | |||||||||||
| C52C | ADD HL,BC | Move on to the next row of the buffer. | ||||||||||
| C52D | EX AF,AF' | Switch in the number of rows. | ||||||||||
| C52E | DEC A | Count it down. | ||||||||||
| C52F | JR NZ,DrawStripGraphic_AlignedLoop | Jump to DrawStripGraphic_AlignedLoop until the rows are done. | ||||||||||
| C531 | JR DrawStrip_Finish | Jump to DrawStrip_Finish. | ||||||||||
|
Draw an aligned image that is flipped.
|
||||||||||||
| DrawStripGraphic_AlignedMirrored | C533 | LD B,$F9 | Point B at ReverseTable. | |||||||||
| C535 | EX AF,AF' | Switch in the number of rows. | ||||||||||
| DrawStripGraphic_AlignedMirroredLoop | C536 | EX AF,AF' | Keep the number of rows in A'. | |||||||||
| C537 | POP DE | Fetch a row of the image. | ||||||||||
| C538 | LD C,D | Point at the second byte, turned round. | ||||||||||
| C539 | LD A,(BC) | Combine it with the first byte of the buffer. | ||||||||||
| C53A | OR (HL) | |||||||||||
| C53B | LD (HL),A | |||||||||||
| C53C | INC HL | Move on to the next byte of the buffer. | ||||||||||
| C53D | LD C,E | Point at the first byte, turned round. | ||||||||||
| C53E | LD A,(BC) | Combine it with the second byte of the buffer. | ||||||||||
| C53F | OR (HL) | |||||||||||
| C540 | LD (HL),A | |||||||||||
| C541 | LD DE,$0017 | Move on to the next row of the buffer. | ||||||||||
| C544 | ADD HL,DE | |||||||||||
| C545 | EX AF,AF' | Switch in the number of rows. | ||||||||||
| C546 | DEC A | Count it down. | ||||||||||
| C547 | JR NZ,DrawStripGraphic_AlignedMirroredLoop | Jump to DrawStripGraphic_AlignedMirroredLoop until the rows are done. | ||||||||||
| C549 | JR DrawStrip_Finish | Jump to DrawStrip_Finish. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: C497 | Up: Map | Next: C54B |