|
1 | 1 | /* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator |
2 | 2 | Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu |
3 | | - Copyright (C)2017-2024 LGB (Gábor Lénárt) <[email protected]> |
| 3 | + Copyright (C)2017-2025 LGB (Gábor Lénárt) <[email protected]> |
4 | 4 |
|
5 | 5 | This program is free software; you can redistribute it and/or modify |
6 | 6 | it under the terms of the GNU General Public License as published by |
@@ -343,7 +343,7 @@ static const struct mem_map_st *mem_map_hints[MEM_HINT_SLOTS]; |
343 | 343 | // * Every areas (other than the first) must start on address which is the previous one's last one PLUS 1 |
344 | 344 | // * The first entry must start at address 0 |
345 | 345 | // * The last entry must be $10000000 - $FFFFFFFF with type MEM_SLOT_TYPE_IMPOSSIBLE as a safe-guard |
346 | | -static struct mem_map_st mem_map[] = { |
| 346 | +static const struct mem_map_st mem_map[] = { |
347 | 347 | { 0x00000000U, 0x0001F7FFU, MEM_SLOT_TYPE_MAIN_RAM }, // OLD memory model used 0-FF as "ZP" to handle CPU I/O port. But now it's VIRTUAL and only exists in CPU's view not in mem-map! |
348 | 348 | { 0x0001F800U, 0x0001FFFFU, MEM_SLOT_TYPE_SHARED_RAM }, // "shared" area, 2K of coulour RAM [C65 legacy], b/c of performance, we must distribute between both of normal and colour RAM |
349 | 349 | { 0x00020000U, 0x0003FFFFU, MEM_SLOT_TYPE_ROM }, // though it's called ROM, it can be normal RAM, if "ROM write protection" is off |
@@ -800,24 +800,28 @@ void cpu65_do_aug_callback ( void ) |
800 | 800 | | MAP | MAP | MAP | MAP | UPPER | UPPER | UPPER | UPPER | Z |
801 | 801 | | BLK7 | BLK6 | BLK5 | BLK4 | OFF19 | OFF18 | OFF17 | OFF16 | |
802 | 802 | +-------+-------+-------+-------+-------+-------+-------+-------+ |
803 | | - -- C65GS extension: Set the MegaByte register for low and high mobies |
804 | | - -- so that we can address all 256MB of RAM. |
805 | | - if reg_x = x"0f" then |
806 | | - reg_mb_low <= reg_a; |
807 | | - end if; |
808 | | - if reg_z = x"0f" then |
809 | | - reg_mb_high <= reg_y; |
810 | | - end if; */ |
| 803 | + */ |
811 | 804 | cpu65.cpu_inhibit_interrupts = 1; // disable interrupts till the next "EOM" (ie: NOP) opcode |
812 | 805 | DEBUG("CPU: MAP opcode, input A=$%02X X=$%02X Y=$%02X Z=$%02X" NL, cpu65.a, cpu65.x, cpu65.y, cpu65.z); |
813 | | - map_offset_low = (cpu65.a << 8) | ((cpu65.x & 15) << 16); // offset of lower half (blocks 0-3) |
814 | | - map_offset_high = (cpu65.y << 8) | ((cpu65.z & 15) << 16); // offset of higher half (blocks 4-7) |
815 | | - map_mask = (cpu65.z & 0xF0) | ( cpu65.x >> 4); // "is mapped" mask for blocks (1 bit for each) |
816 | | - // M65 specific "MB" (megabyte) selector "mode": |
817 | | - if (cpu65.x == 0x0F) |
| 806 | + if (cpu65.x == 0x0F) { |
818 | 807 | map_megabyte_low = (int)cpu65.a << 20; |
819 | | - if (cpu65.z == 0x0F) |
| 808 | + } else { |
| 809 | + map_offset_low = (cpu65.a << 8) | ((cpu65.x & 15) << 16); // offset of lower half (blocks 0-3) |
| 810 | + map_mask = (map_mask & 0xF0) | (cpu65.x >> 4); // "is mapped" mask for the lower half |
| 811 | + } |
| 812 | + if (cpu65.z == 0x0F) { |
820 | 813 | map_megabyte_high = (int)cpu65.y << 20; |
| 814 | + if (in_hypervisor) { |
| 815 | + DEBUG("MEM: warning, altering MB selection for upper 32K memory mapping in hypervisor mode at PC=$%04X" NL, cpu65.pc); |
| 816 | + } |
| 817 | + } else { |
| 818 | + if (!in_hypervisor) { |
| 819 | + map_offset_high = (cpu65.y << 8) | ((cpu65.z & 15) << 16); // offset of higher half (blocks 4-7) |
| 820 | + map_mask = (map_mask & 0x0F) | (cpu65.z & 0xF0); // "is mapped" mask for the upper half |
| 821 | + } else { |
| 822 | + DEBUG("MEM: avoiding to alter upper 32K memory mapping in hypervisor mode at PC=$%04X" NL, cpu65.pc); |
| 823 | + } |
| 824 | + } |
821 | 825 | DEBUG("MEM: applying new memory configuration because of MAP CPU opcode" NL); |
822 | 826 | DEBUG("LOW -OFFSET = $%03X, MB = $%02X" NL, map_offset_low , map_megabyte_low >> 20); |
823 | 827 | DEBUG("HIGH-OFFSET = $%03X, MB = $%02X" NL, map_offset_high, map_megabyte_high >> 20); |
|
0 commit comments