| |
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.... |
| |
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) |
| |
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. |
| |
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
|
| |
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. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
soci, you make me excited, now can you generate code aswell with that? an example? :) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
tmp = range (999)
sta tmp+screen
would work ? |
| |
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. |
| |
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
|
| |
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 ;) |
| |
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 |