home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Xplorer 1
/
Scene_Xplorer_1.iso
/
Tools
/
ProNet
/
source
/
dospackets.s
< prev
next >
Wrap
Text File
|
1978-01-11
|
2KB
|
104 lines
* Routines for handling DosPackets
; -- Create a StandardPacket
CreateStdPacket ; RETURNS d0 *StandardPacket or NULL
movem.l a2-a6,-(sp)
move.l 4.w,a6
move.l #sp_SIZEOF,d0
move.l #MEMF_PUBLIC,d1
LIBCALL AllocMem
tst.l d0
beq.s csp_nomem
move.l d0,a2
bsr CreatePort
move.l d0,sp_Msg+MN_REPLYPORT(a2)
beq.s csp_noport
lea sp_Pkt(a2),a3
move.l a3,sp_Msg+LN_NAME(a2)
move.l a2,sp_Pkt+dp_Link(a2)
move.l a2,d0
movem.l (sp)+,a2-a6
rts
; -- Deallocate a StandardPacket got by CreateStdPacket
DeleteStdPacket ; a0 *StandardPacket
movem.l a2-a6,-(sp)
move.l 4.w,a6
move.l a0,a2
move.l sp_Msg+MN_REPLYPORT(a2),a0
bsr DeletePort
csp_noport move.l a2,a1
move.l #sp_SIZEOF,d0
LIBCALL FreeMem
csp_nomem movem.l (sp)+,a2-a6
moveq #0,d0
rts
; -- Send a StandardPacket to a MsgPort
SendStdPkt ; a0 *MsgPort
; a1 *StandardPacket
move.l a6,-(sp)
move.l 4.w,a6
move.l sp_Msg+MN_REPLYPORT(a1),sp_Pkt+dp_Port(a1)
LIBCALL PutMsg
move.l (sp)+,a6
rts
; -- Send a StandardPacket to a MsgPort, wait for return and get results
SyncStdPkt ; a0 *MsgPort
; a1 *StandardPacket
; RETURNS d0 dp_Res1
; d1 dp_Res2
move.l a1,-(sp)
bsr SendStdPkt
move.l (sp)+,a0
bra WaitStdPkt
; -- Wait for return of the packet and get results
WaitStdPkt ; a0 *StandardPacket
; RETURNS d0 dp_Res1
; d1 dp_Res2
movem.l a2/a6,-(sp)
move.l 4.w,a6
move.l a0,a2
move.l sp_Msg+MN_REPLYPORT(a2),a0
LIBCALL WaitPort
move.l sp_Msg+MN_REPLYPORT(a2),a0
LIBCALL GetMsg
move.l sp_Pkt+dp_Res1(a2),d0
move.l sp_Pkt+dp_Res2(a2),d1
movem.l (sp)+,a2/a6
rts
; Get a packet from the process' messageport
GetPacket ; RETURNS d0 *DosPacket or NULL
movem.l a2/a6,-(sp)
move.l 4.w,a6
move.l ThisTask(a6),a0
lea pr_MsgPort(a0),a0
LIBCALL GetMsg
tst.l d0
beq.s .0
move.l d0,a0
move.l LN_NAME(a0),d0
.0 movem.l (sp)+,a2/a6
rts
; Return packet got by GetPacket
ReturnPacket ; a0: *DosPacket
; d0: long result1
; d1: long result2
movem.l a3/a6,-(sp)
move.l 4.w,a6
move.l ThisTask(a6),a1
move.l d0,dp_Res1(a0)
move.l d1,dp_Res2(a0)
move.l dp_Port(a0),d0
lea pr_MsgPort(a1),a1
move.l a1,dp_Port(a0)
move.l dp_Link(a0),a1
move.l d0,a0
LIBCALL PutMsg
movem.l (sp)+,a3/a6
rts