Import blues from e32a1860

This commit is contained in:
Gregory Montoir 2018-07-08 22:39:28 +08:00
parent 191796a951
commit ef58debe84
7 changed files with 49 additions and 59 deletions

34
game.c
View File

@ -16,16 +16,16 @@ void update_input() {
}
void do_title_screen() {
// _timer_counter = 20;
const uint32_t timestamp = g_sys.get_timestamp() + 20 * 1000;
load_img("pres.sqz");
fade_in_palette();
do {
update_input();
// if (_timer_counter <= 0) {
// break;
// }
} while (g_sys.input.space == 0 && g_sys.input.quit == 0);
// timer_unk3();
if (g_sys.input.space || g_sys.input.quit) {
break;
}
} while (g_sys.get_timestamp() < timestamp);
play_sound(SOUND_0);
fade_out_palette();
g_sys.input.space = 0;
read_file("avtmag.sqv", g_res.avt_sqv);
@ -58,6 +58,7 @@ void do_select_player() {
do {
screen_unk4();
update_input();
const uint32_t timestamp = g_sys.get_timestamp();
switch (state) {
case 0:
screen_add_sprite(95, 155, animframe_0135[frame1]);
@ -87,7 +88,6 @@ void do_select_player() {
screen_vsync();
state = 1;
frame1 = frame2 = 1;
// _timer_counter = 20;
} else if (g_sys.input.direction & INPUT_DIRECTION_LEFT) {
g_sys.input.direction &= ~INPUT_DIRECTION_LEFT;
for (int i = 0; i < colors_count; ++i) {
@ -97,7 +97,6 @@ void do_select_player() {
screen_vsync();
state = 2;
frame1 = frame2 = 1;
// _timer_counter = 20;
}
break;
case 1:
@ -126,7 +125,6 @@ void do_select_player() {
screen_vsync();
state = 2;
frame1 = frame2 = 1;
// _timer_counter = 20;
} else if (g_sys.input.direction & INPUT_DIRECTION_LEFT) {
g_sys.input.direction &= ~INPUT_DIRECTION_LEFT;
for (int i = 0; i < colors_count; ++i) {
@ -138,7 +136,6 @@ void do_select_player() {
screen_vsync();
state = 0;
frame1 = frame2 = 1;
// _timer_counter = 20;
}
break;
case 2:
@ -164,7 +161,6 @@ void do_select_player() {
screen_vsync();
state = 0;
frame1 = frame2 = 1;
// _timer_counter = 20;
} else if (g_sys.input.direction & INPUT_DIRECTION_LEFT) {
g_sys.input.direction &= ~INPUT_DIRECTION_LEFT;
for (int i = 0; i < colors_count; ++i) {
@ -174,7 +170,6 @@ void do_select_player() {
screen_vsync();
state = 1;
frame1 = frame2 = 1;
// _timer_counter = 20;
}
break;
}
@ -203,14 +198,14 @@ void do_select_player() {
}
screen_flip();
screen_vsync();
screen_vsync();
screen_vsync();
const int diff = (timestamp + (1000 / 30)) - g_sys.get_timestamp();
g_sys.sleep(diff < 10 ? 10 : diff);
g_vars.screen_draw_offset ^= 0x2000;
screen_clear_sprites();
if (g_sys.input.space || g_vars.play_demo_flag) {
quit = 1;
}
} while (!quit && g_sys.input.quit == 0);
} while (!quit && !g_sys.input.quit);
}
static void do_inter_screen_helper(int a, int b, int c) {
@ -276,8 +271,13 @@ static void do_inter_screen() {
g_vars.screen_draw_offset = 0x2000;
screen_flip();
g_vars.screen_h = TILEMAP_SCREEN_H;
// _timer_counter = 4;
// while (_timer_counter != 0);
const uint32_t timestamp = g_sys.get_timestamp() + 4 * 1000;
do {
update_input();
if (g_sys.input.space || g_sys.input.quit) {
break;
}
} while (g_sys.get_timestamp() < timestamp);
fade_out_palette();
}

8
game.h
View File

@ -128,7 +128,7 @@ struct object_t {
int16_t tile012_xpos;
int8_t elevator_direction; // -1,1
const uint8_t *trigger3;
uint8_t unk4D;
uint8_t trigger3_num;
// int16_t unk4E;
int16_t unk50;
uint8_t data51; // health for obj39/40, horizontal direction for other objects
@ -191,7 +191,7 @@ struct vars_t {
struct object_t objects[MAX_OBJECTS];
int two_players_flag;
int vinyls_count;
uint16_t timer_counter3;
uint16_t level_loop_counter;
int triggers_counter;
int update_objects_counter;
struct sprite_t sprites_table[MAX_SPRITES];
@ -289,8 +289,8 @@ extern uint16_t triggers_get_next_tile_flags(int x, int y);
extern uint16_t triggers_get_tile_data(struct object_t *obj);
extern uint16_t triggers_get_next_tile_num(int x, int y);
extern void level_call_trigger_func(struct object_t *obj, int y);
extern void triggers_unk3(struct object_t *obj);
extern void triggers_update_tiles1(struct object_t *obj);
extern int16_t triggers_get_dy(struct object_t *obj);
extern void triggers_unk5(struct object_t *obj);
extern void triggers_update_tiles2(struct object_t *obj);
#endif /* GAME_H__ */

32
level.c
View File

@ -188,7 +188,7 @@ static void init_level() {
obj->tile0_flags = 0;
obj->tile012_xpos = 0;
obj->elevator_direction = -1;
obj->unk4D = 0;
obj->trigger3_num = 0;
obj->trigger3 = 0;
obj->unk50 = 0;
// obj->unk4E = 0;
@ -320,7 +320,7 @@ static void do_level_update_scrolling2() {
}
}
do_level_redraw_tilemap(g_vars.screen_tilemap_xorigin, g_vars.screen_tilemap_yorigin);
if ((g_vars.timer_counter3 & 3) == 0) {
if ((g_vars.level_loop_counter & 3) == 0) {
do_level_update_tiles_anim();
}
if (g_vars.screen_tilemap_size_w == 20) {
@ -495,7 +495,7 @@ static void do_level_add_sprite1_case2(struct object_t *obj) {
}
}
if (obj->anim_num < anim_data[0]) {
obj->anim_num += (g_vars.timer_counter3 & 1);
obj->anim_num += (g_vars.level_loop_counter & 1);
} else {
obj->anim_num = 1;
}
@ -616,7 +616,7 @@ static void do_level_add_sprite1(struct object_t *obj) {
break;
}
if (obj->type != 100) {
if (obj->blinking_counter != 0 && (g_vars.timer_counter3 & 1) != 0) {
if (obj->blinking_counter != 0 && (g_vars.level_loop_counter & 1) != 0) {
if (obj->facing_left == 0) {
screen_add_game_sprite3(obj->screen_xpos, obj->screen_ypos + 1, obj->anim_frame, obj->blinking_counter);
} else {
@ -676,7 +676,7 @@ static void do_level_add_sprite3(struct object_t *obj) {
} else if (obj->sprite3_counter == 1) {
if (obj->anim_num < anim_data[0]) {
if (obj->collide_flag == 0) {
obj->anim_num += (g_vars.timer_counter3 & 1);
obj->anim_num += (g_vars.level_loop_counter & 1);
}
obj->anim_frame = anim_data[obj->anim_num];
} else {
@ -698,7 +698,7 @@ static void do_level_add_sprite3(struct object_t *obj) {
}
}
if (obj->type != 100) {
if (obj->blinking_counter != 0 && (g_vars.timer_counter3 & 1) != 0) {
if (obj->blinking_counter != 0 && (g_vars.level_loop_counter & 1) != 0) {
if (obj->facing_left == 0) {
screen_add_game_sprite3(obj->screen_xpos, obj->screen_ypos + 1, obj->anim_frame, obj->blinking_counter);
} else {
@ -1175,10 +1175,10 @@ static void do_level_update_input(struct object_t *obj) {
return;
}
obj->xmaxvelocity = 48;
if (obj->unk4D == 0) {
triggers_unk3(obj);
if (obj->trigger3_num == 0) {
triggers_update_tiles1(obj);
} else {
triggers_unk5(obj);
triggers_update_tiles2(obj);
}
if (g_vars.inp_key_space != 0 && g_vars.inp_key_up != 0 && g_vars.inp_key_up_prev == 0 && !g_vars.player2_scrolling_flag) {
obj->carry_crate_flag = 1;
@ -2096,6 +2096,7 @@ void do_level() {
// _draw_last_sprite_flag = 0;
g_vars.found_music_instrument_flag = 0;
do {
const uint32_t timestamp = g_sys.get_timestamp();
update_input();
if (g_vars.inp_keyboard[0xBF] != 0) { // F5
play_sound(SOUND_0);
@ -2122,13 +2123,7 @@ void do_level() {
screen_redraw_sprites();
draw_foreground_tiles();
}
// if (_timer_counter != _timer_sync) {
// _timer_sync = _timer_counter;
// word_21DC7 = _timer_counter2;
// _timer_counter2 = 0;
// }
// ++_timer_counter2;
++g_vars.timer_counter3;
++g_vars.level_loop_counter;
if (1) { // (!_screen_panel_drawn_flag) {
draw_level_panel();
screen_unk6();
@ -2137,15 +2132,14 @@ void do_level() {
screen_flip();
g_vars.screen_draw_offset ^= 0x2000;
}
// while (_timer_sync_ptr[1] < 3);
const int diff = (timestamp + (1000 / 30)) - g_sys.get_timestamp();
g_sys.sleep(diff < 10 ? 10 : diff);
screen_clear_sprites();
// _draw_last_sprite_flag = 1;
// _timer_sync_ptr[1] = 0;
} while (g_sys.input.quit == 0 && !g_vars.quit_level_flag);
g_vars.screen_draw_offset -= TILEMAP_OFFSET_Y * 40;
screen_unk5();
g_vars.screen_draw_offset += TILEMAP_OFFSET_Y * 40;
if (g_options.amiga_copper_bars) {
g_sys.set_copper_bars(0);
}

View File

@ -154,8 +154,9 @@ static void object_func_op5(struct object_t *obj) {
obj->xmaxvelocity = 32;
}
// bird
static void object_func_op8(struct object_t *obj) {
if (triggers_get_tile_type(obj->xpos16 + 2 - obj->facing_left * 4, obj->ypos16) == 1) {
if (triggers_get_tile_type(obj->xpos16 + 2 - obj->facing_left * 4, obj->ypos16) != 1) {
obj->moving_direction ^= 1;
}
obj->direction_lr = obj->moving_direction + 1;

View File

@ -5,8 +5,6 @@
#include "sys.h"
#include "util.h"
#define HZ 30
void screen_init() {
for (int i = 0; i < MAX_SPRITES; ++i) {
g_vars.sprites[i] = &g_vars.sprites_table[i];
@ -85,7 +83,6 @@ void screen_draw_frame(const uint8_t *frame, int a, int b, int c, int d) {
void screen_flip() {
g_sys.update_screen(g_res.vga, 1);
g_sys.sleep(1000 / HZ);
}
void screen_unk4() {
@ -103,7 +100,6 @@ void screen_unk6() {
// screen_do_transition2();
// _screen_draw_offset += 12;
g_sys.update_screen(g_res.vga, 1);
g_sys.sleep(1000 / HZ); // get_time
memset(g_res.vga, 0, GAME_SCREEN_W * GAME_SCREEN_H);
}

View File

@ -53,9 +53,11 @@ static ModPlugFile *_mpf;
static void mix(void *param, uint8_t *buf, int len) {
memset(buf, 0, len);
if (_mpf) {
ModPlug_Read(_mpf, buf, len);
const int count = ModPlug_Read(_mpf, buf, len);
if (count == 0) {
ModPlug_SeekOrder(_mpf, 0);
}
}
if (_channel.data) {
for (int i = 0; i < len; i += sizeof(int16_t)) {

View File

@ -593,9 +593,6 @@ static void trigger_func_op40(struct object_t *obj) {
}
obj->unk2F = 0;
obj->special_anim = 21;
// if (_timer_counter != _timer_sync) {
// _timer_sync = _timer_counter;
// }
if (counter == 0) {
play_music(g_vars.music_num);
}
@ -739,7 +736,7 @@ void level_call_trigger_func(struct object_t *obj, int y) {
}
}
void triggers_unk3(struct object_t *obj) {
void triggers_update_tiles1(struct object_t *obj) {
struct object_t *obj35 = &g_vars.objects[35];
struct object_t *obj37 = &g_vars.objects[37];
if (obj->yvelocity >= 0 && obj->special_anim != 18) {
@ -765,7 +762,7 @@ void triggers_unk3(struct object_t *obj) {
obj->unk60 = p[9];
}
if (p[8] != 0) {
if (obj->data5F == g_vars.level + 1) { // instrument found
if (obj->data5F == g_vars.level + 1) { // music instrument must have been found to complete the level
if (obj->flag_end_level == 0) {
play_sound(SOUND_13);
obj->flag_end_level = 1;
@ -819,7 +816,7 @@ void triggers_unk3(struct object_t *obj) {
if (obj->special_anim == 21) {
play_sound(SOUND_8);
}
if (obj->data5F == 0 && p[7] != 0) { // music instrument found
if (obj->data5F == 0 && p[7] != 0) { // found music instrument
if (!g_vars.two_players_flag) {
obj->data5F = p[7];
} else {
@ -901,7 +898,7 @@ void triggers_unk3(struct object_t *obj) {
}
}
} else {
obj->unk4D = p[0];
obj->trigger3_num = p[0];
}
}
@ -911,14 +908,14 @@ int16_t triggers_get_dy(struct object_t *obj) {
return g_res.triggers[num].op_table1[obj->xpos & 15] - 1;
}
void triggers_unk5(struct object_t *obj) {
void triggers_update_tiles2(struct object_t *obj) {
int offset = 2;
int _si = offset;
const uint8_t *p = obj->trigger3;
if (p[1] < 10) {
int count = obj->unk4D - 1;
_si += (p[1] << 2) * count;
while ((p[1] << 2) > offset) {
const int num = obj->trigger3_num - 1;
_si += (p[1] << 2) * num;
while (offset < (p[1] << 2)) {
do_level_update_tile(p[_si], p[_si + 1], p[_si + 2]);
offset += 4;
_si += 4;
@ -936,5 +933,5 @@ void triggers_unk5(struct object_t *obj) {
obj->xmaxvelocity = ABS(obj->xvelocity);
do_level_player_hit(obj);
}
obj->unk4D = 0;
obj->trigger3_num = 0;
}