Common subdirectories: yabause-r2604/src/.svn and yabause-wii-beta17/src/.svn
diff -c yabause-r2604/src/Makefile.wii yabause-wii-beta17/src/Makefile.wii
*** yabause-r2604/src/Makefile.wii	Fri Jun 24 23:32:29 2011
--- yabause-wii-beta17/src/Makefile.wii	Wed Nov  3 07:45:49 2010
***************
*** 26,42 ****
  include $(DEVKITPPC)/wii_rules
  
  TARGET = yabause.elf
  DDEFINES=
! VDEFINES=-DPACKAGE=\"yabause-wii\" -DVERSION=\"0.9.6\" -DWORDS_BIGENDIAN -DREENTRANT_SYSCALLS_PROVIDED
! MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float
! CFLAGS=$(VDEFINES) $(DDEFINES) -g -O2 -mrvl -Wall $(MACHDEP) -I$(LIBOGC_INC)
! LDFLAGS= -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
! LIBS := -lfat -lwiiuse -lbte -logc -lm
  OBJS = bios.o cdbase.o cheat.o coffelf.o cs0.o cs1.o cs2.o debug.o \
! error.o m68kcore.o m68kc68k.o m68kd.o memory.o netlink.o peripheral.o \
! profile.o scsp.o scu.o sh2core.o sh2idle.o sh2int.o sh2d.o smpc.o vdp1.o \
  vdp2.o vidshared.o vidsoft.o yabause.o ygl.o c68k/c68k.o c68k/c68kexec.o \
! wii/yui.o wii/perwii.o wii/sndwii.o
  DEPSDIR = $(CURDIR)
  export LD := $(CC)
  export LIBPATHS := -L$(LIBOGC_LIB)
--- 26,61 ----
  include $(DEVKITPPC)/wii_rules
  
  TARGET = yabause.elf
+ #  
  DDEFINES=
! DDEFINES+= -DUSE_WIIGX
! #DDEFINES+= -DWIIAUDIO_THREAD
! #DDEFINES+= -DHIGHRESO
! DDEFINES+= -DWIICONVERTASM
! #
! DDEFINES+= -Dmain=SDL_main
! DDEFINES+= -DHAVE_LIBSDL
! DDEFINES+= -DEXEC_FROM_CACHE
! DDEFINES+= -DOPTIMIZED_DMA
! DDEFINES+= -DHAVE_Q68
! #
! #DDEFINES+= -DDEBUG
! VDEFINES=-DPACKAGE=\"yabause-wii\" -DVERSION=\"ver.\ Unofficial\ r2604\ beta17\" -DWORDS_BIGENDIAN -DREENTRANT_SYSCALLS_PROVIDED
! #MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float -fsigned-char
! MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float -fsigned-char -fomit-frame-pointer -ffast-math -funroll-loops -fauto-inc-dec -finline-functions
! #CFLAGS=$(VDEFINES) $(DDEFINES) -g -O2 -mrvl -Wall $(MACHDEP) -I$(LIBOGC_INC)
! CFLAGS=$(VDEFINES) $(DDEFINES) -O3 -mrvl -Wall $(MACHDEP) -I$(LIBOGC_INC)
! #LDFLAGS= -g $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
! LDFLAGS= $(MACHDEP) -mrvl -Wl,-Map,$(notdir $@).map
! #LIBS := -lfat -lwiiuse -lbte -logc -lm
! LIBS := -lSDL -lfat -lwiiuse -lwiikeyboard -lbte -logc -lm -lmxml
  OBJS = bios.o cdbase.o cheat.o coffelf.o cs0.o cs1.o cs2.o debug.o \
! error.o m68kcore.o m68kc68k.o movie.o m68kd.o memory.o netlink.o peripheral.o \
! profile.o scu.o sh2core.o sh2idle.o sh2int.o sh2d.o smpc.o sndsdl.o snddummy.o vdp1.o \
  vdp2.o vidshared.o vidsoft.o yabause.o ygl.o c68k/c68k.o c68k/c68kexec.o \
! wii/yui.o wii/perwii.o wii/sndwii.o wii/iowii.o \
! m68kq68.o q68/q68.o q68/q68-core.o q68/q68-disasm.o \
! scsp.o
  DEPSDIR = $(CURDIR)
  export LD := $(CC)
  export LIBPATHS := -L$(LIBOGC_LIB)
Only in yabause-wii-beta17/src: Makefile.wii.orig
Only in yabause-wii-beta17/src: Makefile.wii.rej
Only in yabause-wii-beta17/src: bios.d
Only in yabause-wii-beta17/src: boot.dol
Common subdirectories: yabause-r2604/src/c68k and yabause-wii-beta17/src/c68k
Common subdirectories: yabause-r2604/src/carbon and yabause-wii-beta17/src/carbon
Only in yabause-wii-beta17/src: cdbase.d
Only in yabause-wii-beta17/src: cheat.d
Only in yabause-wii-beta17/src: coffelf.d
Only in yabause-wii-beta17/src: cs0.d
Only in yabause-wii-beta17/src: cs1.d
Only in yabause-wii-beta17/src: cs2.d
Only in yabause-wii-beta17/src: debug.d
Common subdirectories: yabause-r2604/src/dreamcast and yabause-wii-beta17/src/dreamcast
Only in yabause-wii-beta17/src: error.d
Common subdirectories: yabause-r2604/src/gameshw and yabause-wii-beta17/src/gameshw
Common subdirectories: yabause-r2604/src/gtk and yabause-wii-beta17/src/gtk
Only in yabause-wii-beta17/src: m68kc68k.d
Only in yabause-wii-beta17/src: m68kcore.d
Only in yabause-wii-beta17/src: m68kd.d
Only in yabause-wii-beta17/src: m68kq68.d
diff -c yabause-r2604/src/memory.c yabause-wii-beta17/src/memory.c
*** yabause-r2604/src/memory.c	Fri Jun 24 23:32:29 2011
--- yabause-wii-beta17/src/memory.c	Mon Aug 23 20:04:10 2010
***************
*** 531,536 ****
--- 531,539 ----
           break;
        }
  */
+ #ifdef GEKKO
+       case 0x2:
+ #endif
        case 0x4:
        case 0x6:
           // Data Array
***************
*** 582,587 ****
--- 585,593 ----
           break;
        }
  */
+ #ifdef GEKKO
+       case 0x2:
+ #endif
        case 0x4:
        case 0x6:
           // Data Array
***************
*** 638,643 ****
--- 644,652 ----
           // Address Array
           return AddressArrayReadLong(addr);
        }
+ #ifdef GEKKO
+       case 0x2:
+ #endif
        case 0x4:
        case 0x6:
           // Data Array
***************
*** 689,694 ****
--- 698,706 ----
           return;
        }
  */
+ #ifdef GEKKO
+       case 0x2:
+ #endif
        case 0x4:
        case 0x6:
           // Data Array
***************
*** 742,747 ****
--- 754,762 ----
           return;
        }
  */
+ #ifdef GEKKO
+       case 0x2:
+ #endif
        case 0x4:
        case 0x6:
           // Data Array
***************
*** 788,804 ****
--- 803,824 ----
           WriteLongList[(addr >> 16) & 0xFFF](addr, val);
           return;
        }
+ #ifndef GEKKO
        case 0x2:
        {
           // Purge Area
           return;
        }
+ #endif
        case 0x3:
        {
           // Address Array
           AddressArrayWriteLong(addr, val);
           return;
        }
+ #ifdef GEKKO
+       case 0x2:
+ #endif
        case 0x4:
        case 0x6:
           // Data Array
***************
*** 909,915 ****
     {
        p = strdup(p);
        for (i = 0; i < strlen(p); i++)
!          p[i] = toupper(p[i]);
        if (strcmp(p, ".COF") == 0 || strcmp(p, ".COFF") == 0)
        {
           MappedMemoryLoadCoff(filename);
--- 929,935 ----
     {
        p = strdup(p);
        for (i = 0; i < strlen(p); i++)
!          p[i] = (char)toupper((int)p[i]);
        if (strcmp(p, ".COF") == 0 || strcmp(p, ".COFF") == 0)
        {
           MappedMemoryLoadCoff(filename);
Only in yabause-wii-beta17/src: memory.d
Only in yabause-wii-beta17/src: movie.d
Only in yabause-wii-beta17/src: netlink.d
Only in yabause-wii-beta17/src: org_wii
Only in yabause-wii-beta17/src: peripheral.d
Only in yabause-wii-beta17/src: profile.d
Common subdirectories: yabause-r2604/src/psp and yabause-wii-beta17/src/psp
Common subdirectories: yabause-r2604/src/q68 and yabause-wii-beta17/src/q68
Common subdirectories: yabause-r2604/src/qt and yabause-wii-beta17/src/qt
diff -c yabause-r2604/src/scsp.c yabause-wii-beta17/src/scsp.c
*** yabause-r2604/src/scsp.c	Fri Jun 24 23:32:28 2011
--- yabause-wii-beta17/src/scsp.c	Sat Sep 18 21:33:44 2010
***************
*** 175,180 ****
--- 175,181 ----
  	u32	finc;			// phase step adder
  	u32	finct;		// non ajusted phase step
  
+ #ifndef GEKKO // to avoid crash.
  	s32	ecnt;			// enveloppe counter
  	s32	einc;			// enveloppe current step adder
  	s32	einca;		// enveloppe step adder for attack
***************
*** 182,187 ****
--- 183,197 ----
  	s32	eincs;		// enveloppe step adder for decay 2
  	s32	eincr;		// enveloppe step adder for release
  	s32	ecmp;			// enveloppe compare to raise next phase
+ #else
+ 	u32	ecnt;			// enveloppe counter
+ 	u32	einc;			// enveloppe current step adder
+ 	u32	einca;		// enveloppe step adder for attack
+ 	u32	eincd;		// enveloppe step adder for decay 1
+ 	u32	eincs;		// enveloppe step adder for decay 2
+ 	u32	eincr;		// enveloppe step adder for release
+ 	u32	ecmp;			// enveloppe compare to raise next phase
+ #endif
  	u32	ecurp;		// enveloppe current phase (attack / decay / release ...)
  
  	void	(*enxt)(struct slot_t *);	// enveloppe function pointer for next phase event
***************
*** 397,402 ****
--- 407,413 ----
  
  static void scsp_dma(void)
  {
+ #ifdef SCSP_DEBUG
  	if (scsp.dmfl & 0x20)
  	{
  		// dsp -> scsp_ram
***************
*** 407,412 ****
--- 418,424 ----
  		// scsp_ram -> dsp
                  SCSPLOG("scsp dma: scsp_ram(%08lx) -> reg(%08lx) * %08lx\n", scsp.dmea, scsp.drga, scsp.dmlen);
  	}
+ #endif
  
  	scsp_ccr[0x16 ^ 3] &= 0xE0;
  
***************
*** 994,1005 ****
--- 1006,1019 ----
  
  static void scsp_set_b(u32 a, u8 d)
  {
+ #ifdef SCSP_DEBUG
  //      if (a != 0x41D) SCSPLOG("scsp : reg %.2X = %.2X\n", a & 0x3F, d);
          if ((a != 0x408) && (a != 0x41D))
  	{
  		SCSPLOG("scsp : reg %.2X = %.2X\n", a & 0x3F, d);
  	}
  //      SCSPLOG("scsp : reg %.2X = %.2X\n", a & 0x3F, d);
+ #endif
  
  	scsp_ccr[a ^ 3] = d;
  
***************
*** 1163,1173 ****
--- 1177,1189 ----
  
  static void scsp_set_w(u32 a, u16 d)
  {
+ #ifdef SCSP_DEBUG
          if ((a != 0x418) && (a != 0x41A) && (a != 0x422))
  	{
  		SCSPLOG("scsp : reg %.2X = %.4X\n", a & 0x3E, d);
  	}
  //      SCSPLOG("scsp : reg %.2X = %.4X\n", a & 0x3E, d);
+ #endif
  
  	*(u16 *)&scsp_ccr[a ^ 2] = d;
  
***************
*** 1287,1292 ****
--- 1303,1309 ----
  {
  	a &= 0x3F;
  
+ #ifdef SCSP_DEBUG
  //      if (a != 0x21) SCSPLOG("r_b scsp : reg %.2X\n", a);
          if ((a != 0x09) && (a != 0x21))
  	{
***************
*** 1294,1299 ****
--- 1311,1317 ----
  	}
  //      if (a == 0x09) SCSPLOG("r_b scsp 09 = %.2X\n", ((scsp.slot[scsp.mslc].fcnt >> (SCSP_FREQ_LB + 12)) & 0x1) << 7);
  //      SCSPLOG("r_b scsp : reg %.2X\n", a);
+ #endif
  
  	switch(a){
  
***************
*** 1342,1351 ****
--- 1360,1371 ----
  {
  	a = (a >> 1) & 0x1F;
  
+ #ifdef SCSP_DEBUG
          if (a != 0x10)
  	{
  		SCSPLOG("r_w scsp : reg %.2X\n", a * 2);
  	}
+ #endif
  
  	switch(a){
  
***************
*** 2375,2384 ****
--- 2395,2406 ----
  
  void FASTCALL scsp_w_w(u32 a, u16 d)
  {
+ #ifdef SCSP_DEBUG
  	if (a & 1)
  	{
                  SCSPLOG("ERROR: scsp w_w misaligned : %.8X\n", a);
  	}
+ #endif
  
  	a &= 0xFFE;
  
***************
*** 2415,2424 ****
--- 2437,2448 ----
  
  void FASTCALL scsp_w_d(u32 a, u32 d)
  {
+ #ifdef SCSP_DEBUG
  	if (a & 3)
  	{
                  SCSPLOG("ERROR: scsp w_d misaligned : %.8X\n", a);
  	}
+ #endif
  
  	a &= 0xFFC;
  
***************
*** 2485,2494 ****
--- 2509,2520 ----
  
  u16 FASTCALL scsp_r_w(u32 a)
  {
+ #ifdef SCSP_DEBUG
  	if (a & 1)
  	{
                  SCSPLOG("ERROR: scsp r_w misaligned : %.8X\n", a);
  	}
+ #endif
  
  	a &= 0xFFE;
  
***************
*** 2518,2527 ****
--- 2544,2555 ----
  
  u32 FASTCALL scsp_r_d(u32 a)
  {
+ #ifdef SCSP_DEBUG
  	if (a & 3)
  	{
                  SCSPLOG("ERROR: scsp r_d misaligned : %.8X\n", a);
  	}
+ #endif
  
  	a &= 0xFFC;
  
***************
*** 2687,2697 ****
--- 2715,2727 ----
  		scsp_null_rate[i - 64] = 0;
  	}
  
+ #ifdef SCSP_DEBUG
  	for(i = 0; i < 96; i++)
  	{
                  SCSPLOG("attack rate[%d] = %.8X -> %.8X\n", i, scsp_attack_rate[i], scsp_attack_rate[i] >> SCSP_ENV_LB);
                  SCSPLOG("decay rate[%d] = %.8X -> %.8X\n", i, scsp_decay_rate[i], scsp_decay_rate[i] >> SCSP_ENV_LB);
  	}
+ #endif
  
          for(i = 0; i < 256; i++)
             scsp_tl_table[i] = scsp_round(pow(10, ((double)i * -0.3762) / 20) * 1024.0);
Only in yabause-wii-beta17/src: scsp.c.orig
Only in yabause-wii-beta17/src: scsp.d
diff -c yabause-r2604/src/scsp2.c yabause-wii-beta17/src/scsp2.c
*** yabause-r2604/src/scsp2.c	Fri Jun 24 23:32:31 2011
--- yabause-wii-beta17/src/scsp2.c	Wed Aug 18 14:59:00 2010
***************
*** 304,309 ****
--- 304,310 ----
     u32  looplen_shifted;// (lea - lsa + 1) << SCSP_FREQ_LOW_BITS
  
     u32  env_phase;      // Current envelope phase (attack/decay/...)
+ #ifndef NOGEKKO
     s32  env_counter;    // Envelope counter
     s32  env_step;       // Envelope counter increment for current phase
     s32  env_target;     // Envelope target value for advancing to next phase
***************
*** 311,324 ****
     s32  env_step_d;     // Envelope counter increment for decay phase
     s32  env_step_s;     // Envelope counter increment for sustain phase
     s32  env_step_r;     // Envelope counter increment for release phase
-    u8   krs_shift;      // Shift count corresponding to KRS
     s32  sl_target;      // Compare value corresponding to SL
     s32  tl_mult;        // Envelope volume multiplier corresponding to TL
  
     u32  lfo_counter;    // LFO counter (fixed point index into LFO waveforms)
     s32  lfo_step;       // LFO counter increment, or -1 if in reset mode
     s32  *lfo_fm_wave;   // LFO frequency modulation waveform pointer
     s32  *lfo_am_wave;   // LFO amplitude modulation waveform pointer
     s8   lfo_fm_shift;   // LFO frequency modulation strength, -1 if disabled
     s8   lfo_am_shift;   // LFO amplitude modulation strength, -1 if disabled
  
--- 312,341 ----
     s32  env_step_d;     // Envelope counter increment for decay phase
     s32  env_step_s;     // Envelope counter increment for sustain phase
     s32  env_step_r;     // Envelope counter increment for release phase
     s32  sl_target;      // Compare value corresponding to SL
     s32  tl_mult;        // Envelope volume multiplier corresponding to TL
+ #else
+    u32  env_counter;    // Envelope counter
+    u32  env_step;       // Envelope counter increment for current phase
+    u32  env_target;     // Envelope target value for advancing to next phase
+    u32  env_step_a;     // Envelope counter increment for attack phase
+    u32  env_step_d;     // Envelope counter increment for decay phase
+    u32  env_step_s;     // Envelope counter increment for sustain phase
+    u32  env_step_r;     // Envelope counter increment for release phase
+    u32  sl_target;      // Compare value corresponding to SL
+    u32  tl_mult;        // Envelope volume multiplier corresponding to TL
+ #endif
+    u8   krs_shift;      // Shift count corresponding to KRS
  
     u32  lfo_counter;    // LFO counter (fixed point index into LFO waveforms)
     s32  lfo_step;       // LFO counter increment, or -1 if in reset mode
+ #ifndef NOGEKKO
     s32  *lfo_fm_wave;   // LFO frequency modulation waveform pointer
     s32  *lfo_am_wave;   // LFO amplitude modulation waveform pointer
+ #else
+    u32  *lfo_fm_wave;   // LFO frequency modulation waveform pointer
+    u32  *lfo_am_wave;   // LFO amplitude modulation waveform pointer
+ #endif
     s8   lfo_fm_shift;   // LFO frequency modulation strength, -1 if disabled
     s8   lfo_am_shift;   // LFO amplitude modulation strength, -1 if disabled
  
***************
*** 447,457 ****
--- 464,486 ----
  static s32 scsp_env_table[SCSP_ENV_LEN*2];
  
  // LFO waveforms for amplitude modulation
+ #ifndef NOGEKKO
  static s32 scsp_lfo_wave_amp[4][SCSP_LFO_LEN];
+ #else
+ static u32 scsp_lfo_wave_amp[4][SCSP_LFO_LEN];
+ #endif
  // LFO waveforms for frequency modulation
+ #ifndef NOGEKKO
  static s32 scsp_lfo_wave_freq[4][SCSP_LFO_LEN];
+ #else
+ static u32 scsp_lfo_wave_freq[4][SCSP_LFO_LEN];
+ #endif
  // LFO counter step values for each LFOF index
+ #ifndef NOGEKKO
  static s32 scsp_lfo_step[32];
+ #else
+ static u32 scsp_lfo_step[32];
+ #endif
  
  // Envelope increments for each attack/decay rate (AR, DR, etc.)
  static s32 scsp_attack_rate[62+16];
Only in yabause-wii-beta17/src: scsp2.d
Only in yabause-wii-beta17/src: scsp2.o
diff -c yabause-r2604/src/scu.c yabause-wii-beta17/src/scu.c
*** yabause-r2604/src/scu.c	Fri Jun 24 23:32:32 2011
--- yabause-wii-beta17/src/scu.c	Sat Aug 21 19:37:04 2010
***************
*** 2093,2101 ****
--- 2093,2103 ----
           ScuRegs->D0EN = val;
           break;
        case 0x14:
+ #ifdef GEKKO
           if ((val & 0x7) != 7) {
              LOG("scu\t: DMA mode 0 interrupt start factor not implemented\n");
           }
+ #endif
           ScuRegs->D0MD = val;
           break;
        case 0x20:
***************
*** 2127,2135 ****
--- 2129,2139 ----
           ScuRegs->D1EN = val;
           break;
        case 0x34:
+ #ifdef DEBUG
           if ((val & 0x7) != 7) {
              LOG("scu\t: DMA mode 1 interrupt start factor not implemented\n");
           }
+ #endif
           ScuRegs->D1MD = val;
           break;
        case 0x40:
***************
*** 2161,2169 ****
--- 2165,2175 ----
           ScuRegs->D2EN = val;
           break;
        case 0x54:
+ #ifdef DEBUG
           if ((val & 0x7) != 7) {
              LOG("scu\t: DMA mode 2 interrupt start factor not implemented\n");
           }
+ #endif
           ScuRegs->D2MD = val;
           break;
        case 0x60:
Only in yabause-wii-beta17/src: scu.d
diff -c yabause-r2604/src/sh2core.c yabause-wii-beta17/src/sh2core.c
*** yabause-r2604/src/sh2core.c	Fri Jun 24 23:32:31 2011
--- yabause-wii-beta17/src/sh2core.c	Sun Sep 26 21:55:40 2010
***************
*** 817,822 ****
--- 817,827 ----
     context->onchip.BDMRB.all = 0x00000000;
     context->onchip.BBRB = 0x0000;
     context->onchip.BRCR = 0x0000;
+ #ifdef GEKKO
+    context->onchip.SAR0= 0x00000000;
+    context->onchip.DAR0= 0x00000000;
+    context->onchip.TCR0= 0x00000000;
+ #endif
     context->onchip.CHCR0 = 0x00000000;
     context->onchip.CHCR1 = 0x00000000;
     context->onchip.DMAOR = 0x00000000;
***************
*** 868,883 ****
--- 873,938 ----
        case 0x005:
  //         LOG("Receive Data Register read: %02X PC = %08X\n", CurrentSH2->onchip.RDR, SH2Core->GetPC(CurrentSH2));
           return CurrentSH2->onchip.RDR;
+ #ifdef GEKKO
+       case 0x010:
+          return CurrentSH2->onchip.TIER;
+ #endif
        case 0x011:
           return CurrentSH2->onchip.FTCSR;
        case 0x012:         
           return CurrentSH2->onchip.FRC.part.H;
        case 0x013:
           return CurrentSH2->onchip.FRC.part.L;
+ #ifdef GEKKO
+       case 0x014:
+          if (!(CurrentSH2->onchip.TOCR & 0x10))
+             return CurrentSH2->onchip.OCRA >> 8;
+          else
+             return CurrentSH2->onchip.OCRB >> 8;
+       case 0x015:
+          if (!(CurrentSH2->onchip.TOCR & 0x10))
+             return CurrentSH2->onchip.OCRA & 0xFF;
+          else
+             return CurrentSH2->onchip.OCRB & 0xFF;
+ #endif
        case 0x016:
           return CurrentSH2->onchip.TCR;
        case 0x017:
           return CurrentSH2->onchip.TOCR;
+ #ifdef GEKKO
+       case 0x018:
+          return CurrentSH2->onchip.FICR >> 8;
+       case 0x019:
+          return CurrentSH2->onchip.FICR & 0xFF;
+       case 0x060:
+          return CurrentSH2->onchip.IPRB >> 8;
+       case 0x062:
+          return CurrentSH2->onchip.VCRA >> 8;
+       case 0x063:
+          return CurrentSH2->onchip.VCRA & 0xFF;
+       case 0x064:
+          return CurrentSH2->onchip.VCRB >> 8;
+       case 0x065:
+          return CurrentSH2->onchip.VCRB & 0xFF;
+       case 0x066:
+          return CurrentSH2->onchip.VCRC >> 8;
+       case 0x067:
+          return CurrentSH2->onchip.VCRC & 0xFF;
+       case 0x068:
+          return CurrentSH2->onchip.VCRD >> 8;
+       case 0x0E0:
+          return CurrentSH2->onchip.ICR >> 8;
+       case 0x0E1:
+          return CurrentSH2->onchip.ICR & 0xFF;
+       case 0x0E2:
+          return CurrentSH2->onchip.IPRA >> 8;
+       case 0x0E3:
+          return CurrentSH2->onchip.IPRA & 0xFF;
+       case 0x0E4:
+          return CurrentSH2->onchip.VCRWDT >> 8;
+       case 0x0E5:
+          return CurrentSH2->onchip.VCRWDT & 0xFF;
+ #endif
        case 0x080:
           return CurrentSH2->onchip.WTCSR;
        case 0x081:
***************
*** 899,908 ****
--- 954,1021 ----
     {
        case 0x060:
           return CurrentSH2->onchip.IPRB;
+ #ifdef GEKKO
+       case 0x062:
+          return CurrentSH2->onchip.VCRA;
+       case 0x064:
+          return CurrentSH2->onchip.VCRB;
+       case 0x066:
+          return CurrentSH2->onchip.VCRC;
+       case 0x068:
+          return CurrentSH2->onchip.VCRD;
+ #endif
        case 0x0E0:
           return CurrentSH2->onchip.ICR;
        case 0x0E2:
           return CurrentSH2->onchip.IPRA;
+ #ifdef GEKKO
+       case 0x0E4:
+          return CurrentSH2->onchip.VCRWDT;
+       case 0x140:
+          return CurrentSH2->onchip.BARA.part.H;
+       case 0x142:
+          return CurrentSH2->onchip.BARA.part.L;
+       case 0x144:
+          return CurrentSH2->onchip.BAMRA.part.H;
+       case 0x146:
+          return CurrentSH2->onchip.BAMRA.part.L;
+       case 0x148:
+          return CurrentSH2->onchip.BBRA;
+       case 0x160:
+          return CurrentSH2->onchip.BARB.part.H;
+       case 0x162:
+          return CurrentSH2->onchip.BAMRB.part.L;
+       case 0x164:
+          return CurrentSH2->onchip.BAMRB.part.H;
+       case 0x166:
+          return CurrentSH2->onchip.BARB.part.L;
+       case 0x168:
+          return CurrentSH2->onchip.BBRB;
+       case 0x170:
+          return CurrentSH2->onchip.BDRB.part.H;
+       case 0x172:
+          return CurrentSH2->onchip.BDMRB.part.L;
+       case 0x174:
+          return CurrentSH2->onchip.BDMRB.part.H;
+       case 0x176:
+          return CurrentSH2->onchip.BDRB.part.L;
+       case 0x178:
+          return CurrentSH2->onchip.BRCR;
+       case 0x1E2: // real BCR1 register is located at 0x1E2-0x1E3; Sega Rally OK
+          return CurrentSH2->onchip.BCR1;
+       case 0x1E6:
+          return CurrentSH2->onchip.BCR2;
+       case 0x1EA:
+          return CurrentSH2->onchip.WCR;
+       case 0x1EE:
+          return CurrentSH2->onchip.MCR;
+       case 0x1F2:
+          return CurrentSH2->onchip.RTCSR;
+       case 0x1F6:
+          return CurrentSH2->onchip.RTCNT;
+       case 0x1FA:
+          return CurrentSH2->onchip.RTCOR;
+ #endif
        default:
           LOG("Unhandled Onchip word read %08X\n", (int)addr);
           return 0;
***************
*** 916,921 ****
--- 1029,1040 ----
  u32 FASTCALL OnchipReadLong(u32 addr) {
     switch(addr)
     {
+ #ifdef GEKKO
+       case 0x058:
+          return CurrentSH2->onchip.IPRB;
+       case 0x070:
+          return ((CurrentSH2->onchip.DRCR0 << 16) | (CurrentSH2->onchip.DRCR1 << 8));
+ #endif
        case 0x100:
        case 0x120:
           return CurrentSH2->onchip.DVSR;
***************
*** 940,953 ****
--- 1059,1120 ----
        case 0x11C: // Acts as a separate register, but is set to the same value
        case 0x13C: // as DVDNTL after division
           return CurrentSH2->onchip.DVDNTUL;
+ #ifdef GEKKO
+       case 0x140:
+          return CurrentSH2->onchip.BARA.all;
+       case 0x144:
+          return CurrentSH2->onchip.BAMRA.all;
+       case 0x160:
+          return CurrentSH2->onchip.BARB.all;
+       case 0x164:
+          return CurrentSH2->onchip.BAMRB.all;
+       case 0x170:
+          return CurrentSH2->onchip.BDRB.all;
+       case 0x174:
+          return CurrentSH2->onchip.BDMRB.all;
+       case 0x180:
+          return CurrentSH2->onchip.SAR0;
+       case 0x184:
+          return CurrentSH2->onchip.DAR0;
+       case 0x188:
+          return CurrentSH2->onchip.TCR0;
+ #endif
        case 0x18C:
           return CurrentSH2->onchip.CHCR0;
+ #ifdef GEKKO
+       case 0x190:
+          return CurrentSH2->onchip.SAR1;
+       case 0x194:
+          return CurrentSH2->onchip.DAR1;
+       case 0x198:
+          return CurrentSH2->onchip.TCR1;
+ #endif
        case 0x19C:
           return CurrentSH2->onchip.CHCR1;
+ #ifdef GEKKO
+       case 0x1A0:
+          return CurrentSH2->onchip.VCRDMA0;
+       case 0x1A8:
+          return CurrentSH2->onchip.VCRDMA1;
+ #endif
        case 0x1B0:
           return CurrentSH2->onchip.DMAOR;
        case 0x1E0:
           return CurrentSH2->onchip.BCR1;
+ #ifdef GEKKO
+       case 0x1E4:
+          return CurrentSH2->onchip.BCR2;
+       case 0x1E8:
+          return CurrentSH2->onchip.WCR;
+       case 0x1EC:
+          return CurrentSH2->onchip.MCR;
+       case 0x1F0:
+          return CurrentSH2->onchip.RTCSR;
+       case 0x1F4:
+          return CurrentSH2->onchip.RTCNT;
+       case 0x1F8:
+          return CurrentSH2->onchip.RTCOR;
+ #endif
        default:
           LOG("Unhandled Onchip long read %08X\n", (int)addr);
           return 0;
***************
*** 1099,1104 ****
--- 1266,1287 ----
        case 0x0E5:
           CurrentSH2->onchip.VCRWDT = (CurrentSH2->onchip.VCRWDT & 0xFF00) | (val & 0x7F);
           return;
+ #ifdef GEKKO
+       case 0x18C:
+          CurrentSH2->onchip.CHCR0 = (CurrentSH2->onchip.CHCR0 & 0x0FFF) | (val << 24);
+          return;
+       case 0x18D:
+          CurrentSH2->onchip.CHCR0 = (CurrentSH2->onchip.CHCR0 & 0xF0FF) | (val << 16);
+          return;
+       case 0x18E:
+          CurrentSH2->onchip.CHCR0 = (CurrentSH2->onchip.CHCR0 & 0xFF0F) | (val << 8);
+          return;
+       case 0x18F:
+          CurrentSH2->onchip.CHCR0 = (CurrentSH2->onchip.CHCR0 & 0xFFF0) | (val);
+          if ((CurrentSH2->onchip.DMAOR & 7) == 1 && (val & 0x3) == 1)
+             DMAExec();
+          return;
+ #endif
        default:
           LOG("Unhandled Onchip byte write %08X\n", (int)addr);
     }
***************
*** 1112,1117 ****
--- 1295,1314 ----
        case 0x060:
           CurrentSH2->onchip.IPRB = val & 0xFF00;
           return;
+ #ifdef GEKKO
+       case 0x062:
+          CurrentSH2->onchip.VCRA = val & 0x7F7F;
+          return;
+       case 0x064:
+          CurrentSH2->onchip.VCRB = val & 0x7F7F;
+          return;
+       case 0x066:
+          CurrentSH2->onchip.VCRC = val & 0x7F7F;
+          return;
+       case 0x068:
+          CurrentSH2->onchip.VCRD = val & 0x7F7F;
+          return;
+ #endif
        case 0x080:
           // This and RSTCSR have got to be the most wackiest register
           // mappings I've ever seen
***************
*** 1175,1184 ****
--- 1372,1426 ----
        case 0x0E2:
           CurrentSH2->onchip.IPRA = val & 0xFFF0;
           return;
+ #ifdef GEKKO
+       case 0x0E4:
+          CurrentSH2->onchip.VCRWDT = val & 0x7F7F;
+          return;
+ #endif
        case 0x108:
        case 0x128:
           CurrentSH2->onchip.DVCR = val & 0x3;
           return;
+ #ifdef GEKKO
+       case 0x140:
+          CurrentSH2->onchip.BARA.part.H = val;
+          return;
+       case 0x142:
+          CurrentSH2->onchip.BARA.part.L = val;
+          return;
+       case 0x144:
+          CurrentSH2->onchip.BAMRA.part.H = val;
+          return;
+       case 0x146:
+          CurrentSH2->onchip.BAMRA.part.L = val;
+          return;
+       case 0x160:
+          CurrentSH2->onchip.BARB.part.H = val;
+          return;
+       case 0x162:
+          CurrentSH2->onchip.BARB.part.L = val;
+          return;
+       case 0x164:
+          CurrentSH2->onchip.BAMRB.part.H = val;
+          return;
+       case 0x166:
+          CurrentSH2->onchip.BAMRB.part.L = val;
+          return;
+       case 0x170:
+          CurrentSH2->onchip.BDRB.part.H = val;
+          return;
+       case 0x172:
+          CurrentSH2->onchip.BDRB.part.L = val;
+          return;
+       case 0x174:
+          CurrentSH2->onchip.BDMRB.part.H = val;
+          return;
+       case 0x176:
+          CurrentSH2->onchip.BDMRB.part.L = val;
+       case 0x168:
+          CurrentSH2->onchip.BBRB = val & 0xFF;
+          return;
+ #endif
        case 0x148:
           CurrentSH2->onchip.BBRA = val & 0xFF;
           return;
Only in yabause-wii-beta17/src: sh2core.c.orig
Only in yabause-wii-beta17/src: sh2core.d
Only in yabause-wii-beta17/src: sh2d.d
Only in yabause-wii-beta17/src: sh2idle.d
Only in yabause-wii-beta17/src: sh2int.d
diff -c yabause-r2604/src/smpc.c yabause-wii-beta17/src/smpc.c
*** yabause-r2604/src/smpc.c	Fri Jun 24 23:32:29 2011
--- yabause-wii-beta17/src/smpc.c	Tue Nov  2 23:18:39 2010
***************
*** 43,48 ****
--- 43,52 ----
  u8 * SmpcRegsT;
  SmpcInternal * SmpcInternalVars;
  
+ #ifdef GEKKO
+ int smpcperipheraltiming = 5000;
+ #endif
+ 
  //////////////////////////////////////////////////////////////////////////////
  
  int SmpcInit(u8 regionid, int clocksync, u32 basetime) {
***************
*** 429,435 ****
--- 433,443 ----
        ScuSendSystemManager();
        return;
     }
+ #ifndef GEKKO
     if ((SmpcInternalVars->intbackIreg0 = SmpcRegs->IREG[0]) != 0) {
+ #else
+    if ((SmpcInternalVars->intbackIreg0 = (SmpcRegs->IREG[0] & 0x1)) != 0) {
+ #endif
        // Return non-peripheral data
        SmpcInternalVars->firstPeri = 1;
        SmpcInternalVars->intback = (SmpcRegs->IREG[1] & 0x8) >> 3; // does the program want peripheral data too?
***************
*** 629,635 ****
--- 637,648 ----
  
              // If retrieving peripheral data, add 15 milliseconds
              if (SmpcRegs->IREG[1] & 0x8)
+ #ifndef GEKKO
                 SmpcInternalVars->timing += 16000; // Strangely enough, this works better
+                                                // too long for wii
+ #else
+                SmpcInternalVars->timing += smpcperipheraltiming;
+ #endif
  //               SmpcInternalVars->timing += 150;
           }
           return;
Only in yabause-wii-beta17/src: smpc.d
Only in yabause-wii-beta17/src: snddummy.d
diff -c yabause-r2604/src/sndsdl.c yabause-wii-beta17/src/sndsdl.c
*** yabause-r2604/src/sndsdl.c	Fri Jun 24 23:32:31 2011
--- yabause-wii-beta17/src/sndsdl.c	Tue Aug 17 21:50:56 2010
***************
*** 21,27 ****
  
  #include <stdlib.h>
  
! #ifdef __APPLE__
   #include <SDL/SDL.h>
  #else
   #include "SDL.h"
--- 21,27 ----
  
  #include <stdlib.h>
  
! #if defined(__APPLE__) || defined(GEKKO)
   #include <SDL/SDL.h>
  #else
   #include "SDL.h"
Only in yabause-wii-beta17/src: sndsdl.d
Only in yabause-wii-beta17/src: test.dol
Only in yabause-wii-beta17/src: thr-dummy.d
Only in yabause-wii-beta17/src: thr-dummy.o
Common subdirectories: yabause-r2604/src/tools and yabause-wii-beta17/src/tools
diff -c yabause-r2604/src/vdp1.c yabause-wii-beta17/src/vdp1.c
*** yabause-r2604/src/vdp1.c	Fri Jun 24 23:32:30 2011
--- yabause-wii-beta17/src/vdp1.c	Sat Oct  9 20:30:46 2010
***************
*** 297,303 ****
--- 297,333 ----
  
  void FASTCALL Vdp1WriteLong(u32 addr, UNUSED u32 val) {
     addr &= 0xFF;
+ #ifndef GEKKO
     LOG("trying to long-write a Vdp1 register - %08X\n", addr);
+ #else
+    switch(addr) {
+       case 0x0:
+          Vdp1Regs->TVMR = val >> 16;
+          Vdp1Regs->FBCR = val & 0xFFFF;
+          break;
+       case 0x4:
+          Vdp1Regs->PTMR = val >> 16;
+          Vdp1Regs->EWDR = val & 0xFFFF;
+          break;
+       case 0x8:
+          Vdp1Regs->EWLR = val >> 16;
+          Vdp1Regs->EWRR = val & 0xFFFF;
+          break;
+       case 0xC:
+          Vdp1Regs->ENDR = val >> 16;
+          break;
+       case 0x10:
+          Vdp1Regs->EDSR = val >> 16;
+          Vdp1Regs->LOPR = val & 0xFFFF;
+          break;
+       case 0x14:
+          Vdp1Regs->COPR = val >> 16;
+          Vdp1Regs->MODR = val & 0xFFFF;
+          break;
+       default:
+          LOG("trying to long-write a Vdp1 register - %08X\n", addr);
+    }
+ #endif
  }
  
  //////////////////////////////////////////////////////////////////////////////
***************
*** 309,316 ****
--- 339,348 ----
  
     VIDCore->Vdp1DrawStart();
  
+ #ifndef GEKKO
     if (!Vdp1Regs->PTMR)
        return;
+ #endif
  
     if (!Vdp1Regs->disptoggle)
     {
***************
*** 370,389 ****
--- 402,437 ----
        }
  
        // Next, determine where to go next
+ #ifndef GEKKO
        switch ((command & 0x3000) >> 12) {
+ #else
+       switch ((command & 0x7000) >> 12) {
+ #endif
           case 0: // NEXT, jump to following table
+ #ifdef GEKKO
+          case 4: // NEXT, jump to following table
+ #endif
              Vdp1Regs->addr += 0x20;
              break;
           case 1: // ASSIGN, jump to CMDLINK
+ #ifdef GEKKO
+          case 5: // ASSIGN, jump to CMDLINK
+ #endif
              Vdp1Regs->addr = T1ReadWord(Vdp1Ram, Vdp1Regs->addr + 2) * 8;
              break;
           case 2: // CALL, call a subroutine
+ #ifdef GEKKO
+          case 6: // CALL, call a subroutine
+ #endif
              if (returnAddr == 0xFFFFFFFF)
                 returnAddr = Vdp1Regs->addr + 0x20;
  	
              Vdp1Regs->addr = T1ReadWord(Vdp1Ram, Vdp1Regs->addr + 2) * 8;
              break;
           case 3: // RETURN, return from subroutine
+ #ifdef GEKKO
+          case 7: // RETURN, return from subroutine
+ #endif
              if (returnAddr != 0xFFFFFFFF) {
                 Vdp1Regs->addr = returnAddr;
                 returnAddr = 0xFFFFFFFF;
***************
*** 411,419 ****
--- 459,469 ----
     u32 commandCounter;
     u16 command;
  
+ #ifndef GEKKO
     // Only when PTMR's not set do we not parse commands
     if (!Vdp1Regs->PTMR)
        return;
+ #endif
  
     Vdp1Regs->addr = 0;
     returnAddr = 0xFFFFFFFF;
***************
*** 456,475 ****
--- 506,541 ----
        }
  
        // Next, determine where to go next
+ #ifndef GEKKO
        switch ((command & 0x3000) >> 12) {
+ #else
+       switch ((command & 0x7000) >> 12) {
+ #endif
           case 0: // NEXT, jump to following table
+ #ifdef GEKKO
+          case 4: // NEXT, jump to following table
+ #endif
              Vdp1Regs->addr += 0x20;
              break;
           case 1: // ASSIGN, jump to CMDLINK
+ #ifdef GEKKO
+          case 5: // ASSIGN, jump to CMDLINK
+ #endif
              Vdp1Regs->addr = T1ReadWord(Vdp1Ram, Vdp1Regs->addr + 2) * 8;
              break;
           case 2: // CALL, call a subroutine
+ #ifdef GEKKO
+          case 6: // CALL, call a subroutine
+ #endif
              if (returnAddr == 0xFFFFFFFF)
                 returnAddr = Vdp1Regs->addr + 0x20;
  	
              Vdp1Regs->addr = T1ReadWord(Vdp1Ram, Vdp1Regs->addr + 2) * 8;
              break;
           case 3: // RETURN, return from subroutine
+ #ifdef GEKKO
+          case 7: // RETURN, return from subroutine
+ #endif
              if (returnAddr != 0xFFFFFFFF) {
                 Vdp1Regs->addr = returnAddr;
                 returnAddr = 0xFFFFFFFF;
Only in yabause-wii-beta17/src: vdp1.d
diff -c yabause-r2604/src/vdp1.h yabause-wii-beta17/src/vdp1.h
*** yabause-r2604/src/vdp1.h	Fri Jun 24 23:32:30 2011
--- yabause-wii-beta17/src/vdp1.h	Tue Aug 17 21:50:56 2010
***************
*** 96,103 ****
--- 96,108 ----
     u32 addr;
     int disptoggle;
  
+ #ifndef GEKKO
     u16 localX;
     u16 localY;
+ #else // from rr branch
+    s16 localX;
+    s16 localY;
+ #endif
  
     u16 systemclipX1;
     u16 systemclipY1;
diff -c yabause-r2604/src/vdp2.c yabause-wii-beta17/src/vdp2.c
*** yabause-r2604/src/vdp2.c	Fri Jun 24 23:32:28 2011
--- yabause-wii-beta17/src/vdp2.c	Sun Oct 24 15:38:54 2010
***************
*** 46,55 ****
--- 46,63 ----
  static u64 diffticks=0;
  static u32 framecount=0;
  static u64 onesecondticks=0;
+ #ifndef GEKKO
  static int fps;
+ #else
+ int fps;
+ #endif
  static int fpsframecount=0;
  static u64 fpsticks;
+ #ifndef GEKKO
  static int fpstoggle=0;
+ #else
+ int fpstoggle=0;
+ #endif
  
  //////////////////////////////////////////////////////////////////////////////
  int GetOSDToggle(void)
***************
*** 400,406 ****
--- 408,418 ----
        diffticks = curticks-lastticks;
  
        if ((onesecondticks+diffticks) > ((yabsys.OneFrameTime * (u64)framecount) + (yabsys.OneFrameTime / 2)) &&
+ #ifndef GEKKO
            framesskipped < 9)
+ #else // more frameskip for speed ..
+           framesskipped < 14)
+ #endif
        {
           // Skip the next frame
           skipnextframe = 1;
***************
*** 469,474 ****
--- 481,490 ----
           return Vdp2Regs->HCNT;
        case 0x00A:
           return Vdp2Regs->VCNT;
+ #ifdef GEKKO
+       case 0x00E:
+          return Vdp2Regs->RAMCTL;
+ #endif
        default:
        {
           LOG("Unhandled VDP2 word read: %08X\n", addr);
***************
*** 482,489 ****
--- 498,518 ----
  //////////////////////////////////////////////////////////////////////////////
  
  u32 FASTCALL Vdp2ReadLong(u32 addr) {
+ #ifndef GEKKO
     LOG("VDP2 register long read = %08X\n", addr);
+ #else
     addr &= 0x1FF;
+    switch (addr)
+    {
+       case 0x058:
+          return (Vdp2Regs->MPIJRA << 16 | Vdp2Regs->MPKLRA);
+       default:
+       {
+          LOG("VDP2 register long read = %08X\n", addr);
+          break;
+       }
+    }
+ #endif
     return 0;
  }
  
***************
*** 970,975 ****
--- 999,1007 ----
           return;
        case 0x00C:
           Vdp2Regs->RAMCTL = val & 0xFFFF;
+ #ifdef GEKKO
+          Vdp2Internal.ColorMode = (Vdp2Regs->RAMCTL >> 12) & 0x3;
+ #endif
           return;
        case 0x010:
           Vdp2Regs->CYCA0L = val >> 16;
***************
*** 1103,1108 ****
--- 1135,1146 ----
           Vdp2Regs->SCXN3 = val >> 16;
           Vdp2Regs->SCYN3 = val & 0xFFFF;
           return;
+ #ifdef GEKKO
+       case 0x098:
+          Vdp2Regs->ZMCTL = val >> 16;
+          Vdp2Regs->SCRCTL = val & 0xFFFF;
+          return;
+ #endif
        case 0x09C:
           Vdp2Regs->VCSTA.all = val;
           return;
***************
*** 1112,1125 ****
--- 1150,1207 ----
        case 0x0A4:
           Vdp2Regs->LSTA1.all = val;
           return;
+ #ifdef GEKKO
+       case 0x0A8:
+          Vdp2Regs->LCTA.all = val;
+          return;
+ #endif
        case 0x0AC:
           Vdp2Regs->BKTAU = val >> 16;
           Vdp2Regs->BKTAL = val & 0xFFFF;
           return;
+ #ifdef GEKKO
+       case 0x0B0:
+          Vdp2Regs->RPMD = val >> 16;
+          Vdp2Regs->RPRCTL = val & 0xFFFF;
+          return;
+       case 0x0B4:
+          Vdp2Regs->KTCTL = val >> 16;
+          Vdp2Regs->KTAOF = val & 0xFFFF;
+          return;
+       case 0x0B8:
+          Vdp2Regs->OVPNRA = val >> 16;
+          Vdp2Regs->OVPNRB = val & 0xFFFF;
+          return;
+       case 0x0BC:
+          Vdp2Regs->RPTA.all = val;
+          return;
+       case 0x0C0:
+          Vdp2Regs->WPSX0 = val >> 16;
+          Vdp2Regs->WPSY0 = val & 0xFFFF;
+          return;
+       case 0x0C4:
+          Vdp2Regs->WPEX0 = val >> 16;
+          Vdp2Regs->WPEY0 = val & 0xFFFF;
+          return;
+       case 0x0C8:
+          Vdp2Regs->WPSX1 = val >> 16;
+          Vdp2Regs->WPSY1 = val & 0xFFFF;
+          return;
+       case 0x0CC:
+          Vdp2Regs->WPEX1 = val >> 16;
+          Vdp2Regs->WPEY1 = val & 0xFFFF;
+          return;
+ #endif
        case 0x0D0:
           Vdp2Regs->WCTLA = val >> 16;
           Vdp2Regs->WCTLB = val & 0xFFFF;
           return;
+ #ifdef GEKKO
+       case 0x0D4:
+          Vdp2Regs->WCTLC = val >> 16;
+          Vdp2Regs->WCTLD = val & 0xFFFF;
+          return;
+ #endif
        case 0x0D8:
           Vdp2Regs->LWTA0.all = val;
           return;
***************
*** 1158,1163 ****
--- 1240,1251 ----
           VIDCore->Vdp2SetPriorityNBG2(Vdp2Regs->PRINB & 0x7);
           VIDCore->Vdp2SetPriorityNBG3((Vdp2Regs->PRINB >> 8) & 0x7);
           return;
+ #ifdef GEKKO
+       case 0x0FC:
+          Vdp2Regs->PRIR = val >> 16;
+          VIDCore->Vdp2SetPriorityRBG0(Vdp2Regs->PRIR & 0x7);
+          return;
+ #endif
        case 0x100:
           Vdp2Regs->CCRSA = val >> 16;
           Vdp2Regs->CCRSB = val & 0xFFFF;
Only in yabause-wii-beta17/src: vdp2.d
Only in yabause-wii-beta17/src: vidshared.d
diff -c yabause-r2604/src/vidshared.h yabause-wii-beta17/src/vidshared.h
*** yabause-r2604/src/vidshared.h	Fri Jun 24 23:32:30 2011
--- yabause-wii-beta17/src/vidshared.h	Wed Sep 22 23:53:12 2010
***************
*** 36,45 ****
  
     int cellw_bits, cellh_bits;
     int mapwh;
!    int planew, planew_bits, planeh, planeh_bits;
!    int pagewh, pagewh_bits;
!    int patternwh, patternwh_bits;
!    int patterndatasize, patterndatasize_bits;
     int specialfunction;
     u32 addr, charaddr, paladdr;
     int colornumber;
--- 36,45 ----
  
     int cellw_bits, cellh_bits;
     int mapwh;
!    int planew, planew_bits, planeh, planeh_bits;
!    int pagewh, pagewh_bits;
!    int patternwh, patternwh_bits;
!    int patterndatasize, patterndatasize_bits;
     int specialfunction;
     u32 addr, charaddr, paladdr;
     int colornumber;
***************
*** 56,61 ****
--- 56,66 ----
     s32 cor;
     s32 cog;
     s32 cob;
+ #ifdef GEKKO
+    u32 oldpixel;
+    int colorcalcmode;
+    int docolorcalcenable;
+ #endif
  
     float coordincx, coordincy;
     void FASTCALL (* PlaneAddr)(void *, int);
***************
*** 165,175 ****
--- 170,229 ----
     int xend, yend;
  } clipping_struct;
  
+ #ifndef GEKKO
  #define tofixed(v) ((v) * (1 << FP_SIZE))
  #define toint(v) ((v) >> FP_SIZE)
  #define touint(v) ((u16)((v) >> FP_SIZE))
  #define tofloat(v) ((float)(v) / (float)(1 << FP_SIZE))
  #define mulfixed(a,b) ((fixed32)((s64)(a) * (s64)(b) >> FP_SIZE))
+ #else
+ // a litte fast, but not accurate
+ #define tofixed(v)                     \
+ ({fixed32 _v=(v);                      \
+     asm volatile("slwi %0,%0,16"       \
+                  :"=r" (_v)            \
+                  :"0" (_v)             \
+                 );                     \
+      (fixed32)_v;                      \
+  })
+ #define toint(v)                       \
+ ({fixed32 _v=(v);                      \
+     asm volatile("srawi %0,%0,16"      \
+                  :"=r" (_v)            \
+                  :"0" (_v)             \
+                 );                     \
+      (fixed32)_v;                      \
+  })
+ #define touint(v)                      \
+ ({fixed32 _v=(v);                      \
+     asm volatile("srwi %0,%0,16"       \
+                  :"=r" (_v)            \
+                  :"0" (_v)             \
+                 );                     \
+      (u16)_v;                          \
+  })
+ #define tofloat(v)                     \
+ ({float _v=(v), _w=(float)0x10000;     \
+     asm volatile("fdivs  %0,%0,%2"     \
+                  :"=f" (_v)            \
+                  :"0" (_v), "f" (_w)   \
+                 );                     \
+      (float)_v;                        \
+  })
+ #define mulfixed(a,b)                  \
+ ({fixed32 _a=(a), _b=(b);              \
+     asm volatile("mullw 8,%2,%0;"      \
+                  "mulhw 7,%2,%0;"      \
+                  "srwi 8,8,16;"        \
+                  "slwi 7,7,16;"        \
+                  "or %0,7,8"           \
+                  :"=r" (_a)            \
+                  :"0" (_a), "r" (_b)   \
+                  :"7","8"              \
+                 );                     \
+      (fixed32)_a;                      \
+ })
+ #endif
  #define divfixed(a,b) (((s64)(a) << FP_SIZE) / (b))
  
  void FASTCALL Vdp2NBG0PlaneAddr(vdp2draw_struct *info, int i);
***************
*** 343,361 ****
     {
        case 0:
           info->planew = info->planeh = 1;
! 		 info->planew_bits = info->planeh_bits = 0;
           break;
        case 1:
!          info->planew = 2; info->planew_bits = 1;
!          info->planeh = 1; info->planeh_bits = 0;
           break;
        case 3:
           info->planew = info->planeh = 2;
! 		 info->planew_bits = info->planeh_bits = 1;
           break;
        default: // Not sure what 0x2 does, though a few games seem to use it
           info->planew = info->planeh = 1;
! 		 info->planew_bits = info->planeh_bits = 0;
           break;
     }
  }
--- 397,415 ----
     {
        case 0:
           info->planew = info->planeh = 1;
! 		 info->planew_bits = info->planeh_bits = 0;
           break;
        case 1:
!          info->planew = 2; info->planew_bits = 1;
!          info->planeh = 1; info->planeh_bits = 0;
           break;
        case 3:
           info->planew = info->planeh = 2;
! 		 info->planew_bits = info->planeh_bits = 1;
           break;
        default: // Not sure what 0x2 does, though a few games seem to use it
           info->planew = info->planeh = 1;
! 		 info->planew_bits = info->planeh_bits = 0;
           break;
     }
  }
***************
*** 365,393 ****
  static INLINE void ReadPatternData(vdp2draw_struct *info, u16 pnc, int chctlwh)
  {
     if(pnc & 0x8000)
!    {
        info->patterndatasize = 1;
! 	  info->patterndatasize_bits = 0;
!    }
     else
!    {
        info->patterndatasize = 2;
! 	  info->patterndatasize_bits = 1;
!    }
  
     if(chctlwh)
!    {
        info->patternwh = 2;
! 	  info->patternwh_bits = 1;
!    }
     else
!    {
        info->patternwh = 1;
! 	  info->patternwh_bits = 0;
!    }
  
!    info->pagewh = 64>>info->patternwh_bits;
!    info->pagewh_bits = 6-info->patternwh_bits;
     info->cellw = info->cellh = 8;
     info->cellw_bits = info->cellh_bits = 3;
     info->supplementdata = pnc & 0x3FF;
--- 419,447 ----
  static INLINE void ReadPatternData(vdp2draw_struct *info, u16 pnc, int chctlwh)
  {
     if(pnc & 0x8000)
!    {
        info->patterndatasize = 1;
! 	  info->patterndatasize_bits = 0;
!    }
     else
!    {
        info->patterndatasize = 2;
! 	  info->patterndatasize_bits = 1;
!    }
  
     if(chctlwh)
!    {
        info->patternwh = 2;
! 	  info->patternwh_bits = 1;
!    }
     else
!    {
        info->patternwh = 1;
! 	  info->patternwh_bits = 0;
!    }
  
!    info->pagewh = 64>>info->patternwh_bits;
!    info->pagewh_bits = 6-info->patternwh_bits;
     info->cellw = info->cellh = 8;
     info->cellw_bits = info->cellh_bits = 3;
     info->supplementdata = pnc & 0x3FF;
***************
*** 429,452 ****
--- 483,552 ----
  {
     if (wctl & 0x2)
     {
+ #ifndef GEKKO
        clip[0].xstart = Vdp2Regs->WPSX0 >> 1; // fix me
        clip[0].ystart = Vdp2Regs->WPSY0;
        clip[0].xend = Vdp2Regs->WPEX0 >> 1; // fix me
        clip[0].yend = Vdp2Regs->WPEY0;
+ #else
+       clip[0].xstart = Vdp2Regs->WPSX0;
+       clip[0].ystart = Vdp2Regs->WPSY0 & 0x1FF;
+       clip[0].xend = Vdp2Regs->WPEX0;
+       clip[0].yend = Vdp2Regs->WPEY0 & 0x1FF;
+ #endif
     }
  
     if (wctl & 0x8)
     {
+ #ifndef GEKKO
        clip[1].xstart = Vdp2Regs->WPSX1 >> 1; // fix me
        clip[1].ystart = Vdp2Regs->WPSY1;
        clip[1].xend = Vdp2Regs->WPEX1 >> 1; // fix me
        clip[1].yend = Vdp2Regs->WPEY1;
+ #else
+       clip[1].xstart = Vdp2Regs->WPSX1;
+       clip[1].ystart = Vdp2Regs->WPSY1 & 0x1FF;
+       clip[1].xend = Vdp2Regs->WPEX1;
+       clip[1].yend = Vdp2Regs->WPEY1 & 0x1FF;
+ #endif
     }
  
+ #if 0
     if (wctl & 0x20)
     {
        // fix me
     }
+ #endif
+ 
+ #ifdef GEKKO
+    switch ((Vdp2Regs->TVMD >> 1) & 0x3)
+    {
+       case 0: // Normal
+          clip[0].xstart = (clip[0].xstart >> 1) & 0x1FF;
+          clip[0].xend = (clip[0].xend >> 1) & 0x1FF;
+          clip[1].xstart = (clip[1].xstart >> 1) & 0x1FF;
+          clip[1].xend = (clip[1].xend >> 1) & 0x1FF;
+          break;
+       case 1: // Hi-Res
+          clip[0].xstart = clip[0].xstart & 0x3FF;
+          clip[0].xend= clip[0].xend & 0x3FF;
+          clip[1].xstart = clip[1].xstart & 0x3FF;
+          clip[1].xend= clip[1].xend & 0x3FF;
+          break;
+       case 2: // Exclusive Normal
+          clip[0].xstart = clip[0].xstart & 0x1FF;
+          clip[0].xend = clip[0].xend & 0x1FF;
+          clip[1].xstart = clip[1].xstart & 0x1FF;
+          clip[1].xend = clip[1].xend & 0x1FF;
+          break;
+       case 3: // Exclusive Hi-Res
+          clip[0].xstart = (clip[0].xstart & 0x3FF) >> 1;
+          clip[0].xend = (clip[0].xend & 0x3FF) >> 1;
+          clip[1].xstart = (clip[1].xstart & 0x3FF) >> 1;
+          clip[1].xend = (clip[1].xend & 0x3FF) >> 1;
+          break;
+    }
+ #endif
  }
  
  //////////////////////////////////////////////////////////////////////////////
***************
*** 471,493 ****
--- 571,668 ----
  
  static INLINE void ReadLineWindowClip(int islinewindow, clipping_struct *clip, u32 *linewnd0addr, u32 *linewnd1addr)
  {
+ #ifdef GEKKO
+    u8 TVMD = ((Vdp2Regs->TVMD >> 1) & 0x3);
+ #endif
     if (islinewindow)
     {
        // Fetch new xstart and xend values from table
        if (islinewindow & 0x1)
        {
           // Window 0
+ #ifndef GEKKO
           clip[0].xstart = (T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x3FF) >> 1; // fix me
+ #else
+    switch (TVMD)
+    {
+       case 0: // Normal
+          clip[0].xstart = ((T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x3FF) >> 1) & 0x1FF;
+          break;
+       case 1: // Hi-Res
+          clip[0].xstart = (T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x3FF);
+          break;
+       case 2: // Exclusive Normal
+          clip[0].xstart = (T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x1FF);
+          break;
+       case 3: // Exclusive Hi-Res
+          clip[0].xstart = ((T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x3FF) >> 1);
+          break;
+    }
+ #endif
           linewnd0addr[0]+=2;
+ #ifndef GEKKO
           clip[0].xend = (T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x3FF) >> 1; // fix me
+ #else
+    switch (TVMD)
+    {
+       case 0: // Normal
+          clip[0].xend= ((T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x3FF) >> 1) & 0x1FF;
+          break;
+       case 1: // Hi-Res
+          clip[0].xend= (T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x3FF);
+          break;
+       case 2: // Exclusive Normal
+          clip[0].xend= (T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x1FF);
+          break;
+       case 3: // Exclusive Hi-Res
+          clip[0].xend= ((T1ReadWord(Vdp2Ram, linewnd0addr[0]) & 0x3FF) >> 1);
+          break;
+    }
+ #endif
           linewnd0addr[0]+=2;
        }
        if (islinewindow & 0x2)
        {
           // Window 1
+ #ifndef GEKKO
           clip[1].xstart = (T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x3FF) >> 1; // fix me
+ #else
+    switch (TVMD)
+    {
+       case 0: // Normal
+          clip[1].xstart = ((T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x3FF) >> 1) & 0x1FF;
+          break;
+       case 1: // Hi-Res
+          clip[1].xstart = (T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x3FF);
+          break;
+       case 2: // Exclusive Normal
+          clip[1].xstart = (T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x1FF);
+          break;
+       case 3: // Exclusive Hi-Res
+          clip[1].xstart = ((T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x3FF) >> 1);
+          break;
+    }
+ #endif
           linewnd1addr[0]+=2;
+ #ifndef GEKKO
           clip[1].xend = (T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x3FF) >> 1; // fix me
+ #else
+    switch (TVMD)
+    {
+       case 0: // Normal
+          clip[1].xend= ((T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x3FF) >> 1) & 0x1FF;
+          break;
+       case 1: // Hi-Res
+          clip[1].xend= (T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x3FF);
+          break;
+       case 2: // Exclusive Normal
+          clip[1].xend= (T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x1FF);
+          break;
+       case 3: // Exclusive Hi-Res
+          clip[1].xend= ((T1ReadWord(Vdp2Ram, linewnd1addr[0]) & 0x3FF) >> 1);
+          break;
+    }
+ #endif
           linewnd1addr[0]+=2;
        }
     }
***************
*** 513,518 ****
--- 688,694 ----
  
  static INLINE int IsScreenRotatedFP(vdp2rotationparameterfp_struct *parameter)
  {
+ #ifndef GEKKO
    return (parameter->deltaXst == tofixed(0.0) &&
            parameter->deltaYst == tofixed(1.0) &&
            parameter->deltaX == tofixed(1.0) &&
***************
*** 523,528 ****
--- 699,716 ----
            parameter->D == tofixed(0.0) &&
            parameter->E == tofixed(1.0) &&
            parameter->F == tofixed(0.0));
+ #else
+   return (parameter->deltaXst == 0x0 &&
+           parameter->deltaYst == 0x10000 &&
+           parameter->deltaX == 0x10000 &&
+           parameter->deltaY == 0x0 &&
+           parameter->A == 0x10000 &&
+           parameter->B == 0x0 &&
+           parameter->C == 0x0 &&
+           parameter->D == 0x0 &&
+           parameter->E == 0x10000 &&
+           parameter->F == 0x0);
+ #endif
  }
  
  //////////////////////////////////////////////////////////////////////////////
***************
*** 602,607 ****
--- 790,796 ----
  
  static INLINE void Vdp1ProcessSpritePixel(int type, u16 *pixel, int *shadow, int *priority, int *colorcalc)
  {
+ #ifndef GEKKO
     switch(type)
     {
        case 0x0:
***************
*** 730,735 ****
--- 919,941 ----
        }
        default: break;
     }
+ #else // from psp-video.c
+     static const uint8_t priority_shift[16] =
+         { 14, 13, 14, 13,  13, 12, 12, 12,  7, 7, 6, 0,  7, 7, 6, 0 };
+     static const uint8_t priority_mask[16] =
+         {  3,  7,  1,  3,   3,  7,  7,  7,  1, 1, 3, 0,  1, 1, 3, 0 };
+     static const uint8_t alpha_shift[16] =
+         { 11, 11, 11, 11,  10, 11, 10,  9,  0, 6, 0, 6,  0, 6, 0, 6 };
+     static const uint8_t alpha_mask[16] =
+         {  7,  3,  7,  3,   7,  1,  3,  7,  0, 1, 0, 3,  0, 1, 0, 3 };
+     static const uint16_t color_mask[16] =
+         { 0x7FF, 0x7FF, 0x7FF, 0x7FF,  0x3FF, 0x7FF, 0x3FF, 0x1FF,
+            0x7F,  0x3F,  0x3F,  0x3F,   0xFF,  0xFF,  0xFF,  0xFF };
+ 
+     *priority  = (*pixel >> priority_shift[type]) & priority_mask[type];
+     *colorcalc = (*pixel >>    alpha_shift[type]) &    alpha_mask[type];
+     *pixel     = *pixel & color_mask[type];
+ #endif
  }
  
  //////////////////////////////////////////////////////////////////////////////
Only in yabause-wii-beta17/src: vidshared.h.orig
diff -c yabause-r2604/src/vidsoft.c yabause-wii-beta17/src/vidsoft.c
*** yabause-r2604/src/vidsoft.c	Fri Jun 24 23:32:30 2011
--- yabause-wii-beta17/src/vidsoft.c	Wed Oct 27 22:42:39 2010
***************
*** 47,52 ****
--- 47,56 ----
  static INLINE u32 COLSAT2YAB32(int priority,u32 temp)            { return (((temp & 0xFF) << 24) | ((temp & 0xFF00) << 8) | ((temp & 0xFF0000) >> 8) | priority); }
  static INLINE u32 COLSAT2YAB32_2(int priority,u32 temp1,u32 temp2)   { return (((temp2 & 0xFF) << 24) | ((temp2 & 0xFF00) << 8) | ((temp1 & 0xFF) << 8) | priority); }
  static INLINE u32 COLSATSTRIPPRIORITY(u32 pixel)              { return (pixel | 0xFF); }
+ #ifdef GEKKO
+ static INLINE u32 COLSAT2YAB16LIT(int priority,u32 temp) { return (priority << 24 | (temp & 0x1F) << 3 | (temp & 0x3E0) << 6 | (temp & 0x7C00) << 9); }
+ static INLINE u32 COLSAT2YAB32LIT(int priority, u32 temp) { return (priority << 24 | (temp & 0xFF0000) | (temp & 0xFF00) | (temp & 0xFF)); }
+ #endif
  #else
  static INLINE u32 COLSAT2YAB16(int priority,u32 temp) { return (priority << 24 | (temp & 0x1F) << 3 | (temp & 0x3E0) << 6 | (temp & 0x7C00) << 9); }
  static INLINE u32 COLSAT2YAB32(int priority, u32 temp) { return (priority << 24 | (temp & 0xFF0000) | (temp & 0xFF00) | (temp & 0xFF)); }
***************
*** 61,66 ****
--- 65,80 ----
                                  (COLOR_ADDb((l >> 8) & 0xFF, g) << 16) | \
                                  (COLOR_ADDb((l >> 16) & 0xFF, b) << 8) | \
                                  ((l >> 24) & 0xFF)
+ #ifdef GEKKO
+ #define COLOR_ADDBIG(l,r,g,b)   (COLOR_ADDb((l >> 24), r) << 24) | \
+                                 (COLOR_ADDb((l >> 16) & 0xFF, g) << 16) | \
+                                 (COLOR_ADDb((l >> 8) & 0xFF, b) << 8) |   \
+                                 (l & 0xFF)
+ #define COLOR_ADD16LIT(l,r,g,b) (COLOR_ADDb((l << 3) & 0xF8, r)) |       \
+                                 (COLOR_ADDb((l >> 2) & 0xF8, g) << 8) |  \
+                                 (COLOR_ADDb((l >> 7) & 0xF8, b) << 16) | \
+                                 (l & 0x8000)
+ #endif
  #else
  #define COLOR_ADD(l,r,g,b)	COLOR_ADDb((l & 0xFF), r) | \
                                  (COLOR_ADDb((l >> 8) & 0xFF, g) << 8) | \
***************
*** 148,153 ****
--- 162,172 ----
  
  static int vdp1width;
  static int vdp1height;
+ #ifdef GEKKO
+ int vdp1w;
+ int vdp1h;
+ extern int specialcoloron;
+ #endif
  static int vdp1clipxstart;
  static int vdp1clipxend;
  static int vdp1clipystart;
***************
*** 197,204 ****
--- 216,227 ----
  static INLINE u8 Vdp2GetPixelPriority(u32 pixel)
  {
  #if defined WORDS_BIGENDIAN
+ #ifndef GEKKO
     return pixel;
  #else
+    return (pixel & 0xFF);
+ #endif
+ #else
     return pixel >> 24;
  #endif
  }
***************
*** 333,339 ****
--- 356,366 ----
  
  static INLINE u32 FASTCALL DoColorOffset(void *info, u32 pixel)
  {
+ #ifndef GEKKO
      return COLOR_ADD(pixel, ((vdp2draw_struct *)info)->cor,
+ #else
+     return COLOR_ADDBIG(pixel, ((vdp2draw_struct *)info)->cor,
+ #endif
                       ((vdp2draw_struct *)info)->cog,
                       ((vdp2draw_struct *)info)->cob);
  }
***************
*** 342,379 ****
  
  static INLINE u32 FASTCALL DoColorCalc(void *info, u32 pixel)
  {
! #if 0
     u8 oldr, oldg, oldb;
     u8 r, g, b;
!    u32 oldpixel = 0x00FFFFFF; // fix me
  
!    static int topratio[32] = {
        31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16,
        15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
     };
!    static int bottomratio[32] = {
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
        17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
     };
  
     // separate color components for top and second pixel
!    r = (pixel & 0xFF) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
!    g = ((pixel >> 8) & 0xFF) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
!    b = ((pixel >> 16) & 0xFF) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
  
  #ifdef WORDS_BIGENDIAN
!    oldr = ((oldpixel >> 24) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldg = ((oldpixel >> 16) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldb = ((oldpixel >> 8) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
  #else
     oldr = (oldpixel & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldg = ((oldpixel >> 8) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldb = ((oldpixel >> 16) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
  #endif
  
     // add color components and reform the pixel
     pixel = ((b + oldb) << 16) | ((g + oldg) << 8) | (r + oldr);
  #endif
     return pixel;
  }
  
--- 369,446 ----
  
  static INLINE u32 FASTCALL DoColorCalc(void *info, u32 pixel)
  {
! #ifdef GEKKO
     u8 oldr, oldg, oldb;
     u8 r, g, b;
!    //u32 oldpixel = 0x00FFFFFF; // fix me
!    u32 oldpixel = ((vdp2draw_struct *)info)->oldpixel;
  
!    static const int topratio[32] = {
        31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16,
        15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
     };
!    static const int bottomratio[32] = {
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
        17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
     };
  
+    if(((vdp2draw_struct *)info)->colorcalcmode)
+    {
+ #ifdef WORDS_BIGENDIAN
     // separate color components for top and second pixel
!    r = (pixel >> 24);
!    g = ((pixel >> 16) & 0xFF);
!    b = ((pixel >> 8) & 0xFF);
!    oldr = (oldpixel >> 24);
!    oldg = ((oldpixel >> 16) & 0xFF);
!    oldb = ((oldpixel >> 8) & 0xFF);
! #else
!    // separate color components for top and second pixel
!    r = (pixel & 0xFF);
!    g = ((pixel >> 8) & 0xFF);
!    b = ((pixel >> 16) & 0xFF);
!    oldr = (oldpixel & 0xFF);
!    oldg = ((oldpixel >> 8) & 0xFF);
!    oldb = ((oldpixel >> 16) & 0xFF);
! #endif
! 
!    // add color components and reform the pixel
! #ifdef WORDS_BIGENDIAN
!    pixel = (COLOR_ADDb(b, oldb) << 8) | (COLOR_ADDb(g, oldg) << 16) | (COLOR_ADDb(r, oldr) << 24) | (pixel & 0xFF);
! #else
!    pixel = (COLOR_ADDb(b, oldb) << 16) | (COLOR_ADDb(g, oldg) << 8) | COLOR_ADDb(r, oldr);
! #endif
! 
!    }
!    else
!    {
  
  #ifdef WORDS_BIGENDIAN
!    // separate color components for top and second pixel
!    r = (pixel >> 24) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
!    g = ((pixel >> 16) & 0xFF) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
!    b = ((pixel >> 8) & 0xFF) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
!    oldr = (oldpixel >> 24) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldg = ((oldpixel >> 16) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldb = ((oldpixel >> 8) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
  #else
+    // separate color components for top and second pixel
+    r = (pixel & 0xFF) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
+    g = ((pixel >> 8) & 0xFF) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
+    b = ((pixel >> 16) & 0xFF) * topratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldr = (oldpixel & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldg = ((oldpixel >> 8) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
     oldb = ((oldpixel >> 16) & 0xFF) * bottomratio[((vdp2draw_struct *)info)->alpha] >> 5;
  #endif
  
     // add color components and reform the pixel
+ #ifdef WORDS_BIGENDIAN
+    pixel = ((b + oldb) << 8) | ((g + oldg) << 16) | ((r + oldr) << 24) | (pixel & 0xFF);
+ #else
     pixel = ((b + oldb) << 16) | ((g + oldg) << 8) | (r + oldr);
  #endif
+    }
+ #endif
     return pixel;
  }
  
***************
*** 383,389 ****
--- 450,460 ----
  {
     pixel = DoColorCalc(info, pixel);
  
+ #ifndef GEKKO
     return COLOR_ADD(pixel, ((vdp2draw_struct *)info)->cor,
+ #else
+    return COLOR_ADDBIG(pixel, ((vdp2draw_struct *)info)->cor,
+ #endif
                      ((vdp2draw_struct *)info)->cog,
                      ((vdp2draw_struct *)info)->cob);
  }
***************
*** 392,397 ****
--- 463,471 ----
  
  static INLINE void ReadVdp2ColorOffset(vdp2draw_struct *info, int clofmask, int ccmask)
  {
+ #ifdef GEKKO
+    info->cor = info->cog = info->cob = 0;
+ #endif
     if (Vdp2Regs->CLOFEN & clofmask)
     {
        // color offset enable
***************
*** 428,441 ****
--- 502,523 ----
  
        if (info->cor == 0 && info->cog == 0 && info->cob == 0)
        {
+ #ifndef GEKKO
           if (Vdp2Regs->CCCTL & ccmask)
+ #else
+          if ((Vdp2Regs->CCCTL & ccmask) && specialcoloron)
+ #endif
              info->PostPixelFetchCalc = &DoColorCalc;
           else
              info->PostPixelFetchCalc = &DoNothing;
        }
        else
        {
+ #ifndef GEKKO
           if (Vdp2Regs->CCCTL & ccmask)
+ #else
+          if ((Vdp2Regs->CCCTL & ccmask) && specialcoloron)
+ #endif
              info->PostPixelFetchCalc = &DoColorCalcWithColorOffset;
           else
              info->PostPixelFetchCalc = &DoColorOffset;
***************
*** 443,453 ****
--- 525,545 ----
     }
     else // color offset disable
     {
+ #ifndef GEKKO
        if (Vdp2Regs->CCCTL & ccmask)
+ #else
+       if ((Vdp2Regs->CCCTL & ccmask) && specialcoloron)
+ #endif
           info->PostPixelFetchCalc = &DoColorCalc;
        else
           info->PostPixelFetchCalc = &DoNothing;
     }
+ #ifdef GEKKO
+    if ((Vdp2Regs->CCCTL & ccmask) && specialcoloron)
+       info->docolorcalcenable = 1;
+    else
+       info->docolorcalcenable = 0;
+ #endif
  
  }
  
***************
*** 489,495 ****
--- 581,591 ----
           if (!(dot & 0x8000) && info->transparencyenable) return 0;
           else
           {
+ #ifndef GEKKO
              *color = COLSAT2YAB16(0, dot);
+ #else
+             *color = COLSAT2YAB16LIT(0, dot);
+ #endif
              return 1;
           }
        case 4: // 32 BPP
***************
*** 497,503 ****
--- 593,603 ----
           if (!(dot & 0x80000000) && info->transparencyenable) return 0;
           else
           {
+ #ifndef GEKKO
              *color = COLSAT2YAB32(0, dot);
+ #else
+             *color = COLSAT2YAB32LIT(0, dot);
+ #endif
              return 1;
           }
        default:
***************
*** 524,533 ****
           if (x >= clip->xstart && x <= clip->xend &&
               y >= clip->ystart && y <= clip->yend)
              return 0;
! 
  		 //it seems to overflow vertically on hardware
  		 if(clip->yend > vdp2height && (x >= clip->xstart && x <= clip->xend ))
  			 return 0;
        }
     }
     return 1;
--- 624,634 ----
           if (x >= clip->xstart && x <= clip->xend &&
               y >= clip->ystart && y <= clip->yend)
              return 0;
! #ifndef GEKKO
  		 //it seems to overflow vertically on hardware
  		 if(clip->yend > vdp2height && (x >= clip->xstart && x <= clip->xend ))
  			 return 0;
+ #endif
        }
     }
     return 1;
***************
*** 539,545 ****
--- 640,650 ----
  {
     int i;
  
+ #ifndef GEKKO
     for (i = 0; i < (info->mapwh*info->mapwh); i++)
+ #else
+    for (i = info->mapwh*info->mapwh -1; i >= 0; i--)
+ #endif
     {
        info->PlaneAddr(info, i);
        planetbl[i] = info->addr;
***************
*** 705,712 ****
--- 810,822 ----
     int scrollx, scrolly;
     int *mosaic_y, *mosaic_x;
  
+ #ifndef GEKKO
     info->coordincx *= (float)resxratio;
     info->coordincy *= (float)resyratio;
+ #else
+    info->coordincx *= (float)(resxratio+1);
+    info->coordincy *= (float)(resyratio+1);
+ #endif
  
     SetupScreenVars(info, &sinfo);
  
***************
*** 736,741 ****
--- 846,855 ----
  	   mosaic_y = mosaic_table[info->mosaicymask-1];
     }
  
+ #ifdef GEKKO
+    info->colorcalcmode = (Vdp2Regs->CCCTL & 0x100);
+ #endif
+ 
     for (j = 0; j < height; j++)
     {
        int Y;
***************
*** 790,796 ****
--- 904,914 ----
  
           // See if screen position is clipped, if it isn't, continue
  		 // AND window logic
+ #ifndef GEKKO
  		 if(!TestWindow(info->wctl, 0x2, 0x1, &clip[0], i, j) && !TestWindow(info->wctl, 0x8, 0x4, &clip[1], i, j) && (info->wctl & 0x80) == 0x80)
+ #else
+ 		 if(!TestWindow(info->wctl, 0x2, 0x1, &clip[0], i << resxratio, j << resyratio) && !TestWindow(info->wctl, 0x8, 0x4, &clip[1], i << resxratio, j << resyratio) && (info->wctl & 0x80) == 0x80)
+ #endif
  		 {
  			 textdata++;
  			 continue;
***************
*** 798,811 ****
--- 916,937 ----
  		 //OR window logic
  		 else if ((info->wctl & 0x80) == 0)
  		 {
+ #ifndef GEKKO
  			 if (!TestWindow(info->wctl, 0x2, 0x1, &clip[0], i, j))
+ #else
+ 			 if (!TestWindow(info->wctl, 0x2, 0x1, &clip[0], i << resxratio, j << resyratio))
+ #endif
  			 {
  				 textdata++;
  				 continue;
  			 }
  
  			 // Window 1
+ #ifndef GEKKO
  			 if (!TestWindow(info->wctl, 0x8, 0x4, &clip[1], i,j))
+ #else
+ 			 if (!TestWindow(info->wctl, 0x8, 0x4, &clip[1], i << resxratio,j << resyratio))
+ #endif
  			 {
  				 textdata++;
  				 continue;
***************
*** 831,837 ****
--- 957,968 ----
  
           // If priority of screen is less than current top pixel and per
           // pixel priority isn't used, skip it
+ #ifndef GEKKO
           if (Vdp2GetPixelPriority(textdata[0]) > info->priority)
+ #else
+          if ((Vdp2GetPixelPriority(*textdata) > info->priority) &&
+                   !info->docolorcalcenable)
+ #endif
           {
              textdata++;
              continue;
***************
*** 849,856 ****
           // and then continue.
           // We almost need to know well ahead of time what the top
           // and second pixel is in order to work this.
! 
           textdata[0] = COLSAT2YAB32(info->priority, info->PostPixelFetchCalc(info, color));
           textdata++;
        }
     }    
--- 980,993 ----
           // and then continue.
           // We almost need to know well ahead of time what the top
           // and second pixel is in order to work this.
! #ifdef GEKKO
!          info->oldpixel = *textdata;
! #endif
! #ifndef GEKKO
           textdata[0] = COLSAT2YAB32(info->priority, info->PostPixelFetchCalc(info, color));
+ #else
+          *textdata = info->PostPixelFetchCalc(info, COLSAT2YAB32(info->priority, color));
+ #endif
           textdata++;
        }
     }    
***************
*** 926,932 ****
--- 1063,1074 ----
   
                 // If priority of screen is less than current top pixel and per
                 // pixel priority isn't used, skip it
+ #ifndef GEKKO
                 if (Vdp2GetPixelPriority(textdata[0]) > info->priority)
+ #else
+                if ((Vdp2GetPixelPriority(*textdata) > info->priority) &&
+                   !info->docolorcalcenable)
+ #endif
                 {
                    textdata++;
                    continue;
***************
*** 939,945 ****
--- 1081,1095 ----
                    continue;
                 }
  
+ #ifdef GEKKO
+                info->oldpixel = *textdata;
+                info->colorcalcmode = (Vdp2Regs->CCCTL & 0x100);
+ #endif
+ #ifndef GEKKO
                 textdata[0] = COLSAT2YAB32(info->priority, info->PostPixelFetchCalc(info, color));
+ #else
+                *textdata = info->PostPixelFetchCalc(info, COLSAT2YAB32(info->priority, color));
+ #endif
                 textdata++;
              }
              ymul += p->deltaYst;
***************
*** 1005,1011 ****
--- 1155,1166 ----
  
              // If priority of screen is less than current top pixel and per
              // pixel priority isn't used, skip it
+ #ifndef GEKKO
              if (Vdp2GetPixelPriority(textdata[0]) > info->priority)
+ #else
+             if ((Vdp2GetPixelPriority(*textdata) > info->priority) &&
+                !info->docolorcalcenable)
+ #endif
              {
                 textdata++;
                 continue;
***************
*** 1018,1024 ****
--- 1173,1187 ----
                 continue;
              }
  
+ #ifdef GEKKO
+             info->oldpixel = *textdata;
+             info->colorcalcmode = (Vdp2Regs->CCCTL & 0x100);
+ #endif
+ #ifndef GEKKO
              textdata[0] = COLSAT2YAB32(info->priority, info->PostPixelFetchCalc(info, color));
+ #else
+             *textdata = info->PostPixelFetchCalc(info, COLSAT2YAB32(info->priority, color));
+ #endif
              textdata++;
           }
           ymul += p->deltaYst;
***************
*** 1036,1048 ****
--- 1199,1220 ----
  static void Vdp2DrawBackScreen(void)
  {
     int i;
+ #ifdef GEKKO
+    vdp2draw_struct info;
+    info.cor = info.cog = info.cob = 0;
+ #endif
  
     // Only draw black if TVMD's DISP and BDCLMD bits are cleared
     if ((Vdp2Regs->TVMD & 0x8000) == 0 && (Vdp2Regs->TVMD & 0x100) == 0)
     {
        // Draw Black
+ #ifndef GEKKO
        for (i = 0; i < (vdp2width * vdp2height); i++)
           vdp2framebuffer[i] = 0;
+ #else
+       for (i = vdp2width * vdp2height - 1; i >= 0; i--)
+          *(vdp2framebuffer + i) = 0;
+ #endif
     }
     else
     {
***************
*** 1050,1055 ****
--- 1222,1230 ----
        u32 scrAddr;
        u16 dot;
  
+ #ifdef GEKKO
+       ReadVdp2ColorOffset(&info, 0x20, 0x20);
+ #endif
        if (Vdp2Regs->VRSIZE & 0x8000)
           scrAddr = (((Vdp2Regs->BKTAU & 0x7) << 16) | Vdp2Regs->BKTAL) * 2;
        else
***************
*** 1058,1066 ****
--- 1233,1252 ----
        if (Vdp2Regs->BKTAU & 0x8000)
        {
           // Per Line
+ #ifndef GEKKO
           for (i = 0; i < vdp2height; i++)
+ #else
+          for (i = vdp2height - 1; i >= 0; i--)
+ #endif
           {
+ #ifndef GEKKO
              dot = T1ReadWord(Vdp2Ram, scrAddr);
+ #else
+             if (Vdp2Regs->CLOFEN & 0x20 && (info.cor || info.cog || info.cob))
+               dot = COLOR_ADD16LIT(T1ReadWord(Vdp2Ram, scrAddr), info.cor, info.cog, info.cob);
+             else
+               dot = T1ReadWord(Vdp2Ram, scrAddr);
+ #endif
              scrAddr += 2;
  
              puthline16(0, i, vdp2width, dot, 0);
***************
*** 1069,1078 ****
--- 1255,1276 ----
        else
        {
           // Single Color
+ #ifndef GEKKO
           dot = T1ReadWord(Vdp2Ram, scrAddr);
+ #else
+          if (Vdp2Regs->CLOFEN & 0x20 && (info.cor || info.cog || info.cob))
+             dot = COLOR_ADD16LIT(T1ReadWord(Vdp2Ram, scrAddr), info.cor, info.cog, info.cob);
+           else
+             dot = T1ReadWord(Vdp2Ram, scrAddr);
+ #endif
  
+ #ifndef GEKKO
           for (i = 0; i < (vdp2width * vdp2height); i++)
              vdp2framebuffer[i] = COLSAT2YAB16(0, dot);
+ #else
+          for (i = vdp2width * vdp2height - 1; i >= 0; i--)
+             *(vdp2framebuffer + i) = COLSAT2YAB16(0, dot);
+ #endif
        }
     }
  }
***************
*** 1448,1458 ****
--- 1646,1664 ----
        return -1;
  
     // Initialize VDP1 framebuffer 1
+ #ifndef GEKKO
     if ((vdp1framebuffer[0] = (u8 *)calloc(sizeof(u8), 0x40000)) == NULL)
+ #else
+    if ((vdp1framebuffer[0] = (u8 *)calloc(sizeof(u8), 0x80000)) == NULL)
+ #endif
        return -1;
  
     // Initialize VDP1 framebuffer 2
+ #ifndef GEKKO
     if ((vdp1framebuffer[1] = (u8 *)calloc(sizeof(u8), 0x40000)) == NULL)
+ #else
+    if ((vdp1framebuffer[1] = (u8 *)calloc(sizeof(u8), 0x80000)) == NULL)
+ #endif
        return -1;
  
     // Initialize VDP2 framebuffer
***************
*** 1569,1574 ****
--- 1775,1781 ----
  
  void VIDSoftVdp1DrawStart(void)
  {
+ #ifndef GEKKO
     if (Vdp1Regs->TVMR & 0x1)
     {
        if (Vdp1Regs->TVMR & 0x2)
***************
*** 1594,1599 ****
--- 1801,1860 ----
        vdp1pixelsize = 2;
     }
  
+ #else
+        vdp1w=0;
+        vdp1h=0;
+ 
+    // Is double-interlace enabled?
+    if (Vdp1Regs->FBCR & 0x8)
+       vdp1h=1;
+ 
+         switch(Vdp1Regs->TVMR & 7) {
+         //Normal
+         default:
+         case 0:
+                 vdp1width = 512;
+                 vdp1height = 256;
+                 vdp1pixelsize = 2;
+                 break;
+         //Hi resolution
+         case 1:
+                 vdp1w=1;
+                 vdp1width = 512;
+                 vdp1height = 256;
+                 vdp1pixelsize= 2;
+                 if (resyratio==1)
+                 {
+                    vdp1h=1;
+                 }
+                 else
+                 {
+                    vdp1h=0;
+                 }
+                 break;
+         //Rotation 16
+         case 2:
+                 vdp1width = 512;
+                 vdp1height = 256;
+                 vdp1pixelsize = 2;
+                 break;
+         //Rotation 8
+         case 3:
+                 //vdp1width = 512;
+                 vdp1width = 256;
+                 vdp1height = 512;
+                 //vdp1pixelsize = 1;
+                 vdp1pixelsize = 2;
+                 break;
+         //HDTV
+         case 4:
+                 vdp1width = 512;
+                 vdp1height = 512;
+                 vdp1pixelsize = 2;
+                 break;
+         }
+ #endif
+ 
     VIDSoftVdp1EraseFrameBuffer();
  }
  
***************
*** 1625,1631 ****
--- 1886,1896 ----
  
  static INLINE u16  Vdp1ReadPattern256( u32 base, u32 offset ) {
  
+ #ifndef GEKKO
    return T1ReadByte(Vdp1Ram, ( base + offset ) & 0x7FFFF) & 0xFF;
+ #else
+   return T1ReadByte(Vdp1Ram, ( base + offset ) & 0x7FFFF);
+ #endif
  }
  
  static INLINE u16  Vdp1ReadPattern64k( u32 base, u32 offset ) {
***************
*** 1738,1745 ****
  			endcode = 63;
  			currentPixel = Vdp1ReadPattern64( characterAddress + (linenumber*(characterWidth)), currentlineindex );
  			if(isTextured && endcodesEnabled && currentPixel == endcode)
  				currentPixel = 0;
! 		//		return 1;
  			if (!((currentPixel == 0) && !SPD)) 
  				currentPixel = colorbank | currentPixel;
  			currentPixelIsVisible = 0x3f;
--- 2003,2013 ----
  			endcode = 63;
  			currentPixel = Vdp1ReadPattern64( characterAddress + (linenumber*(characterWidth)), currentlineindex );
  			if(isTextured && endcodesEnabled && currentPixel == endcode)
+ #ifndef GEKKO
  				currentPixel = 0;
! #else
! 				return 1;
! #endif
  			if (!((currentPixel == 0) && !SPD)) 
  				currentPixel = colorbank | currentPixel;
  			currentPixelIsVisible = 0x3f;
***************
*** 1792,1798 ****
--- 2060,2071 ----
  
  static void putpixel(int x, int y) {
  
+ #ifdef GEKKO
+ 	u16* iPix;
+ #endif
+ #ifndef GEKKO
  	u16* iPix = &((u16 *)vdp1backframebuffer)[(y * vdp1width) + x];
+ #endif
  	int mesh = cmd.CMDPMOD & 0x0100;
  	int SPD = ((cmd.CMDPMOD & 0x40) != 0);//show the actual color of transparent pixels if 1 (they won't be drawn transparent)
  	int currentShape = cmd.CMDCTRL & 0x7;
***************
*** 1810,1821 ****
  		x < vdp1clipxend &&
  		y >= vdp1clipystart &&
  		y < vdp1clipyend)
! 	{}
  	else
  		return;
  
  	if (cmd.CMDPMOD & 0x0400) PopUserClipping();
  
  
  	if ( SPD || (currentPixel & currentPixelIsVisible))
  	{
--- 2083,2110 ----
  		x < vdp1clipxend &&
  		y >= vdp1clipystart &&
  		y < vdp1clipyend)
! 	{
! #ifdef GEKKO
! 	   if (cmd.CMDPMOD & 0x0400) PopUserClipping();
! #endif
!         }
  	else
+ #ifdef GEKKO
+         {
+ 	   if (cmd.CMDPMOD & 0x0400) PopUserClipping();
+ 	   return;
+         } 
+ #else
  		return;
+ #endif
  
+ #ifndef GEKKO
  	if (cmd.CMDPMOD & 0x0400) PopUserClipping();
+ #endif
  
+ #ifdef GEKKO
+         iPix = &((u16 *)vdp1backframebuffer)[((y >> vdp1h) * vdp1width) + (x >> vdp1w)];
+ #endif
  
  	if ( SPD || (currentPixel & currentPixelIsVisible))
  	{
***************
*** 1826,1832 ****
--- 2115,2126 ----
  				*(iPix) = currentPixel;
  			break;
  		case 1: // shadow, TODO
+ #ifndef GEKKO
  			*(iPix) = currentPixel;
+ #else
+                         if ( *(iPix) & (1 << 15) )//only if MSB of framebuffer data is set
+                                 *(iPix) = ((*(iPix) & ~0x8421) >> 1) | (1 << 15);
+ #endif
  			break;
  		case 2: // half luminance
  			*(iPix) = ((currentPixel & ~0x8421) >> 1) | (1 << 15);
***************
*** 2181,2187 ****
--- 2475,2485 ----
  	COLOR colors[4];
  
  	Vdp1ReadCommand(&cmd, Vdp1Regs->addr);
+ #ifndef GEKKO
  	characterWidth = ((cmd.CMDSIZE >> 8) & 0x3F) * 8;
+ #else
+ 	characterWidth = ((cmd.CMDSIZE & 0x3F00) >> 5);
+ #endif
  	characterHeight = cmd.CMDSIZE & 0xFF;
  
  	totalleft  = bresenham(tl_x,tl_y,bl_x,bl_y,xleft,yleft);
***************
*** 2222,2228 ****
--- 2520,2530 ----
  		leftLineStep = (double)totalleft / totalright;
  	}
  
+ #ifndef GEKKO
  	for(i = 0; i < total; i++) {
+ #else
+ 	for(i = total - 1; i >= 0; i--) {
+ #endif
  
  		int xlinelength;
  
***************
*** 2234,2244 ****
--- 2536,2554 ----
  		COLOR_PARAMS leftToRightStep = {0,0,0};
  
  		//get the length of the line we are about to draw
+ #ifndef GEKKO
  		xlinelength = getlinelength(
  			xleft[(int)(i*leftLineStep)],
  			yleft[(int)(i*leftLineStep)],
  			xright[(int)(i*rightLineStep)],
  			yright[(int)(i*rightLineStep)]);
+ #else
+                 xlinelength = getlinelength(
+                         *(xleft + (int)(i*leftLineStep)),
+                         *(yleft + (int)(i*leftLineStep)),
+                         *(xright + (int)(i*rightLineStep)),
+                         *(yright + (int)(i*rightLineStep)));
+ #endif
  
  		//so from 0 to the width of the texture / the length of the line is how far we need to step
  		xtexturestep=interpolate(0,characterWidth,xlinelength);
***************
*** 2268,2277 ****
--- 2578,2594 ----
  		}
  
  		DrawLine(
+ #ifndef GEKKO
  			xleft[(int)(i*leftLineStep)],
  			yleft[(int)(i*leftLineStep)],
  			xright[(int)(i*rightLineStep)],
  			yright[(int)(i*rightLineStep)],
+ #else
+                         *(xleft + (int)(i*leftLineStep)),
+                         *(yleft + (int)(i*leftLineStep)),
+                         *(xright + (int)(i*rightLineStep)),
+                         *(yright + (int)(i*rightLineStep)),
+ #endif
  			ytexturestep*i, 
  			xtexturestep,
  			leftToRightStep.r,
***************
*** 2290,2296 ****
--- 2607,2617 ----
  
  	topLeftx = cmd.CMDXA + Vdp1Regs->localX;
  	topLefty = cmd.CMDYA + Vdp1Regs->localY;
+ #ifndef GEKKO
  	spriteWidth = ((cmd.CMDSIZE >> 8) & 0x3F) * 8;
+ #else
+ 	spriteWidth = ((cmd.CMDSIZE & 0x3F00) >> 5);
+ #endif
  	spriteHeight = cmd.CMDSIZE & 0xFF;
  
  	topRightx = topLeftx+spriteWidth;
***************
*** 2387,2393 ****
--- 2708,2718 ----
  		break;
  	}
  
+ #ifndef GEKKO
  	spriteWidth = ((cmd.CMDSIZE >> 8) & 0x3F) * 8;
+ #else
+ 	spriteWidth = ((cmd.CMDSIZE & 0x3F00) >> 5);
+ #endif
  	spriteHeight = cmd.CMDSIZE & 0xFF;
  
  	topLeftx = x0;
***************
*** 2534,2544 ****
--- 2859,2871 ----
  
  static void PushUserClipping(int mode)
  {
+ #ifndef GEKKO
     if (mode == 1)
     {
        VDP1LOG("User clipping mode 1 not implemented\n");
        return;
     }
+ #endif
  
     vdp1clipxstart = Vdp1Regs->userclipX1;
     vdp1clipxend = Vdp1Regs->userclipX2;
***************
*** 2624,2631 ****
--- 2951,2963 ----
     u32 vdp1coloroffset;
     int colormode = Vdp2Regs->SPCTL & 0x20;
     vdp2draw_struct info;
+ #ifndef GEKKO
     u32 *dst=dispbuffer;
     u32 *vdp2src=vdp2framebuffer;
+ #else
+    u32 *dst=dispbuffer + vdp2height * vdp2width - 1;
+    u32 *vdp2src=vdp2framebuffer + vdp2height * vdp2width - 1;
+ #endif
     int islinewindow;
     clipping_struct clip[2];
     u32 linewnd0addr, linewnd1addr;
***************
*** 2683,2696 ****
--- 3015,3036 ----
  
           if (info.cor == 0 && info.cog == 0 && info.cob == 0)
           {
+ #ifndef GEKKO
              if (Vdp2Regs->CCCTL & 0x40)
+ #else
+             if ((Vdp2Regs->CCCTL & 0x40) && specialcoloron)
+ #endif
                 info.PostPixelFetchCalc = &DoColorCalc;
              else
                 info.PostPixelFetchCalc = &DoNothing;
           }
           else
           {
+ #ifndef GEKKO
              if (Vdp2Regs->CCCTL & 0x40)
+ #else
+             if ((Vdp2Regs->CCCTL & 0x40) && specialcoloron)
+ #endif
                 info.PostPixelFetchCalc = &DoColorCalcWithColorOffset;
              else
                 info.PostPixelFetchCalc = &DoColorOffset;
***************
*** 2698,2708 ****
--- 3038,3058 ----
        }
        else // color offset disable
        {
+ #ifndef GEKKO
           if (Vdp2Regs->CCCTL & 0x40)
+ #else
+          if ((Vdp2Regs->CCCTL & 0x40) && specialcoloron)
+ #endif
              info.PostPixelFetchCalc = &DoColorCalc;
           else
              info.PostPixelFetchCalc = &DoNothing;
        }
+ #ifdef GEKKO
+       if ((Vdp2Regs->CCCTL & 0x40) && specialcoloron)
+          info.docolorcalcenable = 1;
+       else
+          info.docolorcalcenable = 0;
+ #endif
  
        wctl = Vdp2Regs->WCTLC >> 8;
        clip[0].xstart = clip[0].ystart = clip[0].xend = clip[0].yend = 0;
***************
*** 2711,2764 ****
        linewnd0addr = linewnd1addr = 0;
        ReadLineWindowData(&islinewindow, wctl, &linewnd0addr, &linewnd1addr);
  
        for (i2 = 0; i2 < vdp2height; i2++)
        {
           ReadLineWindowClip(islinewindow, clip, &linewnd0addr, &linewnd1addr);
  
           for (i = 0; i < vdp2width; i++)
           {
              // See if screen position is clipped, if it isn't, continue
              // Window 0
              if (!TestWindow(wctl, 0x2, 0x1, &clip[0], i, i2))
              {
                 dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
                 vdp2src++;
                 dst++;
                 continue;
              }
  
              // Window 1
              if (!TestWindow(wctl, 0x8, 0x4, &clip[1], i, i2))
              {
!                vdp2src++;
                 dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
                 dst++;
                 continue;
              }
  
              if (vdp1pixelsize == 2)
              {
                 // 16-bit pixel size
                 pixel = ((u16 *)vdp1frontframebuffer)[(i2 * vdp1width) + i];
  
                 if (pixel == 0)
                    dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
                 else if (pixel & 0x8000 && colormode)
                 {
                    // 16 BPP               
                    if (prioritytable[0] >= Vdp2GetPixelPriority(vdp2src[0]))
                    {
                       // if pixel is 0x8000, only draw pixel if sprite window
                       // is disabled/sprite type 2-7. sprite types 0 and 1 are
                       // -always- drawn and sprite types 8-F are always
                       // transparent.
                       if (pixel != 0x8000 || vdp1spritetype < 2 || (vdp1spritetype < 8 && !(Vdp2Regs->SPCTL & 0x10)))
                          dst[0] = info.PostPixelFetchCalc(&info, COLSAT2YAB16(0xFF, pixel));
                       else
                          dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
                    }
                    else               
                       dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
                 }
                 else
                 {
--- 3061,3169 ----
        linewnd0addr = linewnd1addr = 0;
        ReadLineWindowData(&islinewindow, wctl, &linewnd0addr, &linewnd1addr);
  
+ #ifdef GEKKO
+             info.colorcalcmode = (Vdp2Regs->CCCTL & 0x100);
+             //info.alpha = ((u8 *)&Vdp2Regs->CCRSA)[0] & 0x1F;
+ #endif
+ 
+ #ifndef GEKKO
        for (i2 = 0; i2 < vdp2height; i2++)
+ #else
+       for (i2 = vdp2height - 1; i2 >= 0; i2--)
+ #endif
        {
           ReadLineWindowClip(islinewindow, clip, &linewnd0addr, &linewnd1addr);
  
+ #ifndef GEKKO
           for (i = 0; i < vdp2width; i++)
+ #else
+          for (i = vdp2width - 1; i >= 0; i--)
+ #endif
           {
              // See if screen position is clipped, if it isn't, continue
              // Window 0
              if (!TestWindow(wctl, 0x2, 0x1, &clip[0], i, i2))
              {
                 dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
+ #ifndef GEKKO
                 vdp2src++;
                 dst++;
+ #else
+                vdp2src--;
+                dst--;
+ #endif
                 continue;
              }
  
              // Window 1
              if (!TestWindow(wctl, 0x8, 0x4, &clip[1], i, i2))
              {
! #ifndef GEKKO
!                vdp2src++; 
! #endif
                 dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
+ #ifdef GEKKO
+                vdp2src--;
+                dst--;
+ #endif
+ #ifndef GEKKO
                 dst++;
+ #endif
                 continue;
              }
+ #ifdef GEKKO
+             info.oldpixel = *vdp2src;
+ #endif
  
+ #ifndef GEKKO
              if (vdp1pixelsize == 2)
              {
+ #endif
                 // 16-bit pixel size
+ #ifndef GEKKO
                 pixel = ((u16 *)vdp1frontframebuffer)[(i2 * vdp1width) + i];
+ #else
+                pixel = *(((u16 *)vdp1frontframebuffer) + (i2 * vdp1width) + i);
+ #endif
  
                 if (pixel == 0)
+ #ifndef GEKKO
                    dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
+ #else
+                   *dst = COLSATSTRIPPRIORITY(*vdp2src);
+ #endif
                 else if (pixel & 0x8000 && colormode)
                 {
                    // 16 BPP               
+ #ifndef GEKKO
                    if (prioritytable[0] >= Vdp2GetPixelPriority(vdp2src[0]))
+ #else
+                   if (*prioritytable >= Vdp2GetPixelPriority(*vdp2src))
+ #endif
                    {
                       // if pixel is 0x8000, only draw pixel if sprite window
                       // is disabled/sprite type 2-7. sprite types 0 and 1 are
                       // -always- drawn and sprite types 8-F are always
                       // transparent.
                       if (pixel != 0x8000 || vdp1spritetype < 2 || (vdp1spritetype < 8 && !(Vdp2Regs->SPCTL & 0x10)))
+ #ifndef GEKKO
                          dst[0] = info.PostPixelFetchCalc(&info, COLSAT2YAB16(0xFF, pixel));
+ #else
+                         *dst = DoNothing(&info, COLSAT2YAB16(0xFF, pixel));
+ #endif
                       else
+ #ifndef GEKKO
                          dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
+ #else
+                         *dst = COLSATSTRIPPRIORITY(*vdp2src);
+ #endif
                    }
                    else               
+ #ifndef GEKKO
                       dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
+ #else
+                      *dst = COLSATSTRIPPRIORITY(*vdp2src);
+ #endif
                 }
                 else
                 {
***************
*** 2767,2778 ****
--- 3172,3215 ----
  		  int shadow;
  		  int colorcalc;
  		  priority = 0;  // Avoid compiler warning
+ #ifdef GEKKO
+ 		  shadow = 0;  // Avoid compiler warning
+ 		  colorcalc = 0;  // Avoid compiler warning
+ #endif
                    Vdp1ProcessSpritePixel(vdp1spritetype, &pixel, &shadow, &priority, &colorcalc);
+ #ifdef GEKKO
+                   info.alpha = ((u8 *)&Vdp2Regs->CCRSA)[colorcalc] & 0x1F;
+                   if (pixel != 0x8000 || vdp1spritetype < 2 || (vdp1spritetype < 8 && !(Vdp2Regs->SPCTL & 0x10)))
+                   {
+                      if(info.PostPixelFetchCalc == &DoColorCalc)
+                         info.PostPixelFetchCalc = &DoNothing;
+                      if(info.PostPixelFetchCalc == &DoColorCalcWithColorOffset)
+                         info.PostPixelFetchCalc = &DoColorOffset;
+ 
+                      info.docolorcalcenable=0;
+                   }
+ #endif
+ #ifndef GEKKO
                    if (prioritytable[priority] >= Vdp2GetPixelPriority(vdp2src[0]))
+ #else
+                   if ((*(prioritytable + priority) >= Vdp2GetPixelPriority(*vdp2src)) || info.docolorcalcenable)
+ #endif
+ #ifndef GEKKO
                       dst[0] = info.PostPixelFetchCalc(&info, COLSAT2YAB32(0xFF, Vdp2ColorRamGetColor(vdp1coloroffset + pixel)));
+ #else
+                      if (pixel & 0x8000 && !colormode)
+                         *dst = DoColorOffset(&info, COLSAT2YAB16(0xFF, pixel));
+                      else               
+                         *dst = info.PostPixelFetchCalc(&info, COLSAT2YAB32(0xFF, Vdp2ColorRamGetColor(vdp1coloroffset + pixel)));
+ #endif
                    else               
+ #ifndef GEKKO
                       dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
+ #else
+                      *dst = COLSATSTRIPPRIORITY(*vdp2src);
+ #endif
                 }
+ #ifndef GEKKO
              }
              else
              {
***************
*** 2780,2803 ****
                 pixel = vdp1frontframebuffer[(i2 * vdp1width) + i];
  
                 if (pixel == 0)
                    dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
!                else
                 {
                    // Color bank(fix me)
!                   LOG("8-bit Color Bank draw - %02X\n", pixel);
                    dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
                 }
              }
              vdp2src++;
              dst++;
           }
        }
     }
     else
     {
        // Render VDP2 only
        for (i = 0; i < (vdp2width*vdp2height); i++)
           dispbuffer[i] = COLSATSTRIPPRIORITY(vdp2framebuffer[i]);
     }
  
     VIDSoftVdp1SwapFrameBuffer();
--- 3217,3264 ----
                 pixel = vdp1frontframebuffer[(i2 * vdp1width) + i];
  
                 if (pixel == 0)
+ #ifndef GEKKO
                    dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
!                else if (prioritytable[0] >= Vdp2GetPixelPriority(vdp2src[0]))
!                   dst[0] = COLSAT2YAB32(0xFF, Vdp2ColorRamGetColor(vdp1coloroffset + pixel)); 
! #else
!                   *dst = COLSATSTRIPPRIORITY(*vdp2src);
!                else if ((*prioritytable >= Vdp2GetPixelPriority(*vdp2src))
!                   || info.docolorcalcenable)
!                   *dst = info.PostPixelFetchCalc(&info, COLSAT2YAB32(0xFF, Vdp2ColorRamGetColor(vdp1coloroffset + pixel)));
! #endif
                 {
                    // Color bank(fix me)
!                   //LOG("8-bit Color Bank draw - %02X\n", pixel);
! #ifndef GEKKO
                    dst[0] = COLSATSTRIPPRIORITY(vdp2src[0]);
+ #else
+                   *dst = COLSATSTRIPPRIORITY(*vdp2src);
+ #endif
+ 
                 }
              }
+ #endif // 8-bit
+ #ifndef GEKKO
              vdp2src++;
              dst++;
+ #else
+             vdp2src--;
+             dst--;
+ #endif
           }
        }
     }
     else
     {
        // Render VDP2 only
+ #ifndef GEKKO
        for (i = 0; i < (vdp2width*vdp2height); i++)
           dispbuffer[i] = COLSATSTRIPPRIORITY(vdp2framebuffer[i]);
+ #else
+       for (i = vdp2width*vdp2height - 1; i >=0; i--)
+          *(dispbuffer + i) = COLSATSTRIPPRIORITY(*(vdp2framebuffer + i));
+ #endif
     }
  
     VIDSoftVdp1SwapFrameBuffer();
***************
*** 2842,2847 ****
--- 3303,3309 ----
  {
     int i;
  
+ #ifndef GEKKO
     for (i = 7; i > 0; i--)
     {   
        if (nbg3priority == i)
***************
*** 2855,2860 ****
--- 3317,3337 ----
        if (rbg0priority == i)
           Vdp2DrawRBG0();
     }
+ #else
+    for (i = 7; i > 0; i--)
+    {   
+       if (nbg3priority == ((specialcoloron) ? 8-i:i))
+          Vdp2DrawNBG3();
+       if (nbg2priority == ((specialcoloron) ? 8-i:i))
+          Vdp2DrawNBG2();
+       if (nbg1priority == ((specialcoloron) ? 8-i:i))
+          Vdp2DrawNBG1();
+       if (nbg0priority == ((specialcoloron) ? 8-i:i))
+          Vdp2DrawNBG0();
+       if (rbg0priority == ((specialcoloron) ? 8-i:i))
+          Vdp2DrawRBG0();
+    }
+ #endif
  }
  
  //////////////////////////////////////////////////////////////////////////////
***************
*** 2868,2902 ****
--- 3345,3411 ----
     {
        case 0:
           vdp2width = 320;
+ #ifndef GEKKO
           resxratio=1;
+ #else
+          resxratio=0;
+ #endif
           break;
        case 1:
           vdp2width = 352;
+ #ifndef GEKKO
           resxratio=1;
+ #else
+          resxratio=0;
+ #endif
           break;
        case 2: // 640
           vdp2width = 320;
+ #ifndef GEKKO
           resxratio=2;
+ #else
+          resxratio=1;
+ #endif
           break;
        case 3: // 704
           vdp2width = 352;
+ #ifndef GEKKO
           resxratio=2;
+ #else
+          resxratio=1;
+ #endif
           break;
        case 4:
           vdp2width = 320;
+ #ifndef GEKKO
           resxratio=1;
+ #else
+          resxratio=0;
+ #endif
           break;
        case 5:
           vdp2width = 352;
+ #ifndef GEKKO
           resxratio=1;
+ #else
+          resxratio=0;
+ #endif
           break;
        case 6: // 640
           vdp2width = 320;
+ #ifndef GEKKO
           resxratio=2;
+ #else
+          resxratio=1;
+ #endif
           break;
        case 7: // 704
           vdp2width = 352;
+ #ifndef GEKKO
           resxratio=2;
+ #else
+          resxratio=1;
+ #endif
           break;
     }
  
***************
*** 2914,2927 ****
--- 3423,3444 ----
           break;
        default: break;
     }
+ #ifndef GEKKO
     resyratio=1;
+ #else
+    resyratio=0;
+ #endif
  
     // Check for interlace
     switch ((TVMD >> 6) & 0x3)
     {
        case 3: // Double-density Interlace
  //         vdp2height *= 2;
+ #ifndef GEKKO
           resyratio=2;
+ #else
+          resyratio=1;
+ #endif
           break;
        case 2: // Single-density Interlace
        case 0: // Non-interlace
***************
*** 3008,3014 ****
--- 3525,3535 ----
     for (i2 = (Vdp1Regs->EWLR & 0x1FF); i2 < h; i2++)
     {
        for (i = ((Vdp1Regs->EWLR >> 6) & 0x1F8); i < w; i++)
+ #ifndef GEKKO
           ((u16 *)vdp1backframebuffer)[(i2 * vdp1width) + i] = Vdp1Regs->EWDR;
+ #else
+          *(((u16 *)vdp1backframebuffer) + (i2 * vdp1width) + i) = Vdp1Regs->EWDR;
+ #endif
     }
  }
  
Only in yabause-wii-beta17/src: vidsoft.d
Common subdirectories: yabause-r2604/src/wii and yabause-wii-beta17/src/wii
Common subdirectories: yabause-r2604/src/windows and yabause-wii-beta17/src/windows
Only in yabause-wii-beta17/src: yabause-wii-r2411.diff
diff -c yabause-r2604/src/yabause.c yabause-wii-beta17/src/yabause.c
*** yabause-r2604/src/yabause.c	Fri Jun 24 23:32:28 2011
--- yabause-wii-beta17/src/yabause.c	Wed Aug 18 11:35:46 2010
***************
*** 42,48 ****
  #include "bios.h"
  #include "movie.h"
  #ifdef HAVE_LIBSDL
!  #ifdef __APPLE__
    #include <SDL/SDL.h>
   #else
    #include "SDL.h"
--- 42,48 ----
  #include "bios.h"
  #include "movie.h"
  #ifdef HAVE_LIBSDL
!  #if defined(__APPLE__) || defined(GEKKO)
    #include <SDL/SDL.h>
   #else
    #include "SDL.h"
***************
*** 58,64 ****
  #endif
  #ifdef GEKKO
  #include <ogc/lwp_watchdog.h>
! extern long long gettime();
  #endif
  #ifdef PSP
  #include "psp/common.h"
--- 58,64 ----
  #endif
  #ifdef GEKKO
  #include <ogc/lwp_watchdog.h>
! //extern long long gettime();
  #endif
  #ifdef PSP
  #include "psp/common.h"
***************
*** 107,114 ****
--- 107,119 ----
     const double freq_mult = (freqtype == CLKTYPE_26MHZ) ? 15.0/16.0 : 1.0;
     const double freq_shifted = (freq_base * freq_mult) * (1 << YABSYS_TIMING_BITS);
     const double usec_shifted = 1.0e6 * (1 << YABSYS_TIMING_BITS);
+ #ifndef GEKKO
     const double deciline_time = yabsys.IsPal ? 1.0 /  50        / 313 / 10
                                               : 1.0 / (60/1.001) / 263 / 10;
+ #else
+    const double deciline_time = yabsys.IsPal ? 1.0 /  50.0        / 313.0 / 10.0
+                                              : 1.0 / (60.0/1.001) / 263.0 / 10.0;
+ #endif
  
     yabsys.DecilineCount = 0;
     yabsys.LineCount = 0;
Only in yabause-wii-beta17/src: yabause.c.orig
Only in yabause-wii-beta17/src: yabause.d
Only in yabause-wii-beta17/src: yabause.elf.map
Only in yabause-wii-beta17/src: ygl.d
