#m68kMicroPython happenings: The "struct-types" branch is coming along. There are now autogenerated bindings for the following parts of the API: modmactypes.c
modqd.c
modtoolboxevent.c
modtoolboxutil.c
modwindowmgr.c

there's probably broken stuff but for instance you can now splat directly onto the screen

>>> scrn = qd.qdGlobals().screenBits
>>> n = scrn.bounds.bottom * scrn.rowBytes
>>> for i in range(n): scrn.baseAddr[i] = i

and types are checked:

>>> qd.FillRect(7, "blue")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Expected int, got Rect

um well except the error message is backwards 💦

and in upstream #micropython land my exploration found that there were problems with the uctypes module and "REPR_B", so I'm working on fixing that and ensuring it stays fixed via the CI system: https://github.com/micropython/micropython/pull/17688

right at the moment, the micropython PR is failing for some reason that will probably be more obvious to me once I've had another night to recover from jet lag.

Test REPR_B & fix test failures by jepler · Pull Request #17688 · micropython/micropython

Summary For m68k-micropython I'm interested in REPR_B. However, CI doesn't check any REPR_B builds, so of course there were test failures. This patch series adds a 32-bit REPR_B build (i686...

GitHub

getting mouse position #m68kmicropython

MicroPython 20250706.2-31.g832bbdeb6c on 2025-07-17; macplus with m68000
Type "help()" for more information.
>>> import toolboxevent
>>> import mactypes
>>> p = mactypes.Point()
>>> toolboxevent.GetMouse(p)
>>> p.h, p.v
(466, 50)

creating a window and drawing in it .. output can still happen in the console window too.

code: https://gist.github.com/jepler/af1e6e56fd2cd1921ef0f3dd56408944

needs WIP branch from https://github.com/m68k-micropython/micropython/pull/11

#m68kmicropython

this warrants .. a new release! you can grab your dsk image from the release page: https://github.com/m68k-micropython/micropython/releases/tag/20250717 #m68kMicroPython
Release Wrap more Mac API · m68k-micropython/micropython

What's Changed moductypes: Add types by @jepler in #11 New Contributors @jepler made their first contribution in #11 Full Changelog: https://github.com/m68k-micropython/micropython/commits/2025...

GitHub
@stylus Is this a bug or am I doing something silly here? I’m trying to update the FlyingLine demo for the new release and I can’t figure out why, when I create a bunch of mactypes.Rect objects in a loop, the left/top and right/bottom seem to swap places every couple of iterations…

@smallsco umm I can't quite figure out exactly how it's doing that .. but I do know that the order of the fields in a Rect is different than what you're writing.

If I swap the code to use this order when constructing the subsequent Rects then they no longer switch around, but are the same from line to line.

I did find a problem while investigating this, though. You should be able to write r = Rect(left=671, top=...) but it would only use the first half of the items you specified, leaving some items as zeros. That'll be fixed by https://github.com/m68k-micropython/micropython/pull/13 (hopefully)

@smallsco oh I see it finally. it's a 1-based vs 0-based addressing thing that makes your left/top swap every 2 times instead of every other time.

I am struggling to explain it verbally, but maybe it will help for you to think about why this code prints [20, 21, 21, 22, 22, ...] instead of [20, 21, 22, 23, ...]:

numbers = [20]
for i in range(25):
numbers.append(numbers[i - 1] + 1)

print(l)

it has to do with what element in the list numbers[i-1] refers to. You want numbers[i] or numbers[-1].

@stylus Ah… turns out I was looking at the definition for SetRect() which uses the order (left, top, right, bottom). But when instantiating a Rect, you need to use the order (top, left, bottom, right).

Way to be consistent, Apple! *shakes fist*

And good catch on my test. The actual code used range(1, 50), but I removed the 1 when trying to simplify in order to reproduce the issue, making it worse 😂

Anyway, bounds issues are fixed now, next step is to see if I can run it full screen now that you have the screenBits globals exposed and support for creating windows!

@stylus Success! Well, mostly - can’t hide the menu bar until the Menu Manager is implemented, and I’m using Python’s time.sleep() instead of the Desktop Manager’s SystemTask() but other than that, it works! I even have click-to-exit working 😎

Now, this can probably be done in a much more Pythonic way. It’s more or less a straight port from the C version and makes heavy use of global variables. But for now I’m happy with it!

Source: https://gist.github.com/smallsco/b8b11d5ef8e43b8393c4d6b950758995

As for what’s next, hmm, I think I might try to port over Macstodon’s About dialog - that’s the one piece of the app using pure QuickDraw rather than using the widget framework.