Compare commits
4 Commits
56f2e202e8
...
c52687f0eb
| Author | SHA1 | Date | |
|---|---|---|---|
| c52687f0eb | |||
| 97daca8097 | |||
| 64bcedd82f | |||
| fe9f4fed9c |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,3 +3,6 @@ ascii
|
|||||||
.vscode/*
|
.vscode/*
|
||||||
*.dll
|
*.dll
|
||||||
wiki/*
|
wiki/*
|
||||||
|
scr_min.c
|
||||||
|
tests.lua
|
||||||
|
fake_editor.lua
|
||||||
|
|||||||
15
ascii.cpp
15
ascii.cpp
@@ -189,7 +189,7 @@ int main(int argc,char*argv[]) {
|
|||||||
while(!exit) {
|
while(!exit) {
|
||||||
if (should_reset) {
|
if (should_reset) {
|
||||||
should_reset = false;
|
should_reset = false;
|
||||||
setmode(1);
|
mode(1);
|
||||||
reinit();
|
reinit();
|
||||||
lua_init(lua_filename);
|
lua_init(lua_filename);
|
||||||
lua_call_init();
|
lua_call_init();
|
||||||
@@ -229,9 +229,12 @@ int main(int argc,char*argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
keys = SDL_GetKeyboardState(NULL);
|
keys = SDL_GetKeyboardState(NULL);
|
||||||
mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y);
|
int mx, my;
|
||||||
mouse_x = (mouse_x-40) / (640/screen_width);
|
mouse_buttons = SDL_GetMouseState(&mx, &my);
|
||||||
mouse_y = (mouse_y-40) / (480/screen_height);
|
if (mx>=40 && my>=40 && mx<680 && my<520) {
|
||||||
|
mouse_x = (mx-40) / (640/screen_width);
|
||||||
|
mouse_y = (my-40) / (480/screen_height);
|
||||||
|
}
|
||||||
|
|
||||||
if (lua_is_playing()) {
|
if (lua_is_playing()) {
|
||||||
lua_call_update();
|
lua_call_update();
|
||||||
@@ -629,8 +632,8 @@ void play(const char* str) {
|
|||||||
audio_state = AUDIO_PLAY;
|
audio_state = AUDIO_PLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setmode(const uint8_t mode) {
|
void mode(const uint8_t val) {
|
||||||
current_mode = mode;
|
current_mode = val;
|
||||||
reinit();
|
reinit();
|
||||||
cls();
|
cls();
|
||||||
}
|
}
|
||||||
|
|||||||
2
ascii.h
2
ascii.h
@@ -197,7 +197,7 @@ void sound(float freq, uint32_t len);
|
|||||||
void nosound();
|
void nosound();
|
||||||
void play(const char* str);
|
void play(const char* str);
|
||||||
|
|
||||||
void setmode(const uint8_t mode);
|
void mode(const uint8_t val);
|
||||||
void load(const char* str);
|
void load(const char* str);
|
||||||
|
|
||||||
void fileout(const char* str, uint16_t addr, uint16_t size);
|
void fileout(const char* str, uint16_t addr, uint16_t size);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
function init()
|
function init()
|
||||||
setmode(1)
|
mode(1)
|
||||||
reset()
|
reset()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
function init()
|
function init()
|
||||||
setmode(1)
|
mode(1)
|
||||||
|
|
||||||
mountains = {}
|
mountains = {}
|
||||||
local val = 2
|
local val = 2
|
||||||
53
demos/matrix.lua
Normal file
53
demos/matrix.lua
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
--[[
|
||||||
|
===============================
|
||||||
|
MATRIX CODE DEMO
|
||||||
|
by JailDoctor
|
||||||
|
===============================
|
||||||
|
--]]
|
||||||
|
|
||||||
|
function init()
|
||||||
|
mode(1) -- fiquem el mode multicolor de 40x30 caracters
|
||||||
|
color(0,0) -- tinta i fondo a negre
|
||||||
|
cls() -- borrem pantalla
|
||||||
|
|
||||||
|
-- La tabla 'col' conté, per a cada columna de la pantalla: la coordenada 'y' actual, la llargaria 's' i la espera 'w'
|
||||||
|
col = {}
|
||||||
|
for i=0,39 do
|
||||||
|
col[i] = {
|
||||||
|
y=rnd(30), -- la coordenada y valdrà entre 0 i 29, ningún misteri...
|
||||||
|
s=rnd(5)+2, -- la 's' valdrà entre 2 i 6. S'usarà tant per a definir la llargaria de la estela com per a especificar la velocitat
|
||||||
|
w=1 -- 'w' es un contador de espera: Fiquem 'w' a un valor, i a cada cicle se resta 1. Quan arribe a 0 updatem la columna i se reseteja 'w' al valor anterior.
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Omplim la tabla 'ma' amb els caracters que volem usar
|
||||||
|
ma = {}
|
||||||
|
for i=176,191 do ma[1+#ma] = i end
|
||||||
|
for i=97,122 do ma[1+#ma] = i end
|
||||||
|
|
||||||
|
-- Omplim la pantalla de caracters aleatoris (dins de la selecció que havem deixa a la tabla 'ma').
|
||||||
|
-- No es veuen perque havem ficat el color de tinta i fondo a negre.
|
||||||
|
for i=0,1199 do poke(i,ma[rnd(#ma)+1]) end
|
||||||
|
end
|
||||||
|
|
||||||
|
function update()
|
||||||
|
for i=0,39 do
|
||||||
|
col[i].w=col[i].w-1
|
||||||
|
if col[i].w == 0 then
|
||||||
|
col[i].w = col[i].s
|
||||||
|
col[i].y=col[i].y+1
|
||||||
|
if (col[i].y >= 30) then col[i].y = 0 end
|
||||||
|
local pos = 1200+i+col[i].y*40
|
||||||
|
poke(pos,15) pos=dec(pos)
|
||||||
|
poke(pos,14) pos=dec(pos)
|
||||||
|
for i=0,col[i].s do poke(pos,10) pos=dec(pos) end
|
||||||
|
for i=0,col[i].s do poke(pos,2) pos=dec(pos) end
|
||||||
|
for i=0,max(1,col[i].s-3) do poke(pos,8) pos=dec(pos) end
|
||||||
|
poke(pos,0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Aquesta funció resta 40 a la adreça (per a pujar una linea). Si detecta que se'n va fora per dalt (menys de 1200), suma 1200 per a que aparega per baix
|
||||||
|
|
||||||
|
function dec(value) return value-40 < 1200 and value+1160 or value-40 end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
function init()
|
function init()
|
||||||
setmode(1)
|
mode(1)
|
||||||
setchar(94, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
setchar(94, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
||||||
piano = { "_____", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^", "_____",
|
piano = { "_____", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^", "_____",
|
||||||
"\143\143\143\154\154", " ", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^" }
|
"\143\143\143\154\154", " ", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^" }
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ void print(int x, int y, const char* text, Uint8 color) {
|
|||||||
--]]
|
--]]
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
setmode(1)
|
mode(1)
|
||||||
current_piece = starting[rnd(7)+1]
|
current_piece = starting[rnd(7)+1]
|
||||||
next_piece = starting[rnd(7)+1]
|
next_piece = starting[rnd(7)+1]
|
||||||
|
|
||||||
|
|||||||
8
lua.cpp
8
lua.cpp
@@ -348,9 +348,9 @@ extern "C" {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cpp_setmode(lua_State *L) {
|
static int cpp_mode(lua_State *L) {
|
||||||
int val = luaL_checkinteger(L, 1);
|
int val = luaL_checkinteger(L, 1);
|
||||||
setmode(mid(0,val,3));
|
mode(mid(0,val,3));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ bool lua_is_playing() {
|
|||||||
return lua_state == STATE_PLAYING;
|
return lua_state == STATE_PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char boot[] = "function init()setmode(1)cls()play('o5l0v5cegv4cegv3cegv2cegv1ceg')memcpy(360,4608,240)memcpy(1560,4848,240)ink(1)print('G A M E',8,16)ink(4)print('S Y S T E M',20,16)ink(7)print('mini',9,8)ink(8)print('v0.5.4',34,29)w=0 end function update()w=w+1 if w>90 then cls()load()end end";
|
const char boot[] = "function init()mode(1)cls()play('o5l0v5cegv4cegv3cegv2cegv1ceg')memcpy(360,4608,240)memcpy(1560,4848,240)ink(1)print('G A M E',8,16)ink(4)print('S Y S T E M',20,16)ink(7)print('mini',9,8)ink(8)print('v0.5.4',34,29)w=0 end function update()w=w+1 if w>90 then cls()load()end end";
|
||||||
|
|
||||||
void lua_init(const char* filename, const bool start_playing) {
|
void lua_init(const char* filename, const bool start_playing) {
|
||||||
if (lua_state != STATE_STOPPED) lua_quit();
|
if (lua_state != STATE_STOPPED) lua_quit();
|
||||||
@@ -476,7 +476,7 @@ void lua_init(const char* filename, const bool start_playing) {
|
|||||||
lua_pushcfunction(L,cpp_sound); lua_setglobal(L, "sound");
|
lua_pushcfunction(L,cpp_sound); lua_setglobal(L, "sound");
|
||||||
lua_pushcfunction(L,cpp_nosound); lua_setglobal(L, "nosound");
|
lua_pushcfunction(L,cpp_nosound); lua_setglobal(L, "nosound");
|
||||||
lua_pushcfunction(L,cpp_play); lua_setglobal(L, "play");
|
lua_pushcfunction(L,cpp_play); lua_setglobal(L, "play");
|
||||||
lua_pushcfunction(L,cpp_setmode); lua_setglobal(L, "setmode");
|
lua_pushcfunction(L,cpp_mode); lua_setglobal(L, "mode");
|
||||||
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_log); lua_setglobal(L, "log");
|
||||||
|
|
||||||
|
|||||||
4
main.cpp
4
main.cpp
@@ -79,7 +79,7 @@ uint8_t get_char(uint8_t key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_terminal() {
|
void init_terminal() {
|
||||||
setmode(0);
|
mode(0);
|
||||||
cls();
|
cls();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ void refresh_code_editor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_code_editor() {
|
void init_code_editor() {
|
||||||
setmode(3);
|
mode(3);
|
||||||
code.clear();
|
code.clear();
|
||||||
load_code();
|
load_code();
|
||||||
refresh_code_editor();
|
refresh_code_editor();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
ind = 22
|
ind = 22
|
||||||
function init()
|
function init()
|
||||||
setmode(2)
|
mode(2)
|
||||||
map = {}
|
map = {}
|
||||||
col = {}
|
col = {}
|
||||||
for i=0,299 do
|
for i=0,299 do
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
function init()
|
function init()
|
||||||
setmode(1)
|
mode(1)
|
||||||
setchar(94, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
setchar(94, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
|
||||||
piano = { "_____", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^", "_____",
|
piano = { "_____", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^", "_____",
|
||||||
"\143\143\143\154\154", " ", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^" }
|
"\143\143\143\154\154", " ", "\143\143\143\154\154", " ", "\143\143\143\154\154", "^^^^^" }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
ind = 22
|
ind = 22
|
||||||
function init()
|
function init()
|
||||||
setmode(1)
|
mode(1)
|
||||||
map = {}
|
map = {}
|
||||||
col = {}
|
col = {}
|
||||||
for i=0,1199 do
|
for i=0,1199 do
|
||||||
|
|||||||
11
tweetcarts/matrix.lua
Normal file
11
tweetcarts/matrix.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
q=1200
|
||||||
|
h={}for i=0,q do poke(i,rnd(99))end
|
||||||
|
function t(a)poke(q+p,a)p=(p-40)%q end
|
||||||
|
function update()srand(1)for i=0,39 do
|
||||||
|
h[i]=(h[i] or rnd(30))+(1/(rnd(5)+2))p=i+(flr(h[i])%30)*40
|
||||||
|
t(15)t(14)
|
||||||
|
for j=0,5 do t(10)end
|
||||||
|
for j=0,5 do t(2)end
|
||||||
|
t(8)t(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user