Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Creating 16bit tables in KickAssembler
2015-03-07 23:45
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
2015-03-07 23:53
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
2015-03-08 00:00
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)
}
2015-03-08 00:12
Trap

Registered: Jul 2010
Posts: 223
Thanks guys.

Appreciate the help!

br
Trap
2015-03-08 02:12
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.
2015-03-08 08:36
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.
2015-03-08 09:19
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
2015-03-08 10:03
Dr.j

Registered: Feb 2003
Posts: 277
\0/ ++ for always great stuff of Bonzai . keep rockin'
2015-03-09 01:59
chatGPZ

Registered: Dec 2001
Posts: 11386
i demand a bonzai megademo <3
2015-03-09 17:56
Trap

Registered: Jul 2010
Posts: 223
Mega? oh yes, but probably not in the way you mean it :D
2015-03-09 17:56
Trap

Registered: Jul 2010
Posts: 223
Oh, and thanks for the input TWW! Definitely appreciate any kind of inspiration and feedback.
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
Airwolf/F4CG
MWR/Visdom
The MeatBall
csio/monarchy c+4
Unlock/Padua/Albion
Case/Padua
Walt/Bonzai
iceout/Avatar/HF
Mike
DJ Gruby/TRiAD
Zorch
cadaver/covertbitops
Guests online: 140
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

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