News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: [NDS] Finding level object positions?  (Read 1641 times)

matt!

  • Full Member
  • ***
  • Posts: 141
  • JUS4QIX
    • View Profile
[NDS] Finding level object positions?
« on: April 20, 2017, 06:14:29 pm »
I'm building my own stage viewer for Pang DS.

So far I've extracted the stage NSCRs from the ROM and have written my own renderer in JavaScript using the HTML canvas. So now I can quickly browse all 256 tile maps with both screens joined together.  Fun!

Next, I need to find the positions of level objects (player, balls, power-ups, ladders, entrance/exit, food, etc). I assume they're stored in the main binary?

I've found the level objects graphics in the ROM.

My best guess for the next step is to use an emulator to watch for accesses to the address of the level objects graphics. That will hopefully let me get closer to where the position days is stored.

Any ideas appreciated!



April 21, 2017, 06:09:53 am - (Auto Merged - Double Posts are not allowed before 7 days.)
I've started a personal project thread for my work so far.

http://www.romhacking.net/forum/index.php?topic=23995
« Last Edit: April 21, 2017, 06:09:53 am by emsef »

FAST6191

  • Hero Member
  • *****
  • Posts: 2765
    • View Profile
Re: [NDS] Finding level object positions?
« Reply #1 on: April 21, 2017, 10:14:29 am »
You can trace back through graphics and it is ultimately guaranteed to find you what you want, however it can take a while. For a first pass though (assuming there is not a level editor in the game you can look at, hopefully there are no downloadable levels now gone with the dead wifi as I don't think people would have saved that game) I tend to have a scan through the level files. If you know the locations of the outline files then assuming it is not within the files themselves then you will tend to have a bunch of similarly named files (or files with different extensions), probably identical in number, to the level outline files.

Never played/heard of the game so watched the following
https://www.youtube.com/watch?v=K5vTOyFjcM0

Seems to be a 2d "single" screen/non scrolling platform/puzzler affair, and might have to actually give it a go later. This could mean you have direct OAM locations for objects but parts of that jump between the screens so maybe something more exotic, or just something more high level, is at play like you see in the scrolling variety. Either way once you have a file that looks like the object data then try copying parts from other files, other parts of the file or simply changing it and seeing what happens.
Some of the DS games I have dealt with have got very fiddly in their enemy data/item data and used things like 5 bits per item, however if you are just copying working files/segments it should not matter.

matt!

  • Full Member
  • ***
  • Posts: 141
  • JUS4QIX
    • View Profile
Re: [NDS] Finding level object positions?
« Reply #2 on: April 22, 2017, 04:52:41 am »
There's no level editor I'm aware of. That would have been ideal and saved me a lot of time.

The only thing NWFC provided was online leaderboards so I won't be able to get any related achievements I don't already have. Unless I hack that too.

You can see from my work in the personal projects section of the forum that I already found the NSCR tile maps with the platform data. Is this what you mean by outline files? The only data in them is the file header followed by a screen full of tile and flip data. There are 256x2 stage files, all with filenames starting "stage". Sadly there isn't a set of another 256x2 similarly named files.

I have found the object graphics, but these are standard graphics files. They do not contain the placement of objects on each level.

Any further advice appreciated!

FAST6191

  • Hero Member
  • *****
  • Posts: 2765
    • View Profile
Re: [NDS] Finding level object positions?
« Reply #3 on: April 22, 2017, 01:19:50 pm »
Sometimes the in game editors can trick you a bit but yeah they are nice to have. Similarly if the wifi had provided bonus levels (things like Picross and professor layton being examples) then that also can help.,
The ways levels get constructed in games varies infinitely but it does usually boil to a handful of concepts.
1) All in one, tends to be for simpler games like your basic maze or something.
2) Base level, objects map and possibly another for enemies. Tends to be for anything vaguely complex. The following is actually for a 3d game but does show things well enough http://treeki.rustedlogic.net/romhacking/docs.html
3) Normally seen in 3d stuff where you get an overlay on top of a graphics file. For the DS then the Mario Kart kcl files are a good example. Mario Kart itself has full 3d worlds but no concept of where anything is from the 3d alone so it has those files to tell it where the track, the dirt and completely off the level is. Not so common in 2d any more as sprite collision detection is doable within the hardware on most systems.

Anyway if there are not another bunch of files, or a simple file with it all in named hopefully fairly obviously (or able to be discerned by elimination)
Time for some maths then
http://problemkaputt.de/gbatek.htm#lcdobjoverview covers how to fully define a sprite location. If the game set that as an initial condition then as "Each entry consists of 6 bytes (three 16bit Attributes)" we can start.
6 bytes * 20 items per level (possibly a bit high when looking at that video but I am OK with that) * 256 levels = 30720 bytes, or about 30 kilobytes. Multiply that by 4 for reasons (it has to say what the object is, maybe does not want to pack it all tightly) and you have 120 kilobytes of what could be considered key game data, for a system with 4 megs of RAM. To that end there might well be a massive table somewhere in the binary (usually called arm9.bin in things that extract DS ROMs), an overlay or even a standalone file.


matt!

  • Full Member
  • ***
  • Posts: 141
  • JUS4QIX
    • View Profile
Re: [NDS] Finding level object positions?
« Reply #4 on: April 22, 2017, 07:10:31 pm »
OK, I have been through all files in the ROM. I can assign all files groups as follows:

ball sprites
ball burst effect sprites
backgrounds
confetti
demo (introduction cutscene)
font
game over menu
menu
main menu
icon
in-game hud/score
items/powerups
stage names
stage maps
on screen messages
options
panic mode assets
player sprite
results screen
salon/lounge/achievements
save screen
shots/wire/bullets
sign/score/points sprites
stages (512 files for 256 levels)
title
tour mode assets
tutorial
tutorial replay data (nice!)
vs mode assets
wifi mode assets
download play files
world maps

There are zero files that I am unsure of.  ::)

FAST6191

  • Hero Member
  • *****
  • Posts: 2765
    • View Profile
Re: [NDS] Finding level object positions?
« Reply #5 on: April 22, 2017, 07:39:33 pm »
In that case time to look at the binaries (or more likely just the ARM9 as the ARM7 is not of much interest to hackers just pulling things apart) and overlays. A while back I was writing a basic DS focused how to hack ROMs guide and picked N+ as my level editor of choice, turns out the timers within the level were not of the objects or the background/layout and instead seemed to come from somewhere else. Not what you have here but an idea of what can be at play.

Possible alternative. The download play stuff (a file named utility.bin or possibly located in a dwc directory?) can often be a simplified version of the game and is in turn a DS ROM unto itself. I don't always encourage looking at them as they can be coded quite differently but it might give you an idea of the format/structure of the start positions for something that you can take back to the main ROM.

matt!

  • Full Member
  • ***
  • Posts: 141
  • JUS4QIX
    • View Profile
Re: [NDS] Finding level object positions?
« Reply #6 on: April 23, 2017, 05:49:02 am »
This game supports wireless multi card play, and single card download play.

I can see the utility.bin and I can also see some files with "child" in the filename which seem to be one or the other mode. However, the only mode available over Wi-Fi is panic mode which doesn't have any platform or object placement just a steady stream of balls.

Interestingly, on the back of the box the game shows 3 screenshots: two of them are taken across the screen boundary so show elements of upper and lower screens. Maybe they grabbed them from an emulator? The third screenshot is of test level 000 which is not playable in the game. Sneaky!