Log In  
Follow
sparr

https://github.com/sparr/pico8lib/blob/fix_uint32/tests/test_uint32.p8

This cart produces the error "attempt to yield across a C-call boundary" during a self:assert_equal() in Arithmetic:test_subtraction.

However, things get weird from there, in ways that make this very difficult to reduce to a test case.

It didn't error when I wrote that test. That test started erroring when I wrote another test later, which runs before that test because they run in alphabetical order.

I wasn't able to reduce this to a test case because removing arbitrary parts of the file, including parts that shouldn't be accessing any of the same data, causes the error to go away.

If I comment out either one of these two lines, the error goes away: https://github.com/sparr/pico8lib/blob/fix_uint32/tests/test_uint32.p8#L110-L111

If I comment out this line in another function, the error goes away: https://github.com/sparr/pico8lib/blob/fix_uint32/tests/test_uint32.p8#L42

If I comment out some rows of test_sums, the error goes away.

[ Continue Reading.. ]

1
1 comment



stat(90) and neighbors give us wall clock time, which is useful for logging. However, at more than 1fps we'll get the same wall clock time on consecutive ticks/frames. It would be nice to be able to get milliseconds as well to disambiguate high frequency logs, without needing to track a frame counter in my game code.

1
1 comment



Cart #fill_pattern_demo-5 | 2020-02-19 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
10

Demonstrating the built-in fill patterns in 0.1.12d, which are implemented as numeric constants in variables whose names are the glyph characters.

10
2 comments



Cart #gunnersmates-0 | 2020-02-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

This is a rough draft of my idea for https://itch.io/jam/weekly-game-jam-136 "Single Player Co-Op". You are a turret gunner that can only shoot in one direction, and you only have about 16 seconds (no visible timer yet) to shoot all the targets circling around. Unfortunately that's not enough time. So then you start over, pointing a different direction, helping out your previous iteration, but that's still not enough. So you do it a third time, and now there are three of you. Eventually there are enough of you working together to kill all the enemies within the time limit... and nothing happens because I didn't include an ending yet.

4
0 comments



Cart #tweetbubblewrap-1 | 2020-02-15 | Code ▽ | Embed ▽ | No License
5

My first tweetcart with sound. Pop all the bubble wrap, then start again!

poke(24365,1)s=stat::r::b={}::m::
flip()cls()for p=0,63 do(b[p]and circ or circfill)(p%8*16+8,flr(p/8)*16+8,7,p%15+1)end
if(s(34)>0 and not b[p])sfx(0)b[p]=1
if(#b>62)goto r
x=s(32)y=s(33)pset(x,y,6)p=flr(y/16)*8+flr(x/16)goto m
__sfx__
000400000e6453667528655126350b624
5
5 comments



------------------------------------------------------------------------
-- takes a string describing a map and the width of the map
-- other parameters reimplement map()
-- example "0123456789abcdef",4 represents this 4x2 map:
-- [[0x01,0x23,0x45,0x67],[0x89,0xab,0xcd,0xef]]
function mapstring(mapstr, mapw, celx, cely, sx, sy, celw, celh, layer)
 -- remove[] to save tokens by making parameters mandatory
 ms, celx, cely, sx, sy, celw, celh, layer =
 ms or "", celx or 0, cely or 0, sx or 0, sy or 0, celw or 1, celh or 1, layer or 0
 for y=cely, cely+celh-1 do
  for x=celx, celx+celw-1 do
   local sprnum = tonum("0x"..sub(mapstr,(y*mapw+x)*2+1,(y*mapw+x)*2+2))
   if sprnum>0 and band(layer, fget(sprnum))==layer then
    spr(sprnum, sx+(x-celx)*8, sy+(y-cely)*8)
   end
  end
 end
end

This might be useful for games that define a large number of small maps (like metroid or zelda screens).

3
4 comments



This function uses bresenham's algorithm mirrored to the 8 octants, filtered by angle for the desired arc angles. It's so slow as to be useless; there are much better arc functions on the BBS already. I'm posting it for posterity and future reference, and because it inspired me to come up with a handy octant-range asin() approximation that might actually be useful

-- approximation of asin(d) for 0<=d<=.7071
-- exact at d==0, d==sin(1/16), d==sin(1/8)
-- max error .0021 at d==sin(3/32) in given range
-- error within that max beyond bounds up to d==sin(.137)
function delta2angle(d)
 return d * 0x.29cf + (d > 0x.61f8 and (d - 0x.61f8) * 0x.0785 or 0)
end

function arc(x, y, r, a1, a2, ...)
 a1 %= 1
 a2 %= 1
 if (a1 == a2) pset(x + r * cos(a1), y - r * sin(a1), ...) return
 a2 = a2 + (a1 > a2 and 1 or 0) -- ensure a2>a1
 dx, dy = r, 0
 while dy <= dx do
  a = delta2angle(dy / r)
  for flip_x = -1, 1, 2 do
   for flip_y = -1, 1, 2 do

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=73025#p)
0 comments



 x,y,w,h=64-10.75,64-10.25,20.5,20.5
 rectfill(x,y,x+w-1,y+h-1,8)
 clip(x,y,w,h)
 rectfill(x,y,x+w-1,y+h-1,11)
 circ(64,64,12,12)

Note that on the top and left the circle extends to the edge of the rect, as is expected since the rect was drawn to match the impending clip region. Note the extra row on the bottom, inside the original rectfill, outside the clipping rectangle.

I think this is a bug. At the very least, it's a place where the documentation needs to be clarified.

(the circle being off center is irrelevant)

1
1 comment



a snippet at the end of a line renders fine: [this is code]

however, a snippet in the middle of a line never terminates: [this is code] [this is not code]

2
0 comments



Cart #picochem-6 | 2021-01-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

Playable work in progress demake I've been working on, first for a week last January, now for a week again in the hopes of getting it playable for https://itch.io/jam/zachlike-jam

The original game is http://www.zachtronics.com/spacechem/ and I highly recommend every game they have produced.

Controls: arrows move the cursor. X to open a dialog to create/replace/delete instructions and arrows, arrows to move THAT cursor, X to confirm or O to cancel, optionally then arrows to set the direction/settings of the new instruction. O to open a dialog to run/pause/reset the simulation, or to grab and drop the sense and bond targets, or to change levels.

What works here:
arrows
start (1)

[ Continue Reading.. ]

3
2 comments



When drawing in the sprite editor, left click draws and right click picks up the color under the cursor (like the eye dropper in other image editing tools).
When using the bucket fill tool, left click fills and right click... fills. It would be convenient and consistent if right click was still an eye dropper in this scenario.

1
1 comment



It would be very handy if the built in tostr() was able to call the __tostring() metamethod for tables that have it defined. This is easy enough to add in our own code, but feels like it should be default behavior, similar to normal Lua.

1
2 comments



-32768 and 1 are both perfectly representable in the 16.16 fixed format, as 0x8000.0000 and 0x0001.0000. As far as I can see, this division should be perfect with no floating point shenanigans.

However, 0x8000.0000/0x0001.0000==0x8000.0001

which is throwing a wrench into some code I'm writing.

Other nearby operations work fine, such as

0x8000/2

and

0x7fff.ffff/1

and

0x8000.0001/1

Then there's another group of operations that seem to be technically misbehaving but in a possibly desirable way.

0x4000/0x0.8 0x2000/0x0.4 ... 0x1/0x0.0001

should technically all overflow to 0x8000 (-32768) but they actually evaluate to 0x7fff.ffff which renders as 32768 because it's higher than 32767.9999. Maybe this is intentional, and maybe it's helpful, but I mention it here because it might also be related.

PS: there are markdown rendering bugs affecting this post which is why it's weirdly formatted

1
2 comments



It would be helpful if calling color() to change the default color would return the previously default color. I am currently using a snippet like this to restore a previous default color:

 t=band(peek(24357),15)
 color(c)
 blah blah
 color(t)
4 comments



Cart #paintball_logic-1 | 2020-01-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

This is my first attempt at making a PICO 8 game. It is inspired by Zachtronics puzzle/programming games. The theme here is that a given series of balls will enter the grid from a queue, and you need to output the required series.

This is the second version, which might actually qualify as a real puzzle game now, with a few different mechanics and half a dozen "puzzles". I hope to continue development of features and more real puzzles!

4
4 comments