MCPcopy Index your code
hub / github.com/AppleWin/AppleWin / MemInitializeCustomROM

Function MemInitializeCustomROM

source/Memory.cpp:2173–2213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2171}
2172
2173void MemInitializeCustomROM(void)
2174{
2175 if (g_hCustomRom == INVALID_HANDLE_VALUE)
2176 return;
2177
2178 SetFilePointer(g_hCustomRom, 0, NULL, FILE_BEGIN);
2179 DWORD uNumBytesRead;
2180 BOOL bRes = TRUE;
2181
2182 if (GetFileSize(g_hCustomRom, NULL) == Apple2eRomSize)
2183 {
2184 std::vector<BYTE> oldRomC0(pCxRomInternal, pCxRomInternal+CxRomSize); // range ctor: [first,last)
2185 bRes = ReadFile(g_hCustomRom, pCxRomInternal, CxRomSize, &uNumBytesRead, NULL);
2186 if (uNumBytesRead != CxRomSize)
2187 {
2188 memcpy(pCxRomInternal, &oldRomC0[0], CxRomSize); // ROM at $C000...$CFFF
2189 bRes = FALSE;
2190 }
2191 }
2192
2193 if (bRes)
2194 {
2195 std::vector<BYTE> oldRom(memrom, memrom+Apple2RomSize); // range ctor: [first,last)
2196 bRes = ReadFile(g_hCustomRom, memrom, Apple2RomSize, &uNumBytesRead, NULL);
2197 if (uNumBytesRead != Apple2RomSize)
2198 {
2199 memcpy(memrom, &oldRom[0], Apple2RomSize); // ROM at $D000...$FFFF
2200 bRes = FALSE;
2201 }
2202 }
2203
2204 // NB. If succeeded, then keep g_hCustomRom handle open - so that any next restart can load it again
2205
2206 if (!bRes)
2207 {
2208 GetFrame().FrameMessageBox( "Failed to read custom rom", "AppleWin Error", MB_OK );
2209 CloseHandle(g_hCustomRom);
2210 g_hCustomRom = INVALID_HANDLE_VALUE;
2211 // Failed, so use default rom...
2212 }
2213}
2214
2215// Called by:
2216// . MemInitialize()

Callers 2

MemInitializeFunction · 0.85

Calls 1

FrameMessageBoxMethod · 0.80

Tested by

no test coverage detected