Skip to content

Commit eb09548

Browse files
committed
TinySetPatch: Add backward compatibility for Kickstart 1.x
Save command line arguments (D0=length, A0=pointer) immediately at program entry before any operations can destroy these registers. This replaces the use of GetArgStr() which requires dos.library V36+. Add version checks before calling CacheClearU() in Install060Vectors and FixVector7Align, as this function requires exec V37+. On older Kickstart versions, the cache clear is simply skipped. These changes allow TinySetPatch to run on Kickstart 1.2/1.3 systems, making it useful for creating bootable system disks targeting older Amiga configurations. Changes: - Save D0/A0 to ArgLength/ArgPointer at Start before register clobber - Guard CacheClearU calls with LIB_VERSION >= 37 checks - Rewrite ParseArgs to use saved arguments instead of GetArgStr - Remove a6 from ParseArgs register save (no longer needed)
1 parent ce3542f commit eb09548

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/TinySetPatch.S

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ DEBUG_PATCHES EQU 0 ; Set to 1 to prompt before each patch
8383
; MAIN ENTRY POINT
8484
; =============================================================
8585
Start:
86+
; Save command line arguments (D0=length, A0=pointer)
87+
; Must be done BEFORE any other operations destroy these registers
88+
lea ArgLength(pc),a1
89+
move.l d0,(a1)
90+
lea ArgPointer(pc),a1
91+
move.l a0,(a1)
92+
8693
movem.l d2-d7/a2-a6,-(sp)
8794

8895
; --- Setup DOS for output ---
@@ -603,9 +610,12 @@ Install060Vectors:
603610
move.l a1,VEC_UNIMP_INT(a0)
604611
move.l a1,VEC_UNIMP_INT.w
605612

606-
; Clear caches
613+
; Clear caches (CacheClearU requires exec V37+)
607614
move.l AbsExecBase.w,a6
615+
cmpi.w #37,LIB_VERSION(a6)
616+
blt.s .SkipCacheClr1
608617
jsr _LVOCacheClearU(a6)
618+
.SkipCacheClr1:
609619

610620
movem.l (sp)+,d0-d2/a0-a2
611621
rts
@@ -825,8 +835,12 @@ FixVector7Align:
825835
dc.w $4E7A,$8801 ; MOVEC VBR,A0
826836
moveq #-2,d0
827837
and.l d0,28(a0) ; Clear bit 0 of vector 7
838+
; CacheClearU requires exec V37+
828839
move.l AbsExecBase.w,a6
840+
cmpi.w #37,LIB_VERSION(a6)
841+
blt.s .SkipCacheClr2
829842
jsr _LVOCacheClearU(a6)
843+
.SkipCacheClr2:
830844
movem.l (sp)+,d0/a0/a6
831845
rts
832846

@@ -1047,16 +1061,15 @@ PrintHexLong:
10471061
; =============================================================
10481062
; PARSE COMMAND LINE ARGUMENTS
10491063
; Checks for QUIET keyword (case insensitive)
1064+
; Uses saved D0/A0 from program entry (works on all Kickstart versions)
10501065
; =============================================================
10511066
ParseArgs:
1052-
movem.l d0-d2/a0-a2/a6,-(sp)
1067+
movem.l d0-d2/a0-a2,-(sp)
10531068

1054-
; Get command line using GetArgStr (dos.library V36+)
1055-
move.l DOSBase(pc),a6
1056-
jsr _LVOGetArgStr(a6)
1057-
tst.l d0
1058-
beq.s .pa_done
1059-
move.l d0,a0 ; A0 = argument string
1069+
; Get saved command line (D0=length, A0=pointer from program entry)
1070+
move.l ArgLength(pc),d0
1071+
beq.s .pa_done ; No arguments
1072+
move.l ArgPointer(pc),a0 ; A0 = argument string
10601073

10611074
; Scan for "QUIET" keyword
10621075
lea ArgQuiet(pc),a1 ; A1 = "QUIET" to match
@@ -1109,7 +1122,7 @@ ParseArgs:
11091122
move.b #1,(a0)
11101123

11111124
.pa_done:
1112-
movem.l (sp)+,d0-d2/a0-a2/a6
1125+
movem.l (sp)+,d0-d2/a0-a2
11131126
rts
11141127

11151128
; =============================================================
@@ -1120,6 +1133,8 @@ DOSBase: dc.l 0
11201133
LibBase: dc.l 0
11211134
DetectedCPU: dc.l 0
11221135
SavedCACR: dc.l 0
1136+
ArgLength: dc.l 0 ; Saved from D0 at entry
1137+
ArgPointer: dc.l 0 ; Saved from A0 at entry
11231138
QuietMode: dc.b 0 ; Non-zero = suppress output
11241139
EVEN
11251140

0 commit comments

Comments
 (0)