[FEAT] cnt() i rst()
This commit is contained in:
10
ascii.cpp
10
ascii.cpp
@@ -42,6 +42,7 @@ SDL_Texture *mini_bak = NULL;
|
|||||||
SDL_AudioDeviceID mini_audio_device;
|
SDL_AudioDeviceID mini_audio_device;
|
||||||
Uint32 *pixels;
|
Uint32 *pixels;
|
||||||
int pitch;
|
int pitch;
|
||||||
|
Uint32 counter=0;
|
||||||
|
|
||||||
uint32_t palette[16] = { 0x00000000, 0x000000AA, 0x0000AA00, 0x0000AAAA, 0x00AA0000, 0x00AA00AA, 0x00AA5500, 0x00AAAAAA,
|
uint32_t palette[16] = { 0x00000000, 0x000000AA, 0x0000AA00, 0x0000AAAA, 0x00AA0000, 0x00AA00AA, 0x00AA5500, 0x00AAAAAA,
|
||||||
0x00555555, 0x005555FF, 0x0055FF55, 0x0055FFFF, 0x00FF5555, 0x00FF55FF, 0x00FFFF55, 0x00FFFFFF };
|
0x00555555, 0x005555FF, 0x0055FF55, 0x0055FFFF, 0x00FF5555, 0x00FF55FF, 0x00FFFF55, 0x00FFFFFF };
|
||||||
@@ -63,6 +64,7 @@ const char* get_filename() {
|
|||||||
|
|
||||||
void reinit() {
|
void reinit() {
|
||||||
if (mini_bak != NULL) SDL_DestroyTexture(mini_bak);
|
if (mini_bak != NULL) SDL_DestroyTexture(mini_bak);
|
||||||
|
counter=0;
|
||||||
switch (current_mode) {
|
switch (current_mode) {
|
||||||
case 0:
|
case 0:
|
||||||
screen_width = 80;
|
screen_width = 80;
|
||||||
@@ -305,6 +307,7 @@ int main(int argc,char*argv[]) {
|
|||||||
SDL_RenderCopy(mini_ren, mini_bak, NULL, &rect);
|
SDL_RenderCopy(mini_ren, mini_bak, NULL, &rect);
|
||||||
//SDL_RenderCopy(mini_ren, mini_bak, NULL, NULL);
|
//SDL_RenderCopy(mini_ren, mini_bak, NULL, NULL);
|
||||||
SDL_RenderPresent(mini_ren);
|
SDL_RenderPresent(mini_ren);
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
lua_quit();
|
lua_quit();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
@@ -673,3 +676,10 @@ const char* fromclipboard() {
|
|||||||
|
|
||||||
return str_tmp;
|
return str_tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t cnt() {
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
void rst() {
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
|
|||||||
3
ascii.h
3
ascii.h
@@ -205,3 +205,6 @@ void filein(const char* str, uint16_t addr, uint16_t size);
|
|||||||
|
|
||||||
void toclipboard(const char* str);
|
void toclipboard(const char* str);
|
||||||
const char* fromclipboard();
|
const char* fromclipboard();
|
||||||
|
|
||||||
|
uint32_t cnt();
|
||||||
|
void rst();
|
||||||
|
|||||||
13
lua.cpp
13
lua.cpp
@@ -392,6 +392,16 @@ extern "C" {
|
|||||||
lua_pushstring(L, fromclipboard());
|
lua_pushstring(L, fromclipboard());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_cnt(lua_State *L) {
|
||||||
|
lua_pushinteger(L, cnt());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cpp_rst(lua_State *L) {
|
||||||
|
rst();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STATE_STOPPED 0
|
#define STATE_STOPPED 0
|
||||||
@@ -485,6 +495,9 @@ void lua_init(const char* filename, const bool start_playing) {
|
|||||||
lua_pushcfunction(L,cpp_toclipboard); lua_setglobal(L, "toclipboard");
|
lua_pushcfunction(L,cpp_toclipboard); lua_setglobal(L, "toclipboard");
|
||||||
lua_pushcfunction(L,cpp_fromclipboard); lua_setglobal(L, "fromclipboard");
|
lua_pushcfunction(L,cpp_fromclipboard); lua_setglobal(L, "fromclipboard");
|
||||||
|
|
||||||
|
lua_pushcfunction(L,cpp_cnt); lua_setglobal(L, "cnt");
|
||||||
|
lua_pushcfunction(L,cpp_rst); lua_setglobal(L, "rst");
|
||||||
|
|
||||||
lua_pushinteger(L, 0); lua_setglobal(L, "KEY_UNKNOWN");
|
lua_pushinteger(L, 0); lua_setglobal(L, "KEY_UNKNOWN");
|
||||||
lua_pushinteger(L, 4); lua_setglobal(L, "KEY_A");
|
lua_pushinteger(L, 4); lua_setglobal(L, "KEY_A");
|
||||||
lua_pushinteger(L, 5); lua_setglobal(L, "KEY_B");
|
lua_pushinteger(L, 5); lua_setglobal(L, "KEY_B");
|
||||||
|
|||||||
Reference in New Issue
Block a user