mirror of https://git.sr.ht/~rabbits/uxn
Redesigned assembler
This commit is contained in:
parent
0d9df02190
commit
57d29b1b10
12
README.md
12
README.md
|
@ -29,21 +29,19 @@ Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html).
|
||||||
```
|
```
|
||||||
( hello world )
|
( hello world )
|
||||||
|
|
||||||
&Console { pad 8 char 1 byte 1 short 2 }
|
@RESET
|
||||||
|
|
||||||
|0100 @RESET
|
|
||||||
|
|
||||||
,text1 ,print-label JSR2
|
,text1 ,print-label JSR2
|
||||||
,text2 ,print-label JSR2
|
,text2 ,print-label JSR2
|
||||||
#ab =CNSL.byte
|
#ab =Console.byte
|
||||||
#cdef =CNSL.short
|
#cdef =Console.short
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@print-label ( text )
|
@print-label ( text )
|
||||||
|
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( send ) DUP2 LDR =CNSL.char
|
( send ) DUP2 LDR =Console.char
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
||||||
POP2
|
POP2
|
||||||
|
@ -56,7 +54,7 @@ RTS
|
||||||
|c000 @FRAME
|
|c000 @FRAME
|
||||||
|d000 @ERROR
|
|d000 @ERROR
|
||||||
|
|
||||||
|FF00 ;CNSL Console
|
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
|
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
|
||||||
|
|
129
assembler.c
129
assembler.c
|
@ -16,22 +16,24 @@ typedef signed char Sint8;
|
||||||
typedef unsigned short Uint16;
|
typedef unsigned short Uint16;
|
||||||
typedef signed short Sint16;
|
typedef signed short Sint16;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
char name[64], params[16][64];
|
{
|
||||||
Uint8 len, length[16], size, refs;
|
char name[64];
|
||||||
} Template;
|
unsigned int size;
|
||||||
|
} Map;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[64];
|
char name[64];
|
||||||
Uint8 len, offset, refs;
|
Uint8 len, offset, refs;
|
||||||
Uint16 addr;
|
Uint16 addr;
|
||||||
Template *template;
|
/* map */
|
||||||
|
Map map[16];
|
||||||
|
Uint8 maps;
|
||||||
} Label;
|
} Label;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Uint8 data[256 * 256], tlen, llen;
|
Uint8 data[256 * 256], tlen, llen;
|
||||||
Uint16 ptr;
|
Uint16 ptr;
|
||||||
Template templates[256];
|
|
||||||
Label labels[256];
|
Label labels[256];
|
||||||
} Program;
|
} Program;
|
||||||
|
|
||||||
|
@ -83,16 +85,6 @@ pushtext(char *s, int lit)
|
||||||
while((c = s[i++])) pushbyte(c, 0);
|
while((c = s[i++])) pushbyte(c, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Template *
|
|
||||||
findtemplate(char *s)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for(i = 0; i < p.tlen; ++i)
|
|
||||||
if(scmp(p.templates[i].name, s, 64))
|
|
||||||
return &p.templates[i];
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Label *
|
Label *
|
||||||
findlabel(char *s)
|
findlabel(char *s)
|
||||||
{
|
{
|
||||||
|
@ -114,12 +106,12 @@ findlabeladdr(char *s)
|
||||||
if(scin(s, '.') < 1)
|
if(scin(s, '.') < 1)
|
||||||
return l->addr;
|
return l->addr;
|
||||||
param = s + scin(s, '.') + 1;
|
param = s + scin(s, '.') + 1;
|
||||||
for(i = 0; i < l->template->len; ++i) {
|
for(i = 0; i < l->maps; ++i) {
|
||||||
if(scmp(l->template->params[i], param, 64))
|
if(scmp(l->map[i].name, param, 64))
|
||||||
return l->addr + o;
|
return l->addr + o;
|
||||||
o += l->template->length[i];
|
o += l->map[i].size;
|
||||||
}
|
}
|
||||||
printf("!!! Warning %s.%s[%s]\n", l->name, param, l->template->name);
|
printf("!!! Warning %s.%s\n", l->name, param);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,10 +124,10 @@ findlabellen(char *s)
|
||||||
if(scin(s, '.') < 1)
|
if(scin(s, '.') < 1)
|
||||||
return l->len;
|
return l->len;
|
||||||
param = s + scin(s, '.') + 1;
|
param = s + scin(s, '.') + 1;
|
||||||
for(i = 0; i < l->template->len; ++i)
|
for(i = 0; i < l->maps; ++i)
|
||||||
if(scmp(l->template->params[i], param, 64))
|
if(scmp(l->map[i].name, param, 64))
|
||||||
return l->template->length[i];
|
return l->map[i].size;
|
||||||
printf("!!! Warning %s.%s[%s]\n", l->name, param, l->template->name);
|
printf("!!! Warning %s.%s\n", l->name, param);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,37 +170,7 @@ error(char *name, char *id)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
maketemplate(char *name, FILE *f)
|
makelabel(char *name, Uint16 addr)
|
||||||
{
|
|
||||||
Uint8 mode = 0;
|
|
||||||
Template *m;
|
|
||||||
char wv[64];
|
|
||||||
if(findtemplate(name))
|
|
||||||
return error("Template duplicate", name);
|
|
||||||
if(sihx(name) && slen(name) % 2 == 0)
|
|
||||||
return error("Template name is hex number", name);
|
|
||||||
if(findopcode(name))
|
|
||||||
return error("Template name is invalid", name);
|
|
||||||
m = &p.templates[p.tlen++];
|
|
||||||
scpy(name, m->name, 64);
|
|
||||||
while(fscanf(f, "%s", wv)) {
|
|
||||||
if(wv[0] == '{') continue;
|
|
||||||
if(wv[0] == '}') break;
|
|
||||||
if(mode == 0)
|
|
||||||
scpy(wv, m->params[m->len], 64);
|
|
||||||
else {
|
|
||||||
m->length[m->len] = shex(wv);
|
|
||||||
m->size += m->length[m->len];
|
|
||||||
m->len++;
|
|
||||||
}
|
|
||||||
mode = !mode;
|
|
||||||
}
|
|
||||||
printf("New template: %s[%d:%d]\n", name, m->len, m->size);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
makelabel(char *name, Uint16 addr, Uint8 len, Template *m)
|
|
||||||
{
|
{
|
||||||
Label *l;
|
Label *l;
|
||||||
if(findlabel(name))
|
if(findlabel(name))
|
||||||
|
@ -219,33 +181,29 @@ makelabel(char *name, Uint16 addr, Uint8 len, Template *m)
|
||||||
return error("Label name is invalid", name);
|
return error("Label name is invalid", name);
|
||||||
l = &p.labels[p.llen++];
|
l = &p.labels[p.llen++];
|
||||||
l->addr = addr;
|
l->addr = addr;
|
||||||
l->len = len;
|
|
||||||
l->refs = 0;
|
l->refs = 0;
|
||||||
scpy(name, l->name, 64);
|
scpy(name, l->name, 64);
|
||||||
if(m)
|
|
||||||
l->template = m;
|
|
||||||
printf("New label: %s, at 0x%04x[%d]\n", l->name, l->addr, l->len);
|
printf("New label: %s, at 0x%04x[%d]\n", l->name, l->addr, l->len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
makevariable(char *id, Uint16 *addr, FILE *f)
|
makevariable(char *name, Uint16 *addr, FILE *f)
|
||||||
{
|
{
|
||||||
char wv[64];
|
Label *l;
|
||||||
Uint16 origin;
|
char word[64];
|
||||||
Uint8 len;
|
if(!makelabel(name, *addr))
|
||||||
Template *m = NULL;
|
return error("Could not create variable", name);
|
||||||
fscanf(f, "%s", wv);
|
l = findlabel(name);
|
||||||
origin = *addr;
|
while(fscanf(f, "%s", word)) {
|
||||||
if(sihx(wv))
|
if(word[0] == '{') continue;
|
||||||
len = shex(wv);
|
if(word[0] == '}') break;
|
||||||
else if((m = findtemplate(wv))) {
|
scpy(word, l->map[l->maps].name, 64);
|
||||||
len = m->size;
|
fscanf(f, "%u", &l->map[l->maps].size);
|
||||||
m->refs++;
|
*addr += l->map[l->maps].size;
|
||||||
} else
|
l->maps++;
|
||||||
return error("Invalid template", wv);
|
}
|
||||||
*addr += len;
|
return 1;
|
||||||
return makelabel(id, origin, len, m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -277,18 +235,15 @@ pass1(FILE *f)
|
||||||
else
|
else
|
||||||
addr += slen(w);
|
addr += slen(w);
|
||||||
} else if(w[0] == '@') {
|
} else if(w[0] == '@') {
|
||||||
if(!makelabel(w + 1, addr, 0, NULL))
|
if(!makelabel(w + 1, addr))
|
||||||
return error("Pass1 failed", w);
|
return error("Pass1 failed", w);
|
||||||
scpy(w + 1, scope, 64);
|
scpy(w + 1, scope, 64);
|
||||||
} else if(w[0] == '$') {
|
} else if(w[0] == '$') {
|
||||||
if(!makelabel(sublabel(subw, scope, w + 1), addr, 0, NULL))
|
if(!makelabel(sublabel(subw, scope, w + 1), addr))
|
||||||
return error("Pass1 failed", w);
|
return error("Pass1 failed", w);
|
||||||
} else if(w[0] == ';') {
|
} else if(w[0] == ';') {
|
||||||
if(!makevariable(w + 1, &addr, f))
|
if(!makevariable(w + 1, &addr, f))
|
||||||
return error("Pass1 failed", w);
|
return error("Pass1 failed", w);
|
||||||
} else if(w[0] == '&') {
|
|
||||||
if(!maketemplate(w + 1, f))
|
|
||||||
return error("Pass1 failed", w);
|
|
||||||
} else if(findopcode(w) || scmp(w, "BRK", 4))
|
} else if(findopcode(w) || scmp(w, "BRK", 4))
|
||||||
addr += 1;
|
addr += 1;
|
||||||
else {
|
else {
|
||||||
|
@ -323,7 +278,7 @@ pass2(FILE *f)
|
||||||
while(fscanf(f, "%s", w) == 1) {
|
while(fscanf(f, "%s", w) == 1) {
|
||||||
Uint8 op = 0;
|
Uint8 op = 0;
|
||||||
Label *l;
|
Label *l;
|
||||||
if(w[0] == '&') continue;
|
if(w[0] == ';') continue;
|
||||||
if(w[0] == '$') continue;
|
if(w[0] == '$') continue;
|
||||||
if(skipblock(w, &ccmnt, '(', ')')) continue;
|
if(skipblock(w, &ccmnt, '(', ')')) continue;
|
||||||
if(skipblock(w, &ctemplate, '{', '}')) continue;
|
if(skipblock(w, &ctemplate, '{', '}')) continue;
|
||||||
|
@ -349,11 +304,10 @@ pass2(FILE *f)
|
||||||
}
|
}
|
||||||
else if(w[0] == '|') p.ptr = shex(w + 1);
|
else if(w[0] == '|') p.ptr = shex(w + 1);
|
||||||
else if((op = findopcode(w)) || scmp(w, "BRK", 4)) pushbyte(op, 0);
|
else if((op = findopcode(w)) || scmp(w, "BRK", 4)) pushbyte(op, 0);
|
||||||
else if(w[0] == ';') fscanf(f, "%s", w);
|
|
||||||
else if(w[0] == '.' && (l = findlabel(w + 1))) { pushshort(findlabeladdr(w + 1), 0); l->refs++; }
|
else if(w[0] == '.' && (l = findlabel(w + 1))) { pushshort(findlabeladdr(w + 1), 0); l->refs++; }
|
||||||
else if(w[0] == ',' && (l = findlabel(w + 1))) { pushshort(findlabeladdr(w + 1), 1); l->refs++; }
|
else if(w[0] == ',' && (l = findlabel(w + 1))) { pushshort(findlabeladdr(w + 1), 1); l->refs++; }
|
||||||
else if(w[0] == '=' && (l = findlabel(w + 1)) && l->len){ pushshort(findlabeladdr(w + 1), 1); pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR2" : "STR"), 0); l->refs++;}
|
else if(w[0] == '=' && (l = findlabel(w + 1))) { pushshort(findlabeladdr(w + 1), 1); pushbyte(findopcode(findlabellen(w + 1) == 2 ? "STR2" : "STR"), 0); l->refs++;}
|
||||||
else if(w[0] == '~' && (l = findlabel(w + 1)) && l->len){ pushshort(findlabeladdr(w + 1), 1); pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR2" : "LDR"), 0); l->refs++;}
|
else if(w[0] == '~' && (l = findlabel(w + 1))) { pushshort(findlabeladdr(w + 1), 1); pushbyte(findopcode(findlabellen(w + 1) == 2 ? "LDR2" : "LDR"), 0); l->refs++;}
|
||||||
else if(w[0] == '#' && sihx(w + 1) && slen(w + 1) == 2) pushbyte(shex(w + 1), 1);
|
else if(w[0] == '#' && sihx(w + 1) && slen(w + 1) == 2) pushbyte(shex(w + 1), 1);
|
||||||
else if(w[0] == '#' && sihx(w + 1) && slen(w + 1) == 4) pushshort(shex(w + 1), 1);
|
else if(w[0] == '#' && sihx(w + 1) && slen(w + 1) == 4) pushshort(shex(w + 1), 1);
|
||||||
else if(w[0] == '+' && sihx(w + 1) && slen(w + 1) == 2) pushbyte((Sint8)shex(w + 1), 1);
|
else if(w[0] == '+' && sihx(w + 1) && slen(w + 1) == 2) pushbyte((Sint8)shex(w + 1), 1);
|
||||||
|
@ -367,15 +321,13 @@ pass2(FILE *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cleanup(void)
|
cleanup(char *filename)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
printf("Assembled %s.\n\n", filename);
|
||||||
for(i = 0; i < p.llen; ++i)
|
for(i = 0; i < p.llen; ++i)
|
||||||
if(!p.labels[i].refs)
|
if(!p.labels[i].refs)
|
||||||
printf("--- Unused label: %s\n", p.labels[i].name);
|
printf("--- Unused label: %s\n", p.labels[i].name);
|
||||||
for(i = 0; i < p.tlen; ++i)
|
|
||||||
if(!p.templates[i].refs)
|
|
||||||
printf("--- Unused template: %s\n", p.templates[i].name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -390,7 +342,6 @@ main(int argc, char *argv[])
|
||||||
return error("Assembly", "Failed");
|
return error("Assembly", "Failed");
|
||||||
fwrite(p.data, sizeof(p.data), 1, fopen(argv[2], "wb"));
|
fwrite(p.data, sizeof(p.data), 1, fopen(argv[2], "wb"));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
printf("Assembled %s.\n\n", argv[2]);
|
cleanup(argv[2]);
|
||||||
cleanup();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr
|
||||||
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator
|
||||||
|
|
||||||
# run
|
# run
|
||||||
./bin/assembler projects/examples/dev.ctrl.usm bin/boot.rom
|
./bin/assembler projects/examples/dev.mouse.usm bin/boot.rom
|
||||||
./bin/emulator bin/boot.rom
|
./bin/emulator bin/boot.rom
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
( hello world )
|
( hello world )
|
||||||
|
|
||||||
&Console { pad 8 char 1 byte 1 short 2 }
|
@RESET
|
||||||
|
|
||||||
|0100 @RESET
|
|
||||||
|
|
||||||
,text1 ,print-label JSR2
|
,text1 ,print-label JSR2
|
||||||
,text2 ,print-label JSR2
|
,text2 ,print-label JSR2
|
||||||
#ab =CNSL.byte
|
#ab =Console.byte
|
||||||
#cdef =CNSL.short
|
#cdef =Console.short
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@print-label ( text )
|
@print-label ( text )
|
||||||
|
|
||||||
$loop NOP
|
$loop NOP
|
||||||
( send ) DUP2 LDR =CNSL.char
|
( send ) DUP2 LDR =Console.char
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
( loop ) DUP2 LDR #00 NEQ ^$loop MUL JMPS
|
||||||
POP2
|
POP2
|
||||||
|
@ -27,7 +25,7 @@ RTS
|
||||||
|c000 @FRAME
|
|c000 @FRAME
|
||||||
|d000 @ERROR
|
|d000 @ERROR
|
||||||
|
|
||||||
|FF00 ;CNSL Console
|
|FF00 ;Console { pad 8 char 1 byte 1 short 2 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
|
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
|
|
@ -0,0 +1,75 @@
|
||||||
|
( Controller )
|
||||||
|
|
||||||
|
;slime { color 1 }
|
||||||
|
|
||||||
|
|0100 @RESET
|
||||||
|
|
||||||
|
( set origin )
|
||||||
|
~Screen.width #0002 DIV2 =Sprite.x
|
||||||
|
~Screen.height #0002 DIV2 =Sprite.y
|
||||||
|
,default_icn =Sprite.addr
|
||||||
|
#11 =Sprite.color
|
||||||
|
#0a =slime
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
|c000 @FRAME
|
||||||
|
|
||||||
|
#0a =slime
|
||||||
|
( hold ctrl key to change slime color )
|
||||||
|
,no-ctrl ~Controller.buttons #0f AND #01 NEQ JMP2? POP2
|
||||||
|
#05 =slime
|
||||||
|
@no-ctrl
|
||||||
|
( hold alt key to change slime color )
|
||||||
|
,no-alt ~Controller.buttons #0f AND #02 NEQ JMP2? POP2
|
||||||
|
#0f =slime
|
||||||
|
@no-alt
|
||||||
|
( detect movement )
|
||||||
|
,no-up ~Controller.buttons #f0 AND #10 NEQ JMP2? POP2
|
||||||
|
( clear ) #10 =Sprite.color
|
||||||
|
( move ) ~Sprite.y #0001 SUB2 =Sprite.y ,up_icn =Sprite.addr
|
||||||
|
( draw ) ,redraw JSR2 BRK
|
||||||
|
@no-up
|
||||||
|
,no-down ~Controller.buttons #f0 AND #20 NEQ JMP2? POP2
|
||||||
|
( clear ) #10 =Sprite.color
|
||||||
|
( move ) ~Sprite.y #0001 ADD2 =Sprite.y ,down_icn =Sprite.addr
|
||||||
|
( draw ) ,redraw JSR2 BRK
|
||||||
|
@no-down
|
||||||
|
,no-left ~Controller.buttons #f0 AND #40 NEQ JMP2? POP2
|
||||||
|
( clear ) #10 =Sprite.color
|
||||||
|
( move ) ~Sprite.x #0001 SUB2 =Sprite.x ,left_icn =Sprite.addr
|
||||||
|
( draw ) ,redraw JSR2 BRK
|
||||||
|
@no-left
|
||||||
|
,no-right ~Controller.buttons #f0 AND #80 NEQ JMP2? POP2
|
||||||
|
( clear ) #10 =Sprite.color
|
||||||
|
( move ) ~Sprite.x #0001 ADD2 =Sprite.x ,right_icn =Sprite.addr
|
||||||
|
( draw ) ,redraw JSR2 BRK
|
||||||
|
@no-right
|
||||||
|
|
||||||
|
BRK
|
||||||
|
|
||||||
|
@redraw
|
||||||
|
|
||||||
|
( draw face )
|
||||||
|
#11 =Sprite.color
|
||||||
|
( draw slime )
|
||||||
|
,slime_icn =Sprite.addr
|
||||||
|
~slime =Sprite.color
|
||||||
|
|
||||||
|
RTS
|
||||||
|
|
||||||
|
@default_icn [ 3c7e ffdb ffe7 7e3c ]
|
||||||
|
@up_icn [ 2466 e7db ffff 7e3c ]
|
||||||
|
@down_icn [ 3c7e ffff dbe7 6624 ]
|
||||||
|
@left_icn [ 3c7e ef1f 1fef 7e3c ]
|
||||||
|
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
|
||||||
|
@slime_icn [ 0000 183c 3c18 0000 ]
|
||||||
|
|
||||||
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|
|FF10 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
||||||
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|
|FF30 ;Controller { buttons 1 }
|
||||||
|
|
||||||
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|
|FFF8 [ 0daf 02ff 035f ] ( palette )
|
|
@ -1,79 +0,0 @@
|
||||||
( dev/ctrl )
|
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|
||||||
&Controller { buttons 1 }
|
|
||||||
|
|
||||||
;slime-color 1
|
|
||||||
|
|
||||||
|0100 @RESET
|
|
||||||
|
|
||||||
( set origin )
|
|
||||||
~dev/screen.width #0002 DIV2 =dev/sprite.x
|
|
||||||
~dev/screen.height #0002 DIV2 =dev/sprite.y
|
|
||||||
,default_icn =dev/sprite.addr
|
|
||||||
#11 =dev/sprite.color
|
|
||||||
#0a =slime-color
|
|
||||||
|
|
||||||
BRK
|
|
||||||
|
|
||||||
|c000 @FRAME
|
|
||||||
|
|
||||||
#0a =slime-color
|
|
||||||
( hold ctrl key to change slime color )
|
|
||||||
,no-ctrl ~dev/ctrl.buttons #0f AND #01 NEQ JMP2? POP2
|
|
||||||
#05 =slime-color
|
|
||||||
@no-ctrl
|
|
||||||
( hold alt key to change slime color )
|
|
||||||
,no-alt ~dev/ctrl.buttons #0f AND #02 NEQ JMP2? POP2
|
|
||||||
#0f =slime-color
|
|
||||||
@no-alt
|
|
||||||
( detect movement )
|
|
||||||
,no-up ~dev/ctrl.buttons #f0 AND #10 NEQ JMP2? POP2
|
|
||||||
( clear ) #10 =dev/sprite.color
|
|
||||||
( move ) ~dev/sprite.y #0001 SUB2 =dev/sprite.y ,up_icn =dev/sprite.addr
|
|
||||||
( draw ) ,redraw JSR2 BRK
|
|
||||||
@no-up
|
|
||||||
,no-down ~dev/ctrl.buttons #f0 AND #20 NEQ JMP2? POP2
|
|
||||||
( clear ) #10 =dev/sprite.color
|
|
||||||
( move ) ~dev/sprite.y #0001 ADD2 =dev/sprite.y ,down_icn =dev/sprite.addr
|
|
||||||
( draw ) ,redraw JSR2 BRK
|
|
||||||
@no-down
|
|
||||||
,no-left ~dev/ctrl.buttons #f0 AND #40 NEQ JMP2? POP2
|
|
||||||
( clear ) #10 =dev/sprite.color
|
|
||||||
( move ) ~dev/sprite.x #0001 SUB2 =dev/sprite.x ,left_icn =dev/sprite.addr
|
|
||||||
( draw ) ,redraw JSR2 BRK
|
|
||||||
@no-left
|
|
||||||
,no-right ~dev/ctrl.buttons #f0 AND #80 NEQ JMP2? POP2
|
|
||||||
( clear ) #10 =dev/sprite.color
|
|
||||||
( move ) ~dev/sprite.x #0001 ADD2 =dev/sprite.x ,right_icn =dev/sprite.addr
|
|
||||||
( draw ) ,redraw JSR2 BRK
|
|
||||||
@no-right
|
|
||||||
|
|
||||||
BRK
|
|
||||||
|
|
||||||
@redraw
|
|
||||||
|
|
||||||
( draw face )
|
|
||||||
#11 =dev/sprite.color
|
|
||||||
( draw slime )
|
|
||||||
,slime_icn =dev/sprite.addr
|
|
||||||
~slime-color =dev/sprite.color
|
|
||||||
|
|
||||||
RTS
|
|
||||||
|
|
||||||
@default_icn [ 3c7e ffdb ffe7 7e3c ]
|
|
||||||
@up_icn [ 2466 e7db ffff 7e3c ]
|
|
||||||
@down_icn [ 3c7e ffff dbe7 6624 ]
|
|
||||||
@left_icn [ 3c7e ef1f 1fef 7e3c ]
|
|
||||||
@right_icn [ 3c7e f7f8 f8f7 7e3c ]
|
|
||||||
@slime_icn [ 0000 183c 3c18 0000 ]
|
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|
||||||
|FF20 ;dev/sprite Sprite
|
|
||||||
|FF30 ;dev/ctrl Controller
|
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|
||||||
|FFF8 [ 0daf 02ff 035f ] ( palette )
|
|
|
@ -1,20 +1,11 @@
|
||||||
( dev/key )
|
( Keys )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
;mouse { x 2 y 2 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
;textarea { x1 2 y1 2 x2 2 y2 2 color 1 addr 2 cursor 1 }
|
||||||
&Keyboard { key 1 }
|
;rect { x1 2 y1 2 x2 2 y2 2 }
|
||||||
&Mouse { x 2 y 2 state 1 chord 1 }
|
;color { byte 1 }
|
||||||
|
;blink { byte 1 }
|
||||||
&Textarea2d { x1 2 y1 2 x2 2 y2 2 color 1 addr 2 cursor 1 }
|
;timer { byte 1 }
|
||||||
&Rect2d { x1 2 y1 2 x2 2 y2 2 }
|
|
||||||
&Point2d { x 2 y 2 }
|
|
||||||
|
|
||||||
;mouse Point2d
|
|
||||||
;textarea Textarea2d
|
|
||||||
;rect Rect2d
|
|
||||||
;color 1
|
|
||||||
;blink 1
|
|
||||||
;timer 1
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
|
@ -33,7 +24,7 @@ BRK
|
||||||
|
|
||||||
@redraw-window
|
@redraw-window
|
||||||
|
|
||||||
#0000 #0000 ~dev/screen.width ~dev/screen.height #01 ,pattern ,tile-rect JSR2
|
#0000 #0000 ~Screen.width ~Screen.height #01 ,pattern ,tile-rect JSR2
|
||||||
( dropshadow )
|
( dropshadow )
|
||||||
~textarea.x2 #0001 ADD2 ~textarea.y1 ~textarea.x2 #0004 ADD2 ~textarea.y2 #0004 ADD2 #01 ,fill-rect JSR2
|
~textarea.x2 #0001 ADD2 ~textarea.y1 ~textarea.x2 #0004 ADD2 ~textarea.y2 #0004 ADD2 #01 ,fill-rect JSR2
|
||||||
~textarea.x1 ~textarea.y2 #0001 ADD2 ~textarea.x2 #0001 ADD2 ~textarea.y2 #0004 ADD2 #01 ,fill-rect JSR2
|
~textarea.x1 ~textarea.y2 #0001 ADD2 ~textarea.x2 #0001 ADD2 ~textarea.y2 #0004 ADD2 #01 ,fill-rect JSR2
|
||||||
|
@ -54,8 +45,8 @@ RTS
|
||||||
,skip ~timer #10 LTH JMP2? POP2
|
,skip ~timer #10 LTH JMP2? POP2
|
||||||
#00 =timer
|
#00 =timer
|
||||||
~blink #00 EQU =blink
|
~blink #00 EQU =blink
|
||||||
,cursor =dev/sprite.addr
|
,cursor =Sprite.addr
|
||||||
#05 ~blink ADD =dev/sprite.color
|
#05 ~blink ADD =Sprite.color
|
||||||
@skip
|
@skip
|
||||||
~timer #01 ADD =timer
|
~timer #01 ADD =timer
|
||||||
|
|
||||||
|
@ -63,64 +54,64 @@ RTS
|
||||||
|
|
||||||
@tile-rect ( x1 y1 x2 y2 color addr )
|
@tile-rect ( x1 y1 x2 y2 color addr )
|
||||||
|
|
||||||
=dev/sprite.addr =color =rect.y2 =rect.x2 DUP2 =dev/sprite.y =rect.y1 DUP2 =dev/sprite.x =rect.x1
|
=Sprite.addr =color =rect.y2 =rect.x2 DUP2 =Sprite.y =rect.y1 DUP2 =Sprite.x =rect.x1
|
||||||
|
|
||||||
$ver
|
$ver
|
||||||
~rect.x1 =dev/sprite.x
|
~rect.x1 =Sprite.x
|
||||||
$hor
|
$hor
|
||||||
( draw ) ~color =dev/sprite.color
|
( draw ) ~color =Sprite.color
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
,$hor ~dev/sprite.x ~rect.x2 LTH2 JMP2? POP2
|
,$hor ~Sprite.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
,$ver ~dev/sprite.y ~rect.y2 LTH2 JMP2? POP2
|
,$ver ~Sprite.y ~rect.y2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@fill-rect ( x1 y1 x2 y2 color )
|
@fill-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
$ver
|
$ver
|
||||||
~rect.x1 =dev/screen.x
|
~rect.x1 =Screen.x
|
||||||
$hor
|
$hor
|
||||||
( draw ) ~color =dev/screen.color
|
( draw ) ~color =Screen.color
|
||||||
( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
,$hor ~dev/screen.x ~rect.x2 LTH2 JMP2? POP2
|
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,$ver ~dev/screen.y ~rect.y2 LTH2 JMP2? POP2
|
,$ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@line-rect ( x1 y1 x2 y2 color )
|
@line-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
$hor
|
$hor
|
||||||
( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
( draw ) ~rect.y1 =dev/screen.y ~color =dev/screen.color
|
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
||||||
( draw ) ~rect.y2 =dev/screen.y ~color =dev/screen.color
|
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
||||||
,$hor ~dev/screen.x ~rect.x2 LTH2 JMP2? POP2
|
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
~rect.y1 =dev/screen.y
|
~rect.y1 =Screen.y
|
||||||
$ver
|
$ver
|
||||||
( draw ) ~rect.x1 =dev/screen.x ~color =dev/screen.color
|
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
||||||
( draw ) ~rect.x2 =dev/screen.x ~color =dev/screen.color
|
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
||||||
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,$ver ~dev/screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-textarea ( x y color addr )
|
@draw-textarea ( x y color addr )
|
||||||
|
|
||||||
( load ) =textarea.addr =textarea.color =dev/sprite.y =dev/sprite.x
|
( load ) =textarea.addr =textarea.color =Sprite.y =Sprite.x
|
||||||
~textarea.addr
|
~textarea.addr
|
||||||
$loop
|
$loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =dev/sprite.addr ~textarea.color =dev/sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~textarea.color =Sprite.color
|
||||||
( detect linebreaks )
|
( detect linebreaks )
|
||||||
DUP2 LDR #0d NEQ ,$no-return ROT JMP2? POP2
|
DUP2 LDR #0d NEQ ,$no-return ROT JMP2? POP2
|
||||||
~textarea.x1 =dev/sprite.x
|
~textarea.x1 =Sprite.x
|
||||||
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
( decr ) ~dev/sprite.x #0008 SUB2 =dev/sprite.x
|
( decr ) ~Sprite.x #0008 SUB2 =Sprite.x
|
||||||
$no-return
|
$no-return
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
|
@ -129,43 +120,43 @@ RTS
|
||||||
@do-textarea
|
@do-textarea
|
||||||
|
|
||||||
( ,blink-cursor JSR2 )
|
( ,blink-cursor JSR2 )
|
||||||
,do-textarea-end ~dev/key #00 EQU JMP2? POP2 ( skip on no key )
|
,do-textarea-end ~Keys #00 EQU JMP2? POP2 ( skip on no key )
|
||||||
( backspace )
|
( backspace )
|
||||||
,any-key ~dev/key #08 NEQ JMP2? POP2
|
,any-key ~Keys #08 NEQ JMP2? POP2
|
||||||
,input-end ~textarea.cursor #00 EQU JMP2? POP2
|
,input-end ~textarea.cursor #00 EQU JMP2? POP2
|
||||||
( decr ) ~textarea.cursor #01 SUB =textarea.cursor
|
( decr ) ~textarea.cursor #01 SUB =textarea.cursor
|
||||||
#00 ~textarea.addr #00 ~textarea.cursor ADD2 STR
|
#00 ~textarea.addr #00 ~textarea.cursor ADD2 STR
|
||||||
,input-end JMP2
|
,input-end JMP2
|
||||||
@any-key
|
@any-key
|
||||||
~dev/key ~textarea.addr #00 ~textarea.cursor ADD2 STR
|
~Keys ~textarea.addr #00 ~textarea.cursor ADD2 STR
|
||||||
( incr ) ~textarea.cursor #01 ADD =textarea.cursor
|
( incr ) ~textarea.cursor #01 ADD =textarea.cursor
|
||||||
@input-end
|
@input-end
|
||||||
#00 =dev/key ( release key )
|
#00 =Keys ( release key )
|
||||||
,redraw JSR2
|
,redraw JSR2
|
||||||
( add cursor )
|
( add cursor )
|
||||||
,cursor =dev/sprite.addr
|
,cursor =Sprite.addr
|
||||||
#06 =dev/sprite.color
|
#06 =Sprite.color
|
||||||
@do-textarea-end
|
@do-textarea-end
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@do-cursor
|
@do-cursor
|
||||||
|
|
||||||
,skip-drag ~dev/mouse.state #01 NEQ JMP2? POP2
|
,skip-drag ~Mouse.state #01 NEQ JMP2? POP2
|
||||||
~mouse.x =textarea.x1 ~mouse.y =textarea.y1
|
~mouse.x =textarea.x1 ~mouse.y =textarea.y1
|
||||||
,redraw-window JSR2
|
,redraw-window JSR2
|
||||||
,redraw JSR2
|
,redraw JSR2
|
||||||
@skip-drag
|
@skip-drag
|
||||||
|
|
||||||
~mouse.x ~dev/mouse.x NEQU2
|
~mouse.x ~Mouse.x NEQU2
|
||||||
~mouse.y ~dev/mouse.y NEQU2
|
~mouse.y ~Mouse.y NEQU2
|
||||||
|
|
||||||
#0000 EQU2 RTS? ( Return if unchanged )
|
#0000 EQU2 RTS? ( Return if unchanged )
|
||||||
|
|
||||||
( clear last cursor )
|
( clear last cursor )
|
||||||
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
||||||
( record mouse positions )
|
( record mouse positions )
|
||||||
~dev/mouse.x =mouse.x ~dev/mouse.y =mouse.y
|
~Mouse.x =mouse.x ~Mouse.y =mouse.y
|
||||||
#12 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
#12 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,10 +164,10 @@ RTS
|
||||||
|
|
||||||
@draw-sprite
|
@draw-sprite
|
||||||
|
|
||||||
=dev/sprite.y
|
=Sprite.y
|
||||||
=dev/sprite.x
|
=Sprite.x
|
||||||
=dev/sprite.addr
|
=Sprite.addr
|
||||||
=dev/sprite.color
|
=Sprite.color
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -224,10 +215,10 @@ RTS
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF40 ;dev/key Keyboard
|
|FF40 ;Keys { key 1 }
|
||||||
|FF50 ;dev/mouse Mouse
|
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ f0ff f000 f00f ] ( palette )
|
|FFF8 [ f0ff f000 f00f ] ( palette )
|
||||||
|
|
|
@ -1,53 +1,46 @@
|
||||||
( dev/mouse )
|
( Mouse )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
;label { x 2 y 2 color 1 addr 2 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
;cat { x 2 y 2 }
|
||||||
&Mouse { x 2 y 2 state 1 chord 1 }
|
;pointer { x 2 y 2 }
|
||||||
|
;color { byte 1 }
|
||||||
&Label2d { x 2 y 2 color 1 addr 2 }
|
;timer { byte 1 }
|
||||||
&Point2d { x 2 y 2 }
|
|
||||||
|
|
||||||
;label Label2d
|
|
||||||
;cat Point2d
|
|
||||||
;mouse Point2d
|
|
||||||
;color 1
|
|
||||||
;timer 1
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
( position cat )
|
( position cat )
|
||||||
~dev/screen.width #0002 DIV2 =cat.x
|
~Screen.width #0002 DIV2 =cat.x
|
||||||
~dev/screen.height #0038 SUB2 =cat.y
|
~Screen.height #0038 SUB2 =cat.y
|
||||||
#01 =color
|
#01 =color
|
||||||
( draw polycat )
|
( draw polycat )
|
||||||
,draw-polycat JSR2
|
,draw-polycat JSR2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|0200 @FRAME
|
@FRAME
|
||||||
|
|
||||||
,draw-cursor JSR2
|
,draw-cursor JSR2
|
||||||
|
|
||||||
( reset timer -> move cat tail )
|
( reset timer -> move cat tail )
|
||||||
,no-click ~dev/mouse.state #00 EQU JMP2? POP2
|
,no-click ~Mouse.state #00 EQU JMP2? POP2
|
||||||
#50 =timer
|
#50 =timer
|
||||||
@no-click
|
@no-click
|
||||||
( detect click )
|
( detect click )
|
||||||
,no-click12 ~dev/mouse.state #11 NEQ JMP2? POP2
|
,no-click12 ~Mouse.state #11 NEQ JMP2? POP2
|
||||||
#0058 #0040 #01 ,mouse12_text ,draw-label JSR2
|
#0058 #0040 #01 ,mouse12_text ,draw-label JSR2
|
||||||
#10 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
#10 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2
|
||||||
~color ,mouse12_icn #0048 #0040 ,draw-sprite JSR2
|
~color ,mouse12_icn #0048 #0040 ,draw-sprite JSR2
|
||||||
,end-click JMP2
|
,end-click JMP2
|
||||||
@no-click12
|
@no-click12
|
||||||
,no-click1 ~dev/mouse.state #01 NEQ JMP2? POP2
|
,no-click1 ~Mouse.state #01 NEQ JMP2? POP2
|
||||||
#0058 #0040 #01 ,mouse1_text ,draw-label JSR2
|
#0058 #0040 #01 ,mouse1_text ,draw-label JSR2
|
||||||
#12 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
#12 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2
|
||||||
~color ,mouse1_icn #0048 #0040 ,draw-sprite JSR2
|
~color ,mouse1_icn #0048 #0040 ,draw-sprite JSR2
|
||||||
,end-click JMP2
|
,end-click JMP2
|
||||||
@no-click1
|
@no-click1
|
||||||
,no-click2 ~dev/mouse.state #10 NEQ JMP2? POP2
|
,no-click2 ~Mouse.state #10 NEQ JMP2? POP2
|
||||||
#0058 #0040 #01 ,mouse2_text ,draw-label JSR2
|
#0058 #0040 #01 ,mouse2_text ,draw-label JSR2
|
||||||
#13 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
#13 ,cursor_icn ~pointer.x ~pointer.y ,draw-sprite JSR2
|
||||||
~color ,mouse2_icn #0048 #0040 ,draw-sprite JSR2
|
~color ,mouse2_icn #0048 #0040 ,draw-sprite JSR2
|
||||||
,end-click JMP2
|
,end-click JMP2
|
||||||
@no-click2
|
@no-click2
|
||||||
|
@ -64,16 +57,20 @@ BRK
|
||||||
|
|
||||||
@draw-cursor
|
@draw-cursor
|
||||||
|
|
||||||
~mouse.x ~dev/mouse.x NEQU2
|
|
||||||
~mouse.y ~dev/mouse.y NEQU2
|
|
||||||
|
|
||||||
#0000 EQU2 RTS? ( Return if unchanged )
|
|
||||||
|
|
||||||
( clear last cursor )
|
( clear last cursor )
|
||||||
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
,clear_icn =Sprite.addr
|
||||||
( record mouse positions )
|
~pointer.x =Sprite.x
|
||||||
~dev/mouse.x =mouse.x ~dev/mouse.y =mouse.y
|
~pointer.y =Sprite.y
|
||||||
#11 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
#10 =Sprite.color
|
||||||
|
|
||||||
|
( record pointer positions )
|
||||||
|
~Mouse.x =pointer.x ~Mouse.y =pointer.y
|
||||||
|
|
||||||
|
( draw new cursor )
|
||||||
|
,cursor_icn =Sprite.addr
|
||||||
|
~pointer.x =Sprite.x
|
||||||
|
~pointer.y =Sprite.y
|
||||||
|
#11 =Sprite.color
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -104,8 +101,8 @@ RTS
|
||||||
,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2
|
,polycat #00b0 ADD2 ~cat.x #0008 ADD2 ~cat.y #0010 ADD2 ,draw-sprite-chr JSR2
|
||||||
@animate-polycat-tail-next2
|
@animate-polycat-tail-next2
|
||||||
( look-at )
|
( look-at )
|
||||||
~mouse.x ~cat.x #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP2? POP2
|
~pointer.x ~cat.x #0008 ADD2 GTH2 ,animate-polycat-right ROT JMP2? POP2
|
||||||
~mouse.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP2? POP2
|
~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-left-down ROT JMP2? POP2
|
||||||
,polycat #0040 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
,polycat #0040 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
||||||
,polycat #0050 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
,polycat #0050 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
||||||
RTS
|
RTS
|
||||||
|
@ -114,7 +111,7 @@ RTS
|
||||||
,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
,polycat #0030 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
||||||
RTS
|
RTS
|
||||||
@animate-polycat-right
|
@animate-polycat-right
|
||||||
~mouse.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP2? POP2
|
~pointer.y ~cat.y #0008 ADD2 GTH2 ,animate-polycat-right-down ROT JMP2? POP2
|
||||||
,polycat #0060 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
,polycat #0060 ADD2 ~cat.x ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
||||||
,polycat #0070 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
,polycat #0070 ADD2 ~cat.x #0008 ADD2 ~cat.y #0008 ADD2 ,draw-sprite-chr JSR2
|
||||||
RTS
|
RTS
|
||||||
|
@ -127,12 +124,12 @@ RTS
|
||||||
|
|
||||||
@draw-label ( x y color addr )
|
@draw-label ( x y color addr )
|
||||||
|
|
||||||
( load ) =label.addr =label.color =dev/sprite.y =dev/sprite.x
|
( load ) =label.addr =label.color =Sprite.y =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
$loop
|
$loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =dev/sprite.addr ~label.color =dev/sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 #0001 ADD2 LDR #00 NEQ ,$loop ROT JMP2? POP2
|
DUP2 #0001 ADD2 LDR #00 NEQ ,$loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
|
@ -140,19 +137,19 @@ RTS
|
||||||
|
|
||||||
@draw-sprite
|
@draw-sprite
|
||||||
|
|
||||||
=dev/sprite.y
|
=Sprite.y
|
||||||
=dev/sprite.x
|
=Sprite.x
|
||||||
=dev/sprite.addr
|
=Sprite.addr
|
||||||
=dev/sprite.color
|
=Sprite.color
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-sprite-chr
|
@draw-sprite-chr
|
||||||
|
|
||||||
=dev/sprite.y
|
=Sprite.y
|
||||||
=dev/sprite.x
|
=Sprite.x
|
||||||
=dev/sprite.addr
|
=Sprite.addr
|
||||||
#20 =dev/sprite.color
|
#20 =Sprite.color
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -223,9 +220,9 @@ RTS
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF50 ;dev/mouse Mouse
|
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ 0f85 0fd5 0fb5 ] ( palette )
|
|FFF8 [ 0f85 0fd5 0fb5 ] ( palette )
|
||||||
|
|
|
@ -1,76 +1,65 @@
|
||||||
( dev/screen )
|
( Screen )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
;center { x 2 y 2 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
;timer { byte 1 }
|
||||||
|
;i { byte 1 }
|
||||||
;timer 1
|
|
||||||
;centerx 2 ;centery 2 ;i 2 ;j 1
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
( find screen center )
|
( find screen center )
|
||||||
~dev/screen.width #0002 DIV2 =centerx
|
~Screen.width #0002 DIV2 =center.x
|
||||||
~dev/screen.height #0002 DIV2 =centery
|
~Screen.height #0002 DIV2 =center.y
|
||||||
|
|
||||||
( draw hor line )
|
( draw hor line )
|
||||||
#0000 =i
|
#0000 =Screen.x ~center.y =Screen.y
|
||||||
~centery =dev/screen.y
|
$draw-hor
|
||||||
@draw-hor
|
( draw ) #01 =Screen.color
|
||||||
#03 ~i =dev/screen.x =dev/screen.color
|
( incr ) ~Screen.x #0002 ADD2 =Screen.x
|
||||||
~i #0002 ADD2 =i ( increment )
|
,$draw-hor ~Screen.x ~Screen.width LTH2 JMP2? POP2
|
||||||
~i ~dev/screen.width LTH2 ,draw-hor ROT JMP2? POP2
|
|
||||||
|
|
||||||
( draw ver line )
|
( draw ver line )
|
||||||
#0000 =i
|
~center.x =Screen.x #0000 =Screen.y
|
||||||
~centerx =dev/screen.x
|
$draw-ver
|
||||||
@draw-ver
|
( draw ) #02 =Screen.color
|
||||||
#03 ~i =dev/screen.y =dev/screen.color
|
( incr ) ~Screen.y #0002 ADD2 =Screen.y
|
||||||
~i #0002 ADD2 =i ( increment )
|
,$draw-ver ~Screen.y ~Screen.height LTH2 JMP2? POP2
|
||||||
~i ~dev/screen.width LTH2 ,draw-ver ROT JMP2? POP2
|
|
||||||
|
|
||||||
( draw blending modes )
|
( draw blending modes )
|
||||||
@draw-blends
|
#00 =i
|
||||||
~j ,icon #00 ~j #0008 MUL2 ~dev/screen.height #0010 SUB2 ,draw-sprite JSR2
|
#0020 =Sprite.x #0020 =Sprite.y ,icon =Sprite.addr
|
||||||
~j #01 ADD =j
|
$draw-blends
|
||||||
~j #10 LTH ,draw-blends ROT JMP2? POP2
|
( draw ) #00 ~i ADD =Sprite.color
|
||||||
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
( draw pixel in the middle )
|
( incr ) ~i #01 ADD =i
|
||||||
#01 ~centerx ~centery =dev/screen.y =dev/screen.x =dev/screen.color
|
,$draw-blends ~i #10 LTH JMP2? POP2
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
@draw-sprite
|
@FRAME
|
||||||
=dev/sprite.y
|
|
||||||
=dev/sprite.x
|
|
||||||
=dev/sprite.addr
|
|
||||||
=dev/sprite.color
|
|
||||||
RTS
|
|
||||||
|
|
||||||
@icon [ 3c7e e7c3 c3e7 7e3c ]
|
|
||||||
|
|
||||||
|c000 @FRAME
|
|
||||||
|
|
||||||
( update colors every 40 frames )
|
( update colors every 40 frames )
|
||||||
~timer #40 NEQ ,skip1 ROT JMP2? POP2
|
~timer #40 NEQ ,skip1 ROT JMP2? POP2
|
||||||
#0fac =fffa #f0bb =fffc #f053 =fff8
|
#0fac #fffa STR2 #f0bb #fffc STR2 #f053 #fff8 STR2
|
||||||
@skip1
|
@skip1
|
||||||
~timer #80 NEQ ,skip2 ROT JMP2? POP2
|
~timer #80 NEQ ,skip2 ROT JMP2? POP2
|
||||||
#00fc =fffc #f0bb =fff8 #f053 =fffa
|
#00fc #fffc STR2 #f0bb #fff8 STR2 #f053 #fffa STR2
|
||||||
@skip2
|
@skip2
|
||||||
~timer #c0 NEQ ,skip3 ROT JMP2? POP2
|
~timer #c0 NEQ ,skip3 ROT JMP2? POP2
|
||||||
#000f =fff8 #0f0f =fffa #ff00 =fffc
|
#000f #fff8 STR2 #0f0f #fffa STR2 #ff00 #fffc STR2
|
||||||
@skip3
|
@skip3
|
||||||
~timer #00 NEQ ,skip4 ROT JMP2? POP2
|
~timer #00 NEQ ,skip4 ROT JMP2? POP2
|
||||||
#f0ac =fff8 #f0bb =fffa #f053 =fffc
|
#f0ac #fff8 STR2 #f0bb #fffa STR2 #f053 #fffc STR2
|
||||||
@skip4
|
@skip4
|
||||||
~timer #01 ADD =timer
|
~timer #01 ADD =timer
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@icon [ 3c7e e7c3 c3e7 7e3c ]
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ f0ac f0bb f053 ] ( palette )
|
|FFF8 [ f0ac f0bb f053 ] ( palette )
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
( draw routines )
|
( draw routines )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
;color { byte 1 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
;pointer { x 2 y 2 sprite 2 }
|
||||||
&Mouse { x 2 y 2 state 1 chord 1 }
|
;rect { x1 2 y1 2 x2 2 y2 2 }
|
||||||
|
;r1 { x1 2 y1 2 x2 2 y2 2 }
|
||||||
&Rect2d { x1 2 y1 2 x2 2 y2 2 }
|
;r2 { x1 2 y1 2 x2 2 y2 2 }
|
||||||
&Point2d { x 2 y 2 }
|
;r3 { x1 2 y1 2 x2 2 y2 2 }
|
||||||
|
|
||||||
;color 1
|
|
||||||
;cursor 2
|
|
||||||
;mouse Point2d
|
|
||||||
;rect Rect2d ;r1 Rect2d ;r2 Rect2d ;r3 Rect2d
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
|
@ -20,32 +15,37 @@
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|0200 @FRAME
|
@FRAME
|
||||||
|
|
||||||
,pointer_icn =cursor
|
~pointer.x ~Mouse.x NEQU2
|
||||||
|
~pointer.y ~Mouse.y NEQU2
|
||||||
|
|
||||||
|
#0000 EQU2 BRK? ( Return if unchanged )
|
||||||
|
|
||||||
|
,pointer_icn =pointer.sprite
|
||||||
|
|
||||||
#01 =color
|
#01 =color
|
||||||
( matrix comparison )
|
( matrix comparison )
|
||||||
~dev/mouse.x ~r1.x1 GTH2 ~dev/mouse.x ~r1.x2 LTH2 #0101 EQU2
|
~Mouse.x ~r1.x1 GTH2 ~Mouse.x ~r1.x2 LTH2 #0101 EQU2
|
||||||
~dev/mouse.y ~r1.y1 GTH2 ~dev/mouse.y ~r1.y2 LTH2 #0101 EQU2
|
~Mouse.y ~r1.y1 GTH2 ~Mouse.y ~r1.y2 LTH2 #0101 EQU2
|
||||||
#0101 NEQ2 ,draw1 ROT JMP2? POP2 #02 =color ,hand_icn =cursor
|
#0101 NEQ2 ,$draw1 ROT JMP2? POP2 #02 =color ,hand_icn =pointer.sprite
|
||||||
@draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR2
|
$draw1 ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR2
|
||||||
|
|
||||||
#01 =color
|
#01 =color
|
||||||
( 2-step comparison )
|
( 2-step comparison )
|
||||||
,draw2 ~dev/mouse.x ~r2.x1 GTH2 ~dev/mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP2? POP2
|
,$draw2 ~Mouse.x ~r2.x1 GTH2 ~Mouse.x ~r2.x2 LTH2 #0101 NEQ2 JMP2? POP2
|
||||||
,draw2 ~dev/mouse.y ~r2.y1 GTH2 ~dev/mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP2? POP2
|
,$draw2 ~Mouse.y ~r2.y1 GTH2 ~Mouse.y ~r2.y2 LTH2 #0101 NEQ2 JMP2? POP2
|
||||||
#03 =color ,hand_icn =cursor
|
#03 =color ,hand_icn =pointer.sprite
|
||||||
@draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR2
|
$draw2 ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR2
|
||||||
|
|
||||||
#01 =color
|
#01 =color
|
||||||
( 4-step comparison )
|
( 4-step comparison )
|
||||||
,draw3 ~dev/mouse.x ~r3.x1 LTH2 JMP2? POP2
|
,$draw3 ~Mouse.x ~r3.x1 LTH2 JMP2? POP2
|
||||||
,draw3 ~dev/mouse.x ~r3.x2 GTH2 JMP2? POP2
|
,$draw3 ~Mouse.x ~r3.x2 GTH2 JMP2? POP2
|
||||||
,draw3 ~dev/mouse.y ~r3.y1 LTH2 JMP2? POP2
|
,$draw3 ~Mouse.y ~r3.y1 LTH2 JMP2? POP2
|
||||||
,draw3 ~dev/mouse.y ~r3.y2 GTH2 JMP2? POP2
|
,$draw3 ~Mouse.y ~r3.y2 GTH2 JMP2? POP2
|
||||||
#02 =color ,hand_icn =cursor
|
#02 =color ,hand_icn =pointer.sprite
|
||||||
@draw3 ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR2
|
$draw3 ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR2
|
||||||
|
|
||||||
,draw-cursor JSR2
|
,draw-cursor JSR2
|
||||||
|
|
||||||
|
@ -53,42 +53,37 @@ BRK
|
||||||
|
|
||||||
@draw-cursor
|
@draw-cursor
|
||||||
|
|
||||||
~mouse.x ~dev/mouse.x NEQU2
|
|
||||||
~mouse.y ~dev/mouse.y NEQU2
|
|
||||||
|
|
||||||
#0000 EQU2 RTS? ( Return if unchanged )
|
|
||||||
|
|
||||||
( clear last cursor )
|
( clear last cursor )
|
||||||
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
,clear_icn =Sprite.addr
|
||||||
( record mouse positions )
|
~pointer.x =Sprite.x
|
||||||
~dev/mouse.x =mouse.x ~dev/mouse.y =mouse.y
|
~pointer.y =Sprite.y
|
||||||
#11 ~cursor ~mouse.x ~mouse.y ,draw-sprite JSR2
|
#10 =Sprite.color
|
||||||
|
|
||||||
|
( record pointer positions )
|
||||||
|
~Mouse.x =pointer.x ~Mouse.y =pointer.y
|
||||||
|
|
||||||
|
( draw new cursor )
|
||||||
|
~pointer.sprite =Sprite.addr
|
||||||
|
~pointer.x =Sprite.x
|
||||||
|
~pointer.y =Sprite.y
|
||||||
|
#11 =Sprite.color
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@line-rect ( x1 y1 x2 y2 color )
|
@line-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
@line-rect-hor
|
@line-rect-hor
|
||||||
( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
( draw ) ~rect.y1 =dev/screen.y ~color =dev/screen.color
|
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
||||||
( draw ) ~rect.y2 =dev/screen.y ~color =dev/screen.color
|
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
||||||
,line-rect-hor ~dev/screen.x ~rect.x2 LTH2 JMP2? POP2
|
,line-rect-hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
~rect.y1 =dev/screen.y
|
~rect.y1 =Screen.y
|
||||||
@line-rect-ver
|
@line-rect-ver
|
||||||
( draw ) ~rect.x1 =dev/screen.x ~color =dev/screen.color
|
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
||||||
( draw ) ~rect.x2 =dev/screen.x ~color =dev/screen.color
|
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
||||||
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,line-rect-ver ~dev/screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
,line-rect-ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
|
||||||
|
|
||||||
@draw-sprite
|
|
||||||
|
|
||||||
=dev/sprite.y
|
|
||||||
=dev/sprite.x
|
|
||||||
=dev/sprite.addr
|
|
||||||
=dev/sprite.color
|
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -98,9 +93,9 @@ RTS
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF50 ;dev/mouse Mouse
|
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
|
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
|
|
@ -1,30 +1,22 @@
|
||||||
( draw routines )
|
( draw routines )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
;label { x 2 y 2 color 1 addr 2 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
;rect { x1 2 y1 2 x2 2 y2 2 }
|
||||||
|
;center { x 2 y 2 }
|
||||||
&Label2d { x 2 y 2 color 1 addr 2 }
|
;i { short 2 }
|
||||||
&Rect2d { x1 2 y1 2 x2 2 y2 2 }
|
|
||||||
&Point2d { x 2 y 2 }
|
|
||||||
|
|
||||||
;label Label2d
|
|
||||||
;rect Rect2d
|
|
||||||
;center Point2d
|
|
||||||
;i 2
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
( find screen center )
|
( find screen center )
|
||||||
~dev/screen.width #0002 DIV2 =center.x
|
~Screen.width #0002 DIV2 =center.x
|
||||||
~dev/screen.height #0002 DIV2 =center.y
|
~Screen.height #0002 DIV2 =center.y
|
||||||
|
|
||||||
( draw ver line )
|
( draw ver line )
|
||||||
#0000 =i
|
~center.x =Screen.x #0000 =Screen.y
|
||||||
~center.x =dev/screen.x
|
$draw-ver
|
||||||
@draw-ver
|
( draw ) #02 =Screen.color
|
||||||
#03 ~i =dev/screen.y =dev/screen.color
|
( incr ) ~Screen.y #0002 ADD2 =Screen.y
|
||||||
~i #0002 ADD2 =i ( increment )
|
,$draw-ver ~Screen.y ~Screen.height LTH2 JMP2? POP2
|
||||||
~i ~dev/screen.width LTH2 ,draw-ver ROT JMP2? POP2
|
|
||||||
|
|
||||||
~center.x ~center.y #0010 SUB2 #0c ,text1 ,draw-label-left JSR2
|
~center.x ~center.y #0010 SUB2 #0c ,text1 ,draw-label-left JSR2
|
||||||
~center.x ~center.y #0c ,text2 ,draw-label-middle JSR2
|
~center.x ~center.y #0c ,text2 ,draw-label-middle JSR2
|
||||||
|
@ -36,12 +28,12 @@ BRK
|
||||||
|
|
||||||
@draw-label-left ( x y color addr )
|
@draw-label-left ( x y color addr )
|
||||||
|
|
||||||
( load ) =label.addr =label.color =dev/sprite.y =dev/sprite.x
|
( load ) =label.addr =label.color =Sprite.y =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
@draw-label-left-loop
|
@draw-label-left-loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =dev/sprite.addr ~label.color =dev/sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ,draw-label-left-loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ,draw-label-left-loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
|
@ -49,13 +41,13 @@ RTS
|
||||||
|
|
||||||
@draw-label-middle ( x y color addr )
|
@draw-label-middle ( x y color addr )
|
||||||
|
|
||||||
( load ) =label.addr =label.color =dev/sprite.y
|
( load ) =label.addr =label.color =Sprite.y
|
||||||
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =dev/sprite.x
|
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 #0002 DIV2 SUB2 =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
@draw-label-middle-loop
|
@draw-label-middle-loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =dev/sprite.addr ~label.color =dev/sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ,draw-label-middle-loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ,draw-label-middle-loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
|
@ -63,13 +55,13 @@ RTS
|
||||||
|
|
||||||
@draw-label-right ( x y color addr )
|
@draw-label-right ( x y color addr )
|
||||||
|
|
||||||
( load ) =label.addr =label.color =dev/sprite.y
|
( load ) =label.addr =label.color =Sprite.y
|
||||||
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =dev/sprite.x
|
( align ) ~label.addr ,get-text-length JSR2 #0008 MUL2 SUB2 #0008 SUB2 =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
@draw-label-right-loop
|
@draw-label-right-loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =dev/sprite.addr ~label.color =dev/sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ,draw-label-right-loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ,draw-label-right-loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
|
@ -130,8 +122,8 @@ RTS
|
||||||
|c000 @FRAME BRK
|
|c000 @FRAME BRK
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
|
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
|
|
@ -1,11 +1,6 @@
|
||||||
( gui/picture )
|
( gui/picture )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
;pict { x 2 y 2 width 2 height 2 color 1 addr 2 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|
||||||
|
|
||||||
&Picture2d { x 2 y 2 width 2 height 2 color 1 addr 2 }
|
|
||||||
|
|
||||||
;pict Picture2d
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
|
@ -17,16 +12,16 @@ BRK
|
||||||
|
|
||||||
@draw-picture ( x y width height color addr )
|
@draw-picture ( x y width height color addr )
|
||||||
|
|
||||||
DUP2 =dev/sprite.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =dev/sprite.y =pict.y =pict.x
|
DUP2 =Sprite.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =Sprite.y =pict.y =pict.x
|
||||||
@draw-picture-ver
|
$ver
|
||||||
~pict.x =dev/sprite.x
|
~pict.x =Sprite.x
|
||||||
@draw-picture-hor
|
$hor
|
||||||
( draw ) ~pict.color =dev/sprite.color
|
( draw ) ~pict.color =Sprite.color
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
( incr ) ~dev/sprite.addr #0008 ADD2 =dev/sprite.addr
|
( incr ) ~Sprite.addr #0008 ADD2 =Sprite.addr
|
||||||
,draw-picture-hor ~dev/sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? POP2
|
,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? POP2
|
||||||
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
,draw-picture-ver ~dev/sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2
|
,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -308,8 +303,7 @@ RTS
|
||||||
|c000 @FRAME BRK
|
|c000 @FRAME BRK
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ 0ffc 0f0b 0f03 ] ( palette )
|
|FFF8 [ 0ffc 0f0b 0f03 ] ( palette )
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
( draw routines )
|
( draw routines )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
;label { x 2 y 2 color 1 addr 2 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
;pict { x 2 y 2 width 2 height 2 color 1 addr 2 }
|
||||||
|
;rect { x1 2 y1 2 x2 2 y2 2 }
|
||||||
&Label2d { x 2 y 2 color 1 addr 2 }
|
;color { byte 1 }
|
||||||
&Picture2d { x 2 y 2 width 2 height 2 color 1 addr 2 }
|
|
||||||
&Rect2d { x1 2 y1 2 x2 2 y2 2 }
|
|
||||||
|
|
||||||
;label Label2d
|
|
||||||
;pict Picture2d
|
|
||||||
;rect Rect2d
|
|
||||||
|
|
||||||
;color 1
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
|
@ -36,58 +28,58 @@ BRK
|
||||||
|
|
||||||
@line-rect ( x1 y1 x2 y2 color )
|
@line-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
@line-rect-hor
|
$hor
|
||||||
( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
( draw ) ~rect.y1 =dev/screen.y ~color =dev/screen.color
|
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
||||||
( draw ) ~rect.y2 =dev/screen.y ~color =dev/screen.color
|
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
||||||
,line-rect-hor ~dev/screen.x ~rect.x2 LTH2 JMP2? POP2
|
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
~rect.y1 =dev/screen.y
|
~rect.y1 =Screen.y
|
||||||
@line-rect-ver
|
$ver
|
||||||
( draw ) ~rect.x1 =dev/screen.x ~color =dev/screen.color
|
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
||||||
( draw ) ~rect.x2 =dev/screen.x ~color =dev/screen.color
|
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
||||||
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,line-rect-ver ~dev/screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
,$ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@fill-rect ( x1 y1 x2 y2 color )
|
@fill-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
@fill-rect-ver
|
$ver
|
||||||
~rect.x1 =dev/screen.x
|
~rect.x1 =Screen.x
|
||||||
@fill-rect-hor
|
$hor
|
||||||
( draw ) ~color =dev/screen.color
|
( draw ) ~color =Screen.color
|
||||||
( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
,fill-rect-hor ~dev/screen.x ~rect.x2 LTH2 JMP2? POP2
|
,$hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,fill-rect-ver ~dev/screen.y ~rect.y2 LTH2 JMP2? POP2
|
,$ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-picture ( x y width height color addr )
|
@draw-picture ( x y width height color addr )
|
||||||
|
|
||||||
( load ) DUP2 =dev/sprite.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =dev/sprite.y =pict.y =pict.x
|
( load ) DUP2 =Sprite.addr =pict.addr =pict.color =pict.height =pict.width DUP2 =Sprite.y =pict.y =pict.x
|
||||||
@draw-picture-ver
|
$ver
|
||||||
~pict.x =dev/sprite.x
|
~pict.x =Sprite.x
|
||||||
@draw-picture-hor
|
$hor
|
||||||
( draw ) ~pict.color =dev/sprite.color
|
( draw ) ~pict.color =Sprite.color
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
( incr ) ~dev/sprite.addr #0008 ADD2 =dev/sprite.addr
|
( incr ) ~Sprite.addr #0008 ADD2 =Sprite.addr
|
||||||
,draw-picture-hor ~dev/sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? POP2
|
,$hor ~Sprite.x ~pict.width ~pict.x ADD2 LTH2 JMP2? POP2
|
||||||
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
,draw-picture-ver ~dev/sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2
|
,$ver ~Sprite.y ~pict.height ~pict.y ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-label ( x y color addr )
|
@draw-label ( x y color addr )
|
||||||
|
|
||||||
( load ) =label.addr =label.color =dev/sprite.y =dev/sprite.x ~label.addr
|
( load ) =label.addr =label.color =Sprite.y =Sprite.x ~label.addr
|
||||||
@draw-label-loop
|
$loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =dev/sprite.addr ~label.color =dev/sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 LDR #00 NEQ ,draw-label-loop ROT JMP2? POP2
|
DUP2 LDR #00 NEQ ,$loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
@ -145,8 +137,8 @@ RTS
|
||||||
|c000 @FRAME BRK
|
|c000 @FRAME BRK
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
|
|FFF8 [ 0f0f 0fff 0ff0 ] ( palette )
|
|
@ -1,25 +1,13 @@
|
||||||
( app/hex )
|
( app/hex )
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
;label { x 2 y 2 color 1 addr 2 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
;pixel { x 1 y 1 }
|
||||||
&Controller { buttons 1 }
|
;window { x1 2 y1 2 x2 2 y2 2 }
|
||||||
&Mouse { x 2 y 2 state 1 chord 1 }
|
;pointer { x 2 y 2 sprite 2 }
|
||||||
|
;editor { x1 2 y1 2 addr 2 }
|
||||||
&Label2d { x 2 y 2 color 1 addr 2 }
|
;rect { x1 2 y1 2 x2 2 y2 2 }
|
||||||
&Point2d { x 2 y 2 }
|
;color { byte 1 }
|
||||||
&Rect2d { x1 2 y1 2 x2 2 y2 2 }
|
;addr { short 2 }
|
||||||
&Point { x 1 y 1 }
|
|
||||||
&Editor { x1 2 y1 2 addr 2 }
|
|
||||||
|
|
||||||
;label Label2d
|
|
||||||
;pixel Point
|
|
||||||
;window Rect2d
|
|
||||||
;mouse Point2d
|
|
||||||
;editor Editor
|
|
||||||
;rect Rect2d
|
|
||||||
|
|
||||||
;color 1
|
|
||||||
;addr 2
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
|
@ -36,17 +24,22 @@
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|0200 @FRAME
|
@FRAME
|
||||||
|
|
||||||
,no-ctrl ~dev/ctrl.buttons #00 EQU JMP2? POP2
|
~pointer.x ~Mouse.x NEQU2
|
||||||
|
~pointer.y ~Mouse.y NEQU2
|
||||||
|
|
||||||
,no-ctrl-up ~dev/ctrl.buttons #10 EQU JMP2? POP2
|
#0000 EQU2 BRK? ( Return if unchanged )
|
||||||
|
|
||||||
|
,no-ctrl ~Controller.buttons #00 EQU JMP2? POP2
|
||||||
|
|
||||||
|
,no-ctrl-up ~Controller.buttons #10 EQU JMP2? POP2
|
||||||
~editor.addr #0001 ADD2 =editor.addr
|
~editor.addr #0001 ADD2 =editor.addr
|
||||||
,draw-window JSR2
|
,draw-window JSR2
|
||||||
,draw-editor JSR2
|
,draw-editor JSR2
|
||||||
@no-ctrl-up
|
@no-ctrl-up
|
||||||
|
|
||||||
,no-ctrl-down ~dev/ctrl.buttons #20 EQU JMP2? POP2
|
,no-ctrl-down ~Controller.buttons #20 EQU JMP2? POP2
|
||||||
~editor.addr #0001 SUB2 =editor.addr
|
~editor.addr #0001 SUB2 =editor.addr
|
||||||
,draw-window JSR2
|
,draw-window JSR2
|
||||||
,draw-editor JSR2
|
,draw-editor JSR2
|
||||||
|
@ -54,12 +47,12 @@ BRK
|
||||||
|
|
||||||
@no-ctrl
|
@no-ctrl
|
||||||
|
|
||||||
,no-click ~dev/mouse.state #00 EQU JMP2? POP2
|
,no-click ~Mouse.state #00 EQU JMP2? POP2
|
||||||
|
|
||||||
( load ) ~editor.addr ~dev/mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 LDR
|
( load ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 LDR
|
||||||
( mask ) #01 #07 ~dev/mouse.x ~editor.x1 SUB2 #0008 DIV2 SWP POP SUB ROL
|
( mask ) #01 #07 ~Mouse.x ~editor.x1 SUB2 #0008 DIV2 SWP POP SUB ROL
|
||||||
XOR
|
XOR
|
||||||
( save ) ~editor.addr ~dev/mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 STR
|
( save ) ~editor.addr ~Mouse.y ~editor.y1 SUB2 #0008 DIV2 ADD2 STR
|
||||||
|
|
||||||
,draw-window JSR2
|
,draw-window JSR2
|
||||||
,draw-editor JSR2
|
,draw-editor JSR2
|
||||||
|
@ -72,7 +65,7 @@ BRK
|
||||||
|
|
||||||
@draw-window
|
@draw-window
|
||||||
|
|
||||||
( desktop ) #0000 #0000 ~dev/screen.width ~dev/screen.height #03 ~editor.addr ,tile-rect JSR2
|
( desktop ) #0000 #0000 ~Screen.width ~Screen.height #03 ~editor.addr ,tile-rect JSR2
|
||||||
( outline ) ~window.x1 #0001 SUB2 ~window.y1 #0001 SUB2 ~window.x2 ~window.y2 #01 ,line-rect JSR2
|
( outline ) ~window.x1 #0001 SUB2 ~window.y1 #0001 SUB2 ~window.x2 ~window.y2 #01 ,line-rect JSR2
|
||||||
( background ) ~window.x1 ~window.y1 ~window.x2 ~window.y2 #02 ,fill-rect JSR2
|
( background ) ~window.x1 ~window.y1 ~window.x2 ~window.y2 #02 ,fill-rect JSR2
|
||||||
( label ) ~window.x1 ~window.y1 #04 ,window_name ,draw-label-left JSR2
|
( label ) ~window.x1 ~window.y1 #04 ,window_name ,draw-label-left JSR2
|
||||||
|
@ -81,33 +74,33 @@ RTS
|
||||||
|
|
||||||
@draw-editor
|
@draw-editor
|
||||||
|
|
||||||
~editor.x1 =dev/sprite.x
|
~editor.x1 =Sprite.x
|
||||||
~editor.y1 =dev/sprite.y
|
~editor.y1 =Sprite.y
|
||||||
~editor.addr =dev/sprite.addr
|
~editor.addr =Sprite.addr
|
||||||
|
|
||||||
#00 =pixel.y
|
#00 =pixel.y
|
||||||
@redraw-ver
|
@redraw-ver
|
||||||
#00 =pixel.x
|
#00 =pixel.x
|
||||||
~editor.x1 =dev/sprite.x
|
~editor.x1 =Sprite.x
|
||||||
@redraw-hor
|
@redraw-hor
|
||||||
|
|
||||||
( get bit )
|
( get bit )
|
||||||
,cell0_icn #00
|
,cell0_icn #00
|
||||||
~editor.addr #00 ~pixel.y ADD2 LDR #07 ~pixel.x SUB ROR #01 AND ( get bit )
|
~editor.addr #00 ~pixel.y ADD2 LDR #07 ~pixel.x SUB ROR #01 AND ( get bit )
|
||||||
#0008 MUL2 ADD2 =dev/sprite.addr ( add *8 )
|
#0008 MUL2 ADD2 =Sprite.addr ( add *8 )
|
||||||
|
|
||||||
( draw ) #08 =dev/sprite.color
|
( draw ) #08 =Sprite.color
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
( incr ) ~pixel.x #01 ADD =pixel.x
|
( incr ) ~pixel.x #01 ADD =pixel.x
|
||||||
,redraw-hor ~dev/sprite.x ~editor.x1 #0040 ADD2 LTH2 JMP2? POP2
|
,redraw-hor ~Sprite.x ~editor.x1 #0040 ADD2 LTH2 JMP2? POP2
|
||||||
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
( incr ) ~pixel.y #01 ADD =pixel.y
|
( incr ) ~pixel.y #01 ADD =pixel.y
|
||||||
,redraw-ver ~dev/sprite.y ~editor.y1 #0040 ADD2 LTH2 JMP2? POP2
|
,redraw-ver ~Sprite.y ~editor.y1 #0040 ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
~editor.addr =dev/sprite.addr
|
~editor.addr =Sprite.addr
|
||||||
~window.y1 =dev/sprite.y
|
~window.y1 =Sprite.y
|
||||||
~window.x2 #0008 SUB2 =dev/sprite.x
|
~window.x2 #0008 SUB2 =Sprite.x
|
||||||
( draw ) #01 =dev/sprite.color
|
( draw ) #01 =Sprite.color
|
||||||
|
|
||||||
( TODO: Make a loop.. )
|
( TODO: Make a loop.. )
|
||||||
~window.x1 #0058 ADD2 ~window.y1 #0010 ADD2 #08 ~editor.addr ,draw-byte JSR2
|
~window.x1 #0058 ADD2 ~window.y1 #0010 ADD2 #08 ~editor.addr ,draw-byte JSR2
|
||||||
|
@ -123,12 +116,12 @@ RTS
|
||||||
|
|
||||||
@draw-label-left ( x y color addr )
|
@draw-label-left ( x y color addr )
|
||||||
|
|
||||||
( load ) =label.addr =label.color =dev/sprite.y =dev/sprite.x
|
( load ) =label.addr =label.color =Sprite.y =Sprite.x
|
||||||
~label.addr
|
~label.addr
|
||||||
@draw-label-left-loop
|
@draw-label-left-loop
|
||||||
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =dev/sprite.addr ~label.color =dev/sprite.color
|
( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =Sprite.addr ~label.color =Sprite.color
|
||||||
( incr ) #0001 ADD2
|
( incr ) #0001 ADD2
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
DUP2 #0001 ADD2 LDR #00 NEQ ,draw-label-left-loop ROT JMP2? POP2
|
DUP2 #0001 ADD2 LDR #00 NEQ ,draw-label-left-loop ROT JMP2? POP2
|
||||||
POP2
|
POP2
|
||||||
|
|
||||||
|
@ -136,80 +129,75 @@ RTS
|
||||||
|
|
||||||
@draw-byte ( x y color addr )
|
@draw-byte ( x y color addr )
|
||||||
|
|
||||||
( load ) =addr =color =dev/sprite.y =dev/sprite.x
|
( load ) =addr =color =Sprite.y =Sprite.x
|
||||||
,font_hex #00 ~addr LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr ~color =dev/sprite.color
|
,font_hex #00 ~addr LDR #f0 AND #04 ROR #08 MUL ADD2 =Sprite.addr ~color =Sprite.color
|
||||||
~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
,font_hex #00 ~addr LDR #0f AND #08 MUL ADD2 =dev/sprite.addr ~color =dev/sprite.color
|
,font_hex #00 ~addr LDR #0f AND #08 MUL ADD2 =Sprite.addr ~color =Sprite.color
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@fill-rect ( x1 y1 x2 y2 color )
|
@fill-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
@fill-rect-ver
|
@fill-rect-ver
|
||||||
~rect.x1 =dev/screen.x
|
~rect.x1 =Screen.x
|
||||||
@fill-rect-hor
|
@fill-rect-hor
|
||||||
( draw ) ~color =dev/screen.color
|
( draw ) ~color =Screen.color
|
||||||
( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
,fill-rect-hor ~dev/screen.x ~rect.x2 LTH2 JMP2? POP2
|
,fill-rect-hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,fill-rect-ver ~dev/screen.y ~rect.y2 LTH2 JMP2? POP2
|
,fill-rect-ver ~Screen.y ~rect.y2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@line-rect ( x1 y1 x2 y2 color )
|
@line-rect ( x1 y1 x2 y2 color )
|
||||||
|
|
||||||
( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1
|
( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
|
||||||
@line-rect-hor
|
@line-rect-hor
|
||||||
( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x
|
( incr ) ~Screen.x #0001 ADD2 =Screen.x
|
||||||
( draw ) ~rect.y1 =dev/screen.y ~color =dev/screen.color
|
( draw ) ~rect.y1 =Screen.y ~color =Screen.color
|
||||||
( draw ) ~rect.y2 =dev/screen.y ~color =dev/screen.color
|
( draw ) ~rect.y2 =Screen.y ~color =Screen.color
|
||||||
,line-rect-hor ~dev/screen.x ~rect.x2 LTH2 JMP2? POP2
|
,line-rect-hor ~Screen.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
~rect.y1 =dev/screen.y
|
~rect.y1 =Screen.y
|
||||||
@line-rect-ver
|
@line-rect-ver
|
||||||
( draw ) ~rect.x1 =dev/screen.x ~color =dev/screen.color
|
( draw ) ~rect.x1 =Screen.x ~color =Screen.color
|
||||||
( draw ) ~rect.x2 =dev/screen.x ~color =dev/screen.color
|
( draw ) ~rect.x2 =Screen.x ~color =Screen.color
|
||||||
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y
|
( incr ) ~Screen.y #0001 ADD2 =Screen.y
|
||||||
,line-rect-ver ~dev/screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
,line-rect-ver ~Screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@tile-rect ( x1 y1 x2 y2 color addr )
|
@tile-rect ( x1 y1 x2 y2 color addr )
|
||||||
|
|
||||||
=dev/sprite.addr =color =rect.y2 =rect.x2 DUP2 =dev/sprite.y =rect.y1 DUP2 =dev/sprite.x =rect.x1
|
=Sprite.addr =color =rect.y2 =rect.x2 DUP2 =Sprite.y =rect.y1 DUP2 =Sprite.x =rect.x1
|
||||||
|
|
||||||
@tile-rect-ver
|
@tile-rect-ver
|
||||||
~rect.x1 =dev/sprite.x
|
~rect.x1 =Sprite.x
|
||||||
@tile-rect-hor
|
@tile-rect-hor
|
||||||
( draw ) ~color =dev/sprite.color
|
( draw ) ~color =Sprite.color
|
||||||
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
|
( incr ) ~Sprite.x #0008 ADD2 =Sprite.x
|
||||||
,tile-rect-hor ~dev/sprite.x ~rect.x2 LTH2 JMP2? POP2
|
,tile-rect-hor ~Sprite.x ~rect.x2 LTH2 JMP2? POP2
|
||||||
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y
|
( incr ) ~Sprite.y #0008 ADD2 =Sprite.y
|
||||||
,tile-rect-ver ~dev/sprite.y ~rect.y2 LTH2 JMP2? POP2
|
,tile-rect-ver ~Sprite.y ~rect.y2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-cursor
|
@draw-cursor
|
||||||
|
|
||||||
~mouse.x ~dev/mouse.x NEQU2
|
|
||||||
~mouse.y ~dev/mouse.y NEQU2
|
|
||||||
|
|
||||||
#0000 EQU2 RTS? ( Return if unchanged )
|
|
||||||
|
|
||||||
( clear last cursor )
|
( clear last cursor )
|
||||||
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
,clear_icn =Sprite.addr
|
||||||
( record mouse positions )
|
~pointer.x =Sprite.x
|
||||||
~dev/mouse.x =mouse.x ~dev/mouse.y =mouse.y
|
~pointer.y =Sprite.y
|
||||||
#13 ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR2
|
#10 =Sprite.color
|
||||||
|
|
||||||
RTS
|
( record pointer positions )
|
||||||
|
~Mouse.x =pointer.x ~Mouse.y =pointer.y
|
||||||
|
|
||||||
@draw-sprite
|
( draw new cursor )
|
||||||
|
,cursor_icn =Sprite.addr
|
||||||
=dev/sprite.y
|
~pointer.x =Sprite.x
|
||||||
=dev/sprite.x
|
~pointer.y =Sprite.y
|
||||||
=dev/sprite.addr
|
#11 =Sprite.color
|
||||||
=dev/sprite.color
|
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -271,10 +259,10 @@ RTS
|
||||||
|
|
||||||
|d000 @ERROR BRK
|
|d000 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;dev/screen Screen
|
|FF10 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|FF20 ;dev/sprite Sprite
|
|FF20 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF30 ;dev/ctrl Controller
|
|FF30 ;Controller { buttons 1 }
|
||||||
|FF50 ;dev/mouse Mouse
|
|FF50 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ 0fcf 0fc4 0fc4 ] ( palette )
|
|FFF8 [ 0fcf 0fc4 0fc4 ] ( palette )
|
|
@ -6,29 +6,15 @@
|
||||||
1 2 3 - Select brush
|
1 2 3 - Select brush
|
||||||
)
|
)
|
||||||
|
|
||||||
&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
;bankview { x 2 y 2 mode 1 addr 2 }
|
||||||
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
;tileview { x 2 y 2 addr 2 }
|
||||||
&Controller { buttons 1 }
|
;rect { x1 2 y1 2 x2 2 y2 2 }
|
||||||
&Keyboard { key 1 }
|
;mouse { x 2 y 2 }
|
||||||
&Mouse { x 2 y 2 state 1 chord 1 change 1 }
|
;color { byte 1 }
|
||||||
&File { pad 8 name 2 length 2 load 2 save 2 }
|
;i { byte 1 }
|
||||||
|
;pt { x 1 y 1 }
|
||||||
&Rect2d { x1 2 y1 2 x2 2 y2 2 }
|
;addr { short 2 }
|
||||||
&Point2d { x 2 y 2 }
|
;pos { x 2 y 2 }
|
||||||
&Point { x 1 y 1 }
|
|
||||||
|
|
||||||
&BankView { x 2 y 2 mode 1 addr 2 }
|
|
||||||
&TileView { x 2 y 2 addr 2 }
|
|
||||||
|
|
||||||
;bankview BankView
|
|
||||||
;tileview TileView
|
|
||||||
;rect Rect2d
|
|
||||||
;mouse Point2d
|
|
||||||
;color 1
|
|
||||||
;i 1
|
|
||||||
;pt Point
|
|
||||||
;addr 2
|
|
||||||
;pos Point2d
|
|
||||||
|
|
||||||
|0100 @RESET
|
|0100 @RESET
|
||||||
|
|
||||||
|
@ -774,12 +760,12 @@ RTS
|
||||||
|
|
||||||
|FE00 @ERROR BRK
|
|FE00 @ERROR BRK
|
||||||
|
|
||||||
|FF10 ;SCRN Screen
|
|FF10 ;SCRN { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|FF20 ;SPRT Sprite
|
|FF20 ;SPRT { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|FF30 ;CTRL Controller
|
|FF30 ;CTRL { buttons 1 }
|
||||||
|FF40 ;KEYS Keyboard
|
|FF40 ;KEYS { key 1 }
|
||||||
|FF50 ;MOUS Mouse
|
|FF50 ;MOUS { x 2 y 2 state 1 chord 1 change 1 }
|
||||||
|FF60 ;FILE File
|
|FF60 ;FILE { pad 8 name 2 length 2 load 2 save 2 }
|
||||||
|
|
||||||
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
|FFF0 .RESET .FRAME .ERROR ( vectors )
|
||||||
|FFF8 [ e0fc 30cc 30ac ] ( palette )
|
|FFF8 [ e0fc 30cc 30ac ] ( palette )
|
Loading…
Reference in New Issue