News: 11 March 2016 - Forum Rules

Author Topic: Writing Data to ARAM?  (Read 2360 times)

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Writing Data to ARAM?
« on: May 18, 2015, 06:41:42 pm »
How would one go about this?  I've read that 2140-2143 are key factors here along with $F4-F7 in ARAM being where the values are stored to essentially.

How exactly does this work?  From what I saw stepping through, the value in ROM that's needed gets sent into that area in ARAM but then in ARAM it somehow gets shuffled to the proper location.  Though, how exactly does it get stored to $F4-F7 in ARAM and is it game-specific that it sends data to another area or is there a way about doing this?

I'm really unsure how to properly convey what I mean, this whole aspect confuses the heck out of me.
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Writing Data to ARAM?
« Reply #1 on: May 18, 2015, 07:14:35 pm »
I'm assuming you mean the SNES?  (You never actually specified  ;P)

Both the code in the SPC and the code on the CPU have to be working together.  Values written to 2140-3 on the CPU side are visible at $F4-7 on the SPC side and vice versa.  A typical communication process is:

1)  CPU sets some value to indicate it wants to start loading
2)  CPU waits for SPC to respond
3)  SPC notices value, and responds to CPU telling it it's ready to load
4)  CPU writes target address and value to regs, then sets a flag tell the SPC that it's done supplying data
5)  SPC waits for said flag, then takes the value/address and writes the byte appropriately.
6)  SPC writes a value indicating the copy is done and it's ready for the next byte
7)  CPU waits for that "done" notification, then repeats from step 4



Exactly how this communication is done depends on what code is running on the SPC side.

At startup/reset, when no code has been loaded to the SPC yet... the SPC has a sort of BIOS (or "IPL BOOT ROM") that can be swapped in which does this loading.  This ROM and how to communicate with it to copy data is explained  pretty well in Anomie's SPC docs on this site:

Quote
To properly manipulate this into uploading your data, the following procedure
seems to work:
 1. Wait for a 16-bit read on $2140-1 to return $BBAA.
 2. Write the target address to $2142-3.
 3. Write non-zero to $2141.
 4. Write $CC to $2140.
 5. Wait until reading $2140 returns $CC.
 6. Set your first byte to $2141.
 7. Set your byte index ($00 for the first byte) to $2140.
 8. Wait for $2140 to echo your byte index.
 9. Go back to step 6 with your next byte and ++index until you're done.
10. If you want to write another block, write the next address to $2142-3,
    non-zero to $2141, and index+2 (or +3 if that would be zero, otherwise
    it'll screw up the next transfer) to $2140 and wait for the echo. Then go
    to step 6 with index=0.
11. Otherwise, you can jump to some code you've just uploaded. Put the target
    address in $2142-3, $00 in $2141, and index+2 in $2140 and wait for the
    echo. Shortly afterwards, your code will be executing.

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Re: Writing Data to ARAM?
« Reply #2 on: May 18, 2015, 08:14:42 pm »
Woops, yep, I meant the SNES!

So THAT'S what all that is!  I noticed the game I'm working on does EXACTLY all of that before hand but I could not for the life of me figure out how exactly it was storing the data into a specific address.  I'm working on the Sailor Moon Fuwa Fuwa Panic game and it does everything that you just said.  The voice data gets sent to B700 but I NEVER saw anything that remotely even stated that which threw me off track and STILL does in all honesty.

But now I know that this is all doing that, I know what I want to do is possible, albeit a bit annoying.  Thank you so much!

Edit: Actually, this game is writing the data it wants to transfer into 2141/2142/2143, not the target address.  Is that normal?  It seems when it's transferring a voice, 2140 is constantly '03'.  So the target address isn't actually anywhere that I can see.
« Last Edit: May 18, 2015, 08:22:43 pm by justin3009 »
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Writing Data to ARAM?
« Reply #3 on: May 18, 2015, 08:30:36 pm »
Quote
Actually, this game is writing the data it wants to transfer into 2141/2142/2143, not the target address.  Is that normal?

*shrugs*

Maybe the target address is assumed to be something.  Maybe there are only a few places it will allow you to write to, and the '03' is like an ID telling it which place to write to.

But it's all a guess.  The SPC code could be doing anything.  You'll have to look at what it's doing to figure out how to use it.

justin3009

  • Hero Member
  • *****
  • Posts: 1664
  • Welp
    • View Profile
Re: Writing Data to ARAM?
« Reply #4 on: May 18, 2015, 08:53:58 pm »
Ahh so then it can be a per-game basis then.  That's what I was curious about.  Alrighty!  Thank you again!
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'