Hello world tutorial

From NeoGeo Development Wiki
Revision as of 02:46, 30 October 2011 by Furrtek (talk | contribs)
Jump to: navigation, search

Setting up a minimalist development environment

  1. Download the latest MAME emulator binaries from [this pages]. Extract the zip contents to a folder such as "C:/mame/".
  2. You will need the NeoGeo MVS BIOS files to run NeoGeo roms. Find it with google and make sure you have the 000-lo.lo (64KiB), sfix.sfix (128KiB), sm1.sm1 (128KiB), sp-s2.sp1 (128KiB) and sfix.sfix (128KiB) files in the "c:/mame/roms/neogeo/" folder.
  3. Download a Super Sidekicks romset (ssideki.zip), extract it to "c:/mame/roms/ssideki/".
  4. You will need a batch file to start MAME with the right parameters. Start a new text file and add these contents:
mame ssideki -debug -nofilter -video d3d -waitvsync -window
pause

Run this batch file, MAME should open with its debugger enabled. Don't be scared, just press F5 to see if Super Sidekicks runs fine. If the romset is bad, the missing and/or invalid files will be shown in the DOS prompt (bad checksum, missing files...). When everything works, close the debugger and the emulation window.

  1. Download [the macro assembler AS (ASW)] and this zip file. There is no installation required, just extract those files to a folder like "C:/neogeo/asw/".
  2. For the purpose of this tutorial, notepad can be used as a source editor. Make a folder for this project such as "c:/neogeo/helloworld/".
  3. You will need to add a batch file in this folder to run ASW to assemble your source file. Make a new text file with the following contents:
@echo off
c:\neogeo\asw\asw main -L -quiet
c:\neogeo\asw\p2bin main -r $000000-$01FFFF
d:\neogeo\asw\flip main.bin 052-p1.bin
d:\neogeo\asw\pad 052-p1.bin 524288 255
copy 052-p1.bin c:\mame\roms\ssideki\052-p1.bin

And save it as "make.bat" in the "c:/neogeo/helloworld/" folder.

Asw assembles your code, p2bin makes the P ROM with the right size (128KiB), flip.exe inverts bytes by pairs (byteswapping) because P ROMs have to be that way, pad.exe fills up the P ROM with $FF bytes up to 512KiB (to match the original ssideki ROM size) and it's then copied in place of the original Super Sidekicks rom.

Be aware that only the P ROM is replaced, all graphics, musics and sounds are still the Super Sidekicks ones.

Now that you have everything to assemble and run the ROM, you can start coding.

The code

  • Go to the 68k ASM defines page, copy everything, paste it in a new text file and save it as "regdefs.asm" in "c:/neogeo/helloworld/". This allows you to use register names in place of their pretty meaningless and hard-to-remember addresses. For example, instead of writing $300001 in your code, you'll be able to write REG_DIPSW and ASW will take care of translating that to $300001.
  • Start a new text file and add the following:
    cpu 68000
    supmode on
    INCLUDE "regdefs.asm"

This indicates ASW what CPU we're writing code for, that the code will be run in supervisor mode (allows us to use special instructions), and to include our previous "regdefs.asm" file. Save this file as "main.asm".

TODO