English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 08 July 2019, 17:49   #1
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,247
Returning the current working floppy drive device

Hi all,

Does anyone know of any quick ways to get he current working floppy device.

The example I have is that my start-up sequence loads my game executable from the current device, but then the executable has a custom loader hard coded to use DF0... it'd like it so that if the game has booted from DF1 then I can pass DF1 to the custom loader.

I've looked at a few things already but this problem seems pretty tedious to solve - any help is appreciated.

Geezer
mcgeezer is offline  
Old 08 July 2019, 18:08   #2
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 1,823
Quote:
Originally Posted by mcgeezer View Post
Hi all,

Does anyone know of any quick ways to get he current working floppy device.

The example I have is that my start-up sequence loads my game executable from the current device, but then the executable has a custom loader hard coded to use DF0... it'd like it so that if the game has booted from DF1 then I can pass DF1 to the custom loader.

I've looked at a few things already but this problem seems pretty tedious to solve - any help is appreciated.

Geezer
I can pass to you a message from the bootblock (a system message port containing a string like Rygar n) [n=0/3].
Or you can use Info() from dos.library and check the struct InfoData for the unit from where the exe are started.

Ask and you will get the code
ross is offline  
Old 08 July 2019, 18:34   #3
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,247
Quote:
Originally Posted by ross View Post
I can pass to you a message from the bootblock (a system message port containing a string like Rygar n) [n=0/3].
Or you can use Info() from dos.library and check the struct InfoData for the unit from where the exe are started.

Ask and you will get the code
Thanks Ross, i’ll go for the dos.lib option. If u have the code around then great but otherwise i can code it, i just needed some pointers is all which u have already given!

Top man!
Graeme
mcgeezer is offline  
Old 08 July 2019, 18:56   #4
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 1,823
Yep, I can extract it from my startup code.
I look at it later in the evening, then I'll public here, probably it can also be useful to others.

See you soon
ross is offline  
Old 08 July 2019, 20:45   #5
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 49
Posts: 1,823
And the code!

Works in every possible situation:
- boot from floppy (df0 to df3)
- start from shell (from the same boot device or from a remote CLI)
- start from WB (as a tools or project icon)

Enjoy


Code:
_LVOOldOpenLibrary  equ -408
_LVOCloseLibrary    equ -$19E
_LVOWaitPort        equ -$180
_LVOGetMsg          equ -$174
_LVOReplyMsg        equ -$17A
_LVOForbid          equ -132
_LVOLock            equ -$54
_LVOUnLock          equ -$5a
_LVOParentDir       equ -$d2
_LVOCurrentDir      equ -$7e
_LVOInfo            equ -114

ThisTask            equ $114
pr_CLI              equ $ac
pr_MsgPort          equ $5c
sm_ArgList          equ $24
cli_CommandName     equ $10
SHARED_LOCK         equ -2
id_UnitNumber       equ 4

****************************************************************************

ProgStart
    movea.l $4.w,a6
    lea doslibrary(pc),a1
    jsr _LVOOldOpenLibrary(a6)
    movea.l d0,a5           ; dosbase

    movea.l ThisTask(a6),a3
    move.l  pr_CLI(a3),d3   ; d3 = CLI or WB (NULL)
    bne.s   _from_cli

_from_wb:
    ; Get startup message if we started from Workbench

    lea pr_MsgPort(a3),a0
    jsr _LVOWaitPort(a6)    ; wait for a message
    lea pr_MsgPort(a3),a0
    jsr _LVOGetMsg(a6)      ; then get it
    movea.l d0,a3           ; a3 = WBStartup message
    movea.l sm_ArgList(a3),a0
    move.l  (a0),d5         ; (wa_Lock) FileLock on program dir
    exg a5,a6               ; _dos
    bsr.s   _common

    ; Reply to the startup message

    jsr _LVOForbid(a6)      ; it prohibits WB to unloadseg me
    lea (a3),a1
    jmp _LVOReplyMsg(a6)    ; reply to WB message and exit


_from_cli:
    ; Get FileLock via command name if we started from CLI

    link    a3,#-256

    ; Copy BCPL string to C-style string

    lea (sp),a1
    lsl.l   #2,d3
    movea.l d3,a0
    move.l  cli_CommandName(a0),a0
    adda.l  a0,a0
    adda.l  a0,a0
    move.b  (a0)+,d0

.c  move.b  (a0)+,(a1)+
    subq.b  #1,d0
    bne.b   .c
    clr.b   (a1)

    ; Get a lock on the program and its parent

    exg a5,a6               ; _dos
    move.l  sp,d1           ; d1 = STRPTR name (command string)
    moveq   #SHARED_LOCK,d2 ; d2 = accessMode
    jsr _LVOLock(a6)
    move.l  d0,d7
    move.l  d0,d1
    jsr _LVOParentDir(a6)
    move.l  d7,d1
    move.l  d0,d3           ; d3 = Lock on CLI program dir
    move.l  d0,d5           ; d5 = common Lock
    jsr _LVOUnLock(a6)

    unlk    a3

_common:

    move.l  d5,d1
    jsr _LVOCurrentDir(a6)  ; CD to the program dir
    move.l  d0,d4           ; d4 = initial launch directory

    lea infodata(pc),a0
    lea id_UnitNumber(a0),a2
    move.l  d5,d1
    move.l  a0,d2
    jsr _LVOInfo(a6)
    tst.l   d0
    beq.b   _rts

    move.l  (a2),d0         ; d0 = current floppy device for the main exe

    movem.l d3/d4/a3/a5/a6,-(sp)
    bsr.b   _main
    movem.l (sp)+,d3/d4/a3/a5/a6

    move.l  d3,d1           ; UnLock program dir or zero (from WB)
    jsr _LVOUnLock(a6)

    move.l  d4,d1           ; CD to the initial directory
    jsr _LVOCurrentDir(a6)

    lea (a6),a1
    lea (a5),a6
    jsr _LVOCloseLibrary(a6)
    moveq   #0,d0
_rts
    rts

doslibrary  dc.b    'dos.library',0
            cnop    0,4
infodata    ds.l    9


_main
    rts

    end
ross is offline  
Old 08 July 2019, 21:38   #6
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,247
You're a legend Ross - no other word for it.
mcgeezer is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
External Roctec RF382C-A floppy drive - not working solarmon support.Hardware 25 03 August 2019 01:09
Fs: External amiga floppy drive, fully working NanoBabe MarketPlace 4 12 October 2018 23:10
Slim CD drive with idefix97.....atapi device appears not to be working Smiley support.Hardware 9 28 April 2007 19:03
New floppy drive not working :( Highwayman support.Hardware 0 18 November 2006 13:04
MFM.DEVICE problem with escom floppy drive??? CFOU! support.Hardware 7 22 May 2006 00:22

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:44.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.06478 seconds with 15 queries