static int d_RegTrap(lua_State *ls) { DISZ80 *d; int op, type; d = GetD(ls); op = luaL_check_long(ls, 1); assert(op >= 0 && op < 256); type = luaL_check_long(ls, 2); d->pTrapMap[op] |= (unsigned char)type; return 0; }
static int d_DB(lua_State *ls) { DISZ80 *d; int b, n, i; d = GetD(ls); n = 0; while (lua_isnumber(ls, n+1)) n++; if (n) { AddToDisTabDB(d); for(i=1; i <= n; i++) { b = luaL_check_long(ls, i) & 0xff; if (i > 1) AddToDis(d, ","); Add8BitNum(d, b); } } return 0; }
static int d_LookByteAddr(lua_State *ls) { DISZ80 *d; int addr; d = GetD(ls); addr = luaL_check_long(ls, 1); lua_pushnumber(ls, (double)d->Z80MemBase[addr]); return 1; }
static int str_sub (lua_State *L) { size_t l; const char *s = luaL_check_lstr(L, 1, &l); long start = posrelat(luaL_check_long(L, 2), l); long end = posrelat(luaL_opt_long(L, 3, -1), l); if (start < 1) start = 1; if (end > (long)l) end = l; if (start <= end) lua_pushlstring(L, s+start-1, end-start+1); else lua_pushstring(L, ""); return 1; }
static int d_LookByte(lua_State *ls) { DISZ80 *d; BYTE b; int offset; d = GetD(ls); offset = luaL_check_long(ls, 1); b = LookOpcode(d, offset); lua_pushnumber(ls, (double)b); return 1; }
static int d_IsCodeByte(lua_State *ls) { DISZ80 *d; int addr, isCodeByte; isCodeByte = 1; d = GetD(ls); addr = luaL_check_long(ls, 1); if (d->opMap != NULL) { if (!ISCODEBYTE(d, addr)) isCodeByte = 0; } lua_pushnumber(ls, (double)isCodeByte); return 1; }