![]() |
Routines |
| Prev: 99AF | Up: Map | Next: 99E5 |
|
The inner loop of everything that moves. A sprite is width bytes by height rows, and the row-to-row step is left to SCREEN_ROW_UP rather than being computed here, because the display file's thirds make it anything but a simple addition.
It works upwards. The first row of a sprite's data is its bottom row, so an actor's +$03 and +$04 are the point its feet stand on rather than a top-left corner. Rendering the data top-down produces nothing recognisable; reversed, it comes out as a picture.
How each byte meets what is already on the screen is not decided by a branch. SPRITE_COMBINE_OPCODE hands back an opcode and it is written over the NOP in the middle of the loop, so the same six instructions become a plain copy, an OR, an XOR or an AND with nothing tested per byte. Read live during play the byte is $00 -- a NOP, so a plain copy.
|
||||
| BLIT_SPRITE | 99C9 | POP BC | ||
| 99CA | CALL SPRITE_COMBINE_OPCODE | Fetch the combining opcode and write it into the loop below. | ||
| 99CD | LD (BLIT_SPRITE_OP),A | |||
| 99D0 | CALL FETCH_SPRITE | Bitmap, size and destination. | ||
| BLIT_SPRITE_0 | 99D3 | PUSH BC | ||
| 99D4 | PUSH HL | |||
| BLIT_SPRITE_1 | 99D5 | LD A,(DE) | One byte of the sprite. | |
| 99D6 | INC DE | |||
| BLIT_SPRITE_OP | 99D7 | NOP | Assembled at run time: NOP, OR (HL), XOR (HL) or AND (HL). | |
| 99D8 | LD (HL),A | Store it and move one cell right, width times. | ||
| 99D9 | INC L | |||
| 99DA | DJNZ BLIT_SPRITE_1 | |||
| 99DC | POP HL | |||
| 99DD | CALL SCREEN_ROW_UP | Up one pixel row -- see SCREEN_ROW_UP. Sprites are stored and drawn from the bottom. | ||
| 99E0 | POP BC | Repeat for every row. | ||
| 99E1 | DEC C | |||
| 99E2 | JR NZ,BLIT_SPRITE_0 | |||
| 99E4 | RET | |||
| Prev: 99AF | Up: Map | Next: 99E5 |