![]() |
Routines |
| Prev: AFE9 | Up: Map | Next: B115 |
|
Used by the routine at BuildShip.
Adds one part to the graphic of the ship. The sprite of the part is found in the table at SpriteTables_ShipParts and the place in the graphic where it goes in the table at SpriteTables_ShipPartPositions. The height of the ship is made at least as tall as the part. The mask of the part is ANDed into the graphic, one row at a time, then its picture is ORed in.
|
||||||||
| AddShipPart | B09C | LD HL,$AF95 | The ship-part sprites. | |||||
| B09F | LD C,(IX+$00) | Read offset 00 of IX into C. | ||||||
| B0A2 | DEC C | Step C back. | ||||||
| B0A3 | CALL GetTableEntry | Call GetTableEntry. | ||||||
| B0A6 | EX DE,HL | Swap DE and HL. | ||||||
| B0A7 | PUSH DE | Stash DE on the stack. | ||||||
| B0A8 | LD A,(IX+$00) | Read offset 00 of IX. | ||||||
| B0AB | LD C,A | C=A. | ||||||
| B0AC | DEC C | Step C back. | ||||||
| B0AD | LD HL,$AFD7 | The positions of the ship parts. | ||||||
| B0B0 | CALL GetTableEntry | Call GetTableEntry. | ||||||
| B0B3 | POP DE | Bring DE back off the stack. | ||||||
| B0B4 | PUSH DE | Stash DE on the stack. | ||||||
| B0B5 | PUSH HL | Stash HL on the stack. | ||||||
| B0B6 | DEC DE | Step DE back. | ||||||
| B0B7 | LD A,(DE) | Read DE. | ||||||
| B0B8 | INC DE | Advance DE. | ||||||
| B0B9 | LD B,A | B=A. | ||||||
| B0BA | LD A,($C1A9) | The height of the ship. | ||||||
| B0BD | CP B | Jump to AddShipPart_Picture2 if A is B or more. | ||||||
| B0BE | JR NC,AddShipPart_Picture2 | |||||||
| B0C0 | LD A,B | A=B. | ||||||
| B0C1 | LD ($C1A9),A | Update the height of the ship. | ||||||
| AddShipPart_Picture2 | B0C4 | LD A,(DE) | Read DE. | |||||
| B0C5 | LD B,A | B=A. | ||||||
| B0C6 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| B0C7 | INC DE | Advance DE. | ||||||
| B0C8 | LD A,(DE) | Read DE. | ||||||
| B0C9 | LD ($5C1D),A | The height of the part. | ||||||
| B0CC | INC DE | Advance DE. | ||||||
| B0CD | LD C,A | C=A. | ||||||
| B0CE | XOR A | Clear A. | ||||||
| AddShipPart_Multiply | B0CF | ADD A,C | A gains C. | |||||
| B0D0 | DJNZ AddShipPart_Multiply | Decrease B and jump to AddShipPart_Multiply until none remain. | ||||||
| B0D2 | LD C,A | C=A. | ||||||
| B0D3 | EX DE,HL | Swap DE and HL. | ||||||
| B0D4 | ADD HL,BC | HL gains BC. | ||||||
| B0D5 | EX DE,HL | Swap DE and HL. | ||||||
| B0D6 | LD A,(DE) | Read DE. | ||||||
| B0D7 | CP $FF | Jump to AddShipPart_Picture if A is FF. | ||||||
| B0D9 | JR Z,AddShipPart_Picture | |||||||
| B0DB | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| B0DC | LD B,A | B=A. | ||||||
| B0DD | LD A,($5C1D) | The height of the part. | ||||||
| B0E0 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| B0E1 | LD C,B | C=B. | ||||||
| B0E2 | JR AddShipPart_Row2 | Jump to AddShipPart_Row2. | ||||||
| AddShipPart_Mask | B0E4 | EX AF,AF' | Switch to the alternate accumulator and flags. | |||||
| AddShipPart_Row2 | B0E5 | LD B,C | B=C. | |||||
| B0E6 | PUSH HL | Stash HL on the stack. | ||||||
| AddShipPart_Erase | B0E7 | LD A,(DE) | Read DE. | |||||
| B0E8 | AND (HL) | Keep the bits of A that are set in the byte at HL. | ||||||
| B0E9 | LD (HL),A | Write A where HL points. | ||||||
| B0EA | INC DE | Advance DE. | ||||||
| B0EB | INC HL | Advance HL. | ||||||
| B0EC | DJNZ AddShipPart_Erase | Decrease B and jump to AddShipPart_Erase until none remain. | ||||||
| B0EE | POP HL | Bring HL back off the stack. | ||||||
| B0EF | LD A,$06 | A=06. | ||||||
| B0F1 | CALL AddAToHL | Call AddAToHL. | ||||||
| B0F4 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| B0F5 | DEC A | Step A back. | ||||||
| B0F6 | JR NZ,AddShipPart_Mask | Jump to AddShipPart_Mask if the zero flag is clear. | ||||||
| AddShipPart_Picture | B0F8 | POP HL | Bring HL back off the stack. | |||||
| B0F9 | POP DE | Bring DE back off the stack. | ||||||
| B0FA | LD A,(DE) | Read DE. | ||||||
| B0FB | LD B,A | B=A. | ||||||
| B0FC | LD C,A | C=A. | ||||||
| B0FD | INC DE | Advance DE. | ||||||
| B0FE | LD A,(DE) | Read DE. | ||||||
| B0FF | INC DE | Advance DE. | ||||||
| AddShipPart_Row | B100 | EX AF,AF' | Switch to the alternate accumulator and flags. | |||||
| B101 | LD B,C | B=C. | ||||||
| B102 | PUSH HL | Stash HL on the stack. | ||||||
| AddShipPart_Draw | B103 | LD A,(DE) | Read DE. | |||||
| B104 | OR (HL) | Set the bits of A that are set in the byte at HL. | ||||||
| B105 | LD (HL),A | Write A where HL points. | ||||||
| B106 | INC DE | Advance DE. | ||||||
| B107 | INC HL | Advance HL. | ||||||
| B108 | DJNZ AddShipPart_Draw | Decrease B and jump to AddShipPart_Draw until none remain. | ||||||
| B10A | POP HL | Bring HL back off the stack. | ||||||
| B10B | LD A,$06 | A=06. | ||||||
| B10D | CALL AddAToHL | Call AddAToHL. | ||||||
| B110 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| B111 | DEC A | Step A back. | ||||||
| B112 | JR NZ,AddShipPart_Row | Jump to AddShipPart_Row if the zero flag is clear. | ||||||
| B114 | RET | Return. | ||||||
| Prev: AFE9 | Up: Map | Next: B115 |