![]() |
Routines |
| Prev: C84F | Up: Map | Next: C949 |
|
Used by the routines at Main_Game_Loop, Remove_Entity_From_List, Process_Cluster_Entity and Apply_Entity_Velocity.
Entry point for drawing a narrow entity sprite. Sets draw mode (attribute writes enabled) and falls through to Render_Narrow_Entity_Sprite. XOR-renders 8 rows of 2 bytes each; the sprite type is looked up in Sprite_Pixel_Data_Table for the pixel data address, and the entity colour is written to the 2 attribute cells flanking each pixel row.
|
||||||||
| Draw_Narrow_Entity_Sprite | C856 | EXX | Set draw mode: set the attribute-write flag in D'. | |||||
| C857 | LD D,$01 | |||||||
| C859 | EXX | |||||||
|
This entry point is used by the routine at Erase_Narrow_Entity_Sprite.
Compute the sprite pixel data pointer and screen coordinate.
|
||||||||
| Render_Narrow_Entity_Sprite | C85A | LD B,H | Copy the entity record pointer to BC. | |||||
| C85B | LD C,L | |||||||
| C85C | LD E,(HL) | Read the sprite type byte and form a word offset in DE. | ||||||
| C85D | SLA E | |||||||
| C85F | LD D,$00 | |||||||
| C861 | LD HL,$C60C | Look up the sprite pixel data address in the table at Sprite_Pixel_Data_Table. | ||||||
| C864 | ADD HL,DE | |||||||
| C865 | LD E,(HL) | |||||||
| C866 | INC HL | |||||||
| C867 | LD D,(HL) | |||||||
| C868 | LD H,B | Restore the entity record pointer to HL. | ||||||
| C869 | LD L,C | |||||||
| C86A | INC HL | Advance past the sprite type byte and load the screen row address high byte from the entity record. | ||||||
| C86B | LD B,$46 | |||||||
| C86D | LD C,(HL) | |||||||
| C86E | INC HL | |||||||
| C86F | SLA C | Shift the coordinate into B to build the screen address high byte. | ||||||
| C871 | RL B | |||||||
| C873 | PUSH BC | Stash the screen coordinate on the stack. | ||||||
| C874 | LD A,(HL) | Load the column byte, clear HL, and distribute its bits into L via successive right-rotations to form the pixel offset. | ||||||
| C875 | AND A | |||||||
| C876 | LD HL,$0000 | |||||||
| C879 | RRA | |||||||
| C87A | RR L | |||||||
| C87C | RRA | |||||||
| C87D | RR L | |||||||
| C87F | RRA | |||||||
| C880 | RR L | |||||||
| C882 | RRC L | |||||||
| C884 | ADD HL,DE | Add the sprite data base to the offset, set BC as the sprite pixel data pointer, and restore the screen coordinate. | ||||||
| C885 | LD B,H | |||||||
| C886 | LD C,L | |||||||
| C887 | POP HL | |||||||
| C888 | EXX | |||||||
| C889 | LD C,A | Stash the column offset in alternate C and return to the main register set. | ||||||
| C88A | EXX | |||||||
|
Row 1: XOR-render the first sprite row and optionally write the entity colour to the flanking attribute cells.
|
||||||||
| C88B | ADD A,(HL) | Compute the first screen row address from the entity record into DE. | ||||||
| C88C | LD E,A | |||||||
| C88D | INC HL | |||||||
| C88E | LD D,(HL) | |||||||
| C88F | INC HL | |||||||
| C890 | LD A,(BC) | XOR-render 2 sprite pixel bytes at the first screen row. | ||||||
| C891 | EX DE,HL | |||||||
| C892 | XOR (HL) | |||||||
| C893 | LD (HL),A | |||||||
| C894 | INC BC | |||||||
| C895 | INC HL | |||||||
| C896 | LD A,(BC) | |||||||
| C897 | INC BC | |||||||
| C898 | XOR (HL) | |||||||
| C899 | LD (HL),A | |||||||
| C89A | EXX | Check whether attribute writes are enabled; jump to Render_Narrow_Entity_Sprite_Row2 to skip the colour write in erase mode. | ||||||
| C89B | LD A,D | |||||||
| C89C | AND A | |||||||
| C89D | EXX | |||||||
| C89E | JR Z,Render_Narrow_Entity_Sprite_Row2 | |||||||
| C8A0 | LD A,H | Convert the screen address high byte to an attribute address. | ||||||
| C8A1 | RRCA | |||||||
| C8A2 | RRCA | |||||||
| C8A3 | RRCA | |||||||
| C8A4 | AND %00000011 | Mask to the attribute page bits. | ||||||
| C8A6 | OR %01011000 | Set the attribute area high byte. | ||||||
| C8A8 | LD H,A | Update H to point into attribute RAM. | ||||||
| C8A9 | EXX | Fetch the entity colour via B' and write it to the first attribute cell. | ||||||
| C8AA | LD A,B | |||||||
| C8AB | EXX | |||||||
| C8AC | LD (HL),A | |||||||
| C8AD | DEC HL | |||||||
| C8AE | LD (HL),A | Write the entity colour to the second attribute cell. | ||||||
|
Rows 2–7: XOR-render the remaining sprite rows without attribute writes (attribute colour was set once on row 1).
|
||||||||
| Render_Narrow_Entity_Sprite_Row2 | C8AF | EX DE,HL | Restore the entity record pointer and fetch the column offset from alternate C. | |||||
| C8B0 | EXX | |||||||
| C8B1 | LD A,C | |||||||
| C8B2 | EXX | |||||||
| C8B3 | ADD A,(HL) | Compute the second screen row address from the entity record. | ||||||
| C8B4 | LD E,A | |||||||
| C8B5 | INC HL | |||||||
| C8B6 | LD D,(HL) | |||||||
| C8B7 | INC HL | |||||||
| C8B8 | LD A,(BC) | XOR-render 2 sprite bytes at the second screen row and restore the entity record pointer. | ||||||
| C8B9 | EX DE,HL | |||||||
| C8BA | XOR (HL) | |||||||
| C8BB | LD (HL),A | |||||||
| C8BC | INC BC | |||||||
| C8BD | INC HL | |||||||
| C8BE | LD A,(BC) | |||||||
| C8BF | INC BC | |||||||
| C8C0 | XOR (HL) | |||||||
| C8C1 | LD (HL),A | |||||||
| C8C2 | EX DE,HL | |||||||
| C8C3 | EXX | Fetch the column offset from alternate C. | ||||||
| C8C4 | LD A,C | |||||||
| C8C5 | EXX | |||||||
| C8C6 | ADD A,(HL) | Compute the third screen row address from the entity record. | ||||||
| C8C7 | LD E,A | |||||||
| C8C8 | INC HL | |||||||
| C8C9 | LD D,(HL) | |||||||
| C8CA | INC HL | |||||||
| C8CB | LD A,(BC) | XOR-render 2 sprite bytes at the third screen row and restore. | ||||||
| C8CC | EX DE,HL | |||||||
| C8CD | XOR (HL) | |||||||
| C8CE | LD (HL),A | |||||||
| C8CF | INC BC | |||||||
| C8D0 | INC HL | |||||||
| C8D1 | LD A,(BC) | |||||||
| C8D2 | INC BC | |||||||
| C8D3 | XOR (HL) | |||||||
| C8D4 | LD (HL),A | |||||||
| C8D5 | EX DE,HL | |||||||
| C8D6 | EXX | Fetch the column offset from alternate C. | ||||||
| C8D7 | LD A,C | |||||||
| C8D8 | EXX | |||||||
| C8D9 | ADD A,(HL) | Compute the fourth screen row address from the entity record. | ||||||
| C8DA | LD E,A | |||||||
| C8DB | INC HL | |||||||
| C8DC | LD D,(HL) | |||||||
| C8DD | INC HL | |||||||
| C8DE | LD A,(BC) | XOR-render 2 sprite bytes at the fourth screen row and restore. | ||||||
| C8DF | EX DE,HL | |||||||
| C8E0 | XOR (HL) | |||||||
| C8E1 | LD (HL),A | |||||||
| C8E2 | INC BC | |||||||
| C8E3 | INC HL | |||||||
| C8E4 | LD A,(BC) | |||||||
| C8E5 | INC BC | |||||||
| C8E6 | XOR (HL) | |||||||
| C8E7 | LD (HL),A | |||||||
| C8E8 | EX DE,HL | |||||||
| C8E9 | EXX | Fetch the column offset from alternate C. | ||||||
| C8EA | LD A,C | |||||||
| C8EB | EXX | |||||||
| C8EC | ADD A,(HL) | Compute the fifth screen row address from the entity record. | ||||||
| C8ED | LD E,A | |||||||
| C8EE | INC HL | |||||||
| C8EF | LD D,(HL) | |||||||
| C8F0 | INC HL | |||||||
| C8F1 | LD A,(BC) | XOR-render 2 sprite bytes at the fifth screen row and restore. | ||||||
| C8F2 | EX DE,HL | |||||||
| C8F3 | XOR (HL) | |||||||
| C8F4 | LD (HL),A | |||||||
| C8F5 | INC BC | |||||||
| C8F6 | INC HL | |||||||
| C8F7 | LD A,(BC) | |||||||
| C8F8 | INC BC | |||||||
| C8F9 | XOR (HL) | |||||||
| C8FA | LD (HL),A | |||||||
| C8FB | EX DE,HL | |||||||
| C8FC | EXX | Fetch the column offset from alternate C. | ||||||
| C8FD | LD A,C | |||||||
| C8FE | EXX | |||||||
| C8FF | ADD A,(HL) | Compute the sixth screen row address from the entity record. | ||||||
| C900 | LD E,A | |||||||
| C901 | INC HL | |||||||
| C902 | LD D,(HL) | |||||||
| C903 | INC HL | |||||||
| C904 | LD A,(BC) | XOR-render 2 sprite bytes at the sixth screen row and restore. | ||||||
| C905 | EX DE,HL | |||||||
| C906 | XOR (HL) | |||||||
| C907 | LD (HL),A | |||||||
| C908 | INC BC | |||||||
| C909 | INC HL | |||||||
| C90A | LD A,(BC) | |||||||
| C90B | INC BC | |||||||
| C90C | XOR (HL) | |||||||
| C90D | LD (HL),A | |||||||
| C90E | EX DE,HL | |||||||
| C90F | EXX | Fetch the column offset from alternate C. | ||||||
| C910 | LD A,C | |||||||
| C911 | EXX | |||||||
| C912 | ADD A,(HL) | Compute the seventh screen row address from the entity record. | ||||||
| C913 | LD E,A | |||||||
| C914 | INC HL | |||||||
| C915 | LD D,(HL) | |||||||
| C916 | INC HL | |||||||
| C917 | LD A,(BC) | XOR-render 2 sprite bytes at the seventh screen row and restore the entity record pointer. | ||||||
| C918 | EX DE,HL | |||||||
| C919 | XOR (HL) | |||||||
| C91A | LD (HL),A | |||||||
| C91B | INC BC | |||||||
| C91C | INC HL | |||||||
| C91D | LD A,(BC) | |||||||
| C91E | INC BC | |||||||
| C91F | XOR (HL) | |||||||
| C920 | LD (HL),A | |||||||
| C921 | EX DE,HL | |||||||
|
Row 8: XOR-render the final sprite row and write the entity colour to the flanking attribute cells if in draw mode.
|
||||||||
| C922 | EXX | Fetch the column offset from alternate C. | ||||||
| C923 | LD A,C | |||||||
| C924 | EXX | |||||||
| C925 | ADD A,(HL) | Compute the eighth screen row address from the entity record. | ||||||
| C926 | LD E,A | |||||||
| C927 | INC HL | |||||||
| C928 | LD D,(HL) | |||||||
| C929 | INC HL | |||||||
| C92A | LD A,(BC) | XOR-render 2 sprite bytes at the eighth screen row. | ||||||
| C92B | EX DE,HL | |||||||
| C92C | XOR (HL) | |||||||
| C92D | LD (HL),A | |||||||
| C92E | INC BC | |||||||
| C92F | INC HL | |||||||
| C930 | LD A,(BC) | |||||||
| C931 | INC BC | |||||||
| C932 | XOR (HL) | |||||||
| C933 | LD (HL),A | |||||||
| C934 | EXX | Return without writing attributes if in erase mode. | ||||||
| C935 | LD A,D | |||||||
| C936 | AND A | |||||||
| C937 | EXX | |||||||
| C938 | RET Z | |||||||
| C939 | LD A,H | Convert the screen address high byte to an attribute address. | ||||||
| C93A | RRCA | |||||||
| C93B | RRCA | |||||||
| C93C | RRCA | |||||||
| C93D | AND %00000011 | Mask to the attribute page bits. | ||||||
| C93F | OR %01011000 | Set the attribute area high byte. | ||||||
| C941 | LD H,A | Update H to point into attribute RAM. | ||||||
| C942 | EXX | Fetch the entity colour via B' and write it to the first attribute cell. | ||||||
| C943 | LD A,B | |||||||
| C944 | EXX | |||||||
| C945 | LD (HL),A | |||||||
| C946 | DEC HL | Write the entity colour to the second attribute cell. | ||||||
| C947 | LD (HL),A | |||||||
| C948 | RET | Return. | ||||||
| Prev: C84F | Up: Map | Next: C949 |