general cleanup
authorJavier S. Pedro <maemo@javispedro.com>
Wed, 9 Sep 2009 19:15:47 +0000 (21:15 +0200)
committerJavier S. Pedro <maemo@javispedro.com>
Wed, 9 Sep 2009 19:15:47 +0000 (21:15 +0200)
Makefile
cpuexec.h
hacks.cpp
os9x_65c816.s
os9x_asm_cpu.cpp

index 24aac73..f23764b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,11 +4,17 @@ CPPFLAGS := -I. $(shell sdl-config --cflags) $(shell pkg-config --cflags x11 xsp
 LDLIBS := -lz $(shell sdl-config --libs) $(shell pkg-config --libs x11 xsp) -lpopt -lhgw
 
 # Default CFLAGS for building in N8x0
-ARCH ?= arm
+ARCH ?= armel
 CFLAGS ?= -DMAEMO -DMAEMO_VERSION=4 -march=armv6j -mtune=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp -O2 -g -Wall -static-libgcc
 ASFLAGS ?= -march=armv6j -mfpu=vfp -mfloat-abi=softfp -g
 CXXFLAGS ?= $(CFLAGS)
 
+# Default CFLAGS for building in PC
+#ARCH := i386
+#CFLAGS := -DMAEMO -DMAEMO_VERSION=4 -O2 -g -Wall
+#ASFLAGS := -g
+#CXXFLAGS := $(CFLAGS)
+
 GAME_VERSION ?= $(shell head -n 1 debian/changelog | sed 's/[^0-9.-]//g')-git
 export GAME_VERSION
 export DESTDIR
@@ -16,17 +22,18 @@ export DESTDIR
 # Configuration settings
 CONF_BUILD_ASM_CPU=0
 CONF_BUILD_ASM_SPC700=0
+CONF_BUILD_ASM_SA1=0   # Still not there
 
-ifeq ($(ARCH),arm)
+ifeq ($(ARCH),armel)
        CONF_BUILD_ASM_CPU=1
        CONF_BUILD_ASM_SPC700=1
-       CONF_BUILD_ROUTINES=misc_armel
-else ifeq ($(ARCH),intel)
-       CONF_BUILD_ROUTINES=misc_i386
+       CONF_BUILD_MISC_ROUTINES=misc_armel
+else ifeq ($(ARCH),i386)
+       CONF_BUILD_MISC_ROUTINES=misc_i386
 endif
 
 # SNES stuff
-OBJS = 2xsaiwin.o apu.o c4.o c4emu.o cheats.o cheats2.o clip.o cpu.o cpuexec.o data.o
+OBJS = apu.o c4.o c4emu.o cheats.o cheats2.o clip.o cpu.o cpuexec.o data.o
 OBJS += dma.o dsp1.o fxemu.o fxinst.o gfx.o globals.o loadzip.o memmap.o netplay.o ppu.o
 OBJS += sa1.o sdd1.o sdd1emu.o snapshot.o soundux.o spc700.o srtc.o tile.o
 
@@ -35,7 +42,7 @@ ifeq ($(CONF_BUILD_ASM_CPU), 1)
        OBJS += os9x_asm_cpu.o os9x_65c816.o
        CPPFLAGS += -DCONF_BUILD_ASM_CPU=1
 else
-       OBJS += cpuops.o sa1cpu.o
+       OBJS += cpuops.o
 endif
 
 ifeq ($(CONF_BUILD_ASM_SPC700), 1)
@@ -43,7 +50,13 @@ ifeq ($(CONF_BUILD_ASM_SPC700), 1)
        CPPFLAGS += -DCONF_BUILD_ASM_SPC700=1
 endif
 
-OBJS += $(CONF_BUILD_ROUTINES).o
+ifeq ($(CONF_BUILD_ASM_SA1), 1)
+       crash
+else
+       OBJS += sa1cpu.o
+endif
+
+OBJS += $(CONF_BUILD_MISC_ROUTINES).o
 
 # from open-whatever sdk
 OBJS += unzip.o ioapi.o
index 8db96b0..495155b 100644 (file)
--- a/cpuexec.h
+++ b/cpuexec.h
@@ -46,7 +46,7 @@
 
 #define DO_HBLANK_CHECK() \
     if (CPU.Cycles >= CPU.NextEvent) \
-       S9xDoHBlankProcessing ();
+               S9xDoHBlankProcessing ();
 
 struct SOpcodes {
        void (*S9xOpcode)();
index 1f9baa8..191c704 100644 (file)
--- a/hacks.cpp
+++ b/hacks.cpp
@@ -24,12 +24,18 @@ static unsigned long getGameCrc32()
 static int loadHacks(char * line)
 {
        int count = 0;
+       bool end_of_line = false;
        char *pos = strchr(line, '|'), *start = line;
-       // Skip: Title[start..pos]
+       // Title[start..pos]
+       *pos = '\0';
+       printf("Hacks: detected \"%s\"\n", start);
 
        start = pos + 1;
        pos = strchr(start, '|');
-       if (!pos) return -1;
+       if (!pos) {
+               // If there are no flags, jump directly to hacks
+               goto parse_hacks;
+       }
        // Skip: Flags1[start..pos]
 
        start = pos + 1;
@@ -59,8 +65,8 @@ static int loadHacks(char * line)
        if (!pos) return 0; // No patches!
 
        start = pos + 1;
-       bool end_of_line = false;
-       printf("Loading patches: %s", start);
+
+parse_hacks:
        do {
                char *end;
                unsigned long addr;
@@ -106,10 +112,12 @@ static int loadHacks(char * line)
                        char valStr[3] = { pos[0], pos[1], '\0' };
                        unsigned char val = strtoul(valStr, 0, 16);
 
+#ifdef DEBUG
                        printf("ROM[0x%lx..0x%lx]=0x%hhx 0x%hhx 0x%hhx\n", 
                                addr + i - 1, addr + i + 1,
                                ROM[addr + i - 1], ROM[addr + i], ROM[addr + i + 1]);
                        printf("--> ROM[0x%lx]=0x%hhx\n", addr + i, val);
+#endif
                        ROM[addr + i] = val;
 
                        count++;
@@ -153,13 +161,13 @@ void S9xHacksLoadFile(const char * file)
                        // Hit! This line's CRC matches our current ROM CRC.
                        int res = loadHacks(pos + 1);
                        if (res > 0) {
-                               printf("Hacks: searched %s for crc %lx, %d hacks loaded\n",
-                                       file, gameCrc, res);
+                               printf("Hacks: searched %s for crc %lX, %d byte%s patched\n",
+                                       file, gameCrc, res, (res == 1 ? "" : "s"));
                        } else if (res < 0) {
-                               printf("Hacks: searched %s for crc %lx, error parsing line\n",
+                               printf("Hacks: searched %s for crc %lX, error parsing line\n",
                                        file, gameCrc);
                        } else {
-                               printf("Hacks: searched %s for crc %lx, no hacks\n",
+                               printf("Hacks: searched %s for crc %lX, no hacks\n",
                                        file, gameCrc);
                        }
                        goto hacks_found;
@@ -170,7 +178,7 @@ void S9xHacksLoadFile(const char * file)
                fprintf(stderr, "Error reading hacks file: %s\n", file);
        }
 
-       printf("Hacks: searched %s for crc %lu; nothing found\n", file, gameCrc);
+       printf("Hacks: searched %s for crc %lX; nothing found\n", file, gameCrc);
 
 hacks_found:
        free(line);
index 766c5c8..ad72c44 100644 (file)
@@ -1,10 +1,8 @@
-       .DATA
+
 /****************************************************************      
 ****************************************************************/
-       .align 4
-
-    @ notaz
-       .equiv ASM_SPC700,              1               ;@ 1 = use notaz's ASM_SPC700 core
+@ notaz
+.equiv ASM_SPC700,             1               ;@ 1 = use notaz's ASM_SPC700 core
 
 /****************************************************************
        DEFINES
@@ -37,24 +35,11 @@ rscratch9   .req R10 @ ??????
 reg_cpu_var .req R14
 
 
-
 @ not used
 @ R13  @ Pointer 32 bit on a struct.
 
 @ R15 = pc (sic!)
 
-
-/*
-.equ Carry       1
-.equ Zero        2
-.equ IRQ         4
-.equ Decimal     8
-.equ IndexFlag  16
-.equ MemoryFlag 32
-.equ Overflow   64
-.equ Negative  128
-.equ Emulation 256*/
-
 .equ STATUS_SHIFTER,           24
 .equ MASK_EMUL,                (1<<(STATUS_SHIFTER-1))
 .equ MASK_SHIFTER_CARRY,       (STATUS_SHIFTER+1)
@@ -1150,6 +1135,8 @@ reg_cpu_var .req R14
 
 .text
 
+.align 4
+
 .globl asmS9xGetByte
 .globl asmS9xGetWord
 .globl asmS9xSetByte
index 84719ad..f0af5f6 100644 (file)
@@ -17,7 +17,7 @@ void asm_S9xSetPCBase(uint32 Address)
 {
 #ifdef __debug_c_setpc__
        printf("spcb\n");
-#endif 
+#endif
        S9xSetPCBase(Address);  
 }