News:

11 March 2016 - Forum Rules

Main Menu

Castlevania - SotN Editor

Started by KernelEquinox, August 04, 2022, 08:13:20 PM

Previous topic - Next topic

VincentNL

Quote from: KernelEquinox on August 12, 2022, 06:24:35 PMI updated the Export PNG button to now export entities as well as map tiles, with the option to keep or remove the rectangles around the entities.

Map exported without entity boxes

Map exported with entity boxes

I also noticed something odd when looking through the maps. Apparently, the Anti-Chapel has a weird candle located out of bounds just below the long staircase at the top-right of the map. (ignore the overlapping parts in the tower areas, I haven't fixed that just yet)


I checked and it's definitely there in game, it just has a heart in it. I'm guessing it's been found before, but I still found it interesting.


I've also begun working out the layout for the rework, but I'm hopeless when it comes to UI design. I'll try to make it as usable as possible though.
I love this kind of leftover secrets, hopefully there'll be more of them!

Thanks for your great work  :thumbsup:

KernelEquinox

Just a quick update this time around, I've been working diligently on the C++ rewrite. It's definitely a more comfortable environment for me to work in compared to C#. The code is very unoptimized at the moment, but the results are staggering at how much more efficient and snappy this program is going to be.

For example, when loading the NO3 map (the castle entrance), the MIPS emulator took approximately 10.97 seconds to fully execute all of the entity functions for each entity in the map. With the C++ rewrite however, it fully executes every entity function in approximately 0.254 ms, resulting in a whopping 43,000x speedup. In addition, I've made a few changes to make the MIPS emulator both more accurate and more reliable.

Much of the work so far has been creating the architecture for the program, deciding how memory will be managed, creating the basic structures of the program to support the new planned features, and all of the other Fun Stuff™ that comes with these kinds of projects.

That being said, there hasn't been much work on the UI yet. However, this is what it looks like currently.


In addition, I've been researching and reverse engineering everything about the game from scratch so that I can write the documentation as technically accurate as possible, covering both what's already been documented and what I couldn't find anywhere else. Instead of a TXT or PDF file however, I've decided to make a site called sotn.dev where the documentation will be hosted.

Development is coming along very well though. I may not have any usable builds to release for a while, but I'll keep this thread updated with any new information.

MysticLord

He probably knows already, but you should let paul_met know about this. Ditto for Gemini. Both of them worked on Castlevania SOTN in the past, and could probably tell you a lot about it.

Landon Ray made a mod for it too.

http://ngplus.net/index.php?/forums/topic/1129-mod-updates/&;

pleasejust

Thanks for the link MysticLord, I didn't even know Landon was still around. Kernel, that sounds great. Looking good  :thumbsup:

Xeeynamo

That looks amazing! Congratulations for the results you got. Showing the sprites and the object names is the hardest part as you need to process some MIPS code. But I see you made it anyway. Any plans to make the C++ version open source? I am so curious to look into it.

Not sure if it is known, but I am working on a SOTN Decomp and I have been mainly reversing the entity system and how objects are initialized. The idea is also to split data and code to make possible to easily expand or create entirely new areas as pointers will easily be re-calculated. At some point would like to add support to load and save split files into your editor.

I'll be following your project from now on!

KernelEquinox

Quote from: Xeeynamo on August 22, 2022, 05:00:54 PMThat looks amazing! Congratulations for the results you got. Showing the sprites and the object names is the hardest part as you need to process some MIPS code. But I see you made it anyway. Any plans to make the C++ version open source? I am so curious to look into it.

Thanks, the MIPS emulator was something I was dreading for a while, but it wasn't as bad as I was expecting. In C++ anyway, because it was a nightmare coding it in C#. But yes, I am planning to make it fully open source. After I get it to the point where SNEER's development left off (i.e. displaying maps and entities), I'll upload the source code to GitHub while continuing to improve it and add new features to it.

Quote from: Xeeynamo on August 22, 2022, 05:00:54 PMNot sure if it is known, but I am working on a SOTN Decomp and I have been mainly reversing the entity system and how objects are initialized. The idea is also to split data and code to make possible to easily expand or create entirely new areas as pointers will easily be re-calculated. At some point would like to add support to load and save split files into your editor.

I'll be following your project from now on!

I actually used your sotn-decomp project for determining whether there were any similar sections across map files before I decided to start decompiling the game locally for research purposes. All of my reverse engineering notes will be posted on sotn.dev once I get time to collect them all, but I've mostly been working on the C++ program during my spare time. Most of my notes aren't very useful at the moment since they currently consist of a TXT file and a lot of Ghidra work. For example, this is what the header of every map looks like:


Note that some maps may have certain pointers nulled out, such as SEL (the Main Menu screen), which has no defined rooms, entities, or tile layers. All of this will be in the documentation in a much more digestible format.

As far as updates go, the program can now parse most of the maps and their layers without any issue. Below are examples of NO3 and ST0 as viewed in the program. It only shows the basic layers at the moment since I haven't implemented entity parsing or special handling for the load/save rooms.

NO3 (Castle Entrance)

ST0 (Final Stage: "Bloodlines")

Development has been going strong, but I think I might take a break from development for a bit in order to focus more on the documentation.

gledson999

Quote from: KernelEquinox on August 11, 2022, 10:49:03 PMI've finished implementing parsing for the save rooms and load rooms, and it should now be able to parse most entities and their sprites at this time. It also shows the names of items, relics, and enemies when hovering over the entity.



There are still some things that need to be looked into further though, such as Slogra and Gaibon's sprites not showing up, and I still need to analyze the logic for the red/blue doors.

There's also an odd issue concerning the the lamps in the Library and Reverse Library maps, but I haven't looked much into it just yet. It only shows the flame since the flame itself is composed of only a single sprite, but it doesn't show the surrounding lamp.


Development's coming along pretty well though, all things considered.



That brings me to my next point: I'm considering rewriting SNEER from the ground-up in C++.

SNEER was originally written in C# using the Microsoft XNA framework, and it's what I've been using to build off of it in order to make these modifications. However, C# is incredibly verbose and painfully slow for this purpose, especially when it comes to the MIPS processor.

On the other hand, I'm much more comfortable working in a C/C++ environment, and the MIPS processor (and the program in general) would be significantly more performant being written in C++. In addition, the GUI would be much more modular and aesthetically pleasing with many more possibilities for displaying technical information.

I'll get the current version of the program to a presentable state and then push the code to GitHub, after which I may begin work on the rewrite.

Your initiative is very good, it will be a great, is there a recently compiled version 0.20 to public?

KernelEquinox

#27
Quote from: gledson999 on August 25, 2022, 02:24:21 PMYour initiative is very good, it will be a great, is there a recently compiled version 0.20 to public?

The only public version of the reverse engineered SNEER project is v0.15b, which you can find here.

There won't be any further releases of the reverse engineered SNEER project since I decided to completely rewrite it in C++.

The new project will (tentatively?) be called "SotN Editor", and it will be uploaded to GitHub as soon as all of the functionality in the reverse engineered SNEER project is implemented in the program, which is actually very close to happening.


So far, SotN Editor has the following capabilities:

  • Parses map headers
  • Parses room data
  • Parses sprite data
  • Parse entity CLUTs
  • Parses entity layout data
  • Parses map layers
  • Parses entity graphics data
  • Loads tilesets and tile CLUTs from F_*.BIN
  • Has a MIPS emulator created for the sole purpose of parsing entity data
  • Displays all normal rooms in the map with the ability to pan around and zoom in/out
  • Stores all of the loaded data in a modular manner to better facilitate modifications using fine-grained control over data and parameters


There are currently a few bugs I need to fix and features I need to implement before publishing the code, such as:

  • (Bug) Some maps have very few tiles that are incorrectly offset or that scroll with the viewport
  • (Todo) Actually process the entity functions with the MIPS emulator
  • (Todo) Display entities on the map
  • (Todo) Handle and display the CD/save rooms
  • (Todo) Display the room's data in a tooltip when hovering over a room
  • (Todo) Display the entity's data in the Properties window when an entity is clicked
  • (Todo) Implement native file open dialogues if possible
  • (Todo) Add a minimap somewhere that can also be used to quickly pan the map


Aside from the action items listed above, the program is actually in very good working order and is stable for every map except for SEL, which is arguably not even a "map" itself.

All of the tiles are also displaying their own textures, which means that there can be upwards of a few hundred thousand draw calls when the map is zoomed out to where the entire map is visible in the viewport.

This doesn't cause any issues currently, but I may optimize the draw calls for the main viewport. There will be also be a room editor in the program, which won't be affected by rendering every tile as its own texture since it would only be for that individual room.

KernelEquinox

Just another small update, I've put a few of the symbols for the PSX RTL on sotn.dev since it was looking a bit barren.

MottZilla

Fantastic work KernelEquinox. Glad to see someone is working on a new editor and documentation.

KernelEquinox

Apologies for the lack of updates, things have been busy on my end.

There are only relatively few things I still need to implement (and fix) in order to bring reasonably complete map viewing functionality to the SotN Editor.

SotN Editor interface

Undocked map viewer

Below is a brief list of the new features:

  • Clicking on an entity shows all of the entity's data
  • Optimized entity loading functionality
  • Now handles dynamically-allocated entities
  • Scrolling now pans vertically and horizontally around the map
  • Implemented sprite blend modes
  • Added BLTZ/BGEZ instructions that I forgot to implement
  • All function calls are now emulated by the MIPS emulator (as opposed to only the map functions)
  • The + and - keys zoom in and out, respectively
  • Added a Room Editor tab that does absolutely nothing (for now)

I still need to tweak the blend mode logic so that Flea Armors don't look like they're phasing out of existence and properly parse a few entities that aren't currently being displayed, such as the bells in the Royal Chapel. The CLUT for the reverse castle's Save room also displays incorrectly. The last thing I want to address is overlapping rooms so that the editor won't write tiles to locations where tiles were already written.

Aside from those, I believe it'll be ready to go fully open source after tidying up the code.

KernelEquinox

This isn't really an update on the SotN Editor itself, but I felt it appropriate to post this here since I noticed it while reverse engineering SotN and I'm pretty sure this is a new discovery.

I came across debug functionality in SotN that allows you to view the hitboxes of entities, such as those for Alucard, enemies, pickups, breakables, projectiles, attacks, etc.

The only caveat is that one of the two flags required for enabling this functionality is hardcoded to be disabled. However, this functionality can be fully restored by setting two flags to a non-zero value.

Below is a Gameshark code that can be used to enable this functionality.

800BD1C0 0001
801362B0 0001

I looked online, but I couldn't find any mention of a similar functionality, although I am familiar with a Lua script that does something similar. With this finding, functionality similar to the Lua script can be achieved natively in-game without having to use an emulator with Lua support.

Below are a few screenshots showing this functionality in action.

Stone Rose hitbox

Mist hitbox

Hitboxes for Dodo Bird's feathers

VincentNL

Quote from: KernelEquinox on September 09, 2022, 10:21:16 AM
Hitboxes for Dodo Bird's feathers
Fantastic!

Are there any debug Print functions in the game?

KernelEquinox

Quote from: VincentNL on September 09, 2022, 10:26:15 AMFantastic!

Are there any debug Print functions in the game?

There are debug print functions in the game, both via printf() to stdout and as a visual print to the screen.

For example, if decompression fails for any reason, then the game will display text on screen that shows the address of the data that failed to decompress alongside the error code returned by the decompression function.

Pressing any buttons dismisses the screen and the game continues execution normally from that point.

Error code displayed after a failed decompression

VincentNL

Very interesting thanks for sharing!
Except for specific errors,any sort of debug menu strings?

Keep up with the awesome work!

KernelEquinox

Quote from: VincentNL on September 10, 2022, 09:37:39 AMVery interesting thanks for sharing!
Except for specific errors,any sort of debug menu strings?

Keep up with the awesome work!

There's no indication of any debug menu left in the code that I could find. I haven't analyzed all of the calls to AddPrim, etc. though, so I can't say for certain there's no additional debug functionality.

I thought I may have found debug functionality about a week ago. There was a function that started the game at the post-Richter fight dialogue just before entering the Reverse Castle for the first time. However, the cutscene didn't play after warping to the Reverse Castle. Additionally, all items were inserted in the inventory and all relics were unlocked, as well as each familiar entry, including the Sprite and Nosedevil familiars with Japanese text for their names.

However, further inspection showed that the aforementioned function was also called when setting up the game for viewing any of the Tactics entries when speaking with the Master Librarian. The scenario referred to previously is effectively a Tactics entry with the index 0x4B. Interestingly, you gain full control over Alucard after warping.

VincentNL

Quote from: KernelEquinox on September 10, 2022, 03:22:33 PMThere's no indication of any debug menu left in the code that I could find. I haven't analyzed all of the calls to AddPrim, etc. though, so I can't say for certain there's no additional debug functionality.

I thought I may have found debug functionality about a week ago. There was a function that started the game at the post-Richter fight dialogue just before entering the Reverse Castle for the first time. However, the cutscene didn't play after warping to the Reverse Castle. Additionally, all items were inserted in the inventory and all relics were unlocked, as well as each familiar entry, including the Sprite and Nosedevil familiars with Japanese text for their names.

However, further inspection showed that the aforementioned function was also called when setting up the game for viewing any of the Tactics entries when speaking with the Master Librarian. The scenario referred to previously is effectively a Tactics entry with the index 0x4B. Interestingly, you gain full control over Alucard after warping.
Sounds like a base function to allocate full items/relics for Tactics, unless item/relic presets are based on register / data table.
Either way it's pretty cool :)

MottZilla

#37
Quote from: KernelEquinox on September 10, 2022, 03:22:33 PMAdditionally, all items were inserted in the inventory and all relics were unlocked, as well as each familiar entry, including the Sprite and Nosedevil familiars with Japanese text for their names.

However, further inspection showed that the aforementioned function was also called when setting up the game for viewing any of the Tactics entries when speaking with the Master Librarian. The scenario referred to previously is effectively a Tactics entry with the index 0x4B. Interestingly, you gain full control over Alucard after warping.

If you skip the Richter level at the beginning of the game by changing the starting map, Alucard will have those stats and inventory setup. The function that sets up Alucard's normal starting inventory and stats is called somewhere after Richter defeats Dracula in the prologue. Maybe during or after the story screen with the castle and moon. I noticed this when looking to see how easy it would be to skip that whole intro level and get right to Alucard.

Update: I checked this again, and it is possible to skip the prologue and it seems that when loading the zone for the initial Castle entry is when the Inventory and such is initialized.

KernelEquinox

I just wanted to give a brief update that I've updated the title of the thread as well as the main post.

I've also released the source code for the program on GitHub, which you can find here: https://github.com/KernelEquinox/SotN-Editor.

the_E_y_Es

Wow, this thread made me log in.

Quote from: pianohombre on August 06, 2022, 11:03:30 PMI wish we could like a post instead of having to comment
I second this.

Keep it up, @KernelEquinox.