*********************************************************** * Project main program file.. this ios the event loop for * * the demo program. * *********************************************************** **************************************************************** * EventLoop * * Main loop of the program. All menu setups will go here to * * to start with * **************************************************************** EventLoop Start Using In_Loc Using RAM jsr ClearVars Clear out all temp storage and ZP jsr MakeMenuBar now create and post our menu bar jsr AllocWind create all the windows we need MainLoop ANop Bit QuitFlg check to see if quit selected bpl ML0010 nope no quit rts yes do the quit ML0010 ANop PushWord #0 room for result PushWord #$FFFF PushLong #Event pass the event record _TaskMaster and get the next appl event pla get the event type beq MainLoop if no event do it again ; Now check to see what event was hit.. and handle it accordingly cmp #InSysMenu was it a menu select event? bne ML0020 nope.. try next event jsr MenuSelect handle it jmp MainLoop and go back to beginning ML0020 ANop cmp #InGoAway bne ML0030 jsr CloseWindow close this window jmp MainLoop ML0030 ANop Jmp MainLoop go back to the beginning END **************************************************************** *ClearVars * * This routine zeros out all program variables and inits the * * various memory stuff we need. * **************************************************************** ClearVars START Using RAM stz QuitFlg rts END **************************************************************** *MakeMenuBar * * this routine creates the menu bar that the program is going * * to use and draws it on the screen * **************************************************************** MakeMenuBar START Using RAM PushLong #0 PushLong #MenuMenu _NewMenu PushWord #0 _InsertMenu PushLong #0 PushLong #DemoMenu _NewMenu MenuPtr:=NewMenu(DemoMenu) PushWord #0 _InsertMenu InsertMenu(MenuPtr,0) PushLong #0 room for result PushLong #FileMenu menu data to create _NewMenu and form the menu Pea 0 Posn in menu bar _InsertMenu now insert it into our Bar PushLong #0 room for result PushLong #AppleMenu menu data to create _NewMenu Pea 0 _InsertMenu PushWord #1 _FixAppleMenu Pha Height:=FixMenuBar _FixMenuBar pla _DrawMenuBar and draw the menu bar! ; PushWord #259 DisableItem(258) ; _DisableItem rts END **************************************************************** *AllocWind * * This routine creates the windows that will be used in this * **************************************************************** AllocWind START Using RAM PushLong #0 Space for return value PushLong #Wind1Parm parameters for this wondow _NewWindow create a new window pla sta Window1 pla sta Window1+2 rts END **************************************************************** *CloseWindow * * This routine will put away the top most window when the * * go away button is pressed * **************************************************************** CloseWindow START Using RAM PushLong TaskData Push the pointer to the window to close _HideWindow and get it off the screen rts END **************************************************************** *Wind1UpDate * * This routine redraws the entire contents of Window1. It is * * to be used as your update routine for your window record * * thats why it ends with a RTL... * **************************************************************** Wind1UpDate START Using RAM PushWord #0 PushWord #0 moveto(0,0); _MoveTo PushWord #512 PushWord #512 _LineTo LineTo(512,512); PushWord #512 PushWord #0 _MoveTo MoveTo(512,0); PushWord #0 PushWord #512 _LineTo LineTo(0,512); RTL END **************************************************************** *MenuSelect * * This routine will accept the menu item hit from the event * * record and act on it. * **************************************************************** MenuSelect START Using RAM lda TaskData get the item # hit and #$00FF strip off the high byte asl A multiply by 2 TAX put it into our index lda MenuDisp,x and get the address from the table pha put the address on the stack rts and jump to it {sneaky eh?} MenuDisp ANop table of menu routines dc i'AboutDemo-1' dc i'Quit-1' dc i'WindowDemo-1' dc i'DialogDemo-1' dc i'DisableIt-1' Disable the test Item dc i'MarkIt-1' Mark the test Item dc i'BackToNormal-1' Put the test Item back dc i'UnHiLite-1' This is the test item END **************************************************************** *UnHiLite * * This routine should be called at the end of every menu * * selection to turn off the inversed title bar and return to * * the main loop * **************************************************************** UnHiLite START Using RAM PushWord #0 UnHiLight flag lda TaskData+2 get the menu number selected pha _HiLiteMenu RTS END **************************************************************** *DisableIt * * Disable Menu item 263 * **************************************************************** DisableIt START Using RAM PushWord #263 _DisableItem jmp UnHiLite END **************************************************************** *MarkIt * * places a mark next to item 263 * **************************************************************** MarkIt START Using RAM Pushword #1 PushWord #263 _CheckItem jmp UnHiLite END **************************************************************** *BackToNormal * * sets item 263 back to normal * **************************************************************** BackToNormal START Using RAM PushWord #0 PushWord #263 _CheckItem PushWord #263 _EnableItem Jmp UnHiLite END **************************************************************** *AboutDemo * * This routine will draw the about demo dialog box and then * * call modal dialog. exit via UnHiLite * **************************************************************** AboutDemo START Using RAM PushLong #0 PushLong #MyModal _GetNewModalDialog pla sta Dialog pla sta Dialog+2 PushWord #0 PushLong #0 _ModalDialog pla PushLong Dialog _CloseDialog jmp UnHiLite END **************************************************************** *Quit * * This routine simply sets the quit flag and returns.. * **************************************************************** Quit START Using RAM lda #$FFFF sta QuitFlg jmp UnHiLite END **************************************************************** *WindowDemo * * This routine enables a window for the window manager demo * **************************************************************** WindowDemo START Using RAM PushLong Window1 _SelectWindow select the window for display PushLong Window1 and now show it _ShowWindow jmp UnHiLite now turn off menu bar END ************************************************************ * DialogTest * DialogDemo START using RAM using dlgequ using DialogData _DialogReset pushlong #0 pushlong #rect_dialog pushword #1 pushlong #0 _NewModalDialog pla sta Dialog pla sta Dialog+2 pushlong dialog pushword #1 ; ID pushlong #rect_button pushword #ButtonItem pushlong #title_button PushWord #0 ItemValue pushword #0 ; no flag pushlong #0 ; no color _NewDItem pushlong dialog pushword #2 ; ID pushlong #Rect1_Stattext pushword #StatText+ItemDisable pushlong #Stat1 pushWord #0 ItemValue pushword #0 ; no flag pushlong #0 ; no color _NewDItem pushlong dialog pushword #3 ; ID pushlong #Rect2_Stattext pushword #StatText+ItemDisable pushlong #Stat2 PushWord #0 ItemValue pushword #0 ; no flag pushlong #0 ; no color _NewDItem pushlong dialog pushword #20 ; ID pushlong #Rect1_Radio pushword #RadioItem pushlong #Title1_Radio PushWord #0 ItemValue pushword #0 ; no flag pushlong #0 ; no color _NewDItem pushlong dialog pushword #21 ; ID pushlong #Rect2_Radio pushword #RadioItem pushlong #Title2_Radio PushWord #0 ItemValue pushword #0 ; no flag pushlong #0 ; no color _NewDItem pushlong dialog pushword #10 ; ID pushlong #Rect_Check pushword #CheckItem pushlong #Title_Check PushWord #0 ItemValue pushword #0 ; no flag pushlong #0 ; no color _NewDItem lda #20 Now set the first radio button sta ItemHit to be on.. jsr InvertCtl ; Modal Dialog Loop modalloop anop PushWord #0000 pushlong #0000 _ModalDialog pla sta ItemHit cmp #01 Was the OK Button hit?? bne ML0010 Nope try next item.. jmp DialogDone ML0010 ANOP cmp #10 Item NUmber for check Box.. bne ML0020 jmp CheckBox Handle a checkBox Item.... ML0020 Anop Radio Button Hit.... jsr InvertCtl Invert the one that was hit lda ItemHit Eor #1 and invert the otherone... sta ItemHit jsr InvertCtl brl ModalLoop get next modal event.. CheckBox Anop jsr InvertCtl brl ModalLoop DialogDone ANOP PushLong Dialog Now close the Dialog and end. _CloseDialog Jmp UnHiLite and finish this menu option. InvertCtl Anop This routine is to be used for PushLong #0 inverting the state of any of the ctrls PushLong Dialog in our dialog box PushWord ItemHit stored in ItemHit _GetControlItem pla sta MyTemp save the handle to the Item.. pla sta MyTemp+2 PushWord #0 Now find out what state it is in.. PushLong MyTemp _GetCtlValue pla Eor #1 and set or reset it..... pha and put it back on the stack PushLong MyTemp _SetCtlValue rts END APPEND Proj.data