recolor a full ST LOW to put used colors in first indexes

GFA BASIC-related articles in here please

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

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

recolor a full ST LOW to put used colors in first indexes

Postby hylst » Mon Apr 07, 2014 12:07 am

Hi again !

I've found back again an old (2001) utility to help in demo / game coding on ST Low that i begin to code at that times, and among all functions, there is one that doesn't work :

Scan a loaded PI1 on screen to see if all colours are used or no : OK -> results in col% (16 entry for each color)
Then the rout should move all pixels 'painted' with used colors from highest indexes to the lowest, letting unused colors at high color indexes, blanking them.
But... it doesn't work, i'm reading it back again and again and doesn't find yet why, maybe will you understand why.
Not easy presented like this, sorry =D

Code: Select all

  ' usedcolor&  was found with a pixel scan before, a tab of 16 entry with the number of pixel in whole screen for each of the 16 colours
   cfn&=15
  ' heavy work...  not optimzed at all because just an utility
  FOR c&=0 TO 15
    IF col%(c&)=0  !  colour with no pixel
      FOR cf&=cfn& TO SUCC(c&) STEP -1  ! look 4 an high index of used color to move to lowest free index c&
        IF col%(cf&)>0  !  colour used ( with pixels on screen)
          cfn&=cf&-1
          DEC usedcolors&
          FOR y&=0 TO 199 ! recolor/replace pixels of that colour
            FOR x&=0 TO 319
              IF PTST(x&,y&)=cf& ! if current pixel has the index of color we want to recolor
                PSET x&,y&,c&  ! recolor it with the first available unused color index
              ENDIF
            NEXT x&
          NEXT y&
          CARD{pal%+2*c&}=CARD{pal%+2*cf&} ! moved used color component to unused
          CARD{pal%+2*cf&}=0 ! clear that color components unused now
          BMOVE pal%,&HFFFF8240,32  ! palette display
        ENDIF
        EXIT IF col%(cf&)>0  !  colour with pixels
      NEXT cf&
    ENDIF
    EXIT IF usedcolors&=0 ! if all pixels / colors moved to the lowest index
  NEXT c&
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby hylst » Mon Apr 07, 2014 10:23 am

If anyone is interested, even if old, rough, unfinished and with errors, i can share it with you with the GFA source (that's important to make it flexible for generated code, table calculation, specific file formats or needs ...)
It was done on purpose ^^

An help to code demo / games in ST LOW (for gfx uses) :

1 - picture optimization ( move all used colors in first palette indexes while redrawing the picture to keep it the same, supress duplicate colors, set to 0 unused colors)
2 - automatic pixel recoloring in another color index
3 - dispays picture stats : number of colours / planes used, number of pixel for each color
4 - block cut and save with planes selections ( 1b nb planes 2b width 2b heigth 32b pal + bitmap data)
5 - Generate a file with coordinate from manual mouse movement (each vbl sampling or on click) :
rectangular (x,y or relativ y*160 + 8(1+int(x&/16)) with mask
or polar (dist and angle from x159 y99)
6 - Generate a file with some tables sin cos sqrt 3d... for precalcs
7 - Generate code GFA (sprite, or specific), but could be easily adapted to asm or C ( interest to let the source than can be easily modified to your needs. Most of you already have this kind personnal rout, maybe you'll save time having many of them in one =D )
8 - Generate data source 4 scrolltext from font data for each character according to bitmap
9 - Any other idea ?

As i'm not a "talented coder" ( would need much time to pratice, without many years drops =S ), if it could be useful to you coders to ease your Atari creations, it would make me happy ^^

Atari ruleZ !!
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby simonsunnyboy » Mon Apr 07, 2014 6:32 pm

Sounds like the graphic helper utility I always wanted to have but didn't dare to start. 8)

PS: Output of C and/or M68K preshifted sprites would be great stuff to have.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby hylst » Tue Apr 08, 2014 8:43 am

simonsunnyboy wrote:Sounds like the graphic helper utility I always wanted to have but didn't dare to start. 8)

PS: Output of C and/or M68K preshifted sprites would be great stuff to have.


I'm gathering old programs i find back on my old 15/20 years old disk to compil them and adapt them to this utility.
It's archeology time ^^
I should put it online on Atari forum even if unfinished at the end of the week.
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2978
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby AtariZoll » Tue Apr 08, 2014 9:36 am

I was thinking about similar color reduction long time ago.
Probably not harder to do in ASM, and will be much faster. Then can put in GFA prg as function.
What pic. format it should work with ?
Famous Schrodinger's cat hypothetical experiment says that cat is dead or alive until we open box and see condition of poor animal, which deserved better logic. Cat is always in some certain state - regardless from is observer able or not to see what the state is.

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby hylst » Tue Apr 08, 2014 10:24 am

Presently, it's only degas, but i could had easily other file formats as i've coded a st picture viewer in gfa that load about 15 differents formats.
Only those that will be really useful to demo or games would be implemented.

All will depend on the interest atari people will have of this utility, because it's always time, and times is running so fast ^^

I should precise the program is not gem / mint ... friendly =D
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby hylst » Tue Apr 15, 2014 12:10 am

So here it is, rough, with still many to correct and separate .LST routs to merge, listing to xomment / explain, ... .. .
I'll try first to correct bugs, then will make some adds (NOT IMPLEMENTED function exist but need to be adapted) if i see some people sow me real interest on it.

So here's the GFA source file joined that can be interpreted or compiled if you wih, but better interpreted to make 'realtime' modifs

=)
Last edited by hylst on Thu Apr 17, 2014 10:21 am, edited 1 time in total.
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

evil
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 148
Joined: Sun Nov 12, 2006 8:03 pm

Re: recolor a full ST LOW to put used colors in first indexe

Postby evil » Tue Apr 15, 2014 2:53 pm

Not to spoil the party, but Grafx2 have this feature.
Pal / Reduce / To uniques

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby simonsunnyboy » Tue Apr 15, 2014 3:40 pm

But Grafx2 will never support those many ST specifics..such as sprite cutters, mask generators, code generator for sprites...

Years ago I asked them to support .god file format (should be easy) and as far as i know it is still not implemented. http://code.google.com/p/grafx2/issues/detail?id=499

So back to Hylst and his tool: how about an easy to use sprite preshifter?
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby hylst » Tue Apr 15, 2014 4:40 pm

evil wrote:Not to spoil the party, but Grafx2 have this feature.
Pal / Reduce / To uniques


You're right about the palette optimisation, grafx is so good :) even if it is heavy on a basic 520 stf for example.
Please take in consideration this program was coded about 95% 15-20 years ago.
About 1300 lines of gfa code and more if / when i'll find time to gather more separate routs ,adapt, and debug them.

We could add some functions or use, if interests are shown for.
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby hylst » Tue Apr 15, 2014 4:43 pm

simonsunnyboy wrote:But Grafx2 will never support those many ST specifics..such as sprite cutters, mask generators, code generator for sprites...

Years ago I asked them to support .god file format (should be easy) and as far as i know it is still not implemented. http://code.google.com/p/grafx2/issues/detail?id=499

So back to Hylst and his tool: how about an easy to use sprite preshifter?


Exact Simon=)

We could add highcolor bloc cutting management rather easily. Sprite preshifter is interessant in planar mode ST LOW or 256c falcon.
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

evil
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 148
Joined: Sun Nov 12, 2006 8:03 pm

Re: recolor a full ST LOW to put used colors in first indexe

Postby evil » Wed Apr 16, 2014 8:39 pm

simonsunnyboy wrote:But Grafx2 will never support those many ST specifics..such as sprite cutters, mask generators, code generator for sprites...


Of course not, but the topic of the thread is recolor, which it does very nicely.

simonsunnyboy wrote:Years ago I asked them to support .god file format (should be easy) and as far as i know it is still not implemented. http://code.google.com/p/grafx2/issues/detail?id=499


.god is a hicolour format, Grafx2 is a program for 256 colours with palette, it doesn't match very well. Even if it could export a .god file, reading it back into the software would require conversion to 256 colours (with the palette ordering being lost). It's not optimal at all. It does save as a BMP file which is super easy to read, just byte/pixel with a 24-bit palette. Format: 54 byte header, 1024 byte palette, byte/pixel rawdata.

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby hylst » Thu Apr 17, 2014 12:47 am

I'll correct some bugs, add visibility and modularity, and one thing or 2 till this week end and post it again on a specific thread.
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)

User avatar
hylst
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 133
Joined: Wed Apr 27, 2011 6:22 pm
Location: France : Strasbourg
Contact:

Re: recolor a full ST LOW to put used colors in first indexe

Postby hylst » Sat Apr 19, 2014 11:32 pm

Some bugs corrected, a littler clearer and shorter code, still several bugs.

GFA source in zip archive in attachment
You do not have the required permissions to view the files attached to this post.
Falcon CT60 +CENTRAM14 - 520 STE 4M - 1040 STf
Let's visit my Personal website http://hylst.t15.org !
The new website of my productions (French for the moment)


Social Media

     

Return to “GFA BASIC”

Who is online

Users browsing this forum: No registered users and 3 guests