home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 198.lha / Flip / flip.asm < prev    next >
Encoding:
Assembly Source File  |  1988-12-27  |  36.7 KB  |  1,186 lines

  1. ;***************************************************************
  2. ;    Things to do
  3. ;        1. Clean up error checking in child task
  4. ;            what little there is of it
  5. ;******************************************************************
  6. ;    Registers used in this section
  7. ;    d2    -    idcmpsig
  8. ;    d3    -    mainport2sig
  9. ;    d4    -    mainoridcmpsig
  10. ;    d5    -    wakeupsig
  11. ;    d6    -    secstoshowview
  12.  
  13. ;    a2    -    control window address
  14. ;    a3    -    userquitmessage
  15. ;    a4    -    flipmessage
  16. ;    a5    -    closewindowgadget
  17. ;**************************************************************
  18.     include "flip.h"
  19.     include "flip.macros"
  20. ;***************************************************************
  21.     xdef    execbase
  22.     xdef    dosbase
  23.     xdef    gfxbase
  24.     xdef    intbase
  25.     xdef    totalpause
  26.     xref    _AbsExecBase
  27.     xref    ud
  28.     amiref    Alert
  29.     amiref    Forbid
  30.     amiref    FindTask
  31.     amiref    OpenLibrary
  32.     amiref    CloseLibrary
  33.     amiref    OpenWindow
  34.     amiref    CloseWindow
  35.     amiref    GetMsg
  36.     amiref    ReplyMsg
  37.     amiref    Delay
  38.     amiref    AllocMem
  39.     amiref    FreeMem
  40.     amiref    Permit
  41.     amiref    AllocSignal
  42.     amiref    AddPort
  43.     amiref    RemPort
  44.     amiref    FreeSignal
  45.     amiref    AddTask
  46.     amiref    RemTask
  47.     amiref    Wait
  48.     amiref    WaitPort
  49.     amiref    PutMsg
  50.     amiref    SendIO
  51.     amiref    CheckIO
  52.     amiref    OpenDevice
  53.     amiref    CloseDevice
  54.     amiref    SizeWindow
  55.     amiref    OnGadget
  56.     amiref    OffGadget
  57.     amiref    SetMenuStrip
  58.     amiref    Open
  59.     amiref    Close
  60.     amiref    ActivateWindow
  61.     amiref    OffMenu
  62.     amiref    OnMenu
  63.     amiref    Write
  64.     amiref    MoveWindow        ;Found a way to use a lot
  65.     amiref    WindowToFront        ;of these didn't I?
  66. ;**************************************************************
  67. start
  68.     list
  69.  
  70.     move.l    SP,initialSP
  71.     move.l    _AbsExecBase,a6
  72.     move.l    a6,execbase
  73.     zera    a1        ;clear address reg - argument to FindTask
  74.     execlib    FindTask
  75.     move.l    d0,startask    ;save the address of our task
  76.     movea.l    startask,a0
  77.     tst.l    pr_CLI(a0)    ;if = 0 started from workbench
  78.     beq    WBStart        ;if = 1 do CLI Code - reminders for exit
  79. CLI Code
  80.     move.l    #1,clistart
  81.     bsr    opendos
  82.     bra.s    main
  83. WBStart
  84.     move.l    #1,wbstart
  85.     bsr    opendos
  86.     bsr    waitmsg
  87.     move.l    d0,returnmsg    ;save for exit
  88.     bra.s    main
  89. ;*************************************************************************
  90. waitmsg
  91.     move.l    startask,a1
  92.     lea    pr_MsgPort(a1),a0
  93.     execlib    WaitPort
  94.     move.l    startask,a1
  95.     lea    pr_MsgPort(a1),a0    ;wait for the wbench msg
  96.     execlib    GetMsg
  97.     rts
  98. ;***************************************************************
  99. main
  100.     bsr    openstuff    ;simple program eh?
  101.     bsr    getevent
  102. ;****************************************************************
  103. opendos
  104.     lea    dosname,a1
  105.     zero    d0
  106.     execlib    OpenLibrary    ;open dos lib (for Delay())
  107.     move.l    d0,dosbase    ;is there any way to not busy wait
  108.     beq    testwb        ;without AmigaDos? sure would be nice
  109.     rts            ;if a task could delay
  110. ;***************************************************************
  111. openstuff
  112.     lea    intname,a1
  113.     zero    d0
  114.     execlib    OpenLibrary
  115.     move.l    d0,intbase
  116.     beq    testwb        ;open int and graphics libs
  117.     lea    gfxname,a1
  118.     zero    d0
  119.     execlib    OpenLibrary
  120.     move.l    d0,gfxbase
  121.     beq    testwb
  122.     lea    NewWindowStructure1,a0
  123.     intlib    OpenWindow        ;open the window
  124.     tst.l    d0
  125.     beq    testwb
  126.     move.l    d0,a2
  127.     move.l    d0,a0
  128.     lea    Menu1,a1
  129.     intlib    SetMenuStrip
  130.     move.l    wd_FirstGadget(a2),a0    ;find the window close gadget
  131.     move.l    gg_NextGadget(a0),a0    ;and save adress so we can
  132.     move.l    gg_NextGadget(a0),a0    ;turn it off/on later
  133.     move.l    gg_NextGadget(a0),a5    ;it's the fourth gadget in the list
  134.  
  135.     CreatePort    sigbitx,mainport1,mainport1name,startask
  136.  
  137.     move.l    mainport1,d0
  138.     beq    testwb
  139. junka                    ;junks clear the local labels
  140.  
  141.     CreatePort    sigbitz,mainport2,mainport2name,startask
  142.  
  143.     move.l    mainport2,d0        ;create the ports for the main task
  144.     beq    testwb
  145.     getmem    #MN_SIZE,#MEMF_CLEAR!MEMF_PUBLIC,a3
  146.     move.l    a3,d0
  147.     beq    testwb
  148.                     ;get memory for a message to send
  149.     move.b    #NT_MESSAGE,LN_TYPE(a3)    ;to child task when user stops
  150.                     ;this one wants a reply at
  151.     move.l    mainport1,MN_REPLYPORT(a3)    ;first main port
  152.  
  153.     bsr    createmask    ;go create the main wakeup mask
  154.     bsr    calcgad1    ;go calculate the intial prop gadget    
  155.     bsr    calcgad2    ;pot values
  156.     rts
  157. ;**************************************************************
  158. createmask
  159.     zero    d1
  160.     move.b    sigbitz,d1    ;get the signal bit for mainport2
  161.     move.l    #1,d0
  162.     lsl.l    d1,d0        ;convert signal to # we can use
  163.     move.l    d0,d3    ;save it for later
  164.  
  165.                 ;same here, cept get sigbit from intuition
  166.     movea.l    wd_UserPort(a2),a0    ;opened port
  167.     zero    d1        ;we'll need this for idcmp msgs
  168.     move.b    MP_SIGBIT(a0),d1
  169.     move.l    #1,d0
  170.     lsl.l    d1,d0
  171.     move.l    d0,d2
  172.  
  173.     move.l    d3,d1        ;create the mask so we can
  174.     or.l    d0,d1            ;wait for either signal
  175.     move.l    d1,d4
  176.     rts
  177. ;************************************************************************
  178. calcgad1        ;see the Intuition manual for where i got this
  179.     lea    Gadget1SInfo,a0        ;find gadget special info struct
  180.     zero    d0
  181.     move.w    pi_HorizPot(a0),d0    ;get current value of pot
  182.     bne    1$        ;this effectively sets
  183.     add.w    #75,d0        ;the minimum time btwn flips to 3 secs
  184.                 ;the screen can't flip much faster anyway
  185.                 ;and you get into trouble if the user
  186.                 ;hits start again before a queued up flip
  187.                 ;request is finished processing
  188.                 ;this forces the sychronization of the two
  189.                 ;tasks,not elegant but it should work most
  190.                 ;of the time
  191. 1$
  192.     cmp.w    #$FFFF,d0        ;if it is maxed, skip the next inst
  193.     beq.s    2$        ;if not maxed, add one (we don't want a
  194.     addq.w    #1,d0        ;value of zero or anything larger than a word
  195. 2$
  196.     zero    d1
  197.     move.w    #MAXSECSBTWNFLIPS,d1    ;multiply the pot value by the
  198.     mulu    d1,d0            ;maximum value we want to set
  199.     pushreg    d0            ;save this value
  200.     zero    d1
  201.     move.w    #16,d1        ;divide this value by 65,536 which is
  202.     lsr.l    d1,d0        ;the max value of the pot variable
  203.     move.l    d0,secs        ;this effectively loses the lower word
  204.  
  205.     pullreg    d0        ;get the value back
  206.     move.l    #$FFFF,d1    
  207.     and.l    d1,d0        ;get rid of the upper 16 bits 
  208.     move.l    #1000,d1
  209.     mulu    d1,d0        ;multiply this value by 1,000,000
  210.     mulu    d1,d0        ;to get the number of microsecs
  211.     zero    d1
  212.     move.w    #16,d1
  213.     lsr.l    d1,d0        ;this is really not required since we
  214.     move.l    d0,microsecs    ; are dealing in minutes but what
  215.     rts            ; the heck
  216. ;****************************************************************
  217. calcgad2        ;similar to above with minor changes
  218.     lea    Gadget2SInfo,a0
  219.     zero    d0
  220.     move.w    pi_HorizPot(a0),d0
  221.     cmp.w    #$FFFF,d0
  222.     beq.s    1$
  223.     addq.w    #1,d0
  224. 1$
  225.     zero    d1
  226.     move.w    #MAXSECSTOSHOW,d1
  227.     mulu    d1,d0
  228.     pushreg    d0
  229.     zero    d1
  230.     move.w    #16,d1
  231.     lsr.l    d1,d0
  232.     move.l    d0,d6
  233.  
  234.     pullreg    d0
  235.     move.l    #$FFFF,d1
  236.     and.l    d1,d0
  237.     move.l    #1000,d1
  238.     mulu    d1,d0
  239.     mulu    d1,d0
  240.     zero    d1
  241.     move.w    #16,d1
  242.     lsr.l    d1,d0
  243.     cmp.l    #500000,d0    ;here the microsecs are more important
  244.     ble    2$        ;so we'll test if we are greater than
  245.     addq.l    #1,d6        ; one-half sec and round up if so
  246. 2$
  247.     move.l    d6,d1
  248.     addq.l    #1,d1        ;this seems to improve the accuracy of
  249.     move.l    d1,totalpause    ;timing a bit,besides we can't flip the
  250.     rts            ;screen is less than a sec anyway
  251. ;****************************************************************
  252. getevent
  253.     move.l    d4,d0    ;wait for sig at mainport2 or at UserPort from
  254.     execlib    Wait            ;intuition. the mainport2 signal
  255.     move.l    d0,d5            ;is from chtask telling us to
  256.     move.l    d2,d1            ;flip the screen
  257.     and.l    d0,d1
  258.     bne    handidcmp        ;handle intuition signal
  259. ;    move.l    d5,d0
  260.     move.l    d3,d1
  261.     and.l    d0,d1
  262.     bne.s    chaskedforflip        ;chtask asked us to flip
  263.     bra.s    getevent        ;just in case, should not get here
  264.  
  265. chaskedforflip
  266.     move.l    mainport2,a0        ;chtask told us to flip
  267.     execlib    GetMsg            ;get the msg
  268.     pushreg    d0            ;flip the screen and then reply
  269.     bsr    ud            ;we'll let it wait until we're
  270.     pullreg    d0            ;definitely through
  271.     move.l    d0,a1
  272.     execlib    ReplyMsg    ;now that we've flipped the screen and
  273.     bra.s    getevent    ;replied we can go back for more
  274.  
  275. handidcmp            ;must have received an intuimessage
  276.     movea.l    wd_UserPort(a2),a0    ;get window's Intuition port
  277.     execlib    GetMsg            ;get the message
  278.     beq.s    getevent        ;just in case
  279.  
  280.     movea.l    d0,a1            ;copy the message pointer to a1
  281.     pushreg    d4-d5/a2    ;we'll need these now, so save for later
  282.     move.l    im_Class(a1),d4        ;get the message class
  283.     zero    d5
  284.     move.w    im_Code(a1),d5        ;and code
  285.     movea.l    im_IAddress(a1),a2    ;and address (for gadget)
  286.     execlib    ReplyMsg        ;reply to it so it's happy
  287.  
  288.     cmpi.l    #CLOSEWINDOW,d4        ;is it a close window?
  289.     beq.s    clowinevent
  290.  
  291.     cmpi.l    #MENUPICK,d4        ;menu selection?
  292.     beq.s    menuevent
  293.  
  294.     cmpi.l    #GADGETUP,d4        ;was a gadget selected?
  295.     beq.s    gadevent
  296.                     ;should not reach this point
  297.     pullreg    d4-d5/a2        ;remember to pull these from stack
  298.     bra    getevent        ;again, just in case
  299.  
  300. clowinevent
  301.     pullreg    d4-d5/a2        ;it's a closewindow,therefore
  302.     bra    testwb            ;go to the exit routine
  303.  
  304. menuevent
  305.     cmpi.w    #MENUNULL,d5
  306.     bne    notnullmenu    ;if it's not null, deal with it
  307.     pullreg    d4-d5/a2    ;if it is, go back and wait for more msgs
  308.     bra    getevent
  309.  
  310. gadevent
  311.     zero    d0            ;a gadget was selected
  312.     move.w    gg_GadgetID(a2),d0    ;find out which one, I numbered them
  313.     pullreg    d4-d5/a2        ;1,2,3 in the gadget ID field
  314.  
  315.     cmpi.w    #1,d0            ;is it gad#1(user changed time btwn
  316.     bne.s    notgad1            ;flips)
  317. gad1
  318.     bsr    calcgad1        ;if it was, then recalculate pot
  319.     bra    getevent        ;and go get another event
  320. notgad1
  321.     cmpi.w    #2,d0        ;is it gad#2(user changed time to display
  322.     bne.s    notgad12    ;flipped screen)
  323.  
  324.     bsr    calcgad2    ;if so, go recalculate pot for gad #2
  325.     bra    getevent    ;and then get another event
  326. notgad12
  327.     cmpi.w    #3,d0        ;is it gad#3,(must be if we got here)
  328.     bne    getevent    ;if not we're in trouble
  329.  
  330.     lea    Gadget3,a0    ;now find out the state of the gadget
  331.     zero    d0        ;to decide if it was a start or a stop
  332.     move.w    gg_Flags(a0),d0
  333.     zero    d1
  334.     move.w    #SELECTED,d1    ;test for the toggle state
  335.     and.w    d1,d0
  336.     tst.w    d0        ;user just pushed start and gadget is now
  337.     bne    launch        ;in selected mode,go start chtask
  338.  
  339.     bsr    killchild    ;otherwise, user hit stop,so kill the child
  340.                 ;and go get another event since
  341.     bra    getevent    ;we are now effectively at position
  342.                 ;equivalent to start of program
  343. ;***************************************************************************
  344. ;        These routines handle the menu item requests
  345. ;**************************************************************************
  346. notnullmenu        ;this is simple, test which item and then
  347.     lsr.w    #5,d5        ;branch to a routine that deals with the item
  348.     andi.w    #$3f,d5
  349.     cmpi.w    #0,d5
  350.     beq    handitem0
  351.     cmpi.w    #1,d5
  352.     beq    handitem1
  353.     cmpi.w    #2,d5
  354.     beq    handitem2
  355.     cmpi.w    #3,d5
  356.     beq    handitem3
  357.     cmpi.w    #4,d5
  358.     beq    handitem4
  359.     cmpi.w    #5,d5
  360.     beq    handitem5
  361.  
  362.     bra    getevent        ;just in case
  363. ;***************************************************************************
  364. handitem0            ;user asked for instructions
  365.     pullreg    d4-d5/a2
  366.     opencon    intconsole,intfh    ;open a dos console window
  367.     move.l    wd_Descendant(a2),a1    ;find this window's address
  368.                     ;it is always the primary descendant
  369.                     ;of our control window
  370.     move.l    wd_FirstGadget(a1),a0    ;what we want is the sizing gadget
  371.     move.l    gg_NextGadget(a0),a0    ;of this con window
  372.     move.l    gg_NextGadget(a0),a0    ;it is the third in the list
  373.     pushreg    a2
  374.     zera    a2
  375.     intlib    OffGadget        ;say bye to it
  376.     pullreg    a2    ;if we don't turn it off then we'll
  377.                 ;have to refresh it every time user
  378.                 ;resizes it, too much trouble
  379.  
  380.     move.l    a2,a0        ;since our new con window has no menus
  381.     intlib    ActivateWindow    ;let's deactivate it and activate main win
  382.  
  383.     move.l    a2,a0        ;no we turn off the instructions menu
  384.     zero    d0        ;and turn on the bye instructions menu
  385.     intlib    OffMenu        ;don't want the user to get two sets
  386.     move.l    a2,a0        ;of instructions
  387.     move.l    #$40,d0
  388.     intlib    OnMenu
  389.  
  390.     conout    intfh,instrtext,instrtextend    ;print the text to the
  391.     bra    getevent        ;con window and go back for more
  392.  
  393. handitem1            ;totally analogous to handitem0
  394.     pullreg    d4-d5/a2    ;except this is the about con window
  395.     opencon    abtconsole,abtfh
  396.     move.l    wd_Descendant(a2),a1
  397.     move.l    wd_FirstGadget(a1),a0
  398.     move.l    gg_NextGadget(a0),a0
  399.     move.l    gg_NextGadget(a0),a0
  400.     pushreg    a2
  401.     zera    a2
  402.     intlib    OffGadget
  403.     pullreg    a2
  404.  
  405.     move.l    a2,a0
  406.     intlib    ActivateWindow
  407.     move.l    a2,a0
  408.     move.l    #$20,d0
  409.     intlib    OffMenu
  410.     move.l    a2,a0
  411.     move.l    #$60,d0
  412.     intlib    OnMenu
  413.     conout    abtfh,abtext,abtextend
  414.     bra    getevent
  415.  
  416. handitem2            ;this item closes the instruction window
  417.     pullreg    d4-d5/a2
  418.     tst.l    intfh        ;check if it's there
  419.     beq.s    1$
  420.     closecon    intfh    ;if it is close it
  421. 1$
  422.     move.l    a2,a0        ;now turn off the bye instructions menu
  423.     move.l    #$40,d0        ;and turn on the instructions menu
  424.     intlib    OffMenu        ;so user can ask for them again if desired
  425.     move.l    a2,a0        ;and then go back for more events
  426.     zero    d0
  427.     intlib    OnMenu
  428.     bra    getevent
  429.  
  430. handitem3            ;analogous to handitem2 except this
  431.     pullreg    d4-d5/a2    ;closes the about con window
  432.     tst.l    abtfh
  433.     beq.s    1$
  434.     closecon    abtfh
  435. 1$
  436.     move.l    a2,a0
  437.     move.l    #$60,d0
  438.     intlib    OffMenu
  439.     move.l    a2,a0
  440.     move.l    #$20,d0
  441.     intlib    OnMenu
  442.     bra    getevent
  443.  
  444. handitem4            ;user want's the concealed window exposed
  445.     pullreg    d4-d5/a2
  446.     bsr    enlargewin    ;go enlarge it and go back for more events
  447.     bra    getevent
  448.  
  449. handitem5            ;easy, user wants to quit so go to exit
  450.     pullreg    d4-d5/a2    ;routine
  451.     bra    testwb
  452. ;**************************************************************************
  453. enlargewin        ;can't get here unless the window was shrunk
  454.  
  455.     move.l    a2,a0        ;make sure window is in front, if user
  456.     intlib    WindowToFront    ;hit the window to back gadget while
  457.                 ;concealed it could end up hidden and
  458.                 ;leave user confused (happened to me
  459.                 ;once and I wrote the damn thing)
  460.  
  461.     move.l    a2,a0        ;find out how wide the user has his screen
  462.     move.l    gfxbase,a1    ;set to,normally this will be 640
  463.     zero    d0
  464.     move.w    gb_NormalDisplayColumns(a1),d0
  465.  
  466.     sub.w    #50,d0        ;subtract 50 from the width (our window width)
  467.     neg.w    d0        ;and reverse the sign of this value
  468.                 ;this will move window to left by this amount
  469.                 ;and place it at left edge = 0
  470.     zero    d1
  471.     move.w    #20,d1        ;we'll place it at top edge = 20
  472.     intlib    MoveWindow    ;call the function to move it
  473.  
  474.     move.l    a2,a0        ;now we want to resize it to 360 by 110
  475.                 ;remember, the width is now fixed at 50
  476.                 ;and the height can be any value from
  477.                 ;10 to 110
  478.     zero    d0
  479.     move.w    #310,d0        ;the width increment to resize is fixed
  480.                 ;user cannot adjust this in shrunk state
  481.     zero    d1
  482.     move.w    #110,d1        ;the height value we want
  483.     sub.w    wd_Height(a2),d1    ;subtract the current height
  484.                 ;to get the increment to increase by
  485.     intlib    SizeWindow    ;go to work
  486.  
  487.     move.l    a2,a0        ;now we turn off this menu since once
  488.     move.l    #$80,d0        ;window is enlarged it is useless
  489.     intlib    OffMenu
  490.     rts
  491. ;*************************************************************************
  492. launch
  493.     move.l    a5,a0            ;must have recvd a message to
  494.     move.l    a2,a1            ;start the program
  495.     pushreg    a2        ;not safe to exit the program while the
  496.     zera    a2        ;chtask is running so we'll turn off
  497.     intlib    OffGadget    ;the window close gadget
  498.     pullreg    a2
  499.  
  500.     move.l    a2,a0        ;and we'll also turn off the Quit
  501.     move.l    #$a0,d0        ;menu item
  502.     intlib    OffMenu
  503.  
  504.     bsr    shrinkwindow    ;go shrink and conceal the control window
  505.  
  506.     move.l    a2,a0        ;turn on the enlarge menu so user can
  507.     move.l    #$80,d0        ;get back to original size window
  508.     intlib    OnMenu
  509.  
  510.     bsr    ud        ;let's flip the screen once at the start
  511.  
  512.     MakeTask    chstsize,chstack,chtask,chtaskname,hello
  513.  
  514.     move.l    chtask,d0        ;start the child task which
  515.     beq    testwb        ;will do the timing for us and inform
  516.                 ;us when it is time to flip
  517.     bra    getevent    ;go back and wait for an event
  518. ;***************************************************************************
  519. shrinkwindow
  520.     move.l    a2,a0        ;window address to a0
  521.     zero    d0
  522.     zero    d1
  523.     move.w    wd_Width(a2),d0    ;current window width in d0
  524.     subi.w    #50,d0        ;we want to shrink it to width = 50
  525.  
  526.     move.w    wd_Height(a2),d1    ;current height in d1
  527.     subi.w    #10,d1        ;we want to shrink it to height = 10
  528.     neg.w    d0        ;negate these values to get increments
  529.     neg.w    d1        ;to resize by
  530.     intlib    SizeWindow    ;go resize
  531.  
  532.     move.l    a2,a0        ;window address in a0
  533.     zero    d0
  534.     zero    d1
  535.     move.w    wd_LeftEdge(a0),d1    ;find out current left edge
  536.  
  537.     move.l    gfxbase,a1        ;find out normal width (usually 640)
  538.     move.w    gb_NormalDisplayColumns(a1),d0
  539.  
  540.     sub.w    d1,d0        ;subtract the left edge from normal width
  541.     sub.w    #50,d0        ;subtract desired width from that
  542.                 ;to get final x increment to MoveWindow
  543.  
  544.     move.w    wd_TopEdge(a0),d1    ;get the current top edge
  545.     neg.w    d1            ;negate it since we want the top
  546.                     ;edge to become zero
  547.  
  548.     intlib    MoveWindow        ;move the window
  549.     rts
  550. ;**************************************************************************
  551. killchild
  552.     move.l    chport1,a0    ;if we get here user must have hit the
  553.     move.l    a3,a1        ;stop gadget,and since we have
  554.     execlib    PutMsg        ;chtask looking for a stop message
  555.     move.l    mainport1,a0    ;at chport1,we can send it a message to stop
  556.     execlib    WaitPort    ;we expect a reply from chtask so wait
  557.                 ;if we get a reply,chtask is stopped and
  558.                 ;waiting for us to say bye to it
  559. junkb
  560.     ByeTask        chstsize,chstack,chtask    ;again error check in macro
  561. junkc
  562.     DeletePort    chport1,sigbity        ;error check in macro
  563. junkd                        ;we've killed the task
  564.     DeletePort    chport2,sigbitq        ;and gotten rid of the
  565.     move.l    a5,a0            ;child ports so it is safe
  566.     move.l    a2,a1            ;if user wants to exit program now
  567.     pushreg    a2            ;so we can turn on the closewindow
  568.     zera    a2            ;gadget
  569.     intlib    OnGadget
  570.     pullreg    a2            ;and turn on the quit menu
  571.     move.l    a2,a0
  572.     move.l    #$a0,d0
  573.     intlib    OnMenu
  574.     rts
  575. ;**************************************************************************
  576. testwb            ;the exit routine
  577.     tst.l    intfh        ;close the console windows if they are
  578.     beq.s    1$        ;still open
  579.     closecon    intfh
  580. 1$
  581.     tst.l    abtfh
  582.     beq.s    2$
  583.     closecon    abtfh
  584. 2$
  585.     movea.l    initialSP,SP
  586.     zero    d0
  587.     pushreg    d0            ;save return code on stack
  588. junke
  589.     DeletePort    mainport1,sigbitx
  590. junkf                        ;delete the mainports
  591.     DeletePort    mainport2,sigbitz
  592. junkg
  593.     move.l    a3,d0            ;recover memory
  594.     beq    1$
  595.     byemem    #MN_SIZE,a3
  596. 1$
  597.     move.l    a2,d0
  598.     beq.s    2$
  599.     movea.l    d0,a0            ;close the window
  600.     intlib    CloseWindow
  601. 2$
  602.     move.l    intbase,d0
  603.     beq.s    3$
  604.     clolib    intbase
  605. 3$
  606.     move.l    gfxbase,d0
  607.     beq.s    4$
  608.     clolib    gfxbase
  609. 4$
  610.     movea.l    execbase,a6
  611.     move.l    dosbase,d0
  612.     beq.s    5$
  613.     clolib    dosbase
  614. 5$
  615.     tst.l    wbstart        ;start from wb? if not, branch to exit
  616.     beq.s    6$
  617.     tst.l    returnmsg    ;see if there was a wb message
  618.     beq.s    6$
  619.     execlib    Forbid            ;so workbench won't UnLoadSeg
  620.     movea.l    returnmsg,a1
  621.     execlib    ReplyMsg
  622. 6$
  623.     pullreg    d0            ;restore return (success) code
  624.     rts                ;back to operating system
  625. ;************************************************************************
  626.                 DATA
  627. ;***********************************************************************
  628.         evenpc
  629. dosname        dc.b    'dos.library',0
  630.         evenpc
  631. intname        dc.b    'intuition.library',0
  632.         evenpc
  633. gfxname        dc.b    'graphics.library',0
  634.         evenpc
  635. startask    dc.l    0
  636. clistart    dc.l    0
  637. wbstart        dc.l    0
  638. execbase    dc.l    0
  639. dosbase        dc.l    0
  640. intbase        dc.l    0
  641. gfxbase        dc.l    0
  642. initialSP    dc.l    0
  643. returnmsg    dc.l    0
  644. mainport1    dc.l    0
  645. mainport2    dc.l    0
  646. chstsize    dc.l    $7d0
  647. chstack        dc.l    0
  648. chtask        dc.l    0
  649. totalpause    dc.l    0
  650. secs        dc.l    0
  651. microsecs    dc.l    0
  652. intfh        dc.l    0
  653. abtfh        dc.l    0
  654. sigbitx        dc.b    0
  655.         evenpc
  656. sigbitz        dc.b    0
  657.         evenpc
  658. mainport1name    dc.b    'cjb.mainport1',0
  659.         evenpc
  660. mainport2name    dc.b    'cjb.mainport2',0
  661.         evenpc
  662. chtaskname    dc.b    'cjbtask',0
  663.         evenpc
  664. intconsole    dc.b    'CON:140/70/500/130/',0
  665.         evenpc
  666. abtconsole    dc.b    'CON:0/50/500/150/',0
  667.         evenpc
  668. instrtext
  669.         dc.b    $9b,$31,$3b,$33,$33,$3b,$34,$30,$6d,'How to Operate Flip',10
  670.         dc.b    $9b,$30,$3b,$33,$31,$3b,$34,$30,$6d
  671.         dc.b    '  1. The top gadget is used to set the amount of time      '
  672.         dc.b    'between screen flips.  This value can vary from a few      '
  673.         dc.b    'seconds for a setting of 0 to about 40 minutes at the      '
  674.         dc.b    'maximum setting.',10
  675.         dc.b    '  2. The middle gadget is used to set the length of time   '
  676.         dc.b    'that the flipped view will be displayed.  This value can   '
  677.         dc.b    'vary from about 1 second to a maximum of 9 seconds.',10
  678.         dc.b    '  3. The bottom gadget is used to start or stop the timing '
  679.         dc.b    'process.  Note that it is impossible to exit the program   '
  680.         dc.b    'while the timer is running.  You must stop the timer first '
  681.         dc.b    'and then you will be able to exit the program by selecting '
  682.         dc.b    'Quit from the menu or by clicking the CloseWindow gadget.  '
  683. instrtextend
  684.         evenpc
  685. abtext
  686.         dc.b    $9b,$31,$3b,$33,$33,$3b,$34,$30,$6d,'About Flip',10
  687.         dc.b    $9b,$30,$3b,$33,$31,$3b,$34,$30,$6d
  688.         dc.b    'I started this project in order to learn a little bit about'
  689.         dc.b    'assembly language programming on the Amiga.  It sort of    '
  690.         dc.b    'slowly ballooned into what you see here.  I should warn all'
  691.         dc.b    'programmers to look elsewhere for instructive code.  I know'
  692.         dc.b    'very little about programming and what little I do know is '
  693.         dc.b    'self-taught.  I also have a tendency of finding the time to'
  694.         dc.b    'produce this junk in the wee hours of the evening, long    '
  695.         dc.b    'after my brain has had the good sense to shift into low    '
  696.         dc.b    'gear until the morning.  In any case, if anyone feels the  '
  697.         dc.b    'need to comment on this production, you can reach me on    '
  698.         dc.b    'Compuserve (75226,1266), People Link (ops433 or something  '
  699.         dc.b    'like that, I''ve never bothered to get a personal ID), or on'
  700.         dc.b    'the CA-AUG BBS (216-581-2284).',10
  701.         dc.b    $9b,$33,$3b,$33,$33,$3b,$34,$30,$6d
  702.         dc.b    '                                        Charles J. Besecker'
  703. abtextend
  704.         evenpc
  705. ;***************************************************************************
  706. NewWindowStructure1:
  707.     dc.w    0,12    ;window XY origin relative to TopLeft of screen
  708.     dc.w    360,110    ;window width and height
  709.     dc.b    0,1    ;detail and block pens
  710.     dc.l    MENUPICK+GADGETUP+CLOSEWINDOW    ;IDCMP flags
  711.     dc.l    WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH    ;other window flags
  712.     dc.l    GadgetList1    ;first gadget in gadget list
  713.     dc.l    NULL    ;custom CHECKMARK imagery
  714.     dc.l    NewWindowName1    ;window title
  715.     dc.l    NULL    ;custom screen pointer
  716.     dc.l    NULL    ;custom bitmap
  717.     dc.w    50,10    ;minimum width and height
  718.     dc.w    360,110    ;maximum width and height
  719.     dc.w    WBENCHSCREEN    ;destination screen type
  720. NewWindowName1:
  721.     dc.b    '  Flip Control Window',0
  722.     cnop 0,2
  723. Menu1:
  724.     dc.l    NULL    ;*NextMenu
  725.     dc.w    3,0    ;LeftEdge,TopEdge
  726.     dc.w    54,0    ;Width,Height
  727.     dc.w    MENUENABLED    ;Flags
  728.     dc.l    MenuName1    ;*MenuName
  729.     dc.l    Item0    ;*FirstItem
  730.     dc.w    NULL,NULL,NULL,NULL    ;intuition defined
  731. MenuName1:
  732.     dc.b    'Flip                                              by Charles J. Besecker',0
  733.     evenpc
  734. Item0:
  735.     dc.l    Item1    ;*NextItem
  736.     dc.w    0,0    ;LeftEdge,TopEdge
  737.     dc.w    144,10    ;Width,Height
  738.     dc.w    ITEMENABLED!ITEMTEXT!HIGHCOMP
  739.     dc.l    NULL    ;mutualexclude
  740.     dc.l    ITextItem0    ;*ItemFill
  741.     dc.l    NULL    ;SelectFill
  742.     dc.b    NULL    ;Command
  743.     dc.l    NULL    ;*SubItem
  744.     dc.w    NULL    ;NextSelect
  745.     evenpc
  746. ITextItem0:
  747.     dc.b    0,1,RP_JAM1,0    ;front and back text pens, drawmode and fill byte
  748.     dc.w    0,1    ;XY origin relative to container TopLeft
  749.     dc.l    TOPAZ80    ;font pointer or NULL for default
  750.     dc.l    Item0Text    ;pointer to text
  751.     dc.l    NULL    ;next IntuiText structure
  752. Item0Text:
  753.     dc.b    'Instructions',0
  754.     evenpc
  755. Item1:
  756.     dc.l    Item2    ;*NextItem
  757.     dc.w    0,10    ;LeftEdge,TopEdge
  758.     dc.w    144,10    ;Width,Height
  759.     dc.w    ITEMENABLED!ITEMTEXT!HIGHCOMP
  760.     dc.l    NULL    ;mutualexclude
  761.     dc.l    ITextItem1    ;*ItemFill
  762.     dc.l    NULL    ;SelectFill
  763.     dc.b    NULL    ;Command
  764.     dc.l    NULL    ;*SubItem
  765.     dc.w    NULL    ;NextSelect
  766.     evenpc
  767. ITextItem1:
  768.     dc.b    0,1,RP_JAM1,0    ;front and back text pens, drawmode and fill byte
  769.     dc.w    0,1    ;XY origin relative to container TopLeft
  770.     dc.l    TOPAZ80    ;font pointer or NULL for default
  771.     dc.l    Item1Text    ;pointer to text
  772.     dc.l    NULL    ;next IntuiText structure
  773. Item1Text:
  774.     dc.b    'About',0
  775.     evenpc
  776. Item2:
  777.     dc.l    Item3    ;*NextItem
  778.     dc.w    0,20    ;LeftEdge,TopEdge
  779.     dc.w    144,10    ;Width,Height
  780.     dc.w    ITEMTEXT!HIGHCOMP
  781.     dc.l    NULL    ;mutualexclude
  782.     dc.l    ITextItem2    ;*ItemFill
  783.     dc.l    NULL    ;SelectFill
  784.     dc.b    NULL    ;Command
  785.     dc.l    NULL    ;*SubItem
  786.     dc.w    NULL    ;NextSelect
  787.     evenpc
  788. ITextItem2:
  789.     dc.b    0,1,RP_JAM1,0    ;front and back text pens, drawmode and fill byte
  790.     dc.w    0,1    ;XY origin relative to container TopLeft
  791.     dc.l    TOPAZ80    ;font pointer or NULL for default
  792.     dc.l    Item2Text    ;pointer to text
  793.     dc.l    NULL    ;next IntuiText structure
  794. Item2Text:
  795.     dc.b    'Bye Instructions',0
  796.     evenpc
  797. Item3:
  798.     dc.l    Item4    ;*NextItem
  799.     dc.w    0,30    ;LeftEdge,TopEdge
  800.     dc.w    144,10    ;Width,Height
  801.     dc.w    ITEMTEXT!HIGHCOMP
  802.     dc.l    NULL    ;mutualexclude
  803.     dc.l    ITextItem3    ;*ItemFill
  804.     dc.l    NULL    ;SelectFill
  805.     dc.b    NULL    ;Command
  806.     dc.l    NULL    ;*SubItem
  807.     dc.w    NULL    ;NextSelect
  808.     evenpc
  809. ITextItem3:
  810.     dc.b    0,1,RP_JAM1,0    ;front and back text pens, drawmode and fill byte
  811.     dc.w    0,1    ;XY origin relative to container TopLeft
  812.     dc.l    TOPAZ80    ;font pointer or NULL for default
  813.     dc.l    Item3Text    ;pointer to text
  814.     dc.l    NULL    ;next IntuiText structure
  815. Item3Text:
  816.     dc.b    'Bye About',0
  817.     evenpc
  818. Item4:
  819.     dc.l    Item5    ;*NextItem
  820.     dc.w    0,40    ;LeftEdge,TopEdge
  821.     dc.w    144,10    ;Width,Height
  822.     dc.w    ITEMTEXT!HIGHCOMP
  823.     dc.l    NULL    ;mutualexclude
  824.     dc.l    ITextItem4    ;*ItemFill
  825.     dc.l    NULL    ;SelectFill
  826.     dc.b    NULL    ;Command
  827.     dc.l    NULL    ;*SubItem
  828.     dc.w    NULL    ;NextSelect
  829.     evenpc
  830. ITextItem4:
  831.     dc.b    0,1,RP_JAM1,0    ;front and back text pens, drawmode and fill byte
  832.     dc.w    0,1    ;XY origin relative to container TopLeft
  833.     dc.l    TOPAZ80    ;font pointer or NULL for default
  834.     dc.l    Item4Text    ;pointer to text
  835.     dc.l    NULL    ;next IntuiText structure
  836. Item4Text:
  837.     dc.b    'Enlarge Window',0
  838.     evenpc
  839. Item5:
  840.     dc.l    NULL    ;*NextItem
  841.     dc.w    0,50    ;LeftEdge,TopEdge
  842.     dc.w    144,10    ;Width,Height
  843.     dc.w    ITEMENABLED!ITEMTEXT!HIGHCOMP
  844.     dc.l    NULL    ;mutualexclude
  845.     dc.l    ITextItem5    ;*ItemFill
  846.     dc.l    NULL    ;SelectFill
  847.     dc.b    NULL    ;Command
  848.     dc.l    NULL    ;*SubItem
  849.     dc.w    NULL    ;NextSelect
  850.     evenpc
  851. ITextItem5:
  852.     dc.b    0,1,RP_JAM1,0    ;front and back text pens, drawmode and fill byte
  853.     dc.w    0,1    ;XY origin relative to container TopLeft
  854.     dc.l    TOPAZ80    ;font pointer or NULL for default
  855.     dc.l    Item5Text    ;pointer to text
  856.     dc.l    NULL    ;next IntuiText structure
  857. Item5Text:
  858.     dc.b    'Quit',0
  859.     evenpc
  860. GadgetList1:
  861. Gadget1:
  862.     dc.l    Gadget2    ;next gadget
  863.     dc.w    50,25    ;origin XY of hit box relative to window TopLeft
  864.     dc.w    250,8    ;hit box width and height
  865.     dc.w    NULL    ;gadget flags
  866.     dc.w    RELVERIFY    ;activation flags
  867.     dc.w    PROPGADGET    ;gadget type flags
  868.     dc.l    Image1    ;gadget border or image to be rendered
  869.     dc.l    NULL    ;alternate imagery for selection
  870.     dc.l    IText1    ;first IntuiText structure
  871.     dc.l    NULL    ;gadget mutual-exclude long word
  872.     dc.l    Gadget1SInfo    ;SpecialInfo structure
  873.     dc.w    1    ;user-definable data
  874.     dc.l    NULL    ;pointer to user-definable data
  875. Gadget1SInfo:
  876.     dc.w    AUTOKNOB+FREEHORIZ    ;PROPINFO flags
  877.     dc.w    1638,-1    ;horizontal and vertical pot values
  878.     dc.w    1638,-1    ;horizontal and vertical body values
  879.     dc.w    0,0,0,0,0,0    ;previous requester (filled in by Intuition)
  880. Image1:
  881.     dc.w    0,0    ;XY origin relative to container TopLeft
  882.     dc.w    7,4    ;Image width and height in pixels
  883.     dc.w    0    ;number of bitplanes in Image
  884.     dc.l    NULL    ;pointer to ImageData
  885.     dc.b    $0000,$0000    ;PlanePick and PlaneOnOff
  886.     dc.l    NULL    ;next Image structure
  887. IText1:
  888.     dc.b    3,0,RP_JAM2,0    ;front and back text pens, drawmode and fill byte
  889.     dc.w    -15,-10    ;XY origin relative to container TopLeft
  890.     dc.l    TOPAZ80    ;font pointer or NULL for default
  891.     dc.l    ITextText1    ;pointer to text
  892.     dc.l    IText2    ;next IntuiText structure
  893. ITextText1:
  894.     dc.b    'Time Between Screen Flips In Minutes',0
  895.     cnop 0,2
  896. IText2:
  897.     dc.b    3,0,RP_JAM2,0    ;front and back text pens, drawmode and fill byte
  898.     dc.w    -6,9    ;XY origin relative to container TopLeft
  899.     dc.l    TOPAZ80    ;font pointer or NULL for default
  900.     dc.l    ITextText2    ;pointer to text
  901.     dc.l    NULL    ;next IntuiText structure
  902. ITextText2:
  903.     dc.b    '0      10      20      30      40',0
  904.     cnop 0,2
  905. Gadget2:
  906.     dc.l    Gadget3    ;next gadget
  907.     dc.w    50,56    ;origin XY of hit box relative to window TopLeft
  908.     dc.w    250,8    ;hit box width and height
  909.     dc.w    NULL    ;gadget flags
  910.     dc.w    RELVERIFY    ;activation flags
  911.     dc.w    PROPGADGET    ;gadget type flags
  912.     dc.l    Image2    ;gadget border or image to be rendered
  913.     dc.l    NULL    ;alternate imagery for selection
  914.     dc.l    IText3    ;first IntuiText structure
  915.     dc.l    NULL    ;gadget mutual-exclude long word
  916.     dc.l    Gadget2SInfo    ;SpecialInfo structure
  917.     dc.w    2    ;user-definable data
  918.     dc.l    NULL    ;pointer to user-definable data
  919. Gadget2SInfo:
  920.     dc.w    AUTOKNOB+FREEHORIZ    ;PROPINFO flags
  921.     dc.w    0,-1    ;horizontal and vertical pot values
  922.     dc.w    1638,-1    ;horizontal and vertical body values
  923.     dc.w    0,0,0,0,0,0    ;previous requester (filled in by Intuition)
  924. Image2:
  925.     dc.w    0,0    ;XY origin relative to container TopLeft
  926.     dc.w    7,4    ;Image width and height in pixels
  927.     dc.w    0    ;number of bitplanes in Image
  928.     dc.l    NULL    ;pointer to ImageData
  929.     dc.b    $0000,$0000    ;PlanePick and PlaneOnOff
  930.     dc.l    NULL    ;next Image structure
  931. IText3:
  932.     dc.b    3,0,RP_JAM2,0    ;front and back text pens, drawmode and fill byte
  933.     dc.w    -31,-10    ;XY origin relative to container TopLeft
  934.     dc.l    TOPAZ80    ;font pointer or NULL for default
  935.     dc.l    ITextText3    ;pointer to text
  936.     dc.l    IText4    ;next IntuiText structure
  937. ITextText3:
  938.     dc.b    'Time Before Flip View Disappears in Secs',0
  939.     cnop 0,2
  940. IText4:
  941.     dc.b    3,0,RP_JAM2,0    ;front and back text pens, drawmode and fill byte
  942.     dc.w    -6,9    ;XY origin relative to container TopLeft
  943.     dc.l    TOPAZ80    ;font pointer or NULL for default
  944.     dc.l    ITextText4    ;pointer to text
  945.     dc.l    NULL    ;next IntuiText structure
  946. ITextText4:
  947.     dc.b    '1       3       5       7      9',0
  948.     cnop 0,2
  949. Gadget3:
  950.     dc.l    NULL    ;next gadget
  951.     dc.w    127,78    ;origin XY of hit box relative to window TopLeft
  952.     dc.w    101,21    ;hit box width and height
  953.     dc.w    GADGHIMAGE+GADGIMAGE    ;gadget flags
  954.     dc.w    RELVERIFY+TOGGLESELECT    ;activation flags
  955.     dc.w    BOOLGADGET    ;gadget type flags
  956.     dc.l    Image3    ;gadget border or image to be rendered
  957.     dc.l    Image4    ;alternate imagery for selection
  958.     dc.l    NULL    ;first IntuiText structure
  959.     dc.l    NULL    ;gadget mutual-exclude long word
  960.     dc.l    NULL    ;SpecialInfo structure
  961.     dc.w    3    ;user-definable data
  962.     dc.l    NULL    ;pointer to user-definable data
  963. Image3:
  964.     dc.w    0,0    ;XY origin relative to container TopLeft
  965.     dc.w    101,21    ;Image width and height in pixels
  966.     dc.w    2    ;number of bitplanes in Image
  967.     dc.l    ImageData3    ;pointer to ImageData
  968.     dc.b    $0003,$0000    ;PlanePick and PlaneOnOff
  969.     dc.l    NULL    ;next Image structure
  970. ImageData3:
  971.     dc.w    $003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F
  972.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF
  973.     dc.w    $FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF
  974.     dc.w    $FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF
  975.     dc.w    $FFFF,$FFE0,$0000,$FFC0,$0000,$0000,$0000,$0000
  976.     dc.w    $001F,$F800,$FFC0,$0000,$F020,$0000,$2000,$001F
  977.     dc.w    $F800,$FFC0,$0001,$9860,$0000,$6000,$001F,$F800
  978.     dc.w    $FFC0,$0001,$C0F8,$F3B0,$F800,$001F,$F800,$FFC0
  979.     dc.w    $0000,$E060,$19D8,$6000,$001F,$F800,$FFC0,$0000
  980.     dc.w    $3860,$7998,$6000,$001F,$F800,$FFC0,$0001,$9869
  981.     dc.w    $9980,$6800,$001F,$F800,$FFC0,$0000,$F030,$EFC0
  982.     dc.w    $3000,$001F,$F800,$FFC0,$0000,$0000,$0000,$0000
  983.     dc.w    $001F,$F800,$FFC0,$0000,$0000,$0000,$0000,$001F
  984.     dc.w    $F800,$FFC0,$0000,$0000,$0000,$0000,$001F,$F800
  985.     dc.w    $003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F
  986.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF
  987.     dc.w    $FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF
  988.     dc.w    $FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF
  989.     dc.w    $FFFF,$FFE0,$0000,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
  990.     dc.w    $FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
  991.     dc.w    $F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
  992.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF
  993.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF
  994.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$0FDF
  995.     dc.w    $FFFF,$DFFF,$FFFF,$F800,$FFFF,$FFFE,$679F,$FFFF
  996.     dc.w    $9FFF,$FFFF,$F800,$FFFF,$FFFE,$3F07,$0C4F,$07FF
  997.     dc.w    $FFFF,$F800,$FFFF,$FFFF,$1F9F,$E627,$9FFF,$FFFF
  998.     dc.w    $F800,$FFFF,$FFFF,$C79F,$8667,$9FFF,$FFFF,$F800
  999.     dc.w    $FFFF,$FFFE,$6796,$667F,$97FF,$FFFF,$F800,$FFFF
  1000.     dc.w    $FFFF,$0FCF,$103F,$CFFF,$FFFF,$F800,$FFFF,$FFFF
  1001.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF
  1002.     dc.w    $FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF
  1003.     dc.w    $FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
  1004.     dc.w    $FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
  1005.     dc.w    $F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
  1006.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF
  1007.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
  1008. Image4:
  1009.     dc.w    0,0    ;XY origin relative to container TopLeft
  1010.     dc.w    101,21    ;Image width and height in pixels
  1011.     dc.w    2    ;number of bitplanes in Image
  1012.     dc.l    ImageData4    ;pointer to ImageData
  1013.     dc.b    $0003,$0000    ;PlanePick and PlaneOnOff
  1014.     dc.l    NULL    ;next Image structure
  1015. ImageData4:
  1016.     dc.w    $FFC0,$0000,$0000,$0000,$0000,$001F,$F800,$FFC0
  1017.     dc.w    $0000,$0000,$0000,$0000,$001F,$F800,$FFC0,$0000
  1018.     dc.w    $0000,$0000,$0000,$001F,$F800,$FFC0,$0000,$0000
  1019.     dc.w    $0000,$0000,$001F,$F800,$FFC0,$0000,$0000,$0000
  1020.     dc.w    $0000,$001F,$F800,$003F,$FFFF,$FFFF,$FFFF,$FFFF
  1021.     dc.w    $FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0
  1022.     dc.w    $0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000
  1023.     dc.w    $003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F
  1024.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF
  1025.     dc.w    $FFFF,$FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF
  1026.     dc.w    $FFFF,$FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF
  1027.     dc.w    $FFFF,$FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF
  1028.     dc.w    $FFE0,$0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0
  1029.     dc.w    $0000,$003F,$FFFF,$FFFF,$FFFF,$FFFF,$FFE0,$0000
  1030.     dc.w    $FFC0,$0000,$0000,$0000,$0000,$001F,$F800,$FFC0
  1031.     dc.w    $0000,$0000,$0000,$0000,$001F,$F800,$FFC0,$0000
  1032.     dc.w    $0000,$0000,$0000,$001F,$F800,$FFC0,$0000,$0000
  1033.     dc.w    $0000,$0000,$001F,$F800,$FFC0,$0000,$0000,$0000
  1034.     dc.w    $0000,$001F,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
  1035.     dc.w    $FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
  1036.     dc.w    $F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
  1037.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF
  1038.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF
  1039.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$C3F7
  1040.     dc.w    $FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$99E7,$FFFF
  1041.     dc.w    $FFFF,$FFFF,$F800,$FFFF,$FFFF,$8FC1,$C323,$FFFF
  1042.     dc.w    $FFFF,$F800,$FFFF,$FFFF,$C7E7,$9999,$FFFF,$FFFF
  1043.     dc.w    $F800,$FFFF,$FFFF,$F1E7,$9999,$FFFF,$FFFF,$F800
  1044.     dc.w    $FFFF,$FFFF,$99E5,$9983,$FFFF,$FFFF,$F800,$FFFF
  1045.     dc.w    $FFFF,$C3F3,$C39F,$FFFF,$FFFF,$F800,$FFFF,$FFFF
  1046.     dc.w    $FFFF,$FF0F,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF
  1047.     dc.w    $FFFF,$FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF
  1048.     dc.w    $FFFF,$FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
  1049.     dc.w    $FFFF,$F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
  1050.     dc.w    $F800,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
  1051.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800,$FFFF
  1052.     dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$F800
  1053.  
  1054. TOPAZ80:
  1055.     dc.l    TOPAZname
  1056.     dc.w    TOPAZ_EIGHTY
  1057.     dc.b    0,0
  1058. TOPAZname:
  1059.     dc.b    'topaz.font',0
  1060.     cnop 0,2
  1061. ; end of PowerWindows source generation
  1062. ;************************************************************************
  1063. ;    Code for Child Task Starts Here
  1064. ;**************************************************************************
  1065. hello
  1066.     CreatePort    sigbity,chport1,chport1name,chtask
  1067.     move.l    chport1,d0    ;create the ports for the child
  1068.     beq    chwait        ;this is an ugly exit, I know
  1069. junkh
  1070.     CreatePort    sigbitq,chport2,chport2name,chtask
  1071. junki
  1072.     move.l    chport2,d0
  1073.     beq    chwait        ;this is messy here but I can't see
  1074.                 ;an obvious way out at the moment
  1075.  
  1076.     getmem    #MN_SIZE,#MEMF_CLEAR!MEMF_PUBLIC,a4
  1077.     move.l    a4,d0        ;get some memory for the message we'll
  1078.     beq    chwait        ;send to main when its time to flip        
  1079.  
  1080.     move.b    #NT_MESSAGE,LN_TYPE(a4)
  1081.     move.l    chport2,MN_REPLYPORT(a4)    ;we want a reply
  1082.  
  1083.     move.l    timioreq,d0        ;get some memory for a time request
  1084.     bne    tagain
  1085.     getmem    #IOTV_SIZE,#MEMF_CLEAR!MEMF_PUBLIC,timioreq
  1086.     beq    chwait        ;horrible exit,but???
  1087.  
  1088.     lea    timname,a0
  1089.     move.l    #UNIT_VBLANK,d0
  1090.     move.l    timioreq,a1
  1091.     move.l    #0,d1
  1092.     execlib    OpenDevice        ;open the timer device
  1093.  
  1094. tagain
  1095.     move.l    timioreq,a0        ;have timer reply to us at
  1096.     move.l    chport1,MN_REPLYPORT(a0)    ;chport1
  1097.     move.w    #TR_ADDREQUEST,IO_COMMAND(a0)
  1098.     add.l    #IO_SIZE,a0
  1099.     move.l    secs,TV_SECS(a0)    ;these are from the gad#1 pot value
  1100.     move.l    microsecs,TV_MICRO(a0)    ;obtained in calcgad1
  1101.  
  1102.     move.l    timioreq,a1
  1103.     execlib    SendIO        ;asynchronous request,we've got other things
  1104.                 ;to do while the timer is at work
  1105.  
  1106. waitagain
  1107.     move.l    chport1,a0    ;here we'll get one of two messages,either
  1108.     execlib    WaitPort    ;from the timer or from main telling
  1109.                 ;us to stop
  1110.     movea.l    chport1,a0
  1111.     execlib    GetMsg            ;get the message
  1112.  
  1113.     move.l    d0,a0        ;we can tell which message it is by the
  1114.     move.l    d0,chrecvdmsg        ;task it came from
  1115.     move.l    MN_REPLYPORT(a0),a0
  1116.     move.l    MP_SIGTASK(a0),d0
  1117.     move.l    startask,d1        ;is it from the main task?
  1118.     cmp.l    d1,d0
  1119.     beq    handuserquitmsg        ;if so it must be a stop message
  1120.                     ;so go deal with that
  1121.  
  1122.     move.l    chrecvdmsg,a0        ;otherwise it is a timer msg
  1123.     move.l    MN_REPLYPORT(a0),a0    ;but we'll check replyport to be
  1124.     move.l    MP_SIGTASK(a0),d0    ;sure
  1125.     move.l    chtask,d1
  1126.     cmp.l    d1,d0
  1127.     bne    waitagain        ;just to be safe
  1128.  
  1129.     move.l    mainport2,a0    ;ok, we must tell main to flip the screen
  1130.     move.l    a4,a1        ;love to be able to flip the screen here
  1131.         ;in the child task but the ud routine uses the damn Delay
  1132.         ;function in AmigaDos which we can't call from a lowly task
  1133.         ;silly isn't it?
  1134.  
  1135.     execlib    PutMsg        ;tell main to flip and wait for a reply
  1136.     move.l    chport2,a0    ;saying that it has,we use chport2 for this
  1137.     execlib    WaitPort    ;while chport1 is busy queuing up timer/stop
  1138.     bra    tagain        ;messages,when we get reply, go back and
  1139.                 ;wait for another message at chport1
  1140.  
  1141. handuserquitmsg        ;ok, user wants to stop the flipping
  1142.     move.l    timioreq,a1
  1143.     execlib    CheckIO        ;check to see if timer is still timing
  1144.     bne    requestcomplete    ;if not we don't have to abort the timer
  1145.     ABORTIO    timioreq    ;request, if so, abort it (I went south
  1146.                 ;here many times trying to figure this out)
  1147.             ;still not sure if correct, but it seems to work
  1148. requestcomplete
  1149.     move.l    timioreq,d0    ;timer device is now quiet so we can say
  1150.     move.l    d0,a1        ;bye to it
  1151.     execlib    CloseDevice
  1152.  
  1153.     move.l    timioreq,d0    ;we can also free up the time request memory
  1154.     byemem    #IOTV_SIZE,timioreq
  1155.  
  1156.     byemem    #MN_SIZE,a4        ;and the flip message memory
  1157.  
  1158.     move.l    #0,timioreq        ;set these to zero since
  1159.     zera    a4            ;they don't exist anymore
  1160.  
  1161.     move.l    chrecvdmsg,a1    ;now we can finally reply to main that
  1162.     execlib    ReplyMsg    ;we're closed up tight and ready to be
  1163.                 ;put to sleep
  1164. chwait
  1165.     zero    d0        ;endless wait,so main can close us down
  1166.     execlib    Wait        ;I think this is correct?
  1167. ;**************************************************************************
  1168. ;             Data for Child Task
  1169. ;**************************************************************************
  1170.     evenpc
  1171. chport1        dc.l    0
  1172. chport2        dc.l    0
  1173. timioreq    dc.l    0
  1174. chrecvdmsg    dc.l    0
  1175. sigbity        dc.b    0
  1176.     evenpc
  1177. sigbitq        dc.b    0
  1178.     evenpc
  1179. chport1name    dc.b    'cjb.childport1',0
  1180.     evenpc
  1181. chport2name    dc.b    'cjb.childport2',0
  1182.     evenpc
  1183. timname        dc.b    'timer.device',0
  1184.     evenpc
  1185.     end
  1186.