programming question

Discussion in 'NDS - Emulation and Homebrew' started by pka4916, Dec 19, 2008.

  1. pka4916
    OP

    pka4916 GBAtemp Regular

    Member
    121
    1
    May 24, 2006
    United States
    USA
    hi, hope someone can help me with this,

    I'm trying to find out how to get the picture out of the rom
    and determ what the trimsize could be.

    i am thinking that from reading on
    http://www.bottledlight.com/ds/index...mats/NDSFormat

    that this will show the size?
    ROM size 0x080 0x083 4 0x00EE3E44

    how can i calculate those values to get the right trim size?
    i tried several things, but it just doesnt add up.

    maybe someone can help me out with this.
    I am using Delphi btw.

    thank you so much
     
  2. hankchill

    hankchill I Pwn n00bs.

    Member
    2,344
    42
    Nov 5, 2005
    Canada
    Outer Space
    You need to understand exactly how it works to get the trim size, yes those are the correct locations in the rom for finding the trim size, but it needs to be reversed, so the trimsize will be 0x083 + 0x082 + 0x081 + 0x080, not the other way around.

    After you figure that, it will give the proper rom length in hex.
     
  3. pka4916
    OP

    pka4916 GBAtemp Regular

    Member
    121
    1
    May 24, 2006
    United States
    USA
    so,

    I had this (from rom DQM) 128mb and trimsize = 83.5 mb (according to rominator)


    GRomsize: array [0..3] of Byte


    Seek(129,0); (pos 129 in the rom file)
    Read(gromsize,4); read the 4 bytes

    result is (180, 56, 5, 0)

    so reading it back wards would be 0 , 5 , 56, 180

    what do i need to do from here then? since i was making it 556180 as size
    but don't know if it bytes,kb,mbit
     
  4. anoNL

    anoNL Member

    Newcomer
    32
    0
    Sep 27, 2008
    Netherlands
    http://en.wikipedia.org/wiki/Endianness
    You're trying to read a 4-byte word in little endian.

    unsigned int result = (b[3]
     
  5. pka4916
    OP

    pka4916 GBAtemp Regular

    Member
    121
    1
    May 24, 2006
    United States
    USA
    after reading the wiki, i am more confused now.
     
  6. hankchill

    hankchill I Pwn n00bs.

    Member
    2,344
    42
    Nov 5, 2005
    Canada
    Outer Space
    Maybe should start with something a little more simpler? [​IMG]
     
  7. pka4916
    OP

    pka4916 GBAtemp Regular

    Member
    121
    1
    May 24, 2006
    United States
    USA
    Nah.
    I will figure it out.. got eveything else figured out, except those 2 hickups.
    [​IMG]
     
  8. sypherce

    sypherce Member

    Newcomer
    18
    10
    Dec 4, 2008
    United States
    USA, New York
    The following should do what you want, given that the rom is at rom.nds in the same directory. Since your last post was 3 days ago, you likely figured out your problem, but I was bored so I decided to write up the code anyways.

    Code:
    program DataFiles;
    
    var
    ÂÂÂÂf: file of byte;
    ÂÂÂÂb1: byte;
    ÂÂÂÂb2: byte;
    ÂÂÂÂb3: byte;
    ÂÂÂÂb4: byte;
    ÂÂÂÂli: longint;
    
    begin
    ÂÂÂÂassign(f,'rom.nds');
    ÂÂÂÂreset(f);
    
    ÂÂÂÂseek(f,128);
    ÂÂÂÂread(f,b1);
    ÂÂÂÂread(f,b2);
    ÂÂÂÂread(f,b3);
    ÂÂÂÂread(f,b4);
    ÂÂÂÂclose(f);
    
    ÂÂÂÂli := (b4 shl 24) or (b3 shl 16) or (b2 shl 8) or b1;
    
    ÂÂÂÂwrite(li);
    end.