Skip to content

Commit

Permalink
Update 3DS port
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHuu committed Nov 10, 2024
1 parent 896065f commit 7ce9849
Show file tree
Hide file tree
Showing 33 changed files with 1,094 additions and 451 deletions.
32 changes: 15 additions & 17 deletions Makefile.ctr
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ SOURCES := src src/game src/int src/int/support src/plib/assoc src/plib/colo
DATA := data
INCLUDES := src src/game src/int src/int/support src/plib/assoc src/plib/color src/plib/db src/plib/gnw \
src/platform/ctr third_party/fpattern
GRAPHICS := gfx
GFXBUILD := $(BUILD)
#ROMFS := os/ctr/romfs
GRAPHICS := os/ctr/gfx
ROMFS := romfs
GFXBUILD := $(ROMFS)/gfx

APP_TITLE := Fallout
APP_DESCRIPTION := Fallout-ce port for 3DS
Expand All @@ -50,7 +50,7 @@ APP_PRODUCT_CODE := CTR-P-FALLOUT
APP_UNIQUE_ID := 0xDA3A4
APP_VERSION_MAJOR := 0
APP_VERSION_MINOR := 0
APP_VERSION_MICRO := 4
APP_VERSION_MICRO := 5

APP_RSF := $(TOPDIR)/os/ctr/template.rsf
APP_ICON := $(TOPDIR)/os/ctr/icon.png
Expand All @@ -68,18 +68,21 @@ REMOTE_IP := 192.168.1.96
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft

CFLAGS := -g -Wall -O2 -mword-relocations \
CFLAGS := -g -Wall -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)

CFLAGS += $(INCLUDE) -D__3DS__ -DSDL_MAIN_HANDLED

CFLAGS += -Ofast -funroll-loops -fno-math-errno -ffast-math -flto=auto
#CFLAGS += -D_DEBUG -D_DEBUG_OVERLAY -D_DEBUG_LINK

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17

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

LIBS := -lSDL2 -lz -lcitro3d -lctru -lm
LIBS := -lSDL2 -lcitro2d -lcitro3d -lctru -lm -lz

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
Expand Down Expand Up @@ -109,6 +112,7 @@ CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
Expand Down Expand Up @@ -184,7 +188,7 @@ endif
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(TARGET).cia $(TARGET).elf $(GFXBUILD)
@rm -fr $(BUILD) $(TARGET).3dsx $(TARGET).cia $(TARGET).elf $(GFXBUILD) $(ROMFS)

3dslink: all
@3dslink -a $(REMOTE_IP) $(OUTPUT).3dsx
Expand All @@ -210,7 +214,7 @@ else

COMMON_MAKEROM_PARAMS := -rsf $(APP_RSF) -target t -exefslogo -elf $(OUTPUT).elf -icon $(TARGET).smdh \
-banner $(TARGET).bnr -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(APP_PRODUCT_CODE)" \
-DAPP_UNIQUE_ID="$(APP_UNIQUE_ID)" -DAPP_SYSTEM_MODE="64MB" -DAPP_SYSTEM_MODE_EXT="Legacy" \
-DAPP_UNIQUE_ID="$(APP_UNIQUE_ID)" -DAPP_SYSTEM_MODE="80MB" -DAPP_SYSTEM_MODE_EXT="124MB" \
-major "$(APP_VERSION_MAJOR)" -minor "$(APP_VERSION_MINOR)" -micro "$(APP_VERSION_MICRO)"

ifneq ($(ROMFS),)
Expand Down Expand Up @@ -264,18 +268,12 @@ $(TARGET).smdh : $(APP_ICON)
@$(bin2o)

#---------------------------------------------------------------------------------
.PRECIOUS : %.t3x
.PRECIOUS : %.t3x %.shbin
#---------------------------------------------------------------------------------
%.t3x.o %_t3x.h : %.t3x
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)

#---------------------------------------------------------------------------------
%.t3x %.h : %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@tex3ds -i $< -H $*.h -d $*.d -o $*.t3x
$(SILENTMSG) $(notdir $<)
$(bin2o)

#---------------------------------------------------------------------------------
%.shbin.o %_shbin.h : %.shbin
Expand Down
Binary file added os/ctr/gfx/frame_320x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions os/ctr/gfx/frame_tex.t3s
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--atlas -f rgb888 -z auto

frame_320x240.png
4 changes: 0 additions & 4 deletions os/ctr/romfs/.gitignore

This file was deleted.

11 changes: 10 additions & 1 deletion src/game/art.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include "plib/gnw/grbuf.h"
#include "plib/gnw/memory.h"

#ifdef __3DS__
#include "platform/ctr/ctr_sys.h"
#endif

namespace fallout {

typedef struct ArtListDescription {
Expand Down Expand Up @@ -89,7 +93,12 @@ int art_init()
if (!config_get_value(&game_config, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_ART_CACHE_SIZE_KEY, &cacheSize)) {
cacheSize = 8;
}

#ifdef __3DS__
#ifdef _DEBUG
debug_printf("Setting cacheSize: %9.2f \n",((heapAvailableAtStart / (1024.0f * 1024.0f)) - 16));
#endif
cacheSize = ((heapAvailableAtStart / (1024.0f * 1024.0f)) - 16);
#endif
if (!cache_init(&art_cache, art_data_size, art_data_load, art_data_free, cacheSize << 20)) {
debug_printf("cache_init failed in art_init\n");
return -1;
Expand Down
4 changes: 3 additions & 1 deletion src/game/automap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ void automap(bool isInGame, bool isUsingScanner)

#ifdef __3DS__
setPreviousRectMap(0);
setActiveRectMap(DISPLAY_AUTOMAP);
setRectMapPos(DISPLAY_DYNAMIC, automapWindowX, automapWindowY,
AUTOMAP_WINDOW_WIDTH, AUTOMAP_WINDOW_HEIGHT, false);
setActiveRectMap(DISPLAY_DYNAMIC);
#endif

bool done = false;
Expand Down
4 changes: 2 additions & 2 deletions src/game/bmpdlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ int dialog_out(const char* title, const char** body, int bodyLength, int x, int

#ifdef __3DS__
setPreviousRectMap(1);
setRectMapPos(DISPLAY_PAUSE_CONFIRM, x, y, backgroundWidth, backgroundHeight, false);
setActiveRectMap(DISPLAY_PAUSE_CONFIRM);
setRectMapPos(DISPLAY_DYNAMIC, x, y, backgroundWidth, backgroundHeight, false);
setActiveRectMap(DISPLAY_DYNAMIC); //DISPLAY_PAUSE_CONFIRM
#endif

win_draw(win);
Expand Down
5 changes: 4 additions & 1 deletion src/game/combat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4365,7 +4365,10 @@ static int get_called_shot_location(Object* critter, int* hit_location, int hit_

#ifdef __3DS__
setPreviousRectMap(0);
setActiveRectMap(DISPLAY_VATS);
setRectMapPos(DISPLAY_DYNAMIC, calledShotWindowX, calledShotWindowY,
CALLED_SHOT_WINDOW_WIDTH, CALLED_SHOT_WINDOW_HEIGHT, false);

setActiveRectMap(DISPLAY_DYNAMIC);
#endif

int eventCode;
Expand Down
38 changes: 24 additions & 14 deletions src/game/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "plib/gnw/text.h"

#ifdef __3DS__
#include "platform/ctr/ctr_gfx.h"
#include "platform/ctr/ctr_rectmap.h"
#endif

Expand Down Expand Up @@ -656,14 +657,10 @@ int editor_design(bool isCreationMode)
DrawInfoWin();
}
}

#ifdef __3DS__
if (!isCreationMode) {
setPreviousRectMap(0);
setActiveRectMap(DISPLAY_CHAR);
}
setPreviousRectMap(0);
setActiveRectMap(DISPLAY_CHAR);
#endif

int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
Expand Down Expand Up @@ -783,9 +780,8 @@ int editor_design(bool isCreationMode)
}
}
#ifdef __3DS__
if (!isCreationMode) {
setActiveRectMap(getPreviousRectMap(0));
}
offsetY_char = 0;
setActiveRectMap(getPreviousRectMap(0));
#endif
CharEditEnd();

Expand Down Expand Up @@ -1487,7 +1483,7 @@ int get_input_str(int win, int cancelKeyCode, char* text, int maxLength, int x,

win_draw(win);
#ifdef __3DS__
ctr_input_swkbd("", copy, text);
ctr_input_swkbd("Enter your name", text, text);
buf_fill(windowBuffer + windowWidth * y + x, nameWidth, text_height(), windowWidth, backgroundColor);
text_to_buf(windowBuffer + windowWidth * y + x, copy, windowWidth, windowWidth, textColor);
renderPresent();
Expand Down Expand Up @@ -3069,7 +3065,9 @@ static int AgeWindow()
if (prevBtn != -1) {
win_register_button_sound_func(prevBtn, gsound_med_butt_press, NULL);
}

#ifdef __3DS__
isAgeWindow = true;
#endif
while (true) {
sharedFpsLimiter.mark();

Expand All @@ -3087,6 +3085,9 @@ static int AgeWindow()
}

win_delete(win);
#ifdef __3DS__
isAgeWindow = false;
#endif
return 0;
} else if (keyCode == KEY_ESCAPE || game_user_wants_to_quit != 0) {
break;
Expand Down Expand Up @@ -3195,7 +3196,9 @@ static int AgeWindow()
sharedFpsLimiter.throttle();
}
}

#ifdef __3DS__
isAgeWindow = false;
#endif
stat_set_base(obj_dude, STAT_AGE, savedAge);
PrintAgeBig();
PrintBasicStat(RENDER_ALL_STATS, 0, 0);
Expand All @@ -3217,6 +3220,9 @@ static void SexWindow()
int genderWindowX = (screenGetWidth() - EDITOR_WINDOW_WIDTH) / 2 + 9
+ GInfo[EDITOR_GRAPHIC_NAME_ON].width
+ GInfo[EDITOR_GRAPHIC_AGE_ON].width;
#ifdef __3DS__
genderWindowX -= 40;
#endif
int genderWindowY = (screenGetHeight() - EDITOR_WINDOW_HEIGHT) / 2;
int win = win_add(genderWindowX, genderWindowY, windowWidth, windowHeight, 256, WINDOW_MODAL | WINDOW_DONT_MOVE_TOP);

Expand Down Expand Up @@ -3296,7 +3302,9 @@ static void SexWindow()

int savedGender = stat_level(obj_dude, STAT_GENDER);
win_set_button_rest_state(btns[savedGender], 1, 0);

#ifdef __3DS__
isSexWindow = true;
#endif
while (true) {
sharedFpsLimiter.mark();

Expand Down Expand Up @@ -3335,7 +3343,9 @@ static void SexWindow()
renderPresent();
sharedFpsLimiter.throttle();
}

#ifdef __3DS__
isSexWindow = false;
#endif
PrintGender();
win_delete(win);
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/elevator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,11 @@ static int elevator_start(int elevator)
return -1;
}
#ifdef __3DS__
setRectMapPos(DISPLAY_ELEVATOR, elevatorWindowX, elevatorWindowY,
setRectMapPos(DISPLAY_DYNAMIC, elevatorWindowX, elevatorWindowY,
GInfo[ELEVATOR_FRM_BACKGROUND].width, GInfo[ELEVATOR_FRM_BACKGROUND].height, false);

setPreviousRectMap(0);
setActiveRectMap(DISPLAY_ELEVATOR);
setActiveRectMap(DISPLAY_DYNAMIC);
#endif
win_buf = win_get_buf(elev_win);
memcpy(win_buf, (unsigned char*)grphbmp[ELEVATOR_FRM_BACKGROUND], GInfo[ELEVATOR_FRM_BACKGROUND].width * GInfo[ELEVATOR_FRM_BACKGROUND].height);
Expand Down
12 changes: 12 additions & 0 deletions src/game/endgame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include "plib/gnw/svga.h"
#include "plib/gnw/text.h"

#ifdef __3DS__
#include "platform/ctr/ctr_rectmap.h"
#endif

namespace fallout {

// The maximum number of subtitle lines per slide.
Expand Down Expand Up @@ -340,6 +344,11 @@ static int endgame_init()

palette_fade_to(black_palette);

#ifdef __3DS__
setPreviousRectMap(0);
setActiveRectMap(DISPLAY_ENDGAME);
#endif

// CE: Every slide has a separate color palette which is incompatible with
// main color palette. Setup overlay to hide everything.
gEndgameEndingOverlay = win_add(0, 0, screenGetWidth(), screenGetHeight(), colorTable[0], WINDOW_MOVE_ON_TOP);
Expand Down Expand Up @@ -435,6 +444,9 @@ static void endgame_exit()
if (endgame_map_enabled) {
map_enable_bk_processes();
}
#ifdef __3DS__
setActiveRectMap(getPreviousRectMap(0));
#endif
}

// 0x438D14
Expand Down
12 changes: 9 additions & 3 deletions src/game/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "plib/gnw/text.h"

#ifdef __3DS__
#include "platform/ctr/ctr_input.h"
#include "platform/ctr/ctr_rectmap.h"
#endif

Expand Down Expand Up @@ -425,7 +426,12 @@ void game_exit()
FMExit();
windowClose();
db_exit();
#ifdef __3DS__
gconfig_exit(false); // only save when config is actually changed..
#else
gconfig_exit(true);
#endif

}

// 0x43B748
Expand Down Expand Up @@ -665,9 +671,6 @@ int game_handle_input(int eventCode, bool isInCombatMode)
if (mode != -1) {
gmouse_set_cursor(MOUSE_CURSOR_USE_CROSSHAIR);
gmouse_3d_set_mode(mode);
#ifdef __3DS__
setActiveRectMap(DISPLAY_FIELD);
#endif
}
}
break;
Expand Down Expand Up @@ -1346,6 +1349,9 @@ static void game_splash_screen()
mem_free(palette);

config_set_value(&game_config, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_SPLASH_KEY, splash + 1);
#ifdef __3DS__
gconfig_save();
#endif
}

} // namespace fallout
Loading

0 comments on commit 7ce9849

Please sign in to comment.