Author: wmb
Date: 2009-08-25 09:10:54 +0200 (Tue, 25 Aug 2009)
New Revision: 1329
Modified:
cpu/x86/fb8-ops.fth
dev/olpc/touchpad/touchpad.fth
dev/ps2mouse.fth
ofw/gui/button.fth
ofw/gui/graphics.fth
ofw/gui/iconmenu.fth
ofw/gui/mouse.fth
ofw/termemu/fb8.fth
ofw/termemu/framebuf.fth
Log:
Via - Made the mouse work for the selftest menu.
Modified: cpu/x86/fb8-ops.fth
===================================================================
--- cpu/x86/fb8-ops.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ cpu/x86/fb8-ops.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -406,6 +406,64 @@
8 /n* # sp add
c;
+code fb8-merge ( color bits dst-adr width -- )
+ cx pop \ CX: width
+ dx pop \ DX: adr
+ bx pop \ BX: bits
+ ax pop \ AX: color
+ di push \ Save DI
+ dx di mov \ DI: adr
+ ax dx mov \ DX: color
+ begin
+ bx bx add \ Shift out high bit
+ carry? if
+ al stos
+ else
+ di inc
+ then
+ loopa
+ di pop \ Restore DI
+c;
+
+code fb16-merge ( color bits dst-adr width -- )
+ cx pop \ CX: width
+ dx pop \ DX: adr
+ bx pop \ BX: bits
+ ax pop \ AX: color
+ di push \ Save DI
+ dx di mov \ DI: adr
+ ax dx mov \ DX: color
+ begin
+ bx bx add \ Shift out high bit
+ carry? if
+ op: ax stos
+ else
+ 2 [di] di lea
+ then
+ loopa
+ di pop \ Restore DI
+c;
+
+code fb32-merge ( color bits dst-adr width -- )
+ cx pop \ CX: width
+ dx pop \ DX: adr
+ bx pop \ BX: bits
+ ax pop \ AX: color
+ di push \ Save DI
+ dx di mov \ DI: adr
+ ax dx mov \ DX: color
+ begin
+ bx bx add \ Shift out high bit
+ carry? if
+ ax stos
+ else
+ 4 [di] di lea
+ then
+ loopa
+ di pop \ Restore DI
+c;
+
+
headers
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
Modified: dev/olpc/touchpad/touchpad.fth
===================================================================
--- dev/olpc/touchpad/touchpad.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ dev/olpc/touchpad/touchpad.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -55,12 +55,6 @@
\ get-data waits for and reads a data byte
-\ The normal mouse driver uses remote mode, but this device
-\ doesn't support remote mode, so patch the mouse driver
-\ "open" routine to substitute "noop" for "remote-mode".
-
-patch noop remote-mode open
-
variable ptr
0 value show-raw?
@@ -117,6 +111,13 @@
then
;
+\ The normal mouse driver uses remote mode, but this device
+\ doesn't support remote mode, so patch the mouse driver
+\ "open" routine to substitute "noop" for "remote-mode".
+
+patch start remote-mode open
+
+
\ I have been unable to get this to work. The response is always
\ 64 0 <something>, which doesn't agree with the spec.
\ Perhaps the touchpad version that I have doesn't implement the,
Modified: dev/ps2mouse.fth
===================================================================
--- dev/ps2mouse.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ dev/ps2mouse.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -313,10 +313,16 @@
dup if clear-out-buf then ( error? )
;
+0 value open-count
+
headers
: open ( -- flag )
1 set-port
+ open-count 1+ to open-count
+
+ open-count 1 <> if true exit then
+
\ The "force" argument causes the open to succeed even if no mouse
\ is present
my-args [char] , left-parse-string 2swap 2drop " force" $= if
@@ -331,7 +337,10 @@
remote-mode
true
;
-: close ( -- ) stream-off ;
+: close ( -- )
+ open-count 1 = if stream-off then
+ open-count 1- 0 max to open-count
+;
headerless
\ Filter out large negative motions; they're probably spurious
Modified: ofw/gui/button.fth
===================================================================
--- ofw/gui/button.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ ofw/gui/button.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -218,7 +218,7 @@
def-alert-col-row alert-text-box center-text key drop restore-rectangle
;
: setup ( -- )
- screen-ih 0= if open-devices set-menu-colors then
+ ?open-screen set-menu-colors ?open-mouse
clear-menu install-menu cursor-off refresh
;
[then]
Modified: ofw/gui/graphics.fth
===================================================================
--- ofw/gui/graphics.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ ofw/gui/graphics.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -40,6 +40,7 @@
;
: $call-screen ( ??? adr len -- ??? ) screen-ih $call-method ;
+: screen-execute ( ?? xt -- ?? ) screen-ih package( execute )package ;
\ : screen-wh ( -- x y )
\ screen-ih package( screen-width screen-height )package
@@ -68,9 +69,8 @@
" set-colors" $call-screen
;
-: bytes/pixel ( -- n ) " depth" $call-screen 8 / ;
-: alloc-pixels ( #pixels -- adr ) bytes/pixel * alloc-mem ;
-: free-pixels ( adr #pixels -- ) bytes/pixel * free-mem ;
+: alloc-pixels ( #pixels -- adr ) ['] pix* screen-execute alloc-mem ;
+: free-pixels ( adr #pixels -- ) ['] pix* screen-execute free-mem ;
: fill-rectangle ( color x y w h - )
?inset " fill-rectangle" $call-screen
Modified: ofw/gui/iconmenu.fth
===================================================================
--- ofw/gui/iconmenu.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ ofw/gui/iconmenu.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -416,17 +416,21 @@
bb bb bb 15 set-color \ Bright gray for CD-ROM icon
;
-: open-devices ( -- )
- " screen" open-dev is screen-ih
+: ?open-screen ( -- )
+ screen-ih 0= if
+ " screen" open-dev is screen-ih
+ then
+;
+: ?open-mouse ( -- )
mouse-ih 0= if
- " mouse" open-dev to mouse-ih \ Try alias first
+ " mouse" open-dev is mouse-ih
mouse-ih 0= if
" /mouse" open-dev to mouse-ih
then
- alloc-mouse-cursor
+ mouse-ih if alloc-mouse-cursor then
then
;
-
+
true config-flag menu?
0 value default-selection
@@ -468,7 +472,7 @@
;
: setup-graphics ( -- )
- screen-ih 0= if open-devices set-menu-colors then
+ ?open-screen set-menu-colors ?open-mouse
;
: setup-menu ( -- )
setup-graphics
Modified: ofw/gui/mouse.fth
===================================================================
--- ofw/gui/mouse.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ ofw/gui/mouse.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -18,6 +18,7 @@
\ ' move-cursor is handle-movement
\ mouse position is kept in values x and y
+0 [if]
d# 16 constant cursor-w
d# 16 constant cursor-h
@@ -36,34 +37,93 @@
78000000 , 58000000 , 0c000000 , 0c000000 ,
\ 04000000 , 06000000 , 02000000 , 00000000 ,
06000000 , 06000000 , 00000000 , 00000000 ,
+[else]
+d# 17 constant cursor-w
+d# 31 constant cursor-h
-: merge-line ( color mask adr -- )
- cursor-w bounds ?do ( color mask )
- dup h# 80000000 and if over i c! then ( color mask )
- 2* ( color mask' )
- loop
- 2drop
-;
-: merge-rect ( color mask-adr rect-adr -- )
- cursor-h 0 do ( color mask-adr rect-adr )
- 3dup swap @ swap merge-line
- swap na1+ swap cursor-w +
- loop
- 3drop
-;
+create white-bits
+binary
+ 11000000000000000000000000000000 ,
+ 11100000000000000000000000000000 ,
+ 11011000000000000000000000000000 ,
+ 11001100000000000000000000000000 ,
+ 11000110000000000000000000000000 ,
+ 11000011000000000000000000000000 ,
+ 11000001100000000000000000000000 ,
+ 11000000110000000000000000000000 ,
+ 11000000011000000000000000000000 ,
+ 11000000001100000000000000000000 ,
+ 11000000000110000000000000000000 ,
+ 11000000000011000000000000000000 ,
+ 11000000000001100000000000000000 ,
+ 11000000000000110000000000000000 ,
+ 11000000000000011000000000000000 ,
+ 11000000000000001100000000000000 ,
+ 11000000000111111000000000000000 ,
+ 11000000000011000000000000000000 ,
+ 11000110000011000000000000000000 ,
+ 11001110000001100000000000000000 ,
+ 11010011000001100000000000000000 ,
+ 11100011000000110000000000000000 ,
+ 00000001100000110000000000000000 ,
+ 00000001100000011000000000000000 ,
+ 00000000110000011000000000000000 ,
+ 00000000110000001100000000000000 ,
+ 00000000011000001100000000000000 ,
+ 00000000011000000110000000000000 ,
+ 00000000001100011000000000000000 ,
+ 00000000000111110000000000000000 ,
+ 00000000000111110000000000000000 ,
+create black-bits
+ 00000000000000000000000000000000 ,
+ 00000000000000000000000000000000 ,
+ 00100000000000000000000000000000 ,
+ 00110000000000000000000000000000 ,
+ 00111000000000000000000000000000 ,
+ 00111100000000000000000000000000 ,
+ 00111110000000000000000000000000 ,
+ 00111111000000000000000000000000 ,
+ 00111111100000000000000000000000 ,
+ 00111111110000000000000000000000 ,
+ 00111111111000000000000000000000 ,
+ 00111111111100000000000000000000 ,
+ 00111111111110000000000000000000 ,
+ 00111111111111000000000000000000 ,
+ 00111111111111100000000000000000 ,
+ 00111111111111110000000000000000 ,
+ 00111111111000000000000000000000 ,
+ 00111111111100000000000000000000 ,
+ 00111001111100000000000000000000 ,
+ 00110001111110000000000000000000 ,
+ 00100000111110000000000000000000 ,
+ 00000000111111000000000000000000 ,
+ 00000000011111000000000000000000 ,
+ 00000000011111100000000000000000 ,
+ 00000000001111100000000000000000 ,
+ 00000000001111110000000000000000 ,
+ 00000000000111110000000000000000 ,
+ 00000000000111110000000000000000 ,
+ 00000000000011100000000000000000 ,
+ 00000000000000000000000000000000 ,
+ 00000000000000000000000000000000 ,
+hex
+[then]
+
+
+
0 value /rect
0 value old-rect
0 value new-rect
: alloc-mouse-cursor ( -- )
- cursor-w cursor-h * bytes/pixel * to /rect
+ cursor-w cursor-h * ['] pix* screen-execute to /rect
cursor-w cursor-h * alloc-pixels to old-rect
cursor-w cursor-h * alloc-pixels to new-rect
;
: merge-cursor ( -- )
- 0f white-bits new-rect merge-rect
- 00 black-bits new-rect merge-rect
+ background white-bits new-rect cursor-w cursor-h ['] merge-rect screen-execute
+ black black-bits new-rect cursor-w cursor-h ['] merge-rect screen-execute
;
: put-cursor ( x y adr -- )
@@ -88,7 +148,7 @@
: update-position ( x y -- )
2dup or 0= if 2drop exit then \ Avoid flicker if there is no movement
- \ Minimize the time the cursor is down by doing computation in advance
+ \ Minimize the time the cursor is down by doing computa1000000000000000000 ,tion in advance
\ Considering the amount of code that is executed to put up the cursor,
\ this optimization is probable unnoticeable, but it doesn't cost much.
negate ypos + 0 max-y cursor-h - clamp ( x y' )
Modified: ofw/termemu/fb8.fth
===================================================================
--- ofw/termemu/fb8.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ ofw/termemu/fb8.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -240,6 +240,48 @@
bytes/line + ( #bytes adr' )
loop 2drop ( )
;
+
+[ifndef] fb8-merge
+: fb8-merge ( color bits dst-adr width -- )
+ bounds ?do ( color mask )
+ dup h# 80000000 and if ( color mask )
+ over i c! ( color mask )
+ then ( color mask )
+ 2* ( color mask' )
+ loop ( color mask )
+ 2drop ( )
+;
+: fb16-merge ( color bits dst-adr width -- )
+ cursor-w /w* bounds ?do ( color mask )
+ dup h# 80000000 and if ( color mask )
+ over i w! ( color mask )
+ then ( color mask )
+ 2* ( color mask' )
+ /w +loop ( color mask )
+ 2drop ( )
+;
+: fb32-merge ( color bits dst-adr width -- )
+ cursor-w /l* bounds ?do ( color mask )
+ dup h# 80000000 and if ( color mask )
+ over i l! ( color mask )
+ then ( color mask )
+ 2* ( color mask' )
+ /l +loop ( color mask )
+ 2drop ( )
+;
+[then]
+
+\ This is used for cursor painting. Call it via screen-execute
+
+: merge-rect ( color mask-adr dst-adr width height -- )
+ 0 ?do ( color mask-adr rect-adr width )
+ 2over @ 2over fb-merge ( color mask-adr rect-adr width )
+ rot na1+ -rot ( color mask-adr' rect-adr width )
+ tuck pix* + swap ( color mask-adr rect-adr' width )
+ loop
+ 4drop
+;
+
headers
: fb8-insert-characters ( #chars -- )
#columns column# - min dup
@@ -251,6 +293,7 @@
column# + column# ( #chars' cursor+count-col# cursor-col# )
move-chars ( #chars' ) #columns over - erase-chars
;
+
headerless
: center-display ( -- )
@@ -266,6 +309,7 @@
['] fb8-invert to fb-invert
['] fill to fb-fill
['] fb8-paint to fb-paint
+ ['] fb8-merge to fb-merge
['] colors-8bpp to fb-16map
endof
@@ -274,6 +318,7 @@
['] fb16-invert to fb-invert
['] wfill to fb-fill
['] fb16-paint to fb-paint
+ ['] fb16-merge to fb-merge
['] colors-565 to fb-16map
endof
@@ -282,6 +327,7 @@
['] fb32-invert to fb-invert
['] lfill to fb-fill
['] fb32-paint to fb-paint
+ ['] fb32-merge to fb-merge
['] colors-32bpp to fb-16map
endof
endcase
Modified: ofw/termemu/framebuf.fth
===================================================================
--- ofw/termemu/framebuf.fth 2009-08-25 04:37:54 UTC (rev 1328)
+++ ofw/termemu/framebuf.fth 2009-08-25 07:10:54 UTC (rev 1329)
@@ -76,6 +76,7 @@
termemu-defer fb-fill
termemu-defer fb-paint
termemu-defer fb-16map
+termemu-defer fb-merge
termemu-defer draw-character
termemu-defer insert-characters