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

Function MemInitializeCustomF8ROM

source/Memory.cpp:2120–2171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2118}
2119
2120void MemInitializeCustomF8ROM(void)
2121{
2122 const UINT F8RomSize = 0x800;
2123 const UINT F8RomOffset = Apple2RomSize-F8RomSize;
2124 FrameBase& frame = GetFrame();
2125
2126 if (IsApple2Original(GetApple2Type()) && GetCardMgr().QuerySlot(SLOT0) == CT_LanguageCard)
2127 {
2128 BYTE* pData = frame.GetResource(IDR_APPLE2_PLUS_ROM, "ROM", Apple2RomSize);
2129 if (pData == NULL)
2130 {
2131 frame.FrameMessageBox("Failed to read F8 (auto-start) ROM for language card in original Apple][", "AppleWin Error", MB_OK);
2132 }
2133 else
2134 {
2135 memcpy(memrom+F8RomOffset, pData+F8RomOffset, F8RomSize);
2136 }
2137 }
2138
2139 if (g_hCustomRomF8 != INVALID_HANDLE_VALUE)
2140 {
2141 std::vector<BYTE> oldRom(memrom, memrom+Apple2RomSize); // range ctor: [first,last)
2142
2143 SetFilePointer(g_hCustomRomF8, 0, NULL, FILE_BEGIN);
2144 DWORD uNumBytesRead;
2145 BOOL bRes = ReadFile(g_hCustomRomF8, memrom+F8RomOffset, F8RomSize, &uNumBytesRead, NULL);
2146 if (uNumBytesRead != F8RomSize)
2147 {
2148 memcpy(memrom, &oldRom[0], Apple2RomSize); // ROM at $D000...$FFFF
2149 bRes = FALSE;
2150 }
2151
2152 // NB. If succeeded, then keep g_hCustomRomF8 handle open - so that any next restart can load it again
2153
2154 if (!bRes)
2155 {
2156 GetFrame().FrameMessageBox( "Failed to read custom F8 rom", "AppleWin Error", MB_OK );
2157 CloseHandle(g_hCustomRomF8);
2158 g_hCustomRomF8 = INVALID_HANDLE_VALUE;
2159 // Failed, so use default rom...
2160 }
2161 }
2162
2163 if (GetPropertySheet().GetTheFreezesF8Rom() && IS_APPLE2)
2164 {
2165 BYTE* pData = frame.GetResource(IDR_FREEZES_F8_ROM, "ROM", 0x800);
2166 if (pData)
2167 {
2168 memcpy(memrom+Apple2RomSize-F8RomSize, pData, F8RomSize);
2169 }
2170 }
2171}
2172
2173void MemInitializeCustomROM(void)
2174{

Callers 2

MemInitializeFunction · 0.85

Calls 6

IsApple2OriginalFunction · 0.85
GetApple2TypeFunction · 0.85
QuerySlotMethod · 0.80
GetResourceMethod · 0.80
FrameMessageBoxMethod · 0.80
GetTheFreezesF8RomMethod · 0.45

Tested by

no test coverage detected