******************************************************************************* * * Copyright 1990-1993 Apple Computer, Inc * All Rights Reserved * * 26-Jan-93 SS -- Removed QDAuxStartup call * ******************************************************************************* string asis blanks off print push,off include 'All.macros' include 'E16.Menu' include 'E16.Event' include 'E16.Locator' Import CurrentDirPath Import MyOpenRec Import MyDirEntry Import TempNamePtr Import tempString Import MyClose Import MyID Import MyListCnt Import MyList Import ListCtrl Import AsmtoolErr Import MatchType Import MatchStr Import IdleWind Import VolPopUp Import StackHandle Import StackLevel Import PascalStack Import EntryCount Import Stopping Import SetMessage Import ListCtrl Import screenMode entry MyMemberDraw entry InsertIntoList entry InsertTheItem entry GetHandle entry SetPopup Entry AsmAddFile GBLA &Debug &Debug Seta 0 print pop EJECT ******************************************************************************* * SetAboutMessage PROC Export * * Description: This little routine will set the about message in the message * box and cause it to be drawn. * * * Inputs: None * * Outputs: None * * External Refs: * * Entry Points: * ******************************************************************************* PushLong #VersionInfo jsl SetMessage rtl VersionInfo dc.B textEnd-textStart textStart dc.B $01,$4A,$01,$00 ; center justify dc.B 'Find File',$0d dc.B '©1990-93 Apple Computer Inc.',$0d dc.B 'by Mensch, Yee, Lyons, & Stephenson',$0D dc.B 'Tested by M.S. & B.K. & J.J.J' textEnd EndP ******************************************************************************* * * InstallMyRequestProc * * AcceptRequests(@reqProcName, MMStartUp, ffRequestProc); * ******************************************************************************* InstallMyRequestProc proc export import ffRequestProc pushlong #reqProcName pha _MMStartUp pushlong #ffRequestProc _AcceptRequests rtl reqProcName str 'Apple~FindFile~1.1~' EndP ******************************************************************************* * * ffRequestProc * * This is Find File's Request Procedure, installed by AcceptRequests. * * We watch for systemSaysMenuKey(Command-F) and open ourselves. * ******************************************************************************* ffRequestProc PROC export oldDPage equ 1 RTL1 equ oldDPage+2 DataOut equ RTL1+3 DataIn equ DataOut+4 Request equ DataIn+4 Result equ Request+2 phd tsc tcd phb phk plb lda VolPopup+2 pha lda >VolPopup pha phx rts EndP ;------------------------------------------------------------------ ; ; GSOStoPString ; ; Converts a GS/OS output string to a pstring. ; ; IN: ptr to dest pstring:LONG (Destination) ; ptr to GSOS output string:LONG (Source) ; ; OUT: dest has been converted to a pstring ; ;------------------------------------------------------------------ GSOStoPString PROC EXPORT i equ 1 oldDPage equ i+2 theRTL equ oldDPage+2 Source equ theRTL+3 Dest equ source+4 phd pha ; make room for the data tsc tcd ; set our new direct page... ; ; Start by getting the proper length into i and dest lda [ back on longa On lda #0 clc ; exit like a tool call rtl ; and leave EndP ;--------------------------------------------------------------------------- ; ; Global record for use with the popup menu stuff and disk switch stuff. ; ;--------------------------------------------------------------------------- popUpGlobals record Count ds.w 1 ; stores the number of items in the menu MenuItemTemplate Version dc.w 0 ; must be zero MyItemID ds.w 1 dc.b 0 ; ItemChar, no key equivs... dc.b 0 ; ItemAltChar dc.w 0 ; ItemCheck dc.w $4520 ; bits 9 and 10 describe the item struct. ; ; ItemFlag, XOR hiliting, title is a handle ItemStruct ds.l 1 ; This will be a handle to the volume name ; ; ---- GS/OS parameter block definitions -------------- ; SearchDevNum ds.w 1 ; Device number that was last searched (22-May-91 MSD) DInfoPBlock dc.w 8 ; pcount DevNum ds.w 1 ; device number dc.l DevNameBuffer ; pointer to buffer to store device name Characteristics ds.w 1 ; characteristics ds.l 1 ; totalBlocks ds.w 1 ; slotnum ds.w 1 ; unitnum ds.w 1 ; version DeviceID ds.w 1 ; deviceID VolumePBlock dc.w 2 ; pcount dc.l DevName ; device name (GS/OS input string) dc.l VolNameBuffer ; pointer to buffer to store volume name DevNameBuffer dc.w 35 ; word length count DevName ds.b 35 ; buffer to store device name VolNameBuffer dc.w 35 ; word length count VolumeName ds.b 35 ; buffer to store volume name GetVolNameFlag ds.W 1 ; flag for get vol name... DStatusPBlock dc.W 5 ; pCount DStatDevNum ds.W 1 ; device number dc.W 0 ; status code dc.L StatusList ; status info returned here dc.L $00000002 ; request count, no. of bytes to return ds.L 1 ; amount of info actually returned StatusList StatusWord ds.W 1 ; status word returned for device NotifyPBlock dc.w 1 ; pCount theRoutine ds.L 1 ; the notificaton proc DiskEject equ $0010 DeviceSwitched ds.w 1 DeviceInserted ds.w 1 theName ds.L 1 StaticDeviceTable ds.B 128 ;table of devices not to make DStatus call on. EndR ;============================================================================== ; ; PollDevices ; ; This routine just polls all devices making DStatus calls on them, trying to ; trigger a disk switch event. If one occurs then GS/OS calls my routine ; NotificationPROC to handle the event. ; ;============================================================================== PollDevices PROC EXPORT Import ServiceDiskSwitch with PopUpGlobals phb phk plb *** added 23-Apr-91 DAL -- limit polling frequency to 1.5 seconds jsr GetTick sec sbc prevPollTick cmp #180 bcc DoNothing *** end of 23-Apr-91 DAL stz DStatDevNum ;reset the device number so we can search from begining BigLooper inc DStatDevNum ;check next device lda DStatDevNum ;Check our table to see if this device even needs to be cmp #65 ;polled. Non-removable devices and 5.25s are not polled. bcs @done ;exit when we reach our 64 device limit asl a tax lda StaticDeviceTable-2,x bmi BigLooper _DStatusGS DStatusPBlock bcc BigLooper ;loop until we run out of devices @done *** added 23-Apr-91 DAL jsr GetTick sta prevPollTick *** end of 23-Apr-91 DAL DoNothing plb rtl prevPollTick dc.w 0 GetTick pha pha _TickCount pla plx rts ENDP ;============================================================================== ; ; NotificationPROC ; ; This is the routine that gets installed into GS/OS's notification queue. ; NumVolumes is incremented or decremented depending on the disk switch. We ; save off the device number of the disk that got switched and the flag that ; tells us whether an insertion or ejection occurred. ; We pay particular attention to disk ejects that occurred on the currently ; displayed volume. ; ; On entry: Acc = device number ; event_code = bit 4 set = eject ; bit 3 set = insert ; ;============================================================================== NotificationPROC PROC EXPORT with PopupGlobals Reserved1 ds.L 1 ;link to next task in queue Reserved2 ds.W 1 Signature dc.W $A55A Event_flags dc.L $00000018 ;want disk inserts/ejects Event_code ds.L 1 ;curent event code will be put here by GS/OS with PopUpGlobals phk ;first set the data bank correctly plb cmp #65 ; beyond our 64-device limit? bcs @done ; yes, just ignore it tay ; move device number of disk switched device into y-reg asl a tax lda StaticDeviceTable-2,x bmi @Done ; ignore 5.25's and non-removeable media drives lda Event_Code ;save flag that tells us whether an insert or eject happened lsr a lsr a lsr a and #%0011 ora StaticDeviceTable-2,x sta StaticDeviceTable-2,x sty DeviceSwitched ;set flag to show that we've been through here ;list is automatically redrawn on disk insertion. @Done rtl ENDP ;================================================== ; This routine inserts the notification routine ; into the GS/OS notification queue to get ; informed of disk switch events ;================================================== CallNotifyProc Proc Export with PopupGlobals phb phk plb lda #NotificationPROC sta theRoutine lda #^NotificationPROC sta theRoutine+2 _AddNotifyProcGS NotifyPBlock plb rtl EndP ;================================================== ; This routine removes the notification routine ; from the GS/OS notification queue ;================================================== CallDelNotifyProc Proc Export with PopupGlobals phb phk plb _DelNotifyProcGS NotifyPBlock plb rtl EndP ;=========================================================== ; ;=========================================================== ServiceDiskSwitch Proc Export with PopupGlobals phb phk plb lda DeviceSwitched ; check if there was a disk switch bne gotSwitch brl exit ; that was easy! gotSwitch pha ; save current menu bar on the stack pha _GetMenuBar jsr PushLongVolPopup ; set new menu bar to popup control _SetMenuBar stz DeviceInserted ; init this ldx #0 ; now we walk the list, looking for ANY disk switch @switch_loop lda StaticDeviceTable,x bmi @skip_it ; skip over 5.25's and non-removables beq @skip_it ; no eject/insert here! phx ; save index txa ; convert to device number lsr a inc a ; adjust for 1-based array sta DeviceSwitched ; set this for the update_menu subroutine jsr update_menu ; go update the popup plx ; retrieve index lda StaticDeviceTable,x ;get the eject/insert bits and #%0001 ; was the device inserted? beq @no_insert ; no... lda DeviceSwitched ; else save the device number sta DeviceInserted ; so we can update the menu properly @no_insert stz StaticDeviceTable,x @skip_it inx ; step to next device inx cpx #128 ; maximum of 64 devices in table bcc @switch_loop ; now that we've handled all the ejects/inserts, update the displayed menu lda DeviceInserted ;the last device number that was inserted bne @use_this pha ; get the current setting jsr PushLongVolPopup _GetCtlValue pla cmp DeviceSwitched ; was the ejected device currently set? beq @reset ; if so, reset menu to first device @use_this pha jsr PushLongVolPopup _SetCtlValue ; set popup result to name of newly inserted disk pha ; now let's make sure it was a valid value jsr PushLongVolPopup _GetCtlValue pla bne @was_valid @reset pha ; space for result pea 1 ; menu id _CountMItems ; is there anything in the menu? pla beq @was_valid ; nope, just leave it set to 0 jsr SetPopup @was_valid pea 0 ; width pea 0 ; height pea 1 ; ID of menu _CalcMenuSize _SetMenuBar ; restore original menu bar exit stz DeviceSwitched ; set up for next time through the loop plb rtl update_menu ; ; ----- Handle disk ejection ----------------------------------- ; doEject ; ----- Get rid of the memory for the item struct assoc. with this item ; DPage equ 1 thePtr equ DPage+2 theHandle equ thePtr+4 lda #0 ; space for result pha pha lda DeviceSwitched pha ; that's our menu item number ldx #$4A0F jsl $E10000 ; GetItemStruct bcs doInsert ; it wasn't in the menu to begin with! lda 1,s ; was the item really there? ora 3,s beq doInsert ; no... pha ; space for derefing itemstruct so we can get at pha ; the handle to the item's name phd tsc tcd lda [idleWind ; push grafport ptr PushWord #0 ; input ref is a pointer to a single item template PushLong #PopUpControl1 _NewControl2 pla sta >VolPopUp pla sta >VolPopUp+2 pha ; space for handle to menubar pha _GetMenuBar ; save current menubar, leave handle on stack jsr PushLongVolPopup ; set menubar to popup menu so we can _SetMenuBar ; operate on the popup jsr AddItems ; find all volumes on-line and insert into popup pea 0 ; calculate height and width of newly formed pea 0 ; volumes popup pea 1 ; ID of menu to calculate _CalcMenuSize _SetMenuBar ; Restore original menubar _InitCursor rts ; --------------------------------------------------------------------- ; NewControl2 template for a popup control. ; --------------------------------------------------------------------- PopUpControl1 dc.w 9 ; pcount dc.l 1 ; ID of control dc.w 5+1,10,18,220 ; rectangle for popup control (8-Dec-91 DAL) dc.l $87000000 ; popup procref dc.w $0060 ; type 2 popup, don't hilite title, {right justify title} dc.w $10A0 ; more flags, fctlProcNotPtr, fDrawIconInResult, fDrawArrowIcon dc.l 0 ; no refcon dc.w 0 ; title width dc.l PopupMenu1 ; ptr to menu item list dc.w 1 ; initial value of popup selection PopupMenu1 dc.w 0 ; version, must be zero xMenuID dc.w 1 ; id of popup menu dc.w $0000 ; menu flag dc.l PopupTitle1 ; title of popup menu dc.l 0000 ; no items, empty menu PopupTitle1 str 'Disks: ' ;================================================== ; ; AddItems ; ; This routine calls routine GetNextVolume, which ; returns the next volume that is online. This ; volume is then inserted into the "volumes" popup. ; ;================================================== AddItems With popUpGlobals ; First we zero out the device table ldx #128 @ZeroLoop stz StaticDeviceTable-2,x dex dex bne @ZeroLoop stz DevNum ; start looking starting at DevNum = 1 ; ; ----------- First make sure the popup is empty ------------------------- ; pha ; space for result pea 1 ; ID of menu we want _CountMItems pla sta Count beq @PopupEmpty pea 0 ; new value of popup selection jsr PushLongVolPopup ; this erases current result _SetCtlValue @DeleteAnother pea $FFFF ; to delete last item _DeleteMItem dec Count lda Count bne @DeleteAnother pea 0 ; width pea 0 ; height pea 1 ; ID of menu _CalcMenuSize lda >MyID ora #$0600 pha _DisposeAll ; get rid of all other handles allocated for volume names @PopupEmpty lda #0 sta >getVolNameFlag InsertNext jsr GetNextVolume ; returns with a & x set to ptr to the volume name bcs NoMoreVolumes jsr InsertTheItem bcc InsertNext NoMoreVolumes jsr SetPopup ; sets result of popup to first menu item stz DeviceSwitched rts ;================================================== ; ; GetNextVolume ; ; This routine returns the volume name of the next ; volume that is on-line. ; ; Each time into this routine we bump the device ; number to use as input to _DInfo so we always get ; the next device. _DInfo returns the device name ; which in turn is used as input to _Volume which ; returns the volume name. ; ; For each new device that we ecounter we get a new ; handle to store this name. ; ; When we finally get error $11(invalid device number) ; from _DInfo we know there are no more devices. ; We set the carry upon exit from this routine when ; we encounter this error. ; ; GetNextVolume always returns either a valid volume ; name or carry set which means no more volumes found. ; ; OUT: a = low word of handle to volume ; x = high word of handle to volume ; ;================================================== export GetNextVolume GetNextVolume with popUpGlobals import GSOStoPString NextDevice inc DevNum ; bump the device number to search _DInfoGS DInfoPBlock ; make GS/OS call bcc NoError cmp #$11 ; check for "invalid device number" error ; if we get this then we're done bne NoError brl NoMoreDevices NoError lda DeviceID bne MakeVolumeCall ; ; ----- We've got a 5.25 drive ----------------------------------------- ; lda DevNum sta DStatDevNum _DStatusGS DStatusPBlock lda StatusWord and #$0010 ; Is there a disk in the 5.25 drive beq NextDevice ; If OS says there is then the drive is on-line, else... jsr InsertIntoList lda #DevName sta theName lda #^DevName sta theName+2 bra doNewHandle MakeVolumeCall _VolumeGS VolumePBlock bcs NextDevice ; if we get an error then we need to go to next device lda #VolumeName sta theName lda #^VolumeName sta theName+2 lda Characteristics and #$0004 ; Check if this device contains removable media bne doNewHandle jsr InsertIntoList doNewHandle lda #33 ; size of memory block we want jsr GetHandle ; a = low word of handle, x = high word bcs NoMoreDevices ; get out if we couldn't get the memory to store the name phx pha phd ; save original direct page tsc tcd ; turn stack into direct page so we can deref handle origD equ 1 Handle equ origD+2 lda [MyID ora #$0600 ; set ID to $x1xx so we can get rid of this memory easily pha pea 0 ; no attributes pha pha _NewHandle tay pla ; a = low word plx ; x = high word rts EndP ;------------------------------------------------------------------ ; ; InsertIntoList ; ; Inserts device into list of non-removable media devices. This is ; the list that is used to determine whether a device should be ; polled for disk switch or not. (i.e. should we make the DStatus ; call on the device) Apple 5.25 drives are also included in this ; list. ; ;------------------------------------------------------------------ InsertIntoList PROC with PopUpGlobals lda DevNum ;use device number as index into this list cmp #65 ;beyond our 64-device limit? bcs @skip_it ;yes, just ignore it asl a tax lda #$8000 @StoreIt sta StaticDeviceTable-2,x @skip_it rts ENDP ;------------------------------------------------------------------ ; 22-May-91 MSD Now saves device number that we'll be searching ; in a separate variable so that we can use it ; later to display the correct volume icon in the ; path display for a file. ; ;------------------------------------------------------------------ MakeCurPath Proc Export with popUpGlobals import GetNextVolume ; OldDPage equ 1 OldDBank equ OldDPage+2 theRTL equ oldDBank+1 theResult equ theRTL+3 phb phk plb phd tsc tcd lda #$FFFF sta theResult pha jsr PushLongVolPopup _GetCtlValue pla sta SearchDevNum ; remember device number we're searching (22-May-91 MSD) sta DevNum _DInfoGS DInfoPBlock ; find out the device name bcs ErrorExit noError _VolumeGS VolumePBlock ; now get the volume name bcs ErrorExit PushLong #CurrentDirPath PushLong #VolumeName jsl GSOStoPString ; convert to pstring gotPath lda >CurrentDirPath inc a sta >CurrentDirPath and #$00FF tax lda #':' sta >CurrentDirPath,x exit pld plb rtl ErrorExit stz theResult PushLong #theMessage jsl SetMessage bra exit theMessage dc.B textEnd-textStart textStart dc.B $01,$4A,$00,$00 dc.B 'Problems reading the disk.' textEnd EndP ******************************************************************************* * * MakeSureExtraToolsAreHere -- load and start other tools as needed * ******************************************************************************* MakeSureExtraToolsAreHere proc export *** removed 26-Jan-93 SS -- not needed in 6.0 ; pea 0 ; _QDAuxStatus ; pla ; bne @ok ; ;@again pea $0012 ;tool number = QD Aux ; pea $0304 ;version 3.4 ; _LoadOneTool ; bcs @again ; ; _QDAuxStartUp ;@ok *** end 26-Jan-93 *** added 24-Sep-91 DAL -- make sure List Manager is here, too pea 0 _ListStatus pla bne @ListOK @listAgain pea $001C ;tool number = List Manager pea $0303 ;version 3.3 _LoadOneTool bcs @listAgain _ListStartUp @ListOK *** end 24-Sep-91 rtl EJECT ******************************************************************************* * GetUpTextFromLE PROC Export * * Description: This routine returns a Pascal string from a line edit item * that is all upper case. All you do is pass the LERechandle * and I do the rest! * * * Inputs: theLERecHandle:Handle * theStr:Str32; * * Outputs: none * * External Refs: none * * Entry Points: none * ******************************************************************************* ; ; Stack frame for this call... tempPtr equ 1 oldDPage equ tempPtr+4 theRTL equ oldDPage+2 theStr equ theRTL+3 theLERecHandle equ theStr+4 ; ; First link a stack frame... phd pha pha tsc tcd ; ; Now get the length of the text we are going to use... pha pei theLERecHandle+2 pei theLERecHandle _LEGetTextLen tax pla bcc @cont brl Anerror @Cont sta [theStr] ; save the length in the string... beq Done ; if its zero, then we are done! ; ; Now get the string handle from line edit... pha pha pei theLERecHandle+2 pei theLERecHandle _LEGetTextHand tax pla sta tempPtr pla sta tempPtr+2 bcc @Cont1 brl AnError ; ; Now that we have all the data move it into the string! @Cont1 ldy #2 ; deref the handle lda [tempPtr],y tax lda [tempPtr] bne @ItsOK dec a dex bra @cont3 @ItsOK dec a ; remember to remember the based data @Cont3 sta tempPtr stx tempPtr+2 ; we now have a pointer to that data! lda [theStr] tay ; init our counter... sep #$20 longa Off @Loop lda [tempPtr],y cmp #'A' blt @Loop10 cmp #'Z'+1 bge @Loop10 ora #$20 @Loop10 sta [theStr],y dey bne @Loop rep #$20 longA On Done pla ; unlink the stack pla pld sep #$20 longa Off pla ply plx plx plx plx phy pha rep #$20 longa On RTL AnError txa sta AsmToolErr bra Done EndP EJECT ******************************************************************************* * CreatePathList PROC Export with PopupGlobals * * Description: This routine will take a pointer to a string and turn it into * a list to be displayed by the list manager. * * * Inputs: theStr:str255 * * Outputs: None * * External Refs: * * Entry Points: * ******************************************************************************* ; My member record for use with the passed member record MemString equ 0 ; 4 MemFlag equ MemString+4 ; 6 MemFullName equ MemFlag+2 ; 10 MemType equ MemFullName+4 ; 12 MemAux equ MemType+2 ; 16 MemEOF equ MemAux+4 ; 20 member record is 20 bytes... MemRecSize equ MemEOF+4 ; ; tempPtr equ 1 tempInt equ tempPtr+4 OldDBank equ tempInt+2 OldDPage equ OldDBank+1 theRTL equ OldDPage+2 theInStr equ theRTL+3 ThisRtnAux equ $0300 ; subID for all memory used by this routine ; ; First thing, get rid of any old pathlist data... lda >MyID ora #ThisRtnAux pha _DisposeAll ; dump the old handles phd phb phk plb ; switch to this databank... pha pha pha tsc tcd ; set up our stack frame... ; ; Now clean out my pathname list list... ldx #SizeOfPathList-2 lda #0 @CleanLoop sta PathList,x dex dex bpl @CleanLoop ; ; Now that the path list is all cleaned out, let's create the list of names! ; lda [theInStr] ; set the current length and #$00FF sta PathLeft jsr StripFileName ; strip off the first file name throw it away stz has size of handle to get... lda >MyID ora #ThisRtnAux ; special stack memory pha pea $4000 ; fixed phx phx ; _NewHandle pla sta lda still points to our list entry lda #$0001 sta PathList+MemType,x @ListTooBig ; Now its time to do the new list2 call on this here list... ; PathList:=getCtlHandleFromID(IdleWind,1015 + screenMode); ; ShowControl(PathList); PushLong #MyMemberDraw pea 1 PushLong #PathList pea 0 lda IdleWind ldx #0 lda >screenMode clc adc #1015 bcc @1 inx @1 phx pha _GetCtlHandleFromID _NewList2 ; now the list is made and can be displayed at will! pla pla pla plb pld longa off sep #$20 pla ply plx plx phy pha longa On Rep #$20 rtl ; ; This next routine strips a file name down to the colon and stores it in ; the temp buffer... StripFileName longa off sep #$20 ldy PathLeft ; index into the string ldx #0 ; index into tempnamebuf @StripLoop1 lda [theInStr],y ; get the next value... dey ; lower our string counter.. inx cmp #':' ; if its a colon the pathname is over.. bne @StripLoop1 ; ok, we now know the length of the string to move and ; now copy the string... stx TempNameBuf ; save the string length first! cpx #0 beq @SL2Done ldy PathLeft @StripLoop2 lda [theInStr],y ;;; sta TempNameBuf,x *** 8-Dec-91 DAL cpx #1 beq @skipColon sta TempNameBuf-1,x @skipColon *** end 8-Dec-91 DAL dey dex bne @StripLoop2 @SL2Done ; the string is done, now update the PathLeft Value... sty PathLeft ; and save the value... *** 8-Dec-91 DAL dec TempNameBuf ;we skipped the leading colon *** end 8-Dec-91 lda TempNameBuf ; get the length in rep #$20 longa On and #$00FF inc a ; account for the length byte rts ; and return PathLeft ds.W 1 PathList ds.B MemRecSize*16 ; allow 16 levels of directories... SizeOfPathList equ *-PathList ; bytes in our local pathlist.. TempNameBuf ds.B 32 ; enough to hold a single pathname endp EJECT ******************************************************************************* * MyMemberDraw PROC Export with PopupGlobals * * Description: Procedure used to draw members in my list. This procedure will * take care of drawing each member in the list as well as drawing * the proper small icon to the left of it. * * * ; My member record for use with the passed member record MemString equ 0 MemFlag equ MemString+4 MemFullName equ MemFlag+2 MemType equ MemFullName+4 MemAux equ MemType+2 MemEOF equ MemAux+4 * Inputs: None * * Outputs: None * * External Refs: * * Entry Points: * ******************************************************************************* ; theStack thedPage equ 1 theRTL equ thedPage+2 ListHndl equ theRTL+3 memPtr equ ListHndl+4 rectPtr equ memPtr+4 phd ; save the old dpage tsc tcd pei screenMode ; 320 or 640 mode? cmp #640 beq @its_640 ; 640, position is correct txa ; get calculated position sec sbc #13 ; adjust for "narrower" icon in 320 mode tax @its_640 phx ; put horizontal position on stack iny iny lda [rectPtr],y dec a pha _MoveTo ; move to the proper spot ldy #2 lda [memPtr],y pha lda [memPtr] pha _Drawstring ; ; Now that the member string has been drawn its time to draw the ; proper icon for this item... ; *** 23-Apr-91 DAL -- use GetSysIcon instead of our local hard-coded icon tables *** 22-May-91 MSD -- Use SearchDevNum for device number instead of the volume *** selected in the volume pop-up. This fixes the bug where *** the user changes the volume pop-up and that icon gets used *** in the path display when you click on a found file. pha pha ;space for GetSysIcon result ldy #memFlag lda [memPtr],y bpl @notDevice ; high bit = the bottom list; everything is device/folder ldy #memType lda [SearchDevNum ; get volume actually searched (22-May-91 MSD) sta >DevNum _DInfoGS DInfoPBlock lda >DeviceID pea 1 ;flag for device icon pha ;device ID pea 0 ;moved here 5-Oct-92 DAL pea 0 ;moved here from below (auxtype value) bra @common @notDevice ldy #memFlag ;use open folders for bottom list lda [AsmToolErr ; Now, before we start this function let's look at the spudflag and determine if we need to ; swap in our alternate stack... lda spudFlag,s ; zero means called from pascal set up the stack stuff bpl @notReentry brl @ReEntry ; if negative means this is a reentry @notReentry bne @Running ; if non-zero positive then we are currently running lda >StackHandle+1 ; see if we are still running bne @Running ; if this is non-zero then nope... ; ; If we are here then the DA is not yet started to search. This will now allocate a new ; stack for us to use... ldx #0 pha ; room for result pha phx ; size of handle pea $0800 ; in this case a 2k stack... lda >MyID ora #$0900 ; special stack memory pha pea $4005 ; fixed page align in abs bank phx phx ; X MUST BE ZERO!!!! _NewHandle tax ; save the error code for now! pla sta >StackHandle pla sta >StackHandle+2 bcc @gotStack txa sta >AsmToolErr ; save the tool error! brl ProcessError1 @GotStack ; now deref the stack handle... ; get the pascal stack value tsc ; get the current stack pointer sta >PascalStack ; save the current stack level tdc ;GACK! This was a TCD. 24-Sep-91 DAL sta >PascalDPage ; also save the pascal dpage phd lda >StackHandle+2 ; we wanna deref this in fact... pha ; we need to deref something... lda >StackHandle pha ; so give me some stack for a second... tsc tcd lda [1] ; get our stack pointer plx ; undo the temp direct page plx pld clc adc #$07F0 ; put us at the end! sta >StackLevel ; save the new stack pointer into ; we come here when we know that we already have a stack allocated ; this code will swap out the old stack and swap in the new stack if needed tcs ; make it the new stack lda #0 ; shortcut the next 2 lines pha ; pea 0 ; and zero recursion stack its the end.. ; lda #0 ; zero out the entry count sta >EntryCount ; so we know when to exit properly bra @EntryCont ; fininish the entry brl Repeat ; now the proper stack is in place so continue @running ; we come here when we know that we already have a stack allocated ; this code will swap out the old stack and swap in the new stack if needed tsc ; get the current stack pointer sta >PascalStack ; save the current stack level tdc ;GACK! This was a TCD too! 24-Sep-91 DAL sta >PascalDPage ; also save the pascal dpage lda >StackLevel ; get the asynch stack pointer tcs ; make it the new stack pld ; get the proper direct page pea 0 ; and zero recursion stack its the end.. lda #0 ; zero out the entry count sta >EntryCount ; so we know when to exit properly brl Repeat ; now the proper stack is in place so continue @ReEntry tsc ; get the current stack pointer pha ; save it on the stack... @EntryCont ; now enter the function proper ; ; Begin by setting up our stack frame...... phd tsc sec sbc #FrameSize tcd tcs ; ; Now that our frame is set up, let's get to work... ; MyOpenRec.openPathname:=@currentDirPath; lda #CurrentDirPath>>16 sta >MyOpenRec+4 lda #CurrentDirPath sta >MyOpenRec+2 lda #0 sta >MyOpenRec ; OpenPD(MyOpenRec); _OpenPD MyOpenRec bcc @1 cmp #$45 ;VolNotFound? bne @otherError sta >Stopping @otherError sta >AsmToolErr brl EndProcLevel @1 ; MyRefNum:=MyOpenRec.Openrefnum; lda >MyOpenRec sta MyDirEntry+4 sta >MyDirEntry+6 ; MyDirEntry.NameBuffer:=@tempNamePtr; lda #TempNamePtr>>16 sta >MyDirEntry+$000A lda #TempNamePtr sta >MyDirEntry+$0008 ; tempNamePtr.stat:=16; lda #40 sta >TempNamePtr Repeat ; For proper asynch operation, we must now test the entrycount first, if we ; have passed our threshold of entries then we need to back out for now... lda >EntryCount ; get the current entry count cmp #MaxPerLevel ; have we done the proper number yet? blt @Repeatcont brl AsynchExit ; else exit asynch level @RepeatCont ; MyDirEntry.refnum:=MyRefNum; lda MyDirEntry ; ; Now we determine if we should stop now. lda >Stopping bne @BetterStop ; if the flag is non-zero then we must stop ; Get_Dir_Entry(MyDirEntry); _Get_Dir_Entry MyDirEntry bcc @2 cmp #$45 ; Volume Not Found? bne @BetterStop ; no, exit normally sta >Stopping ; else make sure we stop completely @BetterSTop brl GDEError ; if AsmToolErr=0 then ; begin ; tempString[0]:=char(tempNamePtr.length); {Set the length of the string} @2 ; ; First bump the entry count to indicate we got a good one lda >EntryCount inc a sta >EntryCount lda >TempNamePtr+2 sep #$20 Longa Off sta >tempString rep #$20 Longa On ; for i:=1 to 32 do ; tempString[i]:=tempNamePtr.theName[i]; ldx #0 @CopyLoop1 lda >tempNamePtr+4,x sta >tempString+1,x inx inx cpx #32 ; see if we are finished... blt @CopyLoop1 ; AddFile(tempString); {Add the filename to the list...} PushLong #tempString jsl AsmAddFile pla pla ; if MyDirEntry.fileType = $000F then {Check for recursion...} ; begin lda >MyDirEntry+$000E cmp #$000F beq @3 brl NotADirectory ; MyPathLevel:=ord(CurrentDirPath[0]); {Save the old pathname} @3 lda >CurrentDirPath and #$00FF sta tempNamePtr+2 cmp #$0100 blt @4 brl fNameTooLong ; ; begin ; currentDirPath:=Concat(currentDirPath,tempString,':'); @4 lda #currentDirPath>>16 ; create a pointer to our dest string sta currentDirPath ; add its current length... and #$00FF sec ;always add 1 extra adc tempNamePtr+2 ; get the length to copy sta tempNamePtr+4,x ; source word txy sta [currentDirPath clc adc currentDirPath and #$00FF ; just get the length tax ; use as an index lda #':' ; load the terminator char sta >currentDirPath,x ; and finish the name ; ProcessLevel; pha ; room for result pea $FFFF ; flag says we are reentering jsl ProcessLevel ; do the next level... pla ; AsmToolErr:=0; ; CurrentDirPath[0]:=chr(MyPathLevel); {Back the sucker off now...} lda CurrentDirPath rep #$20 LongA On ; end; ; end; ; end; fNameTooLong NotADirectory brl Repeat ; ; Interupt ready... AsynchExit phd ; save the current direct page also! tsc ; get the current stack level sta >StackLevel ; and save it in our global lda >PascalStack ; get the DA stack level back tcs ; and make it the current stack lda >PascalDPage tcd lda #1 ; get the proper level flag sta spudResult,s ; and make it the result for now... lda spudRTL+1,s ; move the RTL down sta spudRTL+3,s ; down 2 bytes lda spudRTL,s sta spudRTL+2,s pla ; recover the crap RTL ; and finally return GDEError ; until AsmToolErr<>0; ; debug; ; MyClose.fileRefNum:=MyRefNum; ; ClosePD(MyClose); lda MyClose _ClosePD MyClose ; end; {procedure} EndProcLevel ProcessError1 tdc ; unlink our local frame clc adc #FrameSize tcs ; make it our current stack pld ; recover the orihginal dpage ; ; Now we need to unlink the rest of the alternate stack crap ; and also see where we were called from... pla ; recover the old stack level bne @proce1 ; if this is non-zero then we are recursed lda >PascalDPage ; recover the direct page tcd lda >PascalStack ; if zero, get the pascal stack level @ProcE1 tcs ; make it the current stack pointer lda spudFlag,s ; get the spudflag sta spudResult,s ; and make it the result for now... lda spudRTL+1,s ; move the RTL down sta spudRTL+3,s ; down 2 bytes lda spudRTL,s sta spudRTL+2,s pla ; recover the crap RTL ; and finally return PascalDPage ds.W 1 ; place to save the pascal direct page EndP ; ; The following will do the proper comparison and then add the item to the list if ; it matches the proper criterion ; AsmAddFile Proc Export with PopupGlobals import InvisibleFlag ; Stack for this call... tempDeref equ 1 tempHandle equ tempDeref+4 InputString equ tempHandle+4 i equ InputString+4 OldDPage equ i+2 theRTL equ OldDPage+2 theName equ theRTL+3 FrameSize equ theRTL ; ;DirEntryRec = RECORD ; DERrefNum equ 0 ; integer DERreserved equ DERRefNum+2 ; integer DERbase equ DERreserved+2 ; Integer; DERdisplacement equ DERbase+2 ; Integer; DERnameBuffer equ DERdisplacement+2 ; Ptr; DERentryNum equ DERnameBuffer+4 ; Integer; DERfileType equ DERentryNum+2 ; Integer; DERendOfFile equ DERfileType+2 ; Longint; DERblockCount equ DERendOfFile+4 ; Longint; DERcreateTime equ DERblockCount+4 ; TimeRec; DERmodTime equ DERcreateTime+8 ; TimeRec; DERaccess equ DERmodTime+8 ; Integer; DERauxType equ DERaccess+2 ; Longint; DERfileSysID equ DERauxType+4 ; Integer; ; ; Begin by setting up our stack frame...... ; lda 4,s tax lda 6,s tay ; recover our parameter phd tsc sec sbc #FrameSize tcd tcs stx MyDirEntry+DERaccess and #$0004 ;invisible bit beq @notInvisible lda >InvisibleFlag and #$00ff bne @findItAnyway brl EndProcLevel @findItAnyway @notInvisible *** end 1-Oct-91 ; Now do the proper match jsr MatchIt bcc @addIt brl EndProcLevel @addit lda >MyListCnt ; see if we have too many items cmp #MaxEntries ; see if we are beyond the threshold blt @Addit010 ; if not, then continue lda #$FFFF ; flag list overrun sta >Stopping ; and save it in our flag to say stop brl EndProcLevel @Addit010 ; tempHandle:=Str255Hndl(NewHandle(16,MyID+$0700,attrFixed,NIL)); pha ; room for result pha pea 0 ; size pea 40 ; 32 bytes lda >MyID ora #$0700 pha pea $4000 pha pha _NewHandle pla plx sta MyList ; deref MyList sta MyList+2 sta MyListCnt ; create MyListCnt*10 asl a pha asl a asl a clc adc 1,s plx asl a ; multiply by 2 to get *20 clc adc MyDirEntry+DERAuxType ldy #memAuxType sta [tempDeref],y lda >MyDirEntry+DERAuxType+2 ldy #memAuxType+2 sta [tempDeref],y lda >MyDirEntry+DERfileType ldy #memfileType sta [tempDeref],y lda >MyDirEntry+DERendOfFile ldy #memEOF sta [tempDeref],y lda >MyDirEntry+DERendOfFile+2 ldy #memEOF+2 sta [tempDeref],y ; ; Now that the record is updated, update the list ; tempHandle:=Str255Hndl(NewHandle(ord(theFile[0])+ord(CurrentDirPath[0])+3,MyID+$0700,0,NIL)); lda [CurrentDirPath and #$00FF adc #3 pha pha pea 0 pha lda >MyID ora #$0700 pha pea 0 pha pha _NewHandle ; MyList^^[myListCnt].MemFullName:=newHandle; ldy #6 pla sta [currentDirPath and #$00FF sta currentDirPath,x sta [currentDirPath and #$00FF clc adc MyListCnt inc a sta >MyListCnt ; NewList2(MyMemberDraw,-1,ref(MyList),1,myListCnt,listCtrl); PushLong #MyMemberDraw pea $FFFF PushLong MyList pea 1 lda >MyListCnt pha PushLong ListCtrl _NewList2 EndProcLevel tdc ; unlink our local frame clc adc #FrameSize tcs ; make it our current stack pld ; recover the orihginal dpage RTL MatchIt ; Routine to compare and match the file names ; This routine requires that the MatchStr be lower cased. ; it trashed the contents of tempHandle and i ; matchTemp equ tempHandle stz MatchType dec a asl a tax jsr (matchTbl,x) rts matchTbl dc.W Exact dc.W StartsWith dc.W EndsWith dc.W Contains dc.W WildCard ; finds with certain wild card characters ; Exact ; Test to see if the filename is an exact match of the matchstr sep #$20 Longa Off lda >MatchStr ; get the length of the match string sta MatchStr,x ; get the char to match ora #$20 ; make sure its lower case cmp MatchStr,x beq @NextChar brl MatchFail @NextChar iny cpy MatchStr ; get the length of the match string sta MatchStr,x ; get the char to match ora #$20 ; make sure its lower case cmp MatchStr,x beq @NextChar brl MatchFail @NextChar iny cpy MatchStr ; get the length of the match string sta lda MatchStr,x ; get the last char of match string cmp #'A' ; first see if its upper case blt @NonAlpha ; if less than its a non-alpha compare ora #$20 ; make it lower case always... sta 0 then keep going REP #$20 Longa On clc ; else we are done and we found a match rts ; Contains ; Now see if input contains matchString ; First be sure that the Matchstr can be contained by testing the length ; NOTE: This routine requires that the matchstr be lowercased first. ; ; This routine trashes i and matchtemp ; stz i stz MatchTemp stz MatchTemp+2 sep #$20 Longa Off lda >MatchStr ; get the length of the match string sta MatchStr+1 and #$00FF cmp = than i then it cound be here! @NotHere ; otherwise, it can't be in this string... better button up and leave rep #$20 longa on sec ; signal failure rts ; and go back... @MaybeHere ; This routine will determine if the string is actually inside of the input ; string... ldy MatchStr,x and #$00FF cmp MatchStr ; get the length of the match string sta MatchTemp+2 ; save it in our special place lda [MatchStr,x ; get the next char to match cmp #'£' ; is it match number? beq @CompNum cmp #'§' ; is it match Letter? beq @CompAlpha cmp #'Å' ; is it stream of data? beq @CompHole ; Else just a normal compare will do... lda [MatchStr,x ; get the char to match beq @NextChar brl @MatchFail ; ; Only test its numericness.... @CompNum lda [ contains the offset into the matchstr ; comtains the offset into the inputstring ; @CompHole ; First see if wild card is at the end of the match string. If so then ; we have found a match! ; cpy is less than then not enough chars ldy