. [Bug #18940] Extend BSAVE and BLOAD Command To Memory Banks 0 and 1
	Extended debugger BLOAD with bank support:
	. BLOAD [file],[bank:]address[,length]
	. BLOAD [file],[bank:]address[:end]
	. If no filename specified, will use last BLOAD or BSAVE filename.
	Extended debugger BSAVE with bank support:
	. BSAVE [file],[bank:]address,length
	. BSAVE [file],[bank:]address:end
	. If no filename specified, defaults to: '####.####.[bank##].bin'
		(where the form is <address>.<length>.bin)
This commit is contained in:
tomch 2013-09-14 21:46:39 +00:00
parent d5ae003e56
commit fae019856a
6 changed files with 219 additions and 55 deletions

View file

@ -12,10 +12,20 @@ https://developer.berlios.de/feature/?func=addfeature&group_id=6117
Tom Charlesworth Tom Charlesworth
tomch at users.berlios.de tomch at users.berlios.de
1.23.1 - 8 Aug 2013 1.23.2 - 14 Sep 2013
-------------------- --------------------
Changes: Changes:
. Added About dialog showing GPL (at startup, but only when AppleWin version changes). . Added About dialog showing GPL (at startup, but only when AppleWin version changes).
. [Bug #18940] Extend BSAVE and BLOAD Command To Memory Banks 0 and 1
Extended debugger BLOAD with bank support:
. BLOAD [file],[bank:]address[,length]
. BLOAD [file],[bank:]address[:end]
. If no filename specified, will use last BLOAD or BSAVE filename.
Extended debugger BSAVE with bank support:
. BSAVE [file],[bank:]address,length
. BSAVE [file],[bank:]address:end
. If no filename specified, defaults to: '####.####.[bank##].bin'
(where the form is <address>.<length>.bin)
Fixes: Fixes:
. Fixed save-state bug for when 4K BANK1 is dirty (previously it would save the stale data instead). . Fixed save-state bug for when 4K BANK1 is dirty (previously it would save the stale data instead).

View file

@ -246,8 +246,8 @@ DISK_ICON ICON "DISK.ICO"
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,23,1,0 FILEVERSION 1,23,2,0
PRODUCTVERSION 1,23,1,0 PRODUCTVERSION 1,23,2,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -265,12 +265,12 @@ BEGIN
VALUE "Comments", "http://applewin.berlios.de" VALUE "Comments", "http://applewin.berlios.de"
VALUE "CompanyName", "AppleWin" VALUE "CompanyName", "AppleWin"
VALUE "FileDescription", "Apple //e Emulator for Windows" VALUE "FileDescription", "Apple //e Emulator for Windows"
VALUE "FileVersion", "1, 23, 1, 0" VALUE "FileVersion", "1, 23, 2, 0"
VALUE "InternalName", "APPLEWIN" VALUE "InternalName", "APPLEWIN"
VALUE "LegalCopyright", " 1994-2013 Michael O'Brien, Oliver Schmidt, Tom Charlesworth, Michael Pohoreski, Nick Westgate, Linards Ticmanis" VALUE "LegalCopyright", " 1994-2013 Michael O'Brien, Oliver Schmidt, Tom Charlesworth, Michael Pohoreski, Nick Westgate, Linards Ticmanis"
VALUE "OriginalFilename", "APPLEWIN.EXE" VALUE "OriginalFilename", "APPLEWIN.EXE"
VALUE "ProductName", "Apple //e Emulator" VALUE "ProductName", "Apple //e Emulator"
VALUE "ProductVersion", "1, 23, 1, 0" VALUE "ProductVersion", "1, 23, 2, 0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -4007,6 +4007,7 @@ Update_t CmdConfigSetDebugDir (int nArgs)
} }
//=========================================================================== //===========================================================================
#if 0 // Original
Update_t CmdMemoryLoad (int nArgs) Update_t CmdMemoryLoad (int nArgs)
{ {
// BLOAD ["Filename"] , addr[, len] // BLOAD ["Filename"] , addr[, len]
@ -4128,6 +4129,164 @@ Update_t CmdMemoryLoad (int nArgs)
return ConsoleUpdate(); return ConsoleUpdate();
} }
#else // Extended cmd for loading physical memory
Update_t CmdMemoryLoad (int nArgs)
{
// Active memory:
// BLOAD ["Filename"] , addr[, len]
// BLOAD ["Filename"] , addr[: end]
// 1 2 3 4 5
// Physical 64K memory bank:
// BLOAD ["Filename"] , bank : addr [, len]
// BLOAD ["Filename"] , bank : addr [: end]
// 1 2 3 4 5 6 7
if (nArgs > 7)
return Help_Arg_1( CMD_MEMORY_LOAD );
if (nArgs < 1)
return Help_Arg_1( CMD_MEMORY_LOAD );
bool bHaveFileName = false;
if (g_aArgs[1].bType & TYPE_QUOTED_2)
bHaveFileName = true;
// if (g_aArgs[2].bType & TOKEN_QUOTE_DOUBLE)
// bHaveFileName = true;
int iArgComma1 = 2;
int iArgAddress = 3;
int iArgComma2 = 4;
int iArgLength = 5;
int iArgBank = 3;
int iArgColon = 4;
int nBank = 0;
bool bBankSpecified = false;
if (! bHaveFileName)
{
iArgComma1 = 1;
iArgAddress = 2;
iArgComma2 = 3;
iArgLength = 4;
iArgBank = 2;
iArgColon = 3;
if (nArgs > 6)
return Help_Arg_1( CMD_MEMORY_LOAD );
}
if (nArgs >= 5)
{
if (!(g_aArgs[iArgBank].bType & TYPE_ADDRESS && g_aArgs[iArgColon].eToken == TOKEN_COLON))
return Help_Arg_1( CMD_MEMORY_LOAD );
nBank = g_aArgs[iArgBank].nValue;
bBankSpecified = true;
iArgAddress += 2;
iArgComma2 += 2;
iArgLength += 2;
}
else
{
bBankSpecified = false;
}
if (g_aArgs[ iArgComma1 ].eToken != TOKEN_COMMA)
return Help_Arg_1( CMD_MEMORY_LOAD );
TCHAR sLoadSaveFilePath[ MAX_PATH ];
_tcscpy( sLoadSaveFilePath, g_sCurrentDir ); // TODO: g_sDebugDir
WORD nAddressStart;
WORD nAddress2 = 0;
WORD nAddressEnd = 0;
int nAddressLen = 0;
RangeType_t eRange;
eRange = Range_Get( nAddressStart, nAddress2, iArgAddress );
if (nArgs > iArgComma2)
{
if (eRange == RANGE_MISSING_ARG_2)
{
return Help_Arg_1( CMD_MEMORY_LOAD );
}
// if (eRange == RANGE_MISSING_ARG_2)
if (! Range_CalcEndLen( eRange, nAddressStart, nAddress2, nAddressEnd, nAddressLen ))
{
return Help_Arg_1( CMD_MEMORY_LOAD );
}
}
if (bHaveFileName)
{
_tcscpy( g_sMemoryLoadSaveFileName, g_aArgs[ 1 ].sArg );
}
_tcscat( sLoadSaveFilePath, g_sMemoryLoadSaveFileName );
BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank) : mem;
if (!pMemBankBase)
{
ConsoleBufferPush( TEXT( "Error: Bank out of range." ) );
return ConsoleUpdate();
}
FILE *hFile = fopen( sLoadSaveFilePath, "rb" );
if (hFile)
{
fseek( hFile, 0, SEEK_END );
int nFileBytes = ftell( hFile );
fseek( hFile, 0, SEEK_SET );
if (nFileBytes > _6502_MEM_END)
nFileBytes = _6502_MEM_END + 1; // Bank-switched RAM/ROM is only 16-bit
// Caller didn't specify how many bytes to read, default to them all
if (nAddressLen == 0)
{
nAddressLen = nFileBytes;
}
size_t nRead = fread( pMemBankBase+nAddressStart, nAddressLen, 1, hFile );
if (nRead == 1)
{
ConsoleBufferPush( TEXT( "Loaded." ) );
}
else
{
ConsoleBufferPush( TEXT( "Error loading data." ) );
}
fclose( hFile );
if (bBankSpecified)
{
MemUpdatePaging(1);
}
else
{
for (UINT i=(nAddressStart>>8); i!=((nAddressStart+nAddressLen)>>8); i++)
{
memdirty[i] = 0xff;
}
}
}
else
{
ConsoleBufferPush( TEXT( "ERROR: Bad filename" ) );
CmdConfigGetDebugDir( 0 );
TCHAR sFile[ MAX_PATH + 8 ] = "File: ";
_tcscat( sFile, g_sMemoryLoadSaveFileName );
ConsoleBufferPush( sFile );
}
return ConsoleUpdate();
}
#endif
// dst src : len // dst src : len
//=========================================================================== //===========================================================================
@ -4404,7 +4563,10 @@ Update_t CmdMemorySave (int nArgs)
{ {
if (! bHaveFileName) if (! bHaveFileName)
{ {
sprintf( g_sMemoryLoadSaveFileName, "%04X.%04X.bin", nAddressStart, nAddressLen ); // nAddressEnd ); if (! bBankSpecified)
sprintf( g_sMemoryLoadSaveFileName, "%04X.%04X.bin", nAddressStart, nAddressLen );
else
sprintf( g_sMemoryLoadSaveFileName, "%04X.%04X.bank%02X.bin", nAddressStart, nAddressLen, nBank );
} }
else else
{ {
@ -4412,24 +4574,11 @@ Update_t CmdMemorySave (int nArgs)
} }
_tcscat( sLoadSaveFilePath, g_sMemoryLoadSaveFileName ); _tcscat( sLoadSaveFilePath, g_sMemoryLoadSaveFileName );
// if (nArgs == 2)
{
const BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank) : mem; const BYTE * const pMemBankBase = bBankSpecified ? MemGetBankPtr(nBank) : mem;
if (!pMemBankBase) if (!pMemBankBase)
{ {
ConsoleBufferPush( TEXT( "Error: Bank out of range." ) ); ConsoleBufferPush( TEXT( "Error: Bank out of range." ) );
return ConsoleUpdate();; return ConsoleUpdate();
}
BYTE * const pMemory = new BYTE [ nAddressLen ];
BYTE *pDst = pMemory;
const BYTE *pSrc = pMemBankBase + nAddressStart;
// memcpy -- copy out of active memory bank
int iByte;
for( iByte = 0; iByte < nAddressLen; iByte++ )
{
*pDst++ = *pSrc++;
} }
FILE *hFile = fopen( sLoadSaveFilePath, "rb" ); FILE *hFile = fopen( sLoadSaveFilePath, "rb" );
@ -4442,8 +4591,8 @@ Update_t CmdMemorySave (int nArgs)
hFile = fopen( sLoadSaveFilePath, "wb" ); hFile = fopen( sLoadSaveFilePath, "wb" );
if (hFile) if (hFile)
{ {
size_t nWrote = fwrite( pMemory, nAddressLen, 1, hFile ); size_t nWrote = fwrite( pMemBankBase+nAddressStart, nAddressLen, 1, hFile );
if (nWrote == 1) // (size_t)nAddressLen) if (nWrote == 1)
{ {
ConsoleBufferPush( TEXT( "Saved." ) ); ConsoleBufferPush( TEXT( "Saved." ) );
} }
@ -4453,8 +4602,9 @@ Update_t CmdMemorySave (int nArgs)
} }
fclose( hFile ); fclose( hFile );
} }
else
delete [] pMemory; {
ConsoleBufferPush( TEXT( "Error opening file." ) );
} }
} }
} }
@ -4463,7 +4613,6 @@ Update_t CmdMemorySave (int nArgs)
} }
#endif #endif
//=========================================================================== //===========================================================================
int _SearchMemoryFind( int _SearchMemoryFind(
MemorySearchValues_t vMemorySearchValues, MemorySearchValues_t vMemorySearchValues,

View file

@ -1169,26 +1169,25 @@ Update_t CmdHelpSpecific (int nArgs)
case CMD_MEMORY_SAVE: case CMD_MEMORY_SAVE:
if (iCommand == CMD_MEMORY_LOAD) if (iCommand == CMD_MEMORY_LOAD)
{ {
sprintf( sTemp, " Usage: [\"Filename\",]address[,length]" ); sprintf( sTemp, " Usage: [\"Filename\"],[bank:]address[,length]" );
Colorize( sText, sTemp ); Colorize( sText, sTemp );
ConsolePrint( sText ); ConsolePrint( sText );
sprintf( sTemp, " Usage: [\"Filename\",]range" ); sprintf( sTemp, " Usage: [\"Filename\"],[bank:]range" );
Colorize( sText, sTemp ); Colorize( sText, sTemp );
ConsolePrint( sText ); ConsolePrint( sText );
Help_Range(); Help_Range();
ConsoleBufferPush( " Notes: If no filename specified, defaults to the last filename (if possible)" ); ConsoleBufferPush( " Notes: If no filename specified, defaults to the last filename (if possible)" );
ConsoleBufferPush( " Optional bank not supported for BLOAD" );
} }
if (iCommand == CMD_MEMORY_SAVE) if (iCommand == CMD_MEMORY_SAVE)
{ {
sprintf( sTemp, " Usage: [\"Filename\",][bank:]address,length" ); sprintf( sTemp, " Usage: [\"Filename\"],[bank:]address,length" );
Colorize( sText, sTemp ); Colorize( sText, sTemp );
ConsolePrint( sText ); ConsolePrint( sText );
sprintf( sTemp, " Usage: [\"Filename\",][bank:]range" ); sprintf( sTemp, " Usage: [\"Filename\"],[bank:]range" );
Colorize( sText, sTemp ); Colorize( sText, sTemp );
ConsolePrint( sText ); ConsolePrint( sText );
Help_Range(); Help_Range();
ConsoleBufferPush( " Notes: If no filename specified, defaults to: '####.####.bin'" ); ConsoleBufferPush( " Notes: If no filename specified, defaults to: '####.####.[bank##].bin'" );
ConsoleBufferPush( " Where the form is <address>.<length>.bin" ); ConsoleBufferPush( " Where the form is <address>.<length>.bin" );
} }
@ -1198,8 +1197,10 @@ Update_t CmdHelpSpecific (int nArgs)
sprintf( sText, "%s BLOAD \"test\",2000:2010" , CHC_EXAMPLE ); ConsolePrint( sText ); sprintf( sText, "%s BLOAD \"test\",2000:2010" , CHC_EXAMPLE ); ConsolePrint( sText );
sprintf( sText, "%s BSAVE \"test\",F000:FFFF" , CHC_EXAMPLE ); ConsolePrint( sText ); sprintf( sText, "%s BSAVE \"test\",F000:FFFF" , CHC_EXAMPLE ); ConsolePrint( sText );
sprintf( sText, "%s BLOAD \"test\",4000" , CHC_EXAMPLE ); ConsolePrint( sText ); sprintf( sText, "%s BLOAD \"test\",4000" , CHC_EXAMPLE ); ConsolePrint( sText );
sprintf( sText, "%s BSAVE \"test\",0:2000,2000" , CHC_EXAMPLE ); ConsolePrint( sText ); sprintf( sText, "%s BLOAD \"main.bin\",0:2000" , CHC_EXAMPLE ); ConsolePrint( sText );
sprintf( sText, "%s BSAVE \"test\",1:2000:3FFF" , CHC_EXAMPLE ); ConsolePrint( sText ); sprintf( sText, "%s BSAVE \"aux2.bin\",1:2000" , CHC_EXAMPLE ); ConsolePrint( sText );
sprintf( sText, "%s BSAVE \"main.bin\",0:2000,2000" , CHC_EXAMPLE ); ConsolePrint( sText );
sprintf( sText, "%s BSAVE \"aux2.bin\",1:2000:3FFF" , CHC_EXAMPLE ); ConsolePrint( sText );
break; break;
case CMD_MEMORY_SEARCH: case CMD_MEMORY_SEARCH:
Colorize( sText, " Usage: range <\"ASCII text\" | 'apple text' | hex>" ); Colorize( sText, " Usage: range <\"ASCII text\" | 'apple text' | hex>" );

View file

@ -846,6 +846,11 @@ void ResetPaging (BOOL initialize)
//=========================================================================== //===========================================================================
void MemUpdatePaging(BOOL initialize)
{
UpdatePaging(initialize, 0);
}
static void UpdatePaging (BOOL initialize, BOOL updatewriteonly /*Always zero*/) static void UpdatePaging (BOOL initialize, BOOL updatewriteonly /*Always zero*/)
{ {
// SAVE THE CURRENT PAGING SHADOW TABLE // SAVE THE CURRENT PAGING SHADOW TABLE

View file

@ -45,9 +45,8 @@ BYTE MemReadFloatingBus(const ULONG uExecutedCycles);
BYTE MemReadFloatingBus(const BYTE highbit, const ULONG uExecutedCycles); BYTE MemReadFloatingBus(const BYTE highbit, const ULONG uExecutedCycles);
void MemReset (); void MemReset ();
void MemResetPaging (); void MemResetPaging ();
void MemUpdatePaging(BOOL initialize);
BYTE MemReturnRandomData (BYTE highbit); BYTE MemReturnRandomData (BYTE highbit);
void MemSetFastPaging (BOOL);
void MemTrimImages ();
LPVOID MemGetSlotParameters (UINT uSlot); LPVOID MemGetSlotParameters (UINT uSlot);
DWORD MemGetSnapshot(SS_BaseMemory* pSS); DWORD MemGetSnapshot(SS_BaseMemory* pSS);
DWORD MemSetSnapshot(SS_BaseMemory* pSS); DWORD MemSetSnapshot(SS_BaseMemory* pSS);