Prev: F4D1 Up: Map Next: F69F
F4E6: Routine at F4E6
Used by the routine at F450.
F4E6 LD DE,$013F DE=013F.
F4E9 LD BC,($D228) BC=*D228.
F4ED INC C Increment C by one.
F4EE CALL $E0CF Call E0CF.
F4F1 LD A,($D3FC) A=*D3FC.
F4F4 RRCA Rotate A right one position, setting the carry flag if bit 0 was set.
F4F5 JR C,$F4F9 Jump to F4F9 if the carry flag is set.
F4F7 JR Z,$F501 Jump to F501 if A is zero.
F4F9 LD BC,$0001 BC=0001.
F4FC LD E,$02 E=02.
F4FE CALL $F543 Call F543.
F501 LD DE,$013F DE=013F.
F504 LD BC,($D228) BC=*D228.
F508 INC B Increment B by one.
F509 CALL $E0CF Call E0CF.
F50C LD A,($D3FC) A=*D3FC.
F50F RRCA Rotate A right one position, setting the carry flag if bit 0 was set.
F510 JR C,$F514 Jump to F514 if the carry flag is set.
F512 JR Z,$F51C Jump to F51C if A is zero.
F514 LD BC,$0020 BC=0020.
F517 LD E,$03 E=03.
F519 CALL $F543 Call F543.
F51C LD DE,$013F DE=013F.
F51F LD BC,($D228) BC=*D228.
F523 INC B Increment B by one.
F524 INC C Increment C by one.
F525 CALL $E0CF Call E0CF.
F528 LD A,($D3FC) A=*D3FC.
F52B RRCA Rotate A right one position, setting the carry flag if bit 0 was set.
F52C JR C,$F530 Jump to F530 if the carry flag is set.
F52E JR Z,$F538 Jump to F538 if A is zero.
F530 LD BC,$0021 BC=0021.
F533 LD E,$04 E=04.
F535 CALL $F543 Call F543.
F538 XOR A Write 00 to:
F539 LD ($D3FB),A
F53C LD ($D3FC),A
F53F LD ($D219),A
F542 RET Return.
This entry point is used by the routine at F450.
F543 LD A,($D3FC) A=*D3FC.
F546 RRCA Rotate A right one position, setting the carry flag if bit 0 was set.
F547 LD A,($D215) A=*D215.
F54A JR NC,$F551 Jump to F551 if the carry flag is not set.
F54C LD A,$10 A=10.
F54E LD ($D215),A Write A to *D215.
F551 AND A Return if A is zero.
F552 RET Z
F553 CP $09 Jump to F56A if A is lower than 09.
F555 JR C,$F56A
F557 CP $0E Jump to F565 if A is higher than 0E.
F559 JR NC,$F565
F55B LD A,E A=E.
F55C AND %00000001 Keep only bit 0.
F55E XOR %00000001 Flip bit 0.
F560 ADD A,$0E A+=0E.
F562 JP $F61F Jump to F61F.
F565 CP $10 Jump to F5E6 if A is not equal to 10.
F567 JP NZ,$F5E6
F56A LD A,E A=E.
F56B CP $01 Jump to F572 if A is not equal to 01.
F56D JR NZ,$F572
F56F LD ($D219),A Write A to *D219.
F572 CP $04 Jump to F59E if A is not equal to 04.
F574 JR NZ,$F59E
F576 LD A,($D219) Jump to F59E if *D219 is zero.
F579 AND A
F57A JR Z,$F59E
F57C LD A,($D3FC) Jump to F59E if *D3FC is not zero.
F57F AND A
F580 JR NZ,$F59E
F582 PUSH DE Stash DE on the stack.
F583 CALL RandomNumber Call RandomNumber.
F586 POP DE Restore DE from the stack.
F587 CP $10 Jump to F59E if A is higher than 10.
F589 JP NC,$F59E
F58C LD A,($D3F7) A=*D3F7.
F58F CP $08 Jump to F59E if A is equal to 08.
F591 JR Z,$F59E
F593 INC A Increment A by one.
F594 LD ($D3F7),A Write A to *D3F7.
F597 PUSH DE Stash DE on the stack.
F598 CALL $F5A4 Call F5A4.
F59B POP DE Restore DE from the stack.
F59C JR $F538 Jump to F538.
F59E LD A,E A=E.
F59F ADD A,$2F A+=2F.
F5A1 JP $F61F Jump to F61F.
F5A4 CALL RandomNumber Get a random number between 0-3.
F5A7 AND %00000011
F5A9 CP $03 Jump to F5A4 if A is equal to 03.
F5AB JR Z,$F5A4
F5AD ADD A,A C=A*04.
F5AE ADD A,A
F5AF LD C,A
F5B0 CALL RandomNumber Get a random number between 0-3.
F5B3 AND %00000011
F5B5 OR C Set the bits from C.
F5B6 ADD A,A E=4D+A*04.
F5B7 ADD A,A
F5B8 ADD A,$4D
F5BA LD E,A
F5BB LD A,($D218) D=*D218.
F5BE LD D,A
F5BF LD BC,($D22A) BC=*D22A.
F5C3 CALL $F5D8 Call F5D8.
F5C6 INC C Increment C by one.
F5C7 CALL $F5D8 Call F5D8.
F5CA LD HL,$001F HL=001F.
F5CD ADD HL,BC HL+=BC.
F5CE LD B,H B=H.
F5CF LD C,L C=L.
F5D0 CALL $F5D8 Call F5D8.
F5D3 INC C Increment C by one.
F5D4 CALL $F5D8 Call F5D8.
F5D7 RET Return.
F5D8 PUSH DE Stash DE and BC on the stack.
F5D9 PUSH BC
F5DA CALL $DA3D Call DA3D.
F5DD POP BC Restore BC and DE from the stack.
F5DE POP DE
F5DF INC E Increment E by one.
F5E0 LD A,$01 Write melody ID 01 to *MelodyID.
F5E2 LD ($FF8D),A
F5E5 RET Return.
F5E6 CP $11 Jump to F5F4 if A is not equal to 11.
F5E8 JR NZ,$F5F4
F5EA LD A,E A=E.
F5EB CP $03 Compare A with 03...
F5ED LD A,$13 A=13.
F5EF JR NC,$F61F Jump to F61F if A was higher than 03 on line F5EB.
F5F1 DEC A Decrease A by one.
F5F2 JR $F61F Jump to F61F.
F5F4 CP $0E Return if A is equal to 0E.
F5F6 RET Z
F5F7 CP $0F Return if A is equal to 0F.
F5F9 RET Z
F5FA CP $12 Return if A is equal to 12.
F5FC RET Z
F5FD CP $13 Return if A is equal to 13.
F5FF RET Z
F600 CP $15 Return if A is equal to 15.
F602 RET Z
F603 CP $16 Return if A is equal to 16.
F605 RET Z
F606 CP $14 Jump to F614 if A is not equal to 14.
F608 JR NZ,$F614
F60A LD A,E A=E.
F60B CP $03 Compare A with 03...
F60D LD A,$16 A=16.
F60F JR NC,$F61F Jump to F61F A was higher than 03 on line F60B.
F611 DEC A Decrease A by one.
F612 JR $F61F Jump to F61F.
F614 CP $30 Jump to F56A if A is lower than 30.
F616 JP C,$F56A
F619 CP $34 Jump to F56A if A is higher than 34.
F61B JP NC,$F56A
F61E RET Return.
F61F LD E,A E=A.
F620 PUSH BC Stash BC and DE on the stack.
F621 PUSH DE
F622 LD BC,($D228) BC=*D228.
F626 CALL $F63E Call F63E.
F629 POP DE Restore DE and BC from the stack.
F62A POP BC
F62B LD HL,($D22A) HL=*D22A.
F62E ADD HL,BC HL+=BC.
F62F LD B,H B=H.
F630 LD C,L C=L.
F631 LD A,($D218) D=*D218.
F634 LD D,A
F635 CALL $DA3D Call DA3D.
F638 LD A,$01 Write melody ID 01 to *MelodyID.
F63A LD ($FF8D),A
F63D RET Return.
F63E LD HL,$D31F HL=D31F.
F641 LD D,$00 D=00.
F643 LD E,C E=C.
F644 ADD HL,DE HL+=DE.
F645 LD A,(HL) A=*HL.
F646 EX AF,AF' Exchange the AF register with the shadow AF register.
F647 LD E,$01 E=01.
F649 LD A,(HL) A=*HL.
F64A CP $08 Jump to F654 if A is lower than 08.
F64C JR C,$F654
F64E RRCA RRCA.
F64F RRCA
F650 RRCA
F651 AND %00000111 Keep only bits 0-2.
F653 INC E Increment E by one.
F654 LD HL,$D218 HL=D218.
F657 LD (HL),E Write E to *HL.
F658 DEC A Decrease A by one.
F659 ADD A,A A+=A.
F65A LD H,A H=A.
F65B ADD A,A A+=A.
F65C LD L,A L=A.
F65D ADD A,A A+=A.
F65E ADD A,H A+=H.
F65F ADD A,L A+=L.
F660 LD E,A E=A.
F661 LD IX,$D39F IX=Table_Buildings.
F665 ADD IX,DE IX+=DE.
F667 LD A,(IX+$00) A=*IX+00.
F66A CP $03 Return if A is higher than 03.
F66C RET NC
F66D LD A,$13 A=13.
F66F SUB (IX+$05) A-=*IX+05.
F672 LD B,A B=A.
F673 LD A,($D229) A=*D229.
F676 DEC A Decrease A by one.
F677 CP B Jump to F681 if A is higher than B.
F678 JR NC,$F681
F67A EX AF,AF' Exchange the AF register with the shadow AF register.
F67B AND %00000111 Keep only bits 0-2.
F67D LD E,$01 E=01.
F67F JR $F654 Jump to F654.
F681 LD A,(IX+$09) A=*IX+09.
F684 SUB $02 A-=02.
F686 LD (IX+$09),A Write A to *IX+09.
F689 JR NC,$F694 Jump to F694 if {} is higher.
F68B LD (IX+$09),$00 Write 00 to *IX+09.
F68F LD (IX+$00),$02 Write 02 to *IX+00.
F693 RET Return.
F694 LD D,$01 D=01.
F696 LD E,$02 E=02.
F698 LD A,($DF45) A=*Temp_MonsterID.
F69B CALL Handler_AddPoints Call Handler_AddPoints.
F69E RET Return.
Prev: F4D1 Up: Map Next: F69F