Author Topic: Donkey Kong Country maps revisited  (Read 40178 times)

0 Members and 1 Guest are viewing this topic.

Offline Raccoon Sam

  • Full Member
  • ***
  • Posts: 119
Donkey Kong Country maps revisited
« on: May 03, 2008, 09: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.

Offline The Ultimate Koopa

  • Hero Member
  • *****
  • Posts: 509
RE: Donkey Kong Country maps revisited
« Reply #1 on: May 03, 2008, 01:43:45 PM »
Cool :D

Offline Revned

  • Hero Member
  • *****
  • Posts: 1093
RE: Donkey Kong Country maps revisited
« Reply #2 on: May 03, 2008, 02: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?

Offline JonLeung

  • Administrator
  • *****
  • Posts: 3378
RE: Donkey Kong Country maps revisited
« Reply #3 on: May 03, 2008, 03: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)

Offline Raccoon Sam

  • Full Member
  • ***
  • Posts: 119
RE: Donkey Kong Country maps revisited
« Reply #4 on: May 03, 2008, 04: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.)

Offline RT 55J

  • Sr. Member
  • ****
  • Posts: 450
RE: Donkey Kong Country maps revisited
« Reply #5 on: May 03, 2008, 04: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


Offline The Ultimate Koopa

  • Hero Member
  • *****
  • Posts: 509
RE: Donkey Kong Country maps revisited
« Reply #6 on: May 04, 2008, 04:41:45 AM »
Why, Jon do you always have to mention something to do with me? <____< XD

Offline Raccoon Sam

  • Full Member
  • ***
  • Posts: 119
RE: Donkey Kong Country maps revisited
« Reply #7 on: May 04, 2008, 10: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.


Offline Maxim

  • Hero Member
  • *****
  • Posts: 974
RE: Donkey Kong Country maps revisited
« Reply #8 on: May 05, 2008, 05: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)

Offline Raccoon Sam

  • Full Member
  • ***
  • Posts: 119
RE: Donkey Kong Country maps revisited
« Reply #9 on: May 06, 2008, 12:36:56 PM »
All the necessary stuffs sent.

Offline Maxim

  • Hero Member
  • *****
  • Posts: 974
RE: Donkey Kong Country maps revisited
« Reply #10 on: May 06, 2008, 10: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.)

Offline The Ultimate Koopa

  • Hero Member
  • *****
  • Posts: 509
RE: Donkey Kong Country maps revisited
« Reply #11 on: May 07, 2008, 03:49:53 AM »
Yay!



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



OK, seriously I won't do that again.

Offline Rew

  • Full Member
  • ***
  • Posts: 212
RE: Donkey Kong Country maps revisited
« Reply #12 on: May 07, 2008, 07: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
From the Super Smash Bros. Brawl board on GameFAQs:
Quote
The only Fox News we're interested in is breakthroughs in his metagame.

Offline Maxim

  • Hero Member
  • *****
  • Posts: 974
RE: Donkey Kong Country maps revisited
« Reply #13 on: May 07, 2008, 01: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...

Offline Maxim

  • Hero Member
  • *****
  • Posts: 974
RE: Donkey Kong Country maps revisited
« Reply #14 on: May 07, 2008, 02: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.