Commit before the BIG changes...

This commit is contained in:
2021-11-24 15:21:40 +01:00
parent 452a7d14f2
commit 160da08c3d
5 changed files with 165 additions and 81 deletions

View File

@@ -1,8 +1,17 @@
#include "mini.h"
#include <stdio.h>
#include <string.h>
#include "lua.h"
struct surface_t {
uint8_t *pointer;
uint16_t w, h;
uint32_t size_in_bytes;
};
#define swap(a, b) {auto tmp=a;a=b;b=tmp;}
char window_title[256];
#define SCREEN_WIDTH 160
#define SCREEN_HEIGHT 120
#define SCREEN_SIZE_BYTES SCREEN_WIDTH*SCREEN_HEIGHT
@@ -43,11 +52,15 @@ uint8_t tiles[TILES_SIZE_BYTES];
uint32_t palette[16] = { 0x1a1c2c00, 0x5d275d00, 0xb13e5300, 0xef7d5700, 0xffcd7500, 0xa7f07000, 0x38b76400, 0x25717900,
0x29366f00, 0x3b5dc900, 0x41a6f600, 0x73eff700, 0xf4f4f400, 0x94b0c200, 0x566c8600, 0x333c5700 };
const char base64[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char base64font[241] = "00@B@]0X__OnZDYK[G10:9BTDEG5j20@1h000RB:_]OBjW?odl]Wlil9_oTT__omT@@02:DA477ADid@Z=nm]_[g9a[]oIi?;a9m]_mBjGB[M]99o_][]e]M"
"_?A]c_[eiLGBZ]e]mZ]o]Z]mlW:O9IABdTdZ000hR00__H[7?iH]3Oih;1?mXm5GjhB3M]897o]H]5^Mhm1ZchM5>LhB2]eXm2]oXZ5mlh<gJbBBJbJP?0Zm";
uint16_t font[96];
char base64glyphs[193] = "/h/AqV/hhhh/GMYYMGz/t/eS33H477wsjjswY4IOPHEFFVVVAVAVAVIc+dJHMMM/h/qBgBgVqq+//eIUi/dJzhAAhzAAA/eM"
"AMShAAAQsjAAAwsjAAAeSzAAAcU3AAAEqRAAABVaiAAMezhAAAAAMAADH4wAASb2SAAMAttAQYcefACGOe+AAAVVAAAAbbAA";
const int debug_line_size = (SCREEN_WIDTH/4);
const int debug_num_lines = (SCREEN_HEIGHT/6);
const int debug_total_size = debug_line_size*debug_num_lines;
@@ -58,9 +71,30 @@ int debug_cursor = 0;
const Uint8 *keys;
Uint8 key_just_pressed = 0;
int mouse_x, mouse_y;
int mouse_x, mouse_y, mouse_wheel;
Uint32 mouse_buttons;
char* get_value(char* line) {
char* equal_character = strchr(line, '=');
if (equal_character == NULL) return NULL;
*equal_character = '\0';
return ++equal_character;
}
void read_ini() {
FILE *f = fopen("game.ini", "r");
char line[256];
if (f == NULL) return;
while (fgets(line, sizeof(line), f)) {
char *value = get_value(line);
if (value != NULL) {
//if (strcmp(value, "title") == 0)
}
}
fclose(f);
}
void reinit() {
ds::pen_color = 6;
ds::cam[0] = ds::cam[1] = 0;
@@ -111,6 +145,7 @@ int main(int argc,char*argv[]){
while(!exit) {
key_just_pressed = 0;
mouse_wheel = 0;
while(SDL_PollEvent(&mini_eve)) {
if (mini_eve.type == SDL_QUIT) { exit=true; break; }
if (mini_eve.type == SDL_KEYDOWN) {
@@ -131,6 +166,9 @@ int main(int argc,char*argv[]){
key_just_pressed = mini_eve.key.keysym.scancode;
}
}
if (mini_eve.type == SDL_MOUSEWHEEL) {
mouse_wheel = mini_eve.wheel.y;
}
}
keys = SDL_GetKeyboardState(NULL);
mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y);
@@ -608,6 +646,10 @@ int mouseY() {
return mouse_y;
}
int mouseWheel() {
return mouse_wheel;
}
bool mouseButton(uint8_t i) {
return mouse_buttons & SDL_BUTTON(i);
}
@@ -672,6 +714,10 @@ int rnd(int x) {
srand(x);
}*/
char tostr_tmp[256];
const char* tostr(int val) {
return SDL_itoa(val, tostr_tmp, 10);
}
void debug_one_line_up() {
for (int i=0; i<debug_total_size-debug_line_size;++i) debug_text[i] = debug_text[i+debug_line_size];