Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Kickassembler - Converting .PNG to Koala
2012-02-21 15:04
TWW

Registered: Jul 2009
Posts: 545
Kickassembler - Converting .PNG to Koala

Hey fellow hackers.

I wanted to write a converter in Kickassembler which can take any .PNG MC Bitmap screenshot from VICE (Then I don't need to worry about the RGB values since they are known) and convert into raw data you can use in your productions.

This is the way I imagine doing it:

#1 - Determin the background collor based on the most used collor in the picture
#2 - Verify there is no 4x8 block containing more than 3 collors+BG
#3 - Convert each 4x8 block afterwards and write the data into 3 lists (1 for BMP data, 1 for Charcollors and 1 for collmem).
#4 - Add BG collor at the end :-)

I'm looking for improvement comments on this or maybee I need to revise the way I think about this?
 
... 37 posts hidden. Click here to view all posts....
 
2012-02-22 12:24
JackAsser

Registered: Jun 2002
Posts: 2014
Use Enthusi's excellent vice snapshot grapper. Simply take a VICE snapshot (not screenshot) and use the utility to extract what's on screen.

Vice Snapshot Grabber 4.2
2012-02-22 12:27
Flavioweb

Registered: Nov 2011
Posts: 463
isn't already in vice a menu option to 'save multimedia file' for export pictures in koala format?
2012-02-22 14:25
algorithm

Registered: May 2002
Posts: 705
Quote: This is supposed to be easier than taking a screenshot?

Certainly not easier than that, but easier than going through conversion processes of finding background color, checking 4x8 blocks etc.
2012-02-22 15:26
TWW

Registered: Jul 2009
Posts: 545
I think we are getting a bit off track here.

I want to make a macro which converts a 320x200 picture on the PC (which follows the multicollor limitation of bitmap gfx on the C64) directly into my code in Kickassembler.

I want to use the script language supplied by the powerfull Kickassembler to do it and not a 3rd party tool which will add a step to the process.

I know it is possible but I wanted to get some ideas before diving into the matter.

After giving it some thought, i came up with something like this:

- Fetch all "4 collors" 4x8 blocks store them into a list (ignore blocks with 3, 2 or 1 collor(s)).
- repeat for all 1000 blocks and make a new list for each 4 coll block. (there is probably some nice way to store 2D lists (hastables?) which does this effectivly, still figguring this part out).
- Find the common collor in the stored blocks
- Start converting blocks to 2 bit pixel-data while setting the BG to #%"00" when it is encounterred.
- Store the colldata into seperate lists while each block is converted
- memfill the bmp/coll-data where you want it(set by the macro call).

Later if you modify the picture a little bit or change it with another one, just copy the .PNG file and the assembler does the rest.
2012-02-22 15:43
chatGPZ

Registered: Dec 2001
Posts: 11386
<Post edited by chatGPZ on 22/2-2012 20:24>

Quote:
Groepaz's approach can also fail, if there are no blocks using 4 colors at the same time.

ofcourse, as a first step you must count colors per cell and then sort the cells by how many colors are in them :)

edit: thats nonsense ofcourse. if there is no block with 4 colors then you can pick whatever bg color you like =P

that said, i would also suggest to use a makefile and a small external tool. maybe even hack it up yourself (because it is trivial, and didnt we all? =P). doing something like that in the assembler seems a bit pointless, wrong tool for the job, etc.
2012-02-22 19:09
Slammer

Registered: Feb 2004
Posts: 416
I would use this approach (pseudocode):
   backgrounColorSet =  {color0, color1, .., color15}
   for all blocks
      if (block has 4 colors)
         remove all but the 4 colors from the backgroundColorSet

Kick Assembler doesn't support sets yet, but you can use the keys in a hash table as a set and afterwards use 'hashtable.keys()' to get the possible background colors.
2012-02-22 19:50
Cruzer

Registered: Dec 2001
Posts: 1048
Slammer: Guess a list of 16 booleans indicating whether the colors are candidates for bg colors would do the trick. For each 4-color block, set the 12 others to false.
2012-02-23 00:13
TWW

Registered: Jul 2009
Posts: 545
I got an idea.

#1 - progressivly scan each 4x8 block and find the first one with 4 collors and add those collors to a list
#2 - continue scanning untill next block with 4 collors
#3 - find common collors between the two and discard the rest
#4 - repeat untill 1 collor remains in the list, BG collor set.
(I guess this is what you said^^)


I have 2 specific questions:

#1 - Can this:

    .for (var Id = 0 ; Id < 64 ; Id++) {
        .var PixelCollor = gfx.getPixel([Id>>1]&3, [Id>>3])
        .eval BlockCollors.put(Id,PixelCollor)
    }


be written like:

    .for (var Id = 0 ; Id < 64 ; Id++) {
      .eval BlockCollors.put(Id,gfx.getPixel([Id>>1]&3, [Id>>3]))
    }


somehow? (not very importain but just curios).

#2: - I have the collors from a 4x8 block in a hashtable, what is a good way to figgure out how many variants are stored in the table. Are we talking a long line of .if's here or is there a more smooth method?
2012-02-23 01:36
algorithm

Registered: May 2002
Posts: 705
Even more easier

$d021 col=0

check each 4x8 block, if colors in bitmap exceed limitations, then inc d021 and start over. until you get no clash




2012-02-23 01:40
TWW

Registered: Jul 2009
Posts: 545
Interesting. Assume the BG collor and verify...

How about compilation time if the BG = #$0f vs. method stipulated above?
Previous - 1 | 2 | 3 | 4 | 5 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Majikeyric
Dr. Doom/RAD
Scrap/Genesis Project
Sulevi/Virtual Dreams
Guests online: 113
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.046 sec.