;APS00000000000000000000000000000000000000000000000000000000000000000000000000000000 ;include 'asm_includes:hardware.i' ;include 'asm_includes:blit.i' TakeSystem: movem.l d0-d7/a0-a6,-(sp) bsr .Go movem.l (sp)+,d0-d7/a0-a6 rts .Go: movea.l 4.w,a6 lea $dff002,a5 lea GfxName,a1 moveq #0,d0 jsr -552(a6) move.l d0,GfxBase beq.w .exit move.l d0,a6 move.l 34(a6),OldView sub.l a1,a1 jsr -222(a6) ;LoadView jsr -270(a6) ;WaitTOF jsr -270(a6) jsr -456(a6) ;OwnBlitter jsr -228(a6) ;WaitBlit movea.l 4.w,a6 jsr -132(a6) ;Forbid cmpi.b #50,530(a6) beq.b .pal st ntsc .pal: move.w $7c-2(a5),d0 ; AGA register... cmpi.b #$f8,d0 ; are we AGA? bne.b .not_aga ; nope. st AGA ; set the AGA flag. move.w #0,$dff1fc ; reset AGA sprites to normal mode .not_aga: bsr.w GetVBR ; get the vector base pointer move.l d0,VectorBase ; save it for later. move.w $2-2(a5),d0 ; old DMACON bits ori.w #$8000,d0 ; or it set bit for restore move.w d0,OldDMACon ; save it move.w $1c-2(a5),d0 ; old INTEna bits ori.w #$c000,d0 ; or it set bit for restore move.w d0,OldINTEna ; save it move.w $1e-2(a5),d0 move.w d0,OldINTReq bsr.w test_cpu_type move.l $6c.w,OldLev3 move.l #$7fff7fff,$9a-2(a5) ; kill all ints move.w #$7fff,$96-2(a5) ; kill all dma .exit: rts *********************************************************** RestoreSystem: movem.l d0-d7/a0-a6,-(sp) bsr .Go movem.l (sp)+,d0-d7/a0-a6 rts .Go: lea $dff002,a5 ; custom chip base + 2 ; You must do these in this order or you're asking for trouble! move.l #$7fff7fff,$9a-2(a5) ; kill all ints move.w #$7fff,$96-2(a5) ; kill all dma move.l OldLev3(pc),$6c.w move.w OldDMACon(pc),$96-2(a5) ; restore old dma bits move.w OldINTEna(pc),$9a-2(a5) ; restore old int bits move.w OldINTReq(pc),$9c-2(a5) ; restore old intreq bits move.l OldView(pc),a1 move.l GfxBase(pc),a6 jsr -222(a6) ;LoadView jsr -462(a6) ;DisOwnBlitter move.l 38(a6),$80-2(a5) ; restore system clist move.l a6,a1 movea.l 4.w,a6 jsr -414(a6) jsr -138(a6) ;Permit rts TEST_CPU_TYPE: movem.l d0-d1/a0,-(a7) MOVE.L 4.w,A0 MOVE.B $129(A0),D0 MOVE.L #68040,D1 ;68040 BTST #$03,D0 BNE.B .exit MOVE.L #68030,D1 ;68030 BTST #$02,D0 BNE.B .exit MOVE.L #68020,D1 ;68020 BTST #$01,D0 BNE.B .exit MOVE.L #68010,D1 ;68010 BTST #$00,D0 BNE.B .exit MOVE.L #68000,D1 ;68000 .exit MOVE.L D1,CPU movem.l (a7)+,d0-d1/a0 RTS *********************************************************** * Inputs: none * Output: d0 contains vbr. GetVBR: move.l a5,-(sp) ; save it. moveq #0,d0 ; clear movea.l 4.w,a6 ; exec base btst.b #0,296+1(a6) ; are we at least a 68010? beq.b .1 ; nope. lea.l VBR_Exception(pc),a5 ; addr of function to get VBR jsr -30(a6) .1: move.l (sp)+,a5 ; restore it. rts ; return VBR_Exception: dc.w $4e7a,$0801 rte ; back to user state code *********************************************************** GfxName: dc.b 'graphics.library',0 even GfxBase: ds.l 1 ; pointer to graphics base OldView: ds.l 1 ; old Work Bench view addr. OldLev3: ds.l 1 VectorBase: ds.l 1 ; pointer to the Vector Base OldDMACon: ds.w 1 ; old dmacon bits OldINTEna: ds.w 1 ; old intena bits OldINTReq: ds.w 1 ; old intreq bits ntsc: ds.b 1 ; 0 = pal, 1 = ntsc AGA: ds.b 1 ; 0 = ESC/standard, 1 = AGA CPU: ds.l 0 ; cpu type 680x0 .