SymbOS SDK with SDCC

SymbOS 2.0, The Operating System


SymbOS is an operating system based on CPC and MSX computers. This OS can be managed using a windows interface but there is a Shell Command interpreter too. You can find more information in looking for Internet or in the oficial site (http://www.symbos.de/)



SDCC Compiler


The Windows development kit is based on the SDCC freeware compiler. You can find it in the oficial site: (http://sdcc.sourceforge.net/)



SDK Files


To use the SDK is needed to have installed the compiler and tools of SDCC. The SDK Pack comes with an executable "SymbosMake.exe" that calls SDCC compiler and linker and generates an EXE/COM SymboOS compliant.



My first SymbOS app


We are going to start with an easy sample, the typical "Hello World!".
To make that "SymbosMake.exe" works correctly is needed that in the same folder we have a text file "Make.ini" with a format like this:

MACROS = MSX_VERSION=MSX2
SOURCE_PATH = .\
RESOURCE_FILE = main.rc
LIBRARY = symbos/symbos.lib
ENGINE_SOURCES =
MODULE_SOURCES =
MAIN_SOURCE = main
RELEASE_PATH = .\release
C_MODULE_PATH = .\
C_ENGINE_PATH = .\
BIN_PATH = .\
STACK_SIZE = 512
APP_NAME = HELLO_WORLD
SMALL_ICON = smallicon.sgx
BIG_ICON = bigicon.sgx
OUTPUT_NAME = hello.exe


The file "Main.rc" will contain the needed resources for making our EXE. We will detail RC Files more later:


ICON IDI_ICON "smallicon.sgx"

CONTROL_GROUP_DATA_RECORD CGDR_Form1
{
   CONTROL_DATA_RECORD { ID = 0, TYPE = 255, X = 0, Y = 0, W = 10000, H = 10000, PARAM = 0 }
}

WINDOW IDD_MAIN
{
   STATUS_NORMAL,
   IS_SUPERWINDOW,
   X = 0,
   Y = 0,
   WIDTH = 10000,
   HEIGHT = 10000,
   OFF_X = 0,
   OFF_Y = 0,
   FULL_WIDTH = 10000,
   FULL_HEIGHT = 10000,
   MIN_WIDTH = 10000,
   MIN_HEIGHT = 10000,
   MAX_WIDTH = 10000,
   MAX_HEIGHT = 10000,
   ICON = IDI_ICON,
   TITLE_STRING = null,
   STATUS_STRING = null,
   MENU_DATA_RECORD = null,
   CONTROL_GROUP_DATA_RECORD = CGDR_Form1,
   CONTROL_GROUP_DATA_RECORD_TOOLBAR = null,
   TOOLBAR_HEIGHT = 0,
}


And finally the "Main.c" file:

#include "symbos\symbos.h"
#include "symbos\symbos_system.h"
#include "symbos\symbos_desktop.h"
#include "symbos\symbos_device.h"
#include "symbos\symbos_kernel.h"
#include "symbos\symbos_memory.h"
#include "symbos\symbos_shell.h"
#include "symbos\symbos_file.h"
#include "string.h"
#include "resource.h"

#include "symbos\symbos_transfer_area_start.h"
#include "symbos\symbos_transfer_area_end.h"

void main (void)
{
   MESSAGEBOX ("Hello World");
   Sys_Program_End (GET_APPLICATION_ID());
   while (1) Multitasking_SoftInterrupt();
}

Here you can download a RAR file with the previous sample. You will need to install Symbos SDK in the same directory to compile it. Try to generate the "Hello.exe" and run it in Symbos 2.0. The next, we are going to explain better all the saw until now.



Download RAR with Symbos SDK 
Download RAR with the sample "Hello World"

MAKE.INI


"Make.ini" is a needed file to use "SymbosMake.exe" and generate our Symbos applications and games. Their properties:  

MACROS = lets to define precompiler labels. 
SOURCE_PATH = tells were are our source files
RESOURCE_FILE =
what is the RC File to use
LIBRARY =
what libraries (.LIB) we want to include
ENGINE_SOURCES =
file name of sources (.C) that we want to compile
MODULE_SOURCES =
file name of sources (.C) that we want to compile
MAIN_SOURCE =
file name of source (.C) that will contain the main proc
RELEASE_PATH =
folder where we want to move the generated files by the compiler.
C_MODULE_PATH =
folder where module source files will be.
C_ENGINE_PATH =
folder where engine source files will be.
BIN_PATH =
where are the tool binary files (.exe)
STACK_SIZE =
what stack size we want to use in bytes (f.e: 128, 256, 512, etc.)
APP_NAME =
application name
SMALL_ICON =
small app icon (.SGX)
BIG_ICON =
big app icon (.SGX)
OUTPUT_NAME =
output file name (.COM, .EXE)

In our addressing memory model we will find first ENGINE functions, then MODULE functions and finally the MAIN. You can specify more than one file in ENGINE_SOURCES and MODULE_SOURCES in the way:

ENGINE_SOURCES = vdp, psg, pt3, ppi, tools

This will compile the files "vdp.c", "psg.c", "pt3.c", "ppi.c", "tools.c" and we will suppose that this files will be in the folder C_ENGINE_PATH. 
   

The resource file (.RC)

With this file we can add resources to our application (windows, controls, graphics, strings, etc.) When "SymbosMake" compile a RC archive, it generates a "resources.h" file. We can use this C include file for using during compilation time.
The way to include objects is: 

<OBJECT_TYPE> <NAME> <VALUE>
<OBJECT_TYPE> <NAME> { <VALUES> }

We can find all this kind of objects:

ICON <Identifier> <String>
BITMAP <Identifier> <String>

Add a graphic file with Symbos format (.SGX) 

DEFINE <Identifier> <Integer> 

Add a precompiler label in the file "Resources.h"

STRING <Identifier> <String>

Add an ASCII string. <String> is a set of chars separated between " "

For example: 

STRING IDS_CADENA1 "This is a string"
DATA <Identifier>
{
   BYTE = <Integer> | WORD = <Integer> | LONG = <Integer> | POINTER = <Identifier>
   [, BYTE = <Integer> | WORD = <Integer> | LONG = <Integer> | POINTER = <Identifier> [, ...] ]
}

Add an array of data. This let you to add integer numbers of 1 bytes, 2 bytes (WORD, POINTER) and 4 bytes (LONG)


WINDOW <Identifier>
{
    [STATUS_CLOSED, ]
    [STATUS_NORMAL, ]
    [STATUS_MAXIMIZED, ]
    [STATUS_MINIMIZED, ]
    [SHOW_CENTERED, ]
    [SHOW_ICON, ]
    [IS_RESIZEABLE, ]
    [SHOW_CLOSE, ]
    [SHOW_TOOLBAR, ]
    [SHOW_TITLE, ]
    [SHOW_MENU, ]
    [IS_X_ADJUSTED, ]
    [IS_Y_ADJUSTED, ]
    [NOT_SHOW_IN_TASKBAR, ]
    [NOT_MOVEABLE, ]
    [IS_SUPERWINDOW, ]
    [X = <Integer>, ]
    [Y = <Integer>, ]
    [WIDTH = <Integer>, ]
    [HEIGHT = <Integer>, ]
    [OFF_X = <Integer>, ]
    [OFF_Y = <Integer>, ]
    [FULL_WIDTH = <Integer>, ]
    [FULL_HEIGHT = <Integer>, ]
    [MIN_WIDTH = <Integer>, ]
    [MIN_HEIGHT = <Integer>, ]
    [MAX_WIDTH = <Integer>, ]
    [MAX_HEIGHT = <Integer>, ]
    [ICON = <Pointer>, ]
    [TITLE_STRING = <Identifier>, ]
    [STATUS_STRING = <Identifier>, ]
    [MENU_DATA_RECORD = <Identifier>, ]
    [CONTROL_GROUP_DATA_RECORD = <Identifier>, ]
    [CONTROL_GROUP_DATA_RECORD_TOOLBAR = <Identifier>, ]
    [TOOLBAR_HEIGHT = <Integer>, ]
    [SUPERWINDOW_ID = <Integer>, ]
}
CONTROL_GROUP_DATA_RECORD <Identifier>
{
    [CONTROL_DATA_RECORD | AREA | TEXT | FRAME | FRAME_WITH_TITLE |
      PROGRESS | TEXT_WITH_FONT | TEXT_WITH_CODES | GRAPHIC |
      GRAPHIC_WITH_TEXT | GRAPHIC_EX | BUTTON | CHECK_BUTTON | RADIO_BUTTON |
      HIDDEN_BUTTON | TAB | SLIDER | COLLECTION | TEXTLINE | TEXTBOX |
      LIST_TITLE | LIST_CONTENT | LIST_DROPDOWN | LIST <Identifier>
      {
          [ID = <Integer>,]
          [TYPE = <Integer>,]
          [BANK = <Integer>,]
          [PARAM = <Integer>,]
          [PARAM_EX = <Identifier>,]
          [X = <Integer>,]
          [Y = <Integer>,]
          [W = <Integer>,]
          [H = <Integer>,]
       }]
     [CALCULATION_RULE_DATA_RECORD = <Identifier>, ]
     [OBJ_RETURN = <Integer>, ]
     [OBJ_ESCAPE = <Integer>, ]
     [OBJ_FOCUS = <Integer>, ]
}
CALCULATION_RULE_DATA_RECORD <Identifier>
{
   [X = <Integer>, ]
   [X_MUL = <Integer>, ]
   [X_DIV = <Integer>, ]
   [Y = <Integer>, ]
   [Y_MUL = <Integer>, ]
   [Y_DIV = <Integer>, ]
   [W = <Integer>, ]
   [W_MUL = <Integer>, ]
   [W_DIV = <Integer>, ]
   [H = <Integer>, ]
   [H_MUL = <Integer>, ]
   [H_DIV = <Integer>, ]
}
MENU_DATA_RECORD <Identifier>
{
    [ITEM <Identifier>
     {
         [SUBMENU = <Identifier>,]
         [ID = <Identifier>,]
         [TEXT = <Identifier>,]
         [IS_ACTIVED,]
         [IS_CHECKED,]
         [IS_SEPARATOR,]

     }]
}



SymbOS Memory Model


An app has 3 areas defined: CODE, DATA, TRANSFER
When SDK compile and makes the Symbos APP take in account all this. All the code declared in C will be put in the CODE AREA, all the data vars, etc. declared will be put in DATA AREA and all the resources added will be put in TRANSFER AREA.
If you want to add variables or data declared in C into TRANSFER AREA, you will need to put them inside of this #includes.

#include "symbos\symbos_transfer_area_start.h"
#include "symbos\symbos_transfer_area_end.h"


It's very important to declare this #includes at the end of all the data declared. We need that compiler generate the bigger address for our transfer area. Then we could have something like:

unsigned char g_data;
#include "symbos\symbos_transfer_area_start.h"
unsigned char g_t_data;
#include "symbos\symbos_transfer_area_end.h"

But no!

#include "symbos\symbos_transfer_area_start.h"
unsigned char g_t_data;
#include "symbos\symbos_transfer_area_end.h"
unsigned char g_data;
 

API Symbos SDK v.0.0.1 <DOC> <DOWNLOAD> 

It shows you how to create a Timer and play a PT3 file, furthermore you can know how to open a file system dialog and capture window messages.
<DOWNLOAD>

No hay comentarios:

Publicar un comentario