Skip to content

Commit ce6f554

Browse files
Adição de build com Docker, pullrequest snesrev#186
Correção no src/main.cs, pullrequest snesrev#247 Correção no src/opengl.cs, pullrequest snesrev#270 Correção no src/platform/switch/Makefile, pullrequest snesrev#273 Correção no MakeFile, pullrequest snesrev#276 Correção no src/select_file.c, pullrequest snesrev#292
1 parent 2a1e615 commit ce6f554

File tree

7 files changed

+79
-15
lines changed

7 files changed

+79
-15
lines changed

Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM ubuntu:20.04 as build
2+
ENV TZ=Etc/UTC
3+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
4+
5+
# Install dependencies
6+
## apt install python & libraries
7+
RUN apt-get update && \
8+
apt-get install -y \
9+
python3 \
10+
python3-pip \
11+
libjpeg-dev \
12+
zlib1g-dev \
13+
libsdl2-dev \
14+
git \
15+
wget
16+
17+
## install python dependencies
18+
COPY requirements.txt /tmp/
19+
RUN pip3 install -r /tmp/requirements.txt
20+
21+
## Windows build dependencies
22+
#RUN apt-get install -y \
23+
# binutils-mingw-w64
24+
#RUN apt-get install -y \
25+
# tcc \
26+
# unzip
27+
28+
## Switch build dependencies
29+
### Install devkitpro for switch build
30+
#RUN wget https://apt.devkitpro.org/install-devkitpro-pacman && \
31+
# chmod +x ./install-devkitpro-pacman && \
32+
# sed -i 's/apt-get/apt-get -y /g' ./install-devkitpro-pacman && \
33+
# ./install-devkitpro-pacman
34+
### Install switch development tools
35+
#RUN ln -s /proc/self/mounts /etc/mtab
36+
#RUN dkp-pacman --noconfirm -S switch-dev switch-sdl2 switch-tools
37+
38+
RUN mkdir /zelda3
39+
WORKDIR /zelda3
40+
41+
CMD echo 'usage: docker run --rm --mount type=bind,source="$(pwd)",destination=/zelda3 zelda3 make'

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
TARGET_EXEC:=zelda3
2-
ROM:=tables/zelda3.sfc
32
SRCS:=$(wildcard src/*.c snes/*.c) third_party/gl_core/gl_core_3_1.c third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
43
OBJS:=$(SRCS:%.c=%.o)
54
PYTHON:=/usr/bin/env python3
@@ -11,7 +10,7 @@ ifeq (${OS},Windows_NT)
1110
RES:=zelda3.res
1211
SDLFLAGS:=-Wl,-Bstatic $(shell sdl2-config --static-libs)
1312
else
14-
SDLFLAGS:=$(shell sdl2-config --libs) -lm
13+
SDLFLAGS:=-lSDL2 -lm
1514
endif
1615

1716
.PHONY: all clean clean_obj clean_gen
@@ -34,5 +33,5 @@ clean: clean_obj clean_gen
3433
clean_obj:
3534
@$(RM) $(OBJS) $(TARGET_EXEC)
3635
clean_gen:
37-
@$(RM) $(RES) zelda3_assets.dat tables/zelda3_assets.dat tables/*.txt tables/*.png tables/sprites/*.png tables/*.yaml
38-
@rm -rf tables/__pycache__ tables/dungeon tables/img tables/overworld tables/sound
36+
@$(RM) $(RES) zelda3_assets.dat assets/zelda3_assets.dat assets/*.txt tables/*.png assets/sprites/*.png assets/*.yaml
37+
@rm -rf assets/__pycache__ assets/dungeon assets/img assets/overworld assets/sound

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,27 @@ make # Add -j$(nproc) to build using all cores ( Optional )
118118
# You can test the build directly onto the switch ( Optional )
119119
nxlink -s zelda3.nro
120120
```
121+
## Building using Docker
122+
In case you have Docker/Podman intalled you can build a docker image using the `Dockerfile` instead of using the above methods.
123+
124+
### Build the Docker Image
125+
126+
This only needs to be done one time unless the `Dockerfile` has been updated/changed
127+
128+
Clone this repo first
129+
130+
Make sure you are in the root path of this repo
131+
```sh
132+
docker build . -t zelda3
133+
```
134+
135+
### Build the game
136+
Ensure the rom named zelda3.sfc is in the `tables` directory
137+
138+
#### Build for Linux
139+
```sh
140+
docker run --rm --mount type=bind,source="$(pwd)",destination=/zelda3 zelda3 make
141+
```
121142

122143
## More Compilation Help
123144

src/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ int main(int argc, char** argv) {
428428
}
429429
}
430430
break;
431+
case SDL_MOUSEMOTION:
432+
if ((g_win_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 1 || (g_win_flags & SDL_WINDOW_FULLSCREEN) == 1) {
433+
g_cursor = !g_cursor;
434+
SDL_ShowCursor(g_cursor);
435+
}
436+
break;
431437
case SDL_KEYDOWN:
432438
HandleInput(event.key.keysym.sym, event.key.keysym.mod, true);
433439
break;
@@ -617,8 +623,6 @@ static void HandleCommand_Locked(uint32 j, bool pressed) {
617623
case kKeys_Fullscreen:
618624
g_win_flags ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
619625
SDL_SetWindowFullscreen(g_window, g_win_flags & SDL_WINDOW_FULLSCREEN_DESKTOP);
620-
g_cursor = !g_cursor;
621-
SDL_ShowCursor(g_cursor);
622626
break;
623627
case kKeys_Reset:
624628
ZeldaReset(true);

src/opengl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static void OpenGLRenderer_EndDraw() {
208208
}
209209

210210
int viewport_x = (drawable_width - viewport_width) >> 1;
211-
int viewport_y = (viewport_height - viewport_height) >> 1;
211+
int viewport_y = (drawable_height - viewport_height) >> 1;
212212

213213
glBindTexture(GL_TEXTURE_2D, g_texture.gl_texture);
214214
if (g_draw_width == g_texture.width && g_draw_height == g_texture.height) {
@@ -222,7 +222,7 @@ static void OpenGLRenderer_EndDraw() {
222222
if (!g_opengl_es)
223223
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_draw_width, g_draw_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g_screen_buffer);
224224
else
225-
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_draw_width, g_draw_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, g_screen_buffer);
225+
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, g_draw_width, g_draw_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, g_screen_buffer);
226226
}
227227

228228
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

src/platform/switch/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ include $(DEVKITPRO)/libnx/switch_rules
3737
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
3838
# NACP building is skipped as well.
3939
#---------------------------------------------------------------------------------
40-
SRC_DIR := ../..
40+
SRC_DIR := ../../..
4141
TARGET := zelda3
4242
BUILD := bin
43-
SOURCES := $(SRC_DIR) $(SRC_DIR)/snes $(SRC_DIR)/third_party/gl_core $(SRC_DIR)/third_party/opus-1.3.1-stripped
43+
SOURCES := $(SRC_DIR)/src $(SRC_DIR)/snes $(SRC_DIR)/third_party/gl_core $(SRC_DIR)/third_party/opus-1.3.1-stripped
4444

45-
CFILES := $(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/snes/*.c) $(SRC_DIR)/third_party/gl_core/gl_core_3_1.c $(SRC_DIR)/third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
45+
CFILES := $(wildcard $(SRC_DIR)/src/*.c $(SRC_DIR)/snes/*.c) $(SRC_DIR)/third_party/gl_core/gl_core_3_1.c $(SRC_DIR)/third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
4646

47-
INCLUDES := include
47+
INCLUDES := include $(SRC_DIR)/ $(SRC_DIR)/src
4848
APP_TITLE := The Legend of Zelda: A Link to the Past
4949
APP_AUTHOR := snesrev & Lywx
5050
APP_VERSION := $(shell git rev-parse --short HEAD) $(shell git rev-parse --abbrev-ref HEAD)

src/select_file.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,15 +459,14 @@ void CopyFile_SelectionAndBlinker() { // 8cd13f
459459
uint8 k = selectfile_R16;
460460
if (a & 8) {
461461
do {
462-
if (--k < 0) {
462+
if (sign8(--k)) {
463463
k = 3;
464464
break;
465465
}
466466
} while (!selectfile_arr1[k]);
467467
} else {
468468
do {
469-
k++;
470-
if (k >= 4)
469+
if (++k >= 4)
471470
k = 0;
472471
} while (k != 3 && !selectfile_arr1[k]);
473472
}

0 commit comments

Comments
 (0)