![]() |
Routines |
| Prev: AF7B | Up: Map | Next: B09C |
|
Builds the graphic of the ship from the parts that have been fitted. Copies the base of the ship to ShipWorkArea_ShipGraphic and adds each of the nine parts that are flagged at CurrentPlayerState_Parts with AddShipPart. Then works out the height of the ship from the parts, the position of the buffer to draw it from and the vertical position of the ship.
|
||||
| BuildShip | AFE9 | LD A,($F5EE) | The number stored for the first part. | |
| AFEC | ADD A,A | Double that number. | ||
| AFED | LD ($F5EF),A | Use the double as the second part's number. | ||
| AFF0 | LD A,$02 | Both scroll limits start at two. | ||
| AFF2 | LD ($5C3E),A | The horizontal limit. | ||
| AFF5 | LD ($5C3F),A | The vertical limit. | ||
| AFF8 | LD BC,$0054 | The base graphic is 54 bytes. | ||
| AFFB | LD DE,$F755 | The ship graphic is built at ShipWorkArea_ShipGraphic. | ||
| AFFE | LD HL,$C891 | The base graphic is at ShipBaseGraphic. | ||
| B001 | LDIR | Copy the base graphic into the buffer. | ||
| B003 | LD IX,$F5EE | The nine part flags start at CurrentPlayerState_Parts. | ||
| B007 | LD A,$0E | The ship starts 0E rows tall. | ||
| B009 | LD ($C1A9),A | That height. | ||
| B00C | LD B,$09 | Nine parts. | ||
| BuildShip_Loop | B00E | PUSH BC | Keep the part count. | |
| B00F | LD A,(IX+$00) | This part's number. | ||
| B012 | AND A | Add the part when a number is stored. | ||
| B013 | CALL NZ,AddShipPart | |||
| B016 | INC IX | The next part flag. | ||
| B018 | POP BC | Back to the part count. | ||
| B019 | DJNZ BuildShip_Loop | Repeat for all nine parts. | ||
| B01B | LD A,($C1A9) | The height of the ship. | ||
| B01E | LD B,A | B=A. | ||
| B01F | LD A,$28 | A=28. | ||
| B021 | SUB B | Subtract B from A. | ||
| B022 | ADD A,A | Double A. | ||
| B023 | LD E,A | E=A. | ||
| B024 | ADD A,A | Double A. | ||
| B025 | ADD A,E | A gains E. | ||
| B026 | LD E,A | E=A. | ||
| B027 | LD D,$00 | Clear D. | ||
| B029 | LD HL,$F6B9 | The ship work area. | ||
| B02C | ADD HL,DE | HL gains DE. | ||
| B02D | LD ($C1AA),HL | Update the ship buffer address. | ||
| B030 | LD A,($C903) | The row the ship was drawn on. | ||
| B033 | LD B,A | B=A. | ||
| B034 | LD A,($C1A9) | The height of the ship. | ||
| B037 | SUB $0E | Subtract 0E from A. | ||
| B039 | ADD A,$6F | Add 6F to A. | ||
| B03B | OR %00000111 | Set the bits of A that are set in 07. | ||
| B03D | LD ($C903),A | Update the row the ship was drawn on. | ||
| B040 | SUB B | Subtract B from A. | ||
| B041 | LD ($C8EE),A | Update the high byte of the ship's vertical speed. | ||
| B044 | LD IX,$C8E5 | The ship. | ||
| B048 | CALL FindVerticalMove | Call FindVerticalMove. | ||
| B04B | LD (IX+$04),H | Write H to offset 04 of IX. | ||
| B04E | LD (IX+$05),L | Write L to offset 05 of IX. | ||
| B051 | CALL SetShipSpeeds | Call SetShipSpeeds. | ||
| B054 | LD A,($C1A9) | The height of the ship. | ||
| B057 | LD B,A | B=A. | ||
| B058 | LD A,(IX+$1E) | Read offset 1E of IX. | ||
| B05B | SUB B | Subtract B from A. | ||
| B05C | ADD A,$09 | Add 09 to A. | ||
| B05E | LD ($5C38),A | Update the ship row. | ||
| B061 | LD A,($F5F1) | The flag at F5F1. | ||
| B064 | AND A | Leave the horizontal limit at two when it is clear. | ||
| B065 | JR Z,BuildShip_Limit | |||
| B067 | LD A,$04 | A fitted part raises the limit to four. | ||
| B069 | LD ($5C3E),A | The horizontal limit. | ||
| BuildShip_Limit | B06C | LD A,($F5F2) | The flag at F5F2. | |
| B06F | AND A | Leave the vertical limit at two when it is clear. | ||
| B070 | JR Z,BuildShip_Carried | |||
| B072 | LD A,$04 | A fitted part raises the limit to four. | ||
| B074 | LD ($5C3F),A | The vertical limit. | ||
| BuildShip_Carried | B077 | LD A,($F601) | The carried item. | |
| B07A | INC A | Advance A. | ||
| B07B | JR Z,BuildShip_Last | Jump to BuildShip_Last if the zero flag is set. | ||
| B07D | DEC A | Step A back. | ||
| B07E | OR %11000000 | Set the bits of A that are set in C0. | ||
| B080 | LD ($C904),A | Update the item the ship is about to pick up. | ||
| B083 | CALL AttachItemToShip | Call AttachItemToShip. | ||
| B086 | XOR A | Clear A. | ||
| B087 | LD ($C904),A | Update the item the ship is about to pick up. | ||
| BuildShip_Last | B08A | LD A,($F5F6) | The ninth part flag. | |
| B08D | AND A | Jump to BuildStackGraphic if A is zero. | ||
| B08E | JP Z,BuildStackGraphic | |||
| B091 | LD A,($C1A9) | The height of the ship. | ||
| B094 | ADD A,$0B | Add 0B to A. | ||
| B096 | LD ($C1A9),A | Update the height of the ship. | ||
| B099 | JP BuildStackGraphic | Jump to BuildStackGraphic. | ||
| Prev: AF7B | Up: Map | Next: B09C |