From 8a8f84aa1768c52d1a0c9b8b8ebaeeb4d0206ba2 Mon Sep 17 00:00:00 2001 From: Wintermute Date: Sun, 13 Oct 2013 19:57:49 +0200 Subject: [PATCH 1/1] =?utf8?q?Kaninchen=20aus=20mock=20=C3=BCbernommen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- badge/init.c | 2 +- badge/jumpnrun/enemies.c | 14 ++++++++++++++ badge/jumpnrun/enemies.h | 1 + badge/jumpnrun/level_load.c | 34 ++++++++++++++++++++++++++++++++-- badge/main.c | 3 ++- 6 files changed, 51 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 58aaa5b..0abe529 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ DEBUGBUILD = FALSE # IDE Flags (Keeps various IDEs happy) ########################################################################## -OPTDEFINES = -D __NEWLIB__ -DHOB_REV2 +OPTDEFINES = -D __NEWLIB__ -DR0KET ########################################################################## # Project-specific files diff --git a/badge/init.c b/badge/init.c index bb49df1..cc4d044 100644 --- a/badge/init.c +++ b/badge/init.c @@ -13,7 +13,7 @@ static void badge_init_backlight(void) { SCB_CLKOUTCLKSEL = SCB_MAINCLKSEL_SOURCE_WDTOSC; SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_DISABLE; SCB_CLKOUTCLKUEN = SCB_CLKOUTCLKUEN_UPDATE; - SCB_CLKOUTCLKDIV = 30; + SCB_CLKOUTCLKDIV = 75; } void badge_init(void) { diff --git a/badge/jumpnrun/enemies.c b/badge/jumpnrun/enemies.c index ac5dd98..70461b6 100644 --- a/badge/jumpnrun/enemies.c +++ b/badge/jumpnrun/enemies.c @@ -20,6 +20,14 @@ static badge_sprite const anim_mushroom[] = { { 7, 7, (uint8_t const *) "\x04\xc3\xe7\xf3\x31\x10" } }; +static badge_sprite const anim_kaninchen[] = { + { 7, 5, (uint8_t const *) "\x60\x30\xbe\x31\x02" }, + { 7, 5, (uint8_t const *) "\x42\x30\xbe\x31\x01" }, + { 7, 5, (uint8_t const *) "\x42\x30\xae\x35\x01" }, + { 7, 5, (uint8_t const *) "\x60\x30\xae\x35\x02" }, + { 7, 5, (uint8_t const *) "\x60\x30\xbe\x31\x01" } +}; + void jumpnrun_process_enemy(jumpnrun_enemy *self, badge_framebuffer *fb, struct jumpnrun_game_state *state, @@ -134,5 +142,11 @@ jumpnrun_enemy_type const jumpnrun_enemy_type_data[JUMPNRUN_ENEMY_TYPE_COUNT] = enemy_collision_tiles_bounce_horiz, enemy_collision_player_jumpable, enemy_tick_cat + }, { + 9, ARRAY_SIZE(anim_kaninchen), anim_kaninchen, + { FIXED_POINT_I(0, -80), FIXED_POINT_I(0, 0) }, + enemy_collision_tiles_bounce_horiz, + enemy_collision_player_jumpable, + enemy_tick_cat } }; diff --git a/badge/jumpnrun/enemies.h b/badge/jumpnrun/enemies.h index 8277e69..cb88647 100644 --- a/badge/jumpnrun/enemies.h +++ b/badge/jumpnrun/enemies.h @@ -56,6 +56,7 @@ enum { enum { JUMPNRUN_ENEMY_TYPE_CAT, JUMPNRUN_ENEMY_TYPE_MUSHROOM, + JUMPNRUN_ENEMY_TYPE_KANINCHEN, JUMPNRUN_ENEMY_TYPE_COUNT }; diff --git a/badge/jumpnrun/level_load.c b/badge/jumpnrun/level_load.c index c2f9dfe..180b33d 100644 --- a/badge/jumpnrun/level_load.c +++ b/badge/jumpnrun/level_load.c @@ -3,7 +3,9 @@ #include "items.h" #include "enemies.h" +#ifndef __linux__ #include +#endif #include @@ -47,11 +49,19 @@ static void jumpnrun_level_make_enemy(jumpnrun_enemy *dest, level_thing thing) { dest->current_frame = 0; } +#ifdef __linux__ +int jumpnrun_load_level_header_from_file(jumpnrun_level *dest, FILE *fd) { +#else int jumpnrun_load_level_header_from_file(jumpnrun_level *dest, FIL *fd) { - uint16_t head[3]; UINT count; +#endif + uint16_t head[3]; +#ifdef __linux__ + if(1 != fread(&head, sizeof(head), 1, fd)) { +#else if(FR_OK != f_read(fd, head, sizeof(head), &count) || count != sizeof(head)) { +#endif return JUMPNRUN_LEVEL_LOAD_ERROR; } @@ -62,13 +72,21 @@ int jumpnrun_load_level_header_from_file(jumpnrun_level *dest, FIL *fd) { return JUMPNRUN_LEVEL_LOAD_OK; } +#ifdef __linux__ +int jumpnrun_load_level_from_file(jumpnrun_level *dest, FILE *fd) { +#else int jumpnrun_load_level_from_file(jumpnrun_level *dest, FIL *fd) { + UINT count; +#endif size_t i; unsigned char buf[3]; uint16_t spos[2]; - UINT count; +#ifdef __linux__ + if(1 != fread(spos, sizeof(spos), 1, fd)) { +#else if(FR_OK != f_read(fd, spos, sizeof(spos), &count) || count != sizeof(spos)) { +#endif return JUMPNRUN_LEVEL_LOAD_ERROR; } else { dest->start_pos.x = FIXED_POINT(spos[0] * JUMPNRUN_TILE_PIXEL_WIDTH , 0); @@ -76,7 +94,11 @@ int jumpnrun_load_level_from_file(jumpnrun_level *dest, FIL *fd) { } for(i = 0; i < dest->header.tile_count; ++i) { +#ifdef __linux__ + if(1 != fread(buf, 3, 1, fd)) { +#else if(FR_OK != f_read(fd, buf, sizeof(buf), &count) || count != sizeof(buf)) { +#endif return JUMPNRUN_LEVEL_LOAD_ERROR; } @@ -89,7 +111,11 @@ int jumpnrun_load_level_from_file(jumpnrun_level *dest, FIL *fd) { } for(i = 0; i < dest->header.item_count; ++i) { +#ifdef __linux__ + if(1 != fread(buf, 3, 1, fd)) { +#else if(FR_OK != f_read(fd, buf, sizeof(buf), &count) || count != sizeof(buf)) { +#endif return JUMPNRUN_LEVEL_LOAD_ERROR; } @@ -102,7 +128,11 @@ int jumpnrun_load_level_from_file(jumpnrun_level *dest, FIL *fd) { } for(i = 0; i < dest->header.enemy_count; ++i) { +#ifdef __linux__ + if(1 != fread(buf, 3, 1, fd)) { +#else if(FR_OK != f_read(fd, buf, sizeof(buf), &count) || count != sizeof(buf)) { +#endif return JUMPNRUN_LEVEL_LOAD_ERROR; } diff --git a/badge/main.c b/badge/main.c index 5f7fde3..93a243c 100644 --- a/badge/main.c +++ b/badge/main.c @@ -203,6 +203,7 @@ int main(void) badge_init(); #endif + /* for(uint8_t i = 1; ; ++i) { badge_framebuffer fb = { { { 0 } } }; @@ -216,7 +217,7 @@ int main(void) badge_framebuffer_flush(&fb); systickDelay(200); } - + */ { // f_mkfs(0, 1, 0); badge_framebuffer fb; -- 2.20.1