CACHEOFF Equ 0 ;1 = Disable caches NTSCEXIT Equ 0 ;1 = Exit if no PAL CHIPSETEXIT Equ 0 ;1 = Exit if = 68010 ? Beq.s .no010 Lea .getVBRException(PC),a5 Jmp -$1e(a6) ;Supervisor() .no010 Rts CNOP 0,4 .getVBRException Dc.l $4e7a2801 ;MoveC VBR,d2 Rte IFNE CACHEOFF DisableCache Move.l 4.w,a6 MoveQ #0,d0 ;Get old cache state MoveQ #0,d1 Bsr.s CacheControl Lea oldCache(PC),a0 Move.l d0,(a0) Move.l d0,d1 ;Disable cache MoveQ #0,d0 CacheControl ;Based on KCS3.0 MoveQ #0,d3 Move.w $128(a6),d4 Btst #1,d4 Beq.s .no020 And.l d1,d0 Or.w #$808,d0 Not.l d1 Lea .cacheException(PC),a5 Jsr -$1e(a6) ;Supervisor() .no020 Move.l d3,d0 Rts CNOP 0,4 .cacheException Or.w #$700,SR Dc.l $4e7a2002 ;MoveC CACR,d2 Btst #3,d4 Beq.s .no040a Swap d2 Ror.w #8,d2 Rol.l #1,d2 .no040a Move.l d2,d3 And.l d1,d2 Or.l d0,d2 Btst #3,d4 Beq.s .no040b Ror.l #1,d2 Rol.w #8,d2 Swap d2 And.l #$80008000,d2 Nop Dc.w $f4f8 ;CPushA BC .no040b Nop Dc.l $4e7b2002 ;MoveC d2,CACR Nop Rte restoreCache Move.l 4.w,a6 Move.l oldCache(PC),d0 Move.l d0,d1 Bra.s CacheControl ENDC WaitBeam Lsl.l #8,d0 .wlp: Move.l $04(a4),d1 And.l #$1ff00,d1 Cmp.l d0,d1 Bne.s .wlp Rts ;---------------------------------------------------------------------------------------------- FreeSystem Lea $dff000,a4 MoveQ #$1f,d0 Bsr.s WaitBeam Move.l #$7fff3fff,$9a(a4) ;Kill INTENA and INTREQ Move.w #$7fff,$9e(a4) ;Kill ADKCON Move.w #$07ff,$96(a4) ;Kill DMACON Move.l zeroPagePtr(PC),a0 Move.l VBRReg(PC),a1 Move.w #$400/4-1,d7 .clp Move.l (a0)+,(a1)+ Dbf d7,.clp Lea oldDMACON(PC),a0 Move.w (a0)+,$96(a4) ;Restore DMACON Move.w (a0)+,$9e(a4) ;Restore ADKCON Move.l (a0),$9a(a4) ;Restore INTENA and INTREQ IFNE CACHEOFF Bsr.s RestoreCache ENDC Move.l gfxBase(PC),a6 IFEQ CHIPSETEXIT Move.b chipSetFlag(PC),d0 Beq.s .noViewFix ENDC Move.l oldView(PC),a1 ;Old WorkBench view MoveQ #$7f,d0 Bsr.s WaitBeam Jsr -$de(a6) ;LoadView() .noViewFix Move.l $26(a6),$80(a4) ;Restore system copper list Move.l $32(a6),$84(a4) Move.w d0,$88(a4) Jsr -$10e(a6) ;WaitTOF() Jsr -$10e(a6) ;Twice Jsr -$e4(a6) ;WaitBlit() Jsr -$1ce(a6) ;DisownBlitter() Move.l a6,a1 Move.l 4.w,a6 Jsr -$19e(a6) ;CloseLibrary() Move.l zeroPagePtr(pc),a1 Move.l #$400,d0 Jsr -$d2(a6) ;FreeMem() Jmp -$8a(a6) ;Permit() ;====================================================================================================== oldDMACON Ds.w 1 oldADKCON Ds.w 1 oldINTENA Ds.l 1 zeroPagePtr Ds.l 1 VBRReg Ds.l 1 oldView Ds.l 1 gfxBase Ds.l 1 IFNE CACHEOFF oldCache Ds.l 1 ENDC gfxLib: Dc.b 'graphics.library',0 IFNE CHIPSETEXIT-2 chipSetFlag Ds.b 1 ;0 = OCS, 1 = ECS, 2 = AGA ENDC IFEQ NTSCEXIT displayFlag Ds.b 1 ;0 = PAL, -1 = NTSC ENDC even .