uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 57d29b1b100391abcc5d66b0e85075a703014511
parent 0d9df02190d2d7e791e3bf724585574e835197dc
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat, 13 Mar 2021 17:34:08 -0800

Redesigned assembler

Diffstat:
MREADME.md | 12+++++-------
Massembler.c | 129+++++++++++++++++++++++++------------------------------------------------------
Mbuild.sh | 2+-
Mprojects/examples/dev.console.usm | 12+++++-------
Aprojects/examples/dev.controller.usm | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dprojects/examples/dev.ctrl.usm | 79-------------------------------------------------------------------------------
Mprojects/examples/dev.keys.usm | 125+++++++++++++++++++++++++++++++++++++------------------------------------------
Mprojects/examples/dev.mouse.usm | 93++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mprojects/examples/dev.screen.usm | 75++++++++++++++++++++++++++++++++-------------------------------------------
Mprojects/examples/gui.hover.usm | 109++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mprojects/examples/gui.label.usm | 56++++++++++++++++++++++++--------------------------------
Mprojects/examples/gui.picture.usm | 30++++++++++++------------------
Mprojects/examples/gui.shapes.usm | 92++++++++++++++++++++++++++++++++++++-------------------------------------------
Mprojects/examples/win.editor.usm | 178+++++++++++++++++++++++++++++++++++++------------------------------------------
Mprojects/software/nasu.usm | 44+++++++++++++++-----------------------------
15 files changed, 489 insertions(+), 622 deletions(-)

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