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

📄 winintrf.asm

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;    cmp byte[OSPort],1  ; Do not call in the dos port
;    ja .notdos
;.notdos
    cmp byte[soundon],0
    je .nosound
    cmp byte[DSPDisable],1
    je .nosound
    mov eax,256         ; Size
    mov dword[BufferSizeB],eax
    add eax,eax
    mov dword[BufferSizeW],eax
    pushad
    call ProcessSoundBuffer
    popad
    ; DSPBuffer should contain the processed buffer in the specified size
    ; You will have to convert/clip it to 16-bit for actual sound process
.nosound    
    popad
    ret

NEWSYM delay
   ret

NEWSYM Check60hz
    ; Call the timer update function here
    pushad
    call CheckTimers
    popad
    ret

NEWSYM UpdateSoundAgain
    ret

BitPosR db 11 
BitPosG db 5
BitPosB db 0
BitSizeR db 5
BitSizeG db 6
BitSizeB db 5


InitializeGfxStuff:
        ; Process Red Stuff
        mov al,[BitPosR]
        mov cl,al
        mov bx,1
        shl bx,cl
        cmp byte[BitSizeR],6
        jne .no6bit
        mov [vesa2_usbit],bx
        inc al
.no6bit
        or [vesa2_clbit],bx
        mov [vesa2_rpos],al
        dec al
        mov cl,al
        mov bx,001Fh
        cmp cl,0FFh
        je .shrr
        shl bx,cl
        jmp .shlr
.shrr
        shr bx,1
.shlr
        mov word[vesa2_rfull],bx
        add al,5
        mov bx,1
        mov cl,al
        shl bx,cl
        mov word[vesa2_rtrcl],bx
        xor bx,0FFFFh
        mov word[vesa2_rtrcla],bx

        ; Process Green Stuff
        mov al,[BitPosG]
        mov cl,al
        mov bx,1
        shl bx,cl
        cmp byte[BitSizeG],6
        jne .no6bitb
        mov [vesa2_usbit],bx
        inc al
.no6bitb
        or [vesa2_clbit],bx
        mov [vesa2_gpos],al
        dec al
        mov cl,al
        mov bx,001Fh
        cmp cl,0FFh
        je .shrg
        shl bx,cl
        jmp .shlg
.shrg
        shr bx,1
.shlg
        mov word[vesa2_gfull],bx
        add al,5
        mov bx,1
        mov cl,al
        shl bx,cl
        mov word[vesa2_gtrcl],bx
        xor bx,0FFFFh
        mov word[vesa2_gtrcla],bx

        ; Process Blue Stuff
        mov al,[BitPosB]
        mov cl,al
        mov bx,1
        shl bx,cl
        cmp byte[BitSizeB],6
        jne .no6bitc
        mov [vesa2_usbit],bx
        inc al
.no6bitc
        or [vesa2_clbit],bx
        mov [vesa2_bpos],al
        dec al
        mov cl,al
        mov bx,001Fh
        cmp cl,0FFh
        je .shrb
        shl bx,cl
        jmp .shlb
.shrb
        shr bx,1
.shlb
        mov word[vesa2_bfull],bx
        add al,5
        mov bx,1
        mov cl,al
        shl bx,cl
        mov word[vesa2_btrcl],bx
        xor bx,0FFFFh
        mov word[vesa2_btrcla],bx

        xor word[vesa2_clbit],0FFFFh
        call genfulladdtab
        cmp byte[converta],1
         je .red10
         mov eax,565
         jmp .red11
         .red10
         mov eax,555
         .red11
         push eax
         call Init_2xSaIMMXW
         pop eax


        ret


NEWSYM SetInputDevice
    ; eax = pointer to devices, bl = device #, bh = player # (0-4)
    ; Sets keys according to input device selected
    cmp bl,0
    jne near .nozero
    mov dword[eax],0
    mov dword[eax+4],0
    mov dword[eax+8],0
    mov dword[eax+12],0
    mov dword[eax+16],0
    mov dword[eax+20],0
    mov dword[eax+24],0
    mov dword[eax+28],0
    mov dword[eax+32],0
    mov dword[eax+36],0
    mov dword[eax+40],0
    mov dword[eax+44],0
    ret
.nozero
    cmp bh,1
    je near .input2
    mov dword[eax],54
    mov dword[eax+4],28
    mov dword[eax+8],200
    mov dword[eax+12],208
    mov dword[eax+16],203
    mov dword[eax+20],205
    mov dword[eax+24],31
    mov dword[eax+28],45
    mov dword[eax+32],32
    mov dword[eax+36],30
    mov dword[eax+40],44
    mov dword[eax+44],46
    ret
.input2
    mov dword[eax],56
    mov dword[eax+4],29
    mov dword[eax+8],37
    mov dword[eax+12],50
    mov dword[eax+16],49
    mov dword[eax+20],51
    mov dword[eax+24],31
    mov dword[eax+28],32
    mov dword[eax+32],33
    mov dword[eax+36],44
    mov dword[eax+40],45
    mov dword[eax+44],46
    ret

; ****************************
; TCP/IP Stuff
; ****************************

; TCPIPPortNum
NEWSYM TCPIPStatus, db 0
NEWSYM PacketSendSize, dd 0
NEWSYM PacketRecvSize, dd 0
NEWSYM PacketRecvPtr,  dd 0
NEWSYM PacketSendArray, times 2048+256 db 0
NEWSYM PacketRecvArray, times 2048+256 db 0
NEWSYM IPAddrStr, times 20 db 0
NEWSYM RemoteDisconnect, db 0

NEWSYM TCPIPStartServer
    mov byte[RemoteDisconnect],0
    pushad
    mov dword[PacketSendSize],0
    mov dword[PacketRecvSize],0
    call InitTCP
    or eax,eax
    jnz .failed
    mov byte[TCPIPStatus],1
;    StartServer(unsigned short port)
    xor eax,eax
    mov ax,[TCPIPPortNum]
    push eax
    call StartServerCycle
    add esp,4
    or eax,eax
    jnz .failed
    mov byte[TCPIPStatus],2
    popad
    xor eax,eax
    ret
.failed
    popad
    mov eax,-1
    ret

NEWSYM TCPIPWaitForConnection
    mov byte[RemoteDisconnect],0
    pushad
    call ServerCheckNewClient
    mov [.temp],eax
    cmp eax,1
    jne .notwaiting
    call acceptzuser
    or eax,eax
    jnz .failed
.notwaiting
    popad
    mov eax,[.temp]
    ret
.failed
    popad
    mov eax,-1
    ret
.temp dd 0

NEWSYM TCPIPInitConnectToServer
    pushad
    mov dword[PacketSendSize],0
    mov dword[PacketRecvSize],0
    call InitTCP
    or eax,eax
    jnz .failed
    mov byte[TCPIPStatus],1
    ; Convert GUINetTextk2 to IPAddrStr
    mov ebx,GUINetTextk2
    mov edx,IPAddrStr
.notend
    mov al,[ebx]
    cmp al,' '
    je .dontinclude
    mov [edx],al
    inc edx
.dontinclude
    inc ebx
    cmp al,0
    jne .notend
    popad
    xor eax,eax
    ret
.failed
    popad
    mov eax,1
    ret

NEWSYM TCPIPConnectToServer
; int ConnectServer(char *servername, unsigned short port)
    pushad
    xor eax,eax
    mov ax,[TCPIPPortNum]
    push eax
    mov eax,IPAddrStr
    push eax
    xor eax,eax
    call ConnectServer
    add esp,8
    or eax,eax
    jnz .noclient
    mov byte[TCPIPStatus],3
    popad
    xor eax,eax
    ret
.noclient
    mov [.temp],eax
    popad
    mov eax,[.temp]
    ret
.temp dd 0

NEWSYM TCPIPConnectToServerW
; int ConnectServer(char *servername, unsigned short port)
    pushad
    xor eax,eax
    call WaitForServer
    or eax,eax
    jnz .foundclient
    mov byte[TCPIPStatus],3
    popad
    xor eax,eax
    ret
.foundclient
    mov [.temp],eax
    popad
    mov eax,[.temp]
    ret
.temp dd 0

NEWSYM TCPIPStoreByte
    ; Store al into the array
;    cmp dword[PacketSendSize],2048
;    je .packeterror
    push ebx
    mov ebx,[PacketSendSize]
    mov [PacketSendArray+ebx],al
    pop ebx
    inc dword[PacketSendSize]
    ret
.packeterror
    mov byte[RemoteDisconnect],1
    ret

NEWSYM TCPIPGetByte
    ; dh = 0 : No bytes in buffer
    ; dl = resulting character
    cmp dword[PacketRecvSize],0
    jne .bytereceived
    mov dword[PacketRecvPtr],0
    call TCPIPRecvPacket
    cmp dword[PacketRecvSize],0
    jne .bytereceived
    xor dh,dh
    ret
.bytereceived
    push eax
    mov eax,[PacketRecvPtr]
    mov dl,[PacketRecvArray+eax]
    mov dh,1
    inc dword[PacketRecvPtr]
    mov eax,[PacketRecvPtr]
    cmp [PacketRecvSize],eax
    jne .notequal
    mov dword[PacketRecvSize],0
.notequal
    pop eax
    ret

NEWSYM TCPIPSendPacket
    cmp dword[PacketSendSize],0
    je .nopacket
    pushad
    ; Send PacketSendArray with size of PacketSendSize
    ; SendData(int dsize,char *dptr)
    mov eax,PacketSendArray
    push eax
    mov eax,[PacketSendSize]
    push eax
    call SendData
    or eax,eax
    jnz .failed
    add esp,8
    popad
.nopacket
    ret
.failed
    add esp,8
    popad
    call TCPIPDisconnect
    mov byte[RemoteDisconnect],1
    ret

NEWSYM TCPIPSendPacketUDP
    cmp dword[PacketSendSize],0
    je .nopacket
    pushad
    ; Send PacketSendArray with size of PacketSendSize
    ; SendData(int dsize,char *dptr)
    mov eax,PacketSendArray
    push eax
    mov eax,[PacketSendSize]
    push eax
    call SendDataUDP
    or eax,eax
    jnz .failed
    add esp,8
    popad
.nopacket
    ret
.failed
    add esp,8
    popad
    call TCPIPDisconnect
    mov byte[RemoteDisconnect],1
    ret

NEWSYM TCPIPRecvPacket
    pushad
    ; Store packet to PacketRecvArray, size at PacketRecvSize
    ; int GetData(int dsize,char *dptr)
    mov eax,PacketRecvArray
    push eax
    mov eax,2048
    push eax
    call GetData
    cmp eax,-1
    je .failed
    mov [PacketRecvSize],eax
    add esp,8
    popad
    ret
.failed
    add esp,8
    popad
    call TCPIPDisconnect
    mov byte[RemoteDisconnect],1
    ret

NEWSYM TCPIPDisconnect
    call DeInitTCP
    cmp byte[TCPIPStatus],2
    jne .notserver
    call StopServer
.notserver
    cmp byte[TCPIPStatus],3
    jne .notclient
    call Disconnect
.notclient
    mov byte[TCPIPStatus],0
    ret

NEWSYM TCPIPPreparePacket
    mov dword[PacketSendSize],0
    ret

NEWSYM ClearUDPStuff
    pushad
    call UDPClearVars
    popad
    ret

NEWSYM Wait1SecWin
    pushad
    call UDPWait1Sec
    popad
    ret

NEWSYM EnableSUDPPacket
    pushad
    call UDPEnableMode
    popad
    ret

NEWSYM DisableSUDPPacket
    pushad
    call UDPDisableMode
    popad
    ret

NEWSYM WinErrorA
    call WinErrorA2
    ret
NEWSYM WinErrorB
    call WinErrorB2
    ret
NEWSYM WinErrorC
    call WinErrorC2
    ret

NEWSYM GotoHomepage
    pushad
    call ZsnesPage
    popad
    ret

NEWSYM GetTimeInSeconds
	push dword SystemTime
	call [_imp__GetLocalTime@4]
	movzx eax,word [SystemTime.wHour]
	mov ebx,60
	mul ebx
	movzx ebx,word [SystemTime.wMinute]
	add eax,ebx
	mov ebx,60
	mul ebx
	movzx ebx,word [SystemTime.wSecond]
	add eax,ebx
	ret

SystemTime:
.wYear			dw	0
.wMonth			dw	0
.wDayOfWeek		dw	0
.wDay			dw	0
.wHour			dw	0
.wMinute		dw	0
.wSecond		dw	0
.wMilliseconds	dw	0

⌨️ 快捷键说明

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