diff --git a/src/gba/gba-bios.c b/src/gba/gba-bios.c index 019783980..84f89ab76 100644 --- a/src/gba/gba-bios.c +++ b/src/gba/gba-bios.c @@ -226,7 +226,7 @@ void GBASwi16(struct ARMBoard* board, int immediate) { _unLz77(&gba->memory, gba->cpu.gprs[0], &((uint8_t*) gba->memory.iwram)[(gba->cpu.gprs[1] & (SIZE_WORKING_IRAM - 1))]); break; case REGION_VRAM: - _unLz77(&gba->memory, gba->cpu.gprs[0], &((uint8_t*) gba->video.vram)[(gba->cpu.gprs[1] & 0x0001FFFF)]); + _unLz77(&gba->memory, gba->cpu.gprs[0], &((uint8_t*) gba->video.renderer->vram)[(gba->cpu.gprs[1] & 0x0001FFFF)]); break; default: GBALog(GBA_LOG_WARN, "Bad LZ77 destination"); diff --git a/src/gba/gba-memory.c b/src/gba/gba-memory.c index e1ff4e6e1..3213437e8 100644 --- a/src/gba/gba-memory.c +++ b/src/gba/gba-memory.c @@ -133,7 +133,7 @@ int32_t GBALoad32(struct ARMMemory* memory, uint32_t address, int* cycleCounter) value = ((int32_t*) gbaMemory->p->video.palette)[(address & (SIZE_PALETTE_RAM - 1)) >> 2]; break; case BASE_VRAM: - value = ((int32_t*) gbaMemory->p->video.vram)[(address & 0x0001FFFF) >> 2]; + value = ((int32_t*) gbaMemory->p->video.renderer->vram)[(address & 0x0001FFFF) >> 2]; break; case BASE_OAM: value = ((int32_t*) gbaMemory->p->video.oam.raw)[(address & (SIZE_OAM - 1)) >> 2]; @@ -190,7 +190,7 @@ int16_t GBALoad16(struct ARMMemory* memory, uint32_t address, int* cycleCounter) value = gbaMemory->p->video.palette[(address & (SIZE_PALETTE_RAM - 1)) >> 1]; break; case BASE_VRAM: - value = gbaMemory->p->video.vram[(address & 0x0001FFFF) >> 1]; + value = gbaMemory->p->video.renderer->vram[(address & 0x0001FFFF) >> 1]; break; case BASE_OAM: value = gbaMemory->p->video.oam.raw[(address & (SIZE_OAM - 1)) >> 1]; @@ -302,7 +302,7 @@ void GBAStore32(struct ARMMemory* memory, uint32_t address, int32_t value, int* break; case BASE_VRAM: if ((address & OFFSET_MASK) < SIZE_VRAM - 2) { - ((int32_t*) gbaMemory->p->video.vram)[(address & 0x0001FFFF) >> 2] = value; + ((int32_t*) gbaMemory->p->video.renderer->vram)[(address & 0x0001FFFF) >> 2] = value; } break; case BASE_OAM: @@ -342,7 +342,7 @@ void GBAStore16(struct ARMMemory* memory, uint32_t address, int16_t value, int* break; case BASE_VRAM: if ((address & OFFSET_MASK) < SIZE_VRAM) { - gbaMemory->p->video.vram[(address & 0x0001FFFF) >> 1] = value; + gbaMemory->p->video.renderer->vram[(address & 0x0001FFFF) >> 1] = value; } break; case BASE_OAM: diff --git a/src/gba/gba-video.c b/src/gba/gba-video.c index bb3c0f748..97a1310f7 100644 --- a/src/gba/gba-video.c +++ b/src/gba/gba-video.c @@ -5,6 +5,7 @@ #include #include +#include static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer); static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer); @@ -41,10 +42,13 @@ void GBAVideoInit(struct GBAVideo* video) { video->nextHblankIRQ = 0; video->nextVblankIRQ = 0; video->nextVcounterIRQ = 0; + + video->vram = mmap(0, SIZE_VRAM, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); } void GBAVideoDeinit(struct GBAVideo* video) { GBAVideoAssociateRenderer(video, &dummyRenderer); + munmap(video->vram, SIZE_VRAM); } void GBAVideoAssociateRenderer(struct GBAVideo* video, struct GBAVideoRenderer* renderer) { diff --git a/src/gba/gba-video.h b/src/gba/gba-video.h index 8706023f5..081793c34 100644 --- a/src/gba/gba-video.h +++ b/src/gba/gba-video.h @@ -199,7 +199,7 @@ struct GBAVideo { int32_t nextVcounterIRQ; uint16_t palette[SIZE_PALETTE_RAM >> 1]; - uint16_t vram[SIZE_VRAM >> 1]; + uint16_t* vram; union GBAOAM oam; };