classicmacos #17

Merged
IoI_xD merged 4 commits from classicmacos into master 2026-04-16 13:42:32 +09:00
34 changed files with 369 additions and 51 deletions
Showing only changes of commit 5315f4ec4d - Show all commits

classic mac os
Some checks failed
pyrite-dev/milsko/pipeline/head There was a failure building this commit

IoIxD 2026-04-15 20:21:20 -07:00

6
.gitignore vendored
View file

@ -19,3 +19,9 @@ examples/*/*.exe
compile_flags.txt
.cache
.DS_Store
*.pef
*.dsk
*.bin
*.rsrc
*.finf

63
configure vendored
View file

@ -46,14 +46,6 @@ param_set("shared", 1);
param_set("static", 1);
param_set("examples", 1);
if($target ne "Darwin") {
param_set("freetype2", 1);
param_set("stb-truetype", 0);
} else {
param_set("stb-truetype", 1);
}
my %features = (
"classic-theme" => "use classic theme",
"stb-image" => "use stb_image, instead use libjpeg/libpng",
@ -77,13 +69,6 @@ my @features_keys = (
"1wayland", "1gnustep",
);
if($target eq "Linux") {
param_set("x11", 1);
if(!param_get("tiny")){
param_set("wayland", 1);
}
}
foreach my $l (@ARGV) {
if ($l =~ /^--with-([^=]+)=(.+)$/) {
param_set($1, $2);
@ -146,6 +131,25 @@ foreach my $l (@ARGV) {
}
}
if($target ne "Darwin" and $target ne "ClassicMacOS68k" and $target ne "ClassicMacOSPPC") {
param_set("freetype2", 1);
param_set("stb-truetype", 0);
} else {
if($target ne "ClassicMacOS68k" and $target ne "ClassicMacOSPPC"){
param_set("freetype2", 0);
param_set("stb-truetype", 1);
} else {
param_set("stb-truetype", 0);
}
}
if($target eq "Linux") {
param_set("x11", 1);
if(!param_get("tiny")){
param_set("wayland", 1);
}
}
if (-f "./pl/ostype/${target}.pl") {
require("./pl/ostype/${target}.pl");
}
@ -256,7 +260,7 @@ foreach my $l (@library_targets) {
}
print(OUT "${l}: ${s}\n");
print(OUT " \$(CC) $warn \$\(INCDIR) \$(CFLAGS\) -c -o ${l} ${s}\n");
print(OUT " \$(CC) $warn \$\(INCDIR\) \$(CFLAGS\) -c -o ${l} ${s}\n");
}
print(OUT "\n");
print(OUT "\n");
@ -274,12 +278,18 @@ if (param_get("examples")) {
$libs = $examples_libs{$l};
}
print(OUT
"${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"
);
if (param_get("shared")) {
print(OUT
"${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"
);
} else {
print(OUT
"${l}: ${s}${object_suffix} src/${library_prefix}Mw.a\n"
);
}
if (grep(/^cocoa$/, @backends)) {
print(OUT
" \$(CC) -L./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
" \$(CC) -L./src -I\$\(INCDIR\) \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
);
}
else {
@ -287,10 +297,23 @@ if (param_get("examples")) {
" \$(CC) -L src -Wl,-R./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
);
}
if($target eq "ClassicMacOS") {
print(OUT
" ".$ENV{RETRO68_TOOLCHAIN_PATH}."/bin/MakePEF ${l} -o ${s}.pef\n");
print(OUT
" Rez -I ".$ENV{RETRO68_TOOLCHAIN_PATH}."/RIncludes ".$ENV{RETRO68_TOOLCHAIN_PATH}."/RIncludes/Retro68APPL.r -DCFRAG_NAME=\"example\" --data ${l}.pef --cc ${l}.dsk -t APPL\n"
);
print(OUT "${s}${object_suffix}: ${s}.c\n");
print(OUT
" \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n"
);
#print(OUT "Rez -I /path/to/Universal/RIncludes /path/to/libretro/RIncludes/Retro68APPL.r -DCFRAG_NAME="\"MyProgram\"" --data program.pef -o program.bin -t APPL");
}
}
}
print(OUT "\n");

View file

@ -0,0 +1,27 @@
/*!
* @file Mw/LowLevel/ClassicMacOS.h
* @brief ClassicMacOS Backend
* @warning This is used internally
*/
#ifndef __MW_LOWLEVEL_ClassicMacOS_H__
#define __MW_LOWLEVEL_ClassicMacOS_H__
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#include <Mw/LowLevel.h>
struct _MwLLClassicMacOS {
struct _MwLLCommon common;
};
struct _MwLLClassicMacOSColor {
struct _MwLLCommonColor common;
};
struct _MwLLClassicMacOSPixmap {
struct _MwLLCommonPixmap common;
};
MWDECL int MwLLClassicMacOSCallInit(void);
#endif

View file

@ -37,17 +37,28 @@
#define GET_WHEEL_DELTA_WPARAM(x) ((short)HIWORD(x))
#endif
#endif
#elif defined(CLASSIC_MAC_OS)
#include <unistd.h>
#include <MacTypes.h>
#include <CFBundle.h>
#include <CodeFragments.h>
#include <Timer.h>
#include <MacWindows.h>
#include <TextEdit.h>
#include <Dialogs.h>
#else
#include <unistd.h>
#include <pwd.h>
#include <dlfcn.h>
#include <signal.h>
#include <dirent.h>
#include <fcntl.h>
#include <limits.h>
#endif
#ifdef __unix__
#include <dirent.h>
#include <dlfcn.h>
#endif
#ifdef __APPLE__
#include <mach/clock.h>
#include <mach/mach.h>

View file

@ -0,0 +1,7 @@
use_backend("classicmacos");
$cc = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/m68k-apple-macos-gcc";
$ar = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/m68k-apple-macos-ar";
add_cflags("-DCLASSIC_MAC_OS");
1;

View file

@ -0,0 +1,7 @@
use_backend("classicmacos");
$cc = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/powerpc-apple-macos-gcc";
$ar = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/powerpc-apple-macos-ar";
add_cflags("-DCLASSIC_MAC_OS");
1;

View file

@ -30,6 +30,13 @@ if (grep(/^gdi$/, @backends)) {
$gl_libs = "-lopengl32 -lglu32";
}
if (grep(/^classicmacos$/, @backends)) {
#add_cflags("-DCLASSIC_MAC_OS");
new_object("src/backend/classicmacos.c");
$gl_libs = "";
}
if (grep(/^wayland$/, @backends)) {
add_cflags("-DUSE_WAYLAND");
new_object("src/backend/wayland.c");

View file

@ -6,6 +6,10 @@ typedef struct dir {
WIN32_FIND_DATA ffd;
int next;
} dir_t;
#elif defined(CLASSIC_MAC_OS)
typedef struct dir {
int dummy;
} dir_t;
#else
typedef struct dir {
DIR* dir;
@ -31,6 +35,8 @@ void* MwDirectoryOpen(const char* path) {
}
free(p);
dir->next = 1;
#elif defined(CLASSIC_MAC_OS)
/* todo */
#else
if((dir->dir = opendir(path)) == NULL) {
free(dir);
@ -47,6 +53,8 @@ void MwDirectoryClose(void* handle) {
dir_t* dir = handle;
#ifdef _WIN32
FindClose(dir->hFind);
#elif defined(CLASSIC_MAC_OS)
/* todo */
#else
closedir(dir->dir);
free(dir->base);
@ -80,6 +88,8 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
entry->mtime = l->QuadPart / 10000000 - 11644473600;
dir->next = FindNextFile(dir->hFind, &dir->ffd);
#elif defined(CLASSIC_MAC_OS)
/* todo */
#else
struct dirent* d;
struct stat s;
@ -123,6 +133,8 @@ char* MwDirectoryCurrent(void) {
GetCurrentDirectory(len, out);
return out;
#elif CLASSIC_MAC_OS
return "";
#else
return getcwd(NULL, 0);
#endif

View file

@ -12,6 +12,36 @@ void* MwDynamicSymbol(void* handle, const char* symbol) {
void MwDynamicClose(void* handle) {
FreeLibrary(handle);
}
#elif defined(CLASSIC_MAC_OS)
void* MwDynamicOpen(const char* path) {
CFragConnectionID connID;
Ptr* addr;
unsigned char err[255];
if(GetSharedLibrary((ConstStr63Param)path, kPowerPCCFragArch, kPrivateCFragCopy,
&connID, addr, err)) {
printf("Error getting %s: %s\n", path, err);
return NULL;
};
return connID;
}
void* MwDynamicSymbol(void* handle, const char* symbol) {
CFragConnectionID connID = (CFragConnectionID)handle;
Ptr* symAddr;
CFragSymbolClass* symClass;
OSErr err;
if((err = FindSymbol(connID, (ConstStr63Param)symbol, symAddr, symClass))) {
printf("Error getting %s: %d\n", symbol, err);
return NULL;
};
return symAddr;
}
void MwDynamicClose(void* handle) {
CFragConnectionID connID = (CFragConnectionID)handle;
CloseConnection(&connID);
}
#elif defined(__unix__) || defined(__APPLE__)
void* MwDynamicOpen(const char* path) {
return dlopen(path, RTLD_LOCAL | RTLD_LAZY);

View file

@ -32,6 +32,27 @@ void MwTimeSleep(int ms) {
nanosleep(&ts, NULL);
}
#elif defined(CLASSIC_MAC_OS)
static TMTask tm;
static int timer;
void timerUpdateFunc(void) {
timer += 1;
PrimeTime((QElemPtr)&tm, 1);
};
long MwTimeGetTick(void) {
UnsignedWide h;
Microseconds(&h);
return *(long*)&h;
}
void MwTimeSleep(int ms) {
tm.tmAddr = NewTimerProc(timerUpdateFunc);
tm.tmWakeUp = 0;
tm.tmReserved = 0;
InsTime((QElemPtr)&tm);
PrimeTime((QElemPtr)&tm, 1);
}
#elif defined(__unix__)
long MwTimeGetTick(void) {
struct timespec ts;

167
src/backend/classicmacos.c Normal file
View file

@ -0,0 +1,167 @@
#include <Mw/Milsko.h>
#include "../../external/stb_ds.h"
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLL r;
return r;
}
static void MwLLDestroyImpl(MwLL handle) {
MwLLDestroyCommon(handle);
free(handle);
}
static void MwLLBeginDrawImpl(MwLL handle) {
(void)handle;
}
static void MwLLEndDrawImpl(MwLL handle) {
(void)handle;
}
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
int i;
}
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
}
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
MwLLColor c = malloc(sizeof(*c));
MwLLColorUpdate(handle, c, r, g, b);
return c;
}
static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
c->common.red = r;
c->common.green = g;
c->common.blue = b;
}
static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
*x = 0;
*y = 0;
*w = 0;
*h = 0;
}
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
}
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
}
static void MwLLFreeColorImpl(MwLLColor color) {
free(color);
}
static int MwLLPendingImpl(MwLL handle) {
return 0;
}
static void MwLLNextEventImpl(MwLL handle) {
}
static void MwLLSetTitleImpl(MwLL handle, const char* title) {
}
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
MwLLPixmap r = malloc(sizeof(*r));
r->common.raw = malloc(4 * width * height);
memcpy(r->common.raw, data, 4 * width * height);
MwLLPixmapUpdate(r);
return r;
}
static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
}
static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
}
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
}
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
}
static void MwLLForceRenderImpl(MwLL handle) {
}
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
}
static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
}
static void MwLLShowImpl(MwLL handle, int show) {
}
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
}
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
}
static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
}
static void MwLLFocusImpl(MwLL handle) {
}
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
}
static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
/* TODO */
(void)handle;
(void)text;
}
static void MwLLGetClipboardImpl(MwLL handle) {
}
static void MwLLMakeToolWindowImpl(MwLL handle) {
}
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
}
static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
}
static void MwLLBeginStateChangeImpl(MwLL handle) {
MwLLShow(handle, 0);
}
static void MwLLEndStateChangeImpl(MwLL handle) {
MwLLShow(handle, 1);
}
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) {
(void)handle;
(void)toggle;
}
static int MwLLClassicMacOSCallInitImpl(void) {
InitGraf(&qd.thePort);
InitFonts();
FlushEvents(everyEvent, 0);
InitWindows();
InitMenus();
TEInit();
InitDialogs(0L);
InitCursor();
return 0;
}
#include "call.c"
CALL(ClassicMacOS);

View file

@ -53,7 +53,7 @@ static void destroy(MwWidget handle) {
MwDestroyWidget(handle);
}
static void cancel(MwWidget handle, void* user, void* call) {
static void filecancel(MwWidget handle, void* user, void* call) {
(void)user;
(void)call;
@ -147,7 +147,7 @@ static void nav_activate(MwWidget handle, void* user, void* call) {
(void)user;
if(strcmp(e, "Home") == 0) {
#ifdef _WIN32
#if defined(_WIN32) || defined(CLASSIC_MAC_OS)
#else
struct passwd* p = getpwuid(getuid());

View file

@ -2,7 +2,7 @@
#include "../../external/stb_ds.h"
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwBox b = malloc(sizeof(*b));
memset(b, 0, sizeof(*b));

View file

@ -2,7 +2,7 @@
#include "../../external/stb_ds.h"
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNflat, 0);

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNchecked, 0);

View file

@ -2,7 +2,7 @@
#include "../../external/stb_ds.h"
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwComboBox cb = malloc(sizeof(*cb));
cb->list = NULL;

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwEntry t = malloc(sizeof(*t));
t->cursor = 0;

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNhasBorder, 0);

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNhasBorder, 0);

View file

@ -4,7 +4,7 @@
#define Spacing 1
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwLabel lab = malloc(sizeof(*lab));
lab->segment = NULL;

View file

@ -347,7 +347,7 @@ static void resize(MwWidget handle) {
NULL);
}
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwListBox lb = malloc(sizeof(*lb));
memset(lb, 0, sizeof(*lb));

View file

@ -18,7 +18,7 @@ static void set_xywh(MwWidget handle) {
NULL);
}
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwMenu m = malloc(sizeof(*m));
m->name = NULL;

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
int st;
MwEntry e;

View file

@ -101,7 +101,7 @@ typedef struct waylandopengl {
} waylandopengl_t;
#endif
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
void* r = NULL;
MwWidget w = handle;

View file

@ -20,7 +20,7 @@
@end
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
void* r = NULL;
MwWidget w = handle;
@ -128,4 +128,4 @@ MwClassRec MwOpenGLClassRec = {create, /* create */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL, NULL, NULL, NULL};
MwClass MwOpenGLClass = &MwOpenGLClassRec;
MwClass MwOpenGLClass = &MwOpenGLClassRec;

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwVaApply(handle,
MwNminValue, 0,

View file

@ -2,7 +2,7 @@
#include "../../external/stb_ds.h"
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNchecked, 0);

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwScrollBar scr = malloc(sizeof(*scr));
handle->internal = scr;
@ -58,9 +58,9 @@ static void draw(MwWidget handle) {
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64);
MwScrollBar scr = handle->internal;
int or ;
int uy, dy, ux, dx;
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
int or;
int uy, dy, ux, dx;
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
r.x = 0;
r.y = 0;

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNorientation, MwHORIZONTAL);

View file

@ -2,7 +2,7 @@
#include "../../external/stb_ds.h"
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwLLBeginStateChange(handle->lowlevel);
MwSetDefault(handle);

View file

@ -297,7 +297,7 @@ static void resize(MwWidget handle) {
NULL);
}
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwTreeView tv = malloc(sizeof(*tv));
memset(tv, 0, sizeof(*tv));

View file

@ -74,7 +74,7 @@ static void resize(MwWidget handle) {
NULL);
}
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwViewport vp = malloc(sizeof(*vp));
memset(vp, 0, sizeof(*vp));

View file

@ -116,7 +116,7 @@ static int vulkan_instance_setup(MwWidget handle, vulkan_t* o);
static int vulkan_surface_setup(MwWidget handle, vulkan_t* o);
static int vulkan_devices_setup(MwWidget handle, vulkan_t* o);
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
vulkan_t* o = malloc(sizeof(*o));
int err;

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNhasBorder, 0);