Author Topic: Example Platform Engine  (Read 1816 times)

mrhaboobi

  • Hero Member
  • *****
  • Posts: 693
Re: Example Platform Engine
« Reply #15 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..
Looking for (MINT ONLY)
US Manual : Magical Chase, Shockman 
US Box : Turrican,  Soldier Blade, New Adventure Island, Neutopia II
Other : Sapphire OBI, Turbo Play Aug/Sept 90, April/May 92, Turbo Edge Spring 90

PC Engine Special Cards : Bomberman User Battle

Alydnes Super Grafx

nodtveidt

  • Guest
Re: Example Platform Engine
« Reply #16 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...
« Last Edit: October 11, 2011, 11:16:24 AM by The Old Rover »

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Example Platform Engine
« Reply #17 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!
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: Example Platform Engine
« Reply #18 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.

nodtveidt

  • Guest
Re: Example Platform Engine
« Reply #19 on: October 11, 2011, 04:15:22 PM »
OK, whatever works for ya. :) I was just describing how I do it.

thrush

  • Full Member
  • ***
  • Posts: 202
Re: Example Platform Engine
« Reply #20 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!

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Example Platform Engine
« Reply #21 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! :)
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

nodtveidt

  • Guest
Re: Example Platform Engine
« Reply #22 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?

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: Example Platform Engine
« Reply #23 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.

touko

  • Hero Member
  • *****
  • Posts: 953
Re: Example Platform Engine
« Reply #24 on: October 12, 2011, 12:47:48 AM »
Hum strange, i have a neoflash card, and .pce done on pceas (mkit) works fine .
« Last Edit: October 12, 2011, 12:50:40 AM by touko »

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Example Platform Engine
« Reply #25 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.
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

nodtveidt

  • Guest
Re: Example Platform Engine
« Reply #26 on: October 12, 2011, 01:51:36 AM »
So what if you do...

huc -s source.c

and then

pceas -raw source.s

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Example Platform Engine
« Reply #27 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 
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

touko

  • Hero Member
  • *****
  • Posts: 953
Re: Example Platform Engine
« Reply #28 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.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Example Platform Engine
« Reply #29 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
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.