3D rendering: Difference between revisions
Marius851000 (talk | contribs) |
Marius851000 (talk | contribs) Improved syntax and some typo |
||
| Line 1: | Line 1: | ||
== 3D Rendering engine == | == 3D Rendering engine == | ||
The Nintendo DS dispose of hardware that can perform 3D rendering in addition to | The Nintendo DS dispose of hardware that can perform 3D rendering in addition to its dedicated 2D system. EoS mostly use the 2D system, but occasionally make use of the 3D engine for some effects. Those are: | ||
* The dialogue box border and background | * The dialogue box border and background | ||
| Line 7: | Line 7: | ||
* Boss transition wipe | * Boss transition wipe | ||
* A few other effect during cutscenes | * A few other effect during cutscenes | ||
| Line 14: | Line 12: | ||
The 3D engine is capable of rendering in 2D, simply by rendering rectangle in front of the virtual camera, which is what EoS always does. The way this game work is by first buffering the elements to render to a buffer and then a function will submit those to render (probably during VBlank), which will then take effect on the next frame. | The 3D engine is capable of rendering in 2D, simply by rendering rectangle in front of the virtual camera, which is what EoS always does. The way this game work is by first buffering the elements to render to a buffer and then a function will submit those to render (probably during VBlank), which will then take effect on the next frame. | ||
The 3D | The DS 3D hardware can only render on the main screen, which in EoS is the bottom screen. Some game (but not EoS) render on both screen by switching the main screen every frame, dividing by two the frame rate from 60 to 30 FPS. | ||
=== Memory management === | |||
The bank D is dedicated to storing the textures used for the 3D render, and bank F is used to store the palettes. Bank D is 128KiB large, and bank F is 16KiB large. The game seems to mostly allocate texture on a multiple of 1KiB, and palette on a multiple of 0x100 bytes, thought it is possible to perform allocation not aligned on those arbitrary values (but it still (maybe, untested) need to be 4-bytes aligned). | |||
The game store its 3D data in WTE files. It contain the texture and the palette, but not where the file will be stored in the RAM, which is specified in the game’s code. Here is table of the (known) allocation the game make. It is probably exhaustive. | The game store its 3D data in WTE files. It contain the texture and the palette, but not where the file will be stored in the RAM, which is specified in the game’s code. Here is table of the (known) allocation the game make. It is probably exhaustive. | ||
ProcessWTE is the function used to load them ( | ProcessWTE is the function used to load them (function address is for EU ROM, but palette and texture allocation have no reason to be different). | ||
{| class="wikitable" | {| class="wikitable" | ||
|+ | |+ | ||
| Line 87: | Line 83: | ||
|0x400 | |0x400 | ||
|0x200 | |0x200 | ||
|which one depend on language | |which one is loaded depend on language | ||
|- | |- | ||
|c_wipe.wte or w_wipe2.wte | |c_wipe.wte or w_wipe2.wte | ||
| Line 100: | Line 96: | ||
|w_heart.wte | |w_heart.wte | ||
| | | | ||
|multiple hearts | |multiple hearts symbol, filled and shaded | ||
|0x0206b000 | |0x0206b000 | ||
| | | | ||
| Line 127: | Line 123: | ||
|d04p31t1.wte | |d04p31t1.wte | ||
|overworld | |overworld | ||
|waterfall cave diamond | |big wave of the waterfall cave diamond | ||
|overlay_11::02314b9c | |overlay_11::02314b9c | ||
|0x0 | |0x0 | ||
| Line 153: | Line 149: | ||
| | | | ||
|- | |- | ||
|frameX.wte (where X is | |frameX.wte (where X is between 0 to 4) | ||
|both | |both | ||
|dialog box frame | |dialog box frame | ||
| Line 189: | Line 185: | ||
| | | | ||
|} | |} | ||
Based on those allocations, it seems that VRAM from 0x11000 to 0x1EFFF (included) are free to be used both in overworld and dungeon. For the palette, it seems everything from 0x300 to 0x13FF (included) are unused. | |||
==== Loading texture ==== | ==== Loading texture ==== | ||
Once you have your texture in the WTE format saved in the rom, you need to call a function to load WTE ('''LoadWteFromRom''') and then copy stuff to RAM with '''ProcessWTEWrapper''', and then call another (unnamed) function '''DoSomethingOn3dAllocAndClearInput'''. | Once you have your texture in the WTE format saved in the rom, you need to call a function to load WTE ('''LoadWteFromRom''') and then copy stuff to RAM with '''ProcessWTEWrapper''', and then call another (unnamed in pmdsky-debug) function '''DoSomethingOn3dAllocAndClearInput'''. | ||