Language…
12 users online:  Anorakun, bradcomp, DanMario24YT, DasFueller, DimeR, GRIMMKIN,  idol, Metal-Yoshi94,  Shoujo, signature_steve, SMW Magic, steelsburg - Guests: 308 - Bots: 432
Users: 64,795 (2,373 active)
Latest user: mathew

Saving ram changes

Link Thread Closed
What is the difference between a ROM and RAM address, and if I want'ed to find a RAM address (I have translhextion) how would I do that? i notice in the ROM map it gives you first the hex number you can jump to in translhextion then an SNES address... whats the difference?
Then the RAM map only gives an address... is it an SNES address?

Main question that I need solved is: How do I find a RAM address I can use for some ASM thing.
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Quick, dirty, not so accurate explanation...

A ROM address points to part of the game's code. It exists in the cart and is what you see when you open the game with a hex editor.

A RAM address is the game's memory. These can be any number and the game uses them to store variable data. Game genies and game sharks mess with these.


You can't change a ram address with a hex editor (Well, not directly anyway). You have to change them with ASM. The simplest way to do this is:

Code
LDA #$00 ; number. in this case 0
STA $00 ; ram address. in this case $00


This is ASM code that can exist in the game. You can find things like these with a hex editor, though they're in opcode format (number representations). By placing this in the game, and making it somehow run it (through a block or sprite or whatever), you can change ram addresses.
Quote
i notice in the ROM map it gives you first the hex number you can jump to in translhextion then an SNES address... whats the difference?


PC address: where you find it in a hex editor
SNES address: where the processor in the SNES actually sees it. If you made a asm hack that looked up a particular byte in ROM, you use a SNES address.
Lemme refine this a bit. That sort of helps understanding though.

I'm using the Parallel worlds patch and the asm file says if [ram address that I forgot] is set to 01 (it's normally 00) then you can time travel.

I made a custom block which loads 01 into A and stores A into that ram address. I tested it ingame and it worked, when hit it enabled time travel (also it was my second custom block, the first one put a goal sphere in your item box). I then made when which loads 00 and disables the time travel thing, and it worked too.

After finding that out, I asked if I could add a code to any xkas patch (most likely with some kind of powerup thing) so that I could do a similar thing like I did for parallel worlds.

I found out that I can, all I need is too know how I can find RAM addresses that I can change without problem.

This is what Iceyoshi told me
LDA ram address
CMP # number from 00 to ff
BNE Return
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
If you're looking for just any arbitrary RAM address, you can look in SMW Central's RAM map. It includes empty, or free, RAM addresses, which are ones that are not used at all by the original game and can be used for custom codes. $0660-067F is one example; this is a 32-byte chunk of RAM that is untouched by the original SMW except when it clears on game reset. (I would recommend using anything before about $0668 or so, though, since there are patches and other stuff that use them.)

Now, as for changing a RAM address...well, LDA $address CMP #$value BNE Return isn't exactly changing an address, just using it to determine what to do next. The code "LDA $19 CMP #$01 BNE Return", for example, would load the address used for the player's current powerup, check to see if the player is big ("Super Mario"), and skip to "Return" if the player is anything other than big. If you wanted to change the player's powerup, though, you'd usually use STA. If you wanted to make the player big, for example, one way to do it would be LDA #$01 STA $19. (Don't forget the RTS or RTL at the end.)

I hope this helped...if you have any questions, just ask.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Thanks.

Btw for the second part I actually already knew all that, as I showed in my example with the parallel worlds.

Could I if I wanted just run the rom through slogger then find the snes address? Or is that something different.

Also I you say the ram changes reset on game reset... how would I get that to save instead of reseting?
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Quote

Could I if I wanted just run the rom through slogger then find the snes address? Or is that something different.


That is no help if you want to find a RAM address, only ROM address.

Quote
how would I get that to save instead of reseting?


If you want to save values in RAM between resets or power off then you use the battery backed RAM on the cartridge. I think the address to expand it is in 81D8 with a headered ROM, increase it by 01. The .srm file your emulator makes should be larger now. In your hack you access your regular RAM through 7E0000-7FFFFF like the RAM map shows. For saving data you write it to 700000-701FFF for example if your new .srm was 8kb. Do not bother with anything within 700000-7007FF since that's original SMW's save data, while there are free bytes in there you really don't have a reason not to expand SRAM and just forget about it altogether.
To make things sound a bit simpler,

First open up ROM in a hex editor, and change the byte at [x81D8] to any value from 2-5 (I would prefer 3 or 4, not too much) to expand your SRAM size. By default, it's 01 with I think is only 2kb of SRAM. You might want more than that.

Then you just write anything to save to SRAM, which starts from $700800. For example,

LDA $0DBF
STA $700800 ; Store coin counter to SRAM.

On the game load routine, you can then load from that SRAM Address and store it into $0DBF. This is commonly done in patches that have a save game routine.
That helps quite a bit.
Although, question - I've heard that since you can have three different save game files, you would need to do that three times for the seperate save files possible or something? Do I just do that code 3 times with different RAM addresses?

Also what you told me (IceYoshi) with patches to make it unlock later in game...
For unlockable thing
At the beginning of your patch, or before the main code, you add in a check:
LDA !Ram
CMP #!Value
BNE Return
~Powerup code.

And

Then you just write anything to save to SRAM, which starts from $700800. For example,

LDA $0DBF
STA $700800 ; Store coin counter to SRAM.

So at the beginning of a patch that I want to cause to be unlockable later in the game by hitting a custom block that loads something like 01 into A and stores it... would I put something like this into beginning of the patch...

LDA $not sure what I'd put here to make the game save whatever patch does
STA $700800 ; or !Ram

LDA $700800 ; or !Ram
CMP #01 : This should mean that if 01 is loaded into !Ram then patch powerup shall work. If it is anything else the patch will do nothing. Is that correct?
BNE Return
~Powerup code.

Would you recommend the saving to RAM part to be at the end of the patches code, and the thing that enables or disables it at the start?

Would I have it stand alone with an RTL at the end? (For saving RAM)
__________
Also...
LoRom and HiRom, anything to worry about? Has a HiRom hack ever been made? What is the difference, besides size. (I learned from Lunar Expand that apparently the normal size of 500 kb to 8000 kb is LoRom and any higher is HiRom... what does this mean?

________-
Sorry I feel liking I was being lazy while typing this.

edit:
Also I found in the parallel worlds patch where it lets you enable or disable the ability, and it's the same thing you said IceYoshi, so I'll assume it'll work for me for the other spots I'd use it in other patches.... but now I just need to know how to make the RAM address save, and I'm currently testing it out now.

edit 2: Trying to save the effect didn't seem to work this time after what you said. Trying again.

Other thought... Would I want to make it so my custom block saves the change to RAM? So that it'd save the change from 00 to 01, probably like this...

JMP's here

MarioCode:
LDA #$01
STA $06F0 ; RAM address that requires 00 for disable power and 01 for enabled power
LDA #$06F0
STA $!Ram
Return:
RTL

Man I think this is getting a bit advanced now. And this post is getting long.
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG

If you want to make it individual for each file, you need to index !Ram with $010A. File A would be 00, B would be 01 and C would be 02.

There's a problem with your block, try this:

JMPs here

Mario:
LDA #$01
STA $06F0
STA !Ram

I don't know what you currently have !Ram as, but it should be:

!Ram = $700800

(Make sure your ROM is expanded). Also, whats $06F0 for?

"Would you recommend the saving to RAM part to be at the end of the patches code, and the thing that enables or disables it at the start?"

What do you mean here? You already have a block (the one above) that sets the flag to 01. You just add a check at the beginning of the code like I said before.

Also, in what way does it not work? Please can you tell me your issue. My guess is that SRAM is initially non-zero, so it might not work unless you initialise it to 00.

Oh I mean the expanding the save files to 8 kb worked, I meant when I tried putting a command to save effects to SRAM directly in to the xkas patch it didn't work, and I realize why now.

Also, whats $06F0 for?

;the following are ram adresses

!ACTIVATE = $06F0 ;set to 1 to activate time travel

This is the code in the parallel worlds patch that uhh defines the RAM address that needs to be set to 1 to enable the power, and anything else for it to be disabled.

I'm trying to figure this all out for both making wether or not parallel world traveling is enabled or disabled to save, and for having certain powerups be saved after unlocked (Such as I'll probably use ground pound and I want to make it something that once unlocked, you have it forever.)

Also... so this

Mario:
LDA #$01
STA $06F0
STA !Ram

Will store 01 in to 06F0 which is the ram address that defines wether or not time travel is enabled, then stores whatever 06F0 is to a ram address that will be saved even on reset?
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Yeah, that right i think, but remember the JMP's at the start and the RTL at the end.
To disable Time travel, I think it would be:

Code
JMP Mario : JMP Mario : JMP Mario : JMP Mario : JMP Mario : JMP Mario : JMP Return

Mario:
LDA #$00
STA $06F0
STA !Ram
Return:
RTL
Background image by Tzadkiel & Anomalin
Originally posted by x-treme
JMP Mario : JMP Mario : JMP Mario : JMP Mario : JMP Mario : JMP Mario : JMP Return

Only the first three are Mario offsets. The rest are sprites, capes, and fireballs.

Quote
STA !Ram

Where is this defined?
<blm> zsnes users are the flatearthers of emulation
Eww those green boxes... are we supposed to use those code boxes?

LDA #$00
STA $06F0
STA !Ram
Return:
RTL

I believe this (with the JMPS)
Would store 00 into the ram address for whether or not time travel is enabled or disabled (Which is the 06F0)
Then store that too !ram which would be a ram number I choose, and thus the effect will be saved even if I reset the game? I'll have to try this!
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Thanks to this discussion I have finally succeeded in inserting powerdown... I didn't succeed because I had made a patch ips... and it jammed... but after hex... has worked Thanks!
Eh, please don't reply to old threads without contributing something important to it. I'm glad you got the patch to work, but bumping this thread just to say thanks isn't really what you should do.

I guess I'm going to have to close this thread.


 
Link Thread Closed