Usage of Blitter for palette splits

All 680x0 related coding posts in this section please.

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

Zamuel_a
Atari God
Atari God
Posts: 1234
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Usage of Blitter for palette splits

Postby Zamuel_a » Fri May 18, 2012 3:59 pm

Using the blitter is rather easy, but also abit confusing at the beginning since it's not so easy to find good documentation for it. I copied the code I use in my game to change the palette. I hope this should work since I might have forgot something...

Code: Select all

BLITTER   EQU   $ff8a00      blitter chip base address
SRCXINC   EQU   $20      source x increment

   lea   BLITTER+SRCXINC,a0   ;blitter start address
   move.l   #$00020002,(a0)+   ;2 bytes to next word and line
   move.l   pal_start_addr,(a0)+
   move.l   #$ffffffff,(a0)+   ;no mask since data isn't shifted
   move.l   #$ffff0002,(a0)+   ;2 bytes, dest increment   
   move.w   #$0,(a0)+      ;skip 0 bytes each line
   move.l   #$ffff8250,(a0)+   ;dest address, start with color 8
   move.l   #$00080001,(a0)+   ;8 words per line, 1 line
   move.w   #$0203,(a0)+      ;use source direct and no HOP
   move.b   #0,$ffff8a3d      ;no skew

TimerB   move.b   #$C0,$ffff8a3c      ;set new palette with the blitter

; --- setup blitter for next palette change ---

   move.l   #$ffff8250,$ff8a32   ;dest address, start with color 8
   move.w   #1,$ff8a38      ;just one line


It's rather easy. The first part is something that I setup at the beginning of a new VBI so that it's ready when the new frame starts. I only change 8 colors and it's the colors from 8 - 15, so ff8250 is the destination address. "pal_start_addr" is a pointer to my palette data.

When in the TimerB interrupt the first thing I do is to do the blit. After that I setup everything for the next blit, but since it's the same type of data I don't have to change anything except "line" that needs to be reset. The destination address also has to be reset since all addresses are increased.
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe

User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 1564
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Doing STE splitscreen display the proper way

Postby Cyprian » Fri May 18, 2012 10:14 pm

cool example Zamuel_a

16 additional cycles can be saved by using short addressing ".w" and updating only low word of destination address

Code: Select all

    TimerB   move.b   #$C0,$ffff8a3c.w      ;set new palette with the blitter

    ; --- setup blitter for next palette change ---

       move.w   #$8250,$ffff8a34.w   ;dest address, start with color 8
       move.w   #1,$ffff8a38.w      ;just one line
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/

Zamuel_a
Atari God
Atari God
Posts: 1234
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: Doing STE splitscreen display the proper way

Postby Zamuel_a » Sat May 19, 2012 5:41 am

16 additional cycles can be saved by using short addressing ".w" and updating only low word of destination address


Aha good! I mostly use long as I'm not always sure about the result when you use words. You have to make sure your data won't pass the address 65536 if you use W or else you will have a problem I'm not wrong? For example if you want to only handle 10 bytes, when W would be fine, but if the start adress of the bytes are at address 65530 when you need long anyway since the end address will be 65540. With a W it will wrap around to address 4 instead. So it feels like it's a gamle to have word addresses
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe

User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 1564
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Doing STE splitscreen display the proper way

Postby Cyprian » Sat May 19, 2012 1:12 pm

yes, you right, but in this case it works
also, i should works in case of destination address is in screen area, because TOS sets screen base address to $xx8000:
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/

Zamuel_a
Atari God
Atari God
Posts: 1234
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: Doing STE splitscreen display the proper way

Postby Zamuel_a » Sat May 19, 2012 5:41 pm

Yes the color address is not over 65536. Didn't think about that. Saving some cycles are never bad ;) Using the blitter for a palette change is maybe not much faster than a movem instruction, but it's very good to setup everything before so that you can do the blit the first thing you do. Ok you can almost do the same with movem. You copy the stuff you need to all registers after you made the change this line, but that means that you can't use any registers for anything else while you show a picture and that might not be good for anything else than a static display program.

I once tried to use the halftone mask to change the palette and that also worked and was very fast, but it took along time to fill in the data for the mask so in total it was to slow, but the actual palette change was very fast.
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe

User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 1564
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Doing STE splitscreen display the proper way

Postby Cyprian » Sun May 20, 2012 10:41 am

Zamuel_a wrote:I once tried to use the halftone mask to change the palette and that also worked and was very fast, but it took along time to fill in the data for the mask so in total it was to slow, but the actual palette change was very fast.


halftone registers can be filled with blitter:

Code: Select all

move.w   #$8A00,$ffff8a34.w
move.w   #1,$ffff8a38.w
move.b   #$C0,$ffff8a3c.w

but in this case movem is much faster
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/

Zamuel_a
Atari God
Atari God
Posts: 1234
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: Doing STE splitscreen display the proper way

Postby Zamuel_a » Sun May 20, 2012 3:05 pm

I remember I tried to send the halftone data to ff8240 only and got a raster effect with very high resolution since it was much faster than the normal ways. The only problem is that you can't fill it again with anything usefull so you only get a few "raster pixels" on the screen and that's it. :wink:
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe

User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 1564
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Usage of Blitter for palette splits

Postby Cyprian » Mon May 21, 2012 12:06 am

first of all I'm not a coder, I never made any demo. therefore my knowledge is pure theoretical :)

I think that TimerB code can be shortened and we can save another 16 cycles. After each blit, BLiTTER's destination address is rest to initial value: $ffff8250

Code: Select all

        TimerB   move.b   #$C0,$ffff8a3c.w      ;set new palette with the blitter
        ; --- setup blitter for next palette change ---
           move.w   #1,$ffff8a38.w      ;just one line


if we have some spare registers we can save 8 cycles more( initial version reduced from 56 to 16 cycles):

Code: Select all

        TimerB   move.b   D0,(A0)     ;set new palette with the blitter
        ; --- setup blitter for next palette change ---
           move.w   D1,(A1)      ;just one line


I'm not sure about BLiTTER's source address, If I remember correctly after every TimerB blit, it is also rest to initial value, in this case BLITTER+SRCXINC.


well, filling shifter palette register with halftones is as fast as with movem, both methods can change a color every 4 pixels. Both have same issues, they can change only 16 colors at once and need time to be reloaded with new colors. In case of movem all Dx register are blocked.

I think more interesting technique is to use BLiTTER for spectrum512 mode and change raster colors in normal copy mode. In this case color change is every 8 pixels, in old spectrum512 every 12 pixels. This technique is used in Antiques demo: http://pouet.net/prod.php?which=59066
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Steem SSE / Aranym / Saint
http://260ste.appspot.com/

Zamuel_a
Atari God
Atari God
Posts: 1234
Joined: Wed Dec 19, 2007 8:36 pm
Location: Sweden

Re: Usage of Blitter for palette splits

Postby Zamuel_a » Mon May 21, 2012 6:17 am

I can't use registers instead of the direct addresses in my game since I need the registers for other stuff, but I also only change the palette every 16th line so it's not so critical.

After each blit, BLiTTER's destination address is rest to initial value: $ffff8250


What do you mean about that? The source and destination address are increased and will not be reset to the initial value by itself. It would be very bad if they did since for example in sprites you do multiple blits for one sprite to do all bitplanes and you want the address to just increase. For a palette change you have to reset the destination address, but the source address should increase since you probibly want new data for the next line anyway.
ST / STFM / STE / Mega STE / Falcon / TT030 / Portfolio / 2600 / 7800 / Jaguar / 600xl / 130xe

User avatar
Tomchi
Captain Atari
Captain Atari
Posts: 392
Joined: Sat Jun 10, 2006 5:17 pm
Location: Au bord de la rivière
Contact:

Re: Usage of Blitter for palette splits

Postby Tomchi » Sun Aug 19, 2012 6:52 am

well if you set $FFFF8A30 (DESTINATION Y INCREMENT) correctly you don't have to set destination address each time.
There's no way to happiness, happiness is the way ...

Noextra


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 2 guests