Skip to content

Instantly share code, notes, and snippets.

View tobiasvl's full-sized avatar
🦀
Learning Rust

Tobias V. Langhoff tobiasvl

🦀
Learning Rust
View GitHub Profile
poke(24364,3)w={10,11,8,2,12}o="★●♥◆✽"b={[0]=0,0,0,0,0,0}z=56h=6::_::add(b,ceil(rnd(5)))cls()j=6*(8-flr(z/8))-6
?"██",8*(h%6),z+8*flr(h/6),5
?t(),49,58
for q=0,j+6 do
u=abs(b[q])for i in all{1,6}do
if(q<j and(i>1or q%6>1)and u==abs(b[q-i])and u==abs(b[q-i*2])and u!=0)b[q-i]=-u b[q-i*2]=-u b[q]=-u
end
?sub(o,u,u),(q%6)*8,z+flr(q/6)*8,q<j and w[u]or 1
end
for q=0,j do
@tobiasvl
tobiasvl / cvs2git.md
Last active May 9, 2020 07:04
Convert CVS repo to Git
# switch/case macro, should be followed by a jump table with the same number of entries as cases
:macro switch REG {
v0 := REG
v0 <<= v0
:calc table { HERE + 10 }
# for Super-CHIP compatibility, we also load VX for use with jump0 where X is the upper digit of the table's address
# note that if the table is located at address 0xA00 or above, we'll clobber necessary registers here!
:calc table-reg { table >> 8 }
v9 := 0x9
v9 -= v0
: keys
0
1
2
3
4
5
6
7
8
@tobiasvl
tobiasvl / neighboring_tiles.lua
Last active March 24, 2019 20:29
PICO-8 snippets
-- four directions, 16 tokens
for i=0,1,0.25 do
local x,y=cos(i),sin(i)
end
-- eight directions, 24 tokens
for i=0.125,1,0.125 do
local x,y=flr(cos(i)+.5),flr(sin(i)+.5)
end
z="lights out"poke(24364,3)::x::flip()cls()k=btnp()w={[0]="","▒","█"}f=flr
?z,12,18,stat(95)%4
?"z: classic\nx: 2000",12,32,7
if(k<9)goto x
if(k>16)w[3]="█"
b={}p=2m=0
for i=1,35 do
b[i]=i%7<2 and 0or 2
end::_::flip()cls()
?m,30,54
@tobiasvl
tobiasvl / picochallenge.p8
Last active November 15, 2018 10:53
Patrick's Picochallenge
poke(24364,3)x="웃"v="▥"h="▤"b={}for i=1,36 do b[i]=i%9<2 and""or"█"end for i in all{"⬆️","➡️",h,"⬅️","⬇️",v,x}do repeat f=1+flr(rnd(36))until b[f]!=""b[f]=i
if(i==x)p=f
end::_::t=btnp cls()for i=0,35 do
k=b[i+1]
?k,i%9*8,6*flr(i/9)+20,k==x and 11 or 7
end b[p]=""q=p
if(t(0))q-=1
if(t(1))q+=1
if(t(2))q-=9
if(t(3))q+=9
@tobiasvl
tobiasvl / fried_eggs.p8
Last active November 15, 2018 10:47 — forked from nucleartide/fried_eggs.p8
You thought you liked breakfast...
u=64
x,y=u,u
es={}c=circfill
f=abs
p=cos
o=sin::_::
if(btn(0))x-=1
if(btn(1))x+=1
if(btn(2))y-=1
if(btn(3))y+=1
@tobiasvl
tobiasvl / get_map_position.asm
Last active August 21, 2018 20:54
Game Boy snippet
get_map_position:
; from a sprite's pixel position, get the BG map address.
; d: Y pixel position
; e: X pixel position
; hl: returned map address
ld h, HIGH(_SCRN0) >> 2
; Y
ld a, [rSCY] ; account for scroll
sub a, 16 ; account for base sprite offset
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.