Called by: . MemInitialize() eg. on AppleWin start & restart (eg. h/w config changes) . ResetMachineState() eg. Power-cycle ('Apple-Go' button) . Snapshot_LoadState_v2()
| 2292 | // . ResetMachineState() eg. Power-cycle ('Apple-Go' button) |
| 2293 | // . Snapshot_LoadState_v2() |
| 2294 | void MemReset() |
| 2295 | { |
| 2296 | // INITIALIZE THE PAGING TABLES |
| 2297 | memset(memshadow, 0, 256*sizeof(LPBYTE)); |
| 2298 | memset(memwrite , 0, 256*sizeof(LPBYTE)); |
| 2299 | |
| 2300 | // INITIALIZE THE RAM IMAGES |
| 2301 | memset(memaux , 0, 0x10000); |
| 2302 | memset(memmain, 0, 0x10000); |
| 2303 | |
| 2304 | // Init the I/O ROM vars |
| 2305 | IO_SELECT = 0; |
| 2306 | INTC8ROM = false; |
| 2307 | g_eExpansionRomType = eExpRomNull; |
| 2308 | g_uPeripheralRomSlot = 0; |
| 2309 | |
| 2310 | memset(memdirty, 0, 0x100); |
| 2311 | |
| 2312 | memVidHD = NULL; |
| 2313 | |
| 2314 | g_uActiveBank = 0; // Power-cycle sets RamWorks III to 64KiB bank-0 (GH#1414) |
| 2315 | |
| 2316 | // |
| 2317 | |
| 2318 | int iByte; |
| 2319 | |
| 2320 | // Memory is pseudo-initialized across various models of Apple ][ //e //c |
| 2321 | // We chose a random one for nostalgia's sake |
| 2322 | // To inspect: |
| 2323 | // F2. Ctrl-F2. CALL-151, C050 C053 C057 |
| 2324 | // OR |
| 2325 | // F2, Ctrl-F2, F7, HGR |
| 2326 | uint32_t randTime = getRandomTime(); |
| 2327 | MemoryInitPattern_e eMemoryInitPattern = static_cast<MemoryInitPattern_e>(g_nMemoryClearType); |
| 2328 | |
| 2329 | if (g_nMemoryClearType < 0) // random |
| 2330 | { |
| 2331 | eMemoryInitPattern = static_cast<MemoryInitPattern_e>( randTime % NUM_MIP ); |
| 2332 | |
| 2333 | // Don't use unless manually specified as a |
| 2334 | // few badly written programs will not work correctly |
| 2335 | // due to buffer overflows or not initializig memory before using. |
| 2336 | if( eMemoryInitPattern == MIP_PAGE_ADDRESS_LOW ) |
| 2337 | eMemoryInitPattern = MIP_FF_FF_00_00; |
| 2338 | } |
| 2339 | |
| 2340 | switch( eMemoryInitPattern ) |
| 2341 | { |
| 2342 | case MIP_FF_FF_00_00: |
| 2343 | for( iByte = 0x0000; iByte < 0xC000; iByte += 4 ) // NB. ODD 16-bit words are zero'd above... |
| 2344 | { |
| 2345 | memmain[ iByte+0 ] = 0xFF; |
| 2346 | memmain[ iByte+1 ] = 0xFF; |
| 2347 | } |
| 2348 | |
| 2349 | // Exceptions: xx28 xx29 xx68 xx69 Apple //e |
| 2350 | for( iByte = 0x0000; iByte < 0xC000; iByte += 512 ) |
| 2351 | { |
no test coverage detected