Prev: 50665 Up: Map Next: 50883
50681: Draw Wall Strip
Used by the routine at DrawWallStrips.
Draws a wall tile, sixteen pixels wide, into PlayfieldBuffer. The image has the same format as DrawStripGraphic, but it replaces the buffer. The masks from WallTileMasks are written into the AND instructions. The image is flipped if FlipFlag is not zero.
Input
D The vertical position of the bottom of the tile
E The horizontal position of the tile
IY The address of the tile number
Find the image and clip it to the buffer.
DrawWallStrip 50681 LD A,(IY+0) Fetch the tile number.
50684 LD BC,36856 Point BC at WallImagePointers.
50687 CALL GetTableEntry Call GetTableEntry.
50690 LD A,D Subtract 72 from the vertical position.
50691 SUB 72
50693 JR C,ClipWallStripTop Jump to ClipWallStripTop if it is below the bottom.
50695 SUB 112 Subtract 112.
50697 RET NC Return if it is above the top.
50698 NEG Make it the number of rows in the buffer.
50700 CP (HL) Compare it with the height of the image.
50701 JR C,DrawWallStrip_FirstRow Jump to DrawWallStrip_FirstRow if it is fewer.
50703 LD A,(HL) Use the height of the image.
Draw the rows that are in the buffer.
DrawWallStrip_FirstRow 50704 INC HL Move on to the first row of the image.
This entry point is used by the routine at ClipWallStripTop.
DrawWallStrip_Rows 50705 EX AF,AF' Keep the number of rows in A'.
50706 EX DE,HL Put the position in HL.
50707 CALL CalculateBufferAddress Call CalculateBufferAddress.
50710 EX DE,HL Switch the buffer and the image.
50711 PUSH HL Stash the image on the stack.
Write the masks from WallTileMasks into the AND instructions.
50712 LD A,(41550) Fetch ScreenHorizontalPosition.
50715 RRCA Move the shift into the lowest bits.
50716 AND %00000011 Keep the lowest two bits.
50718 LD HL,50883 Point HL at WallTileMasks.
50721 CALL AddAToHL Call AddAToHL.
50724 LD A,(HL) Fetch the mask.
50725 LD (50768),A Set the left-hand AND operands.
50728 LD (50807),A
50731 CPL Complement the mask.
50732 LD (50782),A Set the right-hand AND operands.
50735 LD (50822),A
Choose the draw path.
50738 POP HL Restore the image from the stack.
50739 LD (41501),SP Set SavedStackPointer.
50743 LD SP,HL Point the stack at the image.
50744 LD A,(41550) Fetch ScreenHorizontalPosition.
50747 AND %00000110 Keep bits 1 and 2.
50749 JR Z,DrawWallStrip_Aligned Jump to DrawWallStrip_Aligned if the image is aligned.
50751 OR %11110000 Set the high bits of the page.
50753 LD H,A Set H.
50754 LD A,(41554) Fetch FlipFlag.
50757 AND A Jump to DrawWallStrip_Flipped if it is set.
50758 JR NZ,DrawWallStrip_Flipped
50760 SET 3,H Set bit 3 of H.
50762 EX AF,AF' Switch in the number of rows.
Draw a shifted row.
DrawWallStrip_ShiftedRow 50763 EX AF,AF' Keep the number of rows in A'.
50764 POP BC Fetch a row and point at the first byte.
50765 LD L,C
50766 LD A,(DE) Fetch the first byte of the buffer.
50767 AND %00000000 Keep the bits which are not covered.
50769 OR (HL) Combine it and store the byte.
50770 LD (DE),A
50771 INC DE Move on to the next byte and page.
50772 INC H
50773 LD A,(HL) Look up the bits which moved on.
50774 DEC H Go back to the first page.
50775 LD L,B Point at the second byte of the image.
50776 OR (HL) Combine it and store the byte.
50777 LD (DE),A
50778 INC DE Move on to the next byte and page.
50779 INC H
50780 LD A,(DE) Fetch the third byte of the buffer.
50781 AND %00000000 Keep the bits which are not covered.
50783 OR (HL) Combine it and store the byte.
50784 LD (DE),A
50785 DEC H Go back to the first page.
50786 EX DE,HL Move on to the next row of the buffer.
50787 LD BC,22
50790 ADD HL,BC
50791 EX DE,HL
50792 EX AF,AF' Switch in the number of rows.
50793 DEC A Count it down.
50794 JR NZ,DrawWallStrip_ShiftedRow Jump to DrawWallStrip_ShiftedRow until the rows are done.
Put the stack back.
DrawWallStrip_Finish 50796 LD SP,(41501) Fetch SavedStackPointer and return.
50800 RET
Draw a shifted row that is flipped.
DrawWallStrip_Flipped 50801 EX AF,AF' Switch in the number of rows.
DrawWallStrip_FlippedRow 50802 EX AF,AF' Keep the number of rows in A'.
50803 POP BC Fetch a row and point at the second byte.
50804 LD L,B
50805 LD A,(DE) Fetch the first byte of the buffer.
50806 AND %00000000 Keep the bits which are not covered.
50808 OR (HL) Combine it and store the byte.
50809 LD (DE),A
50810 INC DE Move on to the next byte and page.
50811 INC H
50812 LD B,(HL) Look up the bits which moved on.
50813 DEC H Go back to the first page.
50814 LD L,C Point at the first byte of the image.
50815 LD A,(HL) Fetch the bits which stay.
50816 OR B Combine them and store the byte.
50817 LD (DE),A
50818 INC DE Move on to the next byte and page.
50819 INC H
50820 LD A,(DE) Fetch the third byte of the buffer.
50821 AND %00000000 Keep the bits which are not covered.
50823 OR (HL) Combine it and store the byte.
50824 LD (DE),A
50825 DEC H Go back to the first page.
50826 EX DE,HL Move on to the next row of the buffer.
50827 LD BC,22
50830 ADD HL,BC
50831 EX DE,HL
50832 EX AF,AF' Switch in the number of rows.
50833 DEC A Count it down.
50834 JR NZ,DrawWallStrip_FlippedRow Jump to DrawWallStrip_FlippedRow until the rows are done.
50836 JR DrawWallStrip_Finish Jump to DrawWallStrip_Finish.
Draw an aligned image.
DrawWallStrip_Aligned 50838 EX DE,HL Put the buffer address in HL.
50839 LD A,(41554) Fetch FlipFlag and test it.
50842 AND A
50843 JR NZ,DrawWallStrip_FlippedAligned Jump to DrawWallStrip_FlippedAligned if it is set.
50845 LD BC,23 Set BC to 23.
50848 EX AF,AF' Switch in the number of rows.
DrawWallStrip_AlignedRow 50849 EX AF,AF' Keep the number of rows in A'.
50850 POP DE Fetch a row of the image.
50851 LD (HL),E Store the first byte and move on.
50852 INC HL
50853 LD (HL),D Store the second byte.
50854 ADD HL,BC Move on to the next row of the buffer.
50855 EX AF,AF' Switch in the number of rows.
50856 DEC A Count it down.
50857 JR NZ,DrawWallStrip_AlignedRow Jump to DrawWallStrip_AlignedRow until the rows are done.
50859 JR DrawWallStrip_Finish Jump to DrawWallStrip_Finish.
Draw an aligned image that is flipped.
DrawWallStrip_FlippedAligned 50861 LD B,249 Set B to 249.
50863 EX AF,AF' Switch in the number of rows.
DrawWallStrip_FlippedAlignedRow 50864 EX AF,AF' Keep the number of rows in A'.
50865 POP DE Fetch a row of the image.
50866 LD C,D Point at the second byte, turned round.
50867 LD A,(BC) Store it in the first byte of the buffer.
50868 LD (HL),A
50869 INC HL Move on to the next byte of the buffer.
50870 LD C,E Point at the first byte, turned round.
50871 LD A,(BC) Store it in the second byte of the buffer.
50872 LD (HL),A
50873 LD DE,23 Move on to the next row of the buffer.
50876 ADD HL,DE
50877 EX AF,AF' Switch in the number of rows.
50878 DEC A Count it down.
50879 JR NZ,DrawWallStrip_FlippedAlignedRow Jump to DrawWallStrip_FlippedAlignedRow until the rows are done.
50881 JR DrawWallStrip_Finish Jump to DrawWallStrip_Finish.
View the equivalent code in;
Prev: 50665 Up: Map Next: 50883