Guest User

Pokemon Gold prototype rom fixer

a guest
May 31st, 2018
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. /* public domain */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <inttypes.h>
  5.  
  6. uint8_t* rom_space;
  7.  
  8. int main(void) {
  9.     FILE* fp;
  10.    
  11.     rom_space = (uint8_t*)malloc(sizeof(uint8_t) * 1048576);
  12.     if(rom_space == NULL) return 0;
  13.    
  14.     fp = fopen("Gold_debug.gbc","rb");
  15.     if(fp == NULL) {
  16.         puts("could not open Gold_debug.gbc!");
  17.         free(rom_space);
  18.         return 0;
  19.     }
  20.    
  21.     fread(rom_space, sizeof(uint8_t), 1048576, fp);
  22.     fclose(fp);
  23.     rom_space[0x147] = 0x13;
  24.     rom_space[0x14D] = 0xC4;
  25.    
  26.     fp = fopen("__GOLD_DEBUG_BLPATCHED.gbc","wb");
  27.     if(fp == NULL) {
  28.         puts("could not write the patched rom file");
  29.         free(rom_space);
  30.         return 0;
  31.     }
  32.    
  33.     fwrite(rom_space, sizeof(uint8_t), 1048576, fp);
  34.     fclose(fp);
  35.     puts("Wrote patched file successfully!");
  36.    
  37.     free(rom_space);
  38.    
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment