aboutsummaryrefslogtreecommitdiff
path: root/c/echo.c
diff options
context:
space:
mode:
authorsik2017-07-25 03:53:56 -0300
committersik2017-07-25 03:53:56 -0300
commit7d516cc248777ae239c5a4e50fa325365ddd7d53 (patch)
tree7f392dbe0fb285350c050b649a501b555ab8cd36 /c/echo.c
parent12d03b44f8895e86ac38fe8f83a2400dbc837087 (diff)
Cheating with the driver status to match programmer expectations (even if this is pretty much futurism)
Diffstat (limited to 'c/echo.c')
-rw-r--r--c/echo.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/c/echo.c b/c/echo.c
index 23bd409..60cd34a 100644
--- a/c/echo.c
+++ b/c/echo.c
@@ -375,6 +375,16 @@ void echo_set_pcm_rate(uint8_t rate) {
//***************************************************************************
uint16_t echo_get_status(void) {
+ // Look-up tables used to work around the fact that playing/stopping
+ // won't set the status immediately (only when Echo processes the command)
+ // and this can catch programmers off guard
+ static const uint8_t and_flags[] = {
+ 0xFF,0xFF, 0xFF,0xFE,0xFF,0xFD, 0xFF,0xFF,0xFF
+ };
+ static const uint8_t or_flags[] = {
+ 0x00,0x00, 0x01,0x00,0x02,0x00, 0x00,0x00,0x00
+ };
+
// We need access to the Z80
Z80_REQUEST();
@@ -386,6 +396,15 @@ uint16_t echo_get_status(void) {
if (z80_ram[0x1F00] != 0xFF)
status |= ECHO_STAT_DIRBUSY;
+ // Look ahead in the queue for any pending commands
+ // Adjust the flags accordingly if needed
+ uint8_t command = z80_ram[0x1FFF];
+ status &= and_flags[command];
+ status |= or_flags[command];
+ command = z80_ram[0x1FFB];
+ status &= and_flags[command];
+ status |= or_flags[command];
+
// Done with the Z80
Z80_RELEASE();