Skip to content

Commit 66fce78

Browse files
committed
2025 update
1 parent 56df015 commit 66fce78

File tree

298 files changed

+741
-873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

298 files changed

+741
-873
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.DS_Store
66
*~
77
filesystem/
8+
build/

.vscode/c_cpp_properties.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "libdragon",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"${workspaceFolder}/../../libdragon/**"
8+
]
9+
}
10+
],
11+
"version": 4
12+
}

.vscode/settings.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
{
22
"files.associations": {
3-
"konami.h": "c",
4-
"controls.h": "c",
5-
"bgm.h": "c",
6-
"dfs.h": "c",
7-
"limits": "c",
8-
"type_traits": "c"
3+
"*.h": "c",
94
},
105
"editor.formatOnSave": true
116
}

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
FROM anacierdem/libdragon
1+
FROM ghcr.io/dragonminded/libdragon
2+
ARG LIBDRAGON_COMMIT 9926cc32e384d58c74b609733c7b50457d811732 #11/22/25
23

3-
RUN apt-get update && apt-get install -yq libsox-fmt-all sox
4+
RUN apt-get update -yq
5+
6+
RUN cd /tmp && git clone https://github.com/DragonMinded/libdragon.git && cd libdragon && git reset --hard $LIBDRAGON_COMMIT && make install && make tools-install
47

58
WORKDIR /game

Makefile

Lines changed: 57 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,95 @@
1-
ROOTDIR = $(N64_INST)
2-
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
3-
CHKSUM64PATH = $(ROOTDIR)/bin/chksum64
4-
MKDFSPATH = $(ROOTDIR)/bin/mkdfs
5-
MKSPRITE = $(ROOTDIR)/bin/mksprite
6-
N64TOOL = $(ROOTDIR)/bin/n64tool
7-
LINK_FLAGS = -L$(ROOTDIR)/lib -L$(ROOTDIR)/mips64-elf/lib -ldragon -lc -lm -ldragonsys -Tn64.ld
8-
PROG_NAME = 2048-64
9-
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O2 -Wall -Werror -I$(ROOTDIR)/mips64-elf/include -Iinclude -I/usr/local/include/
10-
ASFLAGS = -mtune=vr4300 -march=vr4300
11-
CC = $(GCCN64PREFIX)gcc
12-
AS = $(GCCN64PREFIX)as
13-
LD = $(GCCN64PREFIX)ld
14-
OBJCOPY = $(GCCN64PREFIX)objcopy
1+
ARES_BIN := /Applications/ares.app/Contents/MacOS/ares
2+
3+
BUILD_DIR := build
4+
SOURCE_DIR := src
5+
ROM_NAME := 2048-64
6+
N64_ROM_TITLE := "2048-64"
7+
8+
N64_MK_PATH := $(N64_INST)/include/n64.mk
9+
ifneq (,$(wildcard $(N64_MK_PATH)))
10+
include $(N64_MK_PATH)
11+
endif
12+
13+
N64_CFLAGS += -Iinclude
14+
N64_ASFLAGS += -Iinclude
1515

1616
all: build
1717

1818
build: ## Create rom.
19-
@docker --version &> /dev/null
20-
@if [ $$? -ne 0 ]; then echo "Building rom..." && make $(PROG_NAME).z64; fi
21-
@if [ $$? -eq 0 ]; then echo "Building rom inside docker environment..." && make docker; fi
19+
@if command -v docker >/dev/null 2>&1; then \
20+
echo "Building rom inside docker environment..."; \
21+
$(MAKE) docker; \
22+
else \
23+
echo "Building rom..."; \
24+
$(MAKE) $(ROM_NAME).z64; \
25+
fi
2226

2327
docker: setup
24-
@docker run --user $(shell id -u):$(shell id -g) -v ${CURDIR}:/game build make $(PROG_NAME).z64
28+
@docker run --user $(shell id -u):$(shell id -g) -v ${CURDIR}:/game build make $(ROM_NAME).z64
2529

2630
rebuild: clean build ## Erase temp files and create the rom.
2731

2832
# gfx #
29-
PNGS := $(wildcard resources/gfx/*/*.png) $(wildcard resources/gfx/*/*/*.png)
33+
PNGS := $(wildcard resources/gfx/sprites/*.png) $(wildcard resources/gfx/sprites/*/*.png)
3034
SPRITES := $(subst .png,.sprite,$(subst resources/,filesystem/,$(PNGS)))
3135
filesystem/gfx/sprites/%.sprite: resources/gfx/sprites/%.png
3236
@mkdir -p `echo $@ | xargs dirname`
33-
$(MKSPRITE) 16 1 1 $< $@
34-
35-
filesystem/gfx/maps/%.sprite: resources/gfx/maps/%.png
36-
@mkdir -p `echo $@ | xargs dirname`
37-
$(MKSPRITE) 16 1 1 $< $@
37+
@echo " [SPRITE] $@"
38+
$(N64_MKSPRITE) -o $(dir $@) $<
3839

3940
# sfx #
4041
MP3S := $(wildcard resources/sfx/bgms/*.mp3)
41-
BGMS := $(subst .mp3,.raw,$(subst resources/,filesystem/,$(MP3S)))
42-
filesystem/sfx/bgms/%.raw: resources/sfx/bgms/%.mp3
42+
BGMS := $(subst .mp3,.wav64,$(subst resources/,filesystem/,$(MP3S)))
43+
filesystem/sfx/bgms/%.wav64: resources/sfx/bgms/%.mp3
4344
@mkdir -p `echo $@ | xargs dirname`
44-
sox $< -b 16 -e signed-integer -B -r 11025 $@ remix -
45+
@echo " [AUDIOCONV] $@"
46+
$(N64_AUDIOCONV) -d --wav-compress 3 --wav-loop false -o $(dir $@) $<
47+
48+
# font #
49+
TTFS := misc/font/clearsans-1.00/TTF/ClearSans-Bold.ttf misc/font/clearsans-1.00/TTF/ClearSans-Bold-flipped.ttf
50+
FONTS := $(subst .ttf,.font64,$(subst misc/font/clearsans-1.00/TTF/,filesystem/fonts/,$(TTFS)))
51+
filesystem/fonts/%.font64: misc/font/clearsans-1.00/TTF/%.ttf
52+
@mkdir -p `echo $@ | xargs dirname`
53+
@echo " [MKFONT] $@"
54+
$(N64_MKFONT) -s 18 --ellipsis 30,0 --range 30-39 -o $(dir $@) $<
4555

4656
# code #
47-
SRCS := $(wildcard src/*.c)
48-
OBJS := $(SRCS:.c=.o)
49-
$(PROG_NAME).elf : $(OBJS)
50-
$(LD) -o $@ $^ $(LINK_FLAGS)
57+
SRCS := $(wildcard $(SOURCE_DIR)/*.c)
58+
OBJS := $(SRCS:$(SOURCE_DIR)/%.c=$(BUILD_DIR)/%.o)
5159

52-
$(PROG_NAME).bin : $(PROG_NAME).elf
53-
$(OBJCOPY) -O binary $< $@
60+
$(BUILD_DIR)/$(ROM_NAME).elf: $(OBJS) $(N64_LIBDIR)/libdragon.a $(N64_LIBDIR)/libdragonsys.a $(N64_LIBDIR)/n64.ld
61+
@mkdir -p $(dir $@)
62+
@echo " [LD] $@"
63+
$(N64_CXX) -o $@ $(filter %.o, $^) $(filter-out $(N64_LIBDIR)/libdragon.a $(N64_LIBDIR)/libdragonsys.a, $(filter %.a, $^)) \
64+
-lc -mabi=o64 $(patsubst %,-Wl$(COMMA)%,$(LDFLAGS)) -Wl,-Map=$(BUILD_DIR)/$(ROM_NAME).map
65+
$(N64_SIZE) -G $@
66+
67+
$(ROM_NAME).z64: $(BUILD_DIR)/$(ROM_NAME).elf
68+
$(ROM_NAME).z64: $(ROM_NAME).dfs
5469

5570
# dfs #
56-
$(PROG_NAME).dfs: $(SPRITES) $(BGMS)
71+
$(ROM_NAME).dfs: $(SPRITES) $(BGMS) $(FONTS)
5772
@mkdir -p ./filesystem/
5873
@echo `git rev-parse HEAD` > ./filesystem/hash
59-
$(MKDFSPATH) $@ ./filesystem/
60-
61-
# rom
62-
$(PROG_NAME).z64: $(PROG_NAME).bin $(PROG_NAME).dfs
63-
@rm -f $@
64-
$(N64TOOL) -l 16M -t "$(PROG_NAME)" -h $(ROOTDIR)/mips64-elf/lib/header -o $(PROG_NAME).z64 $(PROG_NAME).bin -s 1M $(PROG_NAME).dfs
65-
$(CHKSUM64PATH) $@
74+
$(N64_MKDFS) $@ ./filesystem/ >/dev/null
6675

6776
setup: ## Create dev environment (docker image).
68-
@docker build -q -t build - < Dockerfile > /dev/null
77+
@docker build --platform linux/amd64 -t build - < Dockerfile
6978

7079
resetup: ## Force recreate the dev environment (docker image).
7180
@echo "Rebuilding dev environment in docker..."
72-
@docker build -q -t build --no-cache - < Dockerfile > /dev/null
81+
@docker build --platform linux/amd64 -t build --no-cache - < Dockerfile
7382

74-
cen64: ## Start rom in CEN64 emulator.
75-
@echo "Starting cen64..."
76-
$(CEN64_DIR)/cen64 -multithread -controller num=1,pak=rumble $(CEN64_DIR)/pifdata.bin $(PROG_NAME).z64
83+
ares: ## Start rom in Ares emulator.
84+
@echo "Starting ares..."
85+
$(ARES_BIN) $(ROM_NAME).z64
7786

7887
flashair: ## Flash rom to EverDrive using a flashair SD card.
79-
curl -X POST -F 'file=@$(PROG_NAME).z64' http://flashair/upload.cgi
88+
curl -X POST -F 'file=@$(ROM_NAME).z64' http://flashair/upload.cgi
8089

8190
clean: ## Cleanup temp files.
8291
@echo "Cleaning up temp files..."
83-
rm -rf *.z64 *.elf src/*.o *.bin *.dfs filesystem/
92+
rm -rf $(BUILD_DIR) *.z64 *.elf src/*.o *.bin *.dfs filesystem/
8493

8594
help: ## Show this help.
8695
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/:.*##/:/'

include/bgm.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* bgm.h -- bgm helpers header
22
*
3-
* Copyright (C) 2018 Victor Vieux
3+
* Copyright (C) 2018-2025 Victor Vieux
44
*
55
* This software may be modified and distributed under the terms
66
* of the Apache license. See the LICENSE file for details.
@@ -11,15 +11,14 @@
1111

1212
#include <libdragon.h>
1313

14-
#define FREQUENCY_11KHZ 11025
15-
#define FREQUENCY_44KHZ 44100
1614
#define NUM_BGMS 3
1715

1816
void bgm_init();
17+
void bgm_pause();
18+
void bgm_play();
1919
void bgm_start();
2020
void bgm_stop();
2121
int bgm_toggle(int);
22-
void bgm_play_pause();
2322
void bgm_update();
2423

25-
#endif //__BGM_H__
24+
#endif //__BGM_H__

include/colors.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* colors.h -- colors helpers header
22
*
3-
* Copyright (C) 2018 Victor Vieux
3+
* Copyright (C) 2018-2025 Victor Vieux
44
*
55
* This software may be modified and distributed under the terms
66
* of the Apache license. See the LICENSE file for details.
@@ -33,6 +33,8 @@ typedef enum
3333
COLOR_WHITE,
3434
} colors_name_t;
3535

36+
extern color_t colors[];
37+
3638
void colors_init();
3739

3840
#endif //__COLORS_H__

include/controls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* controls.h -- controls helpers header
22
*
3-
* Copyright (C) 2018 Victor Vieux
3+
* Copyright (C) 2018-2025 Victor Vieux
44
*
55
* This software may be modified and distributed under the terms
66
* of the Apache license. See the LICENSE file for details.

include/debug.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

include/dfs.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)