X-Git-Url: http://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/47c27a4c712e6a1927656c69651354df40c3864a..5337261a68ea89b88624ca6fd7319cadd662e057:/badge/jumpnrun/level_load.c?ds=sidebyside diff --git a/badge/jumpnrun/level_load.c b/badge/jumpnrun/level_load.c index bf491f8..a386ecf 100644 --- a/badge/jumpnrun/level_load.c +++ b/badge/jumpnrun/level_load.c @@ -11,8 +11,8 @@ #include typedef struct { - uint8_t x; - uint16_t y; + uint16_t x; + uint8_t y; uint8_t type; } level_thing; @@ -20,7 +20,7 @@ static level_thing jumpnrun_level_parse_blob(unsigned char blob[3]) { level_thing result; result.y = blob[0] >> 4; - result.x = ((blob[0] & 0xf) << 8) | blob[1]; + result.x = ((blob[0] & 0x0f) << 8) | blob[1]; result.type = blob[2]; return result; @@ -100,6 +100,14 @@ int jumpnrun_load_level_from_file(jumpnrun_level *dest, FIL *fd) { dest->start_pos.y = FIXED_INT( spos[1] * JUMPNRUN_TILE_PIXEL_HEIGHT); } +#ifdef __linux__ + if(1 != fread(&dest->start_lives, 1, 1, fd)) { +#else + if(FR_OK != f_read(fd, &dest->start_lives, sizeof(dest->start_lives), &count) || count != sizeof(dest->start_lives)) { +#endif + return JUMPNRUN_LEVEL_LOAD_ERROR; + } + for(i = 0; i < dest->header.tile_count; ++i) { #ifdef __linux__ if(1 != fread(buf, 3, 1, fd)) {