![]() |
Routines |
| Prev: 36896 | Up: Map | Next: 37212 |
|
Use the horizontal speed in *IX+5 to update Jetman's world position.
|
||||||||
| ApplyJetmanSpeed | 36987 | LD A,(IX+5) | Fetch the horizontal speed. | |||||
| 36990 | SRA A | Divide it by 16. | ||||||
| 36992 | SRA A | |||||||
| 36994 | SRA A | |||||||
| 36996 | SRA A | |||||||
| 36998 | LD E,A | Store the pixel step in E. | ||||||
| 36999 | LD D,0 | Clear D for a positive step. | ||||||
| 37001 | JP P,ApplyJetmanSpeed_AddWorldX | Jump to ApplyJetmanSpeed_AddWorldX if the step is positive. | ||||||
| 37004 | LD D,255 | Set D=255 for a negative step. | ||||||
|
Add the step to the world X and wrap it to the planet width.
|
||||||||
| ApplyJetmanSpeed_AddWorldX | 37006 | LD H,(IX+3) | Fetch the high byte of the world X. | |||||
| 37009 | LD L,(IX+2) | Fetch the low byte of the world X. | ||||||
| 37012 | LD A,L | Fetch the fine X. | ||||||
| 37013 | AND %00000111 | Keep only bits 0-2. | ||||||
|
Draw a new terrain column on a cell boundary, then scroll the terrain bitmap by the step.
|
||||||||
| 37015 | PUSH HL | Stash the world X and the step on the stack. | ||||||
| 37016 | PUSH DE | |||||||
| 37017 | CALL Z,DrawNewColumn | Call DrawNewColumn if Jetman is on a cell boundary. | ||||||
| 37020 | POP DE | Restore the step from the stack. | ||||||
| 37021 | CALL ApplyJetmanSpeed_ScrollLeft | Call ApplyJetmanSpeed_ScrollLeft. | ||||||
|
Add the step to the world X and write it back.
|
||||||||
| 37024 | POP HL | Restore the world X from the stack. | ||||||
| 37025 | ADD HL,DE | Add the step to the world X. | ||||||
| 37026 | LD A,H | Fetch the high byte. | ||||||
| 37027 | AND %00011111 | Keep only bits 0-4. | ||||||
| 37029 | LD (IX+3),A | Write the high byte back to *IX+3. | ||||||
| 37032 | LD (IX+2),L | Write the low byte back to *IX+2. | ||||||
| 37035 | RET | Return. | ||||||
|
Scroll the terrain bitmap left or right by the pixel step.
|
||||||||
| ApplyJetmanSpeed_ScrollLeft | 37036 | LD HL,20672 | HL=20672. | |||||
| 37039 | LD C,8 | Set a pixel row counter in C for 8 loops. | ||||||
| 37041 | LD A,E | Return if there is no horizontal movement. | ||||||
| 37042 | AND A | |||||||
| 37043 | RET Z | |||||||
| 37044 | JP P,ApplyJetmanSpeed_ScrollRight | Jump to ApplyJetmanSpeed_ScrollRight if Jetman is moving right. | ||||||
|
When Jetman is moving left, shift the terrain bitmap right.
|
||||||||
| 37047 | NEG | Negate the leftward step. | ||||||
| 37049 | DEC A | Jump to ApplyJetmanSpeed_RotateRowRight if the step is 1. | ||||||
| 37050 | JR Z,ApplyJetmanSpeed_RotateRowRight | |||||||
| 37052 | DEC A | Jump to ApplyJetmanSpeed_TestOddPixel if the step is 2. | ||||||
| 37053 | JR Z,ApplyJetmanSpeed_TestOddPixel | |||||||
| 37055 | LD A,(IX+2) | Fetch the low byte of the world X. | ||||||
| 37058 | AND %00000011 | Keep only bits 0-1. | ||||||
| 37060 | JR NZ,ApplyJetmanSpeed_TestOddPixel | Jump to ApplyJetmanSpeed_TestOddPixel if Jetman is not on a 4-pixel boundary. | ||||||
|
Rotate each pixel row right by four bits.
|
||||||||
| ApplyJetmanSpeed_Loop | 37062 | XOR A | Clear the accumulator. | |||||
| 37063 | LD B,32 | Set a column counter in B for 32 loops. | ||||||
| 37065 | PUSH HL | Stash the row start on the stack. | ||||||
| ApplyJetmanSpeed_RotateNibbleRight | 37066 | RRD | Rotate the nibble through the current byte. | |||||
| 37068 | INC HL | Move onto the next column. | ||||||
| 37069 | DJNZ ApplyJetmanSpeed_RotateNibbleRight | Decrease the column counter by one and loop back to ApplyJetmanSpeed_RotateNibbleRight until the row is done. | ||||||
| 37071 | POP HL | Restore the row start from the stack. | ||||||
| 37072 | INC H | Move down one pixel row. | ||||||
| 37073 | DEC C | Decrease the row counter by one and loop back to ApplyJetmanSpeed_Loop until all eight rows are done. | ||||||
| 37074 | JR NZ,ApplyJetmanSpeed_Loop | |||||||
|
Return the step actually scrolled (-4) in DE.
|
||||||||
| 37076 | LD DE,65532 | DE=65532. | ||||||
| 37079 | RET | Return. | ||||||
|
Rotate each pixel row right by one bit.
|
||||||||
| ApplyJetmanSpeed_RotateRowRight | 37080 | XOR A | Clear the accumulator. | |||||
| 37081 | LD B,32 | Set a column counter in B for 32 loops. | ||||||
| 37083 | PUSH HL | Stash the row start on the stack. | ||||||
| ApplyJetmanSpeed_RotateByteRight | 37084 | RR (HL) | Rotate the current byte right. | |||||
| 37086 | INC HL | Move onto the next column. | ||||||
| 37087 | DJNZ ApplyJetmanSpeed_RotateByteRight | Decrease the column counter by one and loop back to ApplyJetmanSpeed_RotateByteRight until the row is done. | ||||||
| 37089 | POP HL | Restore the row start from the stack. | ||||||
| 37090 | INC H | Move down one pixel row. | ||||||
| 37091 | DEC C | Decrease the row counter by one and loop back to ApplyJetmanSpeed_RotateRowRight until all eight rows are done. | ||||||
| 37092 | JR NZ,ApplyJetmanSpeed_RotateRowRight | |||||||
|
Return the step actually scrolled (-1) in DE.
|
||||||||
| 37094 | LD DE,65535 | DE=65535. | ||||||
| 37097 | RET | Return. | ||||||
|
Use a one-bit rotate if Jetman is on an odd pixel, otherwise fall through to a two-bit rotate.
|
||||||||
| ApplyJetmanSpeed_TestOddPixel | 37098 | LD A,(IX+2) | Fetch the low byte of the world X. | |||||
| 37101 | AND %00000001 | Keep only bit 0. | ||||||
| 37103 | JR NZ,ApplyJetmanSpeed_RotateRowRight | Jump to ApplyJetmanSpeed_RotateRowRight if Jetman is on an odd pixel. | ||||||
|
Rotate each pixel row right by two bits.
|
||||||||
| ApplyJetmanSpeed_RotateRowRight2 | 37105 | XOR A | Clear both accumulators. | |||||
| 37106 | EX AF,AF' | |||||||
| 37107 | XOR A | |||||||
| 37108 | PUSH HL | Stash the row start on the stack. | ||||||
| 37109 | LD B,32 | Set a column counter in B for 32 loops. | ||||||
| ApplyJetmanSpeed_RotateByteRight2 | 37111 | RR (HL) | Rotate the current byte right twice. | |||||
| 37113 | EX AF,AF' | |||||||
| 37114 | RR (HL) | |||||||
| 37116 | EX AF,AF' | |||||||
| 37117 | INC L | Move onto the next column. | ||||||
| 37118 | DJNZ ApplyJetmanSpeed_RotateByteRight2 | Decrease the column counter by one and loop back to ApplyJetmanSpeed_RotateByteRight2 until the row is done. | ||||||
| 37120 | POP HL | Restore the row start from the stack. | ||||||
| 37121 | INC H | Move down one pixel row. | ||||||
| 37122 | DEC C | Decrease the row counter by one and loop back to ApplyJetmanSpeed_RotateRowRight2 until all eight rows are done. | ||||||
| 37123 | JR NZ,ApplyJetmanSpeed_RotateRowRight2 | |||||||
|
Return the step actually scrolled (-2) in DE.
|
||||||||
| 37125 | LD DE,65534 | DE=65534. | ||||||
| 37128 | RET | Return. | ||||||
|
When Jetman is moving right, shift the terrain bitmap left.
|
||||||||
| ApplyJetmanSpeed_ScrollRight | 37129 | LD HL,20703 | HL=20703. | |||||
| 37132 | DEC A | Jump to ApplyJetmanSpeed_RotateRowLeft if the step is 1. | ||||||
| 37133 | JR Z,ApplyJetmanSpeed_RotateRowLeft | |||||||
| 37135 | DEC A | Jump to ApplyJetmanSpeed_TestOddPixelRight if the step is 2. | ||||||
| 37136 | JR Z,ApplyJetmanSpeed_TestOddPixelRight | |||||||
| 37138 | LD A,(IX+2) | Fetch the low byte of the world X. | ||||||
| 37141 | AND %00000011 | Keep only bits 0-1. | ||||||
| 37143 | JR NZ,ApplyJetmanSpeed_TestOddPixelRight | Jump to ApplyJetmanSpeed_TestOddPixelRight if Jetman is not on a 4-pixel boundary. | ||||||
|
Rotate each pixel row left by four bits.
|
||||||||
| ApplyJetmanSpeed_RotateRowLeft4 | 37145 | XOR A | Clear the accumulator. | |||||
| 37146 | LD B,32 | Set a column counter in B for 32 loops. | ||||||
| 37148 | PUSH HL | Stash the row start on the stack. | ||||||
| ApplyJetmanSpeed_RotateNibbleLeft | 37149 | RLD | Rotate the nibble through the current byte. | |||||
| 37151 | DEC L | Move onto the previous column. | ||||||
| 37152 | DJNZ ApplyJetmanSpeed_RotateNibbleLeft | Decrease the column counter by one and loop back to ApplyJetmanSpeed_RotateNibbleLeft until the row is done. | ||||||
| 37154 | POP HL | Restore the row start from the stack. | ||||||
| 37155 | INC H | Move down one pixel row. | ||||||
| 37156 | DEC C | Decrease the row counter by one and loop back to ApplyJetmanSpeed_RotateRowLeft4 until all eight rows are done. | ||||||
| 37157 | JR NZ,ApplyJetmanSpeed_RotateRowLeft4 | |||||||
| 37159 | LD DE,4 | DE=0004. | ||||||
| 37162 | RET | Return. | ||||||
|
Rotate each pixel row left by one bit.
|
||||||||
| ApplyJetmanSpeed_RotateRowLeft | 37163 | XOR A | Clear the accumulator. | |||||
| 37164 | LD B,32 | Set a column counter in B for 32 loops. | ||||||
| 37166 | PUSH HL | Stash the row start on the stack. | ||||||
| ApplyJetmanSpeed_RotateByteLeft | 37167 | RL (HL) | Rotate the current byte left. | |||||
| 37169 | DEC L | Move onto the previous column. | ||||||
| 37170 | DJNZ ApplyJetmanSpeed_RotateByteLeft | Decrease the column counter by one and loop back to ApplyJetmanSpeed_RotateByteLeft until the row is done. | ||||||
| 37172 | POP HL | Restore the row start from the stack. | ||||||
| 37173 | INC H | Move down one pixel row. | ||||||
| 37174 | DEC C | Decrease the row counter by one and loop back to ApplyJetmanSpeed_RotateRowLeft until all eight rows are done. | ||||||
| 37175 | JR NZ,ApplyJetmanSpeed_RotateRowLeft | |||||||
| 37177 | LD DE,1 | DE=0001. | ||||||
| 37180 | RET | Return. | ||||||
|
Rotate by one bit if Jetman is on an odd pixel, else by two.
|
||||||||
| ApplyJetmanSpeed_TestOddPixelRight | 37181 | LD A,(IX+2) | Fetch the low byte of the world X. | |||||
| 37184 | AND %00000001 | Keep only bit 0. | ||||||
| 37186 | JR NZ,ApplyJetmanSpeed_RotateRowLeft | Jump to ApplyJetmanSpeed_RotateRowLeft if Jetman is on an odd pixel. | ||||||
|
Rotate each pixel row left by two bits.
|
||||||||
| ApplyJetmanSpeed_RotateRowLeft2 | 37188 | XOR A | Clear both accumulators. | |||||
| 37189 | EX AF,AF' | |||||||
| 37190 | XOR A | |||||||
| 37191 | PUSH HL | Stash the row start on the stack. | ||||||
| 37192 | LD B,32 | Set a column counter in B for 32 loops. | ||||||
| ApplyJetmanSpeed_RotateByteLeft2 | 37194 | RL (HL) | Rotate the current byte left twice. | |||||
| 37196 | EX AF,AF' | |||||||
| 37197 | RL (HL) | |||||||
| 37199 | EX AF,AF' | |||||||
| 37200 | DEC L | Move onto the previous column. | ||||||
| 37201 | DJNZ ApplyJetmanSpeed_RotateByteLeft2 | Decrease the column counter by one and loop back to ApplyJetmanSpeed_RotateByteLeft2 until the row is done. | ||||||
| 37203 | POP HL | Restore the row start from the stack. | ||||||
| 37204 | INC H | Move down one pixel row. | ||||||
| 37205 | DEC C | Decrease the row counter by one and loop back to ApplyJetmanSpeed_RotateRowLeft2 until all eight rows are done. | ||||||
| 37206 | JR NZ,ApplyJetmanSpeed_RotateRowLeft2 | |||||||
| 37208 | LD DE,2 | DE=0002. | ||||||
| 37211 | RET | Return. | ||||||
| Prev: 36896 | Up: Map | Next: 37212 |