Prev: 40007 Up: Map Next: 40149
40040: BlitJonesShifted
The cat XOR blit for sub-cell offsets k = JonesPos&7 >= 4. Rather than right-shifting each sprite row by k (up to 7 passes), it left-shifts by 8-k (at most 4 passes) with SLA/RL chains and writes the spill byte FIRST — placing the sprite k pixels into the 4-byte output field, the same result as BlitJonesFrame's right-shift path. The number of chain groups to skip is patched into the self-modifying JR at BlitJonesShiftCode2, then 21 rows of 4 bytes are XOR-blitted.
40040 SUB 4 A = k-4: shift groups to SKIP (8-k of 4 run)
40042 LD L,A patch offset = (k-4) * 7 bytes
40043 RLCA
40044 RLCA
40045 RLCA A = shift_count * 8
40046 SUB L A = shift_count * 7 (JR offset into SLA/RL chain)
40047 LD (40067),A patch BlitJonesShiftCode2 JR offset
40050 LD B,21 21 pixel rows
40052 PUSH BC save row counter
40053 EX DE,HL HL = sprite data ptr
40054 LD B,(HL) load the row's 3 sprite bytes
40055 INC HL into B, C, E
40056 LD C,(HL)
40057 INC HL
40058 LD E,(HL)
40059 INC HL
40060 PUSH HL save advanced sprite ptr
40061 LD HL,(39751) HL = this row's screen address
40064 PUSH HL
40065 XOR A A = 0: collects bits shifted out of B's top
40066 JR 40066 self-modifying: JR offset patched to skip N SLA/RL groups
40068 SLA E left-shift the 24-bit row across A:B:C:E;
40070 RL C shifting left by 8-k places the sprite k
40072 RL B pixels from byte A's left edge — the same
40074 RLA result as a right shift by k, but never
40075 SLA E more than 4 shift-group passes
40077 RL C
40079 RL B
40081 RLA
40082 SLA E
40084 RL C
40086 RL B
40088 RLA
40089 SLA E
40091 RL C
40093 RL B
40095 RLA
40096 XOR (HL) XOR-blit the 4 result bytes, spill byte first
40097 LD (HL),A
40098 INC HL
40099 LD A,B
40100 XOR (HL)
40101 LD (HL),A
40102 INC HL
40103 LD A,C
40104 XOR (HL)
40105 LD (HL),A
40106 INC HL
40107 LD A,E
40108 XOR (HL)
40109 LD (HL),A
40110 POP HL back to the row-start screen address
40111 LD A,H finished pixel row 7 of this char row?
40112 AND 7
40114 CP 7
40116 JR Z,40121 yes: char-row / third stepping
40118 INC H no: next pixel row is one display bank up
40119 JR 40136
40121 LD A,L last char row of this screen third?
40122 CP 224
40124 JR NC,40132 yes: hop to the next third
40126 LD BC,63776 no: -1760 = pixel-row 0 of the next char row
40129 ADD HL,BC
40130 JR 40136
40132 LD BC,32 +32 carries into H: row 0 of the next third
40135 ADD HL,BC
40136 LD (39751),HL store the next row's screen address
40139 POP DE DE = sprite ptr
40140 POP BC
40141 DJNZ 40052 next of the 21 rows
40143 POP BC B = caller's iteration count
40144 DEC B (mirror of BlitJonesFrame's ending)
40145 JP NZ,40007 B was 2: advance pos and redraw
40148 RET B was 1: single XOR pass only
Prev: 40007 Up: Map Next: 40149