P2 RAM not cleared on new program load?
potatohead
Posts: 10,261
I just noticed this.
For some reason, I was thinking the P2 would initialize it's RAM when accepting a new program. That doesn't appear to be happening. If this is documented, I missed it clearly.
Right now, I have the texture sample modified to take values from the HUB, and I'm using an instance of the monitor to modify those for some quick, interactive testing. The values are at $2000, which is my typical place to drop them right now. On program load, they are defined in the COG memory as normal, but on the first frame the reads from the HUB insure they never get used.
When I F10 from Pnut.exe while P2 is running, those values persist. When there is a break in the power, they come up zeroes. I just spent some time trying to figure out why something wasn't working, when it was actually working!
For some reason, I was thinking the P2 would initialize it's RAM when accepting a new program. That doesn't appear to be happening. If this is documented, I missed it clearly.
Right now, I have the texture sample modified to take values from the HUB, and I'm using an instance of the monitor to modify those for some quick, interactive testing. The values are at $2000, which is my typical place to drop them right now. On program load, they are defined in the COG memory as normal, but on the first frame the reads from the HUB insure they never get used.
When I F10 from Pnut.exe while P2 is running, those values persist. When there is a break in the power, they come up zeroes. I just spent some time trying to figure out why something wasn't working, when it was actually working!
'Fetch new texture values from HUB setindb #pixu_ reps #6, #1 setptra base 'which is $2000 rdlong INDB++, PTRA++
Comments
I have to think the real chip wouldn't be like this though.
Seems like that would be a security problem...
Normally I would not expect RAM in my machines to be cleared on reset/reload and I would expect RAM to be full of junk at power up.
Seems the Prop I does clear RAM on reset, I have never checked, so the question is who is clearing the RAM?
My bet is is that it's not done by hardware but by the loader or the Spin interpreter when it starts up.
Given that the Prop II has no Spin interpreter on board it would be down to the loader.
For fast boot speed one would not want to be clearing RAM so perhaps Chip left it out on purpose.
Uh oh, the P2 can't tell right from wrong...
C.W.
I'll have to put a couple of big pictures in there to see if it's true for the whole RAM area. I suspect it is.
As for the real chip, that's my question too.
Here is what it does, in order:
- If the loader authenticated, run it.
- If authentication failed, hide the fuses and clear the memory.
- If the key is not 0, shut down (with memory cleared); else, run the monitor.
I guess means that the emulator is behaving the same way as the real silicon will...
So the cool thing is we can now have big data in upper RAM and only upload program code deltas! Short cycles. And if we want to "hot swap" a cog or some data, do it via monitor. Honestly, this all has a very Apple 2 kind of feel to it. It was common to BLOAD various bits and pieces to work with, writing out a finished product or data set when work is done. Nice to know we have those options now.
I have not yet looked at the external RAM... Is it likely to work in a similar way, or would the need to refresh get in the way?