PCEngineFans.com - The PC Engine and TurboGrafx-16 Community Forum

Tech and Homebrew => Turbo/PCE Game/Tool Development => Topic started by: nodtveidt on October 10, 2011, 07:40:35 AM

Title: Example Platform Engine
Post by: nodtveidt on October 10, 2011, 07:40:35 AM
mrhaboobi was asking about this, so I figured I would just release it to the general public. This is a relatively simplistic platform engine that presently supports idle state, moving around, jumping, standing attack, and jump-down-from-platform capabilities. Other states are included but unfinished. It doesn't have any entity handling (no pickups or enemies), as that's a whole different subject and differs from game to game depending on need.

I put up two packages: a complete ready-to-run package, and a source-only package. The complete package is 33.2MB because it contains three audio tracks, the other is about 48KB... add your own WAV files. :)

http://www.frozenutopia.com/platformengine-ready.7z   Ready-to-run version
http://www.frozenutopia.com/platformengine.7z   Add-your-own-WAVs version

I commented it as best I could, and some parts are not optimal, but it works, and quite well too. Feel free to use and abuse as you see fit. :) All flames will be redirected to /dev/null.
Title: Re: Example Platform Engine
Post by: Arkhan on October 10, 2011, 09:32:56 AM
Hehe, NeutopiaChirpy.

Sounds familiar.
Title: Re: Example Platform Engine
Post by: nodtveidt on October 10, 2011, 09:40:34 AM
I swiped it from Squirrel. :P hehe
Title: Re: Example Platform Engine
Post by: Arkhan on October 10, 2011, 10:15:49 AM
Yeah, I figured lol.  Noone around these parts uses "chirpy" very often, ;)


Title: Re: Example Platform Engine
Post by: KingDrool on October 10, 2011, 01:55:43 PM
Very cool of you to do this, Rover.

Excuse my ignorance, but would it be useful - to encourage people into the PC Engine homebrew scene - to write up some sort of "Here's what you need to know and do to program a PC Engine game" guide? I'm not sure what would be involved in that, nor how long it would take as I have no coding/programming knowledge whatsoever. I'm just curious.
Title: Re: Example Platform Engine
Post by: Arkhan on October 10, 2011, 02:34:39 PM
It might help.  There was a guide similar to that at some point on the internet, but like most things in the PCE homebrew scene, it never got finished

I myself thought about doing a series of video tutorials about how to make chiptunes with Squirrel quickly and effectively.  It's something else that the scene could use as far as how-tos.

The only thing holding me back is I can't stand doing video editing/doodling, so I immediately get discouraged.  I may try it again using my girlfriend as a film slave.  She does cameras/video stuff and enjoys it, lol.
Title: Re: Example Platform Engine
Post by: mrhaboobi on October 10, 2011, 03:59:57 PM
Awesome Rover.  Thanks alot for that :)
Title: Re: Example Platform Engine
Post by: touko on October 10, 2011, 11:07:58 PM
It might help.  There was a guide similar to that at some point on the internet, but like most things in the PCE homebrew scene, it never got finished

I myself thought about doing a series of video tutorials about how to make chiptunes with Squirrel quickly and effectively.  It's something else that the scene could use as far as how-tos.


Yes, it's trilinear's "echo's quest" i think..
Title: Re: Example Platform Engine
Post by: Arkhan on October 11, 2011, 02:34:05 AM
It might help.  There was a guide similar to that at some point on the internet, but like most things in the PCE homebrew scene, it never got finished

I myself thought about doing a series of video tutorials about how to make chiptunes with Squirrel quickly and effectively.  It's something else that the scene could use as far as how-tos.


Yes, it's trilinear's "echo's quest" i think..

It might have been.  I don't seem to recall it being Trilinear though.

Too bad that person isn't around anymore.  They were doing some neat things
Title: Re: Example Platform Engine
Post by: touko on October 11, 2011, 04:03:36 AM
Yes, trilinear, eagan, jycet, and many others have stopped everything.
Title: Re: Example Platform Engine
Post by: Arkhan on October 11, 2011, 04:05:33 AM
Jycet's stuff was the first PCE code I ever looked at. 

Any idea why they bailed?  They're before my time.
Title: Re: Example Platform Engine
Post by: nodtveidt on October 11, 2011, 06:08:30 AM
Trilinear's "Echos Quest" was a basic platformer with parallax scrolling. The only problem is that he used sprites to do the background layer, which worked fine in Magic Engine but obviously on real hardware or a proper emulator, it looked like crap. And I think they all bailed for two reasons:

-None of them were serious
-Zeograd abandoned HuC

Of course, not everyone has to be a serious developer. It's fine to just tinker with stuff and learn.
Title: Re: Example Platform Engine
Post by: Arkhan on October 11, 2011, 07:46:48 AM
which worked fine in Magic Engine but obviously on real hardware or a proper emulator, it looked like crap.

???

What do you mean thurrrrr
Title: Re: Example Platform Engine
Post by: dudule on October 11, 2011, 09:59:23 AM
the link don't work  :cry:
Title: Re: Example Platform Engine
Post by: nodtveidt on October 11, 2011, 10:29:08 AM
???

What do you mean thurrrrr
Magic Engine normally doesn't respect the 16-sprite-blocks-per-line limit, so the sprite-based parallax layer works fine. However, on the real machine, or in a proper emulator like Mednafen, the last sprites are clipped due to sprite buffer overflow.

the link don't work  :cry:
Works fine for me...
Title: Re: Example Platform Engine
Post by: mrhaboobi on October 11, 2011, 10:30:49 AM
Rover, do you feel like putting together a small "how to get set up " for newbs, so that we can get HUC up and runnings, an emulator etc..
Title: Re: Example Platform Engine
Post by: nodtveidt on October 11, 2011, 11:04:05 AM
There's a couple of ways to get HuC set up. Fortunately, it's an independent compiler so it doesn't rely on anything else, unlike virtually all other toolchains. I'm going to describe the way I do things, and I'll also explain why I deviate from the "normal" way it's done.

First of all, download it from zeograd.com. Unzip all the files to somewhere you will remember for later. Now, the best thing to do is to make a copy of the files you're going to need for your project.

Create a project folder. I personally have it set up like this:

C:\pceprojects\projectname

so if you have a project called MyLeetThing, you would have

C:\pceprojects\MyLeetThing

Now, copy the required files into this directory. You will need, at the very least, the contents of include/pce inside the HuC files. I always copy the files themselves, not the folder. If you plan on making CDs, you will also need overlay.h that is just in include/. That's all the library files. Now you'll need the compiler files. At least, you will need huc and pceas. These are in the bin/ directory. If you plan on making CDs, you will also need isolink. You won't need pcxtool or nesasm.

The reason I copy the files like this is because I quite often modify the library, and different games have different library requirements. You could always put the executables in your path somewhere if you want. Anyway, once you have the files copied into your project directory, you can start making your project. :)

If you're making a hucard project, it's pitifully easy to get something running quickly. Making a CD project is a hell of a lot more involved so I won't get into that here. Just make a C file (no C++ here, folks), call it whatever you want. So, you could make like MyAwesomeGame.c.

There's only one major detail for your source: you need to #include "huc.h". Also, main() doesn't take any arguments... sorry, no argv/argc here. :) Everything else... is up to you. :)

HuC uses a limited form of SmallC. One of the most immediately noticeable details of this is how functions are used. To make a function in "normal", modern C, you would do this:

Code: [Select]
void function MyFunkyFunc(int argument1, char argument2)
However, here in HuC land, you would do it more like this:

Code: [Select]
function MyFunkyFunc(argument1, argument2)
int argument1;
char argument2;

If you're used to modern C, that takes some getting used to.

Compiling... to make a Hucard, the only thing you really need to do is this from the command line:

huc MyAwesomeGame.c

and that will give you MyAwesomeGame.pce as long as nothing's broken. You can then run it in any PCE emulator. I prefer Mednafen for accuracy. :)

I hope this all helps. :D

EDIT: Jumping the gun a lil bit... if you want to make CDs, there are a lot more steps. First of all, you create what are called "overlays". There are two main types: executable and data. Executable overlays contain program code, data overlays contain... well, data. Your first overlay is going to be overlay 1. This needs to be an executable overlay, as it will be the one that is run when the system card loads the CD.

If you want to share data between executable overlays, you need to create a new file called globals.h. This will contain any variables that you want to be available to all of your programs. You can also put useful #defines here too... I do that a lot, it's useful for making a list of overlays, for example.

Compiling for CD is also different. What you do now are compile overlays rather than ROMs. So:

huc -scd -over MyAwesomeGame.c

will create MyAwesomeGame.ovl as a System 3 overlay (you can use -cd to make a System 2 overlay, but the HuC overhead is too big to do anything serious in System 2 except for making a cderror program, so it's best to stick with System 3). After that, you need to link it using isolink:

isolink MyAwesomeGame.iso MyAwesomeGame.ovl

which will make an ISO that you can run in an emulator, or burn to CD.

You can also make a cuesheet with a warning track, game music files, etc...
Title: Re: Example Platform Engine
Post by: Arkhan on October 11, 2011, 11:08:51 AM
Magic Engine normally doesn't respect the 16-sprite-blocks-per-line limit, so the sprite-based parallax layer works fine. However, on the real machine, or in a proper emulator like Mednafen, the last sprites are clipped due to sprite buffer overflow.
Oh, well duh.  lol.

Atlantean does not have this dilemma!
Title: Re: Example Platform Engine
Post by: TheOldMan on October 11, 2011, 02:10:07 PM
Quote
Now, copy the required files into this directory.....
The reason I copy the files like this is because I quite often modify the library...

We just copy the files we need to change into the root of the project. Huc is 'dumb' enough to use them if it finds them there, rather than the 'standard' library files.
Less to keep track of, and it doesn't impact other projects that need the standard files.
Title: Re: Example Platform Engine
Post by: nodtveidt on October 11, 2011, 04:15:22 PM
OK, whatever works for ya. :) I was just describing how I do it.
Title: Re: Example Platform Engine
Post by: thrush on October 11, 2011, 05:22:41 PM
I'm going to describe the way I do things, and I'll also explain why I deviate from the "normal" way it's done.  [...]

Thanks very much!

I decided last month to start doing some PCE development.  I am a fairly competent programmer as hobbyists go, but this is my first foray into anything retro, console, or undocumented.  As a result, I am a bit confused about the work flow.

I have deliberately not mentioned my interest in joining the ranks of the scene so far because I know that a lot of people show up, say they're going to contribute, then vanish.  Since I am stupidly busy IRL I may not have much to show for my efforts for some time, so I figured it would be best to wait till I had done more reading/messing about.  However, since this is post is so close to what I've been looking for, I decided to fess up.

Now that my cover is blown, here's my question: would it be a bother to explain these steps again from an Assembly standpoint?  I am particularly interested in the ASM side of things, but as I am perversely coding on my Mac so far I've done little more than compile PCEAS, Mednafen, and so forth.

Also, if you don't mind shepherding a noob, are there any tutorials on getting a finished .pce image onto a flash cart and into my system, or advice about what card to purchase?

Sorry for the wall of text, and thanks again!
Title: Re: Example Platform Engine
Post by: Arkhan on October 11, 2011, 05:31:21 PM
The steps are about the same.  just replace huc with pceas and .c with .s:

pceas game.s
pceas -scd game.s

etc.

if you run PCEAS and HuC at the commandline with no arguments, it will display all the options!

Get a NeoFlash PCE flash card. Its the safer bet.  I believe there is a Mac version of the tools to flash the card, but I can't be certain.  Worse case scenario, you have to use a VM.  No biggy.

there are no tutorials, but there are some utilities floating around to set a .PCE up to put on a flashcart and have it work.  A .PCE fresh from PCEAS won't work on Neoflash.


also, lol, that isn't a wall of text!  You should see my posts! :)
Title: Re: Example Platform Engine
Post by: nodtveidt on October 11, 2011, 06:04:35 PM
A .PCE fresh from PCEAS won't work on Neoflash.
I haven't used the Neoflash yet so I wouldn't know about this, but... why is this exactly?
Title: Re: Example Platform Engine
Post by: TheOldMan on October 11, 2011, 11:33:28 PM
A .PCE fresh from PCEAS won't work on Neoflash.
I haven't used the Neoflash yet so I wouldn't know about this, but... why is this exactly?
Dumped roms and Huc add a 512 byte header to the rom. (A leftover from the earlier days, for identifying roms).
That throws the page alignments off. You either have to build without the header (-h, I *think*) or use a tool to
strip the header.

What's really fun is matching the regions. If your flash cart is set for the wrong system, you have to flip the data lines to get it to work. Not much of a problem if you use an automated build system, just one more step you have to be aware of.
Title: Re: Example Platform Engine
Post by: touko on October 12, 2011, 12:47:48 AM
Hum strange, i have a neoflash card, and .pce done on pceas (mkit) works fine .
Title: Re: Example Platform Engine
Post by: Arkhan on October 12, 2011, 01:20:15 AM
Hum strange, i have a neoflash card, and .pce done on pceas (mkit) works fine .

You're not using HuC though. I don't think plain ol' pceas adds this stuff.  It's something in the HuC steps.
Title: Re: Example Platform Engine
Post by: nodtveidt on October 12, 2011, 01:51:36 AM
So what if you do...

huc -s source.c

and then

pceas -raw source.s
Title: Re: Example Platform Engine
Post by: Arkhan on October 12, 2011, 02:01:22 AM
the sauce that HuC makes has all the crap in it.   

well, maybe not if you use -raw.  What the hell does -raw do again? lol 
Title: Re: Example Platform Engine
Post by: touko on October 12, 2011, 02:14:19 AM
You're not using HuC though. I don't think plain ol' pceas adds this stuff.  It's something in the HuC steps.
No,with HuC or mkit, i don't have any problem with .pce on my flashcard.
Title: Re: Example Platform Engine
Post by: Arkhan on October 12, 2011, 02:27:34 AM
Hmm, that's odd.  What flashcard do you use?

If I make a .PCE of Atlantean and just plop it on the card, it doesn't work. lol
Title: Re: Example Platform Engine
Post by: TheOldMan on October 12, 2011, 03:55:13 AM
On a neo 128M w/backup, using neo2 pro manager v1.11
pce version set to US.

Quote
So what if you do...
huc -s source.c
and then
pceas -raw source.s
Yeah, that works. I just never use the -raw flag.  (I forget about it).
Title: Re: Example Platform Engine
Post by: Bonknuts on October 12, 2011, 04:37:09 AM
thrush: I'm all ASM for PC-Engine coding, so if you need someone to bug via such related questions then you can add me to your list. I'm also known as Tomaitheous (and usually hang out on mednafen channel IRC, when I have time). There are some others that are active ASM only coders for PCE; MooZ, Charles MacDonald, Chris Covell to name a few. http://pcedev.blockos.org/ also might be a place you want to ask questions or such too. It's a bit slow, but MooZ always checks the forum (he runs it).

 MooZ, Charles, and I don't use the MagicKit included libraries. We have our own (and many times just written over again on the fly). I found the documentation for Mkits libs seriously lacking. Building your own lib is fairly easy and gives you more freedom and control for your layout, etc. Among some other small advantages. If you're compiling PCEAS, use the last public source for it that's include in HuC source kit. I have my own private build with a few upgrades added in (8k bank boundary crossing error for Code is gone, new directives for easier table making, better name support for Macros, - and + local labeling, etc). MooZ does too, IIRC. I was talking with MooZ and we're supposed to make the new fork/build public. Just waiting on him. Won't be official, but it'll be our own version.



 I don't own the NeoFlash, but after chatting with Chilly Willy I found out my demos wouldn't run for him because PCEAS builds them with the header by default. Yeah, -raw assembles without a header. Which I use for one of my flash cards (just a dip rom board).

 HUC stuff: Someone mentioned something about replacing/reworking the scroll() routine in HuC, in one of these huc related threads. The routine is indeed part of the Mkit lib and is basically just a pass through function. I made an optimized replacement for Xavier. It eats some more memory, but it's fast and very flexible. It behaves like the HDMA setup on the SNES, Or you could think of it similar to 'copper' on the Amiga. It works by using a main table, 8bits per entry. The each of the 8bits is a command telling the hsync routine what to do; change BG color #0, change X, change Y, turn on BG, turn off BG, turn on SPR, turn off SPR, etc. There's a scanline list in a separate table telling which scanline to generate the next function list on. You can do any and all the functions at the same time for a given scanline. And you can do all visible scanlines. It uses the existing irqmask setup that HuC uses (which is a clone of the system card setup and is actually used in place of when building CD projects). I think it worked out fairly nice and gave some powerful hsync functionality to HuC setup.
Title: Re: Example Platform Engine
Post by: touko on October 12, 2011, 05:23:11 AM
Hmm, that's odd.  What flashcard do you use?

If I make a .PCE of Atlantean and just plop it on the card, it doesn't work. lol
I use the 64 Mb version: neo pc-e flash card, with rtype .
I'am flashing with PCE option, and using NEO Power PC-E V1.0 .
Title: Re: Example Platform Engine
Post by: Arkhan on October 12, 2011, 05:31:26 AM
Oh, yay for -raw.  I don't even remember that option being in the usage menu.  maybe it was overlooked. :) Cool.
Title: Re: Example Platform Engine
Post by: thrush on October 18, 2011, 03:40:46 AM
Cool, thanks a lot for the info & recommendations guys.  Sorry it took me like a week to read this.

Bonknuts -- thanks much for the offer!  I have seen your posts as Tomaitheous all over the place on various forums, cool!  I believe I did use the most recent release of PCEAS when I compiled; I'll check later.

I should have more time once November rolls around, so maybe I'll be able to get started on something then & have some real questions for people.  ^_^
Title: Re: Example Platform Engine
Post by: Gredler on March 01, 2016, 12:56:27 PM
bump, cause this is rad
Title: Re: Example Platform Engine
Post by: nodtveidt on March 01, 2016, 01:45:31 PM
Haha, old school :lol: