Skip to content

Commit

Permalink
Move around files
Browse files Browse the repository at this point in the history
  • Loading branch information
snesrev committed Aug 17, 2023
1 parent a23632a commit 43db8cc
Show file tree
Hide file tree
Showing 90 changed files with 351 additions and 319 deletions.
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
*.aps
/obj/
/bin/
/tables/overworld/*.yaml
/tables/dungeon/*.yaml
/tables/img/
/tables/old/
/tables/zelda3.sfc
/tables/zelda3.smc
/assets/overworld/*.yaml
/assets/dungeon/*.yaml
/assets/img/
/assets/old/
/zelda3.sfc
/zelda3.smc
/saves/*.sav
/saves/sram.dat
/saves/sram.bak
/zelda3
__pycache__
/*.o
/src/*.o
/*.exe
/*.out
/snes/*.o
/msu/
/tmp/
/tables/zelda3_assets.dat
/zelda3_assets.dat
/SDL2.dll
/zelda3.*.ini
/zelda3.wiki
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
TARGET_EXEC:=zelda3
ROM:=tables/zelda3.sfc
SRCS:=$(wildcard *.c snes/*.c) third_party/gl_core/gl_core_3_1.c third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
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
CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-O2 -Werror)
CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-O2 -Werror) -I .
CFLAGS:=${CFLAGS} $(shell sdl2-config --cflags) -DSYSTEM_VOLUME_MIXER_AVAILABLE=0

ifeq (${OS},Windows_NT)
Expand All @@ -16,23 +16,23 @@ endif

.PHONY: all clean clean_obj clean_gen

all: $(TARGET_EXEC) tables/zelda3_assets.dat
all: $(TARGET_EXEC) zelda3_assets.dat
$(TARGET_EXEC): $(OBJS) $(RES)
$(CC) $^ -o $@ $(LDFLAGS) $(SDLFLAGS)
%.o : %.c
$(CC) -c $(CFLAGS) $< -o $@

$(RES): platform/win32/zelda3.rc
$(RES): src/platform/win32/zelda3.rc
@echo "Generating Windows resources"
@$(WINDRES) $< -O coff -o $@

tables/zelda3_assets.dat:
zelda3_assets.dat:
@echo "Extracting game resources"
@cd tables; $(PYTHON) restool.py --extract-from-rom -r ../$(ROM)
$(PYTHON) assets/restool.py --extract-from-rom

clean: clean_obj clean_gen
clean_obj:
@$(RM) $(OBJS) $(TARGET_EXEC)
clean_gen:
@$(RM) $(RES) tables/zelda3_assets.dat tables/*.txt tables/*.png tables/sprites/*.png tables/*.yaml
@$(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
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,15 @@ Visit Wiki for more info on building the project: https://github.com/snesrev/zel
## Compiling on Windows with TCC (1mb Tiny C Compiler)
1. Download the project by clicking "Code > Download ZIP" on the github page
2. Extract the ZIP to your hard drive
3. Place the USA rom named `zelda3.sfc` in the "\tables" subfolder
4. Open the command prompt and navigate to that folder
5. Type `python restool.py --extract-from-rom` and hit enter
6. Close the command prompt
7. Download [TCC](https://github.com/FitzRoyX/tinycc/releases/download/tcc_20221020/tcc_20221020.zip) and extract to the "\third_party" subfolder
8. Download [SDL2](https://github.com/libsdl-org/SDL/releases/download/release-2.26.3/SDL2-devel-2.26.3-VC.zip) and extract to the "\third_party" subfolder
9. Double-click `run_with_tcc.bat` in the main dir to create `zelda3.exe` in that same dir
10. Configure with `zelda3.ini` in the main dir
3. Place the USA rom named `zelda3.sfc` in the root directory.
4. Double-click `extract_assets.bat` in the main dir to create `zelda3_assets.dat` in that same dir
5. Download [TCC](https://github.com/FitzRoyX/tinycc/releases/download/tcc_20221020/tcc_20221020.zip) and extract to the "\third_party" subfolder
6. Download [SDL2](https://github.com/libsdl-org/SDL/releases/download/release-2.26.3/SDL2-devel-2.26.3-VC.zip) and extract to the "\third_party" subfolder
7. Double-click `run_with_tcc.bat` in the main dir to create `zelda3.exe` in that same dir
8. Configure with `zelda3.ini` in the main dir

## Compiling on Windows with Visual Studio (4.5gb IDE and compiler)
Same Steps 1-7 above<br/>
Same Steps 1-4 above<br/>
8. Double-click `Zelda3.sln`<br/>
9. Install the **Desktop development with C++** workload with the VS Installer if you don't have it already (it should prompt you to do this).<br/>
10. Change "debug" to "release" in the top dropdown<br/>
Expand Down Expand Up @@ -88,7 +86,7 @@ python3 -m pip install -r requirements.txt
* macOS: `brew install sdl2` (you can get homebrew [here](https://brew.sh/))

## Compiling on Linux/MacOS
1. Place your US ROM file named `zelda3.sfc` in `zelda3/tables`
1. Place your US ROM file named `zelda3.sfc` in `zelda3`
2. Compile
```sh
make
Expand Down Expand Up @@ -124,7 +122,7 @@ Look at the wiki at https://github.com/snesrev/zelda3/wiki for more help.
The ROM needs to be named `zelda3.sfc` and has to be from the US region with this exact SHA256 hash
`66871d66be19ad2c34c927d6b14cd8eb6fc3181965b6e517cb361f7316009cfb`

In case you're planning to move the executable to a different location, please include the file `tables/zelda3_assets.dat`.
In case you're planning to move the executable to a different location, please include the file `zelda3_assets.dat`.

## Usage and controls

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ def write_assets_to_file(print_header = False):
file_data += b'\0'
file_data += v

open('zelda3_assets.dat', 'wb').write(file_data)
open('../zelda3_assets.dat', 'wb').write(file_data)

def main(args):
print_all(args)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions tables/restool.py → assets/restool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import argparse
import util
import sys
import os

os.chdir(os.path.dirname(__file__))


parser = argparse.ArgumentParser(description='Resource tool used to build zelda3_assets.dat', allow_abbrev=False)
parser.add_argument('-r', '--rom', nargs='?', metavar='ROM')
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tables/util.py → assets/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def cache(user_function):

# Both are common SNES rom extensions. For Zelda3 (NA), they are equivalent files.
COMMON_ROM_NAMES = ['zelda3.sfc', 'zelda3.smc']
DEFAULT_ROM_DIRECTORY = os.path.dirname(__file__)
DEFAULT_ROM_DIRECTORY = os.path.join(os.path.dirname(__file__), '..')

ZELDA3_SHA1_US = '6D4F10A8B10E10DBE624CB23CF03B88BB8252973'
ZELDA3_SHA1 = {
Expand Down
25 changes: 25 additions & 0 deletions extract_assets.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@echo off

2>nul (del zelda3_assets.dat)
python assets/restool.py --extract-from-rom
IF NOT ERRORLEVEL 0 goto ERROR

IF NOT EXIST "zelda3_assets.dat" (
ECHO ERROR: The python program didn't generate zelda3_assets.dat successfully.
goto ERROR
) ELSE (
REM
)

goto DONE


:ERROR
ECHO:
ECHO ERROR: Asset extraction failed!
pause
EXIT /B 1

:DONE
echo Complete!
pause
6 changes: 3 additions & 3 deletions run_with_tcc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ IF NOT EXIST "%SDL2%\lib\x64\SDL2.dll" (
REM
)

IF NOT EXIST "tables\zelda3_assets.dat" (
IF NOT EXIST "zelda3_assets.dat" (
ECHO:
ECHO ERROR: tables\zelda3_assets.dat was not found.
ECHO ERROR: zelda3_assets.dat was not found.
ECHO You need to extract assets from the ROM first, or get this file from a friend. Please see README.md
ECHO:
PAUSE
Expand All @@ -38,7 +38,7 @@ IF NOT EXIST "tables\zelda3_assets.dat" (


echo Building with TCC...
third_party\tcc\tcc.exe -ozelda3.exe -DCOMPILER_TCC=1 -DSTBI_NO_SIMD=1 -DHAVE_STDINT_H=1 -D_HAVE_STDINT_H=1 -DSYSTEM_VOLUME_MIXER_AVAILABLE=0 -I%SDL2%/include -L%SDL2%/lib/x64 -lSDL2 *.c snes/*.c third_party/gl_core/gl_core_3_1.c third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
third_party\tcc\tcc.exe -ozelda3.exe -DCOMPILER_TCC=1 -DSTBI_NO_SIMD=1 -DHAVE_STDINT_H=1 -D_HAVE_STDINT_H=1 -DSYSTEM_VOLUME_MIXER_AVAILABLE=0 -I%SDL2%/include -L%SDL2%/lib/x64 -lSDL2 -I. src/*.c snes/*.c third_party/gl_core/gl_core_3_1.c third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c
IF ERRORLEVEL 1 goto GETOUT

copy %SDL2%\lib\x64\SDL2.dll .
Expand Down
2 changes: 1 addition & 1 deletion snes/ppu.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <stddef.h>
#include <assert.h>
#include "ppu.h"
#include "../types.h"
#include "src/types.h"

static const uint8 kSpriteSizes[8][2] = {
{8, 16}, {8, 32}, {8, 64}, {16, 32},
Expand Down
4 changes: 2 additions & 2 deletions snes/ppu.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "saveload.h"
#include "snes/saveload.h"
typedef struct Ppu Ppu;

#include "../types.h"
#include "src/types.h"

typedef struct BgLayer {
uint16_t hScroll;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions main.c → src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,9 @@ uint32 g_asset_sizes[kNumberOfAssets];

static void LoadAssets() {
size_t length = 0;
uint8 *data = ReadWholeFile("tables/zelda3_assets.dat", &length);
uint8 *data = ReadWholeFile("zelda3_assets.dat", &length);
if (!data)
data = ReadWholeFile("zelda3_assets.dat", &length);
data = ReadWholeFile("tables/zelda3_assets.dat", &length);
if (!data) Die("Failed to read zelda3_assets.dat. Please see the README for information about how you get this file.");

static const char kAssetsSig[] = { kAssets_Sig };
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions platform/win32/zelda3.rc → src/platform/win32/zelda3.rc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

1 TEXTINCLUDE
BEGIN
"platform\\win32\\resource.h\0"
"src\\platform\\win32\\resource.h\0"
END

2 TEXTINCLUDE
Expand All @@ -52,7 +52,7 @@ END

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "platform\\win32\\triforce.ico"
IDI_ICON1 ICON "src\\platform\\win32\\triforce.ico"

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 43db8cc

Please sign in to comment.