[FEAT] Peek & Poke
[BUG] Mode not restored after ESC
This commit is contained in:
20
ascii.cpp
20
ascii.cpp
@@ -8,7 +8,7 @@
|
||||
|
||||
char lua_filename[1024];
|
||||
char window_title[256];
|
||||
uint8_t mem[2400];
|
||||
uint8_t mem[2560]; //2400
|
||||
uint8_t *char_screen = NULL;
|
||||
uint8_t *color_screen = NULL;
|
||||
uint8_t screen_width = 40;
|
||||
@@ -102,6 +102,8 @@ void audioCallback(void * userdata, uint8_t * stream, int len) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t old_mode = 0;
|
||||
|
||||
int main(int argc,char*argv[]) {
|
||||
SDL_strlcpy(lua_filename, "game.lua", 9);
|
||||
if (argc > 1) SDL_strlcpy(lua_filename, argv[1], 1023);
|
||||
@@ -143,9 +145,10 @@ int main(int argc,char*argv[]) {
|
||||
if (lua_is_playing()) {
|
||||
lua_pause();
|
||||
//lua_quit();
|
||||
old_mode = current_mode;
|
||||
setmode(0);
|
||||
} else {
|
||||
setmode(1);
|
||||
setmode(old_mode);
|
||||
lua_resume();
|
||||
//lua_init();
|
||||
//lua_call_init();
|
||||
@@ -445,12 +448,19 @@ void setchar(uint8_t index, uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3, uint
|
||||
}
|
||||
|
||||
uint8_t peek(uint16_t addr) {
|
||||
// [TODO]
|
||||
return 0;
|
||||
if (addr < 0xA00) {
|
||||
return mem[addr];
|
||||
} else {
|
||||
return font[addr-0xA00];
|
||||
}
|
||||
}
|
||||
|
||||
void poke(uint16_t addr, uint8_t val) {
|
||||
// [TODO]
|
||||
if (addr < 0xA00) {
|
||||
mem[addr] = val;
|
||||
} else {
|
||||
font[addr-0xA00] = val;
|
||||
}
|
||||
}
|
||||
|
||||
void sound(float freq, uint32_t len) {
|
||||
|
||||
24
mapedit.lua
Normal file
24
mapedit.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
ind = 22
|
||||
function init()
|
||||
setmode(2)
|
||||
map = {}
|
||||
for i=0,299 do
|
||||
map[i] = 32
|
||||
end
|
||||
map[ind] = 65
|
||||
end
|
||||
|
||||
function update()
|
||||
if btn(KEY_TAB) then
|
||||
for i=0,255 do
|
||||
poke(i, i)
|
||||
poke(300+i, 0x0f)
|
||||
end
|
||||
local mx, my = mousex(), mousey()
|
||||
poke(300+(mx+my*20), 0x4e)
|
||||
else
|
||||
for i=0,299 do
|
||||
poke(i, map[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user