diff --git a/examples/primes.p8 b/examples/primes.p8 index dc1e8213e..f89672ed3 100644 --- a/examples/primes.p8 +++ b/examples/primes.p8 @@ -4,18 +4,14 @@ ~ main { ubyte[256] sieve - ubyte candidate_prime = 2 + ubyte candidate_prime = 2 ; is increased in the loop sub start() { - memset(sieve, 256, false) ; clear the sieve + memset(sieve, 256, false) ; clear the sieve, to reset starting situation on subsequent runs ; calculate primes - - ; @todo fix this, it misses some primes.... - - c64scr.print("prime numbers up to 255:\n\n") - ubyte amount + ubyte amount=0 while true { ubyte prime = find_next_prime() if prime==0 @@ -25,13 +21,14 @@ amount++ } c64.CHROUT('\n') - c64scr.print("amount of primes: ") + c64scr.print("number of primes (expected 54): ") c64scr.print_ub(amount) c64.CHROUT('\n') } sub find_next_prime() -> ubyte { + while sieve[candidate_prime] { candidate_prime++ if candidate_prime==0 @@ -40,7 +37,7 @@ ; found next one, mark the multiples and return it. sieve[candidate_prime] = true - uword multiple = candidate_prime**2 + uword multiple = candidate_prime while multiple < len(sieve) { sieve[lsb(multiple)] = true multiple += candidate_prime diff --git a/examples/tehtriz.p8 b/examples/tehtriz.p8 index eea1066c7..da3c00d47 100644 --- a/examples/tehtriz.p8 +++ b/examples/tehtriz.p8 @@ -8,7 +8,7 @@ const ubyte startYpos = boardOffsetY - 2 ubyte lines = 0 - ubyte score = 0 + uword score = 0 ubyte xpos = startXpos ubyte ypos = startYpos ubyte nextBlock = rnd() % 7 diff --git a/examples/test.p8 b/examples/test.p8 index 0295a2460..d34ba4f73 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -7,7 +7,12 @@ ; @todo see problem in looplabelproblem.p8 - ; @todo fix primes.p8 (it misses some primes) + ; @todo add docs for '@zp' tag in variable datatype declarations (including forloop loopvars) + + ; word ww2; byte bb; ww2 = bb * 55.w ; @todo why is this compiling, but resulting in a byte? + ; uword x = sin8u(bb) as uword + 50 ; @todo fix "cannot assign word to uword" + ; uword ypos=4; ypos += 5000 ; @todo fix "cannot assign word to uword" + sub start() { @@ -21,8 +26,10 @@ bb2 = bb*55 ww2 = ww*55 - ww2 = bb * 55.w ; @todo why is this resulting in a byte? - ypos += 5000 ; @todo fix "cannot assign word to uword" + ;uword x = sin8u(bb) as uword + 50 ; @todo fix "cannot assign word to uword" + ;ypos += 5000 ; @todo fix "cannot assign word to uword" + + ww2 = bb * 55.w ; @todo why is this compiling, but resulting in a byte? c64scr.print_w(ww2) c64.CHROUT('\n') ww2 = (bb as word)*55