Prev: 50327 Up: Map Next: 50507
50343: Draw Strip Graphic
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 0, 2, 4 or 6 pixels, using ShiftTables and ReversedShiftTables. The image is flipped if FlipFlag is not zero.
Input
D The vertical position of the bottom of the image
E The horizontal position of the image
HL The address of the image
Clip the image to the buffer.
DrawStripGraphic 50343 LD A,D Subtract 72 from the vertical position.
50344 SUB 72
50346 JR C,ClipEdgeStripTop Jump to ClipEdgeStripTop if it is below the bottom.
50348 SUB 112 Subtract 112.
50350 RET NC Return if it is above the top.
50351 NEG Make it the number of rows in the buffer.
50353 CP (HL) Jump to DrawStripGraphic_FirstRow if it is fewer.
50354 JR C,DrawStripGraphic_FirstRow
50356 LD A,(HL) Use the height of the image.
Draw the rows that are in the buffer.
DrawStripGraphic_FirstRow 50357 INC HL Move on to the first row of the image.
This entry point is used by the routine at ClipEdgeStripTop.
DrawStripGraphic_Draw 50358 EX AF,AF' Keep the number of rows in A'.
50359 EX DE,HL Put the position in HL.
50360 CALL CalculateBufferAddress Call CalculateBufferAddress.
50363 EX DE,HL Switch the buffer and the image.
50364 LD (41501),SP Set SavedStackPointer.
50368 LD SP,HL Point the stack at the image.
Choose the draw path.
50369 LD A,(41550) Fetch ScreenHorizontalPosition.
50372 AND %00000110 Keep bits 1 and 2.
50374 JR Z,DrawStripGraphic_Aligned Jump to DrawStripGraphic_Aligned if the image is aligned.
50376 OR %11110000 Set the high bits of the page.
50378 LD H,A Set H.
50379 LD A,(41554) Fetch FlipFlag.
50382 AND A Jump to DrawStripGraphic_MirroredShifted if it is set.
50383 JR NZ,DrawStripGraphic_MirroredShifted
50385 SET 3,H Set bit 3 of H.
50387 EX AF,AF' Switch in the number of rows.
Draw a shifted row.
DrawStripGraphic_Shifted 50388 EX AF,AF' Keep the number of rows in A'.
50389 POP BC Fetch a row and point at the first byte.
50390 LD L,C
50391 LD A,(DE) Combine the bits which stay with the first byte of the buffer.
50392 OR (HL)
50393 LD (DE),A
50394 INC DE Move on to the next byte and page.
50395 INC H
50396 LD A,(DE) Combine the bits which moved on from the first byte.
50397 OR (HL)
50398 DEC H Point at the second byte of the image.
50399 LD L,B
50400 OR (HL) Combine its bits which stay and store the byte.
50401 LD (DE),A
50402 INC DE Move on to the next byte and page.
50403 INC H
50404 LD A,(DE) Combine the bits which moved on with the next byte of the buffer.
50405 OR (HL)
50406 LD (DE),A
50407 DEC H Go back to the first page.
50408 EX DE,HL Move on to the next row of the buffer.
50409 LD BC,22
50412 ADD HL,BC
50413 EX DE,HL
50414 EX AF,AF' Switch in the number of rows.
50415 DEC A Count it down.
50416 JR NZ,DrawStripGraphic_Shifted Jump to DrawStripGraphic_Shifted until the rows are done.
Put the stack back.
DrawStrip_Finish 50418 LD SP,(41501) Fetch SavedStackPointer and return.
50422 RET
Draw a shifted row that is flipped.
DrawStripGraphic_MirroredShifted 50423 EX AF,AF' Switch in the number of rows.
DrawStripGraphic_MirroredLoop 50424 EX AF,AF' Keep the number of rows in A'.
50425 POP BC Fetch a row and point at the second byte.
50426 LD L,B
50427 LD A,(DE) Combine the bits which stay with the first byte of the buffer.
50428 OR (HL)
50429 LD (DE),A
50430 INC DE Move on to the next byte and page.
50431 INC H
50432 LD A,(DE) Combine the bits which moved on.
50433 OR (HL)
50434 DEC H Point at the first byte of the image.
50435 LD L,C
50436 OR (HL) Combine its bits which stay and store the byte.
50437 LD (DE),A
50438 INC DE Move on to the next byte and page.
50439 INC H
50440 LD A,(DE) Combine the bits which moved on with the next byte of the buffer.
50441 OR (HL)
50442 LD (DE),A
50443 DEC H Go back to the first page.
50444 EX DE,HL Move on to the next row of the buffer.
50445 LD BC,22
50448 ADD HL,BC
50449 EX DE,HL
50450 EX AF,AF' Switch in the number of rows.
50451 DEC A Count it down.
50452 JR NZ,DrawStripGraphic_MirroredLoop Jump to DrawStripGraphic_MirroredLoop until the rows are done.
50454 JR DrawStrip_Finish Jump to DrawStrip_Finish.
Draw an aligned image.
DrawStripGraphic_Aligned 50456 EX DE,HL Put the buffer address in HL.
50457 LD A,(41554) Fetch FlipFlag and test it.
50460 AND A
50461 JR NZ,DrawStripGraphic_AlignedMirrored Jump to DrawStripGraphic_AlignedMirrored if it is set.
50463 LD BC,23 Set BC to 23.
50466 EX AF,AF' Switch in the number of rows.
DrawStripGraphic_AlignedLoop 50467 EX AF,AF' Keep the number of rows in A'.
50468 POP DE Fetch a row of the image.
50469 LD A,(HL) Combine the first byte with the buffer.
50470 OR E
50471 LD (HL),A
50472 INC HL Move on to the next byte of the buffer.
50473 LD A,(HL) Combine the second byte with the buffer.
50474 OR D
50475 LD (HL),A
50476 ADD HL,BC Move on to the next row of the buffer.
50477 EX AF,AF' Switch in the number of rows.
50478 DEC A Count it down.
50479 JR NZ,DrawStripGraphic_AlignedLoop Jump to DrawStripGraphic_AlignedLoop until the rows are done.
50481 JR DrawStrip_Finish Jump to DrawStrip_Finish.
Draw an aligned image that is flipped.
DrawStripGraphic_AlignedMirrored 50483 LD B,249 Point B at ReverseTable.
50485 EX AF,AF' Switch in the number of rows.
DrawStripGraphic_AlignedMirroredLoop 50486 EX AF,AF' Keep the number of rows in A'.
50487 POP DE Fetch a row of the image.
50488 LD C,D Point at the second byte, turned round.
50489 LD A,(BC) Combine it with the first byte of the buffer.
50490 OR (HL)
50491 LD (HL),A
50492 INC HL Move on to the next byte of the buffer.
50493 LD C,E Point at the first byte, turned round.
50494 LD A,(BC) Combine it with the second byte of the buffer.
50495 OR (HL)
50496 LD (HL),A
50497 LD DE,23 Move on to the next row of the buffer.
50500 ADD HL,DE
50501 EX AF,AF' Switch in the number of rows.
50502 DEC A Count it down.
50503 JR NZ,DrawStripGraphic_AlignedMirroredLoop Jump to DrawStripGraphic_AlignedMirroredLoop until the rows are done.
50505 JR DrawStrip_Finish Jump to DrawStrip_Finish.
View the equivalent code in;
Prev: 50327 Up: Map Next: 50507