Skip to content

Commit ba597c8

Browse files
Minor tweaks to wait completion logic
1 parent 1da1509 commit ba597c8

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

video.ino

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Damien Guard (Fonts)
66
// Igor Chaves Cananea (VGA Mode Switching)
77
// Created: 22/03/2022
8-
// Last Updated: 17/04/2023
8+
// Last Updated: 18/04/2023
99
//
1010
// Modinfo:
1111
// 11/07/2022: Baud rate tweaked for Agon Light, HW Flow Control temporarily commented out
@@ -32,6 +32,7 @@
3232
// 12/04/2023: + Fixed bug in play_note
3333
// 13/04/2023: + Fixed bootup fail with no keyboard
3434
// 17/04/2023: RC5 + Moved wait_completion in vdu so that it only executes after graphical operations
35+
// 18/04/2023: + Minor tweaks to wait completion logic
3536

3637
#include "fabgl.h"
3738
#include "HardwareSerial.h"
@@ -88,6 +89,7 @@ int pagedModeCount = 0; // Scroll counter for paged mode
8889
int kbRepeatDelay = 500; // Keyboard repeat delay ms (250, 500, 750 or 1000)
8990
int kbRepeatRate = 100; // Keyboard repeat rate ms (between 33 and 500)
9091
bool initialised = false; // Is the system initialised yet?
92+
bool doWaitCompletion; // For vdu function
9193
uint8_t palette[64]; // Storage for the palette
9294

9395
audio_channel * audio_channels[AUDIO_CHANNELS]; // Storage for the channel data
@@ -865,6 +867,7 @@ void vdu(byte c) {
865867
cursorRight();
866868
}
867869
else {
870+
doWaitCompletion = false;
868871
switch(c) {
869872
case 0x08: // Cursor Left
870873
cursorLeft();
@@ -924,7 +927,9 @@ void vdu(byte c) {
924927
Canvas->drawChar(charX, charY, ' ');
925928
break;
926929
}
927-
Canvas->waitCompletion(false);
930+
if(doWaitCompletion) {
931+
Canvas->waitCompletion(false);
932+
}
928933
}
929934
}
930935

@@ -1064,6 +1069,7 @@ void vdu_palette() {
10641069
return;
10651070
}
10661071
setPaletteItem(l, col);
1072+
doWaitCompletion = true;
10671073
debug_log("vdu_palette: %d,%d,%d,%d,%d\n\r", l, p, r, g, b);
10681074
}
10691075
else {
@@ -1101,6 +1107,7 @@ void vdu_plot() {
11011107
vdu_plot_circle(mode);
11021108
break;
11031109
}
1110+
doWaitCompletion = true;
11041111
}
11051112

11061113
void vdu_plot_triangle(byte mode) {
@@ -1336,6 +1343,7 @@ void vdu_sys_scroll() {
13361343
Canvas->scroll(0, -movement);
13371344
break;
13381345
}
1346+
doWaitCompletion = true;
13391347
}
13401348

13411349
// Play a note
@@ -1415,8 +1423,10 @@ void vdu_sys_sprites(void) {
14151423
int rx = readWord_t(); if(rx == -1) return; x = rx;
14161424
int ry = readWord_t(); if(ry == -1) return; y = ry;
14171425

1418-
if(bitmaps[current_bitmap].data) Canvas->drawBitmap(x,y,&bitmaps[current_bitmap]);
1419-
1426+
if(bitmaps[current_bitmap].data) {
1427+
Canvas->drawBitmap(x,y,&bitmaps[current_bitmap]);
1428+
doWaitCompletion = true;
1429+
}
14201430
debug_log("vdu_sys_sprites: bitmap %d draw command\n\r", current_bitmap);
14211431
} break;
14221432

@@ -1464,6 +1474,7 @@ void vdu_sys_sprites(void) {
14641474
else {
14651475
VGAController->removeSprites();
14661476
}
1477+
doWaitCompletion = true;
14671478
debug_log("vdu_sys_sprites: %d sprites activated\n\r", numsprites);
14681479
} break;
14691480

@@ -1529,6 +1540,7 @@ void vdu_sys_sprites(void) {
15291540
free(bitmaps[n].data);
15301541
bitmaps[n].dataAllocated = false;
15311542
}
1543+
doWaitCompletion = true;
15321544
debug_log("vdu_sys_sprites: reset\n\r");
15331545
} break;
15341546
}

0 commit comments

Comments
 (0)