Merge branch 'master' of https://gitea.sustancia.synology.me/JailDoctor/ascii
This commit is contained in:
20
ascii.cpp
20
ascii.cpp
@@ -246,6 +246,12 @@ int main(int argc,char*argv[]) {
|
|||||||
void cls(uint8_t value) {
|
void cls(uint8_t value) {
|
||||||
SDL_memset(char_screen, value, screen_width*screen_height);
|
SDL_memset(char_screen, value, screen_width*screen_height);
|
||||||
if (current_mode != 0) SDL_memset(color_screen, current_color, screen_width*screen_height);
|
if (current_mode != 0) SDL_memset(color_screen, current_color, screen_width*screen_height);
|
||||||
|
if (!lua_is_playing()) {
|
||||||
|
SDL_memset(debug_text, 32, debug_total_size);
|
||||||
|
debug_cursor = 1;
|
||||||
|
debug_prompt = 0;
|
||||||
|
debug_text[debug_prompt] = '>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ink(uint8_t value) {
|
void ink(uint8_t value) {
|
||||||
@@ -371,7 +377,7 @@ int rnd(int x) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
char tostr_tmp[256];
|
char tostr_tmp[256];
|
||||||
const char* tostr(int val) {
|
const char* tostr(float val) {
|
||||||
return SDL_itoa(val, tostr_tmp, 10);
|
return SDL_itoa(val, tostr_tmp, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,3 +491,15 @@ void load(const char* str) {
|
|||||||
SDL_strlcpy(lua_filename, str, SDL_strlen(str)+1);
|
SDL_strlcpy(lua_filename, str, SDL_strlen(str)+1);
|
||||||
should_reset = true;
|
should_reset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fileout(const char* str, uint16_t addr, uint16_t size) {
|
||||||
|
FILE* f = fopen(str, "wb");
|
||||||
|
fwrite(&mem[addr], size, 1, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void filein(const char* str, uint16_t addr, uint16_t size) {
|
||||||
|
FILE* f = fopen(str, "rb");
|
||||||
|
fread(&mem[addr], size, 1, f);
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|||||||
5
ascii.h
5
ascii.h
@@ -153,7 +153,7 @@ float min(float x, float y);
|
|||||||
int rnd(int x);
|
int rnd(int x);
|
||||||
//void srand(int x);
|
//void srand(int x);
|
||||||
|
|
||||||
const char* tostr(int val);
|
const char* tostr(float val);
|
||||||
|
|
||||||
void debugchr(const uint8_t chr);
|
void debugchr(const uint8_t chr);
|
||||||
void debug(const char *str);
|
void debug(const char *str);
|
||||||
@@ -172,3 +172,6 @@ void nosound();
|
|||||||
void setmode(const uint8_t mode);
|
void setmode(const uint8_t mode);
|
||||||
|
|
||||||
void load(const char* str);
|
void load(const char* str);
|
||||||
|
|
||||||
|
void fileout(const char* str, uint16_t addr, uint16_t size);
|
||||||
|
void filein(const char* str, uint16_t addr, uint16_t size);
|
||||||
|
|||||||
28
lua.cpp
28
lua.cpp
@@ -152,7 +152,7 @@ extern "C" {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int cpp_tostr(lua_State *L) {
|
static int cpp_tostr(lua_State *L) {
|
||||||
int val = luaL_checknumber(L, 1);
|
float val = luaL_checknumber(L, 1);
|
||||||
lua_pushstring(L, tostr(val));
|
lua_pushstring(L, tostr(val));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -223,6 +223,28 @@ extern "C" {
|
|||||||
load(str);
|
load(str);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_log(lua_State *L) {
|
||||||
|
const char* str = luaL_checkstring(L, 1);
|
||||||
|
debug(str);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cpp_fileout(lua_State *L) {
|
||||||
|
const char* str = luaL_checkstring(L, 1);
|
||||||
|
const uint16_t addr = luaL_checknumber(L, 2);
|
||||||
|
const uint16_t size = luaL_checknumber(L, 3);
|
||||||
|
fileout(str, addr, size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cpp_filein(lua_State *L) {
|
||||||
|
const char* str = luaL_checkstring(L, 1);
|
||||||
|
const uint16_t addr = luaL_checknumber(L, 2);
|
||||||
|
const uint16_t size = luaL_checknumber(L, 3);
|
||||||
|
filein(str, addr, size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STATE_STOPPED 0
|
#define STATE_STOPPED 0
|
||||||
@@ -294,6 +316,10 @@ void lua_init(const char* filename, const bool start_playing) {
|
|||||||
lua_pushcfunction(L,cpp_nosound); lua_setglobal(L, "nosound");
|
lua_pushcfunction(L,cpp_nosound); lua_setglobal(L, "nosound");
|
||||||
lua_pushcfunction(L,cpp_setmode); lua_setglobal(L, "setmode");
|
lua_pushcfunction(L,cpp_setmode); lua_setglobal(L, "setmode");
|
||||||
lua_pushcfunction(L,cpp_load); lua_setglobal(L, "load");
|
lua_pushcfunction(L,cpp_load); lua_setglobal(L, "load");
|
||||||
|
lua_pushcfunction(L,cpp_log); lua_setglobal(L, "log");
|
||||||
|
|
||||||
|
lua_pushcfunction(L,cpp_fileout); lua_setglobal(L, "fileout");
|
||||||
|
lua_pushcfunction(L,cpp_filein); lua_setglobal(L, "filein");
|
||||||
|
|
||||||
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");
|
||||||
|
|||||||
2
main.cpp
2
main.cpp
@@ -33,7 +33,7 @@ void do_terminal() {
|
|||||||
else if (key == KEY_PERIOD) { if (mods & KMOD_SHIFT) { debugchr(':'); } else { debugchr('.'); } }
|
else if (key == KEY_PERIOD) { if (mods & KMOD_SHIFT) { debugchr(':'); } else { debugchr('.'); } }
|
||||||
else if (key == KEY_SLASH) { if (mods & KMOD_SHIFT) { debugchr('_'); } else { debugchr('-'); } }
|
else if (key == KEY_SLASH) { if (mods & KMOD_SHIFT) { debugchr('_'); } else { debugchr('-'); } }
|
||||||
}
|
}
|
||||||
cls(0);
|
//cls(0);
|
||||||
pdebug();
|
pdebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
73
mapedit.lua
73
mapedit.lua
@@ -2,23 +2,90 @@ ind = 22
|
|||||||
function init()
|
function init()
|
||||||
setmode(2)
|
setmode(2)
|
||||||
map = {}
|
map = {}
|
||||||
|
col = {}
|
||||||
for i=0,299 do
|
for i=0,299 do
|
||||||
map[i] = 32
|
map[i] = 32
|
||||||
|
col[i] = 0x0f
|
||||||
end
|
end
|
||||||
map[ind] = 65
|
map[ind] = 65
|
||||||
|
sel_col = 0x0f
|
||||||
|
sel_chr = 65
|
||||||
end
|
end
|
||||||
|
|
||||||
|
blink=30
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
if btn(KEY_TAB) then
|
if btn(KEY_TAB) then
|
||||||
|
draw_picker()
|
||||||
|
update_picker()
|
||||||
|
else
|
||||||
|
draw_map()
|
||||||
|
--update_map()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_picker()
|
||||||
for i=0,255 do
|
for i=0,255 do
|
||||||
poke(i, i)
|
poke(i, i)
|
||||||
poke(300+i, 0x0f)
|
poke(300+i, sel_col)
|
||||||
end
|
end
|
||||||
|
for i=0,15 do
|
||||||
|
poke(580+i, i<<4)
|
||||||
|
poke(560+i, i<<4)
|
||||||
|
poke(280+i, 32)
|
||||||
|
poke(260+i, 32)
|
||||||
|
end
|
||||||
|
poke(580, 15) poke(560, 15)
|
||||||
|
poke(260+(sel_col&0xf), 203)
|
||||||
|
poke(280+(sel_col>>4), 203)
|
||||||
local mx, my = mousex(), mousey()
|
local mx, my = mousex(), mousey()
|
||||||
|
|
||||||
|
if my<13 then
|
||||||
poke(300+(mx+my*20), 0x4e)
|
poke(300+(mx+my*20), 0x4e)
|
||||||
|
print(mx+my*20, 16, 13)
|
||||||
|
elseif my>=13 then
|
||||||
|
poke(mx+my*20, 144)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_picker()
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
if mousebutton(1) then
|
||||||
|
if my<13 then
|
||||||
|
sel_chr = mx+my*20
|
||||||
else
|
else
|
||||||
for i=0,299 do
|
if mx < 16 then
|
||||||
poke(i, map[i])
|
if my == 13 then
|
||||||
|
sel_col = (sel_col & 0xf0) + mx
|
||||||
|
else
|
||||||
|
sel_col = (sel_col & 0x0f) + (mx << 4)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function draw_map()
|
||||||
|
for i=0,299 do
|
||||||
|
poke(i, map[i])
|
||||||
|
poke(300+i, col[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
if mousebutton(1) then
|
||||||
|
map[mx+my*20] = sel_chr
|
||||||
|
col[mx+my*20] = sel_col
|
||||||
|
end
|
||||||
|
if btn(KEY_SPACE) then
|
||||||
|
sel_chr = peek(mx+my*20)
|
||||||
|
sel_col = peek(300+mx+my*20)
|
||||||
|
end
|
||||||
|
|
||||||
|
blink = blink - 1
|
||||||
|
if blink < 30 then
|
||||||
|
if blink==0 then blink = 60 end
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
local c = peek(300+(mx+my*20))
|
||||||
|
poke(300+(mx+my*20), c~0xff)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
1
scr_min.bin
Normal file
1
scr_min.bin
Normal file
@@ -0,0 +1 @@
|
|||||||
|
֏<><D68F><EFBFBD><EFBFBD>֏<EFBFBD><D68F><EFBFBD><EFBFBD>֏<EFBFBD><D68F><EFBFBD><EFBFBD>֏<EFBFBD>֏<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԏ<EFBFBD>ԏ<EFBFBD><D48F> <20><>ԏ<EFBFBD><D48F> <20><>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֏<EFBFBD><D68F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԏ<EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD><EFBFBD> <20><>ԏ<EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD>ԏ<EFBFBD><D48F><EFBFBD><EFBFBD>ԏ<EFBFBD>ԏ<EFBFBD><D48F> <07><07><07><01><07>x<08><><EFBFBD>xxxx<07>x<0F><><EFBFBD>xxxxxx<0F>xxx<07>x<0C>
|
||||||
106
scredit.lua
Normal file
106
scredit.lua
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
ind = 22
|
||||||
|
function init()
|
||||||
|
setmode(1)
|
||||||
|
map = {}
|
||||||
|
col = {}
|
||||||
|
for i=0,1199 do
|
||||||
|
map[i] = 32
|
||||||
|
col[i] = 0x0f
|
||||||
|
end
|
||||||
|
map[ind] = 65
|
||||||
|
sel_col = 0x0f
|
||||||
|
sel_chr = 65
|
||||||
|
end
|
||||||
|
|
||||||
|
blink=30
|
||||||
|
|
||||||
|
function update()
|
||||||
|
if btn(KEY_TAB) then
|
||||||
|
draw_picker()
|
||||||
|
update_picker()
|
||||||
|
else
|
||||||
|
draw_map()
|
||||||
|
--update_map()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_picker()
|
||||||
|
for y=0,15 do
|
||||||
|
for x=0,15 do
|
||||||
|
poke(x+y*40, x+y*16)
|
||||||
|
poke(1200+x+y*40, sel_col)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i=0,15 do
|
||||||
|
poke(1840+i, i<<4)
|
||||||
|
poke(1880+i, i<<4)
|
||||||
|
poke(640+i, 32)
|
||||||
|
poke(680+i, 32)
|
||||||
|
end
|
||||||
|
poke(1840, 15) poke(1880, 15)
|
||||||
|
poke(640+(sel_col&0xf), 203)
|
||||||
|
poke(680+(sel_col>>4), 203)
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
|
||||||
|
if mx<16 then
|
||||||
|
if my<16 then
|
||||||
|
poke(1200+(mx+my*40), 0x4e)
|
||||||
|
print(mx+my*40, 16, 13)
|
||||||
|
elseif my>=16 then
|
||||||
|
poke(mx+my*40, 144)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_picker()
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
if mousebutton(1) then
|
||||||
|
if mx<16 then
|
||||||
|
if my<16 then
|
||||||
|
sel_chr = mx+my*16
|
||||||
|
else
|
||||||
|
if my == 16 then
|
||||||
|
sel_col = (sel_col & 0xf0) + mx
|
||||||
|
elseif my == 17 then
|
||||||
|
sel_col = (sel_col & 0x0f) + (mx << 4)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_map()
|
||||||
|
for i=0,1199 do
|
||||||
|
poke(i, map[i])
|
||||||
|
poke(1200+i, col[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
if mousebutton(1) then
|
||||||
|
map[mx+my*40] = sel_chr
|
||||||
|
col[mx+my*40] = sel_col
|
||||||
|
end
|
||||||
|
if btn(KEY_SPACE) then
|
||||||
|
sel_chr = peek(mx+my*40)
|
||||||
|
sel_col = peek(1200+mx+my*40)
|
||||||
|
end
|
||||||
|
|
||||||
|
blink = blink - 1
|
||||||
|
if blink < 30 then
|
||||||
|
if blink==0 then blink = 60 end
|
||||||
|
local mx, my = mousex(), mousey()
|
||||||
|
local c = peek(1200+(mx+my*40))
|
||||||
|
poke(1200+(mx+my*40), c~0xff)
|
||||||
|
end
|
||||||
|
|
||||||
|
if btn(KEY_S) then
|
||||||
|
fileout("scr.bin", 0, 2400);
|
||||||
|
elseif btn(KEY_L) then
|
||||||
|
filein("scr.bin", 0, 2400);
|
||||||
|
for i=0,1199 do
|
||||||
|
map[i] = peek(i)
|
||||||
|
col[i] = peek(1200+i)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user