Code: Select all
--- gui/gui_old.asm 2005-05-28 16:22:19.000000000 +0000
+++ gui/gui.asm 2005-05-30 08:36:58.000000000 +0000
@@ -105,7 +105,7 @@
EXTSYM RestoreSystemVars,GUIBIFIL,GUIHQ2X,GUIHQ3X,GUIHQ4X,firstsaveinc,nssdip1
EXTSYM nssdip2,nssdip3,nssdip4,nssdip5,nssdip6,SkipMovie,MovieStop,MoviePlay
EXTSYM MovieRecord,MovieInsertChapter,MovieSeekAhead,MovieSeekBehind
-EXTSYM ResetDuringMovie,MovieDumpRaw
+EXTSYM ResetDuringMovie,MovieDumpRaw,GUIStringGreater,GUIStringGreater2,tempesi
%ifdef __LINUX__
EXTSYM numlockptr
Code: Select all
--- gui/guiload_old.inc 2005-04-09 08:40:29.000000000 +0000
+++ gui/guiload.inc 2005-05-30 08:38:41.000000000 +0000
@@ -1102,10 +1102,13 @@
dec ecx
.nextentry
push ecx
- ; check if esi > esi+32
+ mov [tempesi],esi
+ pushad
+ ; check if [esi] > [esi+32]
call GUIStringGreater
; if it is, swap!
cmp al,0
+ popad
je near .noswap
mov ecx,31
.nextswap
@@ -1145,14 +1148,13 @@
dec ecx
.nextentryb
push ecx
- mov ebx,[esi]
- mov edx,[esi+4]
- inc ebx
- inc edx
- ; check if ebx > edx
+ pushad
+ mov [tempesi],esi
+ ; check if [[esi]+1] > [[esi+4]+1]
call GUIStringGreater2
; if it is, swap!
cmp al,0
+ popad
je near .noswapb
mov eax,[esi]
mov ebx,[esi+4]
@@ -1218,10 +1220,13 @@
je near .sort2
.nextentry
push ecx
- ; check if esi > esi+32
+ pushad
+ mov [tempesi],esi
+ ; check if [esi] > [esi+32]
call GUIStringGreater
; if it is, swap!
cmp al,0
+ popad
je near .noswap
mov ecx,31
.nextswap
@@ -1261,14 +1266,13 @@
add esi,spcRamcmp
.nextentryb
push ecx
- mov ebx,[esi]
- mov edx,[esi+4]
- inc ebx
- inc edx
- ; check if ebx > edx
+ pushad
+ mov [tempesi],esi
+ ; check if [[esi]+1] > [[esi+4]+1]
call GUIStringGreater2
; if it is, swap!
cmp al,0
+ popad
je near .noswapb
mov eax,[esi]
mov ebx,[esi+4]
Code: Select all
--- gui/guiwindp_old.inc 2005-05-28 00:01:43.000000000 +0000
+++ gui/guiwindp.inc 2005-05-30 08:09:45.000000000 +0000
@@ -23,97 +23,6 @@
; Window Display Routines
; Last button value used = 77
-GUIStringGreater:
- ; compares string at esi to edi and returns 1 to al if esi is >, else 0
- push esi
- cmp word[esi],'.'
- je .less
- cmp word[esi+32],'.'
- je .greater
- cmp word[esi],'..'
- je .less
- cmp word[esi+32],'..'
- je .greater
-.nextchar
- cmp byte[esi],0
- je .less
- cmp byte[esi+32],0
- je .greater
- mov al,[esi]
- mov cl,[esi+32]
- cmp al,'a'
- jb .noucase1
- cmp al,'z'
- ja .noucase1
- sub al,'z'-'Z'
-.noucase1
- cmp cl,'a'
- jb .noucase2
- cmp cl,'z'
- ja .noucase2
- sub cl,'z'-'Z'
-.noucase2
- cmp al,cl
- jb .less
- ja .greater
- inc esi
- jmp .nextchar
-.less
- mov al,0
- jmp .skip
-.greater
- mov al,1
-.skip
- pop esi
- ret
-
-GUIStringGreater2:
- ; compares string at ebx to edx and returns 1 to al if esi is >, else 0
- push edx
- push ebx
- cmp word[ebx],'.'
- je .less
- cmp word[edx],'.'
- je .greater
- cmp word[ebx],'..'
- je .less
- cmp word[ebx],'..'
- je .greater
-.nextchar
- cmp byte[ebx],0
- je .less
- cmp byte[edx],0
- je .greater
- mov al,[ebx]
- mov cl,[edx]
- cmp al,'a'
- jb .noucase1
- cmp al,'z'
- ja .noucase1
- sub al,'z'-'Z'
-.noucase1
- cmp cl,'a'
- jb .noucase2
- cmp cl,'z'
- ja .noucase2
- sub cl,'z'-'Z'
-.noucase2
- cmp al,cl
- jb .less
- ja .greater
- inc ebx
- inc edx
- jmp .nextchar
-.less
- mov al,0
- jmp .skip
-.greater
- mov al,1
-.skip
- pop ebx
- pop edx
- ret
-
%Macro DrawGUILineSc 2
mov dword[GUIcolscaleval],%2
mov edx,%1
Code: Select all
--- Makefile_old.in 2005-04-21 22:14:10.000000000 +0000
+++ Makefile.in 2005-05-30 08:28:18.000000000 +0000
@@ -41,7 +41,7 @@
${CPUDIR}/memtable.o ${CPUDIR}/spc700.o ${CPUDIR}/stable.o\
${CPUDIR}/table.o ${CPUDIR}/tableb.o ${CPUDIR}/tablec.o
-GUIOBJ=${GUIDIR}/gui.o ${GUIDIR}/menu.o
+GUIOBJ=${GUIDIR}/gui.o ${GUIDIR}/guifuncs.o ${GUIDIR}/menu.o
VIDEOBJ=${VIDEODIR}/makev16b.o ${VIDEODIR}/makev16t.o ${VIDEODIR}/makevid.o\
${VIDEODIR}/mode716.o ${VIDEODIR}/mode716b.o ${VIDEODIR}/mode716d.o\
@@ -188,6 +188,7 @@
${GUIDIR}/guimisc.inc ${GUIDIR}/guimouse.inc ${GUIDIR}/guiwindp.inc\
${GUIDIR}/guikeys.inc ${GUIDIR}/guicheat.inc\
${GUIDIR}/guicombo.inc ${GUIDIR}/guiload.inc macros.mac
+${GUIDIR}/guifuncs.o: ${GUIDIR}/guifuncs.c
${GUIDIR}/menu.o: ${GUIDIR}/menu.asm macros.mac
${VIDEODIR}/newgfx.o:${VIDEODIR}/newgfx.asm ${VIDEODIR}/vidmacro.mac\
${VIDEODIR}/newgfx2.mac ${VIDEODIR}/newgfx.mac macros.mac
New file:
Code: Select all
/*
Copyright (C) 1997-2005 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach )
http://www.zsnes.com
http://sourceforge.net/projects/zsnes
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.
*/
#ifdef __LINUX__
#include "gblhdr.h"
#define DIR_SLASH "/"
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#define DIR_SLASH "\\"
#endif
#include "gblvars.h"
bool dirstringcmp(char *string1, char *string2)
{ // compares two strings - returns true if string1 is >, else 0
if (!strcmp(string1, ".")) { return (false); }
if (!strcmp(string2, ".")) { return (true); }
if (!strcmp(string1, "..")) { return (false); }
if (!strcmp(string2, "..")) { return (true); }
return (strcasecmp(string1, string2) > 0); // if equal -> false
}
char GUIStringGreater()
{
char *ptr = (char *)tempesi;
return ((char)dirstringcmp(ptr, ptr+32));
}
char GUIStringGreater2()
{
char **ptr = (char **)tempesi;
return ((char)dirstringcmp((*ptr)+1, (*(ptr+1))+1)); // *(ptr+1) == [esi+4]
}
I agree that this is only temporary. Once the calling code is cleaner, you can fuse the two easily.
But in the meantime, wrapping to a common func from 2 small funcs is easier, safer and gets the job done.
tempesi is a var used to keep backups of esi (durr..), so I used it here.
For GUIStringGreater2, I included the pointer magic done in the asm to set the proper addresses in ebx/edx, so it looks weirder than GUIStringGreater1 but does the same.