diff --git a/A2Mac.xcodeproj/project.pbxproj b/A2Mac.xcodeproj/project.pbxproj index 75f02da..1cc7416 100644 --- a/A2Mac.xcodeproj/project.pbxproj +++ b/A2Mac.xcodeproj/project.pbxproj @@ -28,6 +28,7 @@ 32440B7D247CB649000F9DA1 /* Merlin Macroassembler Side 1 (SDS, 1983).woz in Resources */ = {isa = PBXBuildFile; fileRef = 32440B7B247CB649000F9DA1 /* Merlin Macroassembler Side 1 (SDS, 1983).woz */; }; 32440B80247CB66C000F9DA1 /* Merlin Assembler (early version, 40-column, DOS 3.3) side A.woz in Resources */ = {isa = PBXBuildFile; fileRef = 32440B7E247CB66C000F9DA1 /* Merlin Assembler (early version, 40-column, DOS 3.3) side A.woz */; }; 32440B81247CB66C000F9DA1 /* Merlin Assembler (early version, 40-column, DOS 3.3) side B.woz in Resources */ = {isa = PBXBuildFile; fileRef = 32440B7F247CB66C000F9DA1 /* Merlin Assembler (early version, 40-column, DOS 3.3) side B.woz */; }; + 32440B83247CC4C0000F9DA1 /* Wavy Navy (4am crack).woz in Resources */ = {isa = PBXBuildFile; fileRef = 32440B82247CC4C0000F9DA1 /* Wavy Navy (4am crack).woz */; }; 325EB62F23F8856F00C6B4A4 /* woz.c in Sources */ = {isa = PBXBuildFile; fileRef = 325EB62E23F8856F00C6B4A4 /* woz.c */; }; 325EB63623F8F78300C6B4A4 /* disk.c in Sources */ = {isa = PBXBuildFile; fileRef = 325EB63523F8F78300C6B4A4 /* disk.c */; }; 325EB63923F9E48100C6B4A4 /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 325EB63823F9E48100C6B4A4 /* common.c */; }; @@ -174,6 +175,7 @@ 32440B7B247CB649000F9DA1 /* Merlin Macroassembler Side 1 (SDS, 1983).woz */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Merlin Macroassembler Side 1 (SDS, 1983).woz"; sourceTree = ""; }; 32440B7E247CB66C000F9DA1 /* Merlin Assembler (early version, 40-column, DOS 3.3) side A.woz */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Merlin Assembler (early version, 40-column, DOS 3.3) side A.woz"; sourceTree = ""; }; 32440B7F247CB66C000F9DA1 /* Merlin Assembler (early version, 40-column, DOS 3.3) side B.woz */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Merlin Assembler (early version, 40-column, DOS 3.3) side B.woz"; sourceTree = ""; }; + 32440B82247CC4C0000F9DA1 /* Wavy Navy (4am crack).woz */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Wavy Navy (4am crack).woz"; sourceTree = ""; }; 325EB62D23F8856F00C6B4A4 /* woz.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = woz.h; sourceTree = ""; }; 325EB62E23F8856F00C6B4A4 /* woz.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = woz.c; sourceTree = ""; }; 325EB63423F8F78300C6B4A4 /* disk.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = disk.h; sourceTree = ""; }; @@ -452,6 +454,7 @@ 325EB6972401118200C6B4A4 /* Qbit.woz */, 325EB69A2401118300C6B4A4 /* Sneakers.woz */, 325EB6962401118200C6B4A4 /* Wavy Navy.woz */, + 32440B82247CC4C0000F9DA1 /* Wavy Navy (4am crack).woz */, 325EB69B2401118300C6B4A4 /* Xonix.woz */, 32440B73247CAA00000F9DA1 /* Merlin Pro 2.45 (DOS) Disk 1-2.woz */, 32440B74247CAA00000F9DA1 /* Merlin Pro 2.45 (DOS) Disk 2-2.woz */, @@ -825,6 +828,7 @@ 325EB69023FE028800C6B4A4 /* Donkey Kong.woz in Resources */, 325EB68923FDDF6200C6B4A4 /* Hard Hat Mack - Disk 1, Side A.woz in Resources */, 325EB69F2401118300C6B4A4 /* Crossfire.woz in Resources */, + 32440B83247CC4C0000F9DA1 /* Wavy Navy (4am crack).woz in Resources */, 32440B81247CB66C000F9DA1 /* Merlin Assembler (early version, 40-column, DOS 3.3) side B.woz in Resources */, 32440B80247CB66C000F9DA1 /* Merlin Assembler (early version, 40-column, DOS 3.3) side A.woz in Resources */, 32BFFB5F22EACC660003B53F /* Assets.xcassets in Resources */, diff --git a/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist b/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist index bdfa947..cb63d44 100644 --- a/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist +++ b/A2Mac.xcodeproj/project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger/Expressions.xcexplist @@ -66,9 +66,21 @@ + + + + + + + + + value = "MEMcfg"> + value = "AUX[0x22]"> + + diff --git a/A2Mac/Base.lproj/Main.storyboard b/A2Mac/Base.lproj/Main.storyboard index 3cc8976..b77a966 100644 --- a/A2Mac/Base.lproj/Main.storyboard +++ b/A2Mac/Base.lproj/Main.storyboard @@ -711,6 +711,12 @@ + + + + + + diff --git a/A2Mac/ViewController.swift b/A2Mac/ViewController.swift index 3b49870..67acc09 100644 --- a/A2Mac/ViewController.swift +++ b/A2Mac/ViewController.swift @@ -192,10 +192,12 @@ class ViewController: NSViewController { // static var flashingSpace : Character = " " let ramBufferPointer = UnsafeRawBufferPointer(start: MEM, count: 64 * 1024) - static let textPage1Pointer = UnsafeRawBufferPointer(start: MEM + textPage1Addr, count: textBufferSize * 2) - static let textPage2Pointer = UnsafeRawBufferPointer(start: MEM + textPage2Addr, count: textBufferSize * 2) + static let textPage1Pointer = UnsafeRawBufferPointer(start: MEM + textPage1Addr, count: textBufferSize) + static let textPage2Pointer = UnsafeRawBufferPointer(start: MEM + textPage2Addr, count: textBufferSize) + static let textIntBufferPointer = UnsafeRawBufferPointer(start: RAM + textPage1Addr, count: textBufferSize) + static let textAuxBufferPointer = UnsafeRawBufferPointer(start: AUX + textPage1Addr, count: textBufferSize) + var textBufferPointer = textPage1Pointer - let textAuxBufferPointer = UnsafeRawBufferPointer(start: AUX + textPage1Addr, count: textBufferSize) static let textArraySize = textLines * (textCols + lineEndChars) + textCols * 2 @@ -495,7 +497,7 @@ class ViewController: NSViewController { // Rendering is happening in the main thread, which has two implications: // 1. We can update UI elements // 2. it is independent of the simulation, de that is running in the background thread while we are busy with rendering... - DispatchQueue.main.async { + DispatchQueue.main.sync { var txt : String = "" var fromLines = 0 @@ -542,16 +544,21 @@ class ViewController: NSViewController { } // 80 col else { + let auxPage = ( MEMcfg.is_80STORE == 1 ) && ( MEMcfg.txt_page_2 == 1 ) + + let textIntBuffer = auxPage ? ViewController.textIntBufferPointer : ViewController.textPage1Pointer + let textAuxBuffer = auxPage ? ViewController.textPage1Pointer : ViewController.textAuxBufferPointer + // render the rest of the text screen for y in fromLines ..< toLines { for x in 0 ..< self.textCols { - let byte = self.textBufferPointer[ self.textLineOfs[y] + x ] + let byte = textIntBuffer[ self.textLineOfs[y] + x ] let idx = Int(byte); let chr = ViewController.charConvTbl[idx] self.txtArr[ y * (self.textCols * 2 + self.lineEndChars) + x * 2 + 1] = chr - let byte2 = self.textAuxBufferPointer[ self.textLineOfs[y] + x ] + let byte2 = textAuxBuffer[ self.textLineOfs[y] + x ] let idx2 = Int(byte2); let chr2 = ViewController.charConvTbl[idx2] diff --git a/Resources/Wavy Navy (4am crack).woz b/Resources/Wavy Navy (4am crack).woz new file mode 100644 index 0000000..0d9e397 Binary files /dev/null and b/Resources/Wavy Navy (4am crack).woz differ diff --git a/src/dev/mem/mmio.h b/src/dev/mem/mmio.h index b7baa9a..4535ae9 100644 --- a/src/dev/mem/mmio.h +++ b/src/dev/mem/mmio.h @@ -328,36 +328,32 @@ void resetMemory() { } -static uint8_t page2 = 0; -static uint8_t * activePage = Apple2_64K_RAM + 0x400; +static uint8_t activeTextAuxPage = 0; +static uint8_t * activeTextPage = Apple2_64K_RAM + 0x400; +static uint8_t * shadowTextPage = Apple2_64K_MEM + 0x400; + +inline uint8_t *extracted() { + uint8_t * shadow = Apple2_64K_MEM + 0x400; + return shadow; +} void textPageSelect() { - uint8_t * shadow = Apple2_64K_MEM + 0x400; + uint8_t textAuxPage = MEMcfg.is_80STORE && MEMcfg.txt_page_2; - if ( page2 != MEMcfg.txt_page_2 ) { - page2 = MEMcfg.txt_page_2; - static uint8_t * newPage = NULL; + if ( activeTextAuxPage != textAuxPage ) { + activeTextAuxPage = textAuxPage; + uint8_t * newTextPage = ( textAuxPage ? Apple2_64K_AUX : Apple2_64K_RAM ) + 0x400; - if ( MEMcfg.is_80STORE && MEMcfg.txt_page_2 ) { - newPage = Apple2_64K_AUX + 0x400; - } - else { - 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, newPage, 0x400); - - activePage = newPage; + if ( activeTextPage ) { + // save the content of Shadow Memory + memcpy(activeTextPage, shadowTextPage, 0x400); } + + // load the content of new Video Page + memcpy(shadowTextPage, newTextPage, 0x400); + + activeTextPage = newTextPage; } - } @@ -786,7 +782,7 @@ INLINE void ioWrite( uint16_t addr, uint8_t val ) { case io_VID_TXTPAGE2: // printf("io_VID_TXTPAGE2\n"); - MEMcfg.txt_page_2 = ! MEMcfg.is_80STORE; + MEMcfg.txt_page_2 = 1; textPageSelect(); break;