Skip to content

Commit fdf0035

Browse files
committed
Switched from vorbis to theora, and fixed saving
1 parent dc19dbb commit fdf0035

6 files changed

Lines changed: 113 additions & 104 deletions

File tree

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ INCLUDES := build/include source source/jmact source/jaudiolib/include source/e
4242
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
4343

4444
CFLAGS := -g -Wall -O2 -mword-relocations -std=c99 \
45-
-fomit-frame-pointer -ffunction-sections -ffast-math \
46-
$(ARCH) -DHAVE_VORBIS
45+
-fomit-frame-pointer -ffunction-sections \
46+
$(ARCH)
4747

48-
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DNOASM -std=c99 -DNETCODE_DISABLE
48+
CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DNOASM -std=c99 -DNETCODE_DISABLE -DHAVE_VORBIS
4949

5050
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
5151

5252
ASFLAGS := -g $(ARCH)
5353
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
5454

55-
LIBS := -lctru -lm -lvorbisfile -lvorbis -logg -lm
55+
LIBS := -lctru -lm -lvorbisidec -logg -lm
5656

5757
#---------------------------------------------------------------------------------
5858
# list of directories containing libraries, this must be the top level containing

build/src/compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ uint32_t Bgetsysmemsize(void)
783783

784784
return siz;
785785
#elif defined _3DS
786-
return 16*1024*1024;
786+
return 24*1024*1024;
787787
#elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) && !defined(GEKKO)
788788
uint32_t siz = UINT32_MAX;
789789
int64_t scpagesiz, scphyspages;

build/src/engine.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12187,12 +12187,17 @@ int32_t loadpics(const char *filename, int32_t askedsize)
1218712187

1218812188
Bmemset(gotpic, 0, sizeof(gotpic));
1218912189

12190+
#ifdef _3DS
12191+
cachesize = 4 * 1024 * 1024;
12192+
#else
1219012193
//cachesize = min((int32_t)((Bgetsysmemsize()/100)*60),max(artsize,askedsize));
1219112194
if (Bgetsysmemsize() <= (uint32_t)askedsize)
1219212195
cachesize = (Bgetsysmemsize()/100)*60;
1219312196
else
1219412197
cachesize = askedsize;
1219512198

12199+
#endif
12200+
1219612201
// NOTE: this doesn't make a lot of sense on modern OSs...
1219712202
while ((pic = Bmalloc(cachesize)) == NULL)
1219812203
{

source/jaudiolib/src/vorbis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#if defined __APPLE__
4141
# include <vorbis/vorbisfile.h>
42-
#elif defined GEKKO
42+
#elif defined (GEKKO) || defined (_3DS)
4343
# define USING_TREMOR
4444
# include <tremor/ivorbisfile.h>
4545
#else

source/menus.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,7 +2958,11 @@ static void M_MenuEntryStringActivate(/*MenuEntry_t *entry*/)
29582958
{
29592959
case MENU_SAVE:
29602960
if (!save_xxh)
2961+
#ifdef _3DS
2962+
save_xxh = 1; //Dirty, dirty hack...
2963+
#else
29612964
save_xxh = XXH32((uint8_t *)&ud.savegame[M_SAVE.currentEntry][0], 19, 0xDEADBEEF);
2965+
#endif
29622966
if (ud.savegame[M_SAVE.currentEntry][0])
29632967
M_ChangeMenu(MENU_SAVEVERIFY);
29642968
break;

source/savegame.c

Lines changed: 98 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,89 +2233,89 @@ static void postloadplayer(int32_t savegamep)
22332233

22342234
////////// END GENERIC SAVING/LOADING SYSTEM //////////
22352235

2236-
#ifdef __ANDROID__
2237-
#include <jni.h>
2238-
#include <android/log.h>
2239-
2240-
#ifndef LOGI
2241-
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO,"DUKE", __VA_ARGS__))
2242-
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "DUKE", __VA_ARGS__))
2243-
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR,"DUKE", __VA_ARGS__))
2244-
#endif
2245-
2246-
char const * G_GetStringFromSavegame(const char *filename, int type)
2247-
{
2248-
LOGI("getSavegameText %s", filename);
2249-
int32_t fil = kopen4load(filename, 0);
2250-
2251-
if (fil == -1)
2252-
{
2253-
LOGE("couldn't load %s", filename);
2254-
return "";
2255-
}
2256-
2257-
savehead_t saveh;
2258-
2259-
int32_t i = sv_loadheader(fil, 0, &saveh);
2260-
2261-
if (i && (i != 2 && i != 3))
2262-
goto corrupt;
2263-
2264-
kclose(fil);
2265-
2266-
static char tempbuf[64];
2267-
2268-
switch (type)
2269-
{
2270-
case 0: Bstrncpyz(tempbuf, saveh.savename, sizeof(saveh.savename) - 1); break;
2271-
case 1: Bstrncpyz(tempbuf, saveh.volname, sizeof(saveh.volname) - 1); break;
2272-
case 2: Bstrncpyz(tempbuf, saveh.skillname, sizeof(saveh.skillname) - 1); break;
2273-
}
2274-
return tempbuf;
2275-
2276-
corrupt:
2277-
kclose(fil);
2278-
LOGE("couldn't load %s", filename);
2279-
return "";
2280-
}
2281-
2282-
int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data)
2283-
{
2284-
LOGI("getSavegameScreenshot %s", filename);
2285-
2286-
int32_t fil = kopen4load(filename, 0);
2287-
2288-
if (fil == -1)
2289-
return -1;
2290-
2291-
savehead_t saveh;
2292-
2293-
int32_t i = sv_loadheader(fil, 0, &saveh);
2294-
2295-
if (i && (i != 2 && i != 3))
2296-
goto corrupt;
2297-
2298-
int32_t screenshotofs;
2299-
2300-
if (kread(fil, &screenshotofs, 4) != 4)
2301-
goto corrupt;
2302-
2303-
if (screenshotofs)
2304-
{
2305-
if (kdfread(data, 320, 200, fil) != 200)
2306-
{
2307-
// OSD_Printf("G_LoadSaveHeaderNew(%d): failed reading screenshot\n", spot);
2308-
goto corrupt;
2309-
}
2310-
}
2311-
else
2312-
{
2313-
kclose(fil);
2314-
return -1;
2315-
}
2316-
2317-
kclose(fil);
2318-
2236+
#ifdef __ANDROID__
2237+
#include <jni.h>
2238+
#include <android/log.h>
2239+
2240+
#ifndef LOGI
2241+
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO,"DUKE", __VA_ARGS__))
2242+
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "DUKE", __VA_ARGS__))
2243+
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR,"DUKE", __VA_ARGS__))
2244+
#endif
2245+
2246+
char const * G_GetStringFromSavegame(const char *filename, int type)
2247+
{
2248+
LOGI("getSavegameText %s", filename);
2249+
int32_t fil = kopen4load(filename, 0);
2250+
2251+
if (fil == -1)
2252+
{
2253+
LOGE("couldn't load %s", filename);
2254+
return "";
2255+
}
2256+
2257+
savehead_t saveh;
2258+
2259+
int32_t i = sv_loadheader(fil, 0, &saveh);
2260+
2261+
if (i && (i != 2 && i != 3))
2262+
goto corrupt;
2263+
2264+
kclose(fil);
2265+
2266+
static char tempbuf[64];
2267+
2268+
switch (type)
2269+
{
2270+
case 0: Bstrncpyz(tempbuf, saveh.savename, sizeof(saveh.savename) - 1); break;
2271+
case 1: Bstrncpyz(tempbuf, saveh.volname, sizeof(saveh.volname) - 1); break;
2272+
case 2: Bstrncpyz(tempbuf, saveh.skillname, sizeof(saveh.skillname) - 1); break;
2273+
}
2274+
return tempbuf;
2275+
2276+
corrupt:
2277+
kclose(fil);
2278+
LOGE("couldn't load %s", filename);
2279+
return "";
2280+
}
2281+
2282+
int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data)
2283+
{
2284+
LOGI("getSavegameScreenshot %s", filename);
2285+
2286+
int32_t fil = kopen4load(filename, 0);
2287+
2288+
if (fil == -1)
2289+
return -1;
2290+
2291+
savehead_t saveh;
2292+
2293+
int32_t i = sv_loadheader(fil, 0, &saveh);
2294+
2295+
if (i && (i != 2 && i != 3))
2296+
goto corrupt;
2297+
2298+
int32_t screenshotofs;
2299+
2300+
if (kread(fil, &screenshotofs, 4) != 4)
2301+
goto corrupt;
2302+
2303+
if (screenshotofs)
2304+
{
2305+
if (kdfread(data, 320, 200, fil) != 200)
2306+
{
2307+
// OSD_Printf("G_LoadSaveHeaderNew(%d): failed reading screenshot\n", spot);
2308+
goto corrupt;
2309+
}
2310+
}
2311+
else
2312+
{
2313+
kclose(fil);
2314+
return -1;
2315+
}
2316+
2317+
kclose(fil);
2318+
23192319
char pstr[BMAX_PATH];
23202320

23212321
Bstrcpy(pstr, filename);
@@ -2325,18 +2325,18 @@ int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data)
23252325
int32_t pfil;
23262326

23272327
if ((pfil = kopen4load(pstr, 0)) == -1)
2328-
{
2329-
LOGE("couldn't load %s", pstr);
2330-
return -1;
2331-
}
2332-
2333-
kread(pfil, pal, 768);
2334-
kclose(pfil);
2335-
2336-
return 0;
2337-
2338-
corrupt:
2339-
kclose(fil);
2340-
return 1;
2341-
}
2342-
#endif
2328+
{
2329+
LOGE("couldn't load %s", pstr);
2330+
return -1;
2331+
}
2332+
2333+
kread(pfil, pal, 768);
2334+
kclose(pfil);
2335+
2336+
return 0;
2337+
2338+
corrupt:
2339+
kclose(fil);
2340+
return 1;
2341+
}
2342+
#endif

0 commit comments

Comments
 (0)