The files in the GitHub should use Unix linefeeds instead of classic Mac OS carriage returns. Since you're using retro68, source files with linefeeds should be fine. CodeWarrior also supports linefeeds. Not sure about MPW or Think C or whatever.
CodeWarrior doesn't like UTF-8 and GitHub doesn't like MacRoman, so make sure the source files use only ASCII.
Search for regex
[^ -~\n\t\r] to find illegal characters.
For the .r file, use the Rez include files from the Universal Interfaces RIncludes folder when you Rez and DeRez your resources so that your .r file is more readable. These .r files might be in a Xcode SDK as well.
Bash:
find "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" -name '*.r'
grep -R --include '*.r' -E "'(sysz|ICN#|vers|FREF|ics#|BNDL)'" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
bbfind --name-pattern '*.r' -g "'(sysz|ICN#|vers|FREF|ics#|BNDL)'" "/Volumes/Devs/Metrowerks CodeWarrior 8.0/Metrowerks CodeWarrior/MacOS Support/Universal/Interfaces/RIncludes"
Rez "KeyboardCursorsOpt.rsrc.r" -o "KeyboardCursorsOpt.rsrc"
DeRez "KeyboardCursorsOpt.rsrc" -i "/Volumes/Devs/Metrowerks CodeWarrior 8.0/Metrowerks CodeWarrior/MacOS Support/Universal/Interfaces/RIncludes" Finder.r Icons.r MacTypes.r > "KeyboardCursorsOpt2.rsrc.r"
bbdiff "KeyboardCursorsOpt2.rsrc.r" "KeyboardCursorsOpt.rsrc.r"
# mv "KeyboardCursorsOpt2.rsrc.r" "KeyboardCursorsOpt.rsrc.r"
Rez -i "/Volumes/Devs/Metrowerks CodeWarrior 8.0/Metrowerks CodeWarrior/MacOS Support/Universal/Interfaces/RIncludes" Finder.r Icons.r MacTypes.r "KeyboardCursorsOpt.rsrc.r" -o "KeyboardCursorsOpt.rsrc"
How to use Rez and DeRez is described in MPW_3.0_Reference_Volume_1_1988.pdf
I'm not sure why there's no .r file for the sysz resource but I guess it's simple enough.
https://leopard-adc.pepas.com/qa/ops/ops02.html
https://developer.apple.com/library.../pdf/Operating_System_Utilities/Start_Mgr.pdf
What's
CallPascal for? Isn't there a way to qualify the function pointer ABI as
pascal so that the compiler knows how to call it correctly? Well, I see you didn't define it as a function pointer - just a
long. In CodeWarrior, you can do this:
C:
#include <a4stuff.h>
#include <dialogs.h>
#include <string.h>
#include <Resources.h>
#include "TrapUtilities.h"
// Global Types
typedef pascal Handle ( *Get1ResourceProcPtr )( ResType theType, short theID );
// Globals
Get1ResourceProcPtr oldGet1Resource;
// Prototypes
extern "C" void __Startup__( void );
void main( void );
pascal Handle MyGet1Resource( ResType theType, short theID );
void main( void )
{
EnterCodeResource( );
Handle hdl = RecoverHandle( ( Ptr ) __Startup__ ); // yes, make INIT resident; it is already locked and in the system heap
DetachResource( hdl );
PatchATrap( _Get1Resource, (ProcPtr)MyGet1Resource, (ProcPtr&)oldGet1Resource );
ExitCodeResource( );
}
pascal Handle MyGet1Resource( ResType theType, short theID )
{
EnterCodeResource( );
Handle theResource = oldGet1Resource( theType, theID );
...
ExitCodeResource( );
return theResource;
} // MyGet1Resource
Notes about A5 and patching traps:
https://developer.apple.com/library/archive/technotes/ov/ov_14.html
But you're an INIT, not an APPL.
TrapUtilities.h:
C:
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <MacTypes.h>
bool TrapAvailable(UInt16 theTrap);
void PatchATrap( UInt16 theTrap, ProcPtr newTrap, ProcPtr *saveTrapPtr );
#ifdef __cplusplus
}
#endif
TrapUtilites.cpp:
see Inside Macintosh: Overiew - Chapter 9: Processes
and also
https://developer.apple.com/library...f/Operating_System_Utilities/Trap_Manager.pdf
https://preterhuman.net/macstuff/techpubs/mac/OSUtilities/OSUtilities-171.html
C:
#include "TrapUtilities.h"
#include <Traps.h>
#include <OSutils.h>
const long TrapMask = 0x0800;
short NumToolboxTraps( void );
TrapType GetTrapType(UInt16 theTrap);
short NumToolboxTraps( void )
{
if (GetToolboxTrapAddress(_InitGraf) == GetToolboxTrapAddress(0xAA6E))
return(0x0200);
else
return(0x0400);
}
TrapType GetTrapType(UInt16 theTrap)
{
if ((theTrap & TrapMask) > 0)
return(ToolTrap);
else
return(OSTrap);
}
bool TrapAvailable(UInt16 theTrap)
{
TrapType tType;
tType = GetTrapType(theTrap);
if (tType == ToolTrap)
if (theTrap & 0x3FF >= NumToolboxTraps())
return false;
return (NGetTrapAddress(theTrap, tType) !=
GetToolboxTrapAddress(_Unimplemented));
}
void PatchATrap( UInt16 theTrap, ProcPtr newTrap, ProcPtr *saveTrapPtr )
{
ProcPtr saveTrap;
TrapType tType = GetTrapType( theTrap );
saveTrap = NGetTrapAddress( theTrap, tType );
if ( saveTrapPtr != nil )
*saveTrapPtr = saveTrap;
NSetTrapAddress( newTrap, theTrap, tType );
}
Regarding INITs and Think C, there's this article from MacTech magazine:
http://preserve.mactech.com/articles/mactech/Vol.05/05.10/INITinC/index.html
It describes the CallPascal function.
This tech note has some Think C sample code that has a definition for QDGlobals:
https://preterhuman.net/macstuff/technotes/ov/ov_13.html