home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1992-05-23 | 5.2 KB | 177 lines |
- Screen Open 0,640,256,2,Hires : Colour 1,$FFF : Curs Off
- '---------------------------------------------------------
- ' The various structures are placed in AMOS banks.
- ' They could just as easily be placed in memory allocated
- ' (and then freed) using the AllocMem() Execall.
- ' The IO buffer must be in chip under version 1.3 of the
- ' operating system
- '---------------------------------------------------------
- MSGBANK=7 : IOBANK=8 : BUFBANK=9 : BUFLEN=512*11
- Reserve As Chip Work BUFBANK,BUFLEN
- '---------------------------------------------------------------
- ' Change these parameters if you want to access your hard drive
- '---------------------------------------------------------------
- UNIT=0 : DEVICE$="trackdisk.device"
- '
- '--------------------------------------------------------------
- ' Allocate the port then initialise the IO request structure.
- ' When this is done open the device for IO.
- '--------------------------------------------------------------
- CREATEPORT[MSGBANK]
- CREATEIO[IOBANK,MSGBANK]
- OPENDEVICE[DEVICE$,UNIT,IOBANK,0]
- '
- If Param<>0
- Print "OpenDevice() failed"
- DELETEIO[IOBANK]
- DELETEPORT[MSGBANK]
- End
- End If
- '
- '-------------------------------------------------------
- ' Turn the motor on, read the sector then turn it off.
- '-------------------------------------------------------
- TD_MOTOR[IOBANK,1]
- If Param<>0 Then Print "Warning - DoIO returned error";Param
- For X=0 To 159
- CMD_READ[IOBANK,X,BUFBANK]
- Locate 0,10 : Cline : Locate 0,10 : Print X
- If Param<>0 Then Print "Warning - DoIO returned error";Param
- Next X
- '
- TD_MOTOR[IOBANK,0]
- If Param<>0 Then Print "Warning - DoIO returned error";Param
- '
- '------------------------------------------------------
- ' Close the device, free the port and free the banks.
- '------------------------------------------------------
- KLOSEDEVICE[IOBANK]
- DELETEIO[IOBANK]
- DELETEPORT[MSGBANK]
- '
- '---------------------------------
- ' Format and print the bootblock
- '---------------------------------
- For AD=Start(BUFBANK) To Start(BUFBANK)+492 Step 20
- For AD2=AD To AD+16 Step 4
- Print Right$(Hex$(Leek(AD2),8),8);" ";
- Next
- Print " ";
- For AD2=AD To AD+19
- If Peek(AD2)>32
- Print Chr$(Peek(AD2));
- Else
- Print ".";
- End If
- Next
- Print
- Next
- '
- Procedure CREATEPORT[BANK]
- '
- '-------- Routine to allocate & initialise a message port
- '-------- Note: This port is not placed on the system port list
- '
- Dreg(0)=-1 : Rem This means use any of the available signal bits
- SIGNAL_NUMBER=Execall(-330)
- If SIGNAL_NUMBER=-1
- Print "Signal allocation failed in CREATEPORT"
- Direct
- End If
- '
- Reserve As Work BANK,34
- MSGPORT=Start(BANK)
- '
- '---------------------------------------------------
- ' At offset 276 of ExecBase is the address of the
- ' currently executing task. That must be us if we
- ' are looking at it!
- '---------------------------------------------------
- EXECBASE=Leek(4)
- MY_TASK=Leek(EXECBASE+276)
- '
- '--------------------------------------------
- ' Fill in the nessacary information for the
- ' MsgPort structure.
- '--------------------------------------------
- Poke MSGPORT+9,0 : Rem port priority
- Poke MSGPORT+8,16 : Rem node type is message port
- Poke MSGPORT+14,0 : Rem flags
- Poke MSGPORT+15,SIGNAL_NUMBER : Rem signal number acquired earlier
- Loke MSGPORT+16,MY_TASK : Rem address of our task structure
- '
- End Proc
- '
- Procedure DELETEPORT[BANK]
- '
- '---------Routine to free an allocated port
- '
- MSGPORT=Start(BANK)
- '
- Dreg(0)=Peek(MSGPORT+15)
- X=Execall(-336) : Rem free the signal
- '
- Erase BANK : Rem free the memory
- End Proc
- '
- Procedure CREATEIO[IOBANK,MSGBANK]
- '
- '---------Routine to initialise the IO request structure
- '
- Reserve As Work IOBANK,48
- IOSTDREQ=Start(IOBANK)
- Poke IOSTDREQ+8,32 : Rem insert message type
- Doke IOSTDREQ+18,48 : Rem length of strucure
- Loke IOSTDREQ+14,Start(MSGBANK) : Rem address of message port structure
- End Proc
- '
- Procedure DELETEIO[IOBANK]
- '
- '--------This routine frees an IO request structure
- '
- Erase IOBANK
- End Proc
- '
- Procedure TD_MOTOR[IOBANK,FLAG]
- '
- '--------Switch motor on or off
- '
- IOSTDREQ=Start(IOBANK)
- Doke IOSTDREQ+28,9 : Rem IO command switch motor
- Loke IOSTDREQ+36,FLAG : Rem Switch motor on or off
- Areg(1)=IOSTDREQ
- X=Execall(-456) : Rem DoIo
- End Proc[X]
- '
- Procedure CMD_READ[IOBANK,BLOCK,BUFBANK]
- '
- '----------Routine to get a block
- '
- IOSTDREQ=Start(IOBANK)
- Doke IOSTDREQ+28,11 : Rem IO command to read
- Loke IOSTDREQ+36,Length(BUFBANK) : Rem amount of data is given by length of the buffer
- Loke IOSTDREQ+40,Start(BUFBANK) : Rem address of data buffer
- Loke IOSTDREQ+44,BLOCK*(512*11) : Rem offset at which to start reading
- Areg(1)=IOSTDREQ
- X=Execall(-456) : Rem DoIo
- End Proc[X]
- '
- Procedure OPENDEVICE[DEVNAME$,UNIT,IOBANK,FLAGS]
- '
- '---------Routine to open device prior to doing IO to it
- '
- DEVNAME$=DEVNAME$+Chr$(0) : Rem string must be null terminated
- Areg(0)=Varptr(DEVNAME$)
- Dreg(0)=UNIT
- Areg(1)=Start(IOBANK)
- Dreg(1)=FLAGS
- X=Execall(-444)
- End Proc[X]
- '
- Procedure KLOSEDEVICE[IOBANK]
- '
- '-------- Routine to close a device
- '
- Areg(1)=Start(IOBANK)
- X=Execall(-450)
- End Proc