add iowrite.readbyte() lua function, to read the last value written to write-only port. it currently supports only general sound registers ($4000-4013, $4015, $4017).
This commit is contained in:
parent
7ee2494ba7
commit
9cc4ee1d77
|
@ -205,6 +205,8 @@ static readfunc *AReadG;
|
||||||
static writefunc *BWriteG;
|
static writefunc *BWriteG;
|
||||||
static int RWWrap=0;
|
static int RWWrap=0;
|
||||||
|
|
||||||
|
uint8 IOWriteLog[0x10000];
|
||||||
|
|
||||||
//mbg merge 7/18/06 docs
|
//mbg merge 7/18/06 docs
|
||||||
//bit0 indicates whether emulation is paused
|
//bit0 indicates whether emulation is paused
|
||||||
//bit1 indicates whether emulation is in frame step mode
|
//bit1 indicates whether emulation is in frame step mode
|
||||||
|
|
|
@ -54,6 +54,8 @@ uint8 FCEU_ReadRomByte(uint32 i);
|
||||||
extern readfunc ARead[0x10000];
|
extern readfunc ARead[0x10000];
|
||||||
extern writefunc BWrite[0x10000];
|
extern writefunc BWrite[0x10000];
|
||||||
|
|
||||||
|
extern uint8 IOWriteLog[0x10000];
|
||||||
|
|
||||||
enum GI {
|
enum GI {
|
||||||
GI_RESETM2 =1,
|
GI_RESETM2 =1,
|
||||||
GI_POWER =2,
|
GI_POWER =2,
|
||||||
|
|
|
@ -1206,6 +1206,8 @@ static int rom_gethash(lua_State *L) {
|
||||||
else lua_pushstring(L, "");
|
else lua_pushstring(L, "");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
static int iowrite_readbyte(lua_State *L) { int addr = luaL_checkinteger(L,1); lua_pushinteger(L, (addr >= 0 && addr <= 0xFFFF) ? IOWriteLog[addr] : 0); return 1; }
|
||||||
|
static int iowrite_readbytesigned(lua_State *L) { int addr = luaL_checkinteger(L,1); lua_pushinteger(L, (addr >= 0 && addr <= 0xFFFF) ? (signed char)IOWriteLog[addr] : 0); return 1; }
|
||||||
static int memory_readbyte(lua_State *L) { lua_pushinteger(L, FCEU_CheatGetByte(luaL_checkinteger(L,1))); return 1; }
|
static int memory_readbyte(lua_State *L) { lua_pushinteger(L, FCEU_CheatGetByte(luaL_checkinteger(L,1))); return 1; }
|
||||||
static int memory_writebyte(lua_State *L) { FCEU_CheatSetByte(luaL_checkinteger(L,1), luaL_checkinteger(L,2)); return 0; }
|
static int memory_writebyte(lua_State *L) { FCEU_CheatSetByte(luaL_checkinteger(L,1), luaL_checkinteger(L,2)); return 0; }
|
||||||
static int memory_readbyterange(lua_State *L) {
|
static int memory_readbyterange(lua_State *L) {
|
||||||
|
@ -4699,6 +4701,16 @@ static const struct luaL_reg memorylib [] = {
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct luaL_reg iowritelib [] = {
|
||||||
|
|
||||||
|
{"readbyte", iowrite_readbyte},
|
||||||
|
{"readbytesigned", iowrite_readbytesigned},
|
||||||
|
// alternate naming scheme for unsigned
|
||||||
|
{"readbyteunsigned", iowrite_readbyte},
|
||||||
|
|
||||||
|
{NULL,NULL}
|
||||||
|
};
|
||||||
|
|
||||||
static const struct luaL_reg joypadlib[] = {
|
static const struct luaL_reg joypadlib[] = {
|
||||||
{"get", joypad_get},
|
{"get", joypad_get},
|
||||||
{"getdown", joypad_getdown},
|
{"getdown", joypad_getdown},
|
||||||
|
@ -4921,6 +4933,7 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg) {
|
||||||
luaL_register(L, "emu", emulib); // added for better cross-emulator compatibility
|
luaL_register(L, "emu", emulib); // added for better cross-emulator compatibility
|
||||||
luaL_register(L, "FCEU", emulib); // kept for backward compatibility
|
luaL_register(L, "FCEU", emulib); // kept for backward compatibility
|
||||||
luaL_register(L, "memory", memorylib);
|
luaL_register(L, "memory", memorylib);
|
||||||
|
luaL_register(L, "iowrite", iowritelib);
|
||||||
luaL_register(L, "rom", romlib);
|
luaL_register(L, "rom", romlib);
|
||||||
luaL_register(L, "joypad", joypadlib);
|
luaL_register(L, "joypad", joypadlib);
|
||||||
luaL_register(L, "zapper", zapperlib);
|
luaL_register(L, "zapper", zapperlib);
|
||||||
|
|
|
@ -239,6 +239,7 @@ static void SQReload(int x, uint8 V)
|
||||||
|
|
||||||
static DECLFW(Write_PSG)
|
static DECLFW(Write_PSG)
|
||||||
{
|
{
|
||||||
|
IOWriteLog[A] = V;
|
||||||
A&=0x1F;
|
A&=0x1F;
|
||||||
switch(A)
|
switch(A)
|
||||||
{
|
{
|
||||||
|
@ -311,6 +312,7 @@ static DECLFW(Write_PSG)
|
||||||
|
|
||||||
static DECLFW(Write_DMCRegs)
|
static DECLFW(Write_DMCRegs)
|
||||||
{
|
{
|
||||||
|
IOWriteLog[A] = V;
|
||||||
A&=0xF;
|
A&=0xF;
|
||||||
|
|
||||||
switch(A)
|
switch(A)
|
||||||
|
@ -342,6 +344,7 @@ static DECLFW(Write_DMCRegs)
|
||||||
static DECLFW(StatusWrite)
|
static DECLFW(StatusWrite)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
IOWriteLog[A] = V;
|
||||||
|
|
||||||
DoSQ1();
|
DoSQ1();
|
||||||
DoSQ2();
|
DoSQ2();
|
||||||
|
@ -1005,6 +1008,7 @@ static void RDoNoise(void)
|
||||||
|
|
||||||
DECLFW(Write_IRQFM)
|
DECLFW(Write_IRQFM)
|
||||||
{
|
{
|
||||||
|
IOWriteLog[A] = V;
|
||||||
V=(V&0xC0)>>6;
|
V=(V&0xC0)>>6;
|
||||||
fcnt=0;
|
fcnt=0;
|
||||||
if(V&0x2)
|
if(V&0x2)
|
||||||
|
|
Loading…
Reference in New Issue