Skip to content

Commit

Permalink
Merge branch 'main' into add-bgm
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored Dec 17, 2023
2 parents e7fa3ad + fc1aa31 commit 4547045
Show file tree
Hide file tree
Showing 41 changed files with 398 additions and 305 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.vscode
/build
/filesystem
/output
/tools/sc64/*

Expand Down
39 changes: 20 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ PROJECT_NAME = N64FlashcartMenu

SOURCE_DIR = src
ASSETS_DIR = assets
FILESYSTEM_DIR = filesystem
BUILD_DIR = build
OUTPUT_DIR = output

FLAGS += -DMENU_VERSION=\"0.0.1.$(shell date +%Y-%m-%dT%H:%M:%SZ).ALPHA\"

include $(N64_INST)/include/n64.mk

N64_CFLAGS += -iquote $(SOURCE_DIR) -iquote $(ASSETS_DIR) -I $(SOURCE_DIR)/libs -flto=auto $(FLAGS)
Expand All @@ -15,7 +18,6 @@ SRCS = \
main.c \
boot/boot.c \
boot/cic.c \
boot/crc32.c \
boot/reboot.S \
flashcart/64drive/64drive_ll.c \
flashcart/64drive/64drive.c \
Expand Down Expand Up @@ -61,26 +63,28 @@ SRCS = \
menu/views/system_info.c \
utils/fs.c

ASSETS = \
FONTS = \
FiraMonoBold.ttf

OBJS = $(addprefix $(BUILD_DIR)/, $(addsuffix .o,$(basename $(SRCS) $(ASSETS))))
OBJS = $(addprefix $(BUILD_DIR)/, $(addsuffix .o,$(basename $(SRCS))))
MINIZ_OBJS = $(filter $(BUILD_DIR)/libs/miniz/%.o,$(OBJS))
SPNG_OBJS = $(filter $(BUILD_DIR)/libs/libspng/%.o,$(OBJS))
DEPS = $(OBJS:.o=.d)

FILESYSTEM = \
$(addprefix $(FILESYSTEM_DIR)/, $(notdir $(FONTS:%.ttf=%.font64)))

$(MINIZ_OBJS): N64_CFLAGS+=-DMINIZ_NO_TIME -fcompare-debug-second
$(SPNG_OBJS): N64_CFLAGS+=-isystem $(SOURCE_DIR)/libs/miniz -DSPNG_USE_MINIZ -fcompare-debug-second
$(BUILD_DIR)/FiraMonoBold.asset: MKFONT_FLAGS+=-c 0 --size 16 -r 20-7F -r 2026-2026 --ellipsis 2026,1
$(FILESYSTEM_DIR)/FiraMonoBold.font64: MKFONT_FLAGS+=-c 1 --size 16 -r 20-7F -r 2026-2026 --ellipsis 2026,1

$(BUILD_DIR)/%.asset: $(ASSETS_DIR)/%.ttf
@echo " [FONT] $(basename $@).font64"
@$(N64_MKFONT) $(MKFONT_FLAGS) -o $(BUILD_DIR) "$<"
@mv $(basename $@).font64 $@
$(@info $(shell mkdir -p ./$(FILESYSTEM_DIR) &> /dev/null))

$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.asset $(ASSETS_DIR)/assets.S
@sed -e "s,@sym@,$*,g" -e "s,@file@,$(basename $<).asset," < $(ASSETS_DIR)/assets.S | \
$(CC) -x assembler-with-cpp $(ASFLAGS) -c - -o $@
$(FILESYSTEM_DIR)/%.font64: $(ASSETS_DIR)/%.ttf
@echo " [FONT] $@"
@$(N64_MKFONT) $(MKFONT_FLAGS) -o $(FILESYSTEM_DIR) "$<"

$(BUILD_DIR)/$(PROJECT_NAME).dfs: $(FILESYSTEM)

$(BUILD_DIR)/$(PROJECT_NAME).elf: $(OBJS)

Expand All @@ -89,37 +93,34 @@ disassembly: $(BUILD_DIR)/$(PROJECT_NAME).elf
.PHONY: disassembly

$(PROJECT_NAME).z64: N64_ROM_TITLE=$(PROJECT_NAME)
$(PROJECT_NAME).z64: $(BUILD_DIR)/$(PROJECT_NAME).dfs

$(@info $(shell mkdir -p ./$(OUTPUT_DIR) &> /dev/null))

$(OUTPUT_DIR)/$(PROJECT_NAME).n64: $(PROJECT_NAME).z64
@mv $< $@

$(BUILD_DIR)/$(PROJECT_NAME)_stripped.n64: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
python3 ./tools/strip_debug_data.py $(BUILD_DIR)/$(PROJECT_NAME).elf $< $@
@$(N64_CHKSUM) $@ > /dev/null

64drive: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
@cp $< $(OUTPUT_DIR)/menu.bin
.PHONY: 64drive

ed64: $(BUILD_DIR)/$(PROJECT_NAME)_stripped.n64
ed64: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
@cp $< $(OUTPUT_DIR)/OS64.v64
.PHONY: ed64

ed64-clone: $(BUILD_DIR)/$(PROJECT_NAME)_stripped.n64
ed64-clone: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
@cp $< $(OUTPUT_DIR)/OS64P.v64
.PHONY: ed64-clone

sc64: $(BUILD_DIR)/$(PROJECT_NAME)_stripped.n64
sc64: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
@cp $< $(OUTPUT_DIR)/sc64menu.n64
.PHONY: sc64

all: $(OUTPUT_DIR)/$(PROJECT_NAME).n64 64drive ed64 ed64-clone sc64
.PHONY: all

clean:
@rm -rf ./$(BUILD_DIR) ./$(OUTPUT_DIR)
@rm -rf ./$(BUILD_DIR) ./$(FILESYSTEM_DIR) ./$(OUTPUT_DIR)
.PHONY: clean

run: $(OUTPUT_DIR)/$(PROJECT_NAME).n64
Expand Down
77 changes: 44 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
![Build](https://github.com/polprzewodnikowy/N64FlashcartMenu/actions/workflows/build.yml/badge.svg)

# N64 Flashcart Menu
An open source menu for N64 flashcarts.

## Aims
* Support as many N64 FlashCarts as possible.
* Be open source, using permissive licensed third party licensed libraries.
* Be testable, using unit and smoke tests in ares emulated environment.
* Encourage active development from community members and N64 FlashCart owners.
* Support as many common mods and features as possible.


## Current (notable) menu features
* Fully Open Source.
Expand All @@ -21,43 +16,33 @@ An open source menu for N64 flashcarts.
* Real Time Clock support.
* Music playback (MP3).

## Video showcase (as of Oct 12 2023)

[![N64FlashcartMenu Showcase](http://img.youtube.com/vi/6CKImHTifDA/0.jpg)](http://www.youtube.com/watch?v=6CKImHTifDA "N64FlashcartMenu Showcase (Oct 12 2023)")

## Getting started

### 64drive
Ensure the cart has the latest [firmware](https://64drive.retroactive.be/support.php) installed.
Download the latest `menu.bin` file from the releases page, then put it in the root directory of your SD card.
### Video showcase (as of Oct 12 2023)

### SC64
Ensure the cart has the latest [firmware](https://github.com/Polprzewodnikowy/SummerCart64/releases/latest) installed.
Download the latest `sc64menu.n64` file from the releases page, then put it in the root directory of your SD card.
[![N64FlashcartMenu Showcase](http://img.youtube.com/vi/6CKImHTifDA/0.jpg)](http://www.youtube.com/watch?v=6CKImHTifDA "N64FlashcartMenu Showcase (Oct 12 2023)")

#### 64DD disk support
For the ability to load and run 64DD disk images, you need to add the folder `/menu/64ddipl` on the SD card.
Download and add the relevant ipl files and rename them before adding them to the folder:
- `NDDE0.n64` the US Prototype IPL can be downloaded from [here](https://64dd.org/dumps/64DD_IPL_US_MJR.n64)
- `NDXJ0.n64` the JPN Development IPL can be downloaded from [here](https://64dd.org/dumps/64DD_IPL_DEV_H4G.n64)
- `NDDJ2.n64` the JPN Retail IPL can be downloaded from [here](https://64dd.org/dumps/N64DD_IPLROM_(J).zip)

### ED64 & ED64P
Currently not supported, but there is an aim to do so.
## Aims
* Support as many N64 FlashCarts as possible.
* Be open source, using permissive licensed third party licensed libraries.
* Be testable, using unit and smoke tests in ares emulated environment.
* Encourage active development from community members and N64 FlashCart owners.
* Support as many common mods and features as possible.

The aim is to replace [Altra64](https://github.com/networkfusion/altra64) and [ED64-UnofficialOS](https://github.com/n64-tools/ED64-UnofficialOS-binaries).

## Getting started
Using your PC, insert the SD card and ensure it is formatted for compatibility (We recommend FAT32 in most instances).

### Common to all flashcarts

#### ROM Boxart
### ROM Boxart
To use boxart, you need to place png files of size 158x112 in the folder `/menu/boxart` on the SD card.
Each file must be named according to the 2 letter ROM ID, or 3 letter ROM ID including media type.
i.e. for GoldenEye 2 letters, this would be `GE.png`.
i.e. for GoldenEye 3 letters, this would be `NGE.png`.
A known set of PNG files using 2 letter ID's can be downloaded [here](https://mega.nz/file/6cNGwSqI#8X5ukb65n3YMlGaUtSOGXkKo9HxVnnMOgqn94Epcr7w).

#### Emulator support

### Emulator support
Emulators should be added to the `/menu/emulators` directory on the SD card.

Menu currently supports the following emulators and associated ROM file names:
Expand All @@ -67,8 +52,32 @@ Menu currently supports the following emulators and associated ROM file names:
- **Sega Master System** / **Sega Game Gear** / **Sg1000**: [TotalSMS](https://github.com/ITotalJustice/TotalSMS) - `TotalSMS.z64` (Currently broken)


### SC64 Specific
- Ensure the cart has the latest [firmware](https://github.com/Polprzewodnikowy/SummerCart64/releases/latest) installed.
- Download the latest `sc64menu.n64` file from the releases page, then put it in the root directory of your SD card.

##### 64DD disk support
For the ability to load and run 64DD disk images, you need to add the folder `/menu/64ddipl` on the SD card.
Download and add the relevant ipl files and rename them before adding them to the folder:
- `NDDE0.n64` the US Prototype IPL can be downloaded from [here](https://64dd.org/dumps/64DD_IPL_US_MJR.n64)
- `NDXJ0.n64` the JPN Development IPL can be downloaded from [here](https://64dd.org/dumps/64DD_IPL_DEV_H4G.n64)
- `NDDJ2.n64` the JPN Retail IPL can be downloaded from [here](https://64dd.org/dumps/N64DD_IPLROM_(J).zip)

Note: to load an expansion disk (e.g. F-Zero X) browse to the N64 ROM and load it (but not start it) and then browse to the DD expansion file and press the `R` button.


### 64drive Specific
- Ensure the cart has the latest [firmware](https://64drive.retroactive.be/support.php) installed.
- Download the latest `menu.bin` file from the releases page, then put it in the root directory of your SD card.


### ED64 & ED64P Specific
Currently not supported, but work is in progress (See [PR's](https://github.com/Polprzewodnikowy/N64FlashcartMenu/pulls)).

The aim is to replace [Altra64](https://github.com/networkfusion/altra64) and [ED64-UnofficialOS](https://github.com/n64-tools/ED64-UnofficialOS-binaries).


# Developer documentation
**Work in progress!**

You can use a dev container in VSCode to ease development.

Expand All @@ -79,7 +88,7 @@ You can use a dev container in VSCode to ease development.
* Extract and place `sc64deployer.exe` in the `tools/sc64` directory.

Make sure that your firmware is compatible (currently v2.17.0+)
See: https://github.com/Polprzewodnikowy/SummerCart64/blob/v2.17.0/docs/00_quick_startup_guide.md#firmware-backupupdate
See: [here](https://github.com/Polprzewodnikowy/SummerCart64/blob/v2.17.0/docs/00_quick_startup_guide.md#firmware-backupupdate)


#### From the devcontainer
Expand Down Expand Up @@ -115,7 +124,9 @@ To update to the latest version, use `git submodule update --remote ` from the t
# Generate documentation
Run `doxygen` from the dev container terminal.
Make sure you fix the warnings before creating a PR!
Generated documentation is located in `output/docs` folder.
Generated documentation is located in `output/docs` folder and auto published to the `gh-pages` branch when merged with `main`.

Once merged, they can be viewed [here](https://polprzewodnikowy.github.io/N64FlashcartMenu/)

# Open source software and licenses used
- [libdragon](https://github.com/DragonMinded/libdragon) (UNLICENSE License)
Expand Down
11 changes: 0 additions & 11 deletions assets/assets.S

This file was deleted.

16 changes: 0 additions & 16 deletions assets/assets.h

This file was deleted.

Empty file removed assets/images/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion libdragon
Submodule libdragon updated 238 files
19 changes: 15 additions & 4 deletions src/boot/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,26 @@ static void boot_detect_cic_seed (boot_params_t *params) {

void boot (boot_params_t *params) {
if (params->tv_type == BOOT_TV_TYPE_PASSTHROUGH) {
params->tv_type = OS_INFO->tv_type;
switch (get_tv_type()) {
case TV_PAL:
params->tv_type = BOOT_TV_TYPE_PAL;
break;
case TV_NTSC:
params->tv_type = BOOT_TV_TYPE_NTSC;
break;
case TV_MPAL:
params->tv_type = BOOT_TV_TYPE_MPAL;
break;
default:
params->tv_type = BOOT_TV_TYPE_NTSC;
break;
}
}

if (params->detect_cic_seed) {
boot_detect_cic_seed(params);
}

OS_INFO->mem_size_6105 = OS_INFO->mem_size;

C0_WRITE_STATUS(C0_STATUS_CU1 | C0_STATUS_CU0 | C0_STATUS_FR);

while (!(cpu_io_read(&SP->SR) & SP_SR_HALT));
Expand Down Expand Up @@ -120,7 +131,7 @@ void boot (boot_params_t *params) {

boot_device = (params->device_type & 0x01);
tv_type = (params->tv_type & 0x03);
reset_type = BOOT_RESET_TYPE_NMI;
reset_type = BOOT_RESET_TYPE_COLD;
cic_seed = (params->cic_seed & 0xFF);
version = (params->tv_type == BOOT_TV_TYPE_PAL) ? 6
: (params->tv_type == BOOT_TV_TYPE_NTSC) ? 1
Expand Down
1 change: 0 additions & 1 deletion src/boot/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ typedef struct {
} boot_params_t;


bool boot_is_warm (void);
void boot (boot_params_t *params);


Expand Down
Loading

0 comments on commit 4547045

Please sign in to comment.