Category Archives: Ports

Windows version (and screen mode control)

As mentioned in the earlier posts, a large amount of this Christmas vacation was spent on the Windows version of M.A.C.E. runtime, and creating something for Windows users to try out. Now all the core work has been done, and we have the first prototype of the Windows port of runtime – with all of the existing test applications now available also as Windows executables. Now, there are a couple important points:

  • The windows executables are currently built only for the 64-bit x64 architecture
  • They have only been tested on Windows 10 (and only on Toni’s brand new 3.06Ghz Xeon W3550, and whatever processor Pukka’s new PC has). We have no idea on what other computers they work (or do not work)
  • You might want to avoid running them under certain virtualization software applications, as at least on Toni’s VirtualBox the performance was… not very stellar, at least compared to a physical PC without virtualization.
  • The PC keys are (for now) mapped permanently as follows:
    • Left alt = Left command
    • Left ctrl = Left option
    • Right alt = Right command
    • Right ctrl = Left control
  • Under windows 10, the “windows square” key (between Ctrl and Alt) cannot be used by the emulator as command or option key, because the Windows OS doesn’t seem to allow it to be fully captured (only partially).
  • AltGr key does NOT work as Right alt, because on Windows AltGr actually simulates Left Ctrl + Left Alt key presses. We need to investigate this more in the future.
  • The filesystem package is cached under Users -> username -> AppData -> Roaming -> MACE, with individual cache folder for each pre-packaged test application. So, if you for example create cool Continuum Galaxy files, this is where you’ll find them. And as AppleDouble files, they are exchangeable between M.A.C.E. on Windows, M.A.C.E. on Mac OS X, and theoretically (but not tested) with the Executor emulator which also uses AppleDouble files.

Below is a screenshot of the currently available test apps running on Windows 10:

If you have Windows, you can right now try them out in the Downloads section on this page.

Screen mode control: Full-screen mode and pixel doubling

Another neat new feature that was added to the new M.A.C.E. runtime version, besides the Windows compatibility, is the ability to switch between windowed/fullscreen modes on the fly, and also toggling the pixel-doubling feature. The shortcuts for these are:

  • Cmd+Shift+1: Toggle pixel doubling mode
  • Cmd+Shift+2: Switch between windowed and full-screen modes

These keyboard shortcuts were chosen (for now) as they should conflict very little with existing Mac applications, as they were used as disk eject FKEYs on real Macs.

This new feature has been both updated into the existing Mac OS X test app bundles, as well as in the new Windows versions.

Full list of changes since last post

2020-01-07 00:39:56 +0200 • Skip unwanted packaged VFS entries
2020-01-06 23:40:32 +0200 • Don't cache OSX 10.6 vs 10.9 target in CMake
2020-01-06 20:32:52 +0200 • Fix typo in scaline range check in _StretchBits
2020-01-06 19:10:24 +0200 • Bump runtime version & tweak version info format
2020-01-06 07:08:39 +0200 • Load package VFS from Win32 resource on Windows
2020-01-06 07:07:18 +0200 • Include dynamically generated .rc in win32 targets
2020-01-06 07:06:34 +0200 • Fix encoding of special symbols in two test apps
2020-01-06 06:05:01 +0200 • Add extracting VFS archive in initialization code
2020-01-05 04:30:25 +0200 • Add file archive reader, and clean up CMake files
2020-01-04 23:20:46 +0200 • Sign-extend <32bit args to prevent ARM optimizat..
2020-01-04 04:18:12 +0200 • Try fix Raspberry hMenu bug, enforce 16-bit menuID
2020-01-03 22:22:10 +0200 • Lock SDL window data during screen mode switch
2020-01-03 21:52:42 +0200 • Refactor display toggles to use DynamicConfig keys
2020-01-03 21:50:30 +0200 • Add first part of DynamicConfig system (UserPrefs)
2020-01-01 17:54:41 +0000 • Disable JSON parser tests from build
2020-01-03 01:20:14 +0200 • Fix DynamicConfiguration JSON dependency + bin dir
2020-01-03 00:39:24 +0200 • Merge branch 'master' of 
2020-01-03 00:39:21 +0200 • Add missing header search path for JSON lib
2020-01-03 00:36:54 +0200 • Fix OSX target, CMP0066 and set SDL2 debug/release
2020-01-02 23:08:12 +0200 • Merge branch 'master' of 
2020-01-02 23:08:06 +0200 • Specialize OSX Cmake config to 10.6 and 10.9 bases
2020-01-02 20:36:10 +0200 • Add JSON parser to the MACE runtime (for configs)
2020-01-02 19:09:33 +0200 • Also fix the Mac icns for previously invalid icons
2020-01-02 18:51:14 +0200 • Add stub for DynamicConfiguration module
2020-01-02 18:50:30 +0200 • Sanitize Windows key mappings to be more usable
2020-01-02 04:13:26 +0200 • Add ICO files to EXEs, & use console only in debug
2020-01-02 04:11:18 +0200 • Use debug/release SDL2 lib depending on app target
2020-01-02 04:09:56 +0200 • Reconvert Windows ICO files
2020-01-02 04:09:39 +0200 • Fix incorrect icon assignments of couple test apps
2020-01-02 04:08:20 +0200 • Make SDL2-static compile on VC release mode
2020-01-02 00:51:30 +0200 • Add processing of Windows ICO files
2020-01-01 23:49:58 +0200 • Fix trap glue generator to use new byteswap macros
2020-01-01 23:48:56 +0200 • Refactor cmake to use offline icon conversion
2020-01-01 20:39:58 +0200 • Add lpng 1.6.37 to ThirdParty external libraries
2020-01-01 17:10:36 +0200 • Force redraw of screen on SDL expose events
2020-01-01 15:38:09 +0000 • Haiku compilation fixes

Happy New Year!

This is just a quick status update to celebrate the new year 2020. As teased in the Christmas update one week ago, there has been some progress on the cross-platform ports of M.A.C.E., and this update is just to give a brief glimpse of the state of Windows and Raspberry ports (with a new year celebration theme):

Platform port status: Raspberry PI

Thanks to the hard to work and big efforts done by Pukka on the Raspberry PI port this year, we finally got it to the stage where Toni was able to integrate the platform into CMake build system, and create working builds for the test applications. Pukka found some performance issues in the SDL rendering, which motivated Toni to also get a Raspberry PI to help debug and identify the problem.

It was figured out, that the SDL2 graphics implementation we had previously used had serious issues, and was rewritten mostly to remove dependency on SDL surfaces, using instead SDL texture for the rendering. With this change, the performance on Raspberry improved to the point of matching the Mac (and Windows) platforms. Additionally, we took this opportunity to improve the fullscreen & pixel-double rendering code to the point that they are also almost ready for public testing.

However, for some reason sound does not yet work on the builds done by Toni on Raspbian 10, although they seem to work on Pukka’s Raspbian 8. This need some more investigation, alongside some other issues on the platform. The basic X11 view driver + software renderer driver combination seems to offer however a good solution for the time being.

Platform port status: Windows

The Windows port, which we teased one week ago in the Christmas update, has advanced quickly and will soon be ready for testing. It took in total one week (the Christmas vacation) for fixing the code for MSVC compiler compatibility (a couple thousands errors), and getting the builds to run. The changes we needed to make include:

  • Fixing problems with zero-size struct arrays
  • Lack of typeof(x) macro leading to need to refactor all byte-swapping and RSAlloc macros (and places where they were used)
  • A couple header changes (such as alloca being defined in different headers on POSIX vs. MSVC)
  • Adding some Windows API code for file system iteration and manipulation alongside of POSIX/Std C code
  • Fixing some bugs that were surfaced by the new port, but were affecting all platforms
  • Other minor changes (clock API, refactoring unistd references, tweaking CMake configs, etc…)

The remaining tasks for first Windows test release are still integration with Windows executable resources, and storage of the NativeFS data on windows builds.

What’s next?

The year 2020 should definitely bring us to the point of releasing a more generic way to run M.A.C.E., including additional platform support, and compatibility with much more applications. At the moment the focus is – beside adding the new platform support – on getting as many of the known issues in the current test applications fixed (which you can follow in our status page). But looking forward to the stage #2 of project, we also hope to start work on Sound Manager and Color QuickDraw implementation in the second half of 2020.

Full list of changes since last post

2020-01-01 02:31:53 +0200 • Fix order of debugger setup in environment headers
2020-01-01 02:18:32 +0200 • Set MemErr to noErr if GetHandleSize succeeds     
2020-01-01 02:17:18 +0200 • Add Finnish Apple Macintosh Basics as test app    
2019-12-31 22:49:19 +0200 • Fix byteswap sign bug in CalcMask/SeedFill        
2019-12-31 04:47:15 +0200 • Only grab input in fullscreen mode                
2019-12-31 04:12:39 +0200 • Merge branch 'master' of  
2019-12-31 04:12:34 +0200 • Fix GCC byteswap macros for raspberry pi          
2019-12-31 03:59:25 +0200 • Use left control as command key on windows        
2019-12-31 01:46:39 +0200 • Refactor SDLPlatform to use Textures, not Surfaces
2019-12-31 00:07:32 +0200 • Merge branch 'master' of  
2019-12-31 00:07:13 +0200 • Update CMake configs and MacTCP for raspberry pi  
2019-12-30 22:25:41 +0200 • Merge branch 'master' of  
2019-12-30 22:24:27 +0200 • Fix buffer overflow in StretchBits dstScanlineBuf 
2019-12-30 21:43:20 +0200 • Fix case-sensitive FS filename issue in CMake file
2019-12-30 02:07:02 +0200 • Fix+optimize pixel-double and fullscreen rendering
2019-12-29 22:41:31 +0200 • Merge branch 'master' of  
2019-12-29 22:41:21 +0200 • Fix Windows build audio issue (SDL buffer format) 
2019-12-29 22:39:38 +0200 • Fix crash: Add missing Open/OpenDeny error checks 
2019-12-29 03:57:01 +0200 • Fix debug strcat in AVLTree.c for Mac version     
2019-12-29 03:33:38 +0200 • Refactor byteswapping (& clean up lot of warnings)
2019-12-29 03:25:58 +0200 • Enable console mode for now in MSVC (for debug)   
2019-12-29 03:25:18 +0200 • Fix signature of argc argument in main method     
2019-12-28 23:36:15 +0200 • Fix bug in path separator conversion in MSVC build
2019-12-28 17:32:02 +0000 • Fix some sign bugs, 1000 miles now starts on Win32
2019-12-28 17:29:58 +0000 • Use MSVC built-in byteswap macros for byteswapping
2019-12-28 17:28:21 +0000 • Fix SDL main & set executable as a Windows GUI app
2019-12-28 15:25:55 +0200 • Fix malloc.h/alloca.h header includes for MacOS   
2019-12-28 15:02:36 +0200 • Merge branch 'master' of  
2019-12-28 15:02:31 +0200 • Clean up misc debug macros etc before win32 merge 
2019-12-28 02:22:10 +0000 • A MAJOR Windows and MSVC compatibility update     
2019-12-27 21:59:06 +0000 • Fix potential timestamp conversion shift overflow 
2019-12-27 21:56:14 +0000 • Fix byteswap bug in fractional pen location init  
2019-12-27 00:39:38 +0000 • Don't try to return value from void function      
2019-12-27 00:00:32 +0000 • Fix wrong data size in low-mem Rect setter macro  
2019-12-26 23:00:41 +0000 • Merge branch 'master' of  
2019-12-26 23:00:27 +0000 • Ignore MacOS-specific files in MSVC cmake targets 
2019-12-26 22:58:38 +0000 • MSVC compatible SDL clock (and rotate macros)     
2019-12-27 00:09:04 +0200 • Init PortList and ChunkyDepth                     
2019-12-26 21:18:10 +0200 • Improve InitApplZone, add some CQD low-mem globals
2019-12-26 21:09:34 +0200 • Add proper alpha to SDL RGB output (->pixeldouble)
2019-12-26 21:08:03 +0200 • Add temporary IODone stack hack for MacTCP driver 
2019-12-26 21:04:59 +0200 • Use new enum for killCode in Sound Driver         
2019-12-26 21:04:20 +0200 • Add more logging to .IPP driver 

Happy Holidays!

It’s again the Christmas season, and time again for the annual holiday update, now for the second time! As our greeting to you, here’s the (apparently now traditional) Christmas tree easter egg screenshots from Dark Castle running the latest M.A.C.E. version (it appears only when the game notices that the system time is set to 25th of December in UTC time):

Dark Castle was one of the first games we actually tried M.A.C.E. on over one year ago, and it was already working quite well on the previous Christmas. At that time, the CPU bugs were preventing FireBall levels from being played, but luckily those issues were fixed during this summer, and now all the levels are in playable state.

There are however still minor hiccups, such as weirdly behaving robots, dungeon key being always on the right-most side in the Trouble 3 level, Mutants spawning too quickly, Burning Eye not shooting fireballs, etc. Pukka thinks a common denominator for these issues might be some random number generation code in Dark Castle, but it still needs to be analyzed further.

To celebrate the progress, we recorded a short video of Dark Castle gameplay (with Christmas tree in The Great Hall) on this Christmas Day for your entertainment – all rooms were visited, but sadly I was not lucky enough to topple the Black Knight off his throne this time, even after two tries:

Dark Castle running on M.A.C.E. (Christmas Day easter egg)

Teasers for 2020

Sadly the holiday season has been very busy, which has also slowed down the project progress a little bit. There’s still some teasers for upcoming features which are almost complete, but not yet ready for release:

MacTCP driver

After we tested Bolo in M.A.C.E., we got inspired by the network support it has and had a idea about trying to implement a simple MacTCP driver in M.A.C.E., which would allow us to try out Bolo’s network gameplay we used to play with long time ago. However, the non-standard IODone mechanism, and Bolo’s tricky network performance measurement code, there is still a bit of work to be done to get that into playable state. However, MacTCP Ping seems to be working already quite well, including the DNS resolver:

There is though a “record route” option in “Options” menu, which we could not test because for some reason even using the same option on the real ping (ping -R) on Mac OS X causes the echo packets to get lost.

A more proper introduction about how this all works will be added later when we get the entire driver to work. For now, at least UDP calls to the .IPP driver seem to be working on an “okay” level, although they have so far been really tested only with Bolo, and only for the very first couple UDP packets exchanged by it.

Windows support

As many people have requested, we are already experimenting with adding a third platform into the build system, Windows (from Microsoft, the notorious arch-enemy of Apple Computer 🙂

We already fixed a couple thousand build errors, but there is still a lot of work to be done. For example, the MSVC compiler has a lot of source-code level differences in the C compiler, which need to be abstracted to allow the code to compile both with LLVM/GCC and MSVC targets. Additionally, the networking, file system APIs – and a bunch of other things we have – are POSIX/Unix-only at the moment, which need Win32/64 equivalents to be implemented.

Beyond those two work-in-progress features, we are also still working on increasing stability through bug fixing and debugging. You can always follow the progress on this blog, and check the list of compatible applications in the “Status” page. Thank you for you interest in our efforts, have a merry Christmas!

Full list of changes since last post

2019-12-21 14:09:25 +0200 • Fix VerticalRetraceMgr byteswap bug in inVBL flag 
2019-12-21 14:08:18 +0200 • Add UDPWrite implementation to MacTCP emulation   
2019-12-20 03:14:50 +0200 • First successful UDPRead in MacTCP call (w/ Bolo) 
2019-12-20 01:00:52 +0200 • Implemented UDPCreate for MacTCP driver           
2019-12-20 00:01:36 +0200 • Add MacWWW test app (not working, needs color QD!)
2019-12-20 00:00:21 +0200 • Make MacTCP ipctlEchoICMP support async operations
2019-12-19 23:57:26 +0200 • Improve DA/DeviceMgr enums (accXXX, ioInProgress…)
2019-12-19 23:55:07 +0200 • Fix byteswap bug of dCtlDelay in SystemTask       
2019-12-18 19:22:56 +0200 • Disable unused 128-bit float test code            
2019-12-17 04:29:47 +0200 • Reinforce interrupt safety of device manager calls
2019-12-17 04:02:39 +0200 • Don't close the MacTCP driver                     
2019-12-15 05:23:27 +0200 • Add very primitive foundation for MacTCP driver   
2019-12-15 03:42:24 +0200 • Add a couple more kCStackBased mixedmode handlers 
2019-12-15 03:40:51 +0200 • Add missing prWrErr from earlier PRAM modification
2019-12-15 03:39:53 +0200 • Make RSReturnValue argument safe for function call
2019-12-15 03:37:15 +0200 • Add the DRVR 22 MacTCP (.IPP) driver to fake ROM  
2019-12-15 03:35:32 +0200 • Add MacTCP Ping test app to CMake JSON config     
2019-12-15 02:48:56 +0200 • Fix indexing for GetFileInfo/SetFileInfo          
2019-12-15 02:45:45 +0200 • Start work on kCStackBased MixedMode routine type 
2019-12-15 02:44:19 +0200 • Fix off-by-one-byte bug in FindFolder fld# handler
2019-12-13 03:25:39 +0200 • Add dummy ReadXPRam and WriteXPram for Bolo     

Progress on Haiku port

With help of the new build system, we have now foundation to make porting to other host platforms easier. Currently, Pukka is working on Rasperry Pi port, while I today managed to get the emulator to compile and run on Haiku for the first time!

“Stunt Copter” running on Haiku, with console output on the terminal

With the support for multiple application-specific build targets, we could immediately get all the (currently functional) test apps to run. Below is screenshot of a few of them running at the same time:

Dark Castle, PT-109, Railroad Tycoon and Stunt Copter running on Haiku

The sound output took a bit tweaking to get to work, as for some reason Haiku’s SDL2 implementation did not handle unsigned 8-bit audio (native Mac format) so we had to briefly hack in support for converting it to signed 16-bit PCM on the fly. Sadly, modifier keys don’t work yet, and mouse input is broken, but emulation, file system, rendering and sound output appear to be working ok for now.

There’s however still much to do, and ports aren’t yet a priority, so these ports will probably see less action in the near future until we get all the other tasks done.

EDIT: Here’s a short video of first level of Prince of Persia running in MACE on Haiku:

Prince of Persia running in MACE on Haiku running in VirtualBox on Mac OS X