+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  Unirally/Uniracers level viewer
Pages: [1] 2
Author Topic: Unirally/Uniracers level viewer  (Read 2 times)
Spinal
Guest
« on: August 11, 2008, 10:08:26 am »

Hi everyone,
for a while now I've been working on a Unirally/Uniracers level viewer.
So far I've managed to find the palette and convert it from 6-bit to 8-bit, and I've found the 8x8 sprites and manage to show them.

However, that's where I'm stuck. I assume the 8x8 tiles are "merged" to form 16x16 sprites, which are then somehow used as tiles for the levels.
There are 1156 8x8 sprites, which in hex is 0x484, and there is a maximum of 0x500 (1280) sprites.
So, if you assume a 16x16 tile consists of 4 8x8 sprites, you would somehow need to store which sprites form a tile. If you have 1280 sprites, you will need a minimum of 10 bits for each sprite. 4x10 bits = 40 bits, which is 5 bytes. Or, if you assume 12 bits, it would be 6 bytes.

Now there is a whole bunch of 8-byte sequences in the rom (address 0x108000), that look like this:
0F 04 1E 04 17 1E 00 00
10 04 1F 04 16 1E 00 00
...
15 07 23 06 10 1C 00 00

If you've ever played Unirally/Uniracers, you will know many of the tiles exist in various colors, but this is not represented in the tile data. So, again I assume there is a byte that controls what part of the palette a tile should use. Hm, maybe 2 and then you could think that these 8-byte sequences are the 16x16 tiles with color data in it.
However, I've tried changing many of these values and nothing seems to be changing anything. Without knowing where the 16x16 tiles are, it's pretty damn hard to find the level data.

So, I turn to you for help. Are there any tools or techniques that might help me in my search for the tile data and/or level data?
Nightcrawler
Guest
« Reply #1 on: August 11, 2008, 05:04:52 pm »

Well, I'd advise you start with VSNES and examine a savestate so you can start finding things out for sure instead of assuming anything. Wink Another thing is the term 'sprite', when talking about the SNES platform, typically refers to tile data used for OAM objects which are handled very differently from those used as the typical background data. You'll want to differentiate between the two when speaking about them and what you're looking for.

With that said, I'm assuming you are looking for background tile data. The palette used by each tile is stored in 3 bits of it's 2 byte attribute or 'tile map' table table which may or may not be the hex data you've given us.

I refer you to Anomie's Register Doc. Read the section entitled 'Tile Maps and Character Maps' to understand what I mean.

In VSNES, you'll also be able to tell if a background is using 16x16 tiles or is really just using 8x8 tiles. You'll also be able to tell where the map is and where the tile data is stored. You can then use a debugger to trace back how that data got into VRAM and ultimately find where it is coming from in the ROM.

You've bitten off a fairly large task for being new to this material, so if you want to be successful, you'll need to break this down to clear, small, objectives that we can better help you with.
Spinal
Guest
« Reply #2 on: August 12, 2008, 02:54:59 am »

Sprites/Tiles, whatever you name them, I meant "8x8 bitmap" for sprites, and "stuff the level is made up of" for tiles. Sorry if that was confusing.
I messed around a bit with vSNES, and I can confirm that the "real" background (the layer behind the actual level) is 8x8 tiles, but the level uses 16x16 tiles.

Quote
With that said, I'm assuming you are looking for background tile data.
If by "background" you also mean the level layer, then yes. But like I said: I already found where the 8x8 tiles are stored, but not how these correlate to the 16x16 tiles, and how the 16x16 tiles correlate to the actual level layout.

Quote
You'll also be able to tell where the map is and where the tile data is stored. You can then use a debugger to trace back how that data got into VRAM and ultimately find where it is coming from in the ROM.
Right... that's indeed a bit much for someone who has never done any ROM editing. Where can I find that? In the SceneViewer under "hdma", "CHN 2" I see:
source: 7E:2080, dest: 2107h, comment: "BG1 tilemap: address (D6..D2) [...]" (BG1 is the level layout)
but what does that tell me? The source value looks like something I can feed hex2snes, and it gives me back a hex address, but is that an offset in the rom or something else?

Quote
You've bitten off a fairly large task for being new to this material, so if you want to be successful, you'll need to break this down to clear, small, objectives that we can better help you with.
True, but with a little help of the experts I'm sure I'll be able to pull it off eventually Smiley I may be a newbie, but I'm not a noob Wink
To break it into smaller objectives:
1) Find out how the 16x16 tiles correlate to the 8x8 tiles and the palette
2) Find out how the levels are stored
3) Create the level viewer and possible a level editor (#3 should be easy once I've got the info needed)

Thanks for your help so far, and I'll read the register doc right away.

-edit-
Wow, thanks for that document. It really helped me clear up some things: "Each entry in the tilemap is 2 bytes, formatted as (high low): vhopppcc cccccccc". So indeed 10 bits per tile.
And: "If the appropriate bit of $2105 is set, each "tile" of the tilemap actually corresponds to a 16x16 pixel block consisting of Tile, Tile+1, Tile+16, and Tile+17". So it seems there is no 8x8 to 16x16 conversion, the 16x16 tiles are fixed.
One strange thing though, the document says "The tilemap address is selected by bits 2-7 of registers $2107-a, and the tilemap size is selected by bits 0-1 of that same register". But vSNES shows a 7-bit value for $2107, and its value doesn't match what the document says.
I'll read into it a bit more, but it certainly is helpful!

-edit2-
Ah, I just read somewhere that "Note that, since there is only 64K of VRAM, the most significant bit must be zero". I guess that's why vSNES only displays 7 bits.
« Last Edit: August 12, 2008, 10:09:22 am by Spinal »
Nightcrawler
Guest
« Reply #3 on: August 12, 2008, 10:26:56 am »

Quote from: Spinal on August 12, 2008, 02:54:59 am
Sprites/Tiles, whatever you name them, I meant "8x8 bitmap" for sprites, and "stuff the level is made up of" for tiles. Sorry if that was confusing.
I messed around a bit with vSNES, and I can confirm that the "real" background (the layer behind the actual level) is 8x8 tiles, but the level uses 16x16 tiles.

Quote
With that said, I'm assuming you are looking for background tile data.
If by "background" you also mean the level layer, then yes. But like I said: I already found where the 8x8 tiles are stored, but not how these correlate to the 16x16 tiles, and how the 16x16 tiles correlate to the actual level layout.

Don't think of it in terms of the game, think of it in terms of the hardware. By 'background', I mean just that, one of the four SNES backgrounds. Use ZSNES and press '1','2', '3', and '4'. The BACKGROUND layers will disappear.  If you press '5', the SPRITE layer will disappear.

It's important you determine what it is you're looking for. As I said, they're handled very differently and I can't help you if you can't tell me correctly what it is you are looking for. So, use your emulator and determine if it's background data and if so, which background? (1,2,3, or 4).

Quote
Quote
You'll also be able to tell where the map is and where the tile data is stored. You can then use a debugger to trace back how that data got into VRAM and ultimately find where it is coming from in the ROM.
Right... that's indeed a bit much for someone who has never done any ROM editing. Where can I find that? In the SceneViewer under "hdma", "CHN 2" I see:
source: 7E:2080, dest: 2107h, comment: "BG1 tilemap: address (D6..D2) [...]" (BG1 is the level layout)
but what does that tell me? The source value looks like something I can feed hex2snes, and it gives me back a hex address, but is that an offset in the rom or something else?

In SceneViewer, look at the 'layers' tab and the 'info' tab. That will show you everything you need to know about the backgrounds. Each background will have a tilesize, tilemap location, and a tiledata location. Those 16-bit locations are in VRAM. VRAM only exists in the savestate right now, but we can use the information to find it in the ROM.

So, find the background your data is on (1,2,3, or 4). Then open the 'hex editor' icon at the top. Choose 'VRAM' and now you can go to the address your 'tilemap' is at. You can fiddle with the values to start to understand how they work. You'll see the results in the scene viewer.

VSNES is a great learning tool. You can change VRAM contents and hardware registers and observe the effects immediately (for many hardware features anyway).

You should be able to edit the tilemap in VRAM and see what happens to the tiles. You can get them to use different palettes this way and understand how that works.

Quote
Quote
You've bitten off a fairly large task for being new to this material, so if you want to be successful, you'll need to break this down to clear, small, objectives that we can better help you with.
True, but with a little help of the experts I'm sure I'll be able to pull it off eventually Smiley I may be a newbie, but I'm not a noob Wink
To break it into smaller objectives:
1) Find out how the 16x16 tiles correlate to the 8x8 tiles and the palette
2) Find out how the levels are stored
3) Create the level viewer and possible a level editor (#3 should be easy once I've got the info needed)

Thanks for your help so far, and I'll read the register doc right away.

-edit-
Wow, thanks for that document. It really helped me clear up some things: "Each entry in the tilemap is 2 bytes, formatted as (high low): vhopppcc cccccccc". So indeed 10 bits per tile.
And: "If the appropriate bit of $2105 is set, each "tile" of the tilemap actually corresponds to a 16x16 pixel block consisting of Tile, Tile+1, Tile+16, and Tile+17". So it seems there is no 8x8 to 16x16 conversion, the 16x16 tiles are fixed.
One strange thing though, the document says "The tilemap address is selected by bits 2-7 of registers $2107-a, and the tilemap size is selected by bits 0-1 of that same register". But vSNES shows a 7-bit value for $2107, and its value doesn't match what the document says.
I'll read into it a bit more, but it certainly was helpful!

They're both right. The most significant bit is not used because it would go out of range for VRAM.

VRAM effective addresses range from 0-0xFFFF
However, the SNES use two chips, therefore when you set the actual address you can only set between 0-0x7FFF.

So, when you set actual VRAM address to 0x000, $2118 goes to 0x0000 and $2119 goes to effective location 0x0001. When you set the actual VRAM address to 0x0001, writing to port $2118 it goes to effective location 0x0002 and $2119 goes to effective location 0x0003.
When you set the actual VRAM address to 0x7FFF, writing to port $2118 it goes to effective location 0xFFFE and $2119 goes to effective location 0xFFFF.

So....

Example:

Tilemap should be at effective VRAM location of 0xF800.

So, the actual VRAM address is 0x7C00.

Now shift by 10... and you get 0001 1111. So you take those 6-bits and use them as the upper 6 bits in $2107.

So, the byte that should be at $2107 is 0x7C.


SO... the reason 7-bits are used in VSNES is because the 8th bit is ignored because it can never used because VRAM can only be addressed from 0-0x7ffff.

Just change the value in VSNES and observe the tilemap address results in the Scene Viewer. You'll get how it works.
creaothceann
Guest
« Reply #4 on: August 12, 2008, 10:40:17 am »

EDIT: NC replied while I was typing.


Quote from: Spinal on August 12, 2008, 02:54:59 am
Quote
With that said, I'm assuming you are looking for background tile data.

If by "background" you also mean the level layer, then yes. But like I said: I already found where the 8x8 tiles are stored, but not how these correlate to the 16x16 tiles, and how the 16x16 tiles correlate to the actual level layout.

Open the Memory Viewer and the Scene Viewer, and move the mouse over a background. You should see how the tiles are stored in VRAM: in a 16-tile wide grid. The PPU chips assume that layout when they load the graphics.


Quote from: Spinal on August 12, 2008, 02:54:59 am
Quote
You'll also be able to tell where the map is and where the tile data is stored. You can then use a debugger to trace back how that data got into VRAM and ultimately find where it is coming from in the ROM.

Right... that's indeed a bit much for someone who has never done any ROM editing. Where can I find that? In the SceneViewer under "hdma", "CHN 2" I see:
source: 7E:2080, dest: 2107h, comment: "BG1 tilemap: address (D6..D2) [...]" (BG1 is the level layout)
but what does that tell me? The source value looks like something I can feed hex2snes, and it gives me back a hex address, but is that an offset in the rom or something else?

Tilemaps are stored in VRAM.


Quote from: Spinal on August 12, 2008, 02:54:59 am
Quote
You've bitten off a fairly large task for being new to this material, so if you want to be successful, you'll need to break this down to clear, small, objectives that we can better help you with.

True, but with a little help of the experts I'm sure I'll be able to pull it off eventually Smiley I may be a newbie, but I'm not a noob Wink
To break it into smaller objectives:
1) Find out how the 16x16 tiles correlate to the 8x8 tiles and the palette
2) Find out how the levels are stored
3) Create the level viewer and possible a level editor (#3 should be easy once I've got the info needed)

Thanks for your help so far, and I'll read the register doc right away.

-edit-
Wow, thanks for that document. It really helped me clear up some things: "Each entry in the tilemap is 2 bytes, formatted as (high low): vhopppcc cccccccc". So indeed 10 bits per tile.
And: "If the appropriate bit of $2105 is set, each "tile" of the tilemap actually corresponds to a 16x16 pixel block consisting of Tile, Tile+1, Tile+16, and Tile+17". So it seems there is no 8x8 to 16x16 conversion, the 16x16 tiles are fixed.
One strange thing though, the document says "The tilemap address is selected by bits 2-7 of registers $2107-a, and the tilemap size is selected by bits 0-1 of that same register". But vSNES shows a 7-bit value for $2107, and its value doesn't match what the document says.
I'll read into it a bit more, but it certainly is helpful!

-edit2-
Ah, I just read somewhere that "Note that, since there is only 64K of VRAM, the most significant bit must be zero". I guess that's why vSNES only displays 7 bits.

Btw. VRAM addresses can be in "byte" format or in "word" (2 bytes) format. There are two RAM chips sharing the same access path, so reading/writing a byte accesses one chip first, and the next access goes to the other chip. See registers 2115..2119h for more info.

vSNES (and almost every emulator) treats VRAM as one big array, so it shows addresses in byte granularity.
Spinal
Guest
« Reply #5 on: August 12, 2008, 11:10:19 am »

Quote from: Nightcrawler on August 12, 2008, 10:26:56 am
Don't think of it in terms of the game, think of it in terms of the hardware. By 'background', I mean just that, one of the four SNES backgrounds. Use ZSNES and press '1','2', '3', and '4'. The BACKGROUND layers will disappear.  If you press '5', the SPRITE layer will disappear.
I got that, I just think it's confusing to talk about a background when it's (in the game) not a background. A layer sounds more logical to me Smiley From ZSNES/vSNES I see "background" 1 is the layer I need.

Quote
In SceneViewer, look at the 'layers' tab and the 'info' tab. That will show you everything you need to know about the backgrounds. Each background will have a tilesize, tilemap location, and a tiledata location. Those 16-bit locations are in VRAM. VRAM only exists in the savestate right now, but we can use the information to find it in the ROM.
Okay, so the "tilemap base" is an offset in the VRAM, got it.

Quote
So, find the background your data is on (1,2,3, or 4). Then open the 'hex editor' icon at the top. Choose 'VRAM' and now you can go to the address your 'tilemap' is at. You can fiddle with the values to start to understand how they work. You'll see the results in the scene viewer.
[...]
You should be able to edit the tilemap in VRAM and see what happens to the tiles. You can get them to use different palettes this way and understand how that works.
Oh wow, that's a cool feature Smiley


Quote
VRAM effective addresses range from 0-0xFFFF
However, the SNES use two chips, therefore when you set the actual address you can only set between 0-0x7FFF.

So, when you set actual VRAM address to 0x000, $2118 goes to 0x0000 and $2119 goes to effective location 0x0001. When you set the actual VRAM address to 0x0001, writing to port $2118 it goes to effective location 0x0002 and $2119 goes to effective location 0x0003.
When you set the actual VRAM address to 0x7FFF, writing to port $2118 it goes to effective location 0xFFFE and $2119 goes to effective location 0xFFFF.

So....

Example:

Tilemap should be at effective VRAM location of 0xF800.

So, the actual VRAM address is 0x7C00.

Now shift by 10... and you get 0001 1111. So you take those 6-bits and use them as the upper 6 bits in $2107.

So, the byte that should be at $2107 is 0x7C.


SO... the reason 7-bits are used in VSNES is because the 8th bit is ignored because it can never used because VRAM can only be addressed from 0-0x7ffff.

Just change the value in VSNES and observe the tilemap address results in the Scene Viewer. You'll get how it works.
Okay, I *think* I understand what you're saying here. However, I do not see how to get the ROM address from the VRAM address.
If I understand correctly, when the game is running it writes certain things to register 2117 and it ends up in the VRAM. So can I somehow track where in the rom that data is coming from?



Quote from: creaothceann
Open the Memory Viewer and the Scene Viewer, and move the mouse over a background. You should see how the tiles are stored in VRAM: in a 16-tile wide grid. The PPU chips assume that layout when they load the graphics.
Actually, it looks more like 4 times an 8x8 grid... this is very confusing, the game doesn't load all tiles but somehow makes a selection?
creaothceann
Guest
« Reply #6 on: August 12, 2008, 11:57:43 am »

Quote from: Spinal on August 12, 2008, 11:10:19 am
Quote
So, find the background your data is on (1,2,3, or 4). Then open the 'hex editor' icon at the top. Choose 'VRAM' and now you can go to the address your 'tilemap' is at. You can fiddle with the values to start to understand how they work. You'll see the results in the scene viewer.
[...]
You should be able to edit the tilemap in VRAM and see what happens to the tiles. You can get them to use different palettes this way and understand how that works.

Oh wow, that's a cool feature Smiley

Yeah, a bit slow though (at least on this PC).


Quote from: Spinal on August 12, 2008, 11:10:19 am
Quote from: creaothceann
Open the Memory Viewer and the Scene Viewer, and move the mouse over a background. You should see how the tiles are stored in VRAM: in a 16-tile wide grid. The PPU chips assume that layout when they load the graphics.

Actually, it looks more like 4 times an 8x8 grid... this is very confusing, the game doesn't load all tiles but somehow makes a selection?

Look at the "window size" groupbox, it says that the current viewing window is 16x32 tiles in size. You can also export the picture to an image processing program (e.g. Paintshop Pro) and let it display a grid.

Since the tiles of BG2 are not enlarged, the tilemap must specify all of them. The "info" tab in the SceneViewer shows that the background uses the extended size of 64x64 tiles (BGs can be 32x32, 64x32, 32x64 or 64x64 tiles).
Nightcrawler
Guest
« Reply #7 on: August 12, 2008, 01:49:05 pm »

Quote from: Spinal on August 12, 2008, 11:10:19 am
Okay, I *think* I understand what you're saying here. However, I do not see how to get the ROM address from the VRAM address.
If I understand correctly, when the game is running it writes certain things to register 2117 and it ends up in the VRAM. So can I somehow track where in the rom that data is coming from?

Yes, that's the general idea give or take. I purposely left out how to get the ROM address because that's opening up another can of spam.  I wanted to make sure you understood how things worked first and understand what data you need to change to get the desired effects. With that said, have you been able to change the palette used for the background tiles you're interested in? If you understand what needs to be changed, you'll understand what data you actually need to look for in the ROM and what to do with it.

You should also clarify if you need to change the palette the tile is assigned to using or if you want to modify the actual colors in the palette being used. My assumption thus far as been you want to change the assigned palette. If you want to change the individual colors, you will need to look at the palette data as a whole and get into some CGRAM modification which isn't that hard. The hardest part there is the effects your palette changes may have on the rest of the game. Often you may get undesired effects because palettes are often shared by many things in game.

So you tell me, what have you done so far and what do you want to do next specifically? Finding the tilemap in the ROM for example could be a difficult task if you don't know assembly and the game creates it on the fly. Or it could be simple if the game stores such a map directly in the ROM. The easiest thing you can do is search for the tile map data you see in VRAM in the ROM using any hex editor with byte searching.  You may get lucky and the tilemap is flat out stored in the ROM. Also run a search for just the tile index byte of the map. More often than not, the second byte in the tilemap is generated on the fly when the game determines what palette to use, if any flipping is needed etc. In those cases, it pulls tile indexes from the ROM and assigned the second byte via game code.

If you turn up empty handed on those searches, it's going to be more difficult because you'll need to get an SNES debugger learn to trace some code and figure out how that data got to VRAM so you know where it came from. That could be difficult without prior knowledge of assembly and/or debuggers. It's often a big obstacles for newcomers to get over so be prepared to spend some time on it.
KingMike
Guest
« Reply #8 on: August 12, 2008, 01:58:00 pm »

Once you've found the tilemap data in VRAM: If you do know assembly, it might be easier to see if you can find a RAM mirror of the tilemap. Then use that to trace ROM access, as it's a bit easier to trace RAM access (since it can be directly accessed) than VRAM access (since it can only be accessed through registers).
Spinal
Guest
« Reply #9 on: August 13, 2008, 07:36:56 am »

Quote from: creaothceann on August 12, 2008, 11:57:43 am
Yeah, a bit slow though (at least on this PC).
Yes, here too. But it works Smiley

Quote from: creaothceann
Look at the "window size" groupbox, it says that the current viewing window is 16x32 tiles in size. [...]
I can't believe I missed that :X yes, it's a 16-tile wide grid.

Quote from: Nightcrawler on August 12, 2008, 01:49:05 pm
[...]With that said, have you been able to change the palette used for the background tiles you're interested in? If you understand what needs to be changed, you'll understand what data you actually need to look for in the ROM and what to do with it.
Yes, I have Smiley

Quote
You should also clarify if you need to change the palette the tile is assigned to using or if you want to modify the actual colors in the palette being used. My assumption thus far as been you want to change the assigned palette. If you want to change the individual colors, you will need to look at the palette data as a whole and get into some CGRAM modification which isn't that hard. The hardest part there is the effects your palette changes may have on the rest of the game. Often you may get undesired effects because palettes are often shared by many things in game.
Changing the colors was nice practice to better understand how the tiles are stored, but that's not my ultimate goal. I want to make a level viewer Wink (or background viewer, if you wish)

Quote
So you tell me, what have you done so far and what do you want to do next specifically?
Okay, what I've done so far:
I know where the palette is stored in the ROM and know how to extract/show it.
I know where the 8x8 tiles are stored in the ROM and how to show them.
I'm not entirely sure where to go from here, I guess finding out how the tile map is constructed in the VRAM is the next logical step. The tiles in the ROM and in the VRAM don't match up, so something is going on there. For example, one tile is 740 in vSNES, but it's the 776th in the ROM. Another one is 70 in vSNES but the 670th in the ROM.

Quote
Finding the tilemap in the ROM for example could be a difficult task if you don't know assembly and the game creates it on the fly.
I've done some assembly in the past, but that's over 8 years ago...
Quote
Or it could be simple if the game stores such a map directly in the ROM. The easiest thing you can do is search for the tile map data you see in VRAM in the ROM using any hex editor with byte searching.  You may get lucky and the tilemap is flat out stored in the ROM.
Nope, unfortunately the tilemap data can not be found in the ROM. Not flat out, and not by searching for just the tile-index-byte Sad

Quote
If you turn up empty handed on those searches, it's going to be more difficult because you'll need to get an SNES debugger learn to trace some code and figure out how that data got to VRAM so you know where it came from. That could be difficult without prior knowledge of assembly and/or debuggers. It's often a big obstacles for newcomers to get over so be prepared to spend some time on it.
Quote from: KingMike
Once you've found the tilemap data in VRAM: If you do know assembly, it might be easier to see if you can find a RAM mirror of the tilemap. Then use that to trace ROM access, as it's a bit easier to trace RAM access (since it can be directly accessed) than VRAM access (since it can only be accessed through registers).
Alright, so what debugger can you guys recommend? And where would I start? (Aside from brushing up on my ASM skills)
KingMike
Guest
« Reply #10 on: August 13, 2008, 07:55:45 am »

I use Geiger's Tracer.
Nightcrawler
Guest
« Reply #11 on: August 13, 2008, 09:59:32 am »

Yes, Geiger's is the best available despite being old and outdated. SNES debugger development overall stalled out several years ago.

You'll want to read up on DMA transfers in Anomie's register document. Most all SNES games (there are a few black sheep though) will use a DMA transfer to transfer tiled ata and tile mapsto VRAM. This is because you can only write to VRAM (as well as most PPU/video related registers) on the SNES during the blanking (v-blank or h-blank) period. DMA is the fastest way to transfer the data which is important since you only have a limited amount of time you can do it.

Personally, I like to have a trace file open showing much of the code to help give a bigger picture when I'm either stepping through or just toying with break points trying to find out where data came from. To make a trace file, just click 'CPU' under 'Logging'. Go back to the game and  wait a second, then click the box off to end the trace. There are a few CPU trace options. The most notable is 'Trace Once'. This will trace each instruction one time. Therefore if a routine is used more than once or there is a loop, only the first iteration is printed. Sometimes this is desirable to keep trace size small, however sometimes you'll want to nothing left out and you want a full trace. Note that a full trace can be many MB in size for even a second or two of tracing. So, try not trace more than you have to. Limit it to one or two seconds which should be sufficient for most tasks.

Breakpoints will be your other best friend. You can set the debugger to break on read, write, or execute of any SNES address. This includes ROM, RAM, and even registers. This is how you find things out. You want to know when a value from RAM is written to, you set a breakpoint. Want to know when a value from ROM is read, set a break point. This is how you start to figure out where things came from and how they get to where they're going. I use breakpoints to find code locations and then like to reference my trace file to see the full routine.

The other thing you need to know is DMA tracing. Under 'Special Tracing', you can check DMA, then you'll see all DMA transfers happening. Here's where you'll see source address and destination. It also shows VRAM address in the event it's a transfer to $2118 (more often than not it is). Again, limit your trace to a second or two, or you'll have hundreds of DMA transfers you won't be able to sort through.


OK.. So, in a nutshell, you'll want to do some DMA tracing and see when data is copied to VRAM around the location you know the tile map is in. You'll see where that data came from. It's most likely some location in RAM. Then you can do a few write breakpoints to see when and how the data got to the RAM locations and work backwards.


I've said plenty, I'm sure you'll have a rough time digesting it all. So, go dive in. Wink


P.S. There is a 'Show Hex' button as well. You can view contents of ROM, RAM, and VRAM there similar to VSNES.



Spinal
Guest
« Reply #12 on: August 14, 2008, 05:39:24 am »

Alright, thanks. I guess I'm busy for the next few days Smiley
Spinal
Guest
« Reply #13 on: October 02, 2008, 09:06:29 am »

Right, it's now 6 weeks later so let me tell you what I've been up to...

I've tried debugging for a while, but I just didn't get the hang of it. So the project got halted.
A few days ago I couldn't take it anymore. I just had to do this! I tried a different approach though: corrupting. I started corrupting in large chunks and wrote down what happened. In case of a crash, I went to smaller chunks to see what happened then.
Using this method I found out:
- where the titlescreen graphics are stored
- where the logo is stored
- the title screen uses a different palette than the actual game
- some other graphics
- where the songs are stored (lots of SPC700 stalls in this area)
- I corrupted the "physics" (the unicycles kept bouncing up and down, or the saddle kept sticking to the floor, or the cycle would keep rotating in a funny way)
- the tile graphics are not related to their collision
- I think I did something with either collision testing or changing the collision of the tiles
- and I got a lot of crashes.

I'm now to the point that I broke down most crashes to 1024 bytes or less, but nowhere did I find out where the level data is. Since there are around 45 levels, I highly doubt that it will fit in 1024 bytes, even with RLE.
I really don't know what to do, but I have one idea that I can use your help on:

Is it possible to track which offsets the game is taking data from?

So for example, on the titlescreen it will take data needed for the background, the text etc. from offset xxx. Now if you start a level, it will take data for the graphics at offset yyy, the palette at offset zzz and level data from offset aaa. When you start a different level it will read yyy, zzz and bbb!

If this is possible, please explain how to do! Thanks in advance for any help.
Karatorian
Guest
« Reply #14 on: October 02, 2008, 09:13:23 pm »

Well, you'll basically have to use debugging. If you know where the tile data is stored in the ROM, set a read breakpoint on it and you should be able to trace where the code loads the tiles into VRAM. The other level data loading code may be nearby. If you know where in the RAM the level data is loaded to, you can set a read breakpoint on that and you should find the level loading routine. By tracing that back, you should be able to locate the source in ROM where the data is loaded from.

Best of luck with this project, I played Uniracer a few time back in the day and really enjoyed it, so I hope this project produces some useful results. Keep at it.
Pages: [1] 2  


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