| |
Rudi Account closed
Registered: May 2010 Posts: 125 |
Questions about Basic-statements and logic
Hi,
//PW is DIM-table to {1,2,4,8,16,32,64,128}
210 B1 = PW(7-D0)
212 B2 = PW(R7)
214 B3 = PW(7-D1)
220 P1 = (PEEK(W+B) AND B1) / B1
222 P2 = (PEEK(W+A) AND B2) / B2
224 P3 = (PEEK(W+C) AND B3) / B3
I changed 220, 222 and 224 to:
220 P1 = (PEEK(W+B) AND B1)
222 P2 = (PEEK(W+A) AND B2)
224 P3 = (PEEK(W+C) AND B3)
and added the lines:
226 IF P1=B1 THEN P1=1
227 IF P2=B2 THEN P2=1
228 IF P3=B3 THEN P3=1
but it seems slower. IF..THEN slower than the divides. I guess Basic is doing alot of logic for this and waste more cycles. any ideas what to do to remove the divides?
I first thought of doing a lookup table, but that doesnt. In worst case I have to poke or read data statements of shift-opcodes, but are there any other ways?
Thanks. |
|
... 15 posts hidden. Click here to view all posts.... |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
This thread tickled me, I couldn't resist writing my own version.
Here it is a different approach and 192 bytes:
https://www.dropbox.com/s/qh2yb562u96qi0s/eca.zip?dl=0 |
| |
Rudi Account closed
Registered: May 2010 Posts: 125 |
Fresh: cool! that's how it should be done, and runs fast too |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
indeed, but the patterns doesnt seem as chaotic as they shoould be but thats just my gut feeling. |
| |
bugjam
Registered: Apr 2003 Posts: 2589 |
Created an entry for it: ECA.
Cheers! |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
There were room for further (little) improvements: this final version is 7 bytes shorter and a bit faster.
In the same zip there's another binary: in that version the rule is incremented every frame (starting from 106) so you get some kind of a "slideshow".
https://www.dropbox.com/s/0vxogaeacllylsp/eca2.zip?dl=0 |
| |
Rudi Account closed
Registered: May 2010 Posts: 125 |
Quote: There were room for further (little) improvements: this final version is 7 bytes shorter and a bit faster.
In the same zip there's another binary: in that version the rule is incremented every frame (starting from 106) so you get some kind of a "slideshow".
https://www.dropbox.com/s/0vxogaeacllylsp/eca2.zip?dl=0
cool. is it tricky to do double buffering? also, would it run faster if you don't use random number generator on each iteration but use the same initial condition?
(edit: to get one specific rule in algebraic form use: http://www.wolframalpha.com/input/?i=rule+106+algebraic but wheter or not it can reduce some logic is uncertain. it's also stuck to one rule or fewer rules depending on the algebraic formula. for example rule 90 only needs two inputs: p and q, so r is not needed :P) |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
@Rudy: both features, double buffering and saving the first row, are not that hard to add but I've got something nicer in mind, I'm going to work on in it during the WE.
@Bugjam: I've seen you've added 2 new releases. Thats fine, thanks, but I'll probably post more code in this thread and I wouldn't like to flood csdb with my own WIPs. So, please ask me before adding. Hope you won't mind, there's nothing personal about this.
@Oswald: I'm using SID as random generator, maybe it doesn't produce a nice sequence...
Here it is a shorter (165) and yet a bit faster version.
https://www.dropbox.com/s/xtlerfbxbtwtdy9/eca3.zip?dl=0
I think that this is my limit in terms of size.
Edit:
@Bugjam: Rudi must be credited for the idea in both releases. Thank you. |
| |
Rudi Account closed
Registered: May 2010 Posts: 125 |
Fresh: nice work. oh, im sure ECA4.zip will come pretty soon :P whats WE? is $d012 bad as PRNG? ive used it a couple of times. but in a loop where accumulator changes. eor $d41b or eor $d012. i cant compile your versions because i dont use kickassembler. i use 64tass. |
| |
bugjam
Registered: Apr 2003 Posts: 2589 |
@Fresh: credits to Rudi added.
No offence taken, won´t add any more. |
| |
Fresh
Registered: Jan 2005 Posts: 101 |
@Bugjam: Thanks.
@Rudi: WE = weekend :). I've just added a tass source in ECA3.zip. You can use $d012 as PRNG in Basic but as soon as you shift to assembly you realize that it's too slow and repetitive: SID noise generator is more reliable. However, if you're interested in the topic, there are some useful and smarter solutions in codebase64. |
Previous - 1 | 2 | 3 - Next |