From a8950f5bebd39441b31e399a609c38b3698cc323 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Sun, 27 Feb 2022 07:27:01 +0800 Subject: [PATCH] Import blues from 235e98f2 --- p2/game.c | 62 +++++++++++++++++++++++++++-------- p2/game.h | 2 ++ p2/level.c | 88 +++++++++++++++++++++++++++++++++----------------- p2/monsters.c | 11 +++---- p2/staticres.c | 55 +++++++++++++++++++++++++++++++ sys.h | 1 - sys_sdl2.c | 5 +-- 7 files changed, 173 insertions(+), 51 deletions(-) diff --git a/p2/game.c b/p2/game.c index 1daa666..e5c1147 100644 --- a/p2/game.c +++ b/p2/game.c @@ -79,12 +79,12 @@ static void do_credits() { g_sys.update_screen(g_res.vga, 1); } -static void update_screen_img(const uint8_t *src) { +static void update_screen_img(const uint8_t *src, int present) { const int size = GAME_SCREEN_W * GAME_SCREEN_H; if (size < 64000) { return; } else if (size == 64000) { - g_sys.update_screen(src, 0); + g_sys.update_screen(src, present); } else { memset(g_res.vga, 0, size); const int y_offs = (GAME_SCREEN_H - 200) / 2; @@ -92,7 +92,7 @@ static void update_screen_img(const uint8_t *src) { for (int y = 0; y < 200; ++y) { memcpy(g_res.vga + (y_offs + y) * GAME_SCREEN_W + x_offs, src + y * 320, 320); } - g_sys.update_screen(g_res.vga, 0); + g_sys.update_screen(g_res.vga, present); } } @@ -100,7 +100,7 @@ static void do_titus_screen() { uint8_t *data = load_file("TITUS.SQZ"); if (data) { g_sys.set_screen_palette(data, 0, 256, 6); - update_screen_img(data + 768); + update_screen_img(data + 768, 0); g_sys.fade_in_palette(); wait_input(70); g_sys.fade_out_palette(); @@ -108,13 +108,48 @@ static void do_titus_screen() { } } +static bool fade_palettes(const uint8_t *target, uint8_t *current) { + bool flag = false; + for (int i = 0; i < 768; ++i) { + int al = current[i]; + const int bh = target[i] - al; + if (bh != 0) { + if (abs(bh) < 2) { + flag = true; + al = target[i]; + } else { + if (target[i] < al) { + al -= 2; + } else { + al += 2; + } + } + current[i] = al; + } + } + return flag; +} + static void do_present_screen() { uint8_t *data = load_file("PRESENT.SQZ"); if (data) { - g_sys.set_screen_palette(data, 0, 256, 6); - update_screen_img(data + 768); - g_sys.fade_in_palette(); - wait_input(700); + if (g_uncompressed_size == 65536 + 768) { /* demo version */ + g_sys.set_screen_palette(data, 0, 256, 6); + update_screen_img(data + 768, 0); + g_sys.fade_in_palette(); + } else { + memmove(data + 768, data + 0x1030 * 16, 93 * 320); + g_sys.set_screen_palette(data, 0, 256, 6); + update_screen_img(data + 768, 0); + g_sys.fade_in_palette(); + uint8_t palette[256 * 3]; + memcpy(palette, data, 256 * 3); + while (fade_palettes(present_palette_data, palette) && !g_sys.input.quit) { + g_sys.set_screen_palette(palette, 0, 256, 6); + update_screen_img(data + 768, 1); + wait_input(10); + } + } g_sys.fade_out_palette(); free(data); } @@ -131,7 +166,7 @@ static void do_demo_screen() { if (data) { video_copy_img(data); g_sys.set_screen_palette(joystick_palette_data, 0, 16, 6); - update_screen_img(g_res.background); + update_screen_img(g_res.background, 0); g_sys.fade_in_palette(); free(data); wait_input(1000); @@ -142,7 +177,7 @@ static void do_castle_screen() { uint8_t *data = load_file("CASTLE.SQZ"); if (data) { g_sys.set_screen_palette(data, 0, 256, 6); - update_screen_img(data + 768); + update_screen_img(data + 768, 0); g_sys.fade_in_palette(); free(data); wait_input(1000); @@ -153,7 +188,7 @@ static void do_menu() { uint8_t *data = load_file("MENU.SQZ"); if (data) { g_sys.set_screen_palette(data, 0, 256, 6); - update_screen_img(data + 768); + update_screen_img(data + 768, 0); g_sys.fade_in_palette(); free(data); memset(g_vars.input.keystate, 0, sizeof(g_vars.input.keystate)); @@ -193,7 +228,7 @@ void do_theend_screen() { uint8_t *data = load_file("THEEND.SQZ"); if (data) { g_sys.set_screen_palette(data, 0, 256, 6); - update_screen_img(data + 768); + update_screen_img(data + 768, 0); g_sys.fade_in_palette(); free(data); wait_input(1000); @@ -278,8 +313,9 @@ static void game_run(const char *data_path) { do_demo_screen(); } do_menu(); - if (g_sys.input.quit) + if (g_sys.input.quit) { break; + } } uint8_t level_num; do { diff --git a/p2/game.h b/p2/game.h index 70aac00..0a4c517 100644 --- a/p2/game.h +++ b/p2/game.h @@ -285,6 +285,8 @@ extern struct vars_t g_vars; extern const uint8_t *palettes_tbl[16]; extern const uint8_t credits_palette_data[16 * 3]; extern const uint8_t light_palette_data[16 * 3]; +extern const uint8_t present_palette_data[256 * 3]; +extern const uint8_t menu_palette_data[16 * 3]; extern const uint8_t spr_offs_tbl[922]; extern const uint8_t spr_size_tbl[922]; extern const uint16_t score_tbl[17]; diff --git a/p2/level.c b/p2/level.c index d6ec898..113b6d0 100644 --- a/p2/level.c +++ b/p2/level.c @@ -671,12 +671,12 @@ static void level_init_object_hit_from_xy_pos(int16_t x_pos, int16_t y_pos) { g_vars.current_hit_object = obj; } -static void level_update_tile_type_2() { +static void level_update_tile_type_2(bool tile_flag) { if (g_vars.level_num == 14) { g_vars.player_death_flag = 0xFF; return; } - if (g_options.cheats & CHEATS_NO_HIT) { + if (tile_flag && (g_options.cheats & CHEATS_NO_HIT) != 0) { return; } level_player_die(); @@ -866,7 +866,7 @@ static void level_update_tile0(uint16_t offset) { break; case 6: /* spikes */ - level_update_tile_type_2(); + level_update_tile_type_2(1); break; default: print_warning("Unhandled level_update_tile0 attr1 %d", attr1); @@ -888,7 +888,7 @@ static void level_update_tile0(uint16_t offset) { level_update_tile_attr2_type1(); break; case 2: - level_update_tile_type_2(); + level_update_tile_type_2(1); break; default: print_warning("Unhandled level_update_tile0 attr2 %d", al); @@ -948,7 +948,7 @@ static void level_update_tile1(uint16_t offset) { level_update_tile_type_1(offset); break; case 2: - level_update_tile_type_2(); + level_update_tile_type_2(1); break; default: print_warning("Unhandled level_update_tile1 type %d", type); @@ -962,7 +962,7 @@ static void level_update_tile2(uint16_t offset) { if (type == 2 || type == 4) { switch (type) { case 2: - level_update_tile_type_2(); + level_update_tile_type_2(1); break; default: print_warning("Unhandled level_update_tile2 type %d", type); @@ -991,6 +991,8 @@ static void level_reset() { g_vars.level_completed_flag = 0; g_vars.light.palette_flag1 = 0; g_vars.light.palette_flag2 = 0; + g_vars.player_flying_flag = 0; + g_vars.player_gravity_flag = 0; g_vars.objects_tbl[1].data.p.special_anim_num = 0; g_vars.tilemap.prev_x = _undefined; @@ -1422,7 +1424,7 @@ static void level_update_objects_axe() { static int level_get_tile_monster_offset(uint8_t tile_num, struct object_t *obj) { - const uint8_t attr = g_res.level.tile_attributes1[tile_num]; + const uint8_t attr = g_res.level.tile_attributes3[tile_num]; if ((attr & 0x30) == 0) { return attr; } @@ -1459,7 +1461,7 @@ static void level_update_monster_pos(struct object_t *obj, struct level_monster_ if (m->flags & 0x40) { monster_change_next_anim(obj); m->flags |= 0x80; - obj->data.m.y_velocity &= ~15; + obj->data.m.y_velocity = -16; obj->x_pos += obj->data.m.x_velocity >> 2; return; } @@ -2185,17 +2187,9 @@ static void level_update_player_anim_1(uint8_t al) { level_update_object_anim(p); } -static void level_update_player_anim_2(uint8_t al) { - if (g_vars.player_anim_0x40_flag != 0) { - level_update_player_anim_3_6_7(g_vars.objects_tbl[1].data.p.current_anim_num); - return; - } - if (g_vars.player_nojump_counter != 0) { - level_update_player_anim_0(al); - return; - } +static void level_update_player_anim_2_helper(uint8_t al) { g_vars.level_force_x_scroll_flag = 0; - uint8_t value = g_vars.player_anim2_counter; + const uint8_t value = g_vars.player_anim2_counter; ++g_vars.player_anim2_counter; if (value < 9) { static const int8_t y_tbl[] = { -65, -51, -35, -20, -10, -5, -2, -1, 0 }; @@ -2218,6 +2212,16 @@ static void level_update_player_anim_2(uint8_t al) { level_update_screen_x_velocity(); } +static void level_update_player_anim_2(uint8_t al) { + if (g_vars.player_anim_0x40_flag != 0) { + level_update_player_anim_3_6_7(g_vars.objects_tbl[1].data.p.current_anim_num); + } else if (g_vars.player_nojump_counter != 0) { + level_update_player_anim_0(al); + } else { + level_update_player_anim_2_helper(al); + } +} + static void level_update_player_club_power() { if (g_vars.player_club_powerup_duration <= 48) { g_vars.player_club_powerup_duration += 2; @@ -2263,6 +2267,19 @@ static void level_update_player_anim_8(uint8_t al) { level_update_object_anim(p); } +static void level_update_player_anim_34(uint8_t al) { + if (g_vars.player_unk_counter1 < 24) { + level_update_player_anim_2_helper(al); + } else { + g_vars.player_gravity_flag = 1; + g_vars.player_flying_counter = 24; + g_vars.objects_tbl[1].y_pos -= 3; + g_vars.player_unk_counter1 = 0; + level_update_screen_x_velocity(); + level_update_screen_x_velocity(); + } +} + static void level_update_player_decor() { const int y_pos = (g_vars.objects_tbl[1].y_pos >> 4) - 1; const int spr_num = g_vars.objects_tbl[1].spr_num & 0x1FFF; @@ -2276,15 +2293,15 @@ static void level_update_player_decor() { const int x_pos = g_vars.objects_tbl[1].x_pos >> 4; const int player_ypos_diff = abs((g_vars.objects_tbl[1].y_pos >> 4) - g_vars.tilemap.y); if (player_ypos_diff > (TILEMAP_SCREEN_H / 16)) { - level_update_tile_type_2(); + level_update_tile_type_2(0); } else { const int player_xpos_diff = abs((g_vars.objects_tbl[1].x_pos >> 4) - g_vars.tilemap.x); if (player_xpos_diff > (TILEMAP_SCREEN_W / 16)) { - level_update_tile_type_2(); + level_update_tile_type_2(0); } else if ((g_res.level.scrolling_mask & 4) != 0 && g_vars.objects_tbl[1].y_pos < (g_vars.tilemap.y << 4)) { - level_update_tile_type_2(); + level_update_tile_type_2(0); } else if (g_vars.objects_tbl[1].y_pos >= 0 && g_vars.objects_tbl[1].y_pos > ((g_vars.tilemap.h + 1) << 4)) { - level_update_tile_type_2(); + level_update_tile_type_2(0); } } g_vars.player_tile_flags = 0; @@ -2325,7 +2342,6 @@ static void level_update_player_flying() { return; } if (g_vars.player_gravity_flag != 0) { - g_vars.objects_tbl[1].spr_num &= 0x8000; const int x_vel = abs(g_vars.objects_tbl[1].x_velocity); int num = 48; if (x_vel < 64) { @@ -2337,7 +2353,7 @@ static void level_update_player_flying() { if (g_vars.player_flying_anim_index < 3) { num = 51 - g_vars.player_flying_anim_index; } - g_vars.objects_tbl[1].spr_num |= num; + g_vars.objects_tbl[1].spr_num = (g_vars.objects_tbl[1].spr_num & 0x8000) | num; } const uint8_t *p = &player_flying_anim_data[14]; if ((g_vars.input.key_up | g_vars.input.key_down) == 0 && g_vars.player_flying_anim_index != 3) { @@ -2365,8 +2381,8 @@ static void level_update_player_flying() { ++spr_num; } g_vars.objects_tbl[0].spr_num = spr_num; - g_vars.objects_tbl[0].x_pos += x_delta; - g_vars.objects_tbl[0].y_pos += (int8_t)p[5]; + g_vars.objects_tbl[0].x_pos = g_vars.objects_tbl[1].x_pos + x_delta; + g_vars.objects_tbl[0].y_pos = g_vars.objects_tbl[1].y_pos + (int8_t)p[5]; break; } } @@ -2453,8 +2469,8 @@ static void level_update_player() { ++g_vars.player_update_counter; } if (g_vars.player_flying_flag != 0) { - mask += 0x40; - if ((g_vars.player_flying_flag &= 1) != 0) { + al += 0x20; + if ((g_vars.player_gravity_flag &= 1) != 0) { if (g_vars.input.key_up) { if (g_vars.player_flying_anim_index == 6) { if (g_vars.objects_tbl[1].data.p.y_velocity > 16) { @@ -2491,7 +2507,7 @@ static void level_update_player() { } } else { if (g_vars.objects_tbl[1].data.p.y_velocity > 160) { - g_vars.player_flying_flag = 1; + g_vars.player_gravity_flag = 1; } } } @@ -2519,6 +2535,20 @@ static void level_update_player() { case 8: level_update_player_anim_8(al); break; + case 32: + case 35: + case 36: + case 37: + case 38: + case 39: + level_update_player_anim_5(al); + break; + case 33: + level_update_player_anim_1(al); + break; + case 34: + level_update_player_anim_34(al); + break; default: print_warning("Unhandled anim_lut %d mask %d", al, mask); break; diff --git a/p2/monsters.c b/p2/monsters.c index f111cc4..bac7a63 100644 --- a/p2/monsters.c +++ b/p2/monsters.c @@ -176,7 +176,7 @@ static void monster_func1_type3(struct object_t *obj) { } else if (state == 1) { monster_add_orb(m, 0, obj->y_pos - m->y_pos); const uint16_t pos = ((obj->y_pos >> 4) << 8) | (obj->x_pos >> 4); - const uint8_t tile_num = g_res.leveldat[pos]; + const uint8_t tile_num = level_get_tile(pos); if (g_res.level.tile_attributes1[tile_num] == 0) { return; } @@ -184,8 +184,7 @@ static void monster_func1_type3(struct object_t *obj) { obj->data.m.y_velocity = 0; obj->data.m.state = 2; m->flags |= 0x48; - const int dx = (g_vars.objects_tbl[1].x_pos >= obj->x_pos) ? 48 : -48; - obj->data.m.x_velocity = dx; + obj->data.m.x_velocity = (g_vars.objects_tbl[1].x_pos >= obj->x_pos) ? 48 : -48; monster_change_next_anim(obj); } else if (state == 2) { if (obj->x_pos < 0) { @@ -777,15 +776,15 @@ static bool monster_func2_type10(struct level_monster_t *m) { uint16_t pos = (bh << 8) | bl; for (int i = 0; i < 10 && pos >= 0x300; ++i, pos -= 0x100) { if (pos < (g_vars.tilemap.h << 8)) { - const uint8_t tile_num0 = g_res.leveldat[pos]; + const uint8_t tile_num0 = level_get_tile(pos); if (g_res.level.tile_attributes1[tile_num0] == 0) { continue; } - const uint8_t tile_num1 = g_res.leveldat[pos - 0x100]; + const uint8_t tile_num1 = level_get_tile(pos - 0x100); if (g_res.level.tile_attributes1[tile_num1] != 0) { continue; } - const uint8_t tile_num2 = g_res.leveldat[pos - 0x200]; + const uint8_t tile_num2 = level_get_tile(pos - 0x200); if (g_res.level.tile_attributes1[tile_num2] == 0) { obj->y_pos = (pos >> 8) << 4; obj->spr_num = m->spr_num; diff --git a/p2/staticres.c b/p2/staticres.c index 594b269..e42470e 100644 --- a/p2/staticres.c +++ b/p2/staticres.c @@ -83,6 +83,61 @@ const uint8_t light_palette_data[] = { 0x0C,0x12,0x00,0x00,0x00,0x00,0x15,0x18,0x00,0x0C,0x0C,0x00,0x0F,0x0F,0x06,0x12, 0x12,0x00,0x09,0x0C,0x00,0x0C,0x12,0x00,0x0F,0x18,0x00,0x12,0x1B,0x0F,0x15,0x1B }; +const uint8_t present_palette_data[] = { + 0x00,0x00,0x00,0x38,0x3F,0x2E,0x36,0x3A,0x24,0x35,0x35,0x1B,0x30,0x2A,0x14,0x2B, + 0x1F,0x0D,0x26,0x14,0x08,0x21,0x0A,0x03,0x1C,0x00,0x00,0x06,0x00,0x00,0x28,0x1C, + 0x14,0x0E,0x0C,0x0E,0x06,0x0A,0x0A,0x3A,0x12,0x20,0x3A,0x12,0x20,0x3A,0x12,0x20, + 0x28,0x00,0x08,0x3C,0x2C,0x10,0x34,0x20,0x00,0x38,0x30,0x28,0x3C,0x34,0x20,0x3C, + 0x38,0x28,0x3C,0x3C,0x30,0x2C,0x24,0x24,0x0C,0x10,0x04,0x10,0x18,0x08,0x14,0x20, + 0x0C,0x1C,0x28,0x1C,0x20,0x2C,0x20,0x24,0x34,0x24,0x2C,0x3C,0x2C,0x30,0x2C,0x28, + 0x00,0x00,0x00,0x3C,0x3C,0x3C,0x38,0x28,0x20,0x28,0x18,0x10,0x20,0x10,0x08,0x14, + 0x10,0x14,0x18,0x00,0x00,0x18,0x14,0x18,0x18,0x18,0x1C,0x20,0x20,0x1C,0x24,0x1C, + 0x1C,0x28,0x20,0x18,0x18,0x24,0x18,0x14,0x0C,0x14,0x38,0x38,0x38,0x28,0x28,0x28, + 0x14,0x0C,0x14,0x1C,0x0C,0x14,0x2E,0x24,0x1E,0x32,0x28,0x20,0x35,0x2E,0x25,0x35, + 0x2E,0x25,0x38,0x34,0x2C,0x14,0x0C,0x14,0x14,0x12,0x08,0x10,0x12,0x0A,0x00,0x00, + 0x00,0x38,0x34,0x2C,0x18,0x0C,0x10,0x14,0x10,0x14,0x14,0x10,0x14,0x14,0x0C,0x14, + 0x14,0x0C,0x14,0x14,0x10,0x14,0x00,0x0A,0x14,0x0E,0x06,0x10,0x06,0x00,0x00,0x06, + 0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00, + 0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00, + 0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x06, + 0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00, + 0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00, + 0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C, + 0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00, + 0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x21,0x0A,0x03,0x21,0x09,0x03,0x21,0x09,0x03, + 0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21, + 0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09, + 0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03,0x21,0x09,0x03, + 0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26, + 0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14, + 0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08, + 0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x26,0x14,0x08,0x2B,0x1F,0x0D,0x2B, + 0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E, + 0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D, + 0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x2B, + 0x1E,0x0D,0x2B,0x1E,0x0D,0x2B,0x1E,0x0D,0x30,0x2A,0x14,0x30,0x29,0x14,0x30,0x29, + 0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14, + 0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30, + 0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29,0x14,0x30,0x29, + 0x14,0x30,0x29,0x14,0x35,0x35,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B, + 0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35, + 0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34, + 0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B,0x35,0x34,0x1B, + 0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36, + 0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A, + 0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24, + 0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x36,0x3A,0x24,0x38,0x3F,0x2E,0x38, + 0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F, + 0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E, + 0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x38, + 0x3F,0x2E,0x38,0x3F,0x2E,0x38,0x3F,0x2E,0x3A,0x12,0x22,0x3A,0x12,0x22,0x3A,0x12, + 0x22,0x3A,0x12,0x22,0x3A,0x12,0x22,0x3A,0x12,0x22,0x3A,0x12,0x22,0x3F,0x3F,0x3F +}; +const uint8_t menu_palette_data[] = { + 0x08,0x10,0x1C,0x00,0x04,0x04,0x0C,0x14,0x20,0x10,0x18,0x20,0x38,0x30,0x08,0x38, + 0x30,0x08,0x38,0x30,0x08,0x38,0x30,0x08,0x34,0x20,0x14,0x34,0x20,0x14,0x34,0x20, + 0x14,0x34,0x20,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; const uint8_t spr_offs_tbl[] = { 0x14,0x24,0x10,0x23,0x0C,0x24,0x10,0x24,0x10,0x25,0x10,0x25,0x0F,0x24,0x10,0x23, 0x0F,0x23,0x0F,0x23,0x0C,0x23,0x10,0x26,0x14,0x1F,0x18,0x1F,0x10,0x1F,0x10,0x24, diff --git a/sys.h b/sys.h index f796f55..a3544af 100644 --- a/sys.h +++ b/sys.h @@ -18,7 +18,6 @@ struct input_t { uint8_t direction; bool quit; - bool escape; bool space; bool digit1, digit2, digit3; }; diff --git a/sys_sdl2.c b/sys_sdl2.c index 22e9f3b..3feb454 100644 --- a/sys_sdl2.c +++ b/sys_sdl2.c @@ -381,7 +381,9 @@ static void handle_keyevent(int keysym, bool keydown, struct input_t *input) { input->space = keydown; break; case SDLK_ESCAPE: - input->escape = keydown; + if (keydown) { + g_sys.input.quit = true; + } break; case SDLK_1: input->digit1 = keydown; @@ -436,7 +438,6 @@ static void handle_controllerbutton(int button, bool pressed, struct input_t *in input->space = pressed; break; case SDL_CONTROLLER_BUTTON_BACK: - input->escape = pressed; break; case SDL_CONTROLLER_BUTTON_START: break;