Browse Source

Starting to develop nasu for Uxn

main
neauoire 5 years ago
parent
commit
a54ad89d0b
  1. 3
      .gitignore
  2. 6
      README.md
  3. 892
      nasu.usm

3
.gitignore vendored

@ -4,4 +4,5 @@
*gif~
*bmp~
nasu
untitled.chr
untitled.chr
nasu.rom

6
README.md

@ -10,6 +10,12 @@ To build nasu, you must have [SDL2](https://wiki.libsdl.org/).
cc nasu.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -L/usr/local/lib -lSDL2 -o nasu
```
To assemble and run for Uxn.
```
uxnasm nasu.usm nasu.rom && uxnemu nasu.rom
```
## I/O
To resume working on a tileset:

892
nasu.usm

@ -0,0 +1,892 @@
(
app/nasu : spritesheet editor
arrows - move selection
ctrl+arrows - change page
left-click - add pixel
right-click - remove pixel
1 2 3 - select brush
TODO:
Copy in 2 bits mode, copies 2 tiles
Modify up to 4 pages
Save/load/rename
Select paint color for 2-bit mode
)
%+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%RTN { JMP2r }
%STEP8 { #0033 SFT2 }
%SFL { #40 SFT SFT }
%MOD { DUP2 DIV MUL SUB }
%TOB { SWP POP } %TOS { #00 SWP }
%DEBUG { .Console/byte DEO #0a .Console/char DEO }
%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
%LTS2 { #8000 ++ SWP2 #8000 ++ >> }
%GTS2 { #8000 ++ SWP2 #8000 ++ << }
%SIZE-TO-RECT {
STH2 STH2 OVR2 STH2r ++ OVR2 STH2r ++
} ( x y w h -- x1 y1 x2 y2 )
%SET-RECT {
DUP2 ROT2 SWP2 #0006 ++ STA2
DUP2 ROT2 SWP2 #0004 ++ STA2
DUP2 ROT2 SWP2 #0002 ++ STA2
DUP2 ROT2 SWP2 STA2
POP2
} ( x1 y1 x2 y2 addr -- )
%BANK { #2000 }
( devices )
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ]
|a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]
( variables )
|0000
@settings [
&blending $1
&depth $1
&brush $1
&page $2
&tile $2
&ratio $1 ]
@frame [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 &width $2 &height $2 ]
( interface )
@bankview [ &x $2 &y $2 &mode $1 &selection $1 ]
@tileview [ &x $2 &y $2 ]
@editview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@colorview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@blendview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@dataview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@preview [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@rect [ &x1 $2 &y1 $2 &x2 $2 &y2 $2 ]
@mouse [ &x $2 &y $2 ]
@pt [ &x $1 &y $1 ]
@pos [ &x $2 &y $2 ]
@color $1
@i $1
( program )
|0100 ( -> )
( theme )
#0efc .System/r DEO2
#03cc .System/g DEO2
#03ac .System/b DEO2
( vectors )
;on-button .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2
;on-transfer .File/vector DEO2
( set defaults )
#0130 .frame/width STZ2
#00a8 .frame/height STZ2
#01 .settings/brush STZ
#32 .settings/ratio STZ
.Screen/width DEI2 #0001 SFT2 .frame/width LDZ2 #0001 SFT2 --
.Screen/height DEI2 #0001 SFT2 .frame/height LDZ2 #0001 SFT2 -- #0010 ++
.frame/width LDZ2 .frame/height LDZ2
SIZE-TO-RECT ;frame SET-RECT
.frame/x1 LDZ2 #0010 ++ .bankview/x STZ2
.frame/y1 LDZ2 .bankview/y STZ2
BANK .settings/page STZ2
.frame/x2 LDZ2 #0098 -- .tileview/x STZ2
.frame/y1 LDZ2 .tileview/y STZ2
BANK #0448 ++ .settings/tile STZ2
.frame/x2 LDZ2 #0010 -- .frame/y1 LDZ2 #0010 #0080 SIZE-TO-RECT ;dataview SET-RECT
.frame/x1 LDZ2 #0010 ++ .frame/y2 LDZ2 #0020 -- #0020 #0020 SIZE-TO-RECT ;blendview SET-RECT
.frame/x1 LDZ2 #0060 ++ .frame/y2 LDZ2 #0020 -- #0020 #0020 SIZE-TO-RECT ;colorview SET-RECT
.frame/x1 LDZ2 #0038 ++ .frame/y2 LDZ2 #0020 -- #0020 #0020 SIZE-TO-RECT ;preview SET-RECT
.frame/x2 LDZ2 #0098 -- .frame/y1 LDZ2 #0080 #0080 SIZE-TO-RECT ;editview SET-RECT
( editview grid )
.editview/x1 LDZ2 DUP2 #0080 ++ .editview/y1 LDZ2 #0020 ++ #03 ;line-hor JSR2
.editview/x1 LDZ2 DUP2 #0080 ++ .editview/y1 LDZ2 #0040 ++ #03 ;line-hor JSR2
.editview/x1 LDZ2 DUP2 #0080 ++ .editview/y1 LDZ2 #0060 ++ #03 ;line-hor JSR2
.editview/x1 LDZ2 #0020 ++ .editview/y1 LDZ2 DUP2 #0080 ++ #03 ;line-ver JSR2
.editview/x1 LDZ2 #0040 ++ .editview/y1 LDZ2 DUP2 #0080 ++ #03 ;line-ver JSR2
.editview/x1 LDZ2 #0060 ++ .editview/y1 LDZ2 DUP2 #0080 ++ #03 ;line-ver JSR2
.editview/x1 LDZ2 #0002 -- .editview/y1 LDZ2 #0002 -- .editview/x2 LDZ2 #0001 ++ .editview/y2 LDZ2 #0001 ++ #03 ;line-rect JSR2
#01 .settings/blending STZ
;filepath1 .File/name DEO2 #0800 .File/length DEO2 BANK .File/load DEO2
;filepath2 .File/name DEO2 #0800 .File/length DEO2 BANK #0800 ++ .File/load DEO2
;filepath3 .File/name DEO2 #1000 .File/length DEO2 BANK #1000 ++ .File/load DEO2
;filepath4 .File/name DEO2 #1000 .File/length DEO2 BANK #2000 ++ .File/load DEO2
;filepath5 .File/name DEO2 #1000 .File/length DEO2 BANK #2800 ++ .File/load DEO2
;filepath6 .File/name DEO2 #1000 .File/length DEO2 BANK #3800 ++ .File/load DEO2
#40 DUP .bankview/selection STZ ;select-tile JSR2
BRK
@on-transfer ( -> )
;redraw JSR2
BRK
@on-button ( -> )
( skip ) .Controller/button DEI #00 NEQ #01 JCN [ BRK ]
.Controller/button DEI #11 NEQ ,&no-pageup JCN .settings/page LDZ2
#0800 -- .settings/page STZ2
;redraw JSR2
BRK &no-pageup
.Controller/button DEI #21 NEQ ,&no-pagedown JCN .settings/page LDZ2
#0800 ++ .settings/page STZ2
;redraw JSR2
BRK &no-pagedown
.Controller/button DEI #f0 AND
DUP #04 SFT #01 AND #01 NEQ ,&no-up JCN
( move ) .bankview/selection LDZ #10 SUB .bankview/selection STZ &no-up
DUP #05 SFT #01 AND #01 NEQ ,&no-down JCN
( move ) .bankview/selection LDZ #10 + .bankview/selection STZ &no-down
DUP #06 SFT #01 AND #01 NEQ ,&no-left JCN
( move ) .bankview/selection LDZ #01 SUB .bankview/selection STZ &no-left
DUP #07 SFT #01 AND #01 NEQ ,&no-right JCN
( move ) .bankview/selection LDZ #01 + .bankview/selection STZ &no-right
POP
.bankview/selection LDZ ;select-tile JSR2
BRK
@on-mouse ( -> )
;draw-cursor JSR2
( skip ) .Mouse/state DEI #00 NEQ #01 JCN [ BRK ]
( toolbar )
.Mouse/y DEI2 .bankview/y LDZ2 #0010 -- -- #0008 // #0000 !! ;&no-toolbar-click JCN2
( brush )
.Mouse/x DEI2 .bankview/x LDZ2 -- #0008 // #000d << ,&no-brush-click JCN
.Mouse/x DEI2 .bankview/x LDZ2 -- #0008 // #000f >> ,&no-brush-click JCN
( select ) .mouse/x LDZ2 .bankview/x LDZ2 -- #0008 // #000d -- TOB .bankview/mode STZ
&no-brush-click
.Mouse/x DEI2 .bankview/x LDZ2 -- #0008 // #0005 !! ,&no-toggle-depth JCN
;toggle-depth JSR2
&no-toggle-depth
( release ) #00 .Mouse/state DEO
;redraw JSR2 BRK
&no-toolbar-click
( bankview )
.Mouse/x DEI2 .bankview/x LDZ2 >> .Mouse/x DEI2 .bankview/x LDZ2 #0080 ++ << #0101 ==
.Mouse/y DEI2 .bankview/y LDZ2 >> .Mouse/y DEI2 .bankview/y LDZ2 #0080 ++ << #0101 ==
#0101 == ;on-touch-bankview JCN2
( tileview )
.Mouse/x DEI2 .tileview/x LDZ2 >> .Mouse/x DEI2 .tileview/x LDZ2 #0080 ++ << #0101 ==
.Mouse/y DEI2 .tileview/y LDZ2 >> .Mouse/y DEI2 .tileview/y LDZ2 #0080 ++ << #0101 ==
#0101 == ;on-touch-tileview JCN2
( editview )
.Mouse/x DEI2 DUP2 .editview/x1 LDZ2 >> ROT ROT .editview/x2 LDZ2 << #0101 ==
.Mouse/y DEI2 DUP2 .editview/y1 LDZ2 >> ROT ROT .editview/y2 LDZ2 << #0101 ==
#0101 == ;on-touch-editview JCN2
( dataview )
.Mouse/x DEI2 DUP2 .dataview/x1 LDZ2 >> ROT ROT .dataview/x2 LDZ2 << #0101 ==
.Mouse/y DEI2 DUP2 .dataview/y1 LDZ2 >> ROT ROT .dataview/y2 LDZ2 << #0101 ==
#0101 == ;on-touch-dataview JCN2
( blendbiew )
.Mouse/x DEI2 DUP2 .blendview/x1 LDZ2 >> ROT ROT .blendview/x2 LDZ2 << #0101 ==
.Mouse/y DEI2 DUP2 .blendview/y1 LDZ2 >> ROT ROT .blendview/y2 LDZ2 << #0101 ==
#0101 == ;on-touch-blendview JCN2
( colorview )
.Mouse/x DEI2 DUP2 .colorview/x1 LDZ2 >> ROT ROT .colorview/x2 LDZ2 << #0101 ==
.Mouse/y DEI2 DUP2 .colorview/y1 LDZ2 >> ROT ROT .colorview/y2 LDZ2 << #0101 ==
#0101 == ;on-touch-colorview JCN2
( preview )
.Mouse/x DEI2 DUP2 .preview/x1 LDZ2 >> ROT ROT .preview/x2 LDZ2 << #0101 ==
.Mouse/y DEI2 DUP2 .preview/y1 LDZ2 >> ROT ROT .preview/y2 LDZ2 << #0101 ==
#0101 == ;on-touch-preview JCN2
BRK
@on-touch-bankview ( -> )
.bankview/mode LDZ #01 NEQ ,&not-copy-mode JCN
#00 .i STZ
&copy-loop
( load ) .settings/tile LDZ2 .i LDZ + LDA
( get touch addr )
.Mouse/x DEI2 .bankview/x LDZ2 -- STEP8
.Mouse/y DEI2 .bankview/y LDZ2 -- STEP8 #0010 ** ++
( 2-bit mode ) #00 .settings/depth LDZ #01 + **
.settings/page LDZ2 ++ #00 .i LDZ ++ STA
( incr ) .i LDZ #01 + .i STZ
.i LDZ #08 LTH ,&copy-loop JCN
;redraw JSR2 BRK
&not-copy-mode
.bankview/mode LDZ #02 NEQ ,&not-erase-mode JCN
#00 .i STZ
&erase-loop
#00
( get touch addr )
.Mouse/x DEI2 .bankview/x LDZ2 -- STEP8
.Mouse/y DEI2 .bankview/y LDZ2 -- STEP8 #0010 ** ++
( 2-bit mode ) #00 .settings/depth LDZ #01 + **
.settings/page LDZ2 ++ #00 .i LDZ ++ STA
( incr ) .i LDZ #01 + .i STZ
.i LDZ #08 LTH ,&erase-loop JCN
;redraw JSR2 BRK
&not-erase-mode
( select )
.Mouse/x DEI2 .bankview/x LDZ2 -- #0008 // TOB
.Mouse/y DEI2 .bankview/y LDZ2 -- #0008 // TOB #40 SFT +
DUP .bankview/selection STZ
;select-tile JSR2
BRK
@on-touch-tileview ( -> )
BRK
@on-touch-editview ( -> )
#aa DEBUG
BRK
@on-touch-dataview ( -> )
.Mouse/y DEI2 .dataview/y1 LDZ2 -- STEP8 TOB #60 EQU ,&skip JCN BRK &skip
.Mouse/x DEI2 .dataview/x1 LDZ2 -- #0008 // TOB
DUP #00 NEQ ,&no-move-up JCN
;op_shiftup JSR2
( release ) #00 .Mouse/state DEO
;redraw JSR2 POP BRK &no-move-up
DUP #01 NEQ ,&no-move-down JCN
;op_shiftdown JSR2
( release ) #00 .Mouse/state DEO
;redraw JSR2 POP BRK &no-move-down
POP
BRK
@on-touch-blendview ( -> )
.Mouse/x DEI2 .blendview/x1 LDZ2 -- #0008 // TOB
.Mouse/y DEI2 .blendview/y1 LDZ2 -- #0008 // TOB #04 MUL +
.settings/blending STZ
( release ) #00 .Mouse/state DEO
;redraw JSR2
BRK
@on-touch-colorview ( -> )
( channel ) .Mouse/y DEI2 .colorview/y1 LDZ2 -- #0008 // TOB STH
( rgb ) .Mouse/x DEI2 .colorview/x1 LDZ2 -- #0008 // TOB
DUP #00 NEQ ,&no-brush JCN
DUPr STHr .settings/brush STZ &no-brush
DUP #01 NEQ ,&no-red JCN
DUPr STHr .System/r ;set-color JSR2 &no-red
DUP #02 NEQ ,&no-green JCN
DUPr STHr .System/g ;set-color JSR2 &no-green
DUP #03 NEQ ,&no-blue JCN
DUPr STHr .System/b ;set-color JSR2 &no-blue
POP POPr
( release ) #00 .Mouse/state DEO
;redraw JSR2
BRK
@on-touch-preview ( -> )
( y ) .Mouse/y DEI2 .preview/y1 LDZ2 -- #0008 // TOB
( x ) .Mouse/x DEI2 .preview/x1 LDZ2 -- #0008 // TOB
#40 SFT + #11 +
.settings/ratio STZ
( release ) #00 .Mouse/state DEO
( clear editview )
.editview/x1 LDZ2 .editview/y1 LDZ2 .editview/x2 LDZ2 .editview/y2 LDZ2 #00 ;fill-rect JSR2
;redraw JSR2
BRK
@set-color ( color rgb -- )
STH
DUP #00 NEQ ,&no-red0 JCN
DUPr STHr DEI DUP #04 SFT #01 +
( add/sub ) .Mouse/state DEI #10 EQU #fe MUL +
( resume ) #40 SFT SWP #0f AND + DUPr STHr DEO
&no-red0
DUP #01 NEQ ,&no-red1 JCN
DUPr STHr DEI DUP #0f AND #01 +
( add/sub ) .Mouse/state DEI #10 EQU #fe MUL +
( resume ) #0f AND SWP #f0 AND + DUPr STHr DEO
&no-red1
DUP #02 NEQ ,&no-red2 JCN
DUPr STHr #01 + DEI DUP #04 SFT #01 +
( add/sub ) .Mouse/state DEI #10 EQU #fe MUL +
( resume ) #40 SFT SWP #0f AND + DUPr STHr #01 + DEO
&no-red2
DUP #03 NEQ ,&no-red3 JCN
DUPr STHr #01 + DEI DUP #0f AND #01 +
( add/sub ) .Mouse/state DEI #10 EQU #fe MUL +
( resume ) #0f AND SWP #f0 AND + DUPr STHr #01 + DEO
&no-red3
POP
POPr
RTN
@select-tile ( pos -- )
( x y ) DUP #0f AND SWP #04 SFT
( y ) #10 MOD #10 MUL #00 SWP #0008 **
( x ) ROT #10 MOD #00 SWP #0008 ** ++
( 2-bit mode ) #00 .settings/depth LDZ #01 + **
( offset ) .settings/page LDZ2 ++ .settings/tile STZ2
;redraw JSR2
RTN
@toggle-depth ( -- )
.bankview/selection LDZ
.settings/depth LDZ #00 EQU .settings/depth STZ
;select-tile JSR2
RTN
@op_shiftup ( -- )
.settings/tile LDZ2 LDA
.settings/tile LDZ2 #0001 ++ LDA .settings/tile LDZ2 STA
.settings/tile LDZ2 #0002 ++ LDA .settings/tile LDZ2 #0001 ++ STA
.settings/tile LDZ2 #0003 ++ LDA .settings/tile LDZ2 #0002 ++ STA
.settings/tile LDZ2 #0004 ++ LDA .settings/tile LDZ2 #0003 ++ STA
.settings/tile LDZ2 #0005 ++ LDA .settings/tile LDZ2 #0004 ++ STA
.settings/tile LDZ2 #0006 ++ LDA .settings/tile LDZ2 #0005 ++ STA
.settings/tile LDZ2 #0007 ++ LDA .settings/tile LDZ2 #0006 ++ STA
.settings/tile LDZ2 #0007 ++ STA
RTN
@op_shiftdown ( -- )
.settings/tile LDZ2 #0007 ++ LDA
.settings/tile LDZ2 #0006 ++ LDA .settings/tile LDZ2 #0007 ++ STA
.settings/tile LDZ2 #0005 ++ LDA .settings/tile LDZ2 #0006 ++ STA
.settings/tile LDZ2 #0004 ++ LDA .settings/tile LDZ2 #0005 ++ STA
.settings/tile LDZ2 #0003 ++ LDA .settings/tile LDZ2 #0004 ++ STA
.settings/tile LDZ2 #0002 ++ LDA .settings/tile LDZ2 #0003 ++ STA
.settings/tile LDZ2 #0001 ++ LDA .settings/tile LDZ2 #0002 ++ STA
.settings/tile LDZ2 LDA .settings/tile LDZ2 #0001 ++ STA
.settings/tile LDZ2 STA
RTN
@redraw ( -- )
;draw-bankview JSR2
;draw-editview JSR2
;draw-blendview JSR2
;draw-colorview JSR2
;draw-dataview JSR2
;draw-preview JSR2
RTN
@draw-bankview ( -- )
.bankview/x LDZ2 #0002 -- .bankview/y LDZ2 #0002 -- .bankview/x LDZ2 #0081 ++ .bankview/y LDZ2 #0081 ++ #03 ;line-rect JSR2
( position )
.bankview/x LDZ2 .Screen/x DEO2
.bankview/y LDZ2 #0010 -- .Screen/y DEO2
.settings/page LDZ2 #22 ;draw-short JSR2
( toolbar )
.bankview/y LDZ2 #0010 -- .Screen/y DEO2
.bankview/x LDZ2 #0028 ++ .Screen/x DEO2
;depth_icns #00 .settings/depth LDZ #0008 ** ++ .Screen/addr DEO2
#23 .Screen/color DEO
.bankview/x LDZ2 #0068 ++ .Screen/x DEO2
;tool_selector .Screen/addr DEO2
#21 .bankview/mode LDZ #00 EQU + .Screen/color DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
;tool_hand .Screen/addr DEO2
#21 .bankview/mode LDZ #01 EQU + .Screen/color DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
;tool_eraser .Screen/addr DEO2
#21 .bankview/mode LDZ #02 EQU + .Screen/color DEO
( guides )
.bankview/x LDZ2 #0010 -- .Screen/x DEO2
.bankview/y LDZ2 .Screen/y DEO2
;font-hex .Screen/addr DEO2
#00 #10
&guides
( draw ) OVR .bankview/selection LDZ #04 SFT EQU #22 + .Screen/color DEO
.Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
SWP #01 + SWP
DUP2 LTH ,&guides JCN
POP2
( draw page )
( load ) .settings/page LDZ2 .Screen/addr DEO2
.bankview/y LDZ2 DUP2 #0080 ++
&ver
( save ) OVR2 .Screen/y DEO2
.bankview/x LDZ2 DUP2 #0080 ++
&hor
( save ) OVR2 .Screen/x DEO2
( get selected ) .Screen/addr DEI2 .settings/tile LDZ2 ==
( get blending ) .settings/blending LDZ
( get depth ) .settings/depth LDZ #20 MUL
( draw ) #20 + + + .Screen/color DEO
( incr ) SWP2 #0008 ++ SWP2
( incr ) .Screen/addr DEI2 #0008 ++ #00 .settings/depth LDZ #0008 ** ++ .Screen/addr DEO2
OVR2 OVR2 << ,&hor JCN
POP2 POP2
( incr ) SWP2 #0008 ++ SWP2
OVR2 OVR2 << ,&ver JCN
POP2 POP2
RTN
@draw-editview ( -- )
( position )
.editview/x1 LDZ2 .Screen/x DEO2
.editview/y1 LDZ2 #0010 -- .Screen/y DEO2
.settings/tile LDZ2 #22 ;draw-short JSR2
( tiles )
.settings/tile LDZ2 DUP2 STH2 .Screen/addr DEO2
#00 #04
&ver
OVR #20 MUL TOS .editview/y1 LDZ2 ++ .Screen/y DEO2
#00 #04
&hor
OVR #20 MUL TOS .editview/x1 LDZ2 ++ .Screen/x DEO2
( get x,y )
SWP2 OVR STH SWP2 OVR STHr
( check if within ratio )
.settings/ratio LDZ #0f AND LTH STH
.settings/ratio LDZ #04 SFT LTH STHr
#0101 !! ,&outside JCN
DUP2r STH2r .Screen/addr DEO2
#01 ,draw-tile JSR
( incr ) STH2r #0008 ++ STH2
&outside
( incr ) SWP #01 + SWP
DUP2 LTH ,&hor JCN
POP2
( incr ) SWP #01 + SWP
DUP2 LTH ;&ver JCN2
POP2
POP2r
RTN
@draw-tile ( color -- )
STH
#00 #20
&ver
#00 #20
&hor
OVR #04 MOD #00 EQU ,&skip JCN
STH2 OVR STH2r ROT #04 MOD #00 EQU ,&skip JCN
( get x,y )
SWP2 OVR STH SWP2 OVR STHr
( get address )
.Screen/addr DEI2
( after this, +R XY )
SWP2 SWP STH
( got sprite line )
#04 DIV TOS ++ LDA
( get pixel )
STHr #04 DIV
#07 SWP SUB SFT #01 AND
.Screen/color DEO
&skip
#0001 .Screen/x DEI2 ++ .Screen/x DEO2
( incr ) SWP #01 + SWP
DUP2 LTH ,&hor JCN
POP2
#0001 .Screen/y DEI2 ++ .Screen/y DEO2
.Screen/x DEI2 #0020 -- .Screen/x DEO2
( incr ) SWP #01 + SWP
DUP2 LTH ,&ver JCN
POP2
.Screen/y DEI2 #0020 -- .Screen/y DEO2
POPr
RTN
@draw-tileview-icn ( -- )
#00 .pt/x STZ #00 .pt/y STZ
&ver
#00 .pt/x STZ
&hor
( get bit )
;blank_icn #00
.settings/tile LDZ2 #00 .pt/y LDZ ++ LDA #07 .pt/x LDZ SUB SFT #01 AND ( get bit )
#0008 ** ++ .Screen/addr DEO2 ( add *8 )
( draw ) #21 .Screen/color DEO
( incr ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
( incr ) .pt/x LDZ #01 + .pt/x STZ
.pt/x LDZ #08 LTH ;&hor JCN2
( incr ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
( incr ) .pt/y LDZ #01 + .pt/y STZ
.Screen/x DEI2 #0040 -- .Screen/x DEO2
.pt/y LDZ #08 LTH ;&ver JCN2
RTN
@draw-dataview ( -- )
( bytes )
.tileview/y LDZ2 #0018 ++ .Screen/y DEO2
#00 .i STZ
&bytes
.tileview/x LDZ2 #0088 ++ .Screen/x DEO2
.settings/tile LDZ2 #00 .i LDZ ++ LDA #22 ;draw-byte JSR2
( incr ) .i LDZ #01 + .i STZ
( incr ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
.i LDZ #08 LTH ;&bytes JCN2
( operations )
.Screen/y DEI2 #0008 ++ .Screen/y DEO2
;movedown_icn .Screen/addr DEO2
#21 .Screen/color DEO
.Screen/x DEI2 #0008 -- .Screen/x DEO2
;moveup_icn .Screen/addr DEO2
#21 .Screen/color DEO
( draw tiles 2x2 )
.tileview/y LDZ2 .Screen/y DEO2
#00 .pt/x STZ #00 .pt/y STZ .settings/tile LDZ2 .Screen/addr DEO2
&tiles-ver
#00 .pt/x STZ
.tileview/x LDZ2 #0088 ++ .Screen/x DEO2
&tiles-hor
( draw ) #23 .Screen/color DEO
( incr ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2
( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2
( incr ) .pt/x LDZ #01 + .pt/x STZ
.pt/x LDZ #02 LTH ;&tiles-hor JCN2
( incr ) .pt/y LDZ #01 + .pt/y STZ
( incr ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2
.pt/y LDZ #02 LTH ;&tiles-ver JCN2
RTN
@draw-blendview ( -- )
.settings/tile LDZ2 .Screen/addr DEO2
#00 #10
&loop
OVR #04 MOD #00 SWP #0008 ** .blendview/x1 LDZ2 ++ .Screen/x DEO2
OVR #04 DIV #00 SWP #0008 ** .blendview/y1 LDZ2 ++ .Screen/y DEO2
#20 .Screen/color DEO
OVR #20 + .settings/depth LDZ #20 MUL + .Screen/color DEO
SWP #01 + SWP
DUP2 LTH ,&loop JCN
POP2
.blendview/x1 LDZ2 .Screen/x DEO2
.blendview/y2 LDZ2 #0001 ++ .Screen/y DEO2
( get blending ) .settings/blending LDZ
( get depth ) .settings/depth LDZ #20 MUL
( draw ) #20 + + #21 ;draw-byte JSR2
RTN
@draw-colorview ( -- )
.colorview/x1 LDZ2 .Screen/x DEO2
;circle_icns .Screen/addr DEO2
#00 #04
&loop
OVR .settings/brush LDZ EQU #00 SWP #0008 ** ;circle_icns ++ .Screen/addr DEO2
OVR .colorview/y1 LDZ2 ROT #00 SWP #0008 ** ++ .Screen/y DEO2
OVR #20 + .Screen/color DEO
SWP #01 + SWP
DUP2 LTH ,&loop JCN
POP2
.colorview/y1 LDZ2 #18 + .Screen/y DEO2
.colorview/x1 LDZ2 #08 + .Screen/x DEO2
.System/r DEI2 ,&draw-color-code JSR
.colorview/y1 LDZ2 #18 + .Screen/y DEO2
.colorview/x1 LDZ2 #10 + .Screen/x DEO2
.System/g DEI2 ,&draw-color-code JSR
.colorview/y1 LDZ2 #18 + .Screen/y DEO2
.colorview/x1 LDZ2 #18 + .Screen/x DEO2
.System/b DEI2 ,&draw-color-code JSR
RTN
&draw-color-code ( color* -- )
DUP ;font-hex ROT #0f AND #08 MUL #00 SWP ++ .Screen/addr DEO2
( draw ) #22 .Screen/color DEO
.colorview/y1 LDZ2 #10 + .Screen/y DEO2
;font-hex ROT #04 SFT #08 MUL #00 SWP ++ .Screen/addr DEO2
( draw ) #22 .Screen/color DEO
.colorview/y1 LDZ2 #08 + .Screen/y DEO2
DUP ;font-hex ROT #0f AND #08 MUL #00 SWP ++ .Screen/addr DEO2
( draw ) #22 .Screen/color DEO
.colorview/y1 LDZ2 .Screen/y DEO2
;font-hex ROT #04 SFT #08 MUL #00 SWP ++ .Screen/addr DEO2
( draw ) #22 .Screen/color DEO
RTN
RTN
@draw-preview ( -- )
( stash address )
.settings/tile LDZ2 DUP2 STH2 .Screen/addr DEO2
#00 #04
&ver
OVR #08 MUL TOS .preview/y1 LDZ2 ++ .Screen/y DEO2
#00 #04
&hor
OVR #08 MUL TOS .preview/x1 LDZ2 ++ .Screen/x DEO2
( get x,y )
SWP2 OVR STH SWP2 OVR STHr
( check if within ratio )
.settings/ratio LDZ #0f AND LTH STH
.settings/ratio LDZ #04 SFT LTH STHr
#0101 !! ,&outside JCN
( get tile ) DUP2r STH2r .Screen/addr DEO2
( get blending ) .settings/blending LDZ
( get depth ) .settings/depth LDZ #20 MUL
( draw ) #20 + + .Screen/color DEO
( incr ) STH2r #0008 [ .settings/depth LDZ #08 MUL TOS ++ ] ++ STH2
,&resume JMP
&outside
;halftone_icn .Screen/addr DEO2
#23 .Screen/color DEO
&resume
( incr ) SWP #01 + SWP
DUP2 LTH ,&hor JCN
POP2
( incr ) SWP #01 + SWP
DUP2 LTH ;&ver JCN2
POP2
POP2r
.preview/x1 LDZ2 #0001 -- .Screen/x DEO2
.preview/y2 LDZ2 #0001 ++ .Screen/y DEO2
.settings/ratio LDZ #23 ;draw-byte JSR2
RTN
@draw-cursor ( -- )
( clear last cursor )
.mouse/x LDZ2 .Screen/x DEO2
.mouse/y LDZ2 .Screen/y DEO2
#30 .Screen/color DEO
( record mouse positions )
.Mouse/x DEI2 .mouse/x STZ2
.Mouse/y DEI2 .mouse/y STZ2
( draw new cursor )
.mouse/x LDZ2 .Screen/x DEO2
.mouse/y LDZ2 .Screen/y DEO2
;tool_selector #00 .bankview/mode LDZ #08 MUL ++ .Screen/addr DEO2
#32 .Mouse/state DEI #00 NEQ + .Screen/color DEO
RTN
@draw-byte ( byte color -- )
STH STH
;font-hex #00 DUPr STHr #f0 AND #04 SFT #08 MUL ++ .Screen/addr DEO2
( draw ) OVRr STHr .Screen/color DEO
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
;font-hex #00 STHr #0f AND #08 MUL ++ .Screen/addr DEO2
( draw ) STHr .Screen/color DEO
RTN
@draw-short ( short* color -- )
STH SWP
DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
( draw ) DUPr STHr .Screen/color DEO
#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) DUPr STHr .Screen/color DEO
DUP #04 SFT TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) DUPr STHr .Screen/color DEO
#0f AND TOS #0008 ** ;font-hex ++ .Screen/addr DEO2
.Screen/x DEI2 #0008 ++ .Screen/x DEO2
( draw ) STHr .Screen/color DEO
RTN
( Utils )
@line-rect ( x1* y1* x2* y2* color -- )
( load ) .color STZ DUP2 STH2 .rect/y2 STZ2 .rect/x2 STZ2 DUP2 STH2 .rect/y1 STZ2 .rect/x1 STZ2
STH2r STH2r
&ver
( save ) OVR2 .Screen/y DEO2
( draw ) .rect/x1 LDZ2 .Screen/x DEO2 .color LDZ DUP .Screen/color DEO
( draw ) .rect/x2 LDZ2 .Screen/x DEO2 .Screen/color DEO
( incr ) SWP2 #0001 ++ SWP2
OVR2 OVR2 LTS2 ,&ver JCN
POP2 POP2
.rect/x1 LDZ2 .rect/x2 LDZ2
&hor
( save ) OVR2 .Screen/x DEO2
( draw ) .rect/y1 LDZ2 .Screen/y DEO2 .color LDZ DUP .Screen/color DEO
( draw ) .rect/y2 LDZ2 .Screen/y DEO2 .Screen/color DEO
( incr ) SWP2 #0001 ++ SWP2
OVR2 OVR2 #0001 ++ LTS2 ,&hor JCN
POP2 POP2
RTN
@fill-rect ( x1* y1* x2* y2* color -- )
.color STZ
( x1 x2 y1 y2 ) ROT2 SWP2
&ver
( save ) OVR2 .Screen/y DEO2
STH2 STH2 OVR2 OVR2
&hor
( save ) OVR2 .Screen/x DEO2
( draw ) .color LDZ .Screen/color DEO
( incr ) SWP2 #0001 ++ SWP2
OVR2 OVR2 LTS2 ,&hor JCN
POP2 POP2 STH2r STH2r
( incr ) SWP2 #0001 ++ SWP2
OVR2 OVR2 LTS2 ,&ver JCN
POP2 POP2 POP2 POP2
RTN
@line-hor ( x0* x1* y* color -- )
STH .Screen/y DEO2
&loop
( save ) OVR2 .Screen/x DEO2
( draw ) DUPr STHr .Screen/color DEO
( incr ) SWP2 #0002 ++ SWP2
OVR2 OVR2 << ,&loop JCN
POP2 POP2 POPr
RTN
@line-ver ( x* y0* y1* color -- )
STH ROT2 .Screen/x DEO2
&loop
( save ) OVR2 .Screen/y DEO2
( draw ) DUPr STHr .Screen/color DEO
( incr ) SWP2 #0002 ++ SWP2
OVR2 OVR2 << ,&loop JCN
POP2 POP2 POPr
RTN
@tool_selector 80c0 e0f0 f8e0 1000
@tool_hand 2020 20b8 7c7c 3838
@tool_eraser 2050 b87c 3e1c 0800
@moveup_icn 0010 387c fe10 1000
@movedown_icn 0010 1010 fe7c 3810
@halftone_icn aa55 aa55 aa55 aa55
@circle_icns
0038 7cfe fefe 7c38 ( full )
0038 4482 8282 4438 ( line )
@eye_icns
0038 4492 2810 0000 ( open )
0000 0082 4438 0000 ( closed )
@blank_icn
0000 0000 0000 0000
7cfe fefe fefe 7c00
@depth_icns
00fe 8282 fe82 82fe
00fe 9292 fe92 92fe
@font-hex
007c 8282 8282 827c 0030 1010 1010 1010
007c 8202 7c80 80fe 007c 8202 1c02 827c
000c 1424 4484 fe04 00fe 8080 7c02 827c
007c 8280 fc82 827c 007c 8202 1e02 0202
007c 8282 7c82 827c 007c 8282 7e02 827c
007c 8202 7e82 827e 00fc 8282 fc82 82fc
007c 8280 8080 827c 00fc 8282 8282 82fc
007c 8280 f080 827c 007c 8280 f080 8080
@filepath1 [ "projects/fonts/specter8.bit 00 ]
@filepath2 [ "projects/pictures/cyr10x8.chr 00 ]
@filepath3 [ "projects/pictures/zerotwo10x10.chr 00 ]
@filepath4 [ "projects/fonts/katahira8.bit 00 ]
@filepath5 [ "projects/pictures/ako10x10.chr 00 ]
@filepath6 [ "projects/pictures/logo1x1.bit 00 ]
Loading…
Cancel
Save