Prev: D2A2 Up: Map Next: D356
D2B2: Draw Strip Graphic
Used by the routine at DrawStrip.
Draws a strip which is sixteen pixels wide into PixelBuffer, combining it with what is already there. The strip 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 ScreenXPosition and the strip is moved to the right by 00, 02, 04 or 06 pixels, using ShiftTables and ReversedShiftTables. The strip 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
HL The address of the graphic
Clip the strip to the buffer.
DrawStripGraphic D2B2 LD A,D Subtract 48 from the vertical position.
D2B3 SUB $48
D2B5 JR C,ClipEdgeStripTop Jump to ClipEdgeStripTop if it is below the bottom.
D2B7 SUB $70 Subtract 70.
D2B9 RET NC Return if it is above the top.
D2BA NEG Make it the number of rows in the buffer.
D2BC CP (HL) Jump to DrawStripGraphic_Height if it is fewer.
D2BD JR C,DrawStripGraphic_Height
D2BF LD A,(HL) Use the height of the strip.
Draw the rows that are in the buffer.
DrawStripGraphic_Height D2C0 INC HL Move on to the first row of the graphic.
This entry point is used by the routine at ClipEdgeStripTop.
DrawStripGraphic_Draw D2C1 EX AF,AF' Keep the number of rows in A'.
D2C2 EX DE,HL Put the position in HL.
D2C3 CALL CalculateBufferAddress Call CalculateBufferAddress.
D2C6 EX DE,HL Switch the buffer and the graphic.
D2C7 LD ($BBAE),SP Set SavedStackPointer.
D2CB LD SP,HL Point the stack at the graphic.
Choose the draw path.
D2CC LD A,($BBB6) Fetch ScreenXPosition.
D2CF AND %00000110 Keep bits 1 and 2.
D2D1 JR Z,DrawStripGraphic_Aligned Jump to DrawStripGraphic_Aligned if the strip is aligned.
D2D3 OR %11110000 Set the high bits of the page.
D2D5 LD H,A Set H.
D2D6 LD A,($BBF2) Fetch MirrorFlag.
D2D9 AND A Jump to DrawStripGraphic_MirroredShifted if it is set.
D2DA JR NZ,DrawStripGraphic_MirroredShifted
D2DC SET 3,H Set bit 3 of H.
D2DE EX AF,AF' Switch in the number of rows.
Draw a shifted row.
DrawStripGraphic_Shifted D2DF EX AF,AF' Keep the number of rows in A'.
D2E0 POP BC Fetch a row and point at the first byte.
D2E1 LD L,C
D2E2 LD A,(DE) Combine the bits which stay with the first byte of the buffer.
D2E3 OR (HL)
D2E4 LD (DE),A
D2E5 INC DE Move on to the next byte and page.
D2E6 INC H
D2E7 LD A,(DE) Combine the bits which moved on from the first byte.
D2E8 OR (HL)
D2E9 DEC H Point at the second byte of the graphic.
D2EA LD L,B
D2EB OR (HL) Combine its bits which stay and store the byte.
D2EC LD (DE),A
D2ED INC DE Move on to the next byte and page.
D2EE INC H
D2EF LD A,(DE) Combine the bits which moved on with the next byte of the buffer.
D2F0 OR (HL)
D2F1 LD (DE),A
D2F2 DEC H Go back to the first page.
D2F3 EX DE,HL Move on to the next row of the buffer.
D2F4 LD BC,$0016
D2F7 ADD HL,BC
D2F8 EX DE,HL
D2F9 EX AF,AF' Switch in the number of rows.
D2FA DEC A Count it down.
D2FB JR NZ,DrawStripGraphic_Shifted Jump to DrawStripGraphic_Shifted until the rows are done.
Put the stack back.
DrawStripGraphic_Done D2FD LD SP,($BBAE) Fetch SavedStackPointer and return.
D301 RET
Draw a shifted row that is flipped.
DrawStripGraphic_MirroredShifted D302 EX AF,AF' Switch in the number of rows.
DrawStripGraphic_MirroredLoop D303 EX AF,AF' Keep the number of rows in A'.
D304 POP BC Fetch a row and point at the second byte.
D305 LD L,B
D306 LD A,(DE) Combine the bits which stay with the first byte of the buffer.
D307 OR (HL)
D308 LD (DE),A
D309 INC DE Move on to the next byte and page.
D30A INC H
D30B LD A,(DE) Combine the bits which moved on.
D30C OR (HL)
D30D DEC H Point at the first byte of the graphic.
D30E LD L,C
D30F OR (HL) Combine its bits which stay and store the byte.
D310 LD (DE),A
D311 INC DE Move on to the next byte and page.
D312 INC H
D313 LD A,(DE) Combine the bits which moved on with the next byte of the buffer.
D314 OR (HL)
D315 LD (DE),A
D316 DEC H Go back to the first page.
D317 EX DE,HL Move on to the next row of the buffer.
D318 LD BC,$0016
D31B ADD HL,BC
D31C EX DE,HL
D31D EX AF,AF' Switch in the number of rows.
D31E DEC A Count it down.
D31F JR NZ,DrawStripGraphic_MirroredLoop Jump to DrawStripGraphic_MirroredLoop until the rows are done.
D321 JR DrawStripGraphic_Done Jump to DrawStripGraphic_Done.
Draw an aligned strip.
DrawStripGraphic_Aligned D323 EX DE,HL Put the buffer address in HL.
D324 LD A,($BBF2) Fetch MirrorFlag and test it.
D327 AND A
D328 JR NZ,DrawStripGraphic_AlignedMirrored Jump to DrawStripGraphic_AlignedMirrored if it is set.
D32A LD BC,$0017 Set BC to 17.
D32D EX AF,AF' Switch in the number of rows.
DrawStripGraphic_AlignedLoop D32E EX AF,AF' Keep the number of rows in A'.
D32F POP DE Fetch a row of the graphic.
D330 LD A,(HL) Combine the first byte with the buffer.
D331 OR E
D332 LD (HL),A
D333 INC HL Move on to the next byte of the buffer.
D334 LD A,(HL) Combine the second byte with the buffer.
D335 OR D
D336 LD (HL),A
D337 ADD HL,BC Move on to the next row of the buffer.
D338 EX AF,AF' Switch in the number of rows.
D339 DEC A Count it down.
D33A JR NZ,DrawStripGraphic_AlignedLoop Jump to DrawStripGraphic_AlignedLoop until the rows are done.
D33C JR DrawStripGraphic_Done Jump to DrawStripGraphic_Done.
Draw an aligned strip that is flipped.
DrawStripGraphic_AlignedMirrored D33E LD B,$F9 Point B at ReverseBitsTable.
D340 EX AF,AF' Switch in the number of rows.
DrawStripGraphic_AlignedMirroredLoop D341 EX AF,AF' Keep the number of rows in A'.
D342 POP DE Fetch a row of the graphic.
D343 LD C,D Point at the second byte, turned round.
D344 LD A,(BC) Combine it with the first byte of the buffer.
D345 OR (HL)
D346 LD (HL),A
D347 INC HL Move on to the next byte of the buffer.
D348 LD C,E Point at the first byte, turned round.
D349 LD A,(BC) Combine it with the second byte of the buffer.
D34A OR (HL)
D34B LD (HL),A
D34C LD DE,$0017 Move on to the next row of the buffer.
D34F ADD HL,DE
D350 EX AF,AF' Switch in the number of rows.
D351 DEC A Count it down.
D352 JR NZ,DrawStripGraphic_AlignedMirroredLoop Jump to DrawStripGraphic_AlignedMirroredLoop until the rows are done.
D354 JR DrawStripGraphic_Done Jump to DrawStripGraphic_Done.
View the equivalent code in;
Prev: D2A2 Up: Map Next: D356