English Amiga Board


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

 
 
Thread Tools
Old 20 October 2017, 10:50   #1
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
Loading PCHG IFF files

Can somebody give me a pointer (pun intended!) to how implement loading PCHG IFF files with 68K asm on the Amiga?

I really like what tool.anides.de generates for me, and would love to use that in my games but have no idea about that format...

Thanks,
Michael
Tigerskunk is offline  
Old 20 October 2017, 15:57   #2
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL?
Posts: 2,741
Perhaps http://aminet.net/package/dev/misc/PCHGLib14 ?
pandy71 is offline  
Old 20 October 2017, 16:14   #3
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
There is a ready tool for conversion to copper lists + source for loading and displaying that you can use in your own code if you want, in the Frazetta slideshow
Photon is offline  
Old 21 October 2017, 11:07   #4
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
Ah okay..
Cool, guys. Will have a look into that...

It's great, that you can get help so fast here, almost always...

EAB is really the best place for Amiga coders...


Add:
Okay, I have some questions...
I don't quite get where the code for reading in the PCHG IFF is in that...
I guess it's at the start of PCHG-source.S, but I am really not sure about that.

Last edited by Tigerskunk; 21 October 2017 at 12:57.
Tigerskunk is offline  
Old 22 October 2017, 00:13   #5
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Well, it has an example that loads a picture and displays it, just assemble and run and take it from there, replace the picture, run, copy-paste the example code and insert into your program, etc.
Photon is offline  
Old 22 October 2017, 20:49   #6
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
Sorry if I sound stupid, but once again..

I guess you mean PCHG-source.S?

Why I am asking: At the part where probably the pic is supposed to be displayed there is only a comment reading:

*--- show Buff0 with copdst here! ---*
*--- show Buff0 with copdst here! ---*
.dontshow:
rts

and then going back to the CLI.

So, not that easy for me how to go on after that at the moment...
Tigerskunk is offline  
Old 23 October 2017, 10:26   #7
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
It's quite plug and play, there shouldn't be much to say about the source if you've incorporated others' into your project before.

The example code converts a PCHG so you can display it.

Often you would want control over your buffers, so those comments say what to do to display it: between those lines, you can put code or a bsr to show the screen directly, or you can just trigger the "dontshow" and display in when it's time to display it.

So the comment means, point bitplane pointers to Buff0 and display the destination Copper list (copdst) with all the palette changes in it and you have your picture showing.

And if you don't need to load the pictures after your program has started, you can convert them separately with the commandline utility provided, and INCBIN them.
Photon is offline  
Old 23 October 2017, 12:46   #8
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
Quote:
Originally Posted by Photon View Post
The example code converts a PCHG so you can display it.

Often you would want control over your buffers, so those comments say what to do to display it: between those lines, you can put code or a bsr to show the screen directly, or you can just trigger the "dontshow" and display in when it's time to display it.
I understood that part of the code... I was just wondering where the part is that displays the actual pic.

Quote:
Originally Posted by Photon View Post
So the comment means, point bitplane pointers to Buff0 and display the destination Copper list (copdst) with all the palette changes in it and you have your picture showing.
Well, i tried that yesterday, but had no success... Just got a "blue screen" (not the windows one ).

Maybe I need to try harder then... Seems I did some wrong thinking setting up stuff.

So it's setting the bitplane pointers and setting cop1lc to copdst and then I am done?
Will try again and report..

Thanks for your support,
Photon
Tigerskunk is offline  
Old 23 October 2017, 19:45   #9
Trachu
Registered User
 
Join Date: Dec 2015
Location: Poland
Posts: 189
tool.anides.de DOES NOT generate PCHG IFF file just IFF with taken from Atari ST pallette chunk
Trachu is offline  
Old 23 October 2017, 21:38   #10
AnimaInCorpore
Registered User
 
Join Date: Nov 2012
Location: Willich/Germany
Posts: 232
Trachu is correct. PCHG is actually a misleading term for the format. Loading PCHG images is supported, though, but saving will follow soon.
AnimaInCorpore is offline  
Old 24 October 2017, 09:43   #11
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
Quote:
Originally Posted by AnimaInCorpore View Post
Trachu is correct. PCHG is actually a misleading term for the format. Loading PCHG images is supported, though, but saving will follow soon.
Ah good to know.
And nice that it will work soon.

I got some plans for coding something using PCHG images for my next project after Inviyya, and this will come in handy...
Tigerskunk is offline  
Old 23 August 2018, 16:14   #12
borchen
Registered User
 
Join Date: Jan 2016
Location: NL
Posts: 32
I'm also having no success showing the picture in the example on the screen.


Here's the code I added:
Code:
    INCDIR "SOURCES:Scoopex/Frazetta/"

    SECTION ConvPCHGCF,Code
    JUMPPTR    Start

;        #-----+-----------------------------------------#
;        |Name:| PCHG converter source            |
;        +-----+-----------------------------------------+
;        |V1.00|    Just cleaned up from RC3 for ConvPCHG    |
;        +-----+-----------------------------------------+
;        |            © Photon/Scoopex        |
;        #-----------------------------------------------#

;Converter from ConvPCHG command to also do PCHG and CAMG hunks.

MaxLsize=$19000                ;max copper list size (test!)
maxpic    =$28020                ;352/8*536*6, real max is 384/8*576*6
copsiz    =20+128                ;nullcop with palette

;--- Macros
WAITRAS:MACRO
    move.l    #$1ff00,d2        ; mask
    lsl.l    #8,d0
    and.l    d2,d0
    lea    $04(a6),a0
.wr_l\@
    move.l    (a0),d1
    and.l    d2,d1
    cmp.l    d1,d0
    bne.s    .wr_l\@
    ENDM


Start: 
    movem.l    d1-a6,-(sp)        ; put registers on stack
OSoff:
    move.l    4.w,a6            ; a6 = execbase
    move.l    #Gfxname,a1        ; a1 = gfxname
    jsr    -408(a6)        ; open gfxlibrary
                    ; using oldopenlibrary()
    move.l    d0,a1            ; a1 = gfxlibrary
    move.l    38(a1),d6        ; d4 = copper state
    jsr    -414(a6)        ; close gfxlibrary using closelibrary()

    lea    $dff000,a6        ; a6 = custombase

    move.w    $1c(a6),d5        ; d5 = INTENAR state
    move.w    $02(a6),d4        ; d3 = DMACON  state

    movem.l    d4-d6,-(sp)        ; put registers on stack

    move.l    #302,d0            ; wait for rasterline 302
    WAITRAS                ; = EOFrame

    move.w    #$7fff,$9a(a6)        ; disable all INTENA bits = turn off OS
    move.w    #$7fff,$9c(a6)        ; disable all INTREQ bits
    move.w    #$7fff,$9c(a6)        ; twice because of amiga4000 hw bug!
    move.w    #$7fff,$96(a6)        ; disable all DMACON bits
    move.w    #$8380,$96(a6)        ; enable neccesary bits in DMACON

Example:
    lea    R(PC),a5        ;-R(A5) used to save some bytes for
                    ;nonexistant d16(PC) writes
    lea    Pic,a0            ;source ILBM data.
    bsr    ConvPCHG        ;fills Buff0 and copdst, see below.
    tst.l    d0
    beq.w    .dontshow

    *--- show Buff0 with copdst here! ---*

;--- generate screen setup in copperlist
    lea    copdst,a1        ; copperlist

    move.l    #$01fc0000,(a1)+    ; FMODE slow
    move.l    #$01000000,(a1)+    ; BPLCON0 disable
    move.l    #$008e2c81,(a1)+    ; DIWSTRT
    move.l    #$00902cc1,(a1)+    ; DIWSTOP PAL
    move.l    #$00920038,(a1)+    ; DDFSTRT
    move.l    #$009400d0,(a1)+    ; DDFSTOP
    move.l    #$01020000,(a1)+    ; BPLCON1
    move.l    #$01080000,(a1)+    ; BPL1MOD
    move.l    #$010a0000,(a1)+    ; BPL2MOD

    move.l    #$00e00000,(a1)+    ; BPL1PTH
    move.l    #$00e20000,(a1)+    ; BPL1PTL
    move.l    #$00e40000,(a1)+    
    move.l    #$00e60000,(a1)+    
    move.l    #$00e80000,(a1)+    
    move.l    #$00ea0000,(a1)+    
    move.l    #$00ec0000,(a1)+    
    move.l    #$00ee0000,(a1)+    
    move.l    #$00f00000,(a1)+    
    move.l    #$00f20000,(a1)+    
    move.l    #$00f40000,(a1)+    ; BPL6PTH
    move.l    #$00f60000,(a1)+    ; BPL6PTL

    move.l    #$01006200,(a1)+    ; BPLCON0 6 bitplanes

;--- set bitplane pointers in copperlist
    move.l    #Buff0,d0        ; source screenbuffer
    lea    copdst+(9*4),a1        ; destination in copperlist
    moveq    #6-1,d7            ; 6 bitplanes
.bpl_l
    move.w    d0,6(a1)        ; BPLxPTL
    swap    d0
    move.w    d0,2(a1)        ; BPLxPTH
    swap    d0
    add.w    #(320*256)/8,d0        ; next bitplane +10240B
    addq    #8,a1            ; next pointers copperlist
    dbf    d7,.bpl_l

    move.l    #copdst,$80(a6)        ; COP1LCH set and
    move.w    #0,$88(a6)        ; COPJMP1 activate

.lmb_l
    move.l    #302,d0            ; wait for rasterline 302
    WAITRAS                ; = EOFrame

    btst    #6,$bfe001        ; check left mousebutton
    bne.s    .lmb_l            ; not pressed -> check again

.dontshow:
;    rts

;----- restore states & end the program
OSon:
    movem.l    (sp)+,d4-d6        ; pop registers from stack

    move.w    #$7fff,$096(a6)        ; clear DMACON
    or.w    #$8200,d4        ; set bits of DMACON state (d3)
    move.w    d4,$096(a6)        ; restore original DMACON

    move.l    d6,$080(a6)        ; restore original copperlist

    or.w    #$c000,d5        ; set 2 highest bits of INTENAR state
    move.w    d5,$09a(a6)        ; restore INTENA state = turn on OS

    movem.l    (sp)+,d1-a6        ; pop registers from stack
    moveq    #0,d0            ; nice clean
    rts                ; exit

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

    EVEN

ConvPCHG:                ;a0=src ILBM data.
<the rest is unchanged>
borchen is offline  
Old 27 August 2018, 15:37   #13
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,406
A related question (didn't think this was worth its own thread): how do you actually get PCHG iff files to begin with? I've tried to find picture editors/painting programs that can create & save such images to no avail.

I've had no luck with finding conversion software that converts to PCHG either. Perhaps my aminet-fu and google-fu are weak, but nothing found yet.
roondar is online now  
Old 27 August 2018, 17:04   #14
PeterK
Registered User
 
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
HamLabPlus can do that. Uploaded to the Zone. The author has released it some years ago.
PeterK is offline  
Old 27 August 2018, 17:07   #15
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,406
Thanks! I'll go and grab that for sure.
roondar is online now  
Old 28 August 2018, 10:52   #16
borchen
Registered User
 
Join Date: Jan 2016
Location: NL
Posts: 32
@PeterK

Also thanks!

Until now I was using the demo of HamLabPlus 2.0.8 from Aminet
The (full)version in the Zone is 2.10

Now let's hope Photon sees this thread; he can give a solution in 5min probably...
borchen is offline  
Old 29 August 2018, 12:15   #17
borchen
Registered User
 
Join Date: Jan 2016
Location: NL
Posts: 32
Well, after of lot of trial and error I have 'something' on screen, but it's not perfect yet.

a screenshot is attached.

The code that shows this picture is:
Code:
    INCDIR "SOURCES:Scoopex/Frazetta/"

    SECTION ConvPCHGCF,Code
    JUMPPTR    Start

COPADD    = 68

;        #-----+-----------------------------------------#
;        |Name:| PCHG converter source            |
;        +-----+-----------------------------------------+
;        |V1.00|    Just cleaned up from RC3 for ConvPCHG    |
;        +-----+-----------------------------------------+
;        |            © Photon/Scoopex        |
;        #-----------------------------------------------#

;Converter from ConvPCHG command to also do PCHG and CAMG hunks.

MaxLsize=$19000                ;max copper list size (test!)
maxpic    =$28020                ;352/8*536*6, real max is 384/8*576*6
copsiz    =20+128                ;nullcop with palette

;--- Macros
WAITRAS:MACRO
    move.l    #$1ff00,d2        ; mask
    lsl.l    #8,d0
    and.l    d2,d0
    lea    $04(a6),a0
.wr_l\@
    move.l    (a0),d1
    and.l    d2,d1
    cmp.l    d1,d0
    bne.s    .wr_l\@
    ENDM

Start: 
    movem.l    d1-a6,-(sp)        ; put registers on stack
OSoff:
    move.l    4.w,a6            ; a6 = execbase
    move.l    #Gfxname,a1        ; a1 = gfxname
    jsr    -408(a6)        ; open gfxlibrary
                    ; using oldopenlibrary()
    move.l    d0,a1            ; a1 = gfxlibrary
    move.l    38(a1),d6        ; d4 = copper state
    jsr    -414(a6)        ; close gfxlibrary using closelibrary()

    lea    $dff000,a6        ; a6 = custombase

    move.w    $1c(a6),d5        ; d5 = INTENAR state
    move.w    $02(a6),d4        ; d3 = DMACON  state

    movem.l    d4-d6/a6,-(sp)        ; put registers on stack

    move.l    #302,d0            ; wait for rasterline 302
    WAITRAS                ; = EOFrame

    move.w    #$7fff,$9a(a6)        ; disable all INTENA bits = turn off OS
    move.w    #$7fff,$9c(a6)        ; disable all INTREQ bits
    move.w    #$7fff,$9c(a6)        ; twice because of amiga4000 hw bug!
    move.w    #$7fff,$96(a6)        ; disable all DMACON bits
    move.w    #$8380,$96(a6)        ; enable neccesary bits in DMACON

Example:
    lea    R(PC),a5        ;-R(A5) used to save some bytes for
                    ;nonexistant d16(PC) writes
    lea    Pic,a0            ;source ILBM data.
    bsr    ConvPCHG        ;fills Buff0 and copdst, see below.
    tst.l    d0
    beq.w    .dontshow

    *--- show Buff0 with copdst here! ---*

;--- init colors
    lea    cmapdst,a0        ; source color map
    lea    $180(a6),a1        ; destination COLORxx regs
    moveq    #32-1,d7        ; nr of colors
.col_l    move.w    (a0)+,(a1)+
    dbf    d7,.col_l

;--- generate screen setup in copperlist
    lea    copdst+COPADD,a1    ; copperlist

    move.l    #$00e00000,(a1)+    ; BPL1PTH
    move.l    #$00e20000,(a1)+    ; BPL1PTL
    move.l    #$00e40000,(a1)+    
    move.l    #$00e60000,(a1)+    
    move.l    #$00e80000,(a1)+    
    move.l    #$00ea0000,(a1)+    
    move.l    #$00ec0000,(a1)+    
    move.l    #$00ee0000,(a1)+    
    move.l    #$00f00000,(a1)+    
    move.l    #$00f20000,(a1)+    
    move.l    #$00f40000,(a1)+    ; BPL6PTH
    move.l    #$00f60000,(a1)+    ; BPL6PTL

    move.l    #$008e2681,(a1)+    ; DIWSTRT
    move.l    #$009026c1,(a1)+    ; DIWSTOP
    move.l    #$00920038,(a1)+    ; DDFSTRT
    move.l    #$009400d0,(a1)+    ; DDFSTOP
    move.l    #$01020000,(a1)+    ; BPLCON1
    move.l    #$010800c8,(a1)+    ; BPL1MOD 200
    move.l    #$010a00c8,(a1)+    ; BPL2MOD 200

    move.l    #$01006200,(a1)+    ; BPLCON0 6 bitplanes

;--- set bitplane pointers in copperlist
    move.l    #Buff0+16,d0        ; source screenbuffer
    lea    copdst+COPADD,a1    ; destination in copperlist
    moveq    #6-1,d7            ; 6 bitplanes
.bpl_l
    move.w    d0,6(a1)        ; BPLxPTL
    swap    d0
    move.w    d0,2(a1)        ; BPLxPTH
    swap    d0
    add.w    #(320/8),d0        ; next bitplane +40B
    addq    #8,a1            ; next pointers copperlist
    dbf    d7,.bpl_l

    move.l    #copdst+COPADD,$80(a6)    ; COP1LCH set and
    move.w    #0,$88(a6)        ; COPJMP1 activate

.lmb_l
    move.l    #302,d0            ; wait for rasterline 302
    WAITRAS                ; = EOFrame

    btst    #6,$bfe001        ; check left mousebutton
    bne.s    .lmb_l            ; not pressed -> check again

.dontshow:
;    rts

;----- restore states & end the program
OSon:
    movem.l    (sp)+,d4-d6/a6        ; pop registers from stack

    move.w    #$7fff,$096(a6)        ; clear DMACON
    or.w    #$8200,d4        ; set bits of DMACON state (d3)
    move.w    d4,$096(a6)        ; restore original DMACON

    move.l    d6,$080(a6)        ; restore original copperlist

    or.w    #$c000,d5        ; set 2 highest bits of INTENAR state
    move.w    d5,$09a(a6)        ; restore INTENA state = turn on OS

    movem.l    (sp)+,d1-a6        ; pop registers from stack
    moveq    #0,d0            ; nice clean
    rts                ; exit

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

    EVEN

debug    dc.l    0


ConvPCHG:                ;a0=src ILBM data.
the rest is unchanged...
Attached Thumbnails
Click image for larger version

Name:	020.png
Views:	177
Size:	54.4 KB
ID:	59589  
borchen is offline  
Old 29 August 2018, 12:54   #18
borchen
Registered User
 
Join Date: Jan 2016
Location: NL
Posts: 32
*** BREAKING NEWS ***

I finally managed to show the 'nice' picture in all it's colourfull glory!
See attached screenshot

It was not as 'easy' as Photon made us believe
- the data in the raw-buffer(Buff0) is 320x256x6 (bitplanes) interleaved,
- an offset of 16 must be added to the Buff0 address
- I had to save a state in winuae of the Frazetta-demo when it displayed the 'nice' picture and load it into http://codetapper.com/amiga/maptapper/ to figure out the screen-setup.

The complete code is attached below.
Attached Thumbnails
Click image for larger version

Name:	021.png
Views:	204
Size:	54.4 KB
ID:	59591  
Attached Files
File Type: s PCHG-source-v03.S (16.6 KB, 108 views)
borchen is offline  
Old 12 September 2018, 22:21   #19
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
Nice that you were working on this, Borchen...

I will probably ask you a couple of questions in future about this...

Anyway, great work!
Tigerskunk is offline  
Old 15 September 2018, 10:16   #20
borchen
Registered User
 
Join Date: Jan 2016
Location: NL
Posts: 32
Quote:
Nice that you were working on this, Borchen...
I'm not really working hard on this one; I was curious if I could get it to work at all...

Here's a new version using some pictures I converted myself using the fullversion of HamLabPlus (from the Zone). See next two posts for the pictures...
Just drop the unzipped pictures in "INCDIR "SOURCES:Scoopex/Frazetta/pics"; change the INCDIR to your own development-tree if neccesary.
You can change the picture using the "PIC=n" in the top of the source and assemble it. I just did this the quick 'n dirty way.
Attached Files
File Type: s PCHG-source-v08.S (17.9 KB, 97 views)

Last edited by borchen; 15 September 2018 at 10:35.
borchen 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
Sonic IFF Files on Backbone? DerekAutista123 support.WinUAE 3 06 March 2016 23:44
Ripping DKK IFF-SMUS files BastyCDGS request.Modules 2 23 November 2015 23:58
Listing files, loading files and allocating all available chip ram. h0ffman Coders. System 16 04 April 2013 21:24
Aren't DPaintIV files IFF? Morbane support.Amiga Forever 19 27 November 2011 12:29
Create an ADF slideshow with IFF files. Vollldo request.Demos 13 21 September 2011 19:29

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 09:33.

Top

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