Prev: 53922 Up: Map Next: 54102
53938: 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 0, 2, 4 or 6 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 53938 LD A,D Subtract 72 from the vertical position.
53939 SUB 72
53941 JR C,ClipEdgeStripTop Jump to ClipEdgeStripTop if it is below the bottom.
53943 SUB 112 Subtract 112.
53945 RET NC Return if it is above the top.
53946 NEG Make it the number of rows in the buffer.
53948 CP (HL) Jump to DrawStripGraphic_Height if it is fewer.
53949 JR C,DrawStripGraphic_Height
53951 LD A,(HL) Use the height of the strip.
Draw the rows that are in the buffer.
DrawStripGraphic_Height 53952 INC HL Move on to the first row of the graphic.
This entry point is used by the routine at ClipEdgeStripTop.
DrawStripGraphic_Draw 53953 EX AF,AF' Keep the number of rows in A'.
53954 EX DE,HL Put the position in HL.
53955 CALL CalculateBufferAddress Call CalculateBufferAddress.
53958 EX DE,HL Switch the buffer and the graphic.
53959 LD (48046),SP Set SavedStackPointer.
53963 LD SP,HL Point the stack at the graphic.
Choose the draw path.
53964 LD A,(48054) Fetch ScreenXPosition.
53967 AND %00000110 Keep bits 1 and 2.
53969 JR Z,DrawStripGraphic_Aligned Jump to DrawStripGraphic_Aligned if the strip is aligned.
53971 OR %11110000 Set the high bits of the page.
53973 LD H,A Set H.
53974 LD A,(48114) Fetch MirrorFlag.
53977 AND A Jump to DrawStripGraphic_MirroredShifted if it is set.
53978 JR NZ,DrawStripGraphic_MirroredShifted
53980 SET 3,H Set bit 3 of H.
53982 EX AF,AF' Switch in the number of rows.
Draw a shifted row.
DrawStripGraphic_Shifted 53983 EX AF,AF' Keep the number of rows in A'.
53984 POP BC Fetch a row and point at the first byte.
53985 LD L,C
53986 LD A,(DE) Combine the bits which stay with the first byte of the buffer.
53987 OR (HL)
53988 LD (DE),A
53989 INC DE Move on to the next byte and page.
53990 INC H
53991 LD A,(DE) Combine the bits which moved on from the first byte.
53992 OR (HL)
53993 DEC H Point at the second byte of the graphic.
53994 LD L,B
53995 OR (HL) Combine its bits which stay and store the byte.
53996 LD (DE),A
53997 INC DE Move on to the next byte and page.
53998 INC H
53999 LD A,(DE) Combine the bits which moved on with the next byte of the buffer.
54000 OR (HL)
54001 LD (DE),A
54002 DEC H Go back to the first page.
54003 EX DE,HL Move on to the next row of the buffer.
54004 LD BC,22
54007 ADD HL,BC
54008 EX DE,HL
54009 EX AF,AF' Switch in the number of rows.
54010 DEC A Count it down.
54011 JR NZ,DrawStripGraphic_Shifted Jump to DrawStripGraphic_Shifted until the rows are done.
Put the stack back.
DrawStripGraphic_Done 54013 LD SP,(48046) Fetch SavedStackPointer and return.
54017 RET
Draw a shifted row that is flipped.
DrawStripGraphic_MirroredShifted 54018 EX AF,AF' Switch in the number of rows.
DrawStripGraphic_MirroredLoop 54019 EX AF,AF' Keep the number of rows in A'.
54020 POP BC Fetch a row and point at the second byte.
54021 LD L,B
54022 LD A,(DE) Combine the bits which stay with the first byte of the buffer.
54023 OR (HL)
54024 LD (DE),A
54025 INC DE Move on to the next byte and page.
54026 INC H
54027 LD A,(DE) Combine the bits which moved on.
54028 OR (HL)
54029 DEC H Point at the first byte of the graphic.
54030 LD L,C
54031 OR (HL) Combine its bits which stay and store the byte.
54032 LD (DE),A
54033 INC DE Move on to the next byte and page.
54034 INC H
54035 LD A,(DE) Combine the bits which moved on with the next byte of the buffer.
54036 OR (HL)
54037 LD (DE),A
54038 DEC H Go back to the first page.
54039 EX DE,HL Move on to the next row of the buffer.
54040 LD BC,22
54043 ADD HL,BC
54044 EX DE,HL
54045 EX AF,AF' Switch in the number of rows.
54046 DEC A Count it down.
54047 JR NZ,DrawStripGraphic_MirroredLoop Jump to DrawStripGraphic_MirroredLoop until the rows are done.
54049 JR DrawStripGraphic_Done Jump to DrawStripGraphic_Done.
Draw an aligned strip.
DrawStripGraphic_Aligned 54051 EX DE,HL Put the buffer address in HL.
54052 LD A,(48114) Fetch MirrorFlag and test it.
54055 AND A
54056 JR NZ,DrawStripGraphic_AlignedMirrored Jump to DrawStripGraphic_AlignedMirrored if it is set.
54058 LD BC,23 Set BC to 23.
54061 EX AF,AF' Switch in the number of rows.
DrawStripGraphic_AlignedLoop 54062 EX AF,AF' Keep the number of rows in A'.
54063 POP DE Fetch a row of the graphic.
54064 LD A,(HL) Combine the first byte with the buffer.
54065 OR E
54066 LD (HL),A
54067 INC HL Move on to the next byte of the buffer.
54068 LD A,(HL) Combine the second byte with the buffer.
54069 OR D
54070 LD (HL),A
54071 ADD HL,BC Move on to the next row of the buffer.
54072 EX AF,AF' Switch in the number of rows.
54073 DEC A Count it down.
54074 JR NZ,DrawStripGraphic_AlignedLoop Jump to DrawStripGraphic_AlignedLoop until the rows are done.
54076 JR DrawStripGraphic_Done Jump to DrawStripGraphic_Done.
Draw an aligned strip that is flipped.
DrawStripGraphic_AlignedMirrored 54078 LD B,249 Point B at ReverseBitsTable.
54080 EX AF,AF' Switch in the number of rows.
DrawStripGraphic_AlignedMirroredLoop 54081 EX AF,AF' Keep the number of rows in A'.
54082 POP DE Fetch a row of the graphic.
54083 LD C,D Point at the second byte, turned round.
54084 LD A,(BC) Combine it with the first byte of the buffer.
54085 OR (HL)
54086 LD (HL),A
54087 INC HL Move on to the next byte of the buffer.
54088 LD C,E Point at the first byte, turned round.
54089 LD A,(BC) Combine it with the second byte of the buffer.
54090 OR (HL)
54091 LD (HL),A
54092 LD DE,23 Move on to the next row of the buffer.
54095 ADD HL,DE
54096 EX AF,AF' Switch in the number of rows.
54097 DEC A Count it down.
54098 JR NZ,DrawStripGraphic_AlignedMirroredLoop Jump to DrawStripGraphic_AlignedMirroredLoop until the rows are done.
54100 JR DrawStripGraphic_Done Jump to DrawStripGraphic_Done.
View the equivalent code in;
Prev: 53922 Up: Map Next: 54102