Welcome, Guest | Home | Search | Login | Register
Author SDL2 for PPC MacOS 9 efforts... (Read 66224 times)
lauland
512 MB
*****
Posts: 674
Symtes 7 Mewconer!
View Profile
Reply #30 on: May 11, 2025, 19:18

My excursion on Tiger was quite fruitful, and I was able to build all of SDL1 and its "add ons", two versions of SDL2 and all its "add ons".  A few tiny tweaks and one line patches were needed, but nothing unexpected.  All without having to install MacPorts or anything other than stock 10.4 and XCode...with the sole exception of SDL2_ttf, which needed a newer compiler.  All now uploaded to MG.

Looking at a fully working SDL2 on Tiger helped me learn a lot about how things work on a more sane OS than MacOS 7/8/9.  Especially with how OpenGL hooks in.

----

I have most of the SDL 1.2 timer code now working as a driver for SDL2.  Unfortunately basic timers in SDL2 completely require threads, so without those they'll never work.  There is code for Emscripten that doesn't use threads that might be repurposed...  Otherwise things like SDL_Delay are now real.

The 1.2 loadso driver will probably work, but need to test it.  The joystick code is in the tree, but doesn't build.

I have minimal classic MacOS SDL2 versions of _image, _mixer, and _ttf building (but with a lot disabled since I haven't built their dependent libraries yet), but haven't been able to test them easily since their test programs expect command line parameters!  Will be adding gfx and net, since I built them pretty easily on Tiger.  SDL2_net will be a pain and will need to use GUSI or something like that...I never quite got the SDL 1.2 version working, but having it built, even if it doesn't fully work for SDL2 will be useful.  I'll upload what I have to MG soonish.

All of this is relatively trivial in Retro68, but a major pain in CodeWarrior.  For that reason I'm considering deprecating building with it.  I love it, but it is so old and a pain to set up projects in.  I'll carry over the needed patches, but haven't tested a build using it in a while.

If I do this, everything will be cross compiled, and you couldn't build SDL2 running on an actual MacOS 9 machine, but oh well...it's 2025 and cross compilation isn't that hard, and works very very well.

----

I said I wasn't going to do it, but I'm doing it: SDL2 for m68k Amiga.  Only because getting it building without any drivers is relatively trivial, and, again, nobody else has ever bothered to try.  Adding drivers will be some work, but I can probably fudge up a basic video driver like I did for MacOS 7/8/9, I know enough to do so.  Anyway, since I'm building SDL2 for m68k Mac, I already have all of the infrastructure in place and can even repurpose the Makefiles almost as-is.  The issues and ways to get around them are EXTREMELY similar between classic MacOS and AmigaOS 3.

The makefiles I'm using for MacOS 7/8/9 actually originated from a build for AmigaOS 4, so, in a way, they're coming full circle, and I'm giving back to the community where they came from.

Please forgive me, Mac people, for my transgressions!
Last Edit: May 11, 2025, 19:39 by lauland
lauland
512 MB
*****
Posts: 674
Symtes 7 Mewconer!
View Profile
Reply #31 on: May 12, 2025, 15:31

Well, looking into Amiga has already helped the MacOS 7/8/9 port!

In working on a video driver for m68k Amiga's I copied the Mac code, and started replacing bits with Amiga api equivalents.  This would be relatively simple and I'd be sharing Amiga screenshots of it working with you now, except the Amiga doesn't have native support for any pixel depth higher than 8.  I'm doing everything as 32-bit pixels (RGB+alpha), so I'd need to use an extension called "Cybergrapx" to do so.  Since I haven't written any Amiga code in decades, it came around after I'd stopped, and I do not know anything about it. 

I looked at the Amiga SDL 1.2 video driver for hints and started, but don't know if I'm interested enough to work further on it.  It might be stuck similar to SDL3 for MacOS 7/8/9, as a POC only, but a little further along.  It does set up a video buffer and opens a window, but that may be as far as Amiga goes...

----

Anyway, in working on that driver, I noticed where I allocate the video buffer I was forgetting to divide the depth by 8 AGAIN.  So treating it as if it were 32 bytes instead of 32 bits per pixel, and the buffer was 8 times larger than it needed to be!

This cuts down the memory requirements QUITE a bit, and makes running on an 8m Mac probably possible.  So I might be able to get my SDL2 running on System 6.  Whoohoo!  (From the half dozen people in the world who might actually care).


Last Edit: May 12, 2025, 15:34 by lauland
lauland
512 MB
*****
Posts: 674
Symtes 7 Mewconer!
View Profile
Reply #32 on: June 29, 2025, 08:39

main handling cmd line...
Going to call SDL_SetMainReady...
Going to call SDL_main...
Going to SDL_Init...
macosclassic id thread id=00000064
generic get tls 00000000
generic init tls
macosclassic id thread id=00000064
macosclassic id thread id=00000064
macosclassic id thread id=00000064
generic get tls 00000000
generic set tls 1c728010
macosclassic id thread id=00000064
macosclassic id thread id=00000064
macosclassic id thread id=00000064
generic init tls
macosclassic id thread id=00000064
macosclassic id thread id=00000064
macosclassic id thread id=00000064
generic get tls 1c728010
thread_function is 1c721fa0...
Going to create threads...
generic init tls
macosclassic create thread 1c7280c0 name=Thread 1 handle=00000065
macosclassic create thread 1c7301b0 name=Thread 2 handle=00000066
Going to wait threads...
macosclassic wait thread 1c7280c0 handle=00000065
tstate=0 state=00000000 status=ffffffff
WOULD WAIT1!
macosclassic RunThread data=1c7280c0
handle=00000065 userfunc=1c721fa0 userdata=00000001
macosclassic setup thread name=Thread 1
macosclassic id thread id=00000065
Thread 1 started
Thread 1: Count 0
macosclassic RunThread data=1c7301b0
handle=00000066 userfunc=1c721fa0 userdata=00000002
macosclassic setup thread name=Thread 2
macosclassic id thread id=00000066
Thread 2 started
Thread 2: Count 0
Thread 1: Count 1
Thread 2: Count 1
Thread 1: Count 2
Thread 2: Count 2
Thread 1: Count 3
Thread 2: Count 3
Thread 1: Count 4
Thread 2: Count 4
Thread 1 finished
macosclassic id thread id=00000065
macosclassic id thread id=00000065
macosclassic id thread id=00000065
generic get tls 00000000
Thread 2 finished
macosclassic id thread id=00000066
macosclassic id thread id=00000066
macosclassic id thread id=00000066
generic get tls 00000000
macosclassic wait thread 1c7301b0 handle=00000066
tstate=0 state=00000002 status=00000000
NOT WAITING1!
Going to SDL_Quit...
macosclassic id thread id=00000064
macosclassic id thread id=00000064
macosclassic id thread id=00000064
generic get tls 1c728010
generic set tls 00000000
macosclassic id thread id=00000064
macosclassic id thread id=00000064
macosclassic id thread id=00000064
generic quit tls
cballero
1024 MB
******
Posts: 1176
System 7, today and forever
View Profile
Reply #33 on: June 29, 2025, 15:51

Just gotta say, I'm loving the progression as always, Lauland! :D I'm plowing into FileMaker territory; I know, so 'unprogrammy' of me :( but I'm way more comfortable with its easy-to-develop swimies it comes with, lol; but I truly enjoy reading about each step in your Classic programming adventures, especially since I've long benefited from the SDL driven Android port of Basilisk II, even if the evil G took it down their app store, as I'm sure they killed off so many other cool titles :( I can't wait for all of your upcoming victories in the programming realms! :D
lauland
512 MB
*****
Posts: 674
Symtes 7 Mewconer!
View Profile
Reply #34 on: June 29, 2025, 18:55

It turns out threading is needed to do even basic audio and timers in SDL2, so this is a big step.

They're only cooperative, not preemptive, so not "real", but they're that way in SDL2 for the Nintendo 3DS, and SDL2 runs very well on it, so this bodes well for our beloved system 6/7/8/9 macs.

I've tried a few tiny SDL2 game ports for classic mac, but have always ran into the fact that even though I have a functional skeleton audio driver written (even if it doesn't play any actual sound), they can't run since the audio wants a thread.

I still need to implement semaphores, but those should be relatively easy...and then...we'll see.  The minute I have a real SDL2 game port, I will be crowing from the hills.

Once I have semaphores, I could actually get audio playing...

lauland
512 MB
*****
Posts: 674
Symtes 7 Mewconer!
View Profile
Reply #35 on: July 05, 2025, 05:04

"sdlbird" a Flappy Bird clone is now the first ever working SDL2 game for classic MacOS...

At the SDL2 MG page.
cballero
1024 MB
******
Posts: 1176
System 7, today and forever
View Profile
Reply #36 on: July 05, 2025, 09:15

That's a very cool update, Lauland! 8)
Pages: 1 2 [3]

© 2021 System7Today.com.
The Apple Logo, Macintosh™, Mac OS™, and others property of Apple Computer, Inc.
This site is in no way affiliated with Apple Computer, Inc.