Macros defined and used by networking routines.
INT5C MACRO buffer ; Call NetBIOS Interrupt
push es ; save registers
push bx
push ax
mov ax, seg buffer
mov es, ax
mov bx, offset buffer
int 05Ch ; NetBIOS interrupt
pop ax
pop bx ; restore registers
pop es
ENDM
|
HELLOSEND MACRO
; Input: None
; Output: None
; Calls: SendPacket - This sends out the HelloMsg that has been set up
; MOVMW - Macro to move word from memory to memory.
; MOVMB - Macro to move byte from memory to memory.
; Purpose: This macro sends sets up the HelloMsg with the appropriate values
; and then calls SendPacket to transmit the packet to everyone else.
; A HelloMsg tells what playernumber the message is from, their team
; number, their direction, and their position.
push ax
push bx
mov (HelloMsg PTR TXBuffer).MsgType , HELLO
MOVMB (HelloMsg PTR TXBuffer).PlayerNum , MyNum
MOVMB (HelloMsg PTR TXBuffer).TeamNum, (PlayerType PTR players[bx]).Team
mov bx, MyOffset
MOVMW (PointType PTR (HelloMsg PTR TXBuffer).StartPos).x, (PointType PTR (PlayerType PTR players[bx]).GamePos).x
MOVMW (PointType PTR (HelloMsg PTR TXBuffer).StartPos).y, (PointType PTR (PlayerType PTR players[bx]).GamePos).y
MOVMB (UpdatePos PTR TXBuffer).Direction, players[bx].Dir
mov ax, Sizeof HelloMsg
call SendPacket
pop bx
pop ax
ENDM
|
UPDATEPOSEND MACRO
; Input: None
; Output: None
; Calls: SendPacket - This sends out the HelloMsg that has been set up
; MOVMW - Macro to move word from memory to memory.
; MOVMB - Macro to move byte from memory to memory.
; Purpose: This macro sends sets up the UpdatePos message struct with the
; appropriate values and then calls SendPacket to transmit the packet
; everyone else. An UpdatePos message tells what playernumber the
; message is from, their direction, and their position.
push ax
push bx
mov (UpdatePos PTR TXBuffer).MsgType, UPDATEP
MOVMB (UpdatePos PTR TXBuffer).PlayerNum, MyNum
mov bx, MyOffset
MOVMW (PointType PTR (UpdatePos PTR TXBuffer).UPosition).x, (PointType PTR (PlayerType PTR players[bx]).GamePos).x
MOVMW (PointType PTR (UpdatePos PTR TXBuffer).UPosition).y, (PointType PTR (PlayerType PTR players[bx]).GamePos).y
MOVMB (UpdatePos PTR TXBuffer).Direction, players[bx].Dir
mov ax, Sizeof UpdatePos
call SendPacket
pop bx
pop ax
ENDM
|
UPDATESHOTSEND MACRO BulDir, BulPosX, BulPosY
; Input: BulDir - The direction of the bullet
; BulPosX - The X position the bullet is being fired from
; BulPosY - The Y position the bullet is being fired from
; Output: None
; Calls: SendPacket - This sends out the HelloMsg that has been set up
; MOVMW - Macro to move word from memory to memory.
; MOVMB - Macro to move byte from memory to memory.
; Purpose: This macro sends sets up the UpdateShot message struct with the
; appropriate values and then calls SendPacket to transmit the packet
; everyone else. An UpdateShot message tells what playernumber the
; message is from, the bullet's direction, and the bullet's start position
push ax
mov (UpdateShot PTR TXBuffer).MsgType, UPDATESH
MOVMB (UpdateShot PTR TXBuffer).PlayerNum, MyNum
MOVMW (PointType PTR (UpdateShot PTR TXBuffer).ShotPos).x, BulPosX
MOVMW (PointType PTR (UpdateShot PTR TXBuffer).ShotPos).y, BulPosY
MOVMB (UpdateShot PTR TXBuffer).ShotDir, BulDir
mov ax, Sizeof UpdateShot
call SendPacket
pop ax
ENDM
|
GOODBYESEND MACRO
; Input: None
; Output: None
; Calls: SendPacket - This sends out the HelloMsg that has been set up
; MOVMB - Macro to move byte from memory to memory.
; Purpose: This macro sends sets up the GoodByeMsg message struct with the
; appropriate values and then calls SendPacket to transmit the packet
; everyone else. An GoodByeMsg message tells what playernumber the
; message is from.
push ax
mov (GoodByeMsg PTR TXBuffer).MsgType, GOODBYE
MOVMB (GoodByeMsg PTR TXBuffer).PlayerNum, MyNum
mov ax, Sizeof GoodByeMsg
call SendPacket
pop ax
ENDM
|
MOVMB MACRO dst, src ; MOV Byte from Memory to Memory
PUSH AX
mov al,src
mov dst,al
POP AX
ENDM
|
MOVMW MACRO dst, src ; MOV Word from Memory to Memory
PUSH AX
mov ax,src
mov dst,ax
POP AX
ENDM
|
STRCPY MACRO dst, src, NumBytes
push ds
push es
push ax
push cx
push di
push si
cld
MOV CX,NumBytes
LEA DI, dst
MOV AX, seg dst
MOV ES,AX
LEA SI, src
MOV AX, seg src
MOV DS,AX
REP MOVSB
pop si
pop di
pop cx
pop ax
pop es
pop ds
ENDM
|
STRCPY16 MACRO dst, src ; Optimized Copies 16-byte String
push es
push ds
push eax
push cx
push di
push si
cld
MOV AX,seg dst
MOV ES,AX
MOV DI,offset dst
MOV AX,seg src
MOV DS,AX
MOV SI,offset src
mov cx, 4
rep movsd
pop si
pop di
pop cx
pop eax
pop ds
pop es
ENDM
|
PRINTMSG MACRO message ; Print a text message
LOCAL msgdta
LOCAL msgjmp
JMP msgjmp
msgdta db message , CR , LF , '$'
msgjmp: PUSH DX
MOV DX, offset msgdta
CALL DSPMSG
POP DX
ENDM
|
PRINTSTR MACRO message, varstr ; Print message and a string
LOCAL msgdta
LOCAL msgjmp
JMP msgjmp
msgdta db message , '$'
msgjmp: PUSH DX
MOV DX,offset msgdta
call DSPMSG
MOV DX,offset varstr
Call DSPMSG
MOV DX,offset CRLF
Call DSPMSG
POP DX
ENDM
|
DOSEXIT MACRO RetCode ; exit to dos (like DOSXIT, but w/o message)
MOV AH,4ch
MOV AL,RetCode
INT 21h
ENDM
|
|