Import blues from a65b79d4
This commit is contained in:
parent
ff6fc76c05
commit
07e54eef74
38
ja/game.c
38
ja/game.c
|
@ -44,13 +44,13 @@ static void do_splash_screen() {
|
|||
}
|
||||
|
||||
static void scroll_screen_palette() {
|
||||
g_vars.level_time += 3;
|
||||
if (g_vars.level_time >= 90) {
|
||||
++g_vars.level_time;
|
||||
if (g_vars.level_time >= 30) {
|
||||
g_vars.level_time = 0;
|
||||
}
|
||||
const int count = 90 - g_vars.level_time;
|
||||
for (int i = 0; i < count; i += 3) {
|
||||
g_sys.set_palette_color(225 + i / 3, g_res.tmp + 225 * 3 + g_vars.level_time + i);
|
||||
const int count = 30 - g_vars.level_time;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
g_sys.set_palette_color(225 + i, g_res.tmp + (225 + g_vars.level_time + i) * 3);
|
||||
}
|
||||
g_sys.update_screen(g_res.vga, 1);
|
||||
}
|
||||
|
@ -99,17 +99,15 @@ static void do_select_screen() {
|
|||
if (g_sys.input.direction & INPUT_DIRECTION_RIGHT) {
|
||||
g_sys.input.direction &= ~INPUT_DIRECTION_RIGHT;
|
||||
++bl;
|
||||
bl &= 3;
|
||||
if (bl == 0) {
|
||||
bl = 1;
|
||||
if (bl > 2) {
|
||||
bl = 2;
|
||||
}
|
||||
}
|
||||
if (g_sys.input.direction & INPUT_DIRECTION_LEFT) {
|
||||
g_sys.input.direction &= ~INPUT_DIRECTION_LEFT;
|
||||
--bl;
|
||||
bl &= 3;
|
||||
if (bl == 0) {
|
||||
bl = 3;
|
||||
if (bl < 1) {
|
||||
bl = 1;
|
||||
}
|
||||
}
|
||||
bh ^= bl;
|
||||
|
@ -160,11 +158,14 @@ void do_level_number_screen() {
|
|||
fade_out_palette();
|
||||
}
|
||||
|
||||
static uint16_t get_password(uint16_t ax) {
|
||||
// ax = read(0xF000:0xFFFF, 16) // bios
|
||||
ax ^= 0xAA31;
|
||||
// rol ax, cpu_speed
|
||||
return ax;
|
||||
static uint16_t rol16(uint16_t x, int c) {
|
||||
return (x << c) | (x >> (16 - c));
|
||||
}
|
||||
|
||||
static uint16_t get_password(uint16_t x) {
|
||||
x ^= 0xaa31;
|
||||
x *= 0xb297;
|
||||
return rol16(x, 3);
|
||||
}
|
||||
|
||||
void do_level_password_screen() {
|
||||
|
@ -172,10 +173,7 @@ void do_level_password_screen() {
|
|||
uint16_t ax = get_password(g_vars.player * 50 + g_vars.level - 1);
|
||||
char str[5];
|
||||
for (int i = 0; i < 4; ++i, ax <<= 4) {
|
||||
static const uint8_t rev_bits[] = {
|
||||
0x0, 0x8, 0x4, 0xC, 0x2, 0xA, 0x6, 0xE, 0x1, 0x9, 0x5, 0xD, 0x3, 0xB, 0x7, 0xF
|
||||
};
|
||||
const uint8_t dx = rev_bits[(ax >> 15) & 15] + '0';
|
||||
const uint8_t dx = (ax >> 12) + '0';
|
||||
str[i] = (dx <= '9') ? dx : (dx + 7);
|
||||
}
|
||||
str[4] = 0;
|
||||
|
|
|
@ -169,7 +169,7 @@ extern const uint8_t level_data1p[];
|
|||
extern const uint8_t level_data2p[];
|
||||
extern const uint8_t level_data3[];
|
||||
extern const uint8_t vscroll_offsets_table[];
|
||||
extern const uint16_t rot_tbl[];
|
||||
extern const uint16_t rotation_table[];
|
||||
extern const uint8_t bonus_spr_table[];
|
||||
extern const uint8_t tiles_5dc9_lut[];
|
||||
extern const uint8_t tiles_yoffset_table[];
|
||||
|
|
54
ja/level.c
54
ja/level.c
|
@ -1184,9 +1184,9 @@ static void level_update_object82_type0(struct object_t *obj) {
|
|||
const int state = object82_state(obj);
|
||||
if (state == 0) {
|
||||
const int angle = object82_counter(obj);
|
||||
const int16_t r1 = (60 * (int16_t)rot_tbl[angle + 65]) >> 8;
|
||||
const int16_t r1 = (60 * (int16_t)rotation_table[angle + 65]) >> 8;
|
||||
object82_hflip(obj) = r1 >> 8;
|
||||
const int16_t r2 = (60 * (int16_t)rot_tbl[angle]) >> 8;
|
||||
const int16_t r2 = (60 * (int16_t)rotation_table[angle]) >> 8;
|
||||
object82_counter(obj) += 2;
|
||||
const uint8_t *p = object82_type0_init_data(obj);
|
||||
obj->x_pos = r1 + READ_LE_UINT16(p);
|
||||
|
@ -1686,7 +1686,7 @@ static void level_update_triggers() {
|
|||
const int angle = obj[0].data[2].b[1];
|
||||
const int radius = obj[0].data[4].b[1];
|
||||
|
||||
ax = (radius * (int16_t)rot_tbl[angle + 65]) >> 8;
|
||||
ax = (radius * (int16_t)rotation_table[angle + 65]) >> 8;
|
||||
obj[0].x_pos += ax;
|
||||
ax >>= 1;
|
||||
dx = ax;
|
||||
|
@ -1696,7 +1696,7 @@ static void level_update_triggers() {
|
|||
obj[3].x_pos += ax;
|
||||
obj[1].x_pos += dx;
|
||||
|
||||
ax = (radius * (int16_t)rot_tbl[angle]) >> 8;
|
||||
ax = (radius * (int16_t)rotation_table[angle]) >> 8;
|
||||
obj[0].y_pos += ax;
|
||||
ax >>= 1;
|
||||
dx = ax;
|
||||
|
@ -2132,13 +2132,20 @@ static void init_panel(int x_offset) {
|
|||
}
|
||||
}
|
||||
|
||||
static void draw_panel_helper(int a) {
|
||||
static void draw_panel_vinyl(int offset, int spr, int x_offset) {
|
||||
const uint8_t *src = g_res.board + 0x1E00 + spr * 16;
|
||||
const int y_dst = (GAME_SCREEN_H - PANEL_H) + offset / 80;
|
||||
const int x_dst = (offset % 80) * 4 + 2 + x_offset;
|
||||
for (int y = 0; y < 16; ++y) {
|
||||
memcpy(g_res.vga + (y_dst + y) * GAME_SCREEN_W + x_dst, src, 16);
|
||||
src += 320;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_panel_energy(int di, int count, int x_offset) {
|
||||
static void draw_panel_energy(int offset, int count, int x_offset) {
|
||||
const uint8_t *src = g_res.board + 0x2840 + count * 40;
|
||||
const int y_dst = (GAME_SCREEN_H - PANEL_H) + di / 80;
|
||||
const int x_dst = (di % 80) * 4 + x_offset;
|
||||
const int y_dst = (GAME_SCREEN_H - PANEL_H) + offset / 80;
|
||||
const int x_dst = (offset % 80) * 4 + x_offset;
|
||||
for (int y = 0; y < 6; ++y) {
|
||||
memcpy(g_res.vga + (y_dst + y) * GAME_SCREEN_W + x_dst, src, 40);
|
||||
src += 320;
|
||||
|
@ -2185,7 +2192,7 @@ static void draw_panel() {
|
|||
++cl;
|
||||
}
|
||||
}
|
||||
draw_panel_helper((g_vars.level_loop_counter >> cl) & 3);
|
||||
draw_panel_vinyl(0x141, (g_vars.level_loop_counter >> cl) & 3, x_offset);
|
||||
}
|
||||
}
|
||||
if (g_vars.player != 0) {
|
||||
|
@ -2205,7 +2212,7 @@ static void draw_panel() {
|
|||
++cl;
|
||||
}
|
||||
}
|
||||
draw_panel_helper((g_vars.level_loop_counter >> cl) & 3);
|
||||
draw_panel_vinyl(0x16D, (g_vars.level_loop_counter >> cl) & 3, x_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2965,16 +2972,10 @@ static void init_level(uint16_t level) {
|
|||
g_vars.reset_palette_flag = 0;
|
||||
}
|
||||
|
||||
static bool start_level() {
|
||||
static uint16_t get_level() {
|
||||
const uint8_t *data = (g_vars.player == 2) ? level_data2p : level_data1p;
|
||||
const uint16_t level = READ_BE_UINT16(data + (g_vars.level - 1) * 2);
|
||||
if (level == 0xFFFF) {
|
||||
do_game_win_screen();
|
||||
return false;
|
||||
} else {
|
||||
init_level(level);
|
||||
return true;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
static bool change_level(bool first_level) {
|
||||
|
@ -2984,10 +2985,17 @@ static bool change_level(bool first_level) {
|
|||
if ((g_vars.level & 3) == 0 && g_vars.level < LEVELS_COUNT) {
|
||||
// do_level_password_screen();
|
||||
}
|
||||
do_level_number_screen();
|
||||
const int num = ((g_vars.level >> 3) & 3) + 1;
|
||||
play_music(num);
|
||||
return start_level();
|
||||
const uint16_t level = get_level();
|
||||
if (level == 0xFFFF) {
|
||||
do_game_win_screen();
|
||||
return false;
|
||||
} else {
|
||||
do_level_number_screen();
|
||||
const int num = ((g_vars.level >> 3) & 3) + 1;
|
||||
play_music(num);
|
||||
init_level(level);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void do_level() {
|
||||
|
@ -3021,7 +3029,7 @@ void do_level() {
|
|||
fade_out_palette();
|
||||
assert(g_vars.player != 2);
|
||||
if (g_vars.players_table[0].lifes_count != 0) {
|
||||
start_level();
|
||||
init_level(get_level()); // restart
|
||||
continue;
|
||||
}
|
||||
do_game_over_screen();
|
||||
|
|
|
@ -95,7 +95,7 @@ const uint8_t vscroll_offsets_table[] = {
|
|||
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
|
||||
0x10,0x10,0x10,0x10
|
||||
};
|
||||
const uint16_t rot_tbl[] = {
|
||||
const uint16_t rotation_table[] = {
|
||||
0xFF01,0xFF01,0xFF01,0xFF01,0xFF02,0xFF02,0xFF03,0xFF04,0xFF05,0xFF07,0xFF08,0xFF0A,0xFF0C,0xFF0D,0xFF0F,0xFF12,
|
||||
0xFF14,0xFF16,0xFF19,0xFF1C,0xFF1F,0xFF22,0xFF25,0xFF28,0xFF2C,0xFF2F,0xFF33,0xFF37,0xFF3B,0xFF3F,0xFF43,0xFF47,
|
||||
0xFF4B,0xFF50,0xFF55,0xFF59,0xFF5E,0xFF63,0xFF68,0xFF6D,0xFF72,0xFF78,0xFF7D,0xFF82,0xFF88,0xFF8D,0xFF93,0xFF99,
|
||||
|
|
Loading…
Reference in New Issue