Fixed SDL port compiling. Use the asm core when compiling with USEASM=yes. Optimized the renderer a bit. FF4 intro should be a bit faster, now.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@249 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
jbo_85 2007-12-31 01:24:58 +00:00
parent db7617b2be
commit 2b0ede21e3
4 changed files with 99 additions and 104 deletions

View File

@ -1,9 +1,9 @@
CC=gcc CC=gcc
CPPC=g++ CPPC=g++
CFLAGS=-W -Wall -Wno-unused -O3 -DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DFINAL_VERSION -DBKPT_SUPPORT -DC_CORE -DSDL -DSYSCONFDIR="home" -DUSE_OPENGL CFLAGS=-W -Wall -Wno-unused -O3 -DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DFINAL_VERSION -DBKPT_SUPPORT -DSDL -DSYSCONFDIR="home" -DUSE_OPENGL
CXXFLAGS=${CFLAGS} CXXFLAGS=${CFLAGS}
ASM=nasm ASM=nasm
ASMFLAGS=-w-orphan-labels -f elf -DELF -O1 -Isrc/ ASMFLAGS=-w-orphan-labels -f elf -DELF -O1 -Isrc/hq/asm/
LFLAGS=-lz -lpng -lGL `sdl-config --libs` LFLAGS=-lz -lpng -lGL `sdl-config --libs`
STRIP=strip -s STRIP=strip -s
DEL=rm -f DEL=rm -f
@ -11,7 +11,7 @@ OE=.o
OUT=vba OUT=vba
ifeq ($(PLATFORM),win) ifeq ($(PLATFORM),win)
ASMFLAGS=-w-orphan-labels -f win32 -O1 -Isrc/ ASMFLAGS=-w-orphan-labels -f win32 -O1 -Isrc/hq/asm/
LFLAGS=-lz -lpng -lSDL -lwsock32 -lopengl32 LFLAGS=-lz -lpng -lSDL -lwsock32 -lopengl32
DELETECOMMAND = del DELETECOMMAND = del
OE=.obj OE=.obj
@ -21,7 +21,7 @@ endif
ifeq ($(PLATFORM),win-cross) ifeq ($(PLATFORM),win-cross)
CC=i586-mingw32-gcc CC=i586-mingw32-gcc
CPPC=i586-mingw32-g++ CPPC=i586-mingw32-g++
ASMFLAGS=-w-orphan-labels -f win32 -O1 -Isrc/ ASMFLAGS=-w-orphan-labels -f win32 -O1 -Isrc/hq/asm/
LFLAGS=-lz -lpng -lSDL -lwsock32 -lopengl32 LFLAGS=-lz -lpng -lSDL -lwsock32 -lopengl32
STRIP=i586-mingw32-strip -s STRIP=i586-mingw32-strip -s
OE=.obj OE=.obj
@ -33,16 +33,17 @@ SDLDIR=src/sdl
DMGDIR=src/gb DMGDIR=src/gb
GBAPUDIR=src/gb/gb_apu GBAPUDIR=src/gb/gb_apu
FEXDIR=../dependencies/File_Extractor-0.4.3 FEXDIR=../dependencies/File_Extractor-0.4.3
HQCDIR=src/hq/c
HQASMDIR=src/hq/asm
ASMOBJ=${MAINDIR}/hq3x_16${OE} ${MAINDIR}/hq3x_32${OE} ${MAINDIR}/hq4x_16${OE} ${MAINDIR}/hq4x_32${OE} \ ASMOBJ=${HQASMDIR}/hq3x_16${OE} ${HQASMDIR}/hq3x_32${OE} ${HQASMDIR}/hq4x_16${OE} \
${MAINDIR}/hq3x32${OE} ${HQASMDIR}/hq4x_32${OE} ${HQASMDIR}/hq3x32${OE}
GBAPUOBJ=${GBAPUDIR}/Blip_Buffer${OE} ${GBAPUDIR}/Effects_Buffer${OE} ${GBAPUDIR}/Gb_Apu${OE} \ GBAPUOBJ=${GBAPUDIR}/Blip_Buffer${OE} ${GBAPUDIR}/Effects_Buffer${OE} ${GBAPUDIR}/Gb_Apu${OE} \
${GBAPUDIR}/Gb_Apu_State${OE} ${GBAPUDIR}/Gb_Oscs${OE} ${GBAPUDIR}/Multi_Buffer${OE} ${GBAPUDIR}/Gb_Apu_State${OE} ${GBAPUDIR}/Gb_Oscs${OE} ${GBAPUDIR}/Multi_Buffer${OE}
CALTERNOBJ=${MAINDIR}/hq3x16c${OE} ${MAINDIR}/hq3x32c${OE} ${MAINDIR}/hq4x16c${OE} ${MAINDIR}/hq4x32c${OE} \ CALTERNOBJ=${HQCDIR}/hq_implementation${OE}
${MAINDIR}/hq_shared32${OE}
MAINOBJ=${MAINDIR}/2xSaI${OE} ${MAINDIR}/admame${OE} ${MAINDIR}/agbprint${OE} ${MAINDIR}/armdis${OE} \ MAINOBJ=${MAINDIR}/2xSaI${OE} ${MAINDIR}/admame${OE} ${MAINDIR}/agbprint${OE} ${MAINDIR}/armdis${OE} \
${MAINDIR}/bilinear${OE} ${MAINDIR}/bios${OE} ${MAINDIR}/Cheats${OE} ${MAINDIR}/CheatSearch${OE} \ ${MAINDIR}/bilinear${OE} ${MAINDIR}/bios${OE} ${MAINDIR}/Cheats${OE} ${MAINDIR}/CheatSearch${OE} \
@ -68,6 +69,7 @@ ifeq ($(USEASM),yes)
OBJECTS+=${ASMOBJ} OBJECTS+=${ASMOBJ}
else else
OBJECTS+=${CALTERNOBJ} OBJECTS+=${CALTERNOBJ}
CFLAGS+=-DC_CORE
endif endif
ifeq ($(USEFEX),yes) ifeq ($(USEFEX),yes)

View File

@ -321,10 +321,10 @@ static void count(u32 opcode, int cond_res)
#define EMIT1(op,arg) #op" "arg"; " #define EMIT1(op,arg) #op" "arg"; "
#define EMIT2(op,src,dest) #op" "src", "dest"; " #define EMIT2(op,src,dest) #op" "src", "dest"; "
#define CONST(val) "$"#val #define CONST(val) "$"#val
#define VAR(var) #var #define VAR(var) "_"#var
#define VARL(var) #var #define VARL(var) "_"#var
#define REGREF1(index) "reg("index")" #define REGREF1(index) "_reg("index")"
#define REGREF2(index,scale) "reg(,"index","#scale")" #define REGREF2(index,scale) "_reg(,"index","#scale")"
#define LABEL(n) #n": " #define LABEL(n) #n": "
#define LABELREF(n,dir) #n#dir #define LABELREF(n,dir) #n#dir
#define al "%%al" #define al "%%al"
@ -697,7 +697,7 @@ static void count(u32 opcode, int cond_res)
: "0" (offset), "c" (shift)); : "0" (offset), "c" (shift));
#define RRX_OFFSET \ #define RRX_OFFSET \
asm("btl $0, C_FLAG;" \ asm("btl $0, _C_FLAG;" \
"rcr $1, %0" \ "rcr $1, %0" \
: "=r" (offset) \ : "=r" (offset) \
: "0" (offset)); : "0" (offset));

View File

@ -324,95 +324,95 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
#define ADD_RN_O8(d) \ #define ADD_RN_O8(d) \
asm ("andl $0xFF, %%eax;"\ asm ("andl $0xFF, %%eax;"\
"addl %%eax, %0;"\ "addl %%eax, %0;"\
"setsb N_FLAG;"\ "setsb _N_FLAG;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
"setcb C_FLAG;"\ "setcb _C_FLAG;"\
"setob V_FLAG;"\ "setob _V_FLAG;"\
: "=m" (reg[(d)].I)); : "=m" (reg[(d)].I));
#define CMN_RD_RS \ #define CMN_RD_RS \
asm ("add %0, %1;"\ asm ("add %0, %1;"\
"setsb N_FLAG;"\ "setsb _N_FLAG;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
"setcb C_FLAG;"\ "setcb _C_FLAG;"\
"setob V_FLAG;"\ "setob _V_FLAG;"\
: \ : \
: "r" (value), "r" (reg[dest].I):"1"); : "r" (value), "r" (reg[dest].I):"1");
#define ADC_RD_RS \ #define ADC_RD_RS \
asm ("bt $0, C_FLAG;"\ asm ("bt $0, _C_FLAG;"\
"adc %1, %%ebx;"\ "adc %1, %%ebx;"\
"setsb N_FLAG;"\ "setsb _N_FLAG;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
"setcb C_FLAG;"\ "setcb _C_FLAG;"\
"setob V_FLAG;"\ "setob _V_FLAG;"\
: "=b" (reg[dest].I)\ : "=b" (reg[dest].I)\
: "r" (value), "b" (reg[dest].I)); : "r" (value), "b" (reg[dest].I));
#define SUB_RN_O8(d) \ #define SUB_RN_O8(d) \
asm ("andl $0xFF, %%eax;"\ asm ("andl $0xFF, %%eax;"\
"subl %%eax, %0;"\ "subl %%eax, %0;"\
"setsb N_FLAG;"\ "setsb _N_FLAG;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
"setncb C_FLAG;"\ "setncb _C_FLAG;"\
"setob V_FLAG;"\ "setob _V_FLAG;"\
: "=m" (reg[(d)].I)); : "=m" (reg[(d)].I));
#define MOV_RN_O8(d) \ #define MOV_RN_O8(d) \
asm ("andl $0xFF, %%eax;"\ asm ("andl $0xFF, %%eax;"\
"movb $0, N_FLAG;"\ "movb $0, _N_FLAG;"\
"movl %%eax, %0;"\ "movl %%eax, %0;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
: "=m" (reg[(d)].I)); : "=m" (reg[(d)].I));
#define CMP_RN_O8(d) \ #define CMP_RN_O8(d) \
asm ("andl $0xFF, %%eax;"\ asm ("andl $0xFF, %%eax;"\
"cmpl %%eax, %0;"\ "cmpl %%eax, %0;"\
"setsb N_FLAG;"\ "setsb _N_FLAG;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
"setncb C_FLAG;"\ "setncb _C_FLAG;"\
"setob V_FLAG;"\ "setob _V_FLAG;"\
: \ : \
: "m" (reg[(d)].I)); : "m" (reg[(d)].I));
#define SBC_RD_RS \ #define SBC_RD_RS \
asm volatile ("bt $0, C_FLAG;"\ asm volatile ("bt $0, _C_FLAG;"\
"cmc;"\ "cmc;"\
"sbb %1, %%ebx;"\ "sbb %1, %%ebx;"\
"setsb N_FLAG;"\ "setsb _N_FLAG;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
"setncb C_FLAG;"\ "setncb _C_FLAG;"\
"setob V_FLAG;"\ "setob _V_FLAG;"\
: "=b" (reg[dest].I)\ : "=b" (reg[dest].I)\
: "r" (value), "b" (reg[dest].I) : "cc", "memory"); : "r" (value), "b" (reg[dest].I) : "cc", "memory");
#define LSL_RD_RS \ #define LSL_RD_RS \
asm ("shl %%cl, %%eax;"\ asm ("shl %%cl, %%eax;"\
"setcb C_FLAG;"\ "setcb _C_FLAG;"\
: "=a" (value)\ : "=a" (value)\
: "a" (reg[dest].I), "c" (value)); : "a" (reg[dest].I), "c" (value));
#define LSR_RD_RS \ #define LSR_RD_RS \
asm ("shr %%cl, %%eax;"\ asm ("shr %%cl, %%eax;"\
"setcb C_FLAG;"\ "setcb _C_FLAG;"\
: "=a" (value)\ : "=a" (value)\
: "a" (reg[dest].I), "c" (value)); : "a" (reg[dest].I), "c" (value));
#define ASR_RD_RS \ #define ASR_RD_RS \
asm ("sar %%cl, %%eax;"\ asm ("sar %%cl, %%eax;"\
"setcb C_FLAG;"\ "setcb _C_FLAG;"\
: "=a" (value)\ : "=a" (value)\
: "a" (reg[dest].I), "c" (value)); : "a" (reg[dest].I), "c" (value));
#define ROR_RD_RS \ #define ROR_RD_RS \
asm ("ror %%cl, %%eax;"\ asm ("ror %%cl, %%eax;"\
"setcb C_FLAG;"\ "setcb _C_FLAG;"\
: "=a" (value)\ : "=a" (value)\
: "a" (reg[dest].I), "c" (value)); : "a" (reg[dest].I), "c" (value));
#define NEG_RD_RS \ #define NEG_RD_RS \
asm ("neg %%ebx;"\ asm ("neg %%ebx;"\
"setsb N_FLAG;"\ "setsb _N_FLAG;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
"setncb C_FLAG;"\ "setncb _C_FLAG;"\
"setob V_FLAG;"\ "setob _V_FLAG;"\
: "=b" (reg[dest].I)\ : "=b" (reg[dest].I)\
: "b" (reg[source].I)); : "b" (reg[source].I));
#define CMP_RD_RS \ #define CMP_RD_RS \
asm ("sub %0, %1;"\ asm ("sub %0, %1;"\
"setsb N_FLAG;"\ "setsb _N_FLAG;"\
"setzb Z_FLAG;"\ "setzb _Z_FLAG;"\
"setncb C_FLAG;"\ "setncb _C_FLAG;"\
"setob V_FLAG;"\ "setob _V_FLAG;"\
: \ : \
: "r" (value), "r" (reg[dest].I):"1"); : "r" (value), "r" (reg[dest].I):"1");
#define IMM5_INSN(OP,N) \ #define IMM5_INSN(OP,N) \
@ -420,75 +420,75 @@ static INSN_REGPARM void thumbBreakpoint(u32 opcode)
"shrl $1,%%eax;" \ "shrl $1,%%eax;" \
"andl $7,%%ecx;" \ "andl $7,%%ecx;" \
"andl $0x1C,%%eax;" \ "andl $0x1C,%%eax;" \
"movl reg(%%eax),%%edx;" \ "movl _reg(%%eax),%%edx;" \
OP \ OP \
"setsb N_FLAG;" \ "setsb _N_FLAG;" \
"setzb Z_FLAG;" \ "setzb _Z_FLAG;" \
"movl %%edx,reg(,%%ecx,4);" \ "movl %%edx,_reg(,%%ecx,4);" \
: : "i" (N)) : : "i" (N))
#define IMM5_INSN_0(OP) \ #define IMM5_INSN_0(OP) \
asm("movl %%eax,%%ecx;" \ asm("movl %%eax,%%ecx;" \
"shrl $1,%%eax;" \ "shrl $1,%%eax;" \
"andl $7,%%ecx;" \ "andl $7,%%ecx;" \
"andl $0x1C,%%eax;" \ "andl $0x1C,%%eax;" \
"movl reg(%%eax),%%edx;" \ "movl _reg(%%eax),%%edx;" \
OP \ OP \
"setsb N_FLAG;" \ "setsb _N_FLAG;" \
"setzb Z_FLAG;" \ "setzb _Z_FLAG;" \
"movl %%edx,reg(,%%ecx,4);" \ "movl %%edx,_reg(,%%ecx,4);" \
: : ) : : )
#define IMM5_LSL \ #define IMM5_LSL \
"shll %0,%%edx;"\ "shll %0,%%edx;"\
"setcb C_FLAG;" "setcb _C_FLAG;"
#define IMM5_LSL_0 \ #define IMM5_LSL_0 \
"testl %%edx,%%edx;" "testl %%edx,%%edx;"
#define IMM5_LSR \ #define IMM5_LSR \
"shrl %0,%%edx;"\ "shrl %0,%%edx;"\
"setcb C_FLAG;" "setcb _C_FLAG;"
#define IMM5_LSR_0 \ #define IMM5_LSR_0 \
"testl %%edx,%%edx;"\ "testl %%edx,%%edx;"\
"setsb C_FLAG;"\ "setsb _C_FLAG;"\
"xorl %%edx,%%edx;" "xorl %%edx,%%edx;"
#define IMM5_ASR \ #define IMM5_ASR \
"sarl %0,%%edx;"\ "sarl %0,%%edx;"\
"setcb C_FLAG;" "setcb _C_FLAG;"
#define IMM5_ASR_0 \ #define IMM5_ASR_0 \
"sarl $31,%%edx;"\ "sarl $31,%%edx;"\
"setsb C_FLAG;" "setsb _C_FLAG;"
#define THREEARG_INSN(OP,N) \ #define THREEARG_INSN(OP,N) \
asm("movl %%eax,%%edx;" \ asm("movl %%eax,%%edx;" \
"shrl $1,%%edx;" \ "shrl $1,%%edx;" \
"andl $0x1C,%%edx;" \ "andl $0x1C,%%edx;" \
"andl $7,%%eax;" \ "andl $7,%%eax;" \
"movl reg(%%edx),%%ecx;" \ "movl _reg(%%edx),%%ecx;" \
OP(N) \ OP(N) \
"setsb N_FLAG;" \ "setsb _N_FLAG;" \
"setzb Z_FLAG;" \ "setzb _Z_FLAG;" \
"movl %%ecx,reg(,%%eax,4)"::) "movl %%ecx,_reg(,%%eax,4)"::)
#define ADD_RD_RS_RN(N) \ #define ADD_RD_RS_RN(N) \
"add (reg+"#N"*4),%%ecx;" \ "add (_reg+"#N"*4),%%ecx;" \
"setcb C_FLAG;" \ "setcb _C_FLAG;" \
"setob V_FLAG;" "setob _V_FLAG;"
#define ADD_RD_RS_O3(N) \ #define ADD_RD_RS_O3(N) \
"add $"#N",%%ecx;" \ "add $"#N",%%ecx;" \
"setcb C_FLAG;" \ "setcb _C_FLAG;" \
"setob V_FLAG;" "setob _V_FLAG;"
#define ADD_RD_RS_O3_0(N) \ #define ADD_RD_RS_O3_0(N) \
"movb $0,C_FLAG;" \ "movb $0,_C_FLAG;" \
"add $0,%%ecx;" \ "add $0,%%ecx;" \
"movb $0,V_FLAG;" "movb $0,_V_FLAG;"
#define SUB_RD_RS_RN(N) \ #define SUB_RD_RS_RN(N) \
"sub (reg+"#N"*4),%%ecx;" \ "sub (_reg+"#N"*4),%%ecx;" \
"setncb C_FLAG;" \ "setncb _C_FLAG;" \
"setob V_FLAG;" "setob _V_FLAG;"
#define SUB_RD_RS_O3(N) \ #define SUB_RD_RS_O3(N) \
"sub $"#N",%%ecx;" \ "sub $"#N",%%ecx;" \
"setncb C_FLAG;" \ "setncb _C_FLAG;" \
"setob V_FLAG;" "setob _V_FLAG;"
#define SUB_RD_RS_O3_0(N) \ #define SUB_RD_RS_O3_0(N) \
"movb $1,C_FLAG;" \ "movb $1,_C_FLAG;" \
"sub $0,%%ecx;" \ "sub $0,%%ecx;" \
"movb $0,V_FLAG;" "movb $0,_V_FLAG;"
#endif #endif
#else // !__GNUC__ #else // !__GNUC__
#define ADD_RD_RS_RN(N) \ #define ADD_RD_RS_RN(N) \

View File

@ -297,6 +297,11 @@ static inline void gfxDrawRotScreen(u16 control,
break; break;
} }
int maskX = sizeX-1;
int maskY = sizeY-1;
int yshift = ((control >> 14) & 3)+4;
int dx = pa & 0x7FFF; int dx = pa & 0x7FFF;
if(pa & 0x8000) if(pa & 0x8000)
dx |= 0xFFFF8000; dx |= 0xFFFF8000;
@ -343,12 +348,8 @@ static inline void gfxDrawRotScreen(u16 control,
int yyy = (realY >> 8); int yyy = (realY >> 8);
if(control & 0x2000) { if(control & 0x2000) {
xxx %= sizeX; xxx &= maskX;
yyy %= sizeY; yyy &= maskY;
if(xxx < 0)
xxx += sizeX;
if(yyy < 0)
yyy += sizeY;
} }
if(control & 0x80) { if(control & 0x80) {
@ -359,7 +360,7 @@ static inline void gfxDrawRotScreen(u16 control,
yyy >= sizeY) { yyy >= sizeY) {
line[x] = 0x80000000; line[x] = 0x80000000;
} else { } else {
int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)]; int tile = screenBase[(xxx>>3) + ((yyy>>3)<<yshift)];
int tileX = (xxx & 7); int tileX = (xxx & 7);
int tileY = yyy & 7; int tileY = yyy & 7;
@ -375,12 +376,8 @@ static inline void gfxDrawRotScreen(u16 control,
yyy = (realY >> 8); yyy = (realY >> 8);
if(control & 0x2000) { if(control & 0x2000) {
xxx %= sizeX; xxx &= maskX;
yyy %= sizeY; yyy &= maskY;
if(xxx < 0)
xxx += sizeX;
if(yyy < 0)
yyy += sizeY;
} }
} }
} else { } else {
@ -391,7 +388,7 @@ static inline void gfxDrawRotScreen(u16 control,
yyy >= sizeY) { yyy >= sizeY) {
line[x] = 0x80000000; line[x] = 0x80000000;
} else { } else {
int tile = screenBase[(xxx>>3) + (yyy>>3)*(sizeX>>3)]; int tile = screenBase[(xxx>>3) + ((yyy>>3)<<yshift)];
int tileX = (xxx & 7); int tileX = (xxx & 7);
int tileY = yyy & 7; int tileY = yyy & 7;
@ -407,12 +404,8 @@ static inline void gfxDrawRotScreen(u16 control,
yyy = (realY >> 8); yyy = (realY >> 8);
if(control & 0x2000) { if(control & 0x2000) {
xxx %= sizeX; xxx &= maskX;
yyy %= sizeY; yyy &= maskY;
if(xxx < 0)
xxx += sizeX;
if(yyy < 0)
yyy += sizeY;
} }
} }
} }