+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  ASM problems (Silva Saga, NES, 6502)
Pages: [1]
Author Topic: ASM problems (Silva Saga, NES, 6502)  (Read 2 times)
aishsha
Guest
« on: May 17, 2008, 07:55:23 pm »

OK, this is the first time I actually tried to get this thing working in Silva Saga and got stuck pretty early. So don't be too harsh on an ASM newb Smiley
I used KingMike's document for reference and there it goes.
I defined the line for the first [end] marker (well, the second one but that does not matter, I guess). Here it's 18AED. Minus the header and we have a pointer 18ADD.
Silva Saga has 16KB banks , so our bank starts at 18000. Well, we'll look for a value DD8A or DDCA in the memory. Here (according to the memory viewer) it's DD8A and it takes 0096 and 0097 within the RAM.
I disassembled the ROM and found several of (LDA ($96): B196) but only three of them actually froze the game so I took the most appropriate for the first try. Its ROM address is 3F6C3:
Code:
07/F6B3: B1 96        LDA ($96),Y
After some calculations I found a big empty chunk (at least it looks like that in the RAM and in ROM it's just lots FF) so I took the address 39D90 for making a JSR to.
So I replace the original code in my string:
Code:
A000B196

with a 4-byte code like this:

Code:
20809DEA
And replace the empty space at 39D90 for A000B196, of course. And then the game just crashes... Period.
I spent a pair of days for finding a mistake and checked 2 other B196 locations with about the same result. I also played with the number to exclude any possibility of a nonstandard pointer ('cause SS really uses pointers sometimes embedded into the text) but nothing changed.
Can anybody tell me what I've actually done wrong?
Sliver X
Guest
« Reply #1 on: May 17, 2008, 11:16:01 pm »

First problem: Subtract $39D90 from $3F6C3: #$5933. These locations are not in the same bank (Since they're #$4000 bytes), so you can't use that padding from here without doing some bankswitching.

Even if you could:

Quote
And replace the empty space at 39D90 for A000B196, of course. And then the game just crashes... Period.

You're missing a #$60 (RTS). Once A000B196 is run it would try to execute the following #$FFs, which will crash the CPU. Always remember to exit your subroutines.
« Last Edit: May 18, 2008, 01:22:29 am by Sliver X »
aishsha
Guest
« Reply #2 on: May 18, 2008, 02:41:07 pm »

Thanks - I'll try to figure out Smiley Still can't get why the RAM showed me the wrong bank - does it show all empty space available inside the ROM?
Update: Yeah, I checked the space again and found some empty strings nearby. They do load the text and run the routine but they are too small to fit the final code and DTE dic. Pity. 'cause I won't be able to swap banks on my current level  Sad
« Last Edit: May 18, 2008, 04:36:14 pm by aishsha »
KingMike
Guest
« Reply #3 on: May 18, 2008, 05:21:01 pm »

$0000-07FF = System RAM
$6000-7FFF = Cartridge RAM (usually, a few mappers use these addresses to access the mapper, so they can't have cart RAM. And a pirate mapper or two use this for ROM.)
A handful of the remaining address are used for I/O, the rest are undefined.
$8000-FFFF = ROM. For most mappers, this space is split into several banks, usually $C000-FFFF is permanently set to the last 16KB of PRG (program) ROM, leaving $8000-BFFF swappable.
And it is instantly swappable.
aishsha
Guest
« Reply #4 on: May 18, 2008, 05:44:12 pm »

Ah, ok, think I got that, thanks Smiley
ded302
Guest
« Reply #5 on: May 18, 2008, 11:36:59 pm »

This document explains mmc3 bankswapping.
http://www.tripoint.org/kevtris/mappers/mmc3/index.html
And also look at Dischs mapper docs.
aishsha
Guest
« Reply #6 on: May 20, 2008, 01:45:31 am »

Well, seems like I found a way to live without DTE in this case (rom seems to have enough of empty space to fit almost everything I need and pointer hacking works ok Smiley).
I got another question: Is there any way to tackle with sequential text without some serious ASM work? The thing is that here the whole list of weapon/monsters/items/names/etc is given in a sequential manner and the space is pretty limited. I would not really like to shorten a lot...
KingMike
Guest
« Reply #7 on: May 20, 2008, 08:31:25 am »

Sequential? Like the game counts end-of-string markers to find the string it wants? No, that probably would require ASM hacking if you wanted to seperate it.
I don't think it'd be too hard, but it would require ASM skill.
You'd have to find the routine that counts strings, and rewrite it to instead take the string number, and load the pointer from a table.
Though it might be harder if several different lists are using the routine.
aishsha
Guest
« Reply #8 on: May 20, 2008, 02:15:07 pm »

Quote
Sequential? Like the game counts end-of-string markers to find the string it wants? No, that probably would require ASM hacking if you wanted to seperate it.
Yeah, like that. And the item seems to be called into the game by a specific code. Well, then I'll leave it for the latter part...
HyperHacker
Guest
« Reply #9 on: May 21, 2008, 03:50:35 am »

Do you need to separate it? You can just add characters to the strings, as long as you delete from other strings (or empty space immediately following the array, if there is any).
aishsha
Guest
« Reply #10 on: May 21, 2008, 04:31:51 am »

I know that, but the code seems to divide the whole list into several parts (items-names-monsters) and apart from that I cannot shorten a lot in this case - eg. the monster list includes a lot of creatures from Indian mythology which, as you may guess, will lose the part of their charm after having being shortened... But as I said before - I'll try to think of something.
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC