h6280 - standardize functions
This commit is contained in:
parent
dd5ff363f0
commit
4afbdcc37c
|
@ -130,7 +130,7 @@ static int h6280_ICount = 0;
|
|||
|
||||
static h6280_Regs h6280;
|
||||
|
||||
//static void set_irq_line(int irqline, int state);
|
||||
void h6280_set_irq_line(INT32 irqline, INT32 state);
|
||||
#define set_irq_line h6280_set_irq_line
|
||||
|
||||
/* include the macros */
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
***************************************************************/
|
||||
H6280_INLINE UINT8 RDMEM(offs_t addr) {
|
||||
CHECK_VDC_VCE_PENALTY(addr);
|
||||
return h6280_read(TRANSLATED(addr));
|
||||
return h6280Read(TRANSLATED(addr));
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
|
@ -135,60 +135,60 @@ H6280_INLINE UINT8 RDMEM(offs_t addr) {
|
|||
***************************************************************/
|
||||
H6280_INLINE void WRMEM(offs_t addr, UINT8 data) {
|
||||
CHECK_VDC_VCE_PENALTY(addr);
|
||||
h6280_write(TRANSLATED(addr),data);
|
||||
h6280Write(TRANSLATED(addr),data);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* RDMEMZ read memory - zero page
|
||||
***************************************************************/
|
||||
#define RDMEMZ(addr) \
|
||||
h6280_read( (h6280.mmr[1] << 13) | ((addr)&0x1fff));
|
||||
h6280Read( (h6280.mmr[1] << 13) | ((addr)&0x1fff));
|
||||
|
||||
/***************************************************************
|
||||
* WRMEMZ write memory - zero page
|
||||
***************************************************************/
|
||||
#define WRMEMZ(addr,data) \
|
||||
h6280_write( (h6280.mmr[1] << 13) | ((addr)&0x1fff),data);
|
||||
h6280Write( (h6280.mmr[1] << 13) | ((addr)&0x1fff),data);
|
||||
|
||||
/***************************************************************
|
||||
* RDMEMW read word from memory
|
||||
***************************************************************/
|
||||
#define RDMEMW(addr) \
|
||||
h6280_read(TRANSLATED(addr)) \
|
||||
| ( h6280_read(TRANSLATED(addr+1)) << 8 )
|
||||
h6280Read(TRANSLATED(addr)) \
|
||||
| ( h6280Read(TRANSLATED(addr+1)) << 8 )
|
||||
|
||||
/***************************************************************
|
||||
* RDZPWORD read a word from a zero page address
|
||||
***************************************************************/
|
||||
#define RDZPWORD(addr) \
|
||||
((addr&0xff)==0xff) ? \
|
||||
h6280_read( (h6280.mmr[1] << 13) | ((addr)&0x1fff)) \
|
||||
+(h6280_read( (h6280.mmr[1] << 13) | ((addr-0xff)&0x1fff))<<8) : \
|
||||
h6280_read( (h6280.mmr[1] << 13) | ((addr)&0x1fff)) \
|
||||
+(h6280_read( (h6280.mmr[1] << 13) | ((addr+1)&0x1fff))<<8)
|
||||
h6280Read( (h6280.mmr[1] << 13) | ((addr)&0x1fff)) \
|
||||
+(h6280Read( (h6280.mmr[1] << 13) | ((addr-0xff)&0x1fff))<<8) : \
|
||||
h6280Read( (h6280.mmr[1] << 13) | ((addr)&0x1fff)) \
|
||||
+(h6280Read( (h6280.mmr[1] << 13) | ((addr+1)&0x1fff))<<8)
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* push a register onto the stack
|
||||
***************************************************************/
|
||||
#define PUSH(Rg) h6280_write( (h6280.mmr[1] << 13) | h6280.sp.d,Rg); S--
|
||||
#define PUSH(Rg) h6280Write( (h6280.mmr[1] << 13) | h6280.sp.d,Rg); S--
|
||||
|
||||
/***************************************************************
|
||||
* pull a register from the stack
|
||||
***************************************************************/
|
||||
#define PULL(Rg) S++; Rg = h6280_read( (h6280.mmr[1] << 13) | h6280.sp.d)
|
||||
#define PULL(Rg) S++; Rg = h6280Read( (h6280.mmr[1] << 13) | h6280.sp.d)
|
||||
|
||||
/***************************************************************
|
||||
* RDOP read an opcode
|
||||
***************************************************************/
|
||||
#define RDOP() \
|
||||
h6280_fetch(TRANSLATED(PCW))
|
||||
h6280Fetch(TRANSLATED(PCW))
|
||||
|
||||
/***************************************************************
|
||||
* RDOPARG read an opcode argument
|
||||
***************************************************************/
|
||||
#define RDOPARG() \
|
||||
h6280_fetch(TRANSLATED(PCW))
|
||||
h6280Fetch(TRANSLATED(PCW))
|
||||
|
||||
/***************************************************************
|
||||
* BRA branch relative
|
||||
|
@ -1118,21 +1118,21 @@ H6280_INLINE void WRMEM(offs_t addr, UINT8 data) {
|
|||
***************************************************************/
|
||||
#define ST0 \
|
||||
CLEAR_T; \
|
||||
h6280_write_port(0x0000,tmp)
|
||||
h6280WritePort(0x0000,tmp)
|
||||
|
||||
/* 6280 ********************************************************
|
||||
* ST1 Store at hardware address 2
|
||||
***************************************************************/
|
||||
#define ST1 \
|
||||
CLEAR_T; \
|
||||
h6280_write_port(0x0002,tmp)
|
||||
h6280WritePort(0x0002,tmp)
|
||||
|
||||
/* 6280 ********************************************************
|
||||
* ST2 Store at hardware address 3
|
||||
***************************************************************/
|
||||
#define ST2 \
|
||||
CLEAR_T; \
|
||||
h6280_write_port(0x0003,tmp)
|
||||
h6280WritePort(0x0003,tmp)
|
||||
|
||||
/* 6280 ********************************************************
|
||||
* STA Store accumulator
|
||||
|
|
|
@ -31,6 +31,9 @@ static struct h6280_handler *sPointer;
|
|||
INT32 nh6280CpuCount = 0;
|
||||
INT32 nh6280CpuActive = -1;
|
||||
|
||||
extern void h6280_set_irq_line(INT32 irqline, INT32 state);
|
||||
extern void h6280_init(INT32 (*irqcallback)(INT32));
|
||||
|
||||
void h6280MapMemory(UINT8 *src, UINT32 start, UINT32 finish, INT32 type)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
|
@ -94,7 +97,106 @@ void h6280SetReadHandler(UINT8 (*read)(UINT32))
|
|||
sPointer->h6280Read = read;
|
||||
}
|
||||
|
||||
void h6280_write_rom(UINT32 address, UINT8 data)
|
||||
void h6280WritePort(UINT8 port, UINT8 data)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280WritePort called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280WritePort called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
// bprintf (0, _T("%5.5x write port\n"), port);
|
||||
|
||||
if (sPointer->h6280WriteIO != NULL) {
|
||||
sPointer->h6280WriteIO(port, data);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void h6280Write(UINT32 address, UINT8 data)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280Write called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280Write called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
address &= 0x1fffff;
|
||||
|
||||
// bprintf (0, _T("%5.5x write\n"), address);
|
||||
|
||||
if (sPointer->mem[WRITE][address >> PAGE_SHIFT] != NULL) {
|
||||
sPointer->mem[WRITE][address >> PAGE_SHIFT][address & PAGE_MASK] = data;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sPointer->h6280Write != NULL) {
|
||||
sPointer->h6280Write(address, data);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
UINT8 h6280Read(UINT32 address)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280Read called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280Read called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
address &= 0x1fffff;
|
||||
|
||||
// bprintf (0, _T("%5.5x read\n"), address);
|
||||
|
||||
if (sPointer->mem[ READ][address >> PAGE_SHIFT] != NULL) {
|
||||
return sPointer->mem[ READ][address >> PAGE_SHIFT][address & PAGE_MASK];
|
||||
}
|
||||
|
||||
if (sPointer->h6280Read != NULL) {
|
||||
return sPointer->h6280Read(address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8 h6280Fetch(UINT32 address)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280Fetch called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280Fetch called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
address &= 0x1fffff;
|
||||
|
||||
if (sPointer->mem[FETCH][address >> PAGE_SHIFT] != NULL) {
|
||||
return sPointer->mem[FETCH][address >> PAGE_SHIFT][address & PAGE_MASK];
|
||||
}
|
||||
|
||||
if (sPointer->h6280Read != NULL) {
|
||||
return sPointer->h6280Read(address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void h6280SetIRQLine(INT32 line, INT32 state)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280SetIRQLine called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280SetIRQLine called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
if (state == H6280_IRQSTATUS_AUTO) {
|
||||
h6280_set_irq_line(line, 1);
|
||||
h6280Run(10);
|
||||
h6280_set_irq_line(line, 0);
|
||||
} else {
|
||||
h6280_set_irq_line(line, state);
|
||||
}
|
||||
}
|
||||
|
||||
static void h6280_write_rom(UINT32 address, UINT8 data)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280_write_rom called without init\n"));
|
||||
|
@ -120,123 +222,11 @@ void h6280_write_rom(UINT32 address, UINT8 data)
|
|||
}
|
||||
}
|
||||
|
||||
void h6280_write_port(UINT8 port, UINT8 data)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280_write_port called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280_write_port called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
// bprintf (0, _T("%5.5x write port\n"), port);
|
||||
|
||||
if (sPointer->h6280WriteIO != NULL) {
|
||||
sPointer->h6280WriteIO(port, data);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void h6280_write(UINT32 address, UINT8 data)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280_write called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280_write called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
address &= 0x1fffff;
|
||||
|
||||
// bprintf (0, _T("%5.5x write\n"), address);
|
||||
|
||||
if (sPointer->mem[WRITE][address >> PAGE_SHIFT] != NULL) {
|
||||
sPointer->mem[WRITE][address >> PAGE_SHIFT][address & PAGE_MASK] = data;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sPointer->h6280Write != NULL) {
|
||||
sPointer->h6280Write(address, data);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
UINT8 h6280_read(UINT32 address)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280_read called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280_read called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
address &= 0x1fffff;
|
||||
|
||||
// bprintf (0, _T("%5.5x read\n"), address);
|
||||
|
||||
if (sPointer->mem[ READ][address >> PAGE_SHIFT] != NULL) {
|
||||
return sPointer->mem[ READ][address >> PAGE_SHIFT][address & PAGE_MASK];
|
||||
}
|
||||
|
||||
if (sPointer->h6280Read != NULL) {
|
||||
return sPointer->h6280Read(address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8 h6280_fetch1(UINT32 address)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280_fetch1 called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280_fetch1 called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
address &= 0x1fffff;
|
||||
|
||||
if (sPointer->mem[FETCH][address >> PAGE_SHIFT] != NULL) {
|
||||
return sPointer->mem[FETCH][address >> PAGE_SHIFT][address & PAGE_MASK];
|
||||
}
|
||||
|
||||
if (sPointer->h6280Read != NULL) {
|
||||
return sPointer->h6280Read(address);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8 h6280_fetch(UINT32 address)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280_fetch called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280_fetch called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
address &= 0x1fffff;
|
||||
|
||||
// bprintf (0, _T("%5.5x %5.5x, %2.2x fetch\n"), address, address&0xffff, h6280_fetch1(address));
|
||||
return h6280_fetch1(address);
|
||||
}
|
||||
|
||||
void h6280SetIRQLine(INT32 line, INT32 state)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugCPU_H6280Initted) bprintf(PRINT_ERROR, _T("h6280SetIRQLine called without init\n"));
|
||||
if (nh6280CpuActive == -1) bprintf(PRINT_ERROR, _T("h6280SetIRQLine called with no CPU open\n"));
|
||||
#endif
|
||||
|
||||
if (state == H6280_IRQSTATUS_AUTO) {
|
||||
h6280_set_irq_line(line, 1);
|
||||
h6280Run(10);
|
||||
h6280_set_irq_line(line, 0);
|
||||
} else {
|
||||
h6280_set_irq_line(line, state);
|
||||
}
|
||||
}
|
||||
|
||||
static cpu_core_config H6280CheatCpuConfig =
|
||||
{
|
||||
h6280Open,
|
||||
h6280Close,
|
||||
h6280_read,
|
||||
h6280Read,
|
||||
h6280_write_rom,
|
||||
h6280GetActive,
|
||||
h6280TotalCycles,
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// h6280.cpp
|
||||
void h6280_set_irq_line(INT32 irqline, INT32 state);
|
||||
void h6280_init(INT32 (*irqcallback)(INT32));
|
||||
|
||||
// h6280_intf.cpp
|
||||
void h6280WritePort(UINT8 port, UINT8 data);
|
||||
void h6280Write(UINT32 address, UINT8 data);
|
||||
UINT8 h6280Read(UINT32 address);
|
||||
UINT8 h6280Fetch(UINT32 address);
|
||||
|
||||
#define H6280_READ 1
|
||||
#define H6280_WRITE 2
|
||||
#define H6280_FETCH 4
|
||||
|
@ -19,11 +20,6 @@ void h6280SetWritePortHandler(void (*write)(UINT8, UINT8));
|
|||
void h6280SetWriteHandler(void (*write)(UINT32, UINT8));
|
||||
void h6280SetReadHandler(UINT8 (*read)(UINT32));
|
||||
|
||||
void h6280_write_port(UINT8 port, UINT8 data);
|
||||
void h6280_write(UINT32 address, UINT8 data);
|
||||
UINT8 h6280_read(UINT32 address);
|
||||
UINT8 h6280_fetch(UINT32 address);
|
||||
|
||||
void h6280Init(INT32);
|
||||
void h6280Open(INT32);
|
||||
void h6280Reset();
|
||||
|
@ -49,8 +45,6 @@ void h6280RunEnd();
|
|||
|
||||
INT32 h6280GetActive();
|
||||
|
||||
void h6280_write_rom(UINT32 address, UINT8 data);
|
||||
|
||||
|
||||
UINT8 h6280_irq_status_r(UINT32 offset);
|
||||
void h6280_irq_status_w(UINT32 offset, UINT8 data);
|
||||
|
@ -60,8 +54,3 @@ void h6280_timer_w(UINT32 offset, UINT8 data);
|
|||
// functions for use by the PSG and joypad port only!
|
||||
UINT8 h6280io_get_buffer(void);
|
||||
void h6280io_set_buffer(UINT8);
|
||||
|
||||
|
||||
// internal
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue