blog:x68_devtools

Sharp X68000 Development Tools

Most of the standard system calls you will need to use are either doscalls or iocscalls - this refers to whether the system call is handled by DOS (Human68k DOS, of course), or directly by the BIOS/ROM/IPL functions. Some versions of the C compiler provide a standard C library, including a version of newlib in GCC 4.x, but to do anything other than the basic standard functions you'll need to look at the Sharp-specific calls.

Those functions include things like opening devices, setting screen modes, manipulating graphics memory, reading IO ports etc.

Sadly, most X68000 documentation is in Japanese. To find any information on the available system calls you will need to look up the definitions of those functions in either.


Inside / Outside X68000 series

The two main technical manuals for the X68000 are the Inside and Outside series. Inside X68000 deals with mainly software; memory map, system architecture, system calls, IO interfacing etc, and Outside X68000 is mainly hardware interfacing and the electrical side of things.

archive.org, local copy archive.org, local copy


X68000 Programmers Reference

Comprehensive set of programmers reference manuals covering most of the system calls, the use of (very early) GCC and GDB tools and more.

archive.org, local copy archive.org, local copy

archive.org, local copy

  • Blue book (#0) covers the install and use of early versions of GCC, HAS assembler and GDB
  • Red book (#1) covers the use of the early versions of GCC and the GDB debugger
  • Green book (#2) covers function calls available in old versions of GCC and doscalls (including better worded descriptions compared to 'Inside X68000' or the 'PUNI docs')

It's fair to say that #0 has more assembly examples than #2, which is probably the one you want if you are interested in figuring out how to use the various X68000 system calls in doscalls/dos.h.

Do be aware that when the various libc function calls are listed, this is referring to the old version of GCC, and not the new version which comes with newlib and a smaller set of functions.


Technical Data book

Although not a programming reference per-se, the technical data book does contain some information that is useful to programmers; it covers a broad spectrum of topics - from CPU registers to a description of the X68000 mouse and its communications protocol.

archive.org, local copy


X680x0 Game Programming with GCC

This is another old book that describes how to use GCC (and period assembler and linker, such as HAS, as listed way down this page) to develop game software on the X68000.

NFG Games, local copy

Source code: archive.org, local copy, files extracted from disk images

To be fair, the best source of material for this one is found in the example source code. Note: Disk 1 is just the old GCC compiler, the examples are found on Disk 2. You can either download the disk images and mount them in a real or emulated X68000, or download the extracted sample files so that you can view them with any normal text editor. Be aware that some of the code uses S-JIS encoded for actual function names!!!


Puni docs

The PUNI docs are another source of system information, a bit clearer than the unwieldy several hundred pages of the Inside X68000 book, but not a lot of supporting information or examples.

Note that all of the files are S-JIS encoded, but should translate well on Google. You'll need a text editor that can understand S-JIS encoding though. I can recommend wxMEdit as a good all-round multi-platform hex and text editor with multiple language support.

Here's the full contents of the PUNI documentation.

Filename Description Download Translation
assembler.rtf Description of how to use the X68000 assembler, including command line switches. Not directly relevant to anyone using GCC. assembler.rtf -
basicfunc.rtf X-BASIC external function call list. Not directly relevant to anyone using C. basicfunc.rtf -
bioswork.rtf Description and sizes of the BIOS/ROM memory locations. bioswork.rtf -
code.rtf Note sure what this is - a character encoding table?? code.rtf -
condition.rtf Explanation of the condition bits in status registers resulting from arithmetic operations. condition.rtf -
doscall.rtf List of the available DOS/Human68k system calls; open file, get character input, allocate memory, etc. doscall.rtf Gamesx Wiki
fdformat.rtf Table of the various supported 3.5“ and 5.25” floppy disk formats and their layout (sectors/tracks/heads) etc. fdformat.rtf -
fefunc.rtf List of the available arithmetic operators, including multiplication and division, and their parameters. fefunc.rtf -
filesystem.rtf Interfacing with filesystems - e.g. if implementing your own. filesystem.rtf -
fpcall.rtf Explanation of the various Japanese Kana/Kanji character set functions. fpcall.rtf -
iocscall.rtf Description of the available low level system calls for interacting with hardware; setting video modes, reading joystick position, playing audio etc. iocscall.rtf -
iomap.rtf Illustration of the X68000 hardware memory map, size of memory locations and description of the values at those addresses. iomap.rtf -
oswork.rtf Description of the Human68k working memory area, hooks/trap/vector locations. oswork.rtf -
programmers.rtf Overview of most memory locations used by application programmers; e.g. description of the video memory registers and their meaning, location of data in SRAM etc. programmers.rtf -
puni.rtf Japanese document describing the contents of all of these files. puni.rtf -
scsicall.rtf SCSI interface system call descriptions. scsicall.rtf -
trap.rtf List of available trap functions; e.g. sound handlers, break/interrupt routines. trap.rtf -
v2func.rtf Description of new functions available in Human68k v2.0. v2func.rtf -

There is a wiki on Romhacking that has some of the above files partially translated.


This is a cross-compiler - you run it from Linux and it targets the X68000. So you can use all your modern editors and revision control systems etc. The version of GCC reports as:

human68k-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/toolchains/x68k/bin/human68k-gcc
COLLECT_LTO_WRAPPER=/opt/toolchains/x68k/libexec/gcc/human68k/4.6.2/lto-wrapper
Target: human68k
Configured with: ../gcc-4.6.2-human68k/configure --prefix=/opt/toolchains/x68k --target=human68k --disable-nls --disable-libssp --with-newlib --without-headers --enable-languages=c --disable-werror : (reconfigured) ../gcc-4.6.2-human68k/configure --prefix=/opt/toolchains/x68k --target=human68k --disable-nls --disable-libssp --with-newlib --without-headers --enable-languages=c --disable-werror
Thread model: single
gcc version 4.6.2 (GCC)

The project was originally hosted on Github, but was last updated in June 2013; that's a long time ago, but it's still the latest version of GCC available.

Pre-built binaries for Linux:

If you want to build the tools from source, here's a handy script that patches them with a required fix before install; you must apply the patch, as there is a bug in this version of GCC which will cause a segfault during compilation otherwise:

  • build_x68_gcc.zip - Run the included bash script to configure and patch the source from Github

Note as well, that the current distribution includes some C header prototypes that cause bus errors due to struct alignment problems. This is discussed here: https://nfggames.com/forum2/index.php?msg=41392 The pre-compiled bundle above already has the fixes applied to dos.h.

Using the toolchain:

  • Download the pre-built binaries above and extract in /, it unpacks to /opt/toolchains/x68k
  • X68000 library functions are defined in:
    • /opt/toolchains/x68k/human68k/include/dos.h
    • /opt/toolchains/x68k/human68k/include/iocs.h
  • Use the sample makefile below
# Names of the compiler and friends
APP_BASE = /opt/toolchains/x68k/bin/human68k
AS 		= $(APP_BASE)-as
CC 		= $(APP_BASE)-gcc
LD 		= $(APP_BASE)-ld
OBJCOPY 	= $(APP_BASE)-objcopy
STRIP 		= $(APP_BASE)-strip

# libraries and paths
LIBS	 	= -ldos -liocs
INCLUDES 	=          

# Compiler flags
ASM_FLAGS 	= -m68000 --register-prefx-optional
LDFLAGS 	=
CFLAGS 		= -m68000 -std=c99 -fomit-frame-pointer -Wall -Wno-unused-function -Wno-unused-variable -O3
LDSCRIPT 	=
OCFLAGS		= -O xfile

# What our application is named
TARGET	= test
EXE	= $(TARGET).X

all: $(EXE)

OBJFILES = test.o 

$(EXE):  $(OBJFILES)
	$(CC) $(LDFLAGS) $(OBJFILES) $(LIBS) -o $(TARGET)
	$(OBJCOPY) $(OCFLAGS) $(TARGET) $(EXE)

sample.o: sample.c
	$(CC) $(CFLAGS) -c $< -o sample.o
	
clean:
	rm -f *.o $(EXE) $(TARGET)

One of the problems with this toolchain is that you can't use existing library code from earlier compilers. There are possibly some issues with the assembly syntax as well, there are some details documented on the NFG Games forum: https://nfggames.com/forum2/index.php?topic=4850.0

It's the most modern version of GCC currently available on the X68000 and probably the easiest to use, as long as you are not working on any legacy code or libraries.


Older Versions

I haven't tested any of these, but they have been used at some point by others:

A port of GCC 2.95.2 to run natively on the X68000. So you'll need to compile your code on an emulated or real X68000:


GCC 1.42

This runs on the X68000 itself, so you'll have to compile your source code from within either a real or emulated X68000 environment:

These early versions of GCC rely on a different assembler, so you'll also need:

GCC 1.30

Another cross compiler toolchain, but this is built for Windows:

Although this is an old version of GCC, it's a recent package which includes demo source code and some updated documentation put together by users from the NFG Games forum: https://nfggames.com/forum2/index.php?topic=6140.msg42562#msg42562

  • blog/x68_devtools.txt
  • Last modified: 2020/08/12 20:28
  • by john