MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / MemOptimizeForModeChanging

Function MemOptimizeForModeChanging

source/Memory.cpp:2667–2696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2665}
2666
2667bool MemOptimizeForModeChanging(WORD programcounter, WORD address)
2668{
2669 if (IsAppleIIeOrAbove(GetApple2Type()))
2670 {
2671 // IF THE EMULATED PROGRAM HAS JUST UPDATED THE MEMORY WRITE MODE AND IS
2672 // ABOUT TO UPDATE THE MEMORY READ MODE, HOLD OFF ON ANY PROCESSING UNTIL
2673 // IT DOES SO.
2674 //
2675 // NB. A 6502 interrupt occurring between these memory write & read updates could lead to incorrect behaviour.
2676 // - although any data-race is probably a bug in the 6502 code too.
2677 if ((address >= 4) && (address <= 5) && // Now: RAMWRTOFF or RAMWRTON
2678 ((ReadUINT24FromMemory(programcounter) & 0x00FFFEFF) == 0x00C0028D)) // Next: STA $C002(RAMRDOFF) or STA $C003(RAMRDON)
2679 {
2680 modechanging = 1;
2681 return true;
2682 }
2683
2684 // TODO: support Saturn in any slot.
2685 // NB. GH#602 asks for any examples of this happening:
2686 if ((address >= 0x80) && (address <= 0x8F) && (programcounter < 0xC000) && // Now: LC
2687 (((ReadUINT24FromMemory(programcounter) & 0x00FFFEFF) == 0x00C0048D) || // Next: STA $C004(RAMWRTOFF) or STA $C005(RAMWRTON)
2688 ((ReadUINT24FromMemory(programcounter) & 0x00FFFEFF) == 0x00C0028D))) // or STA $C002(RAMRDOFF) or STA $C003(RAMRDON)
2689 {
2690 modechanging = 1;
2691 return true;
2692 }
2693 }
2694
2695 return false;
2696}
2697
2698//===========================================================================
2699

Callers 2

MemSetPagingFunction · 0.85
IOMethod · 0.85

Calls 3

IsAppleIIeOrAboveFunction · 0.85
GetApple2TypeFunction · 0.85
ReadUINT24FromMemoryFunction · 0.85

Tested by

no test coverage detected