Improve VBL bypass in spin(...)

This commit is contained in:
Zane Kaminski 2021-03-31 07:41:46 -04:00
parent bb0ae40761
commit 214c3f27ea
3 changed files with 6 additions and 6 deletions

Binary file not shown.

Binary file not shown.

12
util.c
View File

@ -13,9 +13,10 @@ char read_applekey(void) { return ((*PB0) | (*PB1)) & 0x80; }
#define SPIN_FRAMESPERCHAR 4 #define SPIN_FRAMESPERCHAR 4
void spin(uint8_t x, uint8_t y) { void spin(uint8_t x, uint8_t y) {
char i; char i;
unsigned int l;
// Sync to frame before starting // Sync to frame before starting
while (*VBL >= 0); for (l = 0; *VBL >= 0 && l < 2500; l++);
// Wait and animate spinner. // Wait and animate spinner.
// Spin_half // Spin_half
@ -40,14 +41,13 @@ void spin(uint8_t x, uint8_t y) {
// Wait specificed number of frames // Wait specificed number of frames
for (k = 0; k < SPIN_FRAMESPERCHAR; k++) { for (k = 0; k < SPIN_FRAMESPERCHAR; k++) {
unsigned char l; for (l = 0; *VBL < 0 && l < 2500; l++);
for (l = 0; *VBL < 0 && l < 255; l++); for (l = 0; *VBL >= 0 && l < 2500; l++);
for (l = 0; *VBL >= 0 && l < 255; l++);
} }
} }
} }
// Wait a frame when finished // Wait a frame when finished
while (*VBL < 0); for (l = 0; *VBL < 0 && l < 2500; l++);
while (*VBL >= 0); for (l = 0; *VBL >= 0 && l < 2500; l++);
} }