+  RHDN Forum Archive
|-+  Romhacking
| |-+  General Romhacking
| | |-+  snes sprite question
Pages: [1] 2
Author Topic: snes sprite question  (Read 1 times)
matrix
Guest
« on: October 13, 2008, 04:49:45 pm »

I'm looking at a football helmet in which the logo and face mask are sprites and the helmet is BG.
In vSNES, I see the x cord, y cord,tile index and flip of the sprites in OAM.  As I understand it, OAM is where the sprite attributes are stored and there should also be some sort of map in VRAM.  (I cant make anything out in vSNES's VRAM) How do I go about finding the ROM location of the sprite attributes.  do I want to get the vram location and use it as a breakpoint with a debugger?
creaothceann
Guest
« Reply #1 on: October 14, 2008, 02:30:58 am »

Quote from: matrix on October 13, 2008, 04:49:45 pm
I'm looking at a football helmet in which the logo and face mask are sprites and the helmet is BG.

Got a savestate?


Quote from: matrix on October 13, 2008, 04:49:45 pm
In vSNES, I see the x cord, y cord,tile index and flip of the sprites in OAM.  As I understand it, OAM is where the sprite attributes are stored and there should also be some sort of map in VRAM.  (I cant make anything out in vSNES's VRAM)

Move the mouse over the sprites in the Scene Viewer; the Memory Viewer should update itself accordingly (unless the offset is too large - in that case try reducing the window size to 1x1).


Quote from: matrix on October 13, 2008, 04:49:45 pm
How do I go about finding the ROM location of the sprite attributes.  do I want to get the vram location and use it as a breakpoint with a debugger?

Yes.
matrix
Guest
« Reply #2 on: October 14, 2008, 03:40:29 pm »

Thanks, reducing the window to 1x1 did the trick.
I have to figure out my debugger, I'm used to fceuxd.
matrix
Guest
« Reply #3 on: October 16, 2008, 04:36:18 pm »

With that vram address, I found the "pixels" of the sprites in the ROM, but it doesnt change the xy location.
Please, how do I find the attributes?
creaothceann
Guest
« Reply #4 on: October 16, 2008, 04:54:04 pm »

Mmmh... OAM's address registers are $2102 and $2103, so you could set a breakpoint at that.

OAM is an array of bits and bytes: 128 4-byte entries (bytes 0..511) followed by 128 2-bit entries (bytes 512..543, 4 entries per byte).

Use the index of the sprite you want to modify in your calculations.
matrix
Guest
« Reply #5 on: October 17, 2008, 04:20:47 pm »

please bare with me, obviously I'm learning as I go.
I gather this is the calculation you're talking about:
address_of_character = (base_location_bits << 14) + (32 * character_number)
I have a couple more questions
1. The source of the $2102 breakpoint should be VRAM?
2. I'm not understanding what << means in the calculation example
Aerdan
Guest
« Reply #6 on: October 17, 2008, 04:42:50 pm »

It's called 'bit shifting', and in that example it means 'shift this number left 14 bits'.
creaothceann
Guest
« Reply #7 on: October 18, 2008, 03:19:07 am »

Shifting left = adding a zero to the binary value; shifting right = removing the last binary digit. Same result as multiplying with / dividing by 2. But no, that's not the calculation. The breakpoint source can be RAM or ROM.

See the section "sprites" in anomie's doc again. OAM has a low table (containing xPos, yPos, tile index, palette etc.) and a high table (containing bit 9 of xPos, and the sprite size selector). Let's say you want to change the vertical position of sprite #53 (counting from zero). The position of sprite #53 in the low table is 53 * 4 = 212, and yPos is the second byte.

...
byte 208 = sprite #52 xPos
byte 209 = sprite #52 yPos
byte 210 = sprite #52 tile
byte 211 = sprite #52 name table, palette etc.
byte 212 = sprite #53 xPos
byte 213 = sprite #53 yPos
byte 214 = sprite #53 tile
byte 215 = sprite #53 name table, palette etc.
byte 216 = sprite #54 xPos
byte 217 = sprite #54 yPos
byte 218 = sprite #54 tile
byte 219 = sprite #54 name table, palette etc.
...

So you'd set the breakpoint for write access at address 2104h (OAM data register) when register 2102h is 213.
Note that a breakpoint hit is only valid when bit 0 of register 2103h is not set (i.e. the low table is selected).


(Please correct me if I'm wrong.)
« Last Edit: October 18, 2008, 12:12:57 pm by creaothceann »
Ryusui
Guest
« Reply #8 on: October 18, 2008, 10:31:47 am »

You can't set breakpoints to VRAM in Snes9x. You can, however, find where the data is being constructed in work RAM and set a breakpoint to it.

Find the data you're looking for in VRAM using either Snes9x or VSNES and then look for it in work RAM (7E:0000-7F:FFFF) using VSNES' search function. Set a breakpoint to the location that the data you saw in VRAM turns up in work RAM.
Nightcrawler
Guest
« Reply #9 on: October 20, 2008, 09:13:33 am »

Quote from: Ryusui on October 18, 2008, 10:31:47 am
You can't set breakpoints to VRAM in Snes9x. You can, however, find where the data is being constructed in work RAM and set a breakpoint to it.

Find the data you're looking for in VRAM using either Snes9x or VSNES and then look for it in work RAM (7E:0000-7F:FFFF) using VSNES' search function. Set a breakpoint to the location that the data you saw in VRAM turns up in work RAM.

Sometimes I work around the limitations of Geiger's debugger by tracing DMA transfers or breaking on writes to $2116. Then you can see the VRAM address being used for the beginning of most transfers to VRAM. Certainly not nearly as nice as breaking on write to specific VRAM addresses, but it's something. If I get severely frustrated, I still keep a copy of BSNES .13 that does break on VRAM writes.

I tried to contact Geiger awhile back for source code so I could update the bloody debugger, but he never answered. SNES debuggers are still stuck in a time warp of several years ago. Sad
byuu
Guest
« Reply #10 on: October 20, 2008, 10:30:46 am »

Quote
I tried to contact Geiger awhile back for source code so I could update the bloody debugger, but he never answered. SNES debuggers are still stuck in a time warp of several years ago. :(

It's not just the debuggers. I don't know of anyone actively researching the SNES. Nearly everyone left in 2006 or so :(

As for the reason most don't have killer debuggers -- they just aren't necessary. The SNES is simple enough that you can fix 99% of bugs, and ROM hack 99% of code, with only a tracelog.

I'd still like to have a killer debugger, but a) getting it to work cross-platform is really tough (can't superclass a textbox on Linux to make a nice memory editor; fonts will never look the same, throwing off the window sizing), b) the lack of savestates kills its usefulness right off the bat and c) just the simple if(debugger_enabled) placements before debugging areas (memory access, opcode execute, etc.) knocks off ~10% of my emulator speed. It'd be much worse for faster ones.

I'm still slowly working on the cross-platform lib, and I'm planning to use class derivatives to avoid the code bloat / overhead of a debugger on the core, so I'll hopefully have something like v013 + PPU memory viewer in the future.

And I know it's not a solution for most, but if you understand C++ ... editing the emu source directly gives you the most amazingly versatile debugger in the world. I've made "enable tracer on 43rd write of NN to memory address, dump all PPU regs, and then enable trace masking after 44th write." style breakpoints. Quite fun.

Nightcrawler
Guest
« Reply #11 on: October 20, 2008, 01:07:23 pm »

Quote from: byuu on October 20, 2008, 10:30:46 am
Quote
I tried to contact Geiger awhile back for source code so I could update the bloody debugger, but he never answered. SNES debuggers are still stuck in a time warp of several years ago. Sad

It's not just the debuggers. I don't know of anyone actively researching the SNES. Nearly everyone left in 2006 or so Sad

At least you've kept things progressing better with emulation though. Tongue Who needs additional research? It just isn't necessary. The SNES is simple enough that emulators, especially yours, already does 99% of everything. How do you like that? Your own logic (regarding debuggers below) against you! Cheesy (I don't even share that view, I said it simply for logic/argument sake)

Quote
As for the reason most don't have killer debuggers -- they just aren't necessary. The SNES is simple enough that you can fix 99% of bugs, and ROM hack 99% of code, with only a tracelog.

Debuggers have never really been about necessity, but rather efficiency and time saving in my opinion. I could do 95% of my hacking work with nothing but a hex editor if I tried hard enough, but why should anyone when there's a better tool for the job that can make it much faster and save valuable time?

A full featured debugger saves time and is more efficient in problem solving, testing, or investigating many occurrences. I think you need to get started on a new SNES ROM hacking project again, use the tools we have, and then tell me if a better debugger would have saved you time. You're too far removed. I'm thinking you'd agree. Wink You yourself have said you have used the BSNES source code for your debugging, thus proving the existing tools are not good enough. Unfortunately, I doubt modifying the BSNES source for debugging needs is going to be a preferred, effective debugging solution for many out there. It certainly isn't for myself.

Quote
I'd still like to have a killer debugger, but a) getting it to work cross-platform is really tough (can't superclass a textbox on Linux to make a nice memory editor; fonts will never look the same, throwing off the window sizing), b) the lack of savestates kills its usefulness right off the bat and c) just the simple if(debugger_enabled) placements before debugging areas (memory access, opcode execute, etc.) knocks off ~10% of my emulator speed. It'd be much worse for faster ones.

I'm still slowly working on the cross-platform lib, and I'm planning to use class derivatives to avoid the code bloat / overhead of a debugger on the core, so I'll hopefully have something like v013 + PPU memory viewer in the future.
I don't know much about this kind of thing, but would it be possible to have a separate program interact or control BSNES as a debugger? It would then be this separate program handling the debugging windows and functionality mostly independent of the emulator other than some control communication back and forth. I think I've seen something like that somewhere before. Just a thought as I'm not versed enough in co-threading or BSNES's design model to know if something like that is feasible.

Quote
And I know it's not a solution for most, but if you understand C++ ... editing the emu source directly gives you the most amazingly versatile debugger in the world. I've made "enable tracer on 43rd write of NN to memory address, dump all PPU regs, and then enable trace masking after 44th write." style breakpoints. Quite fun.

Now, if we could just have that same functionality without having to get compilers, install packages, learn foreign source code, and modify code, we wouldn't be having this conversation!

Lenophis
Guest
« Reply #12 on: October 20, 2008, 01:19:50 pm »

Quote from: Nightcrawler on October 20, 2008, 09:13:33 am
I tried to contact Geiger awhile back for source code so I could update the bloody debugger, but he never answered. SNES debuggers are still stuck in a time warp of several years ago. Sad
You won't get it, either. I could speculate into reasons why, but for the sake of not dwelling, I won't.

The only way to get a fully functioning debugger going is to write one from scratch. bbitmaster has toyed with the idea (co-author of the *XD variant of FCEU), but it appears that he doesn't want to do it. Others have also toyed with the idea, but they've either flamed out or decided against it.

Until the Zsnes team separates the UI from the core, there's no way to attach one to that. Snes9x also has a terrible interface, and a core which is hit and miss compared to Zsnes. On top of that, both cores are still badly inaccurate.

Sadly, I don't see a real debugger for this system for a very long time, yet. :'(
Deathlike2
Guest
« Reply #13 on: October 20, 2008, 03:47:29 pm »

Quote from: Lenophis on October 20, 2008, 01:19:50 pm
Until the Zsnes team separates the UI from the core, there's no way to attach one to that. Snes9x also has a terrible interface, and a core which is hit and miss compared to Zsnes. On top of that, both cores are still badly inaccurate.

It's less to do with the UI.. but the interface itself is barely passable (let's face it, putting up a DOS-ish console screen while running ZSNES isn't the most appealing thing in the world). It will be rewritten using QT. However, the bigger issue is the core (to be rewritten/replaced), which is preventing this portion from finishing...

Even then, you probably should wait til 2020 or something (or earlier perhaps), because the debugger is currently at the backburner of "stuff to do".
byuu
Guest
« Reply #14 on: October 20, 2008, 04:27:48 pm »

Quote
At least you've kept things progressing better with emulation though.

Not really. The last major thing was blargg's S-DSP work. The only thing I can think of in the last two years is some rather large HDMA timing improvements.

Quote
I don't know much about this kind of thing, but would it be possible to have a separate program interact or control BSNES as a debugger?

It would need some really deep hooks, and IPC would be a hell of a lot slower still. Having to have the kernel intervene every time a memory access occurs ... that's not going to be pretty. You can only do that ~100k times a second, assuming your program uses no CPU of its own. The only way this will be practical is for an emulator to be the debugger itself, which makes it just as complex, and send its own IPC messages when breakpoints should occur.

Quote
but the interface itself is barely passable (let's face it, putting up a DOS-ish console screen while running ZSNES isn't the most appealing thing in the world)

I'll admit to not being a fan of the current incarnation (mostly due to the 5x5 font and available mouse capture modes), but the idea really is a good one for portability. I think the biggest flaw was building around a fixed internal resolution of 256x224. It really was some awesome code, albeit scary with that nasm macro issue. The current GUI system in hi-res with some outside work coming up with a nice theme ... it could blend in really well with Win32, GTK+ and Qt; all at the same time.

Nonetheless, Qt should be superior on supported platforms. And you're only really losing DOS (dead) and Xbox (dead + unofficial), anyway. And only having to code for one UI toolkit ... oh, how I envy you.
« Last Edit: October 20, 2008, 04:36:24 pm by byuu »
Pages: [1] 2  


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