Skip to content

Commit 3923f7a

Browse files
committed
Initial commit
0 parents  commit 3923f7a

9 files changed

Lines changed: 1406 additions & 0 deletions

File tree

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Enforce LF for shell scripts
2+
*.sh text=auto eol=lf
3+
# Enforce CRLF for batch scripts
4+
*.bat text=auto eol=crlf

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# compilation output
2+
/dst/*.*
3+
# log output
4+
/**/*.log

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Yonder
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# makecode
2+
makecode is a cli that prints PrimeHack's mods ported to Gecko codes.
3+
4+
## Table of Contents
5+
- [Info](#info)
6+
- [Building](#building)
7+
- [Credits](#credits)
8+
- [License](#license)
9+
10+
## Info
11+
PrimeHack has modifications that you can enable at runtime to do things like unlock hypermode difficulty, disable bloom
12+
, etc. This tool is a port of these mods to Gecko codes. It can print a code based on the game and region.
13+
14+
makecode can print code(s) to the format for Dolphin (`[Gecko]\n$Code Name\ncode`), Ocarina (`GAMEID\nGame Name\n\n
15+
Code Name\ncode`), and raw (`code`).
16+
17+
## Building
18+
Simply run `./compile.sh` at root directory of project. This script uses GCC to compile the sources. It also computes
19+
the md5, sha1, and sha256 hash of the compiled result afterwards using `md5sum`, `sha1sum`, and `sha256sum`. You can
20+
pass `asan` as the first argument to the script to build a debug build with AddressSanitizer (this isn't supported on a
21+
Windows build). For building for Windows, run `./compile.sh` with MSYS2 MinGW x64 or run `.\compile.bat`.
22+
23+
## Credits
24+
- Shio, SirMangler, and many others for their work on PrimeHack, a modification of Dolphin Emulator to allow for FPS
25+
controls and other things on the Metroid Prime series [here](https://github.com/shiiion/dolphin).
26+
27+
## License
28+
```
29+
MIT License
30+
31+
Copyright (c) 2022 Yonder
32+
33+
Permission is hereby granted, free of charge, to any person obtaining a copy
34+
of this software and associated documentation files (the "Software"), to deal
35+
in the Software without restriction, including without limitation the rights
36+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37+
copies of the Software, and to permit persons to whom the Software is
38+
furnished to do so, subject to the following conditions:
39+
40+
The above copyright notice and this permission notice shall be included in all
41+
copies or substantial portions of the Software.
42+
43+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49+
SOFTWARE.
50+
51+
```

compile.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@ECHO OFF
2+
SET "CWD=%~dp0"
3+
SET "CWD=%CWD:~0,-1%"
4+
CALL C:\msys64\msys2_shell.cmd -where "%CWD%" -shell bash -mingw64 -no-start -c "($PWD/compile.sh) &> $PWD/compile.log"

compile.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
ASAN=""
3+
OUTEXT=""
4+
if [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ] || [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
5+
OUTEXT=".exe"
6+
elif [ $# -gt 0 ]; then
7+
if [ "$1" == "asan" ]; then
8+
ASAN="-fsanitize=address -g"
9+
fi
10+
fi
11+
if [ ! -d "./dst" ]; then mkdir ./dst ; fi
12+
gcc -std=c99 $ASAN -Wvla -o ./dst/makecode$OUTEXT ./src/makecode.c
13+
md5sum -b ./dst/makecode$OUTEXT > ./dst/makecode$OUTEXT.md5
14+
sha1sum -b ./dst/makecode$OUTEXT > ./dst/makecode$OUTEXT.sha1
15+
sha256sum -b ./dst/makecode$OUTEXT > ./dst/makecode$OUTEXT.sha256

src/csprintf_s.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2022 Yonder
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
#ifndef _CSPRINTF_S_H_
26+
#define _CSPRINTF_S_H_
27+
#include <stdarg.h>
28+
#include <stdlib.h>
29+
#include <stdio.h>
30+
31+
char* csprintf_s(char* format, ...) {
32+
va_list args;
33+
va_start(args, format);
34+
35+
ssize_t buffSz = vsnprintf(NULL, 0, format, args);
36+
37+
char* buff = malloc(buffSz + 1);
38+
vsnprintf(buff, buffSz + 1, format, args);
39+
40+
va_end(args);
41+
42+
return buff;
43+
}
44+
#endif

0 commit comments

Comments
 (0)