View Single Post
Old 31 March 2018, 15:46   #1
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
ASM newbie, general help

Hi all, I'm asking for basic help about some points:

  1. step to step debug on ASM ONE 1.02
  2. copper behaviour
  3. XOR flag
- About point 1, I usually use the command "AD", however when working with copper I can't go through because screen freezes up when COPPER start to work

- About point 2, with the code below my purpose was to paint a red line starting from the middle of the screen, reaching the bottom of the screen and then reverse back until reaching the top of the screen, switch back again and so on.
Things works more or less, however the bar start from 1/3rd of the screen and reach the 2/3rd of the screen (see the attached image)
What's the matter there?

- About point 3, always on the code below I think I can optimize the code by using an XOR command on Direction flag to switch its value instead of branch to SetUp and SetDown.
How does XOR works?


Thank you

PS
I'm using ASM ONE 1.02 with FS UAE (A600 + HD)

Code:
;*****************
;*   Constants   *
;*****************

OldOpenLibrary	= -$198		; -408
CloseLibrary	= -$19E		; -414

DMASET=	%1000000111000000
;	 -----a-bcdefghij

;	a: Blitter Nasty
;	b: Bitplane DMA (if this isn't set, sprites disappear!)
;	c: Copper DMA
;	d: Blitter DMA
;	e: Sprite DMA
;	f: Disk DMA
;	g-j: Audio 3-0 DMA

	SECTION	CODESECTION,CODE	; This command will run the below code
					; on FAST RAM (if enough) or CHIP RAM

START:
	MOVE.L	$4.W,A6			; Exec pointer to A6
	LEA.L	GfxName(PC),A1		; Set library pointer to A1
	MOVEQ	#0,D0
	JSR	OldOpenLibrary(A6)	; Open graphics.library
					; write to D0 the offset
	MOVE.L	D0,A1			; Use Base-pointer
	MOVE.L	$26(A1),OLDCOP		; Store copperlist system address,
					; retrieved $26 from glib offset
	JSR	CloseLibrary(A6)	; Close graphics library	
				
	move.l	#COPPERLIST,$dff080	; COP1LC - Point to #COPPERLIST
	move.w	d0,$dff088		; COPJMP1 - Start COP

main:
	cmpi.b	#$ff,$dff006	; VHPOSR wait for horizontal line
				; of the light pen
	bne.s	main		; if pen did not reach the end, repeat loop
	bsr.s	movebar		; 

waitmouse:
	btst	#6,$bfe001	; check for left mouse button
	bne.s	main		; if not, repeat the above line
end:
	move.l	OldCop(PC),$dff080	; COP1LC - Point to default COP system
	move.w	d0,$dff088		; COPJMP1 - Restart COP

	move.l	4.w,a6
	jsr	-$7e(a6)	; Enable  Multitasking
	move.l	gfxbase(PC),a1	; Point to gfxbase
	jsr	-$19e(a6)	; Closelibrary
	rts

GfxName:
	dc.b	"graphics.library",0,0
	
GfxBase:		; Dedicated to offset "graphics.library"
	dc.l	0	 

OldCop:			; Dedicated to system COP address
	dc.l	0


Movebar:
	LEA	REDBAR,a0
	TST.B	Direction
	BEQ.S	Movebardown
	BNE.S	Movebarup
;waitpen:
;	cmpi.b	#$ff,$dff006
;	BEQ.S	waitpen
;	BNE.S	waitmouse
	RTS

ToggleDirection:
	TST.B	Direction
	BEQ.S	SetUp
	BNE.S	SetDown
	RTS

SetUp:
	MOVE.B	#1,Direction
	RTS

SetDown:
	MOVE.B	#0,Direction
	RTS
	
Movebarup:
	SUBQ.B	#1,8(a0)
	SUBQ.B	#1,(a0)
	CMPI.W	#$7e07,(a0)
	BEQ.S	ToggleDirection
	RTS	

Movebardown:
	ADDQ.B	#1,(a0)
	ADDQ.B	#1,8(a0)
	CMPI.w	#$fd07,8(a0)
	BEQ.S	ToggleDirection
	RTS	

Direction:
	DC.B	0,0

	SECTION	GRAPHIC,DATA_C	; Section below MUST be executen on CHIP RAM,
				; because COPPERLIST requires it
		
COPPERLIST:
	dc.w	$100,$200	; BPLCON0 - THE BITLANE CONTROL
	dc.w	$180,$000	; Color 0 - BLACK
	dc.w	$7d07,$FFFE
	dc.w	$180,$00f	; Color 0 - BLUE
	dc.w	$7e07,$FFFE	; TOP LIMIT
	dc.w	$180,$000

REDBAR:
	dc.w	$7f07,$FFFE	; Wait for line $7f (half screen)
	dc.w	$180,$F00	; Color 0 - RED
	dc.w	$8007,$FFFE	; Wait for line $80 (next line)
	dc.w	$180,$000	; Color 0 - BLACK
	dc.w	$fe07,$FFFE	; Wait for last line

	dc.w	$180,$00F	; Color 0 - BLUE
	dc.w	$ff07,$FFFE
	dc.w	$180,$000
	dc.w	$FFFF,$FFFE	; END OF COPPERLIST
Attached Thumbnails
Click image for larger version

Name:	red_bar.png
Views:	163
Size:	821 Bytes
ID:	57563  

Last edited by fstarred; 31 March 2018 at 15:52.
fstarred is offline  
 
Page generated in 0.04361 seconds with 12 queries