Skip to content

Instantly share code, notes, and snippets.

View tomaes's full-sized avatar
💭
Programming is for AIs. Let's go shopping.

tomaes

💭
Programming is for AIs. Let's go shopping.
View GitHub Profile
@tomaes
tomaes / whatsmore.bas
Last active May 9, 2019 13:14
Started as a qb.js experiment, but it so happens that qb.js is a very limited implementation of QBasic. Had to go back to the real thing.
' What's more? (v1.1)
' a quick guesstimation game in QBASIC
' (slightly extended version, won't run in qb.js)
DIM c%(2): cont% = 1: r% = 0: bchar% = 97 '97 = a,b / 48 = 0,1
CLS
RANDOMIZE TIMER
t = TIMER
@tomaes
tomaes / sumofparts.bas
Created May 2, 2019 09:42
Miniature Edutainment Game in GW-BASIC. A minor tribute to the first programming language I came in contact with. Back when Pangea was still a thing. ;)
110 REM the sum of parts. GW-Basic edition
120 A$ = ""
125 RANDOMIZE TIMER
130 FOR I=0 TO 19
140 N% = INT(RND(1)*10)
150 S% = S% + N%
160 A$ = A$ + CHR$(48+N%) + "+"
170 NEXT
180 A$ = LEFT$(A$,LEN(A$)-1) + "="
190 CLS: LOCATE 12,1: PRINT A$
@tomaes
tomaes / minesonar.lua
Last active May 9, 2019 13:14
the same minesonar.bas micro game in LUA
-- minesonar.bas in Lua (aka first Lua test, v2)
r, x, y = 0, math.random(8), math.random(8)
print "There is a mine hidden in an 8x8 field"
repeat
r = r + 1
@tomaes
tomaes / minesonar.bas
Created April 26, 2019 07:53
Another micro game (\o/): uncover a mine as quickly as possible. Enter coordinates, get the distance back. (c64/vic20 et al.)
0 x=int(rnd(1)*9):y=int(rnd(1)*9):print"where is the mine? enter x,y coords"
1 r=r+1:inputa,b:d=sqr(((x-a)*(x-a))+((y-b)*(y-b))):print"dist:"d:ifd>.1then1
5 print "done in"r"rounds!":ifr<4thenprint"wow!"
@tomaes
tomaes / c64romandkernal.bas
Last active April 22, 2019 12:51
A tiny program (with some fancy output) to detect a (classic) C64 OS/KERNAL and its version (well, v3 only, but hey...). Works on all(?) 8bit CBM machines.
0 c=-(peek(58504)=54): poke1024,.: k=-((peek(55296)and15)=14)
1 print"c64:"chr$(16*c+99),"kernal v3:"chr$(16*k+99)
@tomaes
tomaes / blocktumble.txt
Last active May 30, 2019 16:51
a few notes on block tumble!
"Block Tumble!" is a humble Commodore 64 puzzle game from 1991 in 2KBytes; it features 56(!) levels.
Here are some random notes I took while poking around in memory...
observations:
- the level encoding is fixed: 18 Bytes x 56 = 1008 Bytes
- the level data starts at 0BF9 (in memory), or at 03FA (file offset)
- a better, flexible encoding of the level data should take around ~870 Bytes
(assuming a not-too-crowded field in most levels and on average at least 8 wall stones)
(also: discussing level encoding should be a separate post, as there are MANY options :))
@tomaes
tomaes / mem20.bas
Last active October 30, 2016 11:31
Short (eh) memory card game for the standard VIC20 (should work on all the 8-bit Commodore machines, I think...)
0 fori=.to7step2:m(i)=i+2:m(i+1)=i+2:next:r=1
1 forj=.to9:fori=.to7:a=int(rnd(.)*8):h=m(i):m(i)=m(a):m(a)=h:nexti,j
2 print"#:"r:fori=.to7:printi;chr$(63+(m(i)<0)):next
3 r=r+1:input"cards";a,b:if(a=b)or((m(a)orm(b))<0)goto3
5 printchr$(13)m(a)m(b)chr$(13):ifm(a)=m(b)thenm(a)=-m(a):m(b)=-m(b)
8 s=.:fori=.to7:s=s+m(i):next:if(s>-40)goto2
@tomaes
tomaes / conveyor belt (vic 20)
Created October 29, 2016 15:55
Speed and patterns can be tweaked a lot. Also works on the 64.
0 s$=right$(s$,63)+chr$(250.3-rnd(.)):?chr$(19)s$s$s$s$s$s$s$:goto
@tomaes
tomaes / heartcash.bas
Created October 29, 2016 11:19
A symbolic 3-liner game in symbolic instruction code (vic 20)
0 v=38400:t=7680:c=164:m=50:h=211:printchr$(5):poke36879,127
1 o=((ti/m)and7)*m:geta$:x=x-(a$=" ")+(x=21)*21
2 ifpeek(t+o)<>83thenpokev+o,2:poket+o,c:?spc(x)chr$(h):goto1
@tomaes
tomaes / oneliners.glsl
Last active February 11, 2019 10:32
shadertoy GLSL oneliners
// fragment shader one-liners
// note: some might break for timing reasons (iDate.a/iDate.w) and some for compatibility reasons ("f+=" on a Mac, f.e.)
//
// void mainImage( out vec4 f, vec2 p )
// and then...
// "flames (red)"
{f=vec4(p.x/p.y*mod(sin(p.x-iDate.a),.001*length(p-.9)),.2,.5,1.0);}
// "rain (small)"