home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / System / DX Clock 1.31 / DX Clockƒ / DX Clock.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-05  |  16.3 KB  |  679 lines  |  [TEXT/KAHL]

  1. /*
  2.     DX Clock.c
  3.     13 août 1991
  4.     Stephan Burlot 1991
  5.  
  6.     Draw a clock in the menu bar.
  7.  
  8.     we use DrawString instead of multiple calls to DrawChars because some fonts are
  9.     kerned and if we use DrawChar in srcCopy, it erases the right side of the previous
  10.     char.
  11.     
  12.     we should calculate the clock's rect every time. (It would be cleaner to do so !)
  13.     
  14.     history :
  15.     
  16.     v1.0 13 Aout 1991 patches SystemTask
  17.     v1.1 29 août 1991 patches JGNEFilter and DrawMenuBar
  18.                       save the clipping rgn
  19.                       detect double click
  20.                       about window
  21.     v1.2 8 septembre 1991
  22.                       added ShowIcon
  23.     
  24.     
  25.     released in the public domain January 5 1994
  26.  
  27.  
  28. */
  29. /*#include    <color.h>    */            /* some info about color quickdraw */
  30.  
  31.  
  32.  
  33. #define    KeypadMap        0x017C      ; bitmap for numeric pad-18bits [long]
  34. #define    KeyMap            0x0174      ; bitmap of the keyboard [2 longs]
  35. #define    DoubleTime        0x02F0      ; double click ticks [long]
  36. #define    RowBits            0x0C20        ; pixels horizontally
  37. #define    ColLines        0x0C22         ; (word) screen vertical pixels
  38. #define    WWExist            0x08F2        ; Window Manager Initialized ?
  39. #define    WMgrCPort        0x0D2C        ; [GLOBAL VAR]  window manager color port
  40. #define    WMgrPort        0x09DE        ; Window Manager Port
  41. #define SystemTask        0xA9B4        ; System Task trap number
  42. #define    GetNextEvent    0xA970        ; GetNextEvent trap number
  43. #define    DrawMenuBar        0xA937        ; DrawMenuBar trap number
  44. #define    Unimplemented    0x9F        ; Unimplemented trap number
  45. #define MBState            0x0172        ; Mouse Button state
  46. #define    Mouse             0x0830        ; mouse loc
  47. #define    FractEnable        0x0BF4         ; fractionnal width allowed ? (byte)
  48. #define    MenuList        0x0A1C        ; menu list
  49. #define    MBTicks         0x016E        ; tick count @ last mouse button [long]
  50. #define    MenuCInfo        0x0D50        ; handle to Menu Color Info
  51. #define    RGBBlack        0x0C10        ; RGB color black
  52. #define    RGBWhite        0x0C16        ; RGB Color white
  53. #define    ChunkyDepth        0x0D60        ; [GLOBAL VAR]  depth of the pixels
  54. #define    JGNEFilter        0x029A        ; address of tail patch to GetNextEvent
  55.  
  56. #define    mctRGB1            0x4
  57. #define    mctRGB4            0x16
  58.  
  59. #define    JMP                0x4EF9
  60. #define    JSR                0x4EB9
  61.  
  62. #define    tnam            0
  63. #define    pointer            4
  64. #define    font            8
  65. #define    size            10
  66. #define    offset            12
  67. #define    stringwid        14
  68. #define    vpos            16
  69. #define    red                18
  70. #define    green            20
  71. #define    blue            22
  72. #define    therect            24
  73. #define    toprect            24
  74. #define    leftrect        26
  75. #define    bottomrect        28
  76. #define    rightrect        30
  77. #define    useclockcolor    31
  78. #define    timewithsecs    32
  79.  
  80. pascal void ShowINIT() ;
  81.  
  82. void Main(void) ;
  83.  
  84. void main()
  85.  
  86. {
  87.     asm    {
  88.  
  89.     move.l    D4,-(SP)            ; save D4 on stack
  90.  
  91.     tst.b    MBState                ; mouse button down ?
  92.     bpl        @noPatch            ; yes, dont install patch
  93.  
  94.     lea        JGNEFilter,A0
  95.     lea        @exitST,A1
  96.     move.l    (A0),(A1)            ; save the previous contents of JGNEFilter into exitST
  97.  
  98.     lea        @lasttime,A0        ; init the last time
  99.     move.l    Time,(A0)
  100.  
  101.     lea        @sysenvrec,A0        ; check the current system version
  102.     move.w    #1,D0
  103.     _SysEnvirons
  104.  
  105.     lea        @hascolor,A1        ; do we have color QD ?
  106.     move.b    9(A0),(A1)
  107.  
  108.     move.w    4(A0),D0            ; system version is in D0
  109.     cmp.w    #0x700,D0            ; system seven ?
  110.     bmi.s    @system6            ; no
  111.     move.w    #65,D2                ; subtract width of two menus at top right corner
  112.     bra.s    @goon
  113. @system6
  114.     move.w    #20,D2                ; subtract width of on cue at top right corner
  115. @goon
  116.  
  117.     subq    #4,SP                ; space for handle
  118.  
  119.     move.l    #'DXCL',-(SP)        ; GetResource('DXCL',1)
  120.     move.w    #0x1,-(SP)
  121.     _GetResource
  122.  
  123.     move.l    (SP)+,A2            ; put handle to resource into A2
  124.     move.l    A2,D3                ; save a copy of the resource handle into D3
  125.     movea.l    (A2),A2                ; dereference handle.
  126.  
  127.     lea        @last,A0            ; calculate size of patch
  128.     lea        @ThePatch,A1
  129.     suba.l    A1,A0
  130.     move.l    A0,D0
  131.     move.l    D0,D4                ; save D4 for BlockMove
  132.     _NewPtr    SYS                    ; allocate ptr in system heap /D0 used
  133.     bne.s    @noPatch            ; if error, exit
  134.  
  135.     lea        JGNEFilter,A1
  136.     move.l    A0,(A1)                ; set address of JGNEFilter to our patch
  137.  
  138.     move.l    A0,-(SP)            ; save ptr onto heap
  139.  
  140.     move.w    #DrawMenuBar,D0        ; get the address of the trap
  141.     _GetTrapAddress                ; result is in A0
  142.  
  143.     lea        @exitDM,A1
  144.     move.l    A0,(A1)                ; save the address of trap into exitDM
  145.  
  146.     lea        @ThePatch,A0
  147.     move.l    (SP),A1
  148.     move.l    D4,D0
  149.     _BlockMove                    ; move the patch code into the system heap, A0/A1/D0 used
  150.  
  151.     lea        @drawmenubarpatch,A0    ; calculate address of drawmenubarpatch
  152.     lea        @ThePatch,A1
  153.     suba.l    A1,A0                ; offset of drawmenubarpatch from beginning of patch
  154.     adda.l    (SP),A0                ; add address of patch in sysheap. A0 contains the dest address
  155.     move.w    #DrawMenuBar,D0        ; set the address of the trap
  156.     _SetTrapAddress
  157.  
  158.     lea        @datarec,A0            ; calculate offset of datarec from beginning of patch
  159.     lea        @ThePatch,A1
  160.     suba.l    A1,A0                ; offset of datarec from beginning of patch
  161.     adda.l    (SP)+,A0            ; add address of patch in sysheap. A0 contains the dest address
  162.     move.l    A0,A1                ; put A0 into A1 for BlockMove (A1 is dest address)
  163.  
  164.     move.l    A0,pointer(A2)        ; store ptr to data into the resource
  165.     move.w    D2,offset(A2)        ; store offset into the resource
  166.  
  167.     move.l    A2,A0
  168.     move.l    #34,D0                ; rec is 34 bytes long
  169.     _BlockMove
  170.  
  171.     move.l    D3,-(SP)            ; save back the resource, because we've changed the pointer value
  172.     move.l    (SP),-(SP)
  173.     _ChangedResource
  174.     _WriteResource
  175.  
  176.     move.w    #128,-(SP)            ; draw icon
  177.     move.w    #-1,-(SP)            ; advance position
  178.     bsr        ShowINIT
  179.     bra.s    @exit
  180.  
  181. @noPatch                        ; no patch, exit
  182.  
  183.     move.w    #128,-(SP)            ; draw icon
  184.     move.w    #0,-(SP)            ; dont advance position
  185.     bsr        ShowINIT
  186.  
  187.     move.w    #127,-(SP)            ; draw cross
  188.     move.w    #-1,-(SP)            ; and advance position
  189.     bsr        ShowINIT
  190.  
  191. @exit
  192.     move.l    (SP)+,D4
  193.  
  194.     rts
  195.  
  196. @sysenvrec                        ; record filled by _SysEnvirons
  197.     DC.W    0
  198.     DC.W    0
  199.     DC.W    0
  200.     DC.W    0
  201.     DC.B    0
  202.     DC.B    0
  203.     DC.W    0
  204.     DC.W    0
  205.     DC.W    0
  206.  
  207. ;************************* the patch *********************************************/
  208.  
  209. #define    saveport    -4
  210. #define    saveclip    -8
  211. #define    local1        saveclip
  212. @ThePatch
  213.  
  214.     bsr.s    @doclock                ; do it, joe
  215.     dc        JMP
  216. @exitST                                ; here comes the address of the original JGNEFilter
  217.     nop
  218.     nop
  219.  
  220. @drawmenubarpatch                ; tail patch to DrawMenuBar
  221.  
  222.     dc        JSR
  223. @exitDM                            ; here comes the address of the original patch
  224.     nop
  225.     nop
  226.  
  227.     link    A6,#local1
  228.  
  229.     movem.l    D0-D4/A0-A2,-(SP)    ; save some registers
  230.     moveq    #0,D3                ; D3:Boolean : draw the date ?
  231.     bra.s    @drawdate
  232.  
  233. @doclock
  234.  
  235.     link    A6,#local1
  236.  
  237.     movem.l    D0-D4/A0-A2,-(SP)    ; save some registers
  238.  
  239.     tst.b    WWExist                ; Window Manager initialized ?
  240.     bne        @goodbye            ; No : exit
  241.     tst.w    MBarHeight            ; is there a menu bar ?
  242.     beq        @goodbye            ; No : exit
  243.  
  244.     moveq    #0,D3                ; D3:Boolean : draw the date ?
  245.  
  246.     cmp.w    #mouseDown,OFFSET(EventRecord,what)(A1)    ; is it a mouse down ?
  247.     bne.s    @drawtime                                ; no, continue
  248.  
  249.     subq    #2,sp                                    ; space for result
  250.     move.l    OFFSET(EventRecord,where)(A1),-(SP)        ; push the point
  251.     pea        @therect                                ; push the rect
  252.     _PtInRect
  253.     move.b    (SP)+,D3
  254.  
  255.     beq.s    @drawtime                ; Pt is not in rect, so draw the time
  256.  
  257.     lea        @oldpoint,A0
  258.     move.l    (A0)+,D0                ; last click pos is in D0
  259.     move.l    (A0),D1                    ; last click time is in D1
  260.  
  261.     lea        @oldpoint,A0
  262.     move.l    OFFSET(EventRecord,where)(A1),(A0)+        ; save the point
  263.     move.l    Ticks,(A0)                ; save the time
  264.  
  265.     cmp.l    OFFSET(EventRecord,where)(A1),D0        ; same point as previous click ?
  266.     bne.s    @drawdate                ; no
  267.     move.l    Ticks,D0                ; time between clicks < DoubleTime ?
  268.     sub.l    D1,D0
  269.     cmp.l    DoubleTime,D0
  270.     bgt.s    @drawdate            ; no, exit
  271.  
  272.     bsr        @doabout
  273.  
  274. @notdblclick
  275.  
  276. ;    move.w    OFFSET(EventRecord,modifiers)(A1),D0
  277. ;    btst    #11,D0
  278. ;    beq.s    @drawdate
  279. ;    lea        @hidden,A0
  280. ;    not        (A0)
  281. ;    beq.s    @drawtime
  282.  
  283. ;    move.l    WMgrPort,-(SP)        ; sets the port to the window manager port
  284. ;    _SetPort
  285. ;    pea        @therect
  286. ;    _EraseRect                    ; erase the clock rect.
  287.     
  288. @drawtime
  289.  
  290.     move.l    @lasttime,D1        ; should we draw the time ?
  291.     cmp.l    Time,D1
  292.     bge        @goodbye            ; no, exit
  293.  
  294. @drawdate
  295.  
  296. ;    move.w    @hidden,D0
  297. ;    bne        @goodbye
  298.  
  299.     move.w    @leftrect,D0
  300.  
  301.     move.l    MenuList,A0            ; we can draw the time if there is no menu on the clock's rect
  302.     move.l    (A0),A0
  303.     move.w    2(A0),D1            ; 2(A0) holds the right coord of last menu
  304.     cmp.w    D0,D1                ; D0 holds the left coord of the clock's rect
  305.     bgt        @goodbye            ; sorry, can't do that
  306.  
  307.     pea        saveport(A6)        ; saves the current port
  308.     _GetPort
  309.     
  310.     move.l    #0x000A0014,D4        ; initialize counter. point (10,20)
  311.  
  312.     move.w    @hascolor,D0        ; are we in color ?
  313.     bne        @initcolor
  314.  
  315.                 ; ************************* init things for BW machine ********************
  316.  
  317.     move.l    WMgrPort,-(SP)        ; sets the port to the window manager port
  318.     _SetPort
  319.  
  320. @t1    subq    #2,-(SP)            ; test if a screen saver is active (stolen from SuperClock)
  321.     move.l    D4,-(SP)
  322.     _GetPixel                    ; works in the local port
  323.     tst.b    (SP)+
  324.     dbeq    D4,@t1
  325.     bne        @endrestore
  326.  
  327.     move.l    WMgrPort,A0                ; A0 holds a pointer to the window manager port
  328.  
  329.     move.w    OFFSET(GrafPort,txFont)(A0),-(SP)        ; save some params on the stack
  330.     move.w    OFFSET(GrafPort,txSize)(A0),-(SP)
  331.     move.w    OFFSET(GrafPort,txMode)(A0),-(SP)
  332.     bra.s    @endinit
  333.  
  334. @initcolor        ; ************************* init things for color machine ********************
  335.  
  336.     move.l    WMgrCPort,-(SP)        ; sets the port to the color window manager port
  337.     _SetPort
  338.  
  339. @t2
  340.     subq.w    #6,SP                ; test if a screen saver is active (stolen from SuperClock)
  341.     move.l    D4,-(SP)
  342.     pea        4(SP)
  343.     _GetCPixel                    ; works in the local port
  344.     move.w    (SP)+,D0
  345.     or.w    (SP)+,D0
  346.     or.w    (SP)+,D0
  347.     dbne    D4,@t2
  348.     beq        @endrestore
  349.  
  350.     move.l    WMgrCPort,A0        ; A0 holds a pointer to the color window manager port
  351.  
  352.     move.w    OFFSET(CGrafPort,txFont)(A0),-(SP)        ; save some params on the stack
  353.     move.w    OFFSET(CGrafPort,txSize)(A0),-(SP)
  354.     move.w    OFFSET(CGrafPort,txMode)(A0),-(SP)
  355.     lea        @savedFGcolor,A1
  356.  
  357.     move.l    OFFSET(CGrafPort,rgbFgColor)(A0),(A1)+    ; save the foreground color
  358.     move.l    OFFSET(CGrafPort,rgbFgColor+4)(A0),(A1)+
  359.     move.l    OFFSET(CGrafPort,rgbFgColor+8)(A0),(A1)    ; save the background color
  360.  
  361. /* the lines above were originally :
  362.     
  363.     move.l    OFFSET(CGrafPort,rgbFgColor)(A0),(A1)+    ; save the foreground color
  364.     move.w    OFFSET(CGrafPort,rgbFgColor+4)(A0),(A1)+
  365.     move.l    OFFSET(CGrafPort,rgbBkColor)(A0),(A1)+    ; save the background color
  366.     move.w    OFFSET(CGrafPort,rgbBkColor+4)(A0),(A1)
  367.  
  368.     so I've saved 8 bytes !
  369. */    
  370.     move.l    #RGBWhite,-(SP)            ; push default colors on the stack
  371.     move.l    #RGBBlack,-(SP)
  372.     
  373.     move.w    ChunkyDepth,D0            ; if we are in one bit mode,
  374.     subq.w    #1,D0
  375.     beq.s    @setcolor                ; don't use MCInfo
  376.  
  377.     move.l    MenuCInfo,A0
  378.     move.l    (A0),A0
  379.     cmp.w    #-99,(A0)                ; item id is -99 if there is no MC entry
  380.     beq.s    @noMCentry
  381.  
  382.     lea        mctRGB1(A0),A1            ; push foreground color
  383.     move.l    A1,(SP)
  384.  
  385.     lea        mctRGB4(A0),A1            ; push background color
  386.     move.l    A1,4(SP)
  387.  
  388. @noMCentry
  389.     move.b    @useclockcolor,D0        ; if we should use the clock's color
  390.     beq.s    @setcolor
  391.     lea        @thecolor,A1
  392.     move.l    A1,(SP)
  393. @setcolor
  394.     _RGBForeColor                    ; set the foreground & background color
  395.     _RGBBackColor
  396.  
  397. @endinit
  398.  
  399.     subq    #4,SP                ; allocate some space on the stack
  400.     _NewRgn                        ; create a new rgn
  401.     move.l    (SP),saveclip(A6)    ; save the handle into saveclip
  402.     _GetClip                    ; get the current clipping rgn
  403.     pea        @therect
  404.     _ClipRect                    ; set the clipping region.
  405.  
  406.     move.w    @leftrect,-(SP)
  407.     move.w    @vpos,-(SP)            ; v coord
  408.     _MoveTo
  409.  
  410.     move.w    @font,-(SP)            ; set the font, size & mode
  411.     _TextFont
  412.     move.w    @size,-(SP)
  413.     _TextSize
  414.     clr.w    -(SP)                ; srcCopy is 0
  415.     _TextMode
  416.  
  417.     lea        @DateTimeRec,A0        ; converts the date & time to num
  418.     move.l    Time,D0
  419.     _Secs2Date
  420.  
  421.     lea        @loop,A1            ; let's do some self modifying code !
  422.     move.w    #':',2(A1)            ; use ':' to draw the time
  423.     lea        @a,A1
  424.     move.w    #0x3018,(A1)        ; move.w    (A0)+,D0
  425.     tst.b    D3
  426.     beq.s    @addoffset
  427.  
  428.     sub.w    #1900,(A0)            ; wont work in the 21th century !
  429.     lea        @loop,A1
  430.     move.w    #'.',2(A1)            ; use '.' to draw the date
  431.     lea        @a,A1
  432.     move.w    #0x3020,(A1)        ; move.w    -(A0),D0
  433. @addoffset
  434.     addq.w    #6,A0                ; A0+6 points to the time
  435.     lea        @thestring,A1
  436.     move.b    #9,(A1)+            ; the string is 9 bytes long
  437.  
  438.     moveq    #02,D2                ; loop 3 times
  439.     bra.s    @loop1                ; skip ':' at start
  440. @loop
  441.      move.b    #':',(A1)+            ; this line can be modified by the code above
  442. @loop1
  443.      moveq    #0,D0
  444. @a    move.w    (A0)+,D0
  445.     divu.w    #10,D0
  446.     or.b    #0x30,D0            ; ASCII('0') is 0x30
  447.     move.b    D0,(A1)+
  448.     swap    D0
  449.     or.b    #0x30,D0            ; ASCII('0') is 0x30
  450.     move.b    D0,(A1)+
  451.     dbf        D2,@loop
  452.  
  453.     tst.b    D3
  454.     bne.s    @drawit
  455.     move.b    @useclockcolor+1,D0    ; should we include the secs ?
  456.     bne.s    @drawit                ; no, draw the time
  457.     lea        @thestring,A1        ; set
  458.     move.b    #5,(A1)
  459. @drawit
  460.     pea        @thestring
  461.     _DrawString                    ; draw the string
  462.  
  463.     move.l    saveclip(A6),-(SP)    ; restore the clipping rgn
  464.     move.l    (SP),-(SP)
  465.     _SetClip
  466.     _DisposeRgn                    ; dispose the save clip rgn
  467.     
  468.     _TextMode                    ; restore things
  469.     _TextSize
  470.     _TextFont
  471.     move.w    @hascolor,D0
  472.     beq.s    @endrestore
  473.  
  474. @restorecolor
  475.  
  476.     pea        @savedFGcolor        ; restore the foreground & background colors
  477.     _RGBForeColor
  478.     pea        @savedBKcolor
  479.     _RGBBackColor
  480.  
  481. @endrestore
  482.  
  483.     move.l    saveport(A6),-(sp)    ; restore current port
  484.     _SetPort
  485.  
  486.     lea        @lasttime,A0
  487.     move.l    Time,(A0)
  488.     tst.b    D3
  489.     beq.s    @goodbye
  490.     add.l    #3,(A0)                ; set the next time to 3 secs ahead
  491.  
  492. @goodbye
  493.  
  494.     movem.l    (SP)+,D0-D4/A0-A2        ; restore registers
  495.     unlk    A6
  496.     rts                                ; back to caller
  497.  
  498. @doabout        ; ************************* aboutwindow *********************************
  499.  
  500. #define    boundsrect    -8
  501. #define    thewindow    -12
  502. #define    saved        -16
  503. #define    locals        saved
  504.  
  505.     link    A6,#locals
  506.     movem.l    A0-A3/D0-D3,-(sp)            ; save some regs
  507.  
  508.     pea        saved(A6)                ; save current port
  509.     _GetPort
  510.  
  511.     lea        boundsrect(A6),A0        ; center window in screen
  512.     move.w    ColLines,D0                ; pixels vert.
  513.     sub.w    #0xC8,D0
  514.     lsr.w    #1,D0
  515.     swap    D0                        ; top coord in high byte of D0
  516.     move.w    RowBits,D1
  517.     sub.w    #0xC8,D1
  518.     lsr.w    #1,D1
  519.     move.w    D1,D0                    ; left coord in low byte of D0
  520.     move.l    D0,(A0)+
  521.     add.l    #0x00C800C8,D0
  522.     move.l    D0,(A0)
  523.     subq    #4,SP                ; result (windowPtr)
  524.     clr.l    -(sp)                ; wStorage (nil)
  525.     pea        boundsrect(a6)        ; boundsrect
  526.     clr.l    -(sp)                ; title ??
  527.     move.b    #1,-(sp)            ; visible
  528.     move.w    #dBoxProc,-(sp)        ; proc id
  529.     move.l    #-1,-(sp)            ; behind
  530.     clr.w    -(sp)                ; go away flag
  531.     clr.l    -(sp)                ; refcon
  532.     _NewWindow
  533.     move.l    (sp),thewindow(A6)        ; result (windowPtr)
  534.     _SetPort
  535.  
  536.     clr.l    -(sp)                ; textfont(0), textsize(0)
  537.     _TextFont
  538.     _TextSize
  539.     subq    #2,SP                ; result (word)
  540.     pea        @str1
  541.     _StringWidth
  542.     move.w    (sp)+,D0
  543.     move.w    #0xC8,D1
  544.     sub.w    D0,D1
  545.     lsr.w    #1,D1
  546.     move.w    D1,-(sp)            ; horizontal coord of string (centered in window)
  547.     move.w    #20,-(sp)
  548.     _MoveTo
  549.     pea        @str1
  550.     _DrawString                    ; draw the string
  551.     
  552.     move.w    #geneva,-(sp)        ; textfont(geneva)
  553.     _TextFont
  554.     move.w    #9,-(sp)            ; textsize(9)
  555.     _TextSize
  556.     
  557.     lea        boundsrect(a6),A0
  558.     move.l    #0x00500005,(A0)+
  559.     move.l    #0x00C300C3,(A0)
  560.     pea        boundsrect(A6)
  561.     _FrameRect
  562.     pea        boundsrect(A6)
  563.     move.l    #0x00020002,-(sp)
  564.     _InsetRect
  565.     pea        @str2                ; pointer to the string
  566.     lea        @endstr2,A0            ; calculate length of string
  567.     lea        @str2,A1
  568.     suba.l    A1,A0
  569.     move.l    A0,-(sp)            ; length of string (long)
  570.     pea        boundsrect(A6)        ; the rect
  571.     move.w    #teJustCenter,-(sp)    ; centered
  572.     _TextBox
  573.  
  574.     move.l    Ticks,D0
  575.     add.l    #30,D0
  576.     
  577.     move.w    #1,-(sp)
  578.     _SysBeep
  579.  
  580. @wait
  581.     cmp.l    Ticks,D0
  582.     bpl.s    @wait
  583.     move.l    KeyMap,D0
  584.     move.l    KeyMap+4,D1
  585.     move.l    KeypadMap,D2
  586. @no    tst.b    MBState                ; wait til button
  587.     bpl.s    @aboutend
  588.     cmp.l    KeyMap,D0
  589.     bne.s    @aboutend
  590.     cmp.l    KeyMap+4,D1
  591.     bne.s    @aboutend
  592.     cmp.l    KeypadMap,D2
  593.     beq.s    @no
  594.  
  595. @aboutend
  596.  
  597.     move.l    #0x0000FFFF,D0
  598.     _FlushEvents
  599.  
  600.     move.l    thewindow(A6),-(sp)    ; kill the window
  601.     _DisposeWindow
  602.  
  603.     move.l    saved(A6),-(sp)        ; restore grafport
  604.     _SetPort
  605.  
  606.     movem.l    (sp)+,A0-A3/D0-D3    ; restore regs
  607.     unlk    A6
  608.     rts
  609.  
  610. ; the strings !!
  611.  
  612. @str1
  613.     DC.B    8,'D','X',' ','C','l','o','c','k'
  614. @str2
  615.     DC.B    'b','y',' ','S','t','e','p','h','a','n',' ','B','u','r','l','o','t'
  616.     DC.B    13,13
  617.     DC.B    'D','X',' ','C','l','o','c','k',' ','i','s',' ','f','r','e','e',' ','!'
  618.     DC.B    13,13
  619.     DC.B    '©',' ','C','o','r','i','o','l','i','s'
  620.     DC.B    13,13,13,13
  621.     DC.B    'p','r','e','s','s',' ','m','o','u','s','e',' ','b','u','t','t','o','n',' ','t','o',' '
  622.     DC.B    'c','o','n','t','i','n','u','e','.'
  623. @endstr2
  624.  
  625. ;@hidden            DC.W    0        ; is the clock hidden
  626. @oldpoint        DC.L    0        ; last point click
  627. @oldticks        DC.L    0        ; last click time
  628.  
  629. @savedFGcolor    DC.W    0        ; saved foreground color for CGrafPort
  630.                 DC.W    0
  631.                 DC.W    0
  632. @savedBKcolor    DC.W    0        ; saved background color for CGrafPort
  633.                 DC.W    0
  634.                 DC.W    0
  635.  
  636. @DateTimeRec                ; holds the converted date & time
  637.  
  638. @year        DC.W    0
  639. @month        DC.W    0
  640. @day        DC.W    0
  641. @hour        DC.W    0
  642. @minute        DC.W    0
  643. @second        DC.W    0
  644. @dayOfW        DC.W    0
  645.  
  646. @thestring    DC.L    0        ; thestring holds the time. 10 bytes long.
  647.             DC.L    0
  648.             DC.W    0x0020    ; last char is always a space.
  649.  
  650. @lasttime    DC.L    0        ; last time we've drawn the clock
  651.  
  652. @hascolor    DC.W    0        ; has color QD ?
  653.  
  654. @datarec                    ; we store the handle 'DXCL' here
  655.  
  656. @tnam        DC.L    0        ; identifier of the resource
  657. @pointer    DC.L    0        ; loc of the ptr
  658. @font        DC.W    0        ; font used
  659. @size        DC.W    0        ; size of the font
  660. @offset        DC.W    0        ; offset from left
  661. @stringwid    DC.W    0        ; width of time
  662. @vpos        DC.W    0        ; v coordinate
  663. @thecolor
  664. @red        DC.W    0        ; red color
  665. @green        DC.W    0        ; green color
  666. @blue        DC.W    0        ; blue color
  667.  
  668. @therect                    ; rect used for clipping & drawing
  669. @toprect    DC.W    0
  670. @leftrect    DC.W    0
  671. @bottomrect    DC.W    0
  672. @rightrect    DC.W    0
  673. @useclockcolor    DC.B    0,0    ; use clock's color instead of menu bar's
  674. ;@timewithsecs    DC.B    0    ; draw the time with seconds
  675.  
  676. @last
  677.     }
  678. }
  679.