AxibugEmuOnline/References/virtuanessrc097-master/NES/State.h

316 lines
14 KiB
C
Raw Normal View History

<EFBFBD><EFBFBD>#ifndef __STATE_INCLUDED__
#define __STATE_INCLUDED__
#pragma pack( push, 1 )
typedef struct tagFILEHDR { // 0123456789AB
BYTE ID[12]; // "VirtuaNES ST"
WORD Reserved;
WORD BlockVersion;
} FILEHDR, *LPFILEHDR;
// VirtuaNES version0.30<EFBFBD>NM<EFBFBD>(u
typedef struct tagFILEHDR2 { // 0123456789AB
BYTE ID[12]; // "VirtuaNES ST"
WORD Reserved;
WORD BlockVersion; // 0x0200 / 0x0210(v0.60<EFBFBD>NM<EFBFBD>)
DWORD Ext0; // ROM:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0CRC FDS:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0ID
WORD Ext1; // ROM:j0W0 FDS:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0ID
WORD Ext2; // ROM:j0W0 FDS:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>gpe
LONG MovieStep; // <EFBFBD><EFBFBD><EFBFBD>(<EFBFBD>S<EFBFBD>0<EFBFBD>vW0)<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0Bfn0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0pe
LONG MovieOffset; // <EFBFBD><EFBFBD><EFBFBD>(<EFBFBD>S<EFBFBD>0<EFBFBD>vW0)<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0Bfn0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
} FILEHDR2, *LPFILEHDR2;
typedef struct tagBLOCKHDR {
BYTE ID[8];
WORD Reserved;
WORD BlockVersion;
DWORD BlockSize;
} BLOCKHDR, *LPBLOCKHDR;
// CPU <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
// version 0x0110~0g0
typedef struct tagCPUSTAT_O {
WORD PC;
BYTE A;
BYTE X;
BYTE Y;
BYTE S;
BYTE P;
BYTE I; // Interrupt pending flag
BYTE FrameIRQ;
BYTE reserved[3];
LONG mod_cycles; // <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0I{g0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0pen0<EFBFBD>_<EFBFBD>Yj0Z0<EFBFBD>0<EFBFBD>02<EFBFBD>P0<EFBFBD>p
// version 0x0110
SQWORD emul_cycles;
SQWORD base_cycles;
} CPUSTAT_O, *LPCPUSTAT_O;
// version 0x0210
typedef struct tagCPUSTAT {
WORD PC;
BYTE A;
BYTE X;
BYTE Y;
BYTE S;
BYTE P;
BYTE I; // Interrupt pending flag
BYTE FrameIRQ;
BYTE FrameIRQ_occur;
BYTE FrameIRQ_count;
BYTE FrameIRQ_type;
LONG FrameIRQ_cycles;
LONG DMA_cycles;
SQWORD emul_cycles;
SQWORD base_cycles;
} CPUSTAT, *LPCPUSTAT;
// PPU <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
typedef struct tagPPUSTAT {
BYTE reg0;
BYTE reg1;
BYTE reg2;
BYTE reg3;
BYTE reg7;
BYTE toggle56;
WORD loopy_t;
WORD loopy_v;
WORD loopy_x;
} PPUSTAT, *LPPPUSTAT;
// APU <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0(<EFBFBD>b5_<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0+T<EFBFBD>0)
typedef struct tagAPUSTAT_O {
BYTE reg[0x0018];
BYTE ext[0x0100];
} APUSTAT_O, *LPAPUSTAT_O;
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
typedef struct tagCTRREG {
DWORD pad1bit;
DWORD pad2bit;
DWORD pad3bit;
DWORD pad4bit;
BYTE strobe;
} CTRREG, *LPCTRREG;
//
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
// ID "REG DATA"
// ver 0x0110~0g0
typedef struct tagREGSTAT_O {
union uniCPUREG {
BYTE cpudata[32];
CPUSTAT_O cpu;
} cpureg;
union uniPPUREG {
BYTE ppudata[32];
PPUSTAT ppu;
} ppureg;
APUSTAT_O apu;
} REGSTAT_O, *LPREGSTAT_O;
// ver 0x0200<EFBFBD>NM<EFBFBD>
typedef struct tagREGSTAT {
union uniCPUREG {
BYTE cpudata[64];
CPUSTAT cpu;
} cpureg;
union uniPPUREG {
BYTE ppudata[32];
PPUSTAT ppu;
} ppureg;
} REGSTAT, *LPREGSTAT;
//
// <EFBFBD>QӁRAM<EFBFBD>0<EFBFBD>0<EFBFBD>0
// ID "RAM DATA"
typedef struct tagRAMSTAT {
BYTE RAM[2*1024]; // Internal NES RAM
BYTE BGPAL[16]; // BG Palette
BYTE SPPAL[16]; // SP Palette
BYTE SPRAM[256]; // Sprite RAM
} RAMSTAT, *LPRAMSTAT;
//
// MMU<EFBFBD>0<EFBFBD>0<EFBFBD>0
// ID "MMU DATA"
typedef struct tagMMUSTAT {
BYTE CPU_MEM_TYPE[8];
WORD CPU_MEM_PAGE[8];
BYTE PPU_MEM_TYPE[12];
WORD PPU_MEM_PAGE[12];
BYTE CRAM_USED[8];
} MMUSTAT, *LPMMUSTAT;
//
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
// ID "MMC DATA"
typedef struct tagMMCSTAT {
BYTE mmcdata[256];
} MMCSTAT, *LPMMCSTAT;
//
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
// ID "CTR DATA"
typedef struct tagCTRSTAT {
union uniCTRDATA {
BYTE ctrdata[32];
CTRREG ctr;
} ctrreg;
} CTRSTAT, *LPCTRSTAT;
//
// SND<EFBFBD>0<EFBFBD>0<EFBFBD>0
// ID "SND DATA"
typedef struct tagSNDSTAT {
BYTE snddata[0x800]; // 2KB
} SNDSTAT, *LPSNDSTAT;
//
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
// Ver0.24~0g0
// ID "DSIDE 0A","DSIDE 0B","DSIDE 1A","DSIDE 1B"
typedef struct tagDISKSTAT {
BYTE DiskTouch[16];
} DISKSTAT, *LPDISKSTAT;
// Ver0.30<EFBFBD>NM<EFBFBD>
// ID "DISKDATA"
typedef struct tagDISKDATA {
LONG DifferentSize;
} DISKDATA, *LPDISKDATA;
// <EFBFBD>N No0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0g0O(uY0<EFBFBD>0
// Ver0.24~0g0
typedef struct tagDISKIMGFILEHDR { // 0123456789AB
BYTE ID[12]; // "VirtuaNES DI"
WORD BlockVersion;
WORD DiskNumber;
} DISKIMGFILEHDR, *LPDISKIMGFILEHDR;
typedef struct tagDISKIMGHDR {
BYTE ID[6]; // ID "SIDE0A","SIDE0B","SIDE1A","SIDE1B"
BYTE DiskTouch[16];
} DISKIMGHDR, *LPDISKIMGHDR;
// VirtuaNES version0.30<EFBFBD>NM<EFBFBD>(u
typedef struct tagDISKFILEHDR { // 0123456789AB
BYTE ID[12]; // "VirtuaNES DI"
WORD BlockVersion; // 0x0200:0.30 0x0210:0.31
WORD Reserved;
DWORD ProgID; // <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0ID
WORD MakerID; // <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0ID
WORD DiskNo; // <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0pe
DWORD DifferentSize; // <EFBFBD>vU<EFBFBD>pe
} DISKFILEHDR, *LPDISKFILEHDR;
// ID "EXCTRDAT"
typedef struct tagEXCTRSTAT {
DWORD data;
} EXCTRSTAT, *LPEXCTRSTAT;
//
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
//
// VirtuaNES version0.60<EFBFBD>NM<EFBFBD>(u
typedef struct tagMOVIEFILEHDR {
BYTE ID[12]; // "VirtuaNES MV"
WORD BlockVersion; // Movie version 0x0300
WORD RecordVersion; // Record version
DWORD Control; // <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
// 76543210(Bit)
// E---4321
// | |||+-- 1P<EFBFBD>0<EFBFBD>0<EFBFBD>0
// | ||+--- 2P<EFBFBD>0<EFBFBD>0<EFBFBD>0
// | |+---- 3P<EFBFBD>0<EFBFBD>0<EFBFBD>0
// | +----- 4P<EFBFBD>0<EFBFBD>0<EFBFBD>0
// +--------- <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ybk
// ]0n0<EFBFBD>N<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0o01P04P(i0<EFBFBD>0g0<EFBFBD>0o<EFBFBD>D0)n0<EFBFBD>eT<EFBFBD>0<EFBFBD>0L0
// hQf0ONn0Bf <EFBFBD>!kn0<EFBFBD><EFBFBD>0<EFBFBD>0<EFBFBD>0L0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0(u<EFBFBD>0<EFBFBD>0<EFBFBD>0k0j0<EFBFBD>0
DWORD Ext0; // ROM:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0CRC FDS:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0ID
WORD Ext1; // ROM:j0W0 FDS:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0ID
WORD Ext2; // ROM:j0W0 FDS:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>gpe
DWORD RecordTimes; // <EFBFBD>2<EFBFBD><EFBFBD>Vpe(<EFBFBD>S<EFBFBD>0<EFBFBD>vW0<EFBFBD>Vpe)
BYTE RenderMethod; // <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>e_
BYTE IRQtype; // IRQ<EFBFBD>0<EFBFBD>0<EFBFBD>0
BYTE FrameIRQ; // FrameIRQ<EFBFBD>ybk
BYTE VideoMode; // NTSC/PAL
BYTE reserved2[8]; // <EFBFBD>N}
LONG StateStOffset; // Movie start state offset
LONG StateEdOffset; // Movie end state offset
LONG MovieOffset; // Movie data offset
LONG MovieStep; // Movie steps(Framepe)
DWORD CRC; // S0n0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0d<EFBFBD>O0CRC(<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>02<EFBFBD>bk)
} MOVIEFILEHDR, *LPMOVIEFILEHDR;
typedef struct tagMOVIEIMGFILEHDRx {
BYTE ID[12]; // "VirtuaNES MV"
WORD BlockVersion;
WORD reserved;
LONG StateStOffset; // Movie start state offset
LONG StateEdOffset; // Movie end state offset
LONG MovieOffset; // Movie data offset
LONG MovieStep; // Movie steps
} MOVIEIMGFILEHDRx, *LPMOVIEIMGFILEHDRx;
// Famtasia Movie....
typedef struct tagFMVHDR {
BYTE ID[4]; // "FMV^Z"
BYTE Control1; // R??????? 0:<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>_K0<EFBFBD>0<EFBFBD>2<EFBFBD><EFBFBD> 1:<EFBFBD>-NK0<EFBFBD>0<EFBFBD>2<EFBFBD>
BYTE Control2; // OT?????? O:1P<EFBFBD>`1X T:2P<EFBFBD>`1X
DWORD Unknown1;
WORD RecordTimes; // <EFBFBD>2<EFBFBD><EFBFBD>Vpe-1
DWORD Unknown2;
BYTE szEmulators[0x40]; // <EFBFBD>2<EFBFBD>W0_0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
BYTE szTitle [0x40]; // <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
} FMVHDR, *LPFMVHDR;
// Nesticle Movie....
typedef struct tagNMVHDR {
BYTE ExRAM[0x2000];
BYTE S_RAM[0x0800];
WORD PC;
BYTE A;
BYTE P;
BYTE X;
BYTE Y;
BYTE SP;
BYTE OAM[0x0100];
BYTE VRAM[0x4000];
BYTE Other[0xC9];
DWORD ScanlineCycles;
DWORD VblankScanlines;
DWORD FrameScanlines;
DWORD VirtualFPS;
} NMVHDR, *LPNMVHDR;
// <EFBFBD>0<EFBFBD>0<EFBFBD>0
#define SETBYTE(p,v) { *p = (v); p++; }
#define SETWORD(p,v) { *(LPWORD)p = (v); p += sizeof(WORD); }
#define SETDWORD(p,v) { *(LPDWORD)p = (v); p += sizeof(DWORD); }
#define SETINT(p,v) { *(LPINT)p = (v); p += sizeof(INT); }
#define SETBLOCK(p,v,s) { memcpy( p, (v), s ); p += s; }
#define GETBYTE(p,v) { (v) = *p; p++; }
#define GETWORD(p,v) { (v) = *(LPWORD)p; p += sizeof(WORD); }
#define GETDWORD(p,v) { (v) = *(LPDWORD)p; p += sizeof(DWORD); }
#define GETINT(p,v) { (v) = *(LPINT)p; p += sizeof(INT); }
#define GETBLOCK(p,v,s) { memcpy( (v), p, s ); p += s; }
#pragma pack( pop )
#endif // !__STATE_INCLUDED__