English Amiga Board


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

 
 
Thread Tools
Old 02 May 2018, 00:23   #1
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
display a picture with custom size?

I'm trying to learn how to display a picture with asm, however I'm stucked with picture with different size (no 320*256) or <> 3 bitplanes.

This is the code for 3 bitplanes:

Code:
    incdir "dh1:/own/images/"
    
    SECTION    CiriCop,CODE

START:
    move.l    4.w,a6        
    jsr    -$78(a6)    
    lea    GfxName(PC),a1    
    jsr    -$198(a6)    
    move.l    d0,GfxBase    
    move.l    d0,a6
    move.l    $26(a6),OldCop    

    MOVE.L    #PIC,d0                        

    LEA    BPLPOINTERS,A1    
                
    MOVEQ    #3-1,D1 ; bitplanes count - 1       
                
POINTBP:
    move.w    d0,6(a1)    
                
    swap    d0                        
                
    move.w    d0,2(a1)    
                
    swap    d0        
                
    add.l    #40*256,d0 ; pic size    
        
    addq.w    #8,a1        
                
    dbra    d1,POINTBP    

    move.l    #COPPERLIST,$dff080    
    move.w    d0,$dff088        

    move.w    #0,$dff1fc        
    move.w    #$c00,$dff106        

mouse:
    btst    #6,$bfe001    
    bne.s    mouse        

    move.l    OldCop(PC),$dff080    
    move.w    d0,$dff088        

    move.l    4.w,a6
    jsr    -$7e(a6)    
    move.l    gfxbase(PC),a1    
    jsr    -$19e(a6)    
    rts            



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

GfxBase:        
    dc.l    0    

OldCop:            
    dc.l    0

    SECTION    GRAPHIC,DATA_C

COPPERLIST:


    dc.w    $120,$0000,$122,$0000,$124,$0000,$126,$0000,$128,$0000    ; clear sprite pointers
    dc.w    $12a,$0000,$12c,$0000,$12e,$0000,$130,$0000,$132,$0000  ; clear sprite pointers
    dc.w    $134,$0000,$136,$0000,$138,$0000,$13a,$0000,$13c,$0000  ; clear sprite pointers
    dc.w    $13e,$0000

    dc.w    $8e,$2c81    ; DiwStrt    (registri con valori normali)
    dc.w    $90,$2cc1    ; DiwStop
    dc.w    $92,$0038    ; DdfStart
    dc.w    $94,$00d0    ; DdfStop
    dc.w    $102,0        ; BplCon1
    dc.w    $104,0        ; BplCon2
    dc.w    $108,0        ; Bpl1Mod
    dc.w    $10a,0        ; Bpl2Mod


            ; 5432109876543210
    dc.w    $100,%0011001000000000    


BPLPOINTERS:
    dc.w $e0,$0000,$e2,$0000    ; BPL0PT
    dc.w $e4,$0000,$e6,$0000    ; BPL1PT
    dc.w $e8,$0000,$ea,$0000    ; BPL2PT

    dc.w $0180,$0001,$0182,$00af,$0184,$0148,$0186,$0666    ; picture palette
    dc.w $0188,$007e,$018a,$0aaa,$018c,$0eee,$018e,$0689    ; picture palette

    dc.w    $FFFF,$FFFE    

PIC:
    incbin    "logo_SM_320_256_3.raw"    
                    
end
Now, let's say I try to load a pic with size 320*128;
the only change I do is with the line:

add.l #40*256,d0 ; pic size
to
add.l #40*128,d0 ; pic size

However I can see my picture twice on the screen, on top and bottom of the screen.. and this is the custom size issue.


Now let's say I try loading a pic 320*256 with 4 bitplanes instead of 3.
I will change:


MOVEQ #3-1,D1 ; bitplanes count - 1
to
MOVEQ #4-1,D1 ; bitplanes count - 1

Change this:
dc.w $100,%0100001000000000 ; bits 14 (4 = %100)

And then I add this line to BLPOINTERS:
dc.w $ec,$0000,$ee,$0000 ; bitplane - BPL3PT

However the picture appears disturbed.

What's wrong with the code?
fstarred is offline  
Old 02 May 2018, 00:42   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by fstarred View Post
However I can see my picture twice on the screen, on top and bottom of the screen.. and this is the custom size issue.
You also have to change the display window size. DIWSTRT is $2cxx = $2c and DIWSTOP is $2cxx = $12c, so you still have a display window from $2c to $12c with 256 lines.

Quote:
dc.w $100,%0100001000000000 ; bits 14 (4 = %100)
It makes not much sense to write BPLCON0 in binary. $4200 will make it more clear (4 bitplanes).

Quote:
And then I add this line to BLPOINTERS:
dc.w $ec,$0000,$ee,$0000 ; bitplane - BPL3PT
Did you insert it at the right place? I.e. directly behind the BPL2PTs?
phx is offline  
Old 02 May 2018, 08:39   #3
Ozzyboshi
Registered User
 
Join Date: Aug 2017
Location: Italy
Posts: 22
Quote:
Originally Posted by phx View Post
You also have to change the display window size. DIWSTRT is $2cxx = $2c and DIWSTOP is $2cxx = $12c, so you still have a display window from $2c to $12c with 256 lines.

It makes not much sense to write BPLCON0 in binary. $4200 will make it more clear (4 bitplanes).

Did you insert it at the right place? I.e. directly behind the BPL2PTs?
He's writing BPLCON0 in binary because he's copying ramjam asm course. The book initially uses the binary notation to help the reader to understand how this register works.
I assume (never tried) that if the windows size remains 320X256 and you use a 128px image, the latter will be duplicated and the bitplanes overlappings dont match...
Increasing the bitplane number is trivial and it should work as you stated, if not I am available to take a look at your code, the ramjam course is well done and I was able to use whatever bitplane combination.
I see you are italian like me, feel free to contact me if you want some help.
Ozzyboshi is offline  
Old 02 May 2018, 10:34   #4
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Hi all!

Quote:
You also have to change the display window size. DIWSTRT is $2cxx = $2c and DIWSTOP is $2cxx = $12c, so you still have a display window from $2c to $12c with 256 lines.
Yes ! I've changed DIWSTOP to $ac ($2c + $80) and now it works!
Thank you very much

Quote:
He's writing BPLCON0 in binary because he's copying ramjam asm course. The book initially uses the binary notation to help the reader to understand how this register works.
Busted!!

This is the full code for 4 bitplanes, I can see the image "disturbed".

Code:

	incdir "dh1:/own/images/"
	
	SECTION	CiriCop,CODE

START:
	move.l	4.w,a6		
	jsr	-$78(a6)	
	lea	GfxName(PC),a1	
	jsr	-$198(a6)	
	move.l	d0,GfxBase	
	move.l	d0,a6
	move.l	$26(a6),OldCop	

	MOVE.L	#PIC,d0						

	LEA	BPLPOINTERS,A1	
				
	MOVEQ #4-1,D1 ; bitplanes count - 1 
				
POINTBP:
	move.w	d0,6(a1)	
				
	swap	d0						
				
	move.w	d0,2(a1)	
				
	swap	d0		
				
	add.l	#40*256,d0	
		
	addq.w	#8,a1		
				
	dbra	d1,POINTBP	

	move.l	#COPPERLIST,$dff080	
	move.w	d0,$dff088		

	move.w	#0,$dff1fc		
	move.w	#$c00,$dff106		

mouse:
	btst	#6,$bfe001	
	bne.s	mouse		

	move.l	OldCop(PC),$dff080	
	move.w	d0,$dff088		

	move.l	4.w,a6
	jsr	-$7e(a6)	
	move.l	gfxbase(PC),a1	
	jsr	-$19e(a6)	
	rts			



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

GfxBase:		
	dc.l	0	

OldCop:			
	dc.l	0

	SECTION	GRAPHIC,DATA_C

COPPERLIST:


	dc.w	$120,$0000,$122,$0000,$124,$0000,$126,$0000,$128,$0000	; clear sprite pointers
	dc.w	$12a,$0000,$12c,$0000,$12e,$0000,$130,$0000,$132,$0000  ; clear sprite pointers
	dc.w	$134,$0000,$136,$0000,$138,$0000,$13a,$0000,$13c,$0000  ; clear sprite pointers
	dc.w	$13e,$0000

	dc.w	$8e,$2c81	; DiwStrt
	dc.w	$90,$2cc1	; DiwStop
	dc.w	$92,$0038	; DdfStart
	dc.w	$94,$00d0	; DdfStop
	dc.w	$102,0		; BplCon1
	dc.w	$104,0		; BplCon2
	dc.w	$108,0		; Bpl1Mod
	dc.w	$10a,0		; Bpl2Mod


	dc.w	$100,$4200


BPLPOINTERS:
	dc.w $e0,$0000,$e2,$0000	; BPL0PT
	dc.w $e4,$0000,$e6,$0000	; BPL1PT
	dc.w $e8,$0000,$ea,$0000	; BPL2PT
	dc.w $ec,$0000,$ee,$0000	; BPL3PT
	

	dc.w $0180,$0000,$0182,$018f,$0184,$0048,$0186,$0555
	dc.w $0188,$005b,$018a,$0998,$018c,$0037,$018e,$007e
	dc.w $0190,$0169,$0192,$0cdd,$0194,$0689,$0196,$0124
	dc.w $0198,$0677,$019a,$0aba,$019c,$0eff,$019e,$00af



	dc.w	$FFFF,$FFFE	


PIC:
	incbin	"logo_SM_320_256_4.raw"	
					
end
Quote:
I see you are italian like me, feel free to contact me if you want some help.
Thank you very much mate!
Attached Thumbnails
Click image for larger version

Name:	a600+hd+wbench2-full-1805021046-01.png
Views:	123
Size:	50.5 KB
ID:	58045  

Last edited by fstarred; 02 May 2018 at 10:47.
fstarred is offline  
Old 02 May 2018, 11:31   #5
Ozzyboshi
Registered User
 
Join Date: Aug 2017
Location: Italy
Posts: 22
the code is correct, the only thing it It might be wrong it's the color palette, did you double check it?

Quote:
Originally Posted by fstarred View Post
Hi all!



Yes ! I've changed DIWSTOP to $ac ($2c + $80) and now it works!
Thank you very much



Busted!!

This is the full code for 4 bitplanes, I can see the image "disturbed".

Code:

	incdir "dh1:/own/images/"
	
	SECTION	CiriCop,CODE

START:
	move.l	4.w,a6		
	jsr	-$78(a6)	
	lea	GfxName(PC),a1	
	jsr	-$198(a6)	
	move.l	d0,GfxBase	
	move.l	d0,a6
	move.l	$26(a6),OldCop	

	MOVE.L	#PIC,d0						

	LEA	BPLPOINTERS,A1	
				
	MOVEQ #4-1,D1 ; bitplanes count - 1 
				
POINTBP:
	move.w	d0,6(a1)	
				
	swap	d0						
				
	move.w	d0,2(a1)	
				
	swap	d0		
				
	add.l	#40*256,d0	
		
	addq.w	#8,a1		
				
	dbra	d1,POINTBP	

	move.l	#COPPERLIST,$dff080	
	move.w	d0,$dff088		

	move.w	#0,$dff1fc		
	move.w	#$c00,$dff106		

mouse:
	btst	#6,$bfe001	
	bne.s	mouse		

	move.l	OldCop(PC),$dff080	
	move.w	d0,$dff088		

	move.l	4.w,a6
	jsr	-$7e(a6)	
	move.l	gfxbase(PC),a1	
	jsr	-$19e(a6)	
	rts			



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

GfxBase:		
	dc.l	0	

OldCop:			
	dc.l	0

	SECTION	GRAPHIC,DATA_C

COPPERLIST:


	dc.w	$120,$0000,$122,$0000,$124,$0000,$126,$0000,$128,$0000	; clear sprite pointers
	dc.w	$12a,$0000,$12c,$0000,$12e,$0000,$130,$0000,$132,$0000  ; clear sprite pointers
	dc.w	$134,$0000,$136,$0000,$138,$0000,$13a,$0000,$13c,$0000  ; clear sprite pointers
	dc.w	$13e,$0000

	dc.w	$8e,$2c81	; DiwStrt
	dc.w	$90,$2cc1	; DiwStop
	dc.w	$92,$0038	; DdfStart
	dc.w	$94,$00d0	; DdfStop
	dc.w	$102,0		; BplCon1
	dc.w	$104,0		; BplCon2
	dc.w	$108,0		; Bpl1Mod
	dc.w	$10a,0		; Bpl2Mod


	dc.w	$100,$4200


BPLPOINTERS:
	dc.w $e0,$0000,$e2,$0000	; BPL0PT
	dc.w $e4,$0000,$e6,$0000	; BPL1PT
	dc.w $e8,$0000,$ea,$0000	; BPL2PT
	dc.w $ec,$0000,$ee,$0000	; BPL3PT
	

	dc.w $0180,$0000,$0182,$018f,$0184,$0048,$0186,$0555
	dc.w $0188,$005b,$018a,$0998,$018c,$0037,$018e,$007e
	dc.w $0190,$0169,$0192,$0cdd,$0194,$0689,$0196,$0124
	dc.w $0198,$0677,$019a,$0aba,$019c,$0eff,$019e,$00af



	dc.w	$FFFF,$FFFE	


PIC:
	incbin	"logo_SM_320_256_4.raw"	
					
end


Thank you very much mate!
Ozzyboshi is offline  
Old 02 May 2018, 11:38   #6
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Quote:
Originally Posted by Ozzyboshi View Post
the code is correct, the only thing it It might be wrong it's the color palette, did you double check it?
Yes, I've attached the IFF, RAW and COPPERLIST if you want to check by yourself.
However if you see also the image output of my previous post, the image display looks disturbed.
Attached Files
File Type: zip logo_SM_320_256_4.zip (32.7 KB, 83 views)
fstarred is offline  
Old 02 May 2018, 12:19   #7
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Apparently it was a fault of kefrons converter.. I've used PicCon250 and it appears to work.
fstarred is offline  
Old 02 May 2018, 15:08   #8
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Having similar issue with any depth image having width <> 320.

Let's say the image is 256*128, I've changed this line
add.l #40*256,d0
with
add.l #32*128,d0

These are the values of DiwStrt and Stop

dc.w $8e,$2c81 ; DiwStrt
dc.w $90,$a1c1 ; DiwStop

The output is attached on the post
Attached Thumbnails
Click image for larger version

Name:	a600+hd+wbench2-full-1805021509-01.png
Views:	117
Size:	11.2 KB
ID:	58053  
fstarred is offline  
Old 02 May 2018, 16:01   #9
dodke
Registered User
 
Join Date: Feb 2018
Location: London / UK
Posts: 112
Have you tried changing the lower 8 bits in window start / stop which are the horizontal values? Try something like $2ca1 and $a1a1
dodke is offline  
Old 02 May 2018, 16:02   #10
Ozzyboshi
Registered User
 
Join Date: Aug 2017
Location: Italy
Posts: 22
how did you calculate a1c1?

Quote:
Originally Posted by fstarred View Post
Having similar issue with any depth image having width <> 320.

Let's say the image is 256*128, I've changed this line
add.l #40*256,d0
with
add.l #32*128,d0

These are the values of DiwStrt and Stop

dc.w $8e,$2c81 ; DiwStrt
dc.w $90,$a1c1 ; DiwStop

The output is attached on the post
Ozzyboshi is offline  
Old 02 May 2018, 17:01   #11
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Uhm.. I don't remember

But at least the height value, I'd calculate values in this way:

height: $2c + $80(128) = $ac
fstarred is offline  
Old 02 May 2018, 17:27   #12
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Check DDFSTRT and DDFSTOP.
ross is offline  
Old 02 May 2018, 18:07   #13
dodke
Registered User
 
Join Date: Feb 2018
Location: London / UK
Posts: 112
Oh, yeah. Change your DDFSTRT and DDFSTOP values. The vertical fetch start / stop are automatically the same as the visible window but when changing the horizontal window size you'll need to set the fetch positions to match so that a correct number of 16 pixels chunks (OCS) are read from memory per scanline. Try increasing/decreasing start/stop by $20 and go from there.
dodke 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
Minimising attached picture size mark_k project.EAB 1 03 February 2013 21:12
Algorithm to double the size of a tile based picture smoothely? Codetapper project.Sprites 9 31 January 2006 04:36
1084s Display Size & WB Overscan Blackjackel6 support.Hardware 1 31 May 2003 14:57
Custom display modes with RivaTuner §ane support.WinUAE 6 02 October 2002 06:54
Custom Display Modes... P-J support.WinUAE 3 15 July 2001 11:23

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 11:01.

Top

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