pandora wip..
authornotaz <notasas@gmail.com>
Thu, 24 Jul 2008 10:29:17 +0000 (10:29 +0000)
committernotaz <notasas@gmail.com>
Thu, 24 Jul 2008 10:29:17 +0000 (10:29 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@562 be3aeb3a-fb24-0410-a615-afba39da0efa

platform/pandora/Makefile
platform/pandora/asm_utils.h [new file with mode: 0644]
platform/pandora/asm_utils.s [new file with mode: 0644]
platform/pandora/emu.c
platform/pandora/pandora.c

index 016a76f..9cd4e1f 100644 (file)
@@ -2,6 +2,7 @@ export CROSS = arm-none-linux-gnueabi-
 \r
 # settings\r
 #mz80 = 1\r
+#cz80 = 1\r
 #debug_cyclone = 1\r
 asm_memory = 1\r
 asm_render = 1\r
@@ -12,7 +13,7 @@ asm_cdmemory = 1
 amalgamate = 0\r
 #profile = 1\r
 #use_musashi = 1\r
-#up = 1\r
+#use_famec = 1\r
 \r
 \r
 ifeq "$(debug_cyclone)" "1"\r
@@ -28,9 +29,9 @@ use_cyclone = 1
 endif\r
 \r
 DEFINC = -I../.. -I. -DARM -DPANDORA\r
-COPT_COMMON = -static -Wall -Winline\r
+COPT_COMMON = -Wall -Winline -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a\r
 ifeq ($(DEBUG),)\r
-COPT_COMMON += -O3 -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
+COPT_COMMON += -O2 # -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
 else\r
 COPT_COMMON += -ggdb\r
 endif\r
@@ -49,7 +50,7 @@ LD = $(CROSS)ld
 OBJCOPY = $(CROSS)objcopy\r
 \r
 # frontend\r
-OBJS += pandora.o main.o emu.o platform/gp2x/menu.o platform/gp2x/usbjoy.o\r
+OBJS += pandora.o main.o emu.o asm_utils.o platform/gp2x/menu.o platform/gp2x/usbjoy.o\r
 \r
 # common\r
 OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \\r
@@ -123,14 +124,23 @@ ifeq "$(use_cyclone)" "1"
 DEFINC += -DEMU_C68K\r
 OBJS += cpu/Cyclone/proj/Cyclone.o cpu/Cyclone/tools/idle.o\r
 endif\r
+ifeq "$(use_famec)" "1"\r
+DEFINC += -DEMU_F68K\r
+OBJS += cpu/fame/famec.o\r
+endif\r
 # drz80/mz80\r
 ifeq "$(mz80)" "1"\r
 DEFINC += -D_USE_MZ80\r
 OBJS += cpu/mz80/mz80.o\r
 else\r
+ifeq "$(cz80)" "1"\r
+DEFINC += -D_USE_CZ80\r
+OBJS += cpu/cz80/cz80.o\r
+else\r
 DEFINC += -D_USE_DRZ80\r
 OBJS += cpu/DrZ80/drz80.o\r
 endif\r
+endif\r
 \r
 vpath %.c = ../..\r
 vpath %.s = ../..\r
diff --git a/platform/pandora/asm_utils.h b/platform/pandora/asm_utils.h
new file mode 100644 (file)
index 0000000..881b0cd
--- /dev/null
@@ -0,0 +1,2 @@
+
+void clut_line(void *dest, const void *src, const unsigned short *pal, int pixels_mask);
diff --git a/platform/pandora/asm_utils.s b/platform/pandora/asm_utils.s
new file mode 100644 (file)
index 0000000..a117d2d
--- /dev/null
@@ -0,0 +1,56 @@
+@ vim:filetype=armasm
+
+
+.global clut_line @ void *dest, void *src, unsigned short *pal, int pixels_mask
+
+clut_line:
+    stmfd   sp!, {r4-r11,lr}
+
+    and     lr, r3, #0xff0000
+    mov     lr, lr, lsr #15        @ mask
+    mov     r3, r3, lsr #3
+    and     r3, r3, #0xff          @ counter
+    add     r11,r0, #800*2
+
+clut_line_loop:
+    ldmia   r1!, {r10,r12}
+
+    and     r4, lr, r10, lsl #1
+    ldrh    r4, [r2, r4]
+    and     r5, lr, r10, lsr #7
+    ldrh    r5, [r2, r5]
+    orr     r4, r4, r4,  lsl #16
+
+    and     r6, lr, r10, lsr #15
+    ldrh    r6, [r2, r6]
+    orr     r5, r5, r5,  lsl #16
+
+    and     r7, lr, r10, lsr #23
+    ldrh    r7, [r2, r7]
+    orr     r6, r6, r6,  lsl #16
+
+    and     r8, lr, r12, lsl #1
+    ldrh    r8, [r2, r8]
+    orr     r7, r7, r7,  lsl #16
+
+    and     r9, lr, r12, lsr #7
+    ldrh    r9, [r2, r9]
+    orr     r8, r8, r8,  lsl #16
+
+    and     r10,lr, r12, lsr #15
+    ldrh    r10,[r2, r10]
+    orr     r9, r9, r9,  lsl #16
+
+    and     r12,lr, r12, lsr #23
+    ldrh    r12,[r2, r12]
+    orr     r10,r10,r10, lsl #16
+
+    subs    r3, r3, #1
+    orr     r12,r12,r12, lsl #16
+
+    stmia   r0!, {r4-r10,r12}
+    stmia   r11!,{r4-r10,r12}
+    bne     clut_line_loop
+
+    ldmfd   sp!, {r4-r11,pc}
+
index 16fa519..7c2af03 100644 (file)
@@ -1,4 +1,4 @@
-// (c) Copyright 2006-2007 notaz, All rights reserved.\r
+// (c) Copyright 2006-2008 notaz, All rights reserved.\r
 // Free for non-commercial use.\r
 \r
 // For commercial use, separate licencing terms must be obtained.\r
@@ -22,6 +22,7 @@
 #include "../common/emu.h"\r
 #include "../common/config.h"\r
 #include "../common/common.h"\r
+#include "asm_utils.h"\r
 \r
 #include <Pico/PicoInt.h>\r
 #include <Pico/Patch.h>\r
@@ -29,6 +30,8 @@
 #include <zlib/zlib.h>\r
 \r
 //#define PFRAMES\r
+#define BENCHMARK\r
+//#define USE_320_SCREEN 1\r
 \r
 #ifdef BENCHMARK\r
 #define OSD_FPS_X (800-200)\r
@@ -133,12 +136,14 @@ void emu_prepareDefaultConfig(void)
 {\r
        memset(&defaultConfig, 0, sizeof(defaultConfig));\r
        defaultConfig.EmuOpt    = 0x9f | 0x00700; // | <- ram_tmng, confirm_save, cd_leds\r
-       defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES|POPT_EN_MCD_GFX;\r
+       defaultConfig.s_PicoOpt  = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC;\r
+       defaultConfig.s_PicoOpt |= POPT_ACC_SPRITES|POPT_EN_MCD_GFX;\r
+       defaultConfig.s_PicoOpt &= ~POPT_EN_SVP_DRC; // crashes :(\r
        defaultConfig.s_PsndRate = 44100;\r
        defaultConfig.s_PicoRegion = 0; // auto\r
        defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP\r
        defaultConfig.s_PicoCDBuffers = 0;\r
-       defaultConfig.Frameskip = 0; // auto\r
+       defaultConfig.Frameskip = 0;\r
        defaultConfig.CPUclock = 200;\r
        defaultConfig.volume = 50;\r
        defaultConfig.scaling = 0;\r
@@ -162,18 +167,28 @@ static void textOut16(int x, int y, const char *text)
 \r
        for (i = 0; i < len; i++)\r
        {\r
-               for (l=0;l<16;l+=2)\r
+               for (l=0;l<16;)\r
                {\r
                        unsigned char fd = fontdata8x8[((text[i])*8)+l/2];\r
-                       int u = l+1;\r
-                       if(fd&0x80) screen[l*SCREEN_WIDTH/2+0]=screen[u*SCREEN_WIDTH/2+0]=0xffffffff;\r
-                       if(fd&0x40) screen[l*SCREEN_WIDTH/2+1]=screen[u*SCREEN_WIDTH/2+1]=0xffffffff;\r
-                       if(fd&0x20) screen[l*SCREEN_WIDTH/2+2]=screen[u*SCREEN_WIDTH/2+2]=0xffffffff;\r
-                       if(fd&0x10) screen[l*SCREEN_WIDTH/2+3]=screen[u*SCREEN_WIDTH/2+3]=0xffffffff;\r
-                       if(fd&0x08) screen[l*SCREEN_WIDTH/2+4]=screen[u*SCREEN_WIDTH/2+4]=0xffffffff;\r
-                       if(fd&0x04) screen[l*SCREEN_WIDTH/2+5]=screen[u*SCREEN_WIDTH/2+5]=0xffffffff;\r
-                       if(fd&0x02) screen[l*SCREEN_WIDTH/2+6]=screen[u*SCREEN_WIDTH/2+6]=0xffffffff;\r
-                       if(fd&0x01) screen[l*SCREEN_WIDTH/2+7]=screen[u*SCREEN_WIDTH/2+7]=0xffffffff;\r
+                       unsigned int *d = &screen[l*SCREEN_WIDTH/2];\r
+                       if (fd&0x80) d[0]=0xffffffff;\r
+                       if (fd&0x40) d[1]=0xffffffff;\r
+                       if (fd&0x20) d[2]=0xffffffff;\r
+                       if (fd&0x10) d[3]=0xffffffff;\r
+                       if (fd&0x08) d[4]=0xffffffff;\r
+                       if (fd&0x04) d[5]=0xffffffff;\r
+                       if (fd&0x02) d[6]=0xffffffff;\r
+                       if (fd&0x01) d[7]=0xffffffff;\r
+                       l++; d = &screen[l*SCREEN_WIDTH/2];\r
+                       if (fd&0x80) d[0]=0xffffffff;\r
+                       if (fd&0x40) d[1]=0xffffffff;\r
+                       if (fd&0x20) d[2]=0xffffffff;\r
+                       if (fd&0x10) d[3]=0xffffffff;\r
+                       if (fd&0x08) d[4]=0xffffffff;\r
+                       if (fd&0x04) d[5]=0xffffffff;\r
+                       if (fd&0x02) d[6]=0xffffffff;\r
+                       if (fd&0x01) d[7]=0xffffffff;\r
+                       l++;\r
                }\r
                screen += 8;\r
        }\r
@@ -199,7 +214,7 @@ void osd_text(int x, int y, const char *text)
                len++;\r
                for (h = 0; h < 16; h++) {\r
                        p = (int *) ((unsigned short *) gp2x_screen+x+SCREEN_WIDTH*(y+h));\r
-                       for (i = len; i; i--, p++) *p = (*p>>2)&0x39e7;\r
+                       for (i = len; i; i--, p++) *p = 0;//(*p>>2)&0x39e7;\r
                }\r
                textOut16(x, y, text);\r
        }\r
@@ -252,6 +267,20 @@ static void draw_pico_ptr(void)
        p[640] ^= 0xffff;\r
 }\r
 \r
+#ifdef USE_320_SCREEN\r
+\r
+static int EmuScanBegin16(unsigned int num)\r
+{\r
+       if (!(Pico.video.reg[1]&8)) num += 8;\r
+       DrawLineDest = (unsigned short *)gp2x_screen + num*800 + 800/2 - 320/2;\r
+       //int w = (Pico.video.reg[12]&1) ? 320 : 256;\r
+       //DrawLineDest = (unsigned short *)gp2x_screen + num*w;\r
+\r
+       return 0;\r
+}\r
+\r
+#else // USE_320_SCREEN\r
+\r
 static int EmuScanEnd16(unsigned int num)\r
 {\r
        unsigned char  *ps=HighCol+8;\r
@@ -269,14 +298,16 @@ static int EmuScanEnd16(unsigned int num)
        if (Pico.video.reg[12]&1) {\r
                len = 320;\r
        } else {\r
-               pd+=32;\r
+               pd += 32*2;\r
                len = 256;\r
        }\r
 \r
        if (!sh && (rendstatus & PDRAW_ACC_SPRITES))\r
                mask=0x3f; // accurate sprites, upper bits are priority stuff\r
 \r
-\r
+#if 1\r
+       clut_line(pd, ps, pal, (mask<<16) | len);\r
+#else\r
        for (; len > 0; len--)\r
        {\r
                unsigned int p = pal[*ps++ & mask];\r
@@ -285,10 +316,13 @@ static int EmuScanEnd16(unsigned int num)
                *(unsigned int *)(&pd[800]) = p;\r
                pd += 2;\r
        }\r
+#endif\r
 \r
        return 0;\r
 }\r
 \r
+#endif // USE_320_SCREEN\r
+\r
 static int EmuScanBegin8(unsigned int num)\r
 {\r
        if (!(Pico.video.reg[1]&8)) num += 8;\r
@@ -365,7 +399,7 @@ static void blit(const char *fps, const char *notice)
                if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8)) h -= 16;\r
                if (notice) osd_text(4, h, notice);\r
                if (emu_opt & 2)\r
-                       osd_text(osd_fps_x+24*2, h-8, fps);\r
+                       osd_text(osd_fps_x, h, fps);\r
        }\r
        if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))\r
                draw_cd_leds();\r
@@ -402,8 +436,13 @@ static void vidResetMode(void)
                gp2x_video_changemode(8);\r
        } else if (currentConfig.EmuOpt&0x80) {\r
                gp2x_video_changemode(16);\r
+#ifdef USE_320_SCREEN\r
+               PicoDrawSetColorFormat(1);\r
+               PicoScanBegin = EmuScanBegin16;\r
+#else\r
                PicoDrawSetColorFormat(-1);\r
                PicoScanEnd = EmuScanEnd16;\r
+#endif\r
        } else {\r
                gp2x_video_changemode(8);\r
                PicoDrawSetColorFormat(2);\r
@@ -726,8 +765,13 @@ void emu_forcedFrame(int opts)
        currentConfig.EmuOpt |= 0x80;\r
 \r
        //vidResetMode();\r
+#ifdef USE_320_SCREEN\r
+       PicoDrawSetColorFormat(1);\r
+       PicoScanBegin = EmuScanBegin16;\r
+#else\r
        PicoDrawSetColorFormat(-1);\r
        PicoScanEnd = EmuScanEnd16;\r
+#endif\r
        Pico.m.dirtyPal = 1;\r
        PicoFrameDrawOnly();\r
 \r
@@ -886,18 +930,17 @@ void emu_Loop(void)
                {\r
 #ifdef BENCHMARK\r
                        static int bench = 0, bench_fps = 0, bench_fps_s = 0, bfp = 0, bf[4];\r
-                       if (++bench == 10) {\r
+                       if (++bench == 4) {\r
                                bench = 0;\r
-                               bench_fps_s = bench_fps;\r
-                               bf[bfp++ & 3] = bench_fps;\r
+                               bench_fps_s = bench_fps / 4;\r
+                               bf[bfp++ & 3] = bench_fps / 4;\r
                                bench_fps = 0;\r
                        }\r
                        bench_fps += frames_shown;\r
-                       sprintf(fpsbuff, "%02i/%02i/%02i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2);\r
+                       sprintf(fpsbuff, "%3i/%3i/%3i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2);\r
 #else\r
                        if (currentConfig.EmuOpt & 2) {\r
-                               //sprintf(fpsbuff, "%02i/%02i", frames_shown, frames_done);\r
-                               sprintf(fpsbuff, "%4i", frames_shown);\r
+                               sprintf(fpsbuff, "%3i/%3i", frames_shown, frames_done);\r
                                if (fpsbuff[5] == 0) { fpsbuff[5] = fpsbuff[6] = ' '; fpsbuff[7] = 0; }\r
                        }\r
 #endif\r
index 1779725..2e69798 100644 (file)
@@ -22,7 +22,8 @@ int memdev = 0;
 static int sounddev = -1, mixerdev = -1, touchdev = -1;\r
 static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };\r
 \r
-#define SCREEN_MAP_SIZE (((800*(480+11)*2)+0xfff)&~0xfff)\r
+//#define SCREEN_MAP_SIZE (((800*(480+11)*2)+0xfff)&~0xfff)\r
+#define SCREEN_MAP_SIZE (800*480*2)\r
 static void *screen;\r
 void *gp2x_screen;\r
 \r
@@ -237,7 +238,8 @@ void gp2x_init(void)
                exit(1);\r
        }\r
        printf("fbptr %p\n", screen);\r
-       gp2x_screen = (char *)screen + 800*10*2-64;\r
+//     gp2x_screen = (char *)screen + 800*10*2-64;\r
+       gp2x_screen = screen;\r
 \r
 \r
        // snd\r