Merge branch 'libretro' into libretro-reset libretro-reset github/libretro-reset
authornotaz <notasas@gmail.com>
Sat, 14 Oct 2017 18:31:28 +0000 (21:31 +0300)
committernotaz <notasas@gmail.com>
Sat, 14 Oct 2017 18:31:28 +0000 (21:31 +0300)
This effectively resets libretro git to upstream and syncs both repos.
Everything in platform/libretro should be retained as I imported that in
my git verbatim, but some core changes may be lost and will have to be
redone. I've checked that picodrive_libretro.so builds and works on x86,
and Android also builds for all archs. I've even bothered to try it
under msvc where it's building for me too.

With this you also get the benefits from significant accuracy improvement
work from 1.92.

100 files changed:
Makefile
Makefile.libretro
README
configure
cpu/cyclone
cpu/cyclone_config.h
cpu/cyclone_config_armv4.h [new file with mode: 0644]
cpu/cz80/cz80.c
cpu/debug.h
cpu/drc/cmn.c
cpu/drc/cmn.h
cpu/drc/emit_arm.c
cpu/fame/famec.c
cpu/fame/famec_opcodes.h
cpu/musashi/m68k_in.c
cpu/musashi/m68kcpu.c
cpu/musashi/m68kcpu.h
cpu/musashi/m68kmake.c
cpu/sh2/compiler.c
cpu/sh2/mame/sh2pico.c
cpu/sh2/sh2.h
jni/Android.mk
jni/Application.mk
pico/32x/32x.c
pico/32x/draw.c [moved from pico/32x/32x_draw.c with 99% similarity]
pico/32x/memory.c [moved from pico/32x/32x_memory.c with 99% similarity]
pico/32x/pwm.c
pico/cart.c
pico/carthw.cfg
pico/carthw/carthw.c
pico/carthw/eeprom_spi.c [new file with mode: 0644]
pico/carthw/eeprom_spi.h [new file with mode: 0644]
pico/carthw/svp/memory.c [moved from pico/carthw/svp/svp_memory.c with 98% similarity]
pico/carthw/svp/svp.c
pico/carthw_cfg.c
pico/cd/cdd.c
pico/cd/gfx_dma.c
pico/cd/mcd.c
pico/cd/memory.c [moved from pico/cd/cd_memory.c with 94% similarity]
pico/cd/memory_arm.S [moved from pico/cd/memory_arm.s with 93% similarity]
pico/cd/misc.c [moved from pico/cd/cd_misc.c with 100% similarity]
pico/cd/sek.c [moved from pico/cd/cd_sek.c with 96% similarity]
pico/debug.c
pico/draw.c
pico/draw2.c
pico/draw2_arm.S
pico/draw_amips.s [deleted file]
pico/draw_arm.S
pico/eeprom.c
pico/memory.c
pico/memory.h
pico/memory_amips.S [moved from pico/memory_amips.s with 93% similarity]
pico/memory_arm.S [moved from pico/memory_arm.s with 73% similarity]
pico/misc.c
pico/misc_amips.s
pico/misc_arm.s
pico/mode4.c
pico/patch.c
pico/pico.c
pico/pico.h
pico/pico/memory.c [moved from pico/pico/pico_memory.c with 100% similarity]
pico/pico/pico.c [moved from pico/pico/pico_pico.c with 98% similarity]
pico/pico_cmn.c
pico/pico_int.h
pico/pico_int_o32.h
pico/pico_port.h [new file with mode: 0644]
pico/sek.c
pico/sms.c
pico/sound/sn76496.c
pico/sound/sound.c
pico/sound/ym2612.c
pico/sound/ym2612.h
pico/sound/ym2612_arm.s
pico/state.c
pico/videoport.c
pico/z80if.c
platform/common/common.mak
platform/common/config_file.c
platform/common/emu.c
platform/common/input_pico.h
platform/common/menu_pico.c
platform/common/mp3.c
platform/common/mp3_libavcodec.c
platform/common/plat_sdl.c
platform/common/version.h
platform/gp2x/940ctl.c
platform/gp2x/emu.c
platform/libpicofe
platform/libretro/libretro.c
platform/libretro/msvc/msvc-2010/msvc-2010.suo [deleted file]
platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj
platform/libretro/msvc/msvc-2010/msvc-2010.vcxproj.filters
platform/libretro/psp/draw_amips.s [deleted file]
platform/linux/emu.c
platform/pandora/Makefile
platform/pandora/PicoDrive.pxml.template
platform/pandora/make_pxml.sh
platform/pandora/plat.c
platform/psp/emu.c
tools/mkoffsets.c

index 9b7e37e..f0cd64e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,14 @@
 TARGET ?= PicoDrive
-DEBUG = 0
-CFLAGS += -Wall 
-CFLAGS += -I. -DINLINE=inline
-
-ifeq ($(DEBUG),1)
-       CFLAGS += -g -O0
-else
-       ifeq ($(platform), vita)
-               CFLAGS += -O3 -DNDEBUG
-       else
-               CFLAGS += -O2 -DNDEBUG -ffunction-sections
-       endif
-endif
-
-ifneq ($(APPLE),1)
-       LDFLAGS += -Wl,--gc-sections
+CFLAGS += -Wall -g
+CFLAGS += -I.
+ifndef DEBUG
+CFLAGS += -O3 -DNDEBUG
 endif
 
-#CFLAGS += -DEVT_LOG
-#CFLAGS += -DDRC_CMP
-#cpu_cmp = 1
-#drc_debug = 7
-#profile = 1
-
-ifeq ($(WANT_GDB),1)
-CFLAGS += ggdb -falign-functions=2
+# This is actually needed, bevieve me.
+# If you really have to disable this, set NO_ALIGN_FUNCTIONS elsewhere.
+ifndef NO_ALIGN_FUNCTIONS
+CFLAGS += -falign-functions=2
 endif
 
 all: config.mak target_
@@ -64,11 +48,6 @@ endif
 
 -include Makefile.local
 
-ifneq "$(use_cyclone)" "1"
-# due to CPU stop flag access
-asm_cdmemory = 0
-endif
-
 ifeq "$(PLATFORM)" "opendingux"
 opk: $(TARGET).opk
 
@@ -84,6 +63,18 @@ OBJS += platform/opendingux/inputmap.o
 # OpenDingux is a generic platform, really.
 PLATFORM := generic
 endif
+ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","rpi1" "rpi2"))
+CFLAGS += -DHAVE_GLES -DRASPBERRY
+CFLAGS += -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux/
+LDFLAGS += -ldl -lbcm_host -L/opt/vc/lib -lEGL -lGLESv2
+OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
+OBJS += platform/common/plat_sdl.o
+OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
+OBJS += platform/libpicofe/plat_dummy.o
+OBJS += platform/libpicofe/gl.o
+OBJS += platform/libpicofe/gl_platform.o
+USE_FRONTEND = 1
+endif
 ifeq "$(PLATFORM)" "generic"
 OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
 OBJS += platform/common/plat_sdl.o
@@ -120,7 +111,7 @@ USE_FRONTEND = 1
 PLATFORM_MP3 = 1
 endif
 ifeq "$(PLATFORM)" "libretro"
-OBJS += platform/libretro/libretro.o 
+OBJS += platform/libretro/libretro.o
 endif
 
 ifeq "$(USE_FRONTEND)" "1"
@@ -191,7 +182,7 @@ clean:
 
 $(TARGET): $(OBJS)
 ifeq ($(STATIC_LINKING), 1)
-       $(AR) rcs $@ $(OBJS)
+       $(AR) rcs $@ $^
 else
        $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) $(LDLIBS)
 endif
@@ -212,16 +203,27 @@ tools/textfilter: tools/textfilter.c
 pico/draw.o: CFLAGS += -fno-strict-aliasing
 pico/draw2.o: CFLAGS += -fno-strict-aliasing
 pico/mode4.o: CFLAGS += -fno-strict-aliasing
-pico/cd/cd_memory.o: CFLAGS += -fno-strict-aliasing
+pico/cd/memory.o: CFLAGS += -fno-strict-aliasing
 pico/cd/cd_file.o: CFLAGS += -fno-strict-aliasing
 pico/cd/pcm.o: CFLAGS += -fno-strict-aliasing
 pico/cd/LC89510.o: CFLAGS += -fno-strict-aliasing
 pico/cd/gfx_cd.o: CFLAGS += -fno-strict-aliasing
 
+# fame needs ~2GB of RAM to compile on gcc 4.8
+# on x86, this is reduced by ~300MB when debug info is off (but not on ARM)
+# not using O3 and -fno-expensive-optimizations seems to also help, but you may
+# want to remove this stuff for better performance if your compiler can handle it
+ifndef DEBUG
+cpu/fame/famec.o: CFLAGS += -g0 -O2 -fno-expensive-optimizations
+endif
+
+pico/carthw_cfg.c: pico/carthw.cfg
+       tools/make_carthw_c $< $@
+
 # random deps
 pico/carthw/svp/compiler.o : cpu/drc/emit_$(ARCH).c
 cpu/sh2/compiler.o : cpu/drc/emit_$(ARCH).c
 cpu/sh2/mame/sh2pico.o : cpu/sh2/mame/sh2.c
 pico/pico.o pico/cd/mcd.o pico/32x/32x.o : pico/pico_cmn.c pico/pico_int.h
-pico/memory.o pico/cd/cd_memory.o pico/32x/32x_memory.o : pico/pico_int.h pico/memory.h
+pico/memory.o pico/cd/memory.o pico/32x/memory.o : pico/pico_int.h pico/memory.h
 cpu/fame/famec.o: cpu/fame/famec.c cpu/fame/famec_opcodes.h
index 14f2dc5..b35a0da 100644 (file)
@@ -215,7 +215,7 @@ else ifeq ($(platform), psp1)
     CC = psp-gcc$(EXE_EXT)
     AR = psp-ar$(EXE_EXT)
     CFLAGS += -G0 -ftracer
-    CFLAGS += -DPSP -D_ASM_DRAW_C_AMIPS
+    CFLAGS += -DPSP
     STATIC_LINKING = 1
     NO_MMAP = 1
     DONT_COMPILE_IN_ZLIB = 1
@@ -232,8 +232,6 @@ else ifeq ($(platform), psp1)
     use_drz80 = 0
     use_cz80 = 1
 
-    OBJS +=platform/libretro/psp/draw_amips.o
-
 # CTR (3DS)
 else ifeq ($(platform), ctr)
    TARGET := $(TARGET_NAME)_libretro_$(platform).a
diff --git a/README b/README
index fbcecc1..d9c1091 100644 (file)
--- a/README
+++ b/README
@@ -13,3 +13,9 @@ then taken over and expanded by notaz.
 PicoDrive was the first emulator ever to properly emulate Virtua Racing and
 it's SVP chip.
 
+How to compile on Raspbian Wheezy:
+
+export CC=gcc-4.8
+export CXX=g++-4.8
+./configure --platform=rpi2
+make
index a25e7c1..1310ab2 100755 (executable)
--- a/configure
+++ b/configure
@@ -31,7 +31,7 @@ check_define()
 # setting options to "yes" or "no" will make that choice default,
 # "" means "autodetect".
 
-platform_list="generic pandora gp2x opendingux"
+platform_list="generic pandora gp2x opendingux rpi1 rpi2"
 platform="generic"
 sound_driver_list="oss alsa sdl"
 sound_drivers=""
@@ -44,6 +44,8 @@ need_sdl="no"
 need_xlib="no"
 # these are for known platforms
 optimize_cortexa8="no"
+optimize_cortexa7="no"
+optimize_arm1176jzf="no"
 optimize_arm926ej="no"
 optimize_arm920="no"
 
@@ -67,6 +69,13 @@ set_platform()
 {
   platform=$1
   case "$platform" in
+  rpi1)
+    optimize_arm1176jzf="yes"
+    ;;
+  rpi2)
+    optimize_cortexa7="yes"
+    have_arm_neon="yes"
+    ;;
   generic)
     ;;
   opendingux)
@@ -159,6 +168,14 @@ arm*)
     CFLAGS="$CFLAGS -mcpu=cortex-a8 -mtune=cortex-a8"
     ASFLAGS="$ASFLAGS -mcpu=cortex-a8"
   fi
+  if [ "$optimize_cortexa7" = "yes" ]; then
+    CFLAGS="$CFLAGS -mcpu=cortex-a7"
+    ASFLAGS="$ASFLAGS -mcpu=cortex-a7"
+  fi
+  if [ "$optimize_arm1176jzf" = "yes" ]; then
+    CFLAGS="$CFLAGS -mcpu=arm1176jzf-s -mfloat-abi=hard"
+    ASFLAGS="$ASFLAGS -mcpu=arm1176jzf-s -mfloat-abi=hard"
+  fi
   if [ "$optimize_arm926ej" = "yes" ]; then
     CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
     ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
@@ -229,7 +246,7 @@ arm*)
 esac
 
 case "$platform" in
-generic | opendingux)
+rpi1 | rpi2 | generic | opendingux)
   need_sdl="yes"
   ;;
 esac
index 66dda84..b889883 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 66dda842eae01f47f5389b931ec9567fb0bbb6a1
+Subproject commit b889883d36b2d247488c82d79d1eaab4dd41d236
index 13e2c5e..2320517 100644 (file)
@@ -8,6 +8,9 @@
 **/\r
 \r
 \r
+#ifndef HAVE_ARMv6\r
+#define HAVE_ARMv6                  1\r
+#endif\r
 #define USE_MS_SYNTAX               0\r
 #define CYCLONE_FOR_GENESIS         2\r
 #define COMPRESS_JUMPTABLE          0\r
diff --git a/cpu/cyclone_config_armv4.h b/cpu/cyclone_config_armv4.h
new file mode 100644 (file)
index 0000000..2319029
--- /dev/null
@@ -0,0 +1,2 @@
+#define HAVE_ARMv6 0
+#include "cyclone_config.h"
index 28d762c..61ca5f8 100644 (file)
@@ -216,7 +216,7 @@ void Cz80_Reset(cz80_struc *CPU)
 \r
 /* */\r
 #if PICODRIVE_HACKS\r
-static INLINE unsigned char picodrive_read(unsigned short a)\r
+static inline unsigned char picodrive_read(unsigned short a)\r
 {\r
        uptr v = z80_read_map[a >> Z80_MEM_SHIFT];\r
        if (map_flag_set(v))\r
index 4ad618d..63728ad 100644 (file)
@@ -26,6 +26,6 @@ int pdb_net_connect(const char *host, const char *port);
 
 #else
 
-static INLINE int pdb_net_connect(const char *host, const char *port) {return 0;}
+static __inline int pdb_net_connect(const char *host, const char *port) {return 0;}
 
 #endif
index 721340a..27ff981 100644 (file)
@@ -1,8 +1,6 @@
 /*
  * PicoDrive
  * Copyright (C) 2009,2010 notaz
- * Copyright (C) 2016      lentillog
- * Copyright (C) 2016      Daniel De Matteis
  *
  * This work is licensed under the terms of MAME license.
  * See COPYING file in the top-level directory.
 #include <pico/pico_int.h>
 #include "cmn.h"
 
-#ifdef _MSC_VER
-u8 tcache[DRC_TCACHE_SIZE];
-#elif defined(VITA)
-#include <psp2/kernel/sysmem.h>
+u8 ALIGNED(4096) tcache_default[DRC_TCACHE_SIZE];
 u8 *tcache;
-static int sceBlock;
-int getVMBlock();
-#else
-u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE];
-#endif
-
 
 void drc_cmn_init(void)
 {
-#ifdef VITA
-   sceBlock = getVMBlock();
-   sceKernelGetMemBlockBase(sceBlock, (void **)&tcache);
-#endif
+  int ret;
+
+  tcache = plat_mem_get_for_drc(DRC_TCACHE_SIZE);
+  if (tcache == NULL)
+    tcache = tcache_default;
 
-  int ret = plat_mem_set_exec(tcache, sizeof(tcache));
+  ret = plat_mem_set_exec(tcache, DRC_TCACHE_SIZE);
   elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d",
-    tcache, sizeof(tcache), ret);
+    tcache, DRC_TCACHE_SIZE, ret);
 
 #ifdef __arm__
   if (PicoOpt & POPT_EN_DRC)
index e6da6ea..8953edd 100644 (file)
@@ -5,11 +5,7 @@ typedef unsigned int   u32;
 
 #define DRC_TCACHE_SIZE         (2*1024*1024)
 
-#ifdef VITA
 extern u8 *tcache;
-#else
-extern u8 tcache[DRC_TCACHE_SIZE];
-#endif
 
 void drc_cmn_init(void);
 void drc_cmn_cleanup(void);
index 26289a4..64face1 100644 (file)
@@ -1,8 +1,6 @@
 /*
  * Basic macros to emit ARM instructions and some utils
  * Copyright (C) 2008,2009,2010 notaz
- * Copyright (C) 2016      lentillog
- * Copyright (C) 2016      Daniel De Matteis
  *
  * This work is licensed under the terms of MAME license.
  * See COPYING file in the top-level directory.
index 9e9dc15..db4eae6 100644 (file)
@@ -742,6 +742,9 @@ static FAMEC_EXTRA_INLINE u32 execute_exception(s32 vect, u32 oldPC, u32 oldSR)
        //u32 oldSR = GET_SR;\r
 \r
         m68kcontext.io_cycle_counter -= exception_cycle_table[vect];\r
+#ifdef FAMEC_EMULATE_TRACE\r
+       m68kcontext.execinfo &= ~FM68K_EMULATE_TRACE;\r
+#endif\r
 \r
        PRE_IO\r
 \r
@@ -763,6 +766,7 @@ static FAMEC_EXTRA_INLINE u32 execute_exception(s32 vect, u32 oldPC, u32 oldSR)
 \r
        /* adjust SR */\r
        flag_S = M68K_SR_S;\r
+       flag_T = 0;\r
 \r
 #ifndef FAMEC_32BIT_PC\r
        newPC&=M68K_ADR_MASK\r
@@ -916,12 +920,11 @@ famec_Exec:
 #ifdef FAMEC_EMULATE_TRACE\r
        if (m68kcontext.execinfo & FM68K_EMULATE_TRACE)\r
        {\r
-               m68kcontext.io_cycle_counter = cycles_needed;\r
+               m68kcontext.io_cycle_counter += cycles_needed;\r
                cycles_needed = 0;\r
                m68kcontext.execinfo &= ~FM68K_EMULATE_TRACE;\r
                m68kcontext.execinfo |= FM68K_DO_TRACE;\r
                SET_PC(execute_exception(M68K_TRACE_EX, GET_PC, GET_SR));\r
-               flag_T=0;\r
                if (m68kcontext.io_cycle_counter > 0)\r
                {\r
                        //NEXT\r
@@ -933,9 +936,9 @@ famec_Exec:
                if (cycles_needed != 0)\r
                {\r
                        u32 line;\r
-                       m68kcontext.io_cycle_counter = cycles_needed;\r
+                       m68kcontext.io_cycle_counter += cycles_needed;\r
                        cycles_needed = 0;\r
-                       if (m68kcontext.io_cycle_counter <= 0) goto famec_End;\r
+                       //if (m68kcontext.io_cycle_counter <= 0) goto famec_End;\r
                        line=interrupt_chk__();\r
                        if (line>0)\r
                        {\r
index c690b45..2df6d78 100644 (file)
@@ -16936,18 +16936,20 @@ OPCODE(0x4800)
        u32 adr, res;
        u32 src, dst;
 
-       res = DREGu8((Opcode >> 0) & 7);
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       dst = DREGu8((Opcode >> 0) & 7);
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       DREGu8((Opcode >> 0) & 7) = res;
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               DREGu8((Opcode >> 0) & 7) = res;
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
 RET(6)
 }
@@ -16960,18 +16962,20 @@ OPCODE(0x4810)
 
        adr = AREG((Opcode >> 0) & 7);
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(12)
@@ -16986,18 +16990,20 @@ OPCODE(0x4818)
        adr = AREG((Opcode >> 0) & 7);
        AREG((Opcode >> 0) & 7) += 1;
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(12)
@@ -17012,18 +17018,20 @@ OPCODE(0x4820)
        adr = AREG((Opcode >> 0) & 7) - 1;
        AREG((Opcode >> 0) & 7) = adr;
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(14)
@@ -17038,18 +17046,20 @@ OPCODE(0x4828)
        FETCH_SWORD(adr);
        adr += AREG((Opcode >> 0) & 7);
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(16)
@@ -17064,18 +17074,20 @@ OPCODE(0x4830)
        adr = AREG((Opcode >> 0) & 7);
        DECODE_EXT_WORD
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(18)
@@ -17089,18 +17101,20 @@ OPCODE(0x4838)
 
        FETCH_SWORD(adr);
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(16)
@@ -17114,18 +17128,20 @@ OPCODE(0x4839)
 
        FETCH_LONG(adr);
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(20)
@@ -17140,18 +17156,20 @@ OPCODE(0x481F)
        adr = AREG(7);
        AREG(7) += 2;
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(12)
@@ -17166,18 +17184,20 @@ OPCODE(0x4827)
        adr = AREG(7) - 2;
        AREG(7) = adr;
        PRE_IO
-       READ_BYTE_F(adr, res)
-       res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+       READ_BYTE_F(adr, dst)
+       res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
 
-       if (res != 0x9a)
+       if (res != 0)
        {
-               if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
-               res &= 0xFF;
-       WRITE_BYTE_F(adr, res)
+               flag_V = res;
+               if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+               res = (res + 0x9a) & 0xFF;
+               WRITE_BYTE_F(adr, res)
+               flag_V &= ~res;
                flag_NotZ |= res;
                flag_X = flag_C = M68K_SR_C;
        }
-       else flag_X = flag_C = 0;
+       else flag_V = flag_X = flag_C = 0;
        flag_N = res;
        POST_IO
 RET(14)
@@ -18554,6 +18574,10 @@ RET(8)
 // ILLEGAL
 OPCODE(0x4AFC)
 {
+#ifdef PICODRIVE_HACK
+       extern void SekFinishIdleDet(void);
+       SekFinishIdleDet();
+#endif
        SET_PC(execute_exception(M68K_ILLEGAL_INSTRUCTION_EX, GET_PC-2, GET_SR));
 RET(0)
 }
@@ -19573,12 +19597,11 @@ RET(14)
 // CHK
 OPCODE(0x4180)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
 
-       src = DREGu16((Opcode >> 0) & 7);
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       src = DREGs16((Opcode >> 0) & 7);
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19589,14 +19612,14 @@ RET(10)
 // CHK
 OPCODE(0x4190)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        adr = AREG((Opcode >> 0) & 7);
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19608,15 +19631,15 @@ RET(14)
 // CHK
 OPCODE(0x4198)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        adr = AREG((Opcode >> 0) & 7);
        AREG((Opcode >> 0) & 7) += 2;
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19628,15 +19651,15 @@ RET(14)
 // CHK
 OPCODE(0x41A0)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        adr = AREG((Opcode >> 0) & 7) - 2;
        AREG((Opcode >> 0) & 7) = adr;
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19648,15 +19671,15 @@ RET(16)
 // CHK
 OPCODE(0x41A8)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        FETCH_SWORD(adr);
        adr += AREG((Opcode >> 0) & 7);
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19668,15 +19691,15 @@ RET(18)
 // CHK
 OPCODE(0x41B0)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        adr = AREG((Opcode >> 0) & 7);
        DECODE_EXT_WORD
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19688,14 +19711,14 @@ RET(20)
 // CHK
 OPCODE(0x41B8)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        FETCH_SWORD(adr);
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19707,14 +19730,14 @@ RET(18)
 // CHK
 OPCODE(0x41B9)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        FETCH_LONG(adr);
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19726,15 +19749,15 @@ RET(22)
 // CHK
 OPCODE(0x41BA)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19746,15 +19769,15 @@ RET(18)
 // CHK
 OPCODE(0x41BB)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19766,12 +19789,12 @@ RET(20)
 // CHK
 OPCODE(0x41BC)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
-       FETCH_WORD(src);
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       FETCH_SWORD(src);
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19783,15 +19806,15 @@ RET(14)
 // CHK
 OPCODE(0x419F)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        adr = AREG(7);
        AREG(7) += 2;
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -19803,15 +19826,15 @@ RET(14)
 // CHK
 OPCODE(0x41A7)
 {
-       u32 adr, res;
-       u32 src, dst;
+       s32 src, res;
+       u32 adr;
 
        adr = AREG(7) - 2;
        AREG(7) = adr;
        PRE_IO
-       READ_WORD_F(adr, src)
-       res = DREGu16((Opcode >> 9) & 7);
-       if (((s32)res < 0) || (res > src))
+       READSX_WORD_F(adr, src)
+       res = DREGs16((Opcode >> 9) & 7);
+       if ((res < 0) || (res > src))
        {
                flag_N = res >> 8;
                SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
@@ -26934,19 +26957,19 @@ OPCODE(0x8100)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        src = DREGu8((Opcode >> 0) & 7);
        dst = DREGu8((Opcode >> 9) & 7);
        res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res -= 6;
+       if (res > 0xF) corf = 6;
        res += (dst & 0xF0) - (src & 0xF0);
-       if (res > 0x99)
-       {
-               res += 0xA0;
-               flag_X = flag_C = M68K_SR_C;
-       }
-       else flag_X = flag_C = 0;
-       flag_NotZ |= res & 0xFF;
+       flag_V = res;
+       flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+       if (res > 0xff) res += 0xA0;
+       res = (res - corf) & 0xFF;
+       flag_V &= ~res;
+       flag_NotZ |= res;
        flag_N = res;
        DREGu8((Opcode >> 9) & 7) = res;
 RET(6)
@@ -26957,6 +26980,7 @@ OPCODE(0x8108)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        adr = AREG((Opcode >> 0) & 7) - 1;
        AREG((Opcode >> 0) & 7) = adr;
@@ -26966,15 +26990,14 @@ OPCODE(0x8108)
        AREG((Opcode >> 9) & 7) = adr;
        READ_BYTE_F(adr, dst)
        res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res -= 6;
+       if (res > 0xF) corf = 6;
        res += (dst & 0xF0) - (src & 0xF0);
-       if (res > 0x99)
-       {
-               res += 0xA0;
-               flag_X = flag_C = M68K_SR_C;
-       }
-       else flag_X = flag_C = 0;
-       flag_NotZ |= res & 0xFF;
+       flag_V = res;
+       flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+       if (res > 0xff) res += 0xA0;
+       res = (res - corf) & 0xFF;
+       flag_V &= ~res;
+       flag_NotZ |= res;
        flag_N = res;
        WRITE_BYTE_F(adr, res)
        POST_IO
@@ -26986,6 +27009,7 @@ OPCODE(0x810F)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        adr = AREG(7) - 2;
        AREG(7) = adr;
@@ -26995,15 +27019,14 @@ OPCODE(0x810F)
        AREG((Opcode >> 9) & 7) = adr;
        READ_BYTE_F(adr, dst)
        res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res -= 6;
+       if (res > 0xF) corf = 6;
        res += (dst & 0xF0) - (src & 0xF0);
-       if (res > 0x99)
-       {
-               res += 0xA0;
-               flag_X = flag_C = M68K_SR_C;
-       }
-       else flag_X = flag_C = 0;
-       flag_NotZ |= res & 0xFF;
+       flag_V = res;
+       flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+       if (res > 0xff) res += 0xA0;
+       res = (res - corf) & 0xFF;
+       flag_V &= ~res;
+       flag_NotZ |= res;
        flag_N = res;
        WRITE_BYTE_F(adr, res)
        POST_IO
@@ -27015,6 +27038,7 @@ OPCODE(0x8F08)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        adr = AREG((Opcode >> 0) & 7) - 1;
        AREG((Opcode >> 0) & 7) = adr;
@@ -27024,15 +27048,14 @@ OPCODE(0x8F08)
        AREG(7) = adr;
        READ_BYTE_F(adr, dst)
        res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res -= 6;
+       if (res > 0xF) corf = 6;
        res += (dst & 0xF0) - (src & 0xF0);
-       if (res > 0x99)
-       {
-               res += 0xA0;
-               flag_X = flag_C = M68K_SR_C;
-       }
-       else flag_X = flag_C = 0;
-       flag_NotZ |= res & 0xFF;
+       flag_V = res;
+       flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+       if (res > 0xff) res += 0xA0;
+       res = (res - corf) & 0xFF;
+       flag_V &= ~res;
+       flag_NotZ |= res;
        flag_N = res;
        WRITE_BYTE_F(adr, res)
        POST_IO
@@ -27044,6 +27067,7 @@ OPCODE(0x8F0F)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        adr = AREG(7) - 2;
        AREG(7) = adr;
@@ -27053,15 +27077,14 @@ OPCODE(0x8F0F)
        AREG(7) = adr;
        READ_BYTE_F(adr, dst)
        res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res -= 6;
+       if (res > 0xF) corf = 6;
        res += (dst & 0xF0) - (src & 0xF0);
-       if (res > 0x99)
-       {
-               res += 0xA0;
-               flag_X = flag_C = M68K_SR_C;
-       }
-       else flag_X = flag_C = 0;
-       flag_NotZ |= res & 0xFF;
+       flag_V = res;
+       flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+       if (res > 0xff) res += 0xA0;
+       res = (res - corf) & 0xFF;
+       flag_V &= ~res;
+       flag_NotZ |= res;
        flag_N = res;
        WRITE_BYTE_F(adr, res)
        POST_IO
@@ -27419,7 +27442,7 @@ OPCODE(0x80F9)
        {
                SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(152)
 #else
 RET(22)
 #endif
@@ -27435,7 +27458,7 @@ RET(22)
                {
                        flag_V = M68K_SR_V;
 #ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(152)
 #else
        RET(82)
 #endif
@@ -27448,7 +27471,7 @@ RET(162)
        DREGu32((Opcode >> 9) & 7) = res;
        }
 #ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(152)
 #else
 RET(102)
 #endif
@@ -27517,7 +27540,7 @@ OPCODE(0x80FB)
        {
                SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(150)
 #else
 RET(20)
 #endif
@@ -27533,7 +27556,7 @@ RET(20)
                {
                        flag_V = M68K_SR_V;
 #ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(150)
 #else
        RET(80)
 #endif
@@ -27546,7 +27569,7 @@ RET(160)
        DREGu32((Opcode >> 9) & 7) = res;
        }
 #ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(150)
 #else
 RET(100)
 #endif
@@ -34121,18 +34144,22 @@ OPCODE(0xC100)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        src = DREGu8((Opcode >> 0) & 7);
        dst = DREGu8((Opcode >> 9) & 7);
        res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res += 6;
+       if (res > 9) corf = 6;
        res += (dst & 0xF0) + (src & 0xF0);
-       if (res > 0x99)
+       flag_V = ~res;
+       res += corf;
+       if (res > 0x9F)
        {
                res -= 0xA0;
                flag_X = flag_C = M68K_SR_C;
        }
        else flag_X = flag_C = 0;
+       flag_V &= res;
        flag_NotZ |= res & 0xFF;
        flag_N = res;
        DREGu8((Opcode >> 9) & 7) = res;
@@ -34144,6 +34171,7 @@ OPCODE(0xC108)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        adr = AREG((Opcode >> 0) & 7) - 1;
        AREG((Opcode >> 0) & 7) = adr;
@@ -34153,14 +34181,17 @@ OPCODE(0xC108)
        AREG((Opcode >> 9) & 7) = adr;
        READ_BYTE_F(adr, dst)
        res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res += 6;
+       if (res > 9) corf = 6;
        res += (dst & 0xF0) + (src & 0xF0);
-       if (res > 0x99)
+       flag_V = ~res;
+       res += corf;
+       if (res > 0x9F)
        {
                res -= 0xA0;
                flag_X = flag_C = M68K_SR_C;
        }
        else flag_X = flag_C = 0;
+       flag_V &= res;
        flag_NotZ |= res & 0xFF;
        flag_N = res;
        WRITE_BYTE_F(adr, res)
@@ -34173,6 +34204,7 @@ OPCODE(0xC10F)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        adr = AREG(7) - 2;
        AREG(7) = adr;
@@ -34182,14 +34214,17 @@ OPCODE(0xC10F)
        AREG((Opcode >> 9) & 7) = adr;
        READ_BYTE_F(adr, dst)
        res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res += 6;
+       if (res > 9) corf = 6;
        res += (dst & 0xF0) + (src & 0xF0);
-       if (res > 0x99)
+       flag_V = ~res;
+       res += corf;
+       if (res > 0x9F)
        {
                res -= 0xA0;
                flag_X = flag_C = M68K_SR_C;
        }
        else flag_X = flag_C = 0;
+       flag_V &= res;
        flag_NotZ |= res & 0xFF;
        flag_N = res;
        WRITE_BYTE_F(adr, res)
@@ -34202,6 +34237,7 @@ OPCODE(0xCF08)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        adr = AREG((Opcode >> 0) & 7) - 1;
        AREG((Opcode >> 0) & 7) = adr;
@@ -34211,14 +34247,17 @@ OPCODE(0xCF08)
        AREG(7) = adr;
        READ_BYTE_F(adr, dst)
        res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res += 6;
+       if (res > 9) corf = 6;
        res += (dst & 0xF0) + (src & 0xF0);
-       if (res > 0x99)
+       flag_V = ~res;
+       res += corf;
+       if (res > 0x9F)
        {
                res -= 0xA0;
                flag_X = flag_C = M68K_SR_C;
        }
        else flag_X = flag_C = 0;
+       flag_V &= res;
        flag_NotZ |= res & 0xFF;
        flag_N = res;
        WRITE_BYTE_F(adr, res)
@@ -34231,6 +34270,7 @@ OPCODE(0xCF0F)
 {
        u32 adr, res;
        u32 src, dst;
+       u32 corf = 0;
 
        adr = AREG(7) - 2;
        AREG(7) = adr;
@@ -34240,14 +34280,17 @@ OPCODE(0xCF0F)
        AREG(7) = adr;
        READ_BYTE_F(adr, dst)
        res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
-       if (res > 9) res += 6;
+       if (res > 9) corf = 6;
        res += (dst & 0xF0) + (src & 0xF0);
-       if (res > 0x99)
+       flag_V = ~res;
+       res += corf;
+       if (res > 0x9F)
        {
                res -= 0xA0;
                flag_X = flag_C = M68K_SR_C;
        }
        else flag_X = flag_C = 0;
+       flag_V &= res;
        flag_NotZ |= res & 0xFF;
        flag_N = res;
        WRITE_BYTE_F(adr, res)
@@ -37966,7 +38009,7 @@ OPCODE(0xE0B0)
                {
                        if (sft == 1) res = (src >> 1) | ((flag_X & M68K_SR_X) << (32 - (M68K_SR_X_SFT + 1)));
                        else res = (src >> sft) | (src << (33 - sft)) | (((flag_X & M68K_SR_X) << (32 - (M68K_SR_X_SFT + 1))) >> (sft - 1));
-                       flag_X = (src >> (32 - sft)) << M68K_SR_X_SFT;
+                       flag_X = (src >> (sft - 1)) << M68K_SR_X_SFT;
                }
                else res = src;
                flag_C = flag_X;
index 5c9cc06..d1756a5 100644 (file)
@@ -918,13 +918,15 @@ M68KMAKE_OP(abcd, 8, rr, .)
        uint src = DY;\r
        uint dst = *r_dst;\r
        uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
-       FLAG_V = ~res; /* Undefined V behavior */\r
+       uint corf = 0;\r
 \r
        if(res > 9)\r
-               res += 6;\r
+               corf = 6;\r
        res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
-       FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+       FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+       res += corf;\r
+       FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
        if(FLAG_C)\r
                res -= 0xa0;\r
 \r
@@ -944,13 +946,15 @@ M68KMAKE_OP(abcd, 8, mm, ax7)
        uint ea  = EA_A7_PD_8();\r
        uint dst = m68ki_read_8(ea);\r
        uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
-       FLAG_V = ~res; /* Undefined V behavior */\r
+       uint corf = 0;\r
 \r
        if(res > 9)\r
-               res += 6;\r
+               corf = 6;\r
        res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
-       FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+       FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+       res += corf;\r
+       FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
        if(FLAG_C)\r
                res -= 0xa0;\r
 \r
@@ -970,13 +974,15 @@ M68KMAKE_OP(abcd, 8, mm, ay7)
        uint ea  = EA_AX_PD_8();\r
        uint dst = m68ki_read_8(ea);\r
        uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
-       FLAG_V = ~res; /* Undefined V behavior */\r
+       uint corf = 0;\r
 \r
        if(res > 9)\r
-               res += 6;\r
+               corf = 6;\r
        res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
-       FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+       FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+       res += corf;\r
+       FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
        if(FLAG_C)\r
                res -= 0xa0;\r
 \r
@@ -996,13 +1002,15 @@ M68KMAKE_OP(abcd, 8, mm, axy7)
        uint ea  = EA_A7_PD_8();\r
        uint dst = m68ki_read_8(ea);\r
        uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
-       FLAG_V = ~res; /* Undefined V behavior */\r
+       uint corf = 0;\r
 \r
        if(res > 9)\r
-               res += 6;\r
+               corf = 6;\r
        res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
-       FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+       FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+       res += corf;\r
+       FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
        if(FLAG_C)\r
                res -= 0xa0;\r
 \r
@@ -1022,13 +1030,15 @@ M68KMAKE_OP(abcd, 8, mm, .)
        uint ea  = EA_AX_PD_8();\r
        uint dst = m68ki_read_8(ea);\r
        uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
-       FLAG_V = ~res; /* Undefined V behavior */\r
+       uint corf = 0;\r
 \r
        if(res > 9)\r
-               res += 6;\r
+               corf = 6;\r
        res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
-       FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+       FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+       res += corf;\r
+       FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
        if(FLAG_C)\r
                res -= 0xa0;\r
 \r
@@ -7794,19 +7804,19 @@ M68KMAKE_OP(mull, 32, ., .)
 M68KMAKE_OP(nbcd, 8, ., d)\r
 {\r
        uint* r_dst = &DY;\r
-       uint dst = *r_dst;\r
-       uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1());\r
+       uint dst = MASK_OUT_ABOVE_8(*r_dst);\r
+       uint res = -dst - XFLAG_AS_1();\r
 \r
-       if(res != 0x9a)\r
+       if(res != 0)\r
        {\r
-               FLAG_V = ~res; /* Undefined V behavior */\r
+               FLAG_V = res; /* Undefined V behavior */\r
 \r
-               if((res & 0x0f) == 0xa)\r
-                       res = (res & 0xf0) + 0x10;\r
+               if(((res|dst) & 0x0f) == 0)\r
+                       res = (res & 0xf0) + 6;\r
 \r
-               res = MASK_OUT_ABOVE_8(res);\r
+               res = MASK_OUT_ABOVE_8(res + 0x9a);\r
 \r
-               FLAG_V &= res; /* Undefined V behavior part II */\r
+               FLAG_V &= ~res; /* Undefined V behavior part II */\r
 \r
                *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;\r
 \r
@@ -7828,18 +7838,18 @@ M68KMAKE_OP(nbcd, 8, ., .)
 {\r
        uint ea = M68KMAKE_GET_EA_AY_8;\r
        uint dst = m68ki_read_8(ea);\r
-       uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1());\r
+       uint res = -dst - XFLAG_AS_1();\r
 \r
-       if(res != 0x9a)\r
+       if(res != 0)\r
        {\r
-               FLAG_V = ~res; /* Undefined V behavior */\r
+               FLAG_V = res; /* Undefined V behavior */\r
 \r
-               if((res & 0x0f) == 0xa)\r
-                       res = (res & 0xf0) + 0x10;\r
+               if(((res|dst) & 0x0f) == 0)\r
+                       res = (res & 0xf0) + 6;\r
 \r
-               res = MASK_OUT_ABOVE_8(res);\r
+               res = MASK_OUT_ABOVE_8(res + 0x9a);\r
 \r
-               FLAG_V &= res; /* Undefined V behavior part II */\r
+               FLAG_V &= ~res; /* Undefined V behavior part II */\r
 \r
                m68ki_write_8(ea, MASK_OUT_ABOVE_8(res));\r
 \r
@@ -9359,26 +9369,26 @@ M68KMAKE_OP(sbcd, 8, rr, .)
        uint src = DY;\r
        uint dst = *r_dst;\r
        uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+       uint corf = 0;\r
 \r
-//  FLAG_V = ~res; /* Undefined V behavior */\r
-       FLAG_V = VFLAG_CLEAR;   /* Undefined in Motorola's M68000PM/AD rev.1 and safer to assume cleared. */\r
-\r
-       if(res > 9)\r
-               res -= 6;\r
+       if(res > 0xf)\r
+               corf = 6;\r
        res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
-       if(res > 0x99)\r
+       FLAG_V = res; /* Undefined V behavior */\r
+       if(res > 0xff)\r
        {\r
                res += 0xa0;\r
                FLAG_X = FLAG_C = CFLAG_SET;\r
-               FLAG_N = NFLAG_SET;     /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
        }\r
+       else if(res < corf)\r
+               FLAG_X = FLAG_C = CFLAG_SET;\r
        else\r
-               FLAG_N = FLAG_X = FLAG_C = 0;\r
+               FLAG_X = FLAG_C = 0;\r
 \r
-       res = MASK_OUT_ABOVE_8(res);\r
+       res = MASK_OUT_ABOVE_8(res - corf);\r
 \r
-//  FLAG_V &= res; /* Undefined V behavior part II */\r
-//  FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+       FLAG_V &= ~res; /* Undefined V behavior part II */\r
+       FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
        FLAG_Z |= res;\r
 \r
        *r_dst = MASK_OUT_BELOW_8(*r_dst) | res;\r
@@ -9391,26 +9401,26 @@ M68KMAKE_OP(sbcd, 8, mm, ax7)
        uint ea  = EA_A7_PD_8();\r
        uint dst = m68ki_read_8(ea);\r
        uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+       uint corf = 0;\r
 \r
-//  FLAG_V = ~res; /* Undefined V behavior */\r
-       FLAG_V = VFLAG_CLEAR;   /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */\r
-\r
-       if(res > 9)\r
-               res -= 6;\r
+       if(res > 0xf)\r
+               corf = 6;\r
        res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
-       if(res > 0x99)\r
+       FLAG_V = res; /* Undefined V behavior */\r
+       if(res > 0xff)\r
        {\r
                res += 0xa0;\r
                FLAG_X = FLAG_C = CFLAG_SET;\r
-               FLAG_N = NFLAG_SET;     /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
        }\r
+       else if(res < corf)\r
+               FLAG_X = FLAG_C = CFLAG_SET;\r
        else\r
-               FLAG_N = FLAG_X = FLAG_C = 0;\r
+               FLAG_X = FLAG_C = 0;\r
 \r
-       res = MASK_OUT_ABOVE_8(res);\r
+       res = MASK_OUT_ABOVE_8(res - corf);\r
 \r
-//  FLAG_V &= res; /* Undefined V behavior part II */\r
-//  FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+       FLAG_V &= ~res; /* Undefined V behavior part II */\r
+       FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
        FLAG_Z |= res;\r
 \r
        m68ki_write_8(ea, res);\r
@@ -9423,26 +9433,26 @@ M68KMAKE_OP(sbcd, 8, mm, ay7)
        uint ea  = EA_AX_PD_8();\r
        uint dst = m68ki_read_8(ea);\r
        uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+       uint corf = 0;\r
 \r
-//  FLAG_V = ~res; /* Undefined V behavior */\r
-       FLAG_V = VFLAG_CLEAR;   /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */\r
-\r
-       if(res > 9)\r
-               res -= 6;\r
+       if(res > 0xf)\r
+               corf = 6;\r
        res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
-       if(res > 0x99)\r
+       FLAG_V = res; /* Undefined V behavior */\r
+       if(res > 0xff)\r
        {\r
                res += 0xa0;\r
                FLAG_X = FLAG_C = CFLAG_SET;\r
-               FLAG_N = NFLAG_SET;     /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
        }\r
+       else if(res < corf)\r
+               FLAG_X = FLAG_C = CFLAG_SET;\r
        else\r
-               FLAG_N = FLAG_X = FLAG_C = 0;\r
+               FLAG_X = FLAG_C = 0;\r
 \r
-       res = MASK_OUT_ABOVE_8(res);\r
+       res = MASK_OUT_ABOVE_8(res - corf);\r
 \r
-//  FLAG_V &= res; /* Undefined V behavior part II */\r
-//  FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+       FLAG_V &= ~res; /* Undefined V behavior part II */\r
+       FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
        FLAG_Z |= res;\r
 \r
        m68ki_write_8(ea, res);\r
@@ -9455,26 +9465,26 @@ M68KMAKE_OP(sbcd, 8, mm, axy7)
        uint ea  = EA_A7_PD_8();\r
        uint dst = m68ki_read_8(ea);\r
        uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+       uint corf = 0;\r
 \r
-//  FLAG_V = ~res; /* Undefined V behavior */\r
-       FLAG_V = VFLAG_CLEAR;   /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */\r
-\r
-       if(res > 9)\r
-               res -= 6;\r
+       if(res > 0xf)\r
+               corf = 6;\r
        res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
-       if(res > 0x99)\r
+       FLAG_V = res; /* Undefined V behavior */\r
+       if(res > 0xff)\r
        {\r
                res += 0xa0;\r
                FLAG_X = FLAG_C = CFLAG_SET;\r
-               FLAG_N = NFLAG_SET;     /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
        }\r
+       else if(res < corf)\r
+               FLAG_X = FLAG_C = CFLAG_SET;\r
        else\r
-               FLAG_N = FLAG_X = FLAG_C = 0;\r
+               FLAG_X = FLAG_C = 0;\r
 \r
-       res = MASK_OUT_ABOVE_8(res);\r
+       res = MASK_OUT_ABOVE_8(res - corf);\r
 \r
-//  FLAG_V &= res; /* Undefined V behavior part II */\r
-//  FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+       FLAG_V &= ~res; /* Undefined V behavior part II */\r
+       FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
        FLAG_Z |= res;\r
 \r
        m68ki_write_8(ea, res);\r
@@ -9487,26 +9497,26 @@ M68KMAKE_OP(sbcd, 8, mm, .)
        uint ea  = EA_AX_PD_8();\r
        uint dst = m68ki_read_8(ea);\r
        uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+       uint corf = 0;\r
 \r
-//  FLAG_V = ~res; /* Undefined V behavior */\r
-       FLAG_V = VFLAG_CLEAR;   /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */\r
-\r
-       if(res > 9)\r
-               res -= 6;\r
+       if(res > 0xf)\r
+               corf = 6;\r
        res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
-       if(res > 0x99)\r
+       FLAG_V = res; /* Undefined V behavior */\r
+       if(res > 0xff)\r
        {\r
                res += 0xa0;\r
                FLAG_X = FLAG_C = CFLAG_SET;\r
-               FLAG_N = NFLAG_SET;     /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
        }\r
+       else if(res < corf)\r
+               FLAG_X = FLAG_C = CFLAG_SET;\r
        else\r
-               FLAG_N = FLAG_X = FLAG_C = 0;\r
+               FLAG_X = FLAG_C = 0;\r
 \r
-       res = MASK_OUT_ABOVE_8(res);\r
+       res = MASK_OUT_ABOVE_8(res - corf);\r
 \r
-//  FLAG_V &= res; /* Undefined V behavior part II */\r
-//  FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+       FLAG_V &= ~res; /* Undefined V behavior part II */\r
+       FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
        FLAG_Z |= res;\r
 \r
        m68ki_write_8(ea, res);\r
index 72bb217..38469f3 100644 (file)
@@ -808,7 +808,7 @@ int m68k_execute(int num_cycles)
                // notaz\r
                m68ki_trace_t1();\r
 \r
-               while(GET_CYCLES() >= 0)\r
+               while(GET_CYCLES() > 0)\r
 //             do\r
                {\r
                        /* Set tracing accodring to T1. (T0 is done inside instruction) */\r
index 83e92c5..63055cb 100644 (file)
@@ -1623,7 +1623,7 @@ INLINE void m68ki_stack_frame_buserr(uint sr)
 /* Format 8 stack frame (68010).\r
  * 68010 only.  This is the 29 word bus/address error frame.\r
  */\r
-void m68ki_stack_frame_1000(uint pc, uint sr, uint vector)\r
+INLINE void m68ki_stack_frame_1000(uint pc, uint sr, uint vector)\r
 {\r
        /* VERSION\r
      * NUMBER\r
@@ -1677,7 +1677,7 @@ void m68ki_stack_frame_1000(uint pc, uint sr, uint vector)
  * if the error happens at an instruction boundary.\r
  * PC stacked is address of next instruction.\r
  */\r
-void m68ki_stack_frame_1010(uint sr, uint vector, uint pc)\r
+INLINE void m68ki_stack_frame_1010(uint sr, uint vector, uint pc)\r
 {\r
        /* INTERNAL REGISTER */\r
        m68ki_push_16(0);\r
@@ -1724,7 +1724,7 @@ void m68ki_stack_frame_1010(uint sr, uint vector, uint pc)
  * if the error happens during instruction execution.\r
  * PC stacked is address of instruction in progress.\r
  */\r
-void m68ki_stack_frame_1011(uint sr, uint vector, uint pc)\r
+INLINE void m68ki_stack_frame_1011(uint sr, uint vector, uint pc)\r
 {\r
        /* INTERNAL REGISTERS (18 words) */\r
        m68ki_push_32(0);\r
@@ -1968,7 +1968,7 @@ m68k_read_memory_8(0x00ffff01);
 \r
 \r
 /* Service an interrupt request and start exception processing */\r
-void m68ki_exception_interrupt(uint int_level)\r
+INLINE void m68ki_exception_interrupt(uint int_level)\r
 {\r
        uint vector;\r
        uint sr;\r
index f315734..361481b 100644 (file)
@@ -1043,6 +1043,11 @@ void process_opcode_handlers(FILE* filep)
                if(opinfo == NULL)\r
                        error_exit("Unable to find matching table entry for %s", func_name);\r
 \r
+#if 1 /* PD hack: 000 only */\r
+               if (opinfo->cpus[0] == UNSPECIFIED_CH)\r
+                       continue;\r
+#endif\r
+\r
                replace->length = 0;\r
 \r
                /* Generate opcode variants */\r
index 3f006c7..4403378 100644 (file)
@@ -1017,7 +1017,7 @@ static void rcache_unlock_all(void)
     reg_temp[i].flags &= ~HRF_LOCKED;
 }
 
-static INLINE u32 rcache_used_hreg_mask(void)
+static u32 rcache_used_hreg_mask(void)
 {
   u32 mask = 0;
   int i;
index 7324166..636ebc6 100644 (file)
@@ -21,7 +21,7 @@ typedef unsigned char  UINT8;
 
 // this nasty conversion is needed for drc-expecting memhandlers
 #define MAKE_READFUNC(name, cname) \
-static INLINE unsigned int name(SH2 *sh2, unsigned int a) \
+static __inline unsigned int name(SH2 *sh2, unsigned int a) \
 { \
        unsigned int ret; \
        sh2->sr |= sh2->icount << 12; \
@@ -32,7 +32,7 @@ static INLINE unsigned int name(SH2 *sh2, unsigned int a) \
 }
 
 #define MAKE_WRITEFUNC(name, cname) \
-static INLINE void name(SH2 *sh2, unsigned int a, unsigned int d) \
+static __inline void name(SH2 *sh2, unsigned int a, unsigned int d) \
 { \
        sh2->sr |= sh2->icount << 12; \
        cname(a, d, sh2); \
index 8c37f43..e945354 100644 (file)
@@ -1,11 +1,7 @@
 #ifndef __SH2_H__\r
 #define __SH2_H__\r
 \r
-#if !defined(REGPARM) && defined(__i386__) \r
-#define REGPARM(x) __attribute__((regparm(x)))\r
-#else\r
-#define REGPARM(x)\r
-#endif\r
+#include "../../pico/pico_port.h"\r
 \r
 // registers - matches structure order\r
 typedef enum {\r
@@ -92,7 +88,7 @@ void sh2_unpack(SH2 *sh2, const unsigned char *buff);
 int  sh2_execute_drc(SH2 *sh2c, int cycles);\r
 int  sh2_execute_interpreter(SH2 *sh2c, int cycles);\r
 \r
-static INLINE int sh2_execute(SH2 *sh2, int cycles, int use_drc)\r
+static __inline int sh2_execute(SH2 *sh2, int cycles, int use_drc)\r
 {\r
   int ret;\r
 \r
index e322752..bc81702 100644 (file)
@@ -7,9 +7,6 @@ ifneq ($(GIT_VERSION)," unknown")
        LOCAL_CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
 endif
 
-#fix stupid change in ndk r11 that breaks compiling even when the exe would run fine
-LOCAL_DISABLE_FATAL_LINKER_WARNINGS := true
-
 LOCAL_MODULE := retro
 
 R := ../
@@ -52,6 +49,13 @@ ifeq ($(TARGET_ARCH),arm)
   asm_misc = 1
 #  asm_cdmemory = 1 # texrels
   asm_mix = 1
+
+# for armeabi to build...
+CYCLONE_CONFIG = cyclone_config_armv4.h
+
+$(cleantarget)::
+       $(MAKE) -C $(FR)cpu/cyclone/ clean
+
 else
   use_fame = 1
   use_cz80 = 1
@@ -83,7 +87,7 @@ LOCAL_SRC_FILES += $(R)unzip/unzip.c
 LOCAL_C_INCLUDES += $(R)
 
 # note: don't use -O3, causes some NDKs run out of memory while compiling FAME
-LOCAL_CFLAGS += -Wall -O2 -ffast-math -DNDEBUG -DINLINE=inline
+LOCAL_CFLAGS += -Wall -O2 -ffast-math -DNDEBUG
 LOCAL_CFLAGS += $(addprefix -D,$(DEFINES))
 LOCAL_LDLIBS := -llog
 
index 222106e..a252a72 100644 (file)
@@ -1 +1 @@
-APP_ABI := armeabi-v7a mips x86
+APP_ABI := all
index 14d1c84..1c166ce 100644 (file)
@@ -134,28 +134,31 @@ void p32x_reset_sh2s(void)
   // if we don't have BIOS set, perform it's work here.
   // MSH2
   if (p32x_bios_m == NULL) {
-    unsigned int idl_src, idl_dst, idl_size; // initial data load
-    unsigned int vbr;
+    sh2_set_gbr(0, 0x20004000);
 
-    // initial data
-    idl_src = HWSWAP(*(unsigned int *)(Pico.rom + 0x3d4)) & ~0xf0000000;
-    idl_dst = HWSWAP(*(unsigned int *)(Pico.rom + 0x3d8)) & ~0xf0000000;
-    idl_size= HWSWAP(*(unsigned int *)(Pico.rom + 0x3dc));
-    if (idl_size > Pico.romsize || idl_src + idl_size > Pico.romsize ||
-        idl_size > 0x40000 || idl_dst + idl_size > 0x40000 || (idl_src & 3) || (idl_dst & 3)) {
-      elprintf(EL_STATUS|EL_ANOMALY, "32x: invalid initial data ptrs: %06x -> %06x, %06x",
-        idl_src, idl_dst, idl_size);
-    }
-    else
-      memcpy(Pico32xMem->sdram + idl_dst, Pico.rom + idl_src, idl_size);
+    if (!(PicoAHW & PAHW_MCD)) {
+      unsigned int idl_src, idl_dst, idl_size; // initial data load
+      unsigned int vbr;
+
+      // initial data
+      idl_src = HWSWAP(*(unsigned int *)(Pico.rom + 0x3d4)) & ~0xf0000000;
+      idl_dst = HWSWAP(*(unsigned int *)(Pico.rom + 0x3d8)) & ~0xf0000000;
+      idl_size= HWSWAP(*(unsigned int *)(Pico.rom + 0x3dc));
+      if (idl_size > Pico.romsize || idl_src + idl_size > Pico.romsize ||
+          idl_size > 0x40000 || idl_dst + idl_size > 0x40000 || (idl_src & 3) || (idl_dst & 3)) {
+        elprintf(EL_STATUS|EL_ANOMALY, "32x: invalid initial data ptrs: %06x -> %06x, %06x",
+          idl_src, idl_dst, idl_size);
+      }
+      else
+        memcpy(Pico32xMem->sdram + idl_dst, Pico.rom + idl_src, idl_size);
 
-    // GBR/VBR
-    vbr = HWSWAP(*(unsigned int *)(Pico.rom + 0x3e8));
-    sh2_set_gbr(0, 0x20004000);
-    sh2_set_vbr(0, vbr);
+      // VBR
+      vbr = HWSWAP(*(unsigned int *)(Pico.rom + 0x3e8));
+      sh2_set_vbr(0, vbr);
 
-    // checksum and M_OK
-    Pico32x.regs[0x28 / 2] = *(unsigned short *)(Pico.rom + 0x18e);
+      // checksum and M_OK
+      Pico32x.regs[0x28 / 2] = *(unsigned short *)(Pico.rom + 0x18e);
+    }
     // program will set M_OK
   }
 
@@ -227,7 +230,7 @@ static void p32x_start_blank(void)
     // XXX: no proper handling of 32col mode..
     if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0 && // 32x not blanking
         (Pico.video.reg[12] & 1) && // 40col mode
-        (PicoDrawMask & PDRAW_32X_ON))
+        (!(Pico.video.debug_p & PVD_KILL_32X)))
     {
       int md_bg = Pico.video.reg[7] & 0x3f;
 
@@ -294,9 +297,9 @@ typedef void (event_cb)(unsigned int now);
 unsigned int p32x_event_times[P32X_EVENT_COUNT];
 static unsigned int event_time_next;
 static event_cb *p32x_event_cbs[P32X_EVENT_COUNT] = {
-  p32x_pwm_irq_event,
-  fillend_event,
-  hint_event,
+  p32x_pwm_irq_event, // P32X_EVENT_PWM
+  fillend_event,      // P32X_EVENT_FILLEND
+  hint_event,         // P32X_EVENT_HINT
 };
 
 // schedule event at some time 'after', in m68k clocks
@@ -363,7 +366,7 @@ static void p32x_run_events(unsigned int until)
       oldest, event_time_next);
 }
 
-static INLINE void run_sh2(SH2 *sh2, int m68k_cycles)
+static void run_sh2(SH2 *sh2, int m68k_cycles)
 {
   int cycles, done;
 
similarity index 99%
rename from pico/32x/32x_draw.c
rename to pico/32x/draw.c
index e33cb37..ee541bd 100644 (file)
@@ -96,7 +96,7 @@ void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est)
   if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0 || // 32x blanking
       // XXX: how is 32col mode hadled by real hardware?
       !(Pico.video.reg[12] & 1) || // 32col mode
-      !(PicoDrawMask & PDRAW_32X_ON))
+      (Pico.video.debug_p & PVD_KILL_32X))
   {
     return;
   }
@@ -292,7 +292,7 @@ void PicoDraw32xLayerMdOnly(int offs, int lines)
   for (l = 0; l < lines; l++) {
     if (have_scan) {
       PicoScan32xBegin(l + offs);
-      dst = (unsigned short*)Pico.est.DrawLineDest + poffs;
+      dst = (unsigned short *)Pico.est.DrawLineDest + poffs;
     }
     for (p = 0; p < plen; p += 4) {
       dst[p + 0] = pal[*pmd++];
similarity index 99%
rename from pico/32x/32x_memory.c
rename to pico/32x/memory.c
index 8b9254f..f3b7006 100644 (file)
@@ -1159,7 +1159,7 @@ static void bank_switch(int b)
     return;
 
   bank = b << 20;
-  if ((Pico.m.sram_reg & SRR_MAPPED) && bank == SRam.start) {
+  if ((Pico.m.sram_reg & SRR_MAPPED) && bank == Pico.sv.start) {
     bank_map_handler();
     return;
   }
@@ -1179,12 +1179,6 @@ static void bank_switch(int b)
   cpu68k_map_set(m68k_read16_map,  0x900000, 0x900000 + rs - 1, Pico.rom + bank, 0);
 
   elprintf(EL_32X, "bank %06x-%06x -> %06x", 0x900000, 0x900000 + rs - 1, bank);
-
-#ifdef EMU_F68K
-  // setup FAME fetchmap
-  for (rs = 0x90; rs < 0xa0; rs++)
-    PicoCpuFM68k.Fetch[rs] = (unsigned long)Pico.rom + bank - 0x900000;
-#endif
 }
 
 // -----------------------------------------------------------------
index 1aba914..5073564 100644 (file)
@@ -326,11 +326,11 @@ void p32x_pwm_state_loaded(void)
   p32x_pwm_ctl_changed();
 
   // for old savestates
-  cycles_diff_sh2 = SekCycleCnt * 3 - Pico32x.pwm_cycle_p;
+  cycles_diff_sh2 = Pico.t.m68c_cnt * 3 - Pico32x.pwm_cycle_p;
   if (cycles_diff_sh2 >= pwm_cycles || cycles_diff_sh2 < 0) {
     Pico32x.pwm_irq_cnt = pwm_irq_reload;
-    Pico32x.pwm_cycle_p = SekCycleCnt * 3;
-    p32x_pwm_schedule(SekCycleCnt);
+    Pico32x.pwm_cycle_p = Pico.t.m68c_cnt * 3;
+    p32x_pwm_schedule(Pico.t.m68c_cnt);
   }
 }
 
index d29e96c..f17ce5e 100644 (file)
@@ -109,7 +109,6 @@ pm_file *pm_open(const char *path)
     return NULL;\r
 \r
   ext = get_ext(path);\r
-#ifndef NO_ZLIB\r
   if (strcasecmp(ext, "zip") == 0)\r
   {\r
     struct zip_file *zfile = NULL;\r
@@ -163,9 +162,7 @@ zip_failed:
       return NULL;\r
     }\r
   }\r
-  else\r
-#endif\r
-  if (strcasecmp(ext, "cso") == 0)\r
+  else if (strcasecmp(ext, "cso") == 0)\r
   {\r
     cso_struct *cso = NULL, *tmp = NULL;\r
     int size;\r
@@ -260,7 +257,6 @@ size_t pm_read(void *ptr, size_t bytes, pm_file *stream)
   {\r
     ret = fread(ptr, 1, bytes, stream->file);\r
   }\r
-#ifndef NO_ZLIB\r
   else if (stream->type == PMT_ZIP)\r
   {\r
     struct zip_file *z = stream->file;\r
@@ -291,7 +287,6 @@ size_t pm_read(void *ptr, size_t bytes, pm_file *stream)
     z->pos += bytes - z->stream.avail_out;\r
     return bytes - z->stream.avail_out;\r
   }\r
-#endif\r
   else if (stream->type == PMT_CSO)\r
   {\r
     cso_struct *cso = stream->param;\r
@@ -367,7 +362,6 @@ int pm_seek(pm_file *stream, long offset, int whence)
     fseek(stream->file, offset, whence);\r
     return ftell(stream->file);\r
   }\r
-#ifndef NO_ZLIB\r
   else if (stream->type == PMT_ZIP)\r
   {\r
     struct zip_file *z = stream->file;\r
@@ -410,7 +404,6 @@ int pm_seek(pm_file *stream, long offset, int whence)
     }\r
     return z->pos;\r
   }\r
-#endif\r
   else if (stream->type == PMT_CSO)\r
   {\r
     cso_struct *cso = stream->param;\r
@@ -436,14 +429,12 @@ int pm_close(pm_file *fp)
   {\r
     fclose(fp->file);\r
   }\r
-#ifndef NO_ZLIB\r
   else if (fp->type == PMT_ZIP)\r
   {\r
     struct zip_file *z = fp->file;\r
     inflateEnd(&z->stream);\r
     closezip(z->zip);\r
   }\r
-#endif\r
   else if (fp->type == PMT_CSO)\r
   {\r
     free(fp->param);\r
@@ -626,9 +617,9 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
   Pico.rom=rom;\r
   Pico.romsize=romsize;\r
 \r
-  if (SRam.data) {\r
-    free(SRam.data);\r
-    SRam.data = NULL;\r
+  if (Pico.sv.data) {\r
+    free(Pico.sv.data);\r
+    Pico.sv.data = NULL;\r
   }\r
 \r
   if (PicoCartUnloadHook != NULL) {\r
@@ -958,8 +949,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
         elprintf(EL_STATUS, "carthw:%d: bad sram_range: %08x - %08x", line, start, end);\r
         goto bad_nomsg;\r
       }\r
-      SRam.start = start;\r
-      SRam.end = end;\r
+      Pico.sv.start = start;\r
+      Pico.sv.end = end;\r
       continue;\r
     }\r
     else if (is_expr("prop", &p)) {\r
@@ -968,9 +959,9 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
       rstrip(p);\r
 \r
       if      (strcmp(p, "no_sram") == 0)\r
-        SRam.flags &= ~SRF_ENABLED;\r
+        Pico.sv.flags &= ~SRF_ENABLED;\r
       else if (strcmp(p, "no_eeprom") == 0)\r
-        SRam.flags &= ~SRF_EEPROM;\r
+        Pico.sv.flags &= ~SRF_EEPROM;\r
       else if (strcmp(p, "filled_sram") == 0)\r
         *fill_sram = 1;\r
       else if (strcmp(p, "force_6btn") == 0)\r
@@ -991,8 +982,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
       type = strtoul(p, &r, 0);\r
       if (r == p || type < 0)\r
         goto bad;\r
-      SRam.eeprom_type = type;\r
-      SRam.flags |= SRF_EEPROM;\r
+      Pico.sv.eeprom_type = type;\r
+      Pico.sv.flags |= SRF_EEPROM;\r
       continue;\r
     }\r
     else if (is_expr("eeprom_lines", &p)) {\r
@@ -1007,9 +998,9 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
           sda_out < 0 || sda_out > 15)\r
         goto bad;\r
 \r
-      SRam.eeprom_bit_cl = scl;\r
-      SRam.eeprom_bit_in = sda_in;\r
-      SRam.eeprom_bit_out= sda_out;\r
+      Pico.sv.eeprom_bit_cl = scl;\r
+      Pico.sv.eeprom_bit_in = sda_in;\r
+      Pico.sv.eeprom_bit_out= sda_out;\r
       continue;\r
     }\r
     else if ((tmp = is_expr("prot_ro_value16", &p)) || is_expr("prot_rw_value16", &p)) {\r
@@ -1049,54 +1040,54 @@ static void PicoCartDetect(const char *carthw_cfg)
 {\r
   int fill_sram = 0;\r
 \r
-  memset(&SRam, 0, sizeof(SRam));\r
+  memset(&Pico.sv, 0, sizeof(Pico.sv));\r
   if (Pico.rom[0x1B1] == 'R' && Pico.rom[0x1B0] == 'A')\r
   {\r
-    SRam.start =  rom_read32(0x1B4) & ~0xff000001; // align\r
-    SRam.end   = (rom_read32(0x1B8) & ~0xff000000) | 1;\r
+    Pico.sv.start =  rom_read32(0x1B4) & ~0xff000001; // align\r
+    Pico.sv.end   = (rom_read32(0x1B8) & ~0xff000000) | 1;\r
     if (Pico.rom[0x1B2] & 0x40)\r
       // EEPROM\r
-      SRam.flags |= SRF_EEPROM;\r
-    SRam.flags |= SRF_ENABLED;\r
+      Pico.sv.flags |= SRF_EEPROM;\r
+    Pico.sv.flags |= SRF_ENABLED;\r
   }\r
-  if (SRam.end == 0 || SRam.start > SRam.end)\r
+  if (Pico.sv.end == 0 || Pico.sv.start > Pico.sv.end)\r
   {\r
     // some games may have bad headers, like S&K and Sonic3\r
     // note: majority games use 0x200000 as starting address, but there are some which\r
     // use something else (0x300000 by HardBall '95). Luckily they have good headers.\r
-    SRam.start = 0x200000;\r
-    SRam.end   = 0x203FFF;\r
-    SRam.flags |= SRF_ENABLED;\r
+    Pico.sv.start = 0x200000;\r
+    Pico.sv.end   = 0x203FFF;\r
+    Pico.sv.flags |= SRF_ENABLED;\r
   }\r
 \r
   // set EEPROM defaults, in case it gets detected\r
-  SRam.eeprom_type   = 0; // 7bit (24C01)\r
-  SRam.eeprom_bit_cl = 1;\r
-  SRam.eeprom_bit_in = 0;\r
-  SRam.eeprom_bit_out= 0;\r
+  Pico.sv.eeprom_type   = 0; // 7bit (24C01)\r
+  Pico.sv.eeprom_bit_cl = 1;\r
+  Pico.sv.eeprom_bit_in = 0;\r
+  Pico.sv.eeprom_bit_out= 0;\r
 \r
   if (carthw_cfg != NULL)\r
     parse_carthw(carthw_cfg, &fill_sram);\r
 \r
-  if (SRam.flags & SRF_ENABLED)\r
+  if (Pico.sv.flags & SRF_ENABLED)\r
   {\r
-    if (SRam.flags & SRF_EEPROM)\r
-      SRam.size = 0x2000;\r
+    if (Pico.sv.flags & SRF_EEPROM)\r
+      Pico.sv.size = 0x2000;\r
     else\r
-      SRam.size = SRam.end - SRam.start + 1;\r
+      Pico.sv.size = Pico.sv.end - Pico.sv.start + 1;\r
 \r
-    SRam.data = calloc(SRam.size, 1);\r
-    if (SRam.data == NULL)\r
-      SRam.flags &= ~SRF_ENABLED;\r
+    Pico.sv.data = calloc(Pico.sv.size, 1);\r
+    if (Pico.sv.data == NULL)\r
+      Pico.sv.flags &= ~SRF_ENABLED;\r
 \r
-    if (SRam.eeprom_type == 1) // 1 == 0 in PD EEPROM code\r
-      SRam.eeprom_type = 0;\r
+    if (Pico.sv.eeprom_type == 1)      // 1 == 0 in PD EEPROM code\r
+      Pico.sv.eeprom_type = 0;\r
   }\r
 \r
-  if ((SRam.flags & SRF_ENABLED) && fill_sram)\r
+  if ((Pico.sv.flags & SRF_ENABLED) && fill_sram)\r
   {\r
     elprintf(EL_STATUS, "SRAM fill");\r
-    memset(SRam.data, 0xff, SRam.size);\r
+    memset(Pico.sv.data, 0xff, Pico.sv.size);\r
   }\r
 \r
   // Unusual region 'code'\r
index 72d4a9a..20742e0 100644 (file)
@@ -70,6 +70,10 @@ check_str = 0x32b74c, "Bishop Level"
 prop = force_6btn
 
 # The SSF2 mapper
+[Mega Everdrive]
+check_str = 0x100, "SEGA SSF"
+hw = ssf2_mapper
+
 [Super Street Fighter II - The New Challengers (U)]
 check_str = 0x150, "SUPER STREET FIGHTER2 The New Challengers"
 hw = ssf2_mapper
index 06936fb..cd47e7c 100644 (file)
@@ -8,8 +8,19 @@
 
 #include "../pico_int.h"
 #include "../memory.h"
+#include "eeprom_spi.h"
 
 
+static int have_bank(u32 base)
+{
+  // the loader allocs in 512K quantities
+  if (base >= Pico.romsize) {
+    elprintf(EL_ANOMALY|EL_STATUS, "carthw: missing bank @ %06x", base);
+    return 0;
+  }
+  return 1;
+}
+
 /* The SSFII mapper */
 static unsigned char ssf2_banks[8];
 
@@ -35,10 +46,8 @@ static void carthw_ssf2_write8(u32 a, u32 d)
        ssf2_banks[a >> 1] = d;
        base = d << 19;
        target = a << 18;
-       if (base + 0x80000 > Pico.romsize) {
-               elprintf(EL_ANOMALY|EL_STATUS, "ssf2: missing bank @ %06x", base);
+       if (!have_bank(base))
                return;
-       }
 
        cpu68k_map_set(m68k_read8_map,  target, target + 0x80000 - 1, Pico.rom + base, 0);
        cpu68k_map_set(m68k_read16_map, target, target + 0x80000 - 1, Pico.rom + base, 0);
@@ -270,6 +279,7 @@ static carthw_state_chunk carthw_pier_state[] =
 {
   { CHUNK_CARTHW,     sizeof(pier_regs),      pier_regs },
   { CHUNK_CARTHW + 1, sizeof(pier_dump_prot), &pier_dump_prot },
+  { CHUNK_CARTHW + 2, 0,                      NULL }, // filled later
   { 0,                0,                      NULL }
 };
 
@@ -308,7 +318,8 @@ static void carthw_pier_write8(u32 a, u32 d)
       base = d << 19;
       goto do_map;
     case 0x09:
-      // TODO
+      Pico.sv.changed = 1;
+      eeprom_spi_write(d);
       break;
     case 0x0b:
       // eeprom read
@@ -321,10 +332,9 @@ static void carthw_pier_write8(u32 a, u32 d)
   return;
 
 do_map:
-  if (base + 0x80000 > Pico.romsize) {
-    elprintf(EL_ANOMALY|EL_STATUS, "pier: missing bank @ %06x", base);
+  if (!have_bank(base))
     return;
-  }
+
   cpu68k_map_set(m68k_read8_map,  target, target + 0x80000 - 1, Pico.rom + base, 0);
   cpu68k_map_set(m68k_read16_map, target, target + 0x80000 - 1, Pico.rom + base, 0);
 }
@@ -346,7 +356,7 @@ static u32 carthw_pier_read8(u32 a)
     return PicoRead8_io(a);
 
   if (a == 0xa1300b)
-    return 0; // TODO
+    return eeprom_spi_read(a);
 
   elprintf(EL_UIO, "pier r8  [%06x] @%06x", a, SekPc);
   return 0;
@@ -413,12 +423,14 @@ static void carthw_pier_reset(void)
 {
   pier_regs[0] = 1;
   pier_regs[1] = pier_regs[2] = pier_regs[3] = 0;
-  pier_dump_prot = 3;
   carthw_pier_statef();
+  eeprom_spi_init(NULL);
 }
 
 void carthw_pier_startup(void)
 {
+  void *eeprom_state;
+  int eeprom_size = 0;
   int i;
 
   elprintf(EL_STATUS, "Pier Solar mapper startup");
@@ -430,10 +442,22 @@ void carthw_pier_startup(void)
     return;
   }
 
+  pier_dump_prot = 3;
+
   // create dump protection bank
   for (i = 0; i < M68K_BANK_SIZE; i += 0x8000)
     memcpy(Pico.rom + Pico.romsize + i, Pico.rom, 0x8000);
 
+  // save EEPROM
+  eeprom_state = eeprom_spi_init(&eeprom_size);
+  Pico.sv.flags = 0;
+  Pico.sv.size = 0x10000;
+  Pico.sv.data = calloc(1, Pico.sv.size);
+  if (!Pico.sv.data)
+    Pico.sv.size = 0;
+  carthw_pier_state[2].ptr = eeprom_state;
+  carthw_pier_state[2].size = eeprom_size;
+
   PicoCartMemSetup  = carthw_pier_mem_setup;
   PicoResetHook     = carthw_pier_reset;
   PicoLoadStateHook = carthw_pier_statef;
@@ -679,3 +703,4 @@ void carthw_prot_lk3_startup(void)
   PicoCartMemSetup = carthw_prot_lk3_mem_setup;
 }
 
+// vim:ts=2:sw=2:expandtab
diff --git a/pico/carthw/eeprom_spi.c b/pico/carthw/eeprom_spi.c
new file mode 100644 (file)
index 0000000..b250aff
--- /dev/null
@@ -0,0 +1,360 @@
+/****************************************************************************
+ *  Genesis Plus
+ *  SPI Serial EEPROM (25xxx/95xxx) support
+ *
+ *  Copyright (C) 2012  Eke-Eke (Genesis Plus GX)
+ *
+ *  Redistribution and use of this code or any derivative works are permitted
+ *  provided that the following conditions are met:
+ *
+ *   - Redistributions may not be sold, nor may they be used in a commercial
+ *     product or activity.
+ *
+ *   - Redistributions that are modified from the original source must include the
+ *     complete source code, including the source code for all components used by a
+ *     binary built from the modified sources. However, as a special exception, the
+ *     source code distributed need not include anything that is normally distributed
+ *     (in either source or binary form) with the major components (compiler, kernel,
+ *     and so on) of the operating system on which the executable runs, unless that
+ *     component itself accompanies the executable.
+ *
+ *   - Redistributions must reproduce the above copyright notice, this list of
+ *     conditions and the following disclaimer in the documentation and/or other
+ *     materials provided with the distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************/
+
+#include "../pico_int.h"
+#include "../cd/genplus_macros.h"
+#include "eeprom_spi.h"
+
+/* max supported size 64KB (25x512/95x512) */
+#define SIZE_MASK 0xffff
+#define PAGE_MASK 0x7f
+
+/* hard-coded board implementation (!WP pin not used) */
+#define BIT_DATA (0)
+#define BIT_CLK  (1)
+#define BIT_HOLD (2)
+#define BIT_CS   (3)
+
+typedef enum
+{
+  STANDBY,
+  GET_OPCODE,
+  GET_ADDRESS,
+  WRITE_BYTE,
+  READ_BYTE
+} T_STATE_SPI;
+
+typedef struct
+{
+  uint8 cs;           /* !CS line state */
+  uint8 clk;          /* SCLK line state */
+  uint8 out;          /* SO line state */
+  uint8 status;       /* status register */
+  uint8 opcode;       /* 8-bit opcode */
+  uint8 buffer;       /* 8-bit data buffer */
+  uint16 addr;        /* 16-bit address */
+  uint32 cycles;      /* current operation cycle */
+  T_STATE_SPI state;  /* current operation state */
+} T_EEPROM_SPI;
+
+static T_EEPROM_SPI spi_eeprom;
+
+void *eeprom_spi_init(int *size)
+{
+  /* reset eeprom state */
+  memset(&spi_eeprom, 0, sizeof(T_EEPROM_SPI));
+  spi_eeprom.out = 1;
+  spi_eeprom.state = GET_OPCODE;
+
+  if (size)
+    *size = sizeof(T_EEPROM_SPI);
+  return &spi_eeprom;
+}
+
+void eeprom_spi_write(unsigned char data)
+{
+  /* Make sure !HOLD is high */
+  if (data & (1 << BIT_HOLD))
+  {
+    /* Check !CS state */
+    if (data & (1 << BIT_CS))
+    {
+      /* !CS high -> end of current operation */
+      spi_eeprom.cycles = 0;
+      spi_eeprom.out = 1;
+      spi_eeprom.opcode = 0;
+      spi_eeprom.state = GET_OPCODE;
+    }
+    else
+    {
+      /* !CS low -> process current operation */
+      switch (spi_eeprom.state)
+      {
+        case GET_OPCODE:
+        {
+          /* latch data on CLK positive edge */
+          if ((data & (1 << BIT_CLK)) && !spi_eeprom.clk)
+          {
+            /* 8-bit opcode buffer */
+            spi_eeprom.opcode |= ((data >> BIT_DATA) & 1);
+            spi_eeprom.cycles++;
+
+            /* last bit ? */
+            if (spi_eeprom.cycles == 8)
+            {
+              /* reset cycles count */
+              spi_eeprom.cycles = 0;
+
+              /* Decode instruction */
+              switch (spi_eeprom.opcode)
+              {
+                case 0x01:
+                {
+                  /* WRITE STATUS */
+                  spi_eeprom.buffer = 0;
+                  spi_eeprom.state = WRITE_BYTE;
+                  break;
+                }
+
+                case 0x02:
+                {
+                  /* WRITE BYTE */
+                  spi_eeprom.addr = 0;
+                  spi_eeprom.state = GET_ADDRESS;
+                  break;
+                }
+
+                case 0x03:
+                {
+                  /* READ BYTE */
+                  spi_eeprom.addr = 0;
+                  spi_eeprom.state = GET_ADDRESS;
+                  break;
+                }
+
+                case 0x04:
+                {
+                  /* WRITE DISABLE */
+                  spi_eeprom.status &= ~0x02;
+                  spi_eeprom.state = STANDBY;
+                  break;
+                }
+
+                case 0x05:
+                {
+                  /* READ STATUS */
+                  spi_eeprom.buffer = spi_eeprom.status;
+                  spi_eeprom.state = READ_BYTE;
+                  break;
+                }
+
+                case 0x06:
+                {
+                  /* WRITE ENABLE */
+                  spi_eeprom.status |= 0x02;
+                  spi_eeprom.state = STANDBY;
+                  break;
+                }
+
+                default:
+                {
+                  /* specific instructions (not supported) */
+                  spi_eeprom.state = STANDBY;
+                  break;
+                }
+              }
+            }
+            else
+            {
+              /* shift opcode value */
+              spi_eeprom.opcode = spi_eeprom.opcode << 1;
+            }
+          }
+          break;
+        }
+
+        case GET_ADDRESS:
+        {
+          /* latch data on CLK positive edge */
+          if ((data & (1 << BIT_CLK)) && !spi_eeprom.clk)
+          {
+            /* 16-bit address */
+            spi_eeprom.addr |= ((data >> BIT_DATA) & 1);
+            spi_eeprom.cycles++;
+
+            /* last bit ? */
+            if (spi_eeprom.cycles == 16)
+            {
+              /* reset cycles count */
+              spi_eeprom.cycles = 0;
+
+              /* mask unused address bits */
+              spi_eeprom.addr &= SIZE_MASK;
+
+              /* operation type */
+              if (spi_eeprom.opcode & 0x01)
+              {
+                /* READ operation */
+                spi_eeprom.buffer = Pico.sv.data[spi_eeprom.addr];
+                spi_eeprom.state = READ_BYTE;
+              }
+              else
+              {
+                /* WRITE operation */
+                spi_eeprom.buffer = 0;
+                spi_eeprom.state = WRITE_BYTE;
+              }
+            }
+            else
+            {
+              /* shift address value */
+              spi_eeprom.addr = spi_eeprom.addr << 1;
+            }
+          }
+          break;
+        }
+
+        case WRITE_BYTE:
+        {
+          /* latch data on CLK positive edge */
+          if ((data & (1 << BIT_CLK)) && !spi_eeprom.clk)
+          {
+            /* 8-bit data buffer */
+            spi_eeprom.buffer |= ((data >> BIT_DATA) & 1);
+            spi_eeprom.cycles++;
+
+            /* last bit ? */
+            if (spi_eeprom.cycles == 8)
+            {
+              /* reset cycles count */
+              spi_eeprom.cycles = 0;
+
+              /* write data to destination */
+              if (spi_eeprom.opcode & 0x01)
+              {
+                /* update status register */
+                spi_eeprom.status = (spi_eeprom.status & 0x02) | (spi_eeprom.buffer & 0x0c);
+
+                /* wait for operation end */
+                spi_eeprom.state = STANDBY;
+              }
+              else
+              {
+                /* Memory Array (write-protected) */
+                if (spi_eeprom.status & 2)
+                {
+                  /* check array protection bits (BP0, BP1) */
+                  switch ((spi_eeprom.status >> 2) & 0x03)
+                  {
+                    case 0x01:
+                    {
+                      /* $C000-$FFFF (sector #3) is protected */
+                      if (spi_eeprom.addr < 0xC000)
+                      {
+                        Pico.sv.data[spi_eeprom.addr] = spi_eeprom.buffer;
+                      }
+                      break;
+                    }
+
+                    case 0x02:
+                    {
+                      /* $8000-$FFFF (sectors #2 and #3) is protected */
+                      if (spi_eeprom.addr < 0x8000)
+                      {
+                        Pico.sv.data[spi_eeprom.addr] = spi_eeprom.buffer;
+                      }
+                      break;
+                    }
+
+                    case 0x03:
+                    {
+                      /* $0000-$FFFF (all sectors) is protected */
+                      break;
+                    }
+
+                    default:
+                    {
+                      /* no sectors protected */
+                      Pico.sv.data[spi_eeprom.addr] = spi_eeprom.buffer;
+                      break;
+                    }
+                  }
+                }
+
+                /* reset data buffer */
+                spi_eeprom.buffer = 0;
+
+                /* increase array address (sequential writes are limited within the same page) */
+                spi_eeprom.addr = (spi_eeprom.addr & ~PAGE_MASK) | ((spi_eeprom.addr + 1) & PAGE_MASK);
+              }
+            }
+            else
+            {
+              /* shift data buffer value */
+              spi_eeprom.buffer = spi_eeprom.buffer << 1;
+            }
+          }
+          break;
+        }
+
+        case READ_BYTE:
+        {
+          /* output data on CLK positive edge */
+          if ((data & (1 << BIT_CLK)) && !spi_eeprom.clk)
+          {
+            /* read out bits */
+            spi_eeprom.out = (spi_eeprom.buffer >> (7 - spi_eeprom.cycles)) & 1;
+            spi_eeprom.cycles++;
+
+            /* last bit ? */
+            if (spi_eeprom.cycles == 8)
+            {
+              /* reset cycles count */
+              spi_eeprom.cycles = 0;
+
+              /* read from memory array ? */
+              if (spi_eeprom.opcode == 0x03)
+              {
+                /* read next array byte */
+                spi_eeprom.addr = (spi_eeprom.addr + 1) & SIZE_MASK;
+                spi_eeprom.buffer = Pico.sv.data[spi_eeprom.addr];
+              }
+            }
+          }
+          break;
+        }
+
+        default:
+        {
+          /* wait for !CS low->high transition */
+          break;
+        }
+      }
+    }
+  }
+
+  /* update input lines */
+  spi_eeprom.cs  = (data >> BIT_CS) & 1;
+  spi_eeprom.clk = (data >> BIT_CLK) & 1;
+}
+
+unsigned int eeprom_spi_read(unsigned int address)
+{
+  return (spi_eeprom.out << BIT_DATA);
+}
+
diff --git a/pico/carthw/eeprom_spi.h b/pico/carthw/eeprom_spi.h
new file mode 100644 (file)
index 0000000..2d60e0f
--- /dev/null
@@ -0,0 +1,47 @@
+/****************************************************************************
+ *  Genesis Plus
+ *  SPI Serial EEPROM (25XX512 only) support
+ *
+ *  Copyright (C) 2012  Eke-Eke (Genesis Plus GX)
+ *
+ *  Redistribution and use of this code or any derivative works are permitted
+ *  provided that the following conditions are met:
+ *
+ *   - Redistributions may not be sold, nor may they be used in a commercial
+ *     product or activity.
+ *
+ *   - Redistributions that are modified from the original source must include the
+ *     complete source code, including the source code for all components used by a
+ *     binary built from the modified sources. However, as a special exception, the
+ *     source code distributed need not include anything that is normally distributed
+ *     (in either source or binary form) with the major components (compiler, kernel,
+ *     and so on) of the operating system on which the executable runs, unless that
+ *     component itself accompanies the executable.
+ *
+ *   - Redistributions must reproduce the above copyright notice, this list of
+ *     conditions and the following disclaimer in the documentation and/or other
+ *     materials provided with the distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************/
+
+#ifndef _EEPROM_SPI_H_
+#define _EEPROM_SPI_H_
+
+/* Function prototypes */
+extern void *eeprom_spi_init(int *size);
+extern void eeprom_spi_write(unsigned char data);
+extern unsigned int eeprom_spi_read(unsigned int address);
+
+#endif
similarity index 98%
rename from pico/carthw/svp/svp_memory.c
rename to pico/carthw/svp/memory.c
index b37985e..c721611 100644 (file)
@@ -87,7 +87,7 @@ static u32 PicoRead16_svpr(u32 a)
         a15004_looping = 0;
 
       if (!a15004_looping)
-        elprintf(EL_SVP, "SVP r%i: [%06x] %04x @%06x", realsize, a, d, SekPc);
+        elprintf(EL_SVP, "SVP r: [%06x] %04x @%06x", a, d, SekPc);
 
       if (a == 0xa15004 && !(d&1)) {
         if (!a15004_looping)
index 1bccb3f..8861de0 100644 (file)
@@ -91,23 +91,20 @@ static void PicoSVPLine(void)
 }
 
 
-static int PicoSVPDma(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp)
+static int PicoSVPDma(unsigned int source, int len, unsigned short **base, unsigned int *mask)
 {
        if (source < Pico.romsize) // Rom
        {
-               source -= 2;
-               *srcp = (unsigned short *)(Pico.rom + (source&~1));
-               *limitp = (unsigned short *)(Pico.rom + Pico.romsize);
-               return 1;
+               *base = (unsigned short *)(Pico.rom + (source & 0xfe0000));
+               *mask = 0x1ffff;
+               return source - 2;
        }
        else if ((source & 0xfe0000) == 0x300000)
        {
                elprintf(EL_VDPDMA|EL_SVP, "SVP DmaSlow from %06x, len=%i", source, len);
-               source &= 0x1fffe;
-               source -= 2;
-               *srcp = (unsigned short *)(svp->dram + source);
-               *limitp = (unsigned short *)(svp->dram + sizeof(svp->dram));
-               return 1;
+               *base = (unsigned short *)svp->dram;
+               *mask = 0x1ffff;
+               return source - 2;
        }
        else
                elprintf(EL_VDPDMA|EL_SVP|EL_ANOMALY, "SVP FIXME unhandled DmaSlow from %06x, len=%i", source, len);
index 91ddec7..2fdd199 100644 (file)
@@ -1,4 +1,4 @@
-/* generated by ./tools/make_carthw_c, do not modify */
+/* generated by tools/make_carthw_c, do not modify */
 static const char builtin_carthw_cfg[] =
   "[]\n"
   "check_str=0x150,\"Virtua Racing\"\n"
@@ -28,6 +28,9 @@ static const char builtin_carthw_cfg[] =
   "check_str=0x32b74c,\"Bishop Level\"\n"
   "prop=force_6btn\n"
   "[]\n"
+  "check_str=0x100,\"SEGA SSF\"\n"
+  "hw=ssf2_mapper\n"
+  "[]\n"
   "check_str=0x150,\"SUPER STREET FIGHTER2 The New Challengers\"\n"
   "hw=ssf2_mapper\n"
   "prop=no_sram\n"
index c6b24b8..501d09e 100644 (file)
@@ -122,12 +122,14 @@ static const uint32 toc_ffightj[29] =
   14553, 9834, 10542, 1699, 1792, 1781, 3783, 3052
 };
 
+#if 0
 /* supported WAVE file header (16-bit stereo samples @44.1kHz) */
 static const unsigned char waveHeader[32] =
 {
   0x57,0x41,0x56,0x45,0x66,0x6d,0x74,0x20,0x10,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
   0x44,0xac,0x00,0x00,0x10,0xb1,0x02,0x00,0x04,0x00,0x10,0x00,0x64,0x61,0x74,0x61
 };
+#endif
 
 #ifdef USE_LIBTREMOR
 #ifdef DISABLE_MANY_OGG_OPEN_FILES
index a24a1c3..7dfe4bc 100644 (file)
@@ -26,7 +26,7 @@ PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, uns
   switch (Pico.video.type)
   {
     case 1: // vram
-      r = Pico.vram;
+      r = PicoMem.vram;
       for(; len; len--)
       {
         asrc = cell_map(source >> 2) << 2;
@@ -42,7 +42,7 @@ PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, uns
 
     case 3: // cram
       Pico.m.dirtyPal = 1;
-      r = Pico.cram;
+      r = PicoMem.cram;
       for(a2=a&0x7f; len; len--)
       {
         asrc = cell_map(source >> 2) << 2;
@@ -58,7 +58,7 @@ PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, uns
       break;
 
     case 5: // vsram[a&0x003f]=d;
-      r = Pico.vsram;
+      r = PicoMem.vsram;
       for(a2=a&0x7f; len; len--)
       {
         asrc = cell_map(source >> 2) << 2;
index 73502b2..af320bd 100644 (file)
@@ -31,6 +31,7 @@ PICO_INTERNAL void PicoExitMCD(void)
 PICO_INTERNAL void PicoPowerMCD(void)
 {
   int fmt_size;
+
   SekCycleCntS68k = SekCycleAimS68k = 0;
 
   fmt_size = sizeof(formatted_bram);
@@ -77,16 +78,16 @@ PICO_INTERNAL int PicoResetMCD(void)
 {
   // reset button doesn't affect MCD hardware
 
-  // use SRam.data for RAM cart
+  // use Pico.sv.data for RAM cart
   if (PicoOpt & POPT_EN_MCD_RAMCART) {
-    if (SRam.data == NULL)
-      SRam.data = calloc(1, 0x12000);
+    if (Pico.sv.data == NULL)
+      Pico.sv.data = calloc(1, 0x12000);
   }
-  else if (SRam.data != NULL) {
-    free(SRam.data);
-    SRam.data = NULL;
+  else if (Pico.sv.data != NULL) {
+    free(Pico.sv.data);
+    Pico.sv.data = NULL;
   }
-  SRam.start = SRam.end = 0; // unused
+  Pico.sv.start = Pico.sv.end = 0; // unused
 
   return 0;
 }
@@ -96,17 +97,17 @@ static void SekRunM68kOnce(void)
   int cyc_do;
   pevt_log_m68k_o(EVT_RUN_START);
 
-  if ((cyc_do = SekCycleAim - SekCycleCnt) > 0) {
-    SekCycleCnt += cyc_do;
+  if ((cyc_do = Pico.t.m68c_aim - Pico.t.m68c_cnt) > 0) {
+    Pico.t.m68c_cnt += cyc_do;
 
 #if defined(EMU_C68K)
     PicoCpuCM68k.cycles = cyc_do;
     CycloneRun(&PicoCpuCM68k);
-    SekCycleCnt -= PicoCpuCM68k.cycles;
+    Pico.t.m68c_cnt -= PicoCpuCM68k.cycles;
 #elif defined(EMU_M68K)
-    SekCycleCnt += m68k_execute(cyc_do) - cyc_do;
+    Pico.t.m68c_cnt += m68k_execute(cyc_do) - cyc_do;
 #elif defined(EMU_F68K)
-    SekCycleCnt += fm68k_emulate(cyc_do, 0) - cyc_do;
+    Pico.t.m68c_cnt += fm68k_emulate(cyc_do, 0) - cyc_do;
 #endif
   }
 
@@ -147,7 +148,7 @@ static void pcd_set_cycle_mult(void)
 {
   // ~1.63 for NTSC, ~1.645 for PAL
   if (Pico.m.pal)
-    mcd_m68k_cycle_mult = ((12500000ull << 16) / (50*312*488));
+    mcd_m68k_cycle_mult = ((12500000ull << 16) / (50*313*488));
   else
     mcd_m68k_cycle_mult = ((12500000ull << 16) / (60*262*488)) + 1;
 }
@@ -201,10 +202,10 @@ typedef void (event_cb)(unsigned int now);
 unsigned int pcd_event_times[PCD_EVENT_COUNT];
 static unsigned int event_time_next;
 static event_cb *pcd_event_cbs[PCD_EVENT_COUNT] = {
-  pcd_cdc_event,
-  pcd_int3_timer_event,
-  gfx_update,
-  pcd_dma_event,
+  pcd_cdc_event,            // PCD_EVENT_CDC
+  pcd_int3_timer_event,     // PCD_EVENT_TIMER3
+  gfx_update,               // PCD_EVENT_GFX
+  pcd_dma_event,            // PCD_EVENT_DMA
 };
 
 void pcd_event_schedule(unsigned int now, enum pcd_event event, int after)
@@ -317,39 +318,39 @@ static void SekSyncM68k(void);
 
 void pcd_run_cpus_normal(int m68k_cycles)
 {
-  SekCycleAim += m68k_cycles;
+  Pico.t.m68c_aim += m68k_cycles;
   if (SekShouldInterrupt() || Pico_mcd->m.m68k_poll_cnt < 12)
     Pico_mcd->m.m68k_poll_cnt = 0;
   else if (Pico_mcd->m.m68k_poll_cnt >= 16) {
-    int s68k_left = pcd_sync_s68k(SekCycleAim, 1);
+    int s68k_left = pcd_sync_s68k(Pico.t.m68c_aim, 1);
     if (s68k_left <= 0) {
       elprintf(EL_CDPOLL, "m68k poll [%02x] x%d @%06x",
         Pico_mcd->m.m68k_poll_a, Pico_mcd->m.m68k_poll_cnt, SekPc);
-      SekCycleCnt = SekCycleAim;
+      Pico.t.m68c_cnt = Pico.t.m68c_aim;
       return;
     }
-    SekCycleCnt = SekCycleAim - (s68k_left * 40220 >> 16);
+    Pico.t.m68c_cnt = Pico.t.m68c_aim - (s68k_left * 40220 >> 16);
   }
 
-  while (CYCLES_GT(SekCycleAim, SekCycleCnt)) {
+  while (CYCLES_GT(Pico.t.m68c_aim, Pico.t.m68c_cnt)) {
     SekRunM68kOnce();
     if (Pico_mcd->m.need_sync) {
       Pico_mcd->m.need_sync = 0;
-      pcd_sync_s68k(SekCycleCnt, 0);
+      pcd_sync_s68k(Pico.t.m68c_cnt, 0);
     }
   }
 }
 
 void pcd_run_cpus_lockstep(int m68k_cycles)
 {
-  unsigned int target = SekCycleAim + m68k_cycles;
+  unsigned int target = Pico.t.m68c_aim + m68k_cycles;
   do {
-    SekCycleAim += 8;
+    Pico.t.m68c_aim += 8;
     SekSyncM68k();
-    pcd_sync_s68k(SekCycleAim, 0);
-  } while (CYCLES_GT(target, SekCycleAim));
+    pcd_sync_s68k(Pico.t.m68c_aim, 0);
+  } while (CYCLES_GT(target, Pico.t.m68c_aim));
 
-  SekCycleAim = target;
+  Pico.t.m68c_aim = target;
 }
 
 #define PICO_CD
@@ -365,7 +366,7 @@ void pcd_prepare_frame(void)
 
   // need this because we can't have direct mapping between
   // master<->slave cycle counters because of overflows
-  mcd_m68k_cycle_base = SekCycleAim;
+  mcd_m68k_cycle_base = Pico.t.m68c_aim;
   mcd_s68k_cycle_base = SekCycleAimS68k;
 }
 
@@ -391,7 +392,7 @@ void pcd_state_loaded(void)
   Pico_mcd->pcm_regs_dirty = 1;
 
   // old savestates..
-  cycles = pcd_cycles_m68k_to_s68k(SekCycleAim);
+  cycles = pcd_cycles_m68k_to_s68k(Pico.t.m68c_aim);
   diff = cycles - SekCycleAimS68k;
   if (diff < -1000 || diff > 1000) {
     SekCycleCntS68k = SekCycleAimS68k = cycles;
similarity index 94%
rename from pico/cd/cd_memory.c
rename to pico/cd/memory.c
index 6070161..6890b57 100644 (file)
@@ -602,14 +602,14 @@ static u32 PicoReadM68k8_ramc(u32 a)
 {\r
   u32 d = 0;\r
   if (a == 0x400001) {\r
-    if (SRam.data != NULL)\r
+    if (Pico.sv.data != NULL)\r
       d = 3; // 64k cart\r
     return d;\r
   }\r
 \r
   if ((a & 0xfe0000) == 0x600000) {\r
-    if (SRam.data != NULL)\r
-      d = SRam.data[((a >> 1) & 0xffff) + 0x2000];\r
+    if (Pico.sv.data != NULL)\r
+      d = Pico.sv.data[((a >> 1) & 0xffff) + 0x2000];\r
     return d;\r
   }\r
 \r
@@ -629,9 +629,9 @@ static u32 PicoReadM68k16_ramc(u32 a)
 static void PicoWriteM68k8_ramc(u32 a, u32 d)\r
 {\r
   if ((a & 0xfe0000) == 0x600000) {\r
-    if (SRam.data != NULL && (Pico_mcd->m.bcram_reg & 1)) {\r
-      SRam.data[((a>>1) & 0xffff) + 0x2000] = d;\r
-      SRam.changed = 1;\r
+    if (Pico.sv.data != NULL && (Pico_mcd->m.bcram_reg & 1)) {\r
+      Pico.sv.data[((a>>1) & 0xffff) + 0x2000] = d;\r
+      Pico.sv.changed = 1;\r
     }\r
     return;\r
   }\r
@@ -877,7 +877,7 @@ static u32 PicoReadS68k16_bram(u32 a)
 static void PicoWriteS68k8_bram(u32 a, u32 d)\r
 {\r
   Pico_mcd->bram[(a >> 1) & 0x1fff] = d;\r
-  SRam.changed = 1;\r
+  Pico.sv.changed = 1;\r
 }\r
 \r
 static void PicoWriteS68k16_bram(u32 a, u32 d)\r
@@ -886,7 +886,7 @@ static void PicoWriteS68k16_bram(u32 a, u32 d)
   a = (a >> 1) & 0x1fff;\r
   Pico_mcd->bram[a++] = d;\r
   Pico_mcd->bram[a++] = d >> 8; // TODO: verify..\r
-  SRam.changed = 1;\r
+  Pico.sv.changed = 1;\r
 }\r
 \r
 #ifndef _ASM_CD_MEMORY_C\r
@@ -1044,7 +1044,6 @@ static void remap_prg_window(u32 r1, u32 r3)
 static void remap_word_ram(u32 r3)\r
 {\r
   void *bank;\r
-  int i;\r
 \r
   // WORD RAM\r
   if (!(r3 & 4)) {\r
@@ -1072,22 +1071,6 @@ static void remap_word_ram(u32 r3)
     cpu68k_map_set(s68k_write8_map,  0x080000, 0x0bffff, s68k_dec_write8[b0 ^ 1][m], 1);\r
     cpu68k_map_set(s68k_write16_map, 0x080000, 0x0bffff, s68k_dec_write16[b0 ^ 1][m], 1);\r
   }\r
-\r
-#ifdef EMU_F68K\r
-  // update fetchmap..\r
-  if (!(r3 & 4))\r
-  {\r
-    for (i = M68K_FETCHBANK1*2/16; (i<<(24-FAMEC_FETCHBITS)) < 0x240000; i++)\r
-      PicoCpuFM68k.Fetch[i] = (unsigned long)Pico_mcd->word_ram2M - 0x200000;\r
-  }\r
-  else\r
-  {\r
-    for (i = M68K_FETCHBANK1*2/16; (i<<(24-FAMEC_FETCHBITS)) < 0x220000; i++)\r
-      PicoCpuFM68k.Fetch[i] = (unsigned long)Pico_mcd->word_ram1M[r3 & 1] - 0x200000;\r
-    for (i = M68K_FETCHBANK1*0x0c/0x100; (i<<(24-FAMEC_FETCHBITS)) < 0x0e0000; i++)\r
-      PicoCpuFS68k.Fetch[i] = (unsigned long)Pico_mcd->word_ram1M[(r3&1)^1] - 0x0c0000;\r
-  }\r
-#endif\r
 }\r
 \r
 void pcd_state_loaded_mem(void)\r
@@ -1182,7 +1165,12 @@ PICO_INTERNAL void PicoMemSetupCD(void)
 \r
   // setup FAME fetchmap\r
   {\r
+#ifdef __clang__\r
+    volatile // prevent strange relocs from clang\r
+#endif\r
+    unsigned long ptr_ram = (unsigned long)PicoMem.ram;\r
     int i;\r
+\r
     // M68k\r
     // by default, point everything to fitst 64k of ROM (BIOS)\r
     for (i = 0; i < M68K_FETCHBANK1; i++)\r
@@ -1192,7 +1180,7 @@ PICO_INTERNAL void PicoMemSetupCD(void)
       PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom;\r
     // .. and RAM\r
     for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)\r
-      PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.ram - (i<<(24-FAMEC_FETCHBITS));\r
+      PicoCpuFM68k.Fetch[i] = ptr_ram - (i<<(24-FAMEC_FETCHBITS));\r
     // S68k\r
     // PRG RAM is default\r
     for (i = 0; i < M68K_FETCHBANK1; i++)\r
similarity index 93%
rename from pico/cd/memory_arm.s
rename to pico/cd/memory_arm.S
index f3a1372..fe82ecb 100644 (file)
@@ -6,6 +6,8 @@
 @* See COPYING file in the top-level directory.
 @*
 
+#include "../pico_int_o32.h"
+
 .equiv PCM_STEP_SHIFT, 11
 
 .text
@@ -57,7 +59,6 @@
 .extern s68k_poll_detect
 .extern pcd_pcm_write
 .extern pcd_pcm_read
-.extern PicoCpuCS68k
 .extern PicoRead8_io
 .extern PicoRead16_io
 .extern PicoWrite8_io
@@ -127,9 +128,9 @@ PicoReadM68k8_cell1:                    @ 0x220000 - 0x23ffff, cell arranged
     mov     r3, #0x0e0000
 0:
     cell_map
-    ldr     r1, =(Pico+0x22200)
+    ldr     r1, =Pico
     add     r0, r0, r3
-    ldr     r1, [r1]
+    ldr     r1, [r1, #OFS_Pico_rom]   @ Pico.mcd (used everywhere)
     eor     r0, r0, #1
     ldrb    r0, [r1, r0]
     bx      lr
@@ -140,9 +141,9 @@ PicoRead8_mcd_io:
     cmp     r1, #0x2000                      @ a120xx?
     bne     PicoRead8_io
 
-    ldr     r1, =(Pico+0x22200)
+    ldr     r1, =Pico
     and     r0, r0, #0x3f
-    ldr     r1, [r1]                  @ Pico.mcd (used everywhere)
+    ldr     r1, [r1, #OFS_Pico_rom]   @ Pico.mcd
     cmp     r0, #0x0e
     ldrlt   pc, [pc, r0, lsl #2]
     b       m_m68k_read8_hi
@@ -237,9 +238,9 @@ PicoReadM68k16_cell1:                   @ 0x220000 - 0x23ffff, cell arranged
     mov     r3, #0x0e0000
 0:
     cell_map
-    ldr     r1, =(Pico+0x22200)
+    ldr     r1, =Pico
     add     r0, r0, r3
-    ldr     r1, [r1]
+    ldr     r1, [r1, #OFS_Pico_rom]   @ Pico.mcd
     bic     r0, r0, #1
     ldrh    r0, [r1, r0]
     bx      lr
@@ -251,9 +252,9 @@ PicoRead16_mcd_io:
     bne     PicoRead16_io
 
 m_m68k_read16_m68k_regs:
-    ldr     r1, =(Pico+0x22200)
+    ldr     r1, =Pico
     and     r0, r0, #0x3e
-    ldr     r1, [r1]                  @ Pico.mcd (used everywhere)
+    ldr     r1, [r1, #OFS_Pico_rom]   @ Pico.mcd
     cmp     r0, #0x0e
     ldrlt   pc, [pc, r0, lsl #1]
     b       m_m68k_read16_hi
@@ -328,8 +329,9 @@ PicoWriteM68k8_cell1:                   @ 0x220000 - 0x23ffff, cell arranged
 0:
     mov     r3, r1
     cell_map
-    ldr     r2, =(Pico+0x22200)
+    ldr     r2, =Pico
     add     r0, r0, r12
+    ldr     r2, [r2, #OFS_Pico_rom]     @ Pico.mcd
     ldr     r2, [r2]
     eor     r0, r0, #1
     strb    r3, [r2, r0]
@@ -355,9 +357,9 @@ PicoWriteM68k16_cell1:                   @ 0x220000 - 0x23ffff, cell arranged
 0:
     mov     r3, r1
     cell_map
-    ldr     r1, =(Pico+0x22200)
+    ldr     r1, =Pico
     add     r0, r0, r12
-    ldr     r1, [r1]
+    ldr     r1, [r1, #OFS_Pico_rom]     @ Pico.mcd
     bic     r0, r0, #1
     strh    r3, [r1, r0]
     bx      lr
@@ -397,9 +399,9 @@ PicoReadS68k8_dec0:                     @ 0x080000 - 0x0bffff
 PicoReadS68k8_dec1:
     mov     r3, #0x0a0000               @ + ^ / 2
 0:
-    ldr     r2, =(Pico+0x22200)
+    ldr     r2, =Pico
     eor     r0, r0, #2
-    ldr     r2, [r2]
+    ldr     r2, [r2, #OFS_Pico_rom]     @ Pico.mcd
     movs    r0, r0, lsr #1              @ +4-6 <<16
     add     r2, r2, r3                  @ map to our address
     ldrb    r0, [r2, r0]
@@ -429,8 +431,8 @@ m_s68k_read8_regs:
     bx      lr
 
 m_s68k_read8_comm:
-    ldr     r1, =(Pico+0x22200)
-    ldr     r1, [r1]
+    ldr     r1, =Pico
+    ldr     r1, [r1, #OFS_Pico_rom]     @ Pico.mcd
     add     r1, r1, #0x110000
     ldrb    r1, [r1, r0]
     bic     r0, r0, #1
@@ -442,9 +444,9 @@ m_s68k_read8_pcm:
     bne     m_read_null
 
     @ must not trash r3 and r12
-    ldr     r1, =(Pico+0x22200)
+    ldr     r1, =Pico
     bic     r0, r0, #0xff0000
-    ldr     r1, [r1]
+    ldr     r1, [r1, #OFS_Pico_rom]     @ Pico.mcd
     mov     r2, #0x110000
     orr     r2, r2, #0x002200
     cmp     r0, #0x2000
@@ -477,9 +479,9 @@ PicoReadS68k16_dec0:                    @ 0x080000 - 0x0bffff
 PicoReadS68k16_dec1:
     mov     r3, #0x0a0000               @ + ^ / 2
 0:
-    ldr     r2, =(Pico+0x22200)
+    ldr     r2, =Pico
     eor     r0, r0, #2
-    ldr     r2, [r2]
+    ldr     r2, [r2, #OFS_Pico_rom]     @ Pico.mcd
     mov     r0, r0, lsr #1              @ +4-6 <<16
     add     r2, r2, r3                  @ map to our address
     ldrb    r0, [r2, r0]
@@ -508,9 +510,9 @@ m_s68k_read16_regs:
 
 
 .macro m_s68k_write8_2M_decode
-    ldr     r2, =(Pico+0x22200)
+    ldr     r2, =Pico
     eor     r0, r0, #2
-    ldr     r2, [r2]                   @ Pico.rom
+    ldr     r2, [r2, #OFS_Pico_rom]     @ Pico.mcd
     movs    r0, r0, lsr #1              @ +4-6 <<16
     add     r2, r2, r3                  @ map to our address
 .endm
@@ -592,9 +594,9 @@ m_s68k_write8_pcm:
     bxlt    lr
 
 m_s68k_write8_pcm_ram:
-    ldr     r3, =(Pico+0x22200)
+    ldr     r3, =Pico
     bic     r0, r0, #0x00e000
-    ldr     r3, [r3]
+    ldr     r3, [r3, #OFS_Pico_rom]     @ Pico.mcd
     mov     r0, r0, lsr #1
     add     r2, r3, #0x110000
     add     r2, r2, #0x002200
@@ -611,9 +613,9 @@ m_s68k_write8_pcm_ram:
 
 
 .macro m_s68k_write16_2M_decode
-    ldr     r2, =(Pico+0x22200)
+    ldr     r2, =Pico
     eor     r0, r0, #2
-    ldr     r2, [r2]
+    ldr     r2, [r2, #OFS_Pico_rom]     @ Pico.mcd
     mov     r0, r0, lsr #1              @ +4-6 <<16
     add     r2, r2, r3                  @ map to our address
 .endm
@@ -692,9 +694,9 @@ m_s68k_write16_regs:
     bne     s68k_reg_write16
 
 m_s68k_write16_regs_spec:               @ special case
-    ldr     r2, =(Pico+0x22200)
+    ldr     r2, =Pico
     mov     r0, #0x110000
-    ldr     r2, [r2]
+    ldr     r2, [r2, #OFS_Pico_rom]     @ Pico.mcd
     add     r0, r0, #0x00000f
     strb    r1, [r2, r0]                @ if (a == 0xe) s68k_regs[0xf] = d;
     bx      lr
similarity index 100%
rename from pico/cd/cd_misc.c
rename to pico/cd/misc.c
similarity index 96%
rename from pico/cd/cd_sek.c
rename to pico/cd/sek.c
index d491490..42fea93 100644 (file)
@@ -178,10 +178,8 @@ PICO_INTERNAL int SekInterruptS68k(int irq)
   PicoCpuCS68k.irq=real_irq;
 #endif
 #ifdef EMU_M68K
-  void *oldcontext = m68ki_cpu_p;
-  m68k_set_context(&PicoCpuMS68k);
-  m68k_set_irq(real_irq);
-  m68k_set_context(oldcontext);
+  // avoid m68k_set_irq() for delaying to work
+  PicoCpuMS68k.int_level = real_irq << 8;
 #endif
 #ifdef EMU_F68K
   PicoCpuFS68k.interrupts[0]=real_irq;
index efcd3fd..82ae8a5 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "pico_int.h"
 #include "sound/ym2612.h"
+#include "memory.h"
 #include "debug.h"
 
 #define bit(r, x) ((r>>x)&1)
@@ -39,10 +40,10 @@ char *PDebugMain(void)
   sprintf(dstrp, "mode set 4: %02x\n", (r=reg[0xC])); MVP;
   sprintf(dstrp, "interlace: %i%i, cells: %i, shadow: %i\n", bit(r,2), bit(r,1), (r&0x80) ? 40 : 32, bit(r,3)); MVP;
   sprintf(dstrp, "scroll size: w: %i, h: %i  SRAM: %i; eeprom: %i (%i)\n", reg[0x10]&3, (reg[0x10]&0x30)>>4,
-    !!(SRam.flags & SRF_ENABLED), !!(SRam.flags & SRF_EEPROM), SRam.eeprom_type); MVP;
-  sprintf(dstrp, "sram range: %06x-%06x, reg: %02x\n", SRam.start, SRam.end, Pico.m.sram_reg); MVP;
+    !!(Pico.sv.flags & SRF_ENABLED), !!(Pico.sv.flags & SRF_EEPROM), Pico.sv.eeprom_type); MVP;
+  sprintf(dstrp, "sram range: %06x-%06x, reg: %02x\n", Pico.sv.start, Pico.sv.end, Pico.m.sram_reg); MVP;
   sprintf(dstrp, "pend int: v:%i, h:%i, vdp status: %04x\n", bit(pv->pending_ints,5), bit(pv->pending_ints,4), pv->status); MVP;
-  sprintf(dstrp, "pal: %i, hw: %02x, frame#: %i, cycles: %i\n", Pico.m.pal, Pico.m.hardware, Pico.m.frame_count, SekCyclesDone()); MVP;
+  sprintf(dstrp, "pal: %i, hw: %02x, frame#: %i, cycles: %u\n", Pico.m.pal, Pico.m.hardware, Pico.m.frame_count, SekCyclesDone()); MVP;
   sprintf(dstrp, "M68k: PC: %06x, SR: %04x, irql: %i\n", SekPc, SekSr, SekIrqLevel); MVP;
   for (r = 0; r < 8; r++) {
     sprintf(dstrp, "d%i=%08x, a%i=%08x\n", r, SekDar(r), r, SekDar(r+8)); MVP;
@@ -116,7 +117,7 @@ char *PDebugSpriteList(void)
     unsigned int *sprite;
     int code, code2, sx, sy, height;
 
-    sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
+    sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
 
     // get sprite info
     code = sprite[0];
@@ -233,6 +234,7 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
   struct PicoVideo *pvid=&Pico.video;
   int table=0,u,link=0,*sprite=0,*fsprite,oldsprite[2];
   int x,y,max_sprites = 80, oldcol, oldreg;
+  unsigned char olddbg;
 
   if (!(pvid->reg[12]&1))
     max_sprites = 64;
@@ -243,23 +245,24 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
 
   for (u=0; u < max_sprites && u <= which; u++)
   {
-    sprite=(int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
+    sprite=(int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
 
     link=(sprite[0]>>16)&0x7f;
     if (!link) break; // End of sprites
   }
   if (u >= max_sprites) return;
 
-  fsprite = (int *)(Pico.vram+(table&0x7ffc));
+  fsprite = (int *)(PicoMem.vram+(table&0x7ffc));
   oldsprite[0] = fsprite[0];
   oldsprite[1] = fsprite[1];
   fsprite[0] = (sprite[0] & ~0x007f01ff) | 0x000080;
   fsprite[1] = (sprite[1] & ~0x01ff8000) | 0x800000;
   oldreg = pvid->reg[7];
-  oldcol = Pico.cram[0];
+  oldcol = PicoMem.cram[0];
+  olddbg = pvid->debug_p;
   pvid->reg[7] = 0;
-  Pico.cram[0] = 0;
-  PicoDrawMask = PDRAW_SPRITES_LOW_ON;
+  PicoMem.cram[0] = 0;
+  pvid->debug_p = PVD_KILL_A | PVD_KILL_B;
 
   PicoFrameFull();
   for (y = 0; y < 8*4; y++)
@@ -273,11 +276,11 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
   fsprite[0] = oldsprite[0];
   fsprite[1] = oldsprite[1];
   pvid->reg[7] = oldreg;
-  Pico.cram[0] = oldcol;
-  PicoDrawMask = -1;
+  PicoMem.cram[0] = oldcol;
+  pvid->debug_p = olddbg;
 }
 
-#define dump_ram(ram,fname) \
+#define dump_ram_m(ram,fname,mode) \
 { \
   unsigned short *sram = (unsigned short *) ram; \
   FILE *f; \
@@ -285,7 +288,7 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
 \
   for (i = 0; i < sizeof(ram)/2; i++) \
     sram[i] = (sram[i]<<8) | (sram[i]>>8); \
-  f = fopen(fname, "wb"); \
+  f = fopen(fname, mode); \
   if (f) { \
     fwrite(ram, 1, sizeof(ram), f); \
     fclose(f); \
@@ -294,6 +297,9 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
     sram[i] = (sram[i]<<8) | (sram[i]>>8); \
 }
 
+#define dump_ram(ram,fname) \
+  dump_ram_m(ram,fname,"wb")
+
 #define dump_ram_noswab(ram,fname) \
 { \
   FILE *f; \
@@ -306,18 +312,31 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
 
 void PDebugDumpMem(void)
 {
-  dump_ram_noswab(Pico.zram, "dumps/zram.bin");
-  dump_ram(Pico.cram, "dumps/cram.bin");
+#if 0
+  char buf[1 << M68K_MEM_SHIFT];
+  unsigned int a;
+  for (a = 0; ; a++) {
+    uptr v = m68k_read16_map[a];
+    if (map_flag_set(v))
+      break;
+    v <<= 1;
+    v += a << M68K_MEM_SHIFT;
+    memcpy(buf, (void *)v, sizeof(buf));
+    dump_ram_m(buf, "dumps/cart.bin", a ? "ab" : "wb");
+  }
+#endif
+  dump_ram_noswab(PicoMem.zram, "dumps/zram.bin");
+  dump_ram(PicoMem.cram, "dumps/cram.bin");
 
   if (PicoAHW & PAHW_SMS)
   {
-    dump_ram_noswab(Pico.vramb, "dumps/vram.bin");
+    dump_ram_noswab(PicoMem.vramb, "dumps/vram.bin");
   }
   else
   {
-    dump_ram(Pico.ram,  "dumps/ram.bin");
-    dump_ram(Pico.vram, "dumps/vram.bin");
-    dump_ram(Pico.vsram,"dumps/vsram.bin");
+    dump_ram(PicoMem.ram,  "dumps/ram.bin");
+    dump_ram(PicoMem.vram, "dumps/vram.bin");
+    dump_ram(PicoMem.vsram,"dumps/vsram.bin");
   }
 
   if (PicoAHW & PAHW_MCD)
@@ -356,7 +375,7 @@ void PDebugZ80Frame(void)
     return;
 
   if (Pico.m.pal) {
-    lines = 312;
+    lines = 313;
     line_sample = 68;
   } else {
     lines = 262;
@@ -364,31 +383,31 @@ void PDebugZ80Frame(void)
   }
 
   z80_resetCycles();
-  emustatus &= ~1;
+  PsndStartFrame();
 
-  if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
-    PicoSyncZ80(line_sample*488);
-  if (ym2612.dacen && PsndDacLine <= line_sample)
-    PsndDoDAC(line_sample);
+  if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
+    PicoSyncZ80(Pico.t.m68c_cnt + line_sample * 488);
   if (PsndOut)
     PsndGetSamples(line_sample);
 
-  if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
-    PicoSyncZ80(224*488);
+  if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
+    PicoSyncZ80(Pico.t.m68c_cnt + 224 * 488);
     z80_int();
   }
-  if (ym2612.dacen && PsndDacLine <= 224)
-    PsndDoDAC(224);
   if (PsndOut)
     PsndGetSamples(224);
 
   // sync z80
-  if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
-    PicoSyncZ80(Pico.m.pal ? 151809 : 127671); // cycles adjusted for converter
-  if (PsndOut && ym2612.dacen && PsndDacLine <= lines-1)
-    PsndDoDAC(lines-1);
+  if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
+    Pico.t.m68c_cnt += Pico.m.pal ? 151809 : 127671; // cycles adjusted for converter
+    PicoSyncZ80(Pico.t.m68c_cnt);
+  }
+  if (PsndOut && ym2612.dacen && PsndDacLine < lines)
+    PsndDoDAC(lines - 1);
+  PsndDoPSG(lines - 1);
 
   timers_cycle();
+  Pico.t.m68c_aim = Pico.t.m68c_cnt;
 }
 
 void PDebugCPUStep(void)
index 4c96a9a..83010a4 100644 (file)
@@ -35,7 +35,6 @@ int (*PicoScanBegin)(unsigned int num) = NULL;
 int (*PicoScanEnd)  (unsigned int num) = NULL;\r
 \r
 static unsigned char DefHighCol[8+320+8];\r
-unsigned char *HighCol = DefHighCol;\r
 static unsigned char *HighColBase = DefHighCol;\r
 static int HighColIncrement;\r
 \r
@@ -47,6 +46,10 @@ static int  HighCacheA[41+1];   // caches for high layers
 static int  HighCacheB[41+1];\r
 static int  HighPreSpr[80*2+1]; // slightly preprocessed sprites\r
 \r
+#define LF_PLANE_1 (1 << 0)\r
+#define LF_SH      (1 << 1) // must be = 2\r
+#define LF_FORCE   (1 << 2)\r
+\r
 #define SPRL_HAVE_HI     0x80 // have hi priority sprites\r
 #define SPRL_HAVE_LO     0x40 // *lo*\r
 #define SPRL_MAY_HAVE_OP 0x20 // may have operator sprites on the line\r
@@ -55,12 +58,9 @@ unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, til
 \r
 int rendstatus_old;\r
 int rendlines;\r
-int PicoDrawMask = -1;\r
 \r
 static int skip_next_line=0;\r
 \r
-//unsigned short ppt[] = { 0x0f11, 0x0ff1, 0x01f1, 0x011f, 0x01ff, 0x0f1f, 0x0f0e, 0x0e7c };\r
-\r
 struct TileStrip\r
 {\r
   int nametab; // Position in VRAM of name table (for this tile line)\r
@@ -97,66 +97,44 @@ void blockcpy_or(void *dst, void *src, size_t n, int pat)
 \r
 \r
 #define TileNormMaker(funcname,pix_func)                     \\r
-static int funcname(int sx,int addr,int pal)                 \\r
+static void funcname(int sx, unsigned int pack, int pal)     \\r
 {                                                            \\r
-  unsigned char *pd = Pico.est.HighCol+sx;                   \\r
-  unsigned int pack=0; unsigned int t=0;                     \\r
-                                                             \\r
-  pack=*(unsigned int *)(Pico.vram+addr); /* Get 8 pixels */ \\r
-  if (pack)                                                  \\r
-  {                                                          \\r
-    t=(pack&0x0000f000)>>12; pix_func(0);                    \\r
-    t=(pack&0x00000f00)>> 8; pix_func(1);                    \\r
-    t=(pack&0x000000f0)>> 4; pix_func(2);                    \\r
-    t=(pack&0x0000000f)    ; pix_func(3);                    \\r
-    t=(pack&0xf0000000)>>28; pix_func(4);                    \\r
-    t=(pack&0x0f000000)>>24; pix_func(5);                    \\r
-    t=(pack&0x00f00000)>>20; pix_func(6);                    \\r
-    t=(pack&0x000f0000)>>16; pix_func(7);                    \\r
-    return 0;                                                \\r
-  }                                                          \\r
+  unsigned char *pd = Pico.est.HighCol + sx;                 \\r
+  unsigned int t;                                            \\r
                                                              \\r
-  return 1; /* Tile blank */                                 \\r
+  t = (pack&0x0000f000)>>12; pix_func(0);                    \\r
+  t = (pack&0x00000f00)>> 8; pix_func(1);                    \\r
+  t = (pack&0x000000f0)>> 4; pix_func(2);                    \\r
+  t = (pack&0x0000000f)    ; pix_func(3);                    \\r
+  t = (pack&0xf0000000)>>28; pix_func(4);                    \\r
+  t = (pack&0x0f000000)>>24; pix_func(5);                    \\r
+  t = (pack&0x00f00000)>>20; pix_func(6);                    \\r
+  t = (pack&0x000f0000)>>16; pix_func(7);                    \\r
 }\r
 \r
-\r
 #define TileFlipMaker(funcname,pix_func)                     \\r
-static int funcname(int sx,int addr,int pal)                 \\r
+static void funcname(int sx, unsigned int pack, int pal)     \\r
 {                                                            \\r
-  unsigned char *pd = Pico.est.HighCol+sx;                   \\r
-  unsigned int pack=0; unsigned int t=0;                     \\r
-                                                             \\r
-  pack=*(unsigned int *)(Pico.vram+addr); /* Get 8 pixels */ \\r
-  if (pack)                                                  \\r
-  {                                                          \\r
-    t=(pack&0x000f0000)>>16; pix_func(0);                    \\r
-    t=(pack&0x00f00000)>>20; pix_func(1);                    \\r
-    t=(pack&0x0f000000)>>24; pix_func(2);                    \\r
-    t=(pack&0xf0000000)>>28; pix_func(3);                    \\r
-    t=(pack&0x0000000f)    ; pix_func(4);                    \\r
-    t=(pack&0x000000f0)>> 4; pix_func(5);                    \\r
-    t=(pack&0x00000f00)>> 8; pix_func(6);                    \\r
-    t=(pack&0x0000f000)>>12; pix_func(7);                    \\r
-    return 0;                                                \\r
-  }                                                          \\r
+  unsigned char *pd = Pico.est.HighCol + sx;                 \\r
+  unsigned int t;                                            \\r
                                                              \\r
-  return 1; /* Tile blank */                                 \\r
+  t = (pack&0x000f0000)>>16; pix_func(0);                    \\r
+  t = (pack&0x00f00000)>>20; pix_func(1);                    \\r
+  t = (pack&0x0f000000)>>24; pix_func(2);                    \\r
+  t = (pack&0xf0000000)>>28; pix_func(3);                    \\r
+  t = (pack&0x0000000f)    ; pix_func(4);                    \\r
+  t = (pack&0x000000f0)>> 4; pix_func(5);                    \\r
+  t = (pack&0x00000f00)>> 8; pix_func(6);                    \\r
+  t = (pack&0x0000f000)>>12; pix_func(7);                    \\r
 }\r
 \r
 \r
-#ifdef _ASM_DRAW_C_AMIPS\r
-int TileNorm(int sx,int addr,int pal);\r
-int TileFlip(int sx,int addr,int pal);\r
-#else\r
-\r
 #define pix_just_write(x) \\r
   if (t) pd[x]=pal|t\r
 \r
 TileNormMaker(TileNorm,pix_just_write)\r
 TileFlipMaker(TileFlip,pix_just_write)\r
 \r
-#endif\r
-\r
 #ifndef _ASM_DRAW_C\r
 \r
 // draw a sprite pixel, process operator colors\r
@@ -208,18 +186,24 @@ TileFlipMaker(TileFlipAS_noop, pix_sh_as_noop)
 TileNormMaker(TileNormAS_onlymark, pix_sh_as_onlymark)\r
 TileFlipMaker(TileFlipAS_onlymark, pix_sh_as_onlymark)\r
 \r
+// mark pixel as sprite pixel (AS)\r
+#define pix_and(x) \\r
+  pd[x] = (pd[x] & 0xc0) | (pd[x] & (pal | t))\r
+\r
+TileNormMaker(TileNorm_and, pix_and)\r
+TileFlipMaker(TileFlip_and, pix_and)\r
 \r
 // --------------------------------------------\r
 \r
 #ifndef _ASM_DRAW_C\r
-static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip)\r
+static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)\r
 {\r
   int tilex,dx,ty,code=0,addr=0,cells;\r
   int oldcode=-1,blank=-1; // The tile we know is blank\r
   int pal=0,sh;\r
 \r
   // Draw tiles across screen:\r
-  sh=(plane_sh<<5)&0x40;\r
+  sh = (lflags & LF_SH) << 5; // 0x40\r
   tilex=((-ts->hscroll)>>3)+cellskip;\r
   ty=(ts->line&7)<<1; // Y-Offset into tile\r
   dx=((ts->hscroll-1)&7)+1;\r
@@ -227,13 +211,14 @@ static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip)
   if(dx != 8) cells++; // have hscroll, need to draw 1 cell more\r
   dx+=cellskip<<3;\r
 \r
-  for (; cells > 0; dx+=8,tilex++,cells--)\r
+  for (; cells > 0; dx+=8, tilex++, cells--)\r
   {\r
-    int zero=0;\r
+    unsigned int pack;\r
 \r
-    code=Pico.vram[ts->nametab+(tilex&ts->xmask)];\r
-    if (code==blank) continue;\r
-    if (code>>15) { // high priority tile\r
+    code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];\r
+    if (code == blank)\r
+      continue;\r
+    if ((code >> 15) | (lflags & LF_FORCE)) { // high priority tile\r
       int cval = code | (dx<<16) | (ty<<25);\r
       if(code&0x1000) cval^=7<<26;\r
       *ts->hc++ = cval; // cache it\r
@@ -250,10 +235,14 @@ static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip)
       pal=((code>>9)&0x30)|sh;\r
     }\r
 \r
-    if (code&0x0800) zero=TileFlip(dx,addr,pal);\r
-    else             zero=TileNorm(dx,addr,pal);\r
+    pack = *(unsigned int *)(PicoMem.vram + addr);\r
+    if (!pack) {\r
+      blank = code;\r
+      continue;\r
+    }\r
 \r
-    if (zero) blank=code; // We know this tile is blank now\r
+    if (code & 0x0800) TileFlip(dx, pack, pal);\r
+    else               TileNorm(dx, pack, pal);\r
   }\r
 \r
   // terminate the cache list\r
@@ -263,7 +252,7 @@ static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip)
 }\r
 \r
 // this is messy\r
-void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)\r
+static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)\r
 {\r
   int tilex,dx,code=0,addr=0,cell=0;\r
   int oldcode=-1,blank=-1; // The tile we know is blank\r
@@ -272,19 +261,24 @@ void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
   // Draw tiles across screen:\r
   tilex=(-ts->hscroll)>>3;\r
   dx=((ts->hscroll-1)&7)+1;\r
-  if(dx != 8) cell--; // have hscroll, start with negative cell\r
+  if (ts->hscroll & 0x0f) {\r
+    int adj = ((ts->hscroll ^ dx) >> 3) & 1;\r
+    cell -= adj + 1;\r
+    ts->cells -= adj;\r
+  }\r
   cell+=cellskip;\r
   tilex+=cellskip;\r
   dx+=cellskip<<3;\r
 \r
   for (; cell < ts->cells; dx+=8,tilex++,cell++)\r
   {\r
-    int zero=0,nametabadd,ty;\r
+    int nametabadd, ty;\r
+    unsigned int pack;\r
 \r
     //if((cell&1)==0)\r
     {\r
       int line,vscroll;\r
-      vscroll=Pico.vsram[(plane_sh&1)+(cell&~1)];\r
+      vscroll=PicoMem.vsram[(plane_sh&1)+(cell&~1)];\r
 \r
       // Find the line in the name table\r
       line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..\r
@@ -292,7 +286,7 @@ void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
       ty=(line&7)<<1; // Y-Offset into tile\r
     }\r
 \r
-    code=Pico.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];\r
+    code=PicoMem.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];\r
     if (code==blank) continue;\r
     if (code>>15) { // high priority tile\r
       int cval = code | (dx<<16) | (ty<<25);\r
@@ -310,10 +304,14 @@ void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
       pal=((code>>9)&0x30)|((plane_sh<<5)&0x40);\r
     }\r
 \r
-    if (code&0x0800) zero=TileFlip(dx,addr,pal);\r
-    else             zero=TileNorm(dx,addr,pal);\r
+    pack = *(unsigned int *)(PicoMem.vram + addr);\r
+    if (!pack) {\r
+      blank = code;\r
+      continue;\r
+    }\r
 \r
-    if (zero) blank=code; // We know this tile is blank now\r
+    if (code & 0x0800) TileFlip(dx, pack, pal);\r
+    else               TileNorm(dx, pack, pal);\r
   }\r
 \r
   // terminate the cache list\r
@@ -340,9 +338,9 @@ void DrawStripInterlace(struct TileStrip *ts)
 \r
   for (; cells; dx+=8,tilex++,cells--)\r
   {\r
-    int zero=0;\r
+    unsigned int pack;\r
 \r
-    code=Pico.vram[ts->nametab+(tilex&ts->xmask)];\r
+    code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];\r
     if (code==blank) continue;\r
     if (code>>15) { // high priority tile\r
       int cval = (code&0xfc00) | (dx<<16) | (ty<<25);\r
@@ -362,10 +360,14 @@ void DrawStripInterlace(struct TileStrip *ts)
       pal=((code>>9)&0x30);\r
     }\r
 \r
-    if (code&0x0800) zero=TileFlip(dx,addr,pal);\r
-    else             zero=TileNorm(dx,addr,pal);\r
+    pack = *(unsigned int *)(PicoMem.vram + addr);\r
+    if (!pack) {\r
+      blank = code;\r
+      continue;\r
+    }\r
 \r
-    if (zero) blank=code; // We know this tile is blank now\r
+    if (code & 0x0800) TileFlip(dx, pack, pal);\r
+    else               TileNorm(dx, pack, pal);\r
   }\r
 \r
   // terminate the cache list\r
@@ -395,8 +397,11 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
 \r
   ts.xmask=(1<<shift[width])-1; // X Mask in tiles (0x1f-0x7f)\r
   ymask=(height<<8)|0xff;       // Y Mask in pixels\r
-  if(width == 1)   ymask&=0x1ff;\r
-  else if(width>1) ymask =0x0ff;\r
+  switch (width) {\r
+    case 1: ymask &= 0x1ff; break;\r
+    case 2: ymask =  0x007; break;\r
+    case 3: ymask =  0x0ff; break;\r
+  }\r
 \r
   // Find name table:\r
   if (plane_sh&1) ts.nametab=(pvid->reg[4]&0x07)<<12; // B\r
@@ -408,11 +413,11 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
   htab+=plane_sh&1; // A or B\r
 \r
   // Get horizontal scroll value, will be masked later\r
-  ts.hscroll=Pico.vram[htab&0x7fff];\r
+  ts.hscroll = PicoMem.vram[htab & 0x7fff];\r
 \r
   if((pvid->reg[12]&6) == 6) {\r
     // interlace mode 2\r
-    vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
+    vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value\r
 \r
     // Find the line in the name table\r
     ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1);\r
@@ -425,7 +430,7 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
     ts.line=ymask|(shift[width]<<24); // save some stuff instead of line\r
     DrawStripVSRam(&ts, plane_sh, cellskip);\r
   } else {\r
-    vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
+    vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value\r
 \r
     // Find the line in the name table\r
     ts.line=(vscroll+est->DrawScanline)&ymask;\r
@@ -462,7 +467,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
 \r
   if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) {\r
     // check the first tile code\r
-    code=Pico.vram[nametab+tilex];\r
+    code = PicoMem.vram[nametab + tilex];\r
     // if the whole window uses same priority (what is often the case), we may be able to skip this field\r
     if ((code>>15) != prio) return;\r
   }\r
@@ -475,36 +480,43 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
   {\r
     for (; tilex < tend; tilex++)\r
     {\r
-      int addr=0,zero=0;\r
+      unsigned int pack;\r
+      int dx, addr;\r
       int pal;\r
 \r
-      code=Pico.vram[nametab+tilex];\r
+      code = PicoMem.vram[nametab + tilex];\r
       if (code==blank) continue;\r
       if ((code>>15) != prio) {\r
         est->rendstatus |= PDRAW_WND_DIFF_PRIO;\r
         continue;\r
       }\r
 \r
-      pal=((code>>9)&0x30);\r
-\r
       // Get tile address/2:\r
       addr=(code&0x7ff)<<4;\r
       if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip\r
 \r
-      if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal);\r
-      else             zero=TileNorm(8+(tilex<<3),addr,pal);\r
+      pack = *(unsigned int *)(PicoMem.vram + addr);\r
+      if (!pack) {\r
+        blank = code;\r
+        continue;\r
+      }\r
 \r
-      if (zero) blank=code; // We know this tile is blank now\r
+      pal = ((code >> 9) & 0x30);\r
+      dx = 8 + (tilex << 3);\r
+\r
+      if (code & 0x0800) TileFlip(dx, pack, pal);\r
+      else               TileNorm(dx, pack, pal);\r
     }\r
   }\r
   else\r
   {\r
     for (; tilex < tend; tilex++)\r
     {\r
-      int addr=0,zero=0;\r
+      unsigned int pack;\r
+      int dx, addr;\r
       int pal;\r
 \r
-      code=Pico.vram[nametab+tilex];\r
+      code = PicoMem.vram[nametab + tilex];\r
       if(code==blank) continue;\r
       if((code>>15) != prio) {\r
         est->rendstatus |= PDRAW_WND_DIFF_PRIO;\r
@@ -525,10 +537,16 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
       addr=(code&0x7ff)<<4;\r
       if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip\r
 \r
-      if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal);\r
-      else             zero=TileNorm(8+(tilex<<3),addr,pal);\r
+      pack = *(unsigned int *)(PicoMem.vram + addr);\r
+      if (!pack) {\r
+        blank = code;\r
+        continue;\r
+      }\r
+\r
+      dx = 8 + (tilex << 3);\r
 \r
-      if (zero) blank=code; // We know this tile is blank now\r
+      if (code & 0x0800) TileFlip(dx, pack, pal);\r
+      else               TileNorm(dx, pack, pal);\r
     }\r
   }\r
 }\r
@@ -551,6 +569,7 @@ static void DrawTilesFromCacheShPrep(void)
 static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est)\r
 {\r
   int code, addr, dx;\r
+  unsigned int pack;\r
   int pal;\r
 \r
   // *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it\r
@@ -566,26 +585,32 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est
   {\r
     short blank=-1; // The tile we know is blank\r
     while ((code=*hc++)) {\r
-      int zero;\r
-      if((short)code == blank) continue;\r
+      if (!(code & 0x8000) || (short)code == blank)\r
+        continue;\r
       // Get tile address/2:\r
-      addr=(code&0x7ff)<<4;\r
-      addr+=(unsigned int)code>>25; // y offset into tile\r
-      dx=(code>>16)&0x1ff;\r
+      addr = (code & 0x7ff) << 4;\r
+      addr += code >> 25; // y offset into tile\r
 \r
-      pal=((code>>9)&0x30);\r
-      if (rlim-dx < 0) goto last_cut_tile;\r
+      pack = *(unsigned int *)(PicoMem.vram + addr);\r
+      if (!pack) {\r
+        blank = (short)code;\r
+        continue;\r
+      }\r
 \r
-      if (code&0x0800) zero=TileFlip(dx,addr,pal);\r
-      else             zero=TileNorm(dx,addr,pal);\r
+      dx = (code >> 16) & 0x1ff;\r
+      pal = ((code >> 9) & 0x30);\r
+      if (rlim-dx < 0)\r
+        goto last_cut_tile;\r
 \r
-      if (zero) blank=(short)code;\r
+      if (code & 0x0800) TileFlip(dx, pack, pal);\r
+      else               TileNorm(dx, pack, pal);\r
     }\r
   }\r
   else\r
   {\r
     while ((code=*hc++)) {\r
       unsigned char *zb;\r
+\r
       // Get tile address/2:\r
       addr=(code&0x7ff)<<4;\r
       addr+=(unsigned int)code>>25; // y offset into tile\r
@@ -594,20 +619,26 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est
       *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;\r
       *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;\r
 \r
-      pal=((code>>9)&0x30);\r
-      if (rlim-dx < 0) goto last_cut_tile;\r
+      pack = *(unsigned int *)(PicoMem.vram + addr);\r
+      if (!pack)\r
+        continue;\r
+\r
+      pal = ((code >> 9) & 0x30);\r
+      if (rlim - dx < 0)\r
+        goto last_cut_tile;\r
 \r
-      if (code&0x0800) TileFlip(dx,addr,pal);\r
-      else             TileNorm(dx,addr,pal);\r
+      if (code & 0x0800) TileFlip(dx, pack, pal);\r
+      else               TileNorm(dx, pack, pal);\r
     }\r
   }\r
   return;\r
 \r
 last_cut_tile:\r
+  // for vertical window cutoff\r
   {\r
-    unsigned int t, pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
-    unsigned char *pd = est->HighCol+dx;\r
-    if (!pack) return;\r
+    unsigned char *pd = est->HighCol + dx;\r
+    unsigned int t;\r
+\r
     if (code&0x0800)\r
     {\r
       switch (rlim-dx+8)\r
@@ -651,7 +682,7 @@ static void DrawSprite(int *sprite, int sh)
   int pal;\r
   int tile=0,delta=0;\r
   int sx, sy;\r
-  int (*fTileFunc)(int sx,int addr,int pal);\r
+  void (*fTileFunc)(int sx, unsigned int pack, int pal);\r
 \r
   // parse the sprite data\r
   sy=sprite[0];\r
@@ -685,15 +716,38 @@ static void DrawSprite(int *sprite, int sh)
 \r
   for (; width; width--,sx+=8,tile+=delta)\r
   {\r
+    unsigned int pack;\r
+\r
     if(sx<=0)   continue;\r
     if(sx>=328) break; // Offscreen\r
 \r
-    tile&=0x7fff; // Clip tile address\r
-    fTileFunc(sx,tile,pal);\r
+    pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
+    fTileFunc(sx, pack, pal);\r
   }\r
 }\r
 #endif\r
 \r
+static NOINLINE void DrawTilesFromCacheForced(const int *hc)\r
+{\r
+  int code, addr, dx;\r
+  unsigned int pack;\r
+  int pal;\r
+\r
+  // *ts->hc++ = code | (dx<<16) | (ty<<25);\r
+  while ((code = *hc++)) {\r
+    // Get tile address/2:\r
+    addr = (code & 0x7ff) << 4;\r
+    addr += (code >> 25) & 0x0e; // y offset into tile\r
+\r
+    dx = (code >> 16) & 0x1ff;\r
+    pal = ((code >> 9) & 0x30);\r
+    pack = *(unsigned int *)(PicoMem.vram + addr);\r
+\r
+    if (code & 0x0800) TileFlip_and(dx, pack, pal);\r
+    else               TileNorm_and(dx, pack, pal);\r
+  }\r
+}\r
+\r
 static void DrawSpriteInterlace(unsigned int *sprite)\r
 {\r
   int width=0,height=0;\r
@@ -728,17 +782,19 @@ static void DrawSpriteInterlace(unsigned int *sprite)
 \r
   for (; width; width--,sx+=8,tile+=delta)\r
   {\r
+    unsigned int pack;\r
+\r
     if(sx<=0)   continue;\r
     if(sx>=328) break; // Offscreen\r
 \r
-    tile&=0x7fff; // Clip tile address\r
-    if (code&0x0800) TileFlip(sx,tile,pal);\r
-    else             TileNorm(sx,tile,pal);\r
+    pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
+    if (code & 0x0800) TileFlip(sx, pack, pal);\r
+    else               TileNorm(sx, pack, pal);\r
   }\r
 }\r
 \r
 \r
-static void DrawAllSpritesInterlace(int pri, int sh)\r
+static NOINLINE void DrawAllSpritesInterlace(int pri, int sh)\r
 {\r
   struct PicoVideo *pvid=&Pico.video;\r
   int i,u,table,link=0,sline=Pico.est.DrawScanline<<1;\r
@@ -753,7 +809,7 @@ static void DrawAllSpritesInterlace(int pri, int sh)
     unsigned int *sprite;\r
     int code, sx, sy, height;\r
 \r
-    sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+    sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
 \r
     // get sprite info\r
     code = sprite[0];\r
@@ -795,7 +851,7 @@ static void DrawAllSpritesInterlace(int pri, int sh)
  */\r
 static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)\r
 {\r
-  int (*fTileFunc)(int sx,int addr,int pal);\r
+  void (*fTileFunc)(int sx, unsigned int pack, int pal);\r
   unsigned char *p;\r
   int cnt;\r
 \r
@@ -851,11 +907,13 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
 \r
     for (; width; width--,sx+=8,tile+=delta)\r
     {\r
+      unsigned int pack;\r
+\r
       if(sx<=0)   continue;\r
       if(sx>=328) break; // Offscreen\r
 \r
-      tile&=0x7fff; // Clip tile address\r
-      fTileFunc(sx,tile,pal);\r
+      pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
+      fTileFunc(sx, pack, pal);\r
     }\r
   }\r
 }\r
@@ -863,7 +921,7 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
 \r
 static void DrawSpritesHiAS(unsigned char *sprited, int sh)\r
 {\r
-  int (*fTileFunc)(int sx,int addr,int pal);\r
+  void (*fTileFunc)(int sx, unsigned int pack, int pal);\r
   unsigned char *p;\r
   int entry, cnt, sh_cnt = 0;\r
 \r
@@ -923,11 +981,13 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh)
     pal |= 0x80;\r
     for (; width; width--,sx+=8,tile+=delta)\r
     {\r
+      unsigned int pack;\r
+\r
       if(sx<=0)   continue;\r
       if(sx>=328) break; // Offscreen\r
 \r
-      tile&=0x7fff; // Clip tile address\r
-      fTileFunc(sx,tile,pal);\r
+      pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
+      fTileFunc(sx, pack, pal);\r
     }\r
   }\r
 \r
@@ -955,7 +1015,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh)
 // Index + 0  :    hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size\r
 // Index + 4  :    xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
 \r
-void PrepareSprites(int full)\r
+static NOINLINE void PrepareSprites(int full)\r
 {\r
   const struct PicoVideo *pvid=&Pico.video;\r
   const struct PicoEState *est=&Pico.est;\r
@@ -986,7 +1046,7 @@ void PrepareSprites(int full)
       unsigned int *sprite;\r
       int code2, sx, sy, height;\r
 \r
-      sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+      sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
 \r
       // parse sprite info\r
       code2 = sprite[1];\r
@@ -1039,7 +1099,7 @@ found:;
       unsigned int *sprite;\r
       int code, code2, sx, sy, hv, height, width;\r
 \r
-      sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+      sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
 \r
       // parse sprite info\r
       code = sprite[0];\r
@@ -1118,16 +1178,9 @@ found:;
 static void DrawAllSprites(unsigned char *sprited, int prio, int sh,\r
                            struct PicoEState *est)\r
 {\r
-  int rs = est->rendstatus;\r
   unsigned char *p;\r
   int cnt;\r
 \r
-  if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
-    //elprintf(EL_STATUS, "PrepareSprites(%i)", (rs>>4)&1);\r
-    PrepareSprites(rs & PDRAW_DIRTY_SPRITES);\r
-    est->rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
-  }\r
-\r
   cnt = sprited[0] & 0x7f;\r
   if (cnt == 0) return;\r
 \r
@@ -1170,7 +1223,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
 \r
   Pico.m.dirtyPal = 0;\r
 \r
-  spal = (void *)Pico.cram;\r
+  spal = (void *)PicoMem.cram;\r
   dpal = (void *)est->HighPal;\r
 \r
   for (i = 0; i < 0x40 / 2; i++) {\r
@@ -1252,9 +1305,9 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
     rs |= PDRAW_SONIC_MODE;\r
     est->rendstatus = rs;\r
     if (dirty_count == 3) {\r
-      blockcpy(est->HighPal, Pico.cram, 0x40*2);\r
+      blockcpy(est->HighPal, PicoMem.cram, 0x40*2);\r
     } else if (dirty_count == 11) {\r
-      blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2);\r
+      blockcpy(est->HighPal+0x40, PicoMem.cram, 0x40*2);\r
     }\r
   }\r
 \r
@@ -1286,8 +1339,14 @@ static int DrawDisplay(int sh)
   struct PicoEState *est=&Pico.est;\r
   unsigned char *sprited = &HighLnSpr[est->DrawScanline][0];\r
   struct PicoVideo *pvid=&Pico.video;\r
-  int win=0,edge=0,hvwind=0;\r
-  int maxw,maxcells;\r
+  int win=0, edge=0, hvwind=0, lflags;\r
+  int maxw, maxcells;\r
+\r
+  if (est->rendstatus & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
+    // elprintf(EL_STATUS, "PrepareSprites(%i)", (est->rendstatus>>4)&1);\r
+    PrepareSprites(est->rendstatus & PDRAW_DIRTY_SPRITES);\r
+    est->rendstatus &= ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
+  }\r
 \r
   est->rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO);\r
 \r
@@ -1319,29 +1378,40 @@ static int DrawDisplay(int sh)
   }\r
 \r
   /* - layer B low - */\r
-  if (PicoDrawMask & PDRAW_LAYERB_ON)\r
-    DrawLayer(1|(sh<<1), HighCacheB, 0, maxcells, est);\r
+  if (!(pvid->debug_p & PVD_KILL_B)) {\r
+    lflags = LF_PLANE_1 | (sh << 1);\r
+    if (pvid->debug_p & PVD_FORCE_B)\r
+      lflags |= LF_FORCE;\r
+    DrawLayer(lflags, HighCacheB, 0, maxcells, est);\r
+  }\r
   /* - layer A low - */\r
-  if (!(PicoDrawMask & PDRAW_LAYERA_ON));\r
+  lflags = 0 | (sh << 1);\r
+  if (pvid->debug_p & PVD_FORCE_A)\r
+    lflags |= LF_FORCE;\r
+  if (pvid->debug_p & PVD_KILL_A)\r
+    ;\r
   else if (hvwind == 1)\r
     DrawWindow(0, maxcells>>1, 0, sh, est);\r
   else if (hvwind == 2) {\r
-    DrawLayer(0|(sh<<1), HighCacheA, (win&0x80) ?    0 : edge<<1, (win&0x80) ?     edge<<1 : maxcells, est);\r
-    DrawWindow(                      (win&0x80) ? edge :       0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est);\r
-  } else\r
-    DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells, est);\r
+    DrawLayer(lflags, HighCacheA, (win&0x80) ?    0 : edge<<1, (win&0x80) ?     edge<<1 : maxcells, est);\r
+    DrawWindow(                   (win&0x80) ? edge :       0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est);\r
+  }\r
+  else\r
+    DrawLayer(lflags, HighCacheA, 0, maxcells, est);\r
   /* - sprites low - */\r
-  if (!(PicoDrawMask & PDRAW_SPRITES_LOW_ON));\r
-  else if (Pico.est.rendstatus & PDRAW_INTERLACE)\r
+  if (pvid->debug_p & PVD_KILL_S_LO)\r
+    ;\r
+  else if (est->rendstatus & PDRAW_INTERLACE)\r
     DrawAllSpritesInterlace(0, sh);\r
   else if (sprited[1] & SPRL_HAVE_LO)\r
     DrawAllSprites(sprited, 0, sh, est);\r
 \r
   /* - layer B hi - */\r
-  if ((PicoDrawMask & PDRAW_LAYERB_ON) && HighCacheB[0])\r
+  if (!(pvid->debug_p & PVD_KILL_B) && HighCacheB[0])\r
     DrawTilesFromCache(HighCacheB, sh, maxw, est);\r
   /* - layer A hi - */\r
-  if (!(PicoDrawMask & PDRAW_LAYERA_ON));\r
+  if (pvid->debug_p & PVD_KILL_A)\r
+    ;\r
   else if (hvwind == 1)\r
     DrawWindow(0, maxcells>>1, 1, sh, est);\r
   else if (hvwind == 2) {\r
@@ -1352,8 +1422,9 @@ static int DrawDisplay(int sh)
     if (HighCacheA[0])\r
       DrawTilesFromCache(HighCacheA, sh, maxw, est);\r
   /* - sprites hi - */\r
-  if (!(PicoDrawMask & PDRAW_SPRITES_HI_ON));\r
-  else if (Pico.est.rendstatus & PDRAW_INTERLACE)\r
+  if (pvid->debug_p & PVD_KILL_S_HI)\r
+    ;\r
+  else if (est->rendstatus & PDRAW_INTERLACE)\r
     DrawAllSpritesInterlace(1, sh);\r
   // have sprites without layer pri bit ontop of sprites with that bit\r
   else if ((sprited[1] & 0xd0) == 0xd0 && (PicoOpt & POPT_ACC_SPRITES))\r
@@ -1363,6 +1434,11 @@ static int DrawDisplay(int sh)
   else if (sprited[1] & SPRL_HAVE_HI)\r
     DrawAllSprites(sprited, 1, 0, est);\r
 \r
+  if (pvid->debug_p & PVD_FORCE_B)\r
+    DrawTilesFromCacheForced(HighCacheB);\r
+  else if (pvid->debug_p & PVD_FORCE_A)\r
+    DrawTilesFromCacheForced(HighCacheA);\r
+\r
 #if 0\r
   {\r
     int *c, a, b;\r
@@ -1448,6 +1524,9 @@ static void PicoLine(int line, int offs, int sh, int bgc)
     return;\r
   }\r
 \r
+  if (Pico.video.debug_p & (PVD_FORCE_A | PVD_FORCE_B))\r
+    bgc = 0x3f;\r
+\r
   // Draw screen:\r
   BackFill(bgc, sh, &Pico.est);\r
   if (Pico.video.reg[1]&0x40)\r
@@ -1471,13 +1550,14 @@ void PicoDrawSync(int to, int blank_last_line)
 \r
   pprof_start(draw);\r
 \r
-  if (rendlines != 240)\r
+  if (rendlines != 240) {\r
     offs = 8;\r
+    if (to > 223)\r
+      to = 223;\r
+  }\r
 \r
   for (line = Pico.est.DrawScanline; line < to; line++)\r
-  {\r
     PicoLine(line, offs, sh, bgc);\r
-  }\r
 \r
   // last line\r
   if (line <= to)\r
@@ -1537,7 +1617,7 @@ void PicoDrawSetOutBuf(void *dest, int increment)
 {\r
   DrawLineDestBase = dest;\r
   DrawLineDestIncrement = increment;\r
-  Pico.est.DrawLineDest = (unsigned char*)DrawLineDestBase + Pico.est.DrawScanline * increment;\r
+  Pico.est.DrawLineDest = (char *)DrawLineDestBase + Pico.est.DrawScanline * increment;\r
 }\r
 \r
 void PicoDrawSetInternalBuf(void *dest, int increment)\r
index 1b8cdf5..f0e0518 100644 (file)
@@ -25,7 +25,7 @@ static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];
 static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers\r
 static int HighCache2B[41*(TILE_ROWS+1)+1+1];\r
 \r
-unsigned short *PicoCramHigh=Pico.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r
+unsigned short *PicoCramHigh=PicoMem.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)\r
 void (*PicoPrepareCram)()=0;            // prepares PicoCramHigh for renderer to use\r
 \r
 \r
@@ -46,7 +46,7 @@ static int TileXnormYnorm(unsigned char *pd,int addr,unsigned char pal)
        int i;\r
 \r
        for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {\r
-               pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+               pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
                if(!pack) continue;\r
 \r
                t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);\r
@@ -69,7 +69,7 @@ static int TileXflipYnorm(unsigned char *pd,int addr,unsigned char pal)
        int i;\r
 \r
        for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {\r
-               pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+               pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
                if(!pack) continue;\r
 \r
                t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);\r
@@ -92,7 +92,7 @@ static int TileXnormYflip(unsigned char *pd,int addr,unsigned char pal)
 \r
        addr+=14;\r
        for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {\r
-               pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+               pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
                if(!pack) continue;\r
 \r
                t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);\r
@@ -116,7 +116,7 @@ static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal)
 \r
        addr+=14;\r
        for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {\r
-               pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+               pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
                if(!pack) continue;\r
 \r
                t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);\r
@@ -161,7 +161,7 @@ static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
        nametab += nametab_step*start;\r
 \r
        // check priority\r
-       code=Pico.vram[nametab+tile_start];\r
+       code=PicoMem.vram[nametab+tile_start];\r
        if ((code>>15) != prio) return; // hack: just assume that whole window uses same priority\r
 \r
        scrpos+=8*LINE_WIDTH+8;\r
@@ -175,7 +175,7 @@ static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
 //                     unsigned short *pal=NULL;\r
                        unsigned char pal;\r
 \r
-                       code=Pico.vram[nametab+tilex];\r
+                       code=PicoMem.vram[nametab+tilex];\r
                        if (code==blank) continue;\r
 \r
                        // Get tile address/2:\r
@@ -222,7 +222,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
 \r
        if(!(pvid->reg[11]&3)) { // full screen scroll\r
                // Get horizontal scroll value\r
-               hscroll=Pico.vram[htab&0x7fff];\r
+               hscroll=PicoMem.vram[htab&0x7fff];\r
                htab = 0; // this marks that we don't have to update scroll value\r
        }\r
 \r
@@ -243,7 +243,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
        scrpos+=8*LINE_WIDTH*(planestart-START_ROW);\r
 \r
        // Get vertical scroll value:\r
-       vscroll=Pico.vsram[plane]&0x1ff;\r
+       vscroll=PicoMem.vsram[plane]&0x1ff;\r
        scrpos+=(8-(vscroll&7))*LINE_WIDTH;\r
        if(vscroll&7) planeend++; // we have vertically clipped tiles due to vscroll, so we need 1 more row\r
 \r
@@ -262,7 +262,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
                if(htab) {\r
                        int htaddr=htab+(trow<<4);\r
                        if(trow) htaddr-=(vscroll&7)<<1;\r
-                       hscroll=Pico.vram[htaddr&0x7fff];\r
+                       hscroll=PicoMem.vram[htaddr&0x7fff];\r
                }\r
 \r
                // Draw tiles across screen:\r
@@ -276,7 +276,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
 //                     unsigned short *pal=NULL;\r
                        unsigned char pal;\r
 \r
-                       code=Pico.vram[nametab_row+(tilex&xmask)];\r
+                       code=PicoMem.vram[nametab_row+(tilex&xmask)];\r
                        if (code==blank) continue;\r
 \r
                        if (code>>15) { // high priority tile\r
@@ -422,7 +422,7 @@ static void DrawAllSpritesFull(int prio, int maxwidth)
                unsigned int *sprite=NULL;\r
                int code, code2, sx, sy, height;\r
 \r
-               sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+               sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
 \r
                // get sprite info\r
                code = sprite[0];\r
@@ -551,9 +551,9 @@ static void DrawDisplayFull(void)
        if (hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }\r
 \r
        HighCache2A[1] = HighCache2B[1] = 0;\r
-       if (PicoDrawMask & PDRAW_LAYERB_ON)\r
+       if (!(pvid->debug_p & PVD_KILL_B))\r
                DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW, est);\r
-       if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin)\r
+       if (!(pvid->debug_p & PVD_KILL_A)) switch (hvwin)\r
        {\r
                case 4:\r
                // fullscreen window\r
@@ -579,12 +579,12 @@ static void DrawDisplayFull(void)
                DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW, est);\r
                break;\r
        }\r
-       if (PicoDrawMask & PDRAW_SPRITES_LOW_ON)\r
+       if (!(pvid->debug_p & PVD_KILL_S_LO))\r
                DrawAllSpritesFull(0, maxw);\r
 \r
        if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B, est);\r
        if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A, est);\r
-       if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin)\r
+       if (!(pvid->debug_p & PVD_KILL_A)) switch (hvwin)\r
        {\r
                case 4:\r
                // fullscreen window\r
@@ -603,7 +603,7 @@ static void DrawDisplayFull(void)
                DrawWindowFull(winstart, winend, 1, est);\r
                break;\r
        }\r
-       if (PicoDrawMask & PDRAW_SPRITES_HI_ON)\r
+       if (!(pvid->debug_p & PVD_KILL_S_HI))\r
                DrawAllSpritesFull(1, maxw);\r
 }\r
 \r
index 6e7e1ac..6b110b3 100644 (file)
@@ -73,8 +73,17 @@ BackFillFull:
 \r
 @ -------- some macros --------\r
 \r
+@ helpers\r
+.macro add_c24 d s c\r
+    add     \d, \s, #(\c & 0x00ff00)\r
+.if \c & 0x0000ff\r
+    add     \d, \d, #(\c & 0x0000ff)\r
+.endif\r
+.if \c & 0xff0000\r
+    add     \d, \d, #(\c & 0xff0000)\r
+.endif\r
+.endm\r
 \r
-@ helper\r
 @ TileLineSinglecol (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: pixels8_old\r
 .macro TileLineSinglecol notsinglecol=0\r
     and     r2, r2, #0xf        @ #0x0000000f\r
@@ -353,10 +362,10 @@ DrawLayerFull:
 \r
     mov     r6, r1        @ hcache\r
 \r
-    ldr     r11, [r12, #OFS_Pico_video]\r
-    ldr     r10, [r12, #OFS_Pico_vram]\r
-    ldrb    r5, [r11, #13]        @ pvid->reg[13]\r
-    ldrb    r7, [r11, #11]\r
+    ldr     r11, [r12, #OFS_EST_Pico]\r
+    ldr     r10, [r12, #OFS_EST_PicoMem_vram]\r
+    ldrb    r5, [r11, #OFS_Pico_video_reg+13] @ pvid->reg[13]\r
+    ldrb    r7, [r11, #OFS_Pico_video_reg+11]\r
 \r
     sub     lr, r3, r2\r
     and     lr, lr, #0x00ff0000   @ lr=cells\r
@@ -366,7 +375,7 @@ DrawLayerFull:
     bic     r5, r5, #0x00ff0000   @ just in case\r
 \r
     tst     r7, #3                @ full screen scroll? (if ==0)\r
-    ldrb    r7, [r11, #16]        @ ??hh??ww\r
+    ldrb    r7, [r11, #OFS_Pico_video_reg+16] @ ??hh??ww\r
     ldreqh  r5, [r10, r5]\r
     biceq   r5, r5, #0x0000fc00   @ r5=hscroll (0-0x3ff)\r
     movne   r5, r5, lsr #1\r
@@ -397,22 +406,21 @@ DrawLayerFull:
 \r
     @ Find name table:\r
     tst     r0, r0\r
-    ldreqb  r4, [r11, #2]\r
+    ldreqb  r4, [r11, #OFS_Pico_video_reg+2]\r
     moveq   r4, r4, lsr #3\r
-    ldrneb  r4, [r11, #4]\r
+    ldrneb  r4, [r11, #OFS_Pico_video_reg+4]\r
     and     r4, r4, #7\r
     orr     lr, lr, r4, lsl #13   @ lr|=nametab_bits{3}<<13\r
 \r
     ldr     r11,[sp, #9*4]        @ est\r
     sub     r4, r9, #(START_ROW<<24)\r
-    ldr     r11, [r11, #OFS_Draw2FB]\r
+    ldr     r11, [r11, #OFS_EST_Draw2FB]\r
     mov     r4, r4, asr #24\r
     mov     r7, #328*8\r
     mla     r11, r4, r7, r11      @ scrpos+=8*328*(planestart-START_ROW);\r
 \r
     @ Get vertical scroll value:\r
-    add     r7, r10, #0x012000\r
-    add     r7, r7,  #0x000180    @ r7=Pico.vsram (Pico+0x22180)\r
+    add_c24 r7, r10, (OFS_PMEM_vsram-OFS_PMEM_vram)\r
     ldr     r7, [r7]\r
     tst     r0, r0\r
     moveq   r7, r7, lsl #22\r
@@ -582,13 +590,13 @@ DrawTilesFromCacheF:
     mov     r9, #0xff000000 @ r9=prevcode=-1\r
     mvn     r6, #0          @ r6=prevy=-1\r
 \r
-    ldr     r4, [r1, #OFS_Draw2FB]\r
+    ldr     r4, [r1, #OFS_EST_Draw2FB]\r
     ldr     r2, [r0], #4    @ read y offset\r
     mov     r7, #328\r
     mla     r2, r7, r2, r4\r
     sub     r12, r2, #(328*8*START_ROW) @ r12=scrpos\r
 \r
-    ldr     r10, [r1, #OFS_Pico_vram]\r
+    ldr     r10, [r1, #OFS_EST_PicoMem_vram]\r
     mov     r8, r0               @ hc\r
     mov     r0, #0xf\r
 \r
@@ -674,11 +682,11 @@ DrawTilesFromCacheF:
 DrawWindowFull:\r
     stmfd   sp!, {r4-r11,lr}\r
 \r
-    ldr     r11, [r3, #OFS_Pico_video]\r
-    ldrb    r12, [r11, #3]        @ pvid->reg[3]\r
+    ldr     r11, [r3, #OFS_EST_Pico]\r
+    ldrb    r12, [r11, #OFS_Pico_video_reg+3] @ pvid->reg[3]\r
     mov     r12, r12, lsl #10\r
 \r
-    ldr     r4, [r11, #12]\r
+    ldr     r4, [r11, #OFS_Pico_video_reg+12]\r
     mov     r5, #1                @ nametab_step\r
     tst     r4, #1                @ 40 cell mode?\r
     andne   r12, r12, #0xf000     @ 0x3c<<10\r
@@ -689,7 +697,7 @@ DrawWindowFull:
     and     r4, r0, #0xff\r
     mla     r12, r5, r4, r12      @ nametab += nametab_step*start;\r
 \r
-    ldr     r10, [r3, #OFS_Pico_vram]\r
+    ldr     r10, [r3, #OFS_EST_PicoMem_vram]\r
     mov     r4, r0, lsr #16       @ r4=start_cell_h\r
     add     r7, r12, r4, lsl #1\r
 \r
@@ -707,7 +715,7 @@ DrawWindowFull:
 \r
     mov     r9, #0xff000000       @ r9=prevcode=-1\r
 \r
-    ldr     r11, [r3, #OFS_Draw2FB]\r
+    ldr     r11, [r3, #OFS_EST_Draw2FB]\r
     and     r4, r0, #0xff\r
     add     r11, r11, #328*8\r
     sub     r4, r4, #START_ROW\r
@@ -760,7 +768,8 @@ DrawWindowFull:
     tst     r9, #0x080000       @ hflip?\r
     bne     .dwf_hflip\r
 \r
-    @ Tile (r1=pdest, r3=pal, r9=prevcode, r10=Pico.vram) r2,r4,r7: scratch, r0=0xf\r
+    @ Tile (r1=pdest, r3=pal, r9=prevcode, r10=PicoMem.vram)\r
+    @ r2,r4,r7: scratch, r0=0xf\r
     Tile 0, 0\r
     b       .dwfloop\r
 \r
@@ -870,7 +879,8 @@ DrawWindowFull:
     cmp     r6, #(END_ROW*8+8)\r
     bge     52b\r
 \r
-    @ Tile (r1=pdest, r3=pal, r9=prevcode, r10=Pico.vram) r2,r4,r7: scratch, r0=0xf\r
+    @ Tile (r1=pdest, r3=pal, r9=prevcode, r10=PicoMem.vram)\r
+    @ r2,r4,r7: scratch, r0=0xf\r
     Tile \hflip, \vflip\r
     b       52b\r
 .endm\r
@@ -905,8 +915,8 @@ DrawSpriteFull:
     and     r3, lr, #0x6000\r
     mov     r3, r3, lsr #9  @ r3=pal=((code>>9)&0x30);\r
 \r
-    ldr     r11, [r1, #OFS_Draw2FB]\r
-    ldr     r10, [r1, #OFS_Pico_vram]\r
+    ldr     r11, [r1, #OFS_EST_Draw2FB]\r
+    ldr     r10, [r1, #OFS_EST_PicoMem_vram]\r
     sub     r1, r12, #(START_ROW*8)\r
     mov     r0, #328\r
     mla     r11, r1, r0, r11      @ scrpos+=(sy-START_ROW*8)*328;\r
diff --git a/pico/draw_amips.s b/pico/draw_amips.s
deleted file mode 100644 (file)
index fa7906e..0000000
+++ /dev/null
@@ -1,1756 +0,0 @@
-#*
-#* several drawing related functions for Allegrex MIPS
-#* (C) notaz, 2007-2008
-#*
-#* This work is licensed under the terms of MAME license.
-#* See COPYING file in the top-level directory.
-#*
-#* this is highly specialized, be careful if changing related C code!
-#*
-
-.set noreorder # don't reorder any instructions
-.set noat      # don't use $at
-
-.text
-.align 4
-
-# void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count)
-
-.global amips_clut
-
-amips_clut:
-    srl     $a3, 2
-amips_clut_loop:
-    lbu     $t0, 0($a1)           # tried lw here, no improvement noticed
-    lbu     $t1, 1($a1)
-    lbu     $t2, 2($a1)
-    lbu     $t3, 3($a1)
-    sll     $t0, 1
-    sll     $t1, 1
-    sll     $t2, 1
-    sll     $t3, 1
-    addu    $t0, $a2
-    addu    $t1, $a2
-    addu    $t2, $a2
-    addu    $t3, $a2
-    lhu     $t0, 0($t0)
-    lhu     $t1, 0($t1)
-    lhu     $t2, 0($t2)
-    lhu     $t3, 0($t3)
-    ins     $t0, $t1, 16, 16      # ins rt, rs, pos, size - Insert size bits starting
-    ins     $t2, $t3, 16, 16      #  from the LSB of rs into rt starting at position pos
-    sw      $t0, 0($a0)
-    sw      $t2, 4($a0)
-    addiu   $a0, 8
-    addiu   $a3, -1
-    bnez    $a3, amips_clut_loop
-    addiu   $a1, 4
-    jr      $ra
-    nop
-
-
-.global amips_clut_6bit
-
-amips_clut_6bit:
-    srl     $a3, 2
-    li      $t4, 0
-    li      $t5, 0
-    li      $t6, 0
-    li      $t7, 0
-amips_clut_loop6:
-    lbu     $t0, 0($a1)           # tried lw here, no improvement noticed
-    lbu     $t1, 1($a1)
-    lbu     $t2, 2($a1)
-    lbu     $t3, 3($a1)
-    ins     $t4, $t0, 1, 6
-    ins     $t5, $t1, 1, 6
-    ins     $t6, $t2, 1, 6
-    ins     $t7, $t3, 1, 6
-    addu    $t0, $t4, $a2
-    addu    $t1, $t5, $a2
-    addu    $t2, $t6, $a2
-    addu    $t3, $t7, $a2
-    lhu     $t0, 0($t0)
-    lhu     $t1, 0($t1)
-    lhu     $t2, 0($t2)
-    lhu     $t3, 0($t3)
-    ins     $t0, $t1, 16, 16      # ins rt, rs, pos, size - Insert size bits starting
-    ins     $t2, $t3, 16, 16      #  from the LSB of rs into rt starting at position pos
-    sw      $t0, 0($a0)
-    sw      $t2, 4($a0)
-    addiu   $a0, 8
-    addiu   $a3, -1
-    bnez    $a3, amips_clut_loop6
-    addiu   $a1, 4
-    jr      $ra
-    nop
-
-
-# $a0 - pd, $a1 - tile word, $a2 - pal
-# ext rt, rs, pos, size  // Extract size bits from position pos in rs and store in rt 
-
-.macro TilePixelPrep shift dreg offs
-.if \shift
-    ext     \dreg, $a1, \shift, 4
-.else
-    andi    \dreg, $a1, 0xf
-.endif
-.if \offs
-    sltu    $t8, $0, \dreg
-    ins     $t9, $t8, \offs, 1
-.else
-    sltu    $t9, $0, \dreg
-.endif
-.endm
-
-.macro TileStartCode
-    sll     $a1, $a1, 1
-    lui     $t1, %hi(Pico+0x10000)
-    addu    $a1, $a1, $t1
-    lw      $a1, %lo(Pico+0x10000)($a1)  # Pico.vram + addr
-    beqz    $a1, TileEmpty
-    rotr    $t1, $a1, 4
-    beq     $t1, $a1, SingleColor
-    and     $v0, $0                      # not empty tile
-.endm
-
-.macro TileEndCode
-    xori    $t8, $t9, 0xff
-    beqz    $t8, tile11111111            # common case
-    lui     $v1, %hi(HighCol)
-    lui     $t8, %hi(TileTable)
-    ins     $t8, $t9, 2, 8
-    lw      $t8, %lo(TileTable)($t8)
-    lw      $v1, %lo(HighCol)($v1)
-    jr      $t8
-    addu    $a0, $v1
-.endm
-
-
-.global TileNorm
-
-TileNorm:
-    TileStartCode
-    TilePixelPrep 12, $t0, 0
-    TilePixelPrep  8, $t1, 1
-    TilePixelPrep  4, $t2, 2
-    TilePixelPrep  0, $t3, 3
-    TilePixelPrep 28, $t4, 4
-    TilePixelPrep 24, $t5, 5
-    TilePixelPrep 20, $t6, 6
-    TilePixelPrep 16, $t7, 7
-    TileEndCode
-
-
-.global TileFlip
-
-TileFlip:
-    TileStartCode
-    TilePixelPrep 16, $t0, 0
-    TilePixelPrep 20, $t1, 1
-    TilePixelPrep 24, $t2, 2
-    TilePixelPrep 28, $t3, 3
-    TilePixelPrep  0, $t4, 4
-    TilePixelPrep  4, $t5, 5
-    TilePixelPrep  8, $t6, 6
-    TilePixelPrep 12, $t7, 7
-    TileEndCode
-
-
-SingleColor:
-    lui     $t9, %hi(HighCol)
-    lw      $t9, %lo(HighCol)($t9)
-    andi    $t0, $a1, 0xf
-    or      $t0, $t0, $a2
-    addu    $a0, $t9
-    sb      $t0, 0($a0)
-    sb      $t0, 1($a0)
-    sb      $t0, 2($a0)
-    sb      $t0, 3($a0)
-    sb      $t0, 4($a0)
-    sb      $t0, 5($a0)
-    sb      $t0, 6($a0)
-    jr      $ra
-    sb      $t0, 7($a0)
-
-TileEmpty:
-    jr      $ra
-    or      $v0, $0, 1                   # empty tile
-
-tile11111111:
-    lw      $v1, %lo(HighCol)($v1)
-    or      $t0, $t0, $a2
-    addu    $a0, $v1
-    sb      $t0, 0($a0)
-tile11111110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11111100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile11111000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile11110000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-tile11100000:
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-tile11000000:
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-tile10000000:
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11111101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11111011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11111010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11111001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11110111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11110110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11110100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11110101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11110011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11110010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11110001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11101111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11101110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11101100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile11101000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11101101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11101011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11101010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11101001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11100111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11100110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11100100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11100101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11100011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11100010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11100001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11011111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11011110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11011100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile11011000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile11010000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11011101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11011011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11011010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11011001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11010111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11010110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11010100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11010101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11010011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11010010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11010001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11001111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11001110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11001100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile11001000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11001101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11001011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11001010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11001001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11000111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11000110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11000100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11000101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11000011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11000010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11000001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10111111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10111110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10111100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile10111000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile10110000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-tile10100000:
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10111101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10111011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10111010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10111001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10110111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10110110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10110100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10110101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10110011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10110010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10110001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10101111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10101110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10101100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile10101000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10101101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10101011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10101010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10101001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10100111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10100110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10100100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10100101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10100011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10100010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10100001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10011111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10011110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10011100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile10011000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile10010000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10011101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10011011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10011010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10011001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10010111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10010110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10010100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10010101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10010011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10010010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10010001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10001111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10001110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10001100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile10001000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10001101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10001011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10001010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10001001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10000111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10000110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10000100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10000101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10000011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10000010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10000001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile01111111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01111110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01111100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile01111000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile01110000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-tile01100000:
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-tile01000000:
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile00000000:
-tile01111101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01111011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01111010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01111001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01110111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01110110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01110100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01110101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01110011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01110010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01110001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01101111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01101110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01101100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile01101000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01101101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01101011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01101010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01101001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01100111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01100110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01100100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01100101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01100011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01100010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01100001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01011111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01011110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01011100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile01011000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile01010000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01011101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01011011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01011010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01011001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01010111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01010110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01010100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01010101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01010011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01010010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01010001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01001111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01001110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01001100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile01001000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01001101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01001011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01001010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01001001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01000111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01000110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01000100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01000101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01000011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01000010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01000001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile00111111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00111110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00111100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile00111000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile00110000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-tile00100000:
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00111101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00111011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00111010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00111001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00110111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00110110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00110100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00110101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00110011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00110010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00110001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00101111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00101110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00101100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile00101000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00101101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00101011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00101010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00101001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00100111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00100110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00100100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00100101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00100011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00100010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00100001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00011111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00011110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00011100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile00011000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile00010000:
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00011101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00011011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00011010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00011001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00010111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00010110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00010100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00010101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00010011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00010010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00010001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00001111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00001110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00001100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile00001000:
-    or      $t3, $t3, $a2
-    jr      $ra
-    sb      $t3, 3($a0)
-tile00001101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    jr      $ra
-    sb      $t3, 3($a0)
-tile00001011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00001010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    jr      $ra
-    sb      $t3, 3($a0)
-tile00001001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    jr      $ra
-    sb      $t3, 3($a0)
-tile00000111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00000110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00000100:
-    or      $t2, $t2, $a2
-    jr      $ra
-    sb      $t2, 2($a0)
-tile00000101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    jr      $ra
-    sb      $t2, 2($a0)
-tile00000011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00000010:
-    or      $t1, $t1, $a2
-    jr      $ra
-    sb      $t1, 1($a0)
-tile00000001:
-    or      $t0, $t0, $a2
-    jr      $ra
-    sb      $t0, 0($a0)
-
-.data
-.align 4
-
-TileTable:
-  .long 000000000000, tile00000001, tile00000010, tile00000011, tile00000100, tile00000101, tile00000110, tile00000111
-  .long tile00001000, tile00001001, tile00001010, tile00001011, tile00001100, tile00001101, tile00001110, tile00001111
-  .long tile00010000, tile00010001, tile00010010, tile00010011, tile00010100, tile00010101, tile00010110, tile00010111
-  .long tile00011000, tile00011001, tile00011010, tile00011011, tile00011100, tile00011101, tile00011110, tile00011111
-  .long tile00100000, tile00100001, tile00100010, tile00100011, tile00100100, tile00100101, tile00100110, tile00100111
-  .long tile00101000, tile00101001, tile00101010, tile00101011, tile00101100, tile00101101, tile00101110, tile00101111
-  .long tile00110000, tile00110001, tile00110010, tile00110011, tile00110100, tile00110101, tile00110110, tile00110111
-  .long tile00111000, tile00111001, tile00111010, tile00111011, tile00111100, tile00111101, tile00111110, tile00111111
-  .long tile01000000, tile01000001, tile01000010, tile01000011, tile01000100, tile01000101, tile01000110, tile01000111
-  .long tile01001000, tile01001001, tile01001010, tile01001011, tile01001100, tile01001101, tile01001110, tile01001111
-  .long tile01010000, tile01010001, tile01010010, tile01010011, tile01010100, tile01010101, tile01010110, tile01010111
-  .long tile01011000, tile01011001, tile01011010, tile01011011, tile01011100, tile01011101, tile01011110, tile01011111
-  .long tile01100000, tile01100001, tile01100010, tile01100011, tile01100100, tile01100101, tile01100110, tile01100111
-  .long tile01101000, tile01101001, tile01101010, tile01101011, tile01101100, tile01101101, tile01101110, tile01101111
-  .long tile01110000, tile01110001, tile01110010, tile01110011, tile01110100, tile01110101, tile01110110, tile01110111
-  .long tile01111000, tile01111001, tile01111010, tile01111011, tile01111100, tile01111101, tile01111110, tile01111111
-  .long tile10000000, tile10000001, tile10000010, tile10000011, tile10000100, tile10000101, tile10000110, tile10000111
-  .long tile10001000, tile10001001, tile10001010, tile10001011, tile10001100, tile10001101, tile10001110, tile10001111
-  .long tile10010000, tile10010001, tile10010010, tile10010011, tile10010100, tile10010101, tile10010110, tile10010111
-  .long tile10011000, tile10011001, tile10011010, tile10011011, tile10011100, tile10011101, tile10011110, tile10011111
-  .long tile10100000, tile10100001, tile10100010, tile10100011, tile10100100, tile10100101, tile10100110, tile10100111
-  .long tile10101000, tile10101001, tile10101010, tile10101011, tile10101100, tile10101101, tile10101110, tile10101111
-  .long tile10110000, tile10110001, tile10110010, tile10110011, tile10110100, tile10110101, tile10110110, tile10110111
-  .long tile10111000, tile10111001, tile10111010, tile10111011, tile10111100, tile10111101, tile10111110, tile10111111
-  .long tile11000000, tile11000001, tile11000010, tile11000011, tile11000100, tile11000101, tile11000110, tile11000111
-  .long tile11001000, tile11001001, tile11001010, tile11001011, tile11001100, tile11001101, tile11001110, tile11001111
-  .long tile11010000, tile11010001, tile11010010, tile11010011, tile11010100, tile11010101, tile11010110, tile11010111
-  .long tile11011000, tile11011001, tile11011010, tile11011011, tile11011100, tile11011101, tile11011110, tile11011111
-  .long tile11100000, tile11100001, tile11100010, tile11100011, tile11100100, tile11100101, tile11100110, tile11100111
-  .long tile11101000, tile11101001, tile11101010, tile11101011, tile11101100, tile11101101, tile11101110, tile11101111
-  .long tile11110000, tile11110001, tile11110010, tile11110011, tile11110100, tile11110101, tile11110110, tile11110111
-  .long tile11111000, tile11111001, tile11111010, tile11111011, tile11111100, tile11111101, tile11111110, tile11111111
-
-# vim:filetype=mips
index 71db183..29af1c1 100644 (file)
 .equ PDRAW_PLANE_HI_PRIO, (1<<6)\r
 .equ PDRAW_SHHI_DONE,     (1<<7)\r
 \r
-@ helper\r
+@ helpers\r
+.macro add_c24 d s c\r
+    add     \d, \s, #(\c & 0x00ff00)\r
+.if \c & 0x0000ff\r
+    add     \d, \d, #(\c & 0x0000ff)\r
+.endif\r
+.if \c & 0xff0000\r
+    add     \d, \d, #(\c & 0xff0000)\r
+.endif\r
+.endm\r
+\r
 .macro TilePixel pat lsrr offs\r
 .if !\lsrr\r
     ands    r4, \pat, r2\r
 @   int cells;   // 0x14\r
 @ };\r
 \r
-@ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,\r
+@ void DrawLayer(int lflags, int *hcache, int cellskip, int maxcells,\r
 @                struct PicoEState *est)\r
 \r
 .global DrawLayer\r
@@ -287,14 +297,14 @@ DrawLayer:
     ldr     r12, [sp]             @ est\r
     stmfd   sp!, {r4-r11,lr}\r
 \r
-    ldr     r11, [r12, #OFS_Pico_video]\r
+    ldr     r11, [r12, #OFS_EST_Pico]\r
     mov     r8, #1\r
 \r
-    ldrb    r7, [r11, #16]        @ ??vv??hh\r
+    ldrb    r7, [r11, #OFS_Pico_video_reg+16] @ ??vv??hh\r
 \r
     mov     r6, r1                @ hcache\r
-    orr     r9, r3, r0, lsl #30\r
-    orr     r9, r9, r2, lsl #8    @ r9=sh[31]|cellskip[15:8]|maxcells[7:0]  (tmp)\r
+    orr     r9, r3, r0, lsl #29   @ r9=force[31]|sh[30]|plane[29]\r
+    orr     r9, r9, r2, lsl #8    @    |cellskip[15:8]|maxcells[7:0]  (tmp)\r
 \r
     mov     r1, r7, lsl #4\r
     orr     r1, r1, #0x00ff\r
@@ -303,19 +313,21 @@ DrawLayer:
     cmp     r10, #1\r
     biclt   r1,  r1, #0xfc00\r
     biceq   r1,  r1, #0xfe00\r
-    bicgt   r1,  r1, #0xff00      @ r1=ymask=(height<<8)|0xff; ...; // Y Mask in pixels\r
+    cmp     r10, #2\r
+    moveq   r1,      #0x0007\r
+    movgt   r1,      #0x00ff      @ r1=ymask=(height<<8)|0xff; ...; // Y Mask in pixels\r
 \r
     add     r10, r10, #5\r
     cmp     r10, #7\r
     subge   r10, r10, #1          @ r10=shift[width] (5,6,6,7)\r
 \r
-    ldr     r2, [r12, #OFS_DrawScanline]\r
-    ldr     lr, [r12, #OFS_Pico_vram]\r
+    ldr     r2, [r12, #OFS_EST_DrawScanline]\r
+    ldr     lr, [r12, #OFS_EST_PicoMem_vram]\r
 \r
     @ Find name table:\r
     ands    r0,  r0, #1\r
-    ldreqb  r12, [r11, #2]\r
-    ldrneb  r12, [r11, #4]\r
+    ldreqb  r12, [r11, #OFS_Pico_video_reg+2]\r
+    ldrneb  r12, [r11, #OFS_Pico_video_reg+4]\r
 \r
     @ calculate xmask:\r
     mov     r5, r8, lsl r10\r
@@ -325,8 +337,8 @@ DrawLayer:
     movne   r12, r12, lsl #13\r
     and     r12, r12, #(7<<13)    @ r12=(ts->nametab<<1) (halfword compliant)\r
 \r
-    ldrh    r8, [r11, #12]\r
-    ldrb    r7, [r11, #11]\r
+    ldrh    r8, [r11, #OFS_Pico_video_reg+12]\r
+    ldrb    r7, [r11, #OFS_Pico_video_reg+11]\r
 \r
     mov     r4, r8, lsr #8        @ pvid->reg[13]\r
     mov     r4, r4, lsl #10       @ htab=pvid->reg[13]<<9; (halfwords)\r
@@ -342,8 +354,7 @@ DrawLayer:
     bne     .DrawStrip_vsscroll\r
 \r
     @ Get vertical scroll value:\r
-    add     r7, lr,  #0x012000\r
-    add     r7, r7,  #0x000180    @ r7=Pico.vsram (Pico+0x22180)\r
+    add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)\r
     ldr     r7, [r7]\r
 \r
     tst     r8, #2\r
@@ -373,10 +384,11 @@ DrawLayer:
     and     r1, r1, #7\r
     add     r7, r1, #1      @ r7=dx=((ts->hscroll-1)&7)+1\r
 \r
-    tst     r9, #1<<31\r
+    movs    r3, r9, lsl #1  @ (force[31]|sh[30]) << 1\r
     mov     r3, #0\r
-    orrne   r10,r10, #1<<23 @ r10=(cells<<24|sh<<23|hi_not_empty<<22|had_output<<21|ty)\r
-    movne   r3, #0x40       @ default to shadowed pal on sh mode\r
+    orrmi   r10,r10, #1<<23 @ r10=cells[31:24]|sh[23]|hi_not_empty[22]\r
+    orrcs   r10,r10, #1<<20 @    |had_output[21]|force[20]|ty[15:0]\r
+    movmi   r3, #0x40       @ default to shadowed pal on sh mode\r
 \r
     cmp     r7, #8\r
     addne   r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll\r
@@ -389,7 +401,7 @@ DrawLayer:
     @ cache some stuff to avoid mem access\r
     ldr     r11,[sp, #9*4]       @ est\r
     mov     r0, #0xf\r
-    ldr     r11,[r11, #OFS_HighCol]\r
+    ldr     r11,[r11, #OFS_EST_HighCol]\r
 \r
     mvn     r9, #0               @ r9=prevcode=-1\r
     add     r1, r11, r7          @ r1=pdest\r
@@ -411,6 +423,7 @@ DrawLayer:
     add     r8, r8, #1\r
 \r
     tst     r7, #0x8000\r
+    tsteq   r10, #1<<20     @ force?\r
     bne     .DrawStrip_hiprio\r
 \r
     cmp     r7, r9\r
@@ -478,7 +491,7 @@ DrawLayer:
     orr     r10, r10, #1<<22\r
 \r
 .DrawStrip_hiprio:\r
-    tst     r10, #0x00c00000\r
+    tst     r10, #0x00d00000 @ sh[23]|hi_not_empty[22]|force[20]\r
     beq     .DrawStrip_hiprio_maybempt\r
     sub     r0, r1, r11\r
     orr     r7, r7, r0,  lsl #16\r
@@ -493,10 +506,10 @@ DrawLayer:
     tst     r10, #1<<21 @ seen non hi-prio tile\r
     ldr     r1, [sp, #9*4]  @ est\r
     mov     r0, #0\r
-    ldreq   r2, [r1, #OFS_rendstatus]\r
+    ldreq   r2, [r1, #OFS_EST_rendstatus]\r
     str     r0, [r6]    @ terminate the cache list\r
     orreq   r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles\r
-    streq   r2, [r1, #OFS_rendstatus]\r
+    streq   r2, [r1, #OFS_EST_rendstatus]\r
 \r
     ldmfd   sp!, {r4-r11,lr}\r
     bx      lr\r
@@ -511,24 +524,29 @@ DrawLayer:
 \r
     ldr     r11, [sp, #9*4]       @ est\r
     orr     r5, r1, r10, lsl #24\r
-    ldr     r4, [r11, #OFS_DrawScanline]\r
+    ldr     r4, [r11, #OFS_EST_DrawScanline]\r
     sub     r1, r3, #1\r
     orr     r5, r5, r4, lsl #16   @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])\r
     and     r1, r1, #7\r
     add     r7, r1, #1            @ r7=dx=((ts->hscroll-1)&7)+1\r
 \r
     mov     r10,r9, lsl #16\r
+    orr     r10,r10, #0xff000000  @ will be adjusted on entering loop\r
     tst     r0, #1\r
     orrne   r10,r10, #0x8000\r
+    tst     r3, #0x0f             @ hscroll & 0x0f?\r
+    beq     0f\r
+    eor     r3, r3, r7\r
+    sub     r10,r10, #1<<24       @ cell--  // start from negative for hscroll\r
+    tst     r3, #0x08\r
+    subne   r10,r10, #1<<16       @ cells--\r
+    subne   r10,r10, #1<<24       @ cell--  // even more negative\r
+0:\r
     tst     r9, #1<<31\r
     mov     r3, #0\r
-    orr     r10,r10, #0xff000000 @ will be adjusted on entering loop\r
     orrne   r10,r10, #1<<23 @ r10=(cell[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0])\r
     movne   r3, #0x40       @ default to shadowed pal on sh mode\r
 \r
-    cmp     r7, #8\r
-    subne   r10,r10, #0x01000000 @ have hscroll, start with negative cell\r
-\r
     and     r9, r9, #0xff00\r
     add     r8, r8, r9, lsr #8   @ tilex+=cellskip\r
     add     r7, r7, r9, lsr #5   @ dx+=cellskip<<3;\r
@@ -537,7 +555,7 @@ DrawLayer:
     @ cache some stuff to avoid mem access\r
     ldr     r11,[sp, #9*4]       @ est\r
     mov     r0, #0xf\r
-    ldr     r11,[r11, #OFS_HighCol]\r
+    ldr     r11,[r11, #OFS_EST_HighCol]\r
 \r
     mvn     r9, #0               @ r9=prevcode=-1\r
     add     r1, r11, r7          @ r1=pdest\r
@@ -552,8 +570,7 @@ DrawLayer:
     ble     .dsloop_vs_exit\r
 \r
     @ calc offset and read tileline code to r7, also calc ty\r
-    add     r7, lr, #0x012000\r
-    add     r7, r7, #0x000180     @ r7=Pico.vsram (Pico+0x22180)\r
+    add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)\r
     add     r7, r7, r10,asr #23   @ vsram + ((cell&~1)<<1)\r
     bic     r7, r7, #3\r
     tst     r10,#0x8000           @ plane1?\r
@@ -572,7 +589,7 @@ DrawLayer:
     mov     r4, r4, lsl r7        @ nametabadd\r
 \r
     and     r7, r8, r8, lsr #25\r
-    add     r7, lr, r7, lsl #1    @ Pico.vram+((tilex&ts->xmask) as halfwords)\r
+    add     r7, lr, r7, lsl #1    @ PicoMem.vram+((tilex&ts->xmask) as halfwords)\r
     add     r7, r7, r4, lsl #1\r
     ldrh    r7, [r7, r12]         @ r7=code (int, but from unsigned, no sign extend)\r
 \r
@@ -594,7 +611,7 @@ DrawLayer:
     mov     r2, r2, lsr #17\r
     eorcs   r2, r2, #0x0e   @ if (code&0x1000) addr^=0xe;\r
 \r
-    ldr     r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+    ldr     r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
 \r
     bic     r7, r3, #0x3f\r
     and     r3, r9, #0x6000\r
@@ -652,7 +669,7 @@ DrawLayer:
     add     r2, r2, r10, lsl #17\r
     mov     r2, r2, lsr #17\r
     eorcs   r2, r2, #0x0e   @ if (code&0x1000) addr^=0xe;\r
-    ldr     r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+    ldr     r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
     mov     r9, r7          @ remember code\r
     tst     r2, r2\r
     orrne   r10, r10, #1<<22\r
@@ -663,10 +680,10 @@ DrawLayer:
     tst     r8, #(1<<24) @ seen non hi-prio tile\r
     ldr     r1, [sp, #9*4]  @ est\r
     mov     r0, #0\r
-    ldreq   r2, [r1, #OFS_rendstatus]\r
+    ldreq   r2, [r1, #OFS_EST_rendstatus]\r
     str     r0, [r6]    @ terminate the cache list\r
     orreq   r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles\r
-    streq   r2, [r1, #OFS_rendstatus]\r
+    streq   r2, [r1, #OFS_EST_rendstatus]\r
 \r
     ldmfd   sp!, {r4-r11,lr}\r
     bx      lr\r
@@ -712,7 +729,7 @@ BackFill:
     stmfd   sp!, {r4-r9,lr}\r
 \r
     mov     r0, r0, lsl #26\r
-    ldr     lr, [r2, #OFS_HighCol]\r
+    ldr     lr, [r2, #OFS_EST_HighCol]\r
     mov     r0, r0, lsr #26\r
     add     lr, lr, #8\r
 \r
@@ -754,9 +771,9 @@ DrawTilesFromCache:
     stmfd   sp!, {r4-r9,r11,lr}\r
 \r
     @ cache some stuff to avoid mem access\r
-    ldr     r11,[r3, #OFS_HighCol]\r
+    ldr     r11,[r3, #OFS_EST_HighCol]\r
     mov     r12,#0xf\r
-    ldr     lr, [r3, #OFS_Pico_vram]\r
+    ldr     lr, [r3, #OFS_EST_PicoMem_vram]\r
     mov     r9, r3         @ est\r
 \r
     mvn     r5, #0         @ r5=prevcode=-1\r
@@ -772,7 +789,8 @@ DrawTilesFromCache:
     bic     r4, r1, #0xfe00\r
     add     r1, r11, r4     @ r1=pdest\r
 \r
-    mov     r7, r6, lsl #16\r
+    movs    r7, r6, lsl #16\r
+    bpl     .dtfc_loop      @ !(code & 0x8000)\r
     cmp     r5, r7, lsr #16\r
     beq     .dtfc_samecode  @ if (code==prevcode)\r
 \r
@@ -887,14 +905,14 @@ DrawTilesFromCache:
 \r
 @ check if we have detected layer covered with hi-prio tiles:\r
 .dtfc_check_rendflags:\r
-    ldr     r2, [r9, #OFS_rendstatus]\r
+    ldr     r2, [r9, #OFS_EST_rendstatus]\r
     tst     r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)\r
     beq     .dtfc_loop\r
     bic     r8, r8, #1      @ sh/hi mode off\r
     tst     r2, #PDRAW_SHHI_DONE\r
     bne     .dtfc_loop      @ already processed\r
     orr     r2, r2, #PDRAW_SHHI_DONE\r
-    str     r2, [r9, #OFS_rendstatus]\r
+    str     r2, [r9, #OFS_EST_rendstatus]\r
 \r
     add     r1, r11,#8\r
     mov     r3, #320/4/4\r
@@ -934,16 +952,16 @@ DrawSpritesSHi:
     add     r10,r0, #3      @ r10=HighLnSpr end\r
     add     r10,r10,r3      @ r10=HighLnSpr end\r
 \r
-    ldr     r11,[r1, #OFS_HighCol]\r
+    ldr     r11,[r1, #OFS_EST_HighCol]\r
     mov     r12,#0xf\r
-    ldr     lr, [r1, #OFS_Pico_vram]\r
+    ldr     lr, [r1, #OFS_EST_PicoMem_vram]\r
 \r
 \r
 DrawSpriteSHi:\r
     @ draw next sprite\r
     ldrb    r0, [r10,#-1]!\r
     ldr     r7, [sp]        @ est\r
-    ldr     r1, [r7, #OFS_HighPreSpr]\r
+    ldr     r1, [r7, #OFS_EST_HighPreSpr]\r
     cmp     r0, #0xff\r
     ldmeqfd sp!, {r1,r4-r11,pc} @ end of list\r
     and     r0, r0, #0x7f\r
@@ -969,7 +987,7 @@ DrawSpriteSHi:
     mov     r5, r3, lsr #24\r
     and     r5, r5, #7      @ r5=height\r
 \r
-    ldr     r7, [r7, #OFS_DrawScanline]\r
+    ldr     r7, [r7, #OFS_EST_DrawScanline]\r
     mov     r0, r3, lsl #16 @ r4=sy<<16 (tmp)\r
 \r
     sub     r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy\r
@@ -1010,7 +1028,7 @@ DrawSpriteSHi:
     mov     r8, r8, lsl #17\r
     mov     r8, r8, lsr #17    @ tile&=0x7fff; // Clip tile address\r
 \r
-    ldr     r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+    ldr     r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
     add     r1, r11, r0        @ r1=pdest\r
     tst     r2, r2\r
     beq     .dsprShi_loop\r
@@ -1101,17 +1119,6 @@ DrawSpriteSHi:
 \r
 DrawAllSprites:\r
     orr     r1, r2, r1, lsl #1\r
-    ldr     r12,[r3, #OFS_rendstatus]\r
-    tst     r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)\r
-    beq     das_no_prep\r
-    stmfd   sp!, {r0,r1,r3,lr}\r
-    and     r0, r12,#PDRAW_DIRTY_SPRITES\r
-    bic     r12,r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)\r
-    str     r12,[r3, #OFS_rendstatus]\r
-    bl      PrepareSprites\r
-    ldmfd   sp!, {r0,r1,r3,lr}\r
-\r
-das_no_prep:\r
     ldr     r2, [r0]\r
     ands    r2, r2, #0x7f\r
     bxeq    lr\r
@@ -1123,9 +1130,9 @@ das_no_prep:
     add     r10,r0, #3\r
     add     r10,r10,r2      @ r10=HighLnSpr end\r
 \r
-    ldr     r11,[r3, #OFS_HighCol]\r
+    ldr     r11,[r3, #OFS_EST_HighCol]\r
     mov     r12,#0xf\r
-    ldr     lr, [r3, #OFS_Pico_vram]\r
+    ldr     lr, [r3, #OFS_EST_PicoMem_vram]\r
 \r
 @ + 0  :    hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size\r
 @ + 4  :    xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
@@ -1140,12 +1147,12 @@ DrawSprite:
     ldmeqfd sp!, {r1,r3-r11,pc} @ end of list\r
     cmp     r2, r8, lsr #1\r
     bne     DrawSprite      @ wrong priority\r
-    ldr     r1, [r7, #OFS_HighPreSpr]\r
+    ldr     r1, [r7, #OFS_EST_HighPreSpr]\r
     and     r0, r0, #0x7f\r
     add     r0, r1, r0, lsl #3\r
 \r
     ldr     r3, [r0]        @ sprite[0]\r
-    ldr     r7, [r7, #OFS_DrawScanline]\r
+    ldr     r7, [r7, #OFS_EST_DrawScanline]\r
     mov     r6, r3, lsr #28\r
     sub     r6, r6, #1      @ r6=width-1 (inc later)\r
     mov     r5, r3, lsr #24\r
@@ -1204,7 +1211,7 @@ DrawSprite:
     mov     r8, r8, lsl #17\r
     mov     r8, r8, lsr #17    @ tile&=0x7fff; // Clip tile address\r
 \r
-    ldr     r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
+    ldr     r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels\r
     add     r1, r11, r0        @ r1=pdest\r
     tst     r2, r2\r
     beq     .dspr_loop\r
@@ -1273,12 +1280,12 @@ DrawWindow:
     ldr     r12, [sp]             @ est\r
     stmfd   sp!, {r4-r11,lr}\r
 \r
-    ldr     r6,  [r12, #OFS_Pico_video]\r
-    ldr     r10, [r12, #OFS_DrawScanline]\r
+    ldr     r6,  [r12, #OFS_EST_Pico]\r
+    ldr     r10, [r12, #OFS_EST_DrawScanline]\r
     mov     r11, r12              @ est\r
-    ldrb    r12, [r6, #3]         @ pvid->reg[3]\r
+    ldrb    r12, [r6, #OFS_Pico_video_reg+3] @ pvid->reg[3]\r
 \r
-    ldr     r4,  [r6, #12]\r
+    ldr     r4,  [r6, #OFS_Pico_video_reg+12]\r
     mov     r5,  r10, lsr #3\r
     and     r10, r10, #7\r
     mov     r10, r10, lsl #1      @ r10=ty\r
@@ -1292,8 +1299,8 @@ DrawWindow:
     addeq   r12, r12, r5, lsl #6  @ nametab\r
     add     r12, r12, r0, lsl #2  @ +starttile\r
 \r
-    ldr     lr, [r11, #OFS_Pico_vram]\r
-    ldr     r6, [r11, #OFS_rendstatus]\r
+    ldr     lr, [r11, #OFS_EST_PicoMem_vram]\r
+    ldr     r6, [r11, #OFS_EST_rendstatus]\r
 \r
     @ fetch the first code now\r
     ldrh    r7, [lr, r12]\r
@@ -1310,7 +1317,7 @@ DrawWindow:
     sub     r8, r1, r0\r
 \r
     @ cache some stuff to avoid mem access\r
-    ldr     r11, [r11, #OFS_HighCol]\r
+    ldr     r11, [r11, #OFS_EST_HighCol]\r
     mov     r8, r8, lsl #1        @ cells\r
     add     r11,r11,#8\r
     mvn     r9, #0                @ r9=prevcode=-1\r
@@ -1398,9 +1405,9 @@ DrawWindow:
     and     r2, r6, #PDRAW_WND_DIFF_PRIO\r
     ldmfd   sp!, {r4-r11,lr}\r
     ldr     r0, [sp]\r
-    ldr     r1, [r0, #OFS_rendstatus]\r
+    ldr     r1, [r0, #OFS_EST_rendstatus]\r
     orr     r1, r1, r2\r
-    str     r1, [r0, #OFS_rendstatus]\r
+    str     r1, [r0, #OFS_EST_rendstatus]\r
 \r
     bx      lr\r
 \r
@@ -1492,17 +1499,17 @@ PicoDoHighPal555:
     stmfd   sp!, {r4-r10,lr}\r
     mov     r10,r2               @ est\r
     mov     r1, #0\r
-    ldr     r8, [r10, #OFS_Pico_video]\r
+    ldr     r8, [r10, #OFS_EST_Pico]\r
 \r
 PicoDoHighPal555_nopush:\r
     orr     r9, r1, r0, lsl #31  @ 0:called from FinalizeLine555, 31: s/h\r
 \r
-    add     r0, r10, #OFS_HighPal\r
+    add     r0, r10, #OFS_EST_HighPal\r
 \r
     mov     r1, #0\r
-    strb    r1, [r8, #-0x1a]     @ 0x2220e ~ dirtyPal\r
+    strb    r1, [r8, #OFS_Pico_m_dirtyPal]\r
 \r
-    sub     r1, r8, #0x128       @ r1=Pico.cram\r
+    ldr     r1, [r10, #OFS_EST_PicoMem_cram]\r
     mov     r2, #0x40\r
     mov     r8,     #0x0061\r
     orr     r8, r8, #0x0800\r
@@ -1513,7 +1520,7 @@ PicoDoHighPal555_nopush:
     tst     r9, #(1<<31)\r
     beq     PicoDoHighPal555_end\r
 \r
-    add     r3, r10, #OFS_HighPal\r
+    add     r3, r10, #OFS_EST_HighPal\r
 \r
     @ shadowed pixels:\r
     mov     r12,    #0x008e\r
@@ -1556,7 +1563,7 @@ PicoDoHighPal555_end:
     tst     r9, #1\r
     ldmeqfd sp!, {r4-r10,pc}\r
 \r
-    ldr     r8, [r10, #OFS_Pico_video]\r
+    ldr     r8, [r10, #OFS_EST_Pico]\r
     b       FinalizeLineRGB555_pal_done\r
 \r
 \r
@@ -1567,33 +1574,33 @@ PicoDoHighPal555_end:
 FinalizeLine555:\r
     stmfd   sp!, {r4-r10,lr}\r
     mov     r10,r2               @ est\r
-    ldr     r8, [r10, #OFS_Pico_video]\r
+    ldr     r8, [r10, #OFS_EST_Pico]\r
 \r
-    ldrb    r2, [r8, #-0x1a]     @ 0x2220e ~ dirtyPal\r
+    ldrb    r2, [r8, #OFS_Pico_m_dirtyPal]\r
     mov     r1, #1\r
     tst     r2, r2\r
     bne     PicoDoHighPal555_nopush\r
 \r
 FinalizeLineRGB555_pal_done:\r
-    add     r3, r10, #OFS_HighPal\r
+    add     r3, r10, #OFS_EST_HighPal\r
 \r
-    ldr     r12, [r10, #OFS_rendstatus]\r
+    ldr     r12, [r10, #OFS_EST_rendstatus]\r
     eors    r0, r0, #1           @ sh is 0\r
     mov     lr, #0xff\r
     tstne   r12,#PDRAW_ACC_SPRITES\r
     movne   lr, #0x3f\r
 \r
-    ldr     r1, [r10, #OFS_HighCol]\r
-    ldr     r0, [r10, #OFS_DrawLineDest]\r
+    ldr     r1, [r10, #OFS_EST_HighCol]\r
+    ldr     r0, [r10, #OFS_EST_DrawLineDest]\r
     add     r1, r1, #8\r
 \r
-    ldrb    r12, [r8, #12]\r
+    ldrb    r12, [r8, #OFS_Pico_video_reg+12]\r
     mov     lr, lr, lsl #1\r
 \r
     tst     r12, #1\r
     movne   r2, #320/8           @ len\r
     bne     .fl_no32colRGB555\r
-    ldr     r4, [r10, #OFS_PicoOpt]\r
+    ldr     r4, [r10, #OFS_EST_PicoOpt]\r
     mov     r2, #256/8\r
     ldr     r4, [r4]\r
     tst     r4, #0x4000\r
index 16f6c05..d727766 100644 (file)
@@ -42,14 +42,14 @@ static void EEPROM_write_do(unsigned int d) // ???? ??la (l=SCL, a=SDA)
   {\r
     // we are started and SCL went high - next cycle\r
     scyc++; // pre-increment\r
-    if(SRam.eeprom_type) {\r
+    if(Pico.sv.eeprom_type) {\r
       // X24C02+\r
       if((ssa&1) && scyc == 18) {\r
         scyc = 9;\r
         saddr++; // next address in read mode\r
-        /*if(SRam.eeprom_type==2) saddr&=0xff; else*/ saddr&=0x1fff; // mask\r
+        /*if(Pico.sv.eeprom_type==2) saddr&=0xff; else*/ saddr&=0x1fff; // mask\r
       }\r
-      else if(SRam.eeprom_type == 2 && scyc == 27) scyc = 18;\r
+      else if(Pico.sv.eeprom_type == 2 && scyc == 27) scyc = 18;\r
       else if(scyc == 36) scyc = 27;\r
     } else {\r
       // X24C01\r
@@ -63,29 +63,29 @@ static void EEPROM_write_do(unsigned int d) // ???? ??la (l=SCL, a=SDA)
   else if((sreg & 8) && (sreg & 2) && !(d&2))\r
   {\r
     // we are started and SCL went low (falling edge)\r
-    if(SRam.eeprom_type) {\r
+    if(Pico.sv.eeprom_type) {\r
       // X24C02+\r
       if(scyc == 9 || scyc == 18 || scyc == 27); // ACK cycles\r
-      else if( (SRam.eeprom_type == 3 && scyc > 27) || (SRam.eeprom_type == 2 && scyc > 18) ) {\r
+      else if( (Pico.sv.eeprom_type == 3 && scyc > 27) || (Pico.sv.eeprom_type == 2 && scyc > 18) ) {\r
         if(!(ssa&1)) {\r
           // data write\r
-          unsigned char *pm=SRam.data+saddr;\r
+          unsigned char *pm=Pico.sv.data+saddr;\r
           *pm <<= 1; *pm |= d&1;\r
           if(scyc == 26 || scyc == 35) {\r
             saddr=(saddr&~0xf)|((saddr+1)&0xf); // only 4 (?) lowest bits are incremented\r
             elprintf(EL_EEPROM, "eeprom: write done, addr inc to: %x, last byte=%02x", saddr, *pm);\r
           }\r
-          SRam.changed = 1;\r
+          Pico.sv.changed = 1;\r
         }\r
       } else if(scyc > 9) {\r
         if(!(ssa&1)) {\r
           // we latch another addr bit\r
           saddr<<=1;\r
-          if(SRam.eeprom_type == 2) saddr&=0xff; else saddr&=0x1fff; // mask\r
+          if(Pico.sv.eeprom_type == 2) saddr&=0xff; else saddr&=0x1fff; // mask\r
           saddr|=d&1;\r
           if(scyc==17||scyc==26) {\r
             elprintf(EL_EEPROM, "eeprom: addr reg done: %x", saddr);\r
-            if(scyc==17&&SRam.eeprom_type==2) { saddr&=0xff; saddr|=(ssa<<7)&0x700; } // add device bits too\r
+            if(scyc==17&&Pico.sv.eeprom_type==2) { saddr&=0xff; saddr|=(ssa<<7)&0x700; } // add device bits too\r
           }\r
         }\r
       } else {\r
@@ -99,13 +99,13 @@ static void EEPROM_write_do(unsigned int d) // ???? ??la (l=SCL, a=SDA)
       else if(scyc > 9) {\r
         if(!(saddr&1)) {\r
           // data write\r
-          unsigned char *pm=SRam.data+(saddr>>1);\r
+          unsigned char *pm=Pico.sv.data+(saddr>>1);\r
           *pm <<= 1; *pm |= d&1;\r
           if(scyc == 17) {\r
             saddr=(saddr&0xf9)|((saddr+2)&6); // only 2 lowest bits are incremented\r
             elprintf(EL_EEPROM, "eeprom: write done, addr inc to: %x, last byte=%02x", saddr>>1, *pm);\r
           }\r
-          SRam.changed = 1;\r
+          Pico.sv.changed = 1;\r
         }\r
       } else {\r
         // we latch another addr bit\r
@@ -129,11 +129,11 @@ static void EEPROM_upd_pending(unsigned int d)
   sreg &= ~0xc0;\r
 \r
   // SCL\r
-  d1 = (d >> SRam.eeprom_bit_cl) & 1;\r
+  d1 = (d >> Pico.sv.eeprom_bit_cl) & 1;\r
   sreg |= d1 << 7;\r
 \r
   // SDA in\r
-  d1 = (d >> SRam.eeprom_bit_in) & 1;\r
+  d1 = (d >> Pico.sv.eeprom_bit_in) & 1;\r
   sreg |= d1 << 6;\r
 \r
   Pico.m.eeprom_status = (unsigned char) sreg;\r
@@ -190,23 +190,23 @@ unsigned int EEPROM_read(void)
   } else if (scyc > 9 && scyc < 18) {\r
     // started and first command word received\r
     shift = 17-scyc;\r
-    if (SRam.eeprom_type) {\r
+    if (Pico.sv.eeprom_type) {\r
       // X24C02+\r
       if (ssa&1) {\r
         elprintf(EL_EEPROM, "eeprom: read: addr %02x, cycle %i, reg %02x", saddr, scyc, sreg);\r
-       if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", SRam.data[saddr]);\r
-        d = (SRam.data[saddr]>>shift)&1;\r
+       if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", Pico.sv.data[saddr]);\r
+        d = (Pico.sv.data[saddr]>>shift)&1;\r
       }\r
     } else {\r
       // X24C01\r
       if (saddr&1) {\r
         elprintf(EL_EEPROM, "eeprom: read: addr %02x, cycle %i, reg %02x", saddr>>1, scyc, sreg);\r
-       if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", SRam.data[saddr>>1]);\r
-        d = (SRam.data[saddr>>1]>>shift)&1;\r
+       if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", Pico.sv.data[saddr>>1]);\r
+        d = (Pico.sv.data[saddr>>1]>>shift)&1;\r
       }\r
     }\r
   }\r
 \r
-  return (d << SRam.eeprom_bit_out);\r
+  return (d << Pico.sv.eeprom_bit_out);\r
 }\r
 \r
index e72628e..e747552 100644 (file)
@@ -63,6 +63,17 @@ void cpu68k_map_set(uptr *map, int start_addr, int end_addr,
     const void *func_or_mh, int is_func)\r
 {\r
   xmap_set(map, M68K_MEM_SHIFT, start_addr, end_addr, func_or_mh, is_func);\r
+#ifdef EMU_F68K\r
+  // setup FAME fetchmap\r
+  if (!is_func)\r
+  {\r
+    int shiftout = 24 - FAMEC_FETCHBITS;\r
+    int i = start_addr >> shiftout;\r
+    uptr base = (uptr)func_or_mh - (i << shiftout);\r
+    for (; i <= (end_addr >> shiftout); i++)\r
+      PicoCpuFM68k.Fetch[i] = base;\r
+  }\r
+#endif\r
 }\r
 \r
 // more specialized/optimized function (does same as above)\r
@@ -89,6 +100,17 @@ void cpu68k_map_all_ram(int start_addr, int end_addr, void *ptr, int is_sub)
   addr >>= 1;\r
   for (i = start_addr >> shift; i <= end_addr >> shift; i++)\r
     r8map[i] = r16map[i] = w8map[i] = w16map[i] = addr;\r
+#ifdef EMU_F68K\r
+  // setup FAME fetchmap\r
+  {\r
+    M68K_CONTEXT *ctx = is_sub ? &PicoCpuFS68k : &PicoCpuFM68k;\r
+    int shiftout = 24 - FAMEC_FETCHBITS;\r
+    i = start_addr >> shiftout;\r
+    addr = (uptr)ptr - (i << shiftout);\r
+    for (; i <= (end_addr >> shiftout); i++)\r
+      ctx->Fetch[i] = addr;\r
+  }\r
+#endif\r
 }\r
 \r
 static u32 m68k_unmapped_read8(u32 a)\r
@@ -243,8 +265,8 @@ static port_read_func *port_readers[3] = {
 \r
 static NOINLINE u32 port_read(int i)\r
 {\r
-  u32 data_reg = Pico.ioports[i + 1];\r
-  u32 ctrl_reg = Pico.ioports[i + 4] | 0x80;\r
+  u32 data_reg = PicoMem.ioports[i + 1];\r
+  u32 ctrl_reg = PicoMem.ioports[i + 4] | 0x80;\r
   u32 in, out;\r
 \r
   out = data_reg & ctrl_reg;\r
@@ -288,7 +310,7 @@ NOINLINE u32 io_ports_read(u32 a)
     case 1:  d = port_read(0); break;\r
     case 2:  d = port_read(1); break;\r
     case 3:  d = port_read(2); break;\r
-    default: d = Pico.ioports[a]; break; // IO ports can be used as RAM\r
+    default: d = PicoMem.ioports[a]; break; // IO ports can be used as RAM\r
   }\r
   return d;\r
 }\r
@@ -301,30 +323,29 @@ NOINLINE void io_ports_write(u32 a, u32 d)
   if (1 <= a && a <= 2)\r
   {\r
     Pico.m.padDelay[a - 1] = 0;\r
-    if (!(Pico.ioports[a] & 0x40) && (d & 0x40))\r
+    if (!(PicoMem.ioports[a] & 0x40) && (d & 0x40))\r
       Pico.m.padTHPhase[a - 1]++;\r
   }\r
 \r
   // certain IO ports can be used as RAM\r
-  Pico.ioports[a] = d;\r
+  PicoMem.ioports[a] = d;\r
 }\r
 \r
-// lame..\r
 static int z80_cycles_from_68k(void)\r
 {\r
-  return z80_cycle_aim\r
-    + cycles_68k_to_z80(SekCyclesDone() - last_z80_sync);\r
+  int m68k_cnt = SekCyclesDone() - Pico.t.m68c_frame_start;\r
+  return cycles_68k_to_z80(m68k_cnt);\r
 }\r
 \r
 void NOINLINE ctl_write_z80busreq(u32 d)\r
 {\r
   d&=1; d^=1;\r
-  elprintf(EL_BUSREQ, "set_zrun: %i->%i [%i] @%06x", Pico.m.z80Run, d, SekCyclesDone(), SekPc);\r
+  elprintf(EL_BUSREQ, "set_zrun: %i->%i [%u] @%06x", Pico.m.z80Run, d, SekCyclesDone(), SekPc);\r
   if (d ^ Pico.m.z80Run)\r
   {\r
     if (d)\r
     {\r
-      z80_cycle_cnt = z80_cycles_from_68k();\r
+      Pico.t.z80c_cnt = z80_cycles_from_68k() + 2;\r
     }\r
     else\r
     {\r
@@ -341,7 +362,7 @@ void NOINLINE ctl_write_z80busreq(u32 d)
 void NOINLINE ctl_write_z80reset(u32 d)\r
 {\r
   d&=1; d^=1;\r
-  elprintf(EL_BUSREQ, "set_zreset: %i->%i [%i] @%06x", Pico.m.z80_reset, d, SekCyclesDone(), SekPc);\r
+  elprintf(EL_BUSREQ, "set_zreset: %i->%i [%u] @%06x", Pico.m.z80_reset, d, SekCyclesDone(), SekPc);\r
   if (d ^ Pico.m.z80_reset)\r
   {\r
     if (d)\r
@@ -356,13 +377,35 @@ void NOINLINE ctl_write_z80reset(u32 d)
     }\r
     else\r
     {\r
-      z80_cycle_cnt = z80_cycles_from_68k();\r
+      Pico.t.z80c_cnt = z80_cycles_from_68k() + 2;\r
       z80_reset();\r
     }\r
     Pico.m.z80_reset = d;\r
   }\r
 }\r
 \r
+static int get_scanline(int is_from_z80);\r
+\r
+static void psg_write_68k(u32 d)\r
+{\r
+  // look for volume write and update if needed\r
+  if ((d & 0x90) == 0x90 && PsndPsgLine < Pico.m.scanline)\r
+    PsndDoPSG(Pico.m.scanline);\r
+\r
+  SN76496Write(d);\r
+}\r
+\r
+static void psg_write_z80(u32 d)\r
+{\r
+  if ((d & 0x90) == 0x90) {\r
+    int scanline = get_scanline(1);\r
+    if (PsndPsgLine < scanline)\r
+      PsndDoPSG(scanline);\r
+  }\r
+\r
+  SN76496Write(d);\r
+}\r
+\r
 // -----------------------------------------------------------------\r
 \r
 #ifndef _ASM_MEMORY_C\r
@@ -371,14 +414,14 @@ void NOINLINE ctl_write_z80reset(u32 d)
 static u32 PicoRead8_sram(u32 a)\r
 {\r
   u32 d;\r
-  if (SRam.start <= a && a <= SRam.end && (Pico.m.sram_reg & SRR_MAPPED))\r
+  if (Pico.sv.start <= a && a <= Pico.sv.end && (Pico.m.sram_reg & SRR_MAPPED))\r
   {\r
-    if (SRam.flags & SRF_EEPROM) {\r
+    if (Pico.sv.flags & SRF_EEPROM) {\r
       d = EEPROM_read();\r
       if (!(a & 1))\r
         d >>= 8;\r
     } else\r
-      d = *(u8 *)(SRam.data - SRam.start + a);\r
+      d = *(u8 *)(Pico.sv.data - Pico.sv.start + a);\r
     elprintf(EL_SRAMIO, "sram r8  [%06x]   %02x @ %06x", a, d, SekPc);\r
     return d;\r
   }\r
@@ -393,12 +436,12 @@ static u32 PicoRead8_sram(u32 a)
 static u32 PicoRead16_sram(u32 a)\r
 {\r
   u32 d;\r
-  if (SRam.start <= a && a <= SRam.end && (Pico.m.sram_reg & SRR_MAPPED))\r
+  if (Pico.sv.start <= a && a <= Pico.sv.end && (Pico.m.sram_reg & SRR_MAPPED))\r
   {\r
-    if (SRam.flags & SRF_EEPROM)\r
+    if (Pico.sv.flags & SRF_EEPROM)\r
       d = EEPROM_read();\r
     else {\r
-      u8 *pm = (u8 *)(SRam.data - SRam.start + a);\r
+      u8 *pm = (u8 *)(Pico.sv.data - Pico.sv.start + a);\r
       d  = pm[0] << 8;\r
       d |= pm[1];\r
     }\r
@@ -416,20 +459,20 @@ static u32 PicoRead16_sram(u32 a)
 \r
 static void PicoWrite8_sram(u32 a, u32 d)\r
 {\r
-  if (a > SRam.end || a < SRam.start || !(Pico.m.sram_reg & SRR_MAPPED)) {\r
+  if (a > Pico.sv.end || a < Pico.sv.start || !(Pico.m.sram_reg & SRR_MAPPED)) {\r
     m68k_unmapped_write8(a, d);\r
     return;\r
   }\r
 \r
   elprintf(EL_SRAMIO, "sram w8  [%06x]   %02x @ %06x", a, d & 0xff, SekPc);\r
-  if (SRam.flags & SRF_EEPROM)\r
+  if (Pico.sv.flags & SRF_EEPROM)\r
   {\r
     EEPROM_write8(a, d);\r
   }\r
   else {\r
-    u8 *pm = (u8 *)(SRam.data - SRam.start + a);\r
+    u8 *pm = (u8 *)(Pico.sv.data - Pico.sv.start + a);\r
     if (*pm != (u8)d) {\r
-      SRam.changed = 1;\r
+      Pico.sv.changed = 1;\r
       *pm = (u8)d;\r
     }\r
   }\r
@@ -437,29 +480,32 @@ static void PicoWrite8_sram(u32 a, u32 d)
 \r
 static void PicoWrite16_sram(u32 a, u32 d)\r
 {\r
-  if (a > SRam.end || a < SRam.start || !(Pico.m.sram_reg & SRR_MAPPED)) {\r
+  if (a > Pico.sv.end || a < Pico.sv.start || !(Pico.m.sram_reg & SRR_MAPPED)) {\r
     m68k_unmapped_write16(a, d);\r
     return;\r
   }\r
 \r
   elprintf(EL_SRAMIO, "sram w16 [%06x] %04x @ %06x", a, d & 0xffff, SekPc);\r
-  if (SRam.flags & SRF_EEPROM)\r
+  if (Pico.sv.flags & SRF_EEPROM)\r
   {\r
     EEPROM_write16(d);\r
   }\r
   else {\r
-    // XXX: hardware could easily use MSB too..\r
-    u8 *pm = (u8 *)(SRam.data - SRam.start + a);\r
-    if (*pm != (u8)d) {\r
-      SRam.changed = 1;\r
-      *pm = (u8)d;\r
+    u8 *pm = (u8 *)(Pico.sv.data - Pico.sv.start + a);\r
+    if (pm[0] != (u8)(d >> 8)) {\r
+      Pico.sv.changed = 1;\r
+      pm[0] = (u8)(d >> 8);\r
+    }\r
+    if (pm[1] != (u8)d) {\r
+      Pico.sv.changed = 1;\r
+      pm[1] = (u8)d;\r
     }\r
   }\r
 }\r
 \r
 // z80 area (0xa00000 - 0xa0ffff)\r
 // TODO: verify mirrors VDP and bank reg (bank area mirroring verified)\r
-u32 PicoRead8_z80(u32 a)\r
+static u32 PicoRead8_z80(u32 a)\r
 {\r
   u32 d = 0xff;\r
   if ((Pico.m.z80Run & 1) || Pico.m.z80_reset) {\r
@@ -469,7 +515,7 @@ u32 PicoRead8_z80(u32 a)
   }\r
 \r
   if ((a & 0x4000) == 0x0000)\r
-    d = Pico.zram[a & 0x1fff];\r
+    d = PicoMem.zram[a & 0x1fff];\r
   else if ((a & 0x6000) == 0x4000) // 0x4000-0x5fff\r
     d = ym2612_read_local_68k(); \r
   else\r
@@ -483,7 +529,7 @@ static u32 PicoRead16_z80(u32 a)
   return d | (d << 8);\r
 }\r
 \r
-void PicoWrite8_z80(u32 a, u32 d)\r
+static void PicoWrite8_z80(u32 a, u32 d)\r
 {\r
   if ((Pico.m.z80Run & 1) || Pico.m.z80_reset) {\r
     // verified on real hw\r
@@ -492,8 +538,7 @@ void PicoWrite8_z80(u32 a, u32 d)
   }\r
 \r
   if ((a & 0x4000) == 0x0000) { // z80 RAM\r
-    SekCyclesBurnRun(2); // FIXME hack\r
-    Pico.zram[a & 0x1fff] = (u8)d;\r
+    PicoMem.zram[a & 0x1fff] = (u8)d;\r
     return;\r
   }\r
   if ((a & 0x6000) == 0x4000) { // FM Sound\r
@@ -503,8 +548,7 @@ void PicoWrite8_z80(u32 a, u32 d)
   }\r
   // TODO: probably other VDP access too? Maybe more mirrors?\r
   if ((a & 0x7ff9) == 0x7f11) { // PSG Sound\r
-    if (PicoOpt & POPT_EN_PSG)\r
-      SN76496Write(d);\r
+    psg_write_68k(d);\r
     return;\r
   }\r
   if ((a & 0x7f00) == 0x6000) // Z80 BANK register\r
@@ -548,7 +592,7 @@ u32 PicoRead8_io(u32 a)
 \r
     if ((a & 0xff01) == 0x1100) { // z80 busreq (verified)\r
       d |= (Pico.m.z80Run | Pico.m.z80_reset) & 1;\r
-      elprintf(EL_BUSREQ, "get_zrun: %02x [%i] @%06x", d, SekCyclesDone(), SekPc);\r
+      elprintf(EL_BUSREQ, "get_zrun: %02x [%u] @%06x", d, SekCyclesDone(), SekPc);\r
     }\r
     goto end;\r
   }\r
@@ -583,7 +627,7 @@ u32 PicoRead16_io(u32 a)
 \r
     if ((a & 0xff00) == 0x1100) { // z80 busreq\r
       d |= ((Pico.m.z80Run | Pico.m.z80_reset) & 1) << 8;\r
-      elprintf(EL_BUSREQ, "get_zrun: %04x [%i] @%06x", d, SekCyclesDone(), SekPc);\r
+      elprintf(EL_BUSREQ, "get_zrun: %04x [%u] @%06x", d, SekCyclesDone(), SekPc);\r
     }\r
     goto end;\r
   }\r
@@ -657,10 +701,21 @@ void PicoWrite16_io(u32 a, u32 d)
 \r
 // VDP area (0xc00000 - 0xdfffff)\r
 // TODO: verify if lower byte goes to PSG on word writes\r
-static u32 PicoRead8_vdp(u32 a)\r
+u32 PicoRead8_vdp(u32 a)\r
 {\r
-  if ((a & 0x00e0) == 0x0000)\r
-    return PicoVideoRead8(a);\r
+  if ((a & 0x00f0) == 0x0000) {\r
+    switch (a & 0x0d)\r
+    {\r
+      case 0x00: return PicoVideoRead8DataH();\r
+      case 0x01: return PicoVideoRead8DataL();\r
+      case 0x04: return PicoVideoRead8CtlH();\r
+      case 0x05: return PicoVideoRead8CtlL();\r
+      case 0x08:\r
+      case 0x0c: return PicoVideoRead8HV_H();\r
+      case 0x09:\r
+      case 0x0d: return PicoVideoRead8HV_L();\r
+    }\r
+  }\r
 \r
   elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc);\r
   return 0;\r
@@ -678,8 +733,7 @@ static u32 PicoRead16_vdp(u32 a)
 static void PicoWrite8_vdp(u32 a, u32 d)\r
 {\r
   if ((a & 0x00f9) == 0x0011) { // PSG Sound\r
-    if (PicoOpt & POPT_EN_PSG)\r
-      SN76496Write(d);\r
+    psg_write_68k(d);\r
     return;\r
   }\r
   if ((a & 0x00e0) == 0x0000) {\r
@@ -693,11 +747,8 @@ static void PicoWrite8_vdp(u32 a, u32 d)
 \r
 static void PicoWrite16_vdp(u32 a, u32 d)\r
 {\r
-  if ((a & 0x00f9) == 0x0010) { // PSG Sound\r
-    if (PicoOpt & POPT_EN_PSG)\r
-      SN76496Write(d);\r
-    return;\r
-  }\r
+  if ((a & 0x00f9) == 0x0010) // PSG Sound\r
+    psg_write_68k(d);\r
   if ((a & 0x00e0) == 0x0000) {\r
     PicoVideoWrite(a, d);\r
     return;\r
@@ -714,7 +765,7 @@ static void m68k_mem_setup(void);
 \r
 PICO_INTERNAL void PicoMemSetup(void)\r
 {\r
-  int mask, rs, a;\r
+  int mask, rs, sstart, a;\r
 \r
   // setup the memory map\r
   cpu68k_map_set(m68k_read8_map,   0x000000, 0xffffff, m68k_unmapped_read8, 1);\r
@@ -730,15 +781,16 @@ PICO_INTERNAL void PicoMemSetup(void)
   cpu68k_map_set(m68k_read16_map, 0x000000, rs - 1, Pico.rom, 0);\r
 \r
   // Common case of on-cart (save) RAM, usually at 0x200000-...\r
-  if ((SRam.flags & SRF_ENABLED) && SRam.data != NULL) {\r
-    rs = SRam.end - SRam.start;\r
+  if ((Pico.sv.flags & SRF_ENABLED) && Pico.sv.data != NULL) {\r
+    sstart = Pico.sv.start;\r
+    rs = Pico.sv.end - sstart;\r
     rs = (rs + mask) & ~mask;\r
-    if (SRam.start + rs >= 0x1000000)\r
-      rs = 0x1000000 - SRam.start;\r
-    cpu68k_map_set(m68k_read8_map,   SRam.start, SRam.start + rs - 1, PicoRead8_sram, 1);\r
-    cpu68k_map_set(m68k_read16_map,  SRam.start, SRam.start + rs - 1, PicoRead16_sram, 1);\r
-    cpu68k_map_set(m68k_write8_map,  SRam.start, SRam.start + rs - 1, PicoWrite8_sram, 1);\r
-    cpu68k_map_set(m68k_write16_map, SRam.start, SRam.start + rs - 1, PicoWrite16_sram, 1);\r
+    if (sstart + rs >= 0x1000000)\r
+      rs = 0x1000000 - sstart;\r
+    cpu68k_map_set(m68k_read8_map,   sstart, sstart + rs - 1, PicoRead8_sram, 1);\r
+    cpu68k_map_set(m68k_read16_map,  sstart, sstart + rs - 1, PicoRead16_sram, 1);\r
+    cpu68k_map_set(m68k_write8_map,  sstart, sstart + rs - 1, PicoWrite8_sram, 1);\r
+    cpu68k_map_set(m68k_write16_map, sstart, sstart + rs - 1, PicoWrite16_sram, 1);\r
   }\r
 \r
   // Z80 region\r
@@ -765,10 +817,10 @@ PICO_INTERNAL void PicoMemSetup(void)
 \r
   // RAM and it's mirrors\r
   for (a = 0xe00000; a < 0x1000000; a += 0x010000) {\r
-    cpu68k_map_set(m68k_read8_map,   a, a + 0xffff, Pico.ram, 0);\r
-    cpu68k_map_set(m68k_read16_map,  a, a + 0xffff, Pico.ram, 0);\r
-    cpu68k_map_set(m68k_write8_map,  a, a + 0xffff, Pico.ram, 0);\r
-    cpu68k_map_set(m68k_write16_map, a, a + 0xffff, Pico.ram, 0);\r
+    cpu68k_map_set(m68k_read8_map,   a, a + 0xffff, PicoMem.ram, 0);\r
+    cpu68k_map_set(m68k_read16_map,  a, a + 0xffff, PicoMem.ram, 0);\r
+    cpu68k_map_set(m68k_write8_map,  a, a + 0xffff, PicoMem.ram, 0);\r
+    cpu68k_map_set(m68k_write16_map, a, a + 0xffff, PicoMem.ram, 0);\r
   }\r
 \r
   // Setup memory callbacks:\r
@@ -796,14 +848,12 @@ PICO_INTERNAL void PicoMemSetup(void)
   {\r
     int i;\r
     // by default, point everything to first 64k of ROM\r
-    for (i = 0; i < M68K_FETCHBANK1; i++)\r
+    for (i = 0; i < M68K_FETCHBANK1 * 0xe0 / 0x100; i++)\r
       PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom - (i<<(24-FAMEC_FETCHBITS));\r
     // now real ROM\r
     for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)\r
       PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom;\r
-    // .. and RAM\r
-    for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)\r
-      PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.ram - (i<<(24-FAMEC_FETCHBITS));\r
+    // RAM already set\r
   }\r
 #endif\r
 #ifdef EMU_M68K\r
@@ -846,10 +896,11 @@ static void m68k_mem_setup(void)
 static int get_scanline(int is_from_z80)\r
 {\r
   if (is_from_z80) {\r
-    int cycles = z80_cyclesDone();\r
-    while (cycles - z80_scanline_cycles >= 228)\r
-      z80_scanline++, z80_scanline_cycles += 228;\r
-    return z80_scanline;\r
+    int mclk_z80 = z80_cyclesDone() * 15;\r
+    int mclk_line = Pico.t.z80_scanline * 488 * 7;\r
+    while (mclk_z80 - mclk_line >= 488 * 7)\r
+      Pico.t.z80_scanline++, mclk_line += 488 * 7;\r
+    return Pico.t.z80_scanline;\r
   }\r
 \r
   return Pico.m.scanline;\r
@@ -909,7 +960,7 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
     int scanline = get_scanline(is_from_z80);\r
     //elprintf(EL_STATUS, "%03i -> %03i dac w %08x z80 %i", PsndDacLine, scanline, d, is_from_z80);\r
     ym2612.dacout = ((int)d - 0x80) << 6;\r
-    if (PsndOut && ym2612.dacen && scanline >= PsndDacLine)\r
+    if (ym2612.dacen)\r
       PsndDoDAC(scanline);\r
     return 0;\r
   }\r
@@ -993,8 +1044,10 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
         }\r
         case 0x2b: { /* DAC Sel  (YM2612) */\r
           int scanline = get_scanline(is_from_z80);\r
-          ym2612.dacen = d & 0x80;\r
-          if (d & 0x80) PsndDacLine = scanline;\r
+          if (ym2612.dacen != (d & 0x80)) {\r
+            ym2612.dacen = d & 0x80;\r
+            PsndDacLine = scanline;\r
+          }\r
 #ifdef __GP2X__\r
           if (PicoOpt & POPT_EXT_FM) YM2612Write_940(a, d, scanline);\r
 #endif\r
@@ -1142,7 +1195,22 @@ void PicoWrite16_32x(u32 a, u32 d) {}
 \r
 static unsigned char z80_md_vdp_read(unsigned short a)\r
 {\r
-  // TODO?\r
+  z80_subCLeft(2);\r
+\r
+  if ((a & 0x00f0) == 0x0000) {\r
+    switch (a & 0x0d)\r
+    {\r
+      case 0x00: return PicoVideoRead8DataH();\r
+      case 0x01: return PicoVideoRead8DataL();\r
+      case 0x04: return PicoVideoRead8CtlH();\r
+      case 0x05: return PicoVideoRead8CtlL();\r
+      case 0x08:\r
+      case 0x0c: return get_scanline(1); // FIXME: make it proper\r
+      case 0x09:\r
+      case 0x0d: return Pico.m.rotate++;\r
+    }\r
+  }\r
+\r
   elprintf(EL_ANOMALY, "z80 invalid r8 [%06x] %02x", a, 0xff);\r
   return 0xff;\r
 }\r
@@ -1152,8 +1220,10 @@ static unsigned char z80_md_bank_read(unsigned short a)
   unsigned int addr68k;\r
   unsigned char ret;\r
 \r
-  addr68k = Pico.m.z80_bank68k<<15;\r
-  addr68k += a & 0x7fff;\r
+  z80_subCLeft(3);\r
+\r
+  addr68k = Pico.m.z80_bank68k << 15;\r
+  addr68k |= a & 0x7fff;\r
 \r
   ret = m68k_read8(addr68k);\r
 \r
@@ -1169,13 +1239,12 @@ static void z80_md_ym2612_write(unsigned int a, unsigned char data)
 \r
 static void z80_md_vdp_br_write(unsigned int a, unsigned char data)\r
 {\r
-  // TODO: allow full VDP access\r
   if ((a&0xfff9) == 0x7f11) // 7f11 7f13 7f15 7f17\r
   {\r
-    if (PicoOpt & POPT_EN_PSG)\r
-      SN76496Write(data);\r
+    psg_write_z80(data);\r
     return;\r
   }\r
+  // at least VDP data writes hang my machine\r
 \r
   if ((a>>8) == 0x60)\r
   {\r
@@ -1214,14 +1283,14 @@ static void z80_md_out(unsigned short p, unsigned char d)
 \r
 static void z80_mem_setup(void)\r
 {\r
-  z80_map_set(z80_read_map, 0x0000, 0x1fff, Pico.zram, 0);\r
-  z80_map_set(z80_read_map, 0x2000, 0x3fff, Pico.zram, 0);\r
+  z80_map_set(z80_read_map, 0x0000, 0x1fff, PicoMem.zram, 0);\r
+  z80_map_set(z80_read_map, 0x2000, 0x3fff, PicoMem.zram, 0);\r
   z80_map_set(z80_read_map, 0x4000, 0x5fff, ym2612_read_local_z80, 1);\r
   z80_map_set(z80_read_map, 0x6000, 0x7fff, z80_md_vdp_read, 1);\r
   z80_map_set(z80_read_map, 0x8000, 0xffff, z80_md_bank_read, 1);\r
 \r
-  z80_map_set(z80_write_map, 0x0000, 0x1fff, Pico.zram, 0);\r
-  z80_map_set(z80_write_map, 0x2000, 0x3fff, Pico.zram, 0);\r
+  z80_map_set(z80_write_map, 0x0000, 0x1fff, PicoMem.zram, 0);\r
+  z80_map_set(z80_write_map, 0x2000, 0x3fff, PicoMem.zram, 0);\r
   z80_map_set(z80_write_map, 0x4000, 0x5fff, z80_md_ym2612_write, 1);\r
   z80_map_set(z80_write_map, 0x6000, 0x7fff, z80_md_vdp_br_write, 1);\r
   z80_map_set(z80_write_map, 0x8000, 0xffff, z80_md_bank_write, 1);\r
@@ -1231,8 +1300,8 @@ static void z80_mem_setup(void)
   drZ80.z80_out = z80_md_out;\r
 #endif\r
 #ifdef _USE_CZ80\r
-  Cz80_Set_Fetch(&CZ80, 0x0000, 0x1fff, (FPTR)Pico.zram); // main RAM\r
-  Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (FPTR)Pico.zram); // mirror\r
+  Cz80_Set_Fetch(&CZ80, 0x0000, 0x1fff, (FPTR)PicoMem.zram); // main RAM\r
+  Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (FPTR)PicoMem.zram); // mirror\r
   Cz80_Set_INPort(&CZ80, z80_md_in);\r
   Cz80_Set_OUTPort(&CZ80, z80_md_out);\r
 #endif\r
index afca082..ae7ae50 100644 (file)
@@ -133,6 +133,25 @@ void name(u32 a, u32 d)                         \
   }                                             \
 }
 
+#ifdef NEED_DMA_SOURCE // meh
+
+static __inline void *m68k_dma_source(u32 a)
+{
+  u8 *base;
+  uptr v;
+  v = m68k_read16_map[a >> M68K_MEM_SHIFT];
+  if (map_flag_set(v)) {
+    if (a >= Pico.romsize) // Rom
+      return NULL;
+    base = Pico.rom;
+  }
+  else
+    base = (void *)(v << 1);
+  return base + (a & 0xfe0000);
+}
+
+#endif
+
 // 32x
 typedef struct {
   uptr addr; // stores (membase >> 1) or ((handler >> 1) | (1<<31))
similarity index 93%
rename from pico/memory_amips.s
rename to pico/memory_amips.S
index 4f09198..7ae2592 100644 (file)
@@ -8,6 +8,8 @@
 
 # OUT OF DATE
 
+#include "pico_int_o32.h"
+
 .set noreorder
 .set noat
 
@@ -184,8 +186,8 @@ m_read32_table:
 
 
 PicoMemReset:
-    lui     $v1, %hi(Pico+0x22204)
-    lw      $v1, %lo(Pico+0x22204)($v1)  # romsize
+    lui     $v1, %hi(Pico+OFS_Pico_romsize)
+    lw      $v1, %lo(Pico+OFS_Pico_romsize)($v1)  # romsize
     lui     $t0, 8
     addu    $v1, $t0
     addiu   $v1, -1
@@ -235,12 +237,11 @@ m_read_neg1:
     jr      $ra
     addiu   $v0, $0, 0xffff
 
-# loads &Pico.rom to $t3
+# loads &Pico to $t3
 .macro m_read_rom_try_sram is200000 size
-    lui     $t2, %hi(SRam)
-    addiu   $t2, %lo(SRam)
-    lui     $t3, %hi(Pico+0x22200)
-    lw      $t1, 8($t2)     # SRam.end
+    lui     $t2, %hi(Pico)
+    addiu   $t2, %lo(Pico)
+    lw      $t1, OFS_Pico_sv_end($t2)
 .if \is200000
     ins     $a0, $0,  19, 13
     lui     $t4, 0x20
@@ -248,12 +249,11 @@ m_read_neg1:
 .endif
     subu    $t4, $a0, $t1
     bgtz    $t4, 1f
-    addiu   $t3, %lo(Pico+0x22200)
-    lw      $t1, 4($t2)     # SRam.start
+    lw      $t1, OFS_Pico_sv_start($t2)
     subu    $t4, $t1, $a0
     bgtz    $t4, 1f
     nop
-    lb      $t1, 0x11($t3)  # Pico.m.sram_reg
+    lb      $t1, OFS_Pico_m_sram_reg($t2)
     andi    $t4, $t1, 5
     beqz    $t4, 1f
     nop
@@ -288,8 +288,8 @@ m_read_neg1:
 .endm
 
 .macro m_read8_rom sect
-    lui     $t0, %hi(Pico+0x22200)
-    lw      $t0, %lo(Pico+0x22200)($t0)  # rom
+    lui     $t0, %hi(Pico+OFS_Pico_rom)
+    lw      $t0, %lo(Pico+OFS_Pico_rom)($t0)  # rom
     xori    $a0, 1
     ins     $a0, $0,  19, 13
 .if \sect
@@ -388,15 +388,15 @@ m_read8_misc_io:
     nop
 
 m_read8_misc_hwreg:
-    lui     $v0, %hi(Pico+0x2220f)
+    lui     $v0, %hi(Pico+OFS_Pico_m_hardware)
     jr      $ra
-    lb      $v0, %lo(Pico+0x2220f)($v0)
+    lb      $v0, %lo(Pico+OFS_Pico_m_hardware)($v0)
 
 m_read8_misc_ioports:
-    lui     $v0, %hi(Pico+0x22000)
+    lui     $v0, %hi(PicoMem+0x22000)
     ins     $v0, $t0, 0, 5
     jr      $ra
-    lb      $v0, %lo(Pico+0x22000)($v0)
+    lb      $v0, %lo(PicoMem+0x22000)($v0)
 
 m_read8_misc2:
     lui     $t0, 0xa1
@@ -423,10 +423,10 @@ m_read8_z80_misc:
     nop
 
 m_read8_fake_ym2612:
-    lb      $v0, %lo(Pico+0x22208)($t0) # Pico.m.rotate
+    lb      $v0, %lo(Pico+OFS_Pico_m_rotate)($t0)
     addiu   $t1, $v0, 1
     jr      $ra
-    sb      $t1, %lo(Pico+0x22208)($t0)
+    sb      $t1, %lo(Pico+OFS_Pico_m_rotate)($t0)
 
 # delay slot friendly
 .macro m_read8_call16 funcname is_func_ptr=0
@@ -468,15 +468,15 @@ m_read8_vdp:
     or      $t0, $t1
     bnez    $t0, m_read_null # invalid address
     nop
-    j       PicoVideoRead8
+    j       PicoRead8_vdp
     nop
 
 m_read8_ram:
-    lui     $t0, %hi(Pico)
+    lui     $t0, %hi(PicoMem)
     ins     $t0, $a0, 0, 16
     xori    $t0, 1
     jr      $ra
-    lb      $v0, %lo(Pico)($t0)
+    lb      $v0, %lo(PicoMem)($t0)
 
 m_read8_above_rom:
     # might still be SRam (Micro Machines, HardBall '95)
@@ -486,8 +486,8 @@ m_read8_above_rom:
 # #############################################################################
 
 .macro m_read16_rom sect
-    lui     $t0, %hi(Pico+0x22200)
-    lw      $t0, %lo(Pico+0x22200)($t0)  # rom
+    lui     $t0, %hi(Pico+OFS_Pico_rom)
+    lw      $t0, %lo(Pico+OFS_Pico_rom)($t0)  # rom
     ins     $a0, $0,   0,  1
     ins     $a0, $0,  19, 13
 .if \sect
@@ -583,11 +583,11 @@ m_read16_vdp:
     nop
 
 m_read16_ram:
-    lui     $t0, %hi(Pico)
+    lui     $t0, %hi(PicoMem)
     ins     $a0, $0, 0, 1
     ins     $t0, $a0, 0, 16
     jr      $ra
-    lh      $v0, %lo(Pico)($t0)
+    lh      $v0, %lo(PicoMem)($t0)
 
 m_read16_above_rom:
     # might still be SRam
@@ -600,8 +600,8 @@ m_read16_above_rom:
 # #############################################################################
 
 .macro m_read32_rom sect
-    lui     $t0, %hi(Pico+0x22200)
-    lw      $t0, %lo(Pico+0x22200)($t0)  # rom
+    lui     $t0, %hi(Pico+OFS_Pico_rom)
+    lw      $t0, %lo(Pico+OFS_Pico_rom)($t0)  # rom
     ins     $a0, $0,   0,  1
     ins     $a0, $0,  19, 13
 .if \sect
@@ -723,11 +723,11 @@ m_read32_vdp:
     m_read32_call16 PicoVideoRead
 
 m_read32_ram:
-    lui     $t0, %hi(Pico)
+    lui     $t0, %hi(PicoMem)
     ins     $a0, $0, 0, 1
     ins     $t0, $a0, 0, 16
-    lh      $v1, %lo(Pico)($t0)
-    lh      $v0, %lo(Pico+2)($t0)
+    lh      $v1, %lo(PicoMem)($t0)
+    lh      $v0, %lo(PicoMem+2)($t0)
     jr      $ra
     ins     $v0, $v1, 16, 16
 
@@ -771,11 +771,11 @@ PicoWriteRomHW_SSF2: # u32 a, u32 d
     bnez    $a0, pwr_banking
 
     # sram register
-    lui     $t0, %hi(Pico+0x22211)
-    lb      $t1, %lo(Pico+0x22211)($t0) # Pico.m.sram_reg
+    lui     $t0, %hi(Pico+OFS_Pico_m_sram_reg)
+    lb      $t1, %lo(Pico+OFS_Pico_m_sram_reg)($t0) # Pico.m.sram_reg
     ins     $t1, $a1, 0, 2
     jr      $ra
-    sb      $t1, %lo(Pico+0x22211)($t0)
+    sb      $t1, %lo(Pico+OFS_Pico_m_sram_reg)($t0)
 
 pwr_banking:
     andi    $a1, 0x1f
similarity index 73%
rename from pico/memory_arm.s
rename to pico/memory_arm.S
index f6d7f79..87846d6 100644 (file)
@@ -6,6 +6,8 @@
  * See COPYING file in the top-level directory.\r
  */\r
 \r
+#include "pico_int_o32.h"\r
+\r
 .equ SRR_MAPPED,    (1 <<  0)\r
 .equ SRR_READONLY,  (1 <<  1)\r
 .equ SRF_EEPROM,    (1 <<  1)\r
 .global PicoWrite8_io\r
 .global PicoWrite16_io\r
 \r
-PicoRead8_sram: @ u32 a, u32 d\r
-    ldr     r2, =(SRam)\r
-    ldr     r3, =(Pico+0x22200)\r
-    ldr     r1, [r2, #8]    @ SRam.end\r
+PicoRead8_sram: @ u32 a\r
+    ldr     r3, =Pico\r
+    ldr     r1, [r3, #OFS_Pico_sv_end]\r
     cmp     r0, r1\r
     bgt     m_read8_nosram\r
-    ldr     r1, [r2, #4]    @ SRam.start\r
-    cmp     r0, r1\r
+    ldr     r2, [r3, #OFS_Pico_sv_start]\r
+    cmp     r0, r2\r
     blt     m_read8_nosram\r
-    ldrb    r1, [r3, #0x11] @ Pico.m.sram_reg\r
+    ldrb    r1, [r3, #OFS_Pico_m_sram_reg]\r
     tst     r1, #SRR_MAPPED\r
     beq     m_read8_nosram\r
-    ldr     r1, [r2, #0x0c]\r
+    ldr     r1, [r3, #OFS_Pico_sv_flags]\r
     tst     r1, #SRF_EEPROM\r
     bne     m_read8_eeprom\r
-    ldr     r1, [r2, #4]    @ SRam.start\r
-    ldr     r2, [r2]        @ SRam.data\r
-    sub     r0, r0, r1\r
-    add     r0, r0, r2\r
-    ldrb    r0, [r0]\r
+    ldr     r1, [r3, #OFS_Pico_sv_data]\r
+    sub     r0, r0, r2\r
+    ldrb    r0, [r0, r1]\r
     bx      lr\r
 \r
 m_read8_nosram:\r
-    ldr     r1, [r3, #4]    @ romsize\r
+    ldr     r1, [r3, #OFS_Pico_romsize]\r
     cmp     r0, r1\r
     movgt   r0, #0\r
     bxgt    lr              @ bad location\r
     @ XXX: banking unfriendly\r
-    ldr     r1, [r3]\r
+    ldr     r1, [r3, #OFS_Pico_rom]\r
     eor     r0, r0, #1\r
     ldrb    r0, [r1, r0]\r
     bx      lr\r
@@ -63,7 +62,7 @@ m_read8_eeprom:
     bx      lr\r
 \r
 \r
-PicoRead8_io: @ u32 a, u32 d\r
+PicoRead8_io: @ u32 a\r
     bic     r2, r0, #0x001f   @ most commonly we get i/o port read,\r
     cmp     r2, #0xa10000     @ so check for it first\r
     beq     io_ports_read\r
@@ -73,11 +72,11 @@ m_read8_not_io:
     cmp     r2, #0x1000\r
     bne     m_read8_not_brq\r
 \r
-    ldr     r3, =(Pico+0x22200)\r
+    ldr     r3, =Pico\r
     mov     r1, r0\r
-    ldr     r0, [r3, #8]      @ Pico.m.rotate\r
+    ldr     r0, [r3, #OFS_Pico_m_rotate]\r
     add     r0, r0, #1\r
-    strb    r0, [r3, #8]\r
+    strb    r0, [r3, #OFS_Pico_m_rotate]\r
     eor     r0, r0, r0, lsl #6\r
 \r
     tst     r1, #1\r
@@ -87,8 +86,8 @@ m_read8_not_io:
     cmp     r2, #0x1100\r
     bxne    lr                @ not busreq\r
 \r
-    ldrb    r1, [r3, #(8+0x01)] @ Pico.m.z80Run\r
-    ldrb    r2, [r3, #(8+0x0f)] @ Pico.m.z80_reset\r
+    ldrb    r1, [r3, #OFS_Pico_m_z80Run]\r
+    ldrb    r2, [r3, #OFS_Pico_m_z80_reset]\r
     orr     r0, r0, r1\r
     orr     r0, r0, r2\r
     bx      lr\r
@@ -104,36 +103,33 @@ m_read8_not_brq:
 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
 \r
 PicoRead16_sram: @ u32 a, u32 d\r
-    ldr     r2, =(SRam)\r
-    ldr     r3, =(Pico+0x22200)\r
-    ldr     r1, [r2, #8]    @ SRam.end\r
+    ldr     r3, =Pico\r
+    ldr     r1, [r3, #OFS_Pico_sv_end]\r
     cmp     r0, r1\r
     bgt     m_read16_nosram\r
-    ldr     r1, [r2, #4]    @ SRam.start\r
-    cmp     r0, r1\r
+    ldr     r2, [r3, #OFS_Pico_sv_start]\r
+    cmp     r0, r2\r
     blt     m_read16_nosram\r
-    ldrb    r1, [r3, #0x11] @ Pico.m.sram_reg\r
+    ldrb    r1, [r3, #OFS_Pico_m_sram_reg]\r
     tst     r1, #SRR_MAPPED\r
     beq     m_read16_nosram\r
-    ldr     r1, [r2, #0x0c]\r
+    ldr     r1, [r3, #OFS_Pico_sv_flags]\r
     tst     r1, #SRF_EEPROM\r
     bne     EEPROM_read\r
-    ldr     r1, [r2, #4]    @ SRam.start\r
-    ldr     r2, [r2]        @ SRam.data\r
-    sub     r0, r0, r1\r
-    add     r0, r0, r2\r
-    ldrb    r1, [r0], #1\r
-    ldrb    r0, [r0]\r
+    ldr     r1, [r3, #OFS_Pico_sv_data]\r
+    sub     r0, r0, r2\r
+    ldrb    r1, [r0, r1]!\r
+    ldrb    r0, [r0, #1]\r
     orr     r0, r0, r1, lsl #8\r
     bx      lr\r
 \r
 m_read16_nosram:\r
-    ldr     r1, [r3, #4]    @ romsize\r
+    ldr     r1, [r3, #OFS_Pico_romsize]\r
     cmp     r0, r1\r
     movgt   r0, #0\r
     bxgt    lr              @ bad location\r
     @ XXX: banking unfriendly\r
-    ldr     r1, [r3]\r
+    ldr     r1, [r3, #OFS_Pico_rom]\r
     ldrh    r0, [r1, r0]\r
     bx      lr\r
 \r
@@ -152,19 +148,19 @@ m_read16_not_io:
     cmp     r2, #0x1000\r
     bne     m_read16_not_brq\r
 \r
-    ldr     r3, =(Pico+0x22200)\r
+    ldr     r3, =Pico\r
     and     r2, r0, #0xff00\r
-    ldr     r0, [r3, #8]      @ Pico.m.rotate\r
+    ldr     r0, [r3, #OFS_Pico_m_rotate]\r
     add     r0, r0, #1\r
-    strb    r0, [r3, #8]\r
+    strb    r0, [r3, #OFS_Pico_m_rotate]\r
     eor     r0, r0, r0, lsl #5\r
     eor     r0, r0, r0, lsl #8\r
     bic     r0, r0, #0x100    @ bit8 defined in this area\r
     cmp     r2, #0x1100\r
     bxne    lr                @ not busreq\r
 \r
-    ldrb    r1, [r3, #(8+0x01)] @ Pico.m.z80Run\r
-    ldrb    r2, [r3, #(8+0x0f)] @ Pico.m.z80_reset\r
+    ldrb    r1, [r3, #OFS_Pico_m_z80Run]\r
+    ldrb    r2, [r3, #OFS_Pico_m_z80_reset]\r
     orr     r0, r0, r1, lsl #8\r
     orr     r0, r0, r2, lsl #8\r
     bx      lr\r
@@ -202,12 +198,12 @@ m_write8_not_z80ctl:
     eor     r2, r2, #0x003000\r
     eors    r2, r2, #0x0000f1\r
     bne     m_write8_not_sreg\r
-    ldr     r3, =(Pico+0x22200)\r
-    ldrb    r2, [r3, #(8+9)] @ Pico.m.sram_reg\r
+    ldr     r3, =Pico\r
+    ldrb    r2, [r3, #OFS_Pico_m_sram_reg]\r
     and     r1, r1, #(SRR_MAPPED|SRR_READONLY)\r
     bic     r2, r2, #(SRR_MAPPED|SRR_READONLY)\r
     orr     r2, r2, r1\r
-    strb    r2, [r3, #(8+9)]\r
+    strb    r2, [r3, #OFS_Pico_m_sram_reg]\r
     bx      lr\r
 \r
 m_write8_not_sreg:\r
@@ -239,12 +235,12 @@ m_write16_not_z80ctl:
     eor     r2, r2, #0x003000\r
     eors    r2, r2, #0x0000f0\r
     bne     m_write16_not_sreg\r
-    ldr     r3, =(Pico+0x22200)\r
-    ldrb    r2, [r3, #(8+9)] @ Pico.m.sram_reg\r
+    ldr     r3, =Pico\r
+    ldrb    r2, [r3, #OFS_Pico_m_sram_reg]\r
     and     r1, r1, #(SRR_MAPPED|SRR_READONLY)\r
     bic     r2, r2, #(SRR_MAPPED|SRR_READONLY)\r
     orr     r2, r2, r1\r
-    strb    r2, [r3, #(8+9)]\r
+    strb    r2, [r3, #OFS_Pico_m_sram_reg]\r
     bx      lr\r
 \r
 m_write16_not_sreg:\r
index ba24f95..47842e3 100644 (file)
@@ -87,35 +87,6 @@ const unsigned char hcounts_32[] = {
 \r
 \r
 #ifndef _ASM_MISC_C\r
-typedef struct\r
-{\r
-       int b0;\r
-       int b1;\r
-       int b2;\r
-       int b3;\r
-       int b4;\r
-       int b5;\r
-       int b6;\r
-       int b7;\r
-} intblock;\r
-\r
-PICO_INTERNAL_ASM void pmemcpy16(unsigned short *dest, unsigned short *src, int count)\r
-{\r
-       if ((((long)dest | (long)src) & 3) == 0)\r
-       {\r
-               if (count >= 32) {\r
-                       memcpy32((int *)dest, (int *)src, count/2);\r
-                       count&=1;\r
-               } else {\r
-                       for (; count >= 2; count -= 2, dest+=2, src+=2)\r
-                               *(int *)dest = *(int *)src;\r
-               }\r
-       }\r
-       while (count--)\r
-               *dest++ = *src++;\r
-}\r
-\r
-\r
 PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)\r
 {\r
        unsigned char *src_ = src;\r
@@ -125,21 +96,10 @@ PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count)
 }\r
 \r
 #ifndef _ASM_MISC_C_AMIPS\r
-PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count)\r
+PICO_INTERNAL_ASM void memset32(void *dest_in, int c, int count)\r
 {\r
-       intblock *bd = (intblock *) dest, *bs = (intblock *) src;\r
+       int *dest = dest_in;\r
 \r
-       for (; count >= sizeof(*bd)/4; count -= sizeof(*bd)/4)\r
-               *bd++ = *bs++;\r
-\r
-       dest = (int *)bd; src = (int *)bs;\r
-       while (count--)\r
-               *dest++ = *src++;\r
-}\r
-\r
-\r
-PICO_INTERNAL_ASM void memset32(int *dest, int c, int count)\r
-{\r
        for (; count >= 8; count -= 8, dest += 8)\r
                dest[0] = dest[1] = dest[2] = dest[3] =\r
                dest[4] = dest[5] = dest[6] = dest[7] = c;\r
index 3aa70c7..7c3f1ad 100644 (file)
@@ -101,78 +101,4 @@ ms32u_return:
     nop
 
 
-.globl memcpy32 # int *dest, int *src, int count
-
-memcpy32:
-mc32_aloop:
-    andi    $t0, $a0, 0x3f
-    beqz    $t0, mc32_bloop_prep
-    nop
-    lw      $t1, 0($a1)
-    addiu   $a2, -1
-    sw      $t1, 0($a0)
-    beqz    $a2, mc32_return
-    addiu   $a0, 4
-    j       mc32_aloop
-    addiu   $a1, 4
-
-mc32_bloop_prep:
-    srl     $t0, $a2, 4    # we will do 64 bytes per iteration (cache line)
-    beqz    $t0, mc32_bloop_end
-
-mc32_bloop:
-    addiu   $t0, -1
-    cache   0x18, ($a0)    # create dirty exclusive
-    lw      $t2, 0x00($a1)
-    lw      $t3, 0x04($a1)
-    lw      $t4, 0x08($a1)
-    lw      $t5, 0x0c($a1)
-    lw      $t6, 0x10($a1)
-    lw      $t7, 0x14($a1)
-    lw      $t8, 0x18($a1)
-    lw      $t9, 0x1c($a1)
-    sw      $t2, 0x00($a0)
-    sw      $t3, 0x04($a0)
-    sw      $t4, 0x08($a0)
-    sw      $t5, 0x0c($a0)
-    sw      $t6, 0x10($a0)
-    sw      $t7, 0x14($a0)
-    sw      $t8, 0x18($a0)
-    sw      $t9, 0x1c($a0)
-    lw      $t2, 0x20($a1)
-    lw      $t3, 0x24($a1)
-    lw      $t4, 0x28($a1)
-    lw      $t5, 0x2c($a1)
-    lw      $t6, 0x30($a1)
-    lw      $t7, 0x34($a1)
-    lw      $t8, 0x38($a1)
-    lw      $t9, 0x3c($a1)
-    sw      $t2, 0x20($a0)
-    sw      $t3, 0x24($a0)
-    sw      $t4, 0x28($a0)
-    sw      $t5, 0x2c($a0)
-    sw      $t6, 0x30($a0)
-    sw      $t7, 0x34($a0)
-    sw      $t8, 0x38($a0)
-    sw      $t9, 0x3c($a0)
-    addiu   $a0, 0x40
-    bnez    $t0, mc32_bloop
-    addiu   $a1, 0x40
-
-mc32_bloop_end:
-    andi    $a2, $a2, 0x0f
-    beqz    $a2, mc32_return
-
-mc32_cloop:
-    lw      $t1, 0($a1)
-    addiu   $a2, -1
-    addiu   $a1, 4
-    sw      $t1, 0($a0)
-    bnez    $a2, mc32_cloop
-    addiu   $a0, 4
-
-mc32_return:
-    jr      $ra
-    nop
-
 # vim:filetype=mips
index 260094e..56c7401 100644 (file)
@@ -6,44 +6,6 @@
  * See COPYING file in the top-level directory.
  */
 
-.global pmemcpy16 @ unsigned short *dest, unsigned short *src, int count
-
-pmemcpy16:
-    eor     r3, r0, r1
-    tst     r3, #2
-    bne     mcp16_cant_align
-
-    tst     r0, #2
-    ldrneh  r3, [r1], #2
-    subne   r2, r2, #1
-    strneh  r3, [r0], #2
-
-    subs    r2, r2, #4
-    bmi     mcp16_fin
-
-mcp16_loop:
-    ldmia   r1!, {r3,r12}
-    subs    r2, r2, #4
-    stmia   r0!, {r3,r12}
-    bpl     mcp16_loop
-
-mcp16_fin:
-    tst     r2, #2
-    ldrne   r3, [r1], #4
-    strne   r3, [r0], #4
-    ands    r2, r2, #1
-    bxeq    lr
-
-mcp16_cant_align:
-    ldrh    r3, [r1], #2
-    subs    r2, r2, #1
-    strh    r3, [r0], #2
-    bne     mcp16_cant_align
-
-    bx      lr
-
-
-
 @ 0x12345678 -> 0x34127856
 @ r4=temp, lr=0x00ff00ff
 .macro bswap reg
@@ -52,7 +14,6 @@ mcp16_cant_align:
     orr     \reg, \reg, r4,   lsl #8
 .endm
 
-
 @ dest must be halfword aligned, src can be unaligned
 .global memcpy16bswap @ unsigned short *dest, void *src, int count
 
@@ -121,37 +82,6 @@ mcp16bs_cant_align2:
     bx      lr
 
 
-
-.global memcpy32 @ int *dest, int *src, int count
-
-memcpy32:
-    stmfd   sp!, {r4,lr}
-
-    subs    r2, r2, #4
-    bmi     mcp32_fin
-
-mcp32_loop:
-    ldmia   r1!, {r3,r4,r12,lr}
-    subs    r2, r2, #4
-    stmia   r0!, {r3,r4,r12,lr}
-    bpl     mcp32_loop
-
-mcp32_fin:
-    tst     r2, #3
-    ldmeqfd sp!, {r4,pc}
-    tst     r2, #1
-    ldrne   r3, [r1], #4
-    strne   r3, [r0], #4
-
-mcp32_no_unal1:
-    tst     r2, #2
-    ldmneia r1!, {r3,r12}
-    ldmfd   sp!, {r4,lr}
-    stmneia r0!, {r3,r12}
-    bx      lr
-
-
-
 .global memset32 @ int *dest, int c, int count
 
 memset32:
index 4abace6..0f3d766 100644 (file)
@@ -31,7 +31,7 @@ static int TileNormM4(int sx, int addr, int pal)
   unsigned char *pd = Pico.est.HighCol + sx;
   unsigned int pack, t;
 
-  pack = *(unsigned int *)(Pico.vram + addr); /* Get 4 bitplanes / 8 pixels */
+  pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
   if (pack)
   {
     PLANAR_PIXEL(0, 0)
@@ -53,7 +53,7 @@ static int TileFlipM4(int sx,int addr,int pal)
   unsigned char *pd = Pico.est.HighCol + sx;
   unsigned int pack, t;
 
-  pack = *(unsigned int *)(Pico.vram + addr); /* Get 4 bitplanes / 8 pixels */
+  pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
   if (pack)
   {
     PLANAR_PIXEL(0, 7)
@@ -83,7 +83,7 @@ static void draw_sprites(int scanline)
   if (pv->reg[0] & 8)
     xoff = 0;
 
-  sat = (unsigned char *)Pico.vram + ((pv->reg[5] & 0x7e) << 7);
+  sat = (unsigned char *)PicoMem.vram + ((pv->reg[5] & 0x7e) << 7);
   if (pv->reg[1] & 2) {
     addr_mask = 0xfe; h = 16;
   } else {
@@ -161,7 +161,7 @@ static void DrawDisplayM4(int scanline)
     line -= 224;
 
   // Find name table:
-  nametab = Pico.vram;
+  nametab = PicoMem.vram;
   nametab += (pv->reg[2] & 0x0e) << (10-1);
   nametab += (line>>3) << (6-1);
 
@@ -179,15 +179,15 @@ static void DrawDisplayM4(int scanline)
   dx += cellskip << 3;
 
   // low priority tiles
-  if (PicoDrawMask & PDRAW_LAYERB_ON)
+  if (!(pv->debug_p & PVD_KILL_B))
     draw_strip(nametab, dx, cells, tilex | 0x0000 | (ty << 16));
 
   // sprites
-  if (PicoDrawMask & PDRAW_SPRITES_LOW_ON)
+  if (!(pv->debug_p & PVD_KILL_S_LO))
     draw_sprites(scanline);
 
   // high priority tiles (use virtual layer switch just for fun)
-  if (PicoDrawMask & PDRAW_LAYERA_ON)
+  if (!(pv->debug_p & PVD_KILL_A))
     draw_strip(nametab, dx, cells, tilex | 0x1000 | (ty << 16));
 
   if (pv->reg[0] & 0x20)
@@ -248,7 +248,7 @@ void PicoLineMode4(int line)
 
 void PicoDoHighPal555M4(void)
 {
-  unsigned int *spal=(void *)Pico.cram;
+  unsigned int *spal=(void *)PicoMem.cram;
   unsigned int *dpal=(void *)Pico.est.HighPal;
   unsigned int t;
   int i;
@@ -287,7 +287,7 @@ static void FinalizeLine8bitM4(int line)
   if (!(PicoOpt & POPT_DIS_32C_BORDER))
     pd += 32;
 
-  memcpy32((int *)pd, (int *)(Pico.est.HighCol+8), 256/4);
+  memcpy(pd, Pico.est.HighCol + 8, 256);
 }
 
 void PicoDrawSetOutputMode4(pdso_t which)
index d2bbec4..d534a2c 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "pico_int.h"
+#include "memory.h"
 #include "patch.h"
 
 struct patch
@@ -173,8 +174,8 @@ void genie_decode_ms(const char *code, struct patch *result)
   /* Correct the address */
   result->addr = ((result->addr >> 4) | (result->addr << 12 & 0xF000)) ^ 0xF000;
   /* Optional: 3 digits for comp */
-  printf("CHEAT: code[8]==%c\n",code[8]);
-  if (code[7]=='-'){
+  if (code[7]=='-')
+  {
     for(i=8;i<11;++i)
     {
       if (i==9) continue; /* 2nd character is ignored */
@@ -354,15 +355,6 @@ void decode(const char* code, struct patch* result)
   return;
 }
 
-
-
-unsigned int PicoRead16(unsigned int a);
-void PicoWrite16(unsigned int a, unsigned short d);
-extern unsigned short m68k_read16(unsigned int a);
-extern void m68k_write16(unsigned int a, unsigned short d);
-extern char PicoRead8_z80(unsigned short a);
-extern void PicoWrite8_z80(unsigned short a, char d);
-
 void PicoPatchUnload(void)
 {
    if (PicoPatches != NULL)
@@ -456,7 +448,7 @@ void PicoPatchPrepare(void)
          if(!(PicoAHW & PAHW_SMS))
             PicoPatches[i].data_old = (unsigned short) m68k_read16(addr);
          else
-            PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr);
+            ;// wrong: PicoPatches[i].data_old = (unsigned char) PicoRead8_z80(addr);
       }
       if (strstr(PicoPatches[i].name, "AUTO"))
          PicoPatches[i].active = 1;
@@ -504,7 +496,7 @@ void PicoPatchApply(void)
             if (!(PicoAHW & PAHW_SMS))
               m68k_write16(addr,PicoPatches[i].data);
             else
-              PicoWrite8_z80(addr,PicoPatches[i].data);
+              ;// wrong: PicoWrite8_z80(addr,PicoPatches[i].data);
          }
          else
          {
@@ -513,10 +505,10 @@ void PicoPatchApply(void)
                if (PicoPatches[u].addr == addr) break;
             if (u == i)
             {
-               if (!(PicoAHW & PAHW_SMS))
-                  m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old);
+              if (!(PicoAHW & PAHW_SMS))
+                 m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old);
               else
-                PicoWrite8_z80(PicoPatches[i].addr,PicoPatches[i].data_old);
+                ;// wrong: PicoWrite8_z80(PicoPatches[i].addr,PicoPatches[i].data_old);
             }
          }
       }
index 62994c1..bf9df26 100644 (file)
 #include "sound/ym2612.h"\r
 \r
 struct Pico Pico;\r
+struct PicoMem PicoMem;\r
 int PicoOpt;     \r
-int PicoSkipFrame;          // skip rendering frame?\r
-int PicoPad[2];             // Joypads, format is MXYZ SACB RLDU\r
-int PicoPadInt[2];          // internal copy\r
-int PicoAHW;                // active addon hardware: PAHW_*\r
-int PicoQuirks;             // game-specific quirks\r
-int PicoRegionOverride;     // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
-int PicoRegionFPSOverride;  // override the refresh rate of the region 0: Auto, 1: NTSC, 2: PAL\r
+int PicoSkipFrame;     // skip rendering frame?\r
+int PicoPad[2];        // Joypads, format is MXYZ SACB RLDU\r
+int PicoPadInt[2];     // internal copy\r
+int PicoAHW;           // active addon hardware: PAHW_*\r
+int PicoQuirks;        // game-specific quirks\r
+int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
 int PicoAutoRgnOrder;\r
 \r
-struct PicoSRAM SRam;\r
 int emustatus;         // rapid_ym2612, multi_ym_updates\r
-int scanlines_total;\r
 \r
 void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware\r
 void (*PicoResetHook)(void) = NULL;\r
@@ -34,11 +32,13 @@ void PicoInit(void)
 {\r
   // Blank space for state:\r
   memset(&Pico,0,sizeof(Pico));\r
+  memset(&PicoMem,0,sizeof(PicoMem));\r
   memset(&PicoPad,0,sizeof(PicoPad));\r
   memset(&PicoPadInt,0,sizeof(PicoPadInt));\r
 \r
-  Pico.est.Pico_video = &Pico.video;\r
-  Pico.est.Pico_vram = Pico.vram;\r
+  Pico.est.Pico = &Pico;\r
+  Pico.est.PicoMem_vram = PicoMem.vram;\r
+  Pico.est.PicoMem_cram = PicoMem.cram;\r
   Pico.est.PicoOpt = &PicoOpt;\r
 \r
   // Init CPUs:\r
@@ -61,18 +61,19 @@ void PicoExit(void)
   PicoCartUnload();\r
   z80_exit();\r
 \r
-  if (SRam.data)\r
-    free(SRam.data);\r
+  free(Pico.sv.data);\r
+  Pico.sv.data = NULL;\r
+  Pico.sv.start = Pico.sv.end = 0;\r
   pevt_dump();\r
 }\r
 \r
 void PicoPower(void)\r
 {\r
   Pico.m.frame_count = 0;\r
-  SekCycleCnt = SekCycleAim = 0;\r
+  Pico.t.m68c_cnt = Pico.t.m68c_aim = 0;\r
 \r
   // clear all memory of the emulated machine\r
-  memset(&Pico.ram,0,(unsigned char *)&Pico.rom - Pico.ram);\r
+  memset(&PicoMem,0,sizeof(PicoMem));\r
 \r
   memset(&Pico.video,0,sizeof(Pico.video));\r
   memset(&Pico.m,0,sizeof(Pico.m));\r
@@ -81,7 +82,7 @@ void PicoPower(void)
   z80_reset();\r
 \r
   // my MD1 VA6 console has this in IO\r
-  Pico.ioports[1] = Pico.ioports[2] = Pico.ioports[3] = 0xff;\r
+  PicoMem.ioports[1] = PicoMem.ioports[2] = PicoMem.ioports[3] = 0xff;\r
 \r
   // default VDP register values (based on Fusion)\r
   Pico.video.reg[0] = Pico.video.reg[1] = 0x04;\r
@@ -99,10 +100,6 @@ void PicoPower(void)
 \r
 PICO_INTERNAL void PicoDetectRegion(void)\r
 {\r
-  // PicoDetectRegion not ready yet\r
-  if (Pico.romsize <= 0)\r
-    return;\r
-\r
   int support=0, hw=0, i;\r
   unsigned char pal=0;\r
 \r
@@ -155,10 +152,6 @@ PICO_INTERNAL void PicoDetectRegion(void)
   else hw=0x80; // USA\r
 \r
   Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached\r
-\r
-  if (PicoRegionFPSOverride > 0)\r
-    pal = PicoRegionFPSOverride - 1; // pal - 0: NTSC, 1: PAL | PicoRegionFPSOverride - 0: Auto, 1: NTSC, 2: PAL\r
-    \r
   Pico.m.pal=pal;\r
 }\r
 \r
@@ -219,12 +212,12 @@ int PicoReset(void)
 \r
   // reset sram state; enable sram access by default if it doesn't overlap with ROM\r
   Pico.m.sram_reg = 0;\r
-  if ((SRam.flags & SRF_EEPROM) || Pico.romsize <= SRam.start)\r
+  if ((Pico.sv.flags & SRF_EEPROM) || Pico.romsize <= Pico.sv.start)\r
     Pico.m.sram_reg |= SRR_MAPPED;\r
 \r
-  if (SRam.flags & SRF_ENABLED)\r
-    elprintf(EL_STATUS, "sram: %06x - %06x; eeprom: %i", SRam.start, SRam.end,\r
-      !!(SRam.flags & SRF_EEPROM));\r
+  if (Pico.sv.flags & SRF_ENABLED)\r
+    elprintf(EL_STATUS, "sram: %06x - %06x; eeprom: %i", Pico.sv.start, Pico.sv.end,\r
+      !!(Pico.sv.flags & SRF_EEPROM));\r
 \r
   return 0;\r
 }\r
@@ -232,40 +225,28 @@ int PicoReset(void)
 // flush config changes before emu loop starts\r
 void PicoLoopPrepare(void)\r
 {\r
-  if (PicoRegionFPSOverride) // PicoRegionFPSOverride is proprietary on PicoRegionOverride\r
-  {\r
-    // force setting possibly changed..\r
-    Pico.m.pal = PicoRegionFPSOverride - 1; // Pico.m.pal - 0: NTSC, 1: PAL | PicoRegionFPSOverride - 0: Auto, 1: NTSC, 2: PAL\r
-  }\r
-  else if (PicoRegionOverride)\r
-  {\r
+  if (PicoRegionOverride)\r
     // force setting possibly changed..\r
     Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;\r
-  }\r
-\r
-  // FIXME: PAL has 313 scanlines..\r
-  scanlines_total = Pico.m.pal ? 312 : 262;\r
 \r
   Pico.m.dirtyPal = 1;\r
   rendstatus_old = -1;\r
 }\r
 \r
-\r
-// dma2vram settings are just hacks to unglitch Legend of Galahad (needs <= 104 to work)\r
-// same for Outrunners (92-121, when active is set to 24)\r
-// 96 is VR hack\r
+// this table is wrong and should be removed\r
+// keeping it for now to compensate wrong timing elswhere, mainly for Outrunners\r
 static const int dma_timings[] = {\r
-  167, 167, 166,  83, // vblank: 32cell: dma2vram dma2[vs|c]ram vram_fill vram_copy\r
-  102, 205, 204, 102, // vblank: 40cell:\r
-  16,   16,  15,   8, // active: 32cell:\r
-  24,   18,  17,   9  // ...\r
+   83, 166,  83,  83, // vblank: 32cell: dma2vram dma2[vs|c]ram vram_fill vram_copy\r
+  102, 204, 102, 102, // vblank: 40cell:\r
+    8,  16,   8,   8, // active: 32cell:\r
+   17,  18,   9,   9  // ...\r
 };\r
 \r
 static const int dma_bsycles[] = {\r
-  (488<<8)/167, (488<<8)/167, (488<<8)/166, (488<<8)/83,\r
-  (488<<8)/102, (488<<8)/233, (488<<8)/204, (488<<8)/102,\r
-  (488<<8)/16,  (488<<8)/16,  (488<<8)/15,  (488<<8)/8,\r
-  (488<<8)/24,  (488<<8)/18,  (488<<8)/17,  (488<<8)/9\r
+  (488<<8)/83,  (488<<8)/166, (488<<8)/83,  (488<<8)/83,\r
+  (488<<8)/102, (488<<8)/204, (488<<8)/102, (488<<8)/102,\r
+  (488<<8)/8,   (488<<8)/16,  (488<<8)/8,   (488<<8)/8,\r
+  (488<<8)/9,   (488<<8)/18,  (488<<8)/9,   (488<<8)/9\r
 };\r
 \r
 // grossly inaccurate.. FIXME FIXXXMEE\r
@@ -292,38 +273,32 @@ PICO_INTERNAL int CheckDMA(void)
     Pico.m.dma_xfers -= xfers_can;\r
   }\r
 \r
-  elprintf(EL_VDPDMA, "~Dma %i op=%i can=%i burn=%i [%i]", Pico.m.dma_xfers, dma_op1, xfers_can, burn, SekCyclesDone());\r
-  //dprintf("~aim: %i, cnt: %i", SekCycleAim, SekCycleCnt);\r
+  elprintf(EL_VDPDMA, "~Dma %i op=%i can=%i burn=%i [%u]",\r
+    Pico.m.dma_xfers, dma_op1, xfers_can, burn, SekCyclesDone());\r
+  //dprintf("~aim: %i, cnt: %i", Pico.t.m68c_aim, Pico.t.m68c_cnt);\r
   return burn;\r
 }\r
 \r
 #include "pico_cmn.c"\r
 \r
-unsigned int last_z80_sync; /* in 68k cycles */\r
-int z80_cycle_cnt;\r
-int z80_cycle_aim;\r
-int z80_scanline;\r
-int z80_scanline_cycles;  /* cycles done until z80_scanline */\r
-\r
 /* sync z80 to 68k */\r
 PICO_INTERNAL void PicoSyncZ80(unsigned int m68k_cycles_done)\r
 {\r
   int m68k_cnt;\r
   int cnt;\r
 \r
-  m68k_cnt = m68k_cycles_done - last_z80_sync;\r
-  z80_cycle_aim += cycles_68k_to_z80(m68k_cnt);\r
-  cnt = z80_cycle_aim - z80_cycle_cnt;\r
-  last_z80_sync = m68k_cycles_done;\r
+  m68k_cnt = m68k_cycles_done - Pico.t.m68c_frame_start;\r
+  Pico.t.z80c_aim = cycles_68k_to_z80(m68k_cnt);\r
+  cnt = Pico.t.z80c_aim - Pico.t.z80c_cnt;\r
 \r
   pprof_start(z80);\r
 \r
   elprintf(EL_BUSREQ, "z80 sync %i (%u|%u -> %u|%u)", cnt,\r
-    z80_cycle_cnt, z80_cycle_cnt / 288,\r
-    z80_cycle_aim, z80_cycle_aim / 288);\r
+    Pico.t.z80c_cnt, Pico.t.z80c_cnt * 15 / 7 / 488,\r
+    Pico.t.z80c_aim, Pico.t.z80c_aim * 15 / 7 / 488);\r
 \r
   if (cnt > 0)\r
-    z80_cycle_cnt += z80_run(cnt);\r
+    Pico.t.z80c_cnt += z80_run(cnt);\r
 \r
   pprof_end(z80);\r
 }\r
index d22babd..f1687f5 100644 (file)
@@ -34,6 +34,9 @@ extern void cache_flush_d_inval_i(void *start_addr, void *end_addr);
 extern void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed);\r
 extern void *plat_mremap(void *ptr, size_t oldsize, size_t newsize);\r
 extern void  plat_munmap(void *ptr, size_t size);\r
+\r
+// memory for the dynarec; plat_mem_get_for_drc() can just return NULL\r
+extern void *plat_mem_get_for_drc(size_t size);\r
 extern int   plat_mem_set_exec(void *ptr, size_t size);\r
 \r
 // this one should handle display mode changes\r
@@ -81,10 +84,9 @@ extern int PicoAHW;            // Pico active hw
 #define PQUIRK_FORCE_6BTN   (1<<0)\r
 extern int PicoQuirks;\r
 \r
-extern int PicoSkipFrame;         // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
-extern int PicoRegionOverride;    // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
-extern int PicoRegionFPSOverride; // override the refresh rate of the region 0: Auto, 1: NTSC, 2: PAL\r
-extern int PicoAutoRgnOrder;      // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP\r
+extern int PicoSkipFrame;      // skip rendering frame, but still do sound (if enabled) and emulation stuff\r
+extern int PicoRegionOverride; // override the region detection 0: auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
+extern int PicoAutoRgnOrder;   // packed priority list of regions, for example 0x148 means this detection order: EUR, USA, JAP\r
 extern int PicoSVPCycles;\r
 void PicoInit(void);\r
 void PicoExit(void);\r
@@ -172,18 +174,11 @@ typedef enum
 void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode);\r
 void PicoDrawSetOutBuf(void *dest, int increment);\r
 void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num));\r
-extern unsigned char *HighCol;\r
 // utility\r
 #ifdef _ASM_DRAW_C\r
 void vidConvCpyRGB565(void *to, void *from, int pixels);\r
 #endif\r
 void PicoDoHighPal555(int sh, int line, struct PicoEState *est);\r
-extern int PicoDrawMask;\r
-#define PDRAW_LAYERB_ON      (1<<2)\r
-#define PDRAW_LAYERA_ON      (1<<3)\r
-#define PDRAW_SPRITES_LOW_ON (1<<4)\r
-#define PDRAW_SPRITES_HI_ON  (1<<7)\r
-#define PDRAW_32X_ON         (1<<8)\r
 // internals\r
 #define PDRAW_SPRITES_MOVED (1<<0) // (asm)\r
 #define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority\r
similarity index 100%
rename from pico/pico/pico_memory.c
rename to pico/pico/memory.c
similarity index 98%
rename from pico/pico/pico_pico.c
rename to pico/pico/pico.c
index bff5a2a..d893f9d 100644 (file)
@@ -23,7 +23,7 @@ PICO_INTERNAL void PicoReratePico(void)
 {
   int rate = guessed_rates[PicoPicohw.r12 & 7];
   if (Pico.m.pal)
-       fifo_bytes_line = (rate<<16)/50/312/2;
+       fifo_bytes_line = (rate<<16)/50/313/2;
   else fifo_bytes_line = (rate<<16)/60/262/2;
   PicoPicoPCMRerate(rate);
 }
index 70d7807..27a66cd 100644 (file)
@@ -7,8 +7,7 @@
  */
 
 #define CYCLES_M68K_LINE     488 // suitable for both PAL/NTSC
-#define CYCLES_M68K_VINT_LAG  68
-#define CYCLES_M68K_ASD      148
+#define CYCLES_M68K_VINT_LAG 112
 
 // pad delay (for 6 button pads)
 #define PAD_DELAY() { \
   SekRunM68k(m68k_cycles)
 #endif
 
-// sync m68k to SekCycleAim
+// sync m68k to Pico.t.m68c_aim
 static void SekSyncM68k(void)
 {
   int cyc_do;
   pprof_start(m68k);
   pevt_log_m68k_o(EVT_RUN_START);
 
-  while ((cyc_do = SekCycleAim - SekCycleCnt) > 0) {
-    SekCycleCnt += cyc_do;
+  while ((cyc_do = Pico.t.m68c_aim - Pico.t.m68c_cnt) > 0) {
+    Pico.t.m68c_cnt += cyc_do;
 
 #if defined(EMU_C68K)
     PicoCpuCM68k.cycles = cyc_do;
     CycloneRun(&PicoCpuCM68k);
-    SekCycleCnt -= PicoCpuCM68k.cycles;
+    Pico.t.m68c_cnt -= PicoCpuCM68k.cycles;
 #elif defined(EMU_M68K)
-    SekCycleCnt += m68k_execute(cyc_do) - cyc_do;
+    Pico.t.m68c_cnt += m68k_execute(cyc_do) - cyc_do;
 #elif defined(EMU_F68K)
-    SekCycleCnt += fm68k_emulate(cyc_do, 0) - cyc_do;
+    Pico.t.m68c_cnt += fm68k_emulate(cyc_do, 0) - cyc_do;
 #endif
   }
 
@@ -50,21 +49,53 @@ static void SekSyncM68k(void)
   pprof_end(m68k);
 }
 
-static INLINE void SekRunM68k(int cyc)
+static __inline void SekRunM68k(int cyc)
 {
-  SekCycleAim += cyc;
+  Pico.t.m68c_aim += cyc;
+  cyc = Pico.t.m68c_aim - Pico.t.m68c_cnt;
+  if (cyc <= 0)
+    return;
+  Pico.t.m68c_cnt += cyc >> 6; // refresh slowdowns
   SekSyncM68k();
 }
 
+static void do_hint(struct PicoVideo *pv)
+{
+  pv->pending_ints |= 0x10;
+  if (pv->reg[0] & 0x10) {
+    elprintf(EL_INTS, "hint: @ %06x [%u]", SekPc, SekCyclesDone());
+    SekInterrupt(4);
+  }
+}
+
+static void do_timing_hacks_as(struct PicoVideo *pv, int vdp_slots)
+{
+  pv->lwrite_cnt += vdp_slots - Pico.m.dma_xfers * 2; // wrong *2
+  if (pv->lwrite_cnt > vdp_slots)
+    pv->lwrite_cnt = vdp_slots;
+  else if (pv->lwrite_cnt < 0)
+    pv->lwrite_cnt = 0;
+  if (Pico.m.dma_xfers)
+    SekCyclesBurn(CheckDMA());
+}
+
+static void do_timing_hacks_vb(void)
+{
+  if (Pico.m.dma_xfers)
+    SekCyclesBurn(CheckDMA());
+}
+
 static int PicoFrameHints(void)
 {
-  struct PicoVideo *pv=&Pico.video;
-  int lines, y, lines_vis = 224, line_sample, skip, vcnt_wrap;
+  struct PicoVideo *pv = &Pico.video;
+  int line_sample = Pico.m.pal ? 68 : 93;
+  int vdp_slots = (Pico.video.reg[12] & 1) ? 18 : 16;
+  int lines, y, lines_vis, skip;
+  int vcnt_wrap, vcnt_adj;
   unsigned int cycles;
   int hint; // Hint counter
 
   pevt_log_m68k_o(EVT_FRAME_START);
-  pv->v_counter = Pico.m.scanline = 0;
 
   if ((PicoOpt&POPT_ALT_RENDERER) && !PicoSkipFrame && (pv->reg[1]&0x40)) { // fast rend., display enabled
     // draw a frame just after vblank in alternative render mode
@@ -77,26 +108,17 @@ static int PicoFrameHints(void)
   }
   else skip=PicoSkipFrame;
 
-  if (Pico.m.pal) {
-    line_sample = 68;
-    if (pv->reg[1]&8) lines_vis = 240;
-  } else {
-    line_sample = 93;
-  }
-
+  Pico.t.m68c_frame_start = Pico.t.m68c_aim;
+  pv->v_counter = Pico.m.scanline = 0;
   z80_resetCycles();
-  PsndDacLine = 0;
-  emustatus &= ~1;
-
-  pv->status&=~0x88; // clear V-Int, come out of vblank
+  PsndStartFrame();
 
-  hint=pv->reg[10]; // Load H-Int counter
-  //dprintf("-hint: %i", hint);
+  // Load H-Int counter
+  hint = (pv->status & PVS_ACTIVE) ? pv->hint_cnt : pv->reg[10];
 
-  // This is to make active scan longer (needed for Double Dragon 2, mainly)
-  CPUS_RUN(CYCLES_M68K_ASD);
+  pv->status |= PVS_ACTIVE;
 
-  for (y = 0; y < lines_vis; y++)
+  for (y = 0; ; y++)
   {
     pv->v_counter = Pico.m.scanline = y;
     if ((pv->reg[12]&6) == 6) { // interlace mode 2
@@ -105,24 +127,16 @@ static int PicoFrameHints(void)
       pv->v_counter &= 0xff;
     }
 
-    // VDP FIFO
-    pv->lwrite_cnt -= 12;
-    if (pv->lwrite_cnt <= 0) {
-      pv->lwrite_cnt=0;
-      Pico.video.status|=0x200;
-    }
+    if ((y == 224 && !(pv->reg[1] & 8)) || y == 240)
+      break;
 
     PAD_DELAY();
 
     // H-Interrupts:
-    if (--hint < 0) // y <= lines_vis: Comix Zone, Golden Axe
+    if (--hint < 0)
     {
-      hint=pv->reg[10]; // Reload H-Int counter
-      pv->pending_ints|=0x10;
-      if (pv->reg[0]&0x10) {
-        elprintf(EL_INTS, "hint: @ %06x [%i]", SekPc, SekCyclesDone());
-        SekInterrupt(4);
-      }
+      hint = pv->reg[10]; // Reload H-Int counter
+      do_hint(pv);
     }
 
     // decide if we draw this line
@@ -145,8 +159,6 @@ static int PicoFrameHints(void)
 
       if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
         PicoSyncZ80(cycles);
-      if (ym2612.dacen && PsndDacLine <= y)
-        PsndDoDAC(y);
 #ifdef PICO_CD
       if (PicoAHW & PAHW_MCD)
         pcd_sync_s68k(cycles, 0);
@@ -158,14 +170,18 @@ static int PicoFrameHints(void)
     }
 
     // Run scanline:
-    line_base_cycles = SekCyclesDone();
-    if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA());
+    Pico.t.m68c_line_start = Pico.t.m68c_aim;
+    do_timing_hacks_as(pv, vdp_slots);
     CPUS_RUN(CYCLES_M68K_LINE);
 
     if (PicoLineHook) PicoLineHook();
     pevt_log_m68k_o(EVT_NEXT_LINE);
   }
 
+  lines_vis = (pv->reg[1] & 8) ? 240 : 224;
+  if (y == lines_vis)
+    pv->status &= ~PVS_ACTIVE;
+
   if (!skip)
   {
     if (Pico.est.DrawScanline < y)
@@ -175,40 +191,36 @@ static int PicoFrameHints(void)
 #endif
   }
 
-  // V-int line (224 or 240)
-  Pico.m.scanline = y;
-  pv->v_counter = 0xe0; // bad for 240 mode
-  if ((pv->reg[12]&6) == 6) pv->v_counter = 0xc1;
-
   // VDP FIFO
-  pv->lwrite_cnt=0;
-  Pico.video.status|=0x200;
+  pv->lwrite_cnt = 0;
+  Pico.video.status |= SR_EMPT;
 
   memcpy(PicoPadInt, PicoPad, sizeof(PicoPadInt));
   PAD_DELAY();
 
-  // Last H-Int:
+  // Last H-Int (normally):
   if (--hint < 0)
   {
-    hint=pv->reg[10]; // Reload H-Int counter
-    pv->pending_ints|=0x10;
-    //printf("rhint: %i @ %06x [%i|%i]\n", hint, SekPc, y, SekCyclesDone());
-    if (pv->reg[0]&0x10) SekInterrupt(4);
+    hint = pv->reg[10]; // Reload H-Int counter
+    do_hint(pv);
   }
 
-  pv->status|=0x08; // go into vblank
-  pv->pending_ints|=0x20;
+  pv->status |= SR_VB | PVS_VB2; // go into vblank
 
   // the following SekRun is there for several reasons:
   // there must be a delay after vblank bit is set and irq is asserted (Mazin Saga)
   // also delay between F bit (bit 7) is set in SR and IRQ happens (Ex-Mutants)
   // also delay between last H-int and V-int (Golden Axe 3)
-  line_base_cycles = SekCyclesDone();
-  if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA());
+  Pico.t.m68c_line_start = Pico.t.m68c_aim;
+  do_timing_hacks_vb();
   CPUS_RUN(CYCLES_M68K_VINT_LAG);
 
-  if (pv->reg[1]&0x20) {
-    elprintf(EL_INTS, "vint: @ %06x [%i]", SekPc, SekCyclesDone());
+  pv->status |= SR_F;
+  pv->pending_ints |= 0x20;
+  if (pv->reg[1] & 0x20) {
+    Pico.t.m68c_aim = Pico.t.m68c_cnt + 11; // HACK
+    SekSyncM68k();
+    elprintf(EL_INTS, "vint: @ %06x [%u]", SekPc, SekCyclesDone());
     SekInterrupt(6);
   }
 
@@ -230,47 +242,83 @@ static int PicoFrameHints(void)
 
   // get samples from sound chips
   if (y == 224 && PsndOut)
-  {
-    if (ym2612.dacen && PsndDacLine <= y)
-      PsndDoDAC(y);
     PsndGetSamples(y);
-  }
 
   // Run scanline:
-  CPUS_RUN(CYCLES_M68K_LINE - CYCLES_M68K_VINT_LAG - CYCLES_M68K_ASD);
+  CPUS_RUN(CYCLES_M68K_LINE - CYCLES_M68K_VINT_LAG);
 
   if (PicoLineHook) PicoLineHook();
   pevt_log_m68k_o(EVT_NEXT_LINE);
 
-  lines = scanlines_total;
-  vcnt_wrap = Pico.m.pal ? 0x103 : 0xEB; // based on Gens, TODO: verify
+  if (Pico.m.pal) {
+    lines = 313;
+    vcnt_wrap = 0x103;
+    vcnt_adj = 57;
+  }
+  else {
+    lines = 262;
+    vcnt_wrap = 0xEB;
+    vcnt_adj = 6;
+  }
 
-  for (y++; y < lines; y++)
+  for (y++; y < lines - 1; y++)
   {
     pv->v_counter = Pico.m.scanline = y;
     if (y >= vcnt_wrap)
-      pv->v_counter -= Pico.m.pal ? 56 : 6;
+      pv->v_counter -= vcnt_adj;
     if ((pv->reg[12]&6) == 6)
       pv->v_counter = (pv->v_counter << 1) | 1;
     pv->v_counter &= 0xff;
 
     PAD_DELAY();
 
+    if ((pv->status & PVS_ACTIVE) && --hint < 0)
+    {
+      hint = pv->reg[10]; // Reload H-Int counter
+      do_hint(pv);
+    }
+
     // Run scanline:
-    line_base_cycles = SekCyclesDone();
-    if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA());
+    Pico.t.m68c_line_start = Pico.t.m68c_aim;
+    do_timing_hacks_vb();
     CPUS_RUN(CYCLES_M68K_LINE);
 
     if (PicoLineHook) PicoLineHook();
     pevt_log_m68k_o(EVT_NEXT_LINE);
   }
 
+  pv->status &= ~(SR_VB | PVS_VB2);
+  pv->status |= ((pv->reg[1] >> 3) ^ SR_VB) & SR_VB; // forced blanking
+
+  // last scanline
+  Pico.m.scanline = y;
+  pv->v_counter = 0xff;
+  pv->lwrite_cnt = 0;
+
+  PAD_DELAY();
+
+  if ((pv->status & PVS_ACTIVE) && --hint < 0)
+  {
+    hint = pv->reg[10]; // Reload H-Int counter
+    do_hint(pv);
+  }
+
+  // Run scanline:
+  Pico.t.m68c_line_start = Pico.t.m68c_aim;
+  do_timing_hacks_as(pv, vdp_slots);
+  CPUS_RUN(CYCLES_M68K_LINE);
+
+  if (PicoLineHook) PicoLineHook();
+  pevt_log_m68k_o(EVT_NEXT_LINE);
+
   // sync cpus
   cycles = SekCyclesDone();
   if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
     PicoSyncZ80(cycles);
-  if (PsndOut && ym2612.dacen && PsndDacLine <= lines-1)
-    PsndDoDAC(lines-1);
+  if (PsndOut && ym2612.dacen && PsndDacLine < lines)
+    PsndDoDAC(lines - 1);
+  if (PsndOut && PsndPsgLine < lines)
+    PsndDoPSG(lines - 1);
 
 #ifdef PICO_CD
   if (PicoAHW & PAHW_MCD)
@@ -281,6 +329,8 @@ static int PicoFrameHints(void)
 #endif
   timers_cycle();
 
+  pv->hint_cnt = hint;
+
   return 0;
 }
 
index b562b2f..e3bf03a 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <string.h>\r
+#include "pico_port.h"\r
 #include "pico.h"\r
 #include "carthw/carthw.h"\r
 \r
 extern "C" {\r
 #endif\r
 \r
-#ifdef _MSC_VER\r
-#define snprintf _snprintf\r
-#define strcasecmp _stricmp\r
-#define strncasecmp _strnicmp\r
-#endif\r
 \r
 // ----------------------- 68000 CPU -----------------------\r
 #ifdef EMU_C68K\r
@@ -122,37 +118,25 @@ extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k;
 #define SekNotPolling     PicoCpuMM68k.not_polling\r
 #define SekNotPollingS68k PicoCpuMS68k.not_polling\r
 \r
-#define SekInterrupt(irq) { \\r
-       void *oldcontext = m68ki_cpu_p; \\r
-       m68k_set_context(&PicoCpuMM68k); \\r
-       m68k_set_irq(irq); \\r
-       m68k_set_context(oldcontext); \\r
-}\r
-#define SekIrqLevel (PicoCpuMM68k.int_level >> 8)\r
+// avoid m68k_set_irq() for delaying to work\r
+#define SekInterrupt(irq)  PicoCpuMM68k.int_level = (irq) << 8\r
+#define SekIrqLevel        (PicoCpuMM68k.int_level >> 8)\r
 \r
 #endif\r
 #endif // EMU_M68K\r
 \r
-// while running, cnt represents target of current timeslice\r
-// while not in SekRun(), it's actual cycles done\r
-// (but always use SekCyclesDone() if you need current position)\r
-// cnt may change if timeslice is ended prematurely or extended,\r
-// so we use SekCycleAim for the actual target\r
-extern unsigned int SekCycleCnt;\r
-extern unsigned int SekCycleAim;\r
-\r
 // number of cycles done (can be checked anywhere)\r
-#define SekCyclesDone()  (SekCycleCnt - SekCyclesLeft)\r
+#define SekCyclesDone()  (Pico.t.m68c_cnt - SekCyclesLeft)\r
 \r
 // burn cycles while not in SekRun() and while in\r
-#define SekCyclesBurn(c)    SekCycleCnt += c\r
+#define SekCyclesBurn(c)    Pico.t.m68c_cnt += c\r
 #define SekCyclesBurnRun(c) { \\r
   SekCyclesLeft -= c; \\r
 }\r
 \r
 // note: sometimes may extend timeslice to delay an irq\r
 #define SekEndRun(after) { \\r
-  SekCycleCnt -= SekCyclesLeft - (after); \\r
+  Pico.t.m68c_cnt -= SekCyclesLeft - (after); \\r
   SekCyclesLeft = after; \\r
 }\r
 \r
@@ -190,6 +174,7 @@ extern struct DrZ80 drZ80;
 #define z80_nmi()          drZ80.Z80IF |= 8\r
 \r
 #define z80_cyclesLeft     drZ80.cycles\r
+#define z80_subCLeft(c)    drZ80.cycles -= c\r
 #define z80_pc()           (drZ80.Z80PC - drZ80.Z80PC_BASE)\r
 \r
 #elif defined(_USE_CZ80)\r
@@ -201,6 +186,7 @@ extern struct DrZ80 drZ80;
 #define z80_nmi()          Cz80_Set_IRQ(&CZ80, IRQ_LINE_NMI, 0)\r
 \r
 #define z80_cyclesLeft     (CZ80.ICount - CZ80.ExtraCycles)\r
+#define z80_subCLeft(c)    CZ80.ICount -= c\r
 #define z80_pc()           Cz80_Get_Reg(&CZ80, CZ80_PC)\r
 \r
 #else\r
@@ -214,20 +200,13 @@ extern struct DrZ80 drZ80;
 \r
 #define Z80_STATE_SIZE 0x60\r
 \r
-extern unsigned int last_z80_sync;\r
-extern int z80_cycle_cnt;        /* 'done' z80 cycles before z80_run() */\r
-extern int z80_cycle_aim;\r
-extern int z80_scanline;\r
-extern int z80_scanline_cycles;  /* cycles done until z80_scanline */\r
-\r
 #define z80_resetCycles() \\r
-  last_z80_sync = SekCyclesDone(); \\r
-  z80_cycle_cnt = z80_cycle_aim = z80_scanline = z80_scanline_cycles = 0;\r
+  Pico.t.z80c_cnt = Pico.t.z80c_aim = Pico.t.z80_scanline = 0\r
 \r
 #define z80_cyclesDone() \\r
-  (z80_cycle_aim - z80_cyclesLeft)\r
+  (Pico.t.z80c_aim - z80_cyclesLeft)\r
 \r
-#define cycles_68k_to_z80(x) ((x)*957 >> 11)\r
+#define cycles_68k_to_z80(x) ((x) * 3823 >> 13)\r
 \r
 // ----------------------- SH2 CPU -----------------------\r
 \r
@@ -286,6 +265,31 @@ extern SH2 sh2s[2];
 #define OSC_NTSC 53693100\r
 #define OSC_PAL  53203424\r
 \r
+// PicoVideo.debug_p\r
+#define PVD_KILL_A    (1 << 0)\r
+#define PVD_KILL_B    (1 << 1)\r
+#define PVD_KILL_S_LO (1 << 2)\r
+#define PVD_KILL_S_HI (1 << 3)\r
+#define PVD_KILL_32X  (1 << 4)\r
+#define PVD_FORCE_A   (1 << 5)\r
+#define PVD_FORCE_B   (1 << 6)\r
+#define PVD_FORCE_S   (1 << 7)\r
+\r
+// PicoVideo.status, not part of real SR\r
+#define SR_PAL        (1 << 0)\r
+#define SR_DMA        (1 << 1)\r
+#define SR_HB         (1 << 2)\r
+#define SR_VB         (1 << 3)\r
+#define SR_ODD        (1 << 4)\r
+#define SR_C          (1 << 5)\r
+#define SR_SOVR       (1 << 6)\r
+#define SR_F          (1 << 7)\r
+#define SR_FULL       (1 << 8)\r
+#define SR_EMPT       (1 << 9)\r
+// not part of real SR\r
+#define PVS_ACTIVE    (1 << 16)\r
+#define PVS_VB2       (1 << 17) // ignores forced blanking\r
+\r
 struct PicoVideo\r
 {\r
   unsigned char reg[0x20];\r
@@ -293,11 +297,15 @@ struct PicoVideo
   unsigned char pending;      // 1 if waiting for second half of 32-bit command\r
   unsigned char type;         // Command type (v/c/vsram read/write)\r
   unsigned short addr;        // Read/Write address\r
-  int status;                 // Status bits\r
+  unsigned int status;        // Status bits (SR) and extra flags\r
   unsigned char pending_ints; // pending interrupts: ??VH????\r
   signed char lwrite_cnt;     // VDP write count during active display line\r
   unsigned short v_counter;   // V-counter\r
-  unsigned char pad[0x10];\r
+  unsigned short debug;       // raw debug register\r
+  unsigned char debug_p;      // ... parsed: PVD_*\r
+  unsigned char addr_u;       // bit16 of .addr\r
+  unsigned char hint_cnt;\r
+  unsigned char pad[0x0b];\r
 };\r
 \r
 struct PicoMisc\r
@@ -341,15 +349,15 @@ struct PicoEState
   void *DrawLineDest;          // draw destination\r
   unsigned char *HighCol;\r
   int *HighPreSpr;\r
-  void *Pico_video;\r
-  void *Pico_vram;\r
+  struct Pico *Pico;\r
+  void *PicoMem_vram;\r
+  void *PicoMem_cram;\r
   int  *PicoOpt;\r
   unsigned char *Draw2FB;\r
   unsigned short HighPal[0x100];\r
 };\r
 \r
-// some assembly stuff depend on these, do not touch!\r
-struct Pico\r
+struct PicoMem\r
 {\r
   unsigned char ram[0x10000];  // 0x00000 scratch ram\r
   union {                      // vram is byteswapped for easier reads when drawing\r
@@ -358,17 +366,9 @@ struct Pico
   };\r
   unsigned char zram[0x2000];  // 0x20000 Z80 ram\r
   unsigned char ioports[0x10]; // XXX: fix asm and mv\r
-  unsigned char pad[0xf0];     // unused\r
-  unsigned short cram[0x40];   // 0x22100\r
-  unsigned short vsram[0x40];  // 0x22180\r
-\r
-  unsigned char *rom;          // 0x22200\r
-  unsigned int romsize;        // 0x22204 (on 32bits)\r
-\r
-  struct PicoMisc m;\r
-  struct PicoVideo video;\r
-  struct PicoMS ms;\r
-  struct PicoEState est;\r
+  unsigned short cram[0x40];   // 0x22010\r
+  unsigned char pad[0x70];     // 0x22050 DrawStripVSRam reads 0 from here\r
+  unsigned short vsram[0x40];  // 0x22100\r
 };\r
 \r
 // sram\r
@@ -378,7 +378,7 @@ struct Pico
 #define SRF_ENABLED  (1 << 0)\r
 #define SRF_EEPROM   (1 << 1)\r
 \r
-struct PicoSRAM\r
+struct PicoCartSave\r
 {\r
   unsigned char *data;         // actual data\r
   unsigned int start;          // start address in 68k address space\r
@@ -394,6 +394,38 @@ struct PicoSRAM
   unsigned int size;\r
 };\r
 \r
+struct PicoTiming\r
+{\r
+  // while running, cnt represents target of current timeslice\r
+  // while not in SekRun(), it's actual cycles done\r
+  // (but always use SekCyclesDone() if you need current position)\r
+  // _cnt may change if timeslice is ended prematurely or extended,\r
+  // so we use _aim for the actual target\r
+  unsigned int m68c_cnt;\r
+  unsigned int m68c_aim;\r
+  unsigned int m68c_frame_start;        // m68k cycles\r
+  unsigned int m68c_line_start;\r
+\r
+  unsigned int z80c_cnt;                // z80 cycles done (this frame)\r
+  unsigned int z80c_aim;\r
+  int z80_scanline;\r
+};\r
+\r
+// run tools/mkoffsets pico/pico_int_o32.h if you change these\r
+// careful with savestate compat\r
+struct Pico\r
+{\r
+  struct PicoVideo video;\r
+  struct PicoMisc m;\r
+  struct PicoTiming t;\r
+  struct PicoCartSave sv;\r
+  struct PicoEState est;\r
+  struct PicoMS ms;\r
+\r
+  unsigned char *rom;\r
+  unsigned int romsize;\r
+};\r
+\r
 // MCD\r
 #define PCM_MIXBUF_LEN ((12500000 / 384) / 50 + 1)\r
 \r
@@ -672,10 +704,9 @@ void pcd_state_loaded_mem(void);
 \r
 // pico.c\r
 extern struct Pico Pico;\r
-extern struct PicoSRAM SRam;\r
+extern struct PicoMem PicoMem;\r
 extern int PicoPadInt[2];\r
 extern int emustatus;\r
-extern int scanlines_total;\r
 extern void (*PicoResetHook)(void);\r
 extern void (*PicoLineHook)(void);\r
 PICO_INTERNAL int  CheckDMA(void);\r
@@ -783,17 +814,19 @@ void ym2612_unpack_state(void);
 \r
 \r
 // videoport.c\r
-extern int line_base_cycles;\r
 PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);\r
 PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);\r
-PICO_INTERNAL_ASM unsigned int PicoVideoRead8(unsigned int a);\r
-extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp);\r
+unsigned char PicoVideoRead8DataH(void);\r
+unsigned char PicoVideoRead8DataL(void);\r
+unsigned char PicoVideoRead8CtlH(void);\r
+unsigned char PicoVideoRead8CtlL(void);\r
+unsigned char PicoVideoRead8HV_H(void);\r
+unsigned char PicoVideoRead8HV_L(void);\r
+extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask);\r
 \r
 // misc.c\r
-PICO_INTERNAL_ASM void pmemcpy16(unsigned short *dest, unsigned short *src, int count);\r
 PICO_INTERNAL_ASM void memcpy16bswap(unsigned short *dest, void *src, int count);\r
-PICO_INTERNAL_ASM void memcpy32(int *dest, int *src, int count); // 32bit word count\r
-PICO_INTERNAL_ASM void memset32(int *dest, int c, int count);\r
+PICO_INTERNAL_ASM void memset32(void *dest, int c, int count);\r
 \r
 // eeprom.c\r
 void EEPROM_write8(unsigned int a, unsigned int d);\r
@@ -813,11 +846,13 @@ PICO_INTERNAL_ASM void wram_1M_to_2M(unsigned char *m);
 \r
 // sound/sound.c\r
 PICO_INTERNAL void PsndReset(void);\r
+PICO_INTERNAL void PsndStartFrame(void);\r
 PICO_INTERNAL void PsndDoDAC(int line_to);\r
+PICO_INTERNAL void PsndDoPSG(int line_to);\r
 PICO_INTERNAL void PsndClear(void);\r
 PICO_INTERNAL void PsndGetSamples(int y);\r
 PICO_INTERNAL void PsndGetSamplesMS(void);\r
-extern int PsndDacLine;\r
+extern int PsndDacLine, PsndPsgLine;\r
 \r
 // sms.c\r
 #ifndef NO_SMS\r
@@ -865,7 +900,7 @@ void p32x_event_schedule_sh2(SH2 *sh2, enum p32x_event event, int after);
 void p32x_schedule_hint(SH2 *sh2, int m68k_cycles);\r
 \r
 // 32x/memory.c\r
-struct Pico32xMem *Pico32xMem;\r
+extern struct Pico32xMem *Pico32xMem;\r
 unsigned int PicoRead8_32x(unsigned int a);\r
 unsigned int PicoRead16_32x(unsigned int a);\r
 void PicoWrite8_32x(unsigned int a, unsigned int d);\r
@@ -929,7 +964,7 @@ void REGPARM(3) sh2_peripheral_write32(unsigned int a, unsigned int d, SH2 *sh2)
 #endif\r
 \r
 /* avoid dependency on newer glibc */\r
-static INLINE int isspace_(int c)\r
+static __inline int isspace_(int c)\r
 {\r
        return (0x09 <= c && c <= 0x0d) || c == ' ';\r
 }\r
@@ -1036,28 +1071,10 @@ void pevt_dump(void);
 #define pevt_dump()\r
 #endif\r
 \r
-// misc\r
-#ifdef _MSC_VER\r
-#define cdprintf\r
-#else\r
-#define cdprintf(x...)\r
-#endif\r
-\r
-#if defined(__GNUC__) && defined(__i386__)\r
-#define REGPARM(x) __attribute__((regparm(x)))\r
-#else\r
-#define REGPARM(x)\r
-#endif\r
-\r
-#ifdef __GNUC__\r
-#define NOINLINE __attribute__((noinline))\r
-#else\r
-#define NOINLINE\r
-#endif\r
-\r
 #ifdef __cplusplus\r
 } // End of extern "C"\r
 #endif\r
 \r
 #endif // PICO_INTERNAL_INCLUDED\r
 \r
+// vim:shiftwidth=2:ts=2:expandtab\r
index dc7aaa2..ca3004f 100644 (file)
@@ -1,11 +1,28 @@
-/* autogenerated by ./tools/mkoffsets, do not edit */
-#define OFS_DrawScanline     0x00
-#define OFS_rendstatus       0x04
-#define OFS_DrawLineDest     0x08
-#define OFS_HighCol          0x0c
-#define OFS_HighPreSpr       0x10
-#define OFS_Pico_video       0x14
-#define OFS_Pico_vram        0x18
-#define OFS_PicoOpt          0x1c
-#define OFS_Draw2FB          0x20
-#define OFS_HighPal          0x24
+/* autogenerated by tools/mkoffsets, do not edit */
+#define OFS_Pico_video_reg   0x0000
+#define OFS_Pico_m_rotate    0x0040
+#define OFS_Pico_m_z80Run    0x0041
+#define OFS_Pico_m_dirtyPal  0x0046
+#define OFS_Pico_m_hardware  0x0047
+#define OFS_Pico_m_z80_reset 0x004f
+#define OFS_Pico_m_sram_reg  0x0049
+#define OFS_Pico_sv          0x007c
+#define OFS_Pico_sv_data     0x007c
+#define OFS_Pico_sv_start    0x0080
+#define OFS_Pico_sv_end      0x0084
+#define OFS_Pico_sv_flags    0x0088
+#define OFS_Pico_rom         0x031c
+#define OFS_Pico_romsize     0x0320
+#define OFS_EST_DrawScanline 0x00
+#define OFS_EST_rendstatus   0x04
+#define OFS_EST_DrawLineDest 0x08
+#define OFS_EST_HighCol      0x0c
+#define OFS_EST_HighPreSpr   0x10
+#define OFS_EST_Pico         0x14
+#define OFS_EST_PicoMem_vram 0x18
+#define OFS_EST_PicoMem_cram 0x1c
+#define OFS_EST_PicoOpt      0x20
+#define OFS_EST_Draw2FB      0x24
+#define OFS_EST_HighPal      0x28
+#define OFS_PMEM_vram        0x10000
+#define OFS_PMEM_vsram       0x22100
diff --git a/pico/pico_port.h b/pico/pico_port.h
new file mode 100644 (file)
index 0000000..605778d
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef PICO_PORT_INCLUDED
+#define PICO_PORT_INCLUDED
+
+#if defined(__GNUC__) && defined(__i386__)
+#define REGPARM(x) __attribute__((regparm(x)))
+#else
+#define REGPARM(x)
+#endif
+
+#ifdef __GNUC__
+#define NOINLINE    __attribute__((noinline))
+#define ALIGNED(n)  __attribute__((aligned(n)))
+#else
+#define NOINLINE
+#define ALIGNED(n)
+#endif
+
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+#define strdup _strdup
+#endif
+
+#endif // PICO_PORT_INCLUDED
index 86a351f..8fece1a 100644 (file)
 #include "pico_int.h"\r
 #include "memory.h"\r
 \r
-\r
-unsigned int SekCycleCnt;\r
-unsigned int SekCycleAim;\r
-\r
-\r
 /* context */\r
 // Cyclone 68000\r
 #ifdef EMU_C68K\r
@@ -30,15 +25,30 @@ M68K_CONTEXT PicoCpuFM68k;
 #endif\r
 \r
 \r
+static int do_ack(int level)\r
+{\r
+  struct PicoVideo *pv = &Pico.video;\r
+\r
+  elprintf(EL_INTS, "%cack: @ %06x [%u], p=%02x",\r
+    level == 6 ? 'v' : 'h', SekPc, SekCyclesDone(), pv->pending_ints);\r
+  // the VDP doesn't look at the 68k level\r
+  if (pv->pending_ints & pv->reg[1] & 0x20) {\r
+    pv->pending_ints &= ~0x20;\r
+    pv->status &= ~SR_F;\r
+    return (pv->reg[0] & pv->pending_ints & 0x10) >> 2;\r
+  }\r
+  else if (pv->pending_ints & pv->reg[0] & 0x10)\r
+    pv->pending_ints &= ~0x10;\r
+\r
+  return 0;\r
+}\r
+\r
 /* callbacks */\r
 #ifdef EMU_C68K\r
 // interrupt acknowledgment\r
 static int SekIntAck(int level)\r
 {\r
-  // try to emulate VDP's reaction to 68000 int ack\r
-  if     (level == 4) { Pico.video.pending_ints  =  0;    elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }\r
-  else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }\r
-  PicoCpuCM68k.irq = 0;\r
+  PicoCpuCM68k.irq = do_ack(level);\r
   return CYCLONE_INT_ACK_AUTOVECTOR;\r
 }\r
 \r
@@ -60,6 +70,8 @@ static int SekUnrecognizedOpcode()
     PicoCpuCM68k.state_flags |= 1;\r
     return 1;\r
   }\r
+  // happened once - may happen again\r
+  SekFinishIdleDet();\r
 #ifdef EMU_M68K // debugging cyclone\r
   {\r
     extern int have_illegal;\r
@@ -74,9 +86,7 @@ static int SekUnrecognizedOpcode()
 #ifdef EMU_M68K\r
 static int SekIntAckM68K(int level)\r
 {\r
-  if     (level == 4) { Pico.video.pending_ints  =  0;    elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }\r
-  else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }\r
-  CPU_INT_LEVEL = 0;\r
+  CPU_INT_LEVEL = do_ack(level) << 8;\r
   return M68K_INT_ACK_AUTOVECTOR;\r
 }\r
 \r
@@ -90,15 +100,7 @@ static int SekTasCallback(void)
 #ifdef EMU_F68K\r
 static void SekIntAckF68K(unsigned level)\r
 {\r
-  if     (level == 4) {\r
-    Pico.video.pending_ints = 0;\r
-    elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCyclesDone());\r
-  }\r
-  else if(level == 6) {\r
-    Pico.video.pending_ints &= ~0x20;\r
-    elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCyclesDone());\r
-  }\r
-  PicoCpuFM68k.interrupts[0] = 0;\r
+  PicoCpuFM68k.interrupts[0] = do_ack(level);\r
 }\r
 #endif\r
 \r
@@ -166,17 +168,17 @@ PICO_INTERNAL int SekReset(void)
 \r
 void SekStepM68k(void)\r
 {\r
-  SekCycleAim=SekCycleCnt+1;\r
+  Pico.t.m68c_aim = Pico.t.m68c_cnt + 1;\r
 #if defined(EMU_CORE_DEBUG)\r
-  SekCycleCnt+=CM_compareRun(1, 0);\r
+  Pico.t.m68c_cnt += CM_compareRun(1, 0);\r
 #elif defined(EMU_C68K)\r
   PicoCpuCM68k.cycles=1;\r
   CycloneRun(&PicoCpuCM68k);\r
-  SekCycleCnt+=1-PicoCpuCM68k.cycles;\r
+  Pico.t.m68c_cnt += 1 - PicoCpuCM68k.cycles;\r
 #elif defined(EMU_M68K)\r
-  SekCycleCnt+=m68k_execute(1);\r
+  Pico.t.m68c_cnt += m68k_execute(1);\r
 #elif defined(EMU_F68K)\r
-  SekCycleCnt+=fm68k_emulate(1, 0);\r
+  Pico.t.m68c_cnt += fm68k_emulate(1, 0);\r
 #endif\r
 }\r
 \r
@@ -226,7 +228,7 @@ PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub)
 \r
   *(unsigned int *)(cpu+0x40) = pc;\r
   *(unsigned int *)(cpu+0x50) =\r
-    is_sub ? SekCycleCntS68k : SekCycleCnt;\r
+    is_sub ? SekCycleCntS68k : Pico.t.m68c_cnt;\r
 }\r
 \r
 PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)\r
@@ -266,7 +268,7 @@ PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
   if (is_sub)\r
     SekCycleCntS68k = *(unsigned int *)(cpu+0x50);\r
   else\r
-    SekCycleCnt = *(unsigned int *)(cpu+0x50);\r
+    Pico.t.m68c_cnt = *(unsigned int *)(cpu+0x50);\r
 }\r
 \r
 \r
@@ -300,7 +302,8 @@ void SekRegisterIdleHit(unsigned int pc)
 \r
 void SekInitIdleDet(void)\r
 {\r
-  unsigned short **tmp = realloc(idledet_ptrs, 0x200*4);\r
+  unsigned short **tmp;\r
+  tmp = realloc(idledet_ptrs, 0x200 * sizeof(tmp[0]));\r
   if (tmp == NULL) {\r
     free(idledet_ptrs);\r
     idledet_ptrs = NULL;\r
@@ -408,7 +411,8 @@ int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx)
   }\r
 \r
   if (idledet_count >= 0x200 && (idledet_count & 0x1ff) == 0) {\r
-    unsigned short **tmp = realloc(idledet_ptrs, (idledet_count+0x200)*4);\r
+    unsigned short **tmp;\r
+    tmp = realloc(idledet_ptrs, (idledet_count+0x200) * sizeof(tmp[0]));\r
     if (tmp == NULL)\r
       return 1;\r
     idledet_ptrs = tmp;\r
@@ -421,6 +425,8 @@ int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx)
 \r
 void SekFinishIdleDet(void)\r
 {\r
+  if (idledet_count < 0)\r
+    return;\r
 #ifdef EMU_C68K\r
   CycloneFinishIdle();\r
 #endif\r
@@ -439,6 +445,7 @@ void SekFinishIdleDet(void)
     else\r
       elprintf(EL_STATUS|EL_IDLE, "idle: don't know how to restore %04x", *op);\r
   }\r
+  idledet_count = -1;\r
 }\r
 \r
 \r
@@ -460,7 +467,7 @@ void SekTrace(int is_s68k)
   struct ref_68k *x68k = &ref_68ks[is_s68k];\r
   u32 pc = is_s68k ? SekPcS68k : SekPc;\r
   u32 sr = is_s68k ? SekSrS68k : SekSr;\r
-  u32 cycles = is_s68k ? SekCycleCntS68k : SekCycleCnt;\r
+  u32 cycles = is_s68k ? SekCycleCntS68k : Pico.t.m68c_cnt;\r
   u32 r;\r
   u8 cmd;\r
 #ifdef CPU_CMP_W\r
@@ -549,6 +556,7 @@ breakloop:
                        printf("D%d: %08x  A%d: %08x\n", i, x68k->dar[i],\r
         i, x68k->dar[i + 8]);\r
                printf("PC: %08x, %08x\n", x68k->pc, x68k->pc_prev);\r
+               printf("SR: %04x\n", x68k->sr);\r
 \r
     PDebugDumpMem();\r
     exit(1);\r
index 8c44d51..a2351b0 100644 (file)
@@ -23,7 +23,7 @@ static unsigned char vdp_data_read(void)
   struct PicoVideo *pv = &Pico.video;
   unsigned char d;
 
-  d = Pico.vramb[pv->addr];
+  d = PicoMem.vramb[pv->addr];
   pv->addr = (pv->addr + 1) & 0x3fff;
   pv->pending = 0;
   return d;
@@ -44,10 +44,10 @@ static void vdp_data_write(unsigned char d)
   struct PicoVideo *pv = &Pico.video;
 
   if (pv->type == 3) {
-    Pico.cram[pv->addr & 0x1f] = d;
+    PicoMem.cram[pv->addr & 0x1f] = d;
     Pico.m.dirtyPal = 1;
   } else {
-    Pico.vramb[pv->addr] = d;
+    PicoMem.vramb[pv->addr] = d;
   }
   pv->addr = (pv->addr + 1) & 0x3fff;
 
@@ -180,7 +180,7 @@ static void xwrite(unsigned int a, unsigned char d)
 {
   elprintf(EL_IO, "z80 write [%04x] %02x", a, d);
   if (a >= 0xc000)
-    Pico.zram[a & 0x1fff] = d;
+    PicoMem.zram[a & 0x1fff] = d;
   if (a >= 0xfff8)
     write_bank(a, d);
 }
@@ -195,7 +195,7 @@ void PicoPowerMS(void)
 {
   int s, tmp;
 
-  memset(&Pico.ram,0,(unsigned char *)&Pico.rom - Pico.ram);
+  memset(&PicoMem,0,sizeof(PicoMem));
   memset(&Pico.video,0,sizeof(Pico.video));
   memset(&Pico.m,0,sizeof(Pico.m));
   Pico.m.pal = 0;
@@ -219,11 +219,11 @@ void PicoPowerMS(void)
 void PicoMemSetupMS(void)
 {
   z80_map_set(z80_read_map, 0x0000, 0xbfff, Pico.rom, 0);
-  z80_map_set(z80_read_map, 0xc000, 0xdfff, Pico.zram, 0);
-  z80_map_set(z80_read_map, 0xe000, 0xffff, Pico.zram, 0);
+  z80_map_set(z80_read_map, 0xc000, 0xdfff, PicoMem.zram, 0);
+  z80_map_set(z80_read_map, 0xe000, 0xffff, PicoMem.zram, 0);
 
   z80_map_set(z80_write_map, 0x0000, 0xbfff, xwrite, 1);
-  z80_map_set(z80_write_map, 0xc000, 0xdfff, Pico.zram, 0);
+  z80_map_set(z80_write_map, 0xc000, 0xdfff, PicoMem.zram, 0);
   z80_map_set(z80_write_map, 0xe000, 0xffff, xwrite, 1);
  
 #ifdef _USE_DRZ80
@@ -232,8 +232,8 @@ void PicoMemSetupMS(void)
 #endif
 #ifdef _USE_CZ80
   Cz80_Set_Fetch(&CZ80, 0x0000, 0xbfff, (FPTR)Pico.rom);
-  Cz80_Set_Fetch(&CZ80, 0xc000, 0xdfff, (FPTR)Pico.zram);
-  Cz80_Set_Fetch(&CZ80, 0xe000, 0xffff, (FPTR)Pico.zram);
+  Cz80_Set_Fetch(&CZ80, 0xc000, 0xdfff, (FPTR)PicoMem.zram);
+  Cz80_Set_Fetch(&CZ80, 0xe000, 0xffff, (FPTR)PicoMem.zram);
   Cz80_Set_INPort(&CZ80, z80_sms_in);
   Cz80_Set_OUTPort(&CZ80, z80_sms_out);
 #endif
@@ -258,6 +258,8 @@ void PicoFrameMS(void)
   int nmi;
   int y;
 
+  PsndStartFrame();
+
   nmi = (PicoPad[0] >> 7) & 1;
   if (!Pico.ms.nmi_state && nmi)
     z80_nmi();
index 8474c70..b212759 100644 (file)
@@ -73,96 +73,54 @@ int *sn76496_regs;
 void SN76496Write(int data)\r
 {\r
        struct SN76496 *R = &ono_sn;\r
-       int n;\r
-\r
+       int n, r, c;\r
 \r
        /* update the output buffer before changing the registers */\r
        //stream_update(R->Channel,0);\r
 \r
+       r = R->LastRegister;\r
        if (data & 0x80)\r
-       {\r
-               int r = (data & 0x70) >> 4;\r
-               int c = r/2;\r
+               r = R->LastRegister = (data & 0x70) >> 4;\r
+       c = r / 2;\r
 \r
-               R->LastRegister = r;\r
-               R->Register[r] = (R->Register[r] & 0x3f0) | (data & 0x0f);\r
-               switch (r)\r
-               {\r
-                       case 0: /* tone 0 : frequency */\r
-                       case 2: /* tone 1 : frequency */\r
-                       case 4: /* tone 2 : frequency */\r
-                               R->Period[c] = R->UpdateStep * R->Register[r];\r
-                               if (R->Period[c] == 0) R->Period[c] = R->UpdateStep;\r
-                               if (r == 4)\r
-                               {\r
-                                       /* update noise shift frequency */\r
-                                       if ((R->Register[6] & 0x03) == 0x03)\r
-                                               R->Period[3] = 2 * R->Period[2];\r
-                               }\r
-                               break;\r
-                       case 1: /* tone 0 : volume */\r
-                       case 3: /* tone 1 : volume */\r
-                       case 5: /* tone 2 : volume */\r
-                       case 7: /* noise  : volume */\r
-                               R->Volume[c] = R->VolTable[data & 0x0f];\r
-                               break;\r
-                       case 6: /* noise  : frequency, mode */\r
-                               {\r
-                                       int n = R->Register[6];\r
-                                       R->NoiseFB = (n & 4) ? FB_WNOISE : FB_PNOISE;\r
-                                       n &= 3;\r
-                                       /* N/512,N/1024,N/2048,Tone #3 output */\r
-                                       R->Period[3] = ((n&3) == 3) ? 2 * R->Period[2] : (R->UpdateStep << (5+(n&3)));\r
-\r
-                                       /* reset noise shifter */\r
-                                       R->RNG = NG_PRESET;\r
-                                       R->Output[3] = R->RNG & 1;\r
-                               }\r
-                               break;\r
-               }\r
-       }\r
+       if (!(data & 0x80) && (r == 0 || r == 2 || r == 4))\r
+               // data byte (tone only)\r
+               R->Register[r] = (R->Register[r] & 0x0f) | ((data & 0x3f) << 4);\r
        else\r
-       {\r
-               int r = R->LastRegister;\r
-               int c = r/2;\r
+               R->Register[r] = (R->Register[r] & 0x3f0) | (data & 0x0f);\r
 \r
-               switch (r)\r
-               {\r
-                       case 0: /* tone 0 : frequency */\r
-                       case 2: /* tone 1 : frequency */\r
-                       case 4: /* tone 2 : frequency */\r
-                               R->Register[r] = (R->Register[r] & 0x0f) | ((data & 0x3f) << 4);\r
-                               R->Period[c] = R->UpdateStep * R->Register[r];\r
-                               if (R->Period[c] == 0) R->Period[c] = R->UpdateStep;\r
-                               if (r == 4)\r
-                               {\r
-                                       /* update noise shift frequency */\r
-                                       if ((R->Register[6] & 0x03) == 0x03)\r
-                                               R->Period[3] = 2 * R->Period[2];\r
-                               }\r
-                               break;\r
-                       case 1: /* tone 0 : volume */\r
-                       case 3: /* tone 1 : volume */\r
-                       case 5: /* tone 2 : volume */\r
-                       case 7: /* noise  : volume */\r
-                               R->Volume[c] = R->VolTable[data & 0x0f];\r
-                               R->Register[r] = (R->Register[r] & 0x3f0) | (data & 0x0f);\r
-                               break;\r
-                       case 6: /* noise  : frequency, mode */\r
-                               {\r
-                                       R->Register[r] = (R->Register[r] & 0x3f0) | (data & 0x0f);\r
-                                       n = R->Register[6];\r
-                                       R->NoiseFB = (n & 4) ? FB_WNOISE : FB_PNOISE;\r
-                                       n &= 3;\r
-                                       /* N/512,N/1024,N/2048,Tone #3 output */\r
-                                       R->Period[3] = ((n&3) == 3) ? 2 * R->Period[2] : (R->UpdateStep << (5+(n&3)));\r
-\r
-                                       /* reset noise shifter */\r
-                                       R->RNG = NG_PRESET;\r
-                                       R->Output[3] = R->RNG & 1;\r
-                               }\r
-                               break;\r
-               }\r
+       data = R->Register[r];\r
+       switch (r)\r
+       {\r
+               case 0: /* tone 0 : frequency */\r
+               case 2: /* tone 1 : frequency */\r
+               case 4: /* tone 2 : frequency */\r
+                       R->Period[c] = R->UpdateStep * data;\r
+                       if (R->Period[c] == 0) R->Period[c] = R->UpdateStep;\r
+                       if (r == 4)\r
+                       {\r
+                               /* update noise shift frequency */\r
+                               if ((R->Register[6] & 0x03) == 0x03)\r
+                                       R->Period[3] = 2 * R->Period[2];\r
+                       }\r
+                       break;\r
+               case 1: /* tone 0 : volume */\r
+               case 3: /* tone 1 : volume */\r
+               case 5: /* tone 2 : volume */\r
+               case 7: /* noise  : volume */\r
+                       R->Volume[c] = R->VolTable[data & 0x0f];\r
+                       break;\r
+               case 6: /* noise  : frequency, mode */\r
+                       n = data;\r
+                       R->NoiseFB = (n & 4) ? FB_WNOISE : FB_PNOISE;\r
+                       n &= 3;\r
+                       /* N/512,N/1024,N/2048,Tone #3 output */\r
+                       R->Period[3] = (n == 3) ? 2 * R->Period[2] : (R->UpdateStep << (5 + n));\r
+\r
+                       /* reset noise shifter */\r
+                       R->RNG = NG_PRESET;\r
+                       R->Output[3] = R->RNG & 1;\r
+                       break;\r
        }\r
 }\r
 \r
index 18e1225..a67ebcc 100644 (file)
 #include "../cd/cue.h"\r
 #include "mix.h"\r
 \r
-#define SIMPLE_WRITE_SOUND 0\r
-\r
 void (*PsndMix_32_to_16l)(short *dest, int *src, int count) = mix_32_to_16l_stereo;\r
 \r
 // master int buffer to mix to\r
 static int PsndBuffer[2*(44100+100)/50];\r
 \r
-// dac\r
-static unsigned short dac_info[312+4]; // pppppppp ppppllll, p - pos in buff, l - length to write for this sample\r
+// dac, psg\r
+static unsigned short dac_info[312+4]; // pos in sample buffer\r
 \r
 // cdda output buffer\r
 short cdda_out_buffer[2*1152];\r
@@ -32,8 +30,9 @@ int PsndRate=0;
 int PsndLen=0; // number of mono samples, multiply by 2 for stereo\r
 int PsndLen_exc_add=0; // this is for non-integer sample counts per line, eg. 22050/60\r
 int PsndLen_exc_cnt=0;\r
-int PsndDacLine=0;\r
+int PsndDacLine, PsndPsgLine;\r
 short *PsndOut=NULL; // PCM data buffer\r
+static int PsndLen_use;\r
 \r
 // timers\r
 int timer_a_next_oflow, timer_a_step; // in z80 cycles\r
@@ -45,7 +44,7 @@ extern int *sn76496_regs;
 \r
 static void dac_recalculate(void)\r
 {\r
-  int i, dac_cnt, pos, len, lines = Pico.m.pal ? 312 : 262, mid = Pico.m.pal ? 68 : 93;\r
+  int i, dac_cnt, pos, len, lines = Pico.m.pal ? 313 : 262, mid = Pico.m.pal ? 68 : 93;\r
 \r
   if (PsndLen <= lines)\r
   {\r
@@ -57,14 +56,12 @@ static void dac_recalculate(void)
     for(i=226; i != 225; i++)\r
     {\r
       if (i >= lines) i = 0;\r
-      len = 0;\r
       if(dac_cnt < 0) {\r
-        len=1;\r
         pos++;\r
         dac_cnt += lines;\r
       }\r
       dac_cnt -= PsndLen;\r
-      dac_info[i] = (pos<<4)|len;\r
+      dac_info[i] = pos;\r
     }\r
   }\r
   else\r
@@ -86,24 +83,12 @@ static void dac_recalculate(void)
           len++;\r
         }\r
       dac_cnt += PsndLen;\r
-      dac_info[i] = (pos<<4)|len;\r
-      pos+=len;\r
+      pos += len;\r
+      dac_info[i] = pos;\r
     }\r
-    // last sample\r
-    for(len = 0, i = pos; i < PsndLen; i++) len++;\r
-    if (PsndLen_exc_add) len++;\r
-    dac_info[224] = (pos<<4)|len;\r
   }\r
-  mid = (dac_info[lines-1] & 0xfff0) + ((dac_info[lines-1] & 0xf) << 4);\r
   for (i = lines; i < sizeof(dac_info) / sizeof(dac_info[0]); i++)\r
-    dac_info[i] = mid;\r
-  //for(i=len=0; i < lines; i++) {\r
-  //  printf("%03i : %03i : %i\n", i, dac_info[i]>>4, dac_info[i]&0xf);\r
-  //  len+=dac_info[i]&0xf;\r
-  //}\r
-  //printf("rate is %i, len %f\n", PsndRate, (double)PsndRate/(Pico.m.pal ? 50.0 : 60.0));\r
-  //printf("len total: %i, last pos: %i\n", len, pos);\r
-  //exit(8);\r
+    dac_info[i] = dac_info[0];\r
 }\r
 \r
 \r
@@ -118,10 +103,6 @@ PICO_INTERNAL void PsndReset(void)
 // to be called after changing sound rate or chips\r
 void PsndRerate(int preserve_state)\r
 {\r
-  // PsndRerate not ready yet\r
-  if (Pico.romsize <= 0)\r
-    return;\r
-\r
   void *state = NULL;\r
   int target_fps = Pico.m.pal ? 50 : 60;\r
 \r
@@ -167,29 +148,77 @@ void PsndRerate(int preserve_state)
 }\r
 \r
 \r
+PICO_INTERNAL void PsndStartFrame(void)\r
+{\r
+  // compensate for float part of PsndLen\r
+  PsndLen_use = PsndLen;\r
+  PsndLen_exc_cnt += PsndLen_exc_add;\r
+  if (PsndLen_exc_cnt >= 0x10000) {\r
+    PsndLen_exc_cnt -= 0x10000;\r
+    PsndLen_use++;\r
+  }\r
+\r
+  PsndDacLine = PsndPsgLine = 0;\r
+  emustatus &= ~1;\r
+  dac_info[224] = PsndLen_use;\r
+}\r
+\r
 PICO_INTERNAL void PsndDoDAC(int line_to)\r
 {\r
   int pos, pos1, len;\r
   int dout = ym2612.dacout;\r
   int line_from = PsndDacLine;\r
 \r
-  if (line_to >= 312)\r
-    line_to = 311;\r
+  if (line_to >= 313)\r
+    line_to = 312;\r
+\r
+  pos  = dac_info[line_from];\r
+  pos1 = dac_info[line_to + 1];\r
+  len = pos1 - pos;\r
+  if (len <= 0)\r
+    return;\r
 \r
   PsndDacLine = line_to + 1;\r
 \r
-  pos =dac_info[line_from]>>4;\r
-  pos1=dac_info[line_to];\r
-  len = ((pos1>>4)-pos) + (pos1&0xf);\r
-  if (!len) return;\r
+  if (!PsndOut)\r
+    return;\r
 \r
   if (PicoOpt & POPT_EN_STEREO) {\r
     short *d = PsndOut + pos*2;\r
-    for (; len > 0; len--, d+=2) *d = dout;\r
+    for (; len > 0; len--, d+=2) *d += dout;\r
   } else {\r
     short *d = PsndOut + pos;\r
-    for (; len > 0; len--, d++)  *d = dout;\r
+    for (; len > 0; len--, d++)  *d += dout;\r
+  }\r
+}\r
+\r
+PICO_INTERNAL void PsndDoPSG(int line_to)\r
+{\r
+  int line_from = PsndPsgLine;\r
+  int pos, pos1, len;\r
+  int stereo = 0;\r
+\r
+  if (line_to >= 313)\r
+    line_to = 312;\r
+\r
+  pos  = dac_info[line_from];\r
+  pos1 = dac_info[line_to + 1];\r
+  len = pos1 - pos;\r
+  //elprintf(EL_STATUS, "%3d %3d %3d %3d %3d",\r
+  //  pos, pos1, len, line_from, line_to);\r
+  if (len <= 0)\r
+    return;\r
+\r
+  PsndPsgLine = line_to + 1;\r
+\r
+  if (!PsndOut || !(PicoOpt & POPT_EN_PSG))\r
+    return;\r
+\r
+  if (PicoOpt & POPT_EN_STEREO) {\r
+    stereo = 1;\r
+    pos <<= 1;\r
   }\r
+  SN76496Update(PsndOut + pos, len, stereo);\r
 }\r
 \r
 // cdda\r
@@ -264,21 +293,6 @@ static int PsndRender(int offset, int length)
 \r
   pprof_start(sound);\r
 \r
-#if !SIMPLE_WRITE_SOUND\r
-  if (offset == 0) { // should happen once per frame\r
-    // compensate for float part of PsndLen\r
-    PsndLen_exc_cnt += PsndLen_exc_add;\r
-    if (PsndLen_exc_cnt >= 0x10000) {\r
-      PsndLen_exc_cnt -= 0x10000;\r
-      length++;\r
-    }\r
-  }\r
-#endif\r
-\r
-  // PSG\r
-  if (PicoOpt & POPT_EN_PSG)\r
-    SN76496Update(PsndOut+offset, length, stereo);\r
-\r
   if (PicoAHW & PAHW_PICO) {\r
     PicoPicoPCMUpdate(PsndOut+offset, length, stereo);\r
     return length;\r
@@ -326,20 +340,17 @@ static int PsndRender(int offset, int length)
 // to be called on 224 or line_sample scanlines only\r
 PICO_INTERNAL void PsndGetSamples(int y)\r
 {\r
-#if SIMPLE_WRITE_SOUND\r
-  if (y != 224) return;\r
-  PsndRender(0, PsndLen);\r
-  if (PicoWriteSound)\r
-    PicoWriteSound(PsndLen * ((PicoOpt & POPT_EN_STEREO) ? 4 : 2));\r
-  PsndClear();\r
-#else\r
   static int curr_pos = 0;\r
 \r
+  if (ym2612.dacen && PsndDacLine < y)\r
+    PsndDoDAC(y - 1);\r
+  PsndDoPSG(y - 1);\r
+\r
   if (y == 224)\r
   {\r
     if (emustatus & 2)\r
          curr_pos += PsndRender(curr_pos, PsndLen-PsndLen/2);\r
-    else curr_pos  = PsndRender(0, PsndLen);\r
+    else curr_pos  = PsndRender(0, PsndLen_use);\r
     if (emustatus & 1)\r
          emustatus |=  2;\r
     else emustatus &= ~2;\r
@@ -347,28 +358,20 @@ PICO_INTERNAL void PsndGetSamples(int y)
       PicoWriteSound(curr_pos * ((PicoOpt & POPT_EN_STEREO) ? 4 : 2));\r
     // clear sound buffer\r
     PsndClear();\r
+    PsndDacLine = 224;\r
+    dac_info[224] = 0;\r
   }\r
   else if (emustatus & 3) {\r
     emustatus|= 2;\r
     emustatus&=~1;\r
     curr_pos = PsndRender(0, PsndLen/2);\r
   }\r
-#endif\r
 }\r
 \r
 PICO_INTERNAL void PsndGetSamplesMS(void)\r
 {\r
   int stereo = (PicoOpt & 8) >> 3;\r
-  int length = PsndLen;\r
-\r
-#if !SIMPLE_WRITE_SOUND\r
-  // compensate for float part of PsndLen\r
-  PsndLen_exc_cnt += PsndLen_exc_add;\r
-  if (PsndLen_exc_cnt >= 0x10000) {\r
-    PsndLen_exc_cnt -= 0x10000;\r
-    length++;\r
-  }\r
-#endif\r
+  int length = PsndLen_use;\r
 \r
   // PSG\r
   if (PicoOpt & POPT_EN_PSG)\r
@@ -386,3 +389,4 @@ PICO_INTERNAL void PsndGetSamplesMS(void)
   PsndClear();\r
 }\r
 \r
+// vim:shiftwidth=2:ts=2:expandtab\r
index 692f34e..0867f55 100644 (file)
@@ -139,10 +139,6 @@ void memset32(int *dest, int c, int count);
 #define INLINE static __inline\r
 #endif\r
 \r
-#ifndef STRICTINLINE\r
-#define STRICTINLINE static inline\r
-#endif\r
-\r
 #ifndef M_PI\r
 #define M_PI    3.14159265358979323846\r
 #endif\r
@@ -535,7 +531,7 @@ static int g_lfo_ampm = 0;
 \r
 \r
 /* OPN Mode Register Write */\r
-static INLINE void set_timers( int v )\r
+INLINE void set_timers( int v )\r
 {\r
        /* b7 = CSM MODE */\r
        /* b6 = 3 slot mode */\r
@@ -557,7 +553,7 @@ static INLINE void set_timers( int v )
 }\r
 \r
 \r
-static INLINE void FM_KEYON(int c , int s )\r
+INLINE void FM_KEYON(int c , int s )\r
 {\r
        FM_SLOT *SLOT = &ym2612.CH[c].SLOT[s];\r
        if( !SLOT->key )\r
@@ -569,7 +565,7 @@ static INLINE void FM_KEYON(int c , int s )
        }\r
 }\r
 \r
-static INLINE void FM_KEYOFF(int c , int s )\r
+INLINE void FM_KEYOFF(int c , int s )\r
 {\r
        FM_SLOT *SLOT = &ym2612.CH[c].SLOT[s];\r
        if( SLOT->key )\r
@@ -582,7 +578,7 @@ static INLINE void FM_KEYOFF(int c , int s )
 \r
 \r
 /* set detune & multiple */\r
-static INLINE void set_det_mul(FM_CH *CH, FM_SLOT *SLOT, int v)\r
+INLINE void set_det_mul(FM_CH *CH, FM_SLOT *SLOT, int v)\r
 {\r
        SLOT->mul = (v&0x0f)? (v&0x0f)*2 : 1;\r
        SLOT->DT  = ym2612.OPN.ST.dt_tab[(v>>4)&7];\r
@@ -590,13 +586,13 @@ static INLINE void set_det_mul(FM_CH *CH, FM_SLOT *SLOT, int v)
 }\r
 \r
 /* set total level */\r
-static INLINE void set_tl(FM_SLOT *SLOT, int v)\r
+INLINE void set_tl(FM_SLOT *SLOT, int v)\r
 {\r
        SLOT->tl = (v&0x7f)<<(ENV_BITS-7); /* 7bit TL */\r
 }\r
 \r
 /* set attack rate & key scale  */\r
-static INLINE void set_ar_ksr(FM_CH *CH, FM_SLOT *SLOT, int v)\r
+INLINE void set_ar_ksr(FM_CH *CH, FM_SLOT *SLOT, int v)\r
 {\r
        UINT8 old_KSR = SLOT->KSR;\r
 \r
@@ -628,7 +624,7 @@ static INLINE void set_ar_ksr(FM_CH *CH, FM_SLOT *SLOT, int v)
 }\r
 \r
 /* set decay rate */\r
-static INLINE void set_dr(FM_SLOT *SLOT, int v)\r
+INLINE void set_dr(FM_SLOT *SLOT, int v)\r
 {\r
        int eg_sh_d1r, eg_sel_d1r;\r
 \r
@@ -641,7 +637,7 @@ static INLINE void set_dr(FM_SLOT *SLOT, int v)
 }\r
 \r
 /* set sustain rate */\r
-static INLINE void set_sr(FM_SLOT *SLOT, int v)\r
+INLINE void set_sr(FM_SLOT *SLOT, int v)\r
 {\r
        int eg_sh_d2r, eg_sel_d2r;\r
 \r
@@ -654,7 +650,7 @@ static INLINE void set_sr(FM_SLOT *SLOT, int v)
 }\r
 \r
 /* set release rate */\r
-static INLINE void set_sl_rr(FM_SLOT *SLOT, int v)\r
+INLINE void set_sl_rr(FM_SLOT *SLOT, int v)\r
 {\r
        int eg_sh_rr, eg_sel_rr;\r
 \r
@@ -668,7 +664,9 @@ static INLINE void set_sl_rr(FM_SLOT *SLOT, int v)
        SLOT->eg_pack_rr = eg_inc_pack[eg_sel_rr] | (eg_sh_rr<<24);\r
 }\r
 \r
-static INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm)\r
+\r
+\r
+INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm)\r
 {\r
        int ret, sin = (phase>>16) + (pm>>1);\r
        int neg = sin & 0x200;\r
@@ -685,7 +683,7 @@ static INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm)
        return neg ? -ret : ret;\r
 }\r
 \r
-static INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm)\r
+INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm)\r
 {\r
        int ret, sin = (phase+pm)>>16;\r
        int neg = sin & 0x200;\r
@@ -703,7 +701,7 @@ static INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm)
 \r
 #if !defined(_ASM_YM2612_C) || defined(EXTERNAL_YM2612)\r
 /* advance LFO to next sample */\r
-static INLINE int advance_lfo(int lfo_ampm, UINT32 lfo_cnt_old, UINT32 lfo_cnt)\r
+INLINE int advance_lfo(int lfo_ampm, UINT32 lfo_cnt_old, UINT32 lfo_cnt)\r
 {\r
        UINT8 pos;\r
        UINT8 prev_pos;\r
@@ -741,83 +739,57 @@ static INLINE int advance_lfo(int lfo_ampm, UINT32 lfo_cnt_old, UINT32 lfo_cnt)
        return lfo_ampm;\r
 }\r
 \r
-#define EG_INC_VAL() \\r
-       ((1 << ((pack >> ((eg_cnt>>shift)&7)*3)&7)) >> 1)\r
-\r
-STRICTINLINE UINT32 update_eg_phase(FM_SLOT *SLOT, UINT32 eg_cnt)\r
+INLINE void update_eg_phase(UINT16 *vol_out, FM_SLOT *SLOT, UINT32 eg_cnt)\r
 {\r
        INT32 volume = SLOT->volume;\r
+       UINT32 pack = SLOT->eg_pack[SLOT->state - 1];\r
+       UINT32 shift = pack >> 24;\r
+       INT32 eg_inc_val;\r
 \r
-       switch(SLOT->state)\r
-       {\r
-               case EG_ATT:            /* attack phase */\r
-               {\r
-                       UINT32 pack = SLOT->eg_pack_ar;\r
-                       UINT32 shift = pack>>24;\r
-                       if ( !(eg_cnt & ((1<<shift)-1) ) )\r
-                       {\r
-                               volume += ( ~volume * EG_INC_VAL() ) >>4;\r
+       if (eg_cnt & ((1 << shift) - 1))\r
+               return;\r
 \r
-                               if (volume <= MIN_ATT_INDEX)\r
-                               {\r
-                                       volume = MIN_ATT_INDEX;\r
-                                       SLOT->state = EG_DEC;\r
-                               }\r
-                       }\r
-                       break;\r
-               }\r
+       eg_inc_val = pack >> ((eg_cnt >> shift) & 7) * 3;\r
+       eg_inc_val = (1 << (eg_inc_val & 7)) >> 1;\r
 \r
-               case EG_DEC:    /* decay phase */\r
+       switch (SLOT->state)\r
+       {\r
+       case EG_ATT:            /* attack phase */\r
+               volume += ( ~volume * eg_inc_val ) >> 4;\r
+               if ( volume <= MIN_ATT_INDEX )\r
                {\r
-                       UINT32 pack = SLOT->eg_pack_d1r;\r
-                       UINT32 shift = pack>>24;\r
-                       if ( !(eg_cnt & ((1<<shift)-1) ) )\r
-                       {\r
-                               volume += EG_INC_VAL();\r
-\r
-                               if ( volume >= (INT32) SLOT->sl )\r
-                                       SLOT->state = EG_SUS;\r
-                       }\r
-                       break;\r
+                       volume = MIN_ATT_INDEX;\r
+                       SLOT->state = EG_DEC;\r
                }\r
+               break;\r
 \r
-               case EG_SUS:    /* sustain phase */\r
-               {\r
-                       UINT32 pack = SLOT->eg_pack_d2r;\r
-                       UINT32 shift = pack>>24;\r
-                       if ( !(eg_cnt & ((1<<shift)-1) ) )\r
-                       {\r
-                               volume += EG_INC_VAL();\r
+       case EG_DEC:    /* decay phase */\r
+               volume += eg_inc_val;\r
+               if ( volume >= (INT32) SLOT->sl )\r
+                       SLOT->state = EG_SUS;\r
+               break;\r
 \r
-                               if ( volume >= MAX_ATT_INDEX )\r
-                               {\r
-                                       volume = MAX_ATT_INDEX;\r
-                                       /* do not change SLOT->state (verified on real chip) */\r
-                               }\r
-                       }\r
-                       break;\r
+       case EG_SUS:    /* sustain phase */\r
+               volume += eg_inc_val;\r
+               if ( volume >= MAX_ATT_INDEX )\r
+               {\r
+                       volume = MAX_ATT_INDEX;\r
+                       /* do not change SLOT->state (verified on real chip) */\r
                }\r
+               break;\r
 \r
-               case EG_REL:    /* release phase */\r
+       case EG_REL:    /* release phase */\r
+               volume += eg_inc_val;\r
+               if ( volume >= MAX_ATT_INDEX )\r
                {\r
-                       UINT32 pack = SLOT->eg_pack_rr;\r
-                       UINT32 shift = pack>>24;\r
-                       if ( !(eg_cnt & ((1<<shift)-1) ) )\r
-                       {\r
-                               volume += EG_INC_VAL();\r
-\r
-                               if ( volume >= MAX_ATT_INDEX )\r
-                               {\r
-                                       volume = MAX_ATT_INDEX;\r
-                                       SLOT->state = EG_OFF;\r
-                               }\r
-                       }\r
-                       break;\r
+                       volume = MAX_ATT_INDEX;\r
+                       SLOT->state = EG_OFF;\r
                }\r
+               break;\r
        }\r
 \r
        SLOT->volume = volume;\r
-       return SLOT->tl + ((UINT32)volume); /* tl is 7bit<<3, volume 0-1023 (0-2039 total) */\r
+       *vol_out = SLOT->tl + volume; /* tl is 7bit<<3, volume 0-1023 (0-2039 total) */\r
 }\r
 #endif\r
 \r
@@ -875,10 +847,10 @@ static void chan_render_loop(chan_rend_context *ct, int *buffer, int length)
                        ct->eg_timer -= EG_TIMER_OVERFLOW;\r
                        ct->eg_cnt++;\r
 \r
-                       if (ct->CH->SLOT[SLOT1].state != EG_OFF) ct->vol_out1 = update_eg_phase(&ct->CH->SLOT[SLOT1], ct->eg_cnt);\r
-                       if (ct->CH->SLOT[SLOT2].state != EG_OFF) ct->vol_out2 = update_eg_phase(&ct->CH->SLOT[SLOT2], ct->eg_cnt);\r
-                       if (ct->CH->SLOT[SLOT3].state != EG_OFF) ct->vol_out3 = update_eg_phase(&ct->CH->SLOT[SLOT3], ct->eg_cnt);\r
-                       if (ct->CH->SLOT[SLOT4].state != EG_OFF) ct->vol_out4 = update_eg_phase(&ct->CH->SLOT[SLOT4], ct->eg_cnt);\r
+                       if (ct->CH->SLOT[SLOT1].state != EG_OFF) update_eg_phase(&ct->vol_out1, &ct->CH->SLOT[SLOT1], ct->eg_cnt);\r
+                       if (ct->CH->SLOT[SLOT2].state != EG_OFF) update_eg_phase(&ct->vol_out2, &ct->CH->SLOT[SLOT2], ct->eg_cnt);\r
+                       if (ct->CH->SLOT[SLOT3].state != EG_OFF) update_eg_phase(&ct->vol_out3, &ct->CH->SLOT[SLOT3], ct->eg_cnt);\r
+                       if (ct->CH->SLOT[SLOT4].state != EG_OFF) update_eg_phase(&ct->vol_out4, &ct->CH->SLOT[SLOT4], ct->eg_cnt);\r
                }\r
 \r
                if (ct->pack & 4) continue; /* output disabled */\r
@@ -1073,7 +1045,7 @@ static void chan_render_loop(chan_rend_context *ct, int *buffer, int length)
                        } else {\r
                                buffer[scounter] += smp;\r
                        }\r
-                       ct->algo = 8; // algo is only used in asm, here only bit3 is used\r
+                       ct->algo |= 8;\r
                }\r
 \r
                /* update phase counters AFTER output calculations */\r
@@ -1203,7 +1175,7 @@ static int chan_render(int *buffer, int length, int c, UINT32 flags) // flags: s
 }\r
 \r
 /* update phase increment and envelope generator */\r
-STRICTINLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc)\r
+INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc)\r
 {\r
        int ksr, fdt;\r
 \r
@@ -1252,7 +1224,7 @@ STRICTINLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc)
 }\r
 \r
 /* update phase increment counters */\r
-void refresh_fc_eg_chan(FM_CH *CH)\r
+INLINE void refresh_fc_eg_chan(FM_CH *CH)\r
 {\r
        if( CH->SLOT[SLOT1].Incr==-1){\r
                int fc = CH->fc;\r
@@ -1264,7 +1236,7 @@ void refresh_fc_eg_chan(FM_CH *CH)
        }\r
 }\r
 \r
-void refresh_fc_eg_chan_sl3(void)\r
+INLINE void refresh_fc_eg_chan_sl3(void)\r
 {\r
        if( ym2612.CH[2].SLOT[SLOT1].Incr==-1)\r
        {\r
@@ -1707,6 +1679,7 @@ void YM2612ResetChip_(void)
        for(i = 0x26 ; i >= 0x20 ; i-- ) OPNWriteReg(i,0);\r
        /* DAC mode clear */\r
        ym2612.dacen = 0;\r
+       ym2612.dacout = 0;\r
        ym2612.addr_A1 = 0;\r
 }\r
 \r
@@ -1721,22 +1694,19 @@ int YM2612Write_(unsigned int a, unsigned int v)
 \r
        v &= 0xff;      /* adjust to 8 bit bus */\r
 \r
-       switch( a&3){\r
+       switch( a & 3 ){\r
        case 0: /* address port 0 */\r
+       case 2: /* address port 1 */\r
                ym2612.OPN.ST.address = v;\r
-               ym2612.addr_A1 = 0;\r
-               ret=0;\r
+               ym2612.addr_A1 = (a & 2) >> 1;\r
+               ret = 0;\r
                break;\r
 \r
-       case 1: /* data port 0    */\r
-               if (ym2612.addr_A1 != 0) {\r
-                       ret=0;\r
-                       break;  /* verified on real YM2608 */\r
-               }\r
-\r
-               addr = ym2612.OPN.ST.address;\r
+       case 1:\r
+       case 3: /* data port */\r
+               addr = ym2612.OPN.ST.address | ((int)ym2612.addr_A1 << 8);\r
 \r
-               switch( addr & 0xf0 )\r
+               switch( addr & 0x1f0 )\r
                {\r
                case 0x20:      /* 0x20-0x2f Mode */\r
                        switch( addr )\r
@@ -1749,6 +1719,7 @@ int YM2612Write_(unsigned int a, unsigned int v)
                                else\r
                                {\r
                                        ym2612.OPN.lfo_inc = 0;\r
+                                       ym2612.OPN.lfo_cnt = 0;\r
                                }\r
                                break;\r
 #if 0 // handled elsewhere\r
@@ -1818,23 +1789,6 @@ int YM2612Write_(unsigned int a, unsigned int v)
                        ret = OPNWriteReg(addr,v);\r
                }\r
                break;\r
-\r
-       case 2: /* address port 1 */\r
-               ym2612.OPN.ST.address = v;\r
-               ym2612.addr_A1 = 1;\r
-               ret=0;\r
-               break;\r
-\r
-       case 3: /* data port 1    */\r
-               if (ym2612.addr_A1 != 1) {\r
-                       ret=0;\r
-                       break;  /* verified on real YM2608 */\r
-               }\r
-\r
-               addr = ym2612.OPN.ST.address | 0x100;\r
-\r
-               ret = OPNWriteReg(addr, v);\r
-               break;\r
        }\r
 \r
        return ret;\r
index f5e98a0..73a36a8 100644 (file)
@@ -43,10 +43,16 @@ typedef struct
        INT16   volume;         /* #0x1a envelope counter | need_save */\r
        UINT32  sl;             /* #0x1c sustain level:sl_table[SL] */\r
 \r
-       UINT32  eg_pack_ar;     /* #0x20 (attack state) */\r
-       UINT32  eg_pack_d1r;    /* #0x24 (decay state) */\r
-       UINT32  eg_pack_d2r;    /* #0x28 (sustain state) */\r
-       UINT32  eg_pack_rr;     /* #0x2c (release state) */\r
+       /* asm relies on this order: */\r
+       union {\r
+               struct {\r
+                       UINT32 eg_pack_rr;  /* #0x20 1 (release state) */\r
+                       UINT32 eg_pack_d2r; /* #0x24 2 (sustain state) */\r
+                       UINT32 eg_pack_d1r; /* #0x28 3 (decay state) */\r
+                       UINT32 eg_pack_ar;  /* #0x2c 4 (attack state) */\r
+               };\r
+               UINT32 eg_pack[4];\r
+       };\r
 } FM_SLOT;\r
 \r
 \r
index 7db3122..9c436d4 100644 (file)
 .equiv EG_TIMER_OVERFLOW, (3*(1<<EG_SH)) @ envelope generator timer overflows every 3 samples (on real chip)
 .equiv LFO_SH,            25  /*  7.25 fixed point (LFO calculations)       */
 
-.equiv ENV_QUIET,                (2*13*256/8)/2
+.equiv ENV_QUIET,                (2*13*256/8)
 
+.text
+.align 2
 
 @ r5=slot, r1=eg_cnt, trashes: r0,r2,r3
 @ writes output to routp, but only if vol_out changes
 .macro update_eg_phase_slot slot
-    ldrb    r2, [r5,#0x17]          @ state
-    mov     r3, #1               @ 1ci
-    cmp     r2, #1
-    blt     5f                   @ EG_OFF
-    beq     3f                   @ EG_REL
-    cmp     r2, #3
-    blt     2f                   @ EG_SUS
-    beq     1f                   @ EG_DEC
-
-0:  @ EG_ATT
-    ldr     r2, [r5,#0x20]       @ eg_pack_ar (1ci)
-    mov     r0, r2, lsr #24
+    ldrb    r2, [r5,#0x17]       @ state
+    add     r3, r5, #0x1c
+    tst     r2, r2
+    beq     0f                   @ EG_OFF
+
+    ldr     r2, [r3, r2, lsl #2] @ pack
+    mov     r3, #1
+    mov     r0, r2, lsr #24      @ shift
     mov     r3, r3, lsl r0
     sub     r3, r3, #1
-    tst     r1, r3
-    bne     5f                   @ do smth for tl problem (set on init?)
-    mov     r3, r1, lsr r0
-    ldrh    r0, [r5,#0x1a]          @ volume, unsigned (0-1023)
-    and     r3, r3, #7
-    add     r3, r3, r3, lsl #1
-    mov     r3, r2, lsr r3
-    and     r3, r3, #7           @ shift for eg_inc calculation
-    mvn     r2, r0
-    mov     r2, r2, lsl r3
-    add     r0, r0, r2, asr #5
-    cmp     r0, #0               @ if (volume <= MIN_ATT_INDEX)
-    movle   r3, #EG_DEC
-    strleb  r3, [r5,#0x17]       @ state
-    movle   r0, #0
-    b       4f
 
-1:  @ EG_DEC
-    ldr     r2, [r5,#0x24]       @ eg_pack_d1r (1ci)
-    mov     r0, r2, lsr #24
-    mov     r3, r3, lsl r0
-    sub     r3, r3, #1
     tst     r1, r3
-    bne     5f                   @ do smth for tl problem (set on init?)
+    bne     0f                   @ no volume change
+
     mov     r3, r1, lsr r0
-    ldrh    r0, [r5,#0x1a]       @ volume
     and     r3, r3, #7
     add     r3, r3, r3, lsl #1
     mov     r3, r2, lsr r3
-    and     r3, r3, #7           @ shift for eg_inc calculation
+    and     r3, r3, #7           @ eg_inc_val shift, may be 0
+    ldrb    r2, [r5,#0x17]       @ state
+    ldrh    r0, [r5,#0x1a]       @ volume, unsigned (0-1023)
+
+    cmp     r2, #4               @ EG_ATT
+    beq     4f
+    cmp     r2, #2
     mov     r2, #1
-    mov     r3, r2, lsl r3
+    mov     r2, r2, lsl r3
+    mov     r2, r2, lsr #1       @ eg_inc_val
+    add     r0, r0, r2
+    blt     1f                   @ EG_REL
+    beq     2f                   @ EG_SUS
+
+3:  @ EG_DEC
     ldr     r2, [r5,#0x1c]       @ sl (can be 16bit?)
-    add     r0, r0, r3, asr #1
+    mov     r3, #EG_SUS
     cmp     r0, r2               @ if ( volume >= (INT32) SLOT->sl )
-    movge   r3, #EG_SUS
     strgeb  r3, [r5,#0x17]       @ state
-    b       4f
+    b       10f
+
+4:  @ EG_ATT
+    subs    r3, r3, #1           @ eg_inc_val_shift - 1
+    mov     r2, #0
+    mvnpl   r2, r0
+    mov     r2, r2, lsl r3
+    add     r0, r0, r2, asr #4
+    cmp     r0, #0               @ if (volume <= MIN_ATT_INDEX)
+    movle   r3, #EG_DEC
+    strleb  r3, [r5,#0x17]       @ state
+    movle   r0, #0
+    b       10f
 
 2:  @ EG_SUS
-    ldr     r2, [r5,#0x28]       @ eg_pack_d2r (1ci)
-    mov     r0, r2, lsr #24
-    mov     r3, r3, lsl r0
-    sub     r3, r3, #1
-    tst     r1, r3
-    bne     5f                   @ do smth for tl problem (set on init?)
-    mov     r3, r1, lsr r0
-    ldrh    r0, [r5,#0x1a]       @ volume
-    and     r3, r3, #7
-    add     r3, r3, r3, lsl #1
-    mov     r3, r2, lsr r3
-    and     r3, r3, #7           @ shift for eg_inc calculation
-    mov     r2, #1
-    mov     r3, r2, lsl r3
-    add     r0, r0, r3, asr #1
     mov     r2, #1024
     sub     r2, r2, #1           @ r2 = MAX_ATT_INDEX
     cmp     r0, r2               @ if ( volume >= MAX_ATT_INDEX )
     movge   r0, r2
-    b       4f
+    b       10f
 
-3:  @ EG_REL
-    ldr     r2, [r5,#0x2c]       @ eg_pack_rr (1ci)
-    mov     r0, r2, lsr #24
-    mov     r3, r3, lsl r0
-    sub     r3, r3, #1
-    tst     r1, r3
-    bne     5f                   @ do smth for tl problem (set on init?)
-    mov     r3, r1, lsr r0
-    ldrh    r0, [r5,#0x1a]       @ volume
-    and     r3, r3, #7
-    add     r3, r3, r3, lsl #1
-    mov     r3, r2, lsr r3
-    and     r3, r3, #7           @ shift for eg_inc calculation
-    mov     r2, #1
-    mov     r3, r2, lsl r3
-    add     r0, r0, r3, asr #1
+1:  @ EG_REL
     mov     r2, #1024
     sub     r2, r2, #1           @ r2 = MAX_ATT_INDEX
     cmp     r0, r2               @ if ( volume >= MAX_ATT_INDEX )
     movge   r3, #EG_OFF
     strgeb  r3, [r5,#0x17]       @ state
 
-4:
+10: @ finish
     ldrh    r3, [r5,#0x18]       @ tl
     strh    r0, [r5,#0x1a]       @ volume
 .if     \slot == SLOT1
     orr     r7, r0, r7, lsr #16
 .endif
 
-5:
+0: @ EG_OFF
 .endm
 
 
     tstne   r12, #(1<<(\slot+8))
 .if     \slot == SLOT1
     mov     r1, r6, lsl #16
-    mov     r1, r1, lsr #17
+    mov     r1, r1, lsr #16
 .elseif \slot == SLOT2
-    mov     r1, r6, lsr #17
+    mov     r1, r6, lsr #16
 .elseif \slot == SLOT3
     mov     r1, r7, lsl #16
-    mov     r1, r1, lsr #17
+    mov     r1, r1, lsr #16
 .elseif \slot == SLOT4
-    mov     r1, r7, lsr #17
+    mov     r1, r7, lsr #16
 .endif
     andne   r2, r12, #0xc0
     movne   r2, r2,  lsr #6
     addne   r2, r2,  #24
     addne   r1, r1,  r12, lsr r2
+    bic     r1, r1,  #1
 .endm
 
 
+@ \r=sin/result, r1=env, r3=ym_tl_tab
 .macro lookup_tl r
     tst     \r, #0x100
     eorne   \r, \r, #0xff   @ if (sin & 0x100) sin = 0xff - (sin&0xff);
     tst     \r, #0x200
     and     \r, \r, #0xff
-    orr     \r, \r, r1, lsl #8
+    orr     \r, \r, r1, lsl #7
     mov     \r, \r, lsl #1
     ldrh    \r, [r3, \r]    @ 2ci if ne
     rsbne   \r, \r, #0
     make_eg_out SLOT3
     cmp     r1, #ENV_QUIET
     ldr     r2, [lr, #0x38] @ mem (for future)
-    movcs   r0, r2
+    mov     r0, #0
     bcs     0f
-    ldr     r0, [lr, #0x18]      @ 1ci
+    ldr     r0, [lr, #0x18]      @ phase3
     mov     r0, r0, lsr #16
     lookup_tl r0                 @ r0=c2
 
     cmp     r1, #ENV_QUIET
     movcs   r2, #0
     bcs     2f
-    ldr     r2, [lr, #0x14]
+    ldr     r2, [lr, #0x14]      @ phase2
     mov     r5, r10, lsr #17
     add     r2, r5, r2, lsr #16
     lookup_tl r2                 @ r2=mem
 
 2:
-    str     r2, [lr, #0x38] @ mem
+    str     r2, [lr, #0x38]      @ mem
 .endm
 
 
     movne   r0, r0, asr #16
     movne   r0, r0, lsl r2
 
-    ldr     r2, [lr, #0x10]
+    ldr     r2, [lr, #0x10]     @ phase1
+    add     r0, r0, r2
     mov     r0, r0, lsr #16
-    add     r0, r0, r2, lsr #16
     lookup_tl r0
     mov     r10,r10,lsl #16     @ ct->op1_out <<= 16;
     mov     r0, r0, lsl #16
@@ -759,11 +731,18 @@ chan_render_loop:
 crl_loop_lfo:
     add     r0, lr, #0x30
     ldmia   r0, {r1,r2}
+
+    subs    r4, r4, #0x100
+    bmi     crl_loop_end
+
     add     r2, r2, r1
     str     r2, [lr, #0x30]
+
     @ r12=lfo_ampm[31:16], r1=lfo_cnt_old, r2=lfo_cnt
     advance_lfo_m
 
+    add     r4, r4, #0x100
+
 crl_loop:
     subs    r4, r4, #0x100
     bmi     crl_loop_end
@@ -859,7 +838,6 @@ crl_algo6:
 
 crl_algo7:
     upd_algo7_m
-    .pool
 
 
 crl_algo_done:
@@ -917,6 +895,7 @@ crl_do_phase:
 
 
 crl_loop_end:
+@    stmia   lr,  {r6,r7}         @ save volumes (for debug)
     str     r8,  [lr, #0x44]     @ eg_timer
     str     r12, [lr, #0x4c]     @ pack (for lfo_ampm)
     str     r4,  [lr, #0x50]     @ was_update
@@ -925,3 +904,4 @@ crl_loop_end:
 
 .pool
 
+@ vim:filetype=armasm
index 88b8655..69e8be0 100644 (file)
@@ -78,54 +78,6 @@ static void *open_save_file(const char *fname, int is_save)
   return afile;\r
 }\r
 \r
-// legacy savestate loading\r
-#define SCANP(f, x) areaRead(&Pico.x, sizeof(Pico.x), 1, f)\r
-\r
-static int state_load_legacy(void *file)\r
-{\r
-  unsigned char head[32];\r
-  unsigned char cpu[0x60];\r
-  unsigned char cpu_z80[Z80_STATE_SIZE];\r
-  void *ym2612_regs;\r
-  int ok;\r
-\r
-  memset(&cpu,0,sizeof(cpu));\r
-  memset(&cpu_z80,0,sizeof(cpu_z80));\r
-\r
-  memset(head, 0, sizeof(head));\r
-  areaRead(head, sizeof(head), 1, file);\r
-  if (strcmp((char *)head, "Pico") != 0)\r
-    return -1;\r
-\r
-  elprintf(EL_STATUS, "legacy savestate");\r
-\r
-  // Scan all the memory areas:\r
-  SCANP(file, ram);\r
-  SCANP(file, vram);\r
-  SCANP(file, zram);\r
-  SCANP(file, cram);\r
-  SCANP(file, vsram);\r
-\r
-  // Pack, scan and unpack the cpu data:\r
-  areaRead(cpu, sizeof(cpu), 1, file);\r
-  SekUnpackCpu(cpu, 0);\r
-\r
-  SCANP(file, m);\r
-  SCANP(file, video);\r
-\r
-  ok = areaRead(cpu_z80, sizeof(cpu_z80), 1, file) == sizeof(cpu_z80);\r
-  // do not unpack if we fail to load z80 state\r
-  if (!ok) z80_reset();\r
-  else     z80_unpack(cpu_z80);\r
-\r
-  ym2612_regs = YM2612GetRegs();\r
-  areaRead(sn76496_regs, 28*4, 1, file);\r
-  areaRead(ym2612_regs, 0x200+4, 1, file);\r
-  ym2612_unpack_state();\r
-\r
-  return 0;\r
-}\r
-\r
 // ---------------------------------------------------------------------------\r
 \r
 typedef enum {\r
@@ -278,9 +230,9 @@ static int state_save(void *file)
     memset(buff, 0, sizeof(buff));\r
     SekPackCpu(buff, 0);\r
     CHECKED_WRITE_BUFF(CHUNK_M68K,  buff);\r
-    CHECKED_WRITE_BUFF(CHUNK_RAM,   Pico.ram);\r
-    CHECKED_WRITE_BUFF(CHUNK_VSRAM, Pico.vsram);\r
-    CHECKED_WRITE_BUFF(CHUNK_IOPORTS, Pico.ioports);\r
+    CHECKED_WRITE_BUFF(CHUNK_RAM,   PicoMem.ram);\r
+    CHECKED_WRITE_BUFF(CHUNK_VSRAM, PicoMem.vsram);\r
+    CHECKED_WRITE_BUFF(CHUNK_IOPORTS, PicoMem.ioports);\r
     ym2612_pack_state();\r
     CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs);\r
   }\r
@@ -288,9 +240,9 @@ static int state_save(void *file)
     CHECKED_WRITE_BUFF(CHUNK_SMS, Pico.ms);\r
   }\r
 \r
-  CHECKED_WRITE_BUFF(CHUNK_VRAM,  Pico.vram);\r
-  CHECKED_WRITE_BUFF(CHUNK_ZRAM,  Pico.zram);\r
-  CHECKED_WRITE_BUFF(CHUNK_CRAM,  Pico.cram);\r
+  CHECKED_WRITE_BUFF(CHUNK_VRAM,  PicoMem.vram);\r
+  CHECKED_WRITE_BUFF(CHUNK_ZRAM,  PicoMem.zram);\r
+  CHECKED_WRITE_BUFF(CHUNK_CRAM,  PicoMem.cram);\r
   CHECKED_WRITE_BUFF(CHUNK_MISC,  Pico.m);\r
   CHECKED_WRITE_BUFF(CHUNK_VIDEO, Pico.video);\r
 \r
@@ -469,14 +421,14 @@ static int state_load(void *file)
         CHECKED_READ_BUFF(buff_z80);\r
         break;\r
 \r
-      case CHUNK_RAM:     CHECKED_READ_BUFF(Pico.ram); break;\r
-      case CHUNK_VRAM:    CHECKED_READ_BUFF(Pico.vram); break;\r
-      case CHUNK_ZRAM:    CHECKED_READ_BUFF(Pico.zram); break;\r
-      case CHUNK_CRAM:    CHECKED_READ_BUFF(Pico.cram); break;\r
-      case CHUNK_VSRAM:   CHECKED_READ_BUFF(Pico.vsram); break;\r
+      case CHUNK_RAM:     CHECKED_READ_BUFF(PicoMem.ram); break;\r
+      case CHUNK_VRAM:    CHECKED_READ_BUFF(PicoMem.vram); break;\r
+      case CHUNK_ZRAM:    CHECKED_READ_BUFF(PicoMem.zram); break;\r
+      case CHUNK_CRAM:    CHECKED_READ_BUFF(PicoMem.cram); break;\r
+      case CHUNK_VSRAM:   CHECKED_READ_BUFF(PicoMem.vsram); break;\r
       case CHUNK_MISC:    CHECKED_READ_BUFF(Pico.m); break;\r
       case CHUNK_VIDEO:   CHECKED_READ_BUFF(Pico.video); break;\r
-      case CHUNK_IOPORTS: CHECKED_READ_BUFF(Pico.ioports); break;\r
+      case CHUNK_IOPORTS: CHECKED_READ_BUFF(PicoMem.ioports); break;\r
       case CHUNK_PSG:     CHECKED_READ2(28*4, sn76496_regs); break;\r
       case CHUNK_FM:\r
         ym2612_regs = YM2612GetRegs();\r
@@ -589,6 +541,9 @@ readend:
   if (PicoAHW & PAHW_32X)\r
     Pico32xStateLoaded(1);\r
 \r
+  if (PicoLoadStateHook != NULL)\r
+    PicoLoadStateHook();\r
+\r
   // must unpack 68k and z80 after banks are set up\r
   if (!(PicoAHW & PAHW_SMS))\r
     SekUnpackCpu(buff_m68k, 0);\r
@@ -598,7 +553,7 @@ readend:
   z80_unpack(buff_z80);\r
 \r
   // due to dep from 68k cycles..\r
-  SekCycleAim = SekCycleCnt;\r
+  Pico.t.m68c_aim = Pico.t.m68c_cnt;\r
   if (PicoAHW & PAHW_32X)\r
     Pico32xStateLoaded(0);\r
   if (PicoAHW & PAHW_MCD)\r
@@ -607,6 +562,11 @@ readend:
     pcd_state_loaded();\r
   }\r
 \r
+  Pico.m.dirtyPal = 1;\r
+  Pico.video.status &= ~(SR_VB | SR_F);\r
+  Pico.video.status |= ((Pico.video.reg[1] >> 3) ^ SR_VB) & SR_VB;\r
+  Pico.video.status |= (Pico.video.pending_ints << 2) & SR_F;\r
+\r
   retval = 0;\r
 \r
 out:\r
@@ -638,9 +598,9 @@ static int state_load_gfx(void *file)
 \r
     switch (buff[0])\r
     {\r
-      case CHUNK_VRAM:  CHECKED_READ_BUFF(Pico.vram);  found++; break;\r
-      case CHUNK_CRAM:  CHECKED_READ_BUFF(Pico.cram);  found++; break;\r
-      case CHUNK_VSRAM: CHECKED_READ_BUFF(Pico.vsram); found++; break;\r
+      case CHUNK_VRAM:  CHECKED_READ_BUFF(PicoMem.vram);  found++; break;\r
+      case CHUNK_CRAM:  CHECKED_READ_BUFF(PicoMem.cram);  found++; break;\r
+      case CHUNK_VSRAM: CHECKED_READ_BUFF(PicoMem.vsram); found++; break;\r
       case CHUNK_VIDEO: CHECKED_READ_BUFF(Pico.video); found++; break;\r
 \r
 #ifndef NO_32X\r
@@ -676,17 +636,8 @@ static int pico_state_internal(void *afile, int is_save)
 \r
   if (is_save)\r
     ret = state_save(afile);\r
-  else {\r
+  else\r
     ret = state_load(afile);\r
-    if (ret != 0) {\r
-      areaSeek(afile, 0, SEEK_SET);\r
-      ret = state_load_legacy(afile);\r
-    }\r
-\r
-    if (PicoLoadStateHook != NULL)\r
-      PicoLoadStateHook();\r
-    Pico.m.dirtyPal = 1;\r
-  }\r
 \r
   return ret;\r
 }\r
@@ -730,10 +681,10 @@ int PicoStateLoadGfx(const char *fname)
   if (ret != 0) {\r
     // assume legacy\r
     areaSeek(afile, 0x10020, SEEK_SET);  // skip header and RAM\r
-    areaRead(Pico.vram, 1, sizeof(Pico.vram), afile);\r
+    areaRead(PicoMem.vram, 1, sizeof(PicoMem.vram), afile);\r
     areaSeek(afile, 0x2000, SEEK_CUR);\r
-    areaRead(Pico.cram, 1, sizeof(Pico.cram), afile);\r
-    areaRead(Pico.vsram, 1, sizeof(Pico.vsram), afile);\r
+    areaRead(PicoMem.cram, 1, sizeof(PicoMem.cram), afile);\r
+    areaRead(PicoMem.vsram, 1, sizeof(PicoMem.vsram), afile);\r
     areaSeek(afile, 0x221a0, SEEK_SET);\r
     areaRead(&Pico.video, 1, sizeof(Pico.video), afile);\r
   }\r
@@ -766,9 +717,9 @@ void *PicoTmpStateSave(void)
   if (t == NULL)\r
     return NULL;\r
 \r
-  memcpy(t->vram, Pico.vram, sizeof(Pico.vram));\r
-  memcpy(t->cram, Pico.cram, sizeof(Pico.cram));\r
-  memcpy(t->vsram, Pico.vsram, sizeof(Pico.vsram));\r
+  memcpy(t->vram, PicoMem.vram, sizeof(PicoMem.vram));\r
+  memcpy(t->cram, PicoMem.cram, sizeof(PicoMem.cram));\r
+  memcpy(t->vsram, PicoMem.vsram, sizeof(PicoMem.vsram));\r
   memcpy(&t->video, &Pico.video, sizeof(Pico.video));\r
 \r
 #ifndef NO_32X\r
@@ -788,9 +739,9 @@ void PicoTmpStateRestore(void *data)
   if (t == NULL)\r
     return;\r
 \r
-  memcpy(Pico.vram, t->vram, sizeof(Pico.vram));\r
-  memcpy(Pico.cram, t->cram, sizeof(Pico.cram));\r
-  memcpy(Pico.vsram, t->vsram, sizeof(Pico.vsram));\r
+  memcpy(PicoMem.vram, t->vram, sizeof(PicoMem.vram));\r
+  memcpy(PicoMem.cram, t->cram, sizeof(PicoMem.cram));\r
+  memcpy(PicoMem.vsram, t->vsram, sizeof(PicoMem.vsram));\r
   memcpy(&Pico.video, &t->video, sizeof(Pico.video));\r
   Pico.m.dirtyPal = 1;\r
 \r
index 1e67ddb..b5e3f86 100644 (file)
@@ -8,8 +8,9 @@
  */\r
 \r
 #include "pico_int.h"\r
+#define NEED_DMA_SOURCE\r
+#include "memory.h"\r
 \r
-int line_base_cycles;\r
 extern const unsigned char  hcounts_32[];\r
 extern const unsigned char  hcounts_40[];\r
 \r
@@ -20,27 +21,39 @@ typedef unsigned int   u32;
 #define UTYPES_DEFINED\r
 #endif\r
 \r
-int (*PicoDmaHook)(unsigned int source, int len, unsigned short **srcp, unsigned short **limitp) = NULL;\r
+int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask) = NULL;\r
 \r
-static INLINE void AutoIncrement(void)\r
+static __inline void AutoIncrement(void)\r
 {\r
   Pico.video.addr=(unsigned short)(Pico.video.addr+Pico.video.reg[0xf]);\r
 }\r
 \r
+static NOINLINE void VideoWrite128(u32 a, u16 d)\r
+{\r
+  // nasty\r
+  a = ((a & 2) >> 1) | ((a & 0x400) >> 9) | (a & 0x3FC) | ((a & 0x1F800) >> 1);\r
+  ((u8 *)PicoMem.vram)[a] = d;\r
+}\r
+\r
 static void VideoWrite(u16 d)\r
 {\r
-  unsigned int a=Pico.video.addr;\r
+  unsigned int a = Pico.video.addr;\r
 \r
   switch (Pico.video.type)\r
   {\r
-    case 1: if(a&1) d=(u16)((d<<8)|(d>>8)); // If address is odd, bytes are swapped (which game needs this?)\r
-            Pico.vram [(a>>1)&0x7fff]=d;\r
+    case 1: if (a & 1)\r
+              d = (u16)((d << 8) | (d >> 8));\r
+            PicoMem.vram [(a >> 1) & 0x7fff] = d;\r
             if (a - ((unsigned)(Pico.video.reg[5]&0x7f) << 9) < 0x400)\r
               Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
             break;\r
     case 3: Pico.m.dirtyPal = 1;\r
-            Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike)\r
-    case 5: Pico.vsram[(a>>1)&0x003f]=d; break;\r
+            PicoMem.cram [(a >> 1) & 0x3f] = d; break;\r
+    case 5: PicoMem.vsram[(a >> 1) & 0x3f] = d; break;\r
+    case 0x81:\r
+      a |= Pico.video.addr_u << 16;\r
+      VideoWrite128(a, d);\r
+      break;\r
     //default:elprintf(EL_ANOMALY, "VDP write %04x with bad type %i", d, Pico.video.type); break;\r
   }\r
 \r
@@ -55,9 +68,9 @@ static unsigned int VideoRead(void)
 \r
   switch (Pico.video.type)\r
   {\r
-    case 0: d=Pico.vram [a&0x7fff]; break;\r
-    case 8: d=Pico.cram [a&0x003f]; break;\r
-    case 4: d=Pico.vsram[a&0x003f]; break;\r
+    case 0: d=PicoMem.vram [a & 0x7fff]; break;\r
+    case 8: d=PicoMem.cram [a & 0x003f]; break;\r
+    case 4: d=PicoMem.vsram[a & 0x003f]; break;\r
     default:elprintf(EL_ANOMALY, "VDP read with bad type %i", Pico.video.type); break;\r
   }\r
 \r
@@ -72,104 +85,92 @@ static int GetDmaLength(void)
   // 16-bit words to transfer:\r
   len =pvid->reg[0x13];\r
   len|=pvid->reg[0x14]<<8;\r
-  // Charles MacDonald:\r
-  if(!len) len = 0xffff;\r
+  len = ((len - 1) & 0xffff) + 1;\r
   return len;\r
 }\r
 \r
-static void DmaSlow(int len)\r
+static void DmaSlow(int len, unsigned int source)\r
 {\r
-  u16 *pd=0, *pdend, *r;\r
-  unsigned int a=Pico.video.addr, a2, d;\r
-  unsigned char inc=Pico.video.reg[0xf];\r
-  unsigned int source;\r
-\r
-  source =Pico.video.reg[0x15]<<1;\r
-  source|=Pico.video.reg[0x16]<<9;\r
-  source|=Pico.video.reg[0x17]<<17;\r
+  u32 inc = Pico.video.reg[0xf];\r
+  u32 a = Pico.video.addr;\r
+  u16 *r, *base = NULL;\r
+  u32 mask = 0x1ffff;\r
 \r
-  elprintf(EL_VDPDMA, "DmaSlow[%i] %06x->%04x len %i inc=%i blank %i [%i] @ %06x",\r
+  elprintf(EL_VDPDMA, "DmaSlow[%i] %06x->%04x len %i inc=%i blank %i [%u] @ %06x",\r
     Pico.video.type, source, a, len, inc, (Pico.video.status&8)||!(Pico.video.reg[1]&0x40),\r
     SekCyclesDone(), SekPc);\r
 \r
   Pico.m.dma_xfers += len;\r
+  if (Pico.m.dma_xfers < len) // lame 16bit var\r
+    Pico.m.dma_xfers = ~0;\r
   SekCyclesBurnRun(CheckDMA());\r
 \r
-  if ((source&0xe00000)==0xe00000) { // Ram\r
-    pd=(u16 *)(Pico.ram+(source&0xfffe));\r
-    pdend=(u16 *)(Pico.ram+0x10000);\r
+  if ((source & 0xe00000) == 0xe00000) { // Ram\r
+    base = (u16 *)PicoMem.ram;\r
+    mask = 0xffff;\r
   }\r
   else if (PicoAHW & PAHW_MCD)\r
   {\r
-    elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", Pico_mcd->s68k_regs[3]);\r
-    if(source<0x20000) { // Bios area\r
-      pd=(u16 *)(Pico_mcd->bios+(source&~1));\r
-      pdend=(u16 *)(Pico_mcd->bios+0x20000);\r
-    } else if ((source&0xfc0000)==0x200000) { // Word Ram\r
-      source -= 2;\r
-      if (!(Pico_mcd->s68k_regs[3]&4)) { // 2M mode\r
-        pd=(u16 *)(Pico_mcd->word_ram2M+(source&0x3fffe));\r
-        pdend=(u16 *)(Pico_mcd->word_ram2M+0x40000);\r
+    u8 r3 = Pico_mcd->s68k_regs[3];\r
+    elprintf(EL_VDPDMA, "DmaSlow CD, r3=%02x", r3);\r
+    if (source < 0x20000) { // Bios area\r
+      base = (u16 *)Pico_mcd->bios;\r
+    } else if ((source & 0xfc0000) == 0x200000) { // Word Ram\r
+      if (!(r3 & 4)) { // 2M mode\r
+        base = (u16 *)(Pico_mcd->word_ram2M + (source & 0x20000));\r
       } else {\r
         if (source < 0x220000) { // 1M mode\r
-          int bank = Pico_mcd->s68k_regs[3]&1;\r
-          pd=(u16 *)(Pico_mcd->word_ram1M[bank]+(source&0x1fffe));\r
-          pdend=(u16 *)(Pico_mcd->word_ram1M[bank]+0x20000);\r
+          int bank = r3 & 1;\r
+          base = (u16 *)(Pico_mcd->word_ram1M[bank]);\r
         } else {\r
-          DmaSlowCell(source, a, len, inc);\r
+          DmaSlowCell(source - 2, a, len, inc);\r
           return;\r
         }\r
       }\r
-    } else if ((source&0xfe0000)==0x020000) { // Prg Ram\r
-      u8 *prg_ram = Pico_mcd->prg_ram_b[Pico_mcd->s68k_regs[3]>>6];\r
-      pd=(u16 *)(prg_ram+(source&0x1fffe));\r
-      pdend=(u16 *)(prg_ram+0x20000);\r
-    } else {\r
-      elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow[%i] %06x->%04x: FIXME: unsupported src", Pico.video.type, source, a);\r
-      return;\r
+      source -= 2;\r
+    } else if ((source & 0xfe0000) == 0x020000) { // Prg Ram\r
+      base = (u16 *)Pico_mcd->prg_ram_b[r3 >> 6];\r
+      source -= 2; // XXX: test\r
     }\r
   }\r
   else\r
   {\r
     // if we have DmaHook, let it handle ROM because of possible DMA delay\r
-    if (PicoDmaHook && PicoDmaHook(source, len, &pd, &pdend));\r
-    else if (source<Pico.romsize) { // Rom\r
-      pd=(u16 *)(Pico.rom+(source&~1));\r
-      pdend=(u16 *)(Pico.rom+Pico.romsize);\r
-    }\r
-    else {\r
-      elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow[%i] %06x->%04x: invalid src", Pico.video.type, source, a);\r
-      return;\r
-    }\r
+    u32 source2;\r
+    if (PicoDmaHook && (source2 = PicoDmaHook(source, len, &base, &mask)))\r
+      source = source2;\r
+    else // Rom\r
+      base = m68k_dma_source(source);\r
   }\r
-\r
-  // overflow protection, might break something..\r
-  if (len > pdend - pd) {\r
-    len = pdend - pd;\r
-    elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow overflow");\r
+  if (!base) {\r
+    elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow[%i] %06x->%04x: invalid src", Pico.video.type, source, a);\r
+    return;\r
   }\r
 \r
+  // operate in words\r
+  source >>= 1;\r
+  mask >>= 1;\r
+\r
   switch (Pico.video.type)\r
   {\r
     case 1: // vram\r
-      r = Pico.vram;\r
-      if (inc == 2 && !(a&1) && a+len*2 < 0x10000)\r
+      r = PicoMem.vram;\r
+      if (inc == 2 && !(a & 1) && a + len * 2 < 0x10000\r
+          && !(((source + len - 1) ^ source) & ~mask))\r
       {\r
         // most used DMA mode\r
-        pmemcpy16(r + (a>>1), pd, len);\r
-        a += len*2;\r
+        memcpy((char *)r + a, base + (source & mask), len * 2);\r
+        a += len * 2;\r
       }\r
       else\r
       {\r
         for(; len; len--)\r
         {\r
-          d=*pd++;\r
-          if(a&1) d=(d<<8)|(d>>8);\r
-          r[a>>1] = (u16)d; // will drop the upper bits\r
+          u16 d = base[source++ & mask];\r
+          if(a & 1) d=(d<<8)|(d>>8);\r
+          r[a >> 1] = d;\r
           // AutoIncrement\r
-          a=(u16)(a+inc);\r
-          // didn't src overlap?\r
-          //if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM\r
+          a = (u16)(a + inc);\r
         }\r
       }\r
       Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
@@ -177,33 +178,34 @@ static void DmaSlow(int len)
 \r
     case 3: // cram\r
       Pico.m.dirtyPal = 1;\r
-      r = Pico.cram;\r
-      for(a2=a&0x7f; len; len--)\r
+      r = PicoMem.cram;\r
+      for (; len; len--)\r
+      {\r
+        r[(a / 2) & 0x3f] = base[source++ & mask];\r
+        // AutoIncrement\r
+        a += inc;\r
+      }\r
+      break;\r
+\r
+    case 5: // vsram\r
+      r = PicoMem.vsram;\r
+      for (; len; len--)\r
       {\r
-        r[a2>>1] = (u16)*pd++; // bit 0 is ignored\r
+        r[(a / 2) & 0x3f] = base[source++ & mask];\r
         // AutoIncrement\r
-        a2+=inc;\r
-        // didn't src overlap?\r
-        //if(pd >= pdend) pd-=0x8000;\r
-        // good dest?\r
-        if(a2 >= 0x80) break; // Todds Adventures in Slime World / Andre Agassi tennis\r
+        a += inc;\r
       }\r
-      a=(a&0xff00)|a2;\r
       break;\r
 \r
-    case 5: // vsram[a&0x003f]=d;\r
-      r = Pico.vsram;\r
-      for(a2=a&0x7f; len; len--)\r
+    case 0x81: // vram 128k\r
+      a |= Pico.video.addr_u << 16;\r
+      for(; len; len--)\r
       {\r
-        r[a2>>1] = (u16)*pd++;\r
+        VideoWrite128(a, base[source++ & mask]);\r
         // AutoIncrement\r
-        a2+=inc;\r
-        // didn't src overlap?\r
-        //if(pd >= pdend) pd-=0x8000;\r
-        // good dest?\r
-        if(a2 >= 0x80) break;\r
+        a = (a + inc) & 0x1ffff;\r
       }\r
-      a=(a&0xff00)|a2;\r
+      Pico.video.addr_u = a >> 16;\r
       break;\r
 \r
     default:\r
@@ -217,25 +219,23 @@ static void DmaSlow(int len)
 \r
 static void DmaCopy(int len)\r
 {\r
-  u16 a=Pico.video.addr;\r
-  unsigned char *vr = (unsigned char *) Pico.vram;\r
-  unsigned char *vrs;\r
-  unsigned char inc=Pico.video.reg[0xf];\r
+  u16 a = Pico.video.addr;\r
+  u8 *vr = (u8 *)PicoMem.vram;\r
+  u8 inc = Pico.video.reg[0xf];\r
   int source;\r
-  elprintf(EL_VDPDMA, "DmaCopy len %i [%i]", len, SekCyclesDone());\r
+  elprintf(EL_VDPDMA, "DmaCopy len %i [%u]", len, SekCyclesDone());\r
 \r
   Pico.m.dma_xfers += len;\r
+  if (Pico.m.dma_xfers < len)\r
+    Pico.m.dma_xfers = ~0;\r
   Pico.video.status |= 2; // dma busy\r
 \r
   source =Pico.video.reg[0x15];\r
   source|=Pico.video.reg[0x16]<<8;\r
-  vrs=vr+source;\r
-\r
-  if (source+len > 0x10000) len=0x10000-source; // clip??\r
 \r
   for (; len; len--)\r
   {\r
-    vr[a] = *vrs++;\r
+    vr[a] = vr[source++ & 0xffff];\r
     // AutoIncrement\r
     a=(u16)(a+inc);\r
   }\r
@@ -244,76 +244,104 @@ static void DmaCopy(int len)
   Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
 }\r
 \r
-// check: Contra, Megaman\r
-// note: this is still inaccurate\r
-static void DmaFill(int data)\r
+static NOINLINE void DmaFill(int data)\r
 {\r
-  int len;\r
-  unsigned short a=Pico.video.addr;\r
-  unsigned char *vr=(unsigned char *) Pico.vram;\r
-  unsigned char high = (unsigned char) (data >> 8);\r
-  unsigned char inc=Pico.video.reg[0xf];\r
+  u16 a = Pico.video.addr;\r
+  u8 *vr = (u8 *)PicoMem.vram;\r
+  u8 high = (u8)(data >> 8);\r
+  u8 inc = Pico.video.reg[0xf];\r
+  int source;\r
+  int len, l;\r
 \r
-  len=GetDmaLength();\r
-  elprintf(EL_VDPDMA, "DmaFill len %i inc %i [%i]", len, inc, SekCyclesDone());\r
+  len = GetDmaLength();\r
+  elprintf(EL_VDPDMA, "DmaFill len %i inc %i [%u]", len, inc, SekCyclesDone());\r
 \r
   Pico.m.dma_xfers += len;\r
+  if (Pico.m.dma_xfers < len) // lame 16bit var\r
+    Pico.m.dma_xfers = ~0;\r
   Pico.video.status |= 2; // dma busy\r
 \r
-  // from Charles MacDonald's genvdp.txt:\r
-  // Write lower byte to address specified\r
-  vr[a] = (unsigned char) data;\r
-  a=(u16)(a+inc);\r
-\r
-  if (!inc) len=1;\r
-\r
-  for (; len; len--) {\r
-    // Write upper byte to adjacent address\r
-    // (here we are byteswapped, so address is already 'adjacent')\r
-    vr[a] = high;\r
+  switch (Pico.video.type)\r
+  {\r
+    case 1: // vram\r
+      for (l = len; l; l--) {\r
+        // Write upper byte to adjacent address\r
+        // (here we are byteswapped, so address is already 'adjacent')\r
+        vr[a] = high;\r
 \r
-    // Increment address register\r
-    a=(u16)(a+inc);\r
+        // Increment address register\r
+        a = (u16)(a + inc);\r
+      }\r
+      break;\r
+    case 3:   // cram\r
+    case 5: { // vsram\r
+      // TODO: needs fifo; anyone using these?\r
+      static int once;\r
+      if (!once++)\r
+        elprintf(EL_STATUS|EL_ANOMALY|EL_VDPDMA, "TODO: cram/vsram fill");\r
+    }\r
+    default:\r
+      a += len * inc;\r
+      break;\r
   }\r
+\r
   // remember addr\r
-  Pico.video.addr=a;\r
-  // update length\r
-  Pico.video.reg[0x13] = Pico.video.reg[0x14] = 0; // Dino Dini's Soccer (E) (by Haze)\r
+  Pico.video.addr = a;\r
+  // register update\r
+  Pico.video.reg[0x13] = Pico.video.reg[0x14] = 0;\r
+  source  = Pico.video.reg[0x15];\r
+  source |= Pico.video.reg[0x16] << 8;\r
+  source += len;\r
+  Pico.video.reg[0x15] = source;\r
+  Pico.video.reg[0x16] = source >> 8;\r
 \r
   Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;\r
 }\r
 \r
-static void CommandDma(void)\r
+static NOINLINE void CommandDma(void)\r
 {\r
   struct PicoVideo *pvid=&Pico.video;\r
-  int len=0,method=0;\r
+  u32 len, method;\r
+  u32 source;\r
 \r
   if ((pvid->reg[1]&0x10)==0) return; // DMA not enabled\r
 \r
-  len=GetDmaLength();\r
+  len = GetDmaLength();\r
+  source =Pico.video.reg[0x15];\r
+  source|=Pico.video.reg[0x16] << 8;\r
+  source|=Pico.video.reg[0x17] << 16;\r
 \r
   method=pvid->reg[0x17]>>6;\r
-  if (method< 2) DmaSlow(len); // 68000 to VDP\r
-  if (method==3) DmaCopy(len); // VRAM Copy\r
+  if (method < 2)\r
+    DmaSlow(len, source << 1); // 68000 to VDP\r
+  else if (method == 3)\r
+    DmaCopy(len); // VRAM Copy\r
+  else\r
+    return;\r
+\r
+  source += len;\r
+  Pico.video.reg[0x13] = Pico.video.reg[0x14] = 0;\r
+  Pico.video.reg[0x15] = source;\r
+  Pico.video.reg[0x16] = source >> 8;\r
 }\r
 \r
-static void CommandChange(void)\r
+static NOINLINE void CommandChange(void)\r
 {\r
-  struct PicoVideo *pvid=&Pico.video;\r
-  unsigned int cmd=0,addr=0;\r
+  struct PicoVideo *pvid = &Pico.video;\r
+  unsigned int cmd, addr;\r
 \r
-  cmd=pvid->command;\r
+  cmd = pvid->command;\r
 \r
   // Get type of transfer 0xc0000030 (v/c/vsram read/write)\r
-  pvid->type=(unsigned char)(((cmd>>2)&0xc)|(cmd>>30));\r
+  pvid->type = (u8)(((cmd >> 2) & 0xc) | (cmd >> 30));\r
+  if (pvid->type == 1) // vram\r
+    pvid->type |= pvid->reg[1] & 0x80; // 128k\r
 \r
   // Get address 0x3fff0003\r
-  addr =(cmd>>16)&0x3fff;\r
-  addr|=(cmd<<14)&0xc000;\r
-  pvid->addr=(unsigned short)addr;\r
-\r
-  // Check for dma:\r
-  if (cmd&0x80) CommandDma();\r
+  addr  = (cmd >> 16) & 0x3fff;\r
+  addr |= (cmd << 14) & 0xc000;\r
+  pvid->addr = (u16)addr;\r
+  pvid->addr_u = (u8)((cmd >> 2) & 1);\r
 }\r
 \r
 static void DrawSync(int blank_on)\r
@@ -329,16 +357,17 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
 {\r
   struct PicoVideo *pvid=&Pico.video;\r
 \r
-  //if (Pico.m.scanline < 224)\r
-  //  elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x", a, d);\r
-  a&=0x1c;\r
+  //elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x [%u] @ %06x",\r
+  //  a, d, SekCyclesDone(), SekPc);\r
 \r
-  if (a==0x00) // Data port 0 or 2\r
+  a &= 0x1c;\r
+  switch (a)\r
   {\r
+  case 0x00: // Data port 0 or 2\r
     // try avoiding the sync..\r
     if (Pico.m.scanline < 224 && (pvid->reg[1]&0x40) &&\r
         !(!pvid->pending &&\r
-          ((pvid->command & 0xc00000f0) == 0x40000010 && Pico.vsram[pvid->addr>>1] == d))\r
+          ((pvid->command & 0xc00000f0) == 0x40000010 && PicoMem.vsram[pvid->addr>>1] == d))\r
        )\r
       DrawSync(0);\r
 \r
@@ -347,40 +376,35 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
       pvid->pending=0;\r
     }\r
 \r
-    // If a DMA fill has been set up, do it\r
-    if ((pvid->command&0x80) && (pvid->reg[1]&0x10) && (pvid->reg[0x17]>>6)==2)\r
+    if (!(pvid->status & SR_VB) && !(PicoOpt&POPT_DIS_VDP_FIFO))\r
     {\r
-      DmaFill(d);\r
+      int use = pvid->type == 1 ? 2 : 1;\r
+      pvid->lwrite_cnt -= use;\r
+      if (pvid->lwrite_cnt < 0)\r
+        SekCyclesLeft = 0;\r
+      elprintf(EL_ASVDP, "VDP data write: [%04x] %04x [%u] {%i} #%i @ %06x",\r
+        Pico.video.addr, d, SekCyclesDone(), Pico.video.type, pvid->lwrite_cnt, SekPc);\r
     }\r
-    else\r
-    {\r
-      // preliminary FIFO emulation for Chaos Engine, The (E)\r
-      if (!(pvid->status&8) && (pvid->reg[1]&0x40) && !(PicoOpt&POPT_DIS_VDP_FIFO)) // active display?\r
-      {\r
-        pvid->status&=~0x200; // FIFO no longer empty\r
-        pvid->lwrite_cnt++;\r
-        if (pvid->lwrite_cnt >= 4) pvid->status|=0x100; // FIFO full\r
-        if (pvid->lwrite_cnt >  4) {\r
-          SekCyclesBurnRun(32); // penalty // 488/12-8\r
-        }\r
-        elprintf(EL_ASVDP, "VDP data write: %04x [%06x] {%i} #%i @ %06x", d, Pico.video.addr,\r
-                 Pico.video.type, pvid->lwrite_cnt, SekPc);\r
-      }\r
-      VideoWrite(d);\r
-    }\r
-    return;\r
-  }\r
+    VideoWrite(d);\r
 \r
-  if (a==0x04) // Control (command) port 4 or 6\r
-  {\r
+    if ((pvid->command&0x80) && (pvid->reg[1]&0x10) && (pvid->reg[0x17]>>6)==2)\r
+      DmaFill(d);\r
+\r
+    break;\r
+\r
+  case 0x04: // Control (command) port 4 or 6\r
     if (pvid->pending)\r
     {\r
-      if (d & 0x80) DrawSync(0); // only need sync for DMA\r
       // Low word of command:\r
-      pvid->command&=0xffff0000;\r
-      pvid->command|=d;\r
-      pvid->pending=0;\r
+      pvid->command &= 0xffff0000;\r
+      pvid->command |= d;\r
+      pvid->pending = 0;\r
       CommandChange();\r
+      // Check for dma:\r
+      if (d & 0x80) {\r
+        DrawSync(0);\r
+        CommandDma();\r
+      }\r
     }\r
     else\r
     {\r
@@ -396,19 +420,22 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
           return;\r
         }\r
 \r
-        if (num == 1 && !(d&0x40) && SekCyclesDone() - line_base_cycles <= 488-390)\r
+        if (num == 1 && !(d&0x40) && SekCyclesDone() - Pico.t.m68c_line_start <= 488-390)\r
           blank_on = 1;\r
         DrawSync(blank_on);\r
         pvid->reg[num]=(unsigned char)d;\r
         switch (num)\r
         {\r
           case 0x00:\r
-            elprintf(EL_INTSW, "hint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x10)>>4,\r
+            elprintf(EL_INTSW, "hint_onoff: %i->%i [%u] pend=%i @ %06x", (dold&0x10)>>4,\r
                     (d&0x10)>>4, SekCyclesDone(), (pvid->pending_ints&0x10)>>4, SekPc);\r
             goto update_irq;\r
           case 0x01:\r
-            elprintf(EL_INTSW, "vint_onoff: %i->%i [%i] pend=%i @ %06x", (dold&0x20)>>5,\r
+            elprintf(EL_INTSW, "vint_onoff: %i->%i [%u] pend=%i @ %06x", (dold&0x20)>>5,\r
                     (d&0x20)>>5, SekCyclesDone(), (pvid->pending_ints&0x20)>>5, SekPc);\r
+            if (!(pvid->status & PVS_VB2))\r
+              pvid->status &= ~SR_VB;\r
+            pvid->status |= ((d >> 3) ^ SR_VB) & SR_VB; // forced blanking\r
             goto update_irq;\r
           case 0x05:\r
             //elprintf(EL_STATUS, "spritep moved to %04x", (unsigned)(Pico.video.reg[5]&0x7f) << 9);\r
@@ -426,14 +453,15 @@ update_irq:
         // update IRQ level\r
         if (!SekShouldInterrupt()) // hack\r
         {\r
-          int lines, pints, irq=0;\r
+          int lines, pints, irq = 0;\r
           lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10);\r
-          pints = (pvid->pending_ints&lines);\r
+          pints = pvid->pending_ints & lines;\r
                if (pints & 0x20) irq = 6;\r
           else if (pints & 0x10) irq = 4;\r
           SekInterrupt(irq); // update line\r
 \r
-          if (irq) SekEndRun(24); // make it delayed\r
+          // this is broken because cost of current insn isn't known here\r
+          if (irq) SekEndRun(21); // make it delayed\r
         }\r
 #endif\r
       }\r
@@ -445,29 +473,58 @@ update_irq:
         pvid->pending=1;\r
       }\r
     }\r
+    break;\r
+\r
+  // case 0x08: // 08 0a - HV counter - lock up\r
+  // case 0x0c: // 0c 0e - HV counter - lock up\r
+  // case 0x10: // 10 12 - PSG - handled by caller\r
+  // case 0x14: // 14 16 - PSG - handled by caller\r
+  // case 0x18: // 18 1a - no effect?\r
+  case 0x1c: // 1c 1e - debug\r
+    pvid->debug = d;\r
+    pvid->debug_p = 0;\r
+    if (d & (1 << 6)) {\r
+      pvid->debug_p |= PVD_KILL_A | PVD_KILL_B;\r
+      pvid->debug_p |= PVD_KILL_S_LO | PVD_KILL_S_HI;\r
+    }\r
+    switch ((d >> 7) & 3) {\r
+      case 1:\r
+        pvid->debug_p &= ~(PVD_KILL_S_LO | PVD_KILL_S_HI);\r
+        pvid->debug_p |= PVD_FORCE_S;\r
+        break;\r
+      case 2:\r
+        pvid->debug_p &= ~PVD_KILL_A;\r
+        pvid->debug_p |= PVD_FORCE_A;\r
+        break;\r
+      case 3:\r
+        pvid->debug_p &= ~PVD_KILL_B;\r
+        pvid->debug_p |= PVD_FORCE_B;\r
+        break;\r
+    }\r
+    break;\r
   }\r
 }\r
 \r
-PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)\r
+static u32 SrLow(const struct PicoVideo *pv)\r
 {\r
-  a&=0x1c;\r
+  unsigned int c, d = pv->status;\r
 \r
-  if (a==0x04) // control port\r
-  {\r
-    struct PicoVideo *pv=&Pico.video;\r
-    unsigned int d;\r
-    d=pv->status;\r
-    //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)\r
-    if (SekCyclesDone() - line_base_cycles >= 488-88)\r
-      d|=0x0004; // H-Blank (Sonic3 vs)\r
-\r
-    d |= ((pv->reg[1]&0x40)^0x40) >> 3;  // set V-Blank if display is disabled\r
-    d |= (pv->pending_ints&0x20)<<2;     // V-int pending?\r
-    if (d&0x100) pv->status&=~0x100; // FIFO no longer full\r
+  c = SekCyclesDone() - Pico.t.m68c_line_start - 39;\r
+  if (c < 92)\r
+    d |= SR_HB;\r
+  return d;\r
+}\r
 \r
-    pv->pending = 0; // ctrl port reads clear write-pending flag (Charles MacDonald)\r
+PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)\r
+{\r
+  a &= 0x1c;\r
 \r
-    elprintf(EL_SR, "SR read: %04x @ %06x", d, SekPc);\r
+  if (a == 0x04) // control port\r
+  {\r
+    struct PicoVideo *pv = &Pico.video;\r
+    unsigned int d = SrLow(pv);\r
+    pv->pending = 0;\r
+    elprintf(EL_SR, "SR read: %04x [%u] @ %06x", d, SekCyclesDone(), SekPc);\r
     return d;\r
   }\r
 \r
@@ -490,12 +547,12 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)
   {\r
     unsigned int d;\r
 \r
-    d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME\r
+    d = (SekCyclesDone() - Pico.t.m68c_line_start) & 0x1ff; // FIXME\r
     if (Pico.video.reg[12]&1)\r
          d = hcounts_40[d];\r
     else d = hcounts_32[d];\r
 \r
-    elprintf(EL_HVCNT, "hv: %02x %02x (%i) @ %06x", d, Pico.video.v_counter, SekCyclesDone(), SekPc);\r
+    elprintf(EL_HVCNT, "hv: %02x %02x [%u] @ %06x", d, Pico.video.v_counter, SekCyclesDone(), SekPc);\r
     return d | (Pico.video.v_counter << 8);\r
   }\r
 \r
@@ -507,43 +564,47 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)
   return 0;\r
 }\r
 \r
-unsigned int PicoVideoRead8(unsigned int a)\r
+unsigned char PicoVideoRead8DataH(void)\r
 {\r
-  unsigned int d;\r
-  a&=0x1d;\r
+  return VideoRead() >> 8;\r
+}\r
 \r
-  switch (a)\r
-  {\r
-    case 0: return VideoRead() >> 8;\r
-    case 1: return VideoRead() & 0xff;\r
-    case 4: // control port/status reg\r
-      d = Pico.video.status >> 8;\r
-      if (d&1) Pico.video.status&=~0x100; // FIFO no longer full\r
-      Pico.video.pending = 0;\r
-      elprintf(EL_SR, "SR read (h): %02x @ %06x", d, SekPc);\r
-      return d;\r
-    case 5:\r
-      d = Pico.video.status & 0xff;\r
-      //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)\r
-      d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3;  // set V-Blank if display is disabled\r
-      d |= (Pico.video.pending_ints&0x20)<<2;     // V-int pending?\r
-      if (SekCyclesDone() - line_base_cycles >= 488-88) d |= 4;    // H-Blank\r
-      Pico.video.pending = 0;\r
-      elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc);\r
-      return d;\r
-    case 8: // hv counter\r
-      elprintf(EL_HVCNT, "vcounter: %02x (%i) @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc);\r
-      return Pico.video.v_counter;\r
-    case 9:\r
-      d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME\r
-      if (Pico.video.reg[12]&1)\r
-           d = hcounts_40[d];\r
-      else d = hcounts_32[d];\r
-      elprintf(EL_HVCNT, "hcounter: %02x (%i) @ %06x", d, SekCyclesDone(), SekPc);\r
-      return d;\r
-  }\r
+unsigned char PicoVideoRead8DataL(void)\r
+{\r
+  return VideoRead();\r
+}\r
 \r
-  return 0;\r
+unsigned char PicoVideoRead8CtlH(void)\r
+{\r
+  u8 d = (u8)(Pico.video.status >> 8);\r
+  Pico.video.pending = 0;\r
+  elprintf(EL_SR, "SR read (h): %02x @ %06x", d, SekPc);\r
+  return d;\r
+}\r
+\r
+unsigned char PicoVideoRead8CtlL(void)\r
+{\r
+  u8 d = SrLow(&Pico.video);\r
+  Pico.video.pending = 0;\r
+  elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc);\r
+  return d;\r
+}\r
+\r
+unsigned char PicoVideoRead8HV_H(void)\r
+{\r
+  elprintf(EL_HVCNT, "vcounter: %02x [%u] @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc);\r
+  return Pico.video.v_counter;\r
+}\r
+\r
+// FIXME: broken\r
+unsigned char PicoVideoRead8HV_L(void)\r
+{\r
+  u32 d = (SekCyclesDone() - Pico.t.m68c_line_start) & 0x1ff; // FIXME\r
+  if (Pico.video.reg[12]&1)\r
+       d = hcounts_40[d];\r
+  else d = hcounts_32[d];\r
+  elprintf(EL_HVCNT, "hcounter: %02x [%u] @ %06x", d, SekCyclesDone(), SekPc);\r
+  return d;\r
 }\r
 \r
 // vim:shiftwidth=2:ts=2:expandtab\r
index 33a8618..b69495e 100644 (file)
@@ -119,29 +119,6 @@ void z80_reset(void)
 #endif
 }
 
-/* save state stuff */
-static int z80_unpack_legacy(const void *data)
-{
-#if defined(_USE_DRZ80)
-  if (*(int *)data == 0x015A7244) { // "DrZ" v1 save?
-    u32 pc, sp;
-    memcpy(&drZ80, data+4, 0x54);
-    pc = (drZ80.Z80PC - drZ80.Z80PC_BASE) & 0xffff;
-    sp = (drZ80.Z80SP - drZ80.Z80SP_BASE) & 0xffff;
-    // update bases
-    drz80_load_pcsp(pc, sp);
-    return 0;
-  }
-#elif defined(_USE_CZ80)
-  if (*(int *)data == 0x00007a43) { // "Cz" save?
-    memcpy(&CZ80, (int*)data+8, offsetof(cz80_struc, BasePC));
-    Cz80_Set_Reg(&CZ80, CZ80_PC, *(int *)((int*)data+4));
-    return 0;
-  }
-#endif
-  return -1;
-}
-
 struct z80sr_main {
   u8 a, f;
   u8 b, c;
@@ -226,9 +203,7 @@ int z80_unpack(const void *data)
 {
   const struct z80_state *s = data;
   if (strcmp(s->magic, "Z80") != 0) {
-    if (z80_unpack_legacy(data) != 0)
-      goto fail;
-    elprintf(EL_STATUS, "legacy z80 state");
+    elprintf(EL_STATUS, "legacy z80 state - ignored");
     return 0;
   }
 
@@ -278,13 +253,9 @@ int z80_unpack(const void *data)
     Cz80_Set_Reg(&CZ80, CZ80_IRQ, s->irq_pending ? HOLD_LINE : CLEAR_LINE);
     return 0;
   }
+#else
+  return 0;
 #endif
-
-fail:
-  elprintf(EL_STATUS|EL_ANOMALY, "z80_unpack failed");
-  z80_reset();
-  z80_int();
-  return -1;
 }
 
 void z80_exit(void)
index c8571ac..89e4605 100644 (file)
@@ -49,7 +49,7 @@ SRCS_COMMON += $(R)pico/draw_arm.S $(R)pico/draw2_arm.S
 endif
 ifeq "$(asm_memory)" "1"
 DEFINES += _ASM_MEMORY_C
-SRCS_COMMON += $(R)pico/memory_arm.s
+SRCS_COMMON += $(R)pico/memory_arm.S
 endif
 ifeq "$(asm_ym2612)" "1"
 DEFINES += _ASM_YM2612_C
@@ -62,7 +62,7 @@ SRCS_COMMON += $(R)pico/cd/misc_arm.s
 endif
 ifeq "$(asm_cdmemory)" "1"
 DEFINES += _ASM_CD_MEMORY_C
-SRCS_COMMON += $(R)pico/cd/memory_arm.s
+SRCS_COMMON += $(R)pico/cd/memory_arm.S
 endif
 ifeq "$(asm_32xdraw)" "1"
 DEFINES += _ASM_32X_DRAW
@@ -87,23 +87,24 @@ else
 DEFINES += NO_SMS
 endif
 # CD
-SRCS_COMMON += $(R)pico/cd/mcd.c $(R)pico/cd/cd_memory.c $(R)pico/cd/cd_sek.c \
+SRCS_COMMON += $(R)pico/cd/mcd.c $(R)pico/cd/memory.c $(R)pico/cd/sek.c \
        $(R)pico/cd/cdc.c $(R)pico/cd/cdd.c $(R)pico/cd/cd_image.c \
        $(R)pico/cd/cue.c $(R)pico/cd/gfx.c $(R)pico/cd/gfx_dma.c \
-       $(R)pico/cd/cd_misc.c $(R)pico/cd/pcm.c
+       $(R)pico/cd/misc.c $(R)pico/cd/pcm.c
 # 32X
 ifneq "$(no_32x)" "1"
-SRCS_COMMON += $(R)pico/32x/32x.c $(R)pico/32x/32x_memory.c $(R)pico/32x/32x_draw.c \
+SRCS_COMMON += $(R)pico/32x/32x.c $(R)pico/32x/memory.c $(R)pico/32x/draw.c \
        $(R)pico/32x/sh2soc.c $(R)pico/32x/pwm.c
 else
 DEFINES += NO_32X
 endif
 # Pico
-SRCS_COMMON += $(R)pico/pico/pico_pico.c $(R)pico/pico/pico_memory.c $(R)pico/pico/xpcm.c
+SRCS_COMMON += $(R)pico/pico/pico.c $(R)pico/pico/memory.c $(R)pico/pico/xpcm.c
 # carthw
 SRCS_COMMON += $(R)pico/carthw/carthw.c
+SRCS_COMMON += $(R)pico/carthw/eeprom_spi.c
 # SVP
-SRCS_COMMON += $(R)pico/carthw/svp/svp.c $(R)pico/carthw/svp/svp_memory.c \
+SRCS_COMMON += $(R)pico/carthw/svp/svp.c $(R)pico/carthw/svp/memory.c \
        $(R)pico/carthw/svp/ssp16.c
 ifeq "$(use_svpdrc)" "1"
 DEFINES += _SVP_DRC
@@ -172,13 +173,15 @@ ifeq "$(use_cyclone)" "1"
 $(FR)pico/pico.c: $(FR)cpu/cyclone/Cyclone.h
 endif
 
+CYCLONE_CONFIG ?= cyclone_config.h
+
 $(FR)cpu/cyclone/Cyclone.h:
        @echo "Cyclone submodule is missing, please run 'git submodule update --init'"
        @false
 
-$(FR)cpu/cyclone/Cyclone.s: $(FR)cpu/cyclone_config.h
+$(FR)cpu/cyclone/Cyclone.s: $(FR)cpu/$(CYCLONE_CONFIG)
        @echo building Cyclone...
-       @make -C $(R)cpu/cyclone/ CONFIG_FILE=../cyclone_config.h
+       @make -C $(R)cpu/cyclone/ CONFIG_FILE=../$(CYCLONE_CONFIG)
 
 $(FR)cpu/cyclone/Cyclone.s: $(FR)cpu/cyclone/*.cpp $(FR)cpu/cyclone/*.h
 
index 97369cb..e66d4e1 100644 (file)
@@ -417,7 +417,7 @@ static void keys_parse_all(FILE *f)
                acts = parse_bind_val(val, &type);
                if (acts == -1) {
                        lprintf("config: unhandled action \"%s\"\n", val);
-                       return;
+                       continue;
                }
 
                mystrip(var + 5);
index 6f42b73..85e1ba7 100644 (file)
@@ -889,20 +889,20 @@ int emu_save_load_game(int load, int sram)
                {\r
                        if (PicoOpt & POPT_EN_MCD_RAMCART) {\r
                                sram_size = 0x12000;\r
-                               sram_data = SRam.data;\r
+                               sram_data = Pico.sv.data;\r
                                if (sram_data)\r
-                                       memcpy32((int *)sram_data, (int *)Pico_mcd->bram, 0x2000/4);\r
+                                       memcpy(sram_data, Pico_mcd->bram, 0x2000);\r
                        } else {\r
                                sram_size = 0x2000;\r
                                sram_data = Pico_mcd->bram;\r
                                truncate  = 0; // the .brm may contain RAM cart data after normal brm\r
                        }\r
                } else {\r
-                       sram_size = SRam.size;\r
-                       sram_data = SRam.data;\r
+                       sram_size = Pico.sv.size;\r
+                       sram_data = Pico.sv.data;\r
                }\r
                if (sram_data == NULL)\r
-                       return 0; // SRam forcefully disabled for this game\r
+                       return 0; // cart saves forcefully disabled for this game\r
 \r
                if (load)\r
                {\r
@@ -913,7 +913,7 @@ int emu_save_load_game(int load, int sram)
                        ret = ret > 0 ? 0 : -1;\r
                        fclose(sramFile);\r
                        if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART))\r
-                               memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4);\r
+                               memcpy(Pico_mcd->bram, sram_data, 0x2000);\r
                } else {\r
                        // sram save needs some special processing\r
                        // see if we have anything to save\r
@@ -973,6 +973,9 @@ void emu_set_fastforward(int set_on)
                currentConfig.EmuOpt = set_EmuOpt;\r
                PsndRerate(1);\r
                is_on = 0;\r
+               // mainly to unbreak pcm\r
+               if (PicoAHW & PAHW_MCD)\r
+                       pcd_state_loaded();\r
        }\r
 }\r
 \r
@@ -1138,6 +1141,8 @@ static void run_events_ui(unsigned int which)
                emu_status_msg("SAVE SLOT %i [%s]", state_slot,\r
                        emu_check_save_file(state_slot, NULL) ? "USED" : "FREE");\r
        }\r
+       if (which & PEV_RESET)\r
+               emu_reset_game();\r
        if (which & PEV_MENU)\r
                engineState = PGS_Menu;\r
 }\r
@@ -1257,9 +1262,9 @@ void emu_init(void)
 void emu_finish(void)\r
 {\r
        // save SRAM\r
-       if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && SRam.changed) {\r
+       if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && Pico.sv.changed) {\r
                emu_save_load_game(0, 1);\r
-               SRam.changed = 0;\r
+               Pico.sv.changed = 0;\r
        }\r
 \r
        if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG)) {\r
@@ -1509,10 +1514,10 @@ void emu_loop(void)
        emu_set_fastforward(0);\r
 \r
        // save SRAM\r
-       if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && SRam.changed) {\r
+       if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && Pico.sv.changed) {\r
                plat_status_msg_busy_first("Writing SRAM/BRAM...");\r
                emu_save_load_game(0, 1);\r
-               SRam.changed = 0;\r
+               Pico.sv.changed = 0;\r
        }\r
 \r
        pemu_loop_end();\r
index c2730b5..c0501d3 100644 (file)
@@ -28,6 +28,7 @@
 #define PEVB_PICO_PNEXT 21
 #define PEVB_PICO_PPREV 20
 #define PEVB_PICO_SWINP 19
+#define PEVB_RESET      18
 
 #define PEV_VOL_DOWN    (1 << PEVB_VOL_DOWN)
 #define PEV_VOL_UP      (1 << PEVB_VOL_UP)
@@ -41,7 +42,8 @@
 #define PEV_PICO_PNEXT  (1 << PEVB_PICO_PNEXT)
 #define PEV_PICO_PPREV  (1 << PEVB_PICO_PPREV)
 #define PEV_PICO_SWINP  (1 << PEVB_PICO_SWINP)
+#define PEV_RESET       (1 << PEVB_RESET)
 
-#define PEV_MASK 0x7ff80000
+#define PEV_MASK 0x7ffc0000
 
 #endif /* INCLUDE_c48097f3ff2a6a9af1cce8fd7a9b3f0c */
index b127077..0f9fa61 100644 (file)
@@ -14,7 +14,7 @@
 #include "input_pico.h"
 #include "version.h"
 
-#include <pico/pico.h>
+#include <pico/pico_int.h>
 #include <pico/patch.h>
 
 #ifdef PANDORA
@@ -312,6 +312,7 @@ me_bind_action emuctrl_actions[] =
        { "Volume Down      ", PEV_VOL_DOWN },
        { "Volume Up        ", PEV_VOL_UP },
        { "Fast forward     ", PEV_FF },
+       { "Reset Game       ", PEV_RESET },
        { "Enter Menu       ", PEV_MENU },
        { "Pico Next page   ", PEV_PICO_PNEXT },
        { "Pico Prev page   ", PEV_PICO_PPREV },
@@ -405,8 +406,6 @@ static const char h_srcart[] = "Emulate the save RAM cartridge accessory\n"
                                "most games don't need this";
 static const char h_scfx[]   = "Emulate scale/rotate ASIC chip for graphics effects\n"
                                "disable to improve performance";
-static const char h_bsync[]  = "More accurate mode for CPUs (needed for some games)\n"
-                               "disable to improve performance";
 
 static menu_entry e_menu_cd_options[] =
 {
@@ -803,11 +802,13 @@ static void draw_text_debug(const char *str, int skip, int from)
 static void draw_frame_debug(void)
 {
        char layer_str[48] = "layers:                   ";
-       if (PicoDrawMask & PDRAW_LAYERB_ON)      memcpy(layer_str +  8, "B", 1);
-       if (PicoDrawMask & PDRAW_LAYERA_ON)      memcpy(layer_str + 10, "A", 1);
-       if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) memcpy(layer_str + 12, "spr_lo", 6);
-       if (PicoDrawMask & PDRAW_SPRITES_HI_ON)  memcpy(layer_str + 19, "spr_hi", 6);
-       if (PicoDrawMask & PDRAW_32X_ON)         memcpy(layer_str + 26, "32x", 4);
+       struct PicoVideo *pv = &Pico.video;
+
+       if (!(pv->debug_p & PVD_KILL_B))    memcpy(layer_str +  8, "B", 1);
+       if (!(pv->debug_p & PVD_KILL_A))    memcpy(layer_str + 10, "A", 1);
+       if (!(pv->debug_p & PVD_KILL_S_LO)) memcpy(layer_str + 12, "spr_lo", 6);
+       if (!(pv->debug_p & PVD_KILL_S_HI)) memcpy(layer_str + 19, "spr_hi", 6);
+       if (!(pv->debug_p & PVD_KILL_32X))  memcpy(layer_str + 26, "32x", 4);
 
        pemu_forced_frame(1, 0);
        make_bg(1);
@@ -818,6 +819,7 @@ static void draw_frame_debug(void)
 
 static void debug_menu_loop(void)
 {
+       struct PicoVideo *pv = &Pico.video;
        int inp, mode = 0;
        int spr_offs = 0, dumped = 0;
        char *tmp;
@@ -878,11 +880,11 @@ static void debug_menu_loop(void)
                                }
                                break;
                        case 1:
-                               if (inp & PBTN_LEFT)  PicoDrawMask ^= PDRAW_LAYERB_ON;
-                               if (inp & PBTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON;
-                               if (inp & PBTN_DOWN)  PicoDrawMask ^= PDRAW_SPRITES_LOW_ON;
-                               if (inp & PBTN_UP)    PicoDrawMask ^= PDRAW_SPRITES_HI_ON;
-                               if (inp & PBTN_MA2)   PicoDrawMask ^= PDRAW_32X_ON;
+                               if (inp & PBTN_LEFT)  pv->debug_p ^= PVD_KILL_B;
+                               if (inp & PBTN_RIGHT) pv->debug_p ^= PVD_KILL_A;
+                               if (inp & PBTN_DOWN)  pv->debug_p ^= PVD_KILL_S_LO;
+                               if (inp & PBTN_UP)    pv->debug_p ^= PVD_KILL_S_HI;
+                               if (inp & PBTN_MA2)   pv->debug_p ^= PVD_KILL_32X;
                                if (inp & PBTN_MOK) {
                                        PsndOut = NULL; // just in case
                                        PicoSkipFrame = 1;
index 01ac782..b2bcaf4 100644 (file)
@@ -8,8 +8,8 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "../../pico/pico_int.h"
-#include "../../pico/sound/mix.h"
+#include <pico/pico_int.h>
+#include <pico/sound/mix.h>
 #include "mp3.h"
 
 static FILE *mp3_current_file;
index 2d3c799..9a528c1 100644 (file)
 #include "../libpicofe/lprintf.h"
 #include "mp3.h"
 
+#if LIBAVCODEC_VERSION_MAJOR < 55
+#define AVCodecID CodecID
+#define AV_CODEC_ID_MP3 CODEC_ID_MP3
+#endif
+
 static AVCodecContext *ctx;
 
 /* avoid compile time linking to libavcodec due to huge list of it's deps..
@@ -94,7 +99,7 @@ int mp3dec_decode(FILE *f, int *file_pos, int file_len)
 int mp3dec_start(FILE *f, int fpos_start)
 {
        void (*avcodec_register_all)(void);
-       AVCodec *(*avcodec_find_decoder)(enum CodecID id);
+       AVCodec *(*avcodec_find_decoder)(enum AVCodecID id);
        AVCodecContext *(*avcodec_alloc_context)(void);
        int (*avcodec_open)(AVCodecContext *avctx, AVCodec *codec);
        void (*av_free)(void *ptr);
@@ -137,8 +142,7 @@ int mp3dec_start(FILE *f, int fpos_start)
        //avcodec_init();
        avcodec_register_all();
 
-       // AV_CODEC_ID_MP3 ?
-       codec = avcodec_find_decoder(CODEC_ID_MP3);
+       codec = avcodec_find_decoder(AV_CODEC_ID_MP3);
        if (codec == NULL) {
                lprintf("mp3dec: codec missing\n");
                return -1;
index 3387b95..1b617d5 100644 (file)
@@ -35,6 +35,7 @@ const struct in_default_bind in_sdl_defbinds[] __attribute__((weak)) = {
        { SDLK_RETURN, IN_BINDTYPE_PLAYER12, GBTN_START },
        { SDLK_f,      IN_BINDTYPE_PLAYER12, GBTN_MODE },
        { SDLK_ESCAPE, IN_BINDTYPE_EMU, PEVB_MENU },
+       { SDLK_TAB,    IN_BINDTYPE_EMU, PEVB_RESET },
        { SDLK_F1,     IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
        { SDLK_F2,     IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
        { SDLK_F3,     IN_BINDTYPE_EMU, PEVB_SSLOT_PREV },
index 01e9b7d..ce4223b 100644 (file)
@@ -1 +1 @@
-#define VERSION "1.91"\r
+#define VERSION "1.92"\r
index 6ba13bd..ff79c88 100644 (file)
@@ -391,7 +391,7 @@ int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
        ym_active_chs = shared_ctl->ym_active_chs;\r
 \r
        // mix in ym buffer. is_buf_empty means nobody mixed there anything yet and it may contain trash\r
-       if (is_buf_empty && ym_active_chs) memcpy32(buffer, ym_buf, length<<stereo);\r
+       if (is_buf_empty && ym_active_chs) memcpy(buffer, ym_buf, length << (stereo + 2));\r
        else memset32(buffer, 0, length<<stereo);\r
 \r
        if (shared_ctl->writebuffsel == 1) {\r
index c0bc71f..01fd162 100644 (file)
@@ -280,7 +280,7 @@ static int EmuScanEnd16_ld(unsigned int num)
                ld_left = ld_lines;\r
 \r
                EmuScanBegin16_ld(num);\r
-               memcpy32(Pico.est.DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4);\r
+               memcpy(Pico.est.DrawLineDest, oldline, 320 * gp2x_current_bpp / 8);\r
                if (emu_scan_end)\r
                        emu_scan_end(ld_counter);\r
 \r
@@ -315,7 +315,7 @@ static int make_local_pal_md(int fast_mode)
                bgr444_to_rgb32(localPal+0x80, Pico.est.HighPal+0x40);\r
        }\r
        else\r
-               memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess\r
+               memcpy(localPal + 0x80, localPal, 0x40 * 4); // for spr prio mess\r
 \r
        return pallen;\r
 }\r
index 21604a0..f287890 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 21604a047941b8fe81d381ede0371c75da964afd
+Subproject commit f287890d65ad36ca75bb71d05745693ae78b1490
index 934b685..7896ffb 100644 (file)
@@ -98,6 +98,7 @@ void cache_flush_d_inval_i(void *start, void *end)
 {
 #ifdef __arm__
    size_t len = (char *)end - (char *)start;
+   (void)len;
 #if defined(__BLACKBERRY_QNX__)
    msync(start, end - start, MS_SYNC | MS_CACHE_ONLY | MS_INVALIDATE_ICACHE);
 #elif defined(__MACH__)
@@ -435,14 +436,25 @@ void plat_munmap(void *ptr, size_t size)
 }
 #endif
 
+// if NULL is returned, static buffer is used
+void *plat_mem_get_for_drc(size_t size)
+{
+   void *mem = NULL;
+#ifdef VITA
+   sceKernelGetMemBlockBase(sceBlock, &mem);
+#endif
+   return mem;
+}
+
 int plat_mem_set_exec(void *ptr, size_t size)
 {
+   int ret = -1;
 #ifdef _WIN32
-   int ret = VirtualProtect(ptr,size,PAGE_EXECUTE_READWRITE,0);
+   ret = VirtualProtect(ptr, size, PAGE_EXECUTE_READWRITE, 0);
    if (ret == 0 && log_cb)
-      log_cb(RETRO_LOG_ERROR, "mprotect(%p, %zd) failed: %d\n", ptr, size, 0);
+      log_cb(RETRO_LOG_ERROR, "VirtualProtect(%p, %d) failed: %d\n", ptr, (int)size,
+             GetLastError());
 #elif defined(_3DS)
-   int ret = -1;
    if (ctr_svchack_successful)
    {
       unsigned int currentHandle;
@@ -461,9 +473,9 @@ int plat_mem_set_exec(void *ptr, size_t size)
    }
 
 #elif defined(VITA)
-   int ret = sceKernelOpenVMDomain();
+   ret = sceKernelOpenVMDomain();
 #else
-   int ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC);
+   ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC);
    if (ret != 0 && log_cb)
       log_cb(RETRO_LOG_ERROR, "mprotect(%p, %zd) failed: %d\n", ptr, size, errno);
 #endif
@@ -472,6 +484,8 @@ int plat_mem_set_exec(void *ptr, size_t size)
 
 void emu_video_mode_change(int start_line, int line_count, int is_32cols)
 {
+   struct retro_system_av_info av_info;
+
    memset(vout_buf, 0, 320 * 240 * 2);
    vout_width = is_32cols ? 256 : 320;
    PicoDrawSetOutBuf(vout_buf, vout_width * 2);
@@ -482,7 +496,6 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols)
    vout_offset = vout_width * start_line;
 
    // Update the geometry
-   struct retro_system_av_info av_info;
    retro_get_system_av_info(&av_info);
    environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &av_info);
 }
@@ -512,7 +525,6 @@ void retro_set_environment(retro_environment_t cb)
       { "picodrive_sprlim",      "No sprite limit; disabled|enabled" },
       { "picodrive_ramcart",     "MegaCD RAM cart; disabled|enabled" },
       { "picodrive_region",      "Region; Auto|Japan NTSC|Japan PAL|US|Europe" },
-      { "picodrive_region_fps",  "Region FPS; Auto|NTSC|PAL" },
       { "picodrive_aspect",      "Core-provided aspect ratio; PAR|4/3|CRT" },
       { "picodrive_overscan",    "Show Overscan; disabled|enabled" },
 #ifdef DRC_SH2
@@ -555,6 +567,8 @@ void retro_get_system_info(struct retro_system_info *info)
 
 void retro_get_system_av_info(struct retro_system_av_info *info)
 {
+   float common_width;
+
    memset(info, 0, sizeof(*info));
    info->timing.fps            = Pico.m.pal ? 50 : 60;
    info->timing.sample_rate    = 44100;
@@ -563,7 +577,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
    info->geometry.max_width    = vout_width;
    info->geometry.max_height   = vout_height;
 
-   float common_width = vout_width;
+   common_width = vout_width;
    if (user_vout_width != 0)
       common_width = user_vout_width;
 
@@ -959,22 +973,6 @@ static const char *find_bios(int *region, const char *cd_fname)
    return NULL;
 }
 
-static void sram_reset()
-{
-   SRam.data = NULL;
-   SRam.start = 0;
-   SRam.end = 0;
-   SRam.flags = '\0';
-   SRam.unused2 = '\0';
-   SRam.changed = '\0' ;
-   SRam.eeprom_type = '\0';
-   SRam.unused3 = '\0';
-   SRam.eeprom_bit_cl = '\0';
-   SRam.eeprom_bit_in = '\0';
-   SRam.eeprom_bit_out = '\0';
-   SRam.size = 0;
-}
-
 bool retro_load_game(const struct retro_game_info *info)
 {
    enum media_type_e media_type;
@@ -1031,8 +1029,6 @@ bool retro_load_game(const struct retro_game_info *info)
       { 0 },
    };
 
-   sram_reset();
-
    enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
    if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) {
       if (log_cb)
@@ -1122,13 +1118,13 @@ void *retro_get_memory_data(unsigned type)
          if (PicoAHW & PAHW_MCD)
             data = Pico_mcd->bram;
          else
-            data = SRam.data;
+            data = Pico.sv.data;
          break;
       case RETRO_MEMORY_SYSTEM_RAM:
          if (PicoAHW & PAHW_SMS)
-            data = Pico.zram;
+            data = PicoMem.zram;
          else
-            data = Pico.ram;
+            data = PicoMem.ram;
          break;
       default:
          data = NULL;
@@ -1151,20 +1147,20 @@ size_t retro_get_memory_size(unsigned type)
             return 0x2000;
 
          if (Pico.m.frame_count == 0)
-            return SRam.size;
+            return Pico.sv.size;
 
          // if game doesn't write to sram, don't report it to
          // libretro so that RA doesn't write out zeroed .srm
-         for (i = 0, sum = 0; i < SRam.size; i++)
-            sum |= SRam.data[i];
+         for (i = 0, sum = 0; i < Pico.sv.size; i++)
+            sum |= Pico.sv.data[i];
 
-         return (sum != 0) ? SRam.size : 0;
+         return (sum != 0) ? Pico.sv.size : 0;
 
       case RETRO_MEMORY_SYSTEM_RAM:
          if (PicoAHW & PAHW_SMS)
             return 0x2000;
          else
-            return sizeof(Pico.ram);
+            return sizeof(PicoMem.ram);
 
       default:
          return 0;
@@ -1215,6 +1211,8 @@ static enum input_device input_name_to_val(const char *name)
 static void update_variables(void)
 {
    struct retro_variable var;
+   int OldPicoRegionOverride;
+   float old_user_vout_width;
 
    var.value = NULL;
    var.key = "picodrive_input1";
@@ -1244,7 +1242,7 @@ static void update_variables(void)
          PicoOpt &= ~POPT_EN_MCD_RAMCART;
    }
 
-   int OldPicoRegionOverride = PicoRegionOverride;
+   OldPicoRegionOverride = PicoRegionOverride;
    var.value = NULL;
    var.key = "picodrive_region";
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
@@ -1260,28 +1258,15 @@ static void update_variables(void)
          PicoRegionOverride = 8;
    }
 
-   int OldPicoRegionFPSOverride = PicoRegionFPSOverride;
-   var.value = NULL;
-   var.key = "picodrive_region_fps";
-   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
-      if (strcmp(var.value, "Auto") == 0)
-         PicoRegionFPSOverride = 0;
-      else if (strcmp(var.value, "NTSC") == 0)
-         PicoRegionFPSOverride = 1;
-      else if (strcmp(var.value, "PAL") == 0)
-         PicoRegionFPSOverride = 2;
-   }
-
    // Update region, fps and sound flags if needed
-   if (PicoRegionOverride    != OldPicoRegionOverride ||
-       PicoRegionFPSOverride != OldPicoRegionFPSOverride)
+   if (Pico.rom && PicoRegionOverride != OldPicoRegionOverride)
    {
       PicoDetectRegion();
       PicoLoopPrepare();
       PsndRerate(1);
    }
 
-   float old_user_vout_width = user_vout_width;
+   old_user_vout_width = user_vout_width;
    var.value = NULL;
    var.key = "picodrive_aspect";
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
@@ -1349,13 +1334,6 @@ void retro_run(void)
       vout_width, vout_height, vout_width * 2);
 }
 
-static void check_system_specs(void)
-{
-   /* TODO - set different performance level for 32X - 6 for ARM dynarec, higher for interpreter core */
-   unsigned level = 5;
-   environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level);
-}
-
 void retro_init(void)
 {
    struct retro_log_callback log;
@@ -1419,3 +1397,5 @@ void retro_deinit(void)
    vout_buf = NULL;
    PicoExit();
 }
+
+// vim:shiftwidth=3:ts=3:expandtab
diff --git a/platform/libretro/msvc/msvc-2010/msvc-2010.suo b/platform/libretro/msvc/msvc-2010/msvc-2010.suo
deleted file mode 100644 (file)
index e2d4612..0000000
Binary files a/platform/libretro/msvc/msvc-2010/msvc-2010.suo and /dev/null differ
index b6a7611..e9bde07 100644 (file)
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{D4156C25-0E30-4407-9198-1F51EF74AA84}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>msvc2010</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-    <OutDir>$(SolutionDir)msvc-2010\$(Configuration)\</OutDir>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-    <OutDir>$(SolutionDir)msvc-2010\$(Configuration)\</OutDir>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);INLINE=_inline;_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;NO_ZLIB;FAMEC_NO_GOTOS</PreprocessorDefinitions>
-      <CompileAs>CompileAsC</CompileAs>
-      <AdditionalIncludeDirectories>$(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <ModuleDefinitionFile>libretro.def</ModuleDefinitionFile>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);INLINE=_inline;_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;NO_ZLIB;FAMEC_NO_GOTOS</PreprocessorDefinitions>
-      <CompileAs>CompileAsC</CompileAs>
-      <AdditionalIncludeDirectories>$(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <ModuleDefinitionFile>libretro.def</ModuleDefinitionFile>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\..\..\cpu\cz80\cz80.c" />
-    <ClCompile Include="..\..\..\..\cpu\drc\cmn.c" />
-    <ClCompile Include="..\..\..\..\cpu\fame\famec.c" />
-    <ClCompile Include="..\..\..\..\cpu\sh2\mame\sh2pico.c" />
-    <ClCompile Include="..\..\..\..\cpu\sh2\sh2.c" />
-    <ClCompile Include="..\..\..\..\pico\32x\32x.c" />
-    <ClCompile Include="..\..\..\..\pico\32x\32x_draw.c" />
-    <ClCompile Include="..\..\..\..\pico\32x\32x_memory.c" />
-    <ClCompile Include="..\..\..\..\pico\32x\pwm.c" />
-    <ClCompile Include="..\..\..\..\pico\32x\sh2soc.c" />
-    <ClCompile Include="..\..\..\..\pico\cart.c" />
-    <ClCompile Include="..\..\..\..\pico\carthw\carthw.c" />
-    <ClCompile Include="..\..\..\..\pico\carthw\svp\svp_memory.c" />
-    <ClCompile Include="..\..\..\..\pico\carthw\svp\ssp16.c" />
-    <ClCompile Include="..\..\..\..\pico\carthw\svp\svp.c" />
-    <ClCompile Include="..\..\..\..\pico\carthw_cfg.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\cdc.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\cdd.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\cd_image.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\cell_map.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\cue.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\gfx.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\gfx_dma.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\mcd.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\cd_memory.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\cd_misc.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\pcm.c" />
-    <ClCompile Include="..\..\..\..\pico\cd\cd_sek.c" />
-    <ClCompile Include="..\..\..\..\pico\debug.c" />
-    <ClCompile Include="..\..\..\..\pico\draw.c" />
-    <ClCompile Include="..\..\..\..\pico\draw2.c" />
-    <ClCompile Include="..\..\..\..\pico\eeprom.c" />
-    <ClCompile Include="..\..\..\..\pico\media.c" />
-    <ClCompile Include="..\..\..\..\pico\memory.c" />
-    <ClCompile Include="..\..\..\..\pico\misc.c" />
-    <ClCompile Include="..\..\..\..\pico\mode4.c" />
-    <ClCompile Include="..\..\..\..\pico\patch.c" />
-    <ClCompile Include="..\..\..\..\pico\pico.c" />
-    <ClCompile Include="..\..\..\..\pico\pico\pico_memory.c" />
-    <ClCompile Include="..\..\..\..\pico\pico\pico_pico.c" />
-    <ClCompile Include="..\..\..\..\pico\pico\xpcm.c" />
-    <ClCompile Include="..\..\..\..\pico\sek.c" />
-    <ClCompile Include="..\..\..\..\pico\sms.c" />
-    <ClCompile Include="..\..\..\..\pico\sound\mix.c" />
-    <ClCompile Include="..\..\..\..\pico\sound\sn76496.c" />
-    <ClCompile Include="..\..\..\..\pico\sound\sound.c" />
-    <ClCompile Include="..\..\..\..\pico\sound\ym2612.c" />
-    <ClCompile Include="..\..\..\..\pico\state.c" />
-    <ClCompile Include="..\..\..\..\pico\videoport.c" />
-    <ClCompile Include="..\..\..\..\pico\z80if.c" />
-    <ClCompile Include="..\..\..\..\unzip\unzip.c" />
-    <ClCompile Include="..\..\..\..\unzip\unzip_stream.c" />
-    <ClCompile Include="..\..\..\..\zlib\adler32.c" />
-    <ClCompile Include="..\..\..\..\zlib\compress.c" />
-    <ClCompile Include="..\..\..\..\zlib\crc32.c" />
-    <ClCompile Include="..\..\..\..\zlib\deflate.c" />
-    <ClCompile Include="..\..\..\..\zlib\example.c" />
-    <ClCompile Include="..\..\..\..\zlib\gzio.c" />
-    <ClCompile Include="..\..\..\..\zlib\infback.c" />
-    <ClCompile Include="..\..\..\..\zlib\inffast.c" />
-    <ClCompile Include="..\..\..\..\zlib\inflate.c" />
-    <ClCompile Include="..\..\..\..\zlib\inftrees.c" />
-    <ClCompile Include="..\..\..\..\zlib\trees.c" />
-    <ClCompile Include="..\..\..\..\zlib\uncompr.c" />
-    <ClCompile Include="..\..\..\..\zlib\zutil.c" />
-    <ClCompile Include="..\..\..\common\mp3.c" />
-    <ClCompile Include="..\..\..\common\mp3_dummy.c" />
-    <ClCompile Include="..\..\libretro.c" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectGuid>{D4156C25-0E30-4407-9198-1F51EF74AA84}</ProjectGuid>\r
+    <Keyword>Win32Proj</Keyword>\r
+    <RootNamespace>msvc2010</RootNamespace>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <UseDebugLibraries>true</UseDebugLibraries>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <UseDebugLibraries>false</UseDebugLibraries>\r
+    <WholeProgramOptimization>true</WholeProgramOptimization>\r
+    <CharacterSet>Unicode</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <LinkIncremental>true</LinkIncremental>\r
+    <OutDir>$(SolutionDir)msvc-2010\$(Configuration)\</OutDir>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <LinkIncremental>false</LinkIncremental>\r
+    <OutDir>$(SolutionDir)msvc-2010\$(Configuration)\</OutDir>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <Optimization>Disabled</Optimization>\r
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;FAMEC_NO_GOTOS</PreprocessorDefinitions>\r
+      <CompileAs>CompileAsC</CompileAs>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;$(SolutionDIr)\..\..\..\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <DisableSpecificWarnings>4018;4090;4101;4146;4244</DisableSpecificWarnings>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Windows</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <ModuleDefinitionFile>libretro.def</ModuleDefinitionFile>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <WarningLevel>Level3</WarningLevel>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+      <Optimization>MaxSpeed</Optimization>\r
+      <FunctionLevelLinking>true</FunctionLevelLinking>\r
+      <IntrinsicFunctions>true</IntrinsicFunctions>\r
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MSVC2010_EXPORTS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;EMU_F68K;_USE_CZ80;FAMEC_NO_GOTOS</PreprocessorDefinitions>\r
+      <CompileAs>CompileAsC</CompileAs>\r
+      <AdditionalIncludeDirectories>$(SolutionDir)\..\..\..\;$(SolutionDIr)\..\..\..\pico;$(SolutionDIr)\..\..\..\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+      <DisableSpecificWarnings>4018;4090;4101;4146;4244</DisableSpecificWarnings>\r
+    </ClCompile>\r
+    <Link>\r
+      <SubSystem>Windows</SubSystem>\r
+      <GenerateDebugInformation>true</GenerateDebugInformation>\r
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+      <OptimizeReferences>true</OptimizeReferences>\r
+      <ModuleDefinitionFile>libretro.def</ModuleDefinitionFile>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\..\..\cpu\cz80\cz80.c" />\r
+    <ClCompile Include="..\..\..\..\cpu\drc\cmn.c" />\r
+    <ClCompile Include="..\..\..\..\cpu\fame\famec.c" />\r
+    <ClCompile Include="..\..\..\..\cpu\sh2\mame\sh2pico.c" />\r
+    <ClCompile Include="..\..\..\..\cpu\sh2\sh2.c" />\r
+    <ClCompile Include="..\..\..\..\pico\32x\32x.c" />\r
+    <ClCompile Include="..\..\..\..\pico\32x\draw.c">\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)\32x\</ObjectFileName>\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)\32x\</ObjectFileName>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\32x\memory.c">\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)\32x\</ObjectFileName>\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)\32x\</ObjectFileName>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\32x\pwm.c" />\r
+    <ClCompile Include="..\..\..\..\pico\32x\sh2soc.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cart.c" />\r
+    <ClCompile Include="..\..\..\..\pico\carthw\carthw.c" />\r
+    <ClCompile Include="..\..\..\..\pico\carthw\eeprom_spi.c" />\r
+    <ClCompile Include="..\..\..\..\pico\carthw\svp\memory.c">\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)\svp\</ObjectFileName>\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)\svp\</ObjectFileName>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\carthw\svp\ssp16.c" />\r
+    <ClCompile Include="..\..\..\..\pico\carthw\svp\svp.c" />\r
+    <ClCompile Include="..\..\..\..\pico\carthw_cfg.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\cdc.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\cdd.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\cd_image.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\cell_map.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\cue.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\gfx.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\gfx_dma.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\mcd.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\memory.c">\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)\cd\</ObjectFileName>\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)\cd\</ObjectFileName>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\misc.c">\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)\cd\</ObjectFileName>\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)\cd\</ObjectFileName>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\pcm.c" />\r
+    <ClCompile Include="..\..\..\..\pico\cd\sek.c">\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)\cd\</ObjectFileName>\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)\cd\</ObjectFileName>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\debug.c" />\r
+    <ClCompile Include="..\..\..\..\pico\draw.c" />\r
+    <ClCompile Include="..\..\..\..\pico\draw2.c" />\r
+    <ClCompile Include="..\..\..\..\pico\eeprom.c" />\r
+    <ClCompile Include="..\..\..\..\pico\media.c" />\r
+    <ClCompile Include="..\..\..\..\pico\memory.c" />\r
+    <ClCompile Include="..\..\..\..\pico\misc.c" />\r
+    <ClCompile Include="..\..\..\..\pico\mode4.c" />\r
+    <ClCompile Include="..\..\..\..\pico\patch.c" />\r
+    <ClCompile Include="..\..\..\..\pico\pico.c" />\r
+    <ClCompile Include="..\..\..\..\pico\pico\memory.c">\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)\pico\</ObjectFileName>\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)\pico\</ObjectFileName>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\pico\pico.c">\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)\pico\</ObjectFileName>\r
+      <ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntDir)\pico\</ObjectFileName>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\pico\xpcm.c" />\r
+    <ClCompile Include="..\..\..\..\pico\sek.c" />\r
+    <ClCompile Include="..\..\..\..\pico\sms.c" />\r
+    <ClCompile Include="..\..\..\..\pico\sound\mix.c" />\r
+    <ClCompile Include="..\..\..\..\pico\sound\sn76496.c" />\r
+    <ClCompile Include="..\..\..\..\pico\sound\sound.c" />\r
+    <ClCompile Include="..\..\..\..\pico\sound\ym2612.c" />\r
+    <ClCompile Include="..\..\..\..\pico\state.c" />\r
+    <ClCompile Include="..\..\..\..\pico\videoport.c" />\r
+    <ClCompile Include="..\..\..\..\pico\z80if.c" />\r
+    <ClCompile Include="..\..\..\..\unzip\unzip.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\adler32.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\compress.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\crc32.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\deflate.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\example.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\gzio.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\infback.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\inffast.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\inflate.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\inftrees.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\trees.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\uncompr.c" />\r
+    <ClCompile Include="..\..\..\..\zlib\zutil.c" />\r
+    <ClCompile Include="..\..\..\common\mp3.c" />\r
+    <ClCompile Include="..\..\..\common\mp3_dummy.c" />\r
+    <ClCompile Include="..\..\libretro.c" />\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
 </Project>
\ No newline at end of file
index 44573ab..a1c0e0f 100644 (file)
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-    <Filter Include="Source Files\platform">
-      <UniqueIdentifier>{13ad8d51-3614-47ce-9d0d-8eb47a4cfabe}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\platform\libretro">
-      <UniqueIdentifier>{56e5d1cc-a749-46f0-9c75-e26037b4e2b3}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\platform\common">
-      <UniqueIdentifier>{ab1e9796-fcf3-49c2-92f2-cbce4ad50f7f}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\zlib">
-      <UniqueIdentifier>{d7cd40e2-d074-4967-84ad-89488a9eed11}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\unzip">
-      <UniqueIdentifier>{76c63342-13b7-413c-b44b-52ef07b4dccc}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\pico">
-      <UniqueIdentifier>{04bd626c-6833-49c7-8256-dc94935efe03}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\pico\cd">
-      <UniqueIdentifier>{3b94bd08-c15d-46a4-9672-094f4cafbc06}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\pico\32x">
-      <UniqueIdentifier>{403b507e-7278-436e-b8a5-5a0deb70dfae}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\pico\carthw">
-      <UniqueIdentifier>{27323686-5607-4502-9488-ac65c90e6969}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\pico\carthw\svp">
-      <UniqueIdentifier>{2e0a2f96-c25d-473e-9456-5e25b6eb8036}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\pico\sound">
-      <UniqueIdentifier>{a208ee7f-75c1-4ff9-9ed5-ea2d42832fc6}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\cpu">
-      <UniqueIdentifier>{04862576-b191-4769-a0f8-bb6400cfa861}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\cpu\famec">
-      <UniqueIdentifier>{337acc4a-3fe4-4547-b655-058d31318ffc}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\cpu\cz80">
-      <UniqueIdentifier>{63c3bec2-54b1-4831-a420-5e1aa120738b}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\cpu\drc">
-      <UniqueIdentifier>{85be1810-42b8-4ec7-bbd5-6c7d1dc5b763}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\cpu\sh2">
-      <UniqueIdentifier>{055bac11-1f11-4fe7-be7b-09ebaeab74d5}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\cpu\sh2\mame">
-      <UniqueIdentifier>{dd1911b8-6d08-42aa-ab21-0ba1154613e1}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\pico\pico">
-      <UniqueIdentifier>{a635c355-0290-4923-84c6-8290ea8b0065}</UniqueIdentifier>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="..\..\libretro.c">
-      <Filter>Source Files\platform\libretro</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\common\mp3.c">
-      <Filter>Source Files\platform\common</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\common\mp3_dummy.c">
-      <Filter>Source Files\platform\common</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\adler32.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\compress.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\crc32.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\deflate.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\example.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\gzio.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\infback.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\inffast.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\inflate.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\inftrees.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\trees.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\uncompr.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\zlib\zutil.c">
-      <Filter>Source Files\zlib</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\unzip\unzip.c">
-      <Filter>Source Files\unzip</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\unzip\unzip_stream.c">
-      <Filter>Source Files\unzip</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cart.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\carthw_cfg.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\debug.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\draw.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\draw2.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\eeprom.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\media.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\memory.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\misc.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\mode4.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\patch.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\pico.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\sek.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\sms.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\state.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\videoport.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\z80if.c">
-      <Filter>Source Files\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\cd_image.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\cdc.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\cdd.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\cell_map.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\cue.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\gfx.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\gfx_dma.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\mcd.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\cd_memory.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\cd_misc.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\pcm.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\cd\cd_sek.c">
-      <Filter>Source Files\pico\cd</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\32x\32x.c">
-      <Filter>Source Files\pico\32x</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\32x\32x_memory.c">
-      <Filter>Source Files\pico\32x</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\32x\pwm.c">
-      <Filter>Source Files\pico\32x</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\32x\sh2soc.c">
-      <Filter>Source Files\pico\32x</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\carthw\carthw.c">
-      <Filter>Source Files\pico\carthw</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\carthw\svp\svp_memory.c">
-      <Filter>Source Files\pico\carthw\svp</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\carthw\svp\ssp16.c">
-      <Filter>Source Files\pico\carthw\svp</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\carthw\svp\svp.c">
-      <Filter>Source Files\pico\carthw\svp</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\sound\mix.c">
-      <Filter>Source Files\pico\sound</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\sound\sn76496.c">
-      <Filter>Source Files\pico\sound</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\sound\sound.c">
-      <Filter>Source Files\pico\sound</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\sound\ym2612.c">
-      <Filter>Source Files\pico\sound</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\cpu\fame\famec.c">
-      <Filter>Source Files\cpu\famec</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\cpu\cz80\cz80.c">
-      <Filter>Source Files\cpu\cz80</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\cpu\drc\cmn.c">
-      <Filter>Source Files\cpu\drc</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\cpu\sh2\sh2.c">
-      <Filter>Source Files\cpu\sh2</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\cpu\sh2\mame\sh2pico.c">
-      <Filter>Source Files\cpu\sh2\mame</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\32x\32x_draw.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\pico\pico_memory.c">
-      <Filter>Source Files\pico\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\pico\pico_pico.c">
-      <Filter>Source Files\pico\pico</Filter>
-    </ClCompile>
-    <ClCompile Include="..\..\..\..\pico\pico\xpcm.c">
-      <Filter>Source Files\pico\pico</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup>\r
+    <Filter Include="Source Files">\r
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
+    </Filter>\r
+    <Filter Include="Header Files">\r
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
+    </Filter>\r
+    <Filter Include="Resource Files">\r
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
+    </Filter>\r
+    <Filter Include="Source Files\platform">\r
+      <UniqueIdentifier>{13ad8d51-3614-47ce-9d0d-8eb47a4cfabe}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\platform\libretro">\r
+      <UniqueIdentifier>{56e5d1cc-a749-46f0-9c75-e26037b4e2b3}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\platform\common">\r
+      <UniqueIdentifier>{ab1e9796-fcf3-49c2-92f2-cbce4ad50f7f}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\zlib">\r
+      <UniqueIdentifier>{d7cd40e2-d074-4967-84ad-89488a9eed11}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\unzip">\r
+      <UniqueIdentifier>{76c63342-13b7-413c-b44b-52ef07b4dccc}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\pico">\r
+      <UniqueIdentifier>{04bd626c-6833-49c7-8256-dc94935efe03}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\pico\cd">\r
+      <UniqueIdentifier>{3b94bd08-c15d-46a4-9672-094f4cafbc06}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\pico\32x">\r
+      <UniqueIdentifier>{403b507e-7278-436e-b8a5-5a0deb70dfae}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\pico\carthw">\r
+      <UniqueIdentifier>{27323686-5607-4502-9488-ac65c90e6969}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\pico\carthw\svp">\r
+      <UniqueIdentifier>{2e0a2f96-c25d-473e-9456-5e25b6eb8036}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\pico\sound">\r
+      <UniqueIdentifier>{a208ee7f-75c1-4ff9-9ed5-ea2d42832fc6}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\cpu">\r
+      <UniqueIdentifier>{04862576-b191-4769-a0f8-bb6400cfa861}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\cpu\famec">\r
+      <UniqueIdentifier>{337acc4a-3fe4-4547-b655-058d31318ffc}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\cpu\cz80">\r
+      <UniqueIdentifier>{63c3bec2-54b1-4831-a420-5e1aa120738b}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\cpu\drc">\r
+      <UniqueIdentifier>{85be1810-42b8-4ec7-bbd5-6c7d1dc5b763}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\cpu\sh2">\r
+      <UniqueIdentifier>{055bac11-1f11-4fe7-be7b-09ebaeab74d5}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\cpu\sh2\mame">\r
+      <UniqueIdentifier>{dd1911b8-6d08-42aa-ab21-0ba1154613e1}</UniqueIdentifier>\r
+    </Filter>\r
+    <Filter Include="Source Files\pico\pico">\r
+      <UniqueIdentifier>{a635c355-0290-4923-84c6-8290ea8b0065}</UniqueIdentifier>\r
+    </Filter>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="..\..\libretro.c">\r
+      <Filter>Source Files\platform\libretro</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\common\mp3.c">\r
+      <Filter>Source Files\platform\common</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\common\mp3_dummy.c">\r
+      <Filter>Source Files\platform\common</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\adler32.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\compress.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\crc32.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\deflate.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\example.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\gzio.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\infback.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\inffast.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\inflate.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\inftrees.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\trees.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\uncompr.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\zlib\zutil.c">\r
+      <Filter>Source Files\zlib</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\unzip\unzip.c">\r
+      <Filter>Source Files\unzip</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cart.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\carthw_cfg.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\debug.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\draw.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\draw2.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\eeprom.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\media.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\memory.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\misc.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\mode4.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\patch.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\pico.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\sek.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\sms.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\state.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\videoport.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\z80if.c">\r
+      <Filter>Source Files\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\cd_image.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\cdc.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\cdd.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\cell_map.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\cue.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\gfx.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\gfx_dma.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\mcd.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\memory.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\misc.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\pcm.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\cd\sek.c">\r
+      <Filter>Source Files\pico\cd</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\32x\32x.c">\r
+      <Filter>Source Files\pico\32x</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\32x\memory.c">\r
+      <Filter>Source Files\pico\32x</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\32x\pwm.c">\r
+      <Filter>Source Files\pico\32x</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\32x\sh2soc.c">\r
+      <Filter>Source Files\pico\32x</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\carthw\carthw.c">\r
+      <Filter>Source Files\pico\carthw</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\carthw\eeprom_spi.c">\r
+      <Filter>Source Files\pico\carthw</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\carthw\svp\memory.c">\r
+      <Filter>Source Files\pico\carthw\svp</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\carthw\svp\ssp16.c">\r
+      <Filter>Source Files\pico\carthw\svp</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\carthw\svp\svp.c">\r
+      <Filter>Source Files\pico\carthw\svp</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\sound\mix.c">\r
+      <Filter>Source Files\pico\sound</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\sound\sn76496.c">\r
+      <Filter>Source Files\pico\sound</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\sound\sound.c">\r
+      <Filter>Source Files\pico\sound</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\sound\ym2612.c">\r
+      <Filter>Source Files\pico\sound</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\cpu\fame\famec.c">\r
+      <Filter>Source Files\cpu\famec</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\cpu\cz80\cz80.c">\r
+      <Filter>Source Files\cpu\cz80</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\cpu\drc\cmn.c">\r
+      <Filter>Source Files\cpu\drc</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\cpu\sh2\sh2.c">\r
+      <Filter>Source Files\cpu\sh2</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\cpu\sh2\mame\sh2pico.c">\r
+      <Filter>Source Files\cpu\sh2\mame</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\pico\xpcm.c">\r
+      <Filter>Source Files\pico\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\pico\pico.c">\r
+      <Filter>Source Files\pico\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\pico\memory.c">\r
+      <Filter>Source Files\pico\pico</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\..\pico\32x\draw.c">\r
+      <Filter>Source Files\pico\32x</Filter>\r
+    </ClCompile>\r
+  </ItemGroup>\r
 </Project>
\ No newline at end of file
diff --git a/platform/libretro/psp/draw_amips.s b/platform/libretro/psp/draw_amips.s
deleted file mode 100644 (file)
index fa7906e..0000000
+++ /dev/null
@@ -1,1756 +0,0 @@
-#*
-#* several drawing related functions for Allegrex MIPS
-#* (C) notaz, 2007-2008
-#*
-#* This work is licensed under the terms of MAME license.
-#* See COPYING file in the top-level directory.
-#*
-#* this is highly specialized, be careful if changing related C code!
-#*
-
-.set noreorder # don't reorder any instructions
-.set noat      # don't use $at
-
-.text
-.align 4
-
-# void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count)
-
-.global amips_clut
-
-amips_clut:
-    srl     $a3, 2
-amips_clut_loop:
-    lbu     $t0, 0($a1)           # tried lw here, no improvement noticed
-    lbu     $t1, 1($a1)
-    lbu     $t2, 2($a1)
-    lbu     $t3, 3($a1)
-    sll     $t0, 1
-    sll     $t1, 1
-    sll     $t2, 1
-    sll     $t3, 1
-    addu    $t0, $a2
-    addu    $t1, $a2
-    addu    $t2, $a2
-    addu    $t3, $a2
-    lhu     $t0, 0($t0)
-    lhu     $t1, 0($t1)
-    lhu     $t2, 0($t2)
-    lhu     $t3, 0($t3)
-    ins     $t0, $t1, 16, 16      # ins rt, rs, pos, size - Insert size bits starting
-    ins     $t2, $t3, 16, 16      #  from the LSB of rs into rt starting at position pos
-    sw      $t0, 0($a0)
-    sw      $t2, 4($a0)
-    addiu   $a0, 8
-    addiu   $a3, -1
-    bnez    $a3, amips_clut_loop
-    addiu   $a1, 4
-    jr      $ra
-    nop
-
-
-.global amips_clut_6bit
-
-amips_clut_6bit:
-    srl     $a3, 2
-    li      $t4, 0
-    li      $t5, 0
-    li      $t6, 0
-    li      $t7, 0
-amips_clut_loop6:
-    lbu     $t0, 0($a1)           # tried lw here, no improvement noticed
-    lbu     $t1, 1($a1)
-    lbu     $t2, 2($a1)
-    lbu     $t3, 3($a1)
-    ins     $t4, $t0, 1, 6
-    ins     $t5, $t1, 1, 6
-    ins     $t6, $t2, 1, 6
-    ins     $t7, $t3, 1, 6
-    addu    $t0, $t4, $a2
-    addu    $t1, $t5, $a2
-    addu    $t2, $t6, $a2
-    addu    $t3, $t7, $a2
-    lhu     $t0, 0($t0)
-    lhu     $t1, 0($t1)
-    lhu     $t2, 0($t2)
-    lhu     $t3, 0($t3)
-    ins     $t0, $t1, 16, 16      # ins rt, rs, pos, size - Insert size bits starting
-    ins     $t2, $t3, 16, 16      #  from the LSB of rs into rt starting at position pos
-    sw      $t0, 0($a0)
-    sw      $t2, 4($a0)
-    addiu   $a0, 8
-    addiu   $a3, -1
-    bnez    $a3, amips_clut_loop6
-    addiu   $a1, 4
-    jr      $ra
-    nop
-
-
-# $a0 - pd, $a1 - tile word, $a2 - pal
-# ext rt, rs, pos, size  // Extract size bits from position pos in rs and store in rt 
-
-.macro TilePixelPrep shift dreg offs
-.if \shift
-    ext     \dreg, $a1, \shift, 4
-.else
-    andi    \dreg, $a1, 0xf
-.endif
-.if \offs
-    sltu    $t8, $0, \dreg
-    ins     $t9, $t8, \offs, 1
-.else
-    sltu    $t9, $0, \dreg
-.endif
-.endm
-
-.macro TileStartCode
-    sll     $a1, $a1, 1
-    lui     $t1, %hi(Pico+0x10000)
-    addu    $a1, $a1, $t1
-    lw      $a1, %lo(Pico+0x10000)($a1)  # Pico.vram + addr
-    beqz    $a1, TileEmpty
-    rotr    $t1, $a1, 4
-    beq     $t1, $a1, SingleColor
-    and     $v0, $0                      # not empty tile
-.endm
-
-.macro TileEndCode
-    xori    $t8, $t9, 0xff
-    beqz    $t8, tile11111111            # common case
-    lui     $v1, %hi(HighCol)
-    lui     $t8, %hi(TileTable)
-    ins     $t8, $t9, 2, 8
-    lw      $t8, %lo(TileTable)($t8)
-    lw      $v1, %lo(HighCol)($v1)
-    jr      $t8
-    addu    $a0, $v1
-.endm
-
-
-.global TileNorm
-
-TileNorm:
-    TileStartCode
-    TilePixelPrep 12, $t0, 0
-    TilePixelPrep  8, $t1, 1
-    TilePixelPrep  4, $t2, 2
-    TilePixelPrep  0, $t3, 3
-    TilePixelPrep 28, $t4, 4
-    TilePixelPrep 24, $t5, 5
-    TilePixelPrep 20, $t6, 6
-    TilePixelPrep 16, $t7, 7
-    TileEndCode
-
-
-.global TileFlip
-
-TileFlip:
-    TileStartCode
-    TilePixelPrep 16, $t0, 0
-    TilePixelPrep 20, $t1, 1
-    TilePixelPrep 24, $t2, 2
-    TilePixelPrep 28, $t3, 3
-    TilePixelPrep  0, $t4, 4
-    TilePixelPrep  4, $t5, 5
-    TilePixelPrep  8, $t6, 6
-    TilePixelPrep 12, $t7, 7
-    TileEndCode
-
-
-SingleColor:
-    lui     $t9, %hi(HighCol)
-    lw      $t9, %lo(HighCol)($t9)
-    andi    $t0, $a1, 0xf
-    or      $t0, $t0, $a2
-    addu    $a0, $t9
-    sb      $t0, 0($a0)
-    sb      $t0, 1($a0)
-    sb      $t0, 2($a0)
-    sb      $t0, 3($a0)
-    sb      $t0, 4($a0)
-    sb      $t0, 5($a0)
-    sb      $t0, 6($a0)
-    jr      $ra
-    sb      $t0, 7($a0)
-
-TileEmpty:
-    jr      $ra
-    or      $v0, $0, 1                   # empty tile
-
-tile11111111:
-    lw      $v1, %lo(HighCol)($v1)
-    or      $t0, $t0, $a2
-    addu    $a0, $v1
-    sb      $t0, 0($a0)
-tile11111110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11111100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile11111000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile11110000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-tile11100000:
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-tile11000000:
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-tile10000000:
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11111101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11111011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11111010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11111001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11110111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11110110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11110100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11110101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11110011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11110010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11110001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11101111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11101110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11101100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile11101000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11101101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11101011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11101010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11101001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11100111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11100110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11100100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11100101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11100011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11100010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11100001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11011111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11011110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11011100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile11011000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile11010000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11011101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11011011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11011010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11011001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11010111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11010110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11010100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11010101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11010011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11010010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11010001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11001111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11001110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11001100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile11001000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11001101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11001011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11001010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11001001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11000111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11000110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile11000100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11000101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11000011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile11000010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile11000001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t6, $t6, $a2
-    sb      $t6, 6($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10111111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10111110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10111100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile10111000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile10110000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-tile10100000:
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10111101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10111011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10111010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10111001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10110111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10110110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10110100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10110101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10110011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10110010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10110001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10101111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10101110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10101100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile10101000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10101101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10101011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10101010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10101001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10100111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10100110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10100100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10100101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10100011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10100010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10100001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10011111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10011110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10011100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile10011000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile10010000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10011101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10011011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10011010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10011001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10010111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10010110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10010100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10010101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10010011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10010010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10010001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10001111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10001110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10001100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile10001000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10001101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10001011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10001010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10001001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10000111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10000110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile10000100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10000101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10000011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile10000010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile10000001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t7, $t7, $a2
-    jr      $ra
-    sb      $t7, 7($a0)
-tile01111111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01111110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01111100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile01111000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile01110000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-tile01100000:
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-tile01000000:
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile00000000:
-tile01111101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01111011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01111010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01111001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01110111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01110110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01110100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01110101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01110011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01110010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01110001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01101111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01101110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01101100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile01101000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01101101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01101011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01101010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01101001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01100111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01100110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01100100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01100101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01100011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01100010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01100001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t5, $t5, $a2
-    sb      $t5, 5($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01011111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01011110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01011100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile01011000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile01010000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01011101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01011011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01011010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01011001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01010111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01010110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01010100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01010101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01010011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01010010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01010001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01001111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01001110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01001100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile01001000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01001101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01001011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01001010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01001001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01000111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01000110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile01000100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01000101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01000011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile01000010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile01000001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t6, $t6, $a2
-    jr      $ra
-    sb      $t6, 6($a0)
-tile00111111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00111110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00111100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile00111000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile00110000:
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-tile00100000:
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00111101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00111011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00111010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00111001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00110111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00110110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00110100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00110101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00110011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00110010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00110001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    sb      $t4, 4($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00101111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00101110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00101100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile00101000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00101101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00101011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00101010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00101001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00100111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00100110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00100100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00100101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00100011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00100010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00100001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t5, $t5, $a2
-    jr      $ra
-    sb      $t5, 5($a0)
-tile00011111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00011110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00011100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile00011000:
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-tile00010000:
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00011101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00011011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00011010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00011001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    sb      $t3, 3($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00010111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00010110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00010100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00010101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00010011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00010010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00010001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t4, $t4, $a2
-    jr      $ra
-    sb      $t4, 4($a0)
-tile00001111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00001110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00001100:
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-tile00001000:
-    or      $t3, $t3, $a2
-    jr      $ra
-    sb      $t3, 3($a0)
-tile00001101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    sb      $t2, 2($a0)
-    or      $t3, $t3, $a2
-    jr      $ra
-    sb      $t3, 3($a0)
-tile00001011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00001010:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-    or      $t3, $t3, $a2
-    jr      $ra
-    sb      $t3, 3($a0)
-tile00001001:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t3, $t3, $a2
-    jr      $ra
-    sb      $t3, 3($a0)
-tile00000111:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00000110:
-    or      $t1, $t1, $a2
-    sb      $t1, 1($a0)
-tile00000100:
-    or      $t2, $t2, $a2
-    jr      $ra
-    sb      $t2, 2($a0)
-tile00000101:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-    or      $t2, $t2, $a2
-    jr      $ra
-    sb      $t2, 2($a0)
-tile00000011:
-    or      $t0, $t0, $a2
-    sb      $t0, 0($a0)
-tile00000010:
-    or      $t1, $t1, $a2
-    jr      $ra
-    sb      $t1, 1($a0)
-tile00000001:
-    or      $t0, $t0, $a2
-    jr      $ra
-    sb      $t0, 0($a0)
-
-.data
-.align 4
-
-TileTable:
-  .long 000000000000, tile00000001, tile00000010, tile00000011, tile00000100, tile00000101, tile00000110, tile00000111
-  .long tile00001000, tile00001001, tile00001010, tile00001011, tile00001100, tile00001101, tile00001110, tile00001111
-  .long tile00010000, tile00010001, tile00010010, tile00010011, tile00010100, tile00010101, tile00010110, tile00010111
-  .long tile00011000, tile00011001, tile00011010, tile00011011, tile00011100, tile00011101, tile00011110, tile00011111
-  .long tile00100000, tile00100001, tile00100010, tile00100011, tile00100100, tile00100101, tile00100110, tile00100111
-  .long tile00101000, tile00101001, tile00101010, tile00101011, tile00101100, tile00101101, tile00101110, tile00101111
-  .long tile00110000, tile00110001, tile00110010, tile00110011, tile00110100, tile00110101, tile00110110, tile00110111
-  .long tile00111000, tile00111001, tile00111010, tile00111011, tile00111100, tile00111101, tile00111110, tile00111111
-  .long tile01000000, tile01000001, tile01000010, tile01000011, tile01000100, tile01000101, tile01000110, tile01000111
-  .long tile01001000, tile01001001, tile01001010, tile01001011, tile01001100, tile01001101, tile01001110, tile01001111
-  .long tile01010000, tile01010001, tile01010010, tile01010011, tile01010100, tile01010101, tile01010110, tile01010111
-  .long tile01011000, tile01011001, tile01011010, tile01011011, tile01011100, tile01011101, tile01011110, tile01011111
-  .long tile01100000, tile01100001, tile01100010, tile01100011, tile01100100, tile01100101, tile01100110, tile01100111
-  .long tile01101000, tile01101001, tile01101010, tile01101011, tile01101100, tile01101101, tile01101110, tile01101111
-  .long tile01110000, tile01110001, tile01110010, tile01110011, tile01110100, tile01110101, tile01110110, tile01110111
-  .long tile01111000, tile01111001, tile01111010, tile01111011, tile01111100, tile01111101, tile01111110, tile01111111
-  .long tile10000000, tile10000001, tile10000010, tile10000011, tile10000100, tile10000101, tile10000110, tile10000111
-  .long tile10001000, tile10001001, tile10001010, tile10001011, tile10001100, tile10001101, tile10001110, tile10001111
-  .long tile10010000, tile10010001, tile10010010, tile10010011, tile10010100, tile10010101, tile10010110, tile10010111
-  .long tile10011000, tile10011001, tile10011010, tile10011011, tile10011100, tile10011101, tile10011110, tile10011111
-  .long tile10100000, tile10100001, tile10100010, tile10100011, tile10100100, tile10100101, tile10100110, tile10100111
-  .long tile10101000, tile10101001, tile10101010, tile10101011, tile10101100, tile10101101, tile10101110, tile10101111
-  .long tile10110000, tile10110001, tile10110010, tile10110011, tile10110100, tile10110101, tile10110110, tile10110111
-  .long tile10111000, tile10111001, tile10111010, tile10111011, tile10111100, tile10111101, tile10111110, tile10111111
-  .long tile11000000, tile11000001, tile11000010, tile11000011, tile11000100, tile11000101, tile11000110, tile11000111
-  .long tile11001000, tile11001001, tile11001010, tile11001011, tile11001100, tile11001101, tile11001110, tile11001111
-  .long tile11010000, tile11010001, tile11010010, tile11010011, tile11010100, tile11010101, tile11010110, tile11010111
-  .long tile11011000, tile11011001, tile11011010, tile11011011, tile11011100, tile11011101, tile11011110, tile11011111
-  .long tile11100000, tile11100001, tile11100010, tile11100011, tile11100100, tile11100101, tile11100110, tile11100111
-  .long tile11101000, tile11101001, tile11101010, tile11101011, tile11101100, tile11101101, tile11101110, tile11101111
-  .long tile11110000, tile11110001, tile11110010, tile11110011, tile11110100, tile11110101, tile11110110, tile11110111
-  .long tile11111000, tile11111001, tile11111010, tile11111011, tile11111100, tile11111101, tile11111110, tile11111111
-
-# vim:filetype=mips
index d90d610..aee8d44 100644 (file)
@@ -31,7 +31,9 @@ void pemu_validate_config(void)
 {\r
        extern int PicoOpt;\r
 //     PicoOpt &= ~POPT_EXT_FM;\r
+#ifndef __arm__\r
        PicoOpt &= ~POPT_EN_DRC;\r
+#endif\r
 }\r
 \r
 static void draw_cd_leds(void)\r
@@ -201,3 +203,7 @@ void plat_wait_till_us(unsigned int us_to)
        }\r
 }\r
 \r
+void *plat_mem_get_for_drc(size_t size)\r
+{\r
+       return NULL;\r
+}\r
index 4240897..a181e09 100644 (file)
@@ -15,8 +15,8 @@ all: rel
 ../../tools/textfilter: ../../tools/textfilter.c
        make -C ../../tools/
 
-readme.txt: ../../tools/textfilter ../base_readme.txt ../../ChangeLog
-       ../../tools/textfilter ../base_readme.txt $@ PANDORA
+#readme.txt: ../../tools/textfilter ../base_readme.txt ../../ChangeLog
+#      ../../tools/textfilter ../base_readme.txt $@ PANDORA
 
 /tmp/PicoDrive.pxml: PicoDrive.pxml.template FORCE
        ./make_pxml.sh $< $@
@@ -24,7 +24,7 @@ readme.txt: ../../tools/textfilter ../base_readme.txt ../../ChangeLog
 rel: ../../PicoDrive PicoDrive.sh picorestore \
        PicoDrive.png PicoDrive_p.png \
        ../../pico/carthw.cfg skin \
-       readme.txt /tmp/PicoDrive.pxml
+       ../../README /tmp/PicoDrive.pxml
        rm -rf out
        mkdir out
        cp -r $^ out/
index 220d48e..635d59c 100644 (file)
@@ -33,7 +33,7 @@
   </licenses>
  
   <version major="@major@" minor="@minor@" release="0" build="@build@"/>
-  <info name="PicoDrive @major@.@minor@ readme" type="text/plain" src="readme.txt"/>
+  <info name="PicoDrive @major@.@minor@ readme" type="text/plain" src="README"/>
  
   <categories>
     <category name="Game">
index 2267c14..3fd03a2 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 set -e
 
 verfile=../common/version.h
index 8f8eac6..9cd5fc5 100644 (file)
@@ -74,6 +74,7 @@ static struct in_default_bind in_evdev_defbinds[] =
        { KEY_S,        IN_BINDTYPE_PLAYER12, GBTN_B },\r
        { KEY_D,        IN_BINDTYPE_PLAYER12, GBTN_C },\r
        { KEY_ENTER,    IN_BINDTYPE_PLAYER12, GBTN_START },\r
+       { KEY_R,        IN_BINDTYPE_EMU, PEVB_RESET },\r
        { KEY_F,        IN_BINDTYPE_EMU, PEVB_FF },\r
        { KEY_BACKSPACE,IN_BINDTYPE_EMU, PEVB_FF },\r
        { KEY_BACKSLASH,IN_BINDTYPE_EMU, PEVB_MENU },\r
index dd4381b..8373a21 100644 (file)
@@ -225,7 +225,7 @@ static void do_pal_update(int allow_sh, int allow_as)
        }
        else if (allow_as && (Pico.est.rendstatus & PDRAW_SPR_LO_ON_HI))
        {
-               memcpy32((int *)dpal+0x80/2, (void *)localPal, 0x40*2/4);
+               memcpy(dpal + 0x80/2, localPal, 0x40*2);
        }
 }
 
index a5c475f..7e57383 100644 (file)
@@ -3,10 +3,25 @@
 
 #include "../pico/pico_int.h"
 
-#define DUMP(f, field) \
+#define DUMP(f, prefix, type, field) \
   fprintf(f, "#define %-20s 0x%02x\n", \
-    "OFS_" #field, \
-    (int)offsetof(struct PicoEState, field))
+    prefix #field, (int)offsetof(type, field))
+
+#define DUMP_P(f, field) \
+  fprintf(f, "#define %-20s 0x%04x\n", \
+    "OFS_Pico_" #field, (char *)&p.field - (char *)&p)
+
+#define DUMP_PS(f, s1, field) \
+  fprintf(f, "#define %-20s 0x%04x\n", \
+    "OFS_Pico_" #s1 "_" #field, (char *)&p.s1.field - (char *)&p)
+
+#define DUMP_EST(f, field) \
+       DUMP(f, "OFS_EST_", struct PicoEState, field)
+
+#define DUMP_PMEM(f, field) \
+       DUMP(f, "OFS_PMEM_", struct PicoMem, field)
+
+extern struct Pico p;
 
 int main(int argc, char *argv[])
 {
@@ -21,16 +36,33 @@ int main(int argc, char *argv[])
   }
 
   fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]);
-  DUMP(f, DrawScanline);
-  DUMP(f, rendstatus);
-  DUMP(f, DrawLineDest);
-  DUMP(f, HighCol);
-  DUMP(f, HighPreSpr);
-  DUMP(f, Pico_video);
-  DUMP(f, Pico_vram);
-  DUMP(f, PicoOpt);
-  DUMP(f, Draw2FB);
-  DUMP(f, HighPal);
+  DUMP_PS(f, video, reg);
+  DUMP_PS(f, m, rotate);
+  DUMP_PS(f, m, z80Run);
+  DUMP_PS(f, m, dirtyPal);
+  DUMP_PS(f, m, hardware);
+  DUMP_PS(f, m, z80_reset);
+  DUMP_PS(f, m, sram_reg);
+  DUMP_P (f, sv);
+  DUMP_PS(f, sv, data);
+  DUMP_PS(f, sv, start);
+  DUMP_PS(f, sv, end);
+  DUMP_PS(f, sv, flags);
+  DUMP_P (f, rom);
+  DUMP_P (f, romsize);
+  DUMP_EST(f, DrawScanline);
+  DUMP_EST(f, rendstatus);
+  DUMP_EST(f, DrawLineDest);
+  DUMP_EST(f, HighCol);
+  DUMP_EST(f, HighPreSpr);
+  DUMP_EST(f, Pico);
+  DUMP_EST(f, PicoMem_vram);
+  DUMP_EST(f, PicoMem_cram);
+  DUMP_EST(f, PicoOpt);
+  DUMP_EST(f, Draw2FB);
+  DUMP_EST(f, HighPal);
+  DUMP_PMEM(f, vram);
+  DUMP_PMEM(f, vsram);
   fclose(f);
 
   return 0;