diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 209a154b..a177b23e --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +## Build folder +/build/* ## Build files *.v64 *.elf diff --git a/Makefile b/Makefile index 0a3dda81..1fb66ed5 100644 --- a/Makefile +++ b/Makefile @@ -19,15 +19,15 @@ OBJDIR = ./obj BINDIR = ./bin TOOLSDIR = ./tools -LINK_FLAGS = -O1 -L$(ROOTDIR)/lib -L$(ROOTDIR)/mips64-elf/lib -ldragon -lmikmod -lmad -lyaml -lc -lm -ldragonsys -lnosys $(LIBS) -Tn64ld.x -PROG_NAME = OS64 -CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O1 -I$(INCDIR) -I$(ROOTDIR)/include -I$(ROOTDIR)/mips64-elf/include -lpthread -lrt -D_REENTRANT -DUSE_TRUETYPE $(SET_DEBUG) +LINK_FLAGS = -O3 -L$(ROOTDIR)/lib -L$(ROOTDIR)/mips64-elf/lib -ldragon -lmad -lmikmod -lyaml -lc -lm -ldragonsys -lnosys $(LIBS) -Tn64ld.x +PROG_NAME = OS64P +CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O3 -I$(INCDIR) -I$(ROOTDIR)/include -I$(ROOTDIR)/mips64-elf/include -lpthread -lrt -D_REENTRANT -DUSE_TRUETYPE $(SET_DEBUG) ASFLAGS = -mtune=vr4300 -march=vr4300 CC = $(GCCN64PREFIX)gcc AS = $(GCCN64PREFIX)as LD = $(GCCN64PREFIX)ld OBJCOPY = $(GCCN64PREFIX)objcopy - + SOURCES := $(wildcard $(SRCDIR)/*.c) OBJECTS = $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o) diff --git a/README.md b/README.md index 122bbc35..09246a6f 100644 --- a/README.md +++ b/README.md @@ -2,76 +2,33 @@ Alternative Everdrive64 menu - -`Altra64` is an open source menu for [Everdrive64](http://krikzz.com/) and is based on a fork of alt64 which was +`Altra64` is an open source menu for [Everdrive64](http://krikzz.com/) and ed64+ and is based on a fork of alt64 which was originally written by saturnu, and released on the [Everdrive64 forum](http://krikzz.com/forum/index.php?topic=816.0). ## Building -If you want to build the menu, you need an n64 toolchain. When using windows 10 or Ubuntu, installation is totally automated through a script. - -### Dependencies (installed automatically) -* Windows 10 (Aniversary Update or above) / Ubuntu 16.04 (or above) -* [libdragon](https://github.com/DragonMinded/libdragon) -* [libmikmod (with n64 driver)](https://github.com/networkfusion/libmikmod) -* [libmad-n64](https://github.com/networkfusion/libmad-n64) -* [libyaml](http://pyyaml.org/wiki/LibYAML) - -### Build the Toolchain - -*You may skip this step if it's already installed.* - -Clone this `Altra64` repo to a directory of your choice. - -On Windows 10: -* Ensure that ["Windows Subsystem For Linux (Ubuntu)"](https://msdn.microsoft.com/en-gb/commandline/wsl/install_guide) is installed. -* browse to the tools directory and double click on ```setup-wsfl.cmd```. - -On Ubuntu, browse to the tools directory and run the command ```$ chmod +x ./setup-linux.sh;source ./setup-linux.sh``` +If you want to build the menu, you need an n64 toolchain. This is terrible to build, moparisthebest ended up creating a Dockerfile in the docker folder, instructions included in it. +Or if you trust him, you can use the one he built and pushed to docker hub, [moparisthebest/altra64-dev](https://hub.docker.com/r/moparisthebest/altra64-dev) ### Build `Altra64` To build the Rom -from the projects root directory, -On Windows 10 run -``` -> build -``` -on linux -``` -$ make -``` -If it all worked, you will find `OS64.v64` in the `Altra64` bin directory. - -### Debug Build `Altra64` -To build the debug version of the Rom - -from the projects root directory, -On Windows 10 run -``` -> build debug -``` -on linux -``` -$ make debug -``` -If it all worked, you will find `OS64.v64` in the `Altra64` bin directory. +from the projects root directory, with docker installed + +$ docker run --rm -v "$(pwd):/build" moparisthebest/altra64-dev make + +If it all worked, you will find `OS64.v64` in the `bin` directory. ### Clean `Altra64` + Finally, we can clean the build objects from the project -from the projects root directory, -On Windows 10 run -``` -> build clean -``` -on linux -``` -$ make clean -``` +from the projects root directory + +$ docker run --rm -v "$(pwd):/build" moparisthebest/altra64-dev make clean Enjoy! diff --git a/build.cmd b/build.cmd old mode 100644 new mode 100755 diff --git a/doc/functions.txt b/doc/functions.txt old mode 100644 new mode 100755 diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..0c7f0aef --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,25 @@ + +# to build and test: +# docker build -t altra64-dev . && docker run --rm -v "$(pwd):/build" -it altra64-dev + +# to use to compile altra64 (or other n64 stuff I guess) +# docker run --rm -v "$(pwd):/build" altra64-dev make + +#FROM ubuntu:18.04 +FROM ubuntu:16.04 + +RUN mkdir /build + +COPY setup-linux.sh /usr/bin/setup-linux.sh + +# run it then delete all build artifacts +RUN /usr/bin/setup-linux.sh && rm -rf /root/* + +ENV N64_INST=/usr/local/libdragon +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/libdragon/bin + +VOLUME [ "/build" ] + +WORKDIR /build + +CMD ["bash"] diff --git a/docker/setup-linux.sh b/docker/setup-linux.sh new file mode 100644 index 00000000..1da68346 --- /dev/null +++ b/docker/setup-linux.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# +# Copyright (c) 2017 The Altra64 project contributors +# See LICENSE file in the project root for full license information. +# + +set -euxo pipefail + +# Download and install latest updates for the system [sudo req.] +apt-get update +apt-get -y upgrade + +# Install essential packages [sudo req.] +apt-get -y install wget build-essential git texinfo libc6 libgmp-dev libmpfr-dev libmpc-dev libpng-dev zlib1g-dev libtool autoconf + +# change to the users root directory +cd ~/ + +# add a system variable and make it perminent +# echo 'N64_INST=/usr/local/libdragon' >> /etc/environment +# echo 'export N64_INST=/usr/local/libdragon' >> ~/.bashrc +export N64_INST=/usr/local/libdragon +# source ~/.bashrc + +# Pull the latest libdragon source code and make a build directory +git clone https://github.com/dragonminded/libdragon.git +# set to correct commit + +# fix issues with the build scripts +sed -i -- 's|${N64_INST:-/usr/local}|/usr/local/libdragon|g' libdragon/tools/build +sed -i -- 's|--with-newlib|--with-newlib --with-system-zlib|g' libdragon/tools/build + +sed -i -- 's| -lpng|\nLDLIBS = -lpng|g' libdragon/tools/mksprite/Makefile +sed -i -- 's| -Werror| -w|g' libdragon/tools/mksprite/Makefile + +# make a build folder for libdragon +mkdir libdragon/build_gcc +cp libdragon/tools/build-toolchain.sh libdragon/build/build-toolchain.sh + +# run the build script (this will take a while! and if not sudo, will ask for password mid flow!) +cd libdragon/build +./build-toolchain.sh + +cd .. +# run the install script [sudo req] +make +make install +make tools +make tools-install + +cd .. +# install libmikmod (custom version) +git clone https://github.com/n64-tools/libmikmod +cd libmikmod/n64 +make +make install +cd .. # we have are in a subfolder, this is not a duplicate... + +cd .. +# install libyaml +git clone https://github.com/yaml/libyaml +cd libyaml +./bootstrap +#$(N64_INST) converterd to $N64_INST below otherwise it will not run on WSFL +export PATH=$PATH:$N64_INST/bin +CFLAGS="-std=gnu99 -march=vr4300 -mtune=vr4300" \ +LDFLAGS="-L$N64_INST/lib -Tn64ld.x" \ +LIBS="-ldragon -lc -ldragonsys -lnosys" \ +./configure --host=mips64-elf --prefix=$N64_INST +make +make install + +cd .. +# install libmad (custom version) +git clone https://github.com/n64-tools/libmad +cd libmad +export PATH=$PATH:$N64_INST/bin +CFLAGS="-std=gnu99 -march=vr4300 -mtune=vr4300" \ +LDFLAGS="-L$N64_INST/lib -Tn64ld.x" \ +LIBS="-ldragon -lc -ldragonsys -lnosys" \ +./configure --host=mips64-elf --prefix=$N64_INST +make +make install + +cd .. + +# Perform cleanup +apt-get -y autoremove +apt-get autoclean + +echo 'export N64_INST=/usr/local/libdragon' >> ~/.bashrc +echo 'export PATH="$PATH:$N64_INST/bin"' >> ~/.bashrc + diff --git a/inc/chksum64.h b/inc/chksum64.h old mode 100644 new mode 100755 diff --git a/inc/cic.h b/inc/cic.h old mode 100644 new mode 100755 diff --git a/inc/debug.h b/inc/debug.h old mode 100644 new mode 100755 diff --git a/inc/diskio.h b/inc/diskio.h old mode 100644 new mode 100755 diff --git a/inc/errors.h b/inc/errors.h old mode 100644 new mode 100755 diff --git a/inc/everdrive.h b/inc/everdrive.h old mode 100644 new mode 100755 diff --git a/inc/ff.h b/inc/ff.h old mode 100644 new mode 100755 diff --git a/inc/ffconf.h b/inc/ffconf.h old mode 100644 new mode 100755 diff --git a/inc/font_patch/font.h b/inc/font_patch/font.h old mode 100644 new mode 100755 diff --git a/inc/font_patch/info.txt b/inc/font_patch/info.txt old mode 100644 new mode 100755 diff --git a/inc/hashtable.h b/inc/hashtable.h old mode 100644 new mode 100755 diff --git a/inc/image.h b/inc/image.h old mode 100644 new mode 100755 diff --git a/inc/ini.h b/inc/ini.h old mode 100644 new mode 100755 diff --git a/inc/integer.h b/inc/integer.h old mode 100644 new mode 100755 diff --git a/inc/main.h b/inc/main.h old mode 100644 new mode 100755 diff --git a/inc/mem.h b/inc/mem.h old mode 100644 new mode 100755 diff --git a/inc/memorypak.h b/inc/memorypak.h old mode 100644 new mode 100755 diff --git a/inc/menu.h b/inc/menu.h old mode 100644 new mode 100755 index 4ac1123f..95cdf844 --- a/inc/menu.h +++ b/inc/menu.h @@ -11,5 +11,7 @@ extern int text_offset; void printText(char *msg, int x, int y, display_context_t dcon); void menu_about(display_context_t disp); +void menu_controls(display_context_t disp); +void menu_delete(display_context_t disp, bool isdir); #endif diff --git a/inc/mp3.h b/inc/mp3.h old mode 100644 new mode 100755 diff --git a/inc/regsinternal.h b/inc/regsinternal.h old mode 100644 new mode 100755 diff --git a/inc/rom.h b/inc/rom.h old mode 100644 new mode 100755 index 783676d7..a5113e83 --- a/inc/rom.h +++ b/inc/rom.h @@ -129,7 +129,7 @@ #define IO_WRITE(addr,data) (*(volatile u32*)PHYS_TO_K1(addr)=(u32)(data)) #define SAVE_SIZE_SRAM 32768 -#define SAVE_SIZE_SRAM96 131072 +#define SAVE_SIZE_SRAM96 131072 //TODO: or should this be 98304 #define SAVE_SIZE_EEP4k 512 #define SAVE_SIZE_EEP16k 2048 #define SAVE_SIZE_FLASH 131072 diff --git a/inc/sd.h b/inc/sd.h old mode 100644 new mode 100755 diff --git a/inc/sound.h b/inc/sound.h old mode 100644 new mode 100755 diff --git a/inc/sram.h b/inc/sram.h old mode 100644 new mode 100755 diff --git a/inc/stb_image.h b/inc/stb_image.h old mode 100644 new mode 100755 diff --git a/inc/stb_truetype.h b/inc/stb_truetype.h old mode 100644 new mode 100755 diff --git a/inc/strlib.h b/inc/strlib.h old mode 100644 new mode 100755 diff --git a/inc/sys.h b/inc/sys.h old mode 100644 new mode 100755 diff --git a/inc/types.h b/inc/types.h old mode 100644 new mode 100755 diff --git a/inc/usb.h b/inc/usb.h old mode 100644 new mode 100755 diff --git a/inc/utils.h b/inc/utils.h old mode 100644 new mode 100755 diff --git a/inc/version.h b/inc/version.h old mode 100644 new mode 100755 diff --git a/res/ALT64.INI b/res/ALT64.INI old mode 100644 new mode 100755 index 9cf6220a..31dfce46 --- a/res/ALT64.INI +++ b/res/ALT64.INI @@ -1,32 +1,29 @@ ; alt64 config file -[ed64] ; Menu config -build=18 ; Release build number -border_color_1=FFFFFFFF ; 0x00000080 RGBT -border_color_2=3F3F3FFF ; 0x3F3F3FFF RGBT 00000060 w light -box_color=000000B6 ; 0x00000080 RGBT -selection_color=80008070 ; 0x80008070 RGBT 6495ED60 -list_font_color=CDC9C940 ; 0x80008070 RGBT 6495ED60 -list_dir_font_color=FFFFE040 ; 0x80008070 RGBT 6495ED60 -selection_font_color=FFB90FFF ; 0x80008070 RGBT 6495ED60 -text_offset=0 ; shift menu horizontal e.g. -1 -cd_behaviour=1 ; 0=first entry 1=last entry -scroll_behaviour=0 ; 0=page-system 1=classic -quick_boot=1 ; 'START' boots last rom -sound_on=1 ; sounds 1=on 0=off -page_display=1 ; display page -tv_mode=2 ; 1=ntsc 2=pal 3=mpal 0=force_off -enable_colored_list=1 ; 1=enable 0=disalbe -ext_type=0 ; 0=classic 1=OS64 -sd_speed=2 ; 1=25MHz 2=50MHz -background_image=background.png ; backgrund png image 320x240 32bit -hide_sysfolder=1 ; 1=hide 0=don't hide -mempak_path=/MEMPAKS/ ; surround with slashes -save_path=SDSAVE ; save directory inside ED64 +[ed64] ; Menu config +build=20 ; Release build number +border_color_1=FFFFFFFF ; 0x00000080 RGBT +border_color_2=3F3F3FFF ; 0x3F3F3FFF RGBT 00000060 w light +box_color=000000B6 ; 0x00000080 RGBT +selection_color=80008070 ; 0x80008070 RGBT 6495ED60 +list_font_color=CDC9C940 ; 0x80008070 RGBT 6495ED60 +list_dir_font_color=FFFFE040 ; 0x80008070 RGBT 6495ED60 +selection_font_color=FFB90FFF ; 0x80008070 RGBT 6495ED60 +text_offset=0 ; shift menu horizontal e.g. -1 +cd_behaviour=1 ; 0=first entry 1=last entry +scroll_behaviour=0 ; 0=page-system 1=classic +quick_boot=1 ; 'START' boots last rom +sound_on=1 ; sounds 1=on 0=off +bgm_on=1 ; music 1=on 0=off +page_display=1 ; display page +tv_mode=0 ; 1=ntsc 2=pal 3=mpal 0=force_off +enable_colored_list=1 ; 1=enable 0=disable +ext_type=1 ; 0=classic 1=OS64 +sd_speed=2 ; 1=25MHz 2=50MHz +background_image= ; backgrund png image 320x240 32bit +hide_sysfolder=1 ; 1=hide 0=don't hide +mempak_path=/MEMPAKS/ ; surround with slashes +save_path=SDSAVE ; save directory inside ED64 [user] -name = Altra64 ; Username - -[gblite] -save_path=/ED64/SDSAVE/ ; save directory surround with slashes -tv_mode=0 ; 1=ntsc 2=pal 3=mpal 0=force_off +name = Altra64 ; Username diff --git a/res/filesystem/sounds/bamboo.wav b/res/filesystem/sounds/bamboo.wav old mode 100644 new mode 100755 diff --git a/res/filesystem/sounds/bgm21.it b/res/filesystem/sounds/bgm21.it old mode 100644 new mode 100755 diff --git a/res/filesystem/sounds/done.wav b/res/filesystem/sounds/done.wav old mode 100644 new mode 100755 diff --git a/res/filesystem/sounds/ed64_mono.wav b/res/filesystem/sounds/ed64_mono.wav old mode 100644 new mode 100755 diff --git a/res/filesystem/sounds/warning.wav b/res/filesystem/sounds/warning.wav old mode 100644 new mode 100755 diff --git a/res/filesystem/sprites/background.png b/res/filesystem/sprites/background.png new file mode 100644 index 00000000..45fa33b9 Binary files /dev/null and b/res/filesystem/sprites/background.png differ diff --git a/res/filesystem/sprites/background.sprite b/res/filesystem/sprites/background.sprite old mode 100644 new mode 100755 index d4ccae78..8d1bdb2e Binary files a/res/filesystem/sprites/background.sprite and b/res/filesystem/sprites/background.sprite differ diff --git a/res/filesystem/sprites/n64controller.png b/res/filesystem/sprites/n64controller.png new file mode 100644 index 00000000..77ef983c Binary files /dev/null and b/res/filesystem/sprites/n64controller.png differ diff --git a/res/filesystem/sprites/n64controller.sprite b/res/filesystem/sprites/n64controller.sprite old mode 100644 new mode 100755 index 437d2b81..f880a0ba Binary files a/res/filesystem/sprites/n64controller.sprite and b/res/filesystem/sprites/n64controller.sprite differ diff --git a/res/filesystem/sprites/old/background.png b/res/filesystem/sprites/old/background.png new file mode 100644 index 00000000..3431ec21 Binary files /dev/null and b/res/filesystem/sprites/old/background.png differ diff --git a/res/filesystem/sprites/old/background.sprite b/res/filesystem/sprites/old/background.sprite new file mode 100644 index 00000000..d4ccae78 Binary files /dev/null and b/res/filesystem/sprites/old/background.sprite differ diff --git a/res/filesystem/sprites/old/n64controller.png b/res/filesystem/sprites/old/n64controller.png new file mode 100644 index 00000000..92e59429 Binary files /dev/null and b/res/filesystem/sprites/old/n64controller.png differ diff --git a/res/filesystem/sprites/old/n64controller.sprite b/res/filesystem/sprites/old/n64controller.sprite new file mode 100644 index 00000000..437d2b81 Binary files /dev/null and b/res/filesystem/sprites/old/n64controller.sprite differ diff --git a/res/filesystem/sprites/old/splash.png b/res/filesystem/sprites/old/splash.png new file mode 100644 index 00000000..9cc4f34d Binary files /dev/null and b/res/filesystem/sprites/old/splash.png differ diff --git a/res/filesystem/sprites/old/splash.sprite b/res/filesystem/sprites/old/splash.sprite new file mode 100644 index 00000000..76810715 Binary files /dev/null and b/res/filesystem/sprites/old/splash.sprite differ diff --git a/res/filesystem/sprites/splash.png b/res/filesystem/sprites/splash.png new file mode 100644 index 00000000..fba3dff9 Binary files /dev/null and b/res/filesystem/sprites/splash.png differ diff --git a/res/filesystem/sprites/splash.sprite b/res/filesystem/sprites/splash.sprite old mode 100644 new mode 100755 index 76810715..af3e979a Binary files a/res/filesystem/sprites/splash.sprite and b/res/filesystem/sprites/splash.sprite differ diff --git a/res/header.ed64 b/res/header.ed64 old mode 100644 new mode 100755 diff --git a/src/chksum64.c b/src/chksum64.c old mode 100644 new mode 100755 diff --git a/src/cic.c b/src/cic.c old mode 100644 new mode 100755 diff --git a/src/debug.c b/src/debug.c old mode 100644 new mode 100755 diff --git a/src/diskio.c b/src/diskio.c old mode 100644 new mode 100755 diff --git a/src/everdrive.c b/src/everdrive.c old mode 100644 new mode 100755 diff --git a/src/ff.c b/src/ff.c old mode 100644 new mode 100755 diff --git a/src/ffsystem.c b/src/ffsystem.c old mode 100644 new mode 100755 diff --git a/src/ffunicode.c b/src/ffunicode.c old mode 100644 new mode 100755 diff --git a/src/hashtable.c b/src/hashtable.c old mode 100644 new mode 100755 diff --git a/src/image.c b/src/image.c old mode 100644 new mode 100755 diff --git a/src/ini.c b/src/ini.c old mode 100644 new mode 100755 diff --git a/src/main.c b/src/main.c index 79634f83..9b23f426 100644 --- a/src/main.c +++ b/src/main.c @@ -49,6 +49,14 @@ #include "menu.h" #include "cic.h" +#define ED64PLUS + +#ifdef ED64PLUS +#define ED64_FIRMWARE_PATH "ED64P" +#else +#define ED64_FIRMWARE_PATH "ED64" +#endif + #ifdef USE_TRUETYPE #define STB_TRUETYPE_IMPLEMENTATION #include "stb_truetype.h" @@ -95,6 +103,7 @@ typedef struct char *mempak_path; char *save_path; int sound_on; + int bgm_on; int page_display; int tv_mode; int quick_boot; @@ -142,7 +151,6 @@ u16 cursor_history_pos = 0; u8 empty = 0; int mp3playing = 0; -u8 gb_load_y = 0; FATFS *fs; @@ -162,6 +170,8 @@ enum InputMap mpk_quick_backup, mp3, abort_screen, + control_screen, + delete_prompt, }; enum InputMap input_mapping = file_manager; @@ -223,6 +233,7 @@ char *list_dir_font_color_s; char *save_path; u8 sound_on = 0; +u8 bgm_on = 0; u8 page_display = 0; u8 tv_mode = 0; // 1=ntsc 2=pal 3=mpal 0=default automatic u8 quick_boot = 0; @@ -707,7 +718,14 @@ void drawBoxNumber(display_context_t disp, int box) box_color = graphics_make_color(0x00, 0x60, 0x00, 0xC3); drawBox(28, 105, 260, 30, disp); break; //green full filename - + case 12: + box_color = graphics_make_color(0x00, 0x60, 0x00, 0xC3); + drawBox(20, 24, 277, 193, disp); + break; //filebrowser + case 13: + box_color = graphics_make_color(0x60, 0x00, 0x00, 0xD3); + drawBox(28, 105, 260, 40, disp); + break; //delete default: break; } @@ -763,6 +781,10 @@ static int configHandler(void *user, const char *section, const char *name, cons { pconfig->sound_on = atoi(value); } + else if (MATCH("ed64", "bgm_on")) + { + pconfig->bgm_on = atoi(value); + } else if (MATCH("ed64", "page_display")) { pconfig->page_display = atoi(value); @@ -864,7 +886,7 @@ void configure() { msg |= 1 << 14; evd_writeReg(REG_MAX_MSG, msg); - + switch(firm) //need to take into account different default firmware versions for each ED64 version { case 0x0214: @@ -879,7 +901,7 @@ void configure() default: break; } - + sleep(1); evd_init(); } @@ -910,11 +932,11 @@ void romInfoScreen(display_context_t disp, u8 *buff, int silent) { TCHAR filename[64]; sprintf(filename, "%s", buff); - + int swapped = 0; FRESULT result; - + int fsize = 512; //rom-headersize 4096 but the bootcode is not needed unsigned char headerdata[fsize]; //1*512 @@ -964,7 +986,7 @@ void romInfoScreen(display_context_t disp, u8 *buff, int silent) //rom size sprintf(rom_name, "Size: %iMB", fsizeMB); printText(rom_name, 11, -1, disp); - + //unique cart id for gametype unsigned char cartID_str[12]; @@ -1015,7 +1037,7 @@ void romInfoScreen(display_context_t disp, u8 *buff, int silent) sprite_t *n64cover; - sprintf(box_path, "/ED64/boxart/lowres/%c%c.png", headerdata[0x3C], headerdata[0x3D]); + sprintf(box_path, "/"ED64_FIRMWARE_PATH"/boxart/lowres/%c%c.png", headerdata[0x3C], headerdata[0x3D]); FILINFO fnoba; result = f_stat (box_path, &fnoba); @@ -1023,7 +1045,7 @@ void romInfoScreen(display_context_t disp, u8 *buff, int silent) if (result != FR_OK) { //not found - sprintf(box_path, "/ED64/boxart/lowres/00.png"); + sprintf(box_path, "/"ED64_FIRMWARE_PATH"/boxart/lowres/00.png"); } n64cover = loadPng(box_path); @@ -1079,53 +1101,59 @@ sprite_t *loadPng(u8 *png_filename) } -void loadgbrom(display_context_t disp, u8 *buff) +void loadgbrom(display_context_t disp, TCHAR *rom_path) { - FRESULT fr; - FILINFO fno; + drawShortInfoBox(disp, " loading please wait", 0); + FRESULT result; + FIL emufile; + UINT emubytesread; + result = f_open(&emufile, "/"ED64_FIRMWARE_PATH"/gb.v64", FA_READ); - fr = f_stat("/ED64/gblite.z64", &fno); - if (fr == FR_OK) + if (result == FR_OK) { - TCHAR gb_sram_file[64]; + int emufsize = f_size(&emufile); + //load gb emulator + result = + f_read ( + &emufile, /* [IN] File object */ + (void *)0xb0000000, /* [OUT] Buffer to store read data */ + emufsize, /* [IN] Number of bytes to read */ + &emubytesread /* [OUT] Number of bytes read */ + ); - sprintf(gb_sram_file, "/ED64/%s/gblite.SRM", save_path); + f_close(&emufile); + + //load gb rom + FIL romfile; + UINT rombytesread; + result = f_open(&romfile, rom_path, FA_READ); - FRESULT result; - FIL file; - UINT bytesread; - result = f_open(&file, gb_sram_file, FA_WRITE | FA_OPEN_ALWAYS); - if (result == FR_OK) { - static uint8_t sram_buffer[36928]; - - for (int i = 0; i < 36928; i++) - sram_buffer[i] = 0; - - sprintf(sram_buffer, buff); + int romfsize = f_size(&romfile); - UINT bw; result = - f_write ( - &file, /* [IN] Pointer to the file object structure */ - sram_buffer, /* [IN] Pointer to the data to be written */ - 32768, /* [IN] Number of bytes to write */ //TODO: why is this shorter than the sram buffer? - &bw /* [OUT] Pointer to the variable to return number of bytes written */ - ); - - f_close(&file); + f_read ( + &romfile, /* [IN] File object */ + (void *)0xb0200000, /* [OUT] Buffer to store read data */ + romfsize, /* [IN] Number of bytes to read */ + &rombytesread /* [OUT] Number of bytes read */ + ); - sprintf(rom_filename, "gblite"); - gbload = 1; - - loadrom(disp, "/ED64/gblite.z64", 1); - + f_close(&romfile); + + boot_cic = CIC_6102; + boot_save = 5; //flash + force_tv = 0; //no force + cheats_on = 0; //cheats off + checksum_fix_on = 0; + + bootRom(disp, 1); } } } -void loadmsx2rom(display_context_t disp, TCHAR *rom_path) +void loadggrom(display_context_t disp, TCHAR *rom_path) //TODO: this could be merged with MSX { FRESULT romresult; @@ -1137,12 +1165,12 @@ void loadmsx2rom(display_context_t disp, TCHAR *rom_path) { int romfsize = f_size(&romfile); - //max 128KB rom - if (romfsize > 128 * 1024) + //max 512KB rom + if (romfsize > 512 * 1024) { //error - drawShortInfoBox(disp, " error: rom > 128KB", 1); + drawShortInfoBox(disp, " error: rom > 512KB", 1); input_mapping = abort_screen; return; @@ -1154,13 +1182,13 @@ void loadmsx2rom(display_context_t disp, TCHAR *rom_path) FRESULT result; FIL file; UINT bytesread; - result = f_open(&file, "/ED64/ultraMSX2.z64", FA_READ); - + result = f_open(&file, "/"ED64_FIRMWARE_PATH"/UltraSMS.z64", FA_READ); + if (result == FR_OK) { int fsize = f_size(&file); - + result = f_read ( &file, /* [IN] File object */ @@ -1168,35 +1196,34 @@ void loadmsx2rom(display_context_t disp, TCHAR *rom_path) fsize, /* [IN] Number of bytes to read */ &bytesread /* [OUT] Number of bytes read */ ); - + f_close(&file); - + romresult = f_read ( &romfile, /* [IN] File object */ - (void *)0xb0000000 + 0x2df48, /* [OUT] Buffer to store read data */ //TODO: why is the offset this particular number + (void *)0xb0000000 + 0x1b410, /* [OUT] Buffer to store read data */ //TODO: why is the offset this particular number romfsize, /* [IN] Number of bytes to read */ &rombytesread /* [OUT] Number of bytes read */ ); f_close(&romfile); - + boot_cic = CIC_6102; boot_save = 0; //save off/cpak force_tv = 0; //no force cheats_on = 0; //cheats off checksum_fix_on = 0; - + checksum_sdram(); bootRom(disp, 1); } } } } - -void loadggrom(display_context_t disp, TCHAR *rom_path) //TODO: this could be merged with MSX +void loadmsx2rom(display_context_t disp, TCHAR *rom_path) { FRESULT romresult; @@ -1208,8 +1235,8 @@ void loadggrom(display_context_t disp, TCHAR *rom_path) //TODO: this could be me { int romfsize = f_size(&romfile); - //max 512KB rom - if (romfsize > 512 * 1024) + //max 128KB rom + if (romfsize > 128 * 1024) { //error @@ -1225,13 +1252,13 @@ void loadggrom(display_context_t disp, TCHAR *rom_path) //TODO: this could be me FRESULT result; FIL file; UINT bytesread; - result = f_open(&file, "/ED64/UltraSMS.z64", FA_READ); - + result = f_open(&file, "/"ED64_FIRMWARE_PATH"/ultraMSX2.z64", FA_READ); + if (result == FR_OK) { int fsize = f_size(&file); - + result = f_read ( &file, /* [IN] File object */ @@ -1239,48 +1266,31 @@ void loadggrom(display_context_t disp, TCHAR *rom_path) //TODO: this could be me fsize, /* [IN] Number of bytes to read */ &bytesread /* [OUT] Number of bytes read */ ); - + f_close(&file); - + romresult = f_read ( &romfile, /* [IN] File object */ - (void *)0xb0000000 + 0x1b410, /* [OUT] Buffer to store read data */ //TODO: why is the offset this particular number + (void *)0xb0000000 + 0x2df48, /* [OUT] Buffer to store read data */ //TODO: why is the offset this particular number romfsize, /* [IN] Number of bytes to read */ &rombytesread /* [OUT] Number of bytes read */ ); f_close(&romfile); - + boot_cic = CIC_6102; boot_save = 0; //save off/cpak force_tv = 0; //no force cheats_on = 0; //cheats off checksum_fix_on = 0; - + checksum_sdram(); bootRom(disp, 1); } } - } -} - -void rom_load_y(void) -{ - FRESULT fr; - FILINFO fno; - - u8 gb_sram_file[64]; - u8 gb_sram_file2[64]; - sprintf(gb_sram_file, "%c%c%c%c%c%c%c", 'O', 'S', '6', '4', 'P', '/', 'O'); - sprintf(gb_sram_file2, "%s%c%c%c%c%c%c%c%c", gb_sram_file, 'S', '6', '4', 'P', '.', 'v', '6', '4'); - - fr = f_stat(gb_sram_file2, &fno); - if (fr == FR_OK) - { - gb_load_y = 1; } } @@ -1289,7 +1299,7 @@ void loadnesrom(display_context_t disp, TCHAR *rom_path) FRESULT result; FIL emufile; UINT emubytesread; - result = f_open(&emufile, "/ED64/neon64bu.rom", FA_READ); + result = f_open(&emufile, "/"ED64_FIRMWARE_PATH"/neon64bu.rom", FA_READ); if (result == FR_OK) { @@ -1309,11 +1319,11 @@ void loadnesrom(display_context_t disp, TCHAR *rom_path) FIL romfile; UINT rombytesread; result = f_open(&romfile, rom_path, FA_READ); - + if (result == FR_OK) { int romfsize = f_size(&romfile); - + result = f_read ( &romfile, /* [IN] File object */ @@ -1321,15 +1331,15 @@ void loadnesrom(display_context_t disp, TCHAR *rom_path) romfsize, /* [IN] Number of bytes to read */ &rombytesread /* [OUT] Number of bytes read */ ); - + f_close(&romfile); boot_cic = CIC_6102; - boot_save = 0; //save off/cpak + boot_save = 2; //SRAM force_tv = 0; //no force cheats_on = 0; //cheats off checksum_fix_on = 0; - + bootRom(disp, 1); } } @@ -1345,7 +1355,7 @@ void loadrom(display_context_t disp, u8 *buff, int fast) TCHAR filename[64]; sprintf(filename, "%s", buff); - + FRESULT result; FIL file; UINT bytesread = 0; @@ -1397,7 +1407,7 @@ void loadrom(display_context_t disp, u8 *buff, int fast) //rom size sprintf(rom_name, "Size: %iMB", fsizeMB); printText(rom_name, 3, -1, disp); - + //unique cart id for gametype unsigned char cartID_str[12]; @@ -1522,7 +1532,7 @@ int backupSaveData(display_context_t disp) { //backup cart-save on sd after reboot TCHAR config_file_path[32]; - sprintf(config_file_path, "/ED64/%s/LASTROM.CFG", save_path); + sprintf(config_file_path, "/"ED64_FIRMWARE_PATH"/%s/LASTROM.CFG", save_path); u8 save_format; u8 cfg_data[2]; //TODO: this should be a strut? @@ -1568,7 +1578,7 @@ int backupSaveData(display_context_t disp) 1, /* [IN] Number of bytes to write */ &bw /* [OUT] Pointer to the variable to return number of bytes written */ ); - + f_close(&file); TRACE(disp, "Disabling save for subsequent system reboots"); @@ -1628,22 +1638,39 @@ int backupSaveData(display_context_t disp) //write a cart-save from a file to the fpga/cart int saveTypeFromSd(display_context_t disp, char *rom_name, int stype) { - rom_load_y(); TRACE(disp, rom_filename); + const char* save_type_extension = saveTypeToExtension(stype, ext_type); TCHAR fname[256] = {0}; - sprintf(fname, "/ED64/%s/%s.%s", save_path, rom_name, saveTypeToExtension(stype, ext_type)); - - TCHAR fname1[50] = {0}; - sprintf(fname1, "/ED64/%s/", save_path); - printText(fname1, 3, -1, disp); - TCHAR fname2[50] = {0}; - sprintf(fname2, "%s.%s", rom_name, saveTypeToExtension(stype, ext_type)); - printText(fname2, 3, -1, disp); + int save_count = 0; //TODO: once this crosses 9999 bad infinite-loop type things happen, look into that one day + FRESULT result; + FILINFO fnoba; + printText("Finding latest save slot...", 3, -1, disp); + display_show(disp); + while (true) { + sprintf(fname, "/"ED64_FIRMWARE_PATH"/%s/%s.%04x.%s", save_path, rom_name, save_count, save_type_extension); + result = f_stat (fname, &fnoba); + if (result != FR_OK) { + // we found our first missing save slot, break + break; + } + ++save_count; + } + if (save_count > 0) { + // we've went 1 past the end, so back up + sprintf(fname, "Found latest save slot: %04x", --save_count); + printText(fname, 3, -1, disp); + sprintf(fname, "/"ED64_FIRMWARE_PATH"/%s/%s.%04x.%s", save_path, rom_name, save_count, save_type_extension); + } else { + // not even a 0000 was found, so look at the original name before numbering was implemented + printText("No save slot found!", 3, -1, disp); + printText("Looking for non-numbered file...", 3, -1, disp); + sprintf(fname, "/"ED64_FIRMWARE_PATH"/%s/%s.%s", save_path, rom_name, save_type_extension); + } + display_show(disp); int size = saveTypeToSize(stype); // int byte uint8_t cartsave_data[size]; - FRESULT result; FIL file; UINT bytesread; result = f_open(&file, fname, FA_READ); @@ -1678,10 +1705,10 @@ int saveTypeFromSd(display_context_t disp, char *rom_name, int stype) case FR_INVALID_NAME: printText("invalid name error", 11, -1, disp); break; - case FR_DENIED: + case FR_DENIED: printText("denied error", 11, -1, disp); break; - case FR_EXIST: + case FR_EXIST: printText("exist error", 11, -1, disp); break; case FR_TIMEOUT: @@ -1692,23 +1719,20 @@ int saveTypeFromSd(display_context_t disp, char *rom_name, int stype) break; default: break; - } + } printText("no save found", 3, -1, disp); //todo: clear memory area return 0; } - if (gb_load_y != 1) + if (pushSaveToCart(stype, cartsave_data)) { - if (pushSaveToCart(stype, cartsave_data)) - { - printText("transferred save data...", 3, -1, disp); - } - else - { - printText("error transfering save data", 3, -1, disp); - } + printText("transferred save data...", 3, -1, disp); + } + else + { + printText("error transfering save data", 3, -1, disp); } return 1; @@ -1716,16 +1740,31 @@ int saveTypeFromSd(display_context_t disp, char *rom_name, int stype) int saveTypeToSd(display_context_t disp, char *rom_name, int stype) { - rom_load_y(); //after reset create new savefile + const char* save_type_extension = saveTypeToExtension(stype, ext_type); TCHAR fname[256]; //TODO: change filename buffers to 256!!! - - sprintf(fname, "/ED64/%s/%s.%s", save_path, rom_name, saveTypeToExtension(stype, ext_type)); + int save_count = 0; //TODO: once this crosses 9999 bad infinite-loop type things happen, look into that one day + FRESULT result; + FILINFO fnoba; + printText("Finding unused save slot...", 3, -1, disp); + display_show(disp); + while (true) { + sprintf(fname, "/"ED64_FIRMWARE_PATH"/%s/%s.%04x.%s", save_path, rom_name, save_count, save_type_extension); + result = f_stat (fname, &fnoba); + if (result != FR_OK) { + // we found our first missing save slot, break + break; + } + ++save_count; + } + sprintf(fname, "Found unused save slot: %04x", save_count); + printText(fname, 3, -1, disp); + display_show(disp); + sprintf(fname, "/"ED64_FIRMWARE_PATH"/%s/%s.%04x.%s", save_path, rom_name, save_count, save_type_extension); int size = saveTypeToSize(stype); // int byte TRACEF(disp, "size for save=%i", size); - FRESULT result; FIL file; UINT bytesread; result = f_open(&file, fname, FA_WRITE | FA_OPEN_ALWAYS); //Could use FA_CREATE_ALWAYS but this could lead to the posibility of the file being emptied @@ -1736,25 +1775,21 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype) uint8_t cartsave_data[size]; //TODO: bring back old initialisation if this doesn't work - + TRACEF(disp, "cartsave_data=%p", &cartsave_data); - + printText("Transfering save data...", 3, -1, disp); if (getSaveFromCart(stype, cartsave_data)) { - //write to file - if (gb_load_y != 1) - { - UINT bw; - result = f_write ( - &file, /* [IN] Pointer to the file object structure */ - cartsave_data, /* [IN] Pointer to the data to be written */ - size, /* [IN] Number of bytes to write */ - &bw /* [OUT] Pointer to the variable to return number of bytes written */ - ); - f_close(&file); - } - + UINT bw; + result = f_write ( + &file, /* [IN] Pointer to the file object structure */ + cartsave_data, /* [IN] Pointer to the data to be written */ + size, /* [IN] Number of bytes to write */ + &bw /* [OUT] Pointer to the variable to return number of bytes written */ + ); + f_close(&file); + printText("RAM area copied to SD card.", 3, -1, disp); return 1; } @@ -1768,6 +1803,7 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype) else { TRACE(disp, "COULDNT CREATE FILE :-("); + printText("Error saving game to SD, couldn't create file!", 3, -1, disp); } } @@ -1775,8 +1811,8 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype) int readConfigFile(void) { TCHAR filename[32]; - sprintf(filename, "/ED64/ALT64.INI"); - + sprintf(filename, "/"ED64_FIRMWARE_PATH"/ALT64.INI"); + FRESULT result; FIL file; UINT bytesread; @@ -1797,7 +1833,7 @@ int readConfigFile(void) ); f_close(&file); - + configuration config; if (ini_parse_str(config_rawdata, configHandler, &config) < 0) @@ -1817,6 +1853,7 @@ int readConfigFile(void) mempak_path = config.mempak_path; save_path = config.save_path; sound_on = config.sound_on; + bgm_on = config.bgm_on; page_display = config.page_display; tv_mode = config.tv_mode; quick_boot = config.quick_boot; @@ -1868,7 +1905,7 @@ void initFilesystem(void) else { fat_initialized = 1; - } + } } //prints the sdcard-filesystem content @@ -1878,7 +1915,7 @@ void readSDcard(display_context_t disp, char *directory) // u8 cresp = 0; // //load the directory-entry - // cresp = fatLoadDirByName("/ED64/CFG"); + // cresp = fatLoadDirByName("/"ED64_FIRMWARE_PATH"/CFG"); // int dsize = dir->size; // char colorlist[dsize][256]; @@ -1892,7 +1929,7 @@ void readSDcard(display_context_t disp, char *directory) // u8 rom_cfg_file[128]; // //set rom_cfg - // sprintf(rom_cfg_file, "/ED64/CFG/%s", frec->name); + // sprintf(rom_cfg_file, "/"ED64_FIRMWARE_PATH"/CFG/%s", frec->name); // static uint8_t cfg_file_data[512] = {0}; @@ -1900,11 +1937,11 @@ void readSDcard(display_context_t disp, char *directory) // FIL file; // UINT bytesread; // result = f_open(&file, rom_cfg_file, FA_READ); - + // if (result == FR_OK) // { // int fsize = f_size(&file); - + // result = // f_read ( // &file, /* [IN] File object */ @@ -1912,12 +1949,12 @@ void readSDcard(display_context_t disp, char *directory) // fsize, /* [IN] Number of bytes to read */ // &bytesread /* [OUT] Number of bytes read */ // ); - + // f_close(&file); // colorlist[i][0] = (char)cfg_file_data[5]; //row i column 0 = colour // strcpy(colorlist[i] + 1, cfg_file_data + 32); //row i column 1+ = fullpath - + // } // } // } @@ -1956,7 +1993,7 @@ void readSDcard(display_context_t disp, char *directory) } strcpy(list[count - 1].filename, fno.fname); list[count - 1].color = 0; - + // if (enable_colored_list) // { // for (int c = 0; c < dsize; c++) @@ -2047,7 +2084,7 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) { return -2; // Out of memory } - + /* * Size of the cheat list can never be more than half the size of the YAML * Minimum YAML example: @@ -2078,7 +2115,7 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) f_close(&file); yaml_parser_set_input_string(&parser, cheatfile, strlen(cheatfile)); - + do { if (!yaml_parser_parse(&parser, &event)) @@ -2090,10 +2127,10 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) free(cheat_lists[0]); cheat_lists[0] = 0; cheat_lists[1] = 0; - + return -3; // Parse error } - + // Process YAML switch (event.type) { @@ -2101,30 +2138,30 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) // Begin code block is_code = 0; break; - + case YAML_SEQUENCE_START_EVENT: // Begin code lines is_code = 1; code_on = (event.data.sequence_start.tag ? !!strcasecmp(event.data.sequence_start.tag, "!off") : 1); break; - + case YAML_SEQUENCE_END_EVENT: // End code lines is_code = 0; code_on = 1; repeater = 0; break; - + case YAML_SCALAR_EVENT: // Code line if (!is_code || !code_on) { break; } - + address = strtoul(event.data.scalar.value, &next, 16); value = strtoul(next, NULL, 16); - + // Do not check code types within "repeater data" if (repeater) { @@ -2133,17 +2170,17 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) *list2++ = value; break; } - + // Determine destination cheat_list for the code type switch (address >> 24) { - + // Uncessary code types case 0x20: // Clear code list case 0xCC: // Exception Handler Selection case 0xDE: // Entry Point break; - + // Boot-time cheats case 0xEE: // Disable Expansion Pak case 0xF0: // 8-bit Boot-Time Write @@ -2152,7 +2189,7 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) *list1++ = address; *list1++ = value; break; - + // In-game cheats case 0x50: // Repeater/Patch // Validate repeater count @@ -2163,7 +2200,7 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) *list2++ = value; } break; - + // Everything else default: if (!address) @@ -2171,7 +2208,7 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) // TODO: Support special code types! :) } // Fall-through! - + case 0xD0: // 8-bit Equal-To Conditional case 0xD1: // 16-bit Equal-To Conditional case 0xD2: // 8-bit Not-Equal-To Conditional @@ -2181,29 +2218,29 @@ int readCheatFile(TCHAR *filename, u32 *cheat_lists[2]) { break; } - + *list2++ = address; *list2++ = value; break; } break; - + case YAML_STREAM_END_EVENT: // And we're outta here! done = 1; break; - + default: break; } - + yaml_event_delete(&event); } while (!done); - + // Free yaml_parser_delete(&parser); free(cheatfile); - + return repeater; // Ok or repeater error } @@ -2222,12 +2259,12 @@ void bootRom(display_context_t disp, int silent) TCHAR cfg_file[32]; //set cfg file with last loaded cart info and save-type - sprintf(cfg_file, "/ED64/%s/LASTROM.CFG", save_path); + sprintf(cfg_file, "/"ED64_FIRMWARE_PATH"/%s/LASTROM.CFG", save_path); FRESULT result; FIL file; result = f_open(&file, cfg_file, FA_WRITE | FA_CREATE_ALWAYS); - + if (result == FR_OK) { uint8_t cfg_data[2] = {boot_save, boot_cic}; @@ -2242,7 +2279,7 @@ void bootRom(display_context_t disp, int silent) ); f_puts(rom_filename, &file); - + f_close(&file); //set the fpga cart-save type @@ -2267,7 +2304,7 @@ void bootRom(display_context_t disp, int silent) printText("try to load cheat-file...", 3, -1, disp); char cheat_filename[64]; - sprintf(cheat_filename, "/ED64/CHEATS/%s.yml", rom_filename); + sprintf(cheat_filename, "/"ED64_FIRMWARE_PATH"/CHEATS/%s.yml", rom_filename); int ok = readCheatFile(cheat_filename, cheat_lists); if (ok == 0) @@ -2325,6 +2362,7 @@ void playSound(int snd) if (snd == 4) sndPlaySFX("rom://sounds/done.wav"); + } //draws the next char at the text input screen @@ -2355,7 +2393,11 @@ void drawTextInput(display_context_t disp, char *msg) } void drawConfirmBox(display_context_t disp) -{ +{ while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawBoxNumber(disp, 5); display_show(disp); @@ -2376,8 +2418,14 @@ void drawConfirmBox(display_context_t disp) } void drawShortInfoBox(display_context_t disp, char *text, u8 mode) -{ +{ while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); + if (mode == 0) + drawBoxNumber(disp, 7); else if (mode == 1) drawBoxNumber(disp, 8); @@ -2405,7 +2453,7 @@ void readRomConfig(display_context_t disp, char *short_filename, char *full_file TCHAR cfg_filename[256]; sprintf(rom_filename, "%s", short_filename); rom_filename[strlen(rom_filename) - 4] = '\0'; // cut extension - sprintf(cfg_filename, "/ED64/CFG/%s.CFG", rom_filename); + sprintf(cfg_filename, "/"ED64_FIRMWARE_PATH"/CFG/%s.CFG", rom_filename); uint8_t rom_cfg_data[512]; @@ -2427,7 +2475,7 @@ void readRomConfig(display_context_t disp, char *short_filename, char *full_file f_close(&file); - + rom_config[0] = 1; //preload cursor position 1 cic rom_config[1] = rom_cfg_data[0]; rom_config[2] = rom_cfg_data[1]; @@ -2606,8 +2654,8 @@ void drawToplistBox(display_context_t disp, int line) if (line == 0) { - char* path = "/ED64/CFG"; - + char* path = "/"ED64_FIRMWARE_PATH"/CFG"; + FRESULT res; DIR dir; UINT i; @@ -2619,7 +2667,7 @@ void drawToplistBox(display_context_t disp, int line) for (;;) { res = f_readdir(&dir, &fno); /* Read a directory item */ if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */ - if (!fno.fattrib & !AM_DIR) { + if (!fno.fattrib & !AM_DIR) { dsize++; } } @@ -2629,7 +2677,7 @@ void drawToplistBox(display_context_t disp, int line) res = f_opendir(&dir, path); /* Open the directory */ if (res == FR_OK) { char toplist[dsize][256]; - + for (;;) { res = f_readdir(&dir, &fno); /* Read a directory item */ if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */ @@ -2641,22 +2689,22 @@ void drawToplistBox(display_context_t disp, int line) // path[i] = 0; } else { /* It is a file. */ TCHAR rom_cfg_file[128]; - + //set rom_cfg sprintf(rom_cfg_file, path, fno.fname); - + FRESULT result; FIL file; UINT bytesread; result = f_open(&file, rom_cfg_file, FA_READ); - + if (result == FR_OK) { - + static uint8_t cfg_file_data[512] = {0}; int fsize = f_size(&file) + 1; - + result = f_read ( &file, /* [IN] File object */ @@ -2664,9 +2712,9 @@ void drawToplistBox(display_context_t disp, int line) fsize, /* [IN] Number of bytes to read */ &bytesread /* [OUT] Number of bytes read */ ); - + f_close(&file); - + toplist[i][0] = (char)cfg_file_data[5]; //quality strcpy(toplist[i] + 1, cfg_file_data + 32); //fullpath i++; @@ -2674,7 +2722,7 @@ void drawToplistBox(display_context_t disp, int line) } } f_closedir(&dir); - + qsort(toplist, dsize, 256, compare_int_reverse); @@ -3038,8 +3086,32 @@ void drawSet4(display_context_t disp) graphics_draw_text(disp, 209, 100, "_"); } + +void showDeletePrompt(display_context_t disp) +{ + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); + display_dir(list, cursor, page, MAX_LIST, count, disp); + drawBoxNumber(disp, 13); + display_show(disp); + + bool isdir = list[cursor].type == DT_DIR; + + if (sound_on) + playSound(2 + isdir); + + menu_delete(disp, isdir); +} + void showAboutScreen(display_context_t disp) { + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawBoxNumber(disp, 2); display_show(disp); @@ -3048,7 +3120,21 @@ void showAboutScreen(display_context_t disp) menu_about(disp); } +void showControlScreen(display_context_t disp) +{ + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); + drawBoxNumber(disp, 12); + display_show(disp); + + if (sound_on) + playSound(2); + menu_controls(disp); +} void loadFile(display_context_t disp) { char name_file[256]; @@ -3077,20 +3163,18 @@ void loadFile(display_context_t disp) ft = 1; else if (!strcmp(extension, "MPK")) ft = 2; - if (!strcmp(extension, "GB")) - ft = 5; - else if (!strcmp(extension, "GBC")) - ft = 6; + else if (!strcmp(extension, "GB") || !strcmp(extension, "GBC") || !strcmp(extension, "SGB")) + ft = 3; else if (!strcmp(extension, "NES")) - ft = 7; + ft = 4; else if (!strcmp(extension, "GG")) - ft = 8; - else if (!strcmp(extension, "MSX")) - ft = 9; + ft = 5; + else if (!strcmp(extension, "MSX") || !strcmp(extension, "ROM")) + ft = 6; else if (!strcmp(extension, "MP3")) - ft = 10; + ft = 7; - if (ft != 10 || ft != 2) + if (ft != 7 || ft != 2) { while (!(disp = display_lock())) ; @@ -3110,16 +3194,16 @@ void loadFile(display_context_t disp) { FRESULT result; FIL file; - result = f_open(&file, "/ED64/LASTROM.CFG", FA_WRITE | FA_CREATE_ALWAYS); + result = f_open(&file, "/"ED64_FIRMWARE_PATH"/LASTROM.CFG", FA_WRITE | FA_CREATE_ALWAYS); if (result == FR_OK) { f_puts ( name_file, /* [IN] String */ &file /* [IN] File object */ ); - - + + f_close(&file); if (result == FR_OK) @@ -3129,7 +3213,7 @@ void loadFile(display_context_t disp) loadrom(disp, name_file, 1); display_show(disp); - + //rom loaded mapping input_mapping = rom_loaded; } @@ -3156,24 +3240,23 @@ void loadFile(display_context_t disp) input_mapping = mpk_choice; sprintf(rom_filename, "%s", name_file); break; - case 5: - case 6: + case 3: loadgbrom(disp, name_file); display_show(disp); break; - case 7: + case 4: loadnesrom(disp, name_file); display_show(disp); break; - case 8: + case 5: loadggrom(disp, name_file); display_show(disp); break; - case 9: + case 6: loadmsx2rom(disp, name_file); display_show(disp); break; - case 10: + case 7: { while (!(disp = display_lock())) ; @@ -3183,8 +3266,8 @@ void loadFile(display_context_t disp) long long start = 0, end = 0, curr, pause = 0, samples; int rate = 44100, last_rate = 44100, channels = 2; - audio_init(44100, 4); - buf_size = audio_get_buffer_length() * 4; + audio_init(44100, 8); + buf_size = audio_get_buffer_length() * 6; buf_ptr = malloc(buf_size); mp3_Start(name_file, &samples, &rate, &channels); @@ -3194,9 +3277,10 @@ void loadFile(display_context_t disp) while (!(disp = display_lock())) ; clearScreen(disp); - drawShortInfoBox(disp, " MP3 Playback", 0); + drawShortInfoBox(disp, " Playing MP3", 0); display_show(disp); input_mapping = mp3; //mp3 stop + break; } default: @@ -3216,6 +3300,10 @@ void handleInput(display_context_t disp, sprite_t *contr) switch (input_mapping) { case file_manager: + + if (sound_on) + playSound(4); + if (select_mode) { if (count != 0) @@ -3287,6 +3375,10 @@ void handleInput(display_context_t disp, sprite_t *contr) switch (input_mapping) { case file_manager: + + if (sound_on) + playSound(4); + if (select_mode) { if (count != 0) @@ -3469,13 +3561,13 @@ void handleInput(display_context_t disp, sprite_t *contr) FRESULT result; FIL file; UINT bytesread; - result = f_open(&file, "/ED64/LASTROM.CFG", FA_READ); - + result = f_open(&file, "/"ED64_FIRMWARE_PATH"/LASTROM.CFG", FA_READ); + if (result == FR_OK) { int fsize = f_size(&file) + 1; //extra char needed for null terminator '/0' uint8_t lastrom_cfg_data[fsize]; - + // result = // f_read ( // &file, /* [IN] File object */ @@ -3485,7 +3577,7 @@ void handleInput(display_context_t disp, sprite_t *contr) // ); f_gets(lastrom_cfg_data, fsize, &file); - + f_close(&file); u8 *file_name = strrchr(lastrom_cfg_data, '/'); @@ -3537,7 +3629,11 @@ void handleInput(display_context_t disp, sprite_t *contr) printText(" ", 9, -1, disp); printText("search...", 9, -1, disp); mpk_to_file(disp, input_text, 0); - + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawShortInfoBox(disp, " done", 0); sleep(1000); @@ -3563,13 +3659,20 @@ void handleInput(display_context_t disp, sprite_t *contr) break; } } - else if (keys.c[0].L) + else if (keys.c[0].L && !keys.c[0].R) { switch (input_mapping) { case file_manager: input_mapping = mempak_menu; + if (sound_on) + playSound(2); + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawBoxNumber(disp, 2); @@ -3585,9 +3688,6 @@ void handleInput(display_context_t disp, sprite_t *contr) printText(" R: Format", 9, -1, disp); printText(" ", 9, -1, disp); printText(" B: Abort", 9, -1, disp); - if (sound_on) - playSound(2); - sleep(1000); break; case mempak_menu: @@ -3611,7 +3711,7 @@ void handleInput(display_context_t disp, sprite_t *contr) break; } } - else if (keys.c[0].R) + else if (keys.c[0].R && !keys.c[0].L) { switch (input_mapping) { @@ -3621,9 +3721,14 @@ void handleInput(display_context_t disp, sprite_t *contr) case mempak_menu: //c-up or A - drawConfirmBox(disp); - //confirm format mpk - input_mapping = mpk_format; + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); + drawConfirmBox(disp); + //confirm format mpk + input_mapping = mpk_format; break; case char_input: @@ -3659,8 +3764,13 @@ void handleInput(display_context_t disp, sprite_t *contr) if (list[cursor].type != DT_DIR && empty == 0) { + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawBoxNumber(disp, 11); - + display_show(disp); char *part; part = malloc(slen(list[cursor].filename)); @@ -3709,6 +3819,11 @@ void handleInput(display_context_t disp, sprite_t *contr) case mpk_format: // format mpk + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawBoxNumber(disp, 2); display_show(disp); @@ -3732,6 +3847,11 @@ void handleInput(display_context_t disp, sprite_t *contr) } else { + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawShortInfoBox(disp, " done", 0); input_mapping = abort_screen; } @@ -3749,6 +3869,11 @@ void handleInput(display_context_t disp, sprite_t *contr) case mpk_restore: //restore mpk + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawBoxNumber(disp, 2); display_show(disp); @@ -3756,7 +3881,11 @@ void handleInput(display_context_t disp, sprite_t *contr) printText(" ", 9, -1, disp); file_to_mpk(disp, rom_filename); - + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawShortInfoBox(disp, " done", 0); sleep(1000); @@ -3767,6 +3896,11 @@ void handleInput(display_context_t disp, sprite_t *contr) case mpk_quick_backup: //quick-backup + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawBoxNumber(disp, 2); display_show(disp); @@ -3775,7 +3909,11 @@ void handleInput(display_context_t disp, sprite_t *contr) printText("search...", 9, -1, disp); mpk_to_file(disp, list[cursor].filename, 1); //quick - + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); drawShortInfoBox(disp, " done", 0); sleep(1000); input_mapping = abort_screen; @@ -3827,6 +3965,12 @@ void handleInput(display_context_t disp, sprite_t *contr) //preload config or file header readRomConfig(disp, rom_filename, name_file); + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); + drawRomConfigBox(disp, 0); display_show(disp); @@ -3934,7 +4078,14 @@ void handleInput(display_context_t disp, sprite_t *contr) if (!strcmp(extension, "Z64") || !strcmp(extension, "V64") || !strcmp(extension, "N64")) { //rom //load rom + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? + display_dir(list, cursor, page, MAX_LIST, count, disp); + drawBoxNumber(disp, 3); //rominfo + display_show(disp); u16 msg = 0; evd_ulockRegs(); @@ -3949,6 +4100,9 @@ void handleInput(display_context_t disp, sprite_t *contr) } else if (!strcmp(extension, "MPK")) { //mpk file + while (!(disp = display_lock())) + ; + clearScreen(disp); drawBoxNumber(disp, 4); display_show(disp); @@ -3990,23 +4144,45 @@ void handleInput(display_context_t disp, sprite_t *contr) { case file_manager: showAboutScreen(disp); - input_mapping = none; + input_mapping = control_screen; break; - case mempak_menu: - if (sound_on) - playSound(2); + case mempak_menu: - drawBoxNumber(disp, 4); - display_show(disp); - view_mpk(disp); - input_mapping = abort_screen; + while (!(disp = display_lock())) + ; + if (sound_on) + playSound(2); + + drawBoxNumber(disp, 4); + display_show(disp); + view_mpk(disp); + + input_mapping = abort_screen; + break; + + case control_screen: + showControlScreen(disp); + input_mapping = none; break; default: break; } } + else if (keys.c[0].R && keys.c[0].L) + { + switch (input_mapping) + { + case file_manager: + showDeletePrompt(disp); + input_mapping = delete_prompt; + break; + + default: + break; + } + } else if (keys.c[0].A) { switch (input_mapping) @@ -4028,7 +4204,7 @@ void handleInput(display_context_t disp, sprite_t *contr) * /ED64 * * cursor=SAVE - * /ED64/SAVE + * /"ED64_FIRMWARE_PATH"/SAVE */ if (strcmp(pwd, "/") == 0) @@ -4062,9 +4238,14 @@ void handleInput(display_context_t disp, sprite_t *contr) case mempak_menu: { //open up charinput screen + while (!(disp = display_lock())) + ; + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); //part clear? input_mapping = char_input; input_text[0] = '\0'; graphics_draw_sprite(disp, 0, 0, contr); + display_show(disp); break; } case char_input: @@ -4094,13 +4275,13 @@ void handleInput(display_context_t disp, sprite_t *contr) u8 resp = 0; //set rom_cfg - sprintf(rom_cfg_file, "/ED64/CFG/%s.CFG", rom_filename); + sprintf(rom_cfg_file, "/"ED64_FIRMWARE_PATH"/CFG/%s.CFG", rom_filename); FRESULT result; FIL file; result = f_open(&file, rom_cfg_file, FA_WRITE | FA_OPEN_ALWAYS); - + if (result == FR_OK) { static uint8_t cfg_file_data[512] = {0}; @@ -4113,10 +4294,10 @@ void handleInput(display_context_t disp, sprite_t *contr) cfg_file_data[6] = rom_config[7]; //country cfg_file_data[7] = rom_config[8]; cfg_file_data[8] = rom_config[9]; - + //copy full rom path to offset at 32 byte - 32 bytes reversed scopy(name_file, cfg_file_data + 32); //filename to rom_cfg file - + UINT bw; result = f_write ( @@ -4125,11 +4306,15 @@ void handleInput(display_context_t disp, sprite_t *contr) 512, /* [IN] Number of bytes to write */ &bw /* [OUT] Pointer to the variable to return number of bytes written */ ); - + f_close(&file); + while (!(disp = display_lock())) + ; + drawRomConfigBox(disp, 0); + display_show(disp); drawShortInfoBox(disp, " done", 0); - toplist_reload = 1; + toplist_reload = 1; } input_mapping = abort_screen; @@ -4164,6 +4349,32 @@ void handleInput(display_context_t disp, sprite_t *contr) input_mapping = file_manager; break; } + case delete_prompt: + { + if (list[cursor].type != DT_DIR) + { + char name_file[256]; + + if (strcmp(pwd, "/") == 0) + sprintf(name_file, "/%s", list[cursor].filename); + else + sprintf(name_file, "%s/%s", pwd, list[cursor].filename); + + f_unlink(name_file); + + while (!(disp = display_lock())) + ; + graphics_set_color(graphics_make_color(0xFF, 0xFF, 0xFF, 0xFF), graphics_make_color(0x00, 0x00, 0x00, 0x00)); + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); + display_show(disp); + + input_mapping = file_manager; + readSDcard(disp, pwd); + display_show(disp); + } + break; + } default: break; } @@ -4243,11 +4454,13 @@ void handleInput(display_context_t disp, sprite_t *contr) break; case mempak_menu: + case delete_prompt: while (!(disp = display_lock())) ; graphics_set_color(graphics_make_color(0xFF, 0xFF, 0xFF, 0xFF), graphics_make_color(0x00, 0x00, 0x00, 0x00)); + new_scroll_pos(&cursor, &page, MAX_LIST, count); clearScreen(disp); display_show(disp); @@ -4301,26 +4514,30 @@ void handleInput(display_context_t disp, sprite_t *contr) mp3_Stop(); mp3playing = 0; audio_close(); - free(buf_ptr); - buf_ptr = 0; + free(buf_ptr); + buf_ptr = 0; + audio_init(44100, 8); + while (!(disp = display_lock())) + ; + graphics_set_color(graphics_make_color(0xFF, 0xFF, 0xFF, 0xFF), graphics_make_color(0x00, 0x00, 0x00, 0x00)); + new_scroll_pos(&cursor, &page, MAX_LIST, count); + clearScreen(disp); + display_show(disp); - clearScreen(disp); //part clear? - display_dir(list, cursor, page, MAX_LIST, count, disp); - - display_show(disp); - - input_mapping = file_manager; + display_dir(list, cursor, page, MAX_LIST, count, disp); + input_mapping = file_manager; + display_show(disp); break; default: while (!(disp = display_lock())) ; - + clearScreen(disp); //part clear? display_dir(list, cursor, page, MAX_LIST, count, disp); - + display_show(disp); //rom info screen @@ -4370,9 +4587,31 @@ int main(void) bi_speed25(); } - if (tv_mode != 0) + /* + * TV Mode from Config and libDragon differ: + * + * Config | libDragon | Mode + * -------|-----------|------- + * 0 | None | Auto + * 1 | 1 | NTSC + * 2 | 0 | PAL + * 3 | 2 | M-PAL + */ + switch (tv_mode) { - *(u32 *)0x80000300 = tv_mode; + case 1: + *(u32 *)0x80000300 = 1U; // NTSC + break; + case 2: + *(u32 *)0x80000300 = 0U; // PAL + break; + case 3: + *(u32 *)0x80000300 = 2U; // M-PAL + break; + default: + // Do nothing. Required to make sure no mode other than 0..2 is used. + // Only there for defensive programming. + break; } init_interrupts(); @@ -4380,7 +4619,7 @@ int main(void) if (sound_on) { //load soundsystem - audio_init(44100, 2); + audio_init(44100, 8); sndInit(); } @@ -4416,13 +4655,13 @@ int main(void) } char background_path[64]; - sprintf(background_path, "/ED64/wallpaper/%s", background_image); + sprintf(background_path, "/"ED64_FIRMWARE_PATH"/wallpaper/%s", background_image); FRESULT fr; FILINFO fno; - + fr = f_stat(background_path, &fno); - + if (fr == FR_OK) { background = loadPng(background_path); @@ -4433,8 +4672,9 @@ int main(void) } //todo: if bgm is enabled, we should start it... - //sndPlayBGM("rom://sounds/bgm21.it"); - + if (sound_on && bgm_on){ + sndPlayBGM("rom://sounds/bgm21.it"); + } border_color_1 = translate_color(border_color_1_s); border_color_2 = translate_color(border_color_2_s); box_color = translate_color(box_color_s); diff --git a/src/mem.c b/src/mem.c old mode 100644 new mode 100755 diff --git a/src/memorypak.c b/src/memorypak.c old mode 100644 new mode 100755 index f903e167..341f8c8f --- a/src/memorypak.c +++ b/src/memorypak.c @@ -187,8 +187,8 @@ void view_mpk_file(display_context_t disp, char *mpk_filename) 32768, /* [IN] Number of bytes to read */ &bytesread /* [OUT] Number of bytes read */ ); - - + + f_close(&file); printText("File contents:", 11, 5, disp); @@ -305,7 +305,7 @@ void view_mpk_file(display_context_t disp, char *mpk_filename) else { printText("empty", 11, -1, disp); - } + } } } @@ -314,7 +314,8 @@ void view_mpk(display_context_t disp) int err; printText("Mempak content:", 11, 5, disp); - get_accessories_present(); + struct controller_data output; + get_accessories_present( &output); /* Make sure they don't have a rumble pak inserted instead */ switch (identify_accessory(0)) @@ -419,7 +420,7 @@ void mpk_to_file(display_context_t disp, char *mpk_filename, int quick) if (result == FR_OK) { controller_init(); - + int err = 0; for (int j = 0; j < 128; j++) { @@ -437,9 +438,9 @@ void mpk_to_file(display_context_t disp, char *mpk_filename, int quick) f_close(&file); - + sprintf(buff, "File: %s%i.MPK", mpk_filename, v); - + printText(buff, 9, -1, disp); printText("backup done...", 9, -1, disp); } diff --git a/src/menu.c b/src/menu.c old mode 100644 new mode 100755 diff --git a/src/menu_about.c b/src/menu_about.c index 0604336e..ed42b897 100644 --- a/src/menu_about.c +++ b/src/menu_about.c @@ -18,15 +18,16 @@ void menu_about(display_context_t disp) sprintf(firmware_str, "ED64 firmware: v%03x", evd_getFirmVersion()); printText(firmware_str, 9, -1, disp); printText("by JonesAlmighty", 9, -1, disp); - printText(" ", 9, -1, disp); printText("Based on ALT64", 9, -1, disp); printText("By Saturnu", 9, -1, disp); - printText(" ", 9, -1, disp); printText("credits to:", 9, -1, disp); printText("Jay Oster", 9, -1, disp); printText("Krikzz", 9, -1, disp); printText("Richard Weick", 9, -1, disp); printText("ChillyWilly", 9, -1, disp); printText("ShaunTaylor", 9, -1, disp); - printText("Conle", 9, -1, disp); -} //TODO: make scrolling text, should include libraries used. + printText("Conle Z: Page 2", 9, -1, disp); + printText("AriaHiro64", 9, -1, disp); + printText("moparisthebest", 9, -1, disp); + printText("Skawo", 9, -1, disp); +} //TODO: make scrolling text, should include libraries used. \ No newline at end of file diff --git a/src/menu_controls.c b/src/menu_controls.c new file mode 100644 index 00000000..a6d0b1c2 --- /dev/null +++ b/src/menu_controls.c @@ -0,0 +1,35 @@ + +#include +#include +#include "types.h" +#include "menu.h" +#include "version.h" +#include "main.h" +#include "everdrive.h" + +void menu_controls(display_context_t disp) +{ + printText(" - Controls -", 4, 4, disp); + printText(" ", 4, -1, disp); + printText(" L: show mempak menu", 4, -1, disp); + printText(" ", 4, -1, disp); + printText(" Z: about screen", 4, -1, disp); + printText(" ", 4, -1, disp); + printText(" A: start rom/directory", 4, -1, disp); + printText(" mempak", 4, -1, disp); + printText(" ", 4, -1, disp); + printText(" B: back/cancel", 4, -1, disp); + printText(" ", 4, -1, disp); + printText(" START: start last rom", 4, -1, disp); + printText(" ", 4, -1, disp); + printText(" C-left: rom info/mempak", 4, -1, disp); + printText(" content view", 4, -1, disp); + printText(" ", 4, -1, disp); + printText("C-right: rom config creen", 4, -1, disp); + printText(" ", 4, -1, disp); + printText(" C-up: view full filename", 4, -1, disp); + printText(" ", 4, -1, disp); + printText(" C-down: Toplist 15", 4, -1, disp); + printText(" ", 4, -1, disp); + printText(" R + L: Delete file", 4, -1, disp); +} diff --git a/src/menu_delete.c b/src/menu_delete.c new file mode 100644 index 00000000..21cacce2 --- /dev/null +++ b/src/menu_delete.c @@ -0,0 +1,24 @@ + +#include +#include +#include "types.h" +#include "menu.h" +#include "version.h" +#include "main.h" +#include "everdrive.h" + + +void menu_delete(display_context_t disp, bool isdir) +{ + if (isdir) + { + printText("Cannot delete directories!", 7, 14, disp); + printText("B: Exit", 13, 16, disp); + } + else + { + printText("Delete this file?", 10, 14, disp); + printText("A: Confirm", 13, 16, disp); + printText("B: Cancel", 13, 17, disp); + } +} diff --git a/src/mp3.c b/src/mp3.c old mode 100644 new mode 100755 diff --git a/src/rom.c b/src/rom.c old mode 100644 new mode 100755 diff --git a/src/sd.c b/src/sd.c old mode 100644 new mode 100755 diff --git a/src/sound.c b/src/sound.c old mode 100644 new mode 100755 index cd3f1e2c..4d0485b9 --- a/src/sound.c +++ b/src/sound.c @@ -2,6 +2,30 @@ // Copyright (c) 2017 The Altra64 project contributors // See LICENSE file in the project root for full license information. // +#define SOUND_ENABLED +#if !defined(SOUND_ENABLED) + +void sndInit(void) +{ +} + +void sndPlayBGM(char* filename) +{ +} + +void sndStopAll(void) +{ +} + +void sndPlaySFX(char* filename) +{ +} + +void sndUpdate(void) +{ +} + +#else #include #include //needed for audio_get_frequency() @@ -40,7 +64,7 @@ void sndInit(void) /* get ready to play */ MikMod_EnableOutput(); - + } void sndPlayBGM(char* filename) @@ -57,7 +81,7 @@ void sndPlayBGM(char* filename) if (moduleBGM) { Player_Start(moduleBGM); - Player_SetVolume(20); + Player_SetVolume(80); } } @@ -88,7 +112,7 @@ void sndPlaySFX(char* filename) { Voice_Stop(voiceSFX); } - + if (hashtable_get(samples, filename) == NULL) { @@ -96,9 +120,9 @@ void sndPlaySFX(char* filename) } //audio_write_silence(); - Voice_SetVolume(voiceSFX, 200); + Voice_SetVolume(voiceSFX, 800); voiceSFX = Sample_Play(hashtable_get(samples, filename), 0, 0); - + MikMod_Update(); //force an update so that the voice is registered as playing! } @@ -111,3 +135,4 @@ void sndUpdate(void) } } +#endif diff --git a/src/sram.c b/src/sram.c old mode 100644 new mode 100755 diff --git a/src/strlib.c b/src/strlib.c old mode 100644 new mode 100755 diff --git a/src/sys.c b/src/sys.c old mode 100644 new mode 100755 diff --git a/src/usb.c b/src/usb.c old mode 100644 new mode 100755 diff --git a/src/utils.c b/src/utils.c old mode 100644 new mode 100755 index bb00a1a1..3b8b3779 --- a/src/utils.c +++ b/src/utils.c @@ -751,12 +751,14 @@ void simulate_boot(u32 cic_chip, u8 gBootCic, u32 *cheat_lists[2]) { // Run code engine "lui $k0, 0x8000;" "lw $k0, 0x0188($k0);" - "addiu $k0, $k0, -0x28;" + "addiu $k0, $k0, -0x38;" "sd $v1, 0x0000($k0);" "sd $v0, 0x0008($k0);" "sd $t9, 0x0010($k0);" "sd $t8, 0x0018($k0);" "sd $t7, 0x0020($k0);" + "sd $t6, 0x0028($k0);" + "sd $t5, 0x0030($k0);" // Handle cheats "lui $t9, 0x8000;" @@ -789,8 +791,18 @@ void simulate_boot(u32 cic_chip, u8 gBootCic, u32 *cheat_lists[2]) { "lw $k1, 0x0004($t9);" // Load value "addiu $t9, $t9, 0x0008;" + "lui $t6, 0x0100;" + "and $t6, $v0, $t6;" // Test for 8-bit or 16-bit code type + "li $t5, 0xA07FFFFF;" + "and $v0, $v0, $t5;" + "lui $t5, 0x8000;" + "or $v0, $v0, $t5;" // Mask address + "2:" - "sh $k1, 0x0000($v0);" // Repeater/Patch write + "beqzl $t6, 5f;" + "sb $k1, 0x0000($v0);" // Repeated 8-bit write + "sh $k1, 0x0000($v0);" // Repeated 16-bit write + "5:" "addiu $t8, $t8, -1;" "addu $v0, $v0, $t7;" "bnez $t8, 2b;" @@ -832,6 +844,8 @@ void simulate_boot(u32 cic_chip, u8 gBootCic, u32 *cheat_lists[2]) { "4:" // Restore registers from our temporary stack, and back to the game! + "ld $t5, 0x0030($k0);" + "ld $t6, 0x0028($k0);" "ld $t7, 0x0020($k0);" "ld $t8, 0x0018($k0);" "ld $t9, 0x0010($k0);" diff --git a/src/version.c b/src/version.c old mode 100644 new mode 100755 index d5f3f87e..c267ba78 --- a/src/version.c +++ b/src/version.c @@ -5,7 +5,7 @@ #include "version.h" -#define ALTRA64_VERSION "0.1.8.6.1.3" +#define ALTRA64_VERSION "0.2.0.3 beta" const char* Altra64_GetVersionString(void) { diff --git a/tools/deploy-sd.sh b/tools/deploy-sd.sh old mode 100644 new mode 100755 diff --git a/tools/extract-firmware.cmd b/tools/extract-firmware.cmd old mode 100644 new mode 100755 diff --git a/tools/reset-wsfl.cmd b/tools/reset-wsfl.cmd old mode 100644 new mode 100755 diff --git a/tools/setup-linux.sh b/tools/setup-linux.sh old mode 100644 new mode 100755 diff --git a/tools/setup-wsfl.cmd b/tools/setup-wsfl.cmd old mode 100644 new mode 100755