English Amiga Board


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

 
 
Thread Tools
Old 24 November 2018, 02:51   #1
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
AGA Palette... how to implement

So I managed to get a 32 colour RAW image loaded successfully and now I want to try a 256 colour image. I am using the classic Tutankhamen image from DPaint IV AGA. So I exported that image as a 256 colour binary (Raw?) image (non-interleaved) using PicCon.

Now I know the palette has to be done seperately which is pretty damn annoying and a lot more complicated for 256 colour images. Just to be clear I am setting the correct screenmodes for AGA ($0210) so that is all good I think. What I am not setting yet is bplcon3 bit 9 (LOCT) as mentioned here in this old thread:

http://ada.untergrund.net/?p=boardthread&id=37

The image I get is scrambled though because I haven't a clue how to implement this damn palette. Any hints would be appreciated. I have exported the palette from PicCon as a binary palette and also an Asm source which is posted below. Which one is the easiest to use and how do I implement this damn palette with regards to setting this bit 9 in bplcon3??

Surely I don't have to do this by hand?? Would take me hours!

Any help is much appreciated!
Attached Thumbnails
Click image for larger version

Name:	029.png
Views:	68
Size:	24.1 KB
ID:	60924   Click image for larger version

Name:	fs-uae-full-1811240047-02.png
Views:	101
Size:	64.6 KB
ID:	60925  

Last edited by Steve; 24 November 2018 at 02:58.
Steve is offline  
Old 24 November 2018, 06:30   #2
NorthWay
Registered User
 
Join Date: May 2013
Location: Grimstad / Norway
Posts: 535
The easy way is to save palette as 24-bit copperlist. Just lightly edit it (no sections or labels) and include(not incbin) it as part of your copperlist (which is mostly redundant if you don't keep changing the colours - set them just the once).
Alternatively, just include the same copperlist somewhere and loop over it as a "customoffset,value" pair? You'd do the same job the copper does, only just once.
NorthWay is offline  
Old 24 November 2018, 14:11   #3
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
I only just found these palette setting in PicCon. Which do you suggest I use? The 32bit setting?
Attached Thumbnails
Click image for larger version

Name:	030.png
Views:	85
Size:	30.3 KB
ID:	60931  
Steve is offline  
Old 24 November 2018, 14:23   #4
ross
Sum, ergo Cogito

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,462
Quote:
Originally Posted by Steve View Post
I only just found these palette setting in PicCon. Which do you suggest I use? The 32bit setting?
These settings are right.

PicCon also make the BPLCON3 settings for you.
You simply need to incbin in your copper list.
ross is offline  
Old 24 November 2018, 16:30   #5
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
Quote:
Originally Posted by ross View Post
These settings are right.

PicCon also make the BPLCON3 settings for you.
You simply need to incbin in your copper list.
Thanks, I seem to have got a bit closer to the correct colours. Looking a bit strange though and it's glitching-out a lot.

I wonder what I'm doing wrong.
Attached Thumbnails
Click image for larger version

Name:	fs-uae-crop-1811241426-02.png
Views:	50
Size:	87.3 KB
ID:	60932   Click image for larger version

Name:	fs-uae-crop-1811241426-01.png
Views:	54
Size:	115.3 KB
ID:	60933   Click image for larger version

Name:	fs-uae-crop-1811241426-03.png
Views:	49
Size:	115.5 KB
ID:	60934   Click image for larger version

Name:	fs-uae-crop-1811241426-04.png
Views:	66
Size:	105.8 KB
ID:	60935  
Steve is offline  
Old 24 November 2018, 17:00   #6
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
Right I think I've found the 'source' of the problem (sorry)

Code:
; Work out the bitplane sizes and addresses and pass to the copperlist.
; Bitplane info: 320*256*8. 40 words per line, 256 lines. 320x356/8bits = 10240bytes
; 10240*5=50kb : 2560 longs per bitplane
;
	lea	bp1h,a0			; first bitplane address in the copper
	moveq	#BITPLANES-1,d0		; Number of bitplanes (BTIPLANES EQU 8)
	move.l	#image,d1		; Address of the picture into d1

	setbpl:
		move.w	d1,6(a0)							; bitplane low address pointer
		swap	d1
		move.w	d1,2(a0)							; bitplane high address
		addq.w	#8,a0								; Point to next bitplane
		swap d1
		add.l 	#10240,d1							; 10240 added for next plane
		dbf d0,setbpl								; branch until all bitplanes are copied
I've not updated these calculations yet! Doh! Scratching my head about the formula for 8 bitplanes. Hmmm.

I've tried increasing the value added to $81920 but that makes it look worse. I bet the solution is obvious to someone.
Steve is offline  
Old 24 November 2018, 19:02   #7
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 586
Probably a silly question, but have you added instructions to set all eight bitplanes to the copperlist? It looks from your screenshot as though at least one bitplane is showing non-image data.
robinsonb5 is offline  
Old 24 November 2018, 19:19   #8
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
Quote:
Originally Posted by robinsonb5 View Post
Probably a silly question, but have you added instructions to set all eight bitplanes to the copperlist? It looks from your screenshot as though at least one bitplane is showing non-image data.
Not a silly question at all. It's a very valid question. Probably what I'm missing. Bugger. lol.

I'm only doing 6 bitplanes. I need to look at this. Not too sure about this part. Still learning this stuff.

Code:
mycopper:			
;	dc.w	BPLCON0,$3200					; %0011001000000000 (3 bitplanes - 8 colours)
;	dc.w	BPLCON0,$5200					; %0101001000000000 (5 bitplanes - 32 colours)
	dc.w	BPLCON0,$0210					; %0101001000000000 (8 bitplanes - 256 colours)
	dc.w	BPLCON1,$0000
	dc.w	BPL1MOD,$0000,BPL2MOD,$0000
	dc.w	DIWSTRT,$2C81,DIWSTOP,$2CC1
	dc.w	DDFSTRT,$0038,DDFSTOP,$00D0
bp1h:	dc.w	BPL1PTH,$0000					; Bitplane 1 high bytes register, use offset
bp1l:	dc.w	BPL1PTL,$0000					; Bitplane 1 high value, Bitplane 1 low register
bp2h:	dc.w	BPL2PTH,$0000					; Bitplane 2 high bytes register, use offset
bp2l:	dc.w	BPL2PTL,$0000					; Bitplane 2 high value, Bitplane 1 low register
bp3h:	dc.w	BPL3PTH,$0000					; Bitplane 3 high bytes register, use offset
bp3l:	dc.w	BPL3PTL,$0000					; Bitplane 3 high value, Bitplane 1 low register
bp4h:	dc.w	BPL4PTH,$0000					; Bitplane 4 high bytes register, use offset
bp4l:	dc.w	BPL4PTL,$0000					; Bitplane 4 high value, Bitplane 1 low register
bp5h:	dc.w	BPL5PTH,$0000					; Bitplane 5 high bytes register, use offset
bp5l:	dc.w	BPL5PTL,$0000					; Bitplane 5 high value, Bitplane 1 low register
bp6h:	dc.w	BPL6PTH,$0000					; Bitplane 6 high bytes register, use offset
bp6l:	dc.w	BPL6PTL,$0000					; Bitplane 6 high value, Bitplane 1 low register
Steve is offline  
Old 24 November 2018, 19:23   #9
ross
Sum, ergo Cogito

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,462
Quote:
Originally Posted by Steve View Post
Right I think I've found the 'source' of the problem (sorry)

I've not updated these calculations yet! Doh! Scratching my head about the formula for 8 bitplanes. Hmmm.

I've tried increasing the value added to $81920 but that makes it look worse. I bet the solution is obvious to someone.
No , the calculation is correct. A bitplane is a bitplane, only the numbers of is changed.
But the real question is: have you inserted in copper list the extra bitplane pointers required to update the extra planes?


EDIT: ok posted before I've seen your post above and as guessed the extra bitplane pointers are missing

Insert:
Code:
bp7h:	dc.w	BPL7PTH,$0000
bp7l:	dc.w	BPL7PTL,$0000
bp8h:	dc.w	BPL8PTH,$0000
bp8l:	dc.w	BPL8PTL,$0000
You are lucky the machine have not crashed, overwriting unwanted memory locations with your code.

Last edited by ross; 24 November 2018 at 19:32.
ross is offline  
Old 24 November 2018, 22:36   #10
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
Thanks for the help Ross. I'm close I think.

I had to manually add in the new registers to my registers.i file and odd things are happening!

If I add the code like this:

Code:
BPL1PT          equ     bplpt+$00
BPL1PTH         equ     bplpt+$00
BPL1PTL         equ     bplpt+$02
BPL2PT          equ     bplpt+$04
BPL2PTH         equ     bplpt+$04
BPL2PTL         equ     bplpt+$06
BPL3PT          equ     bplpt+$08
BPL3PTH         equ     bplpt+$08
BPL3PTL         equ     bplpt+$0A
BPL4PT          equ     bplpt+$0C
BPL4PTH         equ     bplpt+$0C
BPL4PTL         equ     bplpt+$0E
BPL5PT          equ     bplpt+$10
BPL5PTH         equ     bplpt+$10
BPL5PTL         equ     bplpt+$12
BPL6PT          equ     bplpt+$14
BPL6PTH         equ     bplpt+$14
BPL6PTL         equ     bplpt+$16
BPL7PT          equ     bplpt+$18
BPL7PTH         EQU     bplpt+$18
BPL7PTL         EQU     bplpt+$20
BPL8PT          EQU     bplpt+$22
BPL8PTH         EQU     bplpt+$22
BPL8PTL         EQU     bplpt+$24
Then all I get is a grey screen?? The image is gone completely!

EDIT: Ah okay schoolboy error here. Should be $1A, $1C, $1E rght?? Still doesn't explain why the version below doesn't work.

So if I change the last few lines to this (looks correct this time):

Code:
BPL7PTH         EQU     $0F8
BPL7PTL         EQU     $0FA
BPL8PTH         EQU     $0FC
BPL8PTL         EQU     $0FE
Then I get an image but it is corrupted. Am I missing something here?? I've added the new lines for clearing BPL7 and BPL8 to my copperlist so it should work now shouldn't it? #confused
Attached Thumbnails
Click image for larger version

Name:	fs-uae-crop-1811242030-01.png
Views:	25
Size:	2.1 KB
ID:	60938   Click image for larger version

Name:	fs-uae-crop-1811242027-01.png
Views:	60
Size:	130.0 KB
ID:	60939  
Steve is offline  
Old 24 November 2018, 22:51   #11
ross
Sum, ergo Cogito

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,462
Is you image steady now, isnt it?
Then last bitplanes for some reason is not properly initialized in copper list.
You can attach your code if you want, also a zip archive.
Hard to help you otherwise.
ross is offline  
Old 24 November 2018, 22:56   #12
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
yeah it's steady now. I'll up it the zone for you.
Steve is offline  
Old 24 November 2018, 23:07   #13
ross
Sum, ergo Cogito

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,462
Check tut.raw file dimension

From your code:
; Bitplane info: 320*256*8. 40 words per line, 256 lines. 320x256/8bits = 10240bytes


x8=?
ross is offline  
Old 24 November 2018, 23:20   #14
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
Quote:
Originally Posted by ross View Post
Check tut.raw file dimension

From your code:
; Bitplane info: 320*256*8. 40 words per line, 256 lines. 320x256/8bits = 10240bytes


x8=?
Ah, The code was taken from someone else so all the comments are someone else's. I realise the picture is actually 320x200 but wasn't aware I need to change anything? But the display is 320x256 is not? Standard PAL Low Res.

I guess the screenmode has to match the picture resolution. Seems obvious I guess. So I need to open an NTSC screenmode??

Last edited by Steve; 24 November 2018 at 23:28.
Steve is offline  
Old 24 November 2018, 23:28   #15
ross
Sum, ergo Cogito

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,462
Quote:
Originally Posted by Steve View Post
Ah, The code was taken from someone else so all the comments are someone else's. I realise the picture is actually 320x200 but wasn't aware I need to change anything? But the display is 320x256 is not? Standard PAL Low Res.
You have to adapt screen to picture.
File seems to be for a 320x200 picture, your copper code for a 320x256 screen.
So you need a new raw grab for the image or a change in copper values

EDIT:
Quote:
Originally Posted by Steve View Post
EDIT: I guess the screenmode has to match the picture resolution. Seems obvious I guess. So I need to open an NTSC screenmode??
For a 320x200 screen you need DIWSTOP,$F4C1

Actually not an NTSC screen but a restricted 320x200 PAL screen .
If you want real NTSC video signal you need also another register change in addition (and an ECS Agnus because you are in PAL territory).

Last edited by ross; 24 November 2018 at 23:56. Reason: edit
ross is offline  
Old 24 November 2018, 23:41   #16
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
Fantastic! It works. Thank you.

I changed the image to a 320x256 one and converted it again to a raw file.

Here is the correct image.

Quote:
EDIT: use DIWSTOP,$F4C1
This didn't work for some reason. Is this to get the original (320x200) file to work?. Would I also need to set some other register for NTSC?
Attached Thumbnails
Click image for larger version

Name:	fs-uae-full-1811242140-01.png
Views:	54
Size:	51.2 KB
ID:	60944  

Last edited by Steve; 24 November 2018 at 23:49.
Steve is offline  
Old 24 November 2018, 23:53   #17
ross
Sum, ergo Cogito

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,462
Quote:
Originally Posted by Steve View Post
I changed the image to a 320x256 one and converted it again to a raw file.


Quote:
This didn't work for some reason. Is this to get the original (320x200) file to work?. Would I also need to set some other register for NTSC?
Yes, for the original file.
See my edit to previous message.

For real NTSC video you need to modify BEAMCON0, but better leave it alone
ross is offline  
Old 25 November 2018, 00:05   #18
Steve
Truth seeker...
Steve's Avatar
 
Join Date: Jul 2001
Location: UK
Age: 40
Posts: 2,240
Hmmm. It would be nice to have the original file working with a restricted screen - good stuff to know.

However setting DIWSTOP to $F4C1 isn't working. See image below.

Is this because of the code in post #6?
Attached Thumbnails
Click image for larger version

Name:	fs-uae-full-1811242203-01.png
Views:	35
Size:	120.6 KB
ID:	60946  
Steve is offline  
Old 25 November 2018, 00:09   #19
roondar
Registered User

 
Join Date: Jul 2015
Location: The Netherlands
Posts: 773
Quote:
Originally Posted by Steve View Post
Is this because of the code in post #6?
Yes. If you resize the picture to something other than 320x256, the add.l #10240,d1 needs to be changed to reflect the new size - otherwise your bitplane pointers will point to something other than picture data
roondar is offline  
Old 25 November 2018, 00:10   #20
ross
Sum, ergo Cogito

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 48
Posts: 1,462
Quote:
Originally Posted by Steve View Post
Hmmm. It would be nice to have the original file working with a restricted screen - good stuff to know.

However setting DIWSTOP to $F4C1 isn't working. See image below.

Is this because of the code in post #6?
Yes, you have a bitplane of 320x200/8bits.

So you need an
add.l #8000,d1
instead.
ross 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
Trying to implement joystick code in my stuff Akira Coders. General 26 04 June 2018 00:03
implement others 68000 machines ? turrican3 support.WinUAE 28 23 November 2017 01:54
Implement More Option For DirectDraw Mode. Zilog request.UAE Wishlist 4 01 August 2014 10:18
Any plans to implement JIT for PPC OSs? amigafreak68k support.FS-UAE 3 03 January 2014 11:36
Should I implement PM download now ? RCK project.EAB 12 08 January 2002 02:21

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 07:36.


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