Prev: D415 Up: Map Next: D4EF
D425: Draw Wall Strip
Used by the routine at DrawWallStrips.
Draws a wall strip, sixteen pixels wide, into PixelBuffer. The graphic has the same format as DrawStripGraphic, but it replaces the buffer. The masks from WallStripMasks are written into the AND instructions. The graphic is flipped if MirrorFlag is not zero.
Input
D The vertical position of the bottom of the strip
E The horizontal position of the strip
IY The address of the strip number
Find the graphic and clip it to the buffer.
DrawWallStrip D425 LD A,(IY+$00) Fetch the strip number.
D428 LD BC,$6E36 Point BC at WallStripTable.
D42B CALL GetTableEntry Call GetTableEntry.
D42E LD A,D Subtract 48 from the vertical position.
D42F SUB $48
D431 JR C,ClipWallStripTop Jump to ClipWallStripTop if it is below the bottom.
D433 SUB $70 Subtract 70.
D435 RET NC Return if it is above the top.
D436 NEG Make it the number of rows in the buffer.
D438 CP (HL) Compare it with the height of the graphic.
D439 JR C,DrawWallStrip_Height Jump to DrawWallStrip_Height if it is fewer.
D43B LD A,(HL) Use the height of the graphic.
Draw the rows that are in the buffer.
DrawWallStrip_Height D43C INC HL Move on to the first row of the graphic.
This entry point is used by the routine at ClipWallStripTop.
DrawWallStrip_Draw D43D EX AF,AF' Keep the number of rows in A'.
D43E EX DE,HL Put the position in HL.
D43F CALL CalculateBufferAddress Call CalculateBufferAddress.
D442 EX DE,HL Switch the buffer and the graphic.
D443 PUSH HL Stash the graphic on the stack.
Write the masks from WallStripMasks into the AND instructions.
D444 LD A,($BBB6) Fetch ScreenXPosition.
D447 RRCA Move the shift into the lowest bits.
D448 AND %00000011 Keep the lowest two bits.
D44A LD HL,$D4EF Point HL at WallStripMasks.
D44D CALL AddAToHL Call AddAToHL.
D450 LD A,(HL) Fetch the mask.
D451 LD ($D47C),A Set the left-hand AND operands.
D454 LD ($D4A3),A
D457 CPL Complement the mask.
D458 LD ($D48A),A Set the right-hand AND operands.
D45B LD ($D4B2),A
Choose the draw path.
D45E POP HL Restore the graphic from the stack.
D45F LD ($BBAE),SP Set SavedStackPointer.
D463 LD SP,HL Point the stack at the graphic.
D464 LD A,($BBB6) Fetch ScreenXPosition.
D467 AND %00000110 Keep bits 1 and 2.
D469 JR Z,DrawWallStrip_Aligned Jump to DrawWallStrip_Aligned if the graphic is aligned.
D46B OR %11110000 Set the high bits of the page.
D46D LD H,A Set H.
D46E LD A,($BBF2) Fetch MirrorFlag.
D471 AND A Jump to DrawWallStrip_MirroredShifted if it is set.
D472 JR NZ,DrawWallStrip_MirroredShifted
D474 SET 3,H Set bit 3 of H.
D476 EX AF,AF' Switch in the number of rows.
Draw a shifted row.
DrawWallStrip_Shifted D477 EX AF,AF' Keep the number of rows in A'.
D478 POP BC Fetch a row and point at the first byte.
D479 LD L,C
D47A LD A,(DE) Fetch the first byte of the buffer.
D47B AND %00000000 Keep the bits which are not covered.
D47D OR (HL) Combine it and store the byte.
D47E LD (DE),A
D47F INC DE Move on to the next byte and page.
D480 INC H
D481 LD A,(HL) Look up the bits which moved on.
D482 DEC H Go back to the first page.
D483 LD L,B Point at the second byte of the graphic.
D484 OR (HL) Combine it and store the byte.
D485 LD (DE),A
D486 INC DE Move on to the next byte and page.
D487 INC H
D488 LD A,(DE) Fetch the third byte of the buffer.
D489 AND %00000000 Keep the bits which are not covered.
D48B OR (HL) Combine it and store the byte.
D48C LD (DE),A
D48D DEC H Go back to the first page.
D48E EX DE,HL Move on to the next row of the buffer.
D48F LD BC,$0016
D492 ADD HL,BC
D493 EX DE,HL
D494 EX AF,AF' Switch in the number of rows.
D495 DEC A Count it down.
D496 JR NZ,DrawWallStrip_Shifted Jump to DrawWallStrip_Shifted until the rows are done.
Put the stack back.
DrawWallStrip_Done D498 LD SP,($BBAE) Fetch SavedStackPointer and return.
D49C RET
Draw a shifted row that is flipped.
DrawWallStrip_MirroredShifted D49D EX AF,AF' Switch in the number of rows.
DrawWallStrip_MirroredLoop D49E EX AF,AF' Keep the number of rows in A'.
D49F POP BC Fetch a row and point at the second byte.
D4A0 LD L,B
D4A1 LD A,(DE) Fetch the first byte of the buffer.
D4A2 AND %00000000 Keep the bits which are not covered.
D4A4 OR (HL) Combine it and store the byte.
D4A5 LD (DE),A
D4A6 INC DE Move on to the next byte and page.
D4A7 INC H
D4A8 LD B,(HL) Look up the bits which moved on.
D4A9 DEC H Go back to the first page.
D4AA LD L,C Point at the first byte of the graphic.
D4AB LD A,(HL) Fetch the bits which stay.
D4AC OR B Combine them and store the byte.
D4AD LD (DE),A
D4AE INC DE Move on to the next byte and page.
D4AF INC H
D4B0 LD A,(DE) Fetch the third byte of the buffer.
D4B1 AND %00000000 Keep the bits which are not covered.
D4B3 OR (HL) Combine it and store the byte.
D4B4 LD (DE),A
D4B5 DEC H Go back to the first page.
D4B6 EX DE,HL Move on to the next row of the buffer.
D4B7 LD BC,$0016
D4BA ADD HL,BC
D4BB EX DE,HL
D4BC EX AF,AF' Switch in the number of rows.
D4BD DEC A Count it down.
D4BE JR NZ,DrawWallStrip_MirroredLoop Jump to DrawWallStrip_MirroredLoop until the rows are done.
D4C0 JR DrawWallStrip_Done Jump to DrawWallStrip_Done.
Draw an aligned graphic.
DrawWallStrip_Aligned D4C2 EX DE,HL Put the buffer address in HL.
D4C3 LD A,($BBF2) Fetch MirrorFlag and test it.
D4C6 AND A
D4C7 JR NZ,DrawWallStrip_AlignedMirrored Jump to DrawWallStrip_AlignedMirrored if it is set.
D4C9 LD BC,$0017 Set BC to 17.
D4CC EX AF,AF' Switch in the number of rows.
DrawWallStrip_AlignedLoop D4CD EX AF,AF' Keep the number of rows in A'.
D4CE POP DE Fetch a row of the graphic.
D4CF LD (HL),E Store the first byte and move on.
D4D0 INC HL
D4D1 LD (HL),D Store the second byte.
D4D2 ADD HL,BC Move on to the next row of the buffer.
D4D3 EX AF,AF' Switch in the number of rows.
D4D4 DEC A Count it down.
D4D5 JR NZ,DrawWallStrip_AlignedLoop Jump to DrawWallStrip_AlignedLoop until the rows are done.
D4D7 JR DrawWallStrip_Done Jump to DrawWallStrip_Done.
Draw an aligned graphic that is flipped.
DrawWallStrip_AlignedMirrored D4D9 LD B,$F9 Point B at ReverseBitsTable.
D4DB EX AF,AF' Switch in the number of rows.
DrawWallStrip_AlignedMirroredLoop D4DC EX AF,AF' Keep the number of rows in A'.
D4DD POP DE Fetch a row of the graphic.
D4DE LD C,D Point at the second byte, turned round.
D4DF LD A,(BC) Store it in the first byte of the buffer.
D4E0 LD (HL),A
D4E1 INC HL Move on to the next byte of the buffer.
D4E2 LD C,E Point at the first byte, turned round.
D4E3 LD A,(BC) Store it in the second byte of the buffer.
D4E4 LD (HL),A
D4E5 LD DE,$0017 Move on to the next row of the buffer.
D4E8 ADD HL,DE
D4E9 EX AF,AF' Switch in the number of rows.
D4EA DEC A Count it down.
D4EB JR NZ,DrawWallStrip_AlignedMirroredLoop Jump to DrawWallStrip_AlignedMirroredLoop until the rows are done.
D4ED JR DrawWallStrip_Done Jump to DrawWallStrip_Done.
View the equivalent code in;
Prev: D415 Up: Map Next: D4EF