diff --git a/ASSETS_README.md b/ASSETS_README.md new file mode 100644 index 00000000..2fc9081d --- /dev/null +++ b/ASSETS_README.md @@ -0,0 +1,252 @@ +# DKR Assets + +This document explains the different kinds of assets in Diddy Kong Racing. + +The assets folder is not included within the repository itself, but rather extracted from a vanilla Diddy Kong Racing ROM file. You will need to provide your own ROM file and place it within the `/baseroms/` directory. + +## Structure of the assets folder + +``` +assets/ + us_1.0/ + animations/ | All the animations used by 3D models. + audio/ | All the instruments, sound effects, and music tracks. + billboards/ | Information for the 2D billboards. + bin/ | All the unknown/miscellaneous files. + cheats/ | All of the "Magic Codes" and their descriptions. + fonts/ | Information on the 4 fonts used in the game. + levels/ | Level headers, names, models, and object maps + objects/ | Object headers and models. + particles/ | Information on particles and their behaviors. + text/ | Tables containing game & menu text. + textures/ + 2d/ | Textures used by Fonts/Sprites/Billboards. + 3d/ | Textures used by 3D models. + tt_ghosts/ | Information on the T.T. ghost for the 20 main tracks. + ucode/ | RSP Microcodes +``` + +## File types + +``` +.bin: Standard binary file. +.cbin: Binary file that will be compressed during building. +.cheats: Formatted text file for the magic codes. +.png: Image file used for textures. +``` + +## Asset types + +### Animations + +No notes have been created at this time. However, according to SubDrag, the format itself is simple. Click the image below to see his video. + +[![Diddy Kong Racing Animations](https://img.youtube.com/vi/aFByZEBA-4E/0.jpg)](https://www.youtube.com/watch?v=aFByZEBA-4E) + +TODO: More notes are needed. + +--- + +### Audio + +Currently, the instruments, sound effects, and songs are all part of the giant 3.85 MB `audio.6cc230.bin` file. This is because the offsets for all the look-up tables are relative to the rom offset `0x6CC230`, so I thought it would be confusing to seperate the bin files. + +| Table name | offset in file | +|--- | --- | +|Instruments | 0xBACC | +|Sound effects | 0xC7AEC | +|Music tracks | 0x38E44C | + +The `audio_header.6cc1f0.bin` file contains a table with offsets to different parts of the`audio.6cc230.bin` file. + +TODO: More notes are needed. + +--- + +### Billboards + +The billboard files contain information on the textures and positioning. + +| Offset | Type | Description | +|--- | --- | --- | +|0x00 | u16 | Starting texture index | +|0x02 | u16 | Number of textures | +|0x04 | u16 | X/Width coordinate? | +|0x06 | u16 | Y/Height coordinate? | +|0x08 | u32 | Unknown | +|0x0C | u8[] | Texture indicies, length varies based on the number of textures | + +TODO: More notes are needed. + +--- + +### Bin + +Directory that contains unknown/uncategorized files. + +--- + +### Cheats + +The magic codes are encrypted in the ROM by moving the bits around every 4 bytes in the file using this symmetric algorithm: https://pastebin.com/raw/d875C5LV + +The `magic_codes.3833a0.cheats` file contains all the magic codes in the game along with the description of the cheat. Once the ROM becomes shiftable, then adding in new cheats will be as simple as adding a new line to this file. Do note that the game can only support up to 32 cheats. + +``` +"1058732594", "Control T.T." +"8649305321", "Control Drumstick" +"0986754321", "Mirrored tracks" +"1234567890", "High Speed Racing" +"ARNOLD", "Big Characters" +"TEENYWEENIES", "Small Characters" +"JUKEBOX", "Music Menu" +"FREEFRUIT", "Start With 10 Bananas" +"BLABBERMOUTH", "Horn Cheat" +"8846325012", "Print coords" +"WHODIDTHIS", "Display Credits" +"BYEBYEBALLOONS", "Disable Weapons" +"NOYELLOWSTUFF", "Disable Bananas" +"BOGUSBANANAS", "Bananas Reduce Speed" +"VITAMINB", "No Limit To Bananas" +"BOMBSAWAY", "All Balloons are Red" +"TOXICOFFENDER", "All Balloons are Green" +"ROCKETFUEL", "All Balloons are Blue" +"BODYARMOR", "All Balloons are Yellow" +"OPPOSITESATTRACT", "All Balloons are Rainbow" +"FREEFORALL", "Maximum Power Up" +"ZAPTHEZIPPERS", "Turn Off Zippers" +"DOUBLEVISION", "Select Same Player" +"OFFROAD", "Four Wheel Drive" +"JOINTVENTURE", "Two Player Adventure" +"TIMETOLOSE", "Ultimate AI" +"EOLAOBFENRLONE", "Free Balloon" +"EPC", "EPC Lock Up Display" +"DODGYROMMER", "ROM checksum" +``` + +--- + +### Fonts + +Contains information for the 4 fonts used by the game. You can find the textures for the fonts within the `/textures/2d/` directory. + +TODO: More notes are needed. + +--- + +### Levels + +There are 5 kinds of files (exluding the lookup tables): +* Level Names +* Level Headers +* Level Models +* Level Object Maps +* Level Object ID to Object Header translation table + +The level headers contain information to how the level is setup. It connects the level model, object maps, backgrounds, music, camera settings, etc. You can find some information about the header in [this old JUL post from 2011](https://jul.rustedlogic.net/thread.php?pid=357838#357838). + +The level models contain information to the 3D geometry and collision. +TODO: Link to more detailed documentation. + +A level object map contains a list of objects used in the level. The first 0x10 bytes is the header, and each object has a variable number of bytes determined by it's second byte AND'd by 0x7F. The ID of the object is determined by first byte OR'd with the highest bit within the second byte shifted left by 8. +TODO: Link to more detailed documentation. + +The level object id translation table (`level_object_translate_table.6cbde0.bin`) contains 512 u16 values. It is used to convert the 9-bit id number from the level object map into an object header ID. + +Level names aren't directly linked to the headers. There are the same number of names as headers, so I assume the level header ID is the same as the level name ID. + +TODO: More notes are needed. + +--- + +### Objects + +The objects folder has 2 main file types: + +* Object Headers +* Object Models + +Just like levels, the object header is used to define the attributes of an object. The object model format is somewhat similar to level models. +TODO: More notes are needed. Link to more detailed documentation. + +--- + +### Particles + +Contains information related to the different particles used by the game. The `particle` files relate to the textures used, and the `particleBehavior` files relate to how the particles behave. + +TODO: More notes are needed. + +--- + +### Text + +Contains the English, French, and German text for gameplay and the menus. + +TODO: More notes are needed. + +--- + +### Textures + +There are two different look-up tables relating to textures. There is one for the 3D models for levels & objects, and another for 2D billboards, fonts, etc. + +In this decomp every texture has it's own .png file with a specific filename. The filename is important for building. + +Examples: +``` +texture.0ecd50.CFS.00000008000.rgba16.png +texture.0fee30.8.CFS.00000000080.rgba32.png +texture.2b5990.CNZ.0140604D100.ia8.png +texture.2e3530.10.CNS.00000000000.rgba32.png +``` + +The filename format is: + +`.[.]....png` + +``` + = The name of the texture, currently just "texture" for all of them. + = The offset within the ROM file. + = Number of frames in an animated image. Optional. + = 3 characters determining different aspects about the texture. + Char 0: `C` if the texture is compressed, or `U` if not compressed. + Char 1: `F` if the texture should be flipped vertically, or `N` if not flipped. + Char 2: `S` if the texture size is computed in the header, or `Z` for zero. + = 5 1/2 hex bytes needed to recreate the texture header. + Hex digit 0: Upper 4 bits of header byte 0x02 + Hex digits 1-2: header byte 0x03 + Hex digits 3-4: header byte 0x04 + Hex digits 5-6: header byte 0x06 + Hex digits 7-8: header byte 0x07 + Hex digits 9-10: header byte 0x15 + = N64 texture format + rgba32: 8 bits red, green, blue, alpha (transparency) + rgba16: 5 bits red, green, blue, 1 bit alpha + i8: 8 bits grayscale, no alpha + i4: 4 bits grayscale, no alpha + ia16: 8 bits grayscale, 8 bits alpha + ia8: 4 bits grayscale, 4 bits alpha + ia4: 3 bits grayscale, 1 bit alpha + ci formats are currently not supported. +``` + +TODO: More notes are needed. + +--- + +### T.T. Ghosts + +Contains ghost data of T.T. for each of the 20 main tracks. The first byte is the level ID, and the second byte is the vehicle id (0 = car, 1 = hover, 2 = plane). + +TODO: More notes are needed. + +--- + +### Microcode + +DKR uses a modified version of Fast3D that draws lists of triangles instead of individual ones. + +TODO: More notes are needed. + +--- \ No newline at end of file diff --git a/README.md b/README.md index ff99c525..2ef22534 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Diddy Kong Racing -This repo contains a work-in-progress decompilation of Diddy Kong Racing for the N64. You will need to have a original copy of the ROM. +This repo contains a work-in-progress decompilation of Diddy Kong Racing for the N64. You will need to have a original copy of the ROM to extract the game's assets. Currently, only the US 1.0 version of the game is supported. US 1.1, EU 1.0, EU 1.1, and JP are not supported at this time. @@ -18,7 +18,6 @@ Currently, only the US 1.0 version of the game is supported. US 1.1, EU 1.0, EU `sudo apt install build-essential pkg-config git binutils-mips-linux-gnu python3 libssl-dev` - ## Setup 1. Place the ROM file within the `baseroms` directory. **a.** Any DKR ROM should work as long as it is US 1.0. @@ -35,6 +34,10 @@ If you see the message `Setup complete!`, then you are ready to build. To build the ROM, you just simply type in `make` in the main directory. You should see an `OK` at the end of the build if it worked correctly. The generated ROM file should appear in the `/build/` folder. +## Assets + +See the [ASSETS_README.md](ASSETS_README.md) file for more information on the assets within this decompilation. + ## Scripts There are some useful scripts that should be kept in mind when working on this repo. @@ -56,11 +59,11 @@ Note 2: The `/assets/` folder will get deleted if it already exists, so don't pu --- -#### `./rename_symbol.sh ` +#### `./rename_sym.sh ` -This script will rename an existing symbol within `undefined_syms.txt` and all the `.s` files within the `/asm/` directory. +This script will rename an existing symbol within the repo with a new one. -Example: `./rename_symbol.sh D_A4001000 SP_IMEM` +Example: `./rename_sym.sh D_A4001000 SP_IMEM` --- @@ -84,14 +87,15 @@ TODO: Add more things to the TODO list. What should be focused on. -* Determine and integrate the compiler used for the game. -* Determine all of the assets used, instead of just having unknown `.bin` files. +* Decompiling the asm files into matching c files. +* Split the asm files into smaller ones. This has been partially done, but nowhere near complete. ### Minor What can be done, but not essential. -* Split the asm files into smaller ones. This has been partially done, but nowhere near complete. +* Create file formats for all the assets files, instead of just having .bin files. +* Figuring out the unknown .bin files within the /assets/bin/ directory. ### Future diff --git a/asm/assets/assets.s b/asm/assets/assets.s index 5cbc226b..cde8f70a 100755 --- a/asm/assets/assets.s +++ b/asm/assets/assets.s @@ -4020,7 +4020,7 @@ .incbin "./build/objects/objHeader12D_MidiFadePoint.6cbc60.bin" .incbin "./build/objects/objHeader12E_LevelName.6cbce0.bin" .incbin "./build/objects/objHeader12F_Midichset.6cbd60.bin" -.incbin "./build/objects/level_object_translate_table.6cbde0.bin" +.incbin "./build/levels/level_object_translate_table.6cbde0.bin" .incbin "./build/bin/unknown.6cc1e0.bin" .incbin "./build/audio/audio_header.6cc1f0.bin" .incbin "./build/audio/audio.6cc230.bin" diff --git a/extract-ver/dkr-us-1.0.extract-config b/extract-ver/dkr-us-1.0.extract-config index 820974b0..81c16aa1 100755 --- a/extract-ver/dkr-us-1.0.extract-config +++ b/extract-ver/dkr-us-1.0.extract-config @@ -165,7 +165,7 @@ include: "extract-animations/animations-us-1.0.extract-config" include: "extract-objects/object_headers-us-1.0.extract-config" # [0x6CBDE0, 0x6CC1E0] = Level Object Map Id to Object Header Id translatation table. -[0x400]: "Binary", "level_object_translate_table", "objects" +[0x400]: "Binary", "level_object_translate_table", "levels" # ------------------------------------------------------- #