Routines |
Prev: E6C8 | Up: Map | Next: E713 |
Used by the routine at Game_Initialisation.
|
||||||||
GenerateRandomNumber | E6EC | PUSH HL | Stash HL on the stack. | |||||
E6ED | LD HL,($E2C5) | HL=*RandomNumberSeed. | ||||||
E6F0 | LD A,(HL) | Fetch a byte from *HL and store it in A. | ||||||
E6F1 | RLCA | Multiply A by 10. | ||||||
E6F2 | RLCA | |||||||
E6F3 | RLCA | |||||||
E6F4 | PUSH AF | Stash the result on the stack. | ||||||
E6F5 | LD A,R | A=the contents of the Memory Refresh Register. | ||||||
E6F7 | AND %00011111 | Ensure the number is between 00-1F. | ||||||
E6F9 | LD H,A | Store the result in H. | ||||||
E6FA | INC L | Increment L by one. | ||||||
E6FB | LD ($E2C5),HL | Write HL to *RandomNumberSeed. | ||||||
E6FE | POP AF | Restore AF from the stack. | ||||||
E6FF | LD ($E2C5),HL | Write HL to *RandomNumberSeed. | ||||||
E702 | LD HL,$D825 | HL=D825. | ||||||
E705 | SRL A | Divide A by 02. | ||||||
HalveRandomNumber | E707 | SRL A | Divide A by 02. | |||||
E709 | CP (HL) | Jump to HalveRandomNumber if A is greater than or equal to *HL. | ||||||
E70A | JP P,HalveRandomNumber | |||||||
E70D | INC A | Increment A by one. | ||||||
E70E | LD B,$00 | Store the result in BC. | ||||||
E710 | LD C,A | |||||||
E711 | POP HL | Restore HL from the stack. | ||||||
E712 | RET | Return. |
Prev: E6C8 | Up: Map | Next: E713 |