VGMaps

General Boards => Maps In Progress => Topic started by: Raccoon Sam on May 03, 2008, 10:53:12 am

Title: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 03, 2008, 10:53:12 am
You might remember my very first topic at Map Requests where I needed the Jungle Hijinxs map and kinda succeeded thanks to Fearnavigatr's excellent effort.



However, this time I'm into a more technical thing. I'm talking about a method contrary to screenshot-mapping; writing a program that does the maps for us. Allow me to elaborate.



Donkey Kong Country's level format is ridiculously simple. A level is always* 64 tiles wide and 16 tiles high, is sequenced in columns of tiles, one tile being 32 x 32 pixels. Take a look at the very first column of 'Jungle Hijinxs', thats level array begins at 0x190000.

81 40 67 00 78 00 80 00 68 00 49 00 EA 00 EB 00 EC 00 ED 00 EE 00 EF 00 F0 00 F1 00 F2 00 00 00



And since it's 2 bytes per tile, let's isolate to words:

81 40 | 67 00 | 78 00 | 80 00 | 68 00 | 49 00 | EA 00 | EB 00 | EC 00 | ED 00 | EE 00 | EF 00 | F0 00 | F1 00 | F2 00 | 00 00



The very first tile, '81 40' means literally 'Tile 81, flipped horizontally'. Why? Because the first byte, 81, or whatever it might be is always just the tile. You can change it to any value, and the desired tile will change. The  second byte, 40, will be read nibble-by-nibble;

The first nibble, 4, must be read in binary.

Binary table is the following:

Flip Vertically || Flip Horizontally || Ghost || Ghost

If a bit is set, the action is true. 4 is 0100 in Binary, so...

DON'T Flip Vertically, DO Flip Horizontally, DON'T make a ghost, DON'T make a ghost.

(Ghost means that the tile looks normal, but you have no interaction with it. You just walk/fall through it. No idea why it must be defined twice, and who gives a damn anyway since it doesn't serve a purpose in mapping.)

The second nibble, 0 in this case means what bank to use. 0 means use bank 0, 1 means use bank 1, etc...



Now we know how the levels work, but where are the tiles read from? That's when I kick in. I've ripped tilesets of most DKC level types. Below are the links to the Jungle tileset banks 0 to 2.

http://i126.photobucket.com/albums/p82/Raccoon_Sam/Jungle_0.png

http://i126.photobucket.com/albums/p82/Raccoon_Sam/Jungle_1.png

http://i126.photobucket.com/albums/p82/Raccoon_Sam/Jungle_2.png



In short, the program works like this:

1. Read two bytes from desired location

2. Check bank and load corresponding PNG

3. Check the tile byte and print the corresponding tile to the array

4. Check for Vertical or Horizontal flip and apply if true

5. Read next 2 bytes and repeat process

Once 16 tiles are printed below each other, the first column is done, and another column will be started.

Repeat until 1024 tiles are printed.

I've attached a demo movie if you don't get it (requires Flash Player 8).





So yeah, if you're a software developer, be sure to look into this. I'm more than glad to help and will provide all the necessary tilesets if this project gets anywhere.
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on May 03, 2008, 02:43:45 pm
Cool :D
Title: RE: Donkey Kong Country maps revisited
Post by: Revned on May 03, 2008, 03:11:04 pm
Hey, good work. I'd lend a hand, but I've got finals this week. Are the backgrounds stored in the same fashion?
Title: RE: Donkey Kong Country maps revisited
Post by: JonLeung on May 03, 2008, 04:32:40 pm
I don't even know why I still have my crappy DKC maps up.  >_<



Sweet if a program to do this automatically can be made.  Would it work for the whole DKC trilogy, do you think?



(...Hey, I'm sure it's not the same as with the Donkey Kong Land games, but if it did...that'd certainly make The Ultimate Koopa happy.  :P)
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 03, 2008, 05:07:57 pm
Revned: Backgrounds work exactly the same. They're a bit darker than the foreground though.



JonLeung: Sadly, no. DKC2 and 3's level formats remain undiscovered. I've looked into the games (2 and 3 that is) and noticed that there are no similar structures. I've found some tilemaps and pointers, but nothing level-data related (except some arrays that upon editing make the levels look like vomit, but those probably have nothing to do with level data.)
Title: RE: Donkey Kong Country maps revisited
Post by: RT 55J on May 03, 2008, 05:56:57 pm
Maybe the level data in DKC2/3 is compressed.

---

"its a good day to do what has to be done by me and help my brother to defeat the enemys" - John Freeman
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on May 04, 2008, 05:41:45 am
Why, Jon do you always have to mention something to do with me? <____< XD
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 04, 2008, 11:15:53 am
RT-55J: That might well be the case.



And on the tile flipping, I made a more sensible system;

-If the byte is 4x, flip horizontally.

-If the byte is 8x, flip vertically.

-If the byte is Cx, flip horizontally and vertically.

Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 05, 2008, 06:03:02 am
The flipping flags are easy to deal with in code. I might put something together today if you can send me some of the files needed. (my name @ smspower.org)
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 06, 2008, 01:36:56 pm
All the necessary stuffs sent.
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 06, 2008, 11:09:34 pm
If only it was on Monday...



(I'll try and look at it tonight. I'm thinking I can make a fairly generic tool for this that might be reusable.)
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on May 07, 2008, 04:49:53 am
Yay!



Hurry up. why is this ignored? bump bump bump lol <_<



OK, seriously I won't do that again.
Title: RE: Donkey Kong Country maps revisited
Post by: Rew on May 07, 2008, 08:01:50 am
Why were you bumping a thread that had just been posted in only 5-6 hours earlier? =P



---

"So this is what it's like..."

- Spark Mandrill
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 07, 2008, 02:47:29 pm
OK, here we go...



User posted image



You can dump entire level sets as single images (eg. all jungle-themed levels) but a 41920x512 image is hard to deal with...
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 07, 2008, 03:02:51 pm
Actually, get this one. The Tile class wasn't necessary. Source is included in this one as well. Java code where everything happens in main() should not be copied at home.
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 07, 2008, 09:35:02 pm
That is so cool..! Thanks a lot, Maxim, I'll get to ripping ASAP.
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 08, 2008, 12:18:03 am
Type what I said:



java -cp . TileMapReconstructor



Java knows that means "run the TileMapReconstructor.class file".
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 08, 2008, 12:34:08 am
'Exception in thread "main" java.lang.NoClassDefFoundError: TileMapReconstructor'

:<
Title: RE: Donkey Kong Country maps revisited
Post by: Revned on May 08, 2008, 02:01:10 am
Works fine for me. Did you make sure to use the "cd" command to get to the right directory? Try typing the following before the command Maxim gave you:



cd /Users/Bradbury/Desktop/DKCTilemapReconstructor/
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 08, 2008, 03:46:31 am
Hmm, I guess I'm too used to a commandline and never considered you might not be in the right directory.



Here's what it looks like to create the above image for me:



C:\Documents and Settings\GreadyM\Desktop\maps\DKC>java -cp . TileMapReconstructor "Jungle_" 3 32 32 "Donkey Kong Country (U) (V1.0) [!].smc" 0x190000 168 16 "Jungle Hijinks.png"

Loading Jungle_0.png...

Loaded: 512x512

Got 256 tiles.

Loading Jungle_1.png...

Loaded: 512x512

Got 256 tiles.

Loading Jungle_2.png...

Loaded: 512x160

Got 80 tiles.

Loading Donkey Kong Country (U) (V1.0) [!].smc...

Creating map...

Saving...

Done!



It seems you didn't rip all the tilesets yet, but most things I've tried seem to work fine. For the level ranges you've documented, the map width can be calculated from (end offset - start offset + 1) / 32, so for example "190000 - 1914FF   Jungle Hijinx" becomes 0x15000 / 32 = 168 (hence the 168 parameter in the commandline above).
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 08, 2008, 05:45:22 am
Hmm, that's odd. Doesn't seem to work for me.. Is there a way to compile/convert it to a JAR? I'm most certain they work.



And don't thank me for those offsets, they're all Giangurgolo's wondrous works. He has also ripped the banana sets and explained how they work in his site, too. You might want to take that into a consideration too.

http://giangurgolo.home.att.net/dkc/

Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 08, 2008, 06:30:01 am
I'm not sure a jar helps, since it still needs to be in the right directory and to have loads of commandline options passed in.



java -jar TileMapReconstructor.jar "Jungle_" 3 32 32 "Donkey Kong Country (U) (V1.0) [!].smc" 0x190000 168 16 "Jungle Hijinx.png"
Title: RE: Donkey Kong Country maps revisited
Post by: TerraEsperZ on May 08, 2008, 07:08:58 am
Impressive work! I'm always amazed at what people can accomplish from reading a game's original data.



(Although I'm glad in a way that you're not trying to dump/extract maps from games I'm mapping, otherwise I'd be out of work ;))



---

"With the first link, the chain is forged. The first speech censored, the first thought forbidden, the first freedom denied, chains us all irrevocably." [...] The first time any man's freedom is trodden on, we're all damaged. - Captain Jean-Luc Picard



Current projects: Sonic CD (Sega CD), Mega Man V (GB), Mega Man Zero (GBA), Battletoads (NES)
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 08, 2008, 07:30:19 am
Maxim Said:
I'm not sure a jar helps, since it still needs to be in the right directory and to have loads of commandline options passed in.



java -jar TileMapReconstructor.jar "Jungle_" 3 32 32 "Donkey Kong Country (U) (V1.0) [!].smc" 0x190000 168 16 "Jungle Hijinx.png"



Reading Giangurgolo's documents, it seems the water levels are encoded differently and will need a modified program to be dumped.

Oh yes, I forgot to mention that. That's why I had the * in my first post but never explained why.. Sorry about that.

And Slipslide ride is sequenced in rows, too.
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 08, 2008, 08:51:06 am
I'll try to mod it tonight if I get a chance. It's just a simple switch between column-wise and row-wise processing.



I think making it totally generic will be very hard, unfortunately, but the code is hopefully simple enough that it can be adapted for other games. Many games work in a similar way.
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 08, 2008, 09:10:05 am
Hey, that'd be great.

And yeah, a similar format is really common, but what amazed me the most was that a SNES-game used it.
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 08, 2008, 11:52:07 am
Can you point me at tile images and offsets for these horizontally-stored stages? I can't really make it without being able to test it.
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 08, 2008, 12:34:47 pm
Oh, right..!

Well, I've got my entrance exam for an art university tomorrow morning, and it's 21:32 now. It starts 9 o' clock and ends at 4 PM, so I'll get to ripping the tiles in... 19 hours or so.
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 08, 2008, 12:38:35 pm
...by which time, I'll be on a plane. So don't expect a response until Tuesdayish.
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on May 11, 2008, 05:47:14 am
Wow.... it's probably just me but this does look really complicated for me... I know nothing about Java (well I know what Java is but I don't now how to erm.. "use it")...



*coughmakemoremapsnaoorillgomadlolcough* <_< just kidding <_< Nah... I don't want this to go down like the DKL2 topic >_> <_<
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 15, 2008, 12:11:45 pm
Project discontinued under extreme discouragement

http://www.dkc-atlas.com/dkc/maps/1-1.php

Title: RE: Donkey Kong Country maps revisited
Post by: TerraEsperZ on May 15, 2008, 01:03:47 pm
That's too bad, but at least all the maps will be available some day, hopefully. Hope you have something else to fall back on as far as mapping is concerned (unless you're a more balanced person than me without a compulsive need to map games) :)



---

"With the first link, the chain is forged. The first speech censored, the first thought forbidden, the first freedom denied, chains us all irrevocably." [...] The first time any man's freedom is trodden on, we're all damaged. - Captain Jean-Luc Picard



Current projects: Sonic CD (Sega CD), Mega Man V (GB), Mega Man Zero (GBA), Battletoads (NES)
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 15, 2008, 02:27:47 pm
Huh? Well, their tool does everything you wanted, their maps are incomplete and not in the more standard just-a-PNG-file format... why not use their tool to finish the job?
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on May 15, 2008, 02:31:05 pm
By extreme discouragement, do you mean people discouraging you, or do you actually mean extreme lack of ENcouragement?
Title: RE: Donkey Kong Country maps revisited
Post by: JonLeung on May 15, 2008, 04:56:13 pm
I think we've had our fill of your personal encouragement on Donkey Kong maps, Ultimate Koopa.  :P



I'm guessing Raccoon Sam was disappointed that someone beat him to the punch.



And yet, as Maxim said, their maps are incomplete...
Title: RE: Donkey Kong Country maps revisited
Post by: Maxim on May 15, 2008, 07:25:07 pm
Well, here's the output from the DKC Resource Extraction Tool over on DKC Atlas:



User posted image



Obviously there's still work to be done before submitting them. I won't be the one who does it...
Title: RE: Donkey Kong Country maps revisited
Post by: Revned on May 15, 2008, 11:13:11 pm
If I weren't so busy lately I'd definitely lend a hand in assembling these. It looks very doable now.
Title: RE: Donkey Kong Country maps revisited
Post by: Raccoon Sam on May 16, 2008, 05:29:40 am
Yeah, by discouragement I meant that I feel a bit pushed down upon finding someone who already made a superior tool and obsoleted our promising start. They say it's a work in progress and updates sporadically.

But hey, we still could do a VGMaps exclusive I guess. I don't think they'd want us to go and take the maps from their site.
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on May 28, 2008, 03:39:16 pm
About the DKC Resource Extraction Tool... when I tried to generate the level maps, it just crashed... is this yet another one of those "I really shouldn't have brought that tripe that is... Vista" things?
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on June 17, 2008, 02:42:31 pm
... I was going to post about the fact that the program crashes, but I see I already mentioned it... however, I tried it again, but it still crashed, or "stopped working". Is it simply a "Vista-related" thing?
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on June 18, 2008, 06:00:33 pm
I know there's an edit feature, but that doesn't "bump" it. Now, please, I know you hate DKC, but can you tell me WHY it crashes when I try and generate the level maps? And if you don't know, then at least say you don't know, so I KNOW, please?
Title: RE: Donkey Kong Country maps revisited
Post by: Rew on June 18, 2008, 07:45:43 pm
I would help, but...I honestly don't know. But at least now you know. =P



---

"So this is what it's like..."

- Spark Mandrill
Title: RE: Donkey Kong Country maps revisited
Post by: The Ultimate Koopa on June 19, 2008, 05:59:20 am
<_< but I'd still prefer it if someone DID know... but at least I know people haven't totally ignored this.