Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user nurd ! (Registered 2024-06-16) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Kick Assembler Thread 2
2009-07-21 17:20
Slammer

Registered: Feb 2004
Posts: 416
Kick Assembler Thread 2

The previous thread took a little long to load, so this is a new fresh one..
 
... 592 posts hidden. Click here to view all posts....
 
2011-05-10 18:24
Slammer

Registered: Feb 2004
Posts: 416
As Mace said, it is supported. Another example of 'auto namespacing' is when you put a label before a macro execution. This will enable you to access the labels inside the macro which is quite useful.
2011-05-10 18:37
Mace

Registered: May 2002
Posts: 1799
Quote:
Another example of 'auto namespacing' is when you put a label before a macro execution.
Blimey, I needed that! Thanks :-)
2011-07-22 04:59
TWW

Registered: Jul 2009
Posts: 541
Alright, here is a question;

I have a .BMP logo which takes more then 2K (Larger then a char bank). The gfx only uses 3 collors + background.


Traditionally I would do the conversion from koala to char-screen in my own C64 native converter.

What I do on is to take 4x8 Multicollor Pixels and compare they 1 by 1 as I go along and "reuse" any duplicate "char-blocks" to conserve memory and allow fullscreen char-gfx using only 1 char-bank. At the same time the routine also produces the character-set map which is needed to display the gfx.

I reckon a simmular aproach is needed for this in Kickasseblers aswell and hope someone can point me in the right direction on how to aproach this?


I am thinking LoadPicture function with some PC-memory buffer used to sort out the data before filling the c-64 memory...

2011-07-22 08:15
tlr

Registered: Sep 2003
Posts: 1731
@tww: I'd use a hash table indexed by the char contents somehow. If 64-bit variables are allowed use that, otherwise just create the index by concatenating toHexString(<byte>) of all the char bytes. Make the hash entry contain a number indicating which char value it corresponds to.
When you match a char in the hash, just pick that number as char value. Keep the char mem in a list. When all is done, output the contents of the hash and the char mem using .fill or similar.

2011-07-22 09:32
Slammer

Registered: Feb 2004
Posts: 416
It is possible to do big conversions in Kick Assembler (See Cruzer pictureconverter on codebase64) and tlr got a point in using strings and hashtables for fast char-matching - The search process might be time critical since it is a script language.

If you are in the right mood for coding then go for the Tlr approach, if you want an easier way you can start by searching CSDb to see if someone else have done an 'other platform tool' for charpacking which can save you some time.

Tlr : all numeric values are treated as doubles and I guess you want to use a 64-bit integer.
2011-07-22 10:16
Cruzer

Registered: Dec 2001
Posts: 1048
I actually made an equal char packer using a hash table recently. It packs a 320x200 hires pic, but it should be easy to change it to multicolor and extend the size...
.macro equalCharPack(filename, screenAdr, charsetAdr) {
	.var charMap = Hashtable()
	.var charNo = 0
	.var screenData = List()
	.var charsetData = List()
	.var pic = LoadPicture(filename)
	.for (var charY=0; charY<25; charY++) {
		.for (var charX=0; charX<40; charX++) {
			.var currentCharBytes = List()
			.var key = ""
			.for (var i=0; i<8; i++) {
				.var byteVal = pic.getSinglecolorByte(charX, charY*8 + i)
				.eval key = key + toHexString(byteVal) + ","
				.eval currentCharBytes.add(byteVal)
			}
			.var currentChar = charMap.get(key)
			.if (currentChar == null) {
				.eval currentChar = charNo
				.eval charMap.put(key, charNo)
				.eval charNo++
				.for (var i=0; i<8; i++) {
					.eval charsetData.add(currentCharBytes.get(i))
				}
			}
			.eval screenData.add(currentChar)
		}
	}
	.pc = screenAdr "screen"
	.fill screenData.size(), screenData.get(i)
	.pc = charsetAdr "charset"
	.fill charsetData.size(), charsetData.get(i)
}

:equalCharPack("pic.png", $2800, $2000)
2011-07-22 12:09
Slammer

Registered: Feb 2004
Posts: 416
Nice one.. Btw. There is an error directive so you can fail if the number of chars exceeds 256.
2011-07-22 13:16
TWW

Registered: Jul 2009
Posts: 541
Awesome!

A small patch to fix the size issue:

  // Graphics should fit in 8x8 Single collor / 4 x 8 Multi collor blocks
  .var PictureSizeX = pic.width/8
  .var PictureSizeY = pic.height/8

	.for (var charY=0; charY<PictureSizeY; charY++) {
		.for (var charX=0; charX<PictureSizeX; charX++) {


And perhaps letting the gfx-mode (SC/MC) being passed as a argument to the Macro and we've got ourselves a fricking hot converter here.

Perhaps the RGB collors can be passed as an argument aswell so one can keep track of which collor goes to which bit-combination... Goddam!
2011-07-22 13:29
Frantic

Registered: Mar 2003
Posts: 1633
I added the script to codebase (including TWW's addition). If you make further additions/improvements to this script, don't hesitate to modify the codebase version too! It is here:

http://www.codebase64.org/doku.php?id=base:kick_assembler_macro..
2011-07-22 21:13
Pantaloon

Registered: Aug 2003
Posts: 124
Here are some code to find the closest c-64 color index from an RGB value, usefull when doing image conversion.

there are ofcourse better ways to find the best match but this works ok if you have images with c-64 colors allready.

i use it for my kickasm image converters, can convert sprites / hires / multicolor etc.

	.struct RGB {r,g,b}
	
	.var s_palette = List().add(
			RGB(0,0,0),		// black 0
			RGB(255,255,255),	// white 1
			RGB(104,55,43),		// red 2
			RGB(131,240,220),	// cyan 3
			RGB(111,61,134),	// purple 4
			RGB(89,205,54),		// green 5
			RGB(65,55,205),		// blue 6
			RGB(184,199,111),	// yellow 7
			RGB(209,127,48),	// orange 8
			RGB(67,57,0),		// brown 9	
			RGB(154,103,89),	// light_red 10
			RGB(91,91,91),		// dark_gray 11
			RGB(142,142,142),	// gray 12
			RGB(157,255,157),	// light_green 13
			RGB(117,161,236),	// light_blue 14
			RGB(193,193,193)	// light_gray 15
			);
	
	.function colorDistance(c1,c2)
	{
		.var cr = c1.r-c2.r
		.var cg = c1.g-c2.g
		.var cb = c1.b-c2.b
		.return sqrt([cr*cr] + [cg*cg] + [cb*cb])
	}

	.function getClosestColorIndex(rgb)
	{
		.return getClosestColorIndex(
			rgb, s_palette
			)
	}

	.function getClosestColorIndex(rgb, palette)
	{
		.var distance = colorDistance(rgb, palette.get(0))
		.var closestColorIndex = 0

		.for (var index = 1; index < palette.size(); index++)
		{
			.var d = colorDistance(rgb, palette.get(index))
			.if (d < distance)
			{
				.eval distance = d
				.eval closestColorIndex = index
			}
		}

		.return closestColorIndex
	}


Previous - 1 | ... | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ... | 61 - 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
The Phantom
MCM/ONSLAUGHT
Operator Teleksu
Nith/TRIÉ…D
Ghost/Quantum
CA$H/TRiAD
Guests online: 101
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.7)
6 Aliens in Wonderland  (9.6)
7 Comaland 100%  (9.6)
8 No Bounds  (9.6)
9 Uncensored  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Daah, Those Acid Pil..  (9.5)
9 Birth of a Flower  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 SHAPE  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

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