trying to do an interface over lib6502 :
Code:
#include "../burnint.h"
#include "lib6502.h"
#define M6502_READ 1
#define M6502_WRITE 2
#define M6502_FETCH 4
M6502 *mpu = NULL
INT32 libM6502Init(INT32 cpu, INT32 type)
{
mpu = M6502_new(0, 0, 0);
return 0;
}
void libM6502SetIRQLine(UINT32 vector, UINT32 status)
{
if (status == 0)
{
M6502_setVector(mpu, NMI, status);
M6502_setVector(mpu, IRQ, status);
}
if (status == 1)
{
M6502_setVector(mpu, IRQ, status);
}
}
void libM6502_Reset(void)
{
M6502_reset(mpu);
}
INT32 libM6502MapMemory(UINT8* pMemory, UINT16 nStart, UINT16 nEnd, INT32 nType)
{
UINT32 cStart = (nStart>>0);
for (UINT32 i = cStart; i <= (nEnd>>0); i++) {
if (nType & M6502_READ) {
mpu->memory[i] = pMemory + ((i - cStart) << 0);
}
if (nType & M6502_WRITE) {
mpu->memory[i] = pMemory + ((i - cStart) << 0);
}
if (nType & M6502_FETCH) {
mpu->memory[i] = pMemory + ((i - cStart) << 0);
}
}
return 0;
}
void libM6502SetReadHandler(UINT16 nStart, UINT16 nEnd,UINT8 (*pHandler)(UINT16))
{
UINT8 cStart = (nStart >> 8);
for (UINT32 i = cStart; i <= (nEnd >> 8); i++)
{
mpu->callbacks->read[i] = pHandler;
}
}
void libM6502SetWriteHandler(UINT16 nStart, UINT16 nEnd,void (*pHandler)(UINT16, UINT8))
{
UINT8 cStart = (nStart >> 8);
for (UINT32 i = cStart; i <= (nEnd >> 8); i++)
{
mpu->callbacks->write[i] = pHandler;
}
}
int libM6502_Execute(int cycles)
{
M6502_run(mpu,cycles);
}