******************************************************************************* * copper.device.S Written by Readysoft. * Copyright 1993,1994 RS. All rights reserved. 1993.03.03.-1994.05.18. * v1.24. ******************************************************************************* ******************************************************************************* * Macros ******************************************************************************* ;------------------------------------------------------------------------------ ; CopperName Macro ;------------------------------------------------------------------------------ COP.NAM MACRO DC.B 'copper.device',0 EVEN ENDM ******************************************************************************* * DEV Macro ******************************************************************************* COP.DEV MACRO ******************************************************************************* * Constant Definitions ******************************************************************************* ;------------------------------------------------------------------------------ ; Error Codes ;------------------------------------------------------------------------------ cop_er_OK EQU $00000000 all right cop_er_Reset EQU $80040001 unable to reset CList cop_er_Move EQU $80040002 unable to add Move cop_er_Wait EQU $80040003 unable to add Wait cop_er_List EQU $80040004 unable to add List cop_er_Enlarge EQU $80040005 unable to enlarge CList cop_er_Set EQU $80040006 unable to set CList cop_er_UnDef EQU $8004ffff undefined error ******************************************************************************* * Varibles ******************************************************************************* RSRESET cop_CurrentList RS.L 1 current list cop_CLLength RS.L 1 length of current list cop_NewList RS.L 1 new list cop_NLLength RS.L 1 length of new list cop_NLPointer RS.L 1 pointer in new list cop_NLFree RS.L 1 free bytes in new list cop_NLLastVPos RS.W 1 last vertical position cop_SizeOf RS.B 0 ******************************************************************************* * Routine Offsets ******************************************************************************* RSRESET RS.B -6 cop_Init RS.B -6 cop_Reset RS.B -6 cop_AddMove RS.B -6 cop_AddWait RS.B -6 cop_AddList RS.B -6 cop_AskAddress RS.B -6 cop_Set RS.B -6 ******************************************************************************* * Code ******************************************************************************* jmp cop.Set jmp cop.AskAddress jmp cop.AddList jmp cop.AddWait jmp cop.AddMove jmp cop.Reset jmp cop.Init copper.dev BLK.B cop_SizeOf,0 EVEN ;------------------------------------------------------------------------------ ; Init NoOp ;------------------------------------------------------------------------------ cop.Init movem.l d0/a0/a5,-(a7) lea copper.dev(pc),a5 lea cus_BASE,a6 move.l a5,a0 clear varible area move.w #cop_SizeOf-1,d0 .Clear clr.b (a0)+ dbf d0,.Clear bsr cop.Reset init CList lea cop.InitList(pc),a0 move.l #cop_InitLSizeOf,d0 size of InitList bsr cop.AddList add initlist bsr cop.Set set CList movem.l (a7)+,d0/a0/a5 rts ;------------------------------------------------------------------------------ ; Reset NoOp ;------------------------------------------------------------------------------ cop.Reset movem.l d0-d1/a5,-(a7) lea copper.dev(pc),a5 tst.l cop_NewList(a5) is there already bne.s .Error new list ? move.l #1024,d0 allocate 1024 bytes move.l #mem_ty_Chip,d1 for CList jsr mem.AllocMem tst.l d0 beq.s .Error move.l a0,cop_NewList(a5) move.l #1024,cop_NLLength(a5) clr.l cop_NLPointer(a5) move.l #1024,cop_NLFree(a5) clr.w cop_NLLastVPos(a5) movem.l (a7)+,d0-d1/a5 rts .Error move.l #cop_er_Reset,d0 unable to reset CList jmp sys.FatalError ;------------------------------------------------------------------------------ ; AddMove Destination,Data(d0,d1) ;------------------------------------------------------------------------------ cop.AddMove movem.l d0-d3/a0/a5,-(a7) lea copper.dev(pc),a5 move.l d0,d2 move.l d1,d3 tst.l cop_NewList(a5) is there already beq.s .Error new list ? cmpi.l #4,cop_NLFree(a5) bge.s .Enough bsr cop.EnlargeNL .Enough move.l cop_NewList(a5),a0 move.l cop_NLPointer(a5),d0 move.w d2,0(a0,d0.l) move.w d3,2(a0,d0.l) addq.l #4,d0 move.l d0,cop_NLPointer(a5) subq.l #4,cop_NLFree(a5) movem.l (a7)+,d0-d3/a0/a5 rts .Error move.l #cop_er_Move,d0 unable to add Move jmp sys.FatalError ;------------------------------------------------------------------------------ ; AddWait HPos,VPos(d0,d1) ;------------------------------------------------------------------------------ cop.AddWait movem.l d0-d3/a0/a5,-(a7) lea copper.dev(pc),a5 move.l d0,d2 HPos move.l d1,d3 VPos tst.l cop_NewList(a5) is there already beq.s .Error new list ? cmpi.l #8,cop_NLFree(a5) bge.s .Enough bsr cop.EnlargeNL .Enough move.l cop_NewList(a5),a0 move.l cop_NLPointer(a5),d0 cmpi.w #$138,d3 blt.s .PosOK move.w #$138,d3 .PosOK cmpi.w #$100,d3 high position ? blt.s .NoWaitH cmpi.w #$100,cop_NLLastVPos(a5) high last position ? bge.s .NoWaitH move.l #$ffdffffe,0(a0,d0.l) wait high addq.l #4,d0 subq.l #4,cop_NLFree(a5) .NoWaitH move.w d3,cop_NLLastVPos(a5) move.b d3,0(a0,d0.l) move.b d2,1(a0,d0.l) move.w #$fffe,2(a0,d0.l) addq.l #4,d0 subq.l #4,cop_NLFree(a5) move.l d0,cop_NLPointer(a5) movem.l (a7)+,d0-d3/a0/a5 rts .Error move.l #cop_er_Wait,d0 unable to add Wait jmp sys.FatalError ;------------------------------------------------------------------------------ ; AddList List,Length(a0,d0) ;------------------------------------------------------------------------------ cop.AddList movem.l d0-d1/a0-a1/a5,-(a7) lea copper.dev(pc),a5 move.l d0,d1 Length beq.s .Error move.l a0,a1 List tst.l cop_NewList(a5) is there already beq.s .Error new list ? .Test cmp.l cop_NLFree(a5),d1 ble.s .Enough bsr cop.EnlargeNL bra.s .Test .Enough move.l cop_NewList(a5),a0 move.l cop_NLPointer(a5),d0 lea 0(a0,d0.l),a0 add.l d1,cop_NLPointer(a5) sub.l d1,cop_NLFree(a5) lsr.l #2,d1 subq.l #1,d1 .Copy move.l (a1)+,(a0)+ dbf d1,.Copy movem.l (a7)+,d0-d1/a0-a1/a5 rts .Error move.l #cop_er_List,d0 unable to add List jmp sys.FatalError ;------------------------------------------------------------------------------ ; AskAddress NoOp --> CurrentAddress(d0) ;------------------------------------------------------------------------------ cop.AskAddress movem.l a0/a5,-(a7) lea copper.dev(pc),a5 tst.l cop_NewList(a5) is there already beq.s .Error new list ? move.l cop_NewList(a5),a0 address of new list move.l cop_NLPointer(a5),d0 lea 0(a0,d0.l),a0 move.l a0,d0 .Exit movem.l (a7)+,a0/a5 rts .Error moveq #0,d0 no NewList bra.s .Exit ;------------------------------------------------------------------------------ ; Set NoOp ;------------------------------------------------------------------------------ cop.Set movem.l d0/a1/a5,-(a7) lea copper.dev(pc),a5 lea cus_BASE,a6 tst.l cop_NewList(a5) is there already beq.s .Error new list ? tst.l cop_CurrentList(a5) is there current list ? beq.s .NoCL move.l cop_CLLength(a5),d0 free last list move.l cop_CurrentList(a5),a1 jsr mem.FreeMem tst.l d0 beq.s .Error .NoCL move.l cop_NewList(a5),d0 move.l d0,cop_CurrentList(a5) move.l cop_NLLength(a5),d0 move.l d0,cop_CLLength(a5) clr.l cop_NewList(a5) clr.l cop_NLLength(a5) clr.l cop_NLPointer(a5) clr.l cop_NLFree(a5) clr.w cop_NLLastVPos(a5) move.l cop_CurrentList(a5),d0 move.l d0,cus_COP1LC(a6) movem.l (a7)+,d0/a1/a5 rts .Error move.l #cop_er_Set,d0 unable to set CList jmp sys.FatalError ******************************************************************************* * Private Routines ******************************************************************************* ;------------------------------------------------------------------------------ ; EnlargeNL NoOp ;------------------------------------------------------------------------------ cop.EnlargeNL movem.l d0-d1/a0-a2/a5,-(a7) lea copper.dev(pc),a5 move.l cop_NLLength(a5),d0 allocate larger block add.l #1024,d0 move.l #mem_ty_ChipC,d1 jsr mem.AllocMem tst.l d0 beq.w .Error move.l a0,a2 address of new block move.l cop_NewList(a5),a1 old block move.l cop_NLLength(a5),d0 lsr.l #2,d0 subq.l #1,d0 .Copy move.l (a1)+,(a2)+ dbf d0,.Copy move.l cop_NLLength(a5),d0 free old block move.l cop_NewList(a5),a1 jsr mem.FreeMem tst.l d0 beq.s .Error move.l a0,cop_NewList(a5) add.l #1024,cop_NLLength(a5) add.l #1024,cop_NLFree(a5) movem.l (a7)+,d0-d1/a0-a2/a5 rts .Error move.l #cop_er_Enlarge,d0 unable to enlarge CList jmp sys.FatalError ******************************************************************************* * DataArea ******************************************************************************* cop.InitList DC.W $106,0,$1fc,0 DC.W $180,0,$100,$0200 DC.W $ffff,$fffe cop_InitLSizeOf EQU *-cop.InitList size of initlist ENDM