aboutsummaryrefslogtreecommitdiff
path: root/source/fxemu.h
blob: 6c717e3299a43d0b5cba933edf1bf3a601cfb880 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "../copyright"

#ifndef _FXEMU_H_
#define _FXEMU_H_ 1

#include "snes9x.h"

/* The FxInfo_s structure, the link between the FxEmulator and the Snes Emulator */
struct FxInit_s
{
   uint32_t  vFlags;
   uint8_t*  pvRegisters; /* 768 bytes located in the memory at address 0x3000 */
   uint32_t  nRamBanks;   /* Number of 64kb-banks in GSU-RAM/BackupRAM (banks 0x70-0x73) */
   uint8_t*  pvRam;       /* Pointer to GSU-RAM */
   uint32_t  nRomBanks;   /* Number of 32kb-banks in Cart-ROM */
   uint8_t*  pvRom;       /* Pointer to Cart-ROM */
};

/* Reset the FxChip */
extern void FxReset(struct FxInit_s* psFxInfo);

/* Execute until the next stop instruction */
extern int FxEmulate(uint32_t nInstructions);

/* Write access to the cache */
extern void FxCacheWriteAccess(uint16_t vAddress);
extern void FxFlushCache();   /* Callled when the G flag in SFR is set to zero */

/* Step by step execution */
extern int FxStepOver(uint32_t nInstructions);

/* Errors */
extern int FxGetErrorCode();
extern int FxGetIllegalAddress();

/* Access to internal registers */
extern uint32_t FxGetColorRegister();
extern uint32_t FxGetPlotOptionRegister();
extern uint32_t FxGetSourceRegisterIndex();
extern uint32_t FxGetDestinationRegisterIndex();

/* Get the byte currently in the pipe */
extern uint8_t FxPipe();

/* SCBR write seen.  We need to update our cached screen pointers */
extern void fx_dirtySCBR(void);

/* Update RamBankReg and RAM Bank pointer */
extern void fx_updateRamBank(uint8_t Byte);

/* Option flags */
#define FX_FLAG_ADDRESS_CHECKING 0x01
#define FX_FLAG_ROM_BUFFER    0x02

/* Return codes from FxEmulate(), FxStepInto() or FxStepOver() */
#define FX_BREAKPOINT         -1
#define FX_ERROR_ILLEGAL_ADDRESS -2

/* Return the number of bytes in an opcode */
#define OPCODE_BYTES(op) ((((op)>=0x05&&(op)<=0xf)||((op)>=0xa0&&(op)<=0xaf))?2:(((op)>=0xf0)?3:1))

extern void fx_computeScreenPointers();

#endif