![]() |
Routines |
| Prev: 45033 | Up: Map | Next: 45333 |
|
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 | 45212 | LD HL,44949 | The ship-part sprites. | |||||
| 45215 | LD C,(IX+0) | Read offset 0 of IX into C. | ||||||
| 45218 | DEC C | Step C back. | ||||||
| 45219 | CALL GetTableEntry | Call GetTableEntry. | ||||||
| 45222 | EX DE,HL | Swap DE and HL. | ||||||
| 45223 | PUSH DE | Stash DE on the stack. | ||||||
| 45224 | LD A,(IX+0) | Read offset 0 of IX. | ||||||
| 45227 | LD C,A | C=A. | ||||||
| 45228 | DEC C | Step C back. | ||||||
| 45229 | LD HL,45015 | The positions of the ship parts. | ||||||
| 45232 | CALL GetTableEntry | Call GetTableEntry. | ||||||
| 45235 | POP DE | Bring DE back off the stack. | ||||||
| 45236 | PUSH DE | Stash DE on the stack. | ||||||
| 45237 | PUSH HL | Stash HL on the stack. | ||||||
| 45238 | DEC DE | Step DE back. | ||||||
| 45239 | LD A,(DE) | Read DE. | ||||||
| 45240 | INC DE | Advance DE. | ||||||
| 45241 | LD B,A | B=A. | ||||||
| 45242 | LD A,(49577) | The height of the ship. | ||||||
| 45245 | CP B | Jump to AddShipPart_Picture2 if A is B or more. | ||||||
| 45246 | JR NC,AddShipPart_Picture2 | |||||||
| 45248 | LD A,B | A=B. | ||||||
| 45249 | LD (49577),A | Update the height of the ship. | ||||||
| AddShipPart_Picture2 | 45252 | LD A,(DE) | Read DE. | |||||
| 45253 | LD B,A | B=A. | ||||||
| 45254 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| 45255 | INC DE | Advance DE. | ||||||
| 45256 | LD A,(DE) | Read DE. | ||||||
| 45257 | LD (23581),A | The height of the part. | ||||||
| 45260 | INC DE | Advance DE. | ||||||
| 45261 | LD C,A | C=A. | ||||||
| 45262 | XOR A | Clear A. | ||||||
| AddShipPart_Multiply | 45263 | ADD A,C | A gains C. | |||||
| 45264 | DJNZ AddShipPart_Multiply | Decrease B and jump to AddShipPart_Multiply until none remain. | ||||||
| 45266 | LD C,A | C=A. | ||||||
| 45267 | EX DE,HL | Swap DE and HL. | ||||||
| 45268 | ADD HL,BC | HL gains BC. | ||||||
| 45269 | EX DE,HL | Swap DE and HL. | ||||||
| 45270 | LD A,(DE) | Read DE. | ||||||
| 45271 | CP 255 | Jump to AddShipPart_Picture if A is 255. | ||||||
| 45273 | JR Z,AddShipPart_Picture | |||||||
| 45275 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| 45276 | LD B,A | B=A. | ||||||
| 45277 | LD A,(23581) | The height of the part. | ||||||
| 45280 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| 45281 | LD C,B | C=B. | ||||||
| 45282 | JR AddShipPart_Row2 | Jump to AddShipPart_Row2. | ||||||
| AddShipPart_Mask | 45284 | EX AF,AF' | Switch to the alternate accumulator and flags. | |||||
| AddShipPart_Row2 | 45285 | LD B,C | B=C. | |||||
| 45286 | PUSH HL | Stash HL on the stack. | ||||||
| AddShipPart_Erase | 45287 | LD A,(DE) | Read DE. | |||||
| 45288 | AND (HL) | Keep the bits of A that are set in the byte at HL. | ||||||
| 45289 | LD (HL),A | Write A where HL points. | ||||||
| 45290 | INC DE | Advance DE. | ||||||
| 45291 | INC HL | Advance HL. | ||||||
| 45292 | DJNZ AddShipPart_Erase | Decrease B and jump to AddShipPart_Erase until none remain. | ||||||
| 45294 | POP HL | Bring HL back off the stack. | ||||||
| 45295 | LD A,6 | A=6. | ||||||
| 45297 | CALL AddAToHL | Call AddAToHL. | ||||||
| 45300 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| 45301 | DEC A | Step A back. | ||||||
| 45302 | JR NZ,AddShipPart_Mask | Jump to AddShipPart_Mask if the zero flag is clear. | ||||||
| AddShipPart_Picture | 45304 | POP HL | Bring HL back off the stack. | |||||
| 45305 | POP DE | Bring DE back off the stack. | ||||||
| 45306 | LD A,(DE) | Read DE. | ||||||
| 45307 | LD B,A | B=A. | ||||||
| 45308 | LD C,A | C=A. | ||||||
| 45309 | INC DE | Advance DE. | ||||||
| 45310 | LD A,(DE) | Read DE. | ||||||
| 45311 | INC DE | Advance DE. | ||||||
| AddShipPart_Row | 45312 | EX AF,AF' | Switch to the alternate accumulator and flags. | |||||
| 45313 | LD B,C | B=C. | ||||||
| 45314 | PUSH HL | Stash HL on the stack. | ||||||
| AddShipPart_Draw | 45315 | LD A,(DE) | Read DE. | |||||
| 45316 | OR (HL) | Set the bits of A that are set in the byte at HL. | ||||||
| 45317 | LD (HL),A | Write A where HL points. | ||||||
| 45318 | INC DE | Advance DE. | ||||||
| 45319 | INC HL | Advance HL. | ||||||
| 45320 | DJNZ AddShipPart_Draw | Decrease B and jump to AddShipPart_Draw until none remain. | ||||||
| 45322 | POP HL | Bring HL back off the stack. | ||||||
| 45323 | LD A,6 | A=6. | ||||||
| 45325 | CALL AddAToHL | Call AddAToHL. | ||||||
| 45328 | EX AF,AF' | Switch to the alternate accumulator and flags. | ||||||
| 45329 | DEC A | Step A back. | ||||||
| 45330 | JR NZ,AddShipPart_Row | Jump to AddShipPart_Row if the zero flag is clear. | ||||||
| 45332 | RET | Return. | ||||||
| Prev: 45033 | Up: Map | Next: 45333 |