update dino, add to ru game center
This commit is contained in:
parent
cf354ec8d3
commit
cb733c6d1d
@ -16,6 +16,7 @@ Freecell=games/freecell,68
|
|||||||
Pong=games/pong,101
|
Pong=games/pong,101
|
||||||
Pong3=games/pong3,12
|
Pong3=games/pong3,12
|
||||||
Arcanii=/kg/arcanii,12
|
Arcanii=/kg/arcanii,12
|
||||||
|
Dino=games/dino,129
|
||||||
|
|
||||||
[€àª ¤ë]
|
[€àª ¤ë]
|
||||||
LaserTank=/kg/lasertank/lasertank,72
|
LaserTank=/kg/lasertank/lasertank,72
|
||||||
|
@ -7,7 +7,7 @@ KTCC = $(KTCC_DIR)/bin/kos32-tcc
|
|||||||
KPACK = kpack
|
KPACK = kpack
|
||||||
|
|
||||||
SRC = $(wildcard *.c)
|
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
|
LIBS = -limg
|
||||||
|
|
||||||
all: $(SRC)
|
all: $(SRC)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#define DEFAULT_WIDTH 600
|
#define DEFAULT_WIDTH 600
|
||||||
|
#define DEFAULT_HEIGHT 200
|
||||||
#define FPS 60
|
#define FPS 60
|
||||||
|
|
||||||
#define DELTA_MS_DEFAULT 20
|
#define DELTA_MS_DEFAULT 20
|
||||||
|
@ -2,15 +2,12 @@
|
|||||||
#include "sprites.h"
|
#include "sprites.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/*static*/ ksys_colors_table_t sys_color_table;
|
|
||||||
/*static*/ ksys_pos_t win_pos;
|
Image* screenImage;
|
||||||
/*static*/ Image* screenImage;
|
static Image* spriteAtlas;
|
||||||
/*static*/ Image* spriteAtlas;
|
|
||||||
|
|
||||||
|
|
||||||
void graphicsInit() {
|
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);
|
spriteAtlas = img_decode((void*)sprites100, sizeof(sprites100), 0);
|
||||||
*((uint8_t*)spriteAtlas->Palette + 3) = 0; // set black as transparent
|
*((uint8_t*)spriteAtlas->Palette + 3) = 0; // set black as transparent
|
||||||
// for (int i = 0; i < 16; i++) {
|
// for (int i = 0; i < 16; i++) {
|
||||||
@ -24,23 +21,12 @@ void graphicsInit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbg_printf("spriteAtlas->Type = %d\n", spriteAtlas->Type);
|
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)
|
// 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) {
|
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);
|
// 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_width = (int)screenImage->Width;
|
||||||
int screen_height = (int)screenImage->Height;
|
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);
|
//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);
|
img_blend(screenImage, spriteAtlas, destX, destY, atlasX, atlasY, w, h);
|
||||||
asm_inline("emms");
|
asm_inline("emms");
|
||||||
|
|
||||||
@ -94,13 +74,7 @@ void graphicsFillBackground(unsigned r, unsigned g, unsigned b) {
|
|||||||
|
|
||||||
void graphicsRender() {
|
void graphicsRender() {
|
||||||
// don't redraw window on each frame. redraw window only when redraw event (called when widow moved e.g.)
|
// 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);
|
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) {
|
void graphicsDelay(int ms) {
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#define ATLAS_STAR_X 645
|
#define ATLAS_STAR_X 645
|
||||||
#define ATLAS_STAR_Y 2
|
#define ATLAS_STAR_Y 2
|
||||||
|
|
||||||
|
extern Image* screenImage;
|
||||||
|
|
||||||
void graphicsInit();
|
void graphicsInit();
|
||||||
void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, int h, bool center);
|
void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, int h, bool center);
|
||||||
void graphicsFillBackground(unsigned r, unsigned g, unsigned b);
|
void graphicsFillBackground(unsigned r, unsigned g, unsigned b);
|
||||||
|
@ -16,26 +16,29 @@
|
|||||||
#include "trex.h"
|
#include "trex.h"
|
||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
|
|
||||||
uint8_t keyboard_layout[128];
|
static 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;
|
|
||||||
|
|
||||||
int main(int argc, char* args[]) {
|
int main(int argc, char* args[]) {
|
||||||
srand((unsigned int)time(NULL)); // Seed the random number generator
|
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();
|
graphicsInit();
|
||||||
|
|
||||||
runnerInit();
|
runnerInit();
|
||||||
|
|
||||||
dbg_printf("dino started\n");
|
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;
|
int ext_code = 0;
|
||||||
uint8_t old_mode = 0;
|
uint8_t old_mode = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user