Routines |
Prev: D778 | Up: Map | Next: D86F |
Used by the routine at Handler_SeaCreatures.
|
||||||||
Fetch a random-ish number.
|
||||||||
Handler_SeaCreatures_Chooser | D7E7 | CALL UpdateAnimationCounter | Call UpdateAnimationCounter. | |||||
D7EA | AND %00000111 | Ensure the number is between 00 to 04. | ||||||
D7EC | SUB $02 | |||||||
D7EE | CP $05 | |||||||
D7F0 | JR C,Handler_SetSeaCreature | |||||||
D7F2 | LD A,$04 | |||||||
Handler_SetSeaCreature | D7F4 | LD E,A | Create an offset in DE using A. | |||||
D7F5 | LD D,$00 | |||||||
|
||||||||
D7F7 | SLA E | DE*=08. | ||||||
D7F9 | SLA E | |||||||
D7FB | SLA E | |||||||
D7FD | PUSH DE | HL=DE (using the stack). | ||||||
D7FE | POP HL | |||||||
D7FF | SLA E | HL+=DE*02. | ||||||
D801 | RL D | |||||||
D803 | ADD HL,DE | |||||||
D804 | LD DE,$D93E | HL+=TableDefaultSeaCreatures. | ||||||
D807 | ADD HL,DE | |||||||
D808 | PUSH IX | DE=IX (using the stack). | ||||||
D80A | POP DE | |||||||
D80B | LD BC,$0018 | BC=0018. | ||||||
D80E | LDIR | Copy 0018 bytes of data from the chosen creature defaults table to the creature slot. | ||||||
Fetch a random-ish number.
|
||||||||
Handler_SetSeaCreatureYPosition | D810 | CALL UpdateAnimationCounter | Call UpdateAnimationCounter. | |||||
D813 | AND %00001111 | Keep only bits 0-3. | ||||||
D815 | ADD A,$06 | A+=06. | ||||||
D817 | CP $11 | Jump to Handler_SetSeaCreatureYPosition if A is higher than 11. | ||||||
D819 | JR NC,Handler_SetSeaCreatureYPosition | |||||||
D81B | RES 0,A | Reset bit 0 of A. | ||||||
D81D | LD (IX+$01),A | Write A to *IX+01. | ||||||
D820 | LD (IX+$0E),A | Write A to *IX+0E. | ||||||
D823 | PUSH IY | Stash IY on the stack. | ||||||
D825 | LD IY,$DB46 | IY=Data_SeaCreatures. | ||||||
D829 | LD L,A | L=A. | ||||||
D82A | LD BC,($DD98) | BC=*DD98. | ||||||
Handler_SeaCreatures_Chooser_0 | D82E | LD A,(IY+$0A) | Jump to Handler_SeaCreatures_Chooser_1 if *IY+0A is equal to 00. | |||||
D831 | CP $00 | |||||||
D833 | JR Z,Handler_SeaCreatures_Chooser_1 | |||||||
D835 | LD A,(IY+$01) | Jump to Handler_SeaCreatures_Chooser_1 if *IY+01 is not equal to L. | ||||||
D838 | CP L | |||||||
D839 | JR NZ,Handler_SeaCreatures_Chooser_1 | |||||||
D83B | LD A,(IY+$00) | Jump to Handler_SeaCreatures_Chooser_2 if *IY+00 is higher than 0F. | ||||||
D83E | CP $0F | |||||||
D840 | JP NC,Handler_SeaCreatures_Chooser_2 | |||||||
Handler_SeaCreatures_Chooser_1 | D843 | LD DE,$0018 | IY+=0018. | |||||
D846 | ADD IY,DE | |||||||
D848 | DJNZ Handler_SeaCreatures_Chooser_0 | Decrease counter by one and loop back to Handler_SeaCreatures_Chooser_0 until counter is zero. | ||||||
D84A | POP IY | Restore IY from the stack. | ||||||
D84C | LD A,$01 | Write 01 to *IX+0A. | ||||||
D84E | LD (IX+$0A),A | |||||||
D851 | LD A,$22 | A=22+*IX+07. | ||||||
D853 | ADD A,(IX+$07) | |||||||
D856 | LD (IX+$00),A | Write A to *IX+00. | ||||||
D859 | LD (IX+$0D),A | Write A to *IX+0D. | ||||||
D85C | LD (IX+$02),$01 | Write 01 to *IX+02. | ||||||
D860 | LD (IX+$0B),$01 | Write 01 to *IX+0B. | ||||||
D864 | JP Handler_SeaCreatures_Next | Jump to Handler_SeaCreatures_Next. | ||||||
Handler_SeaCreatures_Chooser_2 | D867 | POP IY | Restore IY from the stack. | |||||
D869 | JP Handler_SeaCreatures_Next | Jump to Handler_SeaCreatures_Next. | ||||||
D86C | POP IX | Restore IX from the stack. | ||||||
D86E | RET | Return. |
Prev: D778 | Up: Map | Next: D86F |