![]() |
Routines |
| Prev: 63171 | Up: Map | Next: 63470 |
|
Used by the routines at AnimateIntroSprites and DrawIntroSprites.
Takes the two-byte position entry at HL (byte 0 = Y pixel row, byte 1 = X byte column) and the attribute byte in E (shadow; bit 7 set = erase mode, bit 7 clear = draw mode). Computes each screen pixel address by reading the row base from the screen row LUT at 35840 (indexed by Y) and adding the X column byte offset stored in shadow D. XORs 4 bytes of the fixed bitmap at 27900 into consecutive screen pixel memory for each of 32 pixel rows (4 attribute-cell rows of 8 pixel rows each). After the first pixel row of each attribute-cell row, derives the attribute memory high byte from the pixel address high byte and writes the attribute byte to 4 consecutive attribute cells — suppressed in erase mode.
|
||||||||
|
Initialise the bitmap source (HL=27900 via EX DE,HL) and compute IX into the screen row LUT at 35840 indexed by the Y pixel row. The row is shifted left into the LUT index directly (IX=35840 + Y × 2). Store the X column byte offset in shadow D and set the outer loop count (C=4 shadow, one iteration per attribute-cell row of 8 pixel rows).
|
||||||||
| XorBlitSprite | 63343 | LD DE,27900 | DE=27900 (bitmap source base address; becomes HL via EX DE,HL). | |||||
| 63346 | LD B,70 | B=70 (initial high byte; becomes 140 or 141 after RL B). | ||||||
| 63348 | LD C,(HL) | C=Y pixel row (byte 0 of the position entry). | ||||||
| 63349 | INC HL | Advance HL to byte 1 (X byte column). | ||||||
| 63350 | SLA C | SLA C; carry = bit 7 of Y (selects high byte 140 or 141). | ||||||
| 63352 | RL B | RL B; B=140 (or 141 if carry set) — high byte of LUT pointer. | ||||||
| 63354 | PUSH BC | Stash BC on the stack. | ||||||
| 63355 | LD A,(HL) | A=X byte column (byte 1 of the position entry). | ||||||
| 63356 | EXX | Switch to the shadow registers. | ||||||
| 63357 | LD D,A | D=X byte column offset (held in shadow across all loop iterations). | ||||||
| 63358 | EXX | Switch back to the normal registers. | ||||||
| 63359 | POP IX | POP IX; IX=35840 + Y × 2 (pointer into the screen row LUT). | ||||||
| 63361 | EX DE,HL | HL=27900 (bitmap source pointer); DE=old HL (discarded). | ||||||
| 63362 | EXX | Switch to the shadow registers. | ||||||
| 63363 | LD C,4 | C=4 (shadow, outer loop count: 4 attribute-cell rows). | ||||||
| 63365 | EXX | Switch back to the normal registers. | ||||||
|
Outer loop (4 iterations, one per attribute-cell row of 8 pixel rows). Compute the screen pixel address for the first row of this attribute cell: read shadow D (X column), add the LUT low byte from *(IX) to give E, then read the LUT high byte from *(IX+1) into D. Advance IX by two to the next LUT entry.
|
||||||||
| XorBlitSprite_OuterLoop | 63366 | EXX | Switch to the shadow registers. | |||||
| 63367 | LD A,D | A=D (X byte column offset). | ||||||
| 63368 | EXX | Switch back to the normal registers. | ||||||
| 63369 | ADD A,(IX+0) | A += *(IX) (LUT low byte); low byte of screen pixel address. | ||||||
| 63372 | INC IX | Advance IX to the LUT high byte. | ||||||
| 63374 | LD E,A | E=A (low byte of screen pixel address). | ||||||
| 63375 | LD D,(IX+0) | D=*(IX) (high byte of screen pixel address from LUT). | ||||||
| 63378 | INC IX | Advance IX to the next LUT entry. | ||||||
|
XOR 4 consecutive bytes of the bitmap at (HL)–(HL+3) into screen pixel memory at (DE)–(DE+3), advancing both pointers.
|
||||||||
| 63380 | LD A,(DE) | *(DE) ^= *(HL); advance DE and HL. | ||||||
| 63381 | XOR (HL) | |||||||
| 63382 | LD (DE),A | |||||||
| 63383 | INC DE | |||||||
| 63384 | INC HL | |||||||
| 63385 | LD A,(DE) | *(DE) ^= *(HL); advance DE and HL. | ||||||
| 63386 | XOR (HL) | |||||||
| 63387 | LD (DE),A | |||||||
| 63388 | INC DE | |||||||
| 63389 | INC HL | |||||||
| 63390 | LD A,(DE) | *(DE) ^= *(HL); advance DE and HL. | ||||||
| 63391 | XOR (HL) | |||||||
| 63392 | LD (DE),A | |||||||
| 63393 | INC HL | |||||||
| 63394 | INC DE | |||||||
| 63395 | LD A,(DE) | *(DE) ^= *(HL); advance HL. | ||||||
| 63396 | XOR (HL) | |||||||
| 63397 | LD (DE),A | |||||||
| 63398 | INC HL | |||||||
|
Derive the attribute memory address high byte from the current pixel address high byte in D. Three right-rotations expose the screen-third index in bits 0–1; OR with 88 gives the attribute area high byte (88–91).
|
||||||||
| 63399 | LD A,D | D = (RRCA × 3 of D) AND 3 OR 88 (attribute address high byte). | ||||||
| 63400 | RRCA | |||||||
| 63401 | RRCA | |||||||
| 63402 | RRCA | |||||||
| 63403 | AND 3 | |||||||
| 63405 | OR 88 | |||||||
| 63407 | LD D,A | |||||||
|
Test the erase-mode flag (bit 7 of shadow E). If set, skip writing the attribute byte so that the background colour is preserved during erase.
|
||||||||
| 63408 | EXX | Switch to shadow; A=E (attribute byte); switch back. | ||||||
| 63409 | LD A,E | |||||||
| 63410 | EXX | |||||||
| 63411 | BIT 7,A | Test bit 7 of A (erase-mode flag). | ||||||
| 63413 | JR NZ,XorBlitSprite_InnerSetup | If in erase mode, jump to XorBlitSprite_InnerSetup (skip attribute write). | ||||||
| 63415 | LD (DE),A | Write attribute byte to (DE), (DE−1), (DE−2) and (DE−3). | ||||||
| 63416 | DEC DE | |||||||
| 63417 | LD (DE),A | |||||||
| 63418 | DEC DE | |||||||
| 63419 | LD (DE),A | |||||||
| 63420 | DEC DE | |||||||
| 63421 | LD (DE),A | |||||||
| XorBlitSprite_InnerSetup | 63422 | EXX | Switch to shadow; B=7 (remaining pixel rows in this attribute-cell row); switch back. | |||||
| 63423 | LD B,7 | |||||||
| 63425 | EXX | |||||||
|
Inner loop (7 iterations, one per remaining pixel row in this attribute-cell row). Compute the screen address from the LUT and XOR 4 bitmap bytes into pixel memory. No attribute write.
|
||||||||
| XorBlitSprite_InnerLoop | 63426 | EXX | Switch to the shadow registers. | |||||
| 63427 | LD A,D | A=D (X byte column offset). | ||||||
| 63428 | EXX | Switch back to the normal registers. | ||||||
| 63429 | ADD A,(IX+0) | A += *(IX) (LUT low byte for this pixel row). | ||||||
| 63432 | INC IX | Advance IX to the LUT high byte. | ||||||
| 63434 | LD E,A | E=A (low byte of screen pixel address). | ||||||
| 63435 | LD D,(IX+0) | D=*(IX) (high byte of screen pixel address from LUT). | ||||||
| 63438 | INC IX | Advance IX to the next LUT entry. | ||||||
| 63440 | LD A,(DE) | *(DE) ^= *(HL); advance DE and HL. | ||||||
| 63441 | XOR (HL) | |||||||
| 63442 | LD (DE),A | |||||||
| 63443 | INC DE | |||||||
| 63444 | INC HL | |||||||
| 63445 | LD A,(DE) | *(DE) ^= *(HL); advance DE and HL. | ||||||
| 63446 | XOR (HL) | |||||||
| 63447 | LD (DE),A | |||||||
| 63448 | INC DE | |||||||
| 63449 | INC HL | |||||||
| 63450 | LD A,(DE) | *(DE) ^= *(HL); advance DE and HL. | ||||||
| 63451 | XOR (HL) | |||||||
| 63452 | LD (DE),A | |||||||
| 63453 | INC HL | |||||||
| 63454 | INC DE | |||||||
| 63455 | LD A,(DE) | *(DE) ^= *(HL); advance HL. | ||||||
| 63456 | XOR (HL) | |||||||
| 63457 | LD (DE),A | |||||||
| 63458 | INC HL | |||||||
| 63459 | EXX | Switch to shadow; decrement B (inner pixel row counter); switch back. | ||||||
| 63460 | DEC B | |||||||
| 63461 | EXX | |||||||
| 63462 | JR NZ,XorBlitSprite_InnerLoop | Loop back to XorBlitSprite_InnerLoop until all 7 pixel rows are blitted. | ||||||
| 63464 | EXX | Switch to shadow; decrement C (outer attribute-row counter); switch back. | ||||||
| 63465 | DEC C | |||||||
| 63466 | EXX | |||||||
| 63467 | JR NZ,XorBlitSprite_OuterLoop | Loop back to XorBlitSprite_OuterLoop until all 4 attribute-cell rows are blitted. | ||||||
| 63469 | RET | Return. | ||||||
| Prev: 63171 | Up: Map | Next: 63470 |