Skip to content

Instantly share code, notes, and snippets.

Last active November 19, 2021 16:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
The code I used for my "Hacking Pokemon Red to say Hello! (Nintendo Game Boy)" YouTube video -
#include <stdio.h>
#include <stdint.h>
int main(int argc, char** argv) {
FILE* fp = fopen(argv[1], "rb");
if (fp == NULL) {
return -1;
fseek(fp, 0L, SEEK_END);
size_t len = ftell(fp);
uint8_t* buff = malloc(len);
fread(buff, len, 1, fp);
size_t sum = 0;
for (size_t i = 0; i < len; ++i) {
if (i != 0x14E && i != 0x14F) {
sum += buff[i];
} else {
printf("Skipping checksum\n");
printf("Sum: %zx\n", sum);
return 0;
Copy link

Improve the code if you wish, I just wanted something working asap :P

Copy link

I updated to print out in hex instead of decimal, one less conversion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment