| |
Trap
Registered: Jul 2010 Posts: 223 |
Creating 16bit tables in KickAssembler
Hi,
I need to create a 16-bit table for a sinus. I need the lower 8 bit in one $100-byte segment and the remaining upper 8 bit in another $100-byte segment.
What is the way to do that?
I have this:
.fill 256, 300+300*sin(toRadians(i*360/256))
It's probably easy to do, but I am old and senile so please bear with me :)
/Trap |
|
| |
Conjuror
Registered: Aug 2004 Posts: 168 |
Very easy. Labels and namespace not needed but I really like namespace feature.
sinus: {
lo: .fill 256, <[300+300*sin(toRadians(i*360/256))]
hi: .fill 256, >[300+300*sin(toRadians(i*360/256))]
}
lda sinus.lo,x
lda sinus.hi,x |
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
What Conjuror said. If you get into some more complex calculations, it's a good idea to put it into a list first, and then dump the low and high bytes afterwards, to avoid double calculations.
.var sineList = List()
.for (var i=0; i<256; i++) {
.eval sineList.add(300+300*sin(toRadians(i*360/256)))
}
sinus: {
lo: .fill 256, <sineList.get(i)
hi: .fill 256, >sineList.get(i)
}
|
| |
Trap
Registered: Jul 2010 Posts: 223 |
Thanks guys.
Appreciate the help!
br
Trap |
| |
TWW
Registered: Jul 2009 Posts: 545 |
I used this to 16-bit-schwing a logo once:
Directly calculates $d016 values and character position (no need to convert realtime).
/*«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»« »«»«»«»«»«»
..xxXX - TABLES - XXxx..
«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«» «»«»«»«»«»*/
.pc = * "sine values Char Position"
CharSine:
.fill 256, [359.6 + 359.6*sin(toRadians(i*360/256))]>>3
.byte $ff
.pc = * "sine values $d016"
D16Sine:
.fill 256, [[[359.6 + 359.6*sin(toRadians(i*360/256))]^7]&7]|$10
.byte $ff
Not sure if it's usefull though. |
| |
Dr.j
Registered: Feb 2003 Posts: 277 |
Hi Trap , Sorry for being a nerd but what Conjuror & Cruzer offered is very useful also b'coz sometimes you need multiple sinus tables so its good to use inner lables , also "nice to have" is to make .align $100 so you sinus will be aligned good for
index. |
| |
Trap
Registered: Jul 2010 Posts: 223 |
Thank you guys.
Dr.J, are you seriously excusing for being a nerd in a forum that encourages and cherishes nerdism as a higher form of being? ;) ... In Bonzai nerdism is the true love - a little known fact behind the 'love'-branding of the group :) Can't speak for the others, but that was my interpretation anyway.
I know about align - use it extensively even in places where I probably don't really have to. Just gives a little extra for the readability of my code.
/Trap |
| |
Dr.j
Registered: Feb 2003 Posts: 277 |
\0/ ++ for always great stuff of Bonzai . keep rockin' |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
i demand a bonzai megademo <3 |
| |
Trap
Registered: Jul 2010 Posts: 223 |
Mega? oh yes, but probably not in the way you mean it :D |
| |
Trap
Registered: Jul 2010 Posts: 223 |
Oh, and thanks for the input TWW! Definitely appreciate any kind of inspiration and feedback. |