summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjiangzhengwenjz <jiangzhengwenjzw@qq.com>2019-06-26 05:13:48 +0800
committerjiangzhengwenjz <jiangzhengwenjzw@qq.com>2019-06-26 05:13:48 +0800
commit1f82c7cbd5ee41e7104a555ff876fcb883101dcd (patch)
tree4baed0edb1bf93d229fd87337067431e1236d45e
parent1182626739fe90a687754709abc88cb896cc057e (diff)
parentfd543fd799caf59cabf55721e561fcfb0f59315d (diff)
resolve conflict
-rw-r--r--.gitignore1
-rw-r--r--INSTALL.md12
-rw-r--r--tools/br_ips/br_ips.c22
3 files changed, 25 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index e3cb43d69..a28828524 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,4 +43,5 @@ build/
*.pl
*.bak
src/data/items.h
+src/data/items.h # Autogenerated by jsonproc
tools/br_ips/{br_ips,ips_patch}{,.exe}
diff --git a/INSTALL.md b/INSTALL.md
index 729014051..4829680de 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -42,4 +42,14 @@ If only `.c` or `.s` files were changed, turn off the dependency scanning tempor
make -j$(nproc) NODEP=1
-**Note:** If the build command is not recognized on Linux, including the Linux environment used within Windows, run `nproc` and replace `$(nproc)` with the returned value (e.g.: `make -j4`). Because `nproc` is not available on macOS, the alternative is `sysctl -n hw.ncpu`.
+**Note (until further notice):** If this is your first time building Pokemon FireRed, an unmodified copy of Pokemon FireRed is required in the project root under the name `baserom.gba`. To generate this, you should run the following commands:
+
+ make ips_patch -C tools/br_ips
+ head -c 16777216 /dev/zero > tmp.bin
+ tools/br_ips/ips_patch tmp.bin baserom.ips baserom.gba
+ make compare -j$(nproc)
+ cp pokefirered.gba baserom.gba
+
+Alternatively, you can obtain an unmodified copy of Pokemon FireRed and use that as baserom.gba. Make sure the SHA1 checksum matches with what's provided in [the README](README.md).
+
+**Note 2:** If the build command is not recognized on Linux, including the Linux environment used within Windows, run `nproc` and replace `$(nproc)` with the returned value (e.g.: `make -j4`). Because `nproc` is not available on macOS, the alternative is `sysctl -n hw.ncpu`.
diff --git a/tools/br_ips/br_ips.c b/tools/br_ips/br_ips.c
index 8e4469b5a..10d9a37c0 100644
--- a/tools/br_ips/br_ips.c
+++ b/tools/br_ips/br_ips.c
@@ -24,29 +24,33 @@ static int getline(char ** lineptr, size_t * n, FILE * stream) {
// Static implementation of GNU getline
int i = 0;
int c;
+ if (n == NULL || lineptr == NULL || stream == NULL) return -1;
size_t size = *n;
char * buf = *lineptr;
- if (size == 0) {
- size = BUFSIZ;
- buf = realloc(buf, BUFSIZ);
+ if (buf == NULL || size < 4) {
+ size = 128;
+ *lineptr = buf = realloc(buf, 128);
}
if (buf == NULL) return -1;
- do {
- if (feof(stream)) return -1;
+ while (1) {
c = getc(stream);
+ if (c == EOF) break;
buf[i++] = c;
- if (i == size -1) {
+ if (c == '\n') break;
+ if (i == size - 1) {
size <<= 1;
buf = realloc(buf, size);
if (buf == NULL) return -1;
+ *lineptr = buf;
+ *n = size;
}
- } while (c != '\n');
+ }
+ if (i == 0) return -1;
buf[i] = 0;
- *lineptr = buf;
- *n = size;
return i;
}
+
static void getIncbinsFromFile(hunk_t ** hunks, size_t * num, size_t * maxnum, const char * fname, char ** strbuf, size_t * buffersize) {
// Recursively find incbinned segments and encode them as hunks.
FILE * file = fopen(fname, "r");