One of the most heavily used application I have is nspire_emu. I use it for testing my programs and debugging. Up until today, I used a VM to run the program.
I decided that ~1GB of RAM to run a small emulator was a little too much – not to mention other overheads. I decided to install Wine and get the emulator to run on OS X without a VM.
Unfortunately, there were some minor issues to getting it to run.
- Wine buffers stdout. This means messages from the serial port weren’t being showed on the screen until the buffer was full.
- The easiest way to fix it was to modify the sources to output on stderr instead.
- The binary the mingw cross compiler produced on my Mac kept crashing. Yet the original binary from the same source worked fine.
- The binary also had garbage titles and menu options.
Turns out the crashing was caused by a dodgy hack for quickly dumping an array. The array was casted to a va_list which worked for the original compiler but not for my mingw compiler. This was fixed easily.
The garbage in the titles and menu options was caused by the resources file being incorrectly compiled by my cross compiler. I fired up my VM, installed a native mingw system, compiled it from there and brought the (now correct) object file across and plugged it into the Makefile.
And of course, I changed every printf, putc call to a fprintf(stderr, etc..) call so Wine doesn’t buffer output.
I put everything together nicely into a Applescript bundle which launches Wine which launches the patched emulator. I’ve made this available for others who want to use it and included a README too.