emulua: add rom.readbyte and rom.readbytesigned
This commit is contained in:
parent
eb392878b9
commit
cda4fb4824
|
@ -1,3 +1,7 @@
|
||||||
|
---version 2.0.4 yet to be released---
|
||||||
|
|
||||||
|
02-nov-2008 - zeromus - emulua - add rom.readbyte and rom.readbytesigned
|
||||||
|
|
||||||
---version 2.0.3 released---
|
---version 2.0.3 released---
|
||||||
|
|
||||||
02-nov-2008 - zeromus - fix fcm conversion, recording, and playback of reset and power commands
|
02-nov-2008 - zeromus - fix fcm conversion, recording, and playback of reset and power commands
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "vsuni.h"
|
#include "vsuni.h"
|
||||||
|
#include "ines.h"
|
||||||
|
|
||||||
#ifdef _S9XLUA_H
|
#ifdef _S9XLUA_H
|
||||||
#include "fceulua.h"
|
#include "fceulua.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -1070,3 +1072,10 @@ bool FCEUXLoad(const char *name, FCEUFILE *fp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8 FCEU_ReadRomByte(uint32 i) {
|
||||||
|
extern iNES_HEADER head;
|
||||||
|
if(i < 16) return *((unsigned char *)&head+i);
|
||||||
|
if(i < 16+PRGsize[0])return PRGptr[0][i-16];
|
||||||
|
if(i < 16+PRGsize[0]+CHRsize[0])return CHRptr[0][i-16-PRGsize[0]];
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -45,6 +45,8 @@ extern uint8 *RAM; //shared memory modifications
|
||||||
extern uint8 *GameMemBlock; //shared memory modifications
|
extern uint8 *GameMemBlock; //shared memory modifications
|
||||||
extern int EmulationPaused;
|
extern int EmulationPaused;
|
||||||
|
|
||||||
|
uint8 FCEU_ReadRomByte(uint32 i);
|
||||||
|
|
||||||
extern readfunc ARead[0x10000];
|
extern readfunc ARead[0x10000];
|
||||||
extern writefunc BWrite[0x10000];
|
extern writefunc BWrite[0x10000];
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _INES_H_
|
||||||
|
#define _INES_H_
|
||||||
|
|
||||||
#ifdef INESPRIV
|
#ifdef INESPRIV
|
||||||
|
|
||||||
void iNESStateRestore(int version);
|
void iNESStateRestore(int version);
|
||||||
|
@ -425,3 +428,5 @@ void Mapper245_Init(CartInfo *);
|
||||||
void Mapper249_Init(CartInfo *);
|
void Mapper249_Init(CartInfo *);
|
||||||
void Mapper250_Init(CartInfo *);
|
void Mapper250_Init(CartInfo *);
|
||||||
void Mapper254_Init(CartInfo *);
|
void Mapper254_Init(CartInfo *);
|
||||||
|
|
||||||
|
#endif
|
|
@ -330,6 +330,8 @@ static int fceu_message(lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int rom_readbyte(lua_State *L) { lua_pushinteger(L, FCEU_ReadRomByte(luaL_checkinteger(L,1))); return 1; }
|
||||||
|
static int rom_readbytesigned(lua_State *L) { lua_pushinteger(L, (signed char)FCEU_ReadRomByte(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_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) {
|
||||||
|
@ -1507,6 +1509,13 @@ static const struct luaL_reg fceulib [] = {
|
||||||
{NULL,NULL}
|
{NULL,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct luaL_reg romlib [] = {
|
||||||
|
{"readbyte", rom_readbyte},
|
||||||
|
{"readbytesigned", rom_readbytesigned},
|
||||||
|
{NULL,NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static const struct luaL_reg memorylib [] = {
|
static const struct luaL_reg memorylib [] = {
|
||||||
|
|
||||||
{"readbyte", memory_readbyte},
|
{"readbyte", memory_readbyte},
|
||||||
|
@ -1653,6 +1662,7 @@ int FCEU_LoadLuaCode(const char *filename) {
|
||||||
|
|
||||||
luaL_register(L, "FCEU", fceulib);
|
luaL_register(L, "FCEU", fceulib);
|
||||||
luaL_register(L, "memory", memorylib);
|
luaL_register(L, "memory", memorylib);
|
||||||
|
luaL_register(L, "rom", romlib);
|
||||||
luaL_register(L, "joypad", joypadlib);
|
luaL_register(L, "joypad", joypadlib);
|
||||||
luaL_register(L, "savestate", savestatelib);
|
luaL_register(L, "savestate", savestatelib);
|
||||||
luaL_register(L, "movie", movielib);
|
luaL_register(L, "movie", movielib);
|
||||||
|
|
Loading…
Reference in New Issue