shithub: zelda3

Download patch

ref: e2ab55b65c3a6bdebdbb5f6f71f6d11efd10b46d
parent: bfd7a7aa409f947a262d69ab248fb17480456e17
author: Snesrev <[email protected]>
date: Wed Sep 28 10:45:50 EDT 2022

Add information on how to build with TCC

 - It means you no longer need Visual Studio

--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,6 @@
 /msu/alttp_msu-*.pcm
 /tmp/
 /tables/zelda3_assets.dat
+/third_party/tcc/
+/third_party/SDL2-2.24.0/
+/SDL2.dll
--- a/README.md
+++ b/README.md
@@ -64,6 +64,26 @@
 
 Then build the .sln file with Visual Studio.
 
+### Building with TCC instead of Visual Studio on Windows
+
+You can also build and run it through TCC in case you don't have Visual Studio. Note that TCC builds without optimizations so the game will run considerably slower.
+
+
+<details>
+<summary>
+Read about how to use TCC here...
+</summary>
+Extract the assets as detailed above.
+
+Unzip [TCC for win64](http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win64-bin.zip) into `third_party/tcc`.
+
+Unzip [SDL2](https://github.com/libsdl-org/SDL/releases/download/release-2.24.0/SDL2-devel-2.24.0-VC.zip) into `third_party/SDL2-2.24.0`.
+
+Start `run_with_tcc.bat`. It will perform some basic error checks and then start the game.
+
+</details>
+
+
 ### Linux/macOS
 
 ```sh
--- /dev/null
+++ b/run_with_tcc.bat
@@ -1,0 +1,51 @@
+@echo off
+
+set SDL2=third_party\SDL2-2.24.0
+
+IF NOT EXIST "third_party\tcc\tcc.exe" (
+  ECHO:
+  ECHO ERROR: third_party\tcc\tcc.exe doesn't exist. Please verify that you have put it in the right location.
+  ECHO   Download it from http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win64-bin.zip
+  ECHO   It needs to be the 64-bit version.
+  ECHO:
+  PAUSE
+  EXIT /B 1
+) ELSE (
+  REM
+)
+
+IF NOT EXIST "%SDL2%\lib\x64\SDL2.dll" (
+  ECHO:
+  ECHO ERROR: SDL is not unzipped properly into %SDL2%
+  ECHO   Download it from https://github.com/libsdl-org/SDL/releases/download/release-2.24.0/SDL2-devel-2.24.0-VC.zip
+  ECHO:
+  PAUSE
+  EXIT /B 1
+) ELSE (
+  REM
+)
+
+IF NOT EXIST "tables\zelda3_assets.dat" (
+  ECHO:
+  ECHO ERROR: tables\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
+  EXIT /B 1
+) ELSE (
+  REM
+)
+
+
+echo Building with TCC...
+third_party\tcc\tcc.exe -ozelda3.exe -DHAVE_STDINT_H=1 -D_HAVE_STDINT_H=1 -I%SDL2%/include -L%SDL2%/lib/x64 -lSDL2 *.c snes/*.c
+IF ERRORLEVEL 1 goto GETOUT
+
+copy %SDL2%\lib\x64\SDL2.dll .
+
+echo Running...
+zelda3.exe
+
+
+:GETOUT
+pause
--- a/types.h
+++ b/types.h
@@ -1,7 +1,9 @@
+#ifndef ZELDA3_TYPES_H_
+#define ZELDA3_TYPES_H_
+
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdbool.h>
-#pragma once
 
 // Build time config options
 enum {
@@ -92,3 +94,5 @@
 typedef void HandlerFuncK(int k);
 
 void NORETURN Die(const char *error);
+
+#endif  // ZELDA3_TYPES_H_