![]() |
Routines |
| Prev: 9E4F | Up: Map | Next: 9EB9 |
|
Moves the displayed level of the battery bar by one pixel column towards the actual level, which is a number from 00 to 74. The bar is drawn by toggling the pixels of one column, so it is added to or taken away from the end of the bar. This is called every frame.
|
||||
| UpdateBatteryBar_Increase | 9E55 | INC A | Add one to the displayed level. | |
| 9E56 | LD B,A | Keep the displayed level. | ||
| 9E57 | LD HL,$943F | Point HL at the position of the column before the first one (which has an X position of 3F), so that when the level is added the column that is drawn is the first one that is not yet lit. | ||
| 9E5A | JR UpdateBatteryBar_Draw | Jump to draw the column. | ||
|
This entry point is used by the routine at MainLoop.
|
||||
| UpdateBatteryBar | 9E5C | LD A,($963B) | Fetch the actual level of the battery. | |
| 9E5F | LD B,A | Keep the actual level. | ||
| 9E60 | LD A,($963C) | Fetch the displayed level of the battery. | ||
| 9E63 | CP B | Return if the two are the same. | ||
| 9E64 | RET Z | |||
| 9E65 | JR C,UpdateBatteryBar_Increase | Jump if the displayed level is lower than the actual level. | ||
| 9E67 | LD B,A | Keep the displayed level. | ||
| 9E68 | DEC A | Take one pixel column off the displayed level. | ||
| 9E69 | LD HL,$9440 | Point HL at the position of the first column, which has an X position of 40 and a Y position of 94. | ||
| UpdateBatteryBar_Draw | 9E6C | LD ($963C),A | Store the new displayed level. | |
| 9E6F | ADD A,L | Add the X position to find the X position of the column that is to be drawn... | ||
| 9E70 | LD L,A | ...and put it in the position. | ||
| 9E71 | LD C,A | Keep the X position. | ||
| 9E72 | CALL ScreenAddress | Convert the position into a screen address using ScreenAddress. | ||
| 9E75 | LD A,B | Fetch the level. | ||
| 9E76 | EX AF,AF' | Keep the level. | ||
| 9E77 | EXX | Switch to the shadow registers. | ||
| 9E78 | LD HL,$9EB9 | Point HL' at BatteryBarPattern. | ||
| 9E7B | EXX | Switch back to the main registers. | ||
| 9E7C | LD A,C | Fetch the X position. | ||
| 9E7D | CPL | Find the number of the bit that the column is in, as a number of pixels from the right... | ||
| 9E7E | AND $07 | ...limited to a character. | ||
| 9E80 | LD B,A | Keep the column within the character. | ||
| 9E81 | LD C,$08 | The column has 08 rows. | ||
| 9E83 | INC B | Add one, as it will be used to shift the pattern. | ||
| 9E84 | EX AF,AF' | Fetch the level. | ||
| 9E85 | CP $05 | Jump if the level is at least five, as the column is then not part of the rounded end of the bar. | ||
| 9E87 | JR NC,UpdateBatteryBar_Row | |||
| 9E89 | LD D,B | Save the shift. | ||
| 9E8A | PUSH HL | Save the screen address. | ||
| 9E8B | LD HL,$9EC1 | Point HL at the table of the number of rows to skip at the top and the bottom of the column. | ||
| 9E8E | CALL AddAToHL | Add the level, using AddAToHL. | ||
| 9E91 | LD B,(HL) | Fetch the number of rows to skip. | ||
| 9E92 | POP HL | Restore the screen address. | ||
| UpdateBatteryBar_SkipRows | 9E93 | DEC C | Take off two rows from the end of the column... | |
| 9E94 | DEC C | ...for each row that is skipped at the top... | ||
| 9E95 | INC H | ...and move down one pixel row. | ||
| 9E96 | EXX | Switch to the shadow registers... | ||
| 9E97 | INC HL | ...and skip a byte of the pattern... | ||
| 9E98 | EXX | ...and switch back. | ||
| 9E99 | DJNZ UpdateBatteryBar_SkipRows | Loop back until the rows have been skipped. | ||
| 9E9B | LD B,D | Restore the shift. | ||
| UpdateBatteryBar_Row | 9E9C | EXX | Switch to the shadow registers. | |
| 9E9D | LD A,(HL) | Fetch the next byte of the pattern. | ||
| 9E9E | INC HL | Move on to the next byte of the pattern. | ||
| 9E9F | EXX | Switch back to the main registers. | ||
| 9EA0 | EX DE,HL | Keep the screen address. | ||
| 9EA1 | LD L,A | Put the byte of the pattern in HL... | ||
| 9EA2 | LD H,$00 | ...as a two byte number. | ||
| 9EA4 | LD A,B | Fetch the level... | ||
| UpdateBatteryBar_ShiftPattern | 9EA5 | ADD HL,HL | ...and shift the pattern left by the number of pixels needed to put the pixel in the right place. | |
| 9EA6 | DJNZ UpdateBatteryBar_ShiftPattern | Restore the shift. | ||
| 9EA8 | LD B,A | Keep the level. | ||
| 9EA9 | EX DE,HL | Restore the screen address and the shifted pattern. | ||
| 9EAA | LD A,D | Fetch the first byte of the shifted pattern... | ||
| 9EAB | XOR (HL) | ...toggle it on the screen... | ||
| 9EAC | LD (HL),A | ...and store it. | ||
| 9EAD | INC L | Move on to the next byte of the screen. | ||
| 9EAE | LD A,E | Fetch the second byte of the shifted pattern... | ||
| 9EAF | XOR (HL) | ...toggle it on the screen... | ||
| 9EB0 | LD (HL),A | ...and store it. | ||
| 9EB1 | DEC L | Move back to the first byte. | ||
| 9EB2 | CALL NextPixelRow | Move down to the next pixel row using NextPixelRow. | ||
| 9EB5 | DEC C | Count down the rows. | ||
| 9EB6 | JR NZ,UpdateBatteryBar_Row | Loop back until the whole column has been drawn. | ||
| 9EB8 | RET | Return. | ||
| Prev: 9E4F | Up: Map | Next: 9EB9 |