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 / 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 / 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
10 rem analogue mouse test tool
12 rem - movement detection by polling SID registers s+25/26
14 rem - left/right buttons detection by polling control port #1
16 s=54272: js=56321
18 print"{reverse on}{down}analogue mouse test{reverse off}{down*4}"
20 y$="{light gray}yes{light blue}":n$="{gray}no {light blue}"
22 h$=n$: v$=n$: lmb$=n$: rmb$=n$
24 ho=peek(s+25):vo=peek(s+26)
26 fori=.to39:next
28 if ho<>peek(s+25) then h$=y$
0 b$="19243342":fori=1to8:poke54296,val(mid$(b$,i,1)):pokes,.:forj=.to99:nextj,i:goto.
@tomaes
tomaes / OutOfMemoryError.pde
Last active February 5, 2016 18:52
Pushing counting sort down the stairs. Still neat to sort through 350M+ numbers in ~15 seconds on a below average contemporary PC, with no multi-threading or anything fancy.
// PDE3
final int COUNT = int(pow(2,28)); // 350000000;
final int RANGE = COUNT;
int[] rn = new int[COUNT];
int[] sn = new int[COUNT];
void setup()
{
println("generating " + rn.length + " numbers");
@tomaes
tomaes / csrt.c
Created March 23, 2016 21:21
...turns out PDE is slower than expected; doing the same thing in c99 (-O3'ed) is an order of magnitude faster?
// c99
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#define COUNT 200000000
#define RND_RANGE 200000000
@tomaes
tomaes / p5test.js
Last active April 9, 2016 16:58
P5.js test port / conversion. Fast it is not. :/
// Sierpinski's Carpet bömbing (v3)
// p5.js port (slow...)
var img;
function setup()
{
createCanvas( 729, 729, P2D ); //729 243 324
img = createImage(729,729, RGB);
}
@tomaes
tomaes / flatenthemout.pde
Last active April 11, 2016 12:51
Sierpinsky Carpet bömbing; stylish fractal things + parallax scrolling
// PDE 3.02
// Sierpinski's Carpet bömbing (v3)
// updt: better, faster, interactive
PImage img = createImage(729,729, RGB);
void setup()
{
size( 729, 729, P2D ); //729 243 324
}
@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 / 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