home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
new
/
amigalibdisks
/
d984
/
icontoclip
/
icontoclip.s
< prev
next >
Wrap
Text File
|
1994-04-04
|
23KB
|
1,196 lines
***************************************************
* IconToClip *
* by Douglas Nelson *
* *
* Assemble with Macro68 *
* *
* Object size = 3598 ($0E0E) bytes *
* Output file size = 4052 bytes *
* *
***************************************************
strict
default _absolute,_pcrel
exeobj
errfile ram:assem.output
objfile ram:I2C.exe
listfile ram:listfile
incpath mac:includes
incpath ram:includes
macfile alllibraryoffsets.i
macfile dos/dosextens.i
macfile exec/alerts.i
macfile exec/ports.i
macfile intuition/intuition.i
macfile libraries/iffparse.i
macfile libraries/gadtools.i
macfile workbench/workbench.i
macfile workbench/startup.i
***** startup
move.l sp,(initialSP)
move.l d0,d7 ;store dosCmdLen
movea.l (4).w,a6
move.l a6,(execbase)
* open dos
lea dosname,a1
move.l #37,d0
jsr (_LVOOpenLibrary,a6)
move.l d0,(dosbase)
bne.b gotdos
move.l #AG_OpenLib!AO_DOSLib,d7
jsr (_LVOAlert,a6)
failexit tst.l d7
bne.b fail2
bsr.b getWbMsg
bsr.b replyWbMsg
fail2 moveq #20,d0 ;FAIL
rts
exit movea.l (execbase),a6
movea.l (dosbase),a1
jsr (_LVOCloseLibrary,a6)
tst.l (WBenchMsg)
beq.b exit2
bsr.b replyWbMsg
exit2 move.l (rc),d0
movea.l (initialSP),sp
rts
* the next two subroutines here appear to allow byte branches
replyWbMsg movea.l (execbase),a6
jsr (_LVOForbid,a6)
movea.l (WBenchMsg),a1
jsr (_LVOReplyMsg,a6)
rts
getWbMsg suba.l a1,a1
jsr (_LVOFindTask,a6)
movea.l d0,a5
lea (pr_MsgPort,a5),a0
jsr (_LVOWaitPort,a6)
lea (pr_MsgPort,a5),a0
jsr (_LVOGetMsg,a6)
move.l d0,(WBenchMsg)
rts
gotdos move.l #10,(rc) ;ERROR for early exit
tst.l d7 ;dosCmdLen
beq.b WBstart
* read command line
lea template,a0
move.l a0,d1
lea pathname,a0
move.l a0,d2
moveq #0,d3 ;no optional RdArgs
movea.l (dosbase),a6
jsr (_LVOReadArgs,a6)
move.l d0,d1
jsr (_LVOFreeArgs,a6)
bra main
WBstart
bsr.b getWbMsg
* read WBArgs
movea.l d0,a2
movea.l (sm_ArgList,a2),a2
move.l (wa_Lock,a2),d1
movea.l (dosbase),a6
jsr (_LVOCurrentDir,a6)
move.l d0,d7 ;store old dir
* open icon.library
lea iconname,a1
move.l #37,d0
movea.l (execbase),a6
jsr (_LVOOpenLibrary,a6)
move.l d0,(iconbase)
beq.b endicon
*read ToolTypes
movea.l d0,a6
movea.l (wa_Name,a2),a0
jsr (_LVOGetDiskObject,a6)
tst.l d0
beq.b closeicon
movea.l d0,a2
movea.l (do_ToolTypes,a2),a0
lea pathnamename,a1
jsr (_LVOFindToolType,a6)
tst.l d0
beq.b checkcolumn
moveq #1,d0
move.l d0,(pathname)
checkcolumn movea.l (do_ToolTypes,a2),a0
lea columnname,a1
jsr (_LVOFindToolType,a6)
tst.l d0
beq.b checkwindow
moveq #1,d0
move.l d0,(column)
checkwindow movea.l (do_ToolTypes,a2),a0
lea windowname,a1
jsr (_LVOFindToolType,a6)
tst.l d0
beq.b freediskobj
moveq #1,d0
move.l d0,(window)
freediskobj
movea.l (iconbase),a6
movea.l a2,a0
jsr (_LVOFreeDiskObject,a6)
closeicon movea.l (iconbase),a1
movea.l (execbase),a6
jsr (_LVOCloseLibrary,a6)
* restore old dir
endicon move.l d7,d1
movea.l (dosbase),a6
jsr (_LVOCurrentDir,a6)
***** main program
main movea.l (execbase),a6
lea workbenchname,a1 ;open workbench
moveq #37,d0
jsr (_LVOOpenLibrary,a6)
move.l d0,(workbenchbase)
beq cleanup
lea intuitionname,a1 ;open intuition
moveq #37,d0
jsr (_LVOOpenLibrary,a6)
move.l d0,(intuibase)
beq cleanup
lea iffparsename,a1 ;open iffparse
moveq #37,d0
jsr (_LVOOpenLibrary,a6)
move.l d0,(iffparsebase)
beq cleanup
lea gadtoolsname,a1 ;open gadtools
moveq #37,d0
jsr (_LVOOpenLibrary,a6)
move.l d0,(gadtoolsbase)
beq cleanup
lea diskfontname,a1 ;open diskfont
moveq #37,d0
jsr (_LVOOpenLibrary,a6)
move.l d0,(diskfontbase)
beq cleanup
lea graphicsname,a1 ;open gfx
moveq #37,d0
jsr (_LVOOpenLibrary,a6)
move.l d0,(gfxbase)
beq cleanup
* create our two MsgPorts
movea.l (execbase),a6
jsr (_LVOCreateMsgPort,a6)
move.l d0,(WorkbenchMP)
beq cleanup
jsr (_LVOCreateMsgPort,a6)
move.l d0,(WindowMP)
beq cleanup
* add item to Tools menu
moveq #1,d0
moveq #0,d1
lea menuname,a0
movea.l (WorkbenchMP),a1
suba.l a2,a2
movea.l (workbenchbase),a6
jsr (_LVOAddAppMenuItemA,a6)
move.l d0,(appmenuitem)
beq cleanup
* cleared all obstacles, so set return code to success
moveq #0,d0
move.l d0,(rc)
* store signal masks
movea.l (WindowMP),a0
moveq #0,d1
move.b (MP_SIGBIT,a0),d1
moveq #1,d0
lsl.l d1,d0
move.l d0,(windowsignal)
movea.l (WorkbenchMP),a0
moveq #0,d1
move.b (MP_SIGBIT,a0),d1
moveq #1,d0
lsl.l d1,d0
move.l d0,(wbsignal)
* calculate union of all signal masks
or.l (windowsignal),d0
or.l (breaksignal),d0
move.l d0,(allsignals)
* open window if user specifies
tst.l (window) ;did user ask for window?
beq.b eventloop
bsr SetupScreen
tst.l d0
beq.b nowinbeep
bsr OpenI2CWindow
tst.l d0
bne.b eventloop
nowinbeep movea.l (intuibase),a6
* moveq #0,d0 ;d0 is zero anyway
jsr (_LVODisplayBeep,a6) ;warn that window is not available
eventloop move.l (allsignals),d0
movea.l (execbase),a6
jsr (_LVOWait,a6)
move.l d0,d7 ;store signal mask
* is signal from WorkbenchMP?
move.l (wbsignal),d0
and.l d7,d0
beq.b testwindowsignal
bsr HandleAppMsg
* is signal from WindowMP?
testwindowsignal
move.l (windowsignal),d0
and.l d7,d0
beq.b testbreaksignal
bsr HandleGadget
tst.l d0
beq.b cleanup ;user selected QUIT gadget
* is signal a CTRL-C?
testbreaksignal
move.l (breaksignal),d0
and.l d7,d0
bne.b cleanup ;got BREAK signal
bra eventloop ;wait for next event
* prepare to quit
cleanup tst.l (appmenuitem)
beq closewindow
* clear pending AppMsgs
clearappmsg movea.l (WorkbenchMP),a0
movea.l (execbase),a6
jsr (_LVOGetMsg,a6)
tst.l d0 ;did we get a message?
beq.b killappmenu
movea.l d0,a1
jsr (_LVOReplyMsg,a6)
bra.b clearappmsg
* remove Tools menu item; safe to call with NULL pointer
killappmenu movea.l (appmenuitem),a0
movea.l (workbenchbase),a6
jsr (_LVORemoveAppMenuItem,a6)
* close window if open
closewindow bsr CloseI2CWindow
bsr CloseDownScreen
* close MsgPorts
movea.l (execbase),a6
move.l (WindowMP),d0
beq.b closeWorkbenchMP
movea.l d0,a0
jsr (_LVODeleteMsgPort,a6)
closeWorkbenchMP
move.l (WorkbenchMP),d0
beq.b closelibs
movea.l d0,a0
jsr (_LVODeleteMsgPort,a6)
closelibs move.l (gfxbase),d0
beq.b closediskfont
movea.l d0,a1
jsr (_LVOCloseLibrary,a6)
closediskfont
move.l (diskfontbase),d0
beq.b closegadtools
movea.l d0,a1
jsr (_LVOCloseLibrary,a6)
closegadtools
move.l (gadtoolsbase),d0
beq.b closeiffparse
movea.l d0,a1
jsr (_LVOCloseLibrary,a6)
closeiffparse
move.l (iffparsebase),d0
beq.b closeintui
movea.l d0,a1
jsr (_LVOCloseLibrary,a6)
closeintui move.l (intuibase),d0
beq.b closeworkbench
movea.l d0,a1
jsr (_LVOCloseLibrary,a6)
closeworkbench
move.l (workbenchbase),d0
beq.b allclosed
movea.l d0,a1
jsr (_LVOCloseLibrary,a6)
allclosed
bra exit
***** subroutine HandleAppMsg
* returns NULL in d0 if anything fails
HandleAppMsg
movea.l (WorkbenchMP),a0
movea.l (execbase),a6
jsr (_LVOGetMsg,a6)
move.l d0,(appmsg)
beq endHandleAppMsg
sf (separate) ;first name, so no separator
movea.l d0,a0
move.l (am_ArgList,a0),(arglist)
move.l (am_NumArgs,a0),(numargs)
bne IconIsHilited
* user selected menu with no icons hilited, so open window
move.l (I2CWnd),d0
beq.b openwindow
* window is open so move it to front
movea.l d0,a0
movea.l (intuibase),a6
jsr (_LVOWindowToFront,a6)
bra NextAppMsg
* must call SetupScreen() each time before opening window, since sneaky user
* may have changed Workbench screen
openwindow bsr SetupScreen
tst.l d0
beq.b nowindow
bsr OpenI2CWindow
tst.l d0
bne NextAppMsg ;window opened successfully
nowindow movea.l (intuibase),a6
* moveq #0,d0 ;d0 is zero anyway
jsr (_LVODisplayBeep,a6) ;warn that window is not available
bra NextAppMsg
IconIsHilited
tst.l (column)
beq.b lineformat
move.b #$A,(separator) ;separate names with linefeed
bra.b tryInitClip
lineformat move.b #' ',(separator) ;separate names with space
tryInitClip bsr Init