Skip to content

Commit 3453495

Browse files
committed
[rtg] warn if unable to set MMU page flags
P96 v3.2.4+ no longer supports the fallback to set MMU page flags directly
1 parent 3e26f71 commit 3453495

File tree

1 file changed

+68
-4
lines changed

1 file changed

+68
-4
lines changed

rtg/replay.card.asm

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ SYSTEM_INCLUDES
6464
incdir asm_include:
6565
include lvo/exec_lib.i
6666
include lvo/expansion_lib.i
67+
include lvo/intuition_lib.i
6768
include exec/exec.i
6869
include libraries/expansionbase.i
6970
include hardware/intbits.i
7071
include utility/tagitem.i
72+
include intuition/intuition.i
7173
ENDC
7274

7375
;debug
@@ -513,18 +515,57 @@ DataTable:
513515
move.l a1,gbi_SetSpriteColor(a2)
514516
ENDC
515517

518+
; Only bother with MMU flags if there is a (real) 68060 present
519+
; A softcore CPU is fully snooped, so no need..
520+
move.l gbi_ExecBase(a2),a6
521+
btst #7,AttnFlags+1(a6) ; AFB_68060
522+
beq .skipCM
523+
516524
; Try to set memory region MMU flags via mmu.library first
517525
move.l gbi_MemoryBase(a2),a0
518526
move.l gbi_MemorySize(a2),d0
519527
move.l #MAPP_CACHEINHIBIT|MAPP_IMPRECISE|MAPP_NONSERIALIZED,d1
520-
move.l gbi_ExecBase(a2),a6
521528
bsr SetMMU
522529
cmp.l #-1,d0
523-
bne.b .skip
530+
bne .skipCM
531+
532+
BUG "mmu.library failed"
533+
534+
; Ok, no mmu.library - let's try with the P96 flag BIF_CACHEMODECHANGE
535+
; This is however not supported since P96 v3.2.4 (rtg.library 42.1226)
536+
; Let's check the currently running rtg.library version and warn the user if that's the case
537+
538+
moveq.l #42,d0
539+
lea .rtgName(pc),a1
540+
CALLLIB _LVOOpenLibrary (libName, version)
541+
542+
tst.l d0
543+
bne.b .gotRTG
544+
545+
BUG "Unable to open rtg.library v42"
546+
bra.b .changeCM
547+
548+
.gotRTG:
549+
movea.l d0,a1
550+
move.w LIB_REVISION(a1),-(sp)
551+
move.w LIB_VERSION(a1),-(sp)
552+
CALLLIB _LVOCloseLibrary (library)
553+
554+
move.l (sp)+,d0 ; <LIB_VERSION> | <LIB_REVISION>
524555

525-
; mmu.library failed - let's try with the P96 flags
556+
BUG "P96 / rtg.library %d.%d",d0
557+
558+
cmpi.l #(42<<16)|(1226),d0
559+
blt.b .changeCM
560+
561+
BUG "rtg.library 42.1226 and later - show alert!"
562+
bra.b .errorMMU
563+
564+
.changeCM:
565+
BUG "Using BIF_CACHEMODECHANGE to change MMU flags for %lx/%lx", gbi_MemoryBase(a2), gbi_MemorySize(a2)
526566
ori.l #BIF_CACHEMODECHANGE,gbi_Flags(a2)
527-
.skip
567+
568+
.skipCM
528569
move.l gbi_MemoryBase(a2),(gbi_MemorySpaceBase,a2)
529570
move.l gbi_MemorySize(a2),(gbi_MemorySpaceSize,a2)
530571

@@ -537,6 +578,29 @@ DataTable:
537578
movem.l (sp)+,a2/a5/a6
538579
rts
539580

581+
.errorMMU:
582+
moveq.l #37,d0
583+
lea.l .intuiName(pc),a1
584+
CALLLIB _LVOOpenLibrary (libName, version)
585+
tst.l d0
586+
beq.b .skipCM
587+
588+
movea.l d0,a6
589+
moveq.l #RECOVERY_ALERT,d0
590+
lea.l .noMMUmsg(pc),a0
591+
moveq.l #30,d1
592+
CALLLIB _LVODisplayAlert ( AlertNumber, String, Height )
593+
594+
movea.l a6,a1
595+
CALLLIB _LVOCloseLibrary (library)
596+
597+
bra.b .skipCM
598+
599+
.rtgName: dc.b 'rtg.library',0
600+
.intuiName: dc.b 'intuition.library',0
601+
.noMMUmsg dc.b $00, $28, $10, "Replay.card with P96 v3.2.4+ (rtg.library 42.1226) requires mmu.library", $00, $00
602+
even
603+
540604
;------------------------------------------------------------------------------
541605
SetSwitch:
542606
;------------------------------------------------------------------------------

0 commit comments

Comments
 (0)