| 41 | 41 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,123 @@ |
| 1 |
+( a blank file ) |
|
| 2 |
+ |
|
| 3 |
+%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
|
|
| 4 |
+%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
|
|
| 5 |
+%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
|
|
| 6 |
+%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
|
|
| 7 |
+ |
|
| 8 |
+( fixed-point ) |
|
| 9 |
+ |
|
| 10 |
+%RESF { #0008 }
|
|
| 11 |
+%TO2F { RESF #0040 SFT2 SFT2 }
|
|
| 12 |
+%MUL2F { MUL2 RESF SFT2 }
|
|
| 13 |
+%DIV2F { SWP2 TO2F SWP2 DIV2 }
|
|
| 14 |
+ |
|
| 15 |
+%RTN { JMP2r }
|
|
| 16 |
+%TOB { SWP POP }
|
|
| 17 |
+%MOD2 { OVR2 OVR2 DIV2 MUL2 SUB2 }
|
|
| 18 |
+%MOD { DUP2 / * - }
|
|
| 19 |
+%SFL2 { #0040 SFT2 SFT2 }
|
|
| 20 |
+ |
|
| 21 |
+%DEBUG { .Console/byte DEO #0a .Console/char DEO }
|
|
| 22 |
+%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
|
|
| 23 |
+ |
|
| 24 |
+%WIDTH { #0080 }
|
|
| 25 |
+%HEIGHT { #0080 }
|
|
| 26 |
+ |
|
| 27 |
+( devices ) |
|
| 28 |
+ |
|
| 29 |
+|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ] |
|
| 30 |
+|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] |
|
| 31 |
+|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |
|
| 32 |
+|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
| 33 |
+|40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
| 34 |
+|50 @Audio2 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
| 35 |
+|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
| 36 |
+|70 @Midi [ &vector $2 &channel $1 ¬e $1 &velocity $1 ] |
|
| 37 |
+|80 @Controller [ &vector $2 &button $1 &key $1 ] |
|
| 38 |
+|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] |
|
| 39 |
+|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] |
|
| 40 |
+|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] |
|
| 41 |
+ |
|
| 42 |
+( variables ) |
|
| 43 |
+ |
|
| 44 |
+|0000 |
|
| 45 |
+ |
|
| 46 |
+@zoom $1 |
|
| 47 |
+@iter $1 |
|
| 48 |
+@fractal [ &c_re $2 &c_im $2 &x $2 &y $2 ] |
|
| 49 |
+ |
|
| 50 |
+( program ) |
|
| 51 |
+ |
|
| 52 |
+|0100 ( -> ) |
|
| 53 |
+ |
|
| 54 |
+ ( theme ) |
|
| 55 |
+ #f840 .System/r DEO2 |
|
| 56 |
+ #f840 .System/g DEO2 |
|
| 57 |
+ #f840 .System/b DEO2 |
|
| 58 |
+ |
|
| 59 |
+ #20 .iter POK |
|
| 60 |
+ #04 .zoom POK |
|
| 61 |
+ |
|
| 62 |
+ #0000 #0080 |
|
| 63 |
+ &ver |
|
| 64 |
+ ( col ) OVR2 .Screen/y DEO2 |
|
| 65 |
+ #0000 #0080 |
|
| 66 |
+ &hor |
|
| 67 |
+ ( row ) OVR2 .Screen/x DEO2 |
|
| 68 |
+ ,mandelbrot JSR |
|
| 69 |
+ ( incr ) SWP2 #0001 ++ SWP2 |
|
| 70 |
+ OVR2 OVR2 LTH2 ,&hor JNZ |
|
| 71 |
+ POP2 POP2 |
|
| 72 |
+ ( incr ) SWP2 #0001 ++ SWP2 |
|
| 73 |
+ OVR2 OVR2 LTH2 ,&ver JNZ |
|
| 74 |
+ POP2 POP2 |
|
| 75 |
+ |
|
| 76 |
+BRK |
|
| 77 |
+ |
|
| 78 |
+@mandelbrot ( -- ) |
|
| 79 |
+ ( |
|
| 80 |
+ .Screen/x DEI2 |
|
| 81 |
+ .Screen/y DEI2 ) |
|
| 82 |
+ |
|
| 83 |
+( |
|
| 84 |
+ double c_re = [col - width/2.0]*4.0/width; |
|
| 85 |
+ double c_im = [row - height/2.0]*4.0/width; |
|
| 86 |
+ double x = 0, y = 0; |
|
| 87 |
+ int iteration = 0; |
|
| 88 |
+ while [x*x+y*y <= 4 && iteration < max] {
|
|
| 89 |
+ double x_new = x*x - y*y + c_re; |
|
| 90 |
+ y = 2*x*y + c_im; |
|
| 91 |
+ x = x_new; |
|
| 92 |
+ iteration++; |
|
| 93 |
+ } |
|
| 94 |
+ if [iteration < max] putpixel[col, row, white]; |
|
| 95 |
+ else putpixel[col, row, black]; |
|
| 96 |
+) |
|
| 97 |
+ |
|
| 98 |
+ ( c_re = [col - width / 2.0] * 4.0 / width ) |
|
| 99 |
+ |
|
| 100 |
+ ( |
|
| 101 |
+ |
|
| 102 |
+ .Screen/x DEI2 TO2F |
|
| 103 |
+ WIDTH TO2F |
|
| 104 |
+ #0002 TO2F |
|
| 105 |
+ DIV2F |
|
| 106 |
+ SUB2 |
|
| 107 |
+ |
|
| 108 |
+ #0002 TO2F |
|
| 109 |
+ WIDTH TO2F |
|
| 110 |
+ DIV2F |
|
| 111 |
+ |
|
| 112 |
+ MUL2F |
|
| 113 |
+ |
|
| 114 |
+ .fractal/c_re POK2 |
|
| 115 |
+ |
|
| 116 |
+) |
|
| 117 |
+ |
|
| 118 |
+ |
|
| 119 |
+ |
|
| 120 |
+ #01 .Screen/color DEO |
|
| 121 |
+ |
|
| 122 |
+ |
|
| 123 |
+RTN |
|
| 0 | 124 |
\ No newline at end of file |
| ... | ... |
@@ -23,11 +23,19 @@ initmpu(Mpu *m, Uint8 device) |
| 23 | 23 |
Pm_GetDeviceInfo(i)->name, |
| 24 | 24 |
i == device ? "[x]" : "[ ]"); |
| 25 | 25 |
Pm_OpenInput(&m->midi, device, NULL, 128, 0, NULL); |
| 26 |
+ m->queue = 0; |
|
| 27 |
+ m->error = pmNoError; |
|
| 26 | 28 |
return 1; |
| 27 | 29 |
} |
| 28 | 30 |
|
| 29 | 31 |
void |
| 30 | 32 |
listenmpu(Mpu *m) |
| 31 | 33 |
{
|
| 32 |
- m->queue = Pm_Read(m->midi, m->events, 32); |
|
| 34 |
+ const int result = Pm_Read(m->midi, m->events, 32); |
|
| 35 |
+ if(result < 0) {
|
|
| 36 |
+ m->error = (PmError)result; |
|
| 37 |
+ m->queue = 0; |
|
| 38 |
+ return; |
|
| 39 |
+ } |
|
| 40 |
+ m->queue = result; |
|
| 33 | 41 |
} |
| ... | ... |
@@ -99,7 +99,7 @@ void op_div16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->s
|
| 99 | 99 |
void op_and16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b & a); }
|
| 100 | 100 |
void op_ora16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b | a); }
|
| 101 | 101 |
void op_eor16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b ^ a); }
|
| 102 |
-void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b >> (a & 0x000f) << ((a & 0x00f0) >> 4)); }
|
|
| 102 |
+void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b >> (a & 0x0007) << ((a & 0x0070) >> 4)); }
|
|
| 103 | 103 |
|
| 104 | 104 |
void (*ops[])(Uxn *u) = {
|
| 105 | 105 |
op_brk, op_lit, op_nop, op_pop, op_dup, op_swp, op_ovr, op_rot, |