![]() |
Routines |
| Prev: 38239 | Up: Map | Next: 38616 |
|
Used by the routine at UpdateMapObjects.
Purpose not yet known. It builds a stack of objects in the slot at CrystalStackSlot, one for each of the crystals counted at 62978 and takes different action when the player's ship is in the right place on the map. Called once a frame.
|
||||
| UpdateCrystalStack | 38258 | XOR A | Clear 36156. | |
| 38259 | LD (36156),A | |||
| 38262 | LD A,(38571) | Fetch the flag from 38571. | ||
| 38265 | AND A | Test it. | ||
| 38266 | JR NZ,UpdateCrystalStack_Count | Jump to UpdateCrystalStack_Count if it is set. | ||
| 38268 | LD HL,(52823) | Fetch the map position from MapPosition. | ||
| 38271 | LD A,L | Fetch the map column. | ||
| 38272 | CP 81 | Jump to UpdateCrystalStack_Zone if it is 81. | ||
| 38274 | JR Z,UpdateCrystalStack_Zone | |||
| 38276 | CP 82 | Is it 82? | ||
| 38278 | RET NZ | Return if not. | ||
| UpdateCrystalStack_Zone | 38279 | LD A,H | Fetch the map zone. | |
| 38280 | CP 9 | Jump to UpdateCrystalStack_Count if it is 9. | ||
| 38282 | JR Z,UpdateCrystalStack_Count | |||
| 38284 | CP 10 | Is it 10? | ||
| 38286 | RET NZ | Return if not. | ||
| UpdateCrystalStack_Count | 38287 | LD A,(62978) | Fetch the number of crystals from 62978. | |
| 38290 | AND A | Test it. | ||
| 38291 | RET Z | Return if there are none. | ||
| 38292 | INC A | Add one. | ||
| 38293 | SRL A | Halve it. | ||
| 38295 | LD (36156),A | Store the result in 36156. | ||
| 38298 | LD IX,39500 | Use the slot at CrystalStackSlot. | ||
| 38302 | LD (IX+19),0 | Clear the first state byte of the object. | ||
| 38306 | LD A,(38571) | Fetch the flag from 38571. | ||
| 38309 | AND A | Test it. | ||
| 38310 | JR Z,UpdateCrystalStack_Next | Jump to UpdateCrystalStack_Next if it is clear. | ||
| 38312 | LD A,(39524) | Fetch the frame counter from FrameCounter. | ||
| 38315 | AND %00000011 | Keep the bottom two bits. | ||
| 38317 | CALL PlayPatternedNoise | Play a sound. | ||
| 38320 | CALL SetObjectPosition | Set the position of the object. | ||
| 38323 | LD A,(52410) | Fetch the speed from VerticalSpeed. | ||
| 38326 | NEG | Negate it. | ||
| 38328 | LD (IX+9),A | Set the vertical speed of the object. | ||
| 38331 | LD A,(52824) | Fetch the map zone from 52824. | ||
| 38334 | AND A | Test it. | ||
| 38335 | JR NZ,UpdateCrystalStack_Move | Jump to UpdateCrystalStack_Move if it is not zero. | ||
| 38337 | LD (IX+9),252 | Otherwise set the vertical speed of the object to 252. | ||
| UpdateCrystalStack_Move | 38341 | CALL MoveObject | Update the position of the object. | |
| 38344 | LD L,(IX+2) | Store the horizontal position of the object in 38572. | ||
| 38347 | LD H,(IX+1) | |||
| 38350 | LD (38572),HL | |||
| 38353 | LD L,(IX+5) | Store the vertical position of the object in 38574. | ||
| 38356 | LD H,(IX+4) | |||
| 38359 | LD (38574),HL | |||
| UpdateCrystalStack_Next | 38362 | CALL SetObjectPosition | Set the position of the object. | |
| 38365 | LD A,(IX+19) | Fetch the first state byte of the object and keep it in B. | ||
| 38368 | LD B,A | |||
| 38369 | ADD A,A | Multiply it by five. | ||
| 38370 | ADD A,A | |||
| 38371 | ADD A,B | |||
| 38372 | LD HL,38576 | Use the table at UpdateCrystalStack_Table. | ||
| 38375 | CALL AddAToHL | Add the offset to the address. | ||
| 38378 | LD DE,39516 | Use the data at CrystalStackSlot_Flags. | ||
| 38381 | LD BC,3 | Set the length to three. | ||
| 38384 | LDIR | Copy the three bytes. | ||
| 38386 | LD A,(HL) | Fetch the next byte of the table. | ||
| 38387 | LD (IX+7),A | Set the horizontal speed of the object. | ||
| 38390 | INC HL | Fetch the next byte of the table. | ||
| 38391 | LD A,(HL) | Set the vertical speed of the object. | ||
| 38392 | LD (IX+9),A | |||
| 38395 | CALL MoveObject | Update the position of the object. | ||
| 38398 | LD (IX+7),0 | Clear the horizontal speed. | ||
| 38402 | LD (IX+9),0 | Clear the vertical speed. | ||
| 38406 | LD A,(IX+19) | Fetch the first state byte of the object. | ||
| 38409 | CP 6 | Jump to UpdateCrystalStack_Draw if it is not six. | ||
| 38411 | JR NZ,UpdateCrystalStack_Draw | |||
| 38413 | LD (IX+19),8 | Set the first state byte to eight. | ||
| UpdateCrystalStack_Draw | 38417 | CALL ResetSprites | Reset the collision state. | |
| 38420 | BIT 7,(IX+16) | Test bit 7 of the flags of the object. | ||
| 38424 | CALL NZ,PrepareErase | Call PrepareErase if it is set. | ||
| 38427 | RES 6,(IX+16) | Clear bit 6 of the flags of the object. | ||
| 38431 | EXX | Switch registers. | ||
| 38432 | CALL ProcessObjectFlags | Process the flags of the object. | ||
| 38435 | CALL DrawObject | Call DrawObject. | ||
| 38438 | CALL SetObjectAttributes | Call SetObjectAttributes. | ||
| 38441 | LD IX,39500 | Use the slot at CrystalStackSlot. | ||
| 38445 | LD A,(IX+19) | Fetch the first state byte of the object. | ||
| 38448 | CP 8 | Jump to UpdateCrystalStack_Copy if it is not eight. | ||
| 38450 | JR NZ,UpdateCrystalStack_Copy | |||
| 38452 | LD A,6 | Use six instead. | ||
| 38454 | LD (IX+19),A | Store it. | ||
| UpdateCrystalStack_Copy | 38457 | LD B,A | Keep the state in B. | |
| 38458 | ADD A,A | Multiply it by five. | ||
| 38459 | ADD A,A | |||
| 38460 | ADD A,B | |||
| 38461 | LD HL,38576 | Use the table at UpdateCrystalStack_Table. | ||
| 38464 | CALL AddAToHL | Add the offset to the address. | ||
| 38467 | LD DE,39516 | Use the data at CrystalStackSlot_Flags. | ||
| 38470 | EX DE,HL | Swap the pointers. | ||
| 38471 | LD BC,3 | Set the length to three. | ||
| 38474 | LDIR | Copy the three bytes back. | ||
| 38476 | INC (IX+19) | Move on to the next state. | ||
| 38479 | LD A,(62978) | Fetch the number of crystals from 62978. | ||
| 38482 | CP (IX+19) | Compare it with the state. | ||
| 38485 | JP NZ,UpdateCrystalStack_Next | Jump to UpdateCrystalStack_Next if they are different. | ||
| 38488 | LD A,(62978) | Fetch the number of crystals again. | ||
| 38491 | CP 8 | Are there eight? | ||
| 38493 | RET NZ | Return if not. | ||
| 38494 | LD A,(38571) | Fetch the flag from 38571. | ||
| 38497 | AND A | Test it. | ||
| 38498 | JR Z,UpdateCrystalStack_Docked | Jump to UpdateCrystalStack_Docked if it is clear. | ||
| 38500 | CALL DrawMainFlame | Call DrawMainFlame. | ||
| 38503 | LD A,(38576) | Fetch the value from UpdateCrystalStack_Table. | ||
| 38506 | AND %10000000 | Keep bit 7. | ||
| 38508 | RET NZ | Return if it is set. | ||
| 38509 | DEC A | Decrease it. | ||
| 38510 | LD (38571),A | Store it in 38571. | ||
| 38513 | RET | Return. | ||
| UpdateCrystalStack_Docked | 38514 | LD HL,(51430) | Fetch the map column and horizontal position of the player from 51430. | |
| 38517 | LD A,L | Fetch the map column. | ||
| 38518 | CP 82 | Is it 82? | ||
| 38520 | RET NZ | Return if not. | ||
| 38521 | LD A,H | Fetch the horizontal position. | ||
| 38522 | CP 92 | Is it 92? | ||
| 38524 | RET NZ | Return if not. | ||
| 38525 | LD HL,(51433) | Fetch the map zone and vertical position of the player from 51433. | ||
| 38528 | LD A,L | Fetch the map zone. | ||
| 38529 | CP 10 | Is it 10? | ||
| 38531 | RET NZ | Return if not. | ||
| 38532 | LD A,H | Fetch the vertical position. | ||
| 38533 | CP 99 | Is it lower than 99? | ||
| 38535 | RET C | Return if so. | ||
| 38536 | LD (38571),A | Set the flag at 38571. | ||
| 38539 | LD A,10 | Set the explosion counter at 36691 to 10. | ||
| 38541 | LD (36691),A | |||
| 38544 | CALL RunFrame_Ship | Call RunFrame_Ship. | ||
| 38547 | CALL DrawShipTop | Call DrawShipTop. | ||
| 38550 | XOR A | Clear the explosion counter. | ||
| 38551 | LD (36691),A | |||
| 38554 | LD A,128 | Set 49786 to 128. | ||
| 38556 | LD (49786),A | |||
| 38559 | CALL CheckItemDelivery | Call CheckItemDelivery. | ||
| 38562 | LD HL,0 | Clear 51454. | ||
| 38565 | LD (51454),HL | |||
| 38568 | JP PlayHitSound | Play the explosion sound. | ||
| 38571 | DEFB 0 | |||
| 38572 | DEFW 21096 | |||
| 38574 | DEFW 2675 | |||
| UpdateCrystalStack_Table | 38576 | DEFB 0,0,0,0,0 | ||
| 38581 | DEFB 0,0,0,0,247 | |||
| 38586 | DEFB 0,0,0,0,238 | |||
| 38591 | DEFB 0,0,0,0,222 | |||
| 38596 | DEFB 0,0,0,242,226 | |||
| 38601 | DEFB 0,0,0,22,226 | |||
| 38606 | DEFB 0,0,0,0,209 | |||
| 38611 | DEFB 0,0,0,0,193 | |||
| Prev: 38239 | Up: Map | Next: 38616 |