![]() |
Routines |
| Prev: 58642 | Up: Map | Next: 58800 |
|
Used by the routines at Controls_CheckRight, Controls_CheckLeft, Controls_CheckDown, Controls_CheckUp and Controls_CheckLeftUp.
|
||||
| Handler_CursorMovement | 58684 | CALL FetchTileObject | Call FetchTileObject. | |
| 58687 | LD A,(55340) | Write *DestinationCursor_Y_Position to *StorageCursor_Y_Position. | ||
| 58690 | LD (55344),A | |||
| 58693 | LD A,(55341) | Write *DestinationCursor_X_Position to *StorageCursor_X_Position. | ||
| 58696 | LD (55345),A | |||
| 58699 | LD A,R | A=the contents of the Memory Refresh Register. | ||
| 58701 | RLCA | Multiply A by 2 and store the result in L. | ||
| 58702 | LD L,A | |||
| 58703 | LD H,0 | H=0. | ||
| 58705 | LD B,70 | Set a counter in B for the first outer loop. | ||
| 58707 | LD D,5 | Set a counter in D for the first inner loop. | ||
| CursorMovement_SoundLoop_01 | 58709 | LD A,(HL) | Fetch a byte from the ZX Spectrum ROM and store it in A. | |
| 58710 | AND %00011000 | Keep only bits 3-4. | ||
| 58712 | OR %00000101 | Set bits 0, 2. | ||
| 58714 | OUT (254),A | Send to the speaker. | ||
| 58716 | INC HL | Increment the ROM pointer by one. | ||
| 58717 | PUSH BC | Stash the outer loop counter on the stack. | ||
| 58718 | LD B,D | Set B to the inner loop counter held by D. | ||
| CursorMovement_DelayLoop_01 | 58719 | DJNZ CursorMovement_DelayLoop_01 | Decrease the inner loop counter by one and loop back to CursorMovement_DelayLoop_01 until the counter is zero. | |
| 58721 | POP BC | Restore the outer loop counter from the stack. | ||
| 58722 | DJNZ CursorMovement_SoundLoop_01 | Decrease the outer loop counter by one and loop back to CursorMovement_SoundLoop_01 until the counter is zero. | ||
| 58724 | HALT | Halt operation (suspend CPU until the next interrupt). | ||
|
Update the cursor position.
|
||||
| 58725 | LD A,(55340) | Jump to Handler_CursorMovement_1 if *DestinationCursor_Y_Position is equal to *CurrentCursor_Y_Position. | ||
| 58728 | LD HL,55342 | |||
| 58731 | CP (HL) | |||
| 58732 | JR Z,Handler_CursorMovement_1 | |||
| 58734 | JP P,Handler_CursorMovement_0 | Jump to Handler_CursorMovement_0 if *DestinationCursor_Y_Position is greater than or equal to *CurrentCursor_Y_Position. | ||
| 58737 | DEC (HL) | Decrease *CurrentCursor_Y_Position by one. | ||
| 58738 | JR Handler_CursorMovement_1 | Jump to Handler_CursorMovement_1. | ||
| Handler_CursorMovement_0 | 58740 | INC (HL) | Increment *HL by one. | |
| Handler_CursorMovement_1 | 58741 | LD A,(55341) | Jump to Handler_CursorMovement_3 if *DestinationCursor_X_Position is equal to *CurrentCursor_X_Position. | |
| 58744 | LD HL,55343 | |||
| 58747 | CP (HL) | |||
| 58748 | JR Z,Handler_CursorMovement_3 | |||
| 58750 | JP P,Handler_CursorMovement_2 | Jump to Handler_CursorMovement_2 if *DestinationCursor_X_Position is greater than or equal to *CurrentCursor_X_Position. | ||
| 58753 | DEC (HL) | Decrease *CurrentCursor_X_Position by one. | ||
| 58754 | JR Handler_CursorMovement_3 | Jump to Handler_CursorMovement_3. | ||
| Handler_CursorMovement_2 | 58756 | INC (HL) | Increment *HL by one. | |
| Handler_CursorMovement_3 | 58757 | LD A,(55342) | Jump to Handler_CursorMovement if *CurrentCursor_Y_Position is not equal to *DestinationCursor_Y_Position. | |
| 58760 | LD HL,55340 | |||
| 58763 | CP (HL) | |||
| 58764 | JR NZ,Handler_CursorMovement | |||
| 58766 | LD A,(55343) | Jump to Handler_CursorMovement if *CurrentCursor_X_Position is not equal to *DestinationCursor_X_Position. | ||
| 58769 | LD HL,55341 | |||
| 58772 | CP (HL) | |||
| 58773 | JR NZ,Handler_CursorMovement | |||
|
The final sound effect when the cursor reaches its destination.
|
||||
| 58775 | LD A,R | Set the lower byte in L, which for randomness is the contents of the Memory Refresh Register. | ||
| 58777 | LD L,A | |||
| 58778 | LD H,10 | Set the upper byte of the sound data address (0A00-0AFF). | ||
| 58780 | LD B,35 | Set a counter in B for the second outer loop. | ||
| 58782 | LD C,100 | Set a counter in C for the second inner loop. | ||
| CursorMovement_SoundLoop_02 | 58784 | LD A,(HL) | Fetch a byte from the ZX Spectrum ROM and store it in A. | |
| 58785 | INC HL | Increment the ROM pointer by one. | ||
| 58786 | AND %00011000 | Keep only bits 3-4. | ||
| 58788 | OR %00000101 | Set bits 0, 2. | ||
| 58790 | OUT (254),A | Send to the speaker. | ||
| 58792 | PUSH BC | Stash the outer loop counter on the stack. | ||
| 58793 | LD B,C | Set B to the inner loop counter held by C. | ||
| CursorMovement_DelayLoop_02 | 58794 | DJNZ CursorMovement_DelayLoop_02 | Decrease the inner loop counter by one and loop back to CursorMovement_DelayLoop_02 until counter is zero. | |
| 58796 | POP BC | Restore the outer loop counter from the stack. | ||
| 58797 | DJNZ CursorMovement_SoundLoop_02 | Decrease the outer loop counter by one and loop back to CursorMovement_SoundLoop_02 until the counter is zero. | ||
| 58799 | RET | Return. | ||
| Prev: 58642 | Up: Map | Next: 58800 |