Category Archives: jellyfish

Jellyfish forms

The Jellyfish VM is now running in fluxus on android – a kind of executable rendering primitive which defines it’s form (a 3D triangle list) in the same place as it’s behaviour (a vector processing program), in the primitive’s data array.

This provides a 3D procedural modelling VM loosely inspired by the Playstation 2 which is much faster than interpreting scheme (or Java) on ARM devices like android. There are also possibilities for genetic programming or touch based programming interfaces just like Betablocker DS (think 3D animation rather than music).

Triangles are written to by de-referencing a register that defines the start of the model data, which exists in program memory. It can be programmed with raw vectors for each instruction, and right now the VM is run for 10 cycles for each frame, although this will be configurable “in the future”. Here is a simple program that was used to make the screenshots:

(define jelly (build-jellyfish))

(with-primitive jelly
 (program-jellyfish
  (list
 ; data
   (vector 0 0 0)         ; time (increases by 1 each loop)
   (vector 2 2 -3)        ; shuffle data for converting (x y z) -> (z z x)
 ; code follows to build a vertex by rotation around an angle based on time
   (vector LDA 0 0)       ; load current time from address 0
   (vector LDL 135.3 0)   ; load value 135.3 (angle in degrees)
   (vector MUL 0 0)       ; multiply time by angle
   (vector SIN 0 0)       ; makes (sin(angle) cos(angle) 0)
 ; make a spiral by scaling up with time
   (vector LDA 0 0)       ; load time again
   (vector LDL 0.05 0)    ; load 0.05
   (vector MUL 0 0)       ; multiply to get time*0.05
   (vector MUL 0 0)       ; mul rotation vector by time*0.05
 ; move backward in z so we get some depth
   (vector LDA 0 0)       ; load the time again
   (vector LDL 0.03)      ; load 0.03
   (vector MUL 0 0)       ; multiply the time by 0.01
   (vector LDA 1 0)       ; load the shuffle vec from address 1 
   (vector SHF 0 0)       ; shuffle the x to z position
   (vector ADD 0 0)       ; add (0 0 x) to set z on current position
   (vector STI 0 REG_MDL) ; write position to model memory registers
 ; increment the index by 1
   (vector LDA 0 0)       ; load address
   (vector LDL 1 0)       ; load inc
   (vector ADD 0 0)       ; add them together
   (vector STA 0 0)       ; store at address loc
   (vector JMP 2 0))))    ; goto 2

Jellyfish

Lots of travelling lately and for me, time in airports and long train journeys are time for acts of random research. One of the recent fruits is a new imaginary processor (code name Jellyfish), largely based on Betablocker DS but with ideas stolen from the PS2 vector unit.

Like the PS2 VU it’s a vector processor, but each instruction is 96 bits wide (unlike the PS2 which is 128), enough to store 3 32bit values representing 3D vectors or colours. Like other Betablocker variants every combination of bytes are valid as a runnable program, so it will for example happily execute random junk.

There are currently 25 instructions, with vector operations like dot, cross product and length, and various instructions for reordering vectors. It’s targeted at running on ARM processors so it uses fixed point maths for battery friendliness.

This is an ascii-shot of the super exciting debugger running a similarly exciting program to rotate a vector around the z axis.

-- prog -- pc:11
004   sta 13.000000 0.000000
005   sin 0.000000 0.000000
006   sta 14.000000 0.000000
007   lda 14.000000 0.000000
008   lda 15.000000 0.000000
009   crs 0.000000 0.000000
010   sta 16.000000 0.000000
011 > jmp 0.000000 0.000000
012   0.000000 0.000000 0.000000
013   60.000000 0.000000 0.000000
014   -0.125977 -0.992020 0.000000
015   0.000000 1.000000 0.000000
016   0.000000 0.000000 -0.125977
017   0.000000 0.000000 0.000000
-- stk -- stk:0
  0.000000 0.000000 0.000000 : 199
  0.000000 0.000000 0.000000 : 200
> 0.000000 0.000000 -0.125977 : 201
  0.000000 1.000000 0.000000 : 202