From af899fa90acfd3ec2fde24146f9e7f2946c8c967 Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 19 Nov 2018 22:15:04 +0000 Subject: [PATCH 1/6] Added support for Apple II/II+ 2K video ROMs (fixes #205) --- source/Applewin.cpp | 4 +-- source/NTSC_CharSet.cpp | 55 ++++++++++++++++++++++++++++++++++++++--- source/Video.cpp | 4 +-- source/Video.h | 3 ++- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 9d2fb161..411a0ec8 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -1289,14 +1289,14 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) if ((g_hCustomRomF8 == INVALID_HANDLE_VALUE) || (GetFileSize(g_hCustomRomF8, NULL) != 0x800)) g_bCustomRomF8Failed = true; } - else if (strcmp(lpCmdLine, "-videorom") == 0) // Use 4K,8K or 16K video ROM for Enhanced //e + else if (strcmp(lpCmdLine, "-videorom") == 0) // Use 2K (for II/II+). Use 4K,8K or 16K video ROM (for Enhanced //e) { lpCmdLine = GetCurrArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg); if (!ReadVideoRomFile(lpCmdLine)) { - std::string msg = "Failed to load video rom (not found or not exactly 4/8/16KiB)"; + std::string msg = "Failed to load video rom (not found or not exactly 2/4/8/16KiB)"; LogFileOutput("%s", msg.c_str()); MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); } diff --git a/source/NTSC_CharSet.cpp b/source/NTSC_CharSet.cpp index 88d1250f..a150f26b 100644 --- a/source/NTSC_CharSet.cpp +++ b/source/NTSC_CharSet.cpp @@ -154,11 +154,11 @@ void userVideoRom4K(csbits_t csbits, const BYTE* pVideoRom) } } -void userVideoRom(void) +void userVideoRomForIIe(void) { const BYTE* pVideoRom; - UINT size = GetVideoRom(pVideoRom); // 4K or 8K - if (!size) + UINT size = GetVideoRom(pVideoRom); // 2K or 4K or 8K + if (size < kVideoRomSize4K) return; if (size == kVideoRomSize4K) @@ -173,6 +173,50 @@ void userVideoRom(void) //------------------------------------- +void userVideoRom2K(csbits_t csbits, const BYTE* pVideoRom) +{ + int RA = 0; // rom address + + for (int i=0; i<256; i++, RA+=8) + { + for (int y=0; y<8; y++) + { + BYTE d=0; + BYTE n = pVideoRom[RA+y]; + + // UTAII:8-30 "Bit 7 of your EPROM fonts will control flashing in the lower 1024 bytes of the EPROM" + // UTAII:8-31 "If you leave O7 (EPROM Output7) reset in these patterns, the resulting characters will be inversions..." + if (!(n & 0x80) && RA < 1024) + n = n ^ 0x7f; + n &= 0x7f; + + // UTAII:8-30 "TEXT ROM pattern is ... reversed" + for (BYTE j=0; j<7; j++) + { + if (n & 1) + d |= 1; + d <<= 1; + n >>= 1; + } + + d >>= 1; // Undo the last left shift + csbits[0][i][y] = d; + } + } +} + +void userVideoRomForIIPlus(void) +{ + const BYTE* pVideoRom; + UINT size = GetVideoRom(pVideoRom); // 2K or 4K or 8K + if (size != kVideoRomSize2K) + return; + + userVideoRom2K(&csbits_a2[0], pVideoRom); +} + +//------------------------------------- + void make_csbits(void) { get_csbits(&csbits_enhanced2e[0], TEXT("CHARSET40"), 0); // Enhanced //e: Alt char set off @@ -188,7 +232,10 @@ void make_csbits(void) memcpy(&csbits_2e[1][64], &csbits_2e[0][64], 32*8); // Try to use any user-provided video ROM for Enhanced //e - userVideoRom(); + userVideoRomForIIe(); + + // Try to use any user-provided video ROM for II/II+ + userVideoRomForIIPlus(); } csbits_t GetEnhanced2e_csbits(void) diff --git a/source/Video.cpp b/source/Video.cpp index 3d593218..c26b56e6 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -1160,7 +1160,7 @@ bool ReadVideoRomFile(const char* pRomFile) return false; const ULONG size = GetFileSize(h, NULL); - if (size == kVideoRomSize4K || size == kVideoRomSize8K || size == kVideoRomSize16K) + if (size == kVideoRomSize2K || size == kVideoRomSize4K || size == kVideoRomSize8K || size == kVideoRomSize16K) { DWORD bytesRead; if (ReadFile(h, g_videoRom, size, &bytesRead, NULL) && bytesRead == size) @@ -1197,7 +1197,7 @@ void SetVideoRomRockerSwitch(bool state) bool IsVideoRom4K(void) { - return g_videoRomSize == 0 || g_videoRomSize == kVideoRomSize4K; + return g_videoRomSize <= kVideoRomSize4K; } //=========================================================================== diff --git a/source/Video.h b/source/Video.h index 301b503b..2ab5d360 100644 --- a/source/Video.h +++ b/source/Video.h @@ -200,7 +200,8 @@ void Video_SetBitmapHeader( WinBmpHeader_t *pBmp, int nWidth, int nHeight, int n BYTE VideoSetMode(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles); -const UINT kVideoRomSize4K = 4*1024; +const UINT kVideoRomSize2K = 1024*2; +const UINT kVideoRomSize4K = kVideoRomSize2K*2; bool ReadVideoRomFile(const char* pRomFile); UINT GetVideoRom(const BYTE*& pVideoRom); bool GetVideoRomRockerSwitch(void); From cbd41333c944bc427745feacc3c0563fcd0b29f4 Mon Sep 17 00:00:00 2001 From: tomcw Date: Wed, 21 Nov 2018 21:21:54 +0000 Subject: [PATCH 2/6] 2K ROM: refactor --- source/NTSC_CharSet.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/source/NTSC_CharSet.cpp b/source/NTSC_CharSet.cpp index a150f26b..a5d6c906 100644 --- a/source/NTSC_CharSet.cpp +++ b/source/NTSC_CharSet.cpp @@ -181,25 +181,18 @@ void userVideoRom2K(csbits_t csbits, const BYTE* pVideoRom) { for (int y=0; y<8; y++) { - BYTE d=0; BYTE n = pVideoRom[RA+y]; // UTAII:8-30 "Bit 7 of your EPROM fonts will control flashing in the lower 1024 bytes of the EPROM" // UTAII:8-31 "If you leave O7 (EPROM Output7) reset in these patterns, the resulting characters will be inversions..." if (!(n & 0x80) && RA < 1024) n = n ^ 0x7f; - n &= 0x7f; // UTAII:8-30 "TEXT ROM pattern is ... reversed" - for (BYTE j=0; j<7; j++) - { - if (n & 1) - d |= 1; - d <<= 1; - n >>= 1; - } + BYTE d = 0; + for (BYTE j=0; j<7; j++, n >>= 1) // Just bits [0..6] + d = (d << 1) | (n & 1); - d >>= 1; // Undo the last left shift csbits[0][i][y] = d; } } From 5504d280c7d1606c1cf64d26f6f06a200b5ca40c Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 3 Dec 2018 17:38:52 +0000 Subject: [PATCH 3/6] When drive is off then data register holds its present state. (Fixes #599) NB. Drive off = motor off && stopped spinning after 1 sec delay. --- source/Disk.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index d3998ae7..06cb34dc 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -892,10 +892,14 @@ static void __stdcall DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULO } } - // Should really test for drive off - after 1 second drive off delay (UTAIIe page 9-13) - // but Sherwood Forest sets shift mode and reads with the drive off, so don't check for now if (!floppywritemode) { + // Don't change latch if drive off after 1 second drive-off delay (UTAIIe page 9-13) + // "DRIVES OFF forces the data register to hold its present state." (UTAIIe page 9-12) + // Note: Sherwood Forest sets shift mode and reads with the drive off. + if (!pDrive->spinning) // GH#599 + return; + const ULONG nReadCycleDiff = (ULONG) (g_nCumulativeCycles - g_uDiskLastReadLatchCycle); // Support partial nibble read if disk reads are very close: (GH#582) @@ -954,10 +958,8 @@ static void __stdcall DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULO if (++pFloppy->byte >= pFloppy->nibbles) pFloppy->byte = 0; - // Feature Request #201 Show track status - // https://github.com/AppleWin/AppleWin/issues/201 - // NB. Prevent flooding of forcing UI to redraw!!! - if( ((pFloppy->byte) & 0xFF) == 0 ) + // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!! + if ((pFloppy->byte & 0xFF) == 0) FrameDrawDiskStatus( (HDC)0 ); } @@ -1052,11 +1054,16 @@ bool DiskSelect(const int iDrive) static void __stdcall DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG) { /* floppyloadmode = 1; */ + + // Don't change latch if drive off after 1 second drive-off delay (UTAIIe page 9-13) + // "DRIVES OFF forces the data register to hold its present state." (UTAIIe page 9-12) + // Note: Gemstone Warrior sets load mode with the drive off. + if (g_aFloppyDrive[currdrive].spinning) // GH#599 + return; + if (!write) { // Notes: - // . Should really test for drive off - after 1 second drive off delay (UTAIIe page 9-13) - // but Gemstone Warrior sets load mode with the drive off, so don't check for now // . Phase 1 on also forces write protect in the Disk II drive (UTAIIe page 9-7) but we don't implement that // . write mode doesn't prevent reading write protect (GH#537): // "If for some reason the above write protect check were entered with the READ/WRITE switch in WRITE, From 5ddff0d688e29e5d32b5ea025ca62dc1e158fe4c Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 3 Dec 2018 21:36:54 +0000 Subject: [PATCH 4/6] DiskII: read write protect - fix spinning test --- source/Disk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 06cb34dc..b07f16ab 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -1058,7 +1058,7 @@ static void __stdcall DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, U // Don't change latch if drive off after 1 second drive-off delay (UTAIIe page 9-13) // "DRIVES OFF forces the data register to hold its present state." (UTAIIe page 9-12) // Note: Gemstone Warrior sets load mode with the drive off. - if (g_aFloppyDrive[currdrive].spinning) // GH#599 + if (!g_aFloppyDrive[currdrive].spinning) // GH#599 return; if (!write) From 54fffdf25a978c33faf4e62557b0d67d125bc912 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 8 Dec 2018 13:29:48 +0000 Subject: [PATCH 5/6] 1.27.13: Bump version & update History.txt + help --- AppleWinExpress2008.vcproj | 4 ++++ bin/History.txt | 9 ++++++++- help/CommandLine.html | 14 ++++++++------ help/dbg-screen-layout.html | 4 ++-- help/savestate.html | 3 +++ resource/Applewin.rc | 9 +++++---- resource/version.h | 5 +++++ source/Applewin.cpp | 4 ++-- 8 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 resource/version.h diff --git a/AppleWinExpress2008.vcproj b/AppleWinExpress2008.vcproj index 1b926246..ccc80c1f 100644 --- a/AppleWinExpress2008.vcproj +++ b/AppleWinExpress2008.vcproj @@ -1285,6 +1285,10 @@ RelativePath=".\resource\TKClock.rom" > + + diff --git a/bin/History.txt b/bin/History.txt index 7dd8b0c0..f4a9a2a7 100644 --- a/bin/History.txt +++ b/bin/History.txt @@ -8,10 +8,17 @@ https://github.com/AppleWin/AppleWin/issues/new Tom Charlesworth +1.27.13.0 - 8 Dec 2018 +---------------------- +. [Bug #599] Fix for Ultima V not loading in Authentic Speed mode (regression introduced at 1.27.9.0). +. [Change #205] Added support for Apple II/II+ custom 2K video ROMs. + - Extended command line switch: -videorom + - If the ROM sizs is 2K, then it replaces the video ROM for the Apple II/II+. + 1.27.12.0 - 17 Nov 2018 ----------------------- -. [Change #574] Add support for PAL/European or custom 8K video ROMs: +. [Change #574] Added support for PAL/European or custom 8K video ROMs: - Added new command line switch: -videorom - Replaces the video ROM for the Enhanced //e. - Support video ROM sizes of 4K, 8K and 16K (top 8K only). diff --git a/help/CommandLine.html b/help/CommandLine.html index 0eb15a2d..1d265e69 100644 --- a/help/CommandLine.html +++ b/help/CommandLine.html @@ -20,16 +20,16 @@ -h2 <pathname>
Start with hard disk 2 plugged-in. NB. Hard disk controller card gets enabled.

-s0 <saturn|saturn64|saturn128>
- Insert a Saturn 64K or Saturn 128K card into slot 0 in Apple II or Apple II+ machines (or similar clone).
+ Insert a Saturn 64K or Saturn 128K card into slot 0 in the Apple II or II+ machines (or similar clone).
Where -s0 saturn is an alias for -s0 saturn128.

-s0 <languagecard|lc>
- Insert an Apple 16K Language Card into slot 0 in Apple II and use the F8 auto-start ROM.
+ Insert an Apple 16K Language Card into slot 0 in the original Apple II and use the F8 auto-start ROM.
NB. The Apple II+ already defaults to having a Language Card, so this switch is not required.

-s7 empty
Remove the hard disk controller card from slot 7.
Useful to allow a floppy disk to boot from slot 6, drive 1. Use in combination with -d1.

-r <number of pages>
- Emulate a RAMworks III card with 1 to 127 pages (each page is 64K, giving a max of 8MB) in the auxiliary slot in an Apple //e machine.

+ Emulate a RamWorks III card with 1 to 127 pages (each page is 64K, giving a max of 8MB) in the auxiliary slot in an Apple //e machine.

-load-state <savestate>
Load a save-state file
NB. This takes precedent over the -d1,d2,h1,h2,s0,s7 and -r switches.

@@ -42,10 +42,12 @@
  • nnnn: select a specific resolution with height=nnnn pixels
  • NB. This changes the display resolution (and restores on exit).

    - -f8rom <rom-file>
    - Use custom 2K ROM at [$F800..$FFFF]. <rom-file> must be 2048 bytes long

    + -f8rom <file>
    + Use custom 2K ROM for any Apple II machine at [$F800..$FFFF]. <file> must be 2048 bytes long

    -videorom <file>
    - Use an alternate European or custom 4K, 8K or 16K video ROM.

    + Use an alternate custom 2K video ROM for Apple II or II+ machines (but not clones).
    + Use an alternate European or custom 4K, 8K or 16K (top 8K only) video ROM for the Enhanced //e.
    + NB. There's currently no support for using an alternate video ROM for the original Apple //e or clones.

    -printscreen
    Enable the dialog box to display the last file saved to

    -no-printscreen-key
    diff --git a/help/dbg-screen-layout.html b/help/dbg-screen-layout.html index f3dc010e..e46abe6f 100644 --- a/help/dbg-screen-layout.html +++ b/help/dbg-screen-layout.html @@ -38,14 +38,14 @@
  • 0C: $C00C - Col40/80 (inverse indicates state of 80COL)
  • 0E: $C00E - ASC/MOUS (inverse indicates state of ALTCHARSET)
  • 80: $C080-C087: B2/M R/W (Language Card Bank2) -
  • 88: $C088-C08F: B1/M rNN (Language Card Bank1 and RAMworks 64K bank number) +
  • 88: $C088-C08F: B1/M rNN (Language Card Bank1 and RamWorks 64K bank number)
    • 'B2' or 'B1' is inverse when that LC bank is enabled.
    • If 'M' is inverse: ROM is active for reading.
    • If 'M' is not inverse: LC2 or LC1 RAM is active.
    • If 'W' is inverse: RAM is write enabled.
    • If 'W' is not inverse: RAM is write protected. -
    • 'rNN' will appear if a RAMworks 64K bank is active. +
    • 'rNN' will appear if a RamWorks 64K bank is active.
    • 'sNN' will appear if a Saturn 16K bank is active.
    diff --git a/help/savestate.html b/help/savestate.html index c98e7a32..6cbef20b 100644 --- a/help/savestate.html +++ b/help/savestate.html @@ -37,6 +37,9 @@
  • Uthernet card
  • SAM card
  • No-Slot clock (there's nothing to persist)
  • +
  • Using The Freeze's F8 ROM
  • +
  • Alternate F8 ROM
  • +
  • Alternate video ROM
  • Note: Only the file names of the disk images are stored in the .yaml file (not the full path). This allows you to move your disk image around or distribute them. diff --git a/resource/Applewin.rc b/resource/Applewin.rc index 9c20dd50..ffcc230e 100644 --- a/resource/Applewin.rc +++ b/resource/Applewin.rc @@ -1,6 +1,7 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" +#include "version.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -252,8 +253,8 @@ DISK_ICON ICON "DISK.ICO" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,27,12,0 - PRODUCTVERSION 1,27,12,0 + FILEVERSION APPLEWIN_VERSION + PRODUCTVERSION APPLEWIN_VERSION FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -271,12 +272,12 @@ BEGIN VALUE "Comments", "https://github.com/AppleWin" VALUE "CompanyName", "AppleWin" VALUE "FileDescription", "Apple //e Emulator for Windows" - VALUE "FileVersion", "1, 27, 12, 0" + VALUE "FileVersion", APPLEWIN_VERSION_STR VALUE "InternalName", "APPLEWIN" VALUE "LegalCopyright", " 1994-2018 Michael O'Brien, Oliver Schmidt, Tom Charlesworth, Michael Pohoreski, Nick Westgate, Linards Ticmanis" VALUE "OriginalFilename", "APPLEWIN.EXE" VALUE "ProductName", "Apple //e Emulator" - VALUE "ProductVersion", "1, 27, 12, 0" + VALUE "ProductVersion", APPLEWIN_VERSION_STR END END BLOCK "VarFileInfo" diff --git a/resource/version.h b/resource/version.h new file mode 100644 index 00000000..ba6ac1b3 --- /dev/null +++ b/resource/version.h @@ -0,0 +1,5 @@ +#define APPLEWIN_VERSION 1,27,13,0 + +#define xstr(a) str(a) +#define str(a) #a +#define APPLEWIN_VERSION_STR xstr(APPLEWIN_VERSION) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 411a0ec8..a63fbb39 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -1296,7 +1296,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) if (!ReadVideoRomFile(lpCmdLine)) { - std::string msg = "Failed to load video rom (not found or not exactly 2/4/8/16KiB)"; + std::string msg = "Failed to load video rom (not found or not exactly 2/4/8/16KiB)\n"; LogFileOutput("%s", msg.c_str()); MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); } @@ -1569,7 +1569,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) if (g_bCustomRomF8Failed) { - std::string msg = "Failed to load custom F8 rom (not found or not exactly 2KiB)"; + std::string msg = "Failed to load custom F8 rom (not found or not exactly 2KiB)\n"; LogFileOutput("%s", msg.c_str()); MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); bShutdown = true; From 7e2f53b62cde2e4e8af2cc592dbd3545e4fa39a6 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 8 Dec 2018 13:36:52 +0000 Subject: [PATCH 6/6] History.txt: fixed typo --- bin/History.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/History.txt b/bin/History.txt index f4a9a2a7..58c2d73d 100644 --- a/bin/History.txt +++ b/bin/History.txt @@ -13,7 +13,7 @@ Tom Charlesworth . [Bug #599] Fix for Ultima V not loading in Authentic Speed mode (regression introduced at 1.27.9.0). . [Change #205] Added support for Apple II/II+ custom 2K video ROMs. - Extended command line switch: -videorom - - If the ROM sizs is 2K, then it replaces the video ROM for the Apple II/II+. + - If the ROM size is 2K, then it replaces the video ROM for the Apple II/II+. 1.27.12.0 - 17 Nov 2018