all repos — mgba @ f6a9467e861ccaaa691ab4c826a65cbeb0add6ad

mGBA Game Boy Advance Emulator

Write to renderer VRAM
Jeffrey Pfau jeffrey@endrift.com
Tue, 07 May 2013 03:36:15 -0700
commit

f6a9467e861ccaaa691ab4c826a65cbeb0add6ad

parent

bb1e598a7862892cb848f34e68a2ea85ce3f0576

4 files changed, 10 insertions(+), 6 deletions(-)

jump to
M src/gba/gba-bios.csrc/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.csrc/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.csrc/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.hsrc/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; };