diff --git a/data/ru_RU/settings/games.ini b/data/ru_RU/settings/games.ini index b22f2f2af4..2b3fed5fbd 100644 --- a/data/ru_RU/settings/games.ini +++ b/data/ru_RU/settings/games.ini @@ -16,6 +16,7 @@ Freecell=games/freecell,68 Pong=games/pong,101 Pong3=games/pong3,12 Arcanii=/kg/arcanii,12 +Dino=games/dino,129 [Аркады] LaserTank=/kg/lasertank/lasertank,72 diff --git a/programs/games/dino/Makefile b/programs/games/dino/Makefile index 04f7eb62aa..5a16486ded 100644 --- a/programs/games/dino/Makefile +++ b/programs/games/dino/Makefile @@ -7,7 +7,7 @@ KTCC = $(KTCC_DIR)/bin/kos32-tcc KPACK = kpack SRC = $(wildcard *.c) -FLAGS= -B$(KTCC_DIR)/bin -I $(KLIBC)/include -Wall -stack=20480 +FLAGS= -B$(KTCC_DIR)/bin -I $(KLIBC)/include -Wall# -stack=20480 LIBS = -limg all: $(SRC) diff --git a/programs/games/dino/config.h b/programs/games/dino/config.h index 2b6feea822..90402d2251 100644 --- a/programs/games/dino/config.h +++ b/programs/games/dino/config.h @@ -2,6 +2,7 @@ #define CONFIG_H #define DEFAULT_WIDTH 600 +#define DEFAULT_HEIGHT 200 #define FPS 60 #define DELTA_MS_DEFAULT 20 diff --git a/programs/games/dino/graphics.c b/programs/games/dino/graphics.c index 445bbac81b..be62114983 100644 --- a/programs/games/dino/graphics.c +++ b/programs/games/dino/graphics.c @@ -2,15 +2,12 @@ #include "sprites.h" #include -/*static*/ ksys_colors_table_t sys_color_table; -/*static*/ ksys_pos_t win_pos; -/*static*/ Image* screenImage; -/*static*/ Image* spriteAtlas; + +Image* screenImage; +static Image* spriteAtlas; void graphicsInit() { - win_pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS); - _ksys_get_system_colors(&sys_color_table); spriteAtlas = img_decode((void*)sprites100, sizeof(sprites100), 0); *((uint8_t*)spriteAtlas->Palette + 3) = 0; // set black as transparent // for (int i = 0; i < 16; i++) { @@ -24,23 +21,12 @@ void graphicsInit() { } } dbg_printf("spriteAtlas->Type = %d\n", spriteAtlas->Type); - screenImage = img_create(DEFAULT_WIDTH, 200, IMAGE_BPP32); + screenImage = img_create(DEFAULT_WIDTH, DEFAULT_HEIGHT, IMAGE_BPP32); // asm_inline("emms"); // doenst need bec. libimg functions used here does not use mmx (=> does not currept fpu state) } -// void save_fpu_state(void *fpustate) { -// __asm__("fsave %0" : "=m" (*fpustate) : : "memory"); -// } - -// void restore_fpu_state(const void *fpustate) { -// __asm__("fnsave %0" : : "m" (*fpustate)); -// } - - void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, int h, bool center) { // dbg_printf("start graphicsBlitAtlasImage ax = %d ay = %d dx = %d dy = %d w = %d h = %d %x %x\n", atlasX, atlasY, destX, destY, w, h, screenImage, spriteAtlas); - - // asm_inline("int $3"); int screen_width = (int)screenImage->Width; int screen_height = (int)screenImage->Height; @@ -76,12 +62,6 @@ void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, //printf("start graphicsBlitAtlasImage ax = %d ay = %d dx = %d dy = %d w = %d h = %d %x %x\n\n", atlasX, atlasY, destX, destY, w, h, screenImage, spriteAtlas); - // asm_inline("int $3"); - /*unsigned char buf[512]; - save_fpu_state(buf); - img_blend(screenImage, spriteAtlas, destX, destY, atlasX, atlasY, w, h); - restore_fpu_state(buf);*/ - img_blend(screenImage, spriteAtlas, destX, destY, atlasX, atlasY, w, h); asm_inline("emms"); @@ -94,13 +74,7 @@ void graphicsFillBackground(unsigned r, unsigned g, unsigned b) { void graphicsRender() { // don't redraw window on each frame. redraw window only when redraw event (called when widow moved e.g.) - //_ksys_start_draw(); - //_ksys_create_window(win_pos.x, win_pos.y, screenImage->Width + 10, screenImage->Height + 29, WINDOW_TITLE, sys_color_table.work_area, 0x54); // 0x54. note: C = 1 !! img_draw(screenImage, 5, 24, screenImage->Width, screenImage->Height, 0, 0); - //ksys_draw_bitmap_palette(screenImage->Data, 5, 24, screenImage->Width, screenImage->Height, 32, 0, 0); - // ksys_blitter_params_t bp = {5, 24, screenImage->Width, screenImage->Height, 0, 0, screenImage->Width, screenImage->Height, screenImage->Data, screenImage->Width*4}; - // _ksys_blitter(0, &bp); - //_ksys_end_draw(); } void graphicsDelay(int ms) { diff --git a/programs/games/dino/graphics.h b/programs/games/dino/graphics.h index b17dfba9d6..b57ec8293a 100644 --- a/programs/games/dino/graphics.h +++ b/programs/games/dino/graphics.h @@ -31,6 +31,8 @@ #define ATLAS_STAR_X 645 #define ATLAS_STAR_Y 2 +extern Image* screenImage; + void graphicsInit(); void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, int h, bool center); void graphicsFillBackground(unsigned r, unsigned g, unsigned b); diff --git a/programs/games/dino/main.c b/programs/games/dino/main.c index 6005bf2a28..b816b052a4 100644 --- a/programs/games/dino/main.c +++ b/programs/games/dino/main.c @@ -16,26 +16,29 @@ #include "trex.h" #include "runner.h" -uint8_t keyboard_layout[128]; - -extern ksys_colors_table_t sys_color_table; - extern ksys_pos_t win_pos; - extern Image* screenImage; - extern Image* spriteAtlas; +static uint8_t keyboard_layout[128]; int main(int argc, char* args[]) { srand((unsigned int)time(NULL)); // Seed the random number generator + ksys_pos_t win_pos = _ksys_screen_size(); + win_pos.x /= 2; + win_pos.x -= DEFAULT_WIDTH/2; + win_pos.y /= 2; + win_pos.y -= DEFAULT_HEIGHT/2; + dbg_printf("wx = %d, wy = %d\n", win_pos.x, win_pos.y); + ksys_colors_table_t sys_color_table; + _ksys_get_system_colors(&sys_color_table); + _ksys_set_event_mask(0xC0000027); // ! + _ksys_set_key_input_mode(KSYS_KEY_INPUT_MODE_SCANC); + _ksys_keyboard_layout(KSYS_KEYBOARD_LAYOUT_NORMAL, keyboard_layout); + graphicsInit(); runnerInit(); dbg_printf("dino started\n"); - _ksys_set_event_mask(0xC0000027); // ! - _ksys_set_key_input_mode(KSYS_KEY_INPUT_MODE_SCANC); - _ksys_keyboard_layout(KSYS_KEYBOARD_LAYOUT_NORMAL, keyboard_layout); - int ext_code = 0; uint8_t old_mode = 0;