better lighting
This commit is contained in:
parent
805a2713a3
commit
6ed4e17065
75 changed files with 6417 additions and 3667 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pxl8_ase.h"
|
||||
#include "pxl8_game.h"
|
||||
#include "pxl8_hal.h"
|
||||
#include "pxl8_log.h"
|
||||
|
|
@ -19,6 +20,7 @@
|
|||
#include "pxl8_script.h"
|
||||
#include "pxl8_sfx.h"
|
||||
#include "pxl8_sys.h"
|
||||
#include "pxl8_world.h"
|
||||
|
||||
struct pxl8 {
|
||||
pxl8_cart* cart;
|
||||
|
|
@ -83,6 +85,7 @@ static void pxl8_print_help(void) {
|
|||
printf("Other commands:\n");
|
||||
printf(" pxl8 pack <folder> <out.pxc> Pack folder into cart file\n");
|
||||
printf(" pxl8 bundle <in> <out> Bundle cart into executable\n");
|
||||
printf(" pxl8 remap-ase <in> <out> <palette> Remap ASE to palette by hue/lum\n");
|
||||
printf(" pxl8 help Show this help\n");
|
||||
}
|
||||
|
||||
|
|
@ -93,9 +96,11 @@ pxl8_result pxl8_init(pxl8* sys, i32 argc, char* argv[]) {
|
|||
const char* script_arg = NULL;
|
||||
bool bundle_mode = false;
|
||||
bool pack_mode = false;
|
||||
bool remap_palette_mode = false;
|
||||
bool run_mode = false;
|
||||
const char* pack_input = NULL;
|
||||
const char* pack_output = NULL;
|
||||
const char* remap_palette = NULL;
|
||||
|
||||
bool has_embedded = pxl8_cart_has_embedded(argv[0]);
|
||||
|
||||
|
|
@ -125,12 +130,22 @@ pxl8_result pxl8_init(pxl8* sys, i32 argc, char* argv[]) {
|
|||
pxl8_error("pack requires <folder> <output.pxc>");
|
||||
return PXL8_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
} else if (strcmp(argv[i], "remap-ase") == 0) {
|
||||
remap_palette_mode = true;
|
||||
if (i + 3 < argc) {
|
||||
pack_input = argv[++i];
|
||||
pack_output = argv[++i];
|
||||
remap_palette = argv[++i];
|
||||
} else {
|
||||
pxl8_error("remap-ase requires <input.ase> <output.ase> <palette.ase>");
|
||||
return PXL8_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
} else if (!script_arg) {
|
||||
script_arg = argv[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (!run_mode && !bundle_mode && !pack_mode) {
|
||||
if (!run_mode && !bundle_mode && !pack_mode && !remap_palette_mode) {
|
||||
run_mode = true;
|
||||
}
|
||||
|
||||
|
|
@ -151,6 +166,22 @@ pxl8_result pxl8_init(pxl8* sys, i32 argc, char* argv[]) {
|
|||
return result;
|
||||
}
|
||||
|
||||
if (remap_palette_mode) {
|
||||
u32 palette[256];
|
||||
u32 palette_count = 0;
|
||||
pxl8_result result = pxl8_ase_load_palette(remap_palette, palette, &palette_count);
|
||||
if (result != PXL8_OK) {
|
||||
pxl8_error("failed to load palette: %s", remap_palette);
|
||||
return result;
|
||||
}
|
||||
pxl8_ase_remap_config config = {
|
||||
.palette = palette,
|
||||
.palette_count = palette_count,
|
||||
.hue_tolerance = 0.08f
|
||||
};
|
||||
return pxl8_ase_remap(pack_input, pack_output, &config);
|
||||
}
|
||||
|
||||
pxl8_info("Starting up");
|
||||
|
||||
game->script = pxl8_script_create(game->repl_mode);
|
||||
|
|
@ -246,7 +277,8 @@ pxl8_result pxl8_init(pxl8* sys, i32 argc, char* argv[]) {
|
|||
pxl8_net_config net_cfg = { .address = "127.0.0.1", .port = 7777 };
|
||||
game->net = pxl8_net_create(&net_cfg);
|
||||
if (game->net) {
|
||||
pxl8_net_set_chunk_cache(game->net, pxl8_world_chunk_cache(game->world));
|
||||
pxl8_net_set_chunk_cache(game->net, pxl8_world_get_chunk_cache(game->world));
|
||||
pxl8_net_set_world(game->net, game->world);
|
||||
pxl8_net_connect(game->net);
|
||||
}
|
||||
|
||||
|
|
@ -280,6 +312,15 @@ pxl8_result pxl8_init(pxl8* sys, i32 argc, char* argv[]) {
|
|||
game->last_time = sys->hal->get_ticks();
|
||||
game->running = true;
|
||||
|
||||
#ifdef PXL8_ASYNC_THREADS
|
||||
if (game->net) {
|
||||
pxl8_net_start_thread(game->net);
|
||||
}
|
||||
if (game->world) {
|
||||
pxl8_world_start_sim_thread(game->world, game->net);
|
||||
}
|
||||
#endif
|
||||
|
||||
return PXL8_OK;
|
||||
}
|
||||
|
||||
|
|
@ -351,13 +392,27 @@ pxl8_result pxl8_update(pxl8* sys) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef PXL8_ASYNC_THREADS
|
||||
if (game->world && (pxl8_world_local_player(game->world))) {
|
||||
pxl8_input_msg msg = {0};
|
||||
msg.move_x = (pxl8_key_down(&game->input, "d") ? 1.0f : 0.0f) - (pxl8_key_down(&game->input, "a") ? 1.0f : 0.0f);
|
||||
msg.move_y = (pxl8_key_down(&game->input, "w") ? 1.0f : 0.0f) - (pxl8_key_down(&game->input, "s") ? 1.0f : 0.0f);
|
||||
msg.look_dx = (f32)pxl8_mouse_dx(&game->input);
|
||||
msg.look_dy = (f32)pxl8_mouse_dy(&game->input);
|
||||
msg.buttons = pxl8_key_down(&game->input, "space") ? 1 : 0;
|
||||
pxl8_world_push_input(game->world, &msg);
|
||||
}
|
||||
pxl8_net_update(game->net, dt);
|
||||
#else
|
||||
if (game->net) {
|
||||
while (pxl8_net_poll(game->net)) {}
|
||||
pxl8_net_update(game->net, dt);
|
||||
pxl8_world_sync(game->world, game->net);
|
||||
}
|
||||
|
||||
pxl8_world_update(game->world, dt);
|
||||
pxl8_world_update(game->world, &game->input, dt);
|
||||
#endif
|
||||
|
||||
pxl8_gfx_update(game->gfx, dt);
|
||||
pxl8_sfx_mixer_process(game->mixer);
|
||||
|
||||
|
|
@ -430,6 +485,15 @@ void pxl8_quit(pxl8* sys) {
|
|||
|
||||
pxl8_info("Shutting down");
|
||||
|
||||
#ifdef PXL8_ASYNC_THREADS
|
||||
if (game->world) {
|
||||
pxl8_world_stop_sim_thread(game->world);
|
||||
}
|
||||
if (game->net) {
|
||||
pxl8_net_stop_thread(game->net);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sys->cart) {
|
||||
pxl8_cart_unmount(sys->cart);
|
||||
}
|
||||
|
|
@ -499,6 +563,9 @@ void pxl8_set_relative_mouse_mode(pxl8* sys, bool enabled) {
|
|||
sys->hal->set_relative_mouse_mode(sys->platform_data, enabled);
|
||||
if (sys->game) {
|
||||
sys->game->input.mouse_relative_mode = enabled;
|
||||
#ifdef PXL8_ASYNC_THREADS
|
||||
pxl8_world_pause_sim(sys->game->world, !enabled);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue