Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting larger than 64kB #3

Closed
mateoconlechuga opened this issue Oct 9, 2017 · 3 comments
Closed

Exporting larger than 64kB #3

mateoconlechuga opened this issue Oct 9, 2017 · 3 comments

Comments

@mateoconlechuga
Copy link
Owner

This would entail splitting a large input file into multiple appvars; which the main program would then combine into a singular entity.

@mateoconlechuga
Copy link
Owner Author

Didn't I do this lol

@adriweb
Copy link
Collaborator

adriweb commented Jun 7, 2020

Well, I guess convbin dropped that feature :( Are you able to add it back?
I'd need this for lua, and someone else needs that too: https://tiplanet.org/forum/viewtopic.php?f=12&t=23915

Thanks :)

For reference, here's what the old code looked like:

convbin/main.c

Lines 657 to 721 in aa7fe58

if (offset > max_var_size) {
if (name_length == 8) {
fprintf(stderr, "[error] output name too long for size.\n");
exit(1);
}
unsigned int num_appvars = (offset / max_var_size) + 1;
unsigned int pos = 0;
unsigned int len = max_var_size;
if (num_appvars * max_var_size > MAX_TOTAL_SIZE) {
fprintf(stderr, "[error] input data too large to even split.\n"
"please reduce your program size!\n");
exit(1);
}
if (data[0] == 0xEF && data[1] == 0x7B && var_type == TYPE_PRGM) {
pos = 2;
len -= 2;
}
fprintf(stdout, "input data too large (%u bytes); splitting across %u variable(s).\n", offset, num_appvars);
fprintf(stdout, "--------------------\n");
uint8_t *appvar_info = calloc(0x10000, 1);
unsigned int appvar_info_pos = sizeof asm_large_extractor;
unsigned int i;
w24(r24(&asm_large_extractor[L_SIZE]) + (num_appvars * 11) + 2, &asm_large_extractor[L_SIZE]);
memcpy(appvar_info, asm_large_extractor, appvar_info_pos);
for (i = 0; i < num_appvars; i++) {
char *file_name, *appvar_name;
char tmpbuf[10];
sprintf(tmpbuf, "appvar%u_", i);
file_name = str_dupcat(tmpbuf, out_name);
file_name[strlen(file_name)-1] = 'v';
sprintf(tmpbuf, "%u", i);
appvar_name = str_dupcat(var_name, tmpbuf);
export(appvar_name, file_name, data + pos, len, TYPE_APPVAR, ARCHIVED);
appvar_info[appvar_info_pos] = 0x15;
memcpy(&appvar_info[appvar_info_pos+1], appvar_name, strlen(appvar_name));
appvar_info_pos += 11;
free(file_name);
free(appvar_name);
pos += len;
offset -= len;
if (offset > max_var_size) {
len = max_var_size;
} else {
len = offset;
}
}
if (var_type == TYPE_PRGM) {
appvar_info[appvar_info_pos] = 0x15; appvar_info_pos += 2;
export(var_name, out_name, appvar_info, appvar_info_pos, var_type, archived);
}
free(appvar_info);

@adriweb adriweb reopened this Jun 7, 2020
@mateoconlechuga
Copy link
Owner Author

added with 961c2e3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants