classicmacos #17

Merged
IoI_xD merged 4 commits from classicmacos into master 2026-04-16 13:42:32 +09:00
31 changed files with 220 additions and 180 deletions
Showing only changes of commit f8a94b7380 - Show all commits

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

IoIxD 2026-04-15 21:41:16 -07:00

1
.gitignore vendored
View file

@ -25,3 +25,4 @@ compile_flags.txt
*.bin *.bin
*.rsrc *.rsrc
*.finf *.finf
*.gdb

View file

@ -9,17 +9,27 @@ include(GNUInstallDirs)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" ON)
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON)
option(MW_CLASSIC_THEME "Use classic theme" OFF) option(MW_CLASSIC_THEME "Use classic theme" OFF)
option(MW_BUILD_EXAMPLES "Build examples" OFF) option(MW_BUILD_EXAMPLES "Build examples" OFF)
option(MW_USE_STB_IMAGE "Use stb_image" ON) option(MW_USE_STB_IMAGE "Use stb_image" ON)
option(MW_USE_STB_TRUETYPE "Use stb_truetype" OFF) option(MW_USE_STB_TRUETYPE "Use stb_truetype" OFF)
option(MW_BUILD_SHARED "Build a shared library" ON)
option(MW_BUILD_STATIC "Build a static library" OFF) if(${CMAKE_SYSTEM_NAME} MATCHES Retro)
option(MW_BUILD_SHARED "Build a shared library" OFF)
option(MW_BUILD_STATIC "Build a static library" ON)
option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" OFF)
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" OFF)
else()
option(MW_BUILD_SHARED "Build a shared library" ON)
option(MW_BUILD_STATIC "Build a static library" OFF)
option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" ON)
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON)
endif()
option(MW_INSTALL_HEADERS "Install headers" ON) option(MW_INSTALL_HEADERS "Install headers" ON)
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin OR ${CMAKE_SYSTEM_NAME} MATCHES Retro)
option(MW_USE_FREETYPE2 "Use FreeType 2" OFF) option(MW_USE_FREETYPE2 "Use FreeType 2" OFF)
else() else()
option(MW_USE_FREETYPE2 "Use FreeType 2" ON) option(MW_USE_FREETYPE2 "Use FreeType 2" ON)
@ -298,6 +308,24 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
PRIVATE PRIVATE
-framework Cocoa -framework Cocoa
) )
elseif(CMAKE_SYSTEM_NAME MATCHES "Retro")
target_sources(
Mw
PRIVATE
src/backend/classicmacos.c
)
if(PLATFORM MATCHES retroppc)
endif()
if(PLATFORM MATCHES retroppc)
set_target_properties(Mw PROPERTIES COMPILE_FLAGS "-ffunction-sections -mcpu=601 -Os -Wall -Wextra -Wno-unused-parameter")
set_target_properties(Mw PROPERTIES LINK_FLAGS "-Wl,-gc-sections")
endif()
target_compile_definitions(
Mw
PRIVATE
CLASSIC_MAC_OS
)
else() else()
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(X11 REQUIRED x11) pkg_check_modules(X11 REQUIRED x11)

15
configure vendored
View file

@ -46,6 +46,7 @@ param_set("shared", 1);
param_set("static", 1); param_set("static", 1);
param_set("examples", 1); param_set("examples", 1);
my %features = ( my %features = (
"classic-theme" => "use classic theme", "classic-theme" => "use classic theme",
"stb-image" => "use stb_image, instead use libjpeg/libpng", "stb-image" => "use stb_image, instead use libjpeg/libpng",
@ -131,16 +132,12 @@ foreach my $l (@ARGV) {
} }
} }
if($target ne "Darwin" and $target ne "ClassicMacOS68k" and $target ne "ClassicMacOSPPC") { if($target ne "Darwin" and $target ne "ClassicMacOS") {
param_set("freetype2", 1); param_set("freetype2", 1);
param_set("stb-truetype", 0); param_set("stb-truetype", 0);
} else { } else {
if($target ne "ClassicMacOS68k" and $target ne "ClassicMacOSPPC"){
param_set("freetype2", 0); param_set("freetype2", 0);
param_set("stb-truetype", 1);
} else {
param_set("stb-truetype", 0); param_set("stb-truetype", 0);
}
} }
if($target eq "Linux") { if($target eq "Linux") {
@ -289,7 +286,7 @@ if (param_get("examples")) {
} }
if (grep(/^cocoa$/, @backends)) { if (grep(/^cocoa$/, @backends)) {
print(OUT print(OUT
" \$(CC) -L./src -I\$\(INCDIR) \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n" " \$(CC) -L./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
); );
} }
else { else {
@ -304,16 +301,12 @@ if (param_get("examples")) {
print(OUT 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" " 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 "${s}${object_suffix}: ${s}.c\n");
print(OUT print(OUT
" \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n" " \$(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"); print(OUT "\n");

View file

@ -6,7 +6,11 @@ file(
foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES) foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES)
get_filename_component(TARGET ${PATH} NAME_WE) get_filename_component(TARGET ${PATH} NAME_WE)
if(CMAKE_SYSTEM_NAME MATCHES Retro)
add_application(${TARGET} ${PATH})
else()
add_executable(${TARGET} MACOSX_BUNDLE ${PATH}) add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
endif()
target_link_libraries( target_link_libraries(
${TARGET} ${TARGET}
PRIVATE PRIVATE

View file

@ -106,6 +106,9 @@ MWDECL void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx);
#ifdef USE_COCOA #ifdef USE_COCOA
#include <Mw/LowLevel/Cocoa.h> #include <Mw/LowLevel/Cocoa.h>
#endif #endif
#ifdef CLASSIC_MAC_OS
#include <Mw/LowLevel/ClassicMacOS.h>
#endif
union _MwLL { union _MwLL {
struct _MwLLCommon common; struct _MwLLCommon common;
@ -121,6 +124,9 @@ union _MwLL {
#ifdef USE_COCOA #ifdef USE_COCOA
struct _MwLLCocoa cocoa; struct _MwLLCocoa cocoa;
#endif #endif
#ifdef CLASSIC_MAC_OS
struct _MwLLClassicMacOS cmacos;
#endif
}; };
union _MwLLColor { union _MwLLColor {

View file

@ -12,6 +12,10 @@
struct _MwLLClassicMacOS { struct _MwLLClassicMacOS {
struct _MwLLCommon common; struct _MwLLCommon common;
WindowRef window;
EventRecord event;
Rect winRect;
}; };
struct _MwLLClassicMacOSColor { struct _MwLLClassicMacOSColor {

10
pl/ostype/ClassicMacOS.pl Normal file
View file

@ -0,0 +1,10 @@
use_backend("classicmacos");
print("Compiling for Classic Mac OS via ./configure currently outputs a broken executable and it only supports PowerPC. Help is wanted. In the mean time, use CMake.")
$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");
add_cflags("-DSTBI_NO_THREAD_LOCALS");
1;

View file

@ -1,7 +0,0 @@
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

@ -1,7 +0,0 @@
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

@ -5,6 +5,15 @@
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLL r; MwLL r;
MwLLCreateCommon(r);
SetRect(&r->cmacos.winRect, 100, 100, width, height);
r->cmacos.window = NewCWindow(nil, &r->cmacos.winRect, (ConstStr255Param) "\p", true,
documentProc, (WindowPtr)(-1), true, 0);
SetPort(r->cmacos.window);
return r; return r;
} }
@ -59,8 +68,7 @@ static void MwLLFreeColorImpl(MwLLColor color) {
} }
static int MwLLPendingImpl(MwLL handle) { static int MwLLPendingImpl(MwLL handle) {
return GetNextEvent(everyEvent, &handle->cmacos.event);
return 0;
} }
static void MwLLNextEventImpl(MwLL handle) { static void MwLLNextEventImpl(MwLL handle) {

View file

@ -383,7 +383,7 @@ static void layout(MwWidget handle) {
MwNtext, "Cancel", MwNtext, "Cancel",
NULL); NULL);
MwAddUserHandler(fc->cancel, MwNactivateHandler, cancel, NULL); MwAddUserHandler(fc->cancel, MwNactivateHandler, filecancel, NULL);
} else { } else {
MwVaApply(fc->cancel, MwVaApply(fc->cancel,
MwNx, wx, MwNx, wx,

View file

@ -135,7 +135,7 @@ static void children_update(MwWidget handle) {
} }
MwClassRec MwBoxClassRec = { MwClassRec MwBoxClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -93,7 +93,7 @@ static void prop_change(MwWidget handle, const char* key) {
} }
MwClassRec MwButtonClassRec = { MwClassRec MwButtonClassRec = {
create, /* create */ wcreate, /* create */
NULL, /* destroy */ NULL, /* destroy */
draw, /* draw */ draw, /* draw */
click, /* click */ click, /* click */

View file

@ -38,7 +38,7 @@ static void prop_change(MwWidget handle, const char* key) {
} }
MwClassRec MwCheckBoxClassRec = { MwClassRec MwCheckBoxClassRec = {
create, /* create */ wcreate, /* create */
NULL, /* destroy */ NULL, /* destroy */
draw, /* draw */ draw, /* draw */
click, /* click */ click, /* click */

View file

@ -189,7 +189,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
} }
MwClassRec MwComboBoxClassRec = { MwClassRec MwComboBoxClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
click, /* click */ click, /* click */

View file

@ -172,7 +172,7 @@ static void clipboard(MwWidget handle, const char* data) {
} }
MwClassRec MwEntryClassRec = { MwClassRec MwEntryClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -46,7 +46,7 @@ static void prop_change(MwWidget handle, const char* key) {
} }
MwClassRec MwFrameClassRec = { MwClassRec MwFrameClassRec = {
create, /* create */ wcreate, /* create */
NULL, /* destroy */ NULL, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -42,7 +42,7 @@ static void prop_change(MwWidget handle, const char* key) {
} }
MwClassRec MwImageClassRec = { MwClassRec MwImageClassRec = {
create, /* create */ wcreate, /* create */
NULL, /* destroy */ NULL, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -360,7 +360,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
} }
MwClassRec MwLabelClassRec = { MwClassRec MwLabelClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -595,7 +595,7 @@ static void tick(MwWidget handle) {
} }
MwClassRec MwListBoxClassRec = { MwClassRec MwListBoxClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -189,7 +189,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
} }
MwClassRec MwMenuClassRec = { MwClassRec MwMenuClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -128,7 +128,7 @@ static void prop_change(MwWidget handle, const char* prop) {
} }
MwClassRec MwNumberEntryClassRec = { MwClassRec MwNumberEntryClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -46,7 +46,7 @@ static void prop_change(MwWidget handle, const char* key) {
} }
MwClassRec MwProgressBarClassRec = { MwClassRec MwProgressBarClassRec = {
create, /* create */ wcreate, /* create */
NULL, /* destroy */ NULL, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -47,7 +47,7 @@ static void prop_change(MwWidget handle, const char* key) {
} }
MwClassRec MwRadioBoxClassRec = { MwClassRec MwRadioBoxClassRec = {
create, /* create */ wcreate, /* create */
NULL, /* destroy */ NULL, /* destroy */
draw, /* draw */ draw, /* draw */
click, /* click */ click, /* click */

View file

@ -257,7 +257,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
} }
MwClassRec MwScrollBarClassRec = { MwClassRec MwScrollBarClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -35,7 +35,7 @@ static void prop_change(MwWidget handle, const char* key) {
} }
MwClassRec MwSeparatorClassRec = { MwClassRec MwSeparatorClassRec = {
create, /* create */ wcreate, /* create */
NULL, /* destroy */ NULL, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -241,7 +241,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
} }
MwClassRec MwSubMenuClassRec = { MwClassRec MwSubMenuClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
click, /* click */ click, /* click */

View file

@ -481,7 +481,7 @@ static void tick(MwWidget handle) {
} }
MwClassRec MwTreeViewClassRec = { MwClassRec MwTreeViewClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -176,7 +176,7 @@ static void tick(MwWidget handle) {
} }
MwClassRec MwViewportClassRec = { MwClassRec MwViewportClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -556,7 +556,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
} }
MwClassRec MwVulkanClassRec = { MwClassRec MwVulkanClassRec = {
create, /* create */ wcreate, /* create */
destroy, /* destroy */ destroy, /* destroy */
NULL, /* draw */ NULL, /* draw */
NULL, /* click */ NULL, /* click */

View file

@ -44,7 +44,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
} }
} }
MwClassRec MwWindowClassRec = { MwClassRec MwWindowClassRec = {
create, /* create */ wcreate, /* create */
NULL, /* destroy */ NULL, /* destroy */
draw, /* draw */ draw, /* draw */
NULL, /* click */ NULL, /* click */