A.D.A. Amiga Demoscene Archive

        Welcome guest!

  

  

  

log in with SceneID

  

Demos Amiga Demoscene Archive Forum / Coding / Artefacts flashing over my simple copperlist screen

 

Author Message
thyslo
Member
#1 - Posted: 15 Aug 2019 21:13
Reply Quote
Hi all!

I'm doing my first experiences with Amiga asm, trying to learn about copper lists and all the hardware stuff but want also to use system functions where possible.

And so I took an old, simple example from a book and wrote it down in a more system compliant way, as I think.

The simple copper list which is displayed works good on my OS 3.1.4 dev system (WinUAE). Starting from an rtg screen and going back there also works fine.

But when I start it on another WinUAE config; a basic A1200 setup with 3.1 ROMs and Workbench some artifacts flashing over the screen. Its a bit heavier towards the start, then it becomes 'quieter'.

What can be the reason for the artefacts?

Here is the current code:


include exec/memory.i
include libraries/lowlevel.i

;
; Stating the used LVOs
;
XREF _LVOOpenLibrary
XREF _LVOCloseLibrary
XREF _LVOAllocVec
XREF _LVOFreeVec
XREF _LVOSystemControlA
XREF _LVOLoadView
XREF _LVOWaitTOF

*======================================================================
* Initializations
*======================================================================

move.l 4,a6 ;Use exec.library

;
; Open graphics.library
;
move.l 4,a6
lea GfxName,a1
moveq #0,d0
jsr _LVOOpenLibrary(a6)
move.l d0,_GfxBase
beq Exit

;
; Open lowlevel.library
;
lea LowLevelName,a1
moveq #40,d0
jsr _LVOOpenLibrary(a6)
move.l d0,_LowLevelBase ;Save lowlevel base
beq Exit

;
; Allocate memory for picture
;
move.l #10800,d0 ;Size of needed memory
move.l #MEMF_CHIP,d1 ;It must be Chip memory
or.l #MEMF_CLEAR,d1 ;New memory should be cleared
jsr _LVOAllocVec(a6)
move.l d0,picture ;Save ptr of allocated memory
tst.l d0
beq Exit ;No memory has been reserved

;
; Takeover the system in a compatible way
;
move.l _LowLevelBase,a6
lea TagList1,a1
jsr _LVOSystemControlA(a6)
move.l d0,System ;Result is 0 on success
bne Exit

*======================================================================
* Main
*======================================================================

;
; Switch off current copper list without smashing the current
; screen. The order of LoadView(0) and 2xWaitTOF()
; is set by Commodore
;
move.l _GfxBase,a6 ;Use graphics.library
move.l 34(a6),OldView ;Save current view
sub.l a1,a1 ;Clear a1 to display no view
jsr _LVOLoadView(a6)
jsr _LVOWaitTOF(a6)
jsr _LVOWaitTOF(a6)

;
; Load address of allocated memory for the picture
;
lea picture,a0
move.l (a0),d0
move.w d0,pl1+6
swap d0
move.w d0,pl1+2

move.l #$0020,$dff096 ;Disable sprites

lea copperlist,a2
move.l a2,$dff080 ;Activate copper list
loop:
move.l $dff004,d0 ;WaitTOF (beam)
and.l #$fff00,d0
cmp.l #$0003000,d0
bne.s loop

btst #6,$bfe001 ;Left mouse button pressed?
bne.s loop

move.l #$8020,$dff096 ;Enable sprites


RestoreView:
move.l OldView,d0 ;Restore former view
beq Exit_1 ;But only if there was one
move.l _GfxBase,a6 ;Use graphics.library
jsr _LVOWaitTOF(a6)
jsr _LVOWaitTOF(a6)
move.l OldView,a1
jsr _LVOLoadView(a6)
move.l 38(a6),$dff080 ;Start former copper instr. list

*======================================================================
* Clean up
*======================================================================

Exit:
; Restore system control if it was acquired sucessfully
tst.l System
bne Exit_1
move.l _LowLevelBase,a6
lea TagList2,a1
jsr _LVOSystemControlA(a6)

Exit_1:
; Free memory if it was allocated successfully
move.l 4,a6
move.l picture,d0
tst.l d0
beq Exit_2
move.l d0,a1
jsr _LVOFreeVec(a6)

Exit_2:
; Close lowlevel.library
move.l 4,a6
move.l _LowLevelBase,d0 ;LibBase needed in d-reg for verify
beq Exit_3
move.l d0,a1 ;LibBase needed in a1 for closing
jsr _LVOCloseLibrary(a6)

Exit_3:
; Close graphics.library
move.l 4,a6 ;Use exec.library
move.l _GfxBase,d0 ;LibBase needed in d-reg for verify
beq Exit_4
move.l d0,a1 ;LibBase needed in a1 for closing
jsr _LVOCloseLibrary(a6)


Exit_4:
rts;


*======================================================================
* Data
*======================================================================

_LowLevelBase:
cnop 0,2
dc.l 0

_GfxBase:
dc.l 0

OldView:
dc.l 0

System:
dc.l -1 ; -1 is important; see code refs


LowLevelName:
dc.b "lowlevel.library",0

GfxName:
dc.b "graphics.library",0


TagList1:
dc.l SCON_TakeOverSys,-1 ;TRUE
dc.l SCON_AddCreateKeys,1 ;JoyPort1 to RAW keys
dc.l TAG_DONE

TagList2:
dc.l SCON_TakeOverSys,0 ;FALSE
dc.l SCON_RemCreateKeys,1 ;Reset JoyPort1
dc.l TAG_DONE

picture:
cnop 0,2
ds.l 1


SECTION "dma",data,chip

copperlist CNOP 0,4
dc.w $0207,$fffe ;Required for AGA machines
dc.w $008e,$3081 ;DIWSTRT
dc.w $0090,$35c1 ;DIWSTOP
dc.w $0104,$0064 ;BPLCON2
dc.w $0092,$0038 ;DDFSTRT
dc.w $0094,$00d0 ;DDFSTOP
dc.w $0102,$0000 ;BPLCON1
dc.w $0108,$0000 ;BPL1MOD
dc.w $010a,$0000 ;BPL2MOD
dc.w $0100,$1200 ;BPLCON0
pl1: dc.w $00e0,$0000 ;BPL1PTH
dc.w $00e2,$0000 ;BPL1PTL

dc.w $0180,$0f00 ;COLOR00 -> red
dc.w $7007,$fffe ;WAIT
dc.w $0180,$0fff ;COLOR00 -> white
dc.w $e007,$fffe ;WAIT
dc.w $0180,$0f00 ;COLOR00 -> red

dc.w $ff07,$fffe ;Wait for last ntsc line
dc.w $ffff,$fffe ;Waiting for impossible position

END

jar
Member
#2 - Posted: 19 Aug 2019 11:21
Reply Quote
hi,

maybe disabling the sprite DMA has to be included into the copperlist instead of doing it just once. i.e. try if removing the line

 move.l  #$0020,$dff096      ;Disable sprites


and then adding

dc.w $0096,$0020


to your copperlist helps.
thyslo
Member
#3 - Posted: 19 Aug 2019 21:27
Reply Quote
That fixed it:-)

Thank you!
jar
Member
#4 - Posted: 20 Aug 2019 09:35
Reply Quote
great, glad i could help.
also: seems like i finally start to understand some stuff :)

 

  Please log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0