| 35 | 35 |
deleted file mode 100644 |
| ... | ... |
@@ -1,21 +0,0 @@ |
| 1 |
-( blank ) |
|
| 2 |
- |
|
| 3 |
-;label2d { x 2 y 2 color 1 addr 2 }
|
|
| 4 |
-;picture2d { x 2 y 2 width 2 height 2 color 1 addr 2 }
|
|
| 5 |
-;rect2d { x1 2 y1 2 x2 2 y2 2 }
|
|
| 6 |
-;point2d { x 2 y 2 }
|
|
| 7 |
- |
|
| 8 |
-|0100 @RESET BRK |
|
| 9 |
-|c000 @FRAME BRK |
|
| 10 |
-|d000 @ERROR BRK |
|
| 11 |
- |
|
| 12 |
-|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|
|
| 13 |
-|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
|
| 14 |
-|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|
| 15 |
-|FF30 ;Controller { buttons 1 }
|
|
| 16 |
-|FF40 ;Keys { key 1 }
|
|
| 17 |
-|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|
|
| 18 |
-|FF60 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
|
| 19 |
- |
|
| 20 |
-|FFF0 .RESET .FRAME .ERROR ( vectors ) |
|
| 21 |
-|FFF8 [ 13fd 1ef3 1bf2 ] ( palette ) |
|
| 22 | 0 |
\ No newline at end of file |
| ... | ... |
@@ -60,14 +60,14 @@ |
| 60 | 60 |
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
| 61 | 61 |
|0160 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
| 62 | 62 |
|01F0 .RESET .FRAME .ERROR ( vectors ) |
| 63 |
-|01F8 [ c0ef c07f c05f ] ( palette ) |
|
| 63 |
+|01F8 [ e0fd 30fd 30fd ] ( palette ) |
|
| 64 | 64 |
|
| 65 | 65 |
( program ) |
| 66 | 66 |
|
| 67 | 67 |
|0200 @RESET |
| 68 | 68 |
|
| 69 | 69 |
( default canvas ) |
| 70 |
- #0020 =canvas.w #0010 =canvas.h |
|
| 70 |
+ #002a =canvas.w #001a =canvas.h |
|
| 71 | 71 |
|
| 72 | 72 |
( default brush ) |
| 73 | 73 |
#04 =brush.size |
| ... | ... |
@@ -784,7 +784,7 @@ RTN |
| 784 | 784 |
@save_icn [ fe82 8282 848a f400 ] |
| 785 | 785 |
|
| 786 | 786 |
@blank_icn [ 0000 0000 0000 0000 ] |
| 787 |
-@filepath [ projects/pictures/akane2010.bit 00 ] |
|
| 787 |
+@filepath [ projects/pictures/tima2a1a.bit 00 ] |
|
| 788 | 788 |
|
| 789 | 789 |
@font_hex ( 0-F ) |
| 790 | 790 |
[ |
| 791 | 791 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,46 @@ |
| 1 |
+( hello world ) |
|
| 2 |
+ |
|
| 3 |
+%RTN { JMP2r }
|
|
| 4 |
+ |
|
| 5 |
+( devices ) |
|
| 6 |
+ |
|
| 7 |
+|0100 ;Console { pad 8 char 1 byte 1 short 2 }
|
|
| 8 |
+|01F0 .RESET .FRAME .ERROR ( vectors ) |
|
| 9 |
+|01F8 [ 13fd 1ef3 1bf2 ] ( palette ) |
|
| 10 |
+ |
|
| 11 |
+( program ) |
|
| 12 |
+ |
|
| 13 |
+|0400 @RESET |
|
| 14 |
+ |
|
| 15 |
+ ( for loop ) |
|
| 16 |
+ #00 #0d |
|
| 17 |
+ $loop |
|
| 18 |
+ ( body ) |
|
| 19 |
+ SWP #01 ADD SWP |
|
| 20 |
+ DUP2 LTH ^$loop JNZ |
|
| 21 |
+ POP2 |
|
| 22 |
+ |
|
| 23 |
+ ( while ) |
|
| 24 |
+ #00 #0d |
|
| 25 |
+ $while |
|
| 26 |
+ ( body ) |
|
| 27 |
+ DUP2 EQU ^$end JNZ |
|
| 28 |
+ SWP #01 ADD SWP |
|
| 29 |
+ ^$while JMP $end |
|
| 30 |
+ POP2 |
|
| 31 |
+ |
|
| 32 |
+ ( switch ) |
|
| 33 |
+ #02 |
|
| 34 |
+ DUP #01 NEQ ^$b JNZ |
|
| 35 |
+ ( a ) |
|
| 36 |
+ $b DUP #02 NEQ ^$c JNZ |
|
| 37 |
+ ( b ) |
|
| 38 |
+ $c DUP #03 NEQ ^$default JNZ |
|
| 39 |
+ ( c ) |
|
| 40 |
+ $default |
|
| 41 |
+ POP |
|
| 42 |
+ |
|
| 43 |
+BRK |
|
| 44 |
+ |
|
| 45 |
+@FRAME BRK |
|
| 46 |
+@ERROR BRK |
|
| 0 | 47 |
\ No newline at end of file |
| 1 | 48 |
deleted file mode 100644 |
| ... | ... |
@@ -1,68 +0,0 @@ |
| 1 |
-( Loop ) |
|
| 2 |
- |
|
| 3 |
-;a { byte 1 } ;b { byte 1 } ;c { byte 1 }
|
|
| 4 |
- |
|
| 5 |
-|0100 @RESET |
|
| 6 |
- |
|
| 7 |
- ,slow-muljmp JSR2 |
|
| 8 |
- ,slow-jmppop JSR2 |
|
| 9 |
- ,slow-jmppop-rel JSR2 |
|
| 10 |
- ,fast-byte JSR2 |
|
| 11 |
- ,fast-short JSR2 |
|
| 12 |
- |
|
| 13 |
-BRK |
|
| 14 |
- |
|
| 15 |
-|0200 @slow-muljmp ( type: padded muljmp ) |
|
| 16 |
- |
|
| 17 |
- $loop NOP |
|
| 18 |
- ~a #01 ADD =a |
|
| 19 |
- ~a #d0 LTH ^$loop MUL JMP |
|
| 20 |
- ~a =Console.byte |
|
| 21 |
- |
|
| 22 |
-RTN |
|
| 23 |
- |
|
| 24 |
-|0300 @slow-jmppop ( type: jmppop ) |
|
| 25 |
- |
|
| 26 |
- $loop |
|
| 27 |
- ~b #01 ADD =b |
|
| 28 |
- ,$loop ~b #d0 LTH JNZ2 |
|
| 29 |
- ~b =Console.byte |
|
| 30 |
- |
|
| 31 |
-RTN |
|
| 32 |
- |
|
| 33 |
-|0400 @slow-jmppop-rel ( type: padded jmppop ) |
|
| 34 |
- |
|
| 35 |
- $loop NOP |
|
| 36 |
- ~c #01 ADD =c |
|
| 37 |
- ~c #d0 LTH ^$loop SWP JMP? |
|
| 38 |
- ~c =Console.byte |
|
| 39 |
- |
|
| 40 |
-RTN |
|
| 41 |
- |
|
| 42 |
-|0500 @fast-byte ( fast byte ) |
|
| 43 |
- |
|
| 44 |
- #00 #d0 |
|
| 45 |
- $loop NOP |
|
| 46 |
- ( incr ) SWP #01 ADD SWP |
|
| 47 |
- DUP2 LTH ^$loop SWP JMP? |
|
| 48 |
- POP =Console.byte |
|
| 49 |
- |
|
| 50 |
-RTN |
|
| 51 |
- |
|
| 52 |
-|0600 @fast-short ( fast short ) |
|
| 53 |
- |
|
| 54 |
- #0000 #0d00 |
|
| 55 |
- $loop NOP |
|
| 56 |
- ( incr ) SWP2 #0001 ADD2 SWP2 |
|
| 57 |
- OVR2 OVR2 LTH2 ^$loop SWP JMP? |
|
| 58 |
- POP2 =Console.short |
|
| 59 |
- |
|
| 60 |
-RTN |
|
| 61 |
- |
|
| 62 |
-|c000 @FRAME |
|
| 63 |
-|d000 @ERROR |
|
| 64 |
- |
|
| 65 |
-|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|
|
| 66 |
- |
|
| 67 |
-|FFF0 .RESET .FRAME .ERROR ( vectors ) |
|
| 68 |
-|FFF8 [ 13fd 1ef3 1bf2 ] ( palette ) |
|
| 69 | 0 |
\ No newline at end of file |
| ... | ... |
@@ -154,9 +154,12 @@ findopcode(char *s) |
| 154 | 154 |
if(o[0] != s[0] || o[1] != s[1] || o[2] != s[2]) |
| 155 | 155 |
continue; |
| 156 | 156 |
while(s[3 + m]) {
|
| 157 |
- if(s[3 + m] == '2') i |= (1 << 5); /* mode: short */ |
|
| 158 |
- else if(s[3 + m] == 'r') i |= (1 << 6); /* mode: return */ |
|
| 159 |
- else return 0; /* failed to match */ |
|
| 157 |
+ if(s[3 + m] == '2') |
|
| 158 |
+ i |= (1 << 5); /* mode: short */ |
|
| 159 |
+ else if(s[3 + m] == 'r') |
|
| 160 |
+ i |= (1 << 6); /* mode: return */ |
|
| 161 |
+ else |
|
| 162 |
+ return 0; /* failed to match */ |
|
| 160 | 163 |
m++; |
| 161 | 164 |
} |
| 162 | 165 |
return i; |
| ... | ... |
@@ -424,16 +424,16 @@ datetime_poke(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1) |
| 424 | 424 |
Uint8 *m = u->ram.dat; |
| 425 | 425 |
time_t seconds = time(NULL); |
| 426 | 426 |
struct tm *t = localtime(&seconds); |
| 427 |
- m[ptr + 0] = (t->tm_year & 0xff00) >> 8; |
|
| 428 |
- m[ptr + 1] = t->tm_year & 0xff; |
|
| 429 |
- m[ptr + 2] = t->tm_mon; |
|
| 430 |
- m[ptr + 3] = t->tm_mday; |
|
| 431 |
- m[ptr + 4] = t->tm_hour; |
|
| 432 |
- m[ptr + 5] = t->tm_min; |
|
| 433 |
- m[ptr + 6] = t->tm_sec; |
|
| 434 |
- m[ptr + 7] = t->tm_wday; |
|
| 435 |
- m[ptr + 8] = (t->tm_yday & 0x100) >> 8; |
|
| 436 |
- m[ptr + 9] = t->tm_yday && 0xff; |
|
| 427 |
+ m[ptr + 0] = (t->tm_year & 0xff00) >> 8; |
|
| 428 |
+ m[ptr + 1] = t->tm_year & 0xff; |
|
| 429 |
+ m[ptr + 2] = t->tm_mon; |
|
| 430 |
+ m[ptr + 3] = t->tm_mday; |
|
| 431 |
+ m[ptr + 4] = t->tm_hour; |
|
| 432 |
+ m[ptr + 5] = t->tm_min; |
|
| 433 |
+ m[ptr + 6] = t->tm_sec; |
|
| 434 |
+ m[ptr + 7] = t->tm_wday; |
|
| 435 |
+ m[ptr + 8] = (t->tm_yday & 0x100) >> 8; |
|
| 436 |
+ m[ptr + 9] = t->tm_yday && 0xff; |
|
| 437 | 437 |
m[ptr + 10] = t->tm_isdst; |
| 438 | 438 |
return b1; |
| 439 | 439 |
} |
| ... | ... |
@@ -19,20 +19,22 @@ WITH REGARD TO THIS SOFTWARE. |
| 19 | 19 |
void setflag(Uint8 *a, char flag, int b) { if(b) *a |= flag; else *a &= (~flag); }
|
| 20 | 20 |
int getflag(Uint8 *a, char flag) { return *a & flag; }
|
| 21 | 21 |
Uint8 devpoke8(Uxn *u, Uint8 id, Uint8 b0, Uint8 b1){ return id < u->devices ? u->dev[id].poke(u, PAGE_DEVICE + id * 0x10, b0, b1) : b1; }
|
| 22 |
-void mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = (a & 0xff00) == PAGE_DEVICE ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; }
|
|
| 23 |
-Uint8 mempeek8(Uxn *u, Uint16 a) { return u->ram.dat[a]; }
|
|
| 24 |
-void mempoke16(Uxn *u, Uint16 a, Uint16 b) { mempoke8(u, a, b >> 8); mempoke8(u, a + 1, b); }
|
|
| 25 |
-Uint16 mempeek16(Uxn *u, Uint16 a) { return (mempeek8(u, a) << 8) + mempeek8(u, a + 1); }
|
|
| 22 |
+ |
|
| 26 | 23 |
void push8(Stack *s, Uint8 a) { if (s->ptr == 0xff) { s->error = 2; return; } s->dat[s->ptr++] = a; }
|
| 27 | 24 |
Uint8 pop8(Stack *s) { if (s->ptr == 0) { s->error = 1; return 0; } return s->dat[--s->ptr]; }
|
| 28 | 25 |
Uint8 peek8(Stack *s, Uint8 a) { if (s->ptr < a + 1) s->error = 1; return s->dat[s->ptr - a - 1]; }
|
| 26 |
+void mempoke8(Uxn *u, Uint16 a, Uint8 b) { u->ram.dat[a] = (a & 0xff00) == PAGE_DEVICE ? devpoke8(u, (a & 0xff) >> 4, a & 0xf, b) : b; }
|
|
| 27 |
+Uint8 mempeek8(Uxn *u, Uint16 a) { return u->ram.dat[a]; }
|
|
| 28 |
+ |
|
| 29 | 29 |
void push16(Stack *s, Uint16 a) { push8(s, a >> 8); push8(s, a); }
|
| 30 | 30 |
Uint16 pop16(Stack *s) { return pop8(s) + (pop8(s) << 8); }
|
| 31 | 31 |
Uint16 peek16(Stack *s, Uint8 a) { return peek8(s, a * 2) + (peek8(s, a * 2 + 1) << 8); }
|
| 32 |
+void mempoke16(Uxn *u, Uint16 a, Uint16 b) { mempoke8(u, a, b >> 8); mempoke8(u, a + 1, b); }
|
|
| 33 |
+Uint16 mempeek16(Uxn *u, Uint16 a) { return (mempeek8(u, a) << 8) + mempeek8(u, a + 1); }
|
|
| 32 | 34 |
/* Stack */ |
| 33 | 35 |
void op_brk(Uxn *u) { setflag(&u->status, FLAG_HALT, 1); }
|
| 34 |
-void op_lit(Uxn *u) { u->literal += 1; }
|
|
| 35 | 36 |
void op_nop(Uxn *u) { (void)u; }
|
| 37 |
+void op_lit(Uxn *u) { u->literal += 1; }
|
|
| 36 | 38 |
void op_pop(Uxn *u) { pop8(u->src); }
|
| 37 | 39 |
void op_dup(Uxn *u) { push8(u->src, peek8(u->src, 0)); }
|
| 38 | 40 |
void op_swp(Uxn *u) { Uint8 b = pop8(u->src), a = pop8(u->src); push8(u->src, b); push8(u->src, a); }
|
| ... | ... |
@@ -62,7 +64,7 @@ void op_div(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b
|
| 62 | 64 |
void op_and(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b & a); }
|
| 63 | 65 |
void op_ora(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b | a); }
|
| 64 | 66 |
void op_eor(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b ^ a); }
|
| 65 |
-void op_sft(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); Uint8 left = (a & 0xf0) >> 4; Uint8 right = (a & 0x0f); push8(u->src, b >> (right % 8) << (left % 8)); }
|
|
| 67 |
+void op_sft(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b >> ((a & 0x0f) % 8) << (((a & 0xf0) >> 4) % 8)); }
|
|
| 66 | 68 |
/* Stack */ |
| 67 | 69 |
void op_lit16(Uxn *u) { u->literal += 2; }
|
| 68 | 70 |
void op_nop16(Uxn *u) { printf("%04x\n", pop16(u->src)); }
|
| ... | ... |
@@ -95,7 +97,7 @@ void op_div16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->s
|
| 95 | 97 |
void op_and16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b & a); }
|
| 96 | 98 |
void op_ora16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b | a); }
|
| 97 | 99 |
void op_eor16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b ^ a); }
|
| 98 |
-void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); Uint8 left = (a & 0x00f0) >> 4; Uint8 right = (a & 0x000f); push16(u->src, b >> (right % 16) << (left % 16)); }
|
|
| 100 |
+void op_sft16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b >> ((a & 0x000f) % 16) << (((a & 0x00f0) >> 4) % 16)); }
|
|
| 99 | 101 |
|
| 100 | 102 |
void (*ops[])(Uxn *u) = {
|
| 101 | 103 |
op_brk, op_nop, op_lit, op_pop, op_dup, op_swp, op_ovr, op_rot, |