From dab96d6a28fa21e2c486504c3c7d35bd8c51633b Mon Sep 17 00:00:00 2001 From: tudnai Date: Sat, 2 May 2020 10:36:21 -0700 Subject: [PATCH] Fixed Text Page switching --- src/dev/mem/mmio.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/dev/mem/mmio.h b/src/dev/mem/mmio.h index f50a122..4fcb9ca 100644 --- a/src/dev/mem/mmio.h +++ b/src/dev/mem/mmio.h @@ -324,28 +324,32 @@ void resetMemory() { static uint8_t page2 = 0; +static uint8_t * activePage = Apple2_64K_RAM + 0x400; void textPageSelect() { uint8_t * shadow = Apple2_64K_MEM + 0x400; if ( page2 != MEMcfg.txt_page_2 ) { page2 = MEMcfg.txt_page_2; - + static uint8_t * newPage = NULL; + if ( MEMcfg.is_80STORE && MEMcfg.txt_page_2 ) { - // save the content of Shadow Memory - memcpy(Apple2_64K_RAM + 0x400, shadow, 0x400); - - // load the content of Video Page 2 - memcpy(shadow, Apple2_64K_AUX, 0x400); - + newPage = Apple2_64K_AUX + 0x400; } else { - // save the content of Shadow Memory - memcpy(Apple2_64K_AUX + 0x400, shadow, 0x400); + newPage = Apple2_64K_RAM + 0x400; + } + + if ( activePage != newPage ) { + if ( activePage ) { + // save the content of Shadow Memory + memcpy(activePage, shadow, 0x400); + } // load the content of Video Page 2 - memcpy(shadow, Apple2_64K_RAM, 0x400); + memcpy(shadow, newPage, 0x400); + activePage = newPage; } }