mirror of https://github.com/mgba-emu/mgba.git
GB Memory: Fix OAM DMA blocking regions (fixes #1013)
This commit is contained in:
parent
35716a0895
commit
fac10eae96
1
CHANGES
1
CHANGES
|
@ -53,6 +53,7 @@ Bugfixes:
|
||||||
- GBA: Fix SharkPort saves for EEPROM games
|
- GBA: Fix SharkPort saves for EEPROM games
|
||||||
- Qt: Fix opening in fullscreen (fixes mgba.io/i/993)
|
- Qt: Fix opening in fullscreen (fixes mgba.io/i/993)
|
||||||
- Python: Fix package directory
|
- Python: Fix package directory
|
||||||
|
- GB Memory: Fix OAM DMA blocking regions (fixes mgba.io/i/1013)
|
||||||
Misc:
|
Misc:
|
||||||
- GBA Timer: Use global cycles for timers
|
- GBA Timer: Use global cycles for timers
|
||||||
- GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
|
- GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
|
||||||
|
|
|
@ -26,7 +26,6 @@ enum {
|
||||||
|
|
||||||
GB_VIDEO_HORIZONTAL_LENGTH = 456,
|
GB_VIDEO_HORIZONTAL_LENGTH = 456,
|
||||||
|
|
||||||
GB_VIDEO_MODE_1_LENGTH = 65664,
|
|
||||||
GB_VIDEO_TOTAL_LENGTH = 70224,
|
GB_VIDEO_TOTAL_LENGTH = 70224,
|
||||||
|
|
||||||
GB_BASE_MAP = 0x1800,
|
GB_BASE_MAP = 0x1800,
|
||||||
|
|
|
@ -16,31 +16,33 @@
|
||||||
|
|
||||||
mLOG_DEFINE_CATEGORY(GB_MEM, "GB Memory", "gb.memory");
|
mLOG_DEFINE_CATEGORY(GB_MEM, "GB Memory", "gb.memory");
|
||||||
|
|
||||||
struct OAMBlock {
|
enum GBBus {
|
||||||
uint16_t low;
|
GB_BUS_CPU,
|
||||||
uint16_t high;
|
GB_BUS_MAIN,
|
||||||
|
GB_BUS_VRAM,
|
||||||
|
GB_BUS_RAM
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct OAMBlock _oamBlockDMG[] = {
|
static const enum GBBus _oamBlockDMG[] = {
|
||||||
{ 0xA000, 0xFE00 },
|
GB_BUS_MAIN, // 0x0000
|
||||||
{ 0xA000, 0xFE00 },
|
GB_BUS_MAIN, // 0x2000
|
||||||
{ 0xA000, 0xFE00 },
|
GB_BUS_MAIN, // 0x4000
|
||||||
{ 0xA000, 0xFE00 },
|
GB_BUS_MAIN, // 0x6000
|
||||||
{ 0x8000, 0xA000 },
|
GB_BUS_VRAM, // 0x8000
|
||||||
{ 0xA000, 0xFE00 },
|
GB_BUS_MAIN, // 0xA000
|
||||||
{ 0xA000, 0xFE00 },
|
GB_BUS_MAIN, // 0xC000
|
||||||
{ 0xA000, 0xFE00 },
|
GB_BUS_CPU, // 0xE000
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct OAMBlock _oamBlockCGB[] = {
|
static const enum GBBus _oamBlockCGB[] = {
|
||||||
{ 0xA000, 0xC000 },
|
GB_BUS_MAIN, // 0x0000
|
||||||
{ 0xA000, 0xC000 },
|
GB_BUS_MAIN, // 0x2000
|
||||||
{ 0xA000, 0xC000 },
|
GB_BUS_MAIN, // 0x4000
|
||||||
{ 0xA000, 0xC000 },
|
GB_BUS_MAIN, // 0x6000
|
||||||
{ 0x8000, 0xA000 },
|
GB_BUS_VRAM, // 0x8000
|
||||||
{ 0xA000, 0xC000 },
|
GB_BUS_MAIN, // 0xA000
|
||||||
{ 0xC000, 0xFE00 },
|
GB_BUS_RAM, // 0xC000
|
||||||
{ 0xA000, 0xC000 },
|
GB_BUS_CPU // 0xE000
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _pristineCow(struct GB* gba);
|
static void _pristineCow(struct GB* gba);
|
||||||
|
@ -192,9 +194,10 @@ uint8_t GBLoad8(struct LR35902Core* cpu, uint16_t address) {
|
||||||
struct GB* gb = (struct GB*) cpu->master;
|
struct GB* gb = (struct GB*) cpu->master;
|
||||||
struct GBMemory* memory = &gb->memory;
|
struct GBMemory* memory = &gb->memory;
|
||||||
if (gb->memory.dmaRemaining) {
|
if (gb->memory.dmaRemaining) {
|
||||||
const struct OAMBlock* block = gb->model < GB_MODEL_CGB ? _oamBlockDMG : _oamBlockCGB;
|
const enum GBBus* block = gb->model < GB_MODEL_CGB ? _oamBlockDMG : _oamBlockCGB;
|
||||||
block = &block[memory->dmaSource >> 13];
|
enum GBBus dmaBus = block[memory->dmaSource >> 13];
|
||||||
if (address >= block->low && address < block->high) {
|
enum GBBus accessBus = block[address >> 13];
|
||||||
|
if (dmaBus != GB_BUS_CPU && dmaBus == accessBus) {
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
if (address >= GB_BASE_OAM && address < GB_BASE_UNUSABLE) {
|
if (address >= GB_BASE_OAM && address < GB_BASE_UNUSABLE) {
|
||||||
|
@ -264,9 +267,10 @@ void GBStore8(struct LR35902Core* cpu, uint16_t address, int8_t value) {
|
||||||
struct GB* gb = (struct GB*) cpu->master;
|
struct GB* gb = (struct GB*) cpu->master;
|
||||||
struct GBMemory* memory = &gb->memory;
|
struct GBMemory* memory = &gb->memory;
|
||||||
if (gb->memory.dmaRemaining) {
|
if (gb->memory.dmaRemaining) {
|
||||||
const struct OAMBlock* block = gb->model < GB_MODEL_CGB ? _oamBlockDMG : _oamBlockCGB;
|
const enum GBBus* block = gb->model < GB_MODEL_CGB ? _oamBlockDMG : _oamBlockCGB;
|
||||||
block = &block[memory->dmaSource >> 13];
|
enum GBBus dmaBus = block[memory->dmaSource >> 13];
|
||||||
if (address >= block->low && address < block->high) {
|
enum GBBus accessBus = block[address >> 13];
|
||||||
|
if (dmaBus != GB_BUS_CPU && dmaBus == accessBus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (address >= GB_BASE_OAM && address < GB_BASE_UNUSABLE) {
|
if (address >= GB_BASE_OAM && address < GB_BASE_UNUSABLE) {
|
||||||
|
|
Loading…
Reference in New Issue