| |
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.... |
| |
Pantaloon
Registered: Aug 2003 Posts: 124 |
I wrote a useless test with a zooming 2x2 char fonts, here is the routine in KickAsm that precomputes all the scaled characters if someone is interested.
.pc = $6000 "Zoomed Font"
.const c_zoomLevelCount = 19
.const c_zoomMin = 0.15
.const c_zoomMax = 1
.const c_charCount = 30
//
// load the font into 16x16 pixel chunks
//
.var originalFont = List()
.var charsetFont = LoadPicture("data/fonts/2x2_formaterad.gif", List().add($000000, $ffffff))
.for (var c = 0; c < c_charCount; c++)
{
.var theChar = List()
.for (var y = 0; y < 16; y++)
{
.for (var x = 0; x < 16; x++)
{
.var p = charsetFont.getPixel(x + c * 16, y) & 255
.eval theChar.add(p)
}
}
.eval originalFont.add(theChar)
}
//
// create zoomed versions
//
.function linearInterpolate(a,b,t)
{
.return [a*[1.0-t]] + [b*t]
}
.macro scale16x16(source, dest, zoom)
{
.var xratio = zoom
.var yratio = zoom
.var xoffset = [1-xratio] * 8
.var yoffset = [1-yratio] * 8
.for (var dy = 0; dy < 16; dy++)
{
.var sY = round([dy * yratio] + yoffset)
.for (var dx = 0; dx < 16; dx++)
{
.var sX = round([dx * xratio] + xoffset)
.eval dest.set(sX + sY*16 , source.get(dx + dy * 16))
}
}
}
.for (var c = 0; c < c_charCount; c++)
{
.for (var zoom = 0; zoom < c_zoomLevelCount; zoom++)
{
.var t = zoom / [c_zoomLevelCount-1]
.var zoomLevel = linearInterpolate(c_zoomMin, c_zoomMax, t)
.var originalChar = originalFont.get(c)
.var destChar = List()
.for (var i = 0; i < 256; i++)
.eval destChar.add(0)
:scale16x16(originalChar, destChar, zoomLevel)
.for (var j = 0; j < 2; j++)
{
.for (var y = 0; y < 16; y++)
{
.var theByte = 0
.for (var x = 0; x < 8; x++)
{
.var yy = y
.var xx = x + j * 8
.var addr = xx + yy * 16
.if (destChar.get(addr) == 255)
.eval theByte = theByte | [1 << [7-x]]
}
.byte theByte
}
}
}
}
|
| |
Pantaloon
Registered: Aug 2003 Posts: 124 |
I found a bug (i think) with the .importonce directive.
Lets say i have A.s containg this
.importonce
.var tracksector_hashtable = Hashtable()
.eval tracksector_hashtable.put("STARTUP",TRACKSECTOR(1,0))
And another file, B.s looking like this:
.import source "A.s"
.var ts = tracksector_hashtable.get("STARTUP")
Will produce this error:
Error: Unknown symbol 'tracksector_hashtable'
|
| |
Slammer
Registered: Feb 2004 Posts: 416 |
Panta: Late night coding i guess? :-)
My guess is that you have several .import statements and that the first one is inside a scope, so when you want to access the variable from another file it's out of scope?
I will have to see some example source to say anything precise.
You can check in which scope the tracksector_hashtable is placed yourself by:
1. Change the tracksector_hashtable to a label (.label tracksector_hashtable =...)
2. Comment out the line that fails
3. Assemble and look in the symbol file in which scope tracksector_hashtable is placed.
The symbolfile is not meant for reading (but for .importing) but it should be readable.
Btw. Making a more structured solution to scoping (also for functions and macros) is something thats on the TODO list for a version 4.0. |
| |
Pantaloon
Registered: Aug 2003 Posts: 124 |
Thanks Slammer, i will try it out. If i can't find any obvious errors i'll send you the sourcecode :)
-panta |
| |
Dr.j
Registered: Feb 2003 Posts: 277 |
2 fast quest. from a newcmmer to KickAsm.2
i really new with this stuff so try to easy with me.
1. i want to create macro which just print the
value of $d012 .
2. can i send chunk of data to a list? f.ex: i want
to send location lets say $400-$500 to macro/func. and it
will add it to a list and then do some calc. and store
it back or to the same or other location. to simplify
lets say we add $06 to all the list and store it back.
|
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Dr.J: Macros etc. are for making life easier at compile time, not at run time. So you can't operate on memory content or registers. If you want manipulate the content from $400-$500, you have to keep it in Lists until all the calculations are done before storing it to memory.
|
| |
Dr.j
Registered: Feb 2003 Posts: 277 |
@Cruzer: can you show me ex. of precalc how do i
send the $400-$500 to a list and store it back.
i know how do create bytes from list but didn't see
the opposite.
|
| |
JackAsser
Registered: Jun 2002 Posts: 1997 |
Quote: @Cruzer: can you show me ex. of precalc how do i
send the $400-$500 to a list and store it back.
i know how do create bytes from list but didn't see
the opposite.
What exactly are you trying to accomplish?!? I mean... the assembler can not know what the memory contents on the real device are when assembling.
If you would like to simply add the value 6 to all bytes between $400-$500 you either write a simple assembly loop, or use Lists and macros to generate speed code. |
| |
Dr.j
Registered: Feb 2003 Posts: 277 |
i want to do something like that.. but i guess its not possible...
.macro mymacro(location) {
.define mymacro {
.var mylist=List()
.for (i=0;i<256;i++)
mylist.add (value of location)
mylist.add ($06) - lets say add to all elements..
//;dump to memory
.fill mylist.size(),mylist.get(i)
}
}
:mymacro($0400)
|
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
Nope, not possible. But since you're in control of what gets into $0400-$0500 in the first place, you should wait with the dumping to memory and keep the data elsewhere so it can be used in the macro. And when all calculations are done, it's time for dumping. |
Previous - 1 | ... | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | ... | 61 - Next |