mirror of https://github.com/mgba-emu/mgba.git
Write to renderer VRAM
This commit is contained in:
parent
bb1e598a78
commit
f6a9467e86
|
@ -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))]);
|
_unLz77(&gba->memory, gba->cpu.gprs[0], &((uint8_t*) gba->memory.iwram)[(gba->cpu.gprs[1] & (SIZE_WORKING_IRAM - 1))]);
|
||||||
break;
|
break;
|
||||||
case REGION_VRAM:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
GBALog(GBA_LOG_WARN, "Bad LZ77 destination");
|
GBALog(GBA_LOG_WARN, "Bad LZ77 destination");
|
||||||
|
|
|
@ -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];
|
value = ((int32_t*) gbaMemory->p->video.palette)[(address & (SIZE_PALETTE_RAM - 1)) >> 2];
|
||||||
break;
|
break;
|
||||||
case BASE_VRAM:
|
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;
|
break;
|
||||||
case BASE_OAM:
|
case BASE_OAM:
|
||||||
value = ((int32_t*) gbaMemory->p->video.oam.raw)[(address & (SIZE_OAM - 1)) >> 2];
|
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];
|
value = gbaMemory->p->video.palette[(address & (SIZE_PALETTE_RAM - 1)) >> 1];
|
||||||
break;
|
break;
|
||||||
case BASE_VRAM:
|
case BASE_VRAM:
|
||||||
value = gbaMemory->p->video.vram[(address & 0x0001FFFF) >> 1];
|
value = gbaMemory->p->video.renderer->vram[(address & 0x0001FFFF) >> 1];
|
||||||
break;
|
break;
|
||||||
case BASE_OAM:
|
case BASE_OAM:
|
||||||
value = gbaMemory->p->video.oam.raw[(address & (SIZE_OAM - 1)) >> 1];
|
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;
|
break;
|
||||||
case BASE_VRAM:
|
case BASE_VRAM:
|
||||||
if ((address & OFFSET_MASK) < SIZE_VRAM - 2) {
|
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;
|
break;
|
||||||
case BASE_OAM:
|
case BASE_OAM:
|
||||||
|
@ -342,7 +342,7 @@ void GBAStore16(struct ARMMemory* memory, uint32_t address, int16_t value, int*
|
||||||
break;
|
break;
|
||||||
case BASE_VRAM:
|
case BASE_VRAM:
|
||||||
if ((address & OFFSET_MASK) < SIZE_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;
|
break;
|
||||||
case BASE_OAM:
|
case BASE_OAM:
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer);
|
static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer);
|
||||||
static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer);
|
static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer);
|
||||||
|
@ -41,10 +42,13 @@ void GBAVideoInit(struct GBAVideo* video) {
|
||||||
video->nextHblankIRQ = 0;
|
video->nextHblankIRQ = 0;
|
||||||
video->nextVblankIRQ = 0;
|
video->nextVblankIRQ = 0;
|
||||||
video->nextVcounterIRQ = 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) {
|
void GBAVideoDeinit(struct GBAVideo* video) {
|
||||||
GBAVideoAssociateRenderer(video, &dummyRenderer);
|
GBAVideoAssociateRenderer(video, &dummyRenderer);
|
||||||
|
munmap(video->vram, SIZE_VRAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAVideoAssociateRenderer(struct GBAVideo* video, struct GBAVideoRenderer* renderer) {
|
void GBAVideoAssociateRenderer(struct GBAVideo* video, struct GBAVideoRenderer* renderer) {
|
||||||
|
|
|
@ -199,7 +199,7 @@ struct GBAVideo {
|
||||||
int32_t nextVcounterIRQ;
|
int32_t nextVcounterIRQ;
|
||||||
|
|
||||||
uint16_t palette[SIZE_PALETTE_RAM >> 1];
|
uint16_t palette[SIZE_PALETTE_RAM >> 1];
|
||||||
uint16_t vram[SIZE_VRAM >> 1];
|
uint16_t* vram;
|
||||||
union GBAOAM oam;
|
union GBAOAM oam;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue