AxibugEmuOnline/References/VirtuaNESex_src_191105/NES/State.h

301 lines
6.5 KiB
C
Raw Normal View History

2024-08-05 17:58:53 +08:00
#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>ȍ~<7E>p
typedef struct tagFILEHDR2 { // 0123456789AB
BYTE ID[12]; // "VirtuaNES ST"
WORD Reserved;
WORD BlockVersion; // 0x0200 / 0x0210(v0.60<EFBFBD>ȍ~)
DWORD Ext0; // ROM:<3A>v<EFBFBD><76><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD>CRC FDS:<3A>v<EFBFBD><76><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD>ID
WORD Ext1; // ROM:<3A>Ȃ<EFBFBD> FDS:<3A><><EFBFBD>[<5B>J<EFBFBD>[ID
WORD Ext2; // ROM:<3A>Ȃ<EFBFBD> FDS:<3A>f<EFBFBD>B<EFBFBD>X<EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD>
LONG MovieStep; // <20>NjL(<28><><EFBFBD><EFBFBD><E892BC>)<29><><EFBFBD>[<5B>r<EFBFBD>[<5B><><EFBFBD>̃t<CC83><74><EFBFBD>[<5B><><EFBFBD><EFBFBD>
LONG MovieOffset; // <20>NjL(<28><><EFBFBD><EFBFBD><E892BC>)<29><><EFBFBD>[<5B>r<EFBFBD>[<5B><><EFBFBD>̃t<CC83>@<40>C<EFBFBD><43><EFBFBD>I<EFBFBD>t<EFBFBD>Z<EFBFBD>b<EFBFBD>g
} FILEHDR2, *LPFILEHDR2;
typedef struct tagBLOCKHDR {
BYTE ID[8];
WORD Reserved;
WORD BlockVersion;
DWORD BlockSize;
} BLOCKHDR, *LPBLOCKHDR;
// CPU <20><><EFBFBD>W<EFBFBD>X<EFBFBD>^
// version 0x0110<31>܂<EFBFBD>
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; // <20><><EFBFBD>[<5B>r<EFBFBD>[<5B><><EFBFBD>ŃN<C583><4E><EFBFBD>b<EFBFBD>N<EFBFBD><4E><EFBFBD>̔<EFBFBD><CC94><EFBFBD><EFBFBD>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD><EFBFBD><EFBFBD>h<EFBFBD><68><EFBFBD><EFBFBD>
// 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 <20><><EFBFBD>W<EFBFBD>X<EFBFBD>^
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 <20><><EFBFBD>W<EFBFBD>X<EFBFBD>^(<28>g<EFBFBD><67><EFBFBD>T<EFBFBD>E<EFBFBD><45><EFBFBD>h<EFBFBD>܂<EFBFBD>)
typedef struct tagAPUSTAT_O {
BYTE reg[0x0018];
BYTE ext[0x0100];
} APUSTAT_O, *LPAPUSTAT_O;
// <20>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD><EFBFBD><EFBFBD>W<EFBFBD>X<EFBFBD>^
typedef struct tagCTRREG {
DWORD pad1bit;
DWORD pad2bit;
DWORD pad3bit;
DWORD pad4bit;
BYTE strobe;
} CTRREG, *LPCTRREG;
//
// <20><><EFBFBD>W<EFBFBD>X<EFBFBD>^<5E>f<EFBFBD>[<5B>^
// ID "REG DATA"
// ver 0x0110<31>܂<EFBFBD>
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<30>ȍ~
typedef struct tagREGSTAT {
union uniCPUREG {
BYTE cpudata[64];
CPUSTAT cpu;
} cpureg;
union uniPPUREG {
BYTE ppudata[32];
PPUSTAT ppu;
} ppureg;
} REGSTAT, *LPREGSTAT;
//
// <20><><EFBFBD><EFBFBD>RAM<41>f<EFBFBD>[<5B>^
// 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<4D>f<EFBFBD>[<5B>^
// 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;
//
// <20>}<7D>b<EFBFBD>p<EFBFBD>[<5B>f<EFBFBD>[<5B>^
// ID "MMC DATA"
typedef struct tagMMCSTAT {
BYTE mmcdata[256];
} MMCSTAT, *LPMMCSTAT;
//
// <20>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>f<EFBFBD>[<5B>^
// ID "CTR DATA"
typedef struct tagCTRSTAT {
union uniCTRDATA {
BYTE ctrdata[32];
CTRREG ctr;
} ctrreg;
} CTRSTAT, *LPCTRSTAT;
//
// SND<4E>f<EFBFBD>[<5B>^
// ID "SND DATA"
typedef struct tagSNDSTAT {
BYTE snddata[0x800]; // 2KB
} SNDSTAT, *LPSNDSTAT;
//
// <20>f<EFBFBD>B<EFBFBD>X<EFBFBD>N<EFBFBD>C<EFBFBD><43><EFBFBD>[<5B>W
// Ver0.24<EFBFBD>܂<EFBFBD>
// ID "DSIDE 0A","DSIDE 0B","DSIDE 1A","DSIDE 1B"
typedef struct tagDISKSTAT {
BYTE DiskTouch[16];
} DISKSTAT, *LPDISKSTAT;
// Ver0.30<EFBFBD>ȍ~
// ID "DISKDATA"
typedef struct tagDISKDATA {
LONG DifferentSize;
} DISKDATA, *LPDISKDATA;
// <20>ȉ<EFBFBD><C889>̓f<CD83>B<EFBFBD>X<EFBFBD>N<EFBFBD>Z<EFBFBD>[<5B>u<EFBFBD>C<EFBFBD><43><EFBFBD>[<5B>W<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>Ŏg<C58E>p<EFBFBD><70><EFBFBD><EFBFBD>
// Ver0.24<EFBFBD>܂<EFBFBD>
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>ȍ~<7E>p
typedef struct tagDISKFILEHDR { // 0123456789AB
BYTE ID[12]; // "VirtuaNES DI"
WORD BlockVersion; // 0x0200:0.30 0x0210:0.31
WORD Reserved;
DWORD ProgID; // <20>v<EFBFBD><76><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD>ID
WORD MakerID; // <20><><EFBFBD>[<5B>J<EFBFBD>[ID
WORD DiskNo; // <20>f<EFBFBD>B<EFBFBD>X<EFBFBD>N<EFBFBD><4E>
DWORD DifferentSize; // <20><><EFBFBD>
} DISKFILEHDR, *LPDISKFILEHDR;
//
// <20><><EFBFBD>[<5B>r<EFBFBD>[<5B>t<EFBFBD>@<40>C<EFBFBD><43>
//
// VirtuaNES version0.60<EFBFBD>ȍ~<7E>p
typedef struct tagMOVIEFILEHDR {
BYTE ID[12]; // "VirtuaNES MV"
WORD BlockVersion; // Movie version 0x0300
WORD RecordVersion; // Record version
DWORD Control; // <20>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>o<EFBFBD>C<EFBFBD>g
// 76543210(Bit)
// E---4321
// | |||+-- 1P<31>f<EFBFBD>[<5B>^
// | ||+--- 2P<32>f<EFBFBD>[<5B>^
// | |+---- 3P<33>f<EFBFBD>[<5B>^
// | +----- 4P<34>f<EFBFBD>[<5B>^
// +--------- <20>NjL<C78B>֎~
// <20><><EFBFBD>̑<EFBFBD><CC91>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD><EFBFBD>1P<31>`4P(<28>ǂ<EFBFBD><C782>ł<EFBFBD><C582>ǂ<EFBFBD>)<29>̕<EFBFBD><CC95><EFBFBD><EFBFBD>L<EFBFBD>[<5B><>
// <20>S<EFBFBD><53>ON<4F>̎<EFBFBD><CC8E>C<EFBFBD><43><EFBFBD>̂S<CC82>o<EFBFBD>C<EFBFBD>g<EFBFBD><67><EFBFBD>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>p<EFBFBD>f<EFBFBD>[<5B>^<5E>ɂȂ<C982>
DWORD Ext0; // ROM:<3A>v<EFBFBD><76><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD>CRC FDS:<3A>v<EFBFBD><76><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD>ID
WORD Ext1; // ROM:<3A>Ȃ<EFBFBD> FDS:<3A><><EFBFBD>[<5B>J<EFBFBD>[ID
WORD Ext2; // ROM:<3A>Ȃ<EFBFBD> FDS:<3A>f<EFBFBD>B<EFBFBD>X<EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD>
DWORD RecordTimes; // <20>L<EFBFBD>^<5E><><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><E892BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
BYTE RenderMethod; // <20><><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD>
BYTE IRQtype; // IRQ<52>^<5E>C<EFBFBD>v
BYTE FrameIRQ; // FrameIRQ<52>֎~
BYTE VideoMode; // NTSC/PAL
BYTE reserved2[8]; // <20>\<5C><>
LONG StateStOffset; // Movie start state offset
LONG StateEdOffset; // Movie end state offset
LONG MovieOffset; // Movie data offset
LONG MovieStep; // Movie steps(Frame<6D><65>)
DWORD CRC; // <20><><EFBFBD>̃f<CC83>[<5B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRC(<28>C<EFBFBD><43><EFBFBD>`<60>L<EFBFBD>h<EFBFBD>~)
} MOVIEFILEHDR, *LPMOVIEFILEHDR;
// Famtasia Movie....
typedef struct tagFMVHDR {
BYTE ID[4]; // "FMV^Z"
BYTE Control1; // R??????? 0:<3A><><EFBFBD>Z<EFBFBD>b<EFBFBD>g<EFBFBD><EFBFBD><E382A9><EFBFBD>L<EFBFBD>^<5E>H 1:<3A>r<EFBFBD><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>L<EFBFBD>^
BYTE Control2; // OT?????? O:1P<31><50><EFBFBD><EFBFBD> T:2P<32><50><EFBFBD><EFBFBD>
DWORD Unknown1;
WORD RecordTimes; // <20>L<EFBFBD>^<5E><><EFBFBD><EFBFBD>-1
DWORD Unknown2;
BYTE szEmulators[0x40]; // <20>L<EFBFBD>^<5E><><EFBFBD><EFBFBD><EFBFBD>G<EFBFBD>~<7E><><EFBFBD><EFBFBD><EFBFBD>[<5B>^
BYTE szTitle [0x40]; // <20>^<5E>C<EFBFBD>g<EFBFBD><67>
} 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;
// <20>}<7D>N<EFBFBD><4E>
#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__