SSJX.CO.UK
Browser Games | Cybiko | Amiga | Applications | Windows Games | Python | Guides | Site Map

Creating Apps for the Cybiko

This guide will show you how to build a Cybiko application using the Cybiko SDK. We will be making a simple 'Hello world!' to demonstrate.

Note that this is not a programming guide and more of a guide on how to setup a working environment.

What you will need

This guide assumes Windows is being used but most of it applies if you are using the Linux Cybiko SDK

Setting up the folders

To keep things organised we first need some folders:

  1. Create a folder for the project called 'hello'
  2. Inside this, create a folder called 'src' and a folder called 'res'.

As you have probably guessed, 'src' will contain the source files and 'res' will contain resources such as graphics. We will not be using the 'res' folder in this example.

Creating the root.inf

The root.inf contains author, program name and some version numbers. Don't type in the green text!

app (app/game/lib)
Hello World (program name)
(empty line)
(empty line)
(empty line)
(empty line)
Hello World (unique program identifier)
1.0 (program version)
1.2.53 (min CyOS version required, xtreme = 1.5.1)
Created By Me(Author info)

Save this in the 'hello' folder as 'root.inf'

The SDK manual contains much more information about this but the above is enough to get things working.

Create the make.bat

This batch file runs vcc which compiles the source files and puts it together with any resources into the .app file.

The make.bat below takes the root.inf and compiles the source files in the 'src' folder and outputs 'hello.app'. (Ignore the first line, the second line is the important one.)

@echo off
vcc root.inf src\*.c -o hello.app

Save this in the 'hello' folder as 'make.bat'.

If we had resources such as images in the 'res' folder we would change the line to read something like 'vcc root.inf src\*.c res\* -o hello.app'

Create the hello.c source file

Now we just need to make a program! This will display our message on the screen for 5 seconds before closing:

// Hello World Program!
#include <cybiko.h>

struct module_t main_module;

long main(int argc, char *argv[],bool start)
{
// Trace sends a message to the console on the PC
TRACE("Starting..");

//needed by pretty much all cybiko progs
init_module( &main_module );

// Clear the screen
TGraph_fill_screen( main_module.m_gfx, CLR_WHITE );

// Pick a colour (not needed but just for demo purposes)
TGraph_set_color( main_module.m_gfx, CLR_BLACK );

// Draw our text
DisplayGraphics_draw_text( main_module.m_gfx,"Hello World!", 20, 20 );

// draw everything to the screen
DisplayGraphics_show(main_module.m_gfx );

// wait for 5 seconds
sleep(5000);

TRACE("Done!");
return 0L;
}

Save this in the 'src' folder as 'hello.c'.

Making the hello.app

By now we should have our 3 files (root.inf, make.bat and src\hello.c) so we just need to run the make.bat to create the hello.app.

Get a command line and navigate to the 'hello' folder. If you installed the Open Command Window Here powertoy just right click on the 'hello' folder and select 'Open Command Window Here'. Type in make.bat and you should see the following:

C:\Documents and Settings\me\My Documents\hello>make.bat
root.inf
src\hello.c


Cybiko 3.1.4 Archiver / Compressor.
Copyright (C) 1999-2001 Cybiko, Inc.
Written by Vadim Sytnikov.

Reading root.inf... compressed (75%).
Reading bytecode.bin... compressed (94%).
Reading C:\Program Files\Cybiko\Cybiko_SDK\lib\cybiko\main.e... compressed (71%)
.
Writing archive hello.app...
Done: 3 files.

C:\Documents and Settings\me\My Documents\hello>

If you get any error messages, check through the hello.c file for any typing mistakes.

Send it to the Cybiko

By this point we should have a working app! Use the Cybiko Console and send 'hello.app' to the cybiko. Once there you should find the program in the 'Applications' section, if it does not appear you may need to reset your cybiko.

You can also run the program by typing 'hello' in the Cybiko Console command line.

Download this program

You can download this app and source code using the link below:

Download now (2k)

Next...

You now have the basic structure for making cybiko programs. If you want to make another program you can simply make a copy of the 'hello' folder, edit the 'root' and 'make' files and you are ready to go!

For more information about programming the Cybiko, take a look through the SDK manual. It contains information and examples on how to use graphics, sound and the keyboard enabling you to create some great programs!

If you do make a great program, be sure to post it on the PlanetCybiko forums!

31/5/2008

Support this site : Visit Play-Asia for games and accessories for new and classic games consoles!