| Alien (BUGFIX 1.7) | Routines |
| Prev: 39830 | Up: Map | Next: 40007 |
|
XOR-blits the Jones cat sprite (24 px wide × 21 rows, run-cycle frame 0-4 from the pointer table after JonesPhase) at pixel-X JonesPos on its fixed track (char rows 9-11). First XORs the ink bits of the 4×2 attribute block under the cat (mask = inverted top-left-of-screen ink, so the flash contrasts with the background).
Each sprite row's 3 bytes are sub-shifted by k = JonesPos&7 into 4 output bytes: for k < 4 the SRL/RR chain here right-shifts by k (the self-modifying JR at BlitJonesShiftCode is patched to skip 3-k groups); for k >= 4 BlitJonesShifted left-shifts by 8-k instead — same result, at most 4 shift passes either way.
The DJNZ at the end re-uses B: entered with B=2 (AnimJones) it falls into AdvanceJonesPos for the redraw pass.
|
||||
| 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 COLUMN 0-16 | ||
| 39848 | AND 31 | |||
| 39850 | LD E,A | |||
| 39851 | LD D,0 | DE = the cat's character column | ||
| 39853 | LD HL,19488 | HL = $4C20 (col 0, char row 9, pixel row 4): the run track | ||
| 39856 | ADD HL,DE | + column = the cat sprite's top-left screen address | ||
| 39857 | LD (39751),HL | stash it in AlienScreenPtr | ||
| 39860 | LD HL,22848 | HL = AttrRow10 (attribute row 10, col 0) | ||
| 39863 | ADD HL,DE | + column = attr address of the cat's cells | ||
| 39864 | LD DE,29 | row stride 29, not 28: the 2nd flash row lands one cell right (harmless original quirk) | ||
| 39867 | LD C,2 | 2 attribute rows | ||
| 39869 | LD B,4 | 4 attribute columns per row | ||
| 39871 | LD A,(HL) | flash one attribute cell: | ||
| 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 run-cycle frame (0-4) | ||
| 39886 | LD D,0 | |||
| 39888 | INC HL | HL -> the frame-pointer table that follows | ||
| 39889 | ADD HL,DE | |||
| 39890 | ADD HL,DE | HL -> table[phase] (2 bytes/entry) | ||
| 39891 | LD E,(HL) | DE = this frame's sprite data | ||
| 39892 | INC HL | |||
| 39893 | LD D,(HL) | (3 bytes x 21 rows per frame) | ||
| 39894 | LD A,(39750) | A = JonesPos | ||
| 39897 | AND 7 | A = sub-cell X offset k (0-7) | ||
| 39899 | CP 4 | |||
| 39901 | JP NC,40040 | k >= 4: shift the other way (BlitJonesShifted) | ||
| 39904 | CPL | A = 3-k: shift groups to SKIP | ||
| 39905 | AND 3 | (so k of the 3 SRL/RR groups run = right shift by k) | ||
| 39907 | LD L,A | patch offset = (3-k) * 7 bytes | ||
| 39908 | RLCA | (each skipped shift group is 7 bytes long) | ||
| 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 cat frame | ||
| 39917 | PUSH BC | save row counter | ||
| 39918 | EX DE,HL | HL = sprite data ptr | ||
| 39919 | LD B,(HL) | load the row's 3 sprite bytes | ||
| 39920 | INC HL | into B, C, E | ||
| 39921 | LD C,(HL) | |||
| 39922 | INC HL | |||
| 39923 | LD E,(HL) | |||
| 39924 | INC HL | |||
| 39925 | PUSH HL | save advanced sprite ptr | ||
| 39926 | LD HL,(39751) | HL = this row's screen address | ||
| 39929 | PUSH HL | |||
| 39930 | XOR A | A = 0: spill byte for bits shifted out | ||
|
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 | XOR-blit the 4 result bytes: | ||
| 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' | recover the spill byte | ||
| 39968 | XOR (HL) | |||
| 39969 | LD (HL),A | XOR-blit carry spill byte | ||
| 39970 | POP HL | back to the row-start screen address | ||
| 39971 | LD A,H | finished pixel row 7 of this char row? | ||
| 39972 | AND 7 | |||
| 39974 | CP 7 | |||
| 39976 | JR Z,39981 | yes: char-row / third stepping | ||
| 39978 | INC H | no: next pixel row is one display bank up | ||
| 39979 | JR 39996 | |||
| 39981 | LD A,L | last char row of this screen third? | ||
| 39982 | CP 224 | |||
| 39984 | JR NC,39992 | yes: hop to the next third | ||
| 39986 | LD BC,63776 | no: -1760 = pixel-row 0 of the next char row | ||
| 39989 | ADD HL,BC | |||
| 39990 | JR 39996 | |||
| 39992 | LD BC,32 | +32 carries into H: row 0 of the next third | ||
| 39995 | ADD HL,BC | |||
| 39996 | LD (39751),HL | store the next row's screen address | ||
| 39999 | POP DE | DE = sprite ptr | ||
| 40000 | POP BC | |||
| 40001 | DJNZ 39917 | next of the 21 rows | ||
| 40003 | POP BC | B = caller's iteration count | ||
| 40004 | DJNZ 40007 | B was 2 (AnimJones): advance pos and redraw | ||
| 40006 | RET | B was 1: single XOR pass only | ||
| Prev: 39830 | Up: Map | Next: 40007 |