all repos — mgba @ ac7ae74822d2740f82b62a644e88fbed789ad2be

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};
 36
 37struct mVideoLoggerDirtyInfo {
 38	enum mVideoLoggerDirtyType type;
 39	uint32_t address;
 40	uint32_t value;
 41	uint32_t value2;
 42};
 43
 44struct VFile;
 45struct mVideoLogger {
 46	bool (*writeData)(struct mVideoLogger* logger, const void* data, size_t length);
 47	bool (*readData)(struct mVideoLogger* logger, void* data, size_t length, bool block);
 48	void (*postEvent)(struct mVideoLogger* logger, enum mVideoLoggerEvent event);
 49	void* dataContext;
 50
 51	bool block;
 52	void (*init)(struct mVideoLogger*);
 53	void (*deinit)(struct mVideoLogger*);
 54	void (*reset)(struct mVideoLogger*);
 55
 56	void (*lock)(struct mVideoLogger*);
 57	void (*unlock)(struct mVideoLogger*);
 58	void (*wait)(struct mVideoLogger*);
 59	void (*wake)(struct mVideoLogger*, int y);
 60	void* context;
 61
 62	bool (*parsePacket)(struct mVideoLogger* logger, const struct mVideoLoggerDirtyInfo* packet);
 63	void (*handleEvent)(struct mVideoLogger* logger, enum mVideoLoggerEvent event);
 64	uint16_t* (*vramBlock)(struct mVideoLogger* logger, uint32_t address);
 65
 66	size_t vramSize;
 67	size_t oamSize;
 68	size_t paletteSize;
 69
 70	uint32_t* vramDirtyBitmap;
 71	uint32_t* oamDirtyBitmap;
 72
 73	uint16_t* vram;
 74	uint16_t* oam;
 75	uint16_t* palette;
 76};
 77
 78void mVideoLoggerRendererCreate(struct mVideoLogger* logger, bool readonly);
 79void mVideoLoggerRendererInit(struct mVideoLogger* logger);
 80void mVideoLoggerRendererDeinit(struct mVideoLogger* logger);
 81void mVideoLoggerRendererReset(struct mVideoLogger* logger);
 82
 83void mVideoLoggerRendererWriteVideoRegister(struct mVideoLogger* logger, uint32_t address, uint16_t value);
 84void mVideoLoggerRendererWriteVRAM(struct mVideoLogger* logger, uint32_t address);
 85void mVideoLoggerRendererWritePalette(struct mVideoLogger* logger, uint32_t address, uint16_t value);
 86void mVideoLoggerRendererWriteOAM(struct mVideoLogger* logger, uint32_t address, uint16_t value);
 87
 88void mVideoLoggerWriteBuffer(struct mVideoLogger* logger, uint32_t bufferId, uint32_t offset, uint32_t length, const void* data);
 89
 90void mVideoLoggerRendererDrawScanline(struct mVideoLogger* logger, int y);
 91void mVideoLoggerRendererDrawRange(struct mVideoLogger* logger, int startX, int endX, int y);
 92void mVideoLoggerRendererFlush(struct mVideoLogger* logger);
 93void mVideoLoggerRendererFinishFrame(struct mVideoLogger* logger);
 94
 95bool mVideoLoggerRendererRun(struct mVideoLogger* logger, bool block);
 96
 97struct mVideoLogContext;
 98void mVideoLoggerAttachChannel(struct mVideoLogger* logger, struct mVideoLogContext* context, size_t channelId);
 99
100struct mCore;
101struct mVideoLogContext* mVideoLogContextCreate(struct mCore* core);
102
103void mVideoLogContextSetOutput(struct mVideoLogContext*, struct VFile*);
104void mVideoLogContextWriteHeader(struct mVideoLogContext*, struct mCore* core);
105
106bool mVideoLogContextLoad(struct mVideoLogContext*, struct VFile*);
107void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext*);
108
109void mVideoLogContextRewind(struct mVideoLogContext*, struct mCore*);
110void* mVideoLogContextInitialState(struct mVideoLogContext*, size_t* size);
111
112int mVideoLoggerAddChannel(struct mVideoLogContext*);
113
114struct mCore* mVideoLogCoreFind(struct VFile*);
115
116CXX_GUARD_END
117
118#endif