By this page i want to offer my MSX projects to the community. Sorry about my poor english writting. I am spanish :-)
The SDCC is a cross-compiler for small devices that runs in Windows and in Unix/Linux platforms, that allows you to generate code for a large variety of 8-bit and 16-bit platforms. Among these plataforms we have the Z80 and the Z80 with GameBoy extensions (GBZ80).
The Z80 code that SDCC generates by default is not MSX targeted and the final output is always an IntelHex file with the code. With this backend modification for MSXDOS we will be able to easily convert these IntelHex output files into .COM files. The system requirements for cross-compiling are (for both Windows/Unix/Linux platforms):
Both packages can be installed from binaries or sources. The basic files needed to generate .COM MSXDOS executables are:
files.s functionsinterrupt.sin and out to to make easy the Hitech C code compatibilityioport.sThe startup code is indispensable, since it allows SDCC compiled programs to be runable in MSXDOS. putchar.s and getchar.s are only needed if you want to use stdio.h library for standard console input and output (printf, gets, et cétera) (NOTICE: scanf function aren't implemented in SDCC 2.4.0). files.s contains open, close, read, write, et cétera file handling functions for MSXDOS2. interrupt.s contains the interrupt handling functions install_isr and uninstall_isr. The ioport.h header allows programs to access I/O ports by the standard out(address, data) and in(address) way instead of ussing the "sfr at" reserved word in SDCC compiler.
First we have to do is assemble the .s previous files using the as-z80 assembler included in SDCC package:
$ as-z80 -go crt0msx_msxdos.o crt0msx_msxdos.s "or" $ as-z80 -go crt0msx_msxdos.o crt0msx_msxdos_advanced.s$ as-z80 -o putchar.o putchar.s$ as-z80 -o getchar.o getchar.s$ as-z80 -o files.o files.s$ as-z80 -o interrupt.o interrupt.s$ as-z80 -o ioport.o ioport.sWe obtain 6 object files with .o extension and same name. Let's write a small C sample code for testing ejfile.c (we used data2.txt example data file):
#include <stdio.h>
#include <stdlib.h>
#include "files.h"
#define TO_READ 50
char data[TO_READ + 1];
char fd;
unsigned int size;
void main(void) {
fd = open("DATA2.TXT", O_RDONLY);
if (fd < 0) {
printf("Could not open DATA2.TXT\n");
return;
}
size = read(fd, data, TO_READ);
printf("Attempting to read %d bytes. %d readed.\n\r", TO_READ, size);
data[size] = 0;
printf("Buffer = '%s'\n", data);
close(fd);
return;
}
That we compile this way:
$ sdcc -mz80 --code-loc XXX --data-loc YYY --no-std-crt0 ./crt0msx_msxdos.o ./putchar.o ./getchar.o ./files.o ejfile.c
One notice the --no-std-crt0 parameter, that indicates the compiler that should not use the default startup code for Z80, but we provide by command line. --code-loc allows to place code in a specific location: If we use crt0msx_msxdos.s we shall use XXX = 0x106, but if we use crt0msx_msxdos_advanced.s we shall use XXX = 0x170. YYY indicates location for global variables, if we use YYY = 0 global variables will be allocated just after code.
If there are no compile-time errors, among the output files we should have the ejfile.ihx IntelHex file. Now we process this file with the hex2bin tool to obtain a binary code:
$ hex2bin ejfile.ihx
After this command we should have a ejfile.bin in the current folder, that we can rename directly to ejfile.com and execute it in our MSX:
$ mv ejfile.bin ejfile.com
The ejint.c source is an example interrupt handling code that uses interrupt.o and includes interrupt.h. In this case, to compile we must add the interrupt.o file to the SDCC command line.
$ sdcc -mz80 --no-std-crt0 ./crt0msx_msxdos.o ./putchar.o ./getchar.o ./interrupt.o ejint.c
Notice that we have removed the files.o reference because linker does not need it (in this case).
main function parameters (crt0msx_msxdos_advanced.s).main function parameters and for solve global data initialization problem.files.h and files.s has been patched. Now lseek function is POSIX compliantout(address, data) and in(address) addedread and write file access routines return type changed from "unsigned int" to "int" to allow negative resultsmain function parameters support added and global variables initialization problem solvedmalloc, realloc, free, etcIn this section I will publish all the Moonsound related C code builded or adapted by me. All the current published codes are related to two articles appeared in the Call MSX spanish magazine about the MSX scene (numbers 3 and 4). These two articles are about Moonsound programming and all the source codes are spanish commented (sorry for the inconvenience).
sbiload package:In this section I will put all my work related to Huffman compression implementation for MSX.
huffman.tar.gz contains an ANSI-C implementation of the Huffman compression/uncompression algorithms. This archive also contains an specific MSX implementation of the uncompress algorithm for the SDCC compiler. This MSX targeted version requires:
Read the README at huffman/msx subfolder for further details.
In this section I will put source code, tools and data related to VDP programming.
á é í ó ú ü Á É Í Ó Ú Ü ñ Ñ ¡ ¿ and some minor symbols. Here is:
screen 2 compatible tiles (1 bit per pixel, white = 1, black = 0). This is the result of applying this utility to the previous Latin1 charset table.PSG programming: tools and source code.
psg_sample. This code uses the logaritmic conversion table listed at http://map.tni.nl/articles/psg_sample.php.Fixed point math related section. For Z80 and/or MSX specific.

This work is licensed under a Creative Commons License.
Page maintained by Avelino Herrera Morales