Optimized drawing
This commit is contained in:
parent
89a558bde7
commit
e865be5d88
|
@ -9,7 +9,6 @@
|
||||||
- Scrollbar
|
- Scrollbar
|
||||||
- Don't scroll past oef
|
- Don't scroll past oef
|
||||||
- Hor scroll
|
- Hor scroll
|
||||||
- Follow cursor when moving out of the screen
|
|
||||||
- Real scrolling distance
|
- Real scrolling distance
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -31,7 +30,7 @@
|
||||||
&Touch2d { x1 2 y1 2 x2 2 y2 2 state 1 }
|
&Touch2d { x1 2 y1 2 x2 2 y2 2 state 1 }
|
||||||
|
|
||||||
;lock 1
|
;lock 1
|
||||||
;i 2 ;j 2 ;addr 2
|
;i 2 ;j 2 ;k 1 ;l 1 ;addr 2
|
||||||
|
|
||||||
;selection Range2d ;position Point2d ;scroll Point2d
|
;selection Range2d ;position Point2d ;scroll Point2d
|
||||||
|
|
||||||
|
@ -63,21 +62,21 @@ BRK
|
||||||
,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 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
|
||||||
@no-ctrl-up
|
@no-ctrl-up
|
||||||
,no-ctrl-down ~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 ,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
|
||||||
@no-ctrl-down
|
@no-ctrl-down
|
||||||
,no-ctrl-left ~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,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
|
||||||
@no-ctrl-left
|
@no-ctrl-left
|
||||||
,no-ctrl-right ~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,follow-selection JSR2 ,redraw JSR2 ,ctrl-end JMP2
|
||||||
@no-ctrl-right
|
@no-ctrl-right
|
||||||
( alt )
|
( alt )
|
||||||
,no-alt ~CTRL #0f AND #02 NEQ JMP2? POP2
|
,no-alt ~CTRL #0f AND #02 NEQ JMP2? POP2
|
||||||
|
@ -101,11 +100,11 @@ BRK
|
||||||
( ctrl )
|
( ctrl )
|
||||||
,no-ctrl ~CTRL #0f AND #01 NEQ JMP2? POP2
|
,no-ctrl ~CTRL #0f AND #01 NEQ JMP2? POP2
|
||||||
,no-cup ~CTRL #04 ROR #01 NEQ JMP2? POP2
|
,no-cup ~CTRL #04 ROR #01 NEQ JMP2? POP2
|
||||||
~scroll.y #0004 SUB2 =scroll.y
|
#0004 ,scroll-up JSR2
|
||||||
,redraw JSR2 ,ctrl-end JMP2
|
,redraw JSR2 ,ctrl-end JMP2
|
||||||
@no-cup
|
@no-cup
|
||||||
,no-cdown ~CTRL #04 ROR #02 NEQ JMP2? POP2
|
,no-cdown ~CTRL #04 ROR #02 NEQ JMP2? POP2
|
||||||
~scroll.y #0004 ADD2 =scroll.y
|
#0004 ,scroll-down JSR2
|
||||||
,redraw JSR2 ,ctrl-end JMP2
|
,redraw JSR2 ,ctrl-end JMP2
|
||||||
@no-cdown
|
@no-cdown
|
||||||
,no-cleft ~CTRL #04 ROR #04 NEQ JMP2? POP2
|
,no-cleft ~CTRL #04 ROR #04 NEQ JMP2? POP2
|
||||||
|
@ -240,6 +239,22 @@ RTS
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@scroll-up ( length )
|
||||||
|
|
||||||
|
DUP2 ~scroll.y LTH2 ,$clamp ROT JMP2? POP2
|
||||||
|
#0000 =scroll.y POP2 RTS
|
||||||
|
$clamp
|
||||||
|
~scroll.y SWP2 SUB2 =scroll.y
|
||||||
|
|
||||||
|
RTS
|
||||||
|
|
||||||
|
@scroll-down ( length )
|
||||||
|
|
||||||
|
( TODO: Clamp )
|
||||||
|
~scroll.y SWP2 ADD2 =scroll.y
|
||||||
|
|
||||||
|
RTS
|
||||||
|
|
||||||
@shift-left ( length )
|
@shift-left ( length )
|
||||||
|
|
||||||
=i
|
=i
|
||||||
|
@ -256,14 +271,25 @@ RTS
|
||||||
|
|
||||||
=i
|
=i
|
||||||
~document.eof =j ( end -> start )
|
~document.eof =j ( end -> start )
|
||||||
@shift-right-loop NOP
|
$loop NOP
|
||||||
( move ) ~j ~i SUB2 LDR ~j STR
|
( move ) ~j ~i SUB2 LDR ~j STR
|
||||||
( decr ) ~j #0001 SUB2 =j
|
( decr ) ~j #0001 SUB2 =j
|
||||||
~j ~selection.from GTH2 ^shift-right-loop MUL JMPS
|
~j ~selection.from GTH2 ^$loop MUL JMPS
|
||||||
~document.eof ~i ADD2 =document.eof
|
~document.eof ~i ADD2 =document.eof
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@follow-selection
|
||||||
|
|
||||||
|
,$no-up ~position.y ~scroll.y GTH2 JMP2? POP2
|
||||||
|
~position.y =scroll.y RTS
|
||||||
|
$no-up
|
||||||
|
,$no-down ~position.y ~SCRN.height #0010 SUB2 #0008 DIV2 ~scroll.y ADD2 LTH2 JMP2? POP2
|
||||||
|
~position.y ~SCRN.height #0010 SUB2 #0008 DIV2 SUB2 =scroll.y RTS
|
||||||
|
$no-down
|
||||||
|
|
||||||
|
RTS
|
||||||
|
|
||||||
@clamp-selection
|
@clamp-selection
|
||||||
|
|
||||||
~selection.from ~selection.to LTH2 RTS?
|
~selection.from ~selection.to LTH2 RTS?
|
||||||
|
@ -380,10 +406,10 @@ RTS
|
||||||
#0000 =i ( start )
|
#0000 =i ( start )
|
||||||
~selection.to ~selection.from SUB2 =j ( end )
|
~selection.to ~selection.from SUB2 =j ( end )
|
||||||
~j =clip.len
|
~j =clip.len
|
||||||
$loop
|
$loop NOP
|
||||||
~selection.from ~i ADD2 LDR ,clip.body ~i ADD2 STR
|
~selection.from ~i ADD2 LDR ,clip.body ~i ADD2 STR
|
||||||
( incr ) ~i #0001 ADD2 =i
|
( incr ) ~i #0001 ADD2 =i
|
||||||
,$loop ~i ~j LTH2 JMP2? POP2
|
~i ~j LTH2 ^$loop MUL JMPS
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -392,10 +418,10 @@ RTS
|
||||||
~clip.len ,shift-right JSR2
|
~clip.len ,shift-right JSR2
|
||||||
#0000 =i ( start )
|
#0000 =i ( start )
|
||||||
~clip.len =j ( end )
|
~clip.len =j ( end )
|
||||||
$loop
|
$loop NOP
|
||||||
,clip.body ~i ADD2 LDR ~selection.from ~i ADD2 STR
|
,clip.body ~i ADD2 LDR ~selection.from ~i ADD2 STR
|
||||||
( incr ) ~i #0001 ADD2 =i
|
( incr ) ~i #0001 ADD2 =i
|
||||||
,$loop ~i ~j LTH2 JMP2? POP2
|
~i ~j LTH2 ^$loop MUL JMPS
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
@ -421,43 +447,21 @@ RTS
|
||||||
|
|
||||||
@redraw
|
@redraw
|
||||||
|
|
||||||
,draw-lines JSR2
|
|
||||||
,draw-textarea JSR2
|
,draw-textarea JSR2
|
||||||
,draw-scrollbar JSR2
|
,draw-scrollbar JSR2
|
||||||
,draw-titlebar JSR2
|
,draw-titlebar JSR2
|
||||||
|
|
||||||
( save/load icons )
|
( save/load icons )
|
||||||
|
|
||||||
~SCRN.height #0008 SUB2 =SPRT.y
|
~SCRN.height #0008 SUB2 =SPRT.y
|
||||||
|
|
||||||
~SCRN.width #0018 SUB2 =SPRT.x
|
~SCRN.width #0018 SUB2 =SPRT.x
|
||||||
,load_icn =SPRT.addr
|
,load_icn =SPRT.addr
|
||||||
#02 =SPRT.color
|
#02 =SPRT.color
|
||||||
|
|
||||||
~SCRN.width #0010 SUB2 =SPRT.x
|
~SCRN.width #0010 SUB2 =SPRT.x
|
||||||
,save_icn =SPRT.addr
|
,save_icn =SPRT.addr
|
||||||
#02 =SPRT.color
|
#02 =SPRT.color
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@draw-lines
|
|
||||||
|
|
||||||
#0000 =j
|
|
||||||
#0000 =SPRT.x #0000 =SPRT.y
|
|
||||||
$loop
|
|
||||||
~scroll.y ~j ADD2 =addr
|
|
||||||
#0000 =SPRT.x
|
|
||||||
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
|
|
||||||
( draw ) #02 ~addr ~position.y EQU2 #0c MUL ADD =SPRT.color
|
|
||||||
#0008 =SPRT.x
|
|
||||||
,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =SPRT.addr
|
|
||||||
( draw ) #02 ~addr ~position.y EQU2 #0c MUL ADD =SPRT.color
|
|
||||||
( incr ) ~j #0001 ADD2 =j
|
|
||||||
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
|
|
||||||
,$loop ~j ~SCRN.height #0008 SUB2 #0008 DIV2 NEQ2 JMP2? POP2
|
|
||||||
|
|
||||||
RTS
|
|
||||||
|
|
||||||
@draw-short ( short )
|
@draw-short ( short )
|
||||||
|
|
||||||
=addr
|
=addr
|
||||||
|
@ -506,39 +510,36 @@ RTS
|
||||||
|
|
||||||
( scroll to position )
|
( scroll to position )
|
||||||
#0000 =j ( j is linebreaks )
|
#0000 =j ( j is linebreaks )
|
||||||
@find-scroll-offset NOP
|
$find-offset NOP
|
||||||
,find-scroll-offset-end ~scroll.y ~j EQU2 JMP2? POP2
|
,$find-offset-end ~scroll.y ~j EQU2 JMP2? POP2
|
||||||
,no-break ~textarea.addr LDR #0a NEQ ~textarea.addr LDR #0d NEQ #0101 EQU2 JMP2? POP2
|
,$no-break ~textarea.addr LDR #0a NEQ ~textarea.addr LDR #0d NEQ #0101 EQU2 JMP2? POP2
|
||||||
( incr ) ~j #0001 ADD2 =j
|
( incr ) ~j #0001 ADD2 =j
|
||||||
@no-break
|
$no-break
|
||||||
( incr ) ~textarea.addr #0001 ADD2 =textarea.addr
|
( incr ) ~textarea.addr #0001 ADD2 =textarea.addr
|
||||||
~textarea.addr LDR #00 NEQ ^find-scroll-offset MUL JMPS
|
~textarea.addr LDR #00 NEQ ^$find-offset MUL JMPS
|
||||||
@find-scroll-offset-end
|
$find-offset-end
|
||||||
|
|
||||||
~textarea.addr #0000 ADD2 =textarea.addr
|
#0018 =SPRT.x #0000 =SPRT.y
|
||||||
#0000 =SPRT.y
|
~textarea.addr =i
|
||||||
~textarea.addr =j
|
|
||||||
|
|
||||||
#0018 =SPRT.x
|
|
||||||
|
|
||||||
$loop
|
$loop
|
||||||
|
|
||||||
,$end ~SPRT.y ~SCRN.height #0010 SUB2 GTH2 JMP2? POP2
|
,$end ~SPRT.y ~SCRN.height #0010 SUB2 GTH2 JMP2? POP2
|
||||||
|
|
||||||
( get character )
|
( get character )
|
||||||
,font #00 ~j LDR #20 SUB #0008 MUL2 ADD2 =SPRT.addr
|
,font #00 ~i LDR #20 SUB #0008 MUL2 ADD2 =SPRT.addr
|
||||||
|
|
||||||
( draw ) #01
|
( draw ) #01
|
||||||
~j ~selection.from #0001 SUB2 GTH2
|
~i ~selection.from #0001 SUB2 GTH2
|
||||||
~j ~selection.to LTH2 #0101 EQU2
|
~i ~selection.to LTH2 #0101 EQU2
|
||||||
#05 MUL ADD =SPRT.color
|
#05 MUL ADD =SPRT.color
|
||||||
|
|
||||||
,$no-linebreak ~j LDR #0a NEQ ~j LDR #0d NEQ #0101 EQU2 JMP2? POP2
|
,$no-linebreak ~i LDR #0a NEQ ~i LDR #0d NEQ #0101 EQU2 JMP2? POP2
|
||||||
( draw linebreak )
|
( draw linebreak )
|
||||||
,linebreak_icn =SPRT.addr
|
,linebreak_icn =SPRT.addr
|
||||||
( draw ) #02
|
( draw ) #02
|
||||||
~j ~selection.from #0001 SUB2 GTH2
|
~i ~selection.from #0001 SUB2 GTH2
|
||||||
~j ~selection.to LTH2 #0101 EQU2
|
~i ~selection.to LTH2 #0101 EQU2
|
||||||
#06 MUL ADD =SPRT.color
|
#06 MUL ADD =SPRT.color
|
||||||
( fill clear )
|
( fill clear )
|
||||||
$fill-clear
|
$fill-clear
|
||||||
|
@ -546,14 +547,26 @@ RTS
|
||||||
,font =SPRT.addr
|
,font =SPRT.addr
|
||||||
#01 =SPRT.color
|
#01 =SPRT.color
|
||||||
,$fill-clear ~SPRT.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2
|
,$fill-clear ~SPRT.x ~SCRN.width #0008 SUB2 LTH2 JMP2? POP2
|
||||||
|
|
||||||
|
( draw line number )
|
||||||
|
|
||||||
|
#0000 =SPRT.x
|
||||||
|
~scroll.y ~SPRT.y #0008 DIV2 ADD2 DUP2 SWP POP =k
|
||||||
|
~position.y EQU2 #0c MUL =l
|
||||||
|
,font_hex #00 ~k #f0 AND #04 ROR #08 MUL ADD2 =SPRT.addr
|
||||||
|
#02 ~l ADD =SPRT.color
|
||||||
|
#0008 =SPRT.x
|
||||||
|
,font_hex #00 ~k #0f AND #08 MUL ADD2 =SPRT.addr
|
||||||
|
#02 ~l ADD =SPRT.color
|
||||||
|
|
||||||
#0010 =SPRT.x
|
#0010 =SPRT.x
|
||||||
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
|
( incr ) ~SPRT.y #0008 ADD2 =SPRT.y
|
||||||
$no-linebreak
|
$no-linebreak
|
||||||
|
|
||||||
( incr ) ~j #0001 ADD2 =j
|
( incr ) ~i #0001 ADD2 =i
|
||||||
( incr ) ~SPRT.x #0007 ADD2 =SPRT.x
|
( incr ) ~SPRT.x #0007 ADD2 =SPRT.x
|
||||||
|
|
||||||
,$loop ~j LDR #00 NEQ JMP2? POP2
|
,$loop ~i LDR #00 NEQ JMP2? POP2
|
||||||
|
|
||||||
$end
|
$end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue