Best way to display pics more than 16 cols.

All 680x0 related coding posts in this section please.

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

lowdensity
Atari maniac
Atari maniac
Posts: 89
Joined: Tue Jun 27, 2006 11:50 pm
Location: Portland, Oregon

Re: Best way to display pics more than 16 cols.

Postby lowdensity » Thu Aug 24, 2006 11:39 pm

Maartau wrote:Hi, which is the best way to display two pics on the same screen using 2 different colors palettes? (Horizontaly divided screen).

The same for vertically divided one.

Last but not least, where can I found clear explains for interrupts to enable/disable in those cases.

I'm looking for explains & sources, so if anyone could help me...


May I assume that partial representations are acceptable? And you wouldn't mind scrolling around a bit? If that's okay, you could put a portion of each picture in its relevant half of the screen, and scroll them around until the entire picture is displayed.

User avatar
unseenmenace
Atari God
Atari God
Posts: 1961
Joined: Tue Sep 21, 2004 9:33 pm
Location: Margate, Kent, UK
Contact:

Postby unseenmenace » Fri Aug 25, 2006 7:19 am

Horizontally splitting the screen into 2 different palettes is pretty easy. You use Timer B in Event Count mode (which counts scanlines) and set the timers counter to the number of the line you want to change the palette at and then in your Timer B interrupt routine you set the palette to the one for the bottom picture. To avoid any noticeable flicker you can either leave a blank line between pics or ideally interrupt on the line just before where you want the palette split and then wait a short while until the screen redraw just reaches the end of the next line before switching palette and it should be able to change all 16 colours before the next line starts being drawn. The latter method is all the more important if the 2 pics have a different background colour. You do of course have to set the palette back to the one for the top pic at some point and this is normally best done on the VBL interrupt.

Doing vertical palette changes is possible (after a fashion) but a lot lot more complex and you either need to leave a huge gap or carefully arrange the colours in the pics to compensate for the time needed to change all the colours (which is what Spectrum 512 does). I'd suggest doing horizontal ones first.
UNSEEN MENACE
Several STFM's, 4MB STE, 2MB TT with 1.2GB Hard Drive and 14MB Falcon with 540MB Hard Drive,
Lynx 2 and Jaguar with JagCD
Member of GamebaseST and AtariLegend team
Check out my website at http://unseenmenace.110mb.com

User avatar
leonard
Moderator
Moderator
Posts: 648
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Fri Aug 25, 2006 1:06 pm

unseenmenace is right, do an horizontal first.

even horizontal, you have to take care of the time the change will take. If you want to perfect picture separation, you don't have time to change complete palette in the left border. You better have to setup the timer-b one scanline before, load palette data, then wait at end of the bitmap line, then setup palette at the beginning of the right border. Now the color split should be perfect.
Leonard/OXYGENE.

User avatar
Zorro 2
Administrator
Administrator
Posts: 2209
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Postby Zorro 2 » Mon Aug 28, 2006 2:46 pm

Salut mister Maartau,

I send you by PM the complete source for you, but I give you that you do on your proper code :

1/ You need to initialise TIMER B before installing the VBL :

Code: Select all

   bclr   #3,$fffffa17.w
   sf   $fffffa21.w
   sf   $fffffa1b.w
   bset   #0,$fffffa07.w   * Timer B on
   bset   #0,$fffffa13.w   * Timer B on
   stop   #$2300


2/ Put the code who launch HBL on the VBL :

Code: Select all

   move.l   #HBL0,$120.w
   move.b   #64,$fffffa21.w
   move.b   #8,$fffffa1b.w

(the HBL launch at line 64 to 200 on your screen)

3/ Write your all HBL at each line that you want, you can put something inside like that :

Code: Select all

HBL0:                     * 65
                           sf   $fffffa21.w   * Stop Timer B
                           sf   $fffffa1b.w
                        
                           move.w   #$070,$ffff8240.w
                        
                           move.l   #HBL1,$120.w
                           move.b   #1,$fffffa21.w
                           move.b   #8,$fffffa1b.w
                           rte

HBL1:                     * 66
                           sf   $fffffa21.w   * Stop Timer B
                           sf   $fffffa1b.w
                        
                           move.w   #$700,$ffff8240.w
                        
                           move.l   #HBL2,$120.w
                           move.b   #1,$fffffa21.w
                           move.b   #8,$fffffa1b.w
                           rte

HBL2:                     * 67
                           sf   $fffffa21.w   * Stop Timer B
                           sf   $fffffa1b.w
                        
      move.l   a0,-(sp)
      move.l   a1,-(sp)
      MOVEA.L   #PalPetit,A0
      MOVEA.L   #$FF8240,A1
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      movem.l   (sp)+,a1
      movem.l   (sp)+,a0            
                                 
                           move.l   #HBL3,$120.w
                           move.b   #70,$fffffa21.w
                           move.b   #8,$fffffa1b.w
                           rte

HBL3:                     * 137
                           sf   $fffffa21.w   * Stop Timer B
                           sf   $fffffa1b.w
                        
                           move.w   #$700,$ffff8240.w
                           
                           move.l   #HBL4,$120.w
                           move.b   #1,$fffffa21.w
                           move.b   #8,$fffffa1b.w
                           rte

HBL4:                     * 138
                           sf   $fffffa21.w   * Stop Timer B
                           sf   $fffffa1b.w

                           move.w   #$070,$ffff8240.w      
                        
                           move.l   #HBL5,$120.w
                           move.b   #1,$fffffa21.w
                           move.b   #8,$fffffa1b.w
                           
                           rte

HBL5:                     * 139
                           sf   $fffffa21.w   * Stop Timer B
                           sf   $fffffa1b.w
                        
      move.l   a0,-(sp)
      move.l   a1,-(sp)
      MOVEA.L   #PalGrand,A0
      MOVEA.L   #$FF8240,A1
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      movem.l   (sp)+,a1
      movem.l   (sp)+,a0            
     
                           move.l   #HBL,$120.w
                           move.b   #61,$fffffa21.w
                           move.b   #8,$fffffa1b.w
                           
                           rte

HBL:                     * 200
                           sf   $fffffa21.w   * Stop Timer B
                           sf   $fffffa1b.w
                        
                           REPT   95   * Wait line end
                           nop
                           ENDR   
                           
                           sf   $ffff820a.w   * Modif Frequency 60 Hz !
                        
                           REPT   28   * Wait a little
                           nop
                           ENDR
                        
                           move.b   #$2,$ffff820a.w * 50 Hz !

      move.l   a0,-(sp)
      move.l   a1,-(sp)
      MOVEA.L   #PalPetit,A0
      MOVEA.L   #$FF8240,A1
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      MOVE.L    (A0)+,(A1)+
      movem.l   (sp)+,a1
      movem.l   (sp)+,a0            
                           
                           rte

And finaly you use the remove bottom border with an another palette !

Here the result on the GIF !
You do not have the required permissions to view the files attached to this post.
Member of NoExtra Team

User avatar
Zorro 2
Administrator
Administrator
Posts: 2209
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Postby Zorro 2 » Mon Aug 28, 2006 2:58 pm

Your tricky remember this screen :
Image
Here is the same thing that you search to do ?
Member of NoExtra Team

User avatar
leonard
Moderator
Moderator
Posts: 648
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Mon Aug 28, 2006 8:26 pm

that cool screen is from swedish new year 1. It does not use timerB but three palette per scanline ("spectrum 512" routine).
Leonard/OXYGENE.

User avatar
Zorro 2
Administrator
Administrator
Posts: 2209
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Postby Zorro 2 » Tue Aug 29, 2006 10:23 am

leonard wrote:that cool screen is from swedish new year 1. It does not use timerB but three palette per scanline ("spectrum 512" routine).

Thanks for this information mister Leonard, I thought that this best screen effect was coded with the timer B. Nevertheless...
Member of NoExtra Team

User avatar
bod/STAX
Atari Super Hero
Atari Super Hero
Posts: 508
Joined: Wed Nov 24, 2004 8:13 pm
Location: Halesowen, West Midlands, England

Postby bod/STAX » Wed Sep 27, 2006 2:55 pm

The best to do perfect palette splits it as Leonard wrote is to wait for right border then copy your palette to the palette registers:-

Code: Select all

Timer_b1    movem.l d0-d7/a0/a1,-(sp)      ; save registers 
            movem.l pal1(pc),d1-d7/a0      ; load palette into registers
            move.w #$f8240,a1              ; palette registers
            move.b $fffffa21.w,d0          ; wait for right border
.l1         cmp.b $ffffffa21.w,d0
            beq.s .l1
            movem.l d1-d7/a0,(a1)          ; set palette
            movem.l (sp)+,d0-d7/a0/a1      ; restore registers
            bclr #0,$fffffa0f.w
            rte                            ; end of interupt

pal1        dcb.w 16,$123                  ; the palette

Argonaut
Atari maniac
Atari maniac
Posts: 77
Joined: Wed Sep 20, 2006 7:15 pm
Location: Tadley, UK
Contact:

Postby Argonaut » Mon Oct 23, 2006 6:20 pm

Looking forward to seeing the intro. Good to know new people are coding on the ST :-)

xernobyl
Atarian
Atarian
Posts: 5
Joined: Wed Oct 11, 2006 8:45 pm
Location: Peniche/Lisboa, Portugal

Postby xernobyl » Tue Oct 24, 2006 12:56 am

How many techniques are there for displaying more than 16 colors? From what I've been reading you can use a different 16 color palette per scanline. What more can be done?

User avatar
keops
Atari Super Hero
Atari Super Hero
Posts: 590
Joined: Mon Jul 26, 2004 3:39 pm
Location: Canada
Contact:

Postby keops » Tue Oct 24, 2006 3:12 am

You can change the palette more than once per scanline. However, basic rasters won't do the trick anymore, you will need more precise synchronization to change the palette exactly when you want it to.

User avatar
unseenmenace
Atari God
Atari God
Posts: 1961
Joined: Tue Sep 21, 2004 9:33 pm
Location: Margate, Kent, UK
Contact:

Postby unseenmenace » Tue Oct 24, 2006 7:07 am

The "standard" for doing more than one palette per scanline is the Spectrum 512 routine which can have 3 palettes on each scanline. As Keops mentioned its a bit complicated as you have to synchronise with the screen redraw and then spit palettes out constantly for almost the entire screen, leaving you with very little processor time (basically just the space in the top and bottom borders). The other difficulty is in that since you can't change all the colours in one instant the colour changes are staggered making it tricky to keep track of which palette index is what colour at any particular part of the screen. Routines for this are all over the net but only really useful for displaying pictures created in Spectrum 512 itself. Note there is also a cool picture viewer/convertor called Photochrome which uses the same method as well as a few other tricks to display high colour images on an ST.
UNSEEN MENACE
Several STFM's, 4MB STE, 2MB TT with 1.2GB Hard Drive and 14MB Falcon with 540MB Hard Drive,
Lynx 2 and Jaguar with JagCD
Member of GamebaseST and AtariLegend team
Check out my website at http://unseenmenace.110mb.com

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re:

Postby spiny » Tue Jun 08, 2010 9:00 am

Zorro 2 wrote:Salut mister Maartau,

I send you by PM the complete source for you, but I give you that you do on your proper code :

Here the result on the GIF !



Hi, I know this thread is about four years old, but could you send me the source code too ?

I'm trying to learn palette swaps using timerb and your routine looks like it is along the lines of what I want to do :)

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Best way to display pics more than 16 cols.

Postby spiny » Tue Jun 08, 2010 9:30 am

in fact, this is what I want to do:

Code: Select all

main
      move.l   #HBL0,$120.w      ; point to new routine
      move.b   #180,$fffffa21.w   ; trigger at line 180
      move.b   #8,$fffffa1b.w      ; enable count mode
...




HBL0      ; starts at say line 180
      MOVE.B  #0,$fffffa21.w      ;
      MOVE.B  #0,$fffffa1b.w      ;

      move.l   #current_palette,a0   ; put backup address in a0
      movem.l   $ffff8240,d0-d7      ; all palettes in d0-d7
      movem.l   d0-d7,(a0)      ; move data into old_palette

      move.l   #HBL1,$120.w      ; re point timerb to another routine
      move.b   #1,$fffffa21.w      ; that will run on the next line
      move.b   #8,$fffffa1b.w      ; enable count mode
      rte            ; go back

HBL1      ; now at line 181
      MOVE.B  #0,$fffffa21.w      ;
      MOVE.B  #0,$fffffa1b.w      ;

      movem.l   timerb_pal,d0-d7      ; put 'timerb' palette in d0-d7
      movem.l   d0-d7,$ff8240      ; move palette from d0-d7 to actual hardware register where pal lives

      move.l   #HBL2,$120.w      ; re direct timerb again
      move.b   #19,$fffffa21.w   ; set counter so that it runs 19 lines later (somewhere near the bottom of the screen)
      move.b   #8,$fffffa1b.w      ; enable count mode
      rte            ; go back

HBL2      ; should be around line 200ish
      MOVE.B  #0,$fffffa21.w      ;
      MOVE.B  #0,$fffffa1b.w      ;

      movem.l   current_pal,d0-d7   ; put 'timerb' palette (that was saved earlier) in d0-d7
      movem.l   d0-d7,$ff8240      ; move palette from d0-d7 to actual hardware register where pal lives

      rte            ; go back



timerb_pal
      dc.w   $000,$010,$121,$232,$343,$454,$575,$777
      dc.w   $000,$000,$100,$200,$300,$400,$500,$777



section data

current_palette   ds.l   8


^ that obviously is incomplete, but I would like to show a pic with its palette, but change the palette at line 180 so I can have more colours on screen - I have a routine to slideshow a few pics but I want to have a logo at the bottom that always has the same colours.

In my head, that code up there should work - it waits until line 180 then saves the current pal, then on line 181 swaps in a different pal, then at line 200 puts back the earlier saved pal. so all being well, at the next vbl the original pal is back meaning the picture is displayed correctly.

am I on the right track ?

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Best way to display pics more than 16 cols.

Postby Nyh » Tue Jun 08, 2010 9:50 am

spiny wrote:In my head, that code up there should work - it waits until line 180 then saves the current pal, then on line 181 swaps in a different pal, then at line 200 puts back the earlier saved pal. so all being well, at the next vbl the original pal is back meaning the picture is displayed correctly.

Make it simpler for yourself. Set in the VBL the right palette for the picture you are displaying. Use timer B only for changing palettes and not for restoring them.

Hans Wessels

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Best way to display pics more than 16 cols.

Postby spiny » Tue Jun 08, 2010 10:44 am

Nyh wrote:
spiny wrote:In my head, that code up there should work - it waits until line 180 then saves the current pal, then on line 181 swaps in a different pal, then at line 200 puts back the earlier saved pal. so all being well, at the next vbl the original pal is back meaning the picture is displayed correctly.

Make it simpler for yourself. Set in the VBL the right palette for the picture you are displaying. Use timer B only for changing palettes and not for restoring them.

Hans Wessels


whats the best way to do that to also allow a fade in ?

I show a pic whcih has the main bit as black, I then fade it to white. If I put a 'set palette' in the VBL it upsets the fade routine

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Best way to display pics more than 16 cols.

Postby spiny » Tue Jun 08, 2010 2:09 pm

spiny wrote:
Nyh wrote:
spiny wrote:In my head, that code up there should work - it waits until line 180 then saves the current pal, then on line 181 swaps in a different pal, then at line 200 puts back the earlier saved pal. so all being well, at the next vbl the original pal is back meaning the picture is displayed correctly.

Make it simpler for yourself. Set in the VBL the right palette for the picture you are displaying. Use timer B only for changing palettes and not for restoring them.

Hans Wessels


whats the best way to do that to also allow a fade in ?

I show a pic whcih has the main bit as black, I then fade it to white. If I put a 'set palette' in the VBL it upsets the fade routine


got some tips from .gnd - I was setting the palettes direct address with the fade - he suggested setting a variable, then setting that in the vbl so the vbl always points to the right palette :)

User avatar
Zorro 2
Administrator
Administrator
Posts: 2209
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Re:

Postby Zorro 2 » Wed Jun 09, 2010 7:52 pm

Sorry ! I post the original code source...
You do not have the required permissions to view the files attached to this post.
Member of NoExtra Team

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Best way to display pics more than 16 cols.

Postby spiny » Wed Jun 09, 2010 8:43 pm

thanks :)

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Re:

Postby spiny » Sun Jun 13, 2010 10:40 pm

Maartau wrote:
Zorro 2 wrote:Sorry ! I post the original code source...


Kewl Freddo :D ,

Between two cracks, I'll share some stuffs too... Finally, I'll have time to finish some codes & post them in the good section. :D

"I'm sure we're not the only one interested by 68k... Maybe should I spread some sources if somebody is interested ?" [Let me/us know 8) .]

BTW if you're shy, you also know there's PM for that :wink: .

[smilie=greencolorz4_pdt_17.gif] Coders/crackers are more than welcome 8) [smilie=greencolorz4_pdt_17.gif] .

There's nothing secret to hide, if we does nothing, we'll lost a great part of our pleasure : and for sure some of "us/you" are always interested by the ST... So, a community is here to share hints & I/we'll be happy to help (if I/we can :) ).

I just remind others ppl helped/teached me stuffs... That's how I can stay postive & nostalgique.

There's no stupid questions, there's only fun to share knowledges...


I just want to learn how to make my atari do pretty things :)

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re:

Postby spiny » Sun Aug 12, 2012 10:39 am

bod/STAX wrote:The best to do perfect palette splits it as Leonard wrote is to wait for right border then copy your palette to the palette registers:-

Code: Select all

Timer_b1    movem.l d0-d7/a0/a1,-(sp)      ; save registers 
            movem.l pal1(pc),d1-d7/a0      ; load palette into registers
            move.w #$f8240,a1              ; palette registers
            move.b $fffffa21.w,d0          ; wait for right border
.l1         cmp.b $ffffffa21.w,d0
            beq.s .l1
            movem.l d1-d7/a0,(a1)          ; set palette
            movem.l (sp)+,d0-d7/a0/a1      ; restore registers
            bclr #0,$fffffa0f.w
            rte                            ; end of interupt

pal1        dcb.w 16,$123                  ; the palette


hi guys, I'm playing with rasters again and thought i'd try the above code, but I can't seem to get it to work. If i put it in my timerb routine, my prg just crashes.
I have noticed that there is an extra 'f' on the .li line, is this a typo, or should there be one more on the previous line ? changing both doesn't seem to help much.
my routine:

Code: Select all

timerb2
   movem.l   d0-d7/a0-a6,-(a7)      ; back stuff up
   sf   $fffffa21.w               ; Stop Timer B
   sf   $fffffa1b.w            ;
   move.l #$000,d1               ; load black into d1
   move.w #$ffff8240,a1             ; load bg col into a1
   move.b $ffffffa21.w,d0         ; wait for right border
.l1                           ; local var
   cmp.b $ffffffa21.w,d0         ; is it the same as d0
   beq.s .l1                  ;
   move.l    d1,a1                  ; set palette
   move.l   #timerb3,$120.w      ; change to next timer
   move.b   #10,$fffffa21.w      ; 10 lines later
   move.b   #8,$fffffa1b.w         ; mode
   movem.l   (a7)+,d0-d7/a0-a6      ; restore stuff
   bclr #0,$fffffa0f.w            ;
   rte                               ; end of interupt


any comments gratefully received :)

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Best way to display pics more than 16 cols.

Postby spiny » Mon Aug 13, 2012 9:04 am

I seem to have got it working :)

Code: Select all

timerb2
   movem.l   d0-d7/a0-a6,-(a7)      ; back stuff up

   move.l #000,d1               ; load black into d1
   move.b $fffffa21.w,d0            ; wait for right border
.l1                           ; local var
   cmp.b $fffffa21.w,d0         ; is it the same as d0
   beq.s .l1                  ;
   move.l    d1,$ffff8240            ; set palette
   sf   $fffffa21.w               ; Stop Timer B
   sf   $fffffa1b.w            ;
   move.l   #timerb3,$120.w      ; change to next timer
   move.b   #10,$fffffa21.w      ; 10 lines later
   move.b   #8,$fffffa1b.w         ; mode
   movem.l   (a7)+,d0-d7/a0-a6      ; restore stuff
   bclr #0,$fffffa0f.w            ;
   rte                               ; end of interupt


it seem that the previous example I posted didn't -actually- set the palette :D

WayneKerr
Atari nerd
Atari nerd
Posts: 49
Joined: Mon Mar 03, 2003 7:41 pm

Re: Best way to display pics more than 16 cols.

Postby WayneKerr » Mon Aug 13, 2012 2:37 pm

Glad you got it working, but I think you need to pay a little more attention to your .W's and .L's - this is why your previous version didn't work, and why there is a bug in your current version :)

User avatar
spiny
Disk Imager Supreme
Disk Imager Supreme
Posts: 2624
Joined: Mon Aug 11, 2003 11:53 pm
Location: just outside bristol
Contact:

Re: Best way to display pics more than 16 cols.

Postby spiny » Mon Aug 13, 2012 2:52 pm

WayneKerr wrote:Glad you got it working, but I think you need to pay a little more attention to your .W's and .L's - this is why your previous version didn't work, and why there is a bug in your current version :)


right, I think I know where you mean, I'll check later and re-read the tutorials :)


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 4 guests