Prev: 39830 Up: Map Next: 40007
39832: BlitJonesFrame
Blits the alien tail (Y channel) XOR sprite for the current phase and position. First XORs ink colour bits of a 4x2 attribute block to produce a flash effect. Then loads the current Y-phase sprite pointer (3 bytes/row, 21 rows) and chooses between an unshifted XOR blit (JonesPos&7 < 4) or a shifted one (>= 4). The shift amount is encoded directly into the self-modifying JR at BlitJonesShiftCode (the JR offset byte is patched to select how many SRL/RR passes execute). DJNZ at the end re-uses B to call AdvanceJonesPos when B=2.
39832 PUSH BC save B (iteration count)
39833 LD A,(22528) A = attribute at top-left of screen (AttrFileOrigin)
39836 CPL
39837 AND 7 invert and mask ink colour bits
39839 LD (39873),A patch XOR 7 opcode operand for attribute flash
39842 LD A,(39750) A = JonesPos (pixel Y offset 0-135)
39845 RRA
39846 RRA
39847 RRA A = JonesPos >> 3 (character row 0-16)
39848 AND 31
39850 LD E,A
39851 LD D,0 DE = char row index
39853 LD HL,19488 HL = 0x4C00+1 (display col 1, char-row 0)
39856 ADD HL,DE HL = screen row address for JonesPos
39857 LD (39751),HL AlienScreenPtr = screen row ptr
39860 LD HL,22848 HL = AttrRow10 (attribute row 10, col 0)
39863 ADD HL,DE HL = attr address for JonesPos char row
39864 LD DE,29 DE = attr row stride - 4 (skip to next pair)
39867 LD C,2 2 attribute rows
39869 LD B,4 4 attribute columns per row
39871 LD A,(HL)
39872 XOR 7 toggle ink colour (self-modifying: operand byte patched)
39874 LD (HL),A write flashed attribute
39875 INC HL
39876 DJNZ 39871 next column
39878 ADD HL,DE skip to next attribute row
39879 DEC C
39880 JR NZ,39869 next row
39882 LD HL,39753 HL -> JonesPhase
39885 LD E,(HL) E = current Y phase (0-4)
39886 LD D,0
39888 INC HL HL -> Y frame pointer table
39889 ADD HL,DE
39890 ADD HL,DE HL -> table[phase] (2 bytes/entry)
39891 LD E,(HL)
39892 INC HL
39893 LD D,(HL) DE = tail sprite data ptr for this phase
39894 LD A,(39750) A = JonesPos
39897 AND 7 A = sub-character Y pixel offset (0-7)
39899 CP 4
39901 JP NC,40040 >= 4: shifted blit (BlitJonesShifted)
39904 CPL
39905 AND 3 shift count = 3-(JonesPos&7) in [0,3]
39907 LD L,A
39908 RLCA
39909 RLCA
39910 RLCA A = shift_count * 8
39911 SUB L A = shift_count * 7 (bytes to skip in shift chain)
39912 LD (39932),A patch JR offset: BlitJonesShiftCode entry skips N SRL/RR pairs
39915 LD B,21 21 pixel rows per tail frame
39917 PUSH BC
39918 EX DE,HL
39919 LD B,(HL)
39920 INC HL
39921 LD C,(HL)
39922 INC HL
39923 LD E,(HL)
39924 INC HL
39925 PUSH HL
39926 LD HL,(39751)
39929 PUSH HL
39930 XOR A
Self-modifying right-shift chain. The JR operand byte is patched before entry to skip 0-3 SRL/RR groups, giving a right-shift of 0-3 bits across the 3+1 sprite bytes in {B,C,E,A}. After shifting, the result is XOR-blitted to screen.
39931 JR 39931 self-modifying: JR offset patched to skip N SRL/RR groups
39933 SRL B shift group 3 (shift 3 bits right)
39935 RR C
39937 RR E
39939 RRA
39940 SRL B shift group 2
39942 RR C
39944 RR E
39946 RRA
39947 SRL B shift group 1 (shift 1 bit right)
39949 RR C
39951 RR E
39953 RRA
39954 EX AF,AF' swap: A' = carry spill byte
39955 LD A,B
39956 XOR (HL)
39957 LD (HL),A XOR-blit byte 0 to screen
39958 INC HL
39959 LD A,C
39960 XOR (HL)
39961 LD (HL),A XOR-blit byte 1
39962 INC HL
39963 LD A,E
39964 XOR (HL)
39965 LD (HL),A XOR-blit byte 2
39966 INC HL
39967 EX AF,AF'
39968 XOR (HL)
39969 LD (HL),A XOR-blit carry spill byte
39970 POP HL
39971 LD A,H
39972 AND 7
39974 CP 7
39976 JR Z,39981
39978 INC H
39979 JR 39996
39981 LD A,L
39982 CP 224
39984 JR NC,39992
39986 LD BC,63776
39989 ADD HL,BC
39990 JR 39996
39992 LD BC,32
39995 ADD HL,BC
39996 LD (39751),HL
39999 POP DE
40000 POP BC
40001 DJNZ 39917
40003 POP BC
40004 DJNZ 40007
40006 RET
Prev: 39830 Up: Map Next: 40007