⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guinetpl.inc

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 INC
📖 第 1 页 / 共 3 页
字号:
;Copyright (C) 1997-2001 ZSNES Team ( zsknight@zsnes.com / _demo_@zsnes.com )
;
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either
;version 2 of the License, or (at your option) any later
;version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


; GUI NetPlay Routines (Modem,IPX,UDP+TCP/IP)

ProcessModem:
    cmp byte[ModemProcess],40
    jne near .noprocess40
    cmp byte[maxskip],3
    jae .okaymf
    mov byte[maxskip],3
.okaymf
    mov byte[frameskip],0
    mov byte[Latencytochange],3
    mov byte[Latency],3
    mov byte[IPXSearchval],0
    mov byte[RemoteDisconnect],0
    mov byte[HoldCommand],1
    mov byte[RemoteCommand],1
    ; Clear Screen Buffer
    mov eax,ViewBuffer
    mov ecx,50*32
.clooptcpip
    mov byte[eax],0
    inc eax
    loop .clooptcpip
    mov dword[CCursLoc],0
    mov dword[CViewLoc],0
    mov dword[NViewLoc],0
    mov esi,.tcpipinit
    call .writestr
    mov esi,.tcpipport
    call .writestr
    mov esi,GUINetTextl2
    call .writestr
    mov esi,.tcpipret
    call .writestr
    mov esi,.tcpipportt
    cmp byte[UDPConfig],0
    je .notudp
    mov esi,.tcpipportu
.notudp
    call .writestr
    mov esi,.tcpipret
    call .writestr
    mov esi,.tcpipserv
    call .writestr
    mov byte[ModemProcess],42
    ret
.tcpipdones db 'DONE',13,10,13,10,'WAITING FOR CLIENT...',0
.tcpipdonec db 'DONE',13,10,13,10,'CONNECTING TO SERVER...',0
.tcpipdones2 db 13,10,13,10,'FOUND CLIENT.',0
.tcpipdonec2 db 13,10,13,10,'CONNECTION SUCCESSFUL.',0
.tcpiperror db 'FAILED',13,10,13,10,'ERROR: ',0
.tcpipip db 'IP : ',0
.tcpipip2 db 'SIP     : ',0
.tcpipport db 'PORT    : ',0
.tcpipportu db 'PROTOCOL: UDP',13,10,0
.tcpipportt db 'PROTOCOL: TCP/IP',13,10,0
.tcpipret db 13,10,0
.errorinit db 'FAILED NET INIT',0
.errorinit2 db 'CANNOT START SERVER',0
.errorinit3 db 'CANNOT CONNECT',0
.noprocess40
    cmp byte[ModemProcess],41
    jne near .noprocess41
    cmp byte[maxskip],3
    jae .okaymf2
    mov byte[maxskip],3
.okaymf2
    mov byte[frameskip],0
    mov byte[Latencytochange],3
    mov byte[Latency],3
    mov byte[IPXSearchval],0
    mov byte[RemoteDisconnect],0
    mov byte[HoldCommand],1
    mov byte[RemoteCommand],1
    ; Clear Screen Buffer
    mov eax,ViewBuffer
    mov ecx,50*32
.clooptcpip2
    mov byte[eax],0
    inc eax
    loop .clooptcpip2
    mov dword[CCursLoc],0
    mov dword[CViewLoc],0
    mov dword[NViewLoc],0
    mov esi,.tcpipinit
    call .writestr
    mov esi,.tcpipport
    call .writestr
    mov esi,GUINetTextl2
    call .writestr
    mov esi,.tcpipret
    call .writestr
    mov esi,.tcpipportt
    cmp byte[UDPConfig],0
    je .notudp2
    mov esi,.tcpipportu
.notudp2
    call .writestr
    mov esi,.tcpipip2
    call .writestr
    mov esi,GUINetTextk2
    call .writestr
    mov esi,.tcpipret
    call .writestr
    mov esi,.tcpipret
    call .writestr
    mov esi,.tcpipclie
    call .writestr
    mov byte[ModemProcess],43
    ret
.noprocess41
    cmp byte[ModemProcess],42
    jne near .noprocess42
    call TCPIPStartServer
    or eax,eax
    jnz .tcpfailed
    mov esi,.tcpipdones
    call .writestr
    mov byte[ModemProcess],44
    ret
.tcpfailed
    mov esi,.tcpiperror
    call .writestr
    mov esi,.errorinit
    call .writestr
    mov byte[ModemProcess],255
    ret
.noprocess42
    cmp byte[ModemProcess],43
    jne near .noprocess43
    call TCPIPInitConnectToServer
    or eax,eax
    jnz .tcpfailed2
    mov esi,.tcpipdonec
    call .writestr
    mov byte[ModemProcess],45
    ret
.tcpfailed2
    mov esi,.tcpiperror
    call .writestr
    mov esi,.errorinit
    call .writestr
    mov byte[ModemProcess],255
    ret
.noprocess43
    cmp byte[ModemProcess],44
    jne near .noprocess44
    call TCPIPWaitForConnection
    cmp eax,1
    je .successb
    or eax,eax
    jnz .tcpfailed3
    ret
.successb
    mov esi,.tcpipdones2
    call .writestr
    mov byte[ModemProcess],46
    ret
.tcpfailed3
;    add al,'Z'
;    mov byte[.tcpiperror],al
    mov esi,.tcpiperror
    call .writestr
    mov esi,.errorinit2
    call .writestr
    mov byte[ModemProcess],255
    ret
.noprocess44
    cmp byte[ModemProcess],45
    jne near .noprocess45
    call TCPIPConnectToServer
    or eax,eax
    jnz .tcpfailed4
    mov byte[ModemProcess],47
    ret
.tcpfailed4
;    add al,'Z'
;    mov [.errorinit3],al
    mov esi,.tcpiperror
    call .writestr
    mov esi,.errorinit3
    call .writestr
    mov byte[ModemProcess],255
    ret
.noprocess45
    cmp byte[ModemProcess],46
    jne near .noprocess46
    mov byte[pl2neten],2
    mov byte[pl1neten],1
    mov byte[UseRemoteSRAMData],1
    mov byte[ModemProcess],66
    ret
.noprocess46
    cmp byte[ModemProcess],47
    jne near .noprocess47
    call TCPIPConnectToServerW
    or eax,eax
    jnz .connected
    ret
.connected
    mov esi,.tcpipdonec2
    call .writestr
    mov byte[pl2neten],1
    mov byte[pl1neten],2
    mov byte[UseRemoteSRAMData],2
    mov byte[ModemProcess],66
    ret
.noprocess47
    cmp byte[ModemProcess],30
    jne near .noprocess30
    mov byte[Latencytochange],2
    mov byte[Latency],2
    mov byte[IPXSearchval],0
    ; Clear Screen Buffer
    mov eax,ViewBuffer
    mov ecx,50*32
.cloopipx
    mov byte[eax],0
    inc eax
    loop .cloopipx
    mov dword[CCursLoc],0
    mov dword[CViewLoc],0
    mov dword[NViewLoc],0
    mov esi,.initc
    call .writestr
    mov esi,.localid
    call .writestr
    push es
    mov es,[selc0040]
    mov ax,[es:108]
    mov [IPXInfoStr],ax
    pop es
    call .writehex
    ; ipx
;    cmp byte[OSPort],1
;    je .noinitipx
    call initipx
.noinitipx
    cmp ax,0
    je .success
    mov byte[ModemProcess],255
    mov esi,.noipx
    call .writestr
    ret
.success
    mov byte[ModemProcess],31
    mov dword[ModemPTimer],36
    mov esi,.yesipx
    call .writestr
    ret
.noprocess30
    cmp byte[ModemProcess],31
    jne .noprocess31
    ; Wait for remote
    cmp dword[ModemPTimer],0
    jne .nolookforconnect
    mov dword[ModemPTimer],36
;    cmp byte[OSPort],1
;    je .noipxlook
    call ipxlookforconnect
.noipxlook
    cmp byte[IPXSearchval],0
    je .nolookforconnect
    mov esi,.connectest
    call .writestr
    mov esi,.remoteid
    call .writestr
    mov ax,[IPXInfoStrR]
    call .writehex
    mov byte[ModemProcess],64
    mov byte[Connected],1
    mov byte[WhichRemote],2
.nolookforconnect
    ret
.noprocess31
    cmp byte[ModemProcess],0
    jne near .noprocess0
    mov byte[Latencytochange],2
    mov byte[Latency],2
    cmp byte[ModemInitStat],1
    je .nomodeminit
    call InitModem
    mov byte[ModemInitStat],1
.nomodeminit
    mov byte[Connected],0
    ; Clear Screen Buffer
    mov eax,ViewBuffer
    mov ecx,50*32
.cloop
    mov byte[eax],0
    inc eax
    loop .cloop
    mov dword[CCursLoc],0
    mov dword[CViewLoc],0
    mov dword[NViewLoc],0
    mov esi,.init
    call .writestr
    mov esi,.uart0
    cmp byte[UartType],0
    je .nouart0
    mov esi,.uart1
    cmp byte[UartType],1
    je .nouart0
    mov esi,.uart2
.nouart0
    call .writestr
    mov esi,.initb
    call .writestr
    mov byte[ModemProcess],8
    mov dword[ModemPTimer],36
    mov byte[InitStr1Done],0
    mov byte[ModemOKStat],0
    cmp byte[cantinitmodem],0
    je .okayinit
    mov esi,.unableinit
    call .writestr
    mov byte[ModemProcess],255
.okayinit
    ret
.noprocess0
    cmp byte[ModemProcess],8
    jne .noprocess8
    cmp dword[ModemPTimer],0
    jne .skipnext8
    mov dword[ModemPTimer],18
    mov byte[ModemProcess],1
    cmp byte[CNetType],12
    jne .nomanual
    mov byte[ModemProcess],7
    mov dword[ModemPTimer],0
.nomanual
    mov al,13
    call ModemSendChar
    mov al,13
    call ModemSendChar
.skipnext8
    ret
.noprocess8
    cmp byte[ModemProcess],1
    jne .noprocess1
    cmp dword[ModemPTimer],0
    jne .skipnext
    mov byte[ModemProcess],2
    call ModemClearBuffer
.skipnext
    ret
.noprocess1
    cmp byte[ModemProcess],2
    jne .noprocess2
    mov byte[ModemProcess],3
    mov dword[ModemPTimer],36*5
    mov esi,GUIInitSt1
    cmp byte[InitStr1Done],0
    je .notinit2
    mov esi,GUIInitSt2
.notinit2
    call ModemSendStr
    mov al,13
    call ModemSendChar
    ret
.noprocess2
    cmp byte[ModemProcess],3
    jne .noprocess3
    cmp byte[ModemOKStat],0
    je .norecv
    mov byte[ModemProcess],9
.norecv
    cmp dword[ModemPTimer],0
    jne .notimeout
    mov esi,.tout
    call .writestr
    mov byte[ModemProcess],255
.notimeout
    ret
.noprocess3
    cmp byte[ModemProcess],9
    jne .noprocess9
    cmp dword[ModemPTimer],0
    je .timeout
    cmp byte[ModemOKStat],4
    jne .notcomplete
.timeout
    mov byte[ModemProcess],4
.notcomplete
    ret
.noprocess9
    cmp byte[ModemProcess],4
    jne .noprocess4
    inc byte[InitStr1Done]
    cmp byte[InitStr1Done],2
    je .noinit2
    cmp byte[GUIInitSt2],0
    je .noinit2
    mov byte[ModemProcess],1
    mov dword[ModemPTimer],18
    mov byte[ModemOKStat],0
    ret
.noinit2
    mov byte[ModemProcess],5
    mov dword[ModemPTimer],18
    ret
.noprocess4
    cmp byte[ModemProcess],5
    jne .noprocess5
    cmp dword[ModemPTimer],0
    jne .finishtimer

    ; ***** - Comment the following 4 lines
;    mov byte[ModemProcess],64
;    mov byte[Connected],1
;    mov byte[WhichRemote],1
;    ret

    ; dial, wait for ring, etc.
    cmp byte[CNetType],11       ; dial
    jne .nodial
    mov esi,GUIDialSt
    call ModemSendStr
    mov esi,DialNumber
    call ModemSendStr
    mov al,13
    call ModemSendChar
    mov byte[ModemProcess],7
    ret
.nodial
    cmp byte[CNetType],10       ; wait for ring
    jne .noanswer
    mov esi,.rdet
    call .writestr
    mov byte[ModemProcess],6
    ret
.noanswer
    mov byte[ModemProcess],7
    ret
.finishtimer
.noprocess5
    cmp byte[ModemProcess],6
    jne .noprocess6
    call ModemCheckRing
    cmp al,1
    jne .noprocess6
    mov esi,.ata
    call ModemSendStr
    mov byte[ModemProcess],7
.noprocess6
    cmp byte[ModemProcess],7
    jne .noprocess7
    call ModemCheckDCD
    cmp al,1
    jne .nocdc7
    mov esi,.cdet
    call .writestr
    mov byte[ModemProcess],64
    mov byte[WhichRemote],1
.nocdc7
    ret
.noprocess7

    ; Connect initialization
    cmp byte[ModemProcess],64
    jne .noprocess64
    mov dword[ModemPTimer],72  ;36
    mov byte[ModemProcess],65
    mov byte[Connected],1
    ret
.noprocess64
    cmp byte[ModemProcess],65
    jne .noprocess65
    cmp dword[ModemPTimer],0
    je .okay65
    ret
.okay65
    mov byte[ModemProcess],66
    ret
.noprocess65
    cmp byte[ModemProcess],69
    jne .noprocess69
    cmp dword[ModemPTimer],0
    jne .notimer69
    mov dword[ModemPTimer],90   ; 2.5s
    call PreparePacket
    mov al,228
    call RemoteSendChar
    call SendPacket
.notimer69
    call RemoteGetChar
    cmp dh,0
    je .doneprocess69
    cmp dl,228
    jne .doneprocess69
    mov byte[ModemProcess],66
.doneprocess69
    ret
.noprocess69
    cmp byte[ModemProcess],66
    jne .noprocess66
    ; Send ID and version #
    call PreparePacket
    mov al,'I'
    call RemoteSendChar
    mov al,'D'
    call RemoteSendChar
    mov al,222
    call RemoteSendChar
    mov al,[welcome+7]
    call RemoteSendChar
    mov al,[welcome+9]
    call RemoteSendChar
    mov al,[welcome+10]
    call RemoteSendChar
    mov al,[welcome+11]
    call RemoteSendChar
    mov al,[soundon]
    call RemoteSendChar
    cmp al,byte[CNetType]
    call RemoteSendChar
    call SendPacket
    mov byte[ModemProcess],67
    mov byte[IDCheckPos],0
    ret
    ; Check if versions are the same
.noprocess66
    cmp byte[ModemProcess],67
    jne near .noprocess67
    call RemoteGetChar
    cmp dh,0
    je near .doneprocess
    cmp dl,'I'
    jne .noI
    mov byte[IDCheckPos],1
    ret
.noI
    cmp byte[IDCheckPos],1
    jne .nocheck2
    cmp dl,'D'
    jne .noD
    mov byte[IDCheckPos],2
    ret
.noD
    mov byte[IDCheckPos],0
    ret
.nocheck2
    cmp byte[IDCheckPos],2
    jne .nocheck3
    cmp dl,222
    jne .no222
    mov byte[IDCheckPos],3
    ret
.no222
    mov byte[IDCheckPos],0
    ret
.nocheck3
    cmp byte[IDCheckPos],3
    jne .nocheck4
    cmp dl,[welcome+7]
    jne near .invversion
    mov byte[IDCheckPos],4
    ret
.nocheck4
    cmp byte[IDCheckPos],4
    jne .nocheck5
    cmp dl,[welcome+9]
    jne near .invversion
    mov byte[IDCheckPos],5
    ret
.nocheck5
    cmp byte[IDCheckPos],5
    jne .nocheck6
    cmp dl,[welcome+10]
    jne .invversion
    mov byte[IDCheckPos],6
    ret
.nocheck6
    cmp byte[IDCheckPos],6
    jne .nocheck7
    cmp dl,[welcome+11]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -