Much better way of detecting the 512 header. Should improve compatibility.

This commit is contained in:
zsknight
2001-05-16 22:12:10 +00:00
parent bc20a18ac4
commit 83bd5ab24e

View File

@@ -1718,18 +1718,22 @@ NEWSYM init65816
mov dword[CSStatus+25],'OBC ' mov dword[CSStatus+25],'OBC '
.noobc .noobc
mov ax,[Checksumvalue]
mov esi,[romdata] mov esi,[romdata]
add esi,7FDCh+2 add esi,7FDCh+2
cmp byte[romtype],2 cmp byte[romtype],2
jne .nohirom3 jne .nohirom3
add esi,8000h add esi,8000h
.nohirom3 .nohirom3
mov ax,[Checksumvalue]
cmp ax,[esi] cmp ax,[esi]
jne .failed jne .failed
.passed2
mov dword[CSStatus+36],'OK ' mov dword[CSStatus+36],'OK '
jmp .passed jmp .passed
.failed .failed
mov ax,[Checksumvalue2]
cmp ax,[esi]
je .passed2
mov dword[CSStatus+36],'FAIL' mov dword[CSStatus+36],'FAIL'
.passed .passed
mov dword[Msgptr],CSStatus mov dword[Msgptr],CSStatus
@@ -3525,217 +3529,6 @@ NEWSYM loadfile
jmp loadfileGUI.nogui jmp loadfileGUI.nogui
%ifndef __LINUX__
mov dword[MessageOn],0
mov byte[loadedfromgui],0
mov byte[yesoutofmemory],0
mov byte[Header512],0
mov byte[.fail],0
; determine header size
mov dword[.curfileofs],0
mov byte[.first],1
mov byte[.multfound],0
; open file
mov edx,fname+1
call Open_File
jc near .failed
.nextfile
cmp byte[.first],1
je .nomul
cmp byte[.multfound],0
jne .nomul
push eax
push edx
mov byte[.multfound],1
mov edx,.mult
mov ah,9
call Output_Text
pop edx
pop eax
.nomul
mov bx,ax
mov ecx,4194304+32768
cmp byte[Sup48mbit],0
je .no48mb
add ecx,2097152
.no48mb
cmp byte[Sup16mbit],0
je .no16mb
sub ecx,2097152
.no16mb
sub ecx,[.curfileofs]
jnc .nooverflow
xor ecx,ecx
.nooverflow
mov edx,[headdata]
add edx,[.curfileofs]
call Read_File
jc near .failed
or eax,eax
jz near .success
mov ecx,eax
shr eax,15
shl eax,15
mov esi,[headdata]
add esi,[.curfileofs]
mov edi,[headdata]
add edi,[.curfileofs]
sub ecx,eax
or ecx,ecx
jz .nonoheader
add eax,ecx
sub eax,512
mov ecx,512
mov byte[Header512],1
; mov ecx,512
; and eax,0FFFF8000h
; add eax,8000h
.nonoheader
add [.curfileofs],eax
add edi,ecx
.next
mov cl,[edi]
mov [esi],cl
inc esi
inc edi
dec eax
jnz .next
mov ecx,1
mov edx,.temp
call Read_File
cmp eax,0
je .success
mov byte[.fail],1
.success
call Close_File
jc near .failed
; check for 2nd+ part of file
mov edi,fname+1
mov byte[.cchar],'\'
; get position of . or \
.nextsearch
cmp byte[edi],0
je .nomore
cmp byte[edi],'.'
jne .notdot
mov byte[.cchar],'.'
mov [.dotpos],edi
.notdot
cmp byte[edi],'\'
jne .notslash
mov byte[.cchar],'\'
.notslash
inc edi
jmp .nextsearch
.nomore
cmp byte[.cchar],'\'
jne .noslashb
mov [.dotpos],edi
.noslashb
mov edi,[.dotpos]
; search for .1, .2, etc.
cmp byte[edi],'.'
jne .nonumer
cmp byte[edi+1],'1'
jb .nonumer
cmp byte[edi+1],'8'
ja .nonumer
cmp byte[edi+2],0
jne .nonumer
inc byte[edi+1]
xor ecx,ecx
mov byte[.first],2
mov edx,fname+1
call Open_File
jnc near .nextfile
dec byte[edi+1]
.nonumer
; search for A,B,C, etc.
cmp byte[.first],0
je .yesgd
cmp byte[edi-1],'A'
je .yesgd
cmp byte[edi-1],'a'
je .yesgd
jmp .nogdformat
.yesgd
mov byte[.first],0
inc byte[edi-1]
mov edx,fname+1
call Open_File
jnc near .nextfile
dec byte[edi-1]
.nogdformat
call convertsram
mov byte[SramExists],0
; change to sram dir
mov dl,[SRAMDrive]
mov ebx,SRAMDir
call Change_Dir
; open .srm file
mov edx,fnames+1
call Open_File
jc .notexist
mov byte[SramExists],1
mov bx,ax
mov ecx,65536
mov edx,[sram]
call Read_File
jc near .failed
call Close_File
jc .failed
.notexist
call OpenCombFile
mov edx,.opened
mov ah,9
call Output_Text
; calculate checksum
mov eax,1
.nextcr
add eax,eax
cmp eax,[.curfileofs]
jb .nextcr
mov ecx,eax
mov esi,[romdata]
xor eax,eax
xor ebx,ebx
xor edi,edi
mov edx,ecx
shr edx,1
.nextcs
mov al,[esi+edi]
inc edi
add ebx,eax
cmp edi,[.curfileofs]
jne .notcrs
mov edi,edx
.notcrs
dec ecx
jnz .nextcs
mov [Checksumvalue],bx
mov eax,[.curfileofs]
mov [NumofBytes],eax
shr eax,15
mov [NumofBanks],eax
cmp byte[.fail],0
je .notfailed
mov byte[yesoutofmemory],1
.notfailed
mov byte[TextFile], 1
call PatchIPS
ret
.failed
mov edx,.failop
mov ah,9
call Output_Text
jmp DosExit
%endif
SECTION .data SECTION .data
.multfound db 0 .multfound db 0
.first db 0 .first db 0
@@ -3751,6 +3544,7 @@ SECTION .data
NEWSYM Checksumvalue, dw 0 NEWSYM Checksumvalue, dw 0
NEWSYM Checksumvalue2, dw 0
NEWSYM SramExists, db 0 NEWSYM SramExists, db 0
NEWSYM NumofBanks, dd 0 NEWSYM NumofBanks, dd 0
NEWSYM NumofBytes, dd 0 NEWSYM NumofBytes, dd 0
@@ -4423,12 +4217,13 @@ NEWSYM loadfileGUI
add edx,[.curfileofs] add edx,[.curfileofs]
call Read_File call Read_File
jc near .failed jc near .failed
or eax,eax or eax,eax
jz near .success2 jz near .success2
add dword[.curromspace],eax add dword[.curromspace],eax
mov ecx,eax mov ecx,eax
shr eax,15 ; shr eax,15
shl eax,15 ; shl eax,15
mov esi,[headdata] mov esi,[headdata]
add esi,[.curfileofs] add esi,[.curfileofs]
mov edi,[headdata] mov edi,[headdata]
@@ -4437,45 +4232,33 @@ NEWSYM loadfileGUI
sub ecx,eax sub ecx,eax
; xor ecx,ecx ; xor ecx,ecx
; or ecx,ecx ; or ecx,ecx
cmp ecx,512
jne .nonoheader
mov byte[Header512],1
mov ecx,512
and eax,0FFFF8000h
add eax,8000h
jmp .yesheader
.nonoheader
add eax,ecx
xor ecx,ecx
.yesheader
add edi,ecx
; check if .smc header ; check if .smc header
push esi push esi
push eax push eax
mov esi,[headdata] push ebx
add esi,7FDCh xor ecx,ecx
add esi,512 mov ebx,512
mov ax,[esi] .nextzerocheck
xor ax,[esi+2] cmp byte[esi],0
cmp ax,0FFFFh jne .notzero
je .yessmc inc ecx
add esi,8000h .notzero
mov ax,[esi] inc esi
xor ax,[esi+2] dec ebx
cmp ax,0FFFFh jnz .nextzerocheck
je .yessmc pop ebx
pop eax
pop esi
jmp .next
.yessmc
pop eax pop eax
pop esi pop esi
cmp ecx,450
jb .nomove
mov edi,esi mov edi,esi
add edi,512 add edi,512
and eax,0FFFF8000h sub eax,512
add eax,8000h
; move eax # of bytes from edi to esi ; move eax # of bytes from edi to esi
sub dword[.curromspace],512 sub dword[.curromspace],512
sub dword[.curfileofs],512
.next .next
mov cl,[edi] mov cl,[edi]
mov [esi],cl mov [esi],cl
@@ -4483,6 +4266,7 @@ NEWSYM loadfileGUI
inc edi inc edi
dec eax dec eax
jnz .next jnz .next
.nomove
mov ecx,1 mov ecx,1
mov edx,.temp mov edx,.temp
call Read_File call Read_File
@@ -4599,6 +4383,19 @@ NEWSYM loadfileGUI
jnz .nextcs jnz .nextcs
mov [Checksumvalue],bx mov [Checksumvalue],bx
mov esi,[romdata]
mov ecx,[.curfileofs]
xor eax,eax
xor ebx,ebx
xor edi,edi
.nextcs3
mov al,[esi+edi]
inc edi
add ebx,eax
cmp edi,ecx
jne .nextcs3
mov [Checksumvalue2],bx
cmp byte[ZipSupport],1 cmp byte[ZipSupport],1
jne .nottempdirdel jne .nottempdirdel
@@ -5129,9 +4926,13 @@ NEWSYM showinfo
.nohirom3 .nohirom3
cmp ax,[esi] cmp ax,[esi]
jne .failed jne .failed
.cpassed2
mov edx,.cpassed mov edx,.cpassed
jmp .passed jmp .passed
.failed .failed
mov ax,[Checksumvalue2]
cmp ax,[esi]
je .cpassed2
mov edx,.cfailed mov edx,.cfailed
.passed .passed
mov ah,9 mov ah,9