Jump experiments

This commit is contained in:
neauoire 2021-03-11 12:19:59 -08:00
parent e3e2b792a6
commit 9bb4b84e2f
11 changed files with 433 additions and 327 deletions

View File

@ -29,11 +29,11 @@ evaluxn(u, u->vframe); /* Each frame
- `;variable 2`, assign an address to a label automatically. - `;variable 2`, assign an address to a label automatically.
- `:const 1a2b`, assign an address to a label manually. - `:const 1a2b`, assign an address to a label manually.
- `&macro { x 2 y 2 }`, define a macro named `macro`. - `&macro { x 2 y 2 }`, define a macro named `macro`.
- `.address`, push label address to memory.
- `,literal`, push label address to stack, prefixed with `LIT LEN`.
- `#1a`, a literal byte/short. - `#1a`, a literal byte/short.
- `+1a`, a literal signed byte/short. - `+1a`, a literal signed byte/short.
- `-1a`, a literal signed byte/short(negative). - `-1a`, a literal signed byte/short(negative).
- `.ab`, a raw byte/short in memory.
- `,literal`, push label address to stack, prefixed with `LIT LEN`.
- `=label`, helper to STR, equivalent to `,label STR`, or `label STR2`. - `=label`, helper to STR, equivalent to `,label STR`, or `label STR2`.
- `~label`, helper to LDR, equivalent to `,label LDR2`, or `,label LDR2`. - `~label`, helper to LDR, equivalent to `,label LDR2`, or `,label LDR2`.
- `|0010`, move to position in the program. - `|0010`, move to position in the program.
@ -55,30 +55,30 @@ evaluxn(u, u->vframe); /* Each frame
|0100 @RESET |0100 @RESET
,text1 ,print-label JSR ,text1 ,print-label JSR2
,text2 ,print-label JSR ,text2 ,print-label JSR2
#ab =dev/console.byte #ab =CNSL.byte
#cdef =dev/console.short #cdef =CNSL.short
BRK BRK
@print-label ( text ) @print-label ( text )
@print-label-loop @print-label-loop NOP
DUP2 LDR =dev/console.char ( write pointer value to console ) ( send ) DUP2 LDR =CNSL.char
#0001 ADD2 ( increment string pointer ) ( incr ) #0001 ADD2
DUP2 LDR #00 NEQ ,print-label-loop ROT JMP? POP2 ( while *ptr!=0 goto loop ) DUP2 LDR #00 NEQ ^print-label-loop MUL JMPS
POP2 POP2
RTS RTS
@text1 [ Hello World 0a00 ] ( store text with a linebreak and null byte ) @text1 [ Hello 20 World 0a00 ] ( store text with a linebreak and null byte )
@text2 [ Welcome to UxnVM 0a00 ] @text2 [ Welcome 20 to 20 UxnVM 0a00 ]
|c000 @FRAME |c000 @FRAME
|d000 @ERROR |d000 @ERROR
|FF00 ;dev/console Console |FF00 ;CNSL Console
|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette ) |FFF8 [ 13fd 1ef3 1bf2 ] ( palette )
@ -99,6 +99,16 @@ RTS
- Local loops - Local loops
- Jump helpers - Jump helpers
NOTE: OPCODES should not be relative, but there should be a relative accessor for addresses, like:
$relative_name JMP
## Notes
### Conditional Jumping
I've considered automatically popping an amount of items from the stack equal to the offset between the opcode's push/pop to make the stack length more predictable, and making the pattern JMP? POP2 unecessary, but that idea would make DUP? unusable. That change was reverted.
## Palettes ## Palettes
- `[ 6a03 4a0d aa0c ]`, purple/cyan - `[ 6a03 4a0d aa0c ]`, purple/cyan

View File

@ -184,7 +184,7 @@ makemacro(char *name, FILE *f)
char wv[64]; char wv[64];
if(findmacro(name)) if(findmacro(name))
return error("Macro duplicate", name); return error("Macro duplicate", name);
if(sihx(name)) if(sihx(name) && slen(name) % 2 == 0)
return error("Macro name is hex number", name); return error("Macro name is hex number", name);
if(findopcode(name)) if(findopcode(name))
return error("Macro name is invalid", name); return error("Macro name is invalid", name);
@ -214,7 +214,7 @@ makelabel(char *name, Uint16 addr, Uint8 len, Macro *m)
Label *l; Label *l;
if(findlabel(name)) if(findlabel(name))
return error("Label duplicate", name); return error("Label duplicate", name);
if(sihx(name)) if(sihx(name) && slen(name) % 2 == 0)
return error("Label name is hex number", name); return error("Label name is hex number", name);
if(findopcode(name)) if(findopcode(name))
return error("Label name is invalid", name); return error("Label name is invalid", name);
@ -309,7 +309,8 @@ pass1(FILE *f)
case '=': addr += 4; break; /* STR helper (lit addr-hb addr-lb str) */ case '=': addr += 4; break; /* STR helper (lit addr-hb addr-lb str) */
case '~': addr += 4; break; /* LDR helper (lit addr-hb addr-lb ldr) */ case '~': addr += 4; break; /* LDR helper (lit addr-hb addr-lb ldr) */
case ',': addr += 3; break; case ',': addr += 3; break;
case '.': addr += (slen(w + 1) == 2 ? 1 : 2); break; case '.': addr += 2; break;
case '^': addr += 2; break; /* Relative jump: lit addr-offset */
case '+': /* signed positive */ case '+': /* signed positive */
case '-': /* signed negative */ case '-': /* signed negative */
case '#': addr += (slen(w + 1) == 2 ? 2 : 3); break; case '#': addr += (slen(w + 1) == 2 ? 2 : 3); break;
@ -343,21 +344,24 @@ 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] == '^' && (l = findlabel(w + 1))) {
int off = l->addr - p.ptr - 3;
if(off < -126 || off > 126){ printf("Address %s is too far(%d).\n", w, off); return 0; }
printf("relative %s[%d]\n", w, l->addr - p.ptr - 4);
pushbyte((Sint8)(l->addr - p.ptr - 3), 1); l->refs++;
}
else if(w[0] == ':') fscanf(f, "%s", w); else if(w[0] == ':') fscanf(f, "%s", w);
else if(w[0] == ';') fscanf(f, "%s", w); else if(w[0] == ';') fscanf(f, "%s", w);
else if(w[0] == '.' && sihx(w + 1) && slen(w + 1) == 2) pushbyte(shex(w + 1), 0); else if(w[0] == '.' && (l = findlabel(w + 1))) { pushshort(findlabeladdr(w + 1), 0); l->refs++; }
else if(w[0] == '.' && sihx(w + 1) && slen(w + 1) == 4) pushshort(shex(w + 1), 0); 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] == '#' && 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);
else if(w[0] == '+' && sihx(w + 1) && slen(w + 1) == 4) pushshort((Sint16)shex(w + 1), 1); else if(w[0] == '+' && sihx(w + 1) && slen(w + 1) == 4) pushshort((Sint16)shex(w + 1), 1);
else if(w[0] == '-' && sihx(w + 1) && slen(w + 1) == 2) pushbyte((Sint8)(shex(w + 1) * -1), 1); else if(w[0] == '-' && sihx(w + 1) && slen(w + 1) == 2) pushbyte((Sint8)(shex(w + 1) * -1), 1);
else if(w[0] == '-' && sihx(w + 1) && slen(w + 1) == 4) pushshort((Sint16)(shex(w + 1) * -1), 1); else if(w[0] == '-' && sihx(w + 1) && slen(w + 1) == 4) pushshort((Sint16)(shex(w + 1) * -1), 1);
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] == '=' && sihx(w + 1)) { pushshort(shex(w + 1), 1); pushbyte(findopcode("STR2"), 0); }
else if(w[0] == '~' && sihx(w + 1)) { pushshort(shex(w + 1), 1); pushbyte(findopcode("LDR2"), 0); }
else if((l = findlabel(w + 1))) { pushshort(findlabeladdr(w+1), w[0] == ','); l->refs++; }
else return error("Unknown label in second pass", w); else return error("Unknown label in second pass", w);
/* clang-format on */ /* clang-format on */
} }

View File

@ -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/software/nasu.usm bin/boot.rom ./bin/assembler projects/software/left.usm bin/boot.rom
./bin/emulator bin/boot.rom ./bin/emulator bin/boot.rom

View File

@ -310,8 +310,10 @@ doctrl(Uxn *u, SDL_Event *event, int z)
{ {
Uint8 flag = 0x00; Uint8 flag = 0x00;
Uint16 addr = devctrl->addr; Uint16 addr = devctrl->addr;
if(z && event->key.keysym.sym == SDLK_h && SDL_GetModState() & KMOD_LCTRL) if(z && event->key.keysym.sym == SDLK_h && SDL_GetModState() & KMOD_LCTRL) {
GUIDES = !GUIDES; GUIDES = !GUIDES;
redraw(pixels, u);
}
switch(event->key.keysym.sym) { switch(event->key.keysym.sym) {
case SDLK_LCTRL: flag = 0x01; break; case SDLK_LCTRL: flag = 0x01; break;
case SDLK_LALT: flag = 0x02; break; case SDLK_LALT: flag = 0x02; break;

View File

@ -45,16 +45,15 @@ contexts:
- match: '\,(\S+)\s?' - match: '\,(\S+)\s?'
scope: keyword.control scope: keyword.control
pop: true pop: true
- match: '\.(\S+)\s?'
scope: keyword.control
pop: true
- match: '\^(\S+)\s?'
scope: keyword.control
pop: true
- match: '\#(\S+)\s?' - match: '\#(\S+)\s?'
scope: keyword.control scope: keyword.control
pop: true pop: true
- match: '\.(\S+)\s?'
scope: keyword.control
- match: '\+(\S+)\s?'
scope: string.control
pop: true
- match: '\-(\S+)\s?'
scope: string.control
# Blocks # Blocks

View File

@ -6,17 +6,17 @@
,text1 ,print-label JSR2 ,text1 ,print-label JSR2
,text2 ,print-label JSR2 ,text2 ,print-label JSR2
#ab =dev/console.byte #ab =CNSL.byte
#cdef =dev/console.short #cdef =CNSL.short
BRK BRK
@print-label ( text ) @print-label ( text )
@print-label-loop @print-label-loop NOP
DUP2 LDR =dev/console.char ( write pointer value to console ) ( send ) DUP2 LDR =CNSL.char
#0001 ADD2 ( increment string pointer ) ( incr ) #0001 ADD2
DUP2 LDR #00 NEQ ,print-label-loop ROT JMP2? POP2 ( while *ptr!=0 goto loop ) DUP2 LDR #00 NEQ ^print-label-loop MUL JMPS
POP2 POP2
RTS RTS
@ -27,7 +27,7 @@ RTS
|c000 @FRAME |c000 @FRAME
|d000 @ERROR |d000 @ERROR
|FF00 ;dev/console Console |FF00 ;CNSL Console
|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette ) |FFF8 [ 13fd 1ef3 1bf2 ] ( palette )

View File

@ -45,7 +45,7 @@
,filepath ,load-file JSR2 ,filepath ,load-file JSR2
( place textarea ) ( place textarea )
#0018 =textarea.x1 ~dev/screen.height #0008 SUB2 =textarea.y2 #0018 =textarea.x1 ~SCRN.height #0008 SUB2 =textarea.y2
,select JSR2 ,select JSR2
,redraw JSR2 ,redraw JSR2
@ -56,62 +56,62 @@ BRK
( ctrl ) ( ctrl )
,ctrl-end ~dev/ctrl #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP2? POP2 ,ctrl-end ~CTRL #00 EQU ~lock #00 NEQ #0000 NEQ2 JMP2? POP2
( lock ) #04 =lock ( lock ) #04 =lock
,no-ctrl-up ~dev/ctrl #10 NEQ JMP2? POP2 ,no-ctrl-up ~CTRL #10 NEQ JMP2? POP2
( clamp ) ,no-ctrl-up ~position.y #0000 EQU2 JMP2? POP2 ( clamp ) ,no-ctrl-up ~position.y #0000 EQU2 JMP2? POP2
,find-lineoffset JSR2 =position.x ,find-lineoffset JSR2 =position.x
~position.y #0001 SUB2 =position.y ~position.y #0001 SUB2 =position.y
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to ,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-ctrl-up @no-ctrl-up
,no-ctrl-down ~dev/ctrl #20 NEQ JMP2? POP2 ,no-ctrl-down ~CTRL #20 NEQ JMP2? POP2
,find-lineoffset JSR2 =position.x ~position.y #0001 ADD2 =position.y ,find-lineoffset JSR2 =position.x ~position.y #0001 ADD2 =position.y
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to ,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-ctrl-down @no-ctrl-down
,no-ctrl-left ~dev/ctrl #40 NEQ JMP2? POP2 ,no-ctrl-left ~CTRL #40 NEQ JMP2? POP2
( clamp ) ,no-ctrl-left ~selection.from ,document.body EQU2 JMP2? POP2 ( clamp ) ,no-ctrl-left ~selection.from ,document.body EQU2 JMP2? POP2
~selection.from #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to ~selection.from #0001 SUB2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-ctrl-left @no-ctrl-left
,no-ctrl-right ~dev/ctrl #80 NEQ JMP2? POP2 ,no-ctrl-right ~CTRL #80 NEQ JMP2? POP2
~selection.from #0001 ADD2 DUP2 =selection.from #0001 ADD2 =selection.to ~selection.from #0001 ADD2 DUP2 =selection.from #0001 ADD2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-ctrl-right @no-ctrl-right
( alt ) ( alt )
,no-alt ~dev/ctrl #0f AND #02 NEQ JMP2? POP2 ,no-alt ~CTRL #0f AND #02 NEQ JMP2? POP2
,no-aup ~dev/ctrl #04 ROR #01 NEQ JMP2? POP2 ,no-aup ~CTRL #04 ROR #01 NEQ JMP2? POP2
,find-wordstart JSR2 =selection.to ,find-wordstart JSR2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aup @no-aup
,no-adown ~dev/ctrl #04 ROR #02 NEQ JMP2? POP2 ,no-adown ~CTRL #04 ROR #02 NEQ JMP2? POP2
,find-wordend JSR2 =selection.to ,find-wordend JSR2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-adown @no-adown
,no-aleft ~dev/ctrl #04 ROR #04 NEQ JMP2? POP2 ,no-aleft ~CTRL #04 ROR #04 NEQ JMP2? POP2
~selection.to #0001 SUB2 =selection.to ~selection.to #0001 SUB2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aleft @no-aleft
,no-aright ~dev/ctrl #04 ROR #08 NEQ JMP2? POP2 ,no-aright ~CTRL #04 ROR #08 NEQ JMP2? POP2
~selection.to #0001 ADD2 =selection.to ~selection.to #0001 ADD2 =selection.to
,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,clamp-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-aright @no-aright
@no-alt @no-alt
( ctrl ) ( ctrl )
,no-ctrl ~dev/ctrl #0f AND #01 NEQ JMP2? POP2 ,no-ctrl ~CTRL #0f AND #01 NEQ JMP2? POP2
,no-cup ~dev/ctrl #04 ROR #01 NEQ JMP2? POP2 ,no-cup ~CTRL #04 ROR #01 NEQ JMP2? POP2
~scroll.y #0004 SUB2 =scroll.y ~scroll.y #0004 SUB2 =scroll.y
,redraw JSR2 ,ctrl-end JMP2 ,redraw JSR2 ,ctrl-end JMP2
@no-cup @no-cup
,no-cdown ~dev/ctrl #04 ROR #02 NEQ JMP2? POP2 ,no-cdown ~CTRL #04 ROR #02 NEQ JMP2? POP2
~scroll.y #0004 ADD2 =scroll.y ~scroll.y #0004 ADD2 =scroll.y
,redraw JSR2 ,ctrl-end JMP2 ,redraw JSR2 ,ctrl-end JMP2
@no-cdown @no-cdown
,no-cleft ~dev/ctrl #04 ROR #04 NEQ JMP2? POP2 ,no-cleft ~CTRL #04 ROR #04 NEQ JMP2? POP2
,goto-linestart JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,goto-linestart JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-cleft @no-cleft
,no-cright ~dev/ctrl #04 ROR #08 NEQ JMP2? POP2 ,no-cright ~CTRL #04 ROR #08 NEQ JMP2? POP2
,goto-lineend JSR2 ,redraw JSR2 ,ctrl-end JMP2 ,goto-lineend JSR2 ,redraw JSR2 ,ctrl-end JMP2
@no-cright @no-cright
@no-ctrl @no-ctrl
@ -120,39 +120,39 @@ BRK
( keys ) ( keys )
,keys-end ~dev/key #00 EQU JMP2? POP2 ,keys-end ~KEYS #00 EQU JMP2? POP2
,no-backspace ~dev/key #08 NEQ JMP2? POP2 ,no-backspace ~KEYS #08 NEQ JMP2? POP2
( erase ) ( erase )
~selection.to ~selection.from SUB2 ,shift-left JSR2 ~selection.to ~selection.from SUB2 ,shift-left JSR2
~selection.from #0001 SUB2 =selection.from ~selection.from #0001 SUB2 =selection.from
~selection.from #0001 ADD2 =selection.to ~selection.from #0001 ADD2 =selection.to
( release ) #00 =dev/key ( release ) #00 =KEYS
,redraw JSR2 ,redraw JSR2
,keys-end JMP2 ,keys-end JMP2
@no-backspace @no-backspace
( insert ) ( insert )
~selection.to ~selection.from SUB2 ,shift-right JSR2 ~selection.to ~selection.from SUB2 ,shift-right JSR2
~dev/key ~selection.from STR ~KEYS ~selection.from STR
~selection.from #0001 ADD2 =selection.from ~selection.from #0001 ADD2 =selection.from
~selection.from #0001 ADD2 =selection.to ~selection.from #0001 ADD2 =selection.to
( release ) #00 =dev/key ( release ) #00 =KEYS
,redraw JSR2 ,redraw JSR2
@keys-end @keys-end
( mouse ) ( mouse )
,touch-end ~dev/mouse.state #00 EQU JMP2? POP2 ,touch-end ~MOUS.state #00 EQU JMP2? POP2
,touch-linebar ~dev/mouse.x #0010 LTH2 JMP2? POP2 ,touch-linebar ~MOUS.x #0010 LTH2 JMP2? POP2
,touch-body ~dev/mouse.x ~dev/screen.width #0008 SUB2 LTH2 JMP2? POP2 ,touch-body ~MOUS.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2
,touch-scrollbar JMP2 ,touch-scrollbar JMP2
@touch-end @touch-end
~dev/mouse.state =touch.state ~MOUS.state =touch.state
( unlock ) ,skip-unlock ~lock #00 EQU JMP2? POP2 ~lock #01 SUB =lock @skip-unlock ( unlock ) ,skip-unlock ~lock #00 EQU JMP2? POP2 ~lock #01 SUB =lock @skip-unlock
@ -162,15 +162,15 @@ BRK
@touch-scrollbar @touch-scrollbar
,no-click-scroll-up ~dev/mouse.y #0008 GTH2 JMP2? POP2 ,no-click-scroll-up ~MOUS.y #0008 GTH2 JMP2? POP2
( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y ( decr ) ~scroll.y #00 ~scroll.y #0000 NEQ2 SUB2 =scroll.y
,redraw JSR2 ,touch-end JMP2 ,redraw JSR2 ,touch-end JMP2
@no-click-scroll-up @no-click-scroll-up
,no-click-scroll-down ~dev/mouse.y ~dev/screen.height #0008 SUB2 LTH2 JMP2? POP2 ,no-click-scroll-down ~MOUS.y ~SCRN.height #0008 SUB2 LTH2 JMP2? POP2
( incr ) ~scroll.y #0001 ADD2 =scroll.y ( incr ) ~scroll.y #0001 ADD2 =scroll.y
,redraw JSR2 ,touch-end JMP2 ,redraw JSR2 ,touch-end JMP2
@no-click-scroll-down @no-click-scroll-down
~dev/mouse.y #0008 SUB2 =scroll.y ~MOUS.y #0008 SUB2 =scroll.y
,redraw JSR2 ,redraw JSR2
,touch-end JMP2 ,touch-end JMP2
@ -178,7 +178,7 @@ RTS
@touch-linebar @touch-linebar
~dev/mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y #0000 =position.x ~MOUS.y #0008 DIV2 ~scroll.y ADD2 =position.y #0000 =position.x
,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to ,find-selection JSR2 DUP2 =selection.from #0001 ADD2 =selection.to
,redraw JSR2 ,redraw JSR2
,touch-end JMP2 ,touch-end JMP2
@ -187,10 +187,10 @@ RTS
@touch-body @touch-body
~dev/mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y ~MOUS.y #0008 DIV2 ~scroll.y ADD2 =position.y
~dev/mouse.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x ~MOUS.x ~textarea.x1 SUB2 #0007 ADD2 #0007 DIV2 =position.x
,touch-when ~dev/mouse.state ~touch.state NEQ ~dev/ctrl #0f AND #02 NEQ #0101 EQU2 JMP2? POP2 ,touch-when ~MOUS.state ~touch.state NEQ ~CTRL #0f AND #02 NEQ #0101 EQU2 JMP2? POP2
( on drag ) ( on drag )
,find-selection JSR2 #0001 ADD2 =selection.to ,find-selection JSR2 #0001 ADD2 =selection.to
,clamp-selection JSR2 ,clamp-selection JSR2
@ -207,7 +207,7 @@ RTS
@load-file ( path ) @load-file ( path )
=dev/file.name #8000 =dev/file.length ,document.body =dev/file.load =FILE.name #8000 =FILE.length ,document.body =FILE.load
( get file length ) ( get file length )
,document.body =document.eof ,document.body =document.eof
@ -379,75 +379,75 @@ RTS
( save/load icons ) ( save/load icons )
~dev/screen.height #0008 SUB2 =dev/sprite.y ~SCRN.height #0008 SUB2 =SPRT.y
~dev/screen.width #0018 SUB2 =dev/sprite.x ~SCRN.width #0018 SUB2 =SPRT.x
,load_icn =dev/sprite.addr ,load_icn =SPRT.addr
#02 =dev/sprite.color #02 =SPRT.color
~dev/screen.width #0010 SUB2 =dev/sprite.x ~SCRN.width #0010 SUB2 =SPRT.x
,save_icn =dev/sprite.addr ,save_icn =SPRT.addr
#02 =dev/sprite.color #02 =SPRT.color
RTS RTS
@draw-lines @draw-lines
#0000 =j #0000 =j
#0000 =dev/sprite.x #0000 =dev/sprite.y #0000 =SPRT.x #0000 =SPRT.y
@draw-lines-loop @draw-lines-loop
~scroll.y ~j ADD2 =addr ~scroll.y ~j ADD2 =addr
#0000 =dev/sprite.x #0000 =SPRT.x
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
( draw ) #02 ~addr ~position.y EQU2 #06 MUL ADD =dev/sprite.color ( draw ) #02 ~addr ~position.y EQU2 #06 MUL ADD =SPRT.color
#0008 =dev/sprite.x #0008 =SPRT.x
,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr
( draw ) #02 ~addr ~position.y EQU2 #06 MUL ADD =dev/sprite.color ( draw ) #02 ~addr ~position.y EQU2 #06 MUL ADD =SPRT.color
( incr ) ~j #0001 ADD2 =j ( incr ) ~j #0001 ADD2 =j
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
,draw-lines-loop ~j ~dev/screen.height #0008 SUB2 #0008 DIV2 NEQ2 JMP2? POP2 ,draw-lines-loop ~j ~SCRN.height #0008 SUB2 #0008 DIV2 NEQ2 JMP2? POP2
RTS RTS
@draw-short ( short ) @draw-short ( short )
=addr =addr
,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
( draw ) #0e =dev/sprite.color ( draw ) #0e =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =SPRT.addr
( draw ) #0e =dev/sprite.color ( draw ) #0e =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
( draw ) #0e =dev/sprite.color ( draw ) #0e =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr
( draw ) #0e =dev/sprite.color ( draw ) #0e =SPRT.color
RTS RTS
@draw-cursor @draw-cursor
~mouse.x ~dev/mouse.x NEQU2 ~mouse.x ~MOUS.x NEQU2
~mouse.y ~dev/mouse.y NEQU2 ~mouse.y ~MOUS.y NEQU2
#0000 EQU2 RTS? ( Return if unchanged ) #0000 EQU2 RTS? ( Return if unchanged )
( clear last cursor ) ( clear last cursor )
~mouse.x =dev/sprite.x ~mouse.x =SPRT.x
~mouse.y =dev/sprite.y ~mouse.y =SPRT.y
,blank_icn =dev/sprite.addr ,blank_icn =SPRT.addr
#10 =dev/sprite.color #10 =SPRT.color
( record mouse positions ) ( record mouse positions )
~dev/mouse.x =mouse.x ~MOUS.x =mouse.x
~dev/mouse.y =mouse.y ~MOUS.y =mouse.y
( draw new cursor ) ( draw new cursor )
~mouse.x =dev/sprite.x ~mouse.x =SPRT.x
~mouse.y =dev/sprite.y ~mouse.y =SPRT.y
,cursor_icn =dev/sprite.addr ,cursor_icn =SPRT.addr
#13 =dev/sprite.color #13 =SPRT.color
RTS RTS
@ -467,42 +467,42 @@ RTS
@find-scroll-offset-end @find-scroll-offset-end
~textarea.addr #0000 ADD2 =textarea.addr ~textarea.addr #0000 ADD2 =textarea.addr
#0000 =dev/sprite.y #0000 =SPRT.y
~textarea.addr =j ~textarea.addr =j
#0018 =dev/sprite.x #0018 =SPRT.x
@draw-textarea-loop @draw-textarea-loop
,draw-textarea-end ~dev/sprite.y ~dev/screen.height #0010 SUB2 GTH2 JMP2? POP2 ,draw-textarea-end ~SPRT.y ~SCRN.height #0010 SUB2 GTH2 JMP2? POP2
( get character ) ( get character )
,font #00 ~j LDR #20 SUB #0008 MUL2 ADD2 =dev/sprite.addr ,font #00 ~j LDR #20 SUB #0008 MUL2 ADD2 =SPRT.addr
( draw ) #01 ( draw ) #01
~j ~selection.from #0001 SUB2 GTH2 ~j ~selection.from #0001 SUB2 GTH2
~j ~selection.to LTH2 #0101 EQU2 ~j ~selection.to LTH2 #0101 EQU2
#05 MUL ADD =dev/sprite.color #05 MUL ADD =SPRT.color
,no-linebreak ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2 ,no-linebreak ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2
( draw linebreak ) ( draw linebreak )
,linebreak_icn =dev/sprite.addr ,linebreak_icn =SPRT.addr
( draw ) #03 ( draw ) #03
~j ~selection.from #0001 SUB2 GTH2 ~j ~selection.from #0001 SUB2 GTH2
~j ~selection.to LTH2 #0101 EQU2 ~j ~selection.to LTH2 #0101 EQU2
#05 MUL ADD =dev/sprite.color #05 MUL ADD =SPRT.color
( fill clear ) ( fill clear )
@fill-clear @fill-clear
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
,font =dev/sprite.addr ,font =SPRT.addr
#01 =dev/sprite.color #01 =SPRT.color
,fill-clear ~dev/sprite.x ~dev/screen.width #0008 SUB2 LTH2 JMP2? POP2 ,fill-clear ~SPRT.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2
#0010 =dev/sprite.x #0010 =SPRT.x
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
@no-linebreak @no-linebreak
( incr ) ~j #0001 ADD2 =j ( incr ) ~j #0001 ADD2 =j
( incr ) ~dev/sprite.x #0007 ADD2 =dev/sprite.x ( incr ) ~SPRT.x #0007 ADD2 =SPRT.x
,draw-textarea-loop ~j LDR #00 NEQ JMP2? POP2 ,draw-textarea-loop ~j LDR #00 NEQ JMP2? POP2
@ -512,40 +512,40 @@ RTS
@draw-scrollbar @draw-scrollbar
~dev/screen.width #0008 SUB2 =dev/sprite.x ~SCRN.width #0008 SUB2 =SPRT.x
#0000 =dev/sprite.y #0000 =SPRT.y
,scrollbar_bg =dev/sprite.addr ,scrollbar_bg =SPRT.addr
@draw-scrollbar-loop @draw-scrollbar-loop
( draw ) #08 =dev/sprite.color ( draw ) #08 =SPRT.color
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
,draw-scrollbar-loop ~dev/sprite.y ~dev/screen.height LTH2 JMP2? POP2 ,draw-scrollbar-loop ~SPRT.y ~SCRN.height LTH2 JMP2? POP2
#0000 =dev/sprite.y #0000 =SPRT.y
,arrowup_icn =dev/sprite.addr ,arrowup_icn =SPRT.addr
( draw ) #08 =dev/sprite.color ( draw ) #08 =SPRT.color
( at ) ( at )
~scroll.y #0008 ADD2 =dev/sprite.y ~scroll.y #0008 ADD2 =SPRT.y
,scrollbar_fg =dev/sprite.addr ,scrollbar_fg =SPRT.addr
( draw ) #08 =dev/sprite.color ( draw ) #08 =SPRT.color
~dev/screen.height #0008 SUB2 =dev/sprite.y ~SCRN.height #0008 SUB2 =SPRT.y
,arrowdown_icn =dev/sprite.addr ,arrowdown_icn =SPRT.addr
( draw ) #08 =dev/sprite.color ( draw ) #08 =SPRT.color
RTS RTS
@draw-titlebar @draw-titlebar
#0018 ~dev/screen.height #0008 SUB2 #09 ,filepath #0018 ~SCRN.height #0008 SUB2 #09 ,filepath
( load ) =label.addr =label.color =dev/sprite.y =dev/sprite.x ( load ) =label.addr =label.color =SPRT.y =SPRT.x
~label.addr ~label.addr
@draw-titlebar-loop @draw-titlebar-loop
( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =dev/sprite.addr ~label.color =dev/sprite.color ( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =SPRT.addr ~label.color =SPRT.color
( incr ) #0001 ADD2 ( incr ) #0001 ADD2
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
DUP2 LDR #00 NEQ ,draw-titlebar-loop ROT JMP2? POP2 DUP2 LDR #00 NEQ ,draw-titlebar-loop ROT JMP2? POP2
POP2 POP2
@ -628,20 +628,20 @@ RTS
@arrowdown_icn [ 0010 1010 fe7c 3810 ] @arrowdown_icn [ 0010 1010 fe7c 3810 ]
@load_icn [ feaa d6aa d4aa f400 ] @load_icn [ feaa d6aa d4aa f400 ]
@save_icn [ fe82 8282 848a f400 ] @save_icn [ fe82 8282 848a f400 ]
@filepath [ test.txt 00 ] @filepath1 [ projects/examples/jumptest.usm 00 ]
@filepath1 [ projects/software/left.usm 00 ] @filepath [ projects/software/left.usm 00 ]
|4000 ;document Document |4000 ;document Document
|d000 @ERROR BRK |d000 @ERROR BRK
|FF00 ;dev/console Console |FF00 ;dev/console Console
|FF10 ;dev/screen Screen |FF10 ;SCRN Screen
|FF20 ;dev/sprite Sprite |FF20 ;SPRT Sprite
|FF30 ;dev/ctrl Controller |FF30 ;CTRL Controller
|FF40 ;dev/key Keyboard |FF40 ;KEYS Keyboard
|FF50 ;dev/mouse Mouse |FF50 ;MOUS Mouse
|FF60 ;dev/file File |FF60 ;FILE File
|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ a0fe a0f7 a0f2 ] ( palette ) |FFF8 [ a0fe a0f7 a0f2 ] ( palette )

View File

@ -32,12 +32,12 @@
|0100 @RESET |0100 @RESET
~dev/screen.width #0002 DIV2 #008a SUB2 =bankview.x ~SCRN.width #0002 DIV2 #008a SUB2 =bankview.x
~dev/screen.height #0002 DIV2 #003f SUB2 =bankview.y ~SCRN.height #0002 DIV2 #003f SUB2 =bankview.y
,bank1 =bankview.addr ,bank1 =bankview.addr
~dev/screen.width #0002 DIV2 #0002 ADD2 =tileview.x ~SCRN.width #0002 DIV2 #0002 ADD2 =tileview.x
~dev/screen.height #0002 DIV2 #003f SUB2 =tileview.y ~SCRN.height #0002 DIV2 #003f SUB2 =tileview.y
,bank1 #0448 ADD2 =tileview.addr ,bank1 #0448 ADD2 =tileview.addr
,redraw JSR2 ,redraw JSR2
@ -48,28 +48,28 @@ BRK
( keyboard controls ) ( keyboard controls )
,no-key ~dev/key #00 EQU JMP2? POP2 ,no-key ~KEYS #00 EQU JMP2? POP2
,no-key ~dev/key #31 LTH JMP2? POP2 ,no-key ~KEYS #31 LTH JMP2? POP2
,no-key ~dev/key #33 GTH JMP2? POP2 ,no-key ~KEYS #33 GTH JMP2? POP2
( select ) ~dev/key #31 SUB =bankview.mode ( select ) ~KEYS #31 SUB =bankview.mode
( release ) #00 =dev/key ( release ) #00 =KEYS
,redraw JSR2 ,redraw JSR2
@no-key @no-key
,no-ctrl ~dev/ctrl.buttons #00 EQU JMP2? POP2 ,no-ctrl ~CTRL.buttons #00 EQU JMP2? POP2
,no-ctrl-up ~dev/ctrl.buttons #10 EQU JMP2? POP2 ,no-ctrl-up ~CTRL.buttons #10 EQU JMP2? POP2
~tileview.addr #0080 ADD2 =tileview.addr ~tileview.addr #0080 ADD2 =tileview.addr
@no-ctrl-up @no-ctrl-up
,no-ctrl-down ~dev/ctrl.buttons #20 EQU JMP2? POP2 ,no-ctrl-down ~CTRL.buttons #20 EQU JMP2? POP2
~tileview.addr #0080 SUB2 =tileview.addr ~tileview.addr #0080 SUB2 =tileview.addr
@no-ctrl-down @no-ctrl-down
,no-ctrl-left ~dev/ctrl.buttons #40 EQU JMP2? POP2 ,no-ctrl-left ~CTRL.buttons #40 EQU JMP2? POP2
~tileview.addr #0008 ADD2 =tileview.addr ~tileview.addr #0008 ADD2 =tileview.addr
@no-ctrl-left @no-ctrl-left
,no-ctrl-right ~dev/ctrl.buttons #80 EQU JMP2? POP2 ,no-ctrl-right ~CTRL.buttons #80 EQU JMP2? POP2
~tileview.addr #0008 SUB2 =tileview.addr ~tileview.addr #0008 SUB2 =tileview.addr
@no-ctrl-right @no-ctrl-right
~tileview.addr #0800 DIV2 #0800 MUL2 =bankview.addr ~tileview.addr #0800 DIV2 #0800 MUL2 =bankview.addr
@ -79,30 +79,30 @@ BRK
( mouse controls ) ( mouse controls )
,click-end ~dev/mouse.state #00 EQU JMP2? POP2 ,click-end ~MOUS.state #00 EQU JMP2? POP2
( toolbar ) ( toolbar )
,no-toolbar-click ~dev/mouse.y ~bankview.y #0010 SUB2 SUB2 #0008 DIV2 #0000 NEQ2 JMP2? POP2 ,no-toolbar-click ~MOUS.y ~bankview.y #0010 SUB2 SUB2 #0008 DIV2 #0000 NEQ2 JMP2? POP2
( brush ) ( brush )
,no-brush-click ~dev/mouse.x ~bankview.x SUB2 #0008 DIV2 #000d LTH2 JMP2? POP2 ,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000d LTH2 JMP2? POP2
,no-brush-click ~dev/mouse.x ~bankview.x SUB2 #0008 DIV2 #000f GTH2 JMP2? POP2 ,no-brush-click ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #000f GTH2 JMP2? POP2
( select ) ~mouse.x ~bankview.x SUB2 #0008 DIV2 #000d SUB2 SWP POP =bankview.mode ( select ) ~mouse.x ~bankview.x SUB2 #0008 DIV2 #000d SUB2 SWP POP =bankview.mode
( release ) #00 =dev/mouse.state ( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@no-brush-click @no-brush-click
,no-load-click ~dev/mouse.x ~tileview.x SUB2 #0008 DIV2 #000e NEQU2 JMP2? POP2 ,no-load-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000e NEQU2 JMP2? POP2
( load ) ,filename =dev/file.name #0800 =dev/file.length ~bankview.addr =dev/file.load ( load ) ,filename =FILE.name #0800 =FILE.length ~bankview.addr =FILE.load
( release ) #00 =dev/mouse.state ( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@no-load-click @no-load-click
,no-save-click ~dev/mouse.x ~tileview.x SUB2 #0008 DIV2 #000f NEQU2 JMP2? POP2 ,no-save-click ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #000f NEQU2 JMP2? POP2
( save ) ,filename =dev/file.name #0800 =dev/file.length ~bankview.addr =dev/file.save ( save ) ,filename =FILE.name #0800 =FILE.length ~bankview.addr =FILE.save
( release ) #00 =dev/mouse.state ( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@no-save-click @no-save-click
@ -110,8 +110,8 @@ BRK
( bankview ) ( bankview )
~dev/mouse.x ~bankview.x GTH2 ~dev/mouse.x ~bankview.x #0080 ADD2 LTH2 #0101 EQU2 ~MOUS.x ~bankview.x GTH2 ~MOUS.x ~bankview.x #0080 ADD2 LTH2 #0101 EQU2
~dev/mouse.y ~bankview.y GTH2 ~dev/mouse.y ~bankview.y #0080 ADD2 LTH2 #0101 EQU2 ~MOUS.y ~bankview.y GTH2 ~MOUS.y ~bankview.y #0080 ADD2 LTH2 #0101 EQU2
#0101 NEQ2 ,no-bank-click ROT JMP2? POP2 #0101 NEQ2 ,no-bank-click ROT JMP2? POP2
,not-copy-mode ~bankview.mode #01 NEQ JMP2? POP2 ,not-copy-mode ~bankview.mode #01 NEQ JMP2? POP2
@ -119,8 +119,8 @@ BRK
@copy-loop @copy-loop
( load ) ~tileview.addr ~i ADD LDR ( load ) ~tileview.addr ~i ADD LDR
( get touch addr ) ( get touch addr )
~dev/mouse.x ~bankview.x SUB2 #0008 DIV2 #0008 MUL2 ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #0008 MUL2
~dev/mouse.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2 ~MOUS.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2
~bankview.addr ADD2 #00 ~i ADD2 STR ~bankview.addr ADD2 #00 ~i ADD2 STR
( incr ) ~i #01 ADD =i ( incr ) ~i #01 ADD =i
,copy-loop ~i #08 LTH JMP2? POP2 ,copy-loop ~i #08 LTH JMP2? POP2
@ -132,16 +132,16 @@ BRK
@erase-loop @erase-loop
#00 #00
( get touch addr ) ( get touch addr )
~dev/mouse.x ~bankview.x SUB2 #0008 DIV2 #0008 MUL2 ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #0008 MUL2
~dev/mouse.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2 ~MOUS.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2
~bankview.addr ADD2 #00 ~i ADD2 STR ~bankview.addr ADD2 #00 ~i ADD2 STR
( incr ) ~i #01 ADD =i ( incr ) ~i #01 ADD =i
,erase-loop ~i #08 LTH JMP2? POP2 ,erase-loop ~i #08 LTH JMP2? POP2
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@not-erase-mode @not-erase-mode
~dev/mouse.x ~bankview.x SUB2 #0008 DIV2 #0008 MUL2 ~MOUS.x ~bankview.x SUB2 #0008 DIV2 #0008 MUL2
~dev/mouse.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2 ~MOUS.y ~bankview.y SUB2 #0008 DIV2 #0008 MUL2 #0010 MUL2 ADD2
~bankview.addr ADD2 =tileview.addr ~bankview.addr ADD2 =tileview.addr
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@ -149,16 +149,16 @@ BRK
( tileview ) ( tileview )
~dev/mouse.x ~tileview.x GTH2 ~dev/mouse.x ~tileview.x #0080 ADD2 LTH2 #0101 EQU2 ~MOUS.x ~tileview.x GTH2 ~MOUS.x ~tileview.x #0080 ADD2 LTH2 #0101 EQU2
~dev/mouse.y ~tileview.y GTH2 ~dev/mouse.y ~tileview.y #0080 ADD2 LTH2 #0101 EQU2 ~MOUS.y ~tileview.y GTH2 ~MOUS.y ~tileview.y #0080 ADD2 LTH2 #0101 EQU2
#0101 NEQ2 ,no-tile-click ROT JMP2? POP2 #0101 NEQ2 ,no-tile-click ROT JMP2? POP2
~dev/mouse.x ~tileview.x SUB2 #0008 DIV2 #0008 MUL2 #0040 DIV2 ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0008 MUL2 #0040 DIV2
~dev/mouse.y ~tileview.y SUB2 #0008 DIV2 #0008 MUL2 #0040 DIV2 #0002 MUL2 ADD2 ~MOUS.y ~tileview.y SUB2 #0008 DIV2 #0008 MUL2 #0040 DIV2 #0002 MUL2 ADD2
#0008 MUL2 #0008 MUL2
~tileview.addr ADD2 =addr ( addr offset ) ~tileview.addr ADD2 =addr ( addr offset )
~dev/mouse.x ~tileview.x SUB2 ~dev/mouse.x ~tileview.x SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.x ~MOUS.x ~tileview.x SUB2 ~MOUS.x ~tileview.x SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.x
~dev/mouse.y ~tileview.y SUB2 ~dev/mouse.y ~tileview.y SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.y ~MOUS.y ~tileview.y SUB2 ~MOUS.y ~tileview.y SUB2 #0040 DIV2 #0040 MUL2 SUB2 =pos.y
,no-fill-mode ~bankview.mode #01 NEQ JMP2? POP2 ,no-fill-mode ~bankview.mode #01 NEQ JMP2? POP2
( fill row ) #ff ~addr ~pos.y #0008 DIV2 ADD2 STR ( fill row ) #ff ~addr ~pos.y #0008 DIV2 ADD2 STR
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@ -177,17 +177,17 @@ BRK
( operations ) ( operations )
,no-operations ~dev/mouse.y ~tileview.y SUB2 #0008 DIV2 #000c NEQ2 JMP2? POP2 ,no-operations ~MOUS.y ~tileview.y SUB2 #0008 DIV2 #000c NEQ2 JMP2? POP2
,no-move-up ~dev/mouse.x ~tileview.x SUB2 #0008 DIV2 #0011 NEQ2 JMP2? POP2 ,no-move-up ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0011 NEQ2 JMP2? POP2
,op_shiftup JSR2 ,op_shiftup JSR2
( release ) #00 =dev/mouse.state ( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@no-move-up @no-move-up
,no-move-down ~dev/mouse.x ~tileview.x SUB2 #0008 DIV2 #0012 NEQ2 JMP2? POP2 ,no-move-down ~MOUS.x ~tileview.x SUB2 #0008 DIV2 #0012 NEQ2 JMP2? POP2
,op_shiftdown JSR2 ,op_shiftdown JSR2
( release ) #00 =dev/mouse.state ( release ) #00 =MOUS.state
,redraw JSR2 ,click-end JMP2 ,redraw JSR2 ,click-end JMP2
@no-move-down @no-move-down
@ -240,66 +240,66 @@ RTS
( position ) ( position )
~bankview.x =dev/sprite.x ~bankview.x =SPRT.x
~bankview.y #0010 SUB2 =dev/sprite.y ~bankview.y #0010 SUB2 =SPRT.y
~bankview.addr ,draw-short JSR2 ~bankview.addr ,draw-short JSR2
( toolbar ) ( toolbar )
~bankview.x #0068 ADD2 =dev/sprite.x ~bankview.x #0068 ADD2 =SPRT.x
~bankview.y #0010 SUB2 =dev/sprite.y ~bankview.y #0010 SUB2 =SPRT.y
,tool_selector =dev/sprite.addr ,tool_selector =SPRT.addr
#01 ~bankview.mode #00 EQU ADD =dev/sprite.color #01 ~bankview.mode #00 EQU ADD =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,tool_hand =dev/sprite.addr ,tool_hand =SPRT.addr
#01 ~bankview.mode #01 EQU ADD =dev/sprite.color #01 ~bankview.mode #01 EQU ADD =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,tool_eraser =dev/sprite.addr ,tool_eraser =SPRT.addr
#01 ~bankview.mode #02 EQU ADD =dev/sprite.color #01 ~bankview.mode #02 EQU ADD =SPRT.color
~tileview.x #0070 ADD2 =dev/sprite.x ~tileview.x #0070 ADD2 =SPRT.x
,load_icn =dev/sprite.addr ,load_icn =SPRT.addr
#01 =dev/sprite.color #01 =SPRT.color
~tileview.x #0078 ADD2 =dev/sprite.x ~tileview.x #0078 ADD2 =SPRT.x
,save_icn =dev/sprite.addr ,save_icn =SPRT.addr
#01 =dev/sprite.color #01 =SPRT.color
( guides ) ( guides )
#00 =i ,font_hex =dev/sprite.addr #00 =i ,font_hex =SPRT.addr
@draw-bankview-guides @draw-bankview-guides
~bankview.x #0010 SUB2 =dev/sprite.x ~bankview.x #0010 SUB2 =SPRT.x
~bankview.y #00 ~i #08 MUL ADD2 =dev/sprite.y ~bankview.y #00 ~i #08 MUL ADD2 =SPRT.y
( draw ) #02 =dev/sprite.color ( draw ) #02 =SPRT.color
~bankview.x #00 ~i #08 MUL ADD2 =dev/sprite.x ~bankview.x #00 ~i #08 MUL ADD2 =SPRT.x
~bankview.y #0088 ADD2 =dev/sprite.y ~bankview.y #0088 ADD2 =SPRT.y
( draw ) #02 =dev/sprite.color ( draw ) #02 =SPRT.color
~dev/sprite.addr #0008 ADD2 =dev/sprite.addr ~SPRT.addr #0008 ADD2 =SPRT.addr
( incr ) ~i #01 ADD =i ( incr ) ~i #01 ADD =i
,draw-bankview-guides ~i #10 LTH JMP2? POP2 ,draw-bankview-guides ~i #10 LTH JMP2? POP2
( body ) ( body )
~bankview.x =dev/sprite.x ~bankview.y =dev/sprite.y ~bankview.x =SPRT.x ~bankview.y =SPRT.y
#00 =pt.x #00 =pt.y ~bankview.addr =dev/sprite.addr #00 =pt.x #00 =pt.y ~bankview.addr =SPRT.addr
@draw-bankview-tiles-ver @draw-bankview-tiles-ver
#00 =pt.x #00 =pt.x
~bankview.x =dev/sprite.x ~bankview.x =SPRT.x
@draw-bankview-tiles-hor @draw-bankview-tiles-hor
( draw ) #01 =dev/sprite.color ( draw ) #01 =SPRT.color
,no-highlight ~dev/sprite.addr ~tileview.addr LTH2 JMP2? POP2 ,no-highlight ~SPRT.addr ~tileview.addr LTH2 JMP2? POP2
,no-highlight ~dev/sprite.addr ~tileview.addr #0018 ADD2 GTH2 JMP2? POP2 ,no-highlight ~SPRT.addr ~tileview.addr #0018 ADD2 GTH2 JMP2? POP2
( draw ) #0c =dev/sprite.color ( draw ) #0c =SPRT.color
@no-highlight @no-highlight
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
( incr ) ~dev/sprite.addr #0008 ADD2 =dev/sprite.addr ( incr ) ~SPRT.addr #0008 ADD2 =SPRT.addr
( incr ) ~pt.x #01 ADD =pt.x ( incr ) ~pt.x #01 ADD =pt.x
,draw-bankview-tiles-hor ~pt.x #10 LTH JMP2? POP2 ,draw-bankview-tiles-hor ~pt.x #10 LTH JMP2? POP2
( incr ) ~pt.y #01 ADD =pt.y ( incr ) ~pt.y #01 ADD =pt.y
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
,draw-bankview-tiles-ver ~pt.y #10 LTH JMP2? POP2 ,draw-bankview-tiles-ver ~pt.y #10 LTH JMP2? POP2
RTS RTS
@ -308,96 +308,96 @@ RTS
~tileview.x #0002 SUB2 ~tileview.y #0002 SUB2 ~tileview.x #0080 ADD2 ~tileview.y #0081 ADD2 #03 ,line-rect JSR2 ~tileview.x #0002 SUB2 ~tileview.y #0002 SUB2 ~tileview.x #0080 ADD2 ~tileview.y #0081 ADD2 #03 ,line-rect JSR2
~tileview.x #0028 ADD2 =dev/sprite.x ~tileview.x #0028 ADD2 =SPRT.x
~tileview.y #0010 SUB2 =dev/sprite.y ~tileview.y #0010 SUB2 =SPRT.y
~tileview.addr =dev/sprite.addr ~tileview.addr =SPRT.addr
#03 =dev/sprite.color #03 =SPRT.color
( position ) ( position )
~tileview.x =dev/sprite.x ~tileview.x =SPRT.x
~tileview.y #0010 SUB2 =dev/sprite.y ~tileview.y #0010 SUB2 =SPRT.y
~tileview.addr ,draw-short JSR2 ~tileview.addr ,draw-short JSR2
( body ) ( body )
~tileview.x =dev/sprite.x ~tileview.x =SPRT.x
~tileview.y =dev/sprite.y ~tileview.y =SPRT.y
~tileview.addr =tileview.addr ~tileview.addr =tileview.addr
,draw-tileview-icn JSR2 ,draw-tileview-icn JSR2
~tileview.x #0040 ADD2 =dev/sprite.x ~tileview.x #0040 ADD2 =SPRT.x
~tileview.y =dev/sprite.y ~tileview.y =SPRT.y
~tileview.addr #0008 ADD2 =tileview.addr ~tileview.addr #0008 ADD2 =tileview.addr
,draw-tileview-icn JSR2 ,draw-tileview-icn JSR2
~tileview.x =dev/sprite.x ~tileview.x =SPRT.x
~tileview.y #0040 ADD2 =dev/sprite.y ~tileview.y #0040 ADD2 =SPRT.y
~tileview.addr #0008 ADD2 =tileview.addr ~tileview.addr #0008 ADD2 =tileview.addr
,draw-tileview-icn JSR2 ,draw-tileview-icn JSR2
~tileview.x #0040 ADD2 =dev/sprite.x ~tileview.x #0040 ADD2 =SPRT.x
~tileview.y #0040 ADD2 =dev/sprite.y ~tileview.y #0040 ADD2 =SPRT.y
~tileview.addr #0008 ADD2 =tileview.addr ~tileview.addr #0008 ADD2 =tileview.addr
,draw-tileview-icn JSR2 ,draw-tileview-icn JSR2
( line hor ) ( line hor )
~tileview.y #003f ADD2 =dev/screen.y ~tileview.y #003f ADD2 =SCRN.y
~tileview.x =dev/screen.x ~tileview.x =SCRN.x
@draw-hor @draw-hor
( draw ) #03 =dev/screen.color ( draw ) #03 =SCRN.color
( incr ) ~dev/screen.x #0002 ADD2 =dev/screen.x ( incr ) ~SCRN.x #0002 ADD2 =SCRN.x
~dev/screen.x ~tileview.x #0082 ADD2 LTH2 ,draw-hor ROT JMP2? POP2 ~SCRN.x ~tileview.x #0082 ADD2 LTH2 ,draw-hor ROT JMP2? POP2
( line ver ) ( line ver )
~tileview.y =dev/screen.y ~tileview.y =SCRN.y
~tileview.x #003f ADD2 =dev/screen.x ~tileview.x #003f ADD2 =SCRN.x
@draw-ver @draw-ver
( draw ) #03 =dev/screen.color ( draw ) #03 =SCRN.color
( incr ) ~dev/screen.y #0002 ADD2 =dev/screen.y ( incr ) ~SCRN.y #0002 ADD2 =SCRN.y
~dev/screen.y ~tileview.y #0081 ADD2 LTH2 ,draw-ver ROT JMP2? POP2 ~SCRN.y ~tileview.y #0081 ADD2 LTH2 ,draw-ver ROT JMP2? POP2
( rewind ) ~tileview.addr #0018 SUB2 =tileview.addr ( rewind ) ~tileview.addr #0018 SUB2 =tileview.addr
( bytes ) ( bytes )
~tileview.y #0018 ADD2 =dev/sprite.y ~tileview.y #0018 ADD2 =SPRT.y
#00 =i #00 =i
@draw-tileview-bytes @draw-tileview-bytes
~tileview.x #0088 ADD2 =dev/sprite.x ~tileview.x #0088 ADD2 =SPRT.x
,font_hex #00 ~tileview.addr #00 ~i ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ~tileview.addr #00 ~i ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
( draw ) #02 =dev/sprite.color ( draw ) #02 =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ~tileview.addr #00 ~i ADD2 LDR #0f AND #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ~tileview.addr #00 ~i ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr
( draw ) #02 =dev/sprite.color ( draw ) #02 =SPRT.color
( incr ) ~i #01 ADD =i ( incr ) ~i #01 ADD =i
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
,draw-tileview-bytes ~i #08 LTH JMP2? POP2 ,draw-tileview-bytes ~i #08 LTH JMP2? POP2
( operations ) ( operations )
~dev/sprite.y #0008 ADD2 =dev/sprite.y ~SPRT.y #0008 ADD2 =SPRT.y
,movedown_icn =dev/sprite.addr ,movedown_icn =SPRT.addr
#01 =dev/sprite.color #01 =SPRT.color
~dev/sprite.x #0008 SUB2 =dev/sprite.x ~SPRT.x #0008 SUB2 =SPRT.x
,moveup_icn =dev/sprite.addr ,moveup_icn =SPRT.addr
#01 =dev/sprite.color #01 =SPRT.color
( draw tiles ) ( draw tiles )
~tileview.y =dev/sprite.y ~tileview.y =SPRT.y
#00 =pt.x #00 =pt.y ~tileview.addr =dev/sprite.addr #00 =pt.x #00 =pt.y ~tileview.addr =SPRT.addr
@draw-tileview-tiles-ver @draw-tileview-tiles-ver
#00 =pt.x #00 =pt.x
~tileview.x #0088 ADD2 =dev/sprite.x ~tileview.x #0088 ADD2 =SPRT.x
@draw-tileview-tiles-hor @draw-tileview-tiles-hor
( draw ) #03 =dev/sprite.color ( draw ) #03 =SPRT.color
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
( incr ) ~dev/sprite.addr #0008 ADD2 =dev/sprite.addr ( incr ) ~SPRT.addr #0008 ADD2 =SPRT.addr
( incr ) ~pt.x #01 ADD =pt.x ( incr ) ~pt.x #01 ADD =pt.x
,draw-tileview-tiles-hor ~pt.x #02 LTH JMP2? POP2 ,draw-tileview-tiles-hor ~pt.x #02 LTH JMP2? POP2
( incr ) ~pt.y #01 ADD =pt.y ( incr ) ~pt.y #01 ADD =pt.y
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
,draw-tileview-tiles-ver ~pt.y #02 LTH JMP2? POP2 ,draw-tileview-tiles-ver ~pt.y #02 LTH JMP2? POP2
RTS RTS
@ -411,57 +411,57 @@ RTS
( get bit ) ( get bit )
,blank_icn #00 ,blank_icn #00
~tileview.addr #00 ~pt.y ADD2 LDR #07 ~pt.x SUB ROR #01 AND ( get bit ) ~tileview.addr #00 ~pt.y ADD2 LDR #07 ~pt.x SUB ROR #01 AND ( get bit )
#0008 MUL2 ADD2 =dev/sprite.addr ( add *8 ) #0008 MUL2 ADD2 =SPRT.addr ( add *8 )
( draw ) #01 =dev/sprite.color ( draw ) #01 =SPRT.color
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x ( incr ) ~SPRT.x #0008 ADD2 =SPRT.x
( incr ) ~pt.x #01 ADD =pt.x ( incr ) ~pt.x #01 ADD =pt.x
,redraw-hor ~pt.x #08 LTH JMP2? POP2 ,redraw-hor ~pt.x #08 LTH JMP2? POP2
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y ( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
( incr ) ~pt.y #01 ADD =pt.y ( incr ) ~pt.y #01 ADD =pt.y
~dev/sprite.x #0040 SUB2 =dev/sprite.x ~SPRT.x #0040 SUB2 =SPRT.x
,redraw-ver ~pt.y #08 LTH JMP2? POP2 ,redraw-ver ~pt.y #08 LTH JMP2? POP2
RTS RTS
@draw-cursor @draw-cursor
~mouse.x ~dev/mouse.x NEQU2 ~mouse.x ~MOUS.x NEQU2
~mouse.y ~dev/mouse.y NEQU2 ~mouse.y ~MOUS.y NEQU2
#0000 EQU2 RTS? ( Return if unchanged ) #0000 EQU2 RTS? ( Return if unchanged )
( clear last cursor ) ( clear last cursor )
~mouse.x =dev/sprite.x ~mouse.x =SPRT.x
~mouse.y =dev/sprite.y ~mouse.y =SPRT.y
,blank_icn =dev/sprite.addr ,blank_icn =SPRT.addr
#10 =dev/sprite.color #10 =SPRT.color
( record mouse positions ) ( record mouse positions )
~dev/mouse.x =mouse.x ~MOUS.x =mouse.x
~dev/mouse.y =mouse.y ~MOUS.y =mouse.y
( draw new cursor ) ( draw new cursor )
~mouse.x =dev/sprite.x ~mouse.x =SPRT.x
~mouse.y =dev/sprite.y ~mouse.y =SPRT.y
,tool_selector #00 ~bankview.mode #08 MUL ADD2 =dev/sprite.addr ,tool_selector #00 ~bankview.mode #08 MUL ADD2 =SPRT.addr
#12 =dev/sprite.color #12 =SPRT.color
RTS RTS
@draw-short ( short ) @draw-short ( short )
=addr =addr
,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
( draw ) #02 =dev/sprite.color ( draw ) #02 =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =SPRT.addr
( draw ) #02 =dev/sprite.color ( draw ) #02 =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
( draw ) #02 =dev/sprite.color ( draw ) #02 =SPRT.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x ~SPRT.x #0008 ADD2 =SPRT.x
,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =dev/sprite.addr ,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr
( draw ) #02 =dev/sprite.color ( draw ) #02 =SPRT.color
RTS RTS
@ -469,18 +469,18 @@ 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 =SCRN.y =rect.y1 DUP2 =SCRN.x =rect.x1
@line-rect-hor @line-rect-hor
( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x ( incr ) ~SCRN.x #0001 ADD2 =SCRN.x
( draw ) ~rect.y1 =dev/screen.y ~color =dev/screen.color ( draw ) ~rect.y1 =SCRN.y ~color =SCRN.color
( draw ) ~rect.y2 =dev/screen.y ~color =dev/screen.color ( draw ) ~rect.y2 =SCRN.y ~color =SCRN.color
,line-rect-hor ~dev/screen.x ~rect.x2 LTH2 JMP2? POP2 ,line-rect-hor ~SCRN.x ~rect.x2 LTH2 JMP2? POP2
~rect.y1 =dev/screen.y ~rect.y1 =SCRN.y
@line-rect-ver @line-rect-ver
( draw ) ~rect.x1 =dev/screen.x ~color =dev/screen.color ( draw ) ~rect.x1 =SCRN.x ~color =SCRN.color
( draw ) ~rect.x2 =dev/screen.x ~color =dev/screen.color ( draw ) ~rect.x2 =SCRN.x ~color =SCRN.color
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y ( incr ) ~SCRN.y #0001 ADD2 =SCRN.y
,line-rect-ver ~dev/screen.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2 ,line-rect-ver ~SCRN.y ~rect.y2 #0001 ADD2 LTH2 JMP2? POP2
RTS RTS
@ -774,12 +774,12 @@ RTS
|FE00 @ERROR BRK |FE00 @ERROR BRK
|FF10 ;dev/screen Screen |FF10 ;SCRN Screen
|FF20 ;dev/sprite Sprite |FF20 ;SPRT Sprite
|FF30 ;dev/ctrl Controller |FF30 ;CTRL Controller
|FF40 ;dev/key Keyboard |FF40 ;KEYS Keyboard
|FF50 ;dev/mouse Mouse |FF50 ;MOUS Mouse
|FF60 ;dev/file File |FF60 ;FILE File
|FFF0 .RESET .FRAME .ERROR ( vectors ) |FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ e0fc 30cc 30ac ] ( palette ) |FFF8 [ e0fc 30cc 30ac ] ( palette )

52
projects/tests/jump.usm Normal file
View File

@ -0,0 +1,52 @@
( tests/jump )
&Console { pad 8 char 1 byte 1 short 2 }
|0100 @RESET
( skip forward with value )
#11 =dev/console.byte
#03 JMPS BRK BRK BRK
( skip foward with id )
#22 =dev/console.byte
^jump JMPS BRK BRK BRK @jump
( skip patterns )
#33 =dev/console.byte
,skip1 #12 #34 LTH JMP2? POP2
#ff =dev/console.byte
@skip1
#12 #34 LTH ^skip2 #04 SUB MUL JMPS
#ff =dev/console.byte
@skip2
#44 =dev/console.byte
,end JMP2
( should print aa, bb, cc, dd )
@label1 #aa =dev/console.byte ^label3 JMPS
@label2 #cc =dev/console.byte ^label4 JMPS
@label3 #bb =dev/console.byte ^label2 JMPS
@label4 #dd =dev/console.byte BRK
@end
^label1 JMPS
BRK
|c000 @FRAME
|d000 @ERROR
|FF00 ;dev/console Console
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )

39
projects/tests/loop.usm Normal file
View File

@ -0,0 +1,39 @@
( hello world )
&Console { pad 8 char 1 byte 1 short 2 }
;a 1 ;b 1 ;c 1
|0100 @RESET
( type: padded muljmp )
@loop1 NOP
~a #01 ADD =a
~a #d0 LTH ^loop1 MUL JMPS
( type: jmppop )
@loop2
~b #01 ADD =b
,loop2 ~b #d0 LTH JMP2? POP2
( type: padded jmppop )
@loop3 NOP
~c #01 ADD =c
~c #d0 LTH ^loop3 SWP JMPS? POP
~a =dev/console.byte
~b =dev/console.byte
~c =dev/console.byte
BRK
|c000 @FRAME
|d000 @ERROR
|FF00 ;dev/console Console
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )

4
uxn.c
View File

@ -32,7 +32,7 @@ Uint16 peek16(Stack *s, Uint8 a) { return peek8(s, a * 2) + (peek8(s, a * 2 + 1)
/* I/O */ /* I/O */
void op_brk(Uxn *u) { setflag(&u->status, FLAG_HALT, 1); } void op_brk(Uxn *u) { setflag(&u->status, FLAG_HALT, 1); }
void op_lit(Uxn *u) { u->literal += 1; } void op_lit(Uxn *u) { u->literal += 1; }
void op_nop(Uxn *u) { printf("0x%02x \n", pop8(&u->wst)); fflush(stdout); } void op_nop(Uxn *u) { (void)u; }
void op_jmp(Uxn *u) { Uint8 a = pop8(&u->wst); u->ram.ptr += getflag(&u->status, FLAG_SIGN) ? (Sint8)a : a; } void op_jmp(Uxn *u) { Uint8 a = pop8(&u->wst); u->ram.ptr += getflag(&u->status, FLAG_SIGN) ? (Sint8)a : a; }
void op_jsr(Uxn *u) { Uint8 a = pop8(&u->wst); push16(&u->rst, u->ram.ptr); u->ram.ptr += getflag(&u->status, FLAG_SIGN) ? (Sint8)a : a; } void op_jsr(Uxn *u) { Uint8 a = pop8(&u->wst); push16(&u->rst, u->ram.ptr); u->ram.ptr += getflag(&u->status, FLAG_SIGN) ? (Sint8)a : a; }
void op_rts(Uxn *u) { u->ram.ptr = pop16(&u->rst); } void op_rts(Uxn *u) { u->ram.ptr = pop16(&u->rst); }
@ -102,7 +102,7 @@ void (*ops[])(Uxn *u) = {
}; };
Uint8 opr[][2] = { Uint8 opr[][2] = {
{0,0}, {0,0}, {0,0}, {2,0}, {2,0}, {0,0}, {2,1}, {3,0}, {0,0}, {0,0}, {0,0}, {1,0}, {1,0}, {0,0}, {2,1}, {3,0},
{2,0}, {2,0}, {0,0}, {0,0}, {2,1}, {2,1}, {2,1}, {2,1}, {2,0}, {2,0}, {0,0}, {0,0}, {2,1}, {2,1}, {2,1}, {2,1},
{1,0}, {1,2}, {2,2}, {2,3}, {3,3}, {1,0}, {0,1}, {2,1}, {1,0}, {1,2}, {2,2}, {2,3}, {3,3}, {1,0}, {0,1}, {2,1},
{2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1}, {2,1},