diff --git a/ascii.cpp b/ascii.cpp index 165d26c..9f49f78 100644 --- a/ascii.cpp +++ b/ascii.cpp @@ -67,7 +67,7 @@ void reinit() { case 1: screen_width = 40; screen_height = 30; - current_color = 0x1e; + current_color = 0x07; cursor_x = 0; cursor_y = 0; char_screen = &mem[0]; @@ -78,7 +78,7 @@ void reinit() { case 2: screen_width = 20; screen_height = 15; - current_color = 0x1e; + current_color = 0x07; cursor_x = 0; cursor_y = 0; char_screen = &mem[0]; @@ -469,6 +469,12 @@ void poke(uint16_t addr, uint8_t val) { } } +void memcpy(uint16_t dst, uint16_t src, uint16_t size) { + if (dst <= src) return; + if (src+size>=dst) return; + SDL_memcpy(&mem[dst], &mem[src], size); +} + void sound(float freq, uint32_t len) { // [TODO] audio_len = len*44.1f; diff --git a/ascii.h b/ascii.h index 93e5add..800848d 100644 --- a/ascii.h +++ b/ascii.h @@ -166,6 +166,7 @@ const char* chr(uint8_t ascii); void setchar(uint8_t index, uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5, uint8_t b6, uint8_t b7); uint8_t peek(uint16_t addr); void poke(uint16_t addr, uint8_t val); +void memcpy(uint16_t dst, uint16_t src, uint16_t size); void sound(float freq, uint32_t len); void nosound(); diff --git a/lua.cpp b/lua.cpp index e52d9b6..f41db62 100644 --- a/lua.cpp +++ b/lua.cpp @@ -200,6 +200,14 @@ extern "C" { return 0; } + static int cpp_memcpy(lua_State *L) { + int dst = luaL_checkinteger(L, 1); + int src = luaL_checkinteger(L, 2); + int size = luaL_checkinteger(L, 3); + memcpy(dst, src, size); + return 0; + } + static int cpp_sound(lua_State *L) { float freq = luaL_checknumber(L, 1); int len = luaL_checkinteger(L, 2); @@ -312,6 +320,7 @@ void lua_init(const char* filename, const bool start_playing) { lua_pushcfunction(L,cpp_setchar); lua_setglobal(L, "setchar"); lua_pushcfunction(L,cpp_peek); lua_setglobal(L, "peek"); lua_pushcfunction(L,cpp_poke); lua_setglobal(L, "poke"); + lua_pushcfunction(L,cpp_memcpy); lua_setglobal(L, "memcpy"); lua_pushcfunction(L,cpp_sound); lua_setglobal(L, "sound"); lua_pushcfunction(L,cpp_nosound); lua_setglobal(L, "nosound"); lua_pushcfunction(L,cpp_setmode); lua_setglobal(L, "setmode");