English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 16 April 2021, 14:24   #1
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Advice on a first time Blitting issue

Hi folks,

I've been using some free time over the last few days to start dabbling in assembly/hardware stuff, and it's a lot of fun, but I've hit a brick wall which I just can't seem to get by.

I'm trying to blit a 64x90 (WxH) RAW interlaced image to the screen, but I just can't seem to get it right. I end up with some weird squashed image with no colour except white. I'm not doing anything fancy, it's just a standard $FO blit.

I don't want to fiddle any further with it, because I seem to be making things worse with every edit to the code, and I'm starting to get frustrated at the lack of progress.

Can anyone take a wee eyeball to my code and offer advice? I've likely set something wrong with one of the modulos somewhere, or one of the constants, but my beginner's brain isn't seeing it.

I'm using Notepad++, VASM, WinUAE, A600 setting, 4 Bitplane 320x256 screen.Thanks. Code is below:

Code:
;------------------------------------------------------------------------------------------------------------
;		CONSTANTS & SETUP
;-----------------------------------------------------------------------------------------------------------

	ORG $20000
	
	SECTION code,CODE
	
INIT:

SCR_W				= 	320;
SCR_H				=	256;
SCR_BPLSIZE			=	SCR_W*(SCR_H/8);
SCR_BPL				=	SCR_W/8;		

SCR_B_WIDTH			= 	SCR_BPL*4

; -- Turn off Amiga Operating System using library --

OSoff:
	
	move.l 	4.w,a6							; Execbase
	clr.l 	d0
	move.l 	#GFXNAME,a1
	jsr 	-408(a6)						; oldopenlibrary()
	move.l 	d0,a1
	move.l 	38(a1),d4						; Original copper ptr

	jsr 	-414(a6)						; Closelibrary()
	
; -- Enable/Disable relebant bits in registers --

EnaDis:	
	move.w 	$dff01c,d5
	move.w 	$dff002,d3
	
	move.w 	#%1000000000000000,$dff096		; Set relevant bits in DMACON	- dff096
	
	move.w 	#%0111111111111111,$dff09a		; Disable all bits in INTENA	- dff09a
	move.w 	#%0111111111111111,$dff09c		; Disable all bits in INTENAQ	- dff09c	
	
	;move.w 	#%0000000000100000,$dff106		; Set relevant bits in BPLCON3	- dff106
	
	movem.l d0-a6,-(sp)						; Back up registers to Stack Pointer
	
	bsr Blit
	
HW_INIT:

; -- Fill screen with stuff --

;	lea SCREENADDR,a1
;	move.w #SCR_BPL-1,d0
;.l	move.b #16,(a1)+;
;	dbf d0,.l

; -- BITPLANE POKE --

	lea SCREEN,a0	; Pointer to first bitplne of screen

	lea CoBplPr,a1		; Where to poke the bitplane pointer words.
	move #4-1,d0		; counter
	
.bpl_loop:

	move.l a0,d1
	swap d1
	move.w d1,2(a1)		; hi word
	swap d1
	move.w d1,6(a1)		; lo word

	addq #8,a1			; Point to next bpl to poke in copper
	add SCR_BPLSIZE,a0 
	
	dbf d0,.bpl_loop
	
;-----------------------------------	
;	SET COPPER LIST	
;-----------------------------------

SetCopper:
	
	move.l 	#COPPER,$dff080		;COP1LCH

;------------------------------------------------------------------------------------------------------------
;		MAIN LOOP
;------------------------------------------------------------------------------------------------------------

MAIN_LOOP:
	
	btst	#6,$bfe001			; Click Left Mouse Button to exit	
	bne 	MAIN_LOOP			; If not pressed then loop

;-----------------------------------------------------------------------------------------------------------
;		MAIN LOOP END / EXIT
;----------------------------------------------------------------------------------------------------------

EXIT:
	movem.l (sp)+,d0-a6			; Restore registers from Stack Pointer
	move.l 	d4,$dff080			; Restore original Copper list
	or 		#$C000,d5			; Enable Master bit
	move 	d5,$dff09a			; Restore interrupts and system to INTENA
	rts

;-------------------------------------------------------------------------------------------------------	
;	SUBROUTINES
;-------------------------------------------------------------------------------------------------------
	
; -- BLITTER TEST --
	
Blit:	

bltX 		= 16
bltY 		= 16
bltOffs 	= bltY*(SCR_B_WIDTH*4)+(bltX/8)

blt_height 	= 90
blt_widthV	= 64
blt_width 	= blt_widthV/16

blt_modu 	= (SCR_W-blt_widthV)/8	
	
	lea $dff000,a6								; Custom Chip base address (a6)	
	tst $002(a6)								; DMACONR
	
.waitblit										; Wait for Blitter to finish
	btst #6,$002(a6)
	bne.s .waitblit	

	move.l #$09f00000,$040(a6)					; BLTCON0 - Set Blitter Control bits
	move.l #$ffffffff,$044(a6)					; BLTAFWM - Set Source Mask
	
	move.l #Frame,$050(a6)						; BLTAPTH - Source (A) pointer
	move.l #SCREEN+bltOffs,$054(a6)				; BLTDPTH - Destination (D) pointer
	
	move.w #blt_modu,$064(a6)					; BLTAMOD - Source Modulo
	move.w #blt_modu,$066(a6)					; BLTDMOD - Destination Modulo
	
	move.w #blt_height*4*64+blt_width,$058(a6)	; BLTSIZE - Size of Rectangle
	
	rts

;------------------------------------------------------------------------------------------------------------
;		DATA (COPPER, TABLES, GRAPHICS)
;-----------------------------------------------------------------------------------------------------------	

GFXNAME:
	dc.b "graphics.library",0
	
SECTION DATA_C

	;EVEN
	
; ----- COPPER ---------------------------------------------------------------------------------------------	

COPPER:

; -- DISPLAY SCREEN SIZE --
	dc.w $1fc,0	
	dc.w $08E,$2C81						; Display Screen Top Left  		(VVHH)
	dc.w $090,$F4C1 					; Display Screen Botom Right 	(VVHH)
	dc.w $092,$38						; Display Bitplane Fetch Start 	(XXHH)
	dc.w $094,$D0						; Display Bitplane Fetch Stop	(XXHH)
	
	dc.w $100,%0100001000000001			; BPLCON0
	dc.w $106,%0000000000100000			; BPLCON3 - Enable ECS Border Blanking
	
	dc.w $108,SCR_B_WIDTH-SCR_BPL		; Bitplane Modulo (odd planes)
	dc.w $10A,SCR_B_WIDTH-SCR_BPL		; Bitplane Modulo (even planes)		
		
; -- BITPLANE POINTERS -- 				;	-- 4 Bitplanes --

CoBplPr:
	dc.w $0e0,0							; Bitplane Pointer 1 (High 5 Bits) (ECS)
	dc.w $0e2,0							; Bitplane Pointer 1 (Low 15 Bits)
	
	dc.w $0e4,0							; Bitplane Pointer 2 (High 5 Bits)
	dc.w $0e6,0							; Bitplane Pointer 2 (Low 15 Bits)
	
	dc.w $0e8,0							; Bitplane Pointer 3 (High 5 Bits)
	dc.w $0ea,0							; Bitplane Pointer 3 (Low 15 Bits)
	
	dc.w $0ec,0							; Bitplane Pointer 4 (High 5 Bits)
	dc.w $0ee,0							; Bitplane Pointer 4 (Low 15 Bits)

; -- PALETTE COLOURS -- ;	

PalDefs:
	dc.w $180,$000f					; Colour 0
	dc.w $182,$0111					; Colour 1
	dc.w $184,$0620					; Colour 2
	dc.w $186,$0864					; Colour 3
	dc.w $188,$0A86					; Colour 4
	dc.w $18a,$0046					; Colour 5
	dc.w $18c,$00AC					; Colour 6
	dc.w $18e,$08EE					; Colour 7
	dc.w $190,$0A40					; Colour 8
	dc.w $192,$0E60					; Colour 9
	dc.w $194,$0EA0					; Colour 10
	dc.w $196,$0080					; Colour 11
	dc.w $198,$00C0					; Colour 12
	dc.w $19a,$0ECA					; Colour 13
	dc.w $19c,$0CCC					; Colour 14
	dc.w $19e,$0EEE					; Colour 15
	
; -- COPPER END --

	dc.w $ffff,$fffe				; COPPER END
	
;------------------------------------------------------------------------------------------------------------
;		END OF COPPER LIST
;------------------------------------------------------------------------------------------------------------

Frame:
	INCBIN "C:\Amiga\FFARES\FRAME64x90x4.RAW"
FrameE:

Mask:
	INCBIN "C:\Amiga\FFARES\SNES64x90x4MASK.RAW"
MaskE:

;------------------------------------------------------------------------------------------------------------
;		BSS
;------------------------------------------------------------------------------------------------------------

	SECTION BSS,BSS_C
	
SCREEN:

	ds.b SCR_BPLSIZE
		
	END
Brick Nash is offline  
Old 16 April 2021, 15:19   #2
DanScott
Lemon. / Core Design
 
DanScott's Avatar
 
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
Your BLTAMOD should not be the same as your screen... it maybe should be 0

what is happening is at the end of each line, it is then skipping a lot of gfx data before blitting the next line
DanScott is offline  
Old 16 April 2021, 15:30   #3
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
You are mixing up interleaved and non-interleaved. Copperlist is set up for interleaved bitmap but the rest is not entirely. Try this (no included gfx, so I can't see if it works but it doesn't crash unlike the original that corrupts memory list).
Changes are marked with ";ab":
Code:
;------------------------------------------------------------------------------------------------------------
;		CONSTANTS & SETUP
;-----------------------------------------------------------------------------------------------------------

	ORG $20000
	
	SECTION code,CODE
	
INIT:

SCR_W				= 	320;
SCR_H				=	256;
;ab SCR_BPLSIZE			=	SCR_W*(SCR_H/8);
;ab SCR_BPL				=	SCR_W/8;		
SCR_BPL				=	SCR_W/8
SCR_BPLSIZE			=	SCR_BPL*SCR_H

SCR_B_WIDTH			= 	SCR_BPL*4

; -- Turn off Amiga Operating System using library --

OSoff:
	
	move.l 	4.w,a6							; Execbase
	clr.l 	d0
	move.l 	#GFXNAME,a1
	jsr 	-408(a6)						; oldopenlibrary()
	move.l 	d0,a1
	move.l 	38(a1),d4						; Original copper ptr

	jsr 	-414(a6)						; Closelibrary()
	
; -- Enable/Disable relebant bits in registers --

EnaDis:	
	move.w 	$dff01c,d5
	move.w 	$dff002,d3
	
	move.w 	#%1000000000000000,$dff096		; Set relevant bits in DMACON	- dff096
	
	move.w 	#%0111111111111111,$dff09a		; Disable all bits in INTENA	- dff09a
	move.w 	#%0111111111111111,$dff09c		; Disable all bits in INTENAQ	- dff09c	
	
	;move.w 	#%0000000000100000,$dff106		; Set relevant bits in BPLCON3	- dff106
	
	movem.l d0-a6,-(sp)						; Back up registers to Stack Pointer
	
	bsr Blit
	
HW_INIT:

; -- Fill screen with stuff --

;	lea SCREENADDR,a1
;	move.w #SCR_BPL-1,d0
;.l	move.b #16,(a1)+;
;	dbf d0,.l

; -- BITPLANE POKE --

	lea SCREEN,a0	; Pointer to first bitplne of screen

	lea CoBplPr,a1		; Where to poke the bitplane pointer words.
;ab	move #4-1,d0		; counter
	moveq	#4-1,d0		; counter
	
.bpl_loop:

	move.l a0,d1
	swap d1
	move.w d1,2(a1)		; hi word
	swap d1
	move.w d1,6(a1)		; lo word

	addq #8,a1			; Point to next bpl to poke in copper
;ab	add SCR_BPLSIZE,a0 
	lea	SCR_BPL(a0),a0 	; interleaved bitmap (see BPLxMOD in copperlist)
;or	add.w	#SCR_BPL,a0 

	
	dbf d0,.bpl_loop
	
;-----------------------------------	
;	SET COPPER LIST	
;-----------------------------------

SetCopper:
	
	move.l 	#COPPER,$dff080		;COP1LCH

;------------------------------------------------------------------------------------------------------------
;		MAIN LOOP
;------------------------------------------------------------------------------------------------------------

MAIN_LOOP:
	
	btst	#6,$bfe001			; Click Left Mouse Button to exit	
	bne 	MAIN_LOOP			; If not pressed then loop

;-----------------------------------------------------------------------------------------------------------
;		MAIN LOOP END / EXIT
;----------------------------------------------------------------------------------------------------------

EXIT:
	movem.l (sp)+,d0-a6			; Restore registers from Stack Pointer
	move.l 	d4,$dff080			; Restore original Copper list
	or 		#$C000,d5			; Enable Master bit
	move 	d5,$dff09a			; Restore interrupts and system to INTENA
	rts

;-------------------------------------------------------------------------------------------------------	
;	SUBROUTINES
;-------------------------------------------------------------------------------------------------------
	
; -- BLITTER TEST --
	
Blit:	

bltX 		= 16
bltY 		= 16
;ab bltOffs 	= bltY*(SCR_B_WIDTH*4)+(bltX/8)
bltOffs 	= bltY*SCR_B_WIDTH+(bltX/8)			; SCR_B_WIDTH already mul by 4

blt_height 	= 90
blt_widthV	= 64
blt_width 	= blt_widthV/16

;ab blt_modu 	= (SCR_W-blt_widthV)/8	
blt_modu 	= (SCR_B_WIDTH-blt_widthV)/8		; interleaved, must mul width by 4
	
	lea $dff000,a6								; Custom Chip base address (a6)	
	tst $002(a6)								; DMACONR
	
.waitblit										; Wait for Blitter to finish
	btst #6,$002(a6)
	bne.s .waitblit	

	move.l #$09f00000,$040(a6)					; BLTCON0 - Set Blitter Control bits
	move.l #$ffffffff,$044(a6)					; BLTAFWM - Set Source Mask
	
	move.l #Frame,$050(a6)						; BLTAPTH - Source (A) pointer
	move.l #SCREEN+bltOffs,$054(a6)				; BLTDPTH - Destination (D) pointer
	
	move.w #blt_modu,$064(a6)					; BLTAMOD - Source Modulo
	move.w #blt_modu,$066(a6)					; BLTDMOD - Destination Modulo
	
	move.w #blt_height*4*64+blt_width,$058(a6)	; BLTSIZE - Size of Rectangle
	
	rts

;------------------------------------------------------------------------------------------------------------
;		DATA (COPPER, TABLES, GRAPHICS)
;-----------------------------------------------------------------------------------------------------------	

GFXNAME:
	dc.b "graphics.library",0
	
	SECTION qq,DATA_C

	;EVEN
	
; ----- COPPER ---------------------------------------------------------------------------------------------	

COPPER:

; -- DISPLAY SCREEN SIZE --
	dc.w $1fc,0	
	dc.w $08E,$2C81						; Display Screen Top Left  		(VVHH)
	dc.w $090,$F4C1 					; Display Screen Botom Right 	(VVHH)
	dc.w $092,$38						; Display Bitplane Fetch Start 	(XXHH)
	dc.w $094,$D0						; Display Bitplane Fetch Stop	(XXHH)
	
	dc.w $100,%0100001000000001			; BPLCON0
	dc.w $106,%0000000000100000			; BPLCON3 - Enable ECS Border Blanking
	
	dc.w $108,SCR_B_WIDTH-SCR_BPL		; Bitplane Modulo (odd planes)
	dc.w $10A,SCR_B_WIDTH-SCR_BPL		; Bitplane Modulo (even planes)		
		
; -- BITPLANE POINTERS -- 				;	-- 4 Bitplanes --

CoBplPr:
	dc.w $0e0,0							; Bitplane Pointer 1 (High 5 Bits) (ECS)
	dc.w $0e2,0							; Bitplane Pointer 1 (Low 15 Bits)
	
	dc.w $0e4,0							; Bitplane Pointer 2 (High 5 Bits)
	dc.w $0e6,0							; Bitplane Pointer 2 (Low 15 Bits)
	
	dc.w $0e8,0							; Bitplane Pointer 3 (High 5 Bits)
	dc.w $0ea,0							; Bitplane Pointer 3 (Low 15 Bits)
	
	dc.w $0ec,0							; Bitplane Pointer 4 (High 5 Bits)
	dc.w $0ee,0							; Bitplane Pointer 4 (Low 15 Bits)

; -- PALETTE COLOURS -- ;	

PalDefs:
	dc.w $180,$000f					; Colour 0
	dc.w $182,$0111					; Colour 1
	dc.w $184,$0620					; Colour 2
	dc.w $186,$0864					; Colour 3
	dc.w $188,$0A86					; Colour 4
	dc.w $18a,$0046					; Colour 5
	dc.w $18c,$00AC					; Colour 6
	dc.w $18e,$08EE					; Colour 7
	dc.w $190,$0A40					; Colour 8
	dc.w $192,$0E60					; Colour 9
	dc.w $194,$0EA0					; Colour 10
	dc.w $196,$0080					; Colour 11
	dc.w $198,$00C0					; Colour 12
	dc.w $19a,$0ECA					; Colour 13
	dc.w $19c,$0CCC					; Colour 14
	dc.w $19e,$0EEE					; Colour 15
	
; -- COPPER END --

	dc.w $ffff,$fffe				; COPPER END
	
;------------------------------------------------------------------------------------------------------------
;		END OF COPPER LIST
;------------------------------------------------------------------------------------------------------------

Frame:
	INCBIN "C:\Amiga\FFARES\FRAME64x90x4.RAW"
FrameE:

Mask:
	INCBIN "C:\Amiga\FFARES\SNES64x90x4MASK.RAW"
MaskE:

;------------------------------------------------------------------------------------------------------------
;		BSS
;------------------------------------------------------------------------------------------------------------

	SECTION BSS,BSS_C
	
SCREEN:

	ds.b SCR_BPLSIZE
		
	END
a/b is offline  
Old 16 April 2021, 15:45   #4
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Thank you for the replies, and my sincerest apologies for forgetting to provide the image.

Here is the file: https://drive.google.com/file/d/18g8...ew?usp=sharing

I tried your code a/b, and I also tried DanScott's suggestion about setting the source modulo to #0. Both improved the image, but it's still not quite there.

I'm very grateful to everyone for taking the time to help.
Brick Nash is offline  
Old 16 April 2021, 15:52   #5
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Still thinking about it, I effed up blit modulo. It should remain as:
Code:
blt_modu 	= (SCR_W-blt_widthV)/8
Will check with gfx soon.
a/b is offline  
Old 16 April 2021, 16:17   #6
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Excellent! The image is now displaying!

There's other garbage on the screen for some reason (image below), but everything else looks good. I'll go through the corrections and try to learn what's happening for future reference.

https://drive.google.com/file/d/1EmU...ew?usp=sharing
Brick Nash is offline  
Old 16 April 2021, 16:22   #7
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Yeah, with blit modulos (both A and D should be the same in this case) reverted to original value, it works for me (I get a fighter guy with suspended trousers in top-left corner). There is another problem, you are not allocating the bitmap properly (only 1 bitplane):
Code:
SCREEN:
;ab	ds.b SCR_BPLSIZE
	ds.b SCR_BPLSIZE*4
a/b is offline  
Old 16 April 2021, 16:36   #8
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Yes that works! And that's the very image I was trying to get.

The screen is looking very clean now. I'm getting a weird black line being drawn over his legs, but I'm not sure if that's some rogue pixel that's found its way into the image. I can't see anything.

https://drive.google.com/file/d/1IfA...ew?usp=sharing

EDIT: The line was a streak from when I was grabbing a brush in PPaint. I must have had the draw mode on instead of select.

Anyway, thank you everyone for your help!

Last edited by Brick Nash; 16 April 2021 at 16:51.
Brick Nash is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice for OSSC and a1200 (PAL) Workbench issue Steve030 support.Hardware 3 10 April 2020 21:26
ClassicWB Time Issue? Tempest 2084 support.Hardware 7 06 July 2009 19:38
Time To KickStart *issue* W4r3DeV1L support.Hardware 1 02 December 2008 22:15
Next issue any time soon? MheAd project.APoV 49 31 October 2008 13:22
Borrowed Time issue Unregistered support.Games 1 18 July 2004 02:55

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 00:46.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07993 seconds with 13 queries