Import blues from 96ebdfce
This commit is contained in:
parent
3d297a0cfe
commit
098f6edea0
15
p2/level.c
15
p2/level.c
|
@ -1290,7 +1290,7 @@ static bool level_handle_bonuses_found(struct object_t *obj, struct level_bonus_
|
|||
level_add_object23_bonus(0, 0, 1);
|
||||
++g_vars.level_current_secrets_count;
|
||||
} else {
|
||||
static uint8_t draw_counter = 0;
|
||||
static uint16_t draw_counter = 0;
|
||||
const int diff = abs(g_vars.level_draw_counter - draw_counter);
|
||||
draw_counter = g_vars.level_draw_counter;
|
||||
if (diff < 6) {
|
||||
|
@ -1440,8 +1440,8 @@ static void level_update_monster_pos(struct object_t *obj, struct level_monster_
|
|||
uint8_t dl = level_get_tile(pos);
|
||||
uint8_t dh = level_get_tile(pos - 0x100);
|
||||
int x_vel = obj->data.m.x_velocity;
|
||||
if (x_vel != 0 && x_vel <= 1) {
|
||||
x_vel = -x_vel;
|
||||
if (x_vel != 0) {
|
||||
x_vel = (x_vel < 0) ? -1 : 1;
|
||||
}
|
||||
uint8_t al = level_get_tile(pos + x_vel - 0x100);
|
||||
al = g_res.level.tile_attributes0[al];
|
||||
|
@ -1762,8 +1762,8 @@ static void level_update_objects_decors() {
|
|||
platform->type8.y_velocity = 0;
|
||||
}
|
||||
platform->type8.y_delta = a;
|
||||
if (platform->flags & 0x40) {
|
||||
if (platform->type8.y_velocity != 0 && --platform->type8.counter == 0) {
|
||||
if (platform->flags & 0x40) { /* player on the platform */
|
||||
if (platform->type8.y_velocity != 0 || --platform->type8.counter == 0) {
|
||||
platform->type8.state = 1;
|
||||
platform->type8.y_velocity = 0;
|
||||
}
|
||||
|
@ -2681,7 +2681,7 @@ static void level_update_player_collision() {
|
|||
g_vars.current_bonus.spr_num = obj->spr_num;
|
||||
const int num = (obj->spr_num & 0x1FFF) - 53;
|
||||
obj->spr_num = 0xFFFF;
|
||||
if (num == 226) {
|
||||
if (num == 226) { /* end of level semaphore */
|
||||
if (g_vars.level_num == 2) {
|
||||
g_vars.level_num = 12;
|
||||
} else if (g_vars.level_num == 13) {
|
||||
|
@ -2752,12 +2752,14 @@ static void level_update_player_collision() {
|
|||
} else if (num <= 50) {
|
||||
play_sound(8);
|
||||
g_vars.player_utensils_mask |= 1 << (num - 45);
|
||||
if (num == 46) { /* lighter */
|
||||
for (int j = 0; j < MAX_LEVEL_ITEMS; ++j) {
|
||||
struct level_item_t *item = &g_res.level.items_tbl[j];
|
||||
if (item->spr_num == 278) { /* end of level semaphore */
|
||||
++item->spr_num;
|
||||
}
|
||||
}
|
||||
}
|
||||
level_clear_item(obj);
|
||||
} else if (num <= 64) { /* food */
|
||||
play_sound(4);
|
||||
|
@ -3427,6 +3429,7 @@ static void level_shake_screen() {
|
|||
++g_vars.shake_screen_counter;
|
||||
g_vars.shake_screen_voffset = g_vars.shake_screen_counter;
|
||||
}
|
||||
g_sys.shake_screen(0, g_vars.shake_screen_voffset);
|
||||
}
|
||||
|
||||
static void level_player_death_animation() {
|
||||
|
|
|
@ -467,7 +467,7 @@ static void monster_func1_type10(struct object_t *obj) {
|
|||
if (m->current_tick == 0) {
|
||||
obj->data.m.state = 3;
|
||||
obj->data.m.y_velocity = 0;
|
||||
obj->data.m.x_velocity >>= 15;
|
||||
obj->data.m.x_velocity = (obj->data.m.x_velocity < 0) ? -1 : 0;
|
||||
m->flags = 0x36;
|
||||
monster_change_next_anim(obj);
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ static void monster_func1_type10(struct object_t *obj) {
|
|||
}
|
||||
monster_reset(obj, m);
|
||||
} else if (state == 0xFF) {
|
||||
if ((m->flags & 1) != 0 || (obj->data.m.flags & 0x20) != 0 || g_vars.objects_tbl[1].y_pos >= obj->y_pos) {
|
||||
if ((m->flags & 1) != 0 && ((obj->data.m.flags & 0x20) != 0 || g_vars.objects_tbl[1].y_pos >= obj->y_pos)) {
|
||||
if (obj->data.m.y_velocity < 240) {
|
||||
obj->data.m.y_velocity += 15;
|
||||
}
|
||||
|
|
|
@ -205,7 +205,6 @@ void video_transition_open() {
|
|||
}
|
||||
|
||||
void video_load_sprites() {
|
||||
const uint16_t *sprite_offsets = (const uint16_t *)spr_size_tbl;
|
||||
struct sys_rect_t r[MAX_SPRITES];
|
||||
uint8_t *data = (uint8_t *)calloc(MAX_SPRITESHEET_W * MAX_SPRITESHEET_H, 1);
|
||||
if (data) {
|
||||
|
@ -223,17 +222,17 @@ void video_load_sprites() {
|
|||
/* demo is missing 7 (monster) sprites compared to full game */
|
||||
continue;
|
||||
}
|
||||
const int j = i;
|
||||
const int j = i * 2;
|
||||
|
||||
value = sprite_offsets[j] & 255;
|
||||
value = spr_size_tbl[j];
|
||||
value = (value >> 3) | ((value & 7) << 5);
|
||||
if ((value & 0xE0) != 0) {
|
||||
value &= ~0xE0;
|
||||
++value;
|
||||
}
|
||||
const int h = sprite_offsets[j] >> 8;
|
||||
const int h = spr_size_tbl[j + 1];
|
||||
const int w = value * 8;
|
||||
assert((sprite_offsets[j] & 255) == w);
|
||||
assert(spr_size_tbl[j] == w);
|
||||
const int size = (h * value) * 4;
|
||||
|
||||
if (current_x + w > MAX_SPRITESHEET_W) {
|
||||
|
|
1
sys.h
1
sys.h
|
@ -47,6 +47,7 @@ struct sys_t {
|
|||
void (*fade_in_palette)();
|
||||
void (*fade_out_palette)();
|
||||
void (*update_screen)(const uint8_t *p, int present);
|
||||
void (*shake_screen)(int dx, int dy);
|
||||
void (*transition_screen)(enum sys_transition_e type, bool open);
|
||||
void (*process_events)();
|
||||
void (*sleep)(int duration);
|
||||
|
|
21
sys_sdl2.c
21
sys_sdl2.c
|
@ -29,8 +29,8 @@ static struct sprite_t _sprites[MAX_SPRITES];
|
|||
static int _sprites_count;
|
||||
static SDL_Rect _sprites_cliprect;
|
||||
|
||||
static int _screen_w;
|
||||
static int _screen_h;
|
||||
static int _screen_w, _screen_h;
|
||||
static int _shake_dx, _shake_dy;
|
||||
static SDL_Window *_window;
|
||||
static SDL_Renderer *_renderer;
|
||||
static SDL_Texture *_texture;
|
||||
|
@ -308,8 +308,13 @@ static void sdl2_update_screen(const uint8_t *p, int present) {
|
|||
}
|
||||
SDL_UpdateTexture(_texture, 0, _screen_buffer, _screen_w * sizeof(uint32_t));
|
||||
if (present) {
|
||||
SDL_Rect r;
|
||||
r.x = _shake_dx;
|
||||
r.y = _shake_dy;
|
||||
r.w = _screen_w;
|
||||
r.h = _screen_h;
|
||||
SDL_RenderClear(_renderer);
|
||||
SDL_RenderCopy(_renderer, _texture, 0, 0);
|
||||
SDL_RenderCopy(_renderer, _texture, 0, &r);
|
||||
|
||||
// sprites
|
||||
SDL_RenderSetClipRect(_renderer, &_sprites_cliprect);
|
||||
|
@ -320,8 +325,8 @@ static void sdl2_update_screen(const uint8_t *p, int present) {
|
|||
continue;
|
||||
}
|
||||
SDL_Rect r;
|
||||
r.x = spr->x;
|
||||
r.y = spr->y;
|
||||
r.x = spr->x + _shake_dx;
|
||||
r.y = spr->y + _shake_dy;
|
||||
r.w = sheet->r[spr->num].w;
|
||||
r.h = sheet->r[spr->num].h;
|
||||
if (!spr->xflip) {
|
||||
|
@ -336,6 +341,11 @@ static void sdl2_update_screen(const uint8_t *p, int present) {
|
|||
}
|
||||
}
|
||||
|
||||
static void sdl2_shake_screen(int dx, int dy) {
|
||||
_shake_dx = dx;
|
||||
_shake_dy = dy;
|
||||
}
|
||||
|
||||
static void handle_keyevent(int keysym, bool keydown, struct input_t *input) {
|
||||
switch (keysym) {
|
||||
case SDLK_LEFT:
|
||||
|
@ -705,6 +715,7 @@ struct sys_t g_sys = {
|
|||
.fade_in_palette = sdl2_fade_in_palette,
|
||||
.fade_out_palette = sdl2_fade_out_palette,
|
||||
.update_screen = sdl2_update_screen,
|
||||
.shake_screen = sdl2_shake_screen,
|
||||
.transition_screen = sdl2_transition_screen,
|
||||
.process_events = sdl2_process_events,
|
||||
.sleep = sdl2_sleep,
|
||||
|
|
Loading…
Reference in New Issue