home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************************
- * Program: Tutorial2.asm
- * Descrip: Second tutorial executable for ReSource.
- * Usage: None
- * Author: Jeff Lavin
- * History: 08/18/91 V1.0 Created
- *****************************************************************************
-
- ifnd __m68
- fail 'Wrong assembler!'
- endc
- exeobj
- objfile 'Tutorial2'
-
- ifnd SysBase
- SysBase equ 4
-
- SYS macro ;Call a library function
- jsr (_LVO\1,a6)
- endm
- endc
-
- Tutorial2 lea (DT,pc),a5 ;Get our relative base
- movea.l a5,a0
- moveq #(BSS_Len/4)-1,d1 ;Subtract 1 for the dbcc
- moveq #0,d0
- ..Loop move.l d0,(a0)+ ;Clear work area
- dbra d1,..Loop
-
- movea.l (SysBase).w,a6
- movea.l (ThisTask,a6),a2 ;Our task base
- tst.l (pr_CLI,a2) ;From CLI or WBench?
- bne.b .FromCLI
-
- lea (pr_MsgPort,a2),a0
- SYS WaitPort
- lea (pr_MsgPort,a2),a0
- SYS GetMsg ;Get WBench startup msg
- move.l d0,(_WBenchMsg-DT,a5) ;and save it
-
- .FromCLI lea (GfxName,pc),a1 ;Open graphics.library
- moveq #0,d0 ;Any version
- SYS OpenLibrary
- move.l d0,(_GfxBase-DT,a5)
- beq.w Cleanup
- movea.l d0,a6 ;GraphicsBase is in A6
-
- lea (MyTextAttr,pc),a0
- SYS OpenFont
- move.l d0,(_FontPtr-DT,a5)
- beq.w Cleanup
-
- lea (IntName,pc),a1 ;Open intuition.library
- moveq #0,d0 ;Any version
- movea.l (SysBase).w,a6
- SYS OpenLibrary
- move.l d0,(_IntuitionBase-DT,a5)
- beq.b Cleanup
- movea.l d0,a6 ;IntuitionBase is in A6
-
- lea (MyNewWindow,pc),a0
- SYS OpenWindow ;Open our demo window
- move.l d0,(_WindowPtr-DT,a5)
- beq.b Cleanup
-
- movea.l d0,a0
- movea.l (wd_RPort,a0),a1
- move.l a1,(_RastPort-DT,a5)
- movea.l (_FontPtr-DT,a5),a0
- movea.l (_GfxBase-DT,a5),a6
- SYS SetFont
-
- .GetMsg movea.l (_WindowPtr-DT,a5),a2 ;Ptr to our demo window
- movea.l (wd_UserPort,a2),a0
- movea.l (SysBase).w,a6
- SYS GetMsg
- tst.l d0 ;Did we get an IntuiMsg?
- bne.b .GotMsg
-
- movea.l (wd_UserPort,a2),a0
- SYS WaitPort ;Wait for an IntuiMsg
- bra.b .GetMsg ;Go remove the msg
-
- .GotMsg movea.l d0,a1 ;Ok, we've got an IntuiMsg
- move.l (im_Class,a1),d2 ;Extract the IDCMP class
- movea.l (im_IAddress,a1),a2 ;and the address
- SYS ReplyMsg ;Return the msg to Intuition
-
- cmpi.l #GADGETUP,d2 ;Was it a GADGETUP msg?
- bne.b .CheckDown ;No, check next type
- bsr.w EraseText ;Yes, process it
- bra.b .GetMsg ;Get next msg
-
- .CheckDown cmpi.l #GADGETDOWN,d2 ;Was it a GADGETDOWN msg?
- bne.b .CheckClose ;No, check next type
- .Dispatch movea.l (gg_UserData,a2),a0 ;Get function address
- jsr (a0) ;Do that puppy!
- bra.b .GetMsg ;Get next msg
-
- .CheckClose cmpi.l #CLOSEWINDOW,d2 ;Was it a CLOSEWINDOW msg?
- bne.b .GetMsg ;No, keep looking for msgs
- ;Fall thru to cleanup
- Cleanup move.l (_IntuitionBase-DT,a5),d0 ;Do we have a ptr to Intuition?
- beq.b .CloseFont ;No, then we don't have a window
- movea.l d0,a6 ;Yes, get ptr into A6
- move.l (_WindowPtr-DT,a5),d0
- beq.b .CloseInt
- movea.l d0,a0
- SYS CloseWindow ;Close the demo window
-
- .CloseInt movea.l a6,a1
- movea.l (SysBase).w,a6
- SYS CloseLibrary ;Close intuition.library
-
- .CloseFont move.l (_GfxBase-DT,a5),d0
- beq.b .WBench
- movea.l d0,a6
- move.l (_FontPtr-DT,a5),d0
- beq.b .CloseGfx
- movea.l d0,a1
- SYS CloseFont
-
- .CloseGfx movea.l a6,a1
- movea.l (SysBase).w,a6
- SYS CloseLibrary ;Close graphics.library
-
- .WBench move.l (_WBenchMsg-DT,a5),d2
- beq.b .Exit
- movea.l (SysBase).w,a6
- SYS Forbid ;So WBench won't UnloadSeg() us
- movea.l d2,a1
- SYS ReplyMsg ;Return startup msg
- .Exit moveq #0,d0 ;Always return OK
- rts
-
- ;True_Button function
-
- Brag moveq #3,d0
- lea (True.txt,pc),a0
- bra.b PrintText
-
- ;Face_Button function
-
- Complain moveq #2,d0
- lea (Ouch.txt,pc),a0
- bra.b PrintText
-
- EraseText moveq #0,d0
- lea (Erase.txt,pc),a0
-
- PrintText move.l a0,-(sp)
- movea.l (_RastPort-DT,a5),a1
- movea.l (_GfxBase-DT,a5),a6
- SYS SetAPen
-
- moveq #70,d0
- moveq #46,d1
- movea.l (_RastPort-DT,a5),a1
- SYS Move
-
- movea.l (sp)+,a0
- moveq #4,d0
- movea.l (_RastPort-DT,a5),a1
- SYS Text
- rts
-
- ;False_Button function
-
- Beep movea.l (_WindowPtr-DT,a5),a0
- movea.l (wd_WScreen,a0),a0
- movea.l (_IntuitionBase-DT,a5),a6
- SYS DisplayBeep
- rts
-
- MyTextAttr dl FontName
- dw 8
- db FS_NORMAL
- db FPF_ROMFONT
-
- MyNewWindow dw 100,100,170,55
- db -1,-1
- dl CLOSEWINDOW!GADGETUP!GADGETDOWN
- dl WINDOWCLOSE!WINDOWDRAG!SIMPLE_REFRESH!NOCAREREFRESH!ACTIVATE
- dl True_Button
- dl 0
- dl WindowTitle
- dl 0,0
- dw 0,0,0,0
- dw WBENCHSCREEN
-
- True_Button dl Face_Button
- dw 20,20,31,15
- dw GADGHCOMP
- dw GADGIMMEDIATE!RELVERIFY
- dw BOOLGADGET
- dl Button_Border,0
- dl True_ITxt
- dl 0,0
- dw 0
- dl Brag
-
- True_ITxt db 1,0,RP_JAM1,0
- dw 0,20
- dl MyTextAttr,True.txt,0
-
- Face_Button dl False_Button
- dw 70,20,31,15
- dw GADGIMAGE!GADGHIMAGE
- dw GADGIMMEDIATE!RELVERIFY
- dw BOOLGADGET
- dl Smil