I have spent quite some time over the last week working on ‘Curse’ as my other project may have a conflict of interest, so I’m giving that the time it needs to unfold.
Reviewing my subversion log since my 22nd of March post, the following progress has been made.
- Copied large chunks of static data from the data section of the .exe and put it in the global section of the game engine. I had an idea of using reflection to dynamically load this from a bin file, but it was simpler to copy the data as it was required.
- Add EGA emulation, with correct write plan support, and colour palette swapping.
- Display mono colored text correctly, and positioned correctly.
- Inserted ~9000 throw new System.NotSupportedException(); in front of non-translated assembly, so I could translate code as it was hit. Edit-and-Continue is a blessing for this. You just have to remember to write the new code below the line that triggers the exception, so when you delete the exception, the instruction pointer (or what ever it’s called in the CLR) is now pointing at your new code not after it.
- Added keyboard input process, so System.Windows.Forms.Keys are converted to IBM keyboard scan codes, as expected by the game code.
- Started working on the Copy Protection code wheel icon display code. (This turned out later to be the generic icon display cache)
- Put a lock region around the access of the display bitmap, so avoid exceptions from the engine thread, and the main UI thread.
- Added more keyboard input support, once I worked out how the Word was been used (high word control code, low word ASCI code).
- Started working on the character generation code path. Translation of large amounts of assembly or big data tables.
- Completed the character generation, modification and leveling code.
- Finally worked out how the combat icons where stored in RAM and recoded all the access code to use new understanding.
- Recoded how the display stuff worked. Discovered locking bitmaps, and using System.Runtime.InteropServices.Marshal.Copy to do memory copies. This was such a huge speed improvement over SetPixel (which does a lock/unlock per pixel). It also allowed me to have yet another copy of the display picture. One for the EGA colour codes (to allow colour palette remapping), and a copy of the Windows video ram for direct coping. Besides the speed of the memory copy, this removed the odd multi-thread issue I was having.
- Completed the icon display cache, now that I had more examples of how it was used. Did a lot of refactoring (renaming) at this point, was there are three units of measurement, titles (24x24 pixels), cells(8x8 pixels) and pixels. Lots of this was confusing as there where 7 tables used to manage the icon display cache. All sorted now though.
- Rolled my on serialisation module, to allow for my classes based of original data structures, that have a lot of things that now use an int, when a byte was used, but to maintain compatibility, need to be saved/loaded as a byte. It was really learning how to use reflection.
- Translated ~4000 lines of assembly, about 5700 left.
- Fixed up quite a few memory location address name issues, cause by arrays have values index directly, so have unique names for both, but needing to point to the same location. This is where emulating the memory, and having it managed would have been nice. It would have also allowed me to put an layer, to find out what ranges array indices are index by, for overlaying purposes. There are a lot of places that Pascal non-zero based arrays have caused pain.
I’m currently working through the byte code engine in the game, trying to find my errors. So far they have mainly been of the last bullet point type. Gosh it is really fun working these things out though…