all repos — mgba @ 1b6531e32044481feeb0c631ef01bc61d5ccecc6

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	DIRTY_FRAME,
 24	DIRTY_RANGE,
 25	DIRTY_BUFFER,
 26};
 27
 28struct mVideoLoggerDirtyInfo {
 29	enum mVideoLoggerDirtyType type;
 30	uint32_t address;
 31	uint32_t value;
 32	uint32_t value2;
 33};
 34
 35struct VFile;
 36struct mVideoLogger {
 37	bool (*writeData)(struct mVideoLogger* logger, const void* data, size_t length);
 38	bool (*readData)(struct mVideoLogger* logger, void* data, size_t length, bool block);
 39
 40	bool block;
 41	void (*init)(struct mVideoLogger*);
 42	void (*deinit)(struct mVideoLogger*);
 43	void (*reset)(struct mVideoLogger*);
 44
 45	void (*lock)(struct mVideoLogger*);
 46	void (*unlock)(struct mVideoLogger*);
 47	void (*wait)(struct mVideoLogger*);
 48	void (*wake)(struct mVideoLogger*, int y);
 49	void* context;
 50
 51	bool (*parsePacket)(struct mVideoLogger* logger, const struct mVideoLoggerDirtyInfo* packet);
 52	uint16_t* (*vramBlock)(struct mVideoLogger* logger, uint32_t address);
 53
 54	size_t vramSize;
 55	size_t oamSize;
 56	size_t paletteSize;
 57
 58	uint32_t* vramDirtyBitmap;
 59	uint32_t* oamDirtyBitmap;
 60
 61	uint16_t* vram;
 62	uint16_t* oam;
 63	uint16_t* palette;
 64
 65	struct VFile* vf;
 66};
 67
 68struct mVideoLogChannel {
 69	uint32_t type;
 70	void* initialState;
 71	size_t initialStateSize;
 72	struct VFile* channelData;
 73};
 74
 75struct mVideoLogContext {
 76	void* initialState;
 77	size_t initialStateSize;
 78	uint32_t nChannels;
 79	struct mVideoLogChannel channels[mVL_MAX_CHANNELS];
 80};
 81
 82struct mVideoLogHeader {
 83	char magic[4];
 84	uint32_t reserved;
 85	uint32_t platform;
 86	uint32_t padding;
 87	uint32_t initialStatePointer;
 88	uint32_t initialStateSize;
 89	uint32_t nChannels;
 90	uint32_t channelPointers[mVL_MAX_CHANNELS];
 91};
 92
 93struct mVideoLogChannelHeader {
 94	uint32_t type;
 95	uint32_t channelInitialStatePointer;
 96	uint32_t channelInitialStateSize;
 97	uint32_t channelSize;
 98};
 99
100void mVideoLoggerRendererCreate(struct mVideoLogger* logger, bool readonly);
101void mVideoLoggerRendererInit(struct mVideoLogger* logger);
102void mVideoLoggerRendererDeinit(struct mVideoLogger* logger);
103void mVideoLoggerRendererReset(struct mVideoLogger* logger);
104
105void mVideoLoggerRendererWriteVideoRegister(struct mVideoLogger* logger, uint32_t address, uint16_t value);
106void mVideoLoggerRendererWriteVRAM(struct mVideoLogger* logger, uint32_t address);
107void mVideoLoggerRendererWritePalette(struct mVideoLogger* logger, uint32_t address, uint16_t value);
108void mVideoLoggerRendererWriteOAM(struct mVideoLogger* logger, uint32_t address, uint16_t value);
109
110void mVideoLoggerWriteBuffer(struct mVideoLogger* logger, uint32_t bufferId, uint32_t offset, uint32_t length, const void* data);
111
112void mVideoLoggerRendererDrawScanline(struct mVideoLogger* logger, int y);
113void mVideoLoggerRendererDrawRange(struct mVideoLogger* logger, int startX, int endX, int y);
114void mVideoLoggerRendererFlush(struct mVideoLogger* logger);
115void mVideoLoggerRendererFinishFrame(struct mVideoLogger* logger);
116
117bool mVideoLoggerRendererRun(struct mVideoLogger* logger, bool block);
118
119struct mCore;
120struct mVideoLogContext* mVideoLoggerCreate(struct mCore* core);
121void mVideoLoggerDestroy(struct mCore* core, struct mVideoLogContext*);
122void mVideoLoggerWrite(struct mCore* core, struct mVideoLogContext*, struct VFile*);
123
124struct mCore* mVideoLogCoreFind(struct VFile*);
125bool mVideoLogContextLoad(struct VFile*, struct mVideoLogContext*);
126
127CXX_GUARD_END
128
129#endif