Difference between revisions of "Create my first program"

From MSX Game Library

(Test template program)
(Setup Build Tool)
Line 40: Line 40:
 
* Set <tt>Machine</tt> to the minimal version of MSX hardware you want to support for your program. Let's say <tt>"1"</tt> for {{MSX1}}.
 
* Set <tt>Machine</tt> to the minimal version of MSX hardware you want to support for your program. Let's say <tt>"1"</tt> for {{MSX1}}.
 
* Set <tt>Target</tt> to your target format. Let's say <tt>ROM_48K</tt> (ROM on page 0, 1 and 2 with page 1 & 2 selected at startup).
 
* Set <tt>Target</tt> to your target format. Let's say <tt>ROM_48K</tt> (ROM on page 0, 1 and 2 with page 1 & 2 selected at startup).
* If you have [[Install|configured an emulator path]] in <tt>MSXgl\projects\default_config.js</tt>, set <tt>DoRun</tt> to <tt>true</tt> to allow auto-launch (easier to test your program).
+
* If you have [[Install|configured an emulator path]] in <tt>projects/default_config.js</tt>, set <tt>DoRun</tt> to <tt>true</tt> to allow auto-launch (easier to test your program).
  
* Execute <tt>build.bat</tt>, check the <tt>emul\rom</tt> directory for <tt>mygame.rom</tt> and test it.
+
* Execute <tt>build.bat</tt>, check the <tt>emul/rom</tt> directory for <tt>mygame.rom</tt> and test it.
  
 
Many other build options can be defined in <tt>project_config.js</tt>. See the [[Build Tool|options list]].
 
Many other build options can be defined in <tt>project_config.js</tt>. See the [[Build Tool|options list]].

Revision as of 22:44, 26 December 2022

Test template program

First try to compile and run the template program:

  • Go to projects/template (or template_msx2 if you target MSX2 computer)
  • Execute build.bat (Windows) or ./build.sh (Linux & macOS)
  • Go to projects/template/emul/rom, check if template.rom exists and try it on your MSX machine or emulator.

Note: If you have configured an emulator path in projects/default_config.js, you can edit project_config.js and change "DoRun = false;" to "DoRun = true;" to allow auto-launch of the built program.

Create your project directory

Now that everything work well, let's create your own program.

You can sure start a new project from scratch, but for this example lets duplicate template (or template_msx2) directory, and rename it mygame.

Rename template.c to mygame.c.

Your project directory should look like:

📁 projects
└─📁 mygame Your project directory
  ├─ build.bat Launch Build tool (Windows)
  ├─ build.sh Launch Build tool (Linux)
  ├─ msxgl_config.h Library configuration
  ├─ mygame.c Your program source code
  └─ project_config.js Build tool configuration

Setup Build Tool

Edit project_config.js:

  • Change ProjName to "mygame".
  • Set Machine to the minimal version of MSX hardware you want to support for your program. Let's say "1" for .
  • Set Target to your target format. Let's say ROM_48K (ROM on page 0, 1 and 2 with page 1 & 2 selected at startup).
  • If you have configured an emulator path in projects/default_config.js, set DoRun to true to allow auto-launch (easier to test your program).
  • Execute build.bat, check the emul/rom directory for mygame.rom and test it.

Many other build options can be defined in project_config.js. See the options list.

This is where you will be able to choose which MSX version your program is intended for (MSX 1, 2, 2+ or turbo R) and the type of program you want to create (MSX-DOS, BASIC binary, plain or mapped ROM).

Setup program

  • msxgl_config.h file contains many options to configure the library to better suit your needs.

Change program content

Here it all depends on the type of game you want to play.

TBC...