Write to renderer VRAM
Jeffrey Pfau jeffrey@endrift.com
Tue, 07 May 2013 03:36:15 -0700
4 files changed,
10 insertions(+),
6 deletions(-)
M
src/gba/gba-bios.c
→
src/gba/gba-bios.c
@@ -226,7 +226,7 @@ case REGION_WORKING_IRAM:
_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");
M
src/gba/gba-memory.c
→
src/gba/gba-memory.c
@@ -133,7 +133,7 @@ case BASE_PALETTE_RAM:
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 @@ case BASE_PALETTE_RAM:
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 @@ gbaMemory->p->video.renderer->writePalette(gbaMemory->p->video.renderer, address & (SIZE_PALETTE_RAM - 1), value);
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 @@ gbaMemory->p->video.renderer->writePalette(gbaMemory->p->video.renderer, address & (SIZE_PALETTE_RAM - 1), value);
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:
M
src/gba/gba-video.c
→
src/gba/gba-video.c
@@ -5,6 +5,7 @@ #include "gba-io.h"
#include <limits.h> #include <string.h> +#include <sys/mman.h> static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer); static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer);@@ -41,10 +42,13 @@
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) {
M
src/gba/gba-video.h
→
src/gba/gba-video.h
@@ -199,7 +199,7 @@ int32_t nextVblankIRQ;
int32_t nextVcounterIRQ; uint16_t palette[SIZE_PALETTE_RAM >> 1]; - uint16_t vram[SIZE_VRAM >> 1]; + uint16_t* vram; union GBAOAM oam; };