mirror of https://github.com/mgba-emu/mgba.git
Start implementing DISPCNT
This commit is contained in:
parent
cdddcbf7aa
commit
933e8330d2
|
@ -3,6 +3,7 @@
|
||||||
#include "gba-video.h"
|
#include "gba-video.h"
|
||||||
|
|
||||||
void GBAIOInit(struct GBA* gba) {
|
void GBAIOInit(struct GBA* gba) {
|
||||||
|
gba->memory.io[REG_DISPCNT >> 1] = 0x0080;
|
||||||
gba->memory.io[REG_KEYINPUT >> 1] = 0x3FF;
|
gba->memory.io[REG_KEYINPUT >> 1] = 0x3FF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "video-software.h"
|
#include "video-software.h"
|
||||||
|
|
||||||
#include "gba.h"
|
#include "gba.h"
|
||||||
|
#include "gba-io.h"
|
||||||
|
|
||||||
static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer);
|
static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer);
|
||||||
static void GBAVideoSoftwareRendererDeinit(struct GBAVideoRenderer* renderer);
|
static void GBAVideoSoftwareRendererDeinit(struct GBAVideoRenderer* renderer);
|
||||||
|
@ -8,6 +9,8 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
|
||||||
static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y);
|
static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y);
|
||||||
static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* renderer);
|
static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* renderer);
|
||||||
|
|
||||||
|
static void GBAVideoSoftwareRendererUpdateDISPCNT(struct GBAVideoSoftwareRenderer* renderer);
|
||||||
|
|
||||||
void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer) {
|
void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer) {
|
||||||
renderer->d.init = GBAVideoSoftwareRendererInit;
|
renderer->d.init = GBAVideoSoftwareRendererInit;
|
||||||
renderer->d.deinit = GBAVideoSoftwareRendererDeinit;
|
renderer->d.deinit = GBAVideoSoftwareRendererDeinit;
|
||||||
|
@ -26,6 +29,8 @@ void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer) {
|
||||||
static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer) {
|
static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer) {
|
||||||
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
||||||
|
|
||||||
|
softwareRenderer->dispcnt.packed = 0x0080;
|
||||||
|
|
||||||
pthread_mutex_init(&softwareRenderer->mutex, 0);
|
pthread_mutex_init(&softwareRenderer->mutex, 0);
|
||||||
pthread_cond_init(&softwareRenderer->cond, 0);
|
pthread_cond_init(&softwareRenderer->cond, 0);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +42,11 @@ static void GBAVideoSoftwareRendererDeinit(struct GBAVideoRenderer* renderer) {
|
||||||
static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) {
|
static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) {
|
||||||
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
||||||
switch (address) {
|
switch (address) {
|
||||||
|
case REG_DISPCNT:
|
||||||
|
value &= 0xFFFB;
|
||||||
|
softwareRenderer->dispcnt.packed = value;
|
||||||
|
GBAVideoSoftwareRendererUpdateDISPCNT(softwareRenderer);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
GBALog(GBA_LOG_STUB, "Stub video register write: %03x", address);
|
GBALog(GBA_LOG_STUB, "Stub video register write: %03x", address);
|
||||||
}
|
}
|
||||||
|
@ -47,6 +57,12 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render
|
||||||
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
||||||
int x;
|
int x;
|
||||||
uint16_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y];
|
uint16_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y];
|
||||||
|
if (softwareRenderer->dispcnt.forcedBlank) {
|
||||||
|
for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x) {
|
||||||
|
row[x] = 0x7FFF;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (x = 0; x < 16; ++x) {
|
for (x = 0; x < 16; ++x) {
|
||||||
row[(x * 15) + 0] = renderer->palette[x + (y / 5) * 16];
|
row[(x * 15) + 0] = renderer->palette[x + (y / 5) * 16];
|
||||||
row[(x * 15) + 1] = renderer->palette[x + (y / 5) * 16];
|
row[(x * 15) + 1] = renderer->palette[x + (y / 5) * 16];
|
||||||
|
@ -73,3 +89,7 @@ static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* rendere
|
||||||
pthread_cond_wait(&softwareRenderer->cond, &softwareRenderer->mutex);
|
pthread_cond_wait(&softwareRenderer->cond, &softwareRenderer->mutex);
|
||||||
pthread_mutex_unlock(&softwareRenderer->mutex);
|
pthread_mutex_unlock(&softwareRenderer->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void GBAVideoSoftwareRendererUpdateDISPCNT(struct GBAVideoSoftwareRenderer* renderer) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ struct GBAVideoSoftwareRenderer {
|
||||||
uint16_t* outputBuffer;
|
uint16_t* outputBuffer;
|
||||||
unsigned outputBufferStride;
|
unsigned outputBufferStride;
|
||||||
|
|
||||||
|
union GBARegisterDISPCNT dispcnt;
|
||||||
|
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue