all repos — mgba @ 8a26a7977c0dea8315ea9b1a6df9df7da27b1fe5

mGBA Game Boy Advance Emulator

include/mgba/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#include <mgba-util/circle-buffer.h>
 14
 15#define mVL_MAX_CHANNELS 32
 16
 17enum mVideoLoggerDirtyType {
 18	DIRTY_DUMMY = 0,
 19	DIRTY_FLUSH,
 20	DIRTY_SCANLINE,
 21	DIRTY_REGISTER,
 22	DIRTY_OAM,
 23	DIRTY_PALETTE,
 24	DIRTY_VRAM,
 25	DIRTY_FRAME,
 26	DIRTY_RANGE,
 27	DIRTY_BUFFER,
 28};
 29
 30enum mVideoLoggerEvent {
 31	LOGGER_EVENT_NONE = 0,
 32	LOGGER_EVENT_INIT,
 33	LOGGER_EVENT_DEINIT,
 34	LOGGER_EVENT_RESET,
 35	LOGGER_EVENT_GET_PIXELS,
 36};
 37
 38struct mVideoLoggerDirtyInfo {
 39	enum mVideoLoggerDirtyType type;
 40	uint32_t address;
 41	uint32_t value;
 42	uint32_t value2;
 43};
 44
 45struct VFile;
 46struct mVideoLogger {
 47	bool (*writeData)(struct mVideoLogger* logger, const void* data, size_t length);
 48	bool (*readData)(struct mVideoLogger* logger, void* data, size_t length, bool block);
 49	void (*postEvent)(struct mVideoLogger* logger, enum mVideoLoggerEvent event);
 50	void* dataContext;
 51
 52	bool block;
 53	void (*init)(struct mVideoLogger*);
 54	void (*deinit)(struct mVideoLogger*);
 55	void (*reset)(struct mVideoLogger*);
 56
 57	void (*lock)(struct mVideoLogger*);
 58	void (*unlock)(struct mVideoLogger*);
 59	void (*wait)(struct mVideoLogger*);
 60	void (*wake)(struct mVideoLogger*, int y);
 61	void* context;
 62
 63	bool (*parsePacket)(struct mVideoLogger* logger, const struct mVideoLoggerDirtyInfo* packet);
 64	void (*handleEvent)(struct mVideoLogger* logger, enum mVideoLoggerEvent event);
 65	uint16_t* (*vramBlock)(struct mVideoLogger* logger, uint32_t address);
 66
 67	size_t vramSize;
 68	size_t oamSize;
 69	size_t paletteSize;
 70
 71	uint32_t* vramDirtyBitmap;
 72	uint32_t* oamDirtyBitmap;
 73
 74	uint16_t* vram;
 75	uint16_t* oam;
 76	uint16_t* palette;
 77
 78	const void* pixelBuffer;
 79	size_t pixelStride;
 80};
 81
 82void mVideoLoggerRendererCreate(struct mVideoLogger* logger, bool readonly);
 83void mVideoLoggerRendererInit(struct mVideoLogger* logger);
 84void mVideoLoggerRendererDeinit(struct mVideoLogger* logger);
 85void mVideoLoggerRendererReset(struct mVideoLogger* logger);
 86
 87void mVideoLoggerRendererWriteVideoRegister(struct mVideoLogger* logger, uint32_t address, uint16_t value);
 88void mVideoLoggerRendererWriteVRAM(struct mVideoLogger* logger, uint32_t address);
 89void mVideoLoggerRendererWritePalette(struct mVideoLogger* logger, uint32_t address, uint16_t value);
 90void mVideoLoggerRendererWriteOAM(struct mVideoLogger* logger, uint32_t address, uint16_t value);
 91
 92void mVideoLoggerWriteBuffer(struct mVideoLogger* logger, uint32_t bufferId, uint32_t offset, uint32_t length, const void* data);
 93
 94void mVideoLoggerRendererDrawScanline(struct mVideoLogger* logger, int y);
 95void mVideoLoggerRendererDrawRange(struct mVideoLogger* logger, int startX, int endX, int y);
 96void mVideoLoggerRendererFlush(struct mVideoLogger* logger);
 97void mVideoLoggerRendererFinishFrame(struct mVideoLogger* logger);
 98
 99bool mVideoLoggerRendererRun(struct mVideoLogger* logger, bool block);
100
101struct mVideoLogContext;
102void mVideoLoggerAttachChannel(struct mVideoLogger* logger, struct mVideoLogContext* context, size_t channelId);
103
104struct mCore;
105struct mVideoLogContext* mVideoLogContextCreate(struct mCore* core);
106
107void mVideoLogContextSetOutput(struct mVideoLogContext*, struct VFile*);
108void mVideoLogContextWriteHeader(struct mVideoLogContext*, struct mCore* core);
109
110bool mVideoLogContextLoad(struct mVideoLogContext*, struct VFile*);
111void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext*);
112
113void mVideoLogContextRewind(struct mVideoLogContext*, struct mCore*);
114void* mVideoLogContextInitialState(struct mVideoLogContext*, size_t* size);
115
116int mVideoLoggerAddChannel(struct mVideoLogContext*);
117
118struct mCore* mVideoLogCoreFind(struct VFile*);
119
120CXX_GUARD_END
121
122#endif