Compare commits
9 Commits
3b4501aaec
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 699ac3d052 | |||
| 9db783b3ac | |||
| 2dcbdfa975 | |||
| 709a74a76a | |||
| b2a96309e5 | |||
| b0446f40a1 | |||
| fca1172162 | |||
| dd7e3de890 | |||
| b09360d7ae |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ scr_min.c
|
|||||||
tests.lua
|
tests.lua
|
||||||
fake_editor.lua
|
fake_editor.lua
|
||||||
*.bin
|
*.bin
|
||||||
|
bin/*
|
||||||
25
Makefile
25
Makefile
@@ -1,4 +1,27 @@
|
|||||||
executable = ascii
|
executable = ascii
|
||||||
|
source = *.cpp ./lua/*.c
|
||||||
|
|
||||||
|
windows:
|
||||||
|
@echo off
|
||||||
|
g++ $(source) -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -lmingw32 -lSDL2main -lSDL2 -mwindows -o "$(executable).exe"
|
||||||
|
strip -s -R .comment -R .gnu.version --strip-unneeded "$(executable).exe"
|
||||||
|
|
||||||
|
windows_debug:
|
||||||
|
@echo off
|
||||||
|
g++ $(source) -D DEBUG -g -Wall -Os -lmingw32 -lSDL2main -lSDL2 -o "$(executable)_debug.exe"
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
g++ *.cpp ./lua/*.c -lSDL2 -o $(executable)
|
clang++ $(source) -Wall -Os -std=c++11 -ffunction-sections -fdata-sections -lSDL2 -o "$(executable)"
|
||||||
|
|
||||||
|
macos_debug:
|
||||||
|
clang++ $(source) -D DEBUG -g -Wall -Os -std=c++11 -ffunction-sections -fdata-sections -lSDL2 -o "$(executable)_debug"
|
||||||
|
|
||||||
|
macos_bundle:
|
||||||
|
clang++ $(source) -D MACOS_BUNDLE -Wall -Os -std=c++11 -framework SDL2 -F /Library/Frameworks -ffunction-sections -fdata-sections -o mini_bundle -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12
|
||||||
|
|
||||||
|
linux:
|
||||||
|
g++ $(source) -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -lSDL2 -o "$(executable)"
|
||||||
|
strip -s -R .comment -R .gnu.version --strip-unneeded "$(executable)"
|
||||||
|
|
||||||
|
linux_debug:
|
||||||
|
g++ $(source) -D DEBUG -g -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -lSDL2 -o "$(executable)_debug"
|
||||||
|
|||||||
@@ -198,6 +198,8 @@ int main(int argc,char*argv[]) {
|
|||||||
lua_init(NULL);
|
lua_init(NULL);
|
||||||
lua_call_init();
|
lua_call_init();
|
||||||
|
|
||||||
|
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||||
|
|
||||||
while(!exit) {
|
while(!exit) {
|
||||||
if (should_reset) {
|
if (should_reset) {
|
||||||
should_reset = false;
|
should_reset = false;
|
||||||
@@ -210,6 +212,12 @@ int main(int argc,char*argv[]) {
|
|||||||
mouse_wheel = 0;
|
mouse_wheel = 0;
|
||||||
while(SDL_PollEvent(&mini_eve)) {
|
while(SDL_PollEvent(&mini_eve)) {
|
||||||
if (mini_eve.type == SDL_QUIT) { exit=true; break; }
|
if (mini_eve.type == SDL_QUIT) { exit=true; break; }
|
||||||
|
if (mini_eve.type == SDL_DROPFILE) {
|
||||||
|
char* dropped_filedir = mini_eve.drop.file;
|
||||||
|
load(dropped_filedir);
|
||||||
|
//SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_INFORMATION, "File dropped on window", dropped_filedir, mini_win );
|
||||||
|
SDL_free(dropped_filedir);
|
||||||
|
}
|
||||||
if (mini_eve.type == SDL_KEYDOWN) {
|
if (mini_eve.type == SDL_KEYDOWN) {
|
||||||
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
|
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
|
||||||
if (lua_is_playing()) {
|
if (lua_is_playing()) {
|
||||||
|
|||||||
5
game.lua
Normal file
5
game.lua
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
a=32
|
||||||
|
hex=string.format("%02X",a)
|
||||||
|
print(hex)
|
||||||
|
b=tonumber(hex,16)
|
||||||
|
print(b)
|
||||||
3
lua.cpp
3
lua.cpp
@@ -417,11 +417,12 @@ bool lua_is_playing() {
|
|||||||
return lua_state == STATE_PLAYING;
|
return lua_state == STATE_PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
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";
|
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.6.1',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();
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
|
luaL_openlibs(L);
|
||||||
//init_exists = update_exists = false;
|
//init_exists = update_exists = false;
|
||||||
bool file_loaded = true;
|
bool file_loaded = true;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
//extern "C" {
|
//extern "C" {
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
//#include "lualib.h"
|
#include "lualib.h"
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
//}
|
//}
|
||||||
|
|||||||
@@ -2,26 +2,43 @@ function init()
|
|||||||
ink_color = 15
|
ink_color = 15
|
||||||
paper_color = 0
|
paper_color = 0
|
||||||
setchar(0,0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff)
|
setchar(0,0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff)
|
||||||
sprite={0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03}
|
sprite={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
|
||||||
|
--0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
|
||||||
|
--0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
|
||||||
|
--0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
|
||||||
|
--0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03}
|
||||||
end
|
end
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
|
-- Borra pantalla
|
||||||
color(15,1)
|
color(15,1)
|
||||||
cls()
|
cls()
|
||||||
|
|
||||||
|
-- Pinta sprite en gran a pantalla
|
||||||
color(ink_color,paper_color)
|
color(ink_color,paper_color)
|
||||||
drawbigspr(sprite,1,1)
|
drawbigspr(sprite,1,1)
|
||||||
|
|
||||||
|
-- Pinta el sprite en els caracters A, B, C i D
|
||||||
drawspr(sprite,65)
|
drawspr(sprite,65)
|
||||||
|
|
||||||
|
-- Pinta els caracters AB CD a pantalla
|
||||||
print("AB",18,1) print("CD",18,2)
|
print("AB",18,1) print("CD",18,2)
|
||||||
|
|
||||||
|
-- Pinta la paleta
|
||||||
for i=0,15 do
|
for i=0,15 do
|
||||||
color(0,i)
|
color(0,i)
|
||||||
poke(721+i,0) poke(1921+i,i<<4)
|
poke(721+i,0) poke(1921+i,i<<4)
|
||||||
poke(761+i,0) poke(1961+i,i<<4)
|
poke(761+i,0) poke(1961+i,i<<4)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Pinta el borde roig a les entrades en la paleta seleccionades
|
||||||
poke(1921+ink_color, peek(1921+ink_color)+4)
|
poke(1921+ink_color, peek(1921+ink_color)+4)
|
||||||
poke(1961+paper_color, peek(1961+paper_color)+4)
|
poke(1961+paper_color, peek(1961+paper_color)+4)
|
||||||
|
|
||||||
|
-- Gestió dels clicks en la paleta
|
||||||
if mousebutton(1) and mousex()>=1 and mousey()>=18 and mousex()<=16 and mousey()<=19 then
|
if mousebutton(1) and mousex()>=1 and mousey()>=18 and mousex()<=16 and mousey()<=19 then
|
||||||
if mousey()==18 then
|
if mousey()==18 then
|
||||||
ink_color = mousex()-1
|
ink_color = mousex()-1
|
||||||
@@ -30,7 +47,15 @@ function update()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Gestió dels clicks sobre l'sprite
|
||||||
handlesprmouse()
|
handlesprmouse()
|
||||||
|
|
||||||
|
-- Si pulsem 'C', borrar el sprite
|
||||||
|
if btnp(KEY_C) then
|
||||||
|
for i=1,32 do
|
||||||
|
sprite[i]=0;
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mousepressed = false
|
mousepressed = false
|
||||||
|
|||||||
Reference in New Issue
Block a user