Commit 855214cc authored by Dave Griffiths's avatar Dave Griffiths
Browse files

warp works

parent 7b32e8c0
......@@ -14,6 +14,7 @@
(define swp 32) (define rnd 33) (define mull 34) (define jmr 35) (define ldlv 36)
(define lensq 37) (define noise 38) (define lds 39) (define sts 40) (define mulv 41)
(define synth-crt 42) (define synth-con 43) (define synth-ply 44) (define flr 45)
(define mod 46)
(define instr
'(nop jmp jmz jlt jgt ldl lda ldi sta sti
......@@ -21,7 +22,7 @@
sqr len dup drp cmp shf bld ret dbg
nrm add.x add.y add.z swp rnd mull
jmr ldlv lensq noise lds sts mulv
synth-crt synth-con synth-ply flr))
synth-crt synth-con synth-ply flr mod))
(define prim-triangles 0)
(define prim-tristrip 1)
......@@ -213,8 +214,6 @@
(emit (vector lds 0 0))))
(define (emit-addr x)
(display "ello")(newline)
(display (variable-address (cadr x)))(newline)
(emit (vector ldl (variable-address (cadr x)) 0)))
(define (emit-cond-part x)
......@@ -417,6 +416,7 @@
((eq? (car x) '*v) (binary-procedure mulv x))
((eq? (car x) 'cross) (binary-procedure crs x))
((eq? (car x) 'dot) (binary-procedure dot x))
((eq? (car x) 'modulo) (binary-procedure mod x))
((eq? (car x) 'eq?) (emit-eq? x))
((eq? (car x) '>) (emit-> x))
((eq? (car x) '<) (emit-< x))
......
......@@ -119,7 +119,7 @@
(define warp
(make-jelly
500 prim-triangles
3000 prim-triangles
'(let ((vertex positions-start)
(warp-end 0)
(warp-position (vector 0 0 0))
......@@ -127,11 +127,12 @@
(weft-t 0)
(draft-pos 0)
(draft-size 4)
(draft (vector 1 0 1)) (draft-a1 0)
(draft-b0 (vector 0 1 0)) (draft-b1 1)
(draft-c0 (vector 1 0 1)) (draft-c1 0)
(draft-d0 (vector 0 1 0)) (draft-d1 1)
(draft-end 0))
(draft 1) (d-b 1) (d-c 0) (d-d 0)
(d-e 0) (d-f 1) (d-g 1) (d-h 0)
(d-i 0) (d-j 0) (d-k 1) (d-l 1)
(d-m 1) (d-n 0) (d-o 0) (d-p 1)
(draft-tmp 0)
(shed-tmp 0))
(define build-quad
(lambda (tl size)
......@@ -144,22 +145,31 @@
(define animate-shed
(lambda (i v)
(set! v
(cond ((< v 0.5) 1)
((> v 0.5) -1)))
(set! shed-tmp (cond ((> v 0.5) (vector 0 0 3))
((< v 0.5) (vector 0 0 -3))))
(set! v (cond ((< v 0.5) (vector 0 0 3))
((> v 0.5) (vector 0 0 -3))))
(set! warp-end 0)
(loop (< warp-end 10)
(write-add! (- i 6) 0 v 0 0 v v)
(write-add! i v 0 v v)
(loop (< warp-end 20)
(set! draft-tmp
(read (+ (addr draft) (+ (* draft-pos draft-size)
(modulo warp-end (+ draft-size (vector 0 1 1)) )))))
(cond ((> draft-tmp 0.5)
(write-add! (- i 6) 0 shed-tmp 0 0 shed-tmp shed-tmp
shed-tmp 0 shed-tmp shed-tmp))
((< draft-tmp 0.5)
(write-add! (- i 6) 0 v 0 0 v v
v 0 v v)))
(set! i (+ i 24))
(set! warp-end (+ warp-end 1)))))
(set! vertex positions-start)
; build 4 segments X warp-ends
(loop (< warp-end 10)
(loop (< warp-end 20)
(set! warp-position (+ (vector -25 -35 0)
(* (vector 5 0 0) warp-end)))
(* (vector 2.5 0 0) warp-end)))
(build-quad warp-position (vector 1 35 0))
(build-quad (+ warp-position (vector 0 35 0)) (vector 1 15 0))
(build-quad (+ warp-position (vector 0 50 0)) (vector 1 15 0))
......@@ -168,15 +178,15 @@
(forever
;; todo control externally
(set! weft-t (+ weft-t 0.05))
(cond ((> weft-t 1)
(trace draft-pos)
(set! draft-pos (+ draft-pos 1))
(cond ((> draft-pos draft-size)
(set! draft-pos 0)))
(set! weft-t 0)))
(trace (read (+ (addr draft) (* draft-pos 2))))
(set! vertex (+ positions-start 12))
(animate-shed vertex weft-t)
(set! shed (+ shed 5))
......@@ -200,7 +210,7 @@
((eqv? (modulo i 6) 4) (vector 1 10 0))
((eqv? (modulo i 6) 5) (vector 0 10 0))
)) "t")
(pdata-map! (lambda (c) (vector 1 1 1)) "c")
(pdata-map! (lambda (c) (vector 1 0.5 0.2)) "c")
(pdata-map! (lambda (n) (vector 0 0 0)) "n"))
......@@ -218,7 +228,7 @@
((eqv? (modulo i 6) 4) (vector 1 1 0))
((eqv? (modulo i 6) 5) (vector 0 1 0))
)) "t")
(pdata-map! (lambda (c) (vector 1 1 1)) "c")
(pdata-map! (lambda (c) (vector 0.2 0.8 1)) "c")
(pdata-map! (lambda (n) (vector 0 0 0)) "n"))
(every-frame
......
......@@ -260,9 +260,19 @@ void jellyfish::run()
vec3 v=pop();
m_audio_graph->Play(v.x, (int)v.y, v.z);
} break;
case FLR: { vec3 t=pop(); push(vec3(floor((float)t.x),
floor((float)t.y),
floor((float)t.z))); } break;
case FLR:
{ vec3 t=pop(); push(vec3(floor((float)t.x),
floor((float)t.y),
floor((float)t.z)));
} break;
case MOD:
{
vec3 m=pop();
vec3 t=pop();
push(vec3(fmod((float)t.x,(float)m.x),
fmod((float)t.y,(float)m.y),
fmod((float)t.z,(float)m.z)));
} break;
default: set_instr(pc,false);
};
......
......@@ -71,6 +71,7 @@
#define SYNTH_CON 43
#define SYNTH_PLY 44
#define FLR 45
#define MOD 46
// registers
#define REG_CONTROL 0 // pc, cycles, stack
......@@ -82,7 +83,8 @@
#define REG_SENSOR_ADDR 6
#define CODE_START 7
#define REG_STK 511 // oops hardcoded :/
// 4096
#define REG_STK 4095 // oops hardcoded :/
class jellyfish {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment