spheredev / neosphere

A lightweight game engine and development platform using JavaScript for game coding, based on the original Sphere engine by Chad Austin but with a redesigned, modern API and brand-new command-line development tools.
http://www.spheredev.org/
Other
106 stars 15 forks source link

Implement some missing Sphere 1.5 APIs #168

Open fatcerberus opened 7 years ago

fatcerberus commented 7 years ago

The following Sphere 1.5 functions and methods are missing as of miniSphere 4.7.0 and need to be implemented for full legacy compatibility:

fatcerberus commented 7 years ago

As luck would have it, #167 doesn't apply to Surface#lineSeries() because there are no implicit transformations involved when rendering to a legacy Surface. Coordinates always match 1:1 with surface pixels, unlike with the screen which can be scaled up so that logical pixels != real screen pixels.

fatcerberus commented 7 years ago

I implemented the surface blit functions, but ended up creating a lot of duplicate code in the process. At some point it would be good to go through vanilla.c and refactor to remove some of the duplication. The current state of it is a breeding ground for bugs.

fatcerberus commented 7 years ago

While CreateSpriteset() is not a release blocker (as noted above), there are other inconsistencies between the miniSphere and Sphere 1.x implementations of spritesets that should be reconciled before a release is done. So that would be a good opportunity to get the missing function out of the way, too.

fatcerberus commented 7 years ago

Scratch that, spritesets are going to have to stay incompatible for a bit longer, as the fix turned out to be non-trivial. See https://github.com/fatcerberus/minisphere/issues/175#issuecomment-312545124.

fatcerberus commented 7 years ago

All blockers for 4.6.0 have been implemented; reassigning the remaining functions to v5.0.0.

fatcerberus commented 7 years ago

With #175 now fixed, I can move forward with implementing CreateSpriteset().

fatcerberus commented 7 years ago

I added stubs for the missing APIs to throw a "not implemented" error when called. Hopefully this should clear up the confusion so people stop reporting bugs for "(function name) is undefined" upon attempting to call a missing function. "Not implemented" makes it very clear what's wrong. :o)

fatcerberus commented 7 years ago

I'd like to tackle GetMapEngine() and MapEngine#save() next. That means code needs to be written to save an .rmp file, but seeing as I already have code to load them (which is pretty hairy, gotta be honest :o), saving should be trivial by comparison.

I will need to consult the Sphere 1.x source to see exactly what needs to be saved, though. Obviously zones and triggers, but I'm not sure how 1.x handles persons in this case since internally they are tracked independently from the map.

fatcerberus commented 7 years ago

The code surrounding GetMapEngine().save() in Sphere 1.x is all over the place and doesn't seem to be very well-thought-out. Best I can tell it's also pretty buggy: Changes to tiles are saved, any zones added seem to be kept, but entity changes (new triggers or persons, e.g.) are lost in favor of just saving whatever was there when the map was loaded.

Long story short, I'm just going to wing it because the Sphere 1.x map saving logic is... odd.