Misc tidying (#1134)

Cleaned up Yay0compress cod
Identified / classified remaining bins in the US yaml
Tiny comment removal in a source file
This commit is contained in:
Ethan Roseman 2023-12-11 18:44:57 +09:00 committed by GitHub
parent 3637dae749
commit b716abeadb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 274 additions and 305 deletions

View File

@ -4,7 +4,6 @@
void bgm_update_volume(void);
void bgm_set_target_volume(s16 volume);
// these are BSS
SHIFT_BSS s16 MusicDefaultVolume;
SHIFT_BSS s16 MusicMaxVolume;
SHIFT_BSS s16 MusicCurrentVolume;

View File

@ -3,35 +3,21 @@
#include <string.h>
int main(int argc, const char** argv, const char** envp);
void encode();
void search(unsigned int a1, int a2, int *a3, unsigned int *a4);
int mischarsearch(unsigned char *a1, int a2, unsigned char *a3, int a4);
void initskip(unsigned char *a1, int a2);
void writeshort(short a1);
void writeint4(int a1);
void encode(FILE* fp, int insize, unsigned char* bz);
void search(unsigned int a1, int insize, int* a3, unsigned int* a4, unsigned char* bz);
int mischarsearch(unsigned char* pattern, int patternlen, unsigned char* data, int datalen);
void initskip(unsigned short* skip, unsigned char* a1, int a2);
void writeshort(FILE* fp, short a1);
void writeint4(FILE* fp, int a1);
unsigned short skip[256]; // idb
int cp; // weak
int ndp; // weak
int main(int argc, const char** argv, const char** envp) {
FILE* fp; // idb
unsigned char *def;
unsigned short *pol;
int pp; // weak
int insize; // idb
int ncp; // weak
int npp; // weak
unsigned char *bz;
int dp; // idb
unsigned int *cmd;
int main(int argc, const char **argv, const char **envp)
{
char src[999];
char dest[999];
int insize; // idb
unsigned char* bz;
if (argc < 3)
{
if (argc < 3) {
fprintf(stderr, "Yay0compress [infile] [outfile]\n");
return 1;
}
@ -39,8 +25,7 @@ int main(int argc, const char **argv, const char **envp)
strcpy(src, argv[1]);
strcpy(dest, argv[2]);
if ((fp = fopen(src, "rb")) == NULL)
{
if ((fp = fopen(src, "rb")) == NULL) {
fprintf(stderr, "FILE OPEN ERROR![%s]\n", src);
return 1;
}
@ -53,102 +38,86 @@ int main(int argc, const char **argv, const char **envp)
fread(bz, 1, insize, fp);
fclose(fp);
for (int i = 0; src[i]; i++)
{
if (src[i] == '.')
{
for (int i = 0; src[i]; i++) {
if (src[i] == '.') {
src[i] = 0;
break;
}
}
if ((fp = fopen(dest, "wb")) == NULL)
{
if ((fp = fopen(dest, "wb")) == NULL) {
fprintf(stderr, "FILE CREATE ERROR![%s]\n", dest);
exit(1);
}
encode();
fprintf(fp, "Yay0");
writeint4(insize);
writeint4(4 * cp + 16);
writeint4(2 * pp + 4 * cp + 16);
for (int i = 0; i < cp; i++)
writeint4(cmd[i]);
for (int i = 0; i < pp; i++)
writeshort(pol[i]);
fwrite(def, 1u, dp, fp);
fclose(fp);
encode(fp, insize, bz);
return 0;
}
void encode()
{
void encode(FILE* fp, int insize, unsigned char* bz) {
int pp; // weak
int dp; // idb
unsigned int* cmd;
unsigned char* def;
unsigned short* pol;
unsigned int v0; // esi
unsigned int v1; // edi
int v2; // edx
int v3; // ebx
int v4; // edx
char v5; // [esp+Ch] [ebp-18h]
unsigned int v1 = 0; // edi
int v2 = 0; // edx
int v3 = 0; // ebx
int v4 = 0; // edx
unsigned int v6; // [esp+10h] [ebp-14h]
unsigned int v7; // [esp+14h] [ebp-10h]
int v8; // [esp+18h] [ebp-Ch]
unsigned int a4; // [esp+1Ch] [ebp-8h]
int a3; // [esp+20h] [ebp-4h]
unsigned int v7 = 0; // [esp+14h] [ebp-10h]
int v8 = 0; // [esp+18h] [ebp-Ch]
unsigned int a4 = 0; // [esp+1Ch] [ebp-8h]
int a3 = 0; // [esp+20h] [ebp-4h]
int ncp; // weak
int npp; // weak
int ndp; // weak
int cp;
dp = 0;
pp = 0;
cp = 0;
npp = 4096;
ndp = 4096;
ncp = 4096;
cmd = calloc(0x4000u, 1u);
npp = 0x1000;
ndp = 0x1000;
ncp = 0x1000;
cmd = calloc(0x4000, 1);
pol = malloc(2 * npp);
def = malloc(4 * ndp);
v0 = 0;
v6 = 1024;
v1 = 2147483648;
while ( insize > v0 )
{
if ( v6 < v0 )
v1 = 0x80000000;
while (v0 < insize) {
if (dp == 73) {
int dog = 5;
}
if (v6 < v0) {
v6 += 1024;
search(v0, insize, &a3, &a4);
if ( a4 <= 2 )
{
}
search(v0, insize, &a3, &a4, bz);
if (a4 <= 2) {
cmd[cp] |= v1;
def[dp++] = bz[v0++];
if ( ndp == dp )
{
ndp = dp + 4096;
def = realloc(def, dp + 4096);
if (ndp == dp) {
ndp = dp + 0x1000;
def = realloc(def, dp + 0x1000);
}
}
else
{
search(v0 + 1, insize, &v8, &v7);
if ( v7 > a4 + 1 )
{
} else {
search(v0 + 1, insize, &v8, &v7, bz);
if (v7 > a4 + 1) {
cmd[cp] |= v1;
def[dp++] = bz[v0++];
if ( ndp == dp )
{
ndp = dp + 4096;
def = realloc(def, dp + 4096);
if (ndp == dp) {
ndp = dp + 0x1000;
def = realloc(def, dp + 0x1000);
}
v1 >>= 1;
if ( !v1 )
{
v1 = 2147483648;
if (!v1) {
v1 = 0x80000000;
v2 = cp++;
if ( cp == ncp )
{
if (cp == ncp) {
ncp = v2 + 1025;
cmd = realloc(cmd, 4 * (v2 + 1025));
}
@ -159,156 +128,156 @@ void encode()
}
v3 = v0 - a3 - 1;
a3 = v0 - a3 - 1;
v5 = a4;
if ( a4 > 0x11 )
{
if (a4 > 0x11) {
pol[pp++] = v3;
def[dp++] = v5 - 18;
if ( ndp == dp )
{
ndp = dp + 4096;
def = realloc(def, dp + 4096);
def[dp++] = a4 - 18;
if (ndp == dp) {
ndp = dp + 0x1000;
def = realloc(def, dp + 0x1000);
}
}
else
{
} else {
pol[pp++] = v3 | (((short)a4 - 2) << 12);
}
if ( npp == pp )
{
npp = pp + 4096;
pol = realloc(pol, 2 * (pp + 4096));
if (npp == pp) {
npp += 0x1000;
pol = realloc(pol, 2 * (pp + 0x1000));
}
v0 += a4;
}
v1 >>= 1;
if ( !v1 )
{
v1 = 2147483648;
if (!v1) {
v1 = 0x80000000;
v4 = cp++;
if ( cp == ncp )
{
if (cp == ncp) {
ncp = v4 + 1025;
cmd = realloc(cmd, 4 * (v4 + 1025));
}
cmd[cp] = 0;
}
}
if ( v1 != 0x80000000 )
++cp;
//fprintf(stderr, "IN=%d OUT=%d\n", insize, dp + 2 * pp + 4 * cp + 16);
if (v1 != 0x80000000) {
cp++;
}
void search(unsigned int a1, int a2, int *a3, unsigned int *a4)
{
unsigned int v4; // ebx
fprintf(fp, "Yay0");
writeint4(fp, insize);
writeint4(fp, 4 * cp + 16);
writeint4(fp, 2 * pp + 4 * cp + 16);
for (int i = 0; i < cp; i++)
writeint4(fp, cmd[i]);
for (int i = 0; i < pp; i++)
writeshort(fp, pol[i]);
fwrite(def, 1, dp, fp);
fclose(fp);
}
void search(unsigned int a1, int insize, int* a3, unsigned int* a4, unsigned char* bz) {
unsigned int patternlen; // ebx
unsigned int v5; // esi
unsigned int *v6; // edi
unsigned int v7; // [esp+Ch] [ebp-10h]
int v8; // [esp+14h] [ebp-8h]
unsigned int* v6 = 0; // edi
unsigned int v7 = 0; // [esp+Ch] [ebp-10h]
int v8 = 0; // [esp+14h] [ebp-8h]
unsigned int v9; // [esp+18h] [ebp-4h]
v4 = 3;
patternlen = 3;
v5 = 0;
if ( a1 > 0x1000 )
v5 = a1 - 4096;
if (a1 > 0x1000) {
v5 = a1 - 0x1000;
}
v9 = 273;
if ( a2 - a1 <= 0x111 )
v9 = a2 - a1;
if ( v9 > 2 )
{
while ( a1 > v5 )
{
v7 = mischarsearch(&bz[a1], v4, &bz[v5], v4 + a1 - v5);
if ( v7 >= a1 - v5 )
break;
for ( ; v9 > v4; ++v4 )
{
if ( bz[v4 + v5 + v7] != bz[v4 + a1] )
if (insize - a1 <= 273) {
v9 = insize - a1;
}
if (v9 > 2) {
while (a1 > v5) {
v7 = mischarsearch(&bz[a1], patternlen, &bz[v5], patternlen + a1 - v5);
if (v7 >= a1 - v5) {
break;
}
if ( v9 == v4 )
{
for (; patternlen < v9; patternlen++) {
if (bz[patternlen + v5 + v7] != bz[patternlen + a1]) {
break;
}
}
if (v9 == patternlen) {
*a3 = v7 + v5;
goto LABEL_17;
*a4 = patternlen;
return;
}
v8 = v5 + v7;
++v4;
patternlen++;
v5 += v7 + 1;
}
*a3 = v8;
if ( v4 > 3 )
{
--v4;
LABEL_17:
*a4 = v4;
if (patternlen > 3) {
patternlen--;
*a4 = patternlen;
return;
}
v6 = a4;
}
else
{
} else {
*a4 = 0;
v6 = a3;
}
*v6 = 0;
}
int mischarsearch(unsigned char *pattern, int patternlen, unsigned char *data, int datalen)
{
int result; // eax
int mischarsearch(unsigned char* pattern, int patternlen, unsigned char* data, int datalen) {
unsigned short skip[256]; // idb
int i; // ebx
int v6; // eax
int j; // ecx
result = datalen;
if ( patternlen <= datalen )
{
initskip(pattern, patternlen);
for ( i = patternlen - 1; ; i += v6 )
{
if ( pattern[patternlen - 1] == data[i] )
{
--i;
if (patternlen <= datalen) {
// initskip
for (int k = 0; k < 256; k++) {
skip[k] = patternlen;
}
for (int k = 0; k < patternlen; k++) {
skip[pattern[k]] = patternlen - k - 1;
}
for (i = patternlen - 1;; i += v6) {
if (pattern[patternlen - 1] == data[i]) {
i--;
j = patternlen - 2;
if ( patternlen - 2 < 0 )
return i + 1;
while ( pattern[j] == data[i] )
{
--i;
if ( --j < 0 )
if (j < 0) {
return i + 1;
}
while (pattern[j] == data[i]) {
i--;
j--;
if (j < 0) {
return i + 1;
}
}
if (skip[data[i]] <= patternlen - j) {
v6 = patternlen - j;
if ( skip[data[i]] > patternlen - j )
v6 = skip[data[i]];
continue;
}
}
else
{
v6 = skip[data[i]];
}
}
}
return result;
return datalen;
}
void initskip(unsigned char *pattern, int len)
{
for (int i = 0; i < 256; i++)
skip[i] = len;
for (int i = 0; i < len; i++)
skip[pattern[i]] = len - i - 1;
}
void writeshort(short val)
{
void writeshort(FILE* fp, short val) {
fputc((val & 0xff00) >> 8, fp);
fputc((val & 0x00ff) >> 0, fp);
}
void writeint4(int val)
{
void writeint4(FILE* fp, int val) {
fputc((val & 0x00ff000000) >> 24, fp);
fputc((val & 0x0000ff0000) >> 16, fp);
fputc((val & 0x000000ff00) >> 8, fp);

View File

@ -14725,7 +14725,7 @@ segments:
#################
### Dead maps ###
#################
- [0xE9ECD0, bin] # tail of dead kzn_11
- [0xE9ECD0, bin, dead_kzn_11_end] # tail of dead kzn_11
#- name: dead_kzn_11
# dir: world/dead/area_kzn/kzn_11
# type: code
@ -15006,9 +15006,10 @@ segments:
- [auto, c, flo_19_5_beanstalk]
- [0xF00000, pm_sbn, audio]
- [0x1942C40, bin]
- [0x1942C40, bin, copy_1942C40] # copy of 0x1642C40 - 0x1643000
- { start: 0x1943000, align: 8, type: pm_sprites, name: sprites }
- [0x1B82208, bin] # end of sprite data - todo: figure out what this is
- [0x1B82208, bin, pad_1B82208] # zeros
- [0x1B8220C, bin, copy_1B8220C] # copy of 0x188220C - 0x1883000
- start: 0x1B83000
type: pm_msg
files:
@ -15059,8 +15060,8 @@ segments:
- 2C_QuizQuestions
- 2D_QuizChoices
- 2E_Credits
- [0x1C84D30, bin] # junk(?)
- [0x1E00000, bin] # junk (player sprite data; can be zeroed out with no effect)
- [0x1C84D30, bin, unk_1C84D30] # junk(?)
- [0x1E00000, bin, copy_1E00000] # copy of 0x1943000 - 0x1983000
- [0x1E40000, pm_map_data, mapfs]
- { type: bin, start: 0x27FEE22, subalign: 2 }
- { name: copy_27FEE22, type: bin, start: 0x27FEE22, subalign: 2 } # copy of 0x232EE22 - 0x2330000
- [0x2800000]