Still working on the console...
This commit is contained in:
31
ascii.cpp
31
ascii.cpp
@@ -6,6 +6,7 @@
|
||||
|
||||
#define swap(a, b) {auto tmp=a;a=b;b=tmp;}
|
||||
|
||||
char lua_filename[1024];
|
||||
char window_title[256];
|
||||
uint8_t mem[2400];
|
||||
uint8_t *char_screen = NULL;
|
||||
@@ -40,6 +41,7 @@ char debug_text[debug_total_size];
|
||||
int debug_cursor = 0;
|
||||
int debug_prompt = 0;
|
||||
int debug_cursor_blink = 30;
|
||||
bool should_reset = false;
|
||||
|
||||
//Uint8 keymapping[6] = { SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_Z, SDL_SCANCODE_X };
|
||||
const Uint8 *keys;
|
||||
@@ -54,7 +56,7 @@ void reinit() {
|
||||
case 0:
|
||||
screen_width = 80;
|
||||
screen_height = 30;
|
||||
current_color = 0x19;
|
||||
current_color = 0x07;
|
||||
cursor_x = 0;
|
||||
cursor_y = 0;
|
||||
char_screen = &mem[0];
|
||||
@@ -101,6 +103,8 @@ void audioCallback(void * userdata, uint8_t * stream, int len) {
|
||||
}
|
||||
|
||||
int main(int argc,char*argv[]) {
|
||||
SDL_strlcpy(lua_filename, "game.lua", 9);
|
||||
if (argc > 1) SDL_strlcpy(lua_filename, argv[1], 1023);
|
||||
|
||||
for (int i=0; i<debug_total_size;++i) debug_text[i] = 32;
|
||||
|
||||
@@ -119,10 +123,17 @@ int main(int argc,char*argv[]) {
|
||||
|
||||
reinit();
|
||||
debug("ASCII SYSTEM BOOTING...");
|
||||
lua_init();
|
||||
lua_init(lua_filename);
|
||||
lua_call_init();
|
||||
|
||||
while(!exit) {
|
||||
if (should_reset) {
|
||||
should_reset = false;
|
||||
setmode(1);
|
||||
reinit();
|
||||
lua_init(lua_filename);
|
||||
lua_call_init();
|
||||
}
|
||||
key_just_pressed = 0;
|
||||
mouse_wheel = 0;
|
||||
while(SDL_PollEvent(&mini_eve)) {
|
||||
@@ -142,7 +153,7 @@ int main(int argc,char*argv[]) {
|
||||
} else if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F5) {
|
||||
lua_quit();
|
||||
reinit();
|
||||
lua_init();
|
||||
lua_init(lua_filename);
|
||||
lua_call_init();
|
||||
} else {
|
||||
key_just_pressed = mini_eve.key.keysym.scancode;
|
||||
@@ -215,7 +226,7 @@ int main(int argc,char*argv[]) {
|
||||
//for (int i=0;i<screen_surface->size;++i) pixels[i] = palette[screen_surface->p[i]];
|
||||
|
||||
SDL_UnlockTexture(mini_bak);
|
||||
SDL_SetRenderDrawColor(mini_ren, (palette[9] >> 16)&0xff, (palette[9] >> 8)&0xff, palette[9]&0xff, 0);
|
||||
SDL_SetRenderDrawColor(mini_ren, (palette[0] >> 16)&0xff, (palette[0] >> 8)&0xff, palette[0]&0xff, 0);
|
||||
//SDL_SetRenderDrawColor(mini_ren, 255, 0, 0, 0);
|
||||
SDL_RenderClear(mini_ren);
|
||||
SDL_Rect rect = {40, 40, 640, 480};
|
||||
@@ -410,6 +421,13 @@ uint8_t ascii(const char *str, uint8_t index) {
|
||||
return str[index];
|
||||
}
|
||||
|
||||
char chr_trans[2] = "X";
|
||||
const char* chr(uint8_t ascii) {
|
||||
uint8_t* peiv = (uint8_t*)chr_trans;
|
||||
*peiv = ascii;
|
||||
return chr_trans;
|
||||
}
|
||||
|
||||
void setchar(uint8_t index, uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5, uint8_t b6, uint8_t b7) {
|
||||
font[index*8] = b0;
|
||||
font[index*8+1] = b1;
|
||||
@@ -447,3 +465,8 @@ void setmode(const uint8_t mode) {
|
||||
current_mode = mode;
|
||||
reinit();
|
||||
}
|
||||
|
||||
void load(const char* str) {
|
||||
SDL_strlcpy(lua_filename, str, SDL_strlen(str)+1);
|
||||
should_reset = true;
|
||||
}
|
||||
Reference in New Issue
Block a user