Removed superfluous ^Z at the end of files
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,156 +1,155 @@
|
||||
;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.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
section .data
|
||||
sample times 60 db 0
|
||||
clock_mask db 0
|
||||
data_mask db 0
|
||||
|
||||
section .text
|
||||
|
||||
NEWSYM read_gpp
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
push esi
|
||||
|
||||
cmp al,0
|
||||
jne GPP_L14
|
||||
mov byte [clock_mask],0x10
|
||||
mov byte [data_mask],0x20
|
||||
jmp GPP_L15
|
||||
GPP_L14:
|
||||
mov byte [clock_mask],0x40
|
||||
mov byte [data_mask],0x80
|
||||
GPP_L15:
|
||||
|
||||
|
||||
xor ebx,ebx
|
||||
xor edi,edi
|
||||
|
||||
cli
|
||||
in al,dx
|
||||
mov ah,al
|
||||
|
||||
GPP_L4:
|
||||
xor ecx,ecx
|
||||
GPP_L0:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
in al,dx
|
||||
cmp al,ah
|
||||
jne GPP_L1
|
||||
inc ecx
|
||||
cmp ecx,255
|
||||
jl GPP_L0
|
||||
GPP_L1:
|
||||
cmp ecx,255
|
||||
je near GPP_ERR
|
||||
|
||||
test [clock_mask],ah
|
||||
jz GPP_L2
|
||||
test [clock_mask],al
|
||||
jnz GPP_L2
|
||||
|
||||
test [data_mask],al
|
||||
jz GPP_L3
|
||||
mov byte [sample+edi],1
|
||||
jmp GPP_L12
|
||||
GPP_L3:
|
||||
mov byte [sample+edi],0
|
||||
GPP_L12:
|
||||
inc edi
|
||||
|
||||
GPP_L2:
|
||||
mov ah,al
|
||||
cmp ebx,200
|
||||
je GPP_L13
|
||||
inc ebx
|
||||
cmp edi,50
|
||||
jl GPP_L4
|
||||
|
||||
GPP_L13:
|
||||
sti
|
||||
xor ecx,ecx
|
||||
mov esi,1
|
||||
GPP_L7:
|
||||
cmp byte [sample+esi],1
|
||||
jg GPP_ERR
|
||||
jne GPP_L6
|
||||
inc ecx
|
||||
jmp GPP_L5
|
||||
GPP_L6:
|
||||
xor ecx,ecx
|
||||
|
||||
GPP_L5:
|
||||
cmp ecx,5
|
||||
je GPP_L8
|
||||
cmp esi,edi
|
||||
je GPP_L8
|
||||
inc esi
|
||||
jmp GPP_L7
|
||||
|
||||
GPP_L8:
|
||||
cmp ecx,5
|
||||
jne GPP_ERR
|
||||
add esi,2
|
||||
xor eax,eax
|
||||
xor ebx,ebx
|
||||
xor ecx,ecx
|
||||
xor edx,edx
|
||||
|
||||
GPP_L10:
|
||||
inc ecx
|
||||
cmp ecx,5
|
||||
jne GPP_L11
|
||||
mov ecx,1
|
||||
inc esi
|
||||
GPP_L11:
|
||||
mov dl,[sample+esi]
|
||||
or eax,edx
|
||||
shl eax,1
|
||||
cmp ebx,13
|
||||
je GPP_L9
|
||||
inc ebx
|
||||
inc esi
|
||||
jmp GPP_L10
|
||||
|
||||
GPP_L9:
|
||||
pop esi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
GPP_ERR:
|
||||
sti
|
||||
pop esi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
mov eax,1
|
||||
ret
|
||||
|
||||
;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.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
section .data
|
||||
sample times 60 db 0
|
||||
clock_mask db 0
|
||||
data_mask db 0
|
||||
|
||||
section .text
|
||||
|
||||
NEWSYM read_gpp
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
push edi
|
||||
push esi
|
||||
|
||||
cmp al,0
|
||||
jne GPP_L14
|
||||
mov byte [clock_mask],0x10
|
||||
mov byte [data_mask],0x20
|
||||
jmp GPP_L15
|
||||
GPP_L14:
|
||||
mov byte [clock_mask],0x40
|
||||
mov byte [data_mask],0x80
|
||||
GPP_L15:
|
||||
|
||||
|
||||
xor ebx,ebx
|
||||
xor edi,edi
|
||||
|
||||
cli
|
||||
in al,dx
|
||||
mov ah,al
|
||||
|
||||
GPP_L4:
|
||||
xor ecx,ecx
|
||||
GPP_L0:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
in al,dx
|
||||
cmp al,ah
|
||||
jne GPP_L1
|
||||
inc ecx
|
||||
cmp ecx,255
|
||||
jl GPP_L0
|
||||
GPP_L1:
|
||||
cmp ecx,255
|
||||
je near GPP_ERR
|
||||
|
||||
test [clock_mask],ah
|
||||
jz GPP_L2
|
||||
test [clock_mask],al
|
||||
jnz GPP_L2
|
||||
|
||||
test [data_mask],al
|
||||
jz GPP_L3
|
||||
mov byte [sample+edi],1
|
||||
jmp GPP_L12
|
||||
GPP_L3:
|
||||
mov byte [sample+edi],0
|
||||
GPP_L12:
|
||||
inc edi
|
||||
|
||||
GPP_L2:
|
||||
mov ah,al
|
||||
cmp ebx,200
|
||||
je GPP_L13
|
||||
inc ebx
|
||||
cmp edi,50
|
||||
jl GPP_L4
|
||||
|
||||
GPP_L13:
|
||||
sti
|
||||
xor ecx,ecx
|
||||
mov esi,1
|
||||
GPP_L7:
|
||||
cmp byte [sample+esi],1
|
||||
jg GPP_ERR
|
||||
jne GPP_L6
|
||||
inc ecx
|
||||
jmp GPP_L5
|
||||
GPP_L6:
|
||||
xor ecx,ecx
|
||||
|
||||
GPP_L5:
|
||||
cmp ecx,5
|
||||
je GPP_L8
|
||||
cmp esi,edi
|
||||
je GPP_L8
|
||||
inc esi
|
||||
jmp GPP_L7
|
||||
|
||||
GPP_L8:
|
||||
cmp ecx,5
|
||||
jne GPP_ERR
|
||||
add esi,2
|
||||
xor eax,eax
|
||||
xor ebx,ebx
|
||||
xor ecx,ecx
|
||||
xor edx,edx
|
||||
|
||||
GPP_L10:
|
||||
inc ecx
|
||||
cmp ecx,5
|
||||
jne GPP_L11
|
||||
mov ecx,1
|
||||
inc esi
|
||||
GPP_L11:
|
||||
mov dl,[sample+esi]
|
||||
or eax,edx
|
||||
shl eax,1
|
||||
cmp ebx,13
|
||||
je GPP_L9
|
||||
inc ebx
|
||||
inc esi
|
||||
jmp GPP_L10
|
||||
|
||||
GPP_L9:
|
||||
pop esi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
GPP_ERR:
|
||||
sti
|
||||
pop esi
|
||||
pop edi
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
mov eax,1
|
||||
ret
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,437 +1,436 @@
|
||||
;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.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM ComNum, ComIRQ, BaudRate
|
||||
EXTSYM dssel,FossilUse
|
||||
EXTSYM GUIinit18_2hz,GUIinit36_4hz
|
||||
EXTSYM GUIMenuItem
|
||||
EXTSYM delay
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NEWSYM UartType, db 0
|
||||
NEWSYM cantinitmodem, db 1
|
||||
NEWSYM ModemInited, db 0
|
||||
|
||||
ComPort dw 2E8h ; 1=3F8,2=2F8,3=3E8,4=2E8
|
||||
PortData dw 0,3F8h,2F8h,3E8h,2E8h
|
||||
ComInt db 0
|
||||
BRateSel dw 000Ch,0008h,0006h,0004h,0003h,0002h,0001h
|
||||
oldhandmodems dw 0
|
||||
oldhandmodemo dd 0
|
||||
PICMaskPm db 21h
|
||||
PortNum dw 0
|
||||
CharStore db 0
|
||||
|
||||
NEWSYM ModemGetChar
|
||||
cmp byte[UartType],2
|
||||
je near FossilGetChar
|
||||
xor dh,dh
|
||||
mov eax,[modemhead]
|
||||
cmp eax,[modemtail]
|
||||
je .nonewchar
|
||||
mov dh,1
|
||||
mov dl,[modembuffer+eax]
|
||||
inc dword[modemhead]
|
||||
and dword[modemhead],2047
|
||||
.nonewchar
|
||||
ret
|
||||
|
||||
FossilGetChar:
|
||||
pushad
|
||||
mov ah,0Ch
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
cmp ax,0FFFFh
|
||||
je .nochar
|
||||
mov ah,02h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
mov [CharStore],al
|
||||
popad
|
||||
mov dh,1
|
||||
mov dl,[CharStore]
|
||||
ret
|
||||
.nochar
|
||||
popad
|
||||
xor dh,dh
|
||||
ret
|
||||
|
||||
NEWSYM ModemCheckRing
|
||||
cmp byte[UartType],2
|
||||
je near .fossil
|
||||
mov dx,[ComPort]
|
||||
add dx,6
|
||||
in al,dx
|
||||
shr al,6
|
||||
and al,01h
|
||||
ret
|
||||
.fossil
|
||||
pushad
|
||||
mov ah,03h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
test al,40h
|
||||
jnz .ring
|
||||
popad
|
||||
xor al,al
|
||||
ret
|
||||
.ring
|
||||
popad
|
||||
mov al,1
|
||||
ret
|
||||
|
||||
NEWSYM ModemCheckDCD
|
||||
cmp byte[UartType],2
|
||||
je near .fossil
|
||||
mov dx,[ComPort]
|
||||
add dx,6
|
||||
in al,dx
|
||||
shr al,7
|
||||
and al,01h
|
||||
ret
|
||||
.fossil
|
||||
pushad
|
||||
mov ah,03h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
test al,80h
|
||||
jnz .dcd
|
||||
popad
|
||||
xor al,al
|
||||
ret
|
||||
.dcd
|
||||
popad
|
||||
mov al,1
|
||||
ret
|
||||
|
||||
NEWSYM ModemSendChar
|
||||
cmp byte[UartType],2
|
||||
je near FossilSendChar
|
||||
push ecx
|
||||
push edx
|
||||
push ebx
|
||||
mov ecx,1000000
|
||||
mov bl,al
|
||||
.loop
|
||||
mov dx,[ComPort]
|
||||
add dx,5
|
||||
in al,dx
|
||||
test al,00100000b
|
||||
jnz .transokay
|
||||
loop .loop
|
||||
xor al,al
|
||||
pop ebx
|
||||
pop edx
|
||||
pop ecx
|
||||
ret
|
||||
.transokay
|
||||
mov al,bl
|
||||
mov dx,[ComPort] ; Send the char through the modem
|
||||
out dx,al
|
||||
pop ebx
|
||||
pop edx
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
FossilSendChar:
|
||||
pushad
|
||||
mov ah,01h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
NEWSYM InitModem
|
||||
mov byte[ModemInited],1
|
||||
cmp byte[FossilUse],0
|
||||
jne near InitFossil
|
||||
mov byte[cantinitmodem],0
|
||||
cli
|
||||
; Get Port value
|
||||
xor eax,eax
|
||||
mov al,[ComNum]
|
||||
mov ax,[PortData+eax*2]
|
||||
mov [ComPort],ax
|
||||
|
||||
mov dx,[ComPort]
|
||||
add dx,2
|
||||
xor al,al
|
||||
out dx,al
|
||||
|
||||
; Set IRQ PIC Mask Port
|
||||
mov byte[PICMaskPm],21h
|
||||
mov bl,[ComIRQ]
|
||||
cmp bl,7
|
||||
jbe .noupper
|
||||
add bl,60h
|
||||
add byte[PICMaskPm],80h
|
||||
.noupper
|
||||
add bl,8
|
||||
mov [ComInt],bl
|
||||
|
||||
; Get IRQ handler
|
||||
mov ax,204h
|
||||
mov bl,[ComInt]
|
||||
int 31h
|
||||
mov [oldhandmodems],cx
|
||||
mov [oldhandmodemo],edx
|
||||
; Set IRQ handler
|
||||
mov ax,205h
|
||||
mov bl,[ComInt]
|
||||
mov cx,cs
|
||||
mov edx,modemhandler
|
||||
int 31h
|
||||
|
||||
mov dx,[ComPort]
|
||||
add dx,3
|
||||
mov al,00000011b
|
||||
out dx,al
|
||||
|
||||
; Set Normal Modem functioning, User2 bit, and DTR
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
mov al,00001011b
|
||||
out dx,al
|
||||
|
||||
; Enable IRQ
|
||||
xor dh,dh
|
||||
mov dl,[PICMaskPm] ; Output to IRQ PIC Mask Port
|
||||
mov cl,[ComIRQ] ; Get proper bit
|
||||
and cl,07h
|
||||
mov al,01h
|
||||
shl al,cl
|
||||
not al ; Complement since clear bit = enable
|
||||
mov bl,al
|
||||
in al,dx ; input to preserve other bits
|
||||
and al,bl
|
||||
xor al,al
|
||||
out dx,al
|
||||
|
||||
; Enable interrupt to execute only on data available
|
||||
mov dx,[ComPort]
|
||||
inc dx
|
||||
mov al,00000001b
|
||||
out dx,al
|
||||
sti
|
||||
|
||||
; Write baudrate
|
||||
mov dx,[ComPort]
|
||||
add dx,3
|
||||
in al,dx
|
||||
or al,10000000b
|
||||
out dx,al
|
||||
mov eax,[BaudRate]
|
||||
mov ax,[BRateSel+eax*2]
|
||||
mov dx,[ComPort]
|
||||
inc dx
|
||||
push eax
|
||||
mov al,ah
|
||||
out dx,al
|
||||
pop eax
|
||||
dec dx
|
||||
out dx,al
|
||||
mov dx,[ComPort]
|
||||
add dx,3
|
||||
in al,dx
|
||||
and al,01111111b
|
||||
out dx,al
|
||||
|
||||
; Initialize 16550A UART chip
|
||||
mov dx,[ComPort]
|
||||
add dx,2
|
||||
mov al,0C7h
|
||||
out dx,al
|
||||
nop
|
||||
nop
|
||||
in al,dx
|
||||
mov byte[UartType],1
|
||||
test al,40h
|
||||
jnz .passed16550a
|
||||
xor al,al
|
||||
out dx,al
|
||||
mov byte[UartType],0
|
||||
.passed16550a
|
||||
ret
|
||||
|
||||
InitFossil:
|
||||
xor edx,edx
|
||||
mov dl,[ComNum]
|
||||
dec dl
|
||||
mov [PortNum],dx
|
||||
mov byte[cantinitmodem],0
|
||||
mov byte[UartType],2
|
||||
mov ah,04h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
cmp ax,1954h
|
||||
jne .notsuccess
|
||||
xor ah,ah
|
||||
mov al,00000011b ; 19200 baud, 81N
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
ret
|
||||
.notsuccess
|
||||
mov byte[cantinitmodem],1
|
||||
ret
|
||||
|
||||
modemhandler:
|
||||
push ds
|
||||
push eax
|
||||
mov ax,[cs:dssel]
|
||||
mov ds,ax
|
||||
push edx
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
in al,dx
|
||||
and al,11111101b
|
||||
out dx,al
|
||||
|
||||
.next
|
||||
mov dx,[ComPort]
|
||||
in al,dx
|
||||
mov edx,[modemtail]
|
||||
mov [modembuffer+edx],al
|
||||
inc dword[modemtail]
|
||||
and dword[modemtail],2047
|
||||
mov dx,[ComPort]
|
||||
add dx,2
|
||||
in al,dx
|
||||
test al,1
|
||||
jz .next
|
||||
|
||||
mov al,20h
|
||||
out 20h,al
|
||||
|
||||
cmp byte[ComIRQ],7
|
||||
jbe .nohighirq
|
||||
mov al,20h
|
||||
out 0A0h,al
|
||||
.nohighirq
|
||||
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
in al,dx
|
||||
or al,00000010b
|
||||
out dx,al
|
||||
|
||||
pop edx
|
||||
pop eax
|
||||
pop ds
|
||||
iretd
|
||||
|
||||
NEWSYM ModemClearBuffer
|
||||
mov dword[modemhead],0
|
||||
mov dword[modemtail],0
|
||||
ret
|
||||
|
||||
NEWSYM modembuffer, times 2048 db 0
|
||||
NEWSYM modemhead, dd 0
|
||||
NEWSYM modemtail, dd 0
|
||||
|
||||
NEWSYM DeInitModem
|
||||
cmp byte[ModemInited],1
|
||||
je .okaydeinit
|
||||
ret
|
||||
.okaydeinit
|
||||
mov byte[ModemInited],0
|
||||
cmp byte[UartType],2
|
||||
je near DeInitFossil
|
||||
cli
|
||||
mov dx,[ComPort]
|
||||
add dx,2
|
||||
xor al,al
|
||||
out dx,al
|
||||
|
||||
xor dh,dh
|
||||
mov dl,[PICMaskPm]
|
||||
mov cl,[ComIRQ]
|
||||
and cl,07h
|
||||
mov al,01h
|
||||
shl al,cl
|
||||
mov bl,al
|
||||
in al,dx
|
||||
or al,bl
|
||||
xor al,al
|
||||
out dx,al
|
||||
mov dx,[ComPort]
|
||||
inc dx
|
||||
mov al,00h
|
||||
out dx,al
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
out dx,al
|
||||
|
||||
mov cx,[oldhandmodems]
|
||||
mov edx,[oldhandmodemo]
|
||||
mov ax,205h
|
||||
mov bl,[ComInt]
|
||||
int 31h
|
||||
sti
|
||||
ret
|
||||
|
||||
DeInitFossil:
|
||||
mov byte[cantinitmodem],0
|
||||
jne .nodeinit
|
||||
mov ax,0600h
|
||||
mov dx,[PortNum]
|
||||
int 14h ; Lower DTR
|
||||
mov ah,05h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
.nodeinit
|
||||
ret
|
||||
|
||||
NEWSYM DeInitModemC
|
||||
cmp byte[ModemInited],1
|
||||
je .okaydeinit
|
||||
ret
|
||||
.okaydeinit
|
||||
cmp byte[UartType],2
|
||||
je near DeInitFossil
|
||||
cli
|
||||
mov al,00h
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
out dx,al
|
||||
|
||||
mov al,13
|
||||
mov dx,[ComPort]
|
||||
out dx,al
|
||||
|
||||
mov ecx,16384
|
||||
call delay
|
||||
|
||||
out dx,al
|
||||
|
||||
mov al,00001001b
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
out dx,al
|
||||
sti
|
||||
ret
|
||||
|
||||
|
||||
;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.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM ComNum, ComIRQ, BaudRate
|
||||
EXTSYM dssel,FossilUse
|
||||
EXTSYM GUIinit18_2hz,GUIinit36_4hz
|
||||
EXTSYM GUIMenuItem
|
||||
EXTSYM delay
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NEWSYM UartType, db 0
|
||||
NEWSYM cantinitmodem, db 1
|
||||
NEWSYM ModemInited, db 0
|
||||
|
||||
ComPort dw 2E8h ; 1=3F8,2=2F8,3=3E8,4=2E8
|
||||
PortData dw 0,3F8h,2F8h,3E8h,2E8h
|
||||
ComInt db 0
|
||||
BRateSel dw 000Ch,0008h,0006h,0004h,0003h,0002h,0001h
|
||||
oldhandmodems dw 0
|
||||
oldhandmodemo dd 0
|
||||
PICMaskPm db 21h
|
||||
PortNum dw 0
|
||||
CharStore db 0
|
||||
|
||||
NEWSYM ModemGetChar
|
||||
cmp byte[UartType],2
|
||||
je near FossilGetChar
|
||||
xor dh,dh
|
||||
mov eax,[modemhead]
|
||||
cmp eax,[modemtail]
|
||||
je .nonewchar
|
||||
mov dh,1
|
||||
mov dl,[modembuffer+eax]
|
||||
inc dword[modemhead]
|
||||
and dword[modemhead],2047
|
||||
.nonewchar
|
||||
ret
|
||||
|
||||
FossilGetChar:
|
||||
pushad
|
||||
mov ah,0Ch
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
cmp ax,0FFFFh
|
||||
je .nochar
|
||||
mov ah,02h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
mov [CharStore],al
|
||||
popad
|
||||
mov dh,1
|
||||
mov dl,[CharStore]
|
||||
ret
|
||||
.nochar
|
||||
popad
|
||||
xor dh,dh
|
||||
ret
|
||||
|
||||
NEWSYM ModemCheckRing
|
||||
cmp byte[UartType],2
|
||||
je near .fossil
|
||||
mov dx,[ComPort]
|
||||
add dx,6
|
||||
in al,dx
|
||||
shr al,6
|
||||
and al,01h
|
||||
ret
|
||||
.fossil
|
||||
pushad
|
||||
mov ah,03h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
test al,40h
|
||||
jnz .ring
|
||||
popad
|
||||
xor al,al
|
||||
ret
|
||||
.ring
|
||||
popad
|
||||
mov al,1
|
||||
ret
|
||||
|
||||
NEWSYM ModemCheckDCD
|
||||
cmp byte[UartType],2
|
||||
je near .fossil
|
||||
mov dx,[ComPort]
|
||||
add dx,6
|
||||
in al,dx
|
||||
shr al,7
|
||||
and al,01h
|
||||
ret
|
||||
.fossil
|
||||
pushad
|
||||
mov ah,03h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
test al,80h
|
||||
jnz .dcd
|
||||
popad
|
||||
xor al,al
|
||||
ret
|
||||
.dcd
|
||||
popad
|
||||
mov al,1
|
||||
ret
|
||||
|
||||
NEWSYM ModemSendChar
|
||||
cmp byte[UartType],2
|
||||
je near FossilSendChar
|
||||
push ecx
|
||||
push edx
|
||||
push ebx
|
||||
mov ecx,1000000
|
||||
mov bl,al
|
||||
.loop
|
||||
mov dx,[ComPort]
|
||||
add dx,5
|
||||
in al,dx
|
||||
test al,00100000b
|
||||
jnz .transokay
|
||||
loop .loop
|
||||
xor al,al
|
||||
pop ebx
|
||||
pop edx
|
||||
pop ecx
|
||||
ret
|
||||
.transokay
|
||||
mov al,bl
|
||||
mov dx,[ComPort] ; Send the char through the modem
|
||||
out dx,al
|
||||
pop ebx
|
||||
pop edx
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
FossilSendChar:
|
||||
pushad
|
||||
mov ah,01h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
popad
|
||||
ret
|
||||
|
||||
|
||||
NEWSYM InitModem
|
||||
mov byte[ModemInited],1
|
||||
cmp byte[FossilUse],0
|
||||
jne near InitFossil
|
||||
mov byte[cantinitmodem],0
|
||||
cli
|
||||
; Get Port value
|
||||
xor eax,eax
|
||||
mov al,[ComNum]
|
||||
mov ax,[PortData+eax*2]
|
||||
mov [ComPort],ax
|
||||
|
||||
mov dx,[ComPort]
|
||||
add dx,2
|
||||
xor al,al
|
||||
out dx,al
|
||||
|
||||
; Set IRQ PIC Mask Port
|
||||
mov byte[PICMaskPm],21h
|
||||
mov bl,[ComIRQ]
|
||||
cmp bl,7
|
||||
jbe .noupper
|
||||
add bl,60h
|
||||
add byte[PICMaskPm],80h
|
||||
.noupper
|
||||
add bl,8
|
||||
mov [ComInt],bl
|
||||
|
||||
; Get IRQ handler
|
||||
mov ax,204h
|
||||
mov bl,[ComInt]
|
||||
int 31h
|
||||
mov [oldhandmodems],cx
|
||||
mov [oldhandmodemo],edx
|
||||
; Set IRQ handler
|
||||
mov ax,205h
|
||||
mov bl,[ComInt]
|
||||
mov cx,cs
|
||||
mov edx,modemhandler
|
||||
int 31h
|
||||
|
||||
mov dx,[ComPort]
|
||||
add dx,3
|
||||
mov al,00000011b
|
||||
out dx,al
|
||||
|
||||
; Set Normal Modem functioning, User2 bit, and DTR
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
mov al,00001011b
|
||||
out dx,al
|
||||
|
||||
; Enable IRQ
|
||||
xor dh,dh
|
||||
mov dl,[PICMaskPm] ; Output to IRQ PIC Mask Port
|
||||
mov cl,[ComIRQ] ; Get proper bit
|
||||
and cl,07h
|
||||
mov al,01h
|
||||
shl al,cl
|
||||
not al ; Complement since clear bit = enable
|
||||
mov bl,al
|
||||
in al,dx ; input to preserve other bits
|
||||
and al,bl
|
||||
xor al,al
|
||||
out dx,al
|
||||
|
||||
; Enable interrupt to execute only on data available
|
||||
mov dx,[ComPort]
|
||||
inc dx
|
||||
mov al,00000001b
|
||||
out dx,al
|
||||
sti
|
||||
|
||||
; Write baudrate
|
||||
mov dx,[ComPort]
|
||||
add dx,3
|
||||
in al,dx
|
||||
or al,10000000b
|
||||
out dx,al
|
||||
mov eax,[BaudRate]
|
||||
mov ax,[BRateSel+eax*2]
|
||||
mov dx,[ComPort]
|
||||
inc dx
|
||||
push eax
|
||||
mov al,ah
|
||||
out dx,al
|
||||
pop eax
|
||||
dec dx
|
||||
out dx,al
|
||||
mov dx,[ComPort]
|
||||
add dx,3
|
||||
in al,dx
|
||||
and al,01111111b
|
||||
out dx,al
|
||||
|
||||
; Initialize 16550A UART chip
|
||||
mov dx,[ComPort]
|
||||
add dx,2
|
||||
mov al,0C7h
|
||||
out dx,al
|
||||
nop
|
||||
nop
|
||||
in al,dx
|
||||
mov byte[UartType],1
|
||||
test al,40h
|
||||
jnz .passed16550a
|
||||
xor al,al
|
||||
out dx,al
|
||||
mov byte[UartType],0
|
||||
.passed16550a
|
||||
ret
|
||||
|
||||
InitFossil:
|
||||
xor edx,edx
|
||||
mov dl,[ComNum]
|
||||
dec dl
|
||||
mov [PortNum],dx
|
||||
mov byte[cantinitmodem],0
|
||||
mov byte[UartType],2
|
||||
mov ah,04h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
cmp ax,1954h
|
||||
jne .notsuccess
|
||||
xor ah,ah
|
||||
mov al,00000011b ; 19200 baud, 81N
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
ret
|
||||
.notsuccess
|
||||
mov byte[cantinitmodem],1
|
||||
ret
|
||||
|
||||
modemhandler:
|
||||
push ds
|
||||
push eax
|
||||
mov ax,[cs:dssel]
|
||||
mov ds,ax
|
||||
push edx
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
in al,dx
|
||||
and al,11111101b
|
||||
out dx,al
|
||||
|
||||
.next
|
||||
mov dx,[ComPort]
|
||||
in al,dx
|
||||
mov edx,[modemtail]
|
||||
mov [modembuffer+edx],al
|
||||
inc dword[modemtail]
|
||||
and dword[modemtail],2047
|
||||
mov dx,[ComPort]
|
||||
add dx,2
|
||||
in al,dx
|
||||
test al,1
|
||||
jz .next
|
||||
|
||||
mov al,20h
|
||||
out 20h,al
|
||||
|
||||
cmp byte[ComIRQ],7
|
||||
jbe .nohighirq
|
||||
mov al,20h
|
||||
out 0A0h,al
|
||||
.nohighirq
|
||||
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
in al,dx
|
||||
or al,00000010b
|
||||
out dx,al
|
||||
|
||||
pop edx
|
||||
pop eax
|
||||
pop ds
|
||||
iretd
|
||||
|
||||
NEWSYM ModemClearBuffer
|
||||
mov dword[modemhead],0
|
||||
mov dword[modemtail],0
|
||||
ret
|
||||
|
||||
NEWSYM modembuffer, times 2048 db 0
|
||||
NEWSYM modemhead, dd 0
|
||||
NEWSYM modemtail, dd 0
|
||||
|
||||
NEWSYM DeInitModem
|
||||
cmp byte[ModemInited],1
|
||||
je .okaydeinit
|
||||
ret
|
||||
.okaydeinit
|
||||
mov byte[ModemInited],0
|
||||
cmp byte[UartType],2
|
||||
je near DeInitFossil
|
||||
cli
|
||||
mov dx,[ComPort]
|
||||
add dx,2
|
||||
xor al,al
|
||||
out dx,al
|
||||
|
||||
xor dh,dh
|
||||
mov dl,[PICMaskPm]
|
||||
mov cl,[ComIRQ]
|
||||
and cl,07h
|
||||
mov al,01h
|
||||
shl al,cl
|
||||
mov bl,al
|
||||
in al,dx
|
||||
or al,bl
|
||||
xor al,al
|
||||
out dx,al
|
||||
mov dx,[ComPort]
|
||||
inc dx
|
||||
mov al,00h
|
||||
out dx,al
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
out dx,al
|
||||
|
||||
mov cx,[oldhandmodems]
|
||||
mov edx,[oldhandmodemo]
|
||||
mov ax,205h
|
||||
mov bl,[ComInt]
|
||||
int 31h
|
||||
sti
|
||||
ret
|
||||
|
||||
DeInitFossil:
|
||||
mov byte[cantinitmodem],0
|
||||
jne .nodeinit
|
||||
mov ax,0600h
|
||||
mov dx,[PortNum]
|
||||
int 14h ; Lower DTR
|
||||
mov ah,05h
|
||||
mov dx,[PortNum]
|
||||
int 14h
|
||||
.nodeinit
|
||||
ret
|
||||
|
||||
NEWSYM DeInitModemC
|
||||
cmp byte[ModemInited],1
|
||||
je .okaydeinit
|
||||
ret
|
||||
.okaydeinit
|
||||
cmp byte[UartType],2
|
||||
je near DeInitFossil
|
||||
cli
|
||||
mov al,00h
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
out dx,al
|
||||
|
||||
mov al,13
|
||||
mov dx,[ComPort]
|
||||
out dx,al
|
||||
|
||||
mov ecx,16384
|
||||
call delay
|
||||
|
||||
out dx,al
|
||||
|
||||
mov al,00001001b
|
||||
mov dx,[ComPort]
|
||||
add dx,4
|
||||
out dx,al
|
||||
sti
|
||||
ret
|
||||
|
||||
|
||||
@@ -1,226 +1,225 @@
|
||||
;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.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM SidewinderFix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%macro ParityCheckSW 1
|
||||
mov ecx,ebx
|
||||
xor cl,ch
|
||||
jpe %%ParChkSW
|
||||
mov [%1],ebx
|
||||
%%ParChkSW:
|
||||
%endmacro
|
||||
|
||||
section .data
|
||||
gDump times 256 db 0
|
||||
bDump times 128 db 0
|
||||
NEWSYM _SW1, dd 0
|
||||
NEWSYM _SW2, dd 0
|
||||
NEWSYM _SW3, dd 0
|
||||
NEWSYM _SW4, dd 0
|
||||
NEWSYM _SWCount, dd 0
|
||||
|
||||
section .text
|
||||
NEWSYM _readSideWinder
|
||||
pushad
|
||||
|
||||
mov ecx,200
|
||||
mov ebx,gDump
|
||||
|
||||
cli
|
||||
cmp byte[SidewinderFix],0
|
||||
je .write
|
||||
out dx,al
|
||||
.write
|
||||
GetSWDataLoop:
|
||||
cmp byte[SidewinderFix],0
|
||||
jne .nowrite
|
||||
out dx,al
|
||||
.nowrite
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
in al,dx
|
||||
mov [ebx],al
|
||||
inc ebx
|
||||
dec ecx
|
||||
jnz GetSWDataLoop
|
||||
sti
|
||||
|
||||
xor ebx,ebx
|
||||
xor ecx,ecx
|
||||
xor edi,edi
|
||||
mov esi,1
|
||||
|
||||
FindCycle:
|
||||
mov al,[gDump+edi]
|
||||
inc edi
|
||||
cmp edi,200
|
||||
je SMWError
|
||||
test al,00010000b
|
||||
jnz WMFCS1
|
||||
xor ecx,ecx
|
||||
jmp FindCycle
|
||||
WMFCS1:
|
||||
inc ecx
|
||||
cmp ecx,15
|
||||
jne FindCycle
|
||||
|
||||
xor ebp,ebp
|
||||
|
||||
FindStrobeLow:
|
||||
mov al,[gDump+edi]
|
||||
inc edi
|
||||
cmp edi,200
|
||||
je SMWError
|
||||
test al,00010000b
|
||||
jnz FindStrobeLow
|
||||
xor ecx,ecx
|
||||
|
||||
FindStrobeHigh:
|
||||
inc ecx
|
||||
cmp ecx,15
|
||||
je SWModeCheck
|
||||
mov al,[gDump+edi]
|
||||
inc edi
|
||||
cmp edi,200
|
||||
je SMWError
|
||||
test al,00010000b
|
||||
jz FindStrobeHigh
|
||||
|
||||
mov [bDump+ebp],al
|
||||
inc ebp
|
||||
jmp FindStrobeLow
|
||||
|
||||
SMWDone:
|
||||
popad
|
||||
mov eax,0
|
||||
ret
|
||||
|
||||
SMWError:
|
||||
popad
|
||||
mov eax,1
|
||||
ret
|
||||
|
||||
SWModeCheck:
|
||||
cmp ebp,5
|
||||
je near ModeB1
|
||||
cmp ebp,15
|
||||
je near ModeA1
|
||||
cmp ebp,10
|
||||
je near ModeB2
|
||||
cmp ebp,30
|
||||
je near ModeA2
|
||||
cmp ebp,45
|
||||
je near ModeA3
|
||||
cmp ebp,20
|
||||
je near ModeB4
|
||||
cmp ebp,60
|
||||
je near ModeA4
|
||||
jmp short SMWError
|
||||
|
||||
ModeA1:
|
||||
cmp dword [_SWCount],3
|
||||
je near ModeB3
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW _SW1
|
||||
jmp SMWDone
|
||||
|
||||
ModeA4:
|
||||
mov ebp,45
|
||||
call DoModeA
|
||||
ParityCheckSW _SW4
|
||||
ModeA3:
|
||||
mov ebp,30
|
||||
call DoModeA
|
||||
ParityCheckSW _SW3
|
||||
ModeA2:
|
||||
mov ebp,15
|
||||
call DoModeA
|
||||
ParityCheckSW _SW2
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW _SW1
|
||||
jmp SMWDone
|
||||
|
||||
ModeB4:
|
||||
mov ebp,15
|
||||
call DoModeB
|
||||
ParityCheckSW _SW4
|
||||
ModeB3:
|
||||
mov ebp,10
|
||||
call DoModeB
|
||||
ParityCheckSW _SW3
|
||||
ModeB2:
|
||||
mov ebp,5
|
||||
call DoModeB
|
||||
ParityCheckSW _SW2
|
||||
ModeB1:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW _SW1
|
||||
jmp SMWDone
|
||||
|
||||
DoModeB:
|
||||
xor ebx,ebx
|
||||
mov eax,2
|
||||
mov ecx,5
|
||||
add ebp,bDump
|
||||
ModeBLoop:
|
||||
test byte [ebp],00100000b
|
||||
jnz $+4
|
||||
or ebx,eax
|
||||
shl eax,1
|
||||
test byte [ebp],01000000b
|
||||
jnz $+4
|
||||
or ebx,eax
|
||||
shl eax,1
|
||||
test byte [ebp],10000000b
|
||||
jnz $+4
|
||||
or ebx,eax
|
||||
shl eax,1
|
||||
inc ebp
|
||||
dec ecx
|
||||
jnz ModeBLoop
|
||||
ret
|
||||
|
||||
DoModeA:
|
||||
xor ebx,ebx
|
||||
mov eax,2
|
||||
mov ecx,15
|
||||
add ebp,bDump
|
||||
ModeALoop:
|
||||
test byte [ebp],00100000b
|
||||
jnz $+4
|
||||
or ebx,eax
|
||||
shl eax,1
|
||||
inc ebp
|
||||
dec ecx
|
||||
jnz ModeALoop
|
||||
ret
|
||||
|
||||
;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.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM SidewinderFix
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%macro ParityCheckSW 1
|
||||
mov ecx,ebx
|
||||
xor cl,ch
|
||||
jpe %%ParChkSW
|
||||
mov [%1],ebx
|
||||
%%ParChkSW:
|
||||
%endmacro
|
||||
|
||||
section .data
|
||||
gDump times 256 db 0
|
||||
bDump times 128 db 0
|
||||
NEWSYM _SW1, dd 0
|
||||
NEWSYM _SW2, dd 0
|
||||
NEWSYM _SW3, dd 0
|
||||
NEWSYM _SW4, dd 0
|
||||
NEWSYM _SWCount, dd 0
|
||||
|
||||
section .text
|
||||
NEWSYM _readSideWinder
|
||||
pushad
|
||||
|
||||
mov ecx,200
|
||||
mov ebx,gDump
|
||||
|
||||
cli
|
||||
cmp byte[SidewinderFix],0
|
||||
je .write
|
||||
out dx,al
|
||||
.write
|
||||
GetSWDataLoop:
|
||||
cmp byte[SidewinderFix],0
|
||||
jne .nowrite
|
||||
out dx,al
|
||||
.nowrite
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
in al,dx
|
||||
mov [ebx],al
|
||||
inc ebx
|
||||
dec ecx
|
||||
jnz GetSWDataLoop
|
||||
sti
|
||||
|
||||
xor ebx,ebx
|
||||
xor ecx,ecx
|
||||
xor edi,edi
|
||||
mov esi,1
|
||||
|
||||
FindCycle:
|
||||
mov al,[gDump+edi]
|
||||
inc edi
|
||||
cmp edi,200
|
||||
je SMWError
|
||||
test al,00010000b
|
||||
jnz WMFCS1
|
||||
xor ecx,ecx
|
||||
jmp FindCycle
|
||||
WMFCS1:
|
||||
inc ecx
|
||||
cmp ecx,15
|
||||
jne FindCycle
|
||||
|
||||
xor ebp,ebp
|
||||
|
||||
FindStrobeLow:
|
||||
mov al,[gDump+edi]
|
||||
inc edi
|
||||
cmp edi,200
|
||||
je SMWError
|
||||
test al,00010000b
|
||||
jnz FindStrobeLow
|
||||
xor ecx,ecx
|
||||
|
||||
FindStrobeHigh:
|
||||
inc ecx
|
||||
cmp ecx,15
|
||||
je SWModeCheck
|
||||
mov al,[gDump+edi]
|
||||
inc edi
|
||||
cmp edi,200
|
||||
je SMWError
|
||||
test al,00010000b
|
||||
jz FindStrobeHigh
|
||||
|
||||
mov [bDump+ebp],al
|
||||
inc ebp
|
||||
jmp FindStrobeLow
|
||||
|
||||
SMWDone:
|
||||
popad
|
||||
mov eax,0
|
||||
ret
|
||||
|
||||
SMWError:
|
||||
popad
|
||||
mov eax,1
|
||||
ret
|
||||
|
||||
SWModeCheck:
|
||||
cmp ebp,5
|
||||
je near ModeB1
|
||||
cmp ebp,15
|
||||
je near ModeA1
|
||||
cmp ebp,10
|
||||
je near ModeB2
|
||||
cmp ebp,30
|
||||
je near ModeA2
|
||||
cmp ebp,45
|
||||
je near ModeA3
|
||||
cmp ebp,20
|
||||
je near ModeB4
|
||||
cmp ebp,60
|
||||
je near ModeA4
|
||||
jmp short SMWError
|
||||
|
||||
ModeA1:
|
||||
cmp dword [_SWCount],3
|
||||
je near ModeB3
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW _SW1
|
||||
jmp SMWDone
|
||||
|
||||
ModeA4:
|
||||
mov ebp,45
|
||||
call DoModeA
|
||||
ParityCheckSW _SW4
|
||||
ModeA3:
|
||||
mov ebp,30
|
||||
call DoModeA
|
||||
ParityCheckSW _SW3
|
||||
ModeA2:
|
||||
mov ebp,15
|
||||
call DoModeA
|
||||
ParityCheckSW _SW2
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW _SW1
|
||||
jmp SMWDone
|
||||
|
||||
ModeB4:
|
||||
mov ebp,15
|
||||
call DoModeB
|
||||
ParityCheckSW _SW4
|
||||
ModeB3:
|
||||
mov ebp,10
|
||||
call DoModeB
|
||||
ParityCheckSW _SW3
|
||||
ModeB2:
|
||||
mov ebp,5
|
||||
call DoModeB
|
||||
ParityCheckSW _SW2
|
||||
ModeB1:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW _SW1
|
||||
jmp SMWDone
|
||||
|
||||
DoModeB:
|
||||
xor ebx,ebx
|
||||
mov eax,2
|
||||
mov ecx,5
|
||||
add ebp,bDump
|
||||
ModeBLoop:
|
||||
test byte [ebp],00100000b
|
||||
jnz $+4
|
||||
or ebx,eax
|
||||
shl eax,1
|
||||
test byte [ebp],01000000b
|
||||
jnz $+4
|
||||
or ebx,eax
|
||||
shl eax,1
|
||||
test byte [ebp],10000000b
|
||||
jnz $+4
|
||||
or ebx,eax
|
||||
shl eax,1
|
||||
inc ebp
|
||||
dec ecx
|
||||
jnz ModeBLoop
|
||||
ret
|
||||
|
||||
DoModeA:
|
||||
xor ebx,ebx
|
||||
mov eax,2
|
||||
mov ecx,15
|
||||
add ebp,bDump
|
||||
ModeALoop:
|
||||
test byte [ebp],00100000b
|
||||
jnz $+4
|
||||
or ebx,eax
|
||||
shl eax,1
|
||||
inc ebp
|
||||
dec ecx
|
||||
jnz ModeALoop
|
||||
ret
|
||||
|
||||
@@ -1,330 +1,329 @@
|
||||
;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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;32-bit DOS-Mode driver for the Microsoft Sidewinder Gamepad
|
||||
;Multi-SW Version 1.5
|
||||
;(C) 1997, 1998 Robert William Grubbs, All Rights Reserved
|
||||
;Latest revision 1/20/98
|
||||
; Driver Source code Include file
|
||||
|
||||
;C-linkable, rewrote decoder -sardu
|
||||
|
||||
;Flat memory mode (Protected mode extender required! Tested with DOS32)
|
||||
;Tested with TASM 4.0+
|
||||
|
||||
|
||||
SW1 dd 0 ;SW #1's button status
|
||||
SW2 dd 0 ;SW #2's button status
|
||||
SW3 dd 0 ;SW #3's button status
|
||||
SW4 dd 0 ;SW #4's button status
|
||||
SWCount dd 1 ;Tell the driver how many sidewinders are present
|
||||
SWSetup dd 0 ;Tell the driver what polling mode to use
|
||||
; 0=Interrupts disabled, Multiple OUT statements
|
||||
; 1=Interrupts disabled, Single OUT statement
|
||||
; 2=Interrupts enabled, Multiple OUT statements
|
||||
; 3=Interrupts enabled, Single OUT statement
|
||||
|
||||
gDump times 100h db 0 ;SW Status dump buffer (space for 256 bytes, uses 200)
|
||||
bDump times 80h db 0 ;buffer to hold button data (Modes A and B, all SW)
|
||||
|
||||
;This macro calculates parity for the buttons and compares it to the SW's
|
||||
; parity bit. If they don't match, the button data is discarded.
|
||||
%macro ParityCheckSW 1
|
||||
mov ecx,ebx ;duplicate button status
|
||||
xor cl,ch ;
|
||||
jpe %%ParChkSW
|
||||
mov [%1],ebx ;update button status for SW #n
|
||||
%%ParChkSW ;done
|
||||
%endmacro
|
||||
|
||||
;The main subroutine; this is the important one; bow down before it
|
||||
;IN: None
|
||||
;Out: SWx=buttons (bit 0=null 1=up 2=dn 3=rt 4=lt 5=A 6=B 7=C 8=X)
|
||||
; (9=Y 10=Z 11=L 12=R 13=St 14=M 15=Parity)
|
||||
;No registers destroyed
|
||||
|
||||
readSideWinder:
|
||||
pushad
|
||||
|
||||
mov ecx,200 ;dump buffer fill size
|
||||
mov ebx,gDump ;initial dump pointer
|
||||
mov edx,0201h ;joystick port
|
||||
|
||||
cmp dword[SWSetup],0
|
||||
jne NotSW0
|
||||
cli ;Disable interrupts (required to avoid jitter)
|
||||
GetSWDataLoop: ;
|
||||
out dx,al ;trigger joystick port
|
||||
in al,dx ;read SW status byte
|
||||
mov [ebx],al ;dump status byte
|
||||
inc ebx ;increment dump pointer
|
||||
dec ecx
|
||||
jnz GetSWDataLoop
|
||||
sti ;Re-enable interrupts
|
||||
jmp SWPollDone
|
||||
|
||||
NotSW0:
|
||||
cmp dword[SWSetup],1
|
||||
jne NotSW1
|
||||
cli ;Disable interrupts (required to avoid jitter)
|
||||
out dx,al ;trigger joystick port
|
||||
GetSWDataLoop1: ;
|
||||
in al,dx ;read SW status byte
|
||||
mov [ebx],al ;dump status byte
|
||||
inc ebx ;increment dump pointer
|
||||
dec ecx
|
||||
jnz GetSWDataLoop1
|
||||
sti ;Re-enable interrupts
|
||||
jmp SWPollDone
|
||||
|
||||
NotSW1:
|
||||
cmp dword[SWSetup],2
|
||||
jne NotSW2
|
||||
GetSWDataLoop2: ;
|
||||
out dx,al ;trigger joystick port
|
||||
in al,dx ;read SW status byte
|
||||
mov [ebx],al ;dump status byte
|
||||
inc ebx ;increment dump pointer
|
||||
dec ecx
|
||||
jnz GetSWDataLoop2
|
||||
jmp SWPollDone
|
||||
|
||||
NotSW2:
|
||||
;default all others to SWStatus=3
|
||||
out dx,al ;trigger joystick port
|
||||
GetSWDataLoop3: ;
|
||||
in al,dx ;read SW status byte
|
||||
mov [ebx],al ;dump status byte
|
||||
inc ebx ;increment dump pointer
|
||||
dec ecx
|
||||
jnz GetSWDataLoop3
|
||||
|
||||
SWPollDone:
|
||||
|
||||
mov ecx,0 ;tick count
|
||||
mov esi,1 ;initialize output mask
|
||||
mov ebx,0 ;initialize output
|
||||
mov edi,0 ;initialize input pointer
|
||||
|
||||
;My current method of cycle detection is to look for 15 highs in a row on
|
||||
; the strobe line. Cycle ends is detected by 15 lows in a row.
|
||||
;Mode A has 15 strobes in a cycle, Mode B has 5.
|
||||
; Note that the 15 highs/lows for cycle detection may be too high for slow
|
||||
; machines. I havn't seen a problem yet, but it may exist...
|
||||
;Multiple Sidewinder data complicates things. Each additional SW tags
|
||||
; another set of strobes to the cycle, 5 more in mode B, 15 more in mode A.
|
||||
; Detecting extra SW gamepad data is fairly simple: count the number of
|
||||
; strobes. If it is a multiple of 5, you're in mode B and can divide by 5
|
||||
; to get the total number of gamepads. If it's divisible by 15, use mode A.
|
||||
; However, this method cannot distinguish between mode A for one SW and mode
|
||||
; B for three SW. In that case, the SWCount variable must be set correctly.
|
||||
|
||||
FindCycle:
|
||||
mov al,[gDump+edi] ;get next status byte
|
||||
inc edi ;increment input pointer
|
||||
cmp edi,200 ;test for end of status block
|
||||
je SWNoFind ;if it's the end, quit sub with error
|
||||
test al,00010000b ;Check for nonzero bits
|
||||
jnz WMFCS1 ;
|
||||
xor ecx,ecx ;if zero, reset tick count
|
||||
jmp FindCycle ;can't be pre-cycle
|
||||
WMFCS1: ;Possibly pre-cycle
|
||||
inc ecx ;increment tick count
|
||||
cmp ecx,15 ;test for sufficient ticks for cycle start
|
||||
jne FindCycle ;if insufficient, get next status byte
|
||||
;Yippie! it found a (probable) cycle!
|
||||
|
||||
mov ebp,0 ;initialize bDump index (strobe count)
|
||||
|
||||
FindStrobeLow: ;Search for leading edge of data strobe
|
||||
mov al,[gDump+edi] ;get next status byte
|
||||
inc edi ;increment input pointer
|
||||
cmp edi,200 ;test for end of status block
|
||||
je SWNoFind ;if it's the end, quit sub with error
|
||||
test al,00010000b ;get "strobe" bit
|
||||
jnz SHORT FindStrobeLow ;if it isn't zero, we're not there yet
|
||||
xor ecx,ecx ;initialize cycle end test count
|
||||
|
||||
FindStrobeHigh:
|
||||
inc ecx ;increment zero count
|
||||
cmp ecx,0fh ;is it 15?
|
||||
je SWModeCheck ;if so, goto mode check
|
||||
mov al,[gDump+edi] ;get next status byte
|
||||
inc edi ;increment input pointer
|
||||
cmp edi,200 ;test for end of status block
|
||||
je SWNoFind ;if it's the end, quit sub with error
|
||||
test al,00010000b ;get "strobe" bit
|
||||
jz FindStrobeHigh ;if it is zero, we're not there yet
|
||||
;if not, we're there! data bit is valid (probably)
|
||||
mov [bDump+ebp],al ;preserve data for button decoding
|
||||
inc ebp ;increment strobe count/bDump index
|
||||
jmp FindStrobeLow ;wait for the next button
|
||||
|
||||
SMWDone:
|
||||
SWNoFind:
|
||||
popad
|
||||
ret ;return to calling procedure
|
||||
|
||||
SWModeCheck: ;Check strobe count to identify mode and # of SW
|
||||
cmp ebp,15 ;Is it Mode A with 1 Sidewinder or B with 3?
|
||||
je ModeA1
|
||||
cmp ebp,5 ;Is it Mode B with 1 Sidewinders?
|
||||
je ModeB1
|
||||
cmp ebp,30 ;Is it Mode A with 2 Sidewinders?
|
||||
je ModeA2
|
||||
cmp ebp,10 ;Is it Mode B with 2 Sidewinders?
|
||||
je near ModeB2
|
||||
cmp ebp,45 ;Is it Mode A with 3 Sidewinders?
|
||||
je near ModeA3
|
||||
cmp ebp,60 ;Is it Mode A with 4 Sidewinders?
|
||||
je near ModeA4
|
||||
cmp ebp,20 ;Is it Mode B with 4 Sidewinders?
|
||||
je near ModeB4
|
||||
jmp SHORT SWNoFind ;Any other # of strobes is invalid data
|
||||
|
||||
ModeB1:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW SW1
|
||||
jmp SMWDone
|
||||
|
||||
ModeA1:
|
||||
cmp dword [SWCount],3
|
||||
je near ModeB3
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW SW1
|
||||
jmp SMWDone
|
||||
|
||||
ModeA2:
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW SW1
|
||||
mov ebp,15
|
||||
call DoModeA
|
||||
ParityCheckSW SW2
|
||||
jmp SMWDone
|
||||
|
||||
ModeA3:
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW SW1
|
||||
mov ebp,15
|
||||
call DoModeA
|
||||
ParityCheckSW SW2
|
||||
mov ebp,30
|
||||
call DoModeA
|
||||
ParityCheckSW SW3
|
||||
jmp SMWDone
|
||||
|
||||
ModeA4:
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW SW1
|
||||
mov ebp,15
|
||||
call DoModeA
|
||||
ParityCheckSW SW2
|
||||
mov ebp,30
|
||||
call DoModeA
|
||||
ParityCheckSW SW3
|
||||
mov ebp,45
|
||||
call DoModeA
|
||||
ParityCheckSW SW4
|
||||
jmp SMWDone
|
||||
|
||||
ModeB2:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW SW1
|
||||
mov ebp,5
|
||||
call DoModeB
|
||||
ParityCheckSW SW2
|
||||
jmp SMWDone
|
||||
|
||||
ModeB3:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW SW1
|
||||
mov ebp,5
|
||||
call DoModeB
|
||||
ParityCheckSW SW2
|
||||
mov ebp,10
|
||||
call DoModeB
|
||||
ParityCheckSW SW3
|
||||
jmp SMWDone
|
||||
|
||||
ModeB4:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW SW1
|
||||
mov ebp,5
|
||||
call DoModeB
|
||||
ParityCheckSW SW2
|
||||
mov ebp,10
|
||||
call DoModeB
|
||||
ParityCheckSW SW3
|
||||
mov ebp,15
|
||||
call DoModeB
|
||||
ParityCheckSW SW4
|
||||
jmp SMWDone
|
||||
ENDP
|
||||
|
||||
%macro SWRepeat 1
|
||||
mov al,[bDump+ebp+%1]
|
||||
shr al,5 ;get upper 3 bits
|
||||
shl eax,1+3*%1 ;shift into place
|
||||
or ebx,eax ;or into output
|
||||
%endmacro
|
||||
|
||||
DoModeB:
|
||||
xor ebx,ebx ;Initialize output
|
||||
xor eax,eax
|
||||
|
||||
SWRepeat 0
|
||||
SWRepeat 1
|
||||
SWRepeat 2
|
||||
SWRepeat 3
|
||||
SWRepeat 4
|
||||
|
||||
xor ebx,0FFFEh
|
||||
ret
|
||||
|
||||
DoModeA:
|
||||
xor ebx,ebx ;Clear output
|
||||
mov ecx,15 ;bit count
|
||||
|
||||
ALP:
|
||||
mov al,[bDump+ebp]
|
||||
inc ebp
|
||||
shl al,3
|
||||
rcr ebx,1
|
||||
dec ecx
|
||||
jg ALP
|
||||
|
||||
shr ebx,16
|
||||
xor ebx,0FFFEh
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;32-bit DOS-Mode driver for the Microsoft Sidewinder Gamepad
|
||||
;Multi-SW Version 1.5
|
||||
;(C) 1997, 1998 Robert William Grubbs, All Rights Reserved
|
||||
;Latest revision 1/20/98
|
||||
; Driver Source code Include file
|
||||
|
||||
;C-linkable, rewrote decoder -sardu
|
||||
|
||||
;Flat memory mode (Protected mode extender required! Tested with DOS32)
|
||||
;Tested with TASM 4.0+
|
||||
|
||||
|
||||
SW1 dd 0 ;SW #1's button status
|
||||
SW2 dd 0 ;SW #2's button status
|
||||
SW3 dd 0 ;SW #3's button status
|
||||
SW4 dd 0 ;SW #4's button status
|
||||
SWCount dd 1 ;Tell the driver how many sidewinders are present
|
||||
SWSetup dd 0 ;Tell the driver what polling mode to use
|
||||
; 0=Interrupts disabled, Multiple OUT statements
|
||||
; 1=Interrupts disabled, Single OUT statement
|
||||
; 2=Interrupts enabled, Multiple OUT statements
|
||||
; 3=Interrupts enabled, Single OUT statement
|
||||
|
||||
gDump times 100h db 0 ;SW Status dump buffer (space for 256 bytes, uses 200)
|
||||
bDump times 80h db 0 ;buffer to hold button data (Modes A and B, all SW)
|
||||
|
||||
;This macro calculates parity for the buttons and compares it to the SW's
|
||||
; parity bit. If they don't match, the button data is discarded.
|
||||
%macro ParityCheckSW 1
|
||||
mov ecx,ebx ;duplicate button status
|
||||
xor cl,ch ;
|
||||
jpe %%ParChkSW
|
||||
mov [%1],ebx ;update button status for SW #n
|
||||
%%ParChkSW ;done
|
||||
%endmacro
|
||||
|
||||
;The main subroutine; this is the important one; bow down before it
|
||||
;IN: None
|
||||
;Out: SWx=buttons (bit 0=null 1=up 2=dn 3=rt 4=lt 5=A 6=B 7=C 8=X)
|
||||
; (9=Y 10=Z 11=L 12=R 13=St 14=M 15=Parity)
|
||||
;No registers destroyed
|
||||
|
||||
readSideWinder:
|
||||
pushad
|
||||
|
||||
mov ecx,200 ;dump buffer fill size
|
||||
mov ebx,gDump ;initial dump pointer
|
||||
mov edx,0201h ;joystick port
|
||||
|
||||
cmp dword[SWSetup],0
|
||||
jne NotSW0
|
||||
cli ;Disable interrupts (required to avoid jitter)
|
||||
GetSWDataLoop: ;
|
||||
out dx,al ;trigger joystick port
|
||||
in al,dx ;read SW status byte
|
||||
mov [ebx],al ;dump status byte
|
||||
inc ebx ;increment dump pointer
|
||||
dec ecx
|
||||
jnz GetSWDataLoop
|
||||
sti ;Re-enable interrupts
|
||||
jmp SWPollDone
|
||||
|
||||
NotSW0:
|
||||
cmp dword[SWSetup],1
|
||||
jne NotSW1
|
||||
cli ;Disable interrupts (required to avoid jitter)
|
||||
out dx,al ;trigger joystick port
|
||||
GetSWDataLoop1: ;
|
||||
in al,dx ;read SW status byte
|
||||
mov [ebx],al ;dump status byte
|
||||
inc ebx ;increment dump pointer
|
||||
dec ecx
|
||||
jnz GetSWDataLoop1
|
||||
sti ;Re-enable interrupts
|
||||
jmp SWPollDone
|
||||
|
||||
NotSW1:
|
||||
cmp dword[SWSetup],2
|
||||
jne NotSW2
|
||||
GetSWDataLoop2: ;
|
||||
out dx,al ;trigger joystick port
|
||||
in al,dx ;read SW status byte
|
||||
mov [ebx],al ;dump status byte
|
||||
inc ebx ;increment dump pointer
|
||||
dec ecx
|
||||
jnz GetSWDataLoop2
|
||||
jmp SWPollDone
|
||||
|
||||
NotSW2:
|
||||
;default all others to SWStatus=3
|
||||
out dx,al ;trigger joystick port
|
||||
GetSWDataLoop3: ;
|
||||
in al,dx ;read SW status byte
|
||||
mov [ebx],al ;dump status byte
|
||||
inc ebx ;increment dump pointer
|
||||
dec ecx
|
||||
jnz GetSWDataLoop3
|
||||
|
||||
SWPollDone:
|
||||
|
||||
mov ecx,0 ;tick count
|
||||
mov esi,1 ;initialize output mask
|
||||
mov ebx,0 ;initialize output
|
||||
mov edi,0 ;initialize input pointer
|
||||
|
||||
;My current method of cycle detection is to look for 15 highs in a row on
|
||||
; the strobe line. Cycle ends is detected by 15 lows in a row.
|
||||
;Mode A has 15 strobes in a cycle, Mode B has 5.
|
||||
; Note that the 15 highs/lows for cycle detection may be too high for slow
|
||||
; machines. I havn't seen a problem yet, but it may exist...
|
||||
;Multiple Sidewinder data complicates things. Each additional SW tags
|
||||
; another set of strobes to the cycle, 5 more in mode B, 15 more in mode A.
|
||||
; Detecting extra SW gamepad data is fairly simple: count the number of
|
||||
; strobes. If it is a multiple of 5, you're in mode B and can divide by 5
|
||||
; to get the total number of gamepads. If it's divisible by 15, use mode A.
|
||||
; However, this method cannot distinguish between mode A for one SW and mode
|
||||
; B for three SW. In that case, the SWCount variable must be set correctly.
|
||||
|
||||
FindCycle:
|
||||
mov al,[gDump+edi] ;get next status byte
|
||||
inc edi ;increment input pointer
|
||||
cmp edi,200 ;test for end of status block
|
||||
je SWNoFind ;if it's the end, quit sub with error
|
||||
test al,00010000b ;Check for nonzero bits
|
||||
jnz WMFCS1 ;
|
||||
xor ecx,ecx ;if zero, reset tick count
|
||||
jmp FindCycle ;can't be pre-cycle
|
||||
WMFCS1: ;Possibly pre-cycle
|
||||
inc ecx ;increment tick count
|
||||
cmp ecx,15 ;test for sufficient ticks for cycle start
|
||||
jne FindCycle ;if insufficient, get next status byte
|
||||
;Yippie! it found a (probable) cycle!
|
||||
|
||||
mov ebp,0 ;initialize bDump index (strobe count)
|
||||
|
||||
FindStrobeLow: ;Search for leading edge of data strobe
|
||||
mov al,[gDump+edi] ;get next status byte
|
||||
inc edi ;increment input pointer
|
||||
cmp edi,200 ;test for end of status block
|
||||
je SWNoFind ;if it's the end, quit sub with error
|
||||
test al,00010000b ;get "strobe" bit
|
||||
jnz SHORT FindStrobeLow ;if it isn't zero, we're not there yet
|
||||
xor ecx,ecx ;initialize cycle end test count
|
||||
|
||||
FindStrobeHigh:
|
||||
inc ecx ;increment zero count
|
||||
cmp ecx,0fh ;is it 15?
|
||||
je SWModeCheck ;if so, goto mode check
|
||||
mov al,[gDump+edi] ;get next status byte
|
||||
inc edi ;increment input pointer
|
||||
cmp edi,200 ;test for end of status block
|
||||
je SWNoFind ;if it's the end, quit sub with error
|
||||
test al,00010000b ;get "strobe" bit
|
||||
jz FindStrobeHigh ;if it is zero, we're not there yet
|
||||
;if not, we're there! data bit is valid (probably)
|
||||
mov [bDump+ebp],al ;preserve data for button decoding
|
||||
inc ebp ;increment strobe count/bDump index
|
||||
jmp FindStrobeLow ;wait for the next button
|
||||
|
||||
SMWDone:
|
||||
SWNoFind:
|
||||
popad
|
||||
ret ;return to calling procedure
|
||||
|
||||
SWModeCheck: ;Check strobe count to identify mode and # of SW
|
||||
cmp ebp,15 ;Is it Mode A with 1 Sidewinder or B with 3?
|
||||
je ModeA1
|
||||
cmp ebp,5 ;Is it Mode B with 1 Sidewinders?
|
||||
je ModeB1
|
||||
cmp ebp,30 ;Is it Mode A with 2 Sidewinders?
|
||||
je ModeA2
|
||||
cmp ebp,10 ;Is it Mode B with 2 Sidewinders?
|
||||
je near ModeB2
|
||||
cmp ebp,45 ;Is it Mode A with 3 Sidewinders?
|
||||
je near ModeA3
|
||||
cmp ebp,60 ;Is it Mode A with 4 Sidewinders?
|
||||
je near ModeA4
|
||||
cmp ebp,20 ;Is it Mode B with 4 Sidewinders?
|
||||
je near ModeB4
|
||||
jmp SHORT SWNoFind ;Any other # of strobes is invalid data
|
||||
|
||||
ModeB1:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW SW1
|
||||
jmp SMWDone
|
||||
|
||||
ModeA1:
|
||||
cmp dword [SWCount],3
|
||||
je near ModeB3
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW SW1
|
||||
jmp SMWDone
|
||||
|
||||
ModeA2:
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW SW1
|
||||
mov ebp,15
|
||||
call DoModeA
|
||||
ParityCheckSW SW2
|
||||
jmp SMWDone
|
||||
|
||||
ModeA3:
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW SW1
|
||||
mov ebp,15
|
||||
call DoModeA
|
||||
ParityCheckSW SW2
|
||||
mov ebp,30
|
||||
call DoModeA
|
||||
ParityCheckSW SW3
|
||||
jmp SMWDone
|
||||
|
||||
ModeA4:
|
||||
xor ebp,ebp
|
||||
call DoModeA
|
||||
ParityCheckSW SW1
|
||||
mov ebp,15
|
||||
call DoModeA
|
||||
ParityCheckSW SW2
|
||||
mov ebp,30
|
||||
call DoModeA
|
||||
ParityCheckSW SW3
|
||||
mov ebp,45
|
||||
call DoModeA
|
||||
ParityCheckSW SW4
|
||||
jmp SMWDone
|
||||
|
||||
ModeB2:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW SW1
|
||||
mov ebp,5
|
||||
call DoModeB
|
||||
ParityCheckSW SW2
|
||||
jmp SMWDone
|
||||
|
||||
ModeB3:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW SW1
|
||||
mov ebp,5
|
||||
call DoModeB
|
||||
ParityCheckSW SW2
|
||||
mov ebp,10
|
||||
call DoModeB
|
||||
ParityCheckSW SW3
|
||||
jmp SMWDone
|
||||
|
||||
ModeB4:
|
||||
xor ebp,ebp
|
||||
call DoModeB
|
||||
ParityCheckSW SW1
|
||||
mov ebp,5
|
||||
call DoModeB
|
||||
ParityCheckSW SW2
|
||||
mov ebp,10
|
||||
call DoModeB
|
||||
ParityCheckSW SW3
|
||||
mov ebp,15
|
||||
call DoModeB
|
||||
ParityCheckSW SW4
|
||||
jmp SMWDone
|
||||
ENDP
|
||||
|
||||
%macro SWRepeat 1
|
||||
mov al,[bDump+ebp+%1]
|
||||
shr al,5 ;get upper 3 bits
|
||||
shl eax,1+3*%1 ;shift into place
|
||||
or ebx,eax ;or into output
|
||||
%endmacro
|
||||
|
||||
DoModeB:
|
||||
xor ebx,ebx ;Initialize output
|
||||
xor eax,eax
|
||||
|
||||
SWRepeat 0
|
||||
SWRepeat 1
|
||||
SWRepeat 2
|
||||
SWRepeat 3
|
||||
SWRepeat 4
|
||||
|
||||
xor ebx,0FFFEh
|
||||
ret
|
||||
|
||||
DoModeA:
|
||||
xor ebx,ebx ;Clear output
|
||||
mov ecx,15 ;bit count
|
||||
|
||||
ALP:
|
||||
mov al,[bDump+ebp]
|
||||
inc ebp
|
||||
shl al,3
|
||||
rcr ebx,1
|
||||
dec ecx
|
||||
jg ALP
|
||||
|
||||
shr ebx,16
|
||||
xor ebx,0FFFEh
|
||||
ret
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,267 +1,267 @@
|
||||
//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.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef ZDOS
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define DWORD unsigned int
|
||||
#define BYTE unsigned char
|
||||
|
||||
FILE *FILEHANDLE[16];
|
||||
DWORD CurrentHandle=0;
|
||||
|
||||
|
||||
|
||||
// ZFileSystemInit
|
||||
// return 0
|
||||
|
||||
// ZOpenFile info :
|
||||
BYTE * ZOpenFileName;
|
||||
DWORD ZOpenMode;
|
||||
// Open modes : 0 read/write in
|
||||
// 1 write (create file, overwrite)
|
||||
// return file handle if success, 0xFFFFFFFF if error
|
||||
|
||||
// ZCloseFile info :
|
||||
DWORD ZCloseFileHandle;
|
||||
// return 0
|
||||
|
||||
// ZFileSeek info :
|
||||
DWORD ZFileSeekHandle;
|
||||
DWORD ZFileSeekPos;
|
||||
DWORD ZFileSeekMode; // 0 start, 1 end
|
||||
// return 0
|
||||
|
||||
// ZFileReadBlock info :
|
||||
BYTE * ZFileReadBlock;
|
||||
DWORD ZFileReadSize;
|
||||
DWORD ZFileReadHandle;
|
||||
// return 0
|
||||
|
||||
// ZFileWriteBlock info :
|
||||
BYTE * ZFileWriteBlock;
|
||||
DWORD ZFileWriteSize;
|
||||
DWORD ZFileWriteHandle;
|
||||
// return 0
|
||||
|
||||
// ZFileTell
|
||||
DWORD ZFileTellHandle;
|
||||
|
||||
// ZFileGetftime
|
||||
BYTE * ZFFTimeFName;
|
||||
DWORD ZFTimeHandle;
|
||||
DWORD ZFDate;
|
||||
DWORD ZFTime;
|
||||
|
||||
// MKDir/CHDir
|
||||
BYTE * MKPath;
|
||||
BYTE * CHPath;
|
||||
BYTE * RMPath;
|
||||
|
||||
// GetDir
|
||||
BYTE * DirName;
|
||||
DWORD DriveNumber;
|
||||
|
||||
// ZFileDelete
|
||||
BYTE * ZFileDelFName;
|
||||
// return current position
|
||||
|
||||
DWORD ZFileSystemInit()
|
||||
{
|
||||
CurrentHandle=0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD ZOpenFile()
|
||||
{
|
||||
if(ZOpenMode==0)
|
||||
{
|
||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb"))!=NULL)
|
||||
{
|
||||
CurrentHandle+=1;
|
||||
return(CurrentHandle-1);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
if(ZOpenMode==1)
|
||||
{
|
||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb"))!=NULL)
|
||||
{
|
||||
CurrentHandle+=1;
|
||||
return(CurrentHandle-1);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
if(ZOpenMode==2)
|
||||
{
|
||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b"))!=NULL)
|
||||
{
|
||||
CurrentHandle+=1;
|
||||
return(CurrentHandle-1);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
DWORD ZCloseFile()
|
||||
{
|
||||
fclose(FILEHANDLE[ZCloseFileHandle]);
|
||||
CurrentHandle-=1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD ZFileSeek()
|
||||
{
|
||||
if(ZFileSeekMode==0)
|
||||
{
|
||||
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_SET);
|
||||
return(0);
|
||||
}
|
||||
if(ZFileSeekMode==1)
|
||||
{
|
||||
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_END);
|
||||
return(0);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
DWORD ZFileRead()
|
||||
{
|
||||
return(fread(ZFileReadBlock,1,ZFileReadSize,FILEHANDLE[ZFileReadHandle]));
|
||||
}
|
||||
|
||||
|
||||
DWORD ZFileWrite()
|
||||
{
|
||||
if((fwrite(ZFileWriteBlock,1,ZFileWriteSize,FILEHANDLE[ZFileWriteHandle]))!=ZFileWriteSize) return(0xFFFFFFFF);
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD ZFileTell()
|
||||
{
|
||||
return(ftell(FILEHANDLE[ZFileTellHandle]));
|
||||
}
|
||||
|
||||
DWORD ZFileDelete()
|
||||
{
|
||||
return(remove(ZFileDelFName));
|
||||
}
|
||||
|
||||
|
||||
DWORD ZFileGetFTime()
|
||||
{
|
||||
_dos_open(ZFFTimeFName, 0,&ZFTimeHandle);
|
||||
_dos_getftime(ZFTimeHandle,&ZFDate,&ZFTime);
|
||||
_dos_close(ZFTimeHandle);
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD ZFileMKDir()
|
||||
{
|
||||
return(mkdir(MKPath));
|
||||
}
|
||||
|
||||
DWORD ZFileCHDir()
|
||||
{
|
||||
return(chdir(CHPath));
|
||||
}
|
||||
|
||||
DWORD ZFileRMDir()
|
||||
{
|
||||
return(rmdir(RMPath));
|
||||
}
|
||||
|
||||
DWORD ZFileGetDir()
|
||||
{
|
||||
return(getcwd(DirName,128));
|
||||
}
|
||||
|
||||
BYTE * ZFileFindPATH;
|
||||
DWORD ZFileFindATTRIB;
|
||||
DWORD DTALocPos;
|
||||
|
||||
//struct _find_t {
|
||||
// char reserved[21] __attribute__((packed));
|
||||
// unsigned char attrib __attribute__((packed));
|
||||
// unsigned short wr_time __attribute__((packed));
|
||||
// unsigned short wr_date __attribute__((packed));
|
||||
// unsigned long size __attribute__((packed));
|
||||
// char name[256] __attribute__((packed));
|
||||
//};
|
||||
|
||||
DWORD ZFileFindFirst()
|
||||
{
|
||||
return(_dos_findfirst(ZFileFindPATH,ZFileFindATTRIB,DTALocPos));
|
||||
}
|
||||
|
||||
DWORD ZFileFindNext()
|
||||
{
|
||||
return(_dos_findnext(DTALocPos));
|
||||
}
|
||||
|
||||
DWORD ZFileFindEnd() // for compatibility with windows later
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
//BYTE * DirName;
|
||||
//DWORD DriveNumber;
|
||||
|
||||
//unsigned int _dos_findfirst(char *_name, unsigned int _attr, struct _find_t *_result);
|
||||
//unsigned int _dos_findnext(struct _find_t *_result);
|
||||
|
||||
|
||||
DWORD GetTime()
|
||||
{
|
||||
|
||||
DWORD value;
|
||||
struct tm *newtime;
|
||||
time_t long_time;
|
||||
|
||||
time( &long_time );
|
||||
newtime = localtime( &long_time );
|
||||
|
||||
value = ((newtime->tm_sec) % 10)+((newtime->tm_sec)/10)*16
|
||||
+((((newtime->tm_min) % 10)+((newtime->tm_min)/10)*16) << 8)
|
||||
+((((newtime->tm_hour) % 10)+((newtime->tm_hour)/10)*16) << 16);
|
||||
return(value);
|
||||
}
|
||||
|
||||
DWORD GetDate()
|
||||
{
|
||||
|
||||
DWORD value;
|
||||
struct tm *newtime;
|
||||
time_t long_time;
|
||||
|
||||
time( &long_time );
|
||||
newtime = localtime( &long_time );
|
||||
value = ((newtime->tm_mday) % 10)+((newtime->tm_mday)/10)*16
|
||||
+(((newtime->tm_mon)+1) << 8)
|
||||
+((((newtime->tm_year) % 10)+((newtime->tm_year)/10)*16) << 16);
|
||||
+((newtime->tm_wday) << 28);
|
||||
|
||||
return(value);
|
||||
}
|
||||
//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.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef ZDOS
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define DWORD unsigned int
|
||||
#define BYTE unsigned char
|
||||
|
||||
FILE *FILEHANDLE[16];
|
||||
DWORD CurrentHandle=0;
|
||||
|
||||
|
||||
|
||||
// ZFileSystemInit
|
||||
// return 0
|
||||
|
||||
// ZOpenFile info :
|
||||
BYTE * ZOpenFileName;
|
||||
DWORD ZOpenMode;
|
||||
// Open modes : 0 read/write in
|
||||
// 1 write (create file, overwrite)
|
||||
// return file handle if success, 0xFFFFFFFF if error
|
||||
|
||||
// ZCloseFile info :
|
||||
DWORD ZCloseFileHandle;
|
||||
// return 0
|
||||
|
||||
// ZFileSeek info :
|
||||
DWORD ZFileSeekHandle;
|
||||
DWORD ZFileSeekPos;
|
||||
DWORD ZFileSeekMode; // 0 start, 1 end
|
||||
// return 0
|
||||
|
||||
// ZFileReadBlock info :
|
||||
BYTE * ZFileReadBlock;
|
||||
DWORD ZFileReadSize;
|
||||
DWORD ZFileReadHandle;
|
||||
// return 0
|
||||
|
||||
// ZFileWriteBlock info :
|
||||
BYTE * ZFileWriteBlock;
|
||||
DWORD ZFileWriteSize;
|
||||
DWORD ZFileWriteHandle;
|
||||
// return 0
|
||||
|
||||
// ZFileTell
|
||||
DWORD ZFileTellHandle;
|
||||
|
||||
// ZFileGetftime
|
||||
BYTE * ZFFTimeFName;
|
||||
DWORD ZFTimeHandle;
|
||||
DWORD ZFDate;
|
||||
DWORD ZFTime;
|
||||
|
||||
// MKDir/CHDir
|
||||
BYTE * MKPath;
|
||||
BYTE * CHPath;
|
||||
BYTE * RMPath;
|
||||
|
||||
// GetDir
|
||||
BYTE * DirName;
|
||||
DWORD DriveNumber;
|
||||
|
||||
// ZFileDelete
|
||||
BYTE * ZFileDelFName;
|
||||
// return current position
|
||||
|
||||
DWORD ZFileSystemInit()
|
||||
{
|
||||
CurrentHandle=0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD ZOpenFile()
|
||||
{
|
||||
if(ZOpenMode==0)
|
||||
{
|
||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"rb"))!=NULL)
|
||||
{
|
||||
CurrentHandle+=1;
|
||||
return(CurrentHandle-1);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
if(ZOpenMode==1)
|
||||
{
|
||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"wb"))!=NULL)
|
||||
{
|
||||
CurrentHandle+=1;
|
||||
return(CurrentHandle-1);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
if(ZOpenMode==2)
|
||||
{
|
||||
if((FILEHANDLE[CurrentHandle]=fopen(ZOpenFileName,"r+b"))!=NULL)
|
||||
{
|
||||
CurrentHandle+=1;
|
||||
return(CurrentHandle-1);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
DWORD ZCloseFile()
|
||||
{
|
||||
fclose(FILEHANDLE[ZCloseFileHandle]);
|
||||
CurrentHandle-=1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD ZFileSeek()
|
||||
{
|
||||
if(ZFileSeekMode==0)
|
||||
{
|
||||
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_SET);
|
||||
return(0);
|
||||
}
|
||||
if(ZFileSeekMode==1)
|
||||
{
|
||||
fseek(FILEHANDLE[ZFileSeekHandle],ZFileSeekPos,SEEK_END);
|
||||
return(0);
|
||||
}
|
||||
return(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
DWORD ZFileRead()
|
||||
{
|
||||
return(fread(ZFileReadBlock,1,ZFileReadSize,FILEHANDLE[ZFileReadHandle]));
|
||||
}
|
||||
|
||||
|
||||
DWORD ZFileWrite()
|
||||
{
|
||||
if((fwrite(ZFileWriteBlock,1,ZFileWriteSize,FILEHANDLE[ZFileWriteHandle]))!=ZFileWriteSize) return(0xFFFFFFFF);
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD ZFileTell()
|
||||
{
|
||||
return(ftell(FILEHANDLE[ZFileTellHandle]));
|
||||
}
|
||||
|
||||
DWORD ZFileDelete()
|
||||
{
|
||||
return(remove(ZFileDelFName));
|
||||
}
|
||||
|
||||
|
||||
DWORD ZFileGetFTime()
|
||||
{
|
||||
_dos_open(ZFFTimeFName, 0,&ZFTimeHandle);
|
||||
_dos_getftime(ZFTimeHandle,&ZFDate,&ZFTime);
|
||||
_dos_close(ZFTimeHandle);
|
||||
return(0);
|
||||
}
|
||||
|
||||
DWORD ZFileMKDir()
|
||||
{
|
||||
return(mkdir(MKPath));
|
||||
}
|
||||
|
||||
DWORD ZFileCHDir()
|
||||
{
|
||||
return(chdir(CHPath));
|
||||
}
|
||||
|
||||
DWORD ZFileRMDir()
|
||||
{
|
||||
return(rmdir(RMPath));
|
||||
}
|
||||
|
||||
DWORD ZFileGetDir()
|
||||
{
|
||||
return(getcwd(DirName,128));
|
||||
}
|
||||
|
||||
BYTE * ZFileFindPATH;
|
||||
DWORD ZFileFindATTRIB;
|
||||
DWORD DTALocPos;
|
||||
|
||||
//struct _find_t {
|
||||
// char reserved[21] __attribute__((packed));
|
||||
// unsigned char attrib __attribute__((packed));
|
||||
// unsigned short wr_time __attribute__((packed));
|
||||
// unsigned short wr_date __attribute__((packed));
|
||||
// unsigned long size __attribute__((packed));
|
||||
// char name[256] __attribute__((packed));
|
||||
//};
|
||||
|
||||
DWORD ZFileFindFirst()
|
||||
{
|
||||
return(_dos_findfirst(ZFileFindPATH,ZFileFindATTRIB,DTALocPos));
|
||||
}
|
||||
|
||||
DWORD ZFileFindNext()
|
||||
{
|
||||
return(_dos_findnext(DTALocPos));
|
||||
}
|
||||
|
||||
DWORD ZFileFindEnd() // for compatibility with windows later
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
//BYTE * DirName;
|
||||
//DWORD DriveNumber;
|
||||
|
||||
//unsigned int _dos_findfirst(char *_name, unsigned int _attr, struct _find_t *_result);
|
||||
//unsigned int _dos_findnext(struct _find_t *_result);
|
||||
|
||||
|
||||
DWORD GetTime()
|
||||
{
|
||||
|
||||
DWORD value;
|
||||
struct tm *newtime;
|
||||
time_t long_time;
|
||||
|
||||
time( &long_time );
|
||||
newtime = localtime( &long_time );
|
||||
|
||||
value = ((newtime->tm_sec) % 10)+((newtime->tm_sec)/10)*16
|
||||
+((((newtime->tm_min) % 10)+((newtime->tm_min)/10)*16) << 8)
|
||||
+((((newtime->tm_hour) % 10)+((newtime->tm_hour)/10)*16) << 16);
|
||||
return(value);
|
||||
}
|
||||
|
||||
DWORD GetDate()
|
||||
{
|
||||
|
||||
DWORD value;
|
||||
struct tm *newtime;
|
||||
time_t long_time;
|
||||
|
||||
time( &long_time );
|
||||
newtime = localtime( &long_time );
|
||||
value = ((newtime->tm_mday) % 10)+((newtime->tm_mday)/10)*16
|
||||
+(((newtime->tm_mon)+1) << 8)
|
||||
+((((newtime->tm_year) % 10)+((newtime->tm_year)/10)*16) << 16);
|
||||
+((newtime->tm_wday) << 28);
|
||||
|
||||
return(value);
|
||||
}
|
||||
@@ -1,396 +1,395 @@
|
||||
//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.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
extern void zstart(void);
|
||||
extern void DosExit(void);
|
||||
extern void ConvertJoyMap1(void);
|
||||
extern void ConvertJoyMap2(void);
|
||||
extern void displayparams(void);
|
||||
extern void makeextension(void);
|
||||
|
||||
extern unsigned char Palette0, SPC700sh, OffBy1Line, DSPDisable,
|
||||
FPUCopy, Force8b, ForcePal, GUIClick, MouseDis,
|
||||
MusicRelVol, ScreenScale, SoundCompD, SoundQuality,
|
||||
StereoSound, V8Mode, antienab, cvidmode, debugdisble,
|
||||
debugger, enterpress, finterleave, frameskip,
|
||||
gammalevel, guioff, per2exec, pl1contrl, pl2contrl,
|
||||
romtype, scanlines, showallext, smallscreenon, soundon,
|
||||
spcon, vsyncon, DisplayS, fname, filefound, SnowOn;
|
||||
|
||||
void ccmdline(void);
|
||||
|
||||
char *ers[] =
|
||||
{
|
||||
"Frame Skip must be a value of 0 to 9!\n",
|
||||
"Gamma Correction Level must be a value of 0 to 5!\n",
|
||||
"Sound Sampling Rate must be a value of 0 to 6!\n",
|
||||
"Invalid Video Mode!\n",
|
||||
"Percentage of instructions to execute must be a number from 50 to 150!\n",
|
||||
"Player Input must be a value from 0 to 6!\n",
|
||||
"Volume must be a number from 0 to 100!\n"
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
int main(int margc, char **margv)
|
||||
{
|
||||
argc=margc;
|
||||
argv=margv;
|
||||
zstart();
|
||||
}
|
||||
|
||||
|
||||
int my_atoi(char *nptr)
|
||||
{
|
||||
int p,c;
|
||||
c=0;
|
||||
for(p=0;nptr[p];p++)
|
||||
{
|
||||
if( !isdigit(nptr[p]) ) c+=1;
|
||||
}
|
||||
if(c) return -1;
|
||||
else return atoi(nptr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ccmdline(void)
|
||||
{
|
||||
int p=0;
|
||||
p=pccmdline();
|
||||
if(p == 0) return;
|
||||
|
||||
if(p == 9)
|
||||
{
|
||||
displayparams();
|
||||
}
|
||||
if(p == 4)
|
||||
{
|
||||
// printf("Mangled command line, did you forget a parm?\n");
|
||||
printf("Invalid Commandline!\n");
|
||||
DosExit();
|
||||
}
|
||||
|
||||
if((p > 9) && (p < 17))
|
||||
{
|
||||
printf(ers[p-10]);
|
||||
DosExit();
|
||||
}
|
||||
if(p == 2)
|
||||
{
|
||||
DosExit();
|
||||
}
|
||||
|
||||
|
||||
printf("cmdline returned %i\n",p);
|
||||
DosExit();
|
||||
|
||||
}
|
||||
|
||||
int pccmdline(void)
|
||||
{
|
||||
int p;
|
||||
int gfnm=0;
|
||||
|
||||
for(p=1;p<argc;p++)
|
||||
{
|
||||
/*
|
||||
printf("(%i/%i): %s\n",p,argc,argv[p]);
|
||||
*/
|
||||
|
||||
if(argv[p][0] == '-')
|
||||
{
|
||||
int hasroom=0;
|
||||
int pp=1;
|
||||
int cp=p;
|
||||
int nn='_';
|
||||
for(pp=1;argv[cp][pp];pp++)
|
||||
{
|
||||
if( (p+1) < argc) hasroom=1;
|
||||
nn=tolower(argv[cp][pp+1]);
|
||||
switch(tolower(argv[cp][pp]))
|
||||
{
|
||||
case '1': /* Player 1 Input */
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
pl1contrl=my_atoi(argv[p+1]);
|
||||
if(pl1contrl > 6) return 15;
|
||||
p++;
|
||||
ConvertJoyMap1();
|
||||
break;
|
||||
}
|
||||
case '2': /* Player 2 Input */
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
pl2contrl=my_atoi(argv[p+1]);
|
||||
if(pl2contrl > 6) return 15;
|
||||
p++;
|
||||
ConvertJoyMap2();
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
frameskip=my_atoi(argv[p+1]);
|
||||
if(frameskip > 9) return 10;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case 'g':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
gammalevel=my_atoi(argv[p+1]);
|
||||
if(gammalevel > 5) return 11;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case 'p':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
per2exec=my_atoi(argv[p+1]);
|
||||
if(per2exec > 150) return 14;
|
||||
if(per2exec < 50) return 14;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case 'r':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
SoundQuality=my_atoi(argv[p+1]);
|
||||
if(SoundQuality > 6) return 12;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case 'v':
|
||||
{
|
||||
if(nn == '8')
|
||||
{
|
||||
V8Mode=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
cvidmode=my_atoi(argv[p+1]);
|
||||
if(cvidmode > 10) return 13;
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'k':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
MusicRelVol=my_atoi(argv[p+1]);
|
||||
if(MusicRelVol > 100) return 16;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case '8':
|
||||
{
|
||||
Force8b=1;
|
||||
break;
|
||||
}
|
||||
case '0': /* Palette 0 disable */
|
||||
{
|
||||
Palette0=1;
|
||||
break;
|
||||
}
|
||||
case '7': /* SPC700 speed hack disable */
|
||||
{
|
||||
SPC700sh=1;
|
||||
break;
|
||||
}
|
||||
case '9': /* Off by 1 line */
|
||||
{
|
||||
OffBy1Line=1;
|
||||
break;
|
||||
}
|
||||
case 'e':
|
||||
{
|
||||
enterpress=1;
|
||||
break;
|
||||
}
|
||||
case 'h':
|
||||
{
|
||||
romtype=2;
|
||||
break;
|
||||
}
|
||||
case 'l':
|
||||
{
|
||||
romtype=1;
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
{
|
||||
guioff=1; /* disables GUI */
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
{
|
||||
scanlines=1;
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
{
|
||||
if(nn == 'p')
|
||||
{
|
||||
DisplayS=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
if(nn == 'a')
|
||||
{
|
||||
showallext=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
if(nn == 'n')
|
||||
{
|
||||
SnowOn=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
spcon=1;
|
||||
soundon=1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
{
|
||||
ForcePal=1;
|
||||
break;
|
||||
}
|
||||
case 'u':
|
||||
{
|
||||
ForcePal=2;
|
||||
break;
|
||||
}
|
||||
case 'w':
|
||||
{
|
||||
vsyncon=1;
|
||||
break;
|
||||
}
|
||||
case 'z':
|
||||
{
|
||||
StereoSound=1;
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
{
|
||||
if(nn == 'd')
|
||||
{
|
||||
DSPDisable=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
debugger=1;
|
||||
debugdisble=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'b':
|
||||
{
|
||||
SoundCompD=1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c':
|
||||
{
|
||||
if(nn == 'c')
|
||||
{
|
||||
smallscreenon=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScreenScale=1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'y':
|
||||
{
|
||||
antienab=1;
|
||||
break;
|
||||
}
|
||||
case 'o':
|
||||
{
|
||||
if(nn == 'm')
|
||||
{
|
||||
FPUCopy=2;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FPUCopy=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'i':
|
||||
{
|
||||
finterleave=1;
|
||||
break;
|
||||
}
|
||||
case 'j':
|
||||
{
|
||||
GUIClick=0;
|
||||
MouseDis=1;
|
||||
break;
|
||||
}
|
||||
case '?':
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(gfnm > 0)
|
||||
{
|
||||
printf("Limit yourself to one filename\n");
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *fvar;
|
||||
fvar=&fname;
|
||||
fvar[0] = strlen(argv[p]);
|
||||
strncpy(&fvar[1],argv[p],127);
|
||||
gfnm++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(gfnm == 1)
|
||||
{
|
||||
filefound=0;
|
||||
makeextension();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//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.
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
extern void zstart(void);
|
||||
extern void DosExit(void);
|
||||
extern void ConvertJoyMap1(void);
|
||||
extern void ConvertJoyMap2(void);
|
||||
extern void displayparams(void);
|
||||
extern void makeextension(void);
|
||||
|
||||
extern unsigned char Palette0, SPC700sh, OffBy1Line, DSPDisable,
|
||||
FPUCopy, Force8b, ForcePal, GUIClick, MouseDis,
|
||||
MusicRelVol, ScreenScale, SoundCompD, SoundQuality,
|
||||
StereoSound, V8Mode, antienab, cvidmode, debugdisble,
|
||||
debugger, enterpress, finterleave, frameskip,
|
||||
gammalevel, guioff, per2exec, pl1contrl, pl2contrl,
|
||||
romtype, scanlines, showallext, smallscreenon, soundon,
|
||||
spcon, vsyncon, DisplayS, fname, filefound, SnowOn;
|
||||
|
||||
void ccmdline(void);
|
||||
|
||||
char *ers[] =
|
||||
{
|
||||
"Frame Skip must be a value of 0 to 9!\n",
|
||||
"Gamma Correction Level must be a value of 0 to 5!\n",
|
||||
"Sound Sampling Rate must be a value of 0 to 6!\n",
|
||||
"Invalid Video Mode!\n",
|
||||
"Percentage of instructions to execute must be a number from 50 to 150!\n",
|
||||
"Player Input must be a value from 0 to 6!\n",
|
||||
"Volume must be a number from 0 to 100!\n"
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
int main(int margc, char **margv)
|
||||
{
|
||||
argc=margc;
|
||||
argv=margv;
|
||||
zstart();
|
||||
}
|
||||
|
||||
|
||||
int my_atoi(char *nptr)
|
||||
{
|
||||
int p,c;
|
||||
c=0;
|
||||
for(p=0;nptr[p];p++)
|
||||
{
|
||||
if( !isdigit(nptr[p]) ) c+=1;
|
||||
}
|
||||
if(c) return -1;
|
||||
else return atoi(nptr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ccmdline(void)
|
||||
{
|
||||
int p=0;
|
||||
p=pccmdline();
|
||||
if(p == 0) return;
|
||||
|
||||
if(p == 9)
|
||||
{
|
||||
displayparams();
|
||||
}
|
||||
if(p == 4)
|
||||
{
|
||||
// printf("Mangled command line, did you forget a parm?\n");
|
||||
printf("Invalid Commandline!\n");
|
||||
DosExit();
|
||||
}
|
||||
|
||||
if((p > 9) && (p < 17))
|
||||
{
|
||||
printf(ers[p-10]);
|
||||
DosExit();
|
||||
}
|
||||
if(p == 2)
|
||||
{
|
||||
DosExit();
|
||||
}
|
||||
|
||||
|
||||
printf("cmdline returned %i\n",p);
|
||||
DosExit();
|
||||
|
||||
}
|
||||
|
||||
int pccmdline(void)
|
||||
{
|
||||
int p;
|
||||
int gfnm=0;
|
||||
|
||||
for(p=1;p<argc;p++)
|
||||
{
|
||||
/*
|
||||
printf("(%i/%i): %s\n",p,argc,argv[p]);
|
||||
*/
|
||||
|
||||
if(argv[p][0] == '-')
|
||||
{
|
||||
int hasroom=0;
|
||||
int pp=1;
|
||||
int cp=p;
|
||||
int nn='_';
|
||||
for(pp=1;argv[cp][pp];pp++)
|
||||
{
|
||||
if( (p+1) < argc) hasroom=1;
|
||||
nn=tolower(argv[cp][pp+1]);
|
||||
switch(tolower(argv[cp][pp]))
|
||||
{
|
||||
case '1': /* Player 1 Input */
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
pl1contrl=my_atoi(argv[p+1]);
|
||||
if(pl1contrl > 6) return 15;
|
||||
p++;
|
||||
ConvertJoyMap1();
|
||||
break;
|
||||
}
|
||||
case '2': /* Player 2 Input */
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
pl2contrl=my_atoi(argv[p+1]);
|
||||
if(pl2contrl > 6) return 15;
|
||||
p++;
|
||||
ConvertJoyMap2();
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
frameskip=my_atoi(argv[p+1]);
|
||||
if(frameskip > 9) return 10;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case 'g':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
gammalevel=my_atoi(argv[p+1]);
|
||||
if(gammalevel > 5) return 11;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case 'p':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
per2exec=my_atoi(argv[p+1]);
|
||||
if(per2exec > 150) return 14;
|
||||
if(per2exec < 50) return 14;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case 'r':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
SoundQuality=my_atoi(argv[p+1]);
|
||||
if(SoundQuality > 6) return 12;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case 'v':
|
||||
{
|
||||
if(nn == '8')
|
||||
{
|
||||
V8Mode=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
cvidmode=my_atoi(argv[p+1]);
|
||||
if(cvidmode > 10) return 13;
|
||||
p++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'k':
|
||||
{
|
||||
if(!hasroom) return 4;
|
||||
MusicRelVol=my_atoi(argv[p+1]);
|
||||
if(MusicRelVol > 100) return 16;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
case '8':
|
||||
{
|
||||
Force8b=1;
|
||||
break;
|
||||
}
|
||||
case '0': /* Palette 0 disable */
|
||||
{
|
||||
Palette0=1;
|
||||
break;
|
||||
}
|
||||
case '7': /* SPC700 speed hack disable */
|
||||
{
|
||||
SPC700sh=1;
|
||||
break;
|
||||
}
|
||||
case '9': /* Off by 1 line */
|
||||
{
|
||||
OffBy1Line=1;
|
||||
break;
|
||||
}
|
||||
case 'e':
|
||||
{
|
||||
enterpress=1;
|
||||
break;
|
||||
}
|
||||
case 'h':
|
||||
{
|
||||
romtype=2;
|
||||
break;
|
||||
}
|
||||
case 'l':
|
||||
{
|
||||
romtype=1;
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
{
|
||||
guioff=1; /* disables GUI */
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
{
|
||||
scanlines=1;
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
{
|
||||
if(nn == 'p')
|
||||
{
|
||||
DisplayS=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
if(nn == 'a')
|
||||
{
|
||||
showallext=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
if(nn == 'n')
|
||||
{
|
||||
SnowOn=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
spcon=1;
|
||||
soundon=1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
{
|
||||
ForcePal=1;
|
||||
break;
|
||||
}
|
||||
case 'u':
|
||||
{
|
||||
ForcePal=2;
|
||||
break;
|
||||
}
|
||||
case 'w':
|
||||
{
|
||||
vsyncon=1;
|
||||
break;
|
||||
}
|
||||
case 'z':
|
||||
{
|
||||
StereoSound=1;
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
{
|
||||
if(nn == 'd')
|
||||
{
|
||||
DSPDisable=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
debugger=1;
|
||||
debugdisble=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'b':
|
||||
{
|
||||
SoundCompD=1;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'c':
|
||||
{
|
||||
if(nn == 'c')
|
||||
{
|
||||
smallscreenon=1;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScreenScale=1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'y':
|
||||
{
|
||||
antienab=1;
|
||||
break;
|
||||
}
|
||||
case 'o':
|
||||
{
|
||||
if(nn == 'm')
|
||||
{
|
||||
FPUCopy=2;
|
||||
pp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FPUCopy=0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'i':
|
||||
{
|
||||
finterleave=1;
|
||||
break;
|
||||
}
|
||||
case 'j':
|
||||
{
|
||||
GUIClick=0;
|
||||
MouseDis=1;
|
||||
break;
|
||||
}
|
||||
case '?':
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(gfnm > 0)
|
||||
{
|
||||
printf("Limit yourself to one filename\n");
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *fvar;
|
||||
fvar=&fname;
|
||||
fvar[0] = strlen(argv[p]);
|
||||
strncpy(&fvar[1],argv[p],127);
|
||||
gfnm++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(gfnm == 1)
|
||||
{
|
||||
filefound=0;
|
||||
makeextension();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,212 +1,211 @@
|
||||
;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.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM ipx_init ; To init ipx
|
||||
EXTSYM ipx_initcode ; return 0 if everything is ok (int)
|
||||
EXTSYM ipx_packet ; 80 bytes buffer to send
|
||||
EXTSYM ipx_packet_size ; size to send (max 80 bytes) (dword)
|
||||
EXTSYM sendpacket ; to send a packet
|
||||
EXTSYM checkpacket ; check if a packet is ready to receive
|
||||
EXTSYM ipx_packet_ready ; return 1 if there is a packet ready (byte)
|
||||
EXTSYM read_packet ; to read an incoming packet
|
||||
EXTSYM ipx_read_packet ; 80 bytes buffer of received packet
|
||||
EXTSYM ipx_deinit ; to deinit the ipx
|
||||
EXTSYM IPXInfoStr,IPXInfoStrR
|
||||
EXTSYM modembuffer, modemhead, modemtail
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NEWSYM ipxinited, db 0
|
||||
|
||||
NEWSYM initipx
|
||||
mov dword[modemhead],0
|
||||
mov dword[modemtail],0
|
||||
xor ax,ax
|
||||
cmp byte[ipxinited],1
|
||||
je .notokay
|
||||
call ipx_init
|
||||
mov ax,[ipx_initcode]
|
||||
cmp ax,0
|
||||
jne .notokay
|
||||
mov byte[ipxinited],1
|
||||
.notokay
|
||||
ret
|
||||
|
||||
NEWSYM deinitipx
|
||||
cmp byte[ipxinited],0
|
||||
je .notinitialized
|
||||
mov byte[ipxinited],0
|
||||
call ipx_deinit
|
||||
.notinitialized
|
||||
ret
|
||||
|
||||
NEWSYM PacketPointer, dd 0
|
||||
|
||||
NEWSYM PreparePacketIPX
|
||||
cmp byte[ipxinited],1
|
||||
jne .noipx
|
||||
call ipxpp
|
||||
.noipx
|
||||
ret
|
||||
|
||||
NEWSYM SendPacketIPX
|
||||
cmp byte[ipxinited],1
|
||||
jne .noipx
|
||||
call ipxsp
|
||||
.noipx
|
||||
ret
|
||||
|
||||
NEWSYM ipxsendchar ; prepare packet
|
||||
push esi
|
||||
mov esi,[PacketPointer]
|
||||
mov [esi],al
|
||||
inc dword[PacketPointer]
|
||||
pop esi
|
||||
ret
|
||||
|
||||
NEWSYM IPXSearchval, db 0
|
||||
NEWSYM ipxlookforconnect
|
||||
cmp byte[ipxinited],0
|
||||
je .initialized
|
||||
ret
|
||||
.initialized
|
||||
pushad
|
||||
call checkpacket
|
||||
cmp byte[ipx_packet_ready],1
|
||||
jne near .nopacket
|
||||
call read_packet
|
||||
cmp dword[ipx_read_packet],'ZZ|Z'
|
||||
jne .nopacketf
|
||||
cmp byte[ipx_read_packet+6],'L'
|
||||
jne .nopacketf
|
||||
mov ax,[ipx_read_packet+4]
|
||||
cmp ax,[IPXInfoStr]
|
||||
je .nopacketf
|
||||
mov [IPXInfoStrR],ax
|
||||
mov eax,ipx_packet
|
||||
mov dword[eax],'ZY|Z'
|
||||
mov bx,[IPXInfoStr]
|
||||
mov [eax+4],bx
|
||||
mov bx,[IPXInfoStrR]
|
||||
mov [eax+6],bx
|
||||
mov dword[ipx_packet_size],8
|
||||
call sendpacket
|
||||
mov byte[IPXSearchval],1
|
||||
jmp .skipall
|
||||
.nopacketf
|
||||
cmp dword[ipx_read_packet],'ZY|Z'
|
||||
jne .nopacket
|
||||
mov bx,[IPXInfoStr]
|
||||
cmp [eax+6],bx
|
||||
jne .nopacket
|
||||
mov bx,[eax+4]
|
||||
cmp bx,[IPXInfoStr]
|
||||
je .nopacket
|
||||
mov [IPXInfoStrR],bx
|
||||
mov byte[IPXSearchval],1
|
||||
jmp .skipall
|
||||
.nopacket
|
||||
mov eax,ipx_packet
|
||||
mov dword[eax],'ZZ|Z'
|
||||
mov bx,[IPXInfoStr]
|
||||
mov [eax+4],bx
|
||||
mov byte[eax+6],'L'
|
||||
mov dword[ipx_packet_size],7
|
||||
call sendpacket
|
||||
.skipall
|
||||
popad
|
||||
ret
|
||||
|
||||
NEWSYM ipxpp ; prepare packet
|
||||
pushad
|
||||
mov eax,ipx_packet
|
||||
mov byte[eax],'Z'
|
||||
mov byte[eax+1],'|'
|
||||
mov byte[eax+2],'S'
|
||||
mov bx,[IPXInfoStr]
|
||||
mov [eax+3],bx
|
||||
add eax,6
|
||||
mov [PacketPointer],eax
|
||||
popad
|
||||
ret
|
||||
|
||||
NEWSYM ipxsp ; send packet
|
||||
pushad
|
||||
mov eax,[PacketPointer]
|
||||
sub eax,ipx_packet
|
||||
mov [ipx_packet+5],al
|
||||
mov [ipx_packet_size],eax
|
||||
call sendpacket
|
||||
popad
|
||||
ret
|
||||
|
||||
NEWSYM ipxgetchar
|
||||
pushad
|
||||
call checkpacket
|
||||
cmp byte[ipx_packet_ready],1
|
||||
jne .nopacket
|
||||
call read_packet
|
||||
cmp byte[ipx_read_packet],'Z'
|
||||
jne .nopacket
|
||||
cmp byte[ipx_read_packet+1],'|'
|
||||
jne .nopacket
|
||||
cmp byte[ipx_read_packet+2],'S'
|
||||
jne .nopacket
|
||||
mov bx,[IPXInfoStrR]
|
||||
cmp [ipx_read_packet+3],bx
|
||||
jne .nopacket
|
||||
mov cl,[ipx_read_packet+5]
|
||||
sub cl,6
|
||||
mov esi,ipx_read_packet+6
|
||||
cmp cl,0
|
||||
je .nopacket
|
||||
.loop
|
||||
mov edi,[modemtail]
|
||||
mov al,[esi]
|
||||
mov [modembuffer+edi],al
|
||||
inc dword[modemtail]
|
||||
inc esi
|
||||
and dword[modemtail],2047
|
||||
dec cl
|
||||
jnz .loop
|
||||
.nopacket
|
||||
popad
|
||||
push eax
|
||||
xor dh,dh
|
||||
mov eax,[modemhead]
|
||||
cmp eax,[modemtail]
|
||||
je .nonewchar
|
||||
mov dh,1
|
||||
mov dl,[modembuffer+eax]
|
||||
inc dword[modemhead]
|
||||
and dword[modemhead],2047
|
||||
.nonewchar
|
||||
pop eax
|
||||
ret
|
||||
|
||||
|
||||
;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.
|
||||
|
||||
%include "macros.mac"
|
||||
|
||||
EXTSYM ipx_init ; To init ipx
|
||||
EXTSYM ipx_initcode ; return 0 if everything is ok (int)
|
||||
EXTSYM ipx_packet ; 80 bytes buffer to send
|
||||
EXTSYM ipx_packet_size ; size to send (max 80 bytes) (dword)
|
||||
EXTSYM sendpacket ; to send a packet
|
||||
EXTSYM checkpacket ; check if a packet is ready to receive
|
||||
EXTSYM ipx_packet_ready ; return 1 if there is a packet ready (byte)
|
||||
EXTSYM read_packet ; to read an incoming packet
|
||||
EXTSYM ipx_read_packet ; 80 bytes buffer of received packet
|
||||
EXTSYM ipx_deinit ; to deinit the ipx
|
||||
EXTSYM IPXInfoStr,IPXInfoStrR
|
||||
EXTSYM modembuffer, modemhead, modemtail
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NEWSYM ipxinited, db 0
|
||||
|
||||
NEWSYM initipx
|
||||
mov dword[modemhead],0
|
||||
mov dword[modemtail],0
|
||||
xor ax,ax
|
||||
cmp byte[ipxinited],1
|
||||
je .notokay
|
||||
call ipx_init
|
||||
mov ax,[ipx_initcode]
|
||||
cmp ax,0
|
||||
jne .notokay
|
||||
mov byte[ipxinited],1
|
||||
.notokay
|
||||
ret
|
||||
|
||||
NEWSYM deinitipx
|
||||
cmp byte[ipxinited],0
|
||||
je .notinitialized
|
||||
mov byte[ipxinited],0
|
||||
call ipx_deinit
|
||||
.notinitialized
|
||||
ret
|
||||
|
||||
NEWSYM PacketPointer, dd 0
|
||||
|
||||
NEWSYM PreparePacketIPX
|
||||
cmp byte[ipxinited],1
|
||||
jne .noipx
|
||||
call ipxpp
|
||||
.noipx
|
||||
ret
|
||||
|
||||
NEWSYM SendPacketIPX
|
||||
cmp byte[ipxinited],1
|
||||
jne .noipx
|
||||
call ipxsp
|
||||
.noipx
|
||||
ret
|
||||
|
||||
NEWSYM ipxsendchar ; prepare packet
|
||||
push esi
|
||||
mov esi,[PacketPointer]
|
||||
mov [esi],al
|
||||
inc dword[PacketPointer]
|
||||
pop esi
|
||||
ret
|
||||
|
||||
NEWSYM IPXSearchval, db 0
|
||||
NEWSYM ipxlookforconnect
|
||||
cmp byte[ipxinited],0
|
||||
je .initialized
|
||||
ret
|
||||
.initialized
|
||||
pushad
|
||||
call checkpacket
|
||||
cmp byte[ipx_packet_ready],1
|
||||
jne near .nopacket
|
||||
call read_packet
|
||||
cmp dword[ipx_read_packet],'ZZ|Z'
|
||||
jne .nopacketf
|
||||
cmp byte[ipx_read_packet+6],'L'
|
||||
jne .nopacketf
|
||||
mov ax,[ipx_read_packet+4]
|
||||
cmp ax,[IPXInfoStr]
|
||||
je .nopacketf
|
||||
mov [IPXInfoStrR],ax
|
||||
mov eax,ipx_packet
|
||||
mov dword[eax],'ZY|Z'
|
||||
mov bx,[IPXInfoStr]
|
||||
mov [eax+4],bx
|
||||
mov bx,[IPXInfoStrR]
|
||||
mov [eax+6],bx
|
||||
mov dword[ipx_packet_size],8
|
||||
call sendpacket
|
||||
mov byte[IPXSearchval],1
|
||||
jmp .skipall
|
||||
.nopacketf
|
||||
cmp dword[ipx_read_packet],'ZY|Z'
|
||||
jne .nopacket
|
||||
mov bx,[IPXInfoStr]
|
||||
cmp [eax+6],bx
|
||||
jne .nopacket
|
||||
mov bx,[eax+4]
|
||||
cmp bx,[IPXInfoStr]
|
||||
je .nopacket
|
||||
mov [IPXInfoStrR],bx
|
||||
mov byte[IPXSearchval],1
|
||||
jmp .skipall
|
||||
.nopacket
|
||||
mov eax,ipx_packet
|
||||
mov dword[eax],'ZZ|Z'
|
||||
mov bx,[IPXInfoStr]
|
||||
mov [eax+4],bx
|
||||
mov byte[eax+6],'L'
|
||||
mov dword[ipx_packet_size],7
|
||||
call sendpacket
|
||||
.skipall
|
||||
popad
|
||||
ret
|
||||
|
||||
NEWSYM ipxpp ; prepare packet
|
||||
pushad
|
||||
mov eax,ipx_packet
|
||||
mov byte[eax],'Z'
|
||||
mov byte[eax+1],'|'
|
||||
mov byte[eax+2],'S'
|
||||
mov bx,[IPXInfoStr]
|
||||
mov [eax+3],bx
|
||||
add eax,6
|
||||
mov [PacketPointer],eax
|
||||
popad
|
||||
ret
|
||||
|
||||
NEWSYM ipxsp ; send packet
|
||||
pushad
|
||||
mov eax,[PacketPointer]
|
||||
sub eax,ipx_packet
|
||||
mov [ipx_packet+5],al
|
||||
mov [ipx_packet_size],eax
|
||||
call sendpacket
|
||||
popad
|
||||
ret
|
||||
|
||||
NEWSYM ipxgetchar
|
||||
pushad
|
||||
call checkpacket
|
||||
cmp byte[ipx_packet_ready],1
|
||||
jne .nopacket
|
||||
call read_packet
|
||||
cmp byte[ipx_read_packet],'Z'
|
||||
jne .nopacket
|
||||
cmp byte[ipx_read_packet+1],'|'
|
||||
jne .nopacket
|
||||
cmp byte[ipx_read_packet+2],'S'
|
||||
jne .nopacket
|
||||
mov bx,[IPXInfoStrR]
|
||||
cmp [ipx_read_packet+3],bx
|
||||
jne .nopacket
|
||||
mov cl,[ipx_read_packet+5]
|
||||
sub cl,6
|
||||
mov esi,ipx_read_packet+6
|
||||
cmp cl,0
|
||||
je .nopacket
|
||||
.loop
|
||||
mov edi,[modemtail]
|
||||
mov al,[esi]
|
||||
mov [modembuffer+edi],al
|
||||
inc dword[modemtail]
|
||||
inc esi
|
||||
and dword[modemtail],2047
|
||||
dec cl
|
||||
jnz .loop
|
||||
.nopacket
|
||||
popad
|
||||
push eax
|
||||
xor dh,dh
|
||||
mov eax,[modemhead]
|
||||
cmp eax,[modemtail]
|
||||
je .nonewchar
|
||||
mov dh,1
|
||||
mov dl,[modembuffer+eax]
|
||||
inc dword[modemhead]
|
||||
and dword[modemhead],2047
|
||||
.nonewchar
|
||||
pop eax
|
||||
ret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user