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 > Coding on a PC for the 64?
2016-01-11 05:53
Stablizer

Registered: Jan 2016
Posts: 19
Coding on a PC for the 64?

I've seen various editors out there, currently starting to use the C64Studio for this, but it seems like getting charsets, graphics, music, etc, is a bit problematic when going at it this way, isn't it?

Would love to get some pointers to reading material on the subject (have done some searches already, but haven't come up with anything notable really).

Thanks!
-Stab
 
... 179 posts hidden. Click here to view all posts....
 
2016-01-20 18:38
Slammer

Registered: Feb 2004
Posts: 416
I imagine that you find the range directive and then duplicate the line and insert 0,1,2,3,4... as replacement for the range? (Seems clear to me)
2016-01-20 19:05
Oswald

Registered: Apr 2002
Posts: 5094
nice inline sinus stuff guys. any way to use different numbers than 0-256 ? :)

the subtle difference in syntax doesnt matter, its not why some1 would choose one assembler over the other imho.
2016-01-20 19:22
soci

Registered: Sep 2003
Posts: 480
The macro replacement model gives the correct answer for that example. But I didn't stop there.

Oswald:
A slightly modified version for 100 items in 0-999 range, nicely separated into two tables (low/high bytes).
tmp = 500.5 + 499 * sin(range(100) * rad(360.0/100))
low  .byte <tmp
high .byte >tmp
2016-01-20 20:14
ChristopherJam

Registered: Aug 2004
Posts: 1409
Loving soci's solution for the sine table.

As for me,
from cjplib3 import dumpNumarrayToa65, np

with open("sinus.inc","w") as fo:
    dumpNumarrayToa65(fo, "sinus", (128.5+127*np.sin(np.arange(256)*np.pi/128)).astype(np.int))

All but the last line I'd probably already have in place if there were already other tables or data to include. Fair chance 'i' would already equal range(256), too.
2016-01-20 21:11
Oswald

Registered: Apr 2002
Posts: 5094
soci, you make me excited, now can you generate code aswell with that? an example? :)
2016-01-20 21:20
Oswald

Registered: Apr 2002
Posts: 5094
tmp = range (999)

sta tmp+screen


would work ?
2016-01-20 21:32
Slammer

Registered: Feb 2004
Posts: 416
I think i would just do it twice. Something like:
low: .fill 100, <500.5+499*sin(toRadians(i*360/100))
high: .fill 100, >500.5+499*sin(toRadians(i*360/100))
But you could also define a list or function first if you only want to write you expression once:
.function mySinus(i) { .return 500.5+499*sin(toRadians(i*360/100)) }
low: .fill 100, <mySinus(i)
high: .fill 100, >mySinus(i)

Oswald: My current guess is that soci defines a list with his range command and that all his operations/ functions work on lists. So the range list times the rad(360.0/100) gives another list where all the elements are multiplied by the result of the rad calculation. Etc.
2016-01-20 21:32
soci

Registered: Sep 2003
Posts: 480
Oswald:
Yes it does work, but I go for an example where you don't need to scroll the forum too much after I paste it in ;)
.1000 a2 00          ldx #$00           ldx #0
.1002 9d 00 04       sta $0400,x     lp sta $400+range(4)*256,x
.1005 9d 00 05       sta $0500,x
.1008 9d 00 06       sta $0600,x
.100b 9d 00 07       sta $0700,x
.100e e8             inx                inx
.100f d0 f1          bne $1002          bne lp

A bit less pretty example:
.1000 a5 fb          lda $fb            lda $fb
.1002 0a             asl a              asl [a,] x 4
.1003 0a             asl a
.1004 0a             asl a
.1005 0a             asl a
.1006 85 fb          sta $fb            sta $fb
2016-01-20 21:43
soci

Registered: Sep 2003
Posts: 480
Slammer: Right. That's what happens.

Range generates a range of integers that's the data source.

Universal functions (like the built-in sin() here) can operate on (nested) arrays. And operators too.

Broadcasting happens when the sizes don't match, then things get repeated as necessary (a simple number is an "array" too).

And at the end the ".byte" directive flattens the arrays (if necessary) for storing.

Using this I can throw out most of my verbose for loops.

There are still some corner cases I need to work on, but all my practical use cases are covered.

Better don't think about how much effort it took to implement this using plain C ;)
2016-01-20 21:43
chatGPZ

Registered: Dec 2001
Posts: 11386
is that "how to save 3 lines and make the code unreadable 101" now? :=)
Previous - 1 | ... | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ... | 19 - 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
Alakran_64
MWR/Visdom
Durandal
Guests online: 98
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 No Listen  (9.6)
2 Layers  (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 Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

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