all repos — mgba @ 2860714714b1dd3307a4a50e8854b8eed18e43a6

mGBA Game Boy Advance Emulator

src/gba/renderers/video-software.c (view raw)

 1#include "video-software.h"
 2
 3#include "gba.h"
 4
 5static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer);
 6static void GBAVideoSoftwareRendererDeinit(struct GBAVideoRenderer* renderer);
 7static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value);
 8static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y);
 9static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* renderer);
10
11void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer) {
12	renderer->d.init = GBAVideoSoftwareRendererInit;
13	renderer->d.deinit = GBAVideoSoftwareRendererDeinit;
14	renderer->d.writeVideoRegister = GBAVideoSoftwareRendererWriteVideoRegister;
15	renderer->d.drawScanline = GBAVideoSoftwareRendererDrawScanline;
16	renderer->d.finishFrame = GBAVideoSoftwareRendererFinishFrame;
17
18	{
19		pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
20		renderer->mutex = mutex;
21		pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
22		renderer->cond = cond;
23	}
24}
25
26static void GBAVideoSoftwareRendererInit(struct GBAVideoRenderer* renderer) {
27	struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
28
29	pthread_mutex_init(&softwareRenderer->mutex, 0);
30	pthread_cond_init(&softwareRenderer->cond, 0);
31}
32
33static void GBAVideoSoftwareRendererDeinit(struct GBAVideoRenderer* renderer) {
34	struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
35}
36
37static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) {
38	struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
39	return value;
40}
41
42static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) {
43	struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
44}
45
46static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* renderer) {
47	struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
48
49	pthread_mutex_lock(&softwareRenderer->mutex);
50	pthread_cond_wait(&softwareRenderer->cond, &softwareRenderer->mutex);
51	pthread_mutex_unlock(&softwareRenderer->mutex);
52}