| |
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.... |
| |
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 |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
isn't already in vice a menu option to 'save multimedia file' for export pictures in koala format? |
| |
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. |
| |
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. |
| |
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. |
| |
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. |
| |
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. |
| |
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? |
| |
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
|
| |
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 |