Dead Hackers Society
Select »
 
 

68k Inside

Sommarhack 2024

Silly Venture 2024 SE
External scenelinks  Special feature  Online compos  IRC #atariscne  Garfield vs Atariscene

Select article
Interview with Kalms/TBL
OSX/Atari GCC crossdev
Atari GCC development
PowerPC history
SatanDisk
Overscan
Multicolour
  dhs.nu special feature #2
 
Gizmo of DHS writes about Mac OS X Falcon cross-development, including downloads of cross-development tools
Published August 19, 2006
 


Cross developing low-level Atari TOS/FreeMiNT applications on Mac OS X using Xcode
Magnus Hansson, gizmo(at)dhs.nu
 
  1. Cross developing
  2. Cross GCC 68k on Mac OS X
  3. Low-level screen access
  4. Using Xcode and GCC
  5. Article files

 

Cross developing

A couple of years ago I started to experiment with the FreeMiNT cross compiler tools available for Linux on the SpareMiNT site. The pre buildt gcc-2.95.3 worked fine and I developed a small non-system startup library for low level screen initialization and interrupts. The "devkit" included Aranym 0.9.0, where the debug messages from the demo system were printed to the Linux console. This emulator development on my old Dell 366MHz laptop continued, and we stripped our major assembler demo system, DHS Demo System v15, to also work in Aranym with Devpac. Most of our 3D engine was developed on this configuration, as well as the recent 4K intros from DHS. Later on, this configuration was moved to Mac OS X, and the emulator hacking continued with productions like the Outline Invite, the Genocidal 96k and finally Derealization. The smoothness of having all the scene files from Lightwave 3D, the texture convert scripts and all other custom tools we use, and a decent source editor (vim!) is a big advantage for using Aranym.
 
On the problematic side, Aranym have its shortcomings. As it's not trying to be a Falcon emulator, several Falcon features are missing, the major thing being a working DSP with audio. The MFP timers doesn't work properly and the VBL is always fixed at 50Hz, unlike a real Falcon where the demo would run at 60Hz VBL. And of course, Aranym doesn't show the real speed of the code as it would be on a Falcon. This unfortnely eliminates Aranym as a full featured development system, a real Falcon is needed as well. The above mentioned demos have been co-developed with Aranym and CT60.
 

Cross GCC 68k on Mac OS X

Inspired by Patrice Mandins efforts of building a gcc cross compiler for Atari FreeMiNT and porting a lot of SDL applications, I recently managed to compile gcc-3.3.3 and binutils 2.13.2.1 for Mac OS X using gcc-4.0.1 with m68k-atari-mint as the target. A pre buildt binary package for PPC is available here: m68k-atari-mint.zip. To install the compiler, uncompress the archive to some safe place, i.e. the desktop. Then move the m68k-atari-mint folder to /usr/local. You now have a gcc-3.3.3 cross development system. Also, the MiNTlib and MiNTbin is included in the cross environment. To compile a simple Hello World application, you have to open the terminal and:
  1. Set the path:
     
      # export PATH=$PATH:/usr/local/m68k-atari-mint/bin

  2. Create the source for hello.c
     
  3. Compile the source with:
     
      # m68k-atari-mint-gcc hello.c -o hello.prg

This will produce the Atari/TOS executable hello.prg.
The stack space is usually set to low by default. You have to fix that with something like:
      # m68k-atari-mint-stack --size 10240 hello.prg

Low-level screen access

Now we have a compiler and the standard C library to write text and read files. But we want to code demos! One possibility is to use the SDL library as P. Mandin mentioned above does. However, in the traditional demo coding way, where we want the fastest graphics possible, we need custom screen rendering routines, preferably with direct memory access and hardware register manipulation. This could be perfectly done in C, but as we are so used to the Devpac assembler hacking, we want to do these details in assembler.
 
Many people seems to afraid of the infamous and strange gcc assembler syntax. Perhaps this was true for x86 (and perhaps also for 68k?) back in the gcc-2.xx days. The truth is however that the syntax is almost identical to the Devpac mother tongue we are so used to. I put together a simple screen library that initializes a 320x240x8 screen, the Timer B and C interrupts, and includes routines for setting the palette do proper screen swapping. Also a 6 bitplanes c2p is included. The archive can be found here. Feel free to improve it! It is based on our Devpac demo system. All hardware setup is done in supervisor mode of course, but the actual C routines in the "mainloop" is executed in user mode. In this way simple printf-debugging is possible, which is useful by using Aranym with the console redirected to the OS X terminal.
 
Included in the archive is a simple rotator (effect.c) that uses a mixture of C and ASM just to show that it is possible to mix languages without too much troubles. In the archive there is also a Xcode project file for using the cross compiler and the non-system startup library with Apples developer environment.
 

Using Xcode and GCC

Xcode 2.4 is Apple Computer's integrated development environment for Mac OS X. Anyone familiar with Microsoft's Developer Studio will know the concept. Xcode is tightly bounded to gcc-4.0.1 shipped with the OS X, but it is possible to do "external builds" by using a separate makefile. Any changes to the startup library's build options should then be done in the Makefile.
 
Xcode main window

 
 
One of the many useful features of Xcode is the m68k assembler syntax hi-lightning:
 
Xcode Assembler syntax hilight

 
 

Article files

Files linked in the article
 
  1. m68k-atari-mint.zip (19MB)
    Mac OS X Xcode FreeMiNT development tools. PowerPC only.
     
  2. gcc_start.zip (17kB)
    Atari FreeMiNT GCC demo startup code together with an example effect. Compiles with the Xcode cross development tools.
     
© 1994-2024 Dead Hackers Society Contact: Anders Eriksson