all repos — mgba @ 3f92b1e67f30abfc056df1df141de7c7ccb6df61

mGBA Game Boy Advance Emulator

src/feature/video-logger.h (view raw)

  1/* Copyright (c) 2013-2017 Jeffrey Pfau
  2 *
  3 * This Source Code Form is subject to the terms of the Mozilla Public
  4 * License, v. 2.0. If a copy of the MPL was not distributed with this
  5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6#ifndef VIDEO_LOGGER_H
  7#define VIDEO_LOGGER_H
  8
  9#include <mgba-util/common.h>
 10
 11CXX_GUARD_START
 12
 13#define mVL_MAX_CHANNELS 32
 14
 15enum mVideoLoggerDirtyType {
 16	DIRTY_DUMMY = 0,
 17	DIRTY_FLUSH,
 18	DIRTY_SCANLINE,
 19	DIRTY_REGISTER,
 20	DIRTY_OAM,
 21	DIRTY_PALETTE,
 22	DIRTY_VRAM
 23};
 24
 25struct mVideoLoggerDirtyInfo {
 26	enum mVideoLoggerDirtyType type;
 27	uint32_t address;
 28	uint16_t value;
 29	uint32_t padding;
 30};
 31
 32struct VFile;
 33struct mVideoLogger {
 34	bool (*writeData)(struct mVideoLogger* logger, const void* data, size_t length);
 35	bool (*readData)(struct mVideoLogger* logger, void* data, size_t length, bool block);
 36
 37	bool block;
 38	void (*init)(struct mVideoLogger*);
 39	void (*deinit)(struct mVideoLogger*);
 40	void (*reset)(struct mVideoLogger*);
 41
 42	void (*lock)(struct mVideoLogger*);
 43	void (*unlock)(struct mVideoLogger*);
 44	void (*wait)(struct mVideoLogger*);
 45	void (*wake)(struct mVideoLogger*, int y);
 46	void* context;
 47
 48	bool (*parsePacket)(struct mVideoLogger* logger, const struct mVideoLoggerDirtyInfo* packet);
 49	uint16_t* (*vramBlock)(struct mVideoLogger* logger, uint32_t address);
 50
 51	size_t vramSize;
 52	size_t oamSize;
 53	size_t paletteSize;
 54
 55	uint32_t* vramDirtyBitmap;
 56	uint32_t* oamDirtyBitmap;
 57
 58	uint16_t* vram;
 59	uint16_t* oam;
 60	uint16_t* palette;
 61
 62	struct VFile* vf;
 63};
 64
 65struct mVideoLogChannel {
 66	uint32_t type;
 67	void* initialState;
 68	size_t initialStateSize;
 69	struct VFile* channelData;
 70};
 71
 72struct mVideoLogContext {
 73	void* initialState;
 74	size_t initialStateSize;
 75	uint32_t nChannels;
 76	struct mVideoLogChannel channels[mVL_MAX_CHANNELS];
 77};
 78
 79struct mVideoLogHeader {
 80	char magic[4];
 81	uint32_t reserved;
 82	uint32_t platform;
 83	uint32_t padding;
 84	uint32_t initialStatePointer;
 85	uint32_t initialStateSize;
 86	uint32_t nChannels;
 87	uint32_t channelPointers[mVL_MAX_CHANNELS];
 88};
 89
 90struct mVideoLogChannelHeader {
 91	uint32_t type;
 92	uint32_t channelInitialStatePointer;
 93	uint32_t channelInitialStateSize;
 94	uint32_t channelSize;
 95};
 96
 97void mVideoLoggerRendererCreate(struct mVideoLogger* logger, bool readonly);
 98void mVideoLoggerRendererInit(struct mVideoLogger* logger);
 99void mVideoLoggerRendererDeinit(struct mVideoLogger* logger);
100void mVideoLoggerRendererReset(struct mVideoLogger* logger);
101
102void mVideoLoggerRendererWriteVideoRegister(struct mVideoLogger* logger, uint32_t address, uint16_t value);
103void mVideoLoggerRendererWriteVRAM(struct mVideoLogger* logger, uint32_t address);
104void mVideoLoggerRendererWritePalette(struct mVideoLogger* logger, uint32_t address, uint16_t value);
105void mVideoLoggerRendererWriteOAM(struct mVideoLogger* logger, uint32_t address, uint16_t value);
106
107void mVideoLoggerRendererDrawScanline(struct mVideoLogger* logger, int y);
108void mVideoLoggerRendererFlush(struct mVideoLogger* logger);
109
110bool mVideoLoggerRendererRun(struct mVideoLogger* logger);
111
112struct mCore;
113struct mVideoLogContext* mVideoLoggerCreate(struct mCore* core);
114void mVideoLoggerDestroy(struct mCore* core, struct mVideoLogContext*);
115void mVideoLoggerWrite(struct mCore* core, struct mVideoLogContext*, struct VFile*);
116
117struct mCore* mVideoLogCoreFind(struct VFile*);
118bool mVideoLogContextLoad(struct VFile*, struct mVideoLogContext*);
119
120CXX_GUARD_END
121
122#endif