Atari Themed Clock face - chimes, alarms and mouse fix

Hardware, coding, music, graphic and various applications

Moderators: Mug UK, moondog/.tSCc., [ProToS], lp, Moderator Team

User avatar
jfl
Atari Super Hero
Atari Super Hero
Posts: 806
Joined: Tue Jul 18, 2006 10:55 pm
Location: Liège, Belgium
Contact:

Re: Request for Atari Themed Clock face

Postby jfl » Sun Jul 01, 2012 4:30 pm

wongck wrote:mmm... doesn't the AES takes care of whether the mouse is on your window or not ?
I thought the mouse changes have no effect if the mouse is outside the app window.

I'm not sure either. I suspect that switching it on/off may be global since it is needed for window updates, while changing its form is local to the application. Are you sure you are using the correct procedure? Have you looked into the Compendium?
Jean-François
GEMDict – GEMClip

helmut
Captain Atari
Captain Atari
Posts: 169
Joined: Thu Jan 07, 2010 4:30 pm

Re: Request for Atari Themed Clock face

Postby helmut » Sun Jul 01, 2012 10:39 pm

jfl wrote:
wongck wrote:mmm... doesn't the AES takes care of whether the mouse is on your window or not ?
I thought the mouse changes have no effect if the mouse is outside the app window.

I'm not sure either. I suspect that switching it on/off may be global since it is needed for window updates, while changing its form is local to the application. Are you sure you are using the correct procedure? Have you looked into the Compendium?


Correct: On/Off is global to avoid redraw-errors. Maybe you can use wind_find to check if the mouse is over your window:

http://toshyp.atari.org/en/008009.html#wind_find

-Helmut

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Sun Jul 01, 2012 11:22 pm

jfl wrote:I'm not sure either. I suspect that switching it on/off may be global since it is needed for window updates, while changing its form is local to the application. Are you sure you are using the correct procedure? Have you looked into the Compendium?

Frankly I have not checked the Compendium lately :oops: .
Just coded it according to how I did ages ago :P . Guess I should check to see what's the new stuff according to Mint :roll: .
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Sun Jul 01, 2012 11:29 pm

helmut wrote:Correct: On/Off is global to avoid redraw-errors. Maybe you can use wind_find to check if the mouse is over your window:
http://toshyp.atari.org/en/008009.html#wind_find


Thanks for confirming Helmut :) .
Different behaviour sure mess with me, but what you said makes sense.

You mean only turning off the mouse if it is on my window?

I was thinking may be just put graf_mouse() inside the drawing while () loop.
So if nothing is drawing, it does not turn off the mouse.
But I do graf_mouse(M_ON,0) at the end.
Is graf_mouse() stacked... i.e. like a stack whereby you need equal number of calls to turn it back on ?

What would be the usual practice? I guess checking if you're on your own window.

Like I said, programming in Atari, 70% of the time is due to GUI. :roll:
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
jfl
Atari Super Hero
Atari Super Hero
Posts: 806
Joined: Tue Jul 18, 2006 10:55 pm
Location: Liège, Belgium
Contact:

Re: Request for Atari Themed Clock face

Postby jfl » Mon Jul 02, 2012 5:52 am

wongck wrote:
helmut wrote:Correct: On/Off is global to avoid redraw-errors. Maybe you can use wind_find to check if the mouse is over your window:
http://toshyp.atari.org/en/008009.html#wind_find
You mean only turning off the mouse if it is on my window?
I was thinking may be just put graf_mouse() inside the drawing while () loop.
So if nothing is drawing, it does not turn off the mouse.

But you're redrawing every second anyway to update the clock. On my 1680x1050 screen the clock is almost always visible.
wongck wrote:But I do graf_mouse(M_ON,0) at the end.
Is graf_mouse() stacked... i.e. like a stack whereby you need equal number of calls to turn it back on ?

Absolutely. The calls are nested. That's a documented behaviour.
wongck wrote:What would be the usual practice? I guess checking if you're on your own window.

I don't know about usual, but this looks like the better practice.
wongck wrote:Like I said, programming in Atari, 70% of the time is due to GUI. :roll:

Well, that's the fun part :D
Jean-François
GEMDict – GEMClip

User avatar
jfl
Atari Super Hero
Atari Super Hero
Posts: 806
Joined: Tue Jul 18, 2006 10:55 pm
Location: Liège, Belgium
Contact:

Re: Request for Atari Themed Clock face

Postby jfl » Mon Jul 02, 2012 6:02 am

wongck wrote:
jfl wrote:Have you looked into the Compendium?
Frankly I have not checked the Compendium lately :oops: .

I find it's still a very useful source of information, even after all this time.
wongck wrote:Just coded it according to how I did ages ago :P . Guess I should check to see what's the new stuff according to Mint :roll: .

This hasn't change much at all. And by the way, PH clock is not the only one to do this. Try Kubis 96 (tetris clone). It also switches the mouse pointer on/off all the time. The difference is that is does it while you're actually playing the game, so it's not so distracting :)
Jean-François
GEMDict – GEMClip

joska
Hardware Guru
Hardware Guru
Posts: 3547
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Request for Atari Themed Clock face

Postby joska » Mon Jul 02, 2012 6:25 am

Wongck had done this correctly. The correct procedure when drawing anything on the screen is to first lock screen, then switch off the mouse cursor, draw, enable mouse cursor, unlock screen. There are no exceptions to this.

Avoiding the flickering mouse cursor is the VDI's task. You can't check if the mouse is within the area you're drawing, because you don't know how big the cursor is.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
jfl
Atari Super Hero
Atari Super Hero
Posts: 806
Joined: Tue Jul 18, 2006 10:55 pm
Location: Liège, Belgium
Contact:

Re: Request for Atari Themed Clock face

Postby jfl » Mon Jul 02, 2012 6:45 am

joska wrote:Wongck had done this correctly. The correct procedure when drawing anything on the screen is to first lock screen, then switch off the mouse cursor, draw, enable mouse cursor, unlock screen. There are no exceptions to this.

Nobody said wongck did it wrong. We're trying to find a workaround because this mouse pointer flickering is getting on my nerves so much that I had to disable his application. But I admit that I'm not particularly flicker-tolerant :)
Jean-François
GEMDict – GEMClip

joska
Hardware Guru
Hardware Guru
Posts: 3547
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Request for Atari Themed Clock face

Postby joska » Mon Jul 02, 2012 9:03 am

There is no way to work around this for a user application. This must be handled by the VDI.

Maybe the clock should be updated only once per minute instead?
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Mon Jul 02, 2012 11:13 am

jfl wrote:
wongck wrote:I was thinking may be just put graf_mouse() inside the drawing while () loop.
So if nothing is drawing, it does not turn off the mouse.

But you're redrawing every second anyway to update the clock. On my 1680x1050 screen the clock is almost always visible.


Ok so that's no use. It will redraw always as it is ticking away.
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

helmut
Captain Atari
Captain Atari
Posts: 169
Joined: Thu Jan 07, 2010 4:30 pm

Re: Request for Atari Themed Clock face

Postby helmut » Mon Jul 02, 2012 11:14 am

joska wrote:There is no way to work around this for a user application. This must be handled by the VDI.

Maybe the clock should be updated only once per minute instead?


That wouldn't solve anything - it's a general problem with any realtime-updates which not just the clock has.

I had the idea to intersect the (estimated?) mouse-area and the to-be-redrawn-area, and switch off accordingly. I don't think the mouse-pointer can get that big.

-Helmut

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Mon Jul 02, 2012 11:15 am

joska wrote:Avoiding the flickering mouse cursor is the VDI's task. You can't check if the mouse is within the area you're drawing, because you don't know how big the cursor is.


Yes, right.
Also if the user suddenly decide to move the mouse over to the clock while drawing, it will result in drawing artifacts left around.
Sure it is slim chance but it is still a probability and a very fast user :wink: .
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Mon Jul 02, 2012 11:18 am

joska wrote:Maybe the clock should be updated only once per minute instead?


I was thinking of that.... flickers once per minute rather than 60 times per minute.
Should cut down the distraction by 6000% :lol:
Makes it slightly more bearable.
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Mon Jul 02, 2012 11:20 am

helmut wrote:I had the idea to intersect the (estimated?) mouse-area and the to-be-redrawn-area, and switch off accordingly. I don't think the mouse-pointer can get that big.

Good idea. Hope you can work out how to do that.
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Mon Jul 02, 2012 11:22 am

jfl wrote:
wongck wrote:Like I said, programming in Atari, 70% of the time is due to GUI. :roll:

Well, that's the fun part :D


Well. I rather be working on the program logic than GUI logic.
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

helmut
Captain Atari
Captain Atari
Posts: 169
Joined: Thu Jan 07, 2010 4:30 pm

Re: Request for Atari Themed Clock face

Postby helmut » Mon Jul 02, 2012 8:05 pm

wongck wrote:
helmut wrote:I had the idea to intersect the (estimated?) mouse-area and the to-be-redrawn-area, and switch off accordingly. I don't think the mouse-pointer can get that big.

Good idea. Hope you can work out how to do that.


Ask again next year ;-)
Don't think it would be too difficult, but I don't know your code. The other solution using wind_find should be even easier.

Actually the mouse-pointer should be protected by the VDI and life would be much easier - no more mouse on/off-programming, but GEM is not designed that way.

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Mon Jul 02, 2012 11:28 pm

helmut wrote:Ask again next year ;-)
Don't think it would be too difficult, but I don't know your code. The other solution using wind_find should be even easier.
Actually the mouse-pointer should be protected by the VDI and life would be much easier - no more mouse on/off-programming, but GEM is not designed that way.


Ha ha.... after Xmas.

Another easier variation would be to check if the mouse is some margin away from the window. May be at least 1/2 times the window size away (just an arbitrary amount). It like drawing a circle round the window and if the mouse is inside this circle, need to turn off the mouse. Otherwise just do a redraw without turning off the mouse. This should work as no updates to the screen by other apps during this time. :mrgreen:
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

joska
Hardware Guru
Hardware Guru
Posts: 3547
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Request for Atari Themed Clock face

Postby joska » Tue Jul 03, 2012 6:31 am

helmut wrote:Actually the mouse-pointer should be protected by the VDI and life would be much easier - no more mouse on/off-programming, but GEM is not designed that way.


True, it's a bit messy. The VDI can intersect the drawing operation with the mouse cursor to determine if it's necessary to hide or display it, but that would need some support from the AES.

I took a quick look at the documentation for graf_mouse(). I think you can safely assume that the mouse pointer is 16x16 pixels, as this is the only size currently supported by the AES. So if you intersect the current mouse cursor position with the dirty rectangle (or even for each rectangle in the window rectangle list) *after* you have locked the screen you can determine if you need to switch it off or not. But remember that the M_ON/M_OFF calls must add up, so don't switch the mouse on unless it's actually off.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

helmut
Captain Atari
Captain Atari
Posts: 169
Joined: Thu Jan 07, 2010 4:30 pm

Re: Request for Atari Themed Clock face

Postby helmut » Tue Jul 03, 2012 7:50 am

wongck wrote:
helmut wrote:Ask again next year ;-)
Don't think it would be too difficult, but I don't know your code. The other solution using wind_find should be even easier.
Actually the mouse-pointer should be protected by the VDI and life would be much easier - no more mouse on/off-programming, but GEM is not designed that way.


Ha ha.... after Xmas.

Another easier variation would be to check if the mouse is some margin away from the window. May be at least 1/2 times the window size away (just an arbitrary amount). It like drawing a circle round the window and if the mouse is inside this circle, need to turn off the mouse. Otherwise just do a redraw without turning off the mouse. This should work as no updates to the screen by other apps during this time. :mrgreen:


Why a circle?

Say mouse-area is 16x16 and mouse-pos is in uppper-left - your window is x1,x2,y1,y2:

RECT= x1-16, x2, y1-16, y2

Right?

Forget about wind_find - you should know your window already ;)

Of course joskas approach using the real dirty rect is even better.

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Tue Jul 03, 2012 11:20 am

Circle.... because in some horror movie a circle is drawn around the person to stop something getting into it.. :wink:

Yeah, it a GRECT. :mrgreen:
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

helmut
Captain Atari
Captain Atari
Posts: 169
Joined: Thu Jan 07, 2010 4:30 pm

Re: Request for Atari Themed Clock face

Postby helmut » Tue Jul 03, 2012 1:42 pm

wongck wrote:Circle.... because in some horror movie a circle is drawn around the person to stop something getting into it.. :wink:


Spongebob? :-)


Yeah, it a GRECT. :mrgreen:


The risk is that the user moves the mouse during redraw inside the redraw-area. So you'd better be fast!

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Tue Jul 03, 2012 1:55 pm

helmut wrote:Spongebob? :-)

[smilie=greencolorz4_pdt_01.gif] Yes of course, that's exactly what I mean.... the sea bear. :lol: :lol:
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

joska
Hardware Guru
Hardware Guru
Posts: 3547
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Request for Atari Themed Clock face

Postby joska » Tue Jul 03, 2012 2:04 pm

helmut wrote:The risk is that the user moves the mouse during redraw inside the redraw-area. So you'd better be fast!


No, there is no risk of that. You always lock the screen before *any* redraw - this also prevents the AES from painting the mouse until the screen is unlocked. However, you can risk that the mouse is moved (but not painted) out of the redraw area between locking the screen and interrogating the mouse position. The chances for this happening is close to zero, but if it happens the mouse will not be painted until the mouse is moved.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
wongck
Ultimate Atarian
Ultimate Atarian
Posts: 11857
Joined: Sat May 03, 2008 2:09 pm
Location: Far East
Contact:

Re: Request for Atari Themed Clock face

Postby wongck » Tue Jul 03, 2012 2:14 pm

joska wrote:No, there is no risk of that. You always lock the screen before *any* redraw - this also prevents the AES from painting the mouse until the screen is unlocked. However, you can risk that the mouse is moved (but not painted) out of the redraw area between locking the screen and interrogating the mouse position. The chances for this happening is close to zero, but if it happens the mouse will not be painted until the mouse is moved.


yes, you are right. The screen is locked from update by wind_update(). Since the screen is locked from update, the mouse cannot be moved, so it it find to get the mouse position after locking. Right?
My Stuff: FB/Falcon CT63+CTPCI ATI R7500 14+512MB 30GB HDD CF HxC_SD EtherNEC/ TT030 68882 4+32MB 520MB Nova/ 520STFM 4MB Tos206 SCSI
Shared SCSI Bus:ScsiLink ethernet, 9GB HDD,SD-reader @ http://phsw.atari.org
My Atari stuff for sale - click here for list

joska
Hardware Guru
Hardware Guru
Posts: 3547
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Request for Atari Themed Clock face

Postby joska » Wed Jul 04, 2012 6:22 am

wongck wrote:yes, you are right. The screen is locked from update by wind_update(). Since the screen is locked from update, the mouse cannot be moved, so it it find to get the mouse position after locking. Right?


Yes and no. Locking the screen prevents the mouse from being painted, but the position can still change until the mouse is switched off.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64


Social Media

     

Return to “Professionals”

Who is online

Users browsing this forum: No registered users and 4 guests