| |
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.... |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
No .ifdefined yet. What are you going to use it for? |
| |
TWW
Registered: Jul 2009 Posts: 542 |
F.ex:
I want a spudocommand/routine to behave in three different ways:
#1 - Set a global constant (ex: .const SafeMode = 1) which the automatically preserves all registers within pseudocommands.
#2 - Call up a pseudo with a SafeMode setting which then might overrrule the global setting to allow individual routines behave differently if I so choose.
#3 - If none of them are defined, force a default mode
So basically I want to check if a Constant or a Variable is defined from before.
However I am sure, by your question, you already got a(nother) method to do this^^ |
| |
Slammer
Registered: Feb 2004 Posts: 416 |
I would do something like this:
//---------------------------------------------
// Mode Control
//---------------------------------------------
.enum {MODE1, MODE2, UNSET}
.const defaultMode = MODE1
.var mode=UNSET
.function getMode() {
.if (mode==UNSET) return defaultMode
.return mode
}
//---------------------------------------------
// Commands
//---------------------------------------------
.psesudocommand myCmd a; b {
.if (getMode()==MODE1) {
/* DO SOMETHING */
}
.if (getMode()==MODE2) {
/* DO SOMETHING */
}
} |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
A little request: When a branch distance gets too far, it would be nice to know by how much. |
| |
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.
|
Previous - 1 | ... | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | ... | 61 - Next |