Happy summer of 2023! This post is a bit late, as it’s the last day of summer today, but they do say better later than never! Most of progress in this half of year has been done in the spring, as summer has been more quiet, but there’s still a lot of both under-the-hood and actually visible improvements. Here’s a breakdown what’s new, in somewhat chronological order but also a bit grouped by the topic:
Eat my Photons! (and runtime color depth switching)
While trying to get “Eat my Photons!” game to start up, one major feature that was added was the ability to switch color depth using Palette Manager’s SetDepth & color video DRVR’s cscSetMode Control code. That particular SetDepth was actually a non-functional dummy TODO from long time ago, but now it has proper implementation.
The fact that early Macs of this era had fixed resolutions, but adjustable color depths, does show in the fact that for changing modes happens through this single API call. Interestingly, display modes also (at least by default) started from 128, so 128 was 1-bit monochrome mode, 129 was 2-bit 4-color mode, etc. up to 133 for 32-bit color mode.
SetDepth does not only call the driver to select the new color depth, but also handles some quite important tasks while doing so:
- Sets the GDevice flags to reflect whether color or grayscale mode was requested
- Saves highlighted menu & restores it
- Calls InitGDevice to do the actual device reinitialization
- Active palette of front window again (to apply any possible changes to default colors needed for the GDevice’s color table through Color Manager)
- Redraws desktop, all windows, menu bar – and the rounded corners
The InitGDevice, which was already implemented during the early work on color QD, was fixed to get the video parameters from the given mode parameter instead of hard-coded depth. Other duties of this call include graying the screen using cscGrayScreen DRVR call, reinitialization of GDevice pixmap for new depth, reset drawing colors, reinitialize mouse cursor etc.
With these changes (and implementing the Fix2X trap handler) we did get the Eat my Photons! title screen to show up (after it switched from 256 to 16 color mode on the fly):
Sadly we haven’t yet been able to get further in that game, presumedly because of missing Apple Event support.
Improved INIT handling
One thing that was experimented already earlier was support for INIT (extension/control panel) loading, but it was still quite experimental and had bunch of issues with it. Some things we improved were:
- Previously, the INITs would be loaded on system heap, but that was the wrong way to do it. Instead, we now do more like the real Mac system does:
- Use a temporary application heap zone where INIT operates by default. This is thrown away after each INIT load, while persistent data is expected to be allocated explicitly in the system zone.
- Use ‘sysz’ resource to increase system zone size by requested amount (plus minimum 16K slop) IF the system zone does not have enough requested space. Also compact the zone, and re-open active INIT file if needed while doing so.
- Support loading INITs from not just boot folder (System Folder) but also from arbitrary folders, such as Control Panels and Extensions folders.
These improvements allow us to now run more fun toys, such as ColorDesk, which can be used to set the desktop background picture:
Also, Aaron was also experimented with (in this pic the icon family plotting was not yet implemented), with MacEnvy giving interesting information about the MACE environment:
And for fun, we tried loading lots of INITs at once too 😀 This includes Aaron, After Dark, ColorDesk, ColorSwitch Pro (which does not yet work very well), MenuBarPattern and SoftwareFPU:
Icon Utilities – and more Aaron
As mentioned before, the window title bar icons, and scroll bar arrows/indicator were missing because Icon Utilities was missing the icon family drawing routines, so this gave us a good excuse to finally implement them. Brief summary of what this included:
- Added icon family drawing routines, such as PlotIconID, PlotIconSuite, PlotCIconHandle, and such, which share quite lot of code
- Handling the requested transformations (selected, disabled, and lowcolor variants)
- Choosing the appropriate icon data for given transformation and destination depth
- Adding proper label colors to the System (eventually modifiable by the Colors control panel), and applying those to the icons using a very specific tinting method which attempts to imitate Apple’s original tinting as closely as possible
- Handle alignment of icons (vertical and horizontal placement) plus choosing correct icon size for destination bounds
With this ton of work done, a lot of debugging, cursing and bug-fixing, we now have the new Icon Utilities routines working good enough to make Aaron WDEF to appear correctly (as mentioned, in this case the close & zoom boxes, plus the scroll bar contents):
Kaleidoscope Installer – a bunch of file manager fixes
Inspired by how nicely Aaron worked, we wanted to give Kaleidoscope also a try, given it’s the gold standard of classic Mac OS theming. To do this, we actually wanted to try to see how well Kaleidoscope Installer (made with Aladdin InstallerMaker) would work. This led to discovery of a bunch of bugs which we fixed, and a couple missing features which were implemented:
- NativeFS driver’s Prime call was missing IODone call
- DirCreate did not return ioDirID for newly created directory, thus causing the caller to receive parent ID instead
- Return this proper directory ID from FindFolder, when a new folder was created
- Implemented SetCatInfo, and fixed SetFileInfo to not ignore file name. These allow the installer to set correct metadata for files, such as file creator and type…which are quite important!
Sadly this did not yet allow us to try out Kaleidoscope, as that control panel seems to be incompatible with System 6-style control panel (that is, it ignores the “numItems” parameter in the CDEV function). But on positive side, the File Manager fixes also fix the issues we previously had in Compact Pro SEA archive extraction!
Monochrome color QD fixes
While experimenting with color QD in monochrome mode, we noticed a couple glitches which were fixed:
- The optimization case for text drawing was accidentally using background color for text, which was fixed to use the foreground
- Mask buffer was not applied to regions in colorQD mode for 1-bit targets, which caused artifacts at least in Glider 4.x
Default color mode stack – and Colonization
When trying out Colonization, we got hit by mysterious crashes, which turned out to be an stack overflow issue. With some research, we noticed that on color QD macs, the default stack (DefltStack) is three times larger than the default one for “classic” macs (24K vs 8K). So after we increased it, Colonization seems to (mostly) work now…with some minor glitching in a bunch of places (like game setup screens):
RTE exception frame handling fix – and THINK Pascal color mode debugger
One interesting thing that we noticed was that even though the debugger breakpoints in THINK Pascal was working fine in “classic” (68000) mode, they would crash and burn in color (68020+) mode. This was eventually traced down to the fact that in 68020 mode, the 68K uses varying exception frame size depending on the exception type (in this case being a TRAP exception). After we added a (still somewhat hacky) handling of the variation in frame size, we got the debugger to work in color mode too:
BBEdit
Inspired by the fact that ObjectDraw demo app was written by the same guy who wrote BBEdit, we wanted to give it also a try. There was suprisingly a hidden bug in vCheckLoad call mechanism, where we had forgotten to assign 68K registers on exit from native CheckLoad, which caused the resource decompression in BBEdit to fail badly. But with that fixed, BBEdit at least starts up now:
One bonus feature of BBEdit is that its preferences’ file types setup uses the new icon family drawing routines, giving us another test case for them!
Proper MoveHHi implementation – THINK Pascal compilation fix
Another long-time task has been the proper implementation of MoveHHi for Memory Manager, which not only has caused THINK Pascal to fail compilation of large projects due to memory fragmentation, but also has been a blocker for starting implementation of the 32-bit memory manager. With a couple days of research and work, we finally got it working, and THINK Pascal can FINALLY compile even the huge TCL demo apps from scratch without failing due to fragmentation:
Here’s also a pic of Art Class demo app running in THINK Pascal after being compiled:
and the big news…
32-bit Memory Manager!
Not visually very interesting yet, but under the hood quite significant, we have now 32-bit mode support! After the aforementioned MoveHHi was implemented, we finally had all basic 24-bit Memory Manager calls implemented, so we could start implementing the 32-bit mode! As most of code was shared between 24- and 32-bit mode calls, it was pretty straightforward to branch out the 32-bit version, although there we some special cases that needed to be handled. To sum up this:
- Separated the 24- and 32-bit implementations, but both of them still available at same time as memory manager mode could switch dynamically (not tried that yet though)
- Use the extended memory block header for 32-bit memory blocks (12 bytes vs 8 bytes)
- In 32-bit mode, Control Manager needs to use Auxiliary Control Records for storing control variant code. The same applies to Window Manager which stores the window variant code in AuxWinRecs.
- Dispose control’s AuxCtlRec, AND acCTable (if not default one) in DisposeControl
- Do the same for AuxWinRec for windows in CloseWindow
So far the only visible change of 32-bit mode is that instead of complaining about missing 32-bit mode, Ultimate Doom now loads up a bit further, but wants Sound Manager 3.x next :
In future, the availability for 32-bit mode will allow further features, such as memory access optimizations by bypassing the virtual memory system as pure 32-bit pointers (using mmap to map RAM, ROM and VRAM to be contiguous, and avoid having to mask the pointers). We will talk more about this when we have time to experiment more with this and get some results for it.
Started work on Component Manager
As we eventually want to get Sound Manager 3.x working, and we want to support Sound Components from the Day 1, the next major step is implement the Component Manager – which was originally designed for the QuickTime, but was adopted by Sound Manager 3. There also exist some other use cases besides SM3, one quite approachable one to use as a test case being Internet Config. Which makes it even nicer use case is the fact that BBEdit also supports IC, which will allow us to not just experiment hosting IC with Component Manager, but also trying out BBEdit as client for it!
It will still take a bit of work to get visual results, but implementing it is advancing steadily (we’re been working on load-time component file searching and component loading).
Other notable changes
- Added support for version 2 ‘snd ‘ resources in Sound Manager 2.x SndPlay – these were used by Capitalist Pig game
- Fixed broken ioCompletion call mechanism in IODone, was surprisingly long unnoticed, but Hidden Agenda game was interestingly the first one to use asynchronous I/O calls
- Had to update SDL2 to 2.28.1 for XCode 14.3 compatibility and tweak target requirements (which still need refinement)
Stay tuned for the next update around Christmas/new year time! 🙂 Hopefully we will have new builds of MACE available by then, sadly we did not have time to work on that for this update 😦
Full list of changes since last post
2023-07-26 04:11:10 +0300 • Fix 32-bit allocation of default window aux record
2023-07-24 17:58:55 +0300 • Tweak minimum deployment target
2023-07-24 17:57:57 +0300 • Add new frameworks required by SDL2 to make.cmake
2023-07-24 17:56:49 +0300 • Disable dirty rectangle optimization for now
2023-07-24 17:56:25 +0300 • Disable SDL minimize shortcut
2023-07-24 17:56:16 +0300 • Update SDL2 to 2.28.1 for XCode 14.3 compatibility
2023-07-24 17:54:42 +0300 • Fix thread spawning race condition
2023-07-24 14:32:28 +0300 • Add dummy 68040/7.5.5 profile
2023-07-24 14:31:17 +0300 • Mask handle in 24-bit MMWhichZone
2023-07-24 14:29:55 +0300 • Work on RegisterComponentResource
2023-05-07 01:40:58 +0300 • Add CreateFileIDRef selector for FSDispatch
2023-05-05 18:14:38 +0300 • Implement RegisterComponent for Component Manager
2023-05-05 15:57:22 +0300 • Partial RegisterComponentResource implementation
2023-05-05 12:18:07 +0300 • Add gestaltSysArchitecture 'sysa' Gestalt function
2023-05-05 01:48:06 +0300 • Add missing export of Count1Resources in Rsrc Mgr
2023-05-05 01:46:55 +0300 • Partial RegisterComponentResourceFile handling
2023-05-05 01:34:20 +0300 • Allocate component instance table
2023-05-05 01:21:22 +0300 • Allocate & setup component table in InitComponents
2023-05-03 02:26:49 +0300 • Partial InitComponents and GetComponentMgrVersion
2023-04-29 01:11:55 +0300 • Do groundwork for loading System Folder components
2023-04-29 01:09:43 +0300 • Add Component Manager types
2023-04-28 05:41:04 +0300 • Add Component Manager module
2023-04-28 05:11:12 +0300 • Add dummy AEDisposeDesc
2023-04-28 05:05:23 +0300 • Add dummy AEPutDesc, AEPutKeyDesc, AEGetEventHan..
2023-04-28 01:31:30 +0300 • Fix 32-bit MoveHHi handle masking
2023-04-27 00:14:17 +0300 • Handle 32-bit AuxWinRec stuff in CloseWindow
2023-04-27 00:09:00 +0300 • Handle 32-bit AuxCtlRec stuff in DisposeControl
2023-04-26 23:40:21 +0300 • Handle 32-bit mode case in GetControlVariant
2023-04-26 23:39:58 +0300 • Handle 32-bit mode cases in NewControl
2023-04-26 23:07:48 +0300 • Implement 32-bit GetWVariant
2023-04-26 22:57:35 +0300 • Add MenuList validation function
2023-04-26 22:57:03 +0300 • Fix sysmenu check in MBDF 0 (MenuList dereference)
2023-04-26 22:55:31 +0300 • Set MMU32Bit based on machine 24/32 bit mode state
2023-04-26 05:50:49 +0300 • Fix block relocation, update size of claimed space
2023-04-26 05:49:51 +0300 • Fix master pointer offsets in 32-bit CompactMem
2023-04-26 05:48:40 +0300 • Fix offsets for 32-bit mode fake rom resources
2023-04-26 03:34:39 +0300 • Add 32-bit fake ROM rsrcs to 32bit machine profile
2023-04-26 03:33:21 +0300 • Add 32-bit mode support for mem manager prologue
2023-04-26 03:31:42 +0300 • Support 32-bit zones in the zone dump function
2023-04-26 03:30:58 +0300 • Fix missing deref in 32-bit MP flag manipulation
2023-04-26 03:30:19 +0300 • Fix 32-bit MaxLimit stack address masking
2023-04-26 03:29:48 +0300 • Set zone bkLim properly on 32-bit zone growth
2023-04-26 03:29:12 +0300 • Add 32-bit InitApplZone
2023-04-26 03:28:51 +0300 • Fix CompactMem return value for 32-bit zones
2023-04-26 03:27:23 +0300 • Add MemMgrToggle32BitMode
2023-04-26 03:26:05 +0300 • Conditionally enable 32-bit VM at initialization
2023-04-26 03:24:36 +0300 • Fix VM page handler size for 32-bit video driver
2023-04-26 03:23:26 +0300 • Add 32-bit fake ROM resources
2023-04-26 03:21:39 +0300 • Update MakeROMResources tool
2023-04-25 23:17:31 +0300 • Separate 24- & 32-bit mem mgr code to own modules
2023-04-24 13:56:59 +0300 • Add 32-bit machine profile
2023-04-23 03:17:08 +0300 • Finalize MoveHHi second iteration implementation
2023-04-22 00:35:43 +0300 • Partial work on the REAL MoveHHi implementation
2023-04-20 00:21:30 +0300 • Fix 'itlb' 0 rez source and add some default icons
2023-04-19 16:42:05 +0300 • Implement PlotIconSuite in IconUtils (not tested!)
2023-04-19 16:00:03 +0300 • Set up 68k registers on exit from vCheckLoad
2023-04-19 01:11:06 +0300 • Fix RTE instruction exception frame decoding
2023-04-15 20:28:36 +0300 • Fix typo in fakeplus4mb_sys7 profile
2023-04-15 01:00:31 +0300 • Tweak command handling in SMHandleCommand
2023-04-15 00:58:32 +0300 • Support version 2 'snd ' resource playback in SM2
2023-04-15 00:57:05 +0300 • Add missing EnvBootStackSize to classic profiles
2023-04-14 14:45:11 +0300 • Fix invocation of ioCompletion for async FM calls
2023-04-13 22:16:23 +0300 • Allow DefltStack override & use 0x6000 in color QD
2023-04-13 01:09:56 +0300 • Fix byteswap bug in AECreateDesc
2023-04-13 01:07:31 +0300 • Make SetApplLimit behave like on MacOS 7.5.3
2023-04-10 10:46:14 +0300 • Implement AECreateList selector for AppleEvents
2023-04-10 02:22:11 +0300 • Dummy AEManagerInfo AppleEventDispatch selector
2023-04-10 02:05:51 +0300 • Add dummy IUTextOrder selector, for Galactica Demo
2023-04-10 01:36:44 +0300 • Fix subPin stretching blitter color overflow
2023-04-09 04:28:58 +0300 • Handle OpenWD invalid dirID error & remove assert
2023-04-05 19:42:36 +0300 • Fix minor InitZone & SetApplLimit comparison bugs
2023-04-05 02:01:19 +0300 • Fix passing local variables to IconUtils devloop
2023-04-05 00:41:02 +0300 • Implement hidden CacheFlush trap for ResEdit 2.1.1
2023-04-04 23:34:50 +0300 • Fix memory moved after deref bug in 'dcmp' invoke
2023-04-04 22:20:43 +0300 • Fix applying mask bitmap to region mask in colorQD
2023-04-03 00:26:12 +0300 • Fix color QD text optimization case for b&w ports
2023-04-03 00:24:20 +0300 • Add missing part of new SetCatInfo implementation
2023-04-02 21:44:44 +0300 • Add monochrome version of generic icon blitter
2023-04-02 17:40:40 +0300 • Fix the 1-bit to color port icon blit in IconUtils
2023-04-01 22:08:59 +0300 • Fix FindFolder, return right dirID from DirCreate
2023-04-01 22:05:38 +0300 • Implement _SetCatInfo & improve _SetFileInfo
2023-03-30 00:31:52 +0300 • Return the newly created ioDirID from DirCreate
2023-03-30 00:30:11 +0300 • Fix return from NativeFS driver Prime routine
2023-03-28 00:22:16 +0300 • Implement FCMPD selector for SANE
2023-03-26 01:00:39 +0200 • Commit the new improved INIT loading mechanism
2023-03-26 00:58:36 +0200 • Simulate the InitApplZone wrap patch in SetAppBase
2023-03-23 23:29:31 +0200 • Fix leaking mask region handles in icon blitter
2023-03-23 23:20:08 +0200 • Implement low-color icon blitter
2023-03-23 00:28:07 +0200 • Fix alignment code in Icon Utilities
2023-03-23 00:07:12 +0200 • Fix rgnBBox width calculation in BitmapToRgn
2023-03-22 23:49:42 +0200 • First parts of icon family drawing in IconUtils
2023-03-22 14:29:49 +0200 • Refactor IconUtils colorization code to own module
2023-03-19 11:07:09 +0200 • Implement CheckColorTolerance for PaletteDispatch
2023-03-07 00:38:33 +0200 • Add proto Rez scripts for building the System file
2023-03-04 22:03:00 +0200 • Initialize Icon Utilities global data
2023-03-02 00:17:08 +0200 • Add missing export of Get1IndResource to headers
2023-03-02 00:16:41 +0200 • Add dummy stub for TempMaxMem OSDispatch selector
2023-03-01 23:06:44 +0200 • Fix INIT resource load bug (use Get1IndResource)
2023-02-27 21:11:47 +0200 • Lock boot thread to prevent unexpected interrupts
2023-02-27 21:07:32 +0200 • Add dummy SReadPRAMRec selector to Slot Manager
2023-02-26 13:46:32 +0200 • Implement dummy SReadWord for Slot Manager
2023-02-26 13:41:28 +0200 • Implement PMgrVersion selector for PaletteDispatch
2023-02-26 13:35:33 +0200 • Add dummy SNextTypeSRsrc selector for slot manager
2023-02-26 12:59:31 +0200 • Don't crash on failed OpenResFile ini INIT loading
2023-02-26 12:35:48 +0200 • Implement DisposeIconSuite for IconUtils
2023-02-26 12:15:36 +0200 • Fix byteswap bug in InitRsrcZone sysmap overrides
2023-02-26 00:34:44 +0200 • Add color video DRVR cscGetDefaultMode status call
2023-02-25 01:46:58 +0200 • Proper SetDepth functionality + required DRVR code
2023-02-24 23:04:47 +0200 • Fix fRelAtEnd handling bug in block allocator
2023-02-24 14:58:27 +0200 • Fix Fix2X/Frac2X stack issue, and add X2Fix/X2Frac
2023-02-24 02:38:47 +0200 • Implement Fix2X and Frac2X traps
You must be logged in to post a comment.