-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it be both an executable and resident module
- Loading branch information
1 parent
2d14332
commit 2d5ca5f
Showing
9 changed files
with
160 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
all: NoClick NoClick.mos NoClick.os4 | ||
|
||
NoClick: NoClick.c Makefile | ||
vc +aos68k -nostdlib -c99 -O1 -sc -D__NOLIBBASE__ -o $@ $< | ||
# The order of the files given to the compiler is important as this order | ||
# will be kept in the resulting executable. | ||
# The file containing the startup function must be first as AmigaOS simply | ||
# starts executing from the start of the first hunk. Then to make it as | ||
# efficient as possible to load this as a resident, the Resident structure | ||
# is placed next, followed by the actual code for the patch and then ending | ||
# it with an empty function used to point/skip to the end in Resident | ||
# structure. | ||
NoClick: Startup.c Resident.c ResidentInit.c NoClick.c ResidentEnd.c ResidentInit.h NoClick.h ResidentEnd.h Makefile | ||
vc +aos68k -nostdlib -O1 -sc -D__NOLIBBASE__ -o $@ Startup.c Resident.c ResidentInit.c NoClick.c ResidentEnd.c | ||
|
||
NoClick.mos: NoClick.c Makefile | ||
vc +morphos -nostdlib -O1 -sd -D__NOLIBBASE__ -o $@ $< | ||
NoClick.mos: Startup.c Resident.c ResidentInit.c NoClick.c ResidentEnd.c ResidentInit.h NoClick.h ResidentEnd.h Makefile | ||
vc +morphos -nostdlib -O1 -sd -use-lmw -D__NOLIBBASE__ -o $@ Startup.c Resident.c ResidentInit.c NoClick.c ResidentEnd.c | ||
|
||
NoClick.os4: NoClick.c Makefile | ||
vc +aosppc -nostdlib -O1 -sd -D__USE_INLINE__ -D__NOLIBBASE__ -D__NOGLOBALIFACE__ -o $@ $< | ||
NoClick.os4: Startup.c Resident.c ResidentInit.c NoClick.c ResidentEnd.c ResidentInit.h NoClick.h ResidentEnd.h Makefile | ||
vc +aosppc -nostdlib -O1 -sd -use-lmw -D__USE_INLINE__ -D__NOLIBBASE__ -D__NOGLOBALIFACE__ -o $@ Startup.c Resident.c ResidentInit.c NoClick.c ResidentEnd.c | ||
|
||
clean: | ||
$(RM) NoClick NoClick.mos NoClick.os4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef _NOCLICK_H_ | ||
#define _NOCLICK_H_ | ||
|
||
#include <exec/execbase.h> | ||
|
||
#if defined(__amigaos4__) | ||
void NoClick(struct ExecIFace *IExec); | ||
#elif defined(__MORPHOS__) | ||
void NoClick(struct ExecBase *SysBase); | ||
#else | ||
// Putting SysBase in a6 is not necessary here, it is just to make vbcc | ||
// produce simpler/better code. | ||
void NoClick(__reg("a6") struct ExecBase *SysBase); | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <exec/resident.h> | ||
|
||
#include "ResidentEnd.h" | ||
#include "ResidentInit.h" | ||
|
||
const struct Resident ROMTag = { | ||
.rt_MatchWord = RTC_MATCHWORD, | ||
.rt_MatchTag = (void *) &ROMTag, | ||
.rt_EndSkip = (void *) &EndVariable, | ||
#if defined(__amigaos4__) | ||
.rt_Flags = RTF_COLDSTART | RTF_NATIVE, | ||
#elif defined(__MORPHOS__) | ||
.rt_Flags = RTF_COLDSTART | RTF_PPC, | ||
#else | ||
.rt_Flags = RTF_COLDSTART, | ||
#endif | ||
.rt_Version = 2, | ||
.rt_Type = NT_UNKNOWN, // We just want to run rt_Init | ||
.rt_Pri = 0, // Need to be initialized later than trackdisk at 20 | ||
.rt_Name = "NoClick", | ||
.rt_IdString = "NoClick 2.0 (31.10.2022) by Patrik Axelsson", | ||
.rt_Init = (void *) &ResidentInit | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This variable is just used as a reference to skip to the end when it is | ||
// scanned for Resident structures. | ||
const int EndVariable = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef _RESIDENTEND_H_ | ||
#define _RESIDENTEND_H_ | ||
|
||
extern const int EndVariable; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <exec/execbase.h> | ||
#include <dos/dos.h> | ||
#include <devices/trackdisk.h> | ||
|
||
#include <proto/exec.h> | ||
|
||
#include "NoClick.h" | ||
|
||
#if defined(__amigaos4__) | ||
__saveds void ResidentInit(void *zero, BPTR segList, struct ExecBase *sysBase) { | ||
struct ExecIFace *IExec = (void *) sysBase->MainInterface; | ||
IExec->Obtain(); | ||
NoClick(IExec); | ||
IExec->Release(); | ||
} | ||
#elif defined(__MORPHOS__) | ||
__saveds void ResidentInit(void *zero, BPTR segList, struct ExecBase *SysBase) { | ||
NoClick(SysBase); | ||
} | ||
#else | ||
__saveds void ResidentInit(__reg("d0") void *zero, __reg("a0") BPTR segList, __reg("a6") struct ExecBase *SysBase) { | ||
NoClick(SysBase); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef _RESIDENTINIT_H_ | ||
#define _RESIDENTINIT_H_ | ||
|
||
#include <exec/execbase.h> | ||
#include <dos/dos.h> | ||
|
||
#if defined(__amigaos4__) | ||
__saveds void ResidentInit(void *zero, BPTR segList, struct ExecBase *sysBase); | ||
#elif defined(__MORPHOS__) | ||
__saveds void *ResidentInit(void *zero, BPTR segList, struct ExecBase *SysBase); | ||
#else | ||
__saveds void *ResidentInit(__reg("d0") void *zero, __reg("a0") BPTR segList, __reg("a6") struct ExecBase *SysBase); | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <exec/exec.h> | ||
#include <dos/dos.h> | ||
#include <dos/dosextens.h> | ||
#include <workbench/startup.h> | ||
|
||
#include <proto/exec.h> | ||
#include <proto/dos.h> | ||
|
||
#include "NoClick.h" | ||
|
||
|
||
#if defined(__MORPHOS__) | ||
ULONG __abox__ = 1; | ||
#endif | ||
|
||
#if defined(__amigaos4__) | ||
// Must be named _start in AmigaOS4 binaries. | ||
__saveds int32 _start(STRPTR args, int32 argsLength, struct ExecBase *sysBase) { | ||
struct ExecIFace *IExec = (struct ExecIFace *) sysBase->MainInterface; | ||
IExec->Obtain(); | ||
#else | ||
// In 68k AmigaOS and MorphOS binaries, the symbol name doesn't matter, it just have to be first. | ||
__saveds LONG Startup(void) { | ||
struct ExecBase *SysBase = *(struct ExecBase **) 4; | ||
#endif | ||
|
||
struct WBStartup *wbStartupMsg = NULL; | ||
struct Process *thisProcess = (struct Process *) FindTask(NULL); | ||
if (0 == thisProcess->pr_CLI) { | ||
// If started from Workbench, get the startup message | ||
WaitPort(&thisProcess->pr_MsgPort); | ||
wbStartupMsg = (void *) GetMsg(&thisProcess->pr_MsgPort); | ||
} | ||
|
||
#if defined(__amigaos4__) | ||
NoClick(IExec); | ||
#else | ||
NoClick(SysBase); | ||
#endif | ||
|
||
if(NULL != wbStartupMsg) { | ||
// This is so Workbench won't unload our segment before we exit | ||
Forbid(); | ||
// If started from Workbench, reply to the startup message | ||
ReplyMsg((void *) wbStartupMsg); | ||
} | ||
|
||
#if defined(__amigaos4__) | ||
IExec->Release(); | ||
#endif | ||
|
||
return RETURN_OK; | ||
} |