Import blues from 1ccaf07a
This commit is contained in:
parent
79f3e35872
commit
ce42eaa599
15
game.c
15
game.c
|
@ -15,6 +15,10 @@ static const uint16_t _colors_1a0_data[] = {
|
|||
0x1b0,0xbcf,0x1b2,0xfca,0x1b4,0x30a,0x1b6,0xa9a,0x1b8,0x900,0x1ba,0x666,0x1bc,0x747,0x1be,0x020
|
||||
};
|
||||
|
||||
static const uint8_t _colors_cga[] = {
|
||||
0x00, 0x00, 0x00, 0x55, 0xFF, 0xFF, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
struct vars_t g_vars;
|
||||
|
||||
void update_input() {
|
||||
|
@ -29,7 +33,7 @@ void update_input() {
|
|||
|
||||
void do_title_screen() {
|
||||
const uint32_t timestamp = g_sys.get_timestamp() + 20 * 1000;
|
||||
load_img(g_res.amiga_data ? "blues.lbm" : "pres.sqz", GAME_SCREEN_W);
|
||||
load_img(g_res.amiga_data ? "blues.lbm" : "pres.sqz", GAME_SCREEN_W, g_options.cga_colors ? 0 : -1);
|
||||
fade_in_palette();
|
||||
do {
|
||||
update_input();
|
||||
|
@ -50,7 +54,7 @@ void do_select_player() {
|
|||
int frame2 = 1;
|
||||
const int color_rgb = 2;
|
||||
const int colors_count = 25;
|
||||
load_img(g_res.amiga_data ? "choix.lbm" : "choix.sqz", GAME_SCREEN_W);
|
||||
load_img(g_res.amiga_data ? "choix.lbm" : "choix.sqz", GAME_SCREEN_W, g_options.cga_colors ? 1 : -1);
|
||||
screen_load_graphics();
|
||||
screen_clear_sprites();
|
||||
do {
|
||||
|
@ -215,8 +219,7 @@ static void do_inter_screen_helper(int xpos, int ypos, int c) {
|
|||
static void do_inter_screen() {
|
||||
static const uint8_t xpos[] = { 0xFA, 0x50, 0xF0, 0xC8, 0x50, 0x50 };
|
||||
static const uint8_t ypos[] = { 0xAA, 0x37, 0x28, 0x5F, 0xA5, 0xAA };
|
||||
load_img(g_res.amiga_data ? "inter.lbm" : "inter.sqz", GAME_SCREEN_W);
|
||||
g_vars.screen_draw_h = GAME_SCREEN_H - 1;
|
||||
load_img(g_res.amiga_data ? "inter.lbm" : "inter.sqz", GAME_SCREEN_W, g_options.cga_colors ? 9 : -1);
|
||||
screen_clear_sprites();
|
||||
if (g_vars.level > 1) {
|
||||
for (int i = 0; i < g_vars.level - 1; ++i) {
|
||||
|
@ -297,7 +300,9 @@ void game_main() {
|
|||
extern const uint8_t icon778e[]; // instrument level 5 (found)
|
||||
g_res.spr_frames[144] = icon778e;
|
||||
}
|
||||
if (g_options.amiga_colors) {
|
||||
if (g_options.cga_colors) {
|
||||
g_sys.set_screen_palette(_colors_cga, 4);
|
||||
} else if (g_options.amiga_colors) {
|
||||
uint16_t palette[16];
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
assert(_colors_1a0_data[i * 2] == 0x1a0 + i * 2);
|
||||
|
|
6
game.h
6
game.h
|
@ -49,6 +49,7 @@ struct options_t {
|
|||
bool amiga_colors;
|
||||
bool amiga_status_bar;
|
||||
bool dos_scrolling;
|
||||
bool cga_colors;
|
||||
};
|
||||
|
||||
extern struct options_t g_options;
|
||||
|
@ -155,8 +156,7 @@ struct vars_t {
|
|||
int screen_tilemap_xoffset, screen_tilemap_yoffset;
|
||||
int screen_tilemap_size_w, screen_tilemap_size_h;
|
||||
int screen_scrolling_dirmask;
|
||||
int screen_draw_h;
|
||||
int screen_tile_lut[256];
|
||||
uint16_t screen_tile_lut[128];
|
||||
bool level_completed_flag;
|
||||
bool play_level_flag;
|
||||
bool game_over_flag;
|
||||
|
@ -177,7 +177,7 @@ struct vars_t {
|
|||
bool inp_key_left;
|
||||
bool inp_key_up_prev;
|
||||
bool inp_key_down_prev;
|
||||
bool inp_key_action;
|
||||
bool inp_key_space_prev;
|
||||
struct door_t doors[MAX_DOORS];
|
||||
struct object_t objects[MAX_OBJECTS];
|
||||
int vinyls_count;
|
||||
|
|
102
level.c
102
level.c
|
@ -34,13 +34,14 @@ static const struct {
|
|||
const int16_t *xpos;
|
||||
const int16_t *ypos;
|
||||
uint8_t music;
|
||||
uint8_t cga_dither;
|
||||
} _levels[MAX_LEVELS] = {
|
||||
{ "mag.ck1", "mag.ck2", "mag.sql", "magasin.bin", "avtmag.sqv", "enemi1.sqv", level_xpos_magasin, level_ypos_magasin, 1 },
|
||||
{ "ent.ck1", "ent.ck2", "ent.sql", "entrepot.bin", "avtent.sqv", "enemi2.sqv", level_xpos_ent, level_ypos_ent, 2 },
|
||||
{ "prison.ck1", "prison.ck2", "prison.sql", "prison.bin", "avtpris.sqv", "enemi3.sqv", level_xpos_prison, level_ypos_prison, 3 },
|
||||
{ "egou.ck1", "egou.ck2", "egou.sql", "egou.bin", "avtegou.sqv", "enemi4.sqv", level_xpos_egou, level_ypos_egou, 1 },
|
||||
{ "ville.ck1", "ville.ck2", "ville.sql", "ville.bin", "avtville.sqv", "enemi5.sqv", level_xpos_ville, level_ypos_ville, 2 },
|
||||
{ "concert.ck1", "concert.ck2", "concert.sql", "concert.bin", "", "enemi6.sqv", level_xpos_concert, level_ypos_concert, 3 },
|
||||
{ "mag.ck1", "mag.ck2", "mag.sql", "magasin.bin", "avtmag.sqv", "enemi1.sqv", level_xpos_magasin, level_ypos_magasin, 1, 3 },
|
||||
{ "ent.ck1", "ent.ck2", "ent.sql", "entrepot.bin", "avtent.sqv", "enemi2.sqv", level_xpos_ent, level_ypos_ent, 2, 3 },
|
||||
{ "prison.ck1", "prison.ck2", "prison.sql", "prison.bin", "avtpris.sqv", "enemi3.sqv", level_xpos_prison, level_ypos_prison, 3, 5 },
|
||||
{ "egou.ck1", "egou.ck2", "egou.sql", "egou.bin", "avtegou.sqv", "enemi4.sqv", level_xpos_egou, level_ypos_egou, 1, 3 },
|
||||
{ "ville.ck1", "ville.ck2", "ville.sql", "ville.bin", "avtville.sqv", "enemi5.sqv", level_xpos_ville, level_ypos_ville, 2, 7 },
|
||||
{ "concert.ck1", "concert.ck2", "concert.sql", "concert.bin", "", "enemi6.sqv", level_xpos_concert, level_ypos_concert, 3, 8 },
|
||||
};
|
||||
|
||||
static const struct {
|
||||
|
@ -68,13 +69,14 @@ void load_level_data(int num) {
|
|||
// .avt
|
||||
load_spr(_levels_amiga[num].ennemi, g_res.tmp, SPRITES_COUNT);
|
||||
} else {
|
||||
const int dither_pattern = g_options.cga_colors ? _levels[num].cga_dither : -1;
|
||||
if (num == 0 && g_res.dos_demo) {
|
||||
load_ck("demomag.ck1", 0x6000);
|
||||
load_ck("demomag.ck2", 0x8000);
|
||||
load_ck("demomag.ck1", 0x6000, dither_pattern);
|
||||
load_ck("demomag.ck2", 0x8000, dither_pattern);
|
||||
load_sql("demomag.sql");
|
||||
} else {
|
||||
load_ck(_levels[num].ck1, 0x6000);
|
||||
load_ck(_levels[num].ck2, 0x8000);
|
||||
load_ck(_levels[num].ck1, 0x6000, dither_pattern);
|
||||
load_ck(_levels[num].ck2, 0x8000, dither_pattern);
|
||||
load_sql(_levels[num].sql);
|
||||
}
|
||||
load_bin(_levels[num].bin);
|
||||
|
@ -269,11 +271,7 @@ static void do_level_redraw_tilemap(int xpos, int ypos) {
|
|||
const uint8_t *ptr = lookup_sql(x, y + j);
|
||||
for (int i = 0; i < w; ++i) {
|
||||
const uint8_t num = *ptr++;
|
||||
if (num >= 128) {
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num - 128], 4, i, j);
|
||||
} else {
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num], 3, i, j);
|
||||
}
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num & 0x7F], num & 0x80, i, j);
|
||||
}
|
||||
}
|
||||
g_vars.screen_tilemap_size_w = w;
|
||||
|
@ -312,11 +310,7 @@ static void do_level_update_tiles_anim() {
|
|||
*ptr = num;
|
||||
t->unk16 = num;
|
||||
}
|
||||
if (num >= 128) {
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num - 128], 4, i, j);
|
||||
} else {
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num], 3, i, j);
|
||||
}
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num & 0x7F], num & 0x80, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -822,37 +816,7 @@ static void do_level_add_sprite3(struct object_t *obj) {
|
|||
void do_level_update_tile(int x, int y, int num) {
|
||||
uint8_t *ptr = lookup_sql(x, y);
|
||||
*ptr = num;
|
||||
|
||||
const int tile_xpos = g_vars.screen_tilemap_xorigin >> 4;
|
||||
const int tile_ypos = g_vars.screen_tilemap_yorigin >> 4;
|
||||
|
||||
const int w = (TILEMAP_SCREEN_W / 16) * 2;
|
||||
int _si = (x + tile_xpos) * 2 + g_vars.screen_tilemap_xoffset;
|
||||
if (_si > w - 2) {
|
||||
_si -= w;
|
||||
}
|
||||
const int h = (TILEMAP_SCREEN_H / 16) * 640;
|
||||
int _di = (y - tile_ypos) * 640 + g_vars.screen_tilemap_yoffset;
|
||||
if (_di > h - 640) {
|
||||
_di -= h;
|
||||
}
|
||||
if (tile_xpos > x) {
|
||||
return;
|
||||
}
|
||||
if (tile_xpos + (TILEMAP_SCREEN_W / 16) <= x) {
|
||||
return;
|
||||
}
|
||||
if (tile_ypos > y) {
|
||||
return;
|
||||
}
|
||||
if (tile_ypos + (TILEMAP_SCREEN_H / 16) <= y) {
|
||||
return;
|
||||
}
|
||||
if (num >= 128) {
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num - 128], 4, _si / 2, _di / 640);
|
||||
} else {
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num], 3, _si / 2, _di / 640);
|
||||
}
|
||||
screen_draw_tile(g_vars.screen_tile_lut[num & 0x7F], num & 0x80, x, y);
|
||||
}
|
||||
|
||||
static void do_level_reset_tiles(struct object_t *obj, int dy) {
|
||||
|
@ -1010,7 +974,6 @@ static void do_level_update_grabbed_object(struct object_t *obj) {
|
|||
void do_level_update_panel_lifes(struct object_t *obj) {
|
||||
struct object_t *obj39 = &g_vars.objects[OBJECT_NUM_PLAYER1];
|
||||
struct object_t *obj40 = &g_vars.objects[OBJECT_NUM_PLAYER2];
|
||||
g_vars.screen_draw_h = 172;
|
||||
if (!g_vars.two_players_flag) {
|
||||
static const uint16_t data[] = { 216, 232, 248, 264, 280, 296 };
|
||||
for (int i = 0; i < obj->data51; ++i) {
|
||||
|
@ -1059,11 +1022,9 @@ void do_level_update_panel_lifes(struct object_t *obj) {
|
|||
}
|
||||
}
|
||||
}
|
||||
g_vars.screen_draw_h = TILEMAP_SCREEN_H;
|
||||
}
|
||||
|
||||
static void do_level_update_panel_vinyls(struct object_t *obj) {
|
||||
g_vars.screen_draw_h = 172;
|
||||
if (obj->vinyls_count > 99) {
|
||||
obj->vinyls_count -= 100;
|
||||
if (!g_vars.two_players_flag && obj->data51 < 5) {
|
||||
|
@ -1085,12 +1046,10 @@ static void do_level_update_panel_vinyls(struct object_t *obj) {
|
|||
}
|
||||
g_vars.vinyls_count = obj->vinyls_count;
|
||||
}
|
||||
g_vars.screen_draw_h = TILEMAP_SCREEN_H;
|
||||
}
|
||||
|
||||
static void do_level_update_panel_2nd_player() {
|
||||
struct object_t *obj = &g_vars.objects[OBJECT_NUM_PLAYER2];
|
||||
g_vars.screen_draw_h = 172;
|
||||
if (obj->vinyls_count > 99) {
|
||||
obj->vinyls_count = 0;
|
||||
if (!g_vars.two_players_flag && obj->data51 < 5) {
|
||||
|
@ -1105,13 +1064,11 @@ static void do_level_update_panel_2nd_player() {
|
|||
screen_draw_number(obj->vinyls_count, 280, 163, 2);
|
||||
g_vars.vinyls_count = obj->vinyls_count;
|
||||
}
|
||||
g_vars.screen_draw_h = TILEMAP_SCREEN_H;
|
||||
}
|
||||
|
||||
static void draw_level_panel() {
|
||||
struct object_t *obj39 = &g_vars.objects[OBJECT_NUM_PLAYER1];
|
||||
struct object_t *obj40 = &g_vars.objects[OBJECT_NUM_PLAYER2];
|
||||
g_vars.screen_draw_h = 172;
|
||||
g_vars.vinyls_count = 0;
|
||||
if (!g_vars.two_players_flag) {
|
||||
screen_draw_frame(g_res.spr_frames[123], 12, 320, 0, -12);
|
||||
|
@ -1162,7 +1119,6 @@ static void draw_level_panel() {
|
|||
}
|
||||
}
|
||||
}
|
||||
g_vars.screen_draw_h = TILEMAP_SCREEN_H;
|
||||
}
|
||||
|
||||
void do_level_enter_door(struct object_t *obj) {
|
||||
|
@ -1246,27 +1202,27 @@ static void do_level_update_input(struct object_t *obj) {
|
|||
} else {
|
||||
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) {
|
||||
if (g_vars.inp_key_space && g_vars.inp_key_up && !g_vars.inp_key_up_prev && !g_vars.player2_scrolling_flag) {
|
||||
obj->carry_crate_flag = 1;
|
||||
do_level_enter_door(obj);
|
||||
g_vars.inp_key_action = g_vars.inp_key_space;
|
||||
g_vars.inp_key_space_prev = g_vars.inp_key_space;
|
||||
}
|
||||
if (g_vars.inp_key_space != g_vars.inp_key_action && g_vars.inp_key_up == 0) {
|
||||
if (g_vars.inp_key_space != 0) {
|
||||
if (g_vars.inp_key_space != g_vars.inp_key_space_prev && !g_vars.inp_key_up) {
|
||||
if (g_vars.inp_key_space) {
|
||||
obj->carry_crate_flag = 1;
|
||||
}
|
||||
g_vars.inp_key_action = g_vars.inp_key_space;
|
||||
g_vars.inp_key_space_prev = g_vars.inp_key_space;
|
||||
}
|
||||
if (g_vars.inp_key_right != 0) {
|
||||
if (g_vars.inp_key_right) {
|
||||
obj->direction_lr |= OBJECT_DIRECTION_RIGHT;
|
||||
}
|
||||
if (g_vars.inp_key_left != 0) {
|
||||
if (g_vars.inp_key_left) {
|
||||
obj->direction_lr |= OBJECT_DIRECTION_LEFT;
|
||||
}
|
||||
_si = triggers_get_tile_type(obj->xpos16, obj->ypos16);
|
||||
if (g_vars.inp_key_up != 0 && g_vars.inp_key_space == 0) {
|
||||
if (g_vars.inp_key_up && !g_vars.inp_key_space) {
|
||||
obj->direction_ud = OBJECT_DIRECTION_UP;
|
||||
if (g_vars.inp_key_up_prev == 0 && obj->sprite_type != 0) {
|
||||
if (!g_vars.inp_key_up_prev && obj->sprite_type != 0) {
|
||||
obj->yfriction = 0;
|
||||
_di = triggers_get_tile_type(obj->xpos16, obj->ypos16 - 2);
|
||||
if (_di == 10 && (_si == 0 || _si == 1)) {
|
||||
|
@ -1285,7 +1241,7 @@ static void do_level_update_input(struct object_t *obj) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (g_vars.inp_key_down != 0) {
|
||||
} else if (g_vars.inp_key_down) {
|
||||
obj->direction_ud = 2;
|
||||
if (!g_vars.inp_key_down_prev) {
|
||||
obj->unk2B = 1;
|
||||
|
@ -1622,7 +1578,6 @@ static void do_level_handle_object_bonus_collision(struct object_t *obj, struct
|
|||
|
||||
void do_level_player_hit(struct object_t *obj) {
|
||||
if (obj->blinking_counter == 0) {
|
||||
g_vars.screen_draw_h = 172;
|
||||
if (obj->data51 > 0 && (g_options.cheats & CHEATS_UNLIMITED_ENERGY) == 0) {
|
||||
--obj->data51;
|
||||
do_level_update_panel_lifes(obj);
|
||||
|
@ -1630,7 +1585,6 @@ void do_level_player_hit(struct object_t *obj) {
|
|||
if (obj->special_anim != 16) {
|
||||
obj->blinking_counter = 75;
|
||||
}
|
||||
g_vars.screen_draw_h = TILEMAP_SCREEN_H;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2127,7 +2081,7 @@ static void draw_foreground_tiles() {
|
|||
|
||||
void do_level() {
|
||||
static const int W = 320 / 16;
|
||||
for (int tile_num = 0; tile_num < 256; ++tile_num) {
|
||||
for (int tile_num = 0; tile_num < 128; ++tile_num) {
|
||||
g_vars.screen_tile_lut[tile_num] = (tile_num / W) * 640 + (tile_num % W);
|
||||
}
|
||||
g_vars.screen_tilemap_w = level_dim[g_vars.level * 2];
|
||||
|
@ -2142,7 +2096,8 @@ void do_level() {
|
|||
if (g_options.amiga_copper_bars) {
|
||||
g_sys.set_copper_bars(_copper_data + g_vars.level * 18);
|
||||
}
|
||||
if (g_options.amiga_colors) {
|
||||
if (g_options.cga_colors) {
|
||||
} else if (g_options.amiga_colors) {
|
||||
g_sys.set_palette_amiga(_colors_data + g_vars.level * 16, 0);
|
||||
}
|
||||
g_vars.inp_keyboard[0xB9] = 0; // SPACE
|
||||
|
@ -2152,7 +2107,6 @@ void do_level() {
|
|||
g_vars.level_completed_flag = 0;
|
||||
g_vars.quit_level_flag = 0;
|
||||
g_vars.player2_scrolling_flag = 0;
|
||||
g_vars.screen_draw_h = TILEMAP_SCREEN_H;
|
||||
g_vars.found_music_instrument_flag = 0;
|
||||
render_set_sprites_clipping_rect(0, TILEMAP_OFFSET_Y, TILEMAP_SCREEN_W, TILEMAP_SCREEN_H);
|
||||
bool screen_transition_flag = true;
|
||||
|
|
1
main.c
1
main.c
|
@ -37,6 +37,7 @@ int main(int argc, char *argv[]) {
|
|||
g_options.amiga_colors = true;
|
||||
// g_options.amiga_status_bar = true;
|
||||
g_options.dos_scrolling = false;
|
||||
// g_options.cga_colors = true;
|
||||
const char *data_path = DEFAULT_DATA_PATH;
|
||||
int scale_factor = DEFAULT_SCALE_FACTOR;
|
||||
const char *scale_filter = DEFAULT_SCALE_FILTER;
|
||||
|
|
89
resource.c
89
resource.c
|
@ -23,6 +23,11 @@ void res_init(int vga_size) {
|
|||
if (!g_res.avt_sqv) {
|
||||
print_error("Failed to allocate avt buffer, %d bytes", AVT_SQV_SIZE);
|
||||
}
|
||||
static const int CGA_SIZE = 160 * 200;
|
||||
g_res.cga = (uint8_t *)malloc(CGA_SIZE);
|
||||
if (!g_res.cga) {
|
||||
print_error("Failed to allocate cga buffer, %d bytes", CGA_SIZE);
|
||||
}
|
||||
const int tmp_size = 32000 + vga_size;
|
||||
g_res.tmp = (uint8_t *)malloc(tmp_size);
|
||||
if (!g_res.tmp) {
|
||||
|
@ -64,6 +69,8 @@ void res_fini() {
|
|||
g_res.avt_sqv = 0;
|
||||
free(g_res.tmp);
|
||||
g_res.tmp = 0;
|
||||
free(g_res.cga);
|
||||
g_res.cga = 0;
|
||||
free(g_res.vga);
|
||||
g_res.vga = 0;
|
||||
free(g_res.tiles);
|
||||
|
@ -88,6 +95,60 @@ int read_compressed_file(const char *filename, uint8_t *dst) {
|
|||
return unpack(filename, dst);
|
||||
}
|
||||
|
||||
extern const uint8_t dither_cga_table[];
|
||||
|
||||
static void dither_cga(int num, uint8_t *dst) {
|
||||
const uint8_t *_bx = dither_cga_table + num * 32;
|
||||
for (int i = 0; i < 256; ++i) { // even lines
|
||||
const uint8_t a = _bx[(i & 15) * 2]; // 0x20 | 0x10
|
||||
const uint8_t b = _bx[(i >> 4) * 2 + 1]; // 0x80 | 0x40
|
||||
const uint8_t tmp = ((b & 3) << 2) | (a & 3);
|
||||
dst[0x100 + i] = tmp << 4;
|
||||
dst[ i] = tmp;
|
||||
}
|
||||
for (int i = 0; i < 256; ++i) { // odd lines
|
||||
const uint8_t a = _bx[(i & 15) * 2 + 1]; // 0x20 | 0x10
|
||||
const uint8_t b = _bx[(i >> 4) * 2]; // 0x80 | 0x40
|
||||
const uint8_t tmp = ((b & 3) << 2) | (a & 3);
|
||||
dst[0x300 + i] = tmp << 4;
|
||||
dst[0x200 + i] = tmp;
|
||||
}
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
uint8_t mask = i;
|
||||
static const uint8_t lut[] = { 1, 0, 3, 2 };
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
dst[0x400 + lut[j]] = ((mask & 1) << 7) | ((mask & 2) << 2); // 0x80 | 0x08
|
||||
mask >>= 2;
|
||||
}
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_cga(const uint8_t *src, uint8_t *di, uint8_t *dither_temp) {
|
||||
for (int y = 0; y < 200; ++y) {
|
||||
for (int x = 0; x < 40; ++x) {
|
||||
int a = 0;
|
||||
int d = 0;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
const int b = src[i * 40] * 4;
|
||||
a |= READ_LE_UINT16(dither_temp + 0x400 + b) >> (3 - i);
|
||||
d |= READ_LE_UINT16(dither_temp + 0x402 + b) >> (3 - i);
|
||||
}
|
||||
const uint8_t *p = dither_temp + (y & 1) * 0x200;
|
||||
uint8_t _cl = p[a & 255] | p[0x100 + (a >> 8)];
|
||||
uint8_t _ch = p[d & 255] | p[0x100 + (d >> 8)];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
*di++ = _ch & 3; _ch >>= 2;
|
||||
}
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
*di++ = _cl & 3; _cl >>= 2;
|
||||
}
|
||||
++src;
|
||||
}
|
||||
src += 120;
|
||||
}
|
||||
}
|
||||
|
||||
static void decode_bitplane_scanline(const uint8_t *src, int depth, int w, uint8_t *dst) {
|
||||
const int plane_size = w / depth;
|
||||
for (int x = 0; x < plane_size; ++x) {
|
||||
|
@ -106,7 +167,7 @@ static void decode_bitplane_scanline(const uint8_t *src, int depth, int w, uint8
|
|||
}
|
||||
}
|
||||
|
||||
static void load_iff(const uint8_t *data, uint32_t size, uint8_t *dst, int dst_pitch) {
|
||||
static void load_iff(const uint8_t *data, uint32_t size, uint8_t *dst, int dst_pitch, int cga_dither_pattern) {
|
||||
print_debug(DBG_RESOURCE, "load_iff size %d", size);
|
||||
if (data && memcmp(data, "FORM", 4) == 0) {
|
||||
int offset = 12;
|
||||
|
@ -147,15 +208,19 @@ static void load_iff(const uint8_t *data, uint32_t size, uint8_t *dst, int dst_p
|
|||
while (i < len && offset < 32000) {
|
||||
int code = (int8_t)buf[i++];
|
||||
if (code != -128) {
|
||||
const int scanline_offset = offset % 160;
|
||||
if (code < 0) {
|
||||
code = 1 - code;
|
||||
memset(scanline + offset % 160, buf[i], code);
|
||||
memset(scanline + scanline_offset, buf[i], code);
|
||||
++i;
|
||||
} else {
|
||||
++code;
|
||||
memcpy(scanline + offset % 160, buf + i, code);
|
||||
memcpy(scanline + scanline_offset, buf + i, code);
|
||||
i += code;
|
||||
}
|
||||
if (!(cga_dither_pattern < 0)) {
|
||||
memcpy(g_res.cga + offset, scanline + scanline_offset, code);
|
||||
}
|
||||
offset += code;
|
||||
if ((offset % 160) == 0) {
|
||||
decode_bitplane_scanline(scanline, 4, 160, dst + y * dst_pitch);
|
||||
|
@ -169,6 +234,12 @@ static void load_iff(const uint8_t *data, uint32_t size, uint8_t *dst, int dst_p
|
|||
offset += 8 + len;
|
||||
}
|
||||
}
|
||||
if (!(cga_dither_pattern < 0)) {
|
||||
uint8_t dither_temp[2048];
|
||||
memset(dither_temp, 0, sizeof(dither_temp));
|
||||
dither_cga(cga_dither_pattern, dither_temp);
|
||||
copy_cga(g_res.cga, dst, dither_temp);
|
||||
}
|
||||
}
|
||||
|
||||
void load_avt(const char *filename, uint8_t *dst, int offset) {
|
||||
|
@ -237,7 +308,7 @@ void load_blk(const char *filename) {
|
|||
read_file(filename, g_res.tiles, 256 * 16 * 8);
|
||||
}
|
||||
|
||||
void load_ck(const char *filename, uint16_t offset) {
|
||||
void load_ck(const char *filename, uint16_t offset, int dither_pattern) {
|
||||
const int size = read_compressed_file(filename, g_res.tmp);
|
||||
switch (offset) {
|
||||
case 0x6000: // page3
|
||||
|
@ -250,11 +321,13 @@ void load_ck(const char *filename, uint16_t offset) {
|
|||
print_error("Unexpected offset 0x%x in load_ck()", offset);
|
||||
break;
|
||||
}
|
||||
load_iff(g_res.tmp, size, g_res.tiles + offset, 640);
|
||||
load_iff(g_res.tmp, size, g_res.tiles + offset, 640, dither_pattern);
|
||||
if (dither_pattern < 0) {
|
||||
g_sys.set_screen_palette(g_res.palette, 16);
|
||||
}
|
||||
}
|
||||
|
||||
void load_img(const char *filename, int screen_w) {
|
||||
void load_img(const char *filename, int screen_w, int dither_pattern) {
|
||||
int size;
|
||||
const char *ext = strrchr(filename, '.');
|
||||
if (ext && strcmp(ext + 1, "lbm") == 0) {
|
||||
|
@ -263,8 +336,10 @@ void load_img(const char *filename, int screen_w) {
|
|||
size = read_compressed_file(filename, g_res.tmp);
|
||||
}
|
||||
assert(size <= 32000);
|
||||
load_iff(g_res.tmp, size, g_res.tmp + 32000, screen_w);
|
||||
load_iff(g_res.tmp, size, g_res.tmp + 32000, screen_w, dither_pattern);
|
||||
if (dither_pattern < 0) {
|
||||
g_sys.set_screen_palette(g_res.palette, 16);
|
||||
}
|
||||
g_sys.update_screen(g_res.tmp + 32000, 0);
|
||||
memcpy(g_res.vga, g_res.tmp + 32000, g_res.vga_size);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ struct resource_data_t {
|
|||
const uint8_t *spr_frames[MAX_SPR_FRAMES];
|
||||
uint8_t palette[16 * 3];
|
||||
struct trigger_t triggers[MAX_TRIGGERS];
|
||||
uint8_t *cga;
|
||||
uint8_t *vga;
|
||||
int vga_size;
|
||||
uint8_t *tiles;
|
||||
|
@ -56,8 +57,8 @@ extern int read_compressed_file(const char *filename, uint8_t *dst);
|
|||
extern void load_avt(const char *filename, uint8_t *dst, int offset);
|
||||
extern void load_bin(const char *filename);
|
||||
extern void load_blk(const char *filename);
|
||||
extern void load_ck(const char *filename, uint16_t offset);
|
||||
extern void load_img(const char *filename, int screen_w);
|
||||
extern void load_ck(const char *filename, uint16_t offset, int dither_pattern);
|
||||
extern void load_img(const char *filename, int screen_w, int dither_pattern);
|
||||
extern void load_m(const char *filename);
|
||||
extern void load_spr(const char *filename, uint8_t *dst, int offset);
|
||||
extern void load_sqv(const char *filename, uint8_t *dst, int offset);
|
||||
|
|
4
screen.c
4
screen.c
|
@ -53,9 +53,11 @@ void fade_out_palette() {
|
|||
}
|
||||
|
||||
void screen_adjust_palette_color(int color, int b, int c) {
|
||||
if (!g_options.cga_colors) {
|
||||
g_res.palette[color * 3 + b] += c;
|
||||
screen_vsync();
|
||||
g_sys.set_screen_palette(g_res.palette, 16);
|
||||
}
|
||||
}
|
||||
|
||||
void screen_vsync() {
|
||||
|
@ -115,7 +117,7 @@ void screen_clear(int a) {
|
|||
|
||||
void screen_draw_tile(int tile, int type, int x, int y) {
|
||||
const uint8_t *src = g_res.tiles + tile * 16;
|
||||
if (type == 4) {
|
||||
if (type != 0) {
|
||||
src += 320;
|
||||
}
|
||||
x = g_vars.screen_tilemap_xoffset + x * 16;
|
||||
|
|
22
staticres.c
22
staticres.c
|
@ -1785,3 +1785,25 @@ const uint8_t icon778e[] = {
|
|||
0x86,0x5d,0x20,0x04,0x9a,0xbd,0x80,0x05,0x80,0x1d,0x80,0xe5,0xa1,0x5d,0x00,0x00,
|
||||
0x00,0x0c,0x00,0x10
|
||||
};
|
||||
const uint8_t dither_cga_table[] = {
|
||||
0x00,0x00,0x55,0x55,0xAA,0xAA,0xFF,0xFF,0xFF,0xFF,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,
|
||||
0x00,0x00,0x55,0x55,0xFF,0xFF,0xAA,0xAA,0x00,0x00,0x55,0x55,0xFF,0xFF,0xAA,0xAA,
|
||||
0x00,0x00,0xAA,0xAA,0x55,0x55,0x55,0x55,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xAA,0xAA,
|
||||
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x55,0x55,0xFF,0xFF,0xAA,0xAA,0xFF,0xFF,
|
||||
0x00,0x00,0xAA,0xAA,0x55,0x55,0x55,0x55,0x00,0x00,0xFF,0xFF,0xAA,0xAA,0xAA,0xAA,
|
||||
0x55,0x55,0x55,0x55,0x55,0x55,0x00,0x00,0xFF,0xFF,0xAA,0x00,0x55,0x55,0xFF,0xFF,
|
||||
0x00,0x00,0xAA,0xAA,0x55,0xAA,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xAA,0xAA,
|
||||
0x55,0x55,0x00,0x00,0xAA,0xAA,0x00,0x00,0x55,0x55,0xAA,0x00,0x00,0x00,0xFF,0xFF,
|
||||
0x00,0x00,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xAA,0xAA,
|
||||
0x55,0x55,0x00,0x00,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xAA,0xAA,0x00,0x00,0xFF,0xFF,
|
||||
0x00,0x00,0xAA,0xAA,0xFF,0xFF,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xAA,0xAA,
|
||||
0x55,0x55,0x00,0x00,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xAA,0xAA,0x00,0x00,0xFF,0xFF,
|
||||
0x00,0x00,0x00,0x00,0xAA,0xAA,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xAA,0xAA,
|
||||
0x55,0x55,0x00,0x00,0xAA,0xAA,0x00,0x00,0x55,0x55,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,
|
||||
0x00,0x00,0xFF,0xFF,0x00,0x00,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xAA,0xAA,
|
||||
0x55,0x55,0x55,0x55,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xAA,0xAA,0xAA,0xAA,0xFF,0xFF,
|
||||
0x00,0x00,0xAA,0xAA,0x55,0x55,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0x00,0x00,0xAA,0xAA,
|
||||
0x55,0x55,0xAA,0xAA,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0x55,0x55,0xFF,0xFF,0xFF,0xFF,
|
||||
0x00,0x00,0x00,0x00,0xAA,0xAA,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x55,0x55,
|
||||
0x55,0x55,0x00,0x00,0xAA,0xAA,0x00,0x00,0xFF,0xFF,0xAA,0xAA,0x55,0x55,0xFF,0xFF
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue