![]() |
Routines |
| Prev: 58566 | Up: Map | Next: 58751 |
|
Used by the routine at RunFrame.
Called every frame. Every eighth frame the restart position is updated if the player has been standing on a place where it can restart. The frame counter is increased and the screen buffer is copied to the screen, starting with the rows that are chosen by ScrollValue. The copy of the buffer to the screen is done by using the stack pointer.
|
||||||
|
Every eighth frame, remember where the player is standing so that a new life can start from there.
|
||||||
| UpdateScreen | 58572 | LD A,(41693) | Fetch the frame counter. | |||
| 58575 | AND %00000111 | Use bits 0-2. | ||||
| 58577 | JR NZ,UpdateScreen_Count | Jump to UpdateScreen_Count unless this is an eighth frame. | ||||
| 58579 | LD A,(46430) | Read field 30 of the player entity. | ||||
| 58582 | AND %10000000 | Keep bit 7, which is set if the player is on the ground. | ||||
| 58584 | JR Z,UpdateScreen_Store | Jump to UpdateScreen_Store if the player is not on the ground, to forget the place that was found. | ||||
| 58586 | LD A,(58567) | Read the byte at 58567, which is not zero if a place to restart from has been found. | ||||
| 58589 | AND A | Test it. | ||||
| 58590 | JR Z,UpdateScreen_Count | Jump to UpdateScreen_Count if no place has been found. | ||||
| 58592 | LD A,(46400) | Fetch the type of the player entity. | ||||
| 58595 | DEC A | Decrease it by one. | ||||
| 58596 | LD A,0 | A is 0 ready to forget the place. | ||||
| 58598 | JR NZ,UpdateScreen_Store | Jump to UpdateScreen_Store if the player is not of type 1 to forget the place that was found. | ||||
|
Copy the place that was found to the restart position of the level.
|
||||||
| 58600 | LD A,(58566) | Read the byte at RestartCandidate. | ||||
| 58603 | LD (57078),A | Store it at 57078. | ||||
| 58606 | LD A,(58567) | Read the byte at 58567 and take away 32. | ||||
| 58609 | SUB 32 | |||||
| 58611 | LD B,A | Keep it in B. | ||||
| 58612 | LD A,(58571) | Read the byte at 58571. | ||||
| 58615 | AND %11110000 | Use bits 4-7. | ||||
| 58617 | OR B | Combine them with the byte in B. | ||||
| 58618 | LD (57077),A | Store them at RestartPosition. | ||||
| 58621 | LD A,(58569) | Read the byte at 58569. | ||||
| 58624 | LD (57079),A | Store it at 57079. | ||||
| 58627 | LD A,(58568) | Read the byte at 58568. | ||||
| 58630 | LD (57080),A | Store it at 57080. | ||||
| 58633 | XOR A | A is 0. | ||||
| UpdateScreen_Store | 58634 | LD (58567),A | Forget the place that was found. | |||
|
Count the frame, and make the random numbers move on.
|
||||||
| UpdateScreen_Count | 58637 | LD HL,(41693) | Fetch the frame counter into HL. | |||
| 58640 | INC HL | Add one to it. | ||||
| 58641 | LD (41693),HL | Store it. | ||||
| 58644 | CALL GetRandomNumber | Update the random number. | ||||
|
Copy the screen buffer to the game window, one pixel line at a time, starting from the line that is chosen by ScrollValue. The stack pointer is used to read the buffer, which saves time.
|
||||||
| 58647 | LD (23770),SP | Store the stack pointer, which is restored at the end. | ||||
| 58651 | LD A,(23785) | Fetch the number that selects the first line. | ||||
| 58654 | LD HL,58534 | Point HL at the table of line addresses at BufferRowTable. | ||||
| 58657 | CALL AddToAddress | Find the entry in the table. | ||||
| 58660 | LD E,(HL) | Fetch the address of the first line of the buffer into DE. | ||||
| 58661 | INC HL | |||||
| 58662 | LD D,(HL) | |||||
| 58663 | LD B,112 | Set the number of pixel lines to copy to 112. | ||||
| 58665 | EX DE,HL | Point the stack pointer at the first line of the buffer. | ||||
| 58666 | LD SP,HL | |||||
|
This entry point is used by the routine at DrawWipeStep.
|
||||||
| UpdateScreen_Copy | 58667 | LD HL,16422 | Set HL to the screen address of the first pixel line of the game window, 16422. | |||
| 58670 | JP UpdateScreen_Bytes | Jump to UpdateScreen_Bytes to copy the first line. | ||||
|
Move down by one pixel line on the screen.
|
||||||
| UpdateScreen_Row | 58673 | LD L,C | Go back to the first column of the window. | |||
| 58674 | INC H | Move down a pixel line. | ||||
| 58675 | LD A,H | Fetch the screen address into A. | ||||
| 58676 | AND %00000111 | Use bits 0-2, which are zero at the start of a character row. | ||||
| 58678 | JP NZ,UpdateScreen_Bytes | Jump to UpdateScreen_Bytes if the line is in the same character row. | ||||
| 58681 | LD A,L | Move on to the next character row... | ||||
| 58682 | ADD A,32 | |||||
| 58684 | LD L,A | ...by adding 32. | ||||
| 58685 | JP C,UpdateScreen_Bytes | Jump to UpdateScreen_Bytes if that stays in the same third of the screen. | ||||
| 58688 | LD A,H | Move on to the next third of the screen. | ||||
| 58689 | SUB 8 | |||||
| 58691 | LD H,A | |||||
|
Copy twenty bytes of the buffer to the screen, and skip the last four bytes of the line in the buffer.
|
||||||
| UpdateScreen_Bytes | 58692 | LD C,L | Keep the first column of the line in C. | |||
| 58693 | POP DE | Copy the first two bytes of the line. | ||||
| 58694 | LD (HL),E | |||||
| 58695 | INC L | |||||
| 58696 | LD (HL),D | |||||
| 58697 | INC L | |||||
| 58698 | POP DE | Copy the next two bytes of the line. | ||||
| 58699 | LD (HL),E | |||||
| 58700 | INC L | |||||
| 58701 | LD (HL),D | |||||
| 58702 | INC L | |||||
| 58703 | POP DE | Copy the next two bytes of the line. | ||||
| 58704 | LD (HL),E | |||||
| 58705 | INC L | |||||
| 58706 | LD (HL),D | |||||
| 58707 | INC L | |||||
| 58708 | POP DE | Copy the next two bytes of the line. | ||||
| 58709 | LD (HL),E | |||||
| 58710 | INC L | |||||
| 58711 | LD (HL),D | |||||
| 58712 | INC L | |||||
| 58713 | POP DE | Copy the next two bytes of the line. | ||||
| 58714 | LD (HL),E | |||||
| 58715 | INC L | |||||
| 58716 | LD (HL),D | |||||
| 58717 | INC L | |||||
| 58718 | POP DE | Copy the next two bytes of the line. | ||||
| 58719 | LD (HL),E | |||||
| 58720 | INC L | |||||
| 58721 | LD (HL),D | |||||
| 58722 | INC L | |||||
| 58723 | POP DE | Copy the next two bytes of the line. | ||||
| 58724 | LD (HL),E | |||||
| 58725 | INC L | |||||
| 58726 | LD (HL),D | |||||
| 58727 | INC L | |||||
| 58728 | POP DE | Copy the next two bytes of the line. | ||||
| 58729 | LD (HL),E | |||||
| 58730 | INC L | |||||
| 58731 | LD (HL),D | |||||
| 58732 | INC L | |||||
| 58733 | POP DE | Copy the next two bytes of the line. | ||||
| 58734 | LD (HL),E | |||||
| 58735 | INC L | |||||
| 58736 | LD (HL),D | |||||
| 58737 | INC L | |||||
| 58738 | POP DE | Copy the last two bytes of the line. | ||||
| 58739 | LD (HL),E | |||||
| 58740 | INC L | |||||
| 58741 | LD (HL),D | |||||
| 58742 | POP DE | Skip the four bytes at the end of the line in the buffer. | ||||
| 58743 | POP DE | |||||
| 58744 | DJNZ UpdateScreen_Row | Decrease the line counter and loop back to UpdateScreen_Row until all 112 lines have been copied. | ||||
| UpdateScreen_Return | 58746 | LD SP,(23770) | Restore the stack pointer. | |||
| 58750 | RET | Return. | ||||
| Prev: 58566 | Up: Map | Next: 58751 |