GUI screen pack pure MMBasic


Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6523
Posted: 07:18am 24 Mar 2021      

Changes made to run on CMM2

At the beginning:
 if mm.device$ = "Colour Maximite 2" then
   mp = mm.info(option mouse) ' mouse port
   cmm2 = 1
   option console serial
   GUI CURSOR ON 0, 100,100,rgb(red)
   CONTROLLER MOUSE OPEN mp
   mm.fontheight = MM.INFO(FONTHEIGHT)
   mm.fontwidth = MM.INFO(FONTWIDTH)
 endif


That gets the mouse underway and makes MM.FONTWIDTH etc available
Getting MM.FONTWIDTH working fixed all the alignment issues.

GUI BITMAP was easy enough to handle.
I put it into a SUB to make playing easier
sub gui_bitmap x as integer, y as integer, o as integer
 local integer dx,dy, dc
 local cbin$ = bin$(o,64)
 if cmm2 then
   GUI CURSOR hide
   for dy = 0 to 7
     for dx = 0 to 7
       dc = &hFFFFFF * (1 - val(mid$(cbin$,dy*8+dx+1,1)))
       pixel x+dx, y+7-dy ,dc
     next dx
   next dy
   gui cursor show
 else
   gui bitmap x+2, y+2, o
 endif
end sub


While the CMM2 doesn't have TOUCH(), as such, it is used as a proxy for MOUSE() so I had to get creative there also.
 
sub getTouch
 if cmm2 then
   ' GUI CURSOR MOUSE(x,0),MOUSE(y,0)  ' here or main loop
   Xt = -1
   if mouse(R,mp) then save image "gui.bmp",0,0,320,240
   if mouse(L,mp) then ' left button down
     Xt = mouse(X,mp)
     Yt = mouse(Y,mp)
   endif
   
 else
   Xt = touch(X)
   Yt = touch(Y)
 endif
 
end sub

The same change was done in the waitnotouch sub
 'waits for the stylus to be lifted off the panel
Sub WaitNoTouch
 if cmm2 then
   Do
     'Watchdog here if you want it
     Pause 10
   loop until mouse(L,mp) = 0
 else
   do
     'Watchdog here if you want it
     pause 10
   Loop Until touch(X)=-1
 endif
End Sub


An interesting exercise that filled in the day for me.

Jim