Clear up warnings, add support for rating values.
This commit is contained in:
parent
c518996f62
commit
162a8cc19b
4 changed files with 60 additions and 136 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 1a647bdd8006cdf679f09f3907240c46c0399a90
|
||||
Subproject commit 6949e070315072c0fcc123288a4d80d83e4c0dd3
|
|
@ -4,6 +4,7 @@
|
|||
#include "pc/wav.h"
|
||||
#include "pc/stb_vorbis.h"
|
||||
#include "types.h"
|
||||
#include "3ds/smdh.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -154,7 +155,7 @@ int cmd_make_banner(const std::string& image, const std::string& audio, const st
|
|||
return 0;
|
||||
}
|
||||
|
||||
int cmd_make_smdh(const std::string& shortTitle, const std::string& longTitle, const std::string& publisher, const std::string& icon, SMDHRegionFlag regionFlags, u64 matchMakerId, u32 smdhFlags, u16 eulaVersion, u32 optimalBannerFrame, u32 streetpassId, const std::string& output) {
|
||||
int cmd_make_smdh(const std::string& shortTitle, const std::string& longTitle, const std::string& publisher, const std::string& icon, SMDH base, const std::string& output) {
|
||||
u8* icon48Data = load_image(icon.c_str(), 48, 48);
|
||||
if(icon48Data == NULL) {
|
||||
return 1;
|
||||
|
@ -205,22 +206,14 @@ int cmd_make_smdh(const std::string& shortTitle, const std::string& longTitle, c
|
|||
return 1;
|
||||
}
|
||||
|
||||
SMDH smdh;
|
||||
for(int i = 0; i < 0x10; i++) {
|
||||
utf8_to_utf16(smdh.titles[i].shortTitle, shortTitle.c_str(), 0x40);
|
||||
utf8_to_utf16(smdh.titles[i].longTitle, longTitle.c_str(), 0x80);
|
||||
utf8_to_utf16(smdh.titles[i].publisher, publisher.c_str(), 0x40);
|
||||
utf8_to_utf16(base.titles[i].shortTitle, shortTitle.c_str(), 0x40);
|
||||
utf8_to_utf16(base.titles[i].longTitle, longTitle.c_str(), 0x80);
|
||||
utf8_to_utf16(base.titles[i].publisher, publisher.c_str(), 0x40);
|
||||
}
|
||||
|
||||
smdh.settings.regionLock = regionFlags;
|
||||
memcpy(smdh.settings.matchMakerId, &matchMakerId, 0xC);
|
||||
smdh.settings.flags = smdhFlags;
|
||||
smdh.settings.eulaVersion = eulaVersion;
|
||||
smdh.settings.optimalBannerFrame = optimalBannerFrame;
|
||||
smdh.settings.streetpassId = streetpassId;
|
||||
|
||||
memcpy(smdh.largeIcon, icon48, 0x1200);
|
||||
memcpy(smdh.smallIcon, icon24, 0x480);
|
||||
memcpy(base.largeIcon, icon48, 0x1200);
|
||||
memcpy(base.smallIcon, icon24, 0x480);
|
||||
free(icon48);
|
||||
|
||||
FILE* fd = fopen(output.c_str(), "wb");
|
||||
|
@ -229,7 +222,7 @@ int cmd_make_smdh(const std::string& shortTitle, const std::string& longTitle, c
|
|||
return 2;
|
||||
}
|
||||
|
||||
fwrite(&smdh, 1, sizeof(SMDH), fd);
|
||||
fwrite(&base, 1, sizeof(SMDH), fd);
|
||||
fclose(fd);
|
||||
|
||||
printf("Created SMDH \"%s\".\n", output.c_str());
|
||||
|
@ -368,6 +361,15 @@ void cmd_print_info(const std::string& command) {
|
|||
printf(" -ev/--eulaversion: Optional. Version of the EULA required to be accepted before launching.\n");
|
||||
printf(" -obf/--optimalbannerframe: Optional. Optimal frame of the accompanying banner.\n");
|
||||
printf(" -spid/--streetpassid: Optional. Streetpass ID of the SMDH.\n");
|
||||
printf(" -cer/--cero: Optional. CERO rating number (0-255).\n");
|
||||
printf(" -er/--esrb: Optional. ESRB rating number (0-255).\n");
|
||||
printf(" -ur/--usk: Optional. USK rating number (0-255).\n");
|
||||
printf(" -pgr/--pegigen: Optional. PEGI GEN rating number (0-255).\n");
|
||||
printf(" -ppr/--pegiptr: Optional. PEGI PTR rating number (0-255).\n");
|
||||
printf(" -pbr/--pegibbfc: Optional. PEGI BBFC rating number (0-255).\n");
|
||||
printf(" -cr/--cob: Optional. COB rating number (0-255).\n");
|
||||
printf(" -gr/--grb: Optional. GR rating number (0-255).\n");
|
||||
printf(" -cgr/--cgsrr: Optional. CGSRR rating number (0-255).\n");
|
||||
} else if(command.compare("makecwav") == 0) {
|
||||
printf("makecwav - Creates a CWAV file from a WAV.\n");
|
||||
printf(" -i/--input: WAV file to convert.\n");
|
||||
|
@ -438,67 +440,80 @@ int cmd_process_command(int argc, char* argv[]) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
std::vector<std::string> regions = cmd_parse_list(cmd_find_arg(args, "r", "regions", "regionfree"));
|
||||
std::vector<std::string> flags = cmd_parse_list(cmd_find_arg(args, "f", "flags", "visible,allow3d,recordusage"));
|
||||
u64 matchMakerId = (u64) atoll(cmd_find_arg(args, "mmid", "matchmakerid", "0").c_str());
|
||||
u16 eulaVersion = (u16) atoi(cmd_find_arg(args, "ev", "eulaversion", "0").c_str());
|
||||
u32 optimalBannerFrame = (u32) atoll(cmd_find_arg(args, "obf", "optimalbannerframe", "0").c_str());
|
||||
u32 streetpassId = (u32) atoll(cmd_find_arg(args, "spid", "streetpassid", "0").c_str());
|
||||
SMDH smdh;
|
||||
memset(&smdh, 0, sizeof(SMDH));
|
||||
|
||||
u32 regionFlags = 0;
|
||||
std::vector<std::string> regions = cmd_parse_list(cmd_find_arg(args, "r", "regions", "regionfree"));
|
||||
for(std::vector<std::string>::iterator it = regions.begin(); it != regions.end(); it++) {
|
||||
const std::string region = *it;
|
||||
if(region.compare("regionfree") == 0) {
|
||||
regionFlags = REGION_FREE;
|
||||
smdh.settings.regionLock = REGION_FREE;
|
||||
break;
|
||||
} else if(region.compare("japan") == 0) {
|
||||
regionFlags |= JAPAN;
|
||||
smdh.settings.regionLock |= JAPAN;
|
||||
} else if(region.compare("northamerica") == 0) {
|
||||
regionFlags |= NORTH_AMERICA;
|
||||
smdh.settings.regionLock |= NORTH_AMERICA;
|
||||
} else if(region.compare("europe") == 0) {
|
||||
regionFlags |= EUROPE;
|
||||
smdh.settings.regionLock |= EUROPE;
|
||||
} else if(region.compare("australia") == 0) {
|
||||
regionFlags |= AUSTRALIA;
|
||||
smdh.settings.regionLock |= AUSTRALIA;
|
||||
} else if(region.compare("china") == 0) {
|
||||
regionFlags |= CHINA;
|
||||
smdh.settings.regionLock |= CHINA;
|
||||
} else if(region.compare("korea") == 0) {
|
||||
regionFlags |= KOREA;
|
||||
smdh.settings.regionLock |= KOREA;
|
||||
} else if(region.compare("taiwan") == 0) {
|
||||
regionFlags |= TAIWAN;
|
||||
smdh.settings.regionLock |= TAIWAN;
|
||||
} else {
|
||||
cmd_invalid_arg("regions", command);
|
||||
}
|
||||
}
|
||||
|
||||
u32 smdhFlags = 0;
|
||||
std::vector<std::string> flags = cmd_parse_list(cmd_find_arg(args, "f", "flags", "visible,allow3d,recordusage"));
|
||||
for(std::vector<std::string>::iterator it = flags.begin(); it != flags.end(); it++) {
|
||||
const std::string flag = *it;
|
||||
if(flag.compare("visible") == 0) {
|
||||
smdhFlags |= VISIBLE;
|
||||
smdh.settings.flags |= VISIBLE;
|
||||
} else if(flag.compare("autoboot") == 0) {
|
||||
smdhFlags |= AUTO_BOOT;
|
||||
smdh.settings.flags |= AUTO_BOOT;
|
||||
} else if(flag.compare("allow3d") == 0) {
|
||||
smdhFlags |= ALLOW_3D;
|
||||
smdh.settings.flags |= ALLOW_3D;
|
||||
} else if(flag.compare("requireeula") == 0) {
|
||||
smdhFlags |= REQUIRE_EULA;
|
||||
smdh.settings.flags |= REQUIRE_EULA;
|
||||
} else if(flag.compare("autosave") == 0) {
|
||||
smdhFlags |= AUTO_SAVE_ON_EXIT;
|
||||
smdh.settings.flags |= AUTO_SAVE_ON_EXIT;
|
||||
} else if(flag.compare("extendedbanner") == 0) {
|
||||
smdhFlags |= USE_EXTENDED_BANNER;
|
||||
smdh.settings.flags |= USE_EXTENDED_BANNER;
|
||||
} else if(flag.compare("ratingrequired") == 0) {
|
||||
smdhFlags |= RATING_REQUIED;
|
||||
smdh.settings.flags |= RATING_REQUIED;
|
||||
} else if(flag.compare("savedata") == 0) {
|
||||
smdhFlags |= USE_SAVE_DATA;
|
||||
smdh.settings.flags |= USE_SAVE_DATA;
|
||||
} else if(flag.compare("recordusage") == 0) {
|
||||
smdhFlags |= RECORD_USAGE;
|
||||
smdh.settings.flags |= RECORD_USAGE;
|
||||
} else if(flag.compare("nosavebackups") == 0) {
|
||||
smdhFlags |= DISABLE_SAVE_BACKUPS;
|
||||
smdh.settings.flags |= DISABLE_SAVE_BACKUPS;
|
||||
} else {
|
||||
cmd_invalid_arg("flags", command);
|
||||
}
|
||||
}
|
||||
|
||||
return cmd_make_smdh(shortTitle, longTitle, publisher, icon, (SMDHRegionFlag) regionFlags, matchMakerId, smdhFlags, eulaVersion, optimalBannerFrame, streetpassId, output);
|
||||
u64 matchMakerId = (u64) atoll(cmd_find_arg(args, "mmid", "matchmakerid", "0").c_str());
|
||||
memcpy(smdh.settings.matchMakerId, &matchMakerId, 0xC);
|
||||
|
||||
smdh.settings.eulaVersion = (u16) atoi(cmd_find_arg(args, "ev", "eulaversion", "0").c_str());
|
||||
smdh.settings.optimalBannerFrame = (u32) atoll(cmd_find_arg(args, "obf", "optimalbannerframe", "0").c_str());
|
||||
smdh.settings.streetpassId = (u32) atoll(cmd_find_arg(args, "spid", "streetpassid", "0").c_str());
|
||||
|
||||
smdh.settings.gameRatings[CERO] = (u8) atoi(cmd_find_arg(args, "cer", "cero", "0").c_str());
|
||||
smdh.settings.gameRatings[ESRB] = (u8) atoi(cmd_find_arg(args, "er", "esrb", "0").c_str());
|
||||
smdh.settings.gameRatings[USK] = (u8) atoi(cmd_find_arg(args, "ur", "usk", "0").c_str());
|
||||
smdh.settings.gameRatings[PEGI_GEN] = (u8) atoi(cmd_find_arg(args, "pgr", "pegigen", "0").c_str());
|
||||
smdh.settings.gameRatings[PEGI_PTR] = (u8) atoi(cmd_find_arg(args, "ppr", "pegiptr", "0").c_str());
|
||||
smdh.settings.gameRatings[PEGI_BBFC] = (u8) atoi(cmd_find_arg(args, "pbr", "pegibbfc", "0").c_str());
|
||||
smdh.settings.gameRatings[COB] = (u8) atoi(cmd_find_arg(args, "cor", "cob", "0").c_str());
|
||||
smdh.settings.gameRatings[GRB] = (u8) atoi(cmd_find_arg(args, "gr", "grb", "0").c_str());
|
||||
smdh.settings.gameRatings[CGSRR] = (u8) atoi(cmd_find_arg(args, "cgr", "cgsrr", "0").c_str());
|
||||
|
||||
return cmd_make_smdh(shortTitle, longTitle, publisher, icon, smdh, output);
|
||||
} else if(strcmp(command, "makecwav") == 0) {
|
||||
const std::string input = cmd_find_arg(args, "i", "input", "");
|
||||
const std::string output = cmd_find_arg(args, "o", "output", "");
|
||||
|
|
|
@ -1235,18 +1235,6 @@ stbi_inline static stbi_uc stbi__get8(stbi__context *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
stbi_inline static int stbi__at_eof(stbi__context *s)
|
||||
{
|
||||
if (s->io.read) {
|
||||
if (!(s->io.eof)(s->io_user_data)) return 0;
|
||||
// if feof() is true, check if buffer = end
|
||||
// special case: we've only got the special 0 character at the end
|
||||
if (s->read_from_callbacks == 0) return 1;
|
||||
}
|
||||
|
||||
return s->img_buffer >= s->img_buffer_end;
|
||||
}
|
||||
|
||||
static void stbi__skip(stbi__context *s, int n)
|
||||
{
|
||||
if (n < 0) {
|
||||
|
|
|
@ -1868,85 +1868,6 @@ static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **out
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
|
||||
static int codebook_decode_deinterleave_repeat_2(vorb *f, Codebook *c, float **outputs, int *c_inter_p, int *p_inter_p, int len, int total_decode)
|
||||
{
|
||||
int c_inter = *c_inter_p;
|
||||
int p_inter = *p_inter_p;
|
||||
int i,z, effective = c->dimensions;
|
||||
|
||||
// type 0 is only legal in a scalar context
|
||||
if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream);
|
||||
|
||||
while (total_decode > 0) {
|
||||
float last = CODEBOOK_ELEMENT_BASE(c);
|
||||
DECODE_VQ(z,f,c);
|
||||
|
||||
if (z < 0) {
|
||||
if (!f->bytes_in_seg)
|
||||
if (f->last_seg) return FALSE;
|
||||
return error(f, VORBIS_invalid_stream);
|
||||
}
|
||||
|
||||
// if this will take us off the end of the buffers, stop short!
|
||||
// we check by computing the length of the virtual interleaved
|
||||
// buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter),
|
||||
// and the length we'll be using (effective)
|
||||
if (c_inter + p_inter*2 + effective > len * 2) {
|
||||
effective = len*2 - (p_inter*2 - c_inter);
|
||||
}
|
||||
|
||||
{
|
||||
z *= c->dimensions;
|
||||
if (c->sequence_p) {
|
||||
// haven't optimized this case because I don't have any examples
|
||||
for (i=0; i < effective; ++i) {
|
||||
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
|
||||
if (outputs[c_inter])
|
||||
outputs[c_inter][p_inter] += val;
|
||||
if (++c_inter == 2) { c_inter = 0; ++p_inter; }
|
||||
last = val;
|
||||
}
|
||||
} else {
|
||||
i=0;
|
||||
if (c_inter == 1 && i < effective) {
|
||||
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
|
||||
if (outputs[c_inter])
|
||||
outputs[c_inter][p_inter] += val;
|
||||
c_inter = 0; ++p_inter;
|
||||
++i;
|
||||
}
|
||||
{
|
||||
float *z0 = outputs[0];
|
||||
float *z1 = outputs[1];
|
||||
for (; i+1 < effective;) {
|
||||
float v0 = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
|
||||
float v1 = CODEBOOK_ELEMENT_FAST(c,z+i+1) + last;
|
||||
if (z0)
|
||||
z0[p_inter] += v0;
|
||||
if (z1)
|
||||
z1[p_inter] += v1;
|
||||
++p_inter;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
if (i < effective) {
|
||||
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
|
||||
if (outputs[c_inter])
|
||||
outputs[c_inter][p_inter] += val;
|
||||
if (++c_inter == 2) { c_inter = 0; ++p_inter; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
total_decode -= effective;
|
||||
}
|
||||
*c_inter_p = c_inter;
|
||||
*p_inter_p = p_inter;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int predict_point(int x, int x0, int x1, int y0, int y1)
|
||||
{
|
||||
int dy = y1 - y0;
|
||||
|
@ -3980,7 +3901,7 @@ static int start_decoder(vorb *f)
|
|||
g->sorted_order[j] = (uint8) p[j].y;
|
||||
// precompute the neighbors
|
||||
for (j=2; j < g->values; ++j) {
|
||||
int low,hi;
|
||||
int low = 0, hi = 0;
|
||||
neighbors(g->Xlist, j, &low,&hi);
|
||||
g->neighbors[j][0] = low;
|
||||
g->neighbors[j][1] = hi;
|
||||
|
@ -4652,7 +4573,7 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
|
|||
ProbedPage left, right, mid;
|
||||
int i, start_seg_with_known_loc, end_pos, page_start;
|
||||
uint32 delta, stream_length, padding;
|
||||
double offset, bytes_per_sample;
|
||||
double offset = 0, bytes_per_sample = 0;
|
||||
int probe = 0;
|
||||
|
||||
// find the last page and validate the target sample
|
||||
|
|
Loading…
Reference in a new issue