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 / basic chr$(32) adventure (c64)
Last active December 14, 2015 07:08
mini game. space shooter without space. and shooting.
10 print"{clear}{down*8}{14}{red}dodge!{light blue}{return}{reverse on}{162*21}";:s=54296
20 sc=1024:py=0:lv=3:w=40:t=10:ti$="000000":js=56320:poke53280,6:cl=646:zz=198
30 j=peek(js)and3:if(j<>3)thenpy=py-(j=1)+(j=2):py=pyand7
40 sp=sc+(t+py)*w+t:pokesp,62:pokesc+(t+int(rnd(.)*8))*w+19,w:pokes,2:pokes,.
50 print"{home}{down*9}":fori=.to7:print" {delete} ":next:print
60 ifpeek(sp)<>32thenlv=lv-1:pokecl,2:pokes,9:pokes,.
70 print"{up}{reverse on}>"str$(lv)"{space*12}"ti$"{light blue}":iflv>.thengoto30
80 print"{up}{reverse on}game over,score:":pokezz,.:waitzz,1:run
@tomaes
tomaes / femto racer (c64)
Last active December 14, 2015 02:19
pico racer's anorexic sister. now 2 lines of code.
4 rem femto racer; press <space> (or not) to stay on the road
6 printspc(9+sin(f)*6+6+sin(f*2)*5)"{white}: {green}:{gray}"m:f=f+.1:geta$:p=p+(a$=" ")*2+1
8 q=4^5+p:m=m+1:ifpeek(q)<>58thenpokeq,22:goto6
@tomaes
tomaes / joystick test (c64)
Last active December 14, 2015 01:39
for when "10 print peek(56320): goto 10" is not enough
10 rem joystick port test mini tool, press <space> to switch ports
20 p=56320:s=0
30 print" {return*2}{cyan} joystick (#"str$(2-s)") port"p+s"{return*2}"
40 j=peek(p+s): print"{up*2}{light gray} 0 1 2 3 4 5 6 7 val{light blue}"
50 geta$:if a$=" " then s=abs(s-1):print"{up*4}";:goto 30
60 print abs((jand1)>0)abs((jand2)>0)abs((jand4)>0)abs((jand8)>0);
70 print abs((jand16)>0)abs((jand32)>0)abs((jand64)>0)abs((jand128)>0);j
80 goto 40
@tomaes
tomaes / pattern drawing performance (c64)
Created February 21, 2013 12:47
some pattern drawing methods benchmarked (c64)
0 rem char screen pattern drawing methods and performance / commodore basic v2.0 (c64)
2 rem results for lines:
3 rem 10-> 18s (!)
4 rem 20-> 9s (same as 10, but twice as fast)
5 rem 30-> 3s (no PRNG? waay faster still)
6 rem 40/50-> <= 1s (cashed string 'brush' with and without PRNG, pretty fast)
7 rem all: <= 14s
9 ti$="000000"
10 for i=0 to 999: poke 1024+i,160+rnd(0)+0.5: next i
20 a=1024:b=2023:c=160:fori=atob:pokei,c+rnd(.)+.5:next
; working title: sea changes near wallpaper city
*= $801
byte $0B, $08, $0A, $00, $9E, $34, $30, $39, $36, $00, $00, $00
chars
byte 78, 77, 73, 75, 242, 66, 97, 72
txt
byte 13, 5; color
text "E-SIRAMIS " ; 10b
@tomaes
tomaes / s_atan
Last active August 29, 2015 14:02
holy colorful patterns, batman. (c64)
0 s=4^5:f=55296:w=40:c=85:h=198:z=z+.05:fory=.to24:forx=.to39
1 v=abs(atn(sin(x*y*z)*.5)*3):pokes+y*w+x,c+v:pokef+y*w+x,4+v:nextx,y
3 print"{home}[key]":pokeh,.:waith,1:goto
@tomaes
tomaes / heart curve (c128)
Created May 30, 2014 06:02
Someone was asking for this. ;)
1 rem c128 heart curve
2 color 4,5: rem bg
4 color 0,1: rem screen
6 color 1,3: rem drawing color
8 graphic 1,1:h=200:hh=100:wh=160:cw=10:ch=6
10 forx=-.99to1step.06
20 q=sqr(1-x*x)
22 y0=sqr(x*x)-q
24 y1=sqr(x*x)+q
44 xa=int((x+1)*wh):ya=h-int((y0+1)*hh)
@tomaes
tomaes / micro note
Last active August 29, 2015 14:01
mini note file viewer. rev2 with multi-page support. (c64)
;
; a minimal noter example with generated audio, BASIC header and multi-page support
;
* = $801
; 0 SYS4096
byte $0B, $08, $00, $00, $9E, '4', '0', '9', '6', $00, $00, $00
* = $1000
@tomaes
tomaes / flower tower
Last active August 29, 2015 14:01
54 wasteful bytes; looks kinda neat though. interactive. (c64)
;
; wallpaper scroll / flower tower (interactive)
;
* = 4096
lda #6
sta $d020
start ;
; user input to init field color and width
;
@tomaes
tomaes / Plop-8
Last active August 29, 2015 14:01
Mini step sequencer. 7 volume levels per cell. Press <1> to <8> to program some ploppy beats. 116 bytes. c64 again.
0 n=54296:geti:s(i)=(s(i)+1)and7:fori=1to8:poke1024+i,s(i):next:p=(p+1)and7
2 poke1065+p,30:fori=.to99:next:poke1065+p,32:poken,s(p+1):poken,.:goto