home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-01-08 | 3.4 KB | 113 lines |
- Screen Open 0,640,200,2,Hires : Colour 1,$FFF : Flash Off
- MSGBANK=7 : IOBANK=8 : BUFBANK=9 : BUFLEN=512
- Reserve As Chip Work BUFBANK,BUFLEN
- ' change params if you want to access hard drive
- UNIT=0 : DEVICE$="trackdisk.device"
- CREATEPORT[MSGBANK]
- CREATEIO[IOBANK,MSGBANK]
- OPENDEVICE[DEVICE$,UNIT,IOBANK,0]
- If Param<>0
- Print "opendevice failed"
- DELETEIO[IOBANK]
- DELETEPORT[MSGBANK]
- End
- End If
- ' turn motor on, read sector then turn motor off
- TD_MOTOR[IOBANK,1]
- If Param<>0 Then Print "warning doio returned an error ";Param
- CMD_READ[IOBANK,0,BUFBANK]
- If Param<>0 Then Print "warning doio returned an error ";Param
- TD_MOTOR[IOBANK,0]
- If Param<>0 Then Print "warning doio returned an 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 necessary 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
- Loke MSGPORT+16,MY_TASK : Rem address of our task structure
- End Proc
- Procedure DELETEPORT[BANK]
- ' routine to free an alocated port
- MSGPORT=Start(BANK)
- Dreg(0)=Peek(MSGPORT+15)
- X=Execall(-336) : Rem free the signal
- Erase BANK : Rem free 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 structure
- 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/off
- Areg(1)=IOSTDREQ
- X=Execall(-456) : Rem dolo
- End Proc[X]
- Procedure CMD_READ[IOBANK,BLOCK,BUFBANK]
- 'routine to get a block
- IOSTDREQ=Start(IOBANK)
- Doke IOSTDREQ+28,2 : Rem io command to read
- Loke IOSTDREQ+36,Length(BUFBANK) : Rem amount of data is given by length of this buffer
- Loke IOSTDREQ+40,Start(BUFBANK) : Rem address of data buffer
- Loke IOSTDREQ+44,BLOCK*512 : Rem offset at which to start reading
- Areg(1)=IOSTDREQ
- X=Execall(-456) : Rem dolo
- End Proc[X]
- Procedure OPENDEVICE[DEVNAME$,UNIT,IOBANK,FLAGS]
- 'routine to open a device prior to doing io to it
- DEVNAME$=DEVNAME$+Chr$(0)
- 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 device
- Areg(1)=Start(IOBANK)
- X=Execall(-450)
- End Proc