programming question

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

Dec 19, 2008

programming question by pka4916 at 9:57 PM (874 Views / 0 Likes) 7 replies

  1. pka4916
    OP

    Member pka4916 GBAtemp Regular

    Joined:
    May 24, 2006
    Messages:
    120
    Location:
    USA
    Country:
    United States
    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

    Member hankchill I Pwn n00bs.

    Joined:
    Nov 5, 2005
    Messages:
    2,344
    Location:
    Outer Space
    Country:
    Canada
    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

    Member pka4916 GBAtemp Regular

    Joined:
    May 24, 2006
    Messages:
    120
    Location:
    USA
    Country:
    United States
    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

    Newcomer anoNL Member

    Joined:
    Sep 27, 2008
    Messages:
    32
    Country:
    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

    Member pka4916 GBAtemp Regular

    Joined:
    May 24, 2006
    Messages:
    120
    Location:
    USA
    Country:
    United States
    after reading the wiki, i am more confused now.
     
  6. hankchill

    Member hankchill I Pwn n00bs.

    Joined:
    Nov 5, 2005
    Messages:
    2,344
    Location:
    Outer Space
    Country:
    Canada
    Maybe should start with something a little more simpler? [​IMG]
     
  7. pka4916
    OP

    Member pka4916 GBAtemp Regular

    Joined:
    May 24, 2006
    Messages:
    120
    Location:
    USA
    Country:
    United States
    Nah.
    I will figure it out.. got eveything else figured out, except those 2 hickups.
    [​IMG]
     
  8. sypherce

    Newcomer sypherce Member

    Joined:
    Dec 4, 2008
    Messages:
    14
    Location:
    USA, New York
    Country:
    United States
    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.
     

Share This Page