Added keyboard controls to nasu

This commit is contained in:
neauoire 2021-03-05 10:38:18 -08:00
parent 339854c8ea
commit 0c99df4b37
4 changed files with 19 additions and 152 deletions

View File

@ -90,17 +90,6 @@ RTS
- Load external disk in disk2
- Build hex editor
- Build sprite editor
### Examples
- Basics:
- Simple drag/drop redraw
- Window basics with open/close drag/drop redraw
- Example of button pointing to a subroutine
- GUI:
- Line routine
- Extra frame buffer addressing? Mirror sprites?
### Assembler

View File

@ -1,45 +0,0 @@
( app/hex )
&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
;color 1 ;addr 2 ;i 1
|0100 @RESET
@loop
#00 ~i #0018 MUL2 #0008 ADD2 #0040 #01 ,font #00 ~i ADD2 ,draw-byte JSR
( incr ) ~i #01 ADD =i
,loop ~i #08 LTH JMP? POP2
BRK
|0200 @FRAME BRK
@draw-byte ( x y color addr )
( load ) =addr =color =dev/sprite.y =dev/sprite.x
,font #00 ~addr LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr #01 =dev/sprite.color
~dev/sprite.x #0008 ADD2 =dev/sprite.x
,font #00 ~addr LDR #0f AND #08 MUL ADD2 =dev/sprite.addr #01 =dev/sprite.color
RTS
@font ( 0-F )
[
7c82 8282 8282 7c00 3010 1010 1010 1000
7c82 027c 8080 fe00 7c82 027c 0282 7c00
4282 82fe 0202 0200 fc82 807c 0282 7c00
7c82 80fc 8282 7c00 7c82 021e 0202 0200
7c82 827c 8282 7c00 7c82 827e 0202 0400
7c82 027e 8282 7e00 fc82 82fc 8282 fc00
7c82 8080 8082 7c00 fc82 8282 8282 fc00
7c82 80f0 8082 7c00 7c82 80f0 8080 8000
]
|d000 @ERROR BRK
|FF20 ;dev/sprite Sprite
|FFF0 .RESET .FRAME .ERROR ( vectors )
|FFF8 [ 13fd 1ef3 1bf2 ] ( palette )

View File

@ -1,8 +1,15 @@
( app/nasu )
(
arrows - move
click - Paint/Select cell
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 }
@ -41,6 +48,16 @@ BRK
( keyboard controls )
,no-key ~dev/key #00 EQU JMP? POP2
,no-key ~dev/key #31 LTH JMP? POP2
,no-key ~dev/key #33 GTH JMP? POP2
( select ) ~dev/key #31 SUB =bankview.mode
( release ) #00 =dev/key
,redraw JSR
@no-key
,no-ctrl ~dev/ctrl.buttons #00 EQU JMP? POP2
,no-ctrl-up ~dev/ctrl.buttons #10 EQU JMP? POP2
@ -69,7 +86,7 @@ BRK
,no-toolbar-click ~dev/mouse.y ~bankview.y #0010 SUB2 SUB2 #0008 DIV2 #0000 NEQ2 JMP? POP2
( brush )
,no-brush-click ~dev/mouse.x ~bankview.x SUB2 #0008 DIV2 #000d LTH2 JMP? POP2
,no-brush-click ~dev/mouse.x ~bankview.x SUB2 #0008 DIV2 #000f GTH2 JMP? POP2
( select ) ~mouse.x ~bankview.x SUB2 #0008 DIV2 #000d SUB2 SWP POP =bankview.mode
@ -694,6 +711,7 @@ RTS
|FF10 ;dev/screen Screen
|FF20 ;dev/sprite Sprite
|FF30 ;dev/ctrl Controller
|FF40 ;dev/key Keyboard
|FF50 ;dev/mouse Mouse
|FF60 ;dev/file File

View File

@ -1,95 +0,0 @@
( sprite )
:dev/r fff8 ( std read port )
:dev/w fff9 ( std write port )
&Point2d { x 2 y 2 }
;mouse Point2d
;state 1 ;color 1 ;brush 2
|0100 @RESET
#05 =dev/r ( set dev/read mouse )
#02 =dev/w ( set dev/write to sprite )
#05 =color ( select a default color )
,brush_large =brush ( select a default brush )
,draw-interface JSR
BRK
|c000 @FRAME
( clear last cursor )
#10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR
( record mouse values )
#00 IOR2 =mouse.x #02 IOR2 =mouse.y
#04 IOR #11 ADD =state
~state ,cursor_icn ~mouse.x ~mouse.y ,draw-sprite JSR
( check click )
#04 IOR #00 EQU ,end-touch ROT JMP? POP2
( check interface )
#00 IOR2 #0008 DIV2 #0001 NEQ2 ,end-interface ROT JMP? POP2
@option0
#02 IOR2 #0008 DIV2 #0004 NEQ2 ,option1 ROT JMP? POP2
,brush_large =brush BRK
@option1
#02 IOR2 #0008 DIV2 #0005 NEQ2 ,option2 ROT JMP? POP2
,brush_small =brush BRK
@option2
#02 IOR2 #0008 DIV2 #0006 NEQ2 ,option3 ROT JMP? POP2
,brush_tiny =brush BRK
@option3
#02 IOR2 #0008 DIV2 #000b NEQ2 ,option4 ROT JMP? POP2
#05 =color BRK
@option4
#02 IOR2 #0008 DIV2 #000c NEQ2 ,option5 ROT JMP? POP2
#0a =color BRK
@option5
#02 IOR2 #0008 DIV2 #000d NEQ2 ,option6 ROT JMP? POP2
#0f =color BRK
@option6
BRK
@end-interface
~color ~brush ~mouse.x #0004 SUB2 ~mouse.y #0004 SUB2 ,draw-sprite JSR
@end-touch
BRK
@draw-interface
#05 ,brush_large #0008 #0020 ,draw-sprite JSR
#05 ,brush_small #0008 #0028 ,draw-sprite JSR
#05 ,brush_tiny #0008 #0030 ,draw-sprite JSR
#05 ,brush_large #0008 #0058 ,draw-sprite JSR
#0a ,brush_large #0008 #0060 ,draw-sprite JSR
#0f ,brush_large #0008 #0068 ,draw-sprite JSR
RTS
@draw-sprite
IOW2 ( y byte )
IOW2 ( x byte )
IOW2 ( sprite address )
IOW ( layer-color )
RTS
|0200 @SPRITESHEET
@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
@clear_icn [ 0000 0000 0000 0000 ]
@brush_large [ 387c fefe fe7c 3800 ]
@brush_small [ 0038 7c7c 7c38 0000 ]
@brush_tiny [ 0000 1038 1000 0000 ]
BRK
|d000 @ERROR BRK
|FFF0 .RESET .FRAME .ERROR
|FFF8 [ f1c3 f12e f12a ] ( palette )