GBA rom trimmer for Mac?

Discussion in 'NDS - Flashcarts and Accessories' started by DMPugh, Dec 16, 2008.

  1. DMPugh

    DMPugh Advanced Member

    Aug 3, 2008
    Not sure if this is the right forum for this, but can someone point me to a rom trimmer for Mac for GBA roms? Preferably something like Rominator which can automatically rename the roms. These will be used on a 3-in-1 through an Acekard 2.1. Thanks!
  2. enarky

    enarky owls?

    GBAtemp Patron
    enarky is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Jul 31, 2003
    If you have access to a C Compiler you could take this snippet from Pogoshell to compile your own Max OS X command line trimmer... been using it for years on Windows and Linux, works fine.

    * romtrunc - this programm removes "unnecessary" bytes from the end of *
    * (theoretically any, but in this case) GBA files. *
    * last changed September 9th 2003 *


    #define BUF_SIZE 65536

    int main(int argc, char *argv[])
    unsigned char buf[BUF_SIZE], c, oldc;
    int l;

    FILE *fpi, *fpo;

    if(argc != 3){
    printf("Truncate similar bytes from end of file\n");
    printf("Usage: ""romtrunc infile.gba outfile.gba"" or\n");
    printf(" ""romtrunc infile.gba""\n");

    if(!(fpo=fopen(argv[2], "wb"))){
    printf("ERROR, either your disk is full or this file does not exist.");

    if(!(fpi=fopen(argv[1], "rb"))){
    printf("ERROR, either your disk is full or this file does not exist.");

    // Begin of truncating operation.

    fseek(fpi, -1, SEEK_END);
    fread(&c, 1, 1, fpi);
    oldc = c;

    while((!c || (c == 0xFF) || (c==0x00)) && (oldc == c)){
    fseek(fpi, -2, SEEK_CUR);
    oldc = c;
    fread(&c, 1, 1, fpi);

    l = ftell(fpi);
    fseek(fpi, 0, SEEK_SET);
    printf("Truncating at %d\n", l);

    while(l > BUF_SIZE){
    fread(buf, 1, BUF_SIZE, fpi);
    fwrite(buf, 1, BUF_SIZE, fpo);
    l -= BUF_SIZE;

    fread(buf, 1, l, fpi);
    fwrite(buf,1, l, fpo);

    return 0;
    If Mac OS X has gcc installed (what I hope, it's based on BSD, afterall...) just paste this into a text file and call it 'romtrunc.c'. Then compile it with 'gcc -Wall -g romtrunc.c -o romtrunc.
  3. Narin

    Narin The Cheat Master, kupo!

    Former Staff
    Feb 19, 2008
    United States
    I wouldn't bother really. I took about a gigabyte of GBA ROMs (About a thousand in total) and trimmed them and only saved like 32 megabytes. Most GBA ROMs use up all the space in the ROM so unlike NDS games, you gain very little from trimming them.