It is currently Sun Oct 22, 2017 9:38 pm

All times are UTC - 7 hours

Forum rules


Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Need help with SPC2ROM
PostPosted: Thu Oct 24, 2013 12:43 pm 
User avatar

Joined: Sat Jun 27, 2009 11:05 pm
Posts: 712
Location: New Mexico, USA
SPC2ROM Source:

I am using SPC2ROM to test various SPC700 instructions on my SNES console. However, I've run into an issue when trying to test the BRK/TCALL instructions. In my SPC700 source file I am defining some vector addresses for the various BRK/TCALL vectors from $FFC0-$FFDF. However, when I run spc2rom on my .spc file and I look at the resulting .sfc my vectors are nowhere to be found. In fact, anything at all that I put in the region from $FFC0-$FFFF is replaced with all-zeros in the final .sfc rom file that is generated.

Being that the region in question is the IPL ROM area I did some investigation into the SPC2ROM source code and here is what I found...

In the file SPC2ROM.cpp a structure is defined called APURAM which is exactly 64Kbytes in size:
struct APURAM
   u8   dp0[0xF0];                        //Direct Page 0
   u8   testReg;                        //Test register (no use)
   u8   control;                        //Control register
   u8   dspAddr;                        //DSP Address
   u8   dspData;                        //DSP Data
   u8   port0;                           //In port 0
   u8   port1;                           //In port 1
   u8   port2;                           //In port 2
   u8   port3;                           //In port 3
   u8   unused1;                        //unused
   u8   unused2;                        //unused
   u8   t0;                              //Timer 0
   u8   t1;                              //Timer 1
   u8   t2;                              //Timer 2
   u8   c0;                              //Counter 0
   u8   c1;                              //Counter 1
   u8   c2;                              //Counter 2

   u8   dp1[0x100];                        //Direct Page 1 (Stack)

   u8   gp[0xFD00];                        //General Pages 2-254

   u8   up[0x0C0];                        //Uppermost Page 255
   u8   ipl[0x40];                        //Program used to transfer memory

An instance of APU RAM is created:
APURAM   ram;

The APURAM instance is filled with the contents of my .spc file that I specified on the command line (called 'fh'):
//Read various components ------------------
   fread(&ram,0x10000,1,fh); -- line A
   fseek(fh,0x40,SEEK_CUR); -- line B
   fread(&ram.ipl,0x40,1,fh); -- line C

On line A the contents of the 64K of SPC ram are placed into the APURAM struct. This is good. At this point. All of my vectors from $FFC0-$FFDF still exist (I know because I inserted debug statements to check).

However, on lines B and C we find the problem. On line A the .spc file pointer skips over the 64 bytes of "unused" space and is placed at the "Extra RAM" region of the SPC file header. You can see the "unused" and "Extra RAM" regions in the SPC file format here:

After line C is executed my BRK/TCALL vectors from $FFC0-$FFDF have been filled with all zeros (since that is the contents of my SPC file header in the "Extra RAM" region). If I comment out line C and re-run SPC2ROM all of my BRK/TCALL vectors are exactly where they should be. Additionally, when I run the new ROM on an emulator or on my real console it works perfectly and all of the BRK/TCALL vectors work just like they should.

So now that I understand how SPC2ROM is wiping out all of my BRK/TCALL vectors, my question is why is it doing this? And why does the SPC file format specify this 64-byte "Extra RAM" region that overwrites the region from $FFC0-$FFFF? Shouldn't it just fill that region with the contents of the 64Kbytes of ram in my .spc file like it does with the data in every other page of ram?

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 6 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group