Skip to content

Commit

Permalink
Adição de build com Docker, pullrequest snesrev#186
Browse files Browse the repository at this point in the history
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
  • Loading branch information
danielsoares02 committed Jan 5, 2025
1 parent 2a1e615 commit ce6f554
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 15 deletions.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:20.04 as build
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Install dependencies
## apt install python & libraries
RUN apt-get update && \
apt-get install -y \
python3 \
python3-pip \
libjpeg-dev \
zlib1g-dev \
libsdl2-dev \
git \
wget

## install python dependencies
COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt

## Windows build dependencies
#RUN apt-get install -y \
# binutils-mingw-w64
#RUN apt-get install -y \
# tcc \
# unzip

## Switch build dependencies
### Install devkitpro for switch build
#RUN wget https://apt.devkitpro.org/install-devkitpro-pacman && \
# chmod +x ./install-devkitpro-pacman && \
# sed -i 's/apt-get/apt-get -y /g' ./install-devkitpro-pacman && \
# ./install-devkitpro-pacman
### Install switch development tools
#RUN ln -s /proc/self/mounts /etc/mtab
#RUN dkp-pacman --noconfirm -S switch-dev switch-sdl2 switch-tools

RUN mkdir /zelda3
WORKDIR /zelda3

CMD echo 'usage: docker run --rm --mount type=bind,source="$(pwd)",destination=/zelda3 zelda3 make'
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
TARGET_EXEC:=zelda3
ROM:=tables/zelda3.sfc
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
OBJS:=$(SRCS:%.c=%.o)
PYTHON:=/usr/bin/env python3
Expand All @@ -11,7 +10,7 @@ ifeq (${OS},Windows_NT)
RES:=zelda3.res
SDLFLAGS:=-Wl,-Bstatic $(shell sdl2-config --static-libs)
else
SDLFLAGS:=$(shell sdl2-config --libs) -lm
SDLFLAGS:=-lSDL2 -lm
endif

.PHONY: all clean clean_obj clean_gen
Expand All @@ -34,5 +33,5 @@ clean: clean_obj clean_gen
clean_obj:
@$(RM) $(OBJS) $(TARGET_EXEC)
clean_gen:
@$(RM) $(RES) zelda3_assets.dat tables/zelda3_assets.dat tables/*.txt tables/*.png tables/sprites/*.png tables/*.yaml
@rm -rf tables/__pycache__ tables/dungeon tables/img tables/overworld tables/sound
@$(RM) $(RES) zelda3_assets.dat assets/zelda3_assets.dat assets/*.txt tables/*.png assets/sprites/*.png assets/*.yaml
@rm -rf assets/__pycache__ assets/dungeon assets/img assets/overworld assets/sound
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ make # Add -j$(nproc) to build using all cores ( Optional )
# You can test the build directly onto the switch ( Optional )
nxlink -s zelda3.nro
```
## Building using Docker
In case you have Docker/Podman intalled you can build a docker image using the `Dockerfile` instead of using the above methods.

### Build the Docker Image

This only needs to be done one time unless the `Dockerfile` has been updated/changed

Clone this repo first

Make sure you are in the root path of this repo
```sh
docker build . -t zelda3
```

### Build the game
Ensure the rom named zelda3.sfc is in the `tables` directory

#### Build for Linux
```sh
docker run --rm --mount type=bind,source="$(pwd)",destination=/zelda3 zelda3 make
```

## More Compilation Help

Expand Down
8 changes: 6 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ int main(int argc, char** argv) {
}
}
break;
case SDL_MOUSEMOTION:
if ((g_win_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 1 || (g_win_flags & SDL_WINDOW_FULLSCREEN) == 1) {
g_cursor = !g_cursor;
SDL_ShowCursor(g_cursor);
}
break;
case SDL_KEYDOWN:
HandleInput(event.key.keysym.sym, event.key.keysym.mod, true);
break;
Expand Down Expand Up @@ -617,8 +623,6 @@ static void HandleCommand_Locked(uint32 j, bool pressed) {
case kKeys_Fullscreen:
g_win_flags ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
SDL_SetWindowFullscreen(g_window, g_win_flags & SDL_WINDOW_FULLSCREEN_DESKTOP);
g_cursor = !g_cursor;
SDL_ShowCursor(g_cursor);
break;
case kKeys_Reset:
ZeldaReset(true);
Expand Down
4 changes: 2 additions & 2 deletions src/opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void OpenGLRenderer_EndDraw() {
}

int viewport_x = (drawable_width - viewport_width) >> 1;
int viewport_y = (viewport_height - viewport_height) >> 1;
int viewport_y = (drawable_height - viewport_height) >> 1;

glBindTexture(GL_TEXTURE_2D, g_texture.gl_texture);
if (g_draw_width == g_texture.width && g_draw_height == g_texture.height) {
Expand All @@ -222,7 +222,7 @@ static void OpenGLRenderer_EndDraw() {
if (!g_opengl_es)
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);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_draw_width, g_draw_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, g_screen_buffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, g_draw_width, g_draw_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, g_screen_buffer);
}

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
Expand Down
8 changes: 4 additions & 4 deletions src/platform/switch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ include $(DEVKITPRO)/libnx/switch_rules
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
SRC_DIR := ../..
SRC_DIR := ../../..
TARGET := zelda3
BUILD := bin
SOURCES := $(SRC_DIR) $(SRC_DIR)/snes $(SRC_DIR)/third_party/gl_core $(SRC_DIR)/third_party/opus-1.3.1-stripped
SOURCES := $(SRC_DIR)/src $(SRC_DIR)/snes $(SRC_DIR)/third_party/gl_core $(SRC_DIR)/third_party/opus-1.3.1-stripped

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
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

INCLUDES := include
INCLUDES := include $(SRC_DIR)/ $(SRC_DIR)/src
APP_TITLE := The Legend of Zelda: A Link to the Past
APP_AUTHOR := snesrev & Lywx
APP_VERSION := $(shell git rev-parse --short HEAD) $(shell git rev-parse --abbrev-ref HEAD)
Expand Down
5 changes: 2 additions & 3 deletions src/select_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,15 +459,14 @@ void CopyFile_SelectionAndBlinker() { // 8cd13f
uint8 k = selectfile_R16;
if (a & 8) {
do {
if (--k < 0) {
if (sign8(--k)) {
k = 3;
break;
}
} while (!selectfile_arr1[k]);
} else {
do {
k++;
if (k >= 4)
if (++k >= 4)
k = 0;
} while (k != 3 && !selectfile_arr1[k]);
}
Expand Down

0 comments on commit ce6f554

Please sign in to comment.