• HomeBoards
  • RulesRules
  • HelpHelp
  • WikiWiki
  • Donate

Author Topic: Post Apocalyptic Petra, a 3D adventure game  (Read 2216 times)

BadSector (OP)

  • Posts: 6
Post Apocalyptic Petra, a 3D adventure game
« on: December 01, 2020, 08:41:08 pm »
Hi all,

A few months ago there was a game jam for making MS-DOS games so i made a 3D adventure game in Free Pascal which i called "Post Apocalyptic Petra". It is somewhat similar to classic Tomb Raider 1 but without the shooting or major platforming (though there is a bit of platforming) and puzzles and exploration turned way up.

Here is a screenshot from the game itself (starting room):


So i decided to port it. The process wasn't that easy since even though i used SDL, i couldn't convince Free Pascal to produce a nice executable that runs on GCW0. My initial attempt was to use a MIPS-based distribution of Debian on QEMU to build it there but that didn't really work out (though in hindsight it could have worked if i had realized some stuff earlier but anyway). Eventually i decided to build a i386 VM with Slackware (which i already had it around), install the official SDK, install the official i386 version of Free Pascal 3.2.0, build a custom cross-compiler from i386 to mipsel and smash everything together... which didn't exactly work out of the box but after a bit of tweaking (and making sure the generated executable didn't refer to any libc stuff because then FPC introduced some dependencies to symbols that do not exist in uClibc - i guess i could modify the startup code in FPC to avoid that but i didn't need libc anyway since under Linux FPC performs syscalls directly).

After a bit of back and forth i got it running:



Originally i thought it might be too slow to run in the software rendering mode but turns out to run perfectly fine. The engine also has support for adding hardware accelerated backends but i mainly added that so i can make a 3dfx Voodoo 1 version and the software rendering version looks better / more crunchy to me :-P so i didn't bother with that. The software version is how it is "meant to be played" anyway :-).

You can download it together with the source code from here:

https://bad-sector.itch.io/post-apocalyptic-petra (look for the Petra099jGCW0.zip file).

The default controls seem to be mostly fine so i didn't bother much with that outside of changing a prompt from "Press Space to continue" to "Press Y to continue". The controls are:

Code: [Select]
  D-Pad      Move/turn
  B          Jump
  A          Perform action/climb
  Y          Move to next screen
  Select     Open inventory, Exit screen
  Start      Pick up item, Confirm

This may also work in other JZ4770 OpenDingux devices, though GCW Zero is all i have.
~bs~

Surkow

  • * Administrator
  • Posts: 686
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #1 on: December 02, 2020, 12:14:09 am »
Interesting to see there's still game jams for MS-DOS games. The game looks neat, especially after checking an MS-DOS playthrough on youtube. I'll try to give feedback after I run it on my GCW Zero later this week. I haven't actually seen anyone attempt to use Qemu to compile executables. ;)

BadSector (OP)

  • Posts: 6
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #2 on: December 02, 2020, 04:58:03 am »
Actually that'd be a FreeDOS playthrough - the guy in the video is Jim Hall, the FreeDOS founder and coordinator :-).

When i wrote the post i wasn't able to use QEMU to make executables and used the custom cross-compiler and official GCW SDK in a i386 VM in VirtualBox but a couple of hours ago i decided to give it a second try now that i solved the other issues and guess what - it turns out to be quite straightforward (well, as straightforward as installing an OS in QEMU can be anyway).

Basically the process is simple and doesn't need the official SDK:

  • Install QEMU (of course), including the mipsel emulator
  • Install Debian on it as mentioned in this post. Make sure you switch to the serial view. I used the latest Debian instead of those linked since the post is a bit old. Also since i'm on Windows i used 7zip to take out the kernel and initrd files from the disk image instead of messing up with mounting, etc.
  • Install FPC and utils using Debian's repositories: apt install fpc libsdl1.2-dev squashfs-tools unzip elinks
  • Copy/download the Post Apocalyptic Petra source code and binaries (doesn't matter which version you only need the Data directory)
  • Make a directory and uncompress the files in there
  • Run sh makegcw.sh and wait :-P

You'll get a Petra099j.opk file that you can then drop in GCW Zero's apps directory and it should work.

This works because Free Pascal makes syscalls directly instead of relying on libc so the fact that Debian uses glibc and GCW Zero uses uClibc doesn't enter into the picture - until you try to use some library that causes FPC to link against the C library that is (the source code contains modified SDL bindings that remove the dependency from libc to avoid that, but some other libraries or FPC units can bring the dependency back). Though depending on what exactly the dependencies are and if they are also available on uClibc, it might be possible to use patchelf to replace the glibc dependency with the uClibc one directly in the binary. But i haven't tried that myself, so this is just a guess.

On the other hand compiling under QEMU is a bit slower than under VirtualBox and in VB i have a full desktop environment which can help. On the other hand QEMU is only accessible via the virtual serial terminal and the terminal is a bit glitchy making things a bit harder.

However it is nice to go from not being sure if i can make something in GCW Zero with Free Pascal to actually having two options :-P
~bs~

mth

  • Posts: 319
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #3 on: December 02, 2020, 07:13:02 pm »
Cool stuff!

I'm impressed by the effort you put into getting it building, but it might be simpler to add a Makefile for Free Pascal in Buildroot and build a GCW Zero cross dev toolchain with Free Pascal in it.

BadSector (OP)

  • Posts: 6
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #4 on: December 02, 2020, 07:29:45 pm »
What do you mean with that? I never used the official SDK myself so i don't know what Buildroot is.
~bs~

mth

  • Posts: 319
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #5 on: December 02, 2020, 08:06:05 pm »
Buildroot is a tool to make toolchains and rootfs images for embedded Linux. It is what we use to build the official SDK. The OpenDingux customized version can be found here.

Buildroot has a modular structure, where you can add a package to it by adding a bit of menu configuration and a Makefile that tells Buildroot how to build your package. Some of those instructions look a bit weird though: building a compiler should not require the use of sudo.

BadSector (OP)

  • Posts: 6
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #6 on: December 02, 2020, 11:15:51 pm »
Ah i see. Well, for now my approaches seem to be working fine, though with the limitation that i can't use C library stuff. I'll check it out in the future if i encounter a problem.
~bs~

Optimus

  • Posts: 108
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #7 on: December 03, 2020, 12:18:22 pm »
This is great!

I just tested on GCW0, RG350 and even GameKiddy 350h and it runs in all of them.

One bug happened on RG350 (but first I need to check it's not my fault, as I had installed rogue firmware above the official firmware or maybe the opposite, maybe I messed up things) is that the colors came wrong. The game uses 8bpp palettized mode, so maybe the conversion from SDL (I was thinking of posting bug request to the devs but again I need to clean up my device and install the firmware from scratch now I am thinking it). Does it work correctly to other people's RG350?

BadSector (OP)

  • Posts: 6
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #8 on: December 03, 2020, 05:11:35 pm »
I'd be interested on knowing that since i was thinking about buying a RG350P (supposedly the "newest" version of RG350) exactly because it seems to be the most compatible with GCW Zero :-).
~bs~

BadSector (OP)

  • Posts: 6
Re: Post Apocalyptic Petra, a 3D adventure game
« Reply #9 on: December 03, 2020, 09:01:13 pm »
Uploaded a new version: https://bad-sector.itch.io/post-apocalyptic-petra/devlog/201399/posted-version-099k-bug-fixes-and-performance-improvements

This should fix the palette issue, though the previous version will most likely also work for newer community firmware. According to one of the developers in the retro game handhelds discord, the issue was my use of software surface and palette. I guess the official GCW0 firmware SDL either forced or emulated the hardware palette. I changed it to use hardware surface + palette (and hope there wont be any device out there that doesn't support 8bit mode or has pitch != width :-P).

This also fixes a few other bugs.
~bs~

 

Post a new topic
Post a new topic