Saturday 23 March 2019

Siege of Avalon lifted

- or an example of migrating old source code to newer grounds.

Compiled with latest Delphi (10.3.1 Rio) - Nice inventory graphics.

This post is just about the few steps I did on migrating the Delphi 4 source of Siege of Avalon to Delphi 10.3.1, and the intentions and road-map I have proposed to the players and modders of this nice game.


Intentions and road-map for my fork of the GitHub repository - as proposed on a German forum
  1. Ensure that everyone can compile the original source with the newest free Delphi CE - which actually make it bearable to work with the source. DONE
  2. Clean up the source - remove rot. And different separation, to help move code to cross-platform. WIP
  3. Add the fixes, enhancements done by the great people who have gritted their teeth on the code previously.
  4. Add documentation on the assets file-formats used.
  5. Evaluate the tools - maybe redo/merge them - and include them in the repository.
  6. Replacing DirectX - with what makes better sense (SDL2 would be easiest) - might include the DDraw fixes in code as first step (getting rid of DDraw.dll).
  7. Cross-platform - that could be Windows, macOS, (Linux) and tablets (Android/iOS) - would need control overlays. Lowest priority since - clean code makes the rest easier.
Under the enhancements I refer to:

  • HD/FullHD support - but I think that should be optional (also keeping the original 800x600) - so either add a "launcher" or re-organizing the "Options"
  • Add a character/sex selector - again probably re-organizing the "Character Creator" dialog - Character in the center - male/female choices.
  • Mod selection - more DLC style - extendable instead of destructive copy/paste exercises.
  • Better multi-language support in the released source - right now it is crippled, like other parts of the UI code.

Backstory

Siege was open-sourced back in mid-2003, and at that time I grabbed the source with the intention to look into it some day.

Fast forward almost 16 years - and when Diablo was released on GOG.com (in corporation with Blizzard) two weeks ago - I remembered that I had the source laying about somewhere, found it and threw it on my private git server - where it should have been.

I then started to google about what had happened in the years gone by, finding that the proponent of the open-sourcing had put some of the original source, including an unfinished port to SDL and FPC on GitHub.

That had very recently been forked and picked up - compiled and working in Delphi 4 - with some else then adding support for higher resolutions screens, all based on the non-SDL code.

Process

So I thought that I could contribute to this project, I the way I would have liked it done - with focus on the code - so I did a fork of the Delphi 4 working repo - always building on the great shoulders of the people that came prior to us :)

Found my old CD of my Delphi 4 Enterprise - which in my opinion was the worst version of Delphi ever.

Ensured I could compile and play the game from that source - and the started to move the code to Delphi 7 and again Delphi 2007 until at last Delphi 10.3.1 Rio.

Apart from a bit of pointer fun and code clean-ups - it was fairly painless - the biggest pain was the changes that had happened in the Windows OS and DirectX area, breaking things and adding glitches - 2 days lost on that account :(.

So first goal achieved, the code is now able to compile in a free Delphi 10.3.1 Community Edition, to produce a fully working executable. Link to source code here.

There is still a lot of code cleanup to be done. The project is not trivial, and might take a bit of time - but it is just like eating an elephant - bit by bit - pun intended.

Why I did not try to fix the non-working FPC/SDL code

Order matters - both in the sense of keeping things tidy, but also in what order things are done to make it easier
  • Code that compiles and works is funnier to work with.
  • Based on working code you can refactor - otherwise it is bug fixing.
  • Based on working code you can enhance and add features - otherwise it is useless.
  • Getting clean working and accessible code invites others to contribute.
  • By having more to contribute everyone wins - that is what it is about.
  • Adding more platforms at this stages just adds more complexity - and more platforms to test and debug on.
  • The working code was originally written in Delphi 4, so moving it to the latest "open/free" Community Edition is to me the natural choice - that is what the Community Edition is supposed to be used for.
  • To me it is a very big difference to work in a Delphi 4/7/2007-like environment, and the latest modern version of Delphi.
  • Spending my time effectively.

And why not just port the code to C#/Go/Java/Python/Unity?


  • Well feel free, but to what purpose? Using the same assets and story, does not make it a better game - it could make it worse if the execution of the port is badly done. This game has sold worldwide - the original source is where to start.
  • The game does not benefit from it - unless you rewrite the engine, modernize the assets, but then you end up with a different game.
  • The engine is open-sourced, not the assets - so you can add new assets.
And should you not be aware; the Community Edition of Delphi - is free and feature-wise identical to the Professional edition which includes support for Windows, macOS, iOS and Android - you just need to keep your earnings with it below $5000 USD :) Get it here.

/enjoy

11 comments:

  1. "Code that compiles and works is funnier to work with."
    I think you mean "is more fun" here rather than "funnier".

    ReplyDelete
    Replies
    1. I mean "funnier" - even if the grammatical compiler will fail ;) It is more fun, and I can always say that English is not my native tongue. But thanks for point it out.

      Delete
    2. That would be: "pointing it out" :D Maybe I should get some rest.

      Delete
  2. This got me very excited!
    Are we talking about the same game as shown here?
    https://www.youtube.com/watch?v=TawEaozQCGo

    Now that I think of it, the Sulaco team ported both Doom and Quake 2 to Delphi back in the day. It could be interesting to clean these up and collect the games in a single repo on github.

    There is a lot of knowledge for young developers (and older) to pick up from game code. Would be brilliant to see these updated and made available today.

    Best regards

    Jon Lennart Aasenden
    Embarcadero

    ReplyDelete
    Replies
    1. Thanks Jon, Yes it is the game in the video.

      Yes game code can be more inviting than a sales order system, for "young" developers - even when I had computer class back in pre-80s - we wanted to make games - "guess a number" or "three-in-a-row" - would be great :D

      I am more the adventurous type - FPS/Arena type would not be something I would work on - but good idea to pickup the Sulaco stuff.

      Sorry for the late reply - seems my notification settings went with G+ :)

      Congratulations on the new job btw.

      BRGDS
      Steffen

      Delete
  3. Yes, it is. Currently testing the removal of the DFX DLLs, so no hidden binary dependency. This will also make 32bpp work. But progress is a bit on and off - since I do have other things on my plate. But look in the German SoAmigos forum - a mega-pack installer with all mods is available,around 4 gb data.

    ReplyDelete
  4. Hi Steffen!

    I'm sorry if this message seems horribly random. I stumbled upon Siege of Avalon: Anthology on Steam. It lists you, Digital Tome, and General Arcade as the developer and SNEG as the publisher. I'm messaging you out of curiosity for how and why the game is on Steam. For the life of me I cant find any information on who SNEG is and from what I've read of comments on places on the internet, no one was even aware that the game was going to come out on Steam. It's as if it just sort of appeared. Would you be able to shed any light on this to sate my curiosity? Thanks!

    ReplyDelete
  5. Is there an editor for PAX/IDX files? I installed the unofficial patch 1.4, which has the resources compiled into these archives without loose files. I want to change some images.

    ReplyDelete
    Replies
    1. I remember it as just being the resources as a memory stream and then the idx is well the index. I remember it similar to the .ag files from HeroX. Those I read in POXStudio. But I am not sure why you bother with the old 1.4 patch? We should be way past that with the GOG and Steam release.

      Delete