Skip to content

Commit 66957cd

Browse files
committed
68k compatibility
1 parent 9625897 commit 66957cd

File tree

13 files changed

+351
-105
lines changed

13 files changed

+351
-105
lines changed

CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ file(GLOB_RECURSE data resources/*)
3939
###############################################################################
4040

4141
# add the data to the target, so it becomes visible in some IDE
42+
4243
if(CMAKE_SYSTEM_NAME MATCHES Retro)
4344
add_application(os9fetch ${sources} ${data})
4445
else()
@@ -56,12 +57,20 @@ set_target_properties(os9fetch PROPERTIES COMPILE_OPTIONS -ffunction-sections)
5657

5758
#target_link_libraries( os9fetch ThreadsLib)
5859

59-
target_link_libraries( os9fetch PowerMgrLib)
60-
target_link_libraries( os9fetch NameRegistryLib)
61-
target_link_libraries( os9fetch AppleScriptLib)
60+
if(PLATFORM MATCHES retro68)
61+
add_compile_definitions(FOR_68K)
62+
endif()
63+
64+
if(PLATFORM MATCHES retroppc)
65+
add_compile_definitions(FOR_PPC)
66+
target_link_libraries( os9fetch PowerMgrLib)
67+
target_link_libraries( os9fetch NameRegistryLib)
68+
endif()
69+
70+
6271
target_link_libraries( os9fetch -Lglut.lib)
6372
include_directories( "${RETRO68_TOOLCHAIN}universal/CIncludes/")
64-
73+
message(STATUS "Making for ${CMAKE_SYSTEM_NAME}")
6574
if(CMAKE_SYSTEM_NAME MATCHES Retro68)
6675
set_target_properties(os9fetch PROPERTIES LINK_FLAGS "-Wl,--mac-strip-macsbug")
6776
endif()

src/console/Console.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ namespace retro
100100
void Idle();
101101

102102
bool IsEOF() const { return eof; }
103+
void Update();
104+
void PutCharNoUpdate(char c);
103105

104106
private:
105107
State sequenceState;
@@ -124,9 +126,6 @@ namespace retro
124126
bool cursorVisible = true;
125127
bool eof = false;
126128

127-
void PutCharNoUpdate(char c);
128-
void Update();
129-
130129
short CalcStartX(short x, short y);
131130
Rect CellRect(short x, short y);
132131
void DrawCell(short x, short y, bool erase = true);

src/console/ConsoleWindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ ConsoleWindow::ConsoleWindow(Rect r, ConstStr255Param title)
4747
Rect portRect;
4848
GetPortBounds(port, &portRect);
4949
#endif
50+
#ifdef FOR_PPC
5051
portRect = (Rect){
5152
.top = 0,
5253
.left = 0,
5354
.bottom = 480,
5455
.right = 640,
5556
};
57+
#endif
5658
port->portRect = portRect;
5759

5860
SetPort(port);

src/console/InitConsole.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ void retro::InitConsole()
5959
#else
6060
Rect r = (*GetMainDevice())->gdRect;
6161
#endif
62+
63+
#ifdef FOR_PPC
6264
r = (Rect){
6365
.top = (r.bottom / 4),
6466
.left = (r.right / 4),
65-
.bottom = (r.bottom / 4) + 320,
66-
.right = (r.right / 4) + 640,
67+
.bottom = (r.bottom / 4) + 480,
68+
.right = (r.bottom / 4) + 640,
6769
};
70+
#endif
6871
{
6972
// give MultiFinder a chance to bring the App to front
7073
// see Technote TB 35 - MultiFinder Miscellanea

src/detection/68kextras.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#include <OSUtils.h>
2+
#include <stdio.h>
3+
4+
namespace detection
5+
{
6+
7+
void
8+
fpu()
9+
{
10+
SysEnvRec rec;
11+
SysEnvirons(1, &rec);
12+
if (rec.hasFPU)
13+
{
14+
printf("FPU: Yes");
15+
}
16+
else
17+
{
18+
printf("FPU: No");
19+
}
20+
}
21+
22+
void color()
23+
{
24+
SysEnvRec rec;
25+
SysEnvirons(1, &rec);
26+
if (rec.hasColorQD)
27+
{
28+
printf("Color: Yes");
29+
}
30+
else
31+
{
32+
printf("Color: No");
33+
}
34+
}
35+
36+
void keyboard()
37+
{
38+
SysEnvRec rec;
39+
SysEnvirons(1, &rec);
40+
switch (rec.keyBoardType)
41+
{
42+
case 0:
43+
printf("Keyboard: Unknown");
44+
break;
45+
case 1:
46+
printf("Keyboard: Macintosh Keyboard");
47+
break;
48+
case 2:
49+
printf("Keyboard: Macintosh Keyboard (w/ Keypad)");
50+
break;
51+
case 3:
52+
printf("Keyboard: Macintosh Plus Keyboard (w/ Keypad)");
53+
break;
54+
case 4:
55+
printf("Keyboard: Apple Extended Keyboard");
56+
break;
57+
case 5:
58+
printf("Keyboard: Standard ADB Keyboard");
59+
break;
60+
case 6:
61+
printf("Keyboard: Portable ADB Keyboard");
62+
break;
63+
case 7:
64+
printf("Keyboard: Portable ISO Keyboard");
65+
break;
66+
case 8:
67+
printf("Keyboard: Standard ISO ADB");
68+
break;
69+
case 9:
70+
printf("Keyboard: Extended ISO ADB");
71+
break;
72+
}
73+
}
74+
}

src/detection/cpu.cpp

Lines changed: 126 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,68 @@
1313
namespace detection
1414
{
1515

16+
#ifdef FOR_68K
17+
void cpu_68k();
1618
void cpu()
19+
{
20+
cpu_68k();
21+
}
22+
#endif
23+
#ifdef FOR_PPC
24+
void cpu_ppc();
25+
void cpu()
26+
{
27+
cpu_ppc();
28+
}
29+
#endif
30+
void clockSpeed();
31+
32+
void cpu_68k()
33+
{
34+
int ver = os_version();
35+
36+
long procType;
37+
if (ver >= 0x600)
38+
{
39+
procType = detection::gestalt(gestaltProcessorType);
40+
}
41+
else
42+
{
43+
SysEnvRec rec;
44+
SysEnvirons(1, &rec);
45+
procType = rec.processor;
46+
}
47+
if (procType != NULL)
48+
{
49+
switch (procType)
50+
{
51+
case gestalt68000:
52+
printf("CPU: 68000");
53+
break;
54+
case gestalt68010:
55+
printf("CPU: 68010");
56+
break;
57+
case gestalt68020:
58+
printf("CPU: 68020");
59+
break;
60+
case gestalt68030:
61+
printf("CPU: 68030");
62+
break;
63+
case gestalt68040:
64+
printf("CPU: 68040");
65+
break;
66+
}
67+
68+
int ver = os_version();
69+
if (ver >= 0x600)
70+
{
71+
clockSpeed();
72+
}
73+
printf(" (ID: %d)", procType);
74+
}
75+
}
76+
77+
void cpu_ppc()
1778
{
1879
CPUDevice::Initialize();
1980
auto vec = CPUDevice::GetCPUS();
@@ -503,57 +564,90 @@ namespace detection
503564

504565
printf("CPU: %s", name.c_str());
505566

506-
long speed = detection::gestalt(gestaltProcClkSpeed);
507-
if (speed != NULL)
508-
{
509-
if (speed < 1000)
510-
{
511-
printf(" %luHz", speed);
512-
}
513-
else if (speed < 1000000)
514-
{
515-
printf(" %luKHz", speed / 1000);
516-
}
517-
else if (speed < 1000000000)
518-
{
519-
printf(" %luMHz", speed / 1000000);
520-
}
521-
else if (speed < 1000000000000)
522-
{
523-
printf(" %luGHz", speed / 1000000000);
524-
}
525-
else if (speed < 1000000000000000)
526-
{
527-
printf(" %luTHz", speed / 1000000000000);
528-
}
529-
else if (speed < 1000000000000000000)
530-
{
531-
printf(" %luPHz", speed / 1000000000000000);
532-
}
533-
}
567+
clockSpeed();
534568

535569
printf(" (ID: %0X)", processorVersion);
536570
}
537571
}
538572

573+
void clockSpeed()
574+
{
575+
float speed = (float)detection::gestalt(gestaltProcClkSpeed);
576+
if (speed != NULL)
577+
{
578+
if (speed < 1024.0)
579+
{
580+
printf(" %0.2fHz", speed);
581+
}
582+
else if (speed < 1048576.0)
583+
{
584+
printf(" %0.2fKHz", speed / 1024.0);
585+
}
586+
else if (speed < 1073741824.0)
587+
{
588+
printf(" %0.2fMHz", speed / 1048576.0);
589+
}
590+
else if (speed < 1099511627776.0)
591+
{
592+
printf(" %0.2fGHz", speed / 1073741824.0);
593+
}
594+
else if (speed < 1125899906842624.0)
595+
{
596+
printf(" %0.2fTHz", speed / 1099511627776.0);
597+
}
598+
else
599+
{
600+
printf(" %0.2fPHz", speed / 1125899906842624.0);
601+
}
602+
printf(" (%0.2f)", speed);
603+
}
604+
}
539605
void model()
540606
{
541-
long sys = detection::gestalt(gestaltMachineType);
607+
int ver = os_version();
608+
609+
long sys;
610+
if (ver >= 0x600)
611+
{
612+
sys = detection::gestalt(gestaltMachineType);
613+
}
614+
else
615+
{
616+
SysEnvRec rec;
617+
SysEnvirons(1, &rec);
618+
sys = rec.machineType;
619+
// The result we get near perfectly maps to the modern one, with some exceptions.
620+
if (sys == 1)
621+
{
622+
sys = -1;
623+
}
624+
else if (sys == 2)
625+
{
626+
sys = 2;
627+
}
628+
else
629+
{
630+
sys -= 2;
631+
}
632+
}
542633
if (sys != NULL)
543634
{
544635
// We're supposed to be able to use GetIndString. This does not work, presumably because they stopped updating the index, but they did give us all the numbers in the last header file.
545636
const char *name = NULL;
546637
unsigned char *name2 = NULL;
547638
switch (sys)
548639
{
640+
case 0:
641+
name = "Macintosh 128k";
642+
break;
549643
case 1:
550644
name = "Macintosh Classic";
551645
break;
552646
case 2:
553647
name = "Macintosh XL";
554648
break;
555649
case 3:
556-
name = "Macintosh 512Ke";
650+
name = "Macintosh 512K";
557651
break;
558652

559653
case 4:
@@ -882,11 +976,11 @@ namespace detection
882976
}
883977
if (name != NULL)
884978
{
885-
printf("Model: %s (ID: %lu)", name, sys);
979+
printf("Model: %s (ID: %0.2f)", name, sys);
886980
}
887981
else
888982
{
889-
printf("Model: %s (ID: %lu)", name2, sys);
983+
printf("Model: %s (ID: %0.2f)", name2, sys);
890984
}
891985
}
892986
return;

0 commit comments

Comments
 (0)