|
5 | 5 | // Damien Guard (Fonts) |
6 | 6 | // Igor Chaves Cananea (VGA Mode Switching) |
7 | 7 | // Created: 22/03/2022 |
8 | | -// Last Updated: 17/04/2023 |
| 8 | +// Last Updated: 18/04/2023 |
9 | 9 | // |
10 | 10 | // Modinfo: |
11 | 11 | // 11/07/2022: Baud rate tweaked for Agon Light, HW Flow Control temporarily commented out |
|
32 | 32 | // 12/04/2023: + Fixed bug in play_note |
33 | 33 | // 13/04/2023: + Fixed bootup fail with no keyboard |
34 | 34 | // 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 |
35 | 36 |
|
36 | 37 | #include "fabgl.h" |
37 | 38 | #include "HardwareSerial.h" |
@@ -88,6 +89,7 @@ int pagedModeCount = 0; // Scroll counter for paged mode |
88 | 89 | int kbRepeatDelay = 500; // Keyboard repeat delay ms (250, 500, 750 or 1000) |
89 | 90 | int kbRepeatRate = 100; // Keyboard repeat rate ms (between 33 and 500) |
90 | 91 | bool initialised = false; // Is the system initialised yet? |
| 92 | +bool doWaitCompletion; // For vdu function |
91 | 93 | uint8_t palette[64]; // Storage for the palette |
92 | 94 |
|
93 | 95 | audio_channel * audio_channels[AUDIO_CHANNELS]; // Storage for the channel data |
@@ -865,6 +867,7 @@ void vdu(byte c) { |
865 | 867 | cursorRight(); |
866 | 868 | } |
867 | 869 | else { |
| 870 | + doWaitCompletion = false; |
868 | 871 | switch(c) { |
869 | 872 | case 0x08: // Cursor Left |
870 | 873 | cursorLeft(); |
@@ -924,7 +927,9 @@ void vdu(byte c) { |
924 | 927 | Canvas->drawChar(charX, charY, ' '); |
925 | 928 | break; |
926 | 929 | } |
927 | | - Canvas->waitCompletion(false); |
| 930 | + if(doWaitCompletion) { |
| 931 | + Canvas->waitCompletion(false); |
| 932 | + } |
928 | 933 | } |
929 | 934 | } |
930 | 935 |
|
@@ -1064,6 +1069,7 @@ void vdu_palette() { |
1064 | 1069 | return; |
1065 | 1070 | } |
1066 | 1071 | setPaletteItem(l, col); |
| 1072 | + doWaitCompletion = true; |
1067 | 1073 | debug_log("vdu_palette: %d,%d,%d,%d,%d\n\r", l, p, r, g, b); |
1068 | 1074 | } |
1069 | 1075 | else { |
@@ -1101,6 +1107,7 @@ void vdu_plot() { |
1101 | 1107 | vdu_plot_circle(mode); |
1102 | 1108 | break; |
1103 | 1109 | } |
| 1110 | + doWaitCompletion = true; |
1104 | 1111 | } |
1105 | 1112 |
|
1106 | 1113 | void vdu_plot_triangle(byte mode) { |
@@ -1336,6 +1343,7 @@ void vdu_sys_scroll() { |
1336 | 1343 | Canvas->scroll(0, -movement); |
1337 | 1344 | break; |
1338 | 1345 | } |
| 1346 | + doWaitCompletion = true; |
1339 | 1347 | } |
1340 | 1348 |
|
1341 | 1349 | // Play a note |
@@ -1415,8 +1423,10 @@ void vdu_sys_sprites(void) { |
1415 | 1423 | int rx = readWord_t(); if(rx == -1) return; x = rx; |
1416 | 1424 | int ry = readWord_t(); if(ry == -1) return; y = ry; |
1417 | 1425 |
|
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 | + } |
1420 | 1430 | debug_log("vdu_sys_sprites: bitmap %d draw command\n\r", current_bitmap); |
1421 | 1431 | } break; |
1422 | 1432 |
|
@@ -1464,6 +1474,7 @@ void vdu_sys_sprites(void) { |
1464 | 1474 | else { |
1465 | 1475 | VGAController->removeSprites(); |
1466 | 1476 | } |
| 1477 | + doWaitCompletion = true; |
1467 | 1478 | debug_log("vdu_sys_sprites: %d sprites activated\n\r", numsprites); |
1468 | 1479 | } break; |
1469 | 1480 |
|
@@ -1529,6 +1540,7 @@ void vdu_sys_sprites(void) { |
1529 | 1540 | free(bitmaps[n].data); |
1530 | 1541 | bitmaps[n].dataAllocated = false; |
1531 | 1542 | } |
| 1543 | + doWaitCompletion = true; |
1532 | 1544 | debug_log("vdu_sys_sprites: reset\n\r"); |
1533 | 1545 | } break; |
1534 | 1546 | } |
|
0 commit comments