Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
54484e6
Import vendored zip library for mod loading
Vagabond Sep 13, 2025
9677023
WIP
Vagabond Sep 14, 2025
d4928ea
Enumerate zip files in mod directories and their contents
Vagabond Sep 19, 2025
21127f2
Get background overrides working and make progress on sprites
Vagabond Sep 21, 2025
fb7cb59
Support loading sprites from mods
Vagabond Sep 21, 2025
afa945b
Support music mods
Vagabond Sep 22, 2025
ae15300
Support multiple music remixes co-existing
Vagabond Sep 22, 2025
6356348
Allow selection of the music source (originals/remixes/both)
Vagabond Sep 22, 2025
215695b
Support parsing bk/af animdata.ini and fighter header.ini from mods
Vagabond Sep 22, 2025
ecc61b3
Fix minizip build on Windows
Nopey Sep 23, 2025
775498b
Fix clang-tidy issue and a leak
Vagabond Sep 23, 2025
0dc42c6
Try to fix another clang-tidy issue in miniz
Vagabond Sep 23, 2025
77b8ebd
Handle "common" sprite loads and fix some naming to match wiki
Vagabond Sep 23, 2025
2c80b9a
Add fallback "common" loads for AF/BK animdata
Vagabond Sep 23, 2025
b8dbd2d
Switch to filename, not id lookups, fix sprite load bug
Vagabond Sep 23, 2025
173d42b
Remove unused var
Vagabond Sep 23, 2025
d91ef7f
Cleanup some leaks
Vagabond Sep 24, 2025
0846c04
Try to fix #1317
katajakasa Oct 9, 2025
dd43f7e
Improvements to mod loading
Vagabond Oct 6, 2025
a04d4cf
Sort mods by load order and dedup by version
Vagabond Oct 6, 2025
ddc5fc3
WIP on tournament support
Vagabond Oct 9, 2025
255de71
Fixes and clang-tidy issues
Vagabond Oct 10, 2025
f6e07d7
More tidy
Vagabond Oct 10, 2025
4360f52
Fix another leak
Vagabond Oct 10, 2025
3c31c48
Switch to omf_strncasecmp
Vagabond Oct 10, 2025
bea820e
Switch to omf_strcasecmp
Vagabond Oct 11, 2025
3420969
Constrain pilot photo select to PLAYERS.PIC
Vagabond Oct 11, 2025
cbffbf8
Support replacing PLAYER.pic portraits via mods
Vagabond Oct 12, 2025
64636ec
Allow larger sd_sprites by making len field u32
Vagabond Oct 14, 2025
a98e5c3
Support portrait width/height in ini files, load HAR palettes
Vagabond Oct 15, 2025
239b567
Allow for integer multiple sizes of assets (2x 4x etc) and pick best
Vagabond Jan 2, 2026
2ab7473
Better resolution rounding
Vagabond Feb 12, 2026
398968e
Fix the leaks
Vagabond Feb 13, 2026
5544ae6
fmt
Vagabond Feb 13, 2026
abd999f
Death to strcmp, all hail str_equal_c
Vagabond Feb 13, 2026
892b460
Tidy
Vagabond Feb 13, 2026
89b6e6e
Reorg headers, tidy and fmt
Vagabond Feb 13, 2026
5439c51
Prevent most mod assets loading during netplay
Vagabond Feb 13, 2026
45cb6a9
Some review comments
Vagabond Feb 13, 2026
5c31ddb
More review comments
Vagabond Feb 13, 2026
d0c9efb
More memory leak fixes from review
Vagabond Mar 28, 2026
c13290c
Parse hit coordinates and sprite origin from hitcoord.png
Vagabond Mar 30, 2026
60997d4
free -> omf_free
Vagabond Mar 30, 2026
fa9576e
add rb_free
Vagabond Mar 30, 2026
7c2df61
Fix signature of fallback function def
Vagabond Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get background overrides working and make progress on sprites
  • Loading branch information
Vagabond committed Feb 12, 2026
commit 21127f2538d5d15d184bf804610e61d99937903f
20 changes: 20 additions & 0 deletions src/formats/vga_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "formats/error.h"
#include "formats/vga_image.h"
#include "utils/allocator.h"
#include "utils/log.h"
#include "utils/png_reader.h"
#include "utils/png_writer.h"

Expand Down Expand Up @@ -72,6 +73,25 @@ int sd_vga_image_from_png(sd_vga_image *img, const path *filename) {
return SD_SUCCESS;
}

int sd_vga_image_from_png_in_memory(sd_vga_image *img, const unsigned char *buf, size_t len) {
int w = 0;
int h = 0;
// first do a read to figure out dimensions
if(!read_paletted_png_from_memory(buf, len, NULL, &w, &h)) {
return SD_FAILURE;
}
log_info("allocating png %dx%d", w, h);
if(sd_vga_image_create(img, w, h) != SD_SUCCESS) {
return SD_FAILURE;
}

if(!read_paletted_png_from_memory(buf, len, (unsigned char *)img->data, &w, &h)) {
return SD_FAILURE;
}

return SD_SUCCESS;
}

int sd_vga_image_to_png(const sd_vga_image *img, const vga_palette *pal, const path *filename) {
if(img == NULL || filename == NULL) {
return SD_INVALID_INPUT;
Expand Down
20 changes: 20 additions & 0 deletions src/formats/vga_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ int sd_vga_image_decode(sd_rgba_image *dst, const sd_vga_image *src, const vga_p
*/
int sd_vga_image_from_png(sd_vga_image *img, const path *filename);

/*! \brief Load an indexed image from a PNG file in memory.
*
* Loads an indexed (paletted) image from a PNG file.
*
* Note! The output vga image will be created here. If the image had been
* already created by using sd_vga_image_create() previously, there may
* potentially be a memory leak, since the old image internals will not be freed.
*
* \retval SD_INVALID_INPUT Image or filename was NULL
* \retval SD_FILE_INVALID_TYPE Input image was of invalid type.
* \retval SD_FORMAT_NOT_SUPPORTED File format (PNG) is not supported.
* \retval SD_SUCCESS Success.
*
* \param img Destination image pointer
* \param buf Source memory buffer
* \param len Source memory buffer length
*/

int sd_vga_image_from_png_in_memory(sd_vga_image *img, const unsigned char *buf, size_t len);

/*! \brief Save an indexed image from a PNG file.
*
* Saves an indexed (paletted) image to a PNG file. Maximum allowed image
Expand Down
3 changes: 2 additions & 1 deletion src/game/protos/scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ void scene_render_overlay(scene *scene) {
}

void scene_render(scene *scene) {
video_draw(&scene->bk_data->background, 0, 0);
// render potential high res asset with original dimensions
video_draw_size(&scene->bk_data->background, 0, 0, 320, 200);

if(scene->render != NULL) {
scene->render(scene);
Expand Down
2 changes: 1 addition & 1 deletion src/resources/af.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void af_create(af *a, void *src) {
for(int i = 0; i < 70; i++) {
if(sdaf->moves[i] != NULL) {
af_move *move = omf_calloc(1, sizeof(af_move));
af_move_create(move, &a->sprites, (void *)sdaf->moves[i], i);
af_move_create(a->id, move, &a->sprites, (void *)sdaf->moves[i], i);
array_set(&a->moves, i, move);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/resources/af_move.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "resources/af_move.h"
#include "formats/move.h"

void af_move_create(af_move *move, array *sprites, void *src, int id) {
void af_move_create(int file_id, af_move *move, array *sprites, void *src, int id) {
sd_move *sdmv = (sd_move *)src;
str_from_c(&move->move_string, sdmv->move_string);
str_from_c(&move->footer_string, sdmv->footer_string);
Expand All @@ -17,7 +17,7 @@ void af_move_create(af_move *move, array *sprites, void *src, int id) {
move->pos_constraints = sdmv->pos_constraint;
move->throw_duration = sdmv->throw_duration;
move->extra_string_selector = sdmv->extra_string_selector;
animation_create(&move->ani, sprites, sdmv->animation, id);
animation_create(AF_ANIMATION, file_id, &move->ani, sprites, sdmv->animation, id);
if(id == ANIM_JUMPING) {
// fixup the jump coordinates
animation_fixup_coordinates(&move->ani, 0, JUMP_COORD_ADJUSTMENT * -1);
Expand Down
2 changes: 1 addition & 1 deletion src/resources/af_move.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef struct af_move_t {
#endif
} af_move;

void af_move_create(af_move *move, array *sprites, void *src, int id);
void af_move_create(int file_id, af_move *move, array *sprites, void *src, int id);
void af_move_free(af_move *move);

#endif // AF_MOVE_H
3 changes: 2 additions & 1 deletion src/resources/animation.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ typedef struct sprite_reference_t {
sprite *sprite;
} sprite_reference;

void animation_create(animation *ani, array *sprites, void *src, int id) {
void animation_create(animation_source type, int file_id, animation *ani, array *sprites, void *src, int id) {
sd_animation *sdani = (sd_animation *)src;

// Copy simple stuff
Expand Down Expand Up @@ -49,6 +49,7 @@ void animation_create(animation *ani, array *sprites, void *src, int id) {
vector_append(&ani->sprites, &spr);
} else {
tmp_sprite = omf_calloc(1, sizeof(sprite));
// TODO check the mod overrides for a replacement sprite
sprite_create(tmp_sprite, (void *)sdani->sprites[i], i);
sprite_reference spr;
spr.sprite = tmp_sprite;
Expand Down
8 changes: 7 additions & 1 deletion src/resources/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
#include "utils/vec.h"
#include "utils/vector.h"

typedef enum
{
BK_ANIMATION,
AF_ANIMATION
} animation_source;

// All HARs have these predefined animations
enum
{
Expand Down Expand Up @@ -46,7 +52,7 @@ typedef struct animation_t {
vector sprites;
} animation;

void animation_create(animation *ani, array *sprites, void *src, int id);
void animation_create(animation_source type, int file_id, animation *ani, array *sprites, void *src, int id);
sprite *animation_get_sprite(animation *ani, int sprite_id);
void animation_free(animation *ani);

Expand Down
12 changes: 10 additions & 2 deletions src/resources/bk.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "formats/bk.h"
#include "resources/bk.h"
#include "resources/modmanager.h"
#include "utils/allocator.h"
#include "utils/log.h"
#include <string.h>

void bk_create(bk *b, void *src) {
Expand All @@ -10,7 +12,13 @@ void bk_create(bk *b, void *src) {
b->file_id = sdbk->file_id;

// Copy VGA image
surface_create_from_vga(&b->background, sdbk->background);
sd_vga_image *img;
if(modmanager_get_bk_background(b->file_id, &img)) {
log_info("using modified BK background");
surface_create_from_vga(&b->background, img);
} else {
surface_create_from_vga(&b->background, sdbk->background);
}

// Copy sound translation table
memcpy(b->sound_translation_table, sdbk->soundtable, 30);
Expand All @@ -31,7 +39,7 @@ void bk_create(bk *b, void *src) {
bk_info tmp_bk_info;
for(int i = 0; i < 50; i++) {
if(sdbk->anims[i] != NULL) {
bk_info_create(&tmp_bk_info, &b->sprites, (void *)sdbk->anims[i], i);
bk_info_create(b->file_id, &tmp_bk_info, &b->sprites, (void *)sdbk->anims[i], i);
hashmap_put_int(&b->infos, i, &tmp_bk_info, sizeof(bk_info));
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/resources/bk_info.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "resources/bk_info.h"
#include "formats/bkanim.h"

void bk_info_create(bk_info *info, array *sprites, void *src, int id) {
void bk_info_create(int file_id, bk_info *info, array *sprites, void *src, int id) {
sd_bk_anim *sdinfo = (sd_bk_anim *)src;
animation_create(&info->ani, sprites, sdinfo->animation, id);
animation_create(BK_ANIMATION, file_id, &info->ani, sprites, sdinfo->animation, id);
// TODO check for mod data here
info->chain_hit = sdinfo->chain_hit;
info->chain_no_hit = sdinfo->chain_no_hit;
info->load_on_start = sdinfo->load_on_start;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/bk_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct bk_info_t {
animation ani;
} bk_info;

void bk_info_create(bk_info *info, array *sprites, void *src, int id);
void bk_info_create(int file_id, bk_info *info, array *sprites, void *src, int id);
void bk_info_free(bk_info *info);

#endif // BK_INFO_H
63 changes: 61 additions & 2 deletions src/resources/modmanager.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "resources/modmanager.h"

#include "formats/chr.h"
#include "formats/error.h"
#include "game/utils/settings.h"
#include "resource_files.h"
#include "utils/allocator.h"
#include "utils/c_string_util.h"
#include "utils/log.h"
Expand All @@ -12,6 +10,8 @@
#include <stdio.h>
#include <string.h>

hashmap mod_resources;

int mod_find(list *mod_list) {
size_t size = 0;
path scan = get_system_mod_directory();
Expand All @@ -33,6 +33,8 @@ int mod_find(list *mod_list) {
}

bool modmanager_init(void) {

hashmap_create(&mod_resources);
list dir_list;
list_create(&dir_list);
mod_find(&dir_list);
Expand All @@ -48,11 +50,38 @@ bool modmanager_init(void) {
for(size_t i = 0; i < (size_t)entries; i++) {
if(zip_entry_openbyindex(zip, i) == 0 && zip_entry_isdir(zip) == 0) {
log_info("mod contains %s", zip_entry_name(zip));
str filename;
str_create(&filename);
str_from_c(&filename, zip_entry_name(zip));
// str_tolower(&filename);
unsigned long long entry_size = zip_entry_uncomp_size(zip);
void *entry_buf = omf_calloc(entry_size, 1);
if(zip_entry_noallocread(zip, entry_buf, entry_size) < 0) {
log_warn("failed to load %s into memory", zip_entry_name(zip));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue;

?

}

path path;
str fn, ext;
path_from_str(&path, &filename);
path_filename(&path, &fn);
path_ext(&path, &ext);

log_info("path %s has filename %s and extension %s", str_c(&filename), str_c(&fn), str_c(&ext));

if(strcmp("background.png", str_c(&fn)) == 0) {
// parse as background image
sd_vga_image img;
sd_vga_image_from_png_in_memory(&img, entry_buf, entry_size);

log_info("got vga image %dx%d with size %d", img.w, img.h, sizeof(img));

hashmap_put_str(&mod_resources, str_c(&filename), &img, sizeof(img));
} else if(strcmp(".png", str_c(&ext)) == 0) {
// parse as sprite
}

// TODO each filename should be a list
// TODO each filetype should be parsed (eg png to sprite, etc)
}
}
} else {
Expand All @@ -63,3 +92,33 @@ bool modmanager_init(void) {
list_free(&dir_list);
return true;
}

bool modmanager_get_bk_background(int file_id, sd_vga_image **img) {
str filename;
switch(file_id) {
case 8:
str_from_c(&filename, "arenas/arena0/background.png");
break;
case 16:
str_from_c(&filename, "arenas/arena1/background.png");
break;
case 32:
str_from_c(&filename, "arenas/arena2/background.png");
break;
case 64:
str_from_c(&filename, "arenas/arena3/background.png");
break;
case 128:
str_from_c(&filename, "arenas/arena4/background.png");
break;
default:
return false;
}

unsigned int len;
if(!hashmap_get_str(&mod_resources, str_c(&filename), (void **)img, &len)) {
log_info("got vga image %dx%d with size %d", (*img)->w, (*img)->h, len);
return true;
}
return false;
}
5 changes: 4 additions & 1 deletion src/resources/modmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
#define MODMANAGER_H

#include "formats/chr.h"
#include "utils/list.h"
#include "resource_files.h"
#include "utils/hashmap.h"

bool modmanager_init(void);

bool modmanager_get_bk_background(int file_id, sd_vga_image **img);

#endif // MODMANAGER_H
3 changes: 0 additions & 3 deletions src/resources/resource_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,3 @@ path get_user_mod_directory(void) {
}
return name;
}



Loading