gpfce patch part2
authornotaz <notasas@gmail.com>
Sat, 7 Apr 2007 14:03:06 +0000 (14:03 +0000)
committernotaz <notasas@gmail.com>
Sat, 7 Apr 2007 14:03:06 +0000 (14:03 +0000)
git-svn-id: file:///home/notaz/opt/svn/fceu@92 be3aeb3a-fb24-0410-a615-afba39da0efa

43 files changed:
Makefile [new file with mode: 0644]
Makefile.gp2x [new file with mode: 0644]
README.compile.gp2x [new file with mode: 0644]
drivers/cli/dos-joystick.c [deleted file]
drivers/cli/dos-joystick.h [deleted file]
drivers/cli/dos-keyboard.c [deleted file]
drivers/cli/dos-mouse.c [deleted file]
drivers/cli/dos-sound.c [deleted file]
drivers/cli/dos-sound.h [deleted file]
drivers/cli/dos-video.c [deleted file]
drivers/cli/dos-video.h [deleted file]
drivers/cli/dos.c [deleted file]
drivers/cli/dos.h [deleted file]
drivers/cli/minimal.c [new file with mode: 0644]
drivers/cli/minimal.h [new file with mode: 0644]
drivers/cli/minimal_940t.h [new file with mode: 0644]
drivers/win/cheat.c [deleted file]
drivers/win/cheat.h [deleted file]
drivers/win/common.h [deleted file]
drivers/win/config.c [deleted file]
drivers/win/input.c [deleted file]
drivers/win/input.h [deleted file]
drivers/win/joystick.c [deleted file]
drivers/win/joystick.h [deleted file]
drivers/win/keyboard.c [deleted file]
drivers/win/keyboard.h [deleted file]
drivers/win/keyscan.h [deleted file]
drivers/win/main.c [deleted file]
drivers/win/netplay.c [deleted file]
drivers/win/res.res [deleted file]
drivers/win/sound.c [deleted file]
drivers/win/throttle.c [deleted file]
drivers/win/video.c [deleted file]
drivers/win/wave.c [deleted file]
drivers/win/window.c [deleted file]
palettes/conv.c [new file with mode: 0644]
palettes/palettes.h [new file with mode: 0644]
palettes/rp2c04001.old [new file with mode: 0644]
palettes/rp2c04002.h [new file with mode: 0644]
palettes/rp2c04003.h [new file with mode: 0644]
palettes/rp2c05004.h [new file with mode: 0644]
ppu.c [new file with mode: 0644]
ppu.h [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..1e061ab
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,28 @@
+CC     = arm-linux-gcc 
+TFLAGS  =  -mcpu=arm920t -O3 -Izlib  -DGP2X=1 -DLSB_FIRST -DSDL -DUNIX -DPSS_STYLE=1 -DZLIB  -D_REENTRANT 
+RM     = rm -f
+B      = drivers/pc/
+
+all:           fceu
+       mv fceu gpfce
+
+include zlib/Makefile
+
+OBJDRIVER      = ${B}minimal.o ${B}sdl.o ${B}main.o ${B}throttle.o ${B}unix-netplay.o ${B}sdl-sound.o ${B}sdl-video.o ${B}sdl-joystick.o drivers/common/cheat.o drivers/common/config.o drivers/common/args.o drivers/common/vidblit.o ${UNZIPOBJS} ppu.o
+LDRIVER                = -L /mnt/sd/lib  -L/mnt/sd/gp2x/usr/lib  -lm  -lpthread -lz -static 
+#                   `arm-linux-sdl-config --libs` 
+
+include Makefile.base
+
+${B}sdl-joystick.o:    ${B}sdl-joystick.c
+${B}main.o:            ${B}main.c ${B}main.h ${B}usage.h ${B}input.c ${B}keyscan.h
+${B}sdl.o:             ${B}sdl.c ${B}sdl.h
+${B}sdl-video.o:       ${B}sdl-video.c
+${B}sdl-video.o:       ${B}minimal.c
+${B}sdl-sound.o:       ${B}sdl-sound.c
+#${B}sdl-netplay.o:    ${B}sdl-netplay.c
+${B}unix-netplay.o:    ${B}unix-netplay.c
+${B}throttle.o:         ${B}throttle.c ${B}main.h ${B}throttle.h
+ppu.o:                 ppu.c ppu.h
+
+include Makefile.common
diff --git a/Makefile.gp2x b/Makefile.gp2x
new file mode 100644 (file)
index 0000000..1e061ab
--- /dev/null
@@ -0,0 +1,28 @@
+CC     = arm-linux-gcc 
+TFLAGS  =  -mcpu=arm920t -O3 -Izlib  -DGP2X=1 -DLSB_FIRST -DSDL -DUNIX -DPSS_STYLE=1 -DZLIB  -D_REENTRANT 
+RM     = rm -f
+B      = drivers/pc/
+
+all:           fceu
+       mv fceu gpfce
+
+include zlib/Makefile
+
+OBJDRIVER      = ${B}minimal.o ${B}sdl.o ${B}main.o ${B}throttle.o ${B}unix-netplay.o ${B}sdl-sound.o ${B}sdl-video.o ${B}sdl-joystick.o drivers/common/cheat.o drivers/common/config.o drivers/common/args.o drivers/common/vidblit.o ${UNZIPOBJS} ppu.o
+LDRIVER                = -L /mnt/sd/lib  -L/mnt/sd/gp2x/usr/lib  -lm  -lpthread -lz -static 
+#                   `arm-linux-sdl-config --libs` 
+
+include Makefile.base
+
+${B}sdl-joystick.o:    ${B}sdl-joystick.c
+${B}main.o:            ${B}main.c ${B}main.h ${B}usage.h ${B}input.c ${B}keyscan.h
+${B}sdl.o:             ${B}sdl.c ${B}sdl.h
+${B}sdl-video.o:       ${B}sdl-video.c
+${B}sdl-video.o:       ${B}minimal.c
+${B}sdl-sound.o:       ${B}sdl-sound.c
+#${B}sdl-netplay.o:    ${B}sdl-netplay.c
+${B}unix-netplay.o:    ${B}unix-netplay.c
+${B}throttle.o:         ${B}throttle.c ${B}main.h ${B}throttle.h
+ppu.o:                 ppu.c ppu.h
+
+include Makefile.common
diff --git a/README.compile.gp2x b/README.compile.gp2x
new file mode 100644 (file)
index 0000000..96355c3
--- /dev/null
@@ -0,0 +1,6 @@
+1) Use Linux on x86
+2) Rename drivers/cli to drivers/pc
+3) Use GCC 4.1.0
+4) Need GP2X libraries
+
+
diff --git a/drivers/cli/dos-joystick.c b/drivers/cli/dos-joystick.c
deleted file mode 100644 (file)
index 3729187..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <dpmi.h>
-#include <sys/farptr.h>
-#include <go32.h>
-#include <pc.h>
-
-#include "dos.h"
-#include "dos-joystick.h"
-
-#define JOY_A   1
-#define JOY_B   2
-#define JOY_SELECT      4
-#define JOY_START       8
-#define JOY_UP  0x10
-#define JOY_DOWN        0x20
-#define JOY_LEFT        0x40
-#define JOY_RIGHT       0x80
-
-int joy=0;
-int joyBMap[4];
-
-static int32 joybuttons=0;
-static uint32 joyx=0;
-static uint32 joyy=0;
-static uint32 joyxcenter;
-static uint32 joyycenter;
-
-static void ConfigJoystick(void);
-volatile int soundjoyer=0;
-volatile int soundjoyeron=0;
-
-/* Crude method to detect joystick. */
-static int DetectJoystick(void)
-{
- uint8 b;
-
- outportb(0x201,0);
- b=inportb(0x201);
- sleep(1);
- if((inportb(0x201)&3)==(b&3))
-  return 0;
- else
-  return 1;
-}
-
-void UpdateJoyData(void)
-{
- uint32 xc,yc;
-
-
- joybuttons=((inportb(0x201)&0xF0)^0xF0)>>4;
-
- xc=yc=0;
-
- {
-  outportb(0x201,0);
-
-  for(;;)
-  {
-   uint8 b;
-
-   b=inportb(0x201);
-   if(!(b&3))
-    break;
-   if(b&1) xc++;
-   if(b&2) yc++;
-  }
- }
-
- joyx=xc;
- joyy=yc;
-}
-
-uint32 GetJSOr(void)
-{
-        int y;
-        unsigned long ret;
-        ret=0;
-
-        if(!soundo)
-         UpdateJoyData();
-        for(y=0;y<4;y++)
-         if(joybuttons&joyBMap[y]) ret|=(1<<y)<<((joy-1)<<3);
-
-        if(joyx<=joyxcenter*.25) ret|=JOY_LEFT<<((joy-1)<<3);
-        else if(joyx>=joyxcenter*1.75) ret|=JOY_RIGHT<<((joy-1)<<3);
-        if(joyy<=joyycenter*.25) ret|=JOY_UP<<((joy-1)<<3);
-        else if(joyy>=joyycenter*1.75) ret|=JOY_DOWN<<((joy-1)<<3);
-
-        return ret;
-}
-
-int InitJoysticks(void)
-{
-       if(!joy) return(0);
-        if(!DetectJoystick())
-        {
-         printf("Joystick not detected!\n");
-         joy=0;
-         return 0;
-        }
-        if(soundo)
-        {
-         soundjoyeron=1;
-         while(!soundjoyer);
-        }
-        else
-         UpdateJoyData();
-
-        joyxcenter=joyx;
-        joyycenter=joyy;
-
-        if(!(joyBMap[0]|joyBMap[1]|joyBMap[2]|joyBMap[3]))
-         ConfigJoystick();
-        return(1);
-}
-
-static void BConfig(int b)
-{
-  int c=0;
-  uint32 st=time(0);
-
-  while(time(0)< (st+4) )
-  {
-   if(!soundo)
-    UpdateJoyData();
-   if(joybuttons) c=joybuttons;
-   else if(c && !joybuttons)
-   {
-    joyBMap[b]=c;
-    break;
-   }
-
-  }
-}
-
-void KillJoysticks(void)
-{
-
-}
-
-static void ConfigJoystick(void)
-{
- static char *genb="** Press button for ";
-
- printf("\n\n Joystick button configuration:\n\n");
- printf("   Push and release the button to map to the virtual joystick.\n");
- printf("   If you do not wish to assign a button, wait a few seconds\n");
- printf("   and the configuration will continue.\n\n");
- printf("   Press enter to continue...\n");
- getchar();
-                                                        
- printf("%s\"Select\".\n",genb);
- BConfig(2);
-
- printf("%s\"Start\".\n",genb);
- BConfig(3);
-
- printf("%s\"B\".\n",genb);
- BConfig(1);
-
- printf("%s\"A\".\n",genb);
- BConfig(0);
-}
-
diff --git a/drivers/cli/dos-joystick.h b/drivers/cli/dos-joystick.h
deleted file mode 100644 (file)
index 6cfaee5..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-void UpdateJoyData(void);\r
-uint32 GetJSOr(void);\r
-int InitJoysticks(void);\r
-\r
-/* Variables to save in config file. */\r
-extern int joy;\r
-extern int joyBMap[4];\r
diff --git a/drivers/cli/dos-keyboard.c b/drivers/cli/dos-keyboard.c
deleted file mode 100644 (file)
index 22ca9e8..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-#include <stdio.h>\r
-#include <signal.h>\r
-#include <string.h>\r
-#include <pc.h>\r
-#include <dpmi.h>\r
-#include <go32.h>\r
-#include "keyscan.h"\r
-\r
-static unsigned char lastsc;\r
-static char keybuf[256];\r
-int newk;\r
-\r
-/* Read scan code from port $60 */\r
-/* Acknowledge interrupt( output $20 to port $20) */\r
-\r
-static void ihandler(_go32_dpmi_registers *r)\r
-{\r
- unsigned char scode=inp(0x60);        /* Get scan code. */\r
-\r
-\r
- if(scode!=0xE0)\r
- {\r
-  int offs=0;\r
-\r
-  /* I'm only interested in preserving the independent status of the\r
-     right ALT and CONTROL keys.\r
-  */\r
-  if(lastsc==0xE0)\r
-   if((scode&0x7F)==SCAN_LEFTALT || (scode&0x7F)==SCAN_LEFTCONTROL)\r
-    offs=0x80;\r
-  \r
-\r
-  keybuf[(scode&0x7f)|offs]=((scode&0x80)^0x80);\r
-  newk++;\r
- }\r
- lastsc=scode;\r
-\r
- outp(0x20,0x20);      /* Acknowledge interrupt. */\r
-}\r
-\r
-static _go32_dpmi_seginfo KBIBack,KBIBackRM;\r
-static _go32_dpmi_seginfo KBI,KBIRM;\r
-static _go32_dpmi_registers KBIRMRegs;\r
-static int initdone=0;\r
-\r
-int InitKeyboard(void)\r
-{\r
- /* I'll assume that the keyboard is in the correct scancode mode(translated\r
-    mode 2, I think).\r
- */\r
-  newk=0;\r
-  memset(keybuf,0,sizeof(keybuf));\r
-  KBIRM.pm_offset=KBI.pm_offset=(int)ihandler;\r
-  KBIRM.pm_selector=KBI.pm_selector=_my_cs();\r
-\r
-  _go32_dpmi_get_real_mode_interrupt_vector(9,&KBIBackRM);\r
-  _go32_dpmi_allocate_real_mode_callback_iret(&KBIRM, &KBIRMRegs);\r
-  _go32_dpmi_set_real_mode_interrupt_vector(9,&KBIRM);\r
-\r
-  _go32_dpmi_get_protected_mode_interrupt_vector(9,&KBIBack);\r
-  _go32_dpmi_allocate_iret_wrapper(&KBI);\r
-  _go32_dpmi_set_protected_mode_interrupt_vector(9,&KBI);\r
-  lastsc=0;\r
-  initdone=1;\r
-  return(1);\r
-}\r
-\r
-void KillKeyboard(void)\r
-{\r
- if(initdone)\r
- {\r
-  _go32_dpmi_set_protected_mode_interrupt_vector(9,&KBIBack);\r
-  _go32_dpmi_free_iret_wrapper(&KBI);\r
-\r
-  _go32_dpmi_set_real_mode_interrupt_vector(9,&KBIBackRM);\r
-  _go32_dpmi_free_real_mode_callback(&KBIRM);\r
-  initdone=0;\r
- }\r
-}\r
-\r
-/* In FCE Ultra, it doesn't matter if the key states change\r
-   in the middle of the keyboard handling code.  If you want\r
-   to use this code elsewhere, you may want to memcpy() keybuf\r
-   to another buffer and return that when GetKeyboard() is\r
-   called.\r
-*/\r
-\r
-char *GetKeyboard(void)\r
-{\r
- return keybuf;\r
-}\r
-\r
-/* Returns 1 on new scan codes generated, 0 on no new scan codes. */\r
-int UpdateKeyboard(void)\r
-{\r
- int t=newk;\r
-\r
- if(t)\r
- {\r
-  asm volatile(\r
-        "subl %%eax,_newk\n\t"\r
-       :\r
-       : "a" (t)\r
-  );\r
-\r
-  if(keybuf[SCAN_LEFTCONTROL] && keybuf[SCAN_C])\r
-   raise(SIGINT);\r
-  return(1);\r
- }\r
- return(0);\r
-}\r
diff --git a/drivers/cli/dos-mouse.c b/drivers/cli/dos-mouse.c
deleted file mode 100644 (file)
index ae3e341..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-#include <dpmi.h>\r
-#include <string.h>\r
-\r
-#include "dos.h"\r
-\r
-int InitMouse(void)\r
-{\r
- __dpmi_regs regs;\r
-\r
- memset(&regs,0,sizeof(regs));\r
- regs.x.ax=0;\r
- __dpmi_int(0x33,&regs);\r
- if(regs.x.ax!=0xFFFF)\r
-  return(0);\r
-\r
- memset(&regs,0,sizeof(regs));\r
- regs.x.ax=0x7;\r
- regs.x.cx=0;           // Min X\r
- regs.x.dx=260;         // Max X\r
- __dpmi_int(0x33,&regs);\r
-\r
- memset(&regs,0,sizeof(regs));\r
- regs.x.ax=0x8;\r
- regs.x.cx=0;           // Min Y\r
- regs.x.dx=260;         // Max Y\r
- __dpmi_int(0x33,&regs);\r
-\r
- memset(&regs,0,sizeof(regs));\r
- regs.x.ax=0xF;\r
- regs.x.cx=8;           // Mickey X\r
- regs.x.dx=8;           // Mickey Y\r
- __dpmi_int(0x33,&regs);\r
-\r
- memset(&regs,0,sizeof(regs));\r
- regs.x.ax=0x2;\r
- __dpmi_int(0x33,&regs);\r
-\r
- return(1);\r
-}\r
-\r
-uint32 GetMouseData(uint32 *x, uint32 *y)\r
-{\r
- __dpmi_regs regs;\r
-\r
- memset(&regs,0,sizeof(regs));\r
- regs.x.ax=0x3;\r
- __dpmi_int(0x33,&regs);\r
-\r
- *x=regs.x.cx;\r
- *y=regs.x.dx;\r
- return(regs.x.bx&3);\r
-}\r
-\r
-void KillMouse(void)\r
-{\r
-\r
-}\r
diff --git a/drivers/cli/dos-sound.c b/drivers/cli/dos-sound.c
deleted file mode 100644 (file)
index 19ef271..0000000
+++ /dev/null
@@ -1,567 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <sys/farptr.h>\r
-#include <pc.h>\r
-#include <dos.h>\r
-#include <dpmi.h>\r
-#include <go32.h>\r
-#include <ctype.h>\r
-\r
-#include "dos.h"\r
-#include "dos-sound.h"\r
-#include "dos-joystick.h"\r
-\r
-\r
-static void SBIRQHandler(_go32_dpmi_registers *r);\r
-static uint32 LMBuffer;         /* Address of low memory DMA playback buffer. */\r
-static int LMSelector;\r
-\r
-static uint8 *WaveBuffer;\r
-static unsigned int IVector, SBIRQ, SBDMA, SBDMA16, SBPort;\r
-static int DSPV,hsmode;\r
-static int format;\r
-static int frags, fragsize, fragtotal;\r
-static volatile int WritePtr, ReadPtr;\r
-static volatile int hbusy;\r
-static volatile int whichbuf;\r
-\r
-\r
-static uint8 PICMask;\r
-/* Protected mode interrupt vector info. */\r
-static _go32_dpmi_seginfo SBIH,SBIHOld;\r
-\r
-/* Real mode interrupt vector info. */\r
-static _go32_dpmi_seginfo SBIHRM,SBIHRMOld;\r
-static _go32_dpmi_registers SBIHRMRegs;\r
-\r
-static int WriteDSP(uint8 V)\r
-{\r
- int x;\r
-\r
- for(x=65536;x;x--)\r
- {\r
-  if(!(inportb(SBPort+0xC)&0x80))\r
-  {\r
-   outportb(SBPort+0xC,V);\r
-   return(1);\r
-  }\r
- }\r
- return(0);\r
-}\r
-\r
-static int ReadDSP(uint8 *V)\r
-{\r
- int x;\r
-\r
- for(x=65536;x;x--)             /* Should be more than enough time... */\r
- {\r
-  if(inportb(SBPort+0xE)&0x80)\r
-  {\r
-   *V=inportb(SBPort+0xA);\r
-   return(1);\r
-  }\r
- }\r
- return(0);\r
-}\r
-\r
-\r
-static int SetVectors(void)\r
-{\r
- SBIH.pm_offset=SBIHRM.pm_offset=(int)SBIRQHandler;\r
- SBIH.pm_selector=SBIHRM.pm_selector=_my_cs();\r
-\r
- /* Get and set real mode interrupt vector.  */\r
- _go32_dpmi_get_real_mode_interrupt_vector(IVector,&SBIHRMOld);\r
- _go32_dpmi_allocate_real_mode_callback_iret(&SBIHRM, &SBIHRMRegs);\r
- _go32_dpmi_set_real_mode_interrupt_vector(IVector,&SBIHRM);  \r
-\r
- /* Get and set protected mode interrupt vector. */\r
- _go32_dpmi_get_protected_mode_interrupt_vector(IVector,&SBIHOld);\r
- _go32_dpmi_allocate_iret_wrapper(&SBIH);\r
- _go32_dpmi_set_protected_mode_interrupt_vector(IVector,&SBIH); \r
-\r
- return(1);\r
-}\r
-\r
-static void ResetVectors(void)\r
-{\r
- _go32_dpmi_set_protected_mode_interrupt_vector(IVector,&SBIHOld);\r
- _go32_dpmi_free_iret_wrapper(&SBIH);\r
- _go32_dpmi_set_real_mode_interrupt_vector(IVector,&SBIHRMOld);\r
- _go32_dpmi_free_real_mode_callback(&SBIHRM);\r
-}\r
-\r
-int GetBLASTER(void)\r
-{\r
- int check=0;\r
- char *s;\r
-\r
- if(!(s=getenv("BLASTER")))\r
- {\r
-  puts(" Error getting BLASTER environment variable.");\r
-  return(0);\r
- }\r
-\r
- while(*s)\r
- {\r
-  switch(toupper(*s))\r
-  {\r
-   case 'A': check|=(sscanf(s+1,"%x",&SBPort)==1)?1:0;break;\r
-   case 'I': check|=(sscanf(s+1,"%d",&SBIRQ)==1)?2:0;break;\r
-   case 'D': check|=(sscanf(s+1,"%d",&SBDMA)==1)?4:0;break;\r
-   case 'H': check|=(sscanf(s+1,"%d",&SBDMA16)==1)?8:0;break;\r
-  }\r
-  s++;\r
- }\r
\r
- if((check^7)&7 || SBDMA>=4 || (SBDMA16<=4 && check&8) || SBIRQ>15)\r
- {\r
-  puts(" Invalid or incomplete BLASTER environment variable.");\r
-  return(0);\r
- }\r
- if(!(check&8))\r
-  format=0;\r
- return(1);\r
-}\r
-\r
-static int ResetDSP(void)\r
-{\r
- uint8 b;\r
-\r
- outportb(SBPort+0x6,0x1);\r
- delay(10);\r
- outportb(SBPort+0x6,0x0);\r
- delay(10);\r
-\r
- if(ReadDSP(&b))\r
-  if(b==0xAA)\r
-   return(1); \r
- return(0);\r
-}\r
-\r
-static int GetDSPVersion(void)\r
-{\r
- int ret;\r
- uint8 t;\r
-\r
- if(!WriteDSP(0xE1))\r
-  return(0);\r
- if(!ReadDSP(&t))\r
-  return(0);\r
- ret=t<<8;\r
- if(!ReadDSP(&t))\r
-  return(0);\r
- ret|=t;\r
-\r
- return(ret);\r
-}\r
-\r
-static void KillDMABuffer(void)\r
-{\r
- __dpmi_free_dos_memory(LMSelector);\r
-}\r
-\r
-static int MakeDMABuffer(void)\r
-{\r
- uint32 size;\r
- int32 tmp;\r
-\r
- size=fragsize*2;       /* Two buffers in the DMA buffer. */\r
- size<<=format;         /* Twice the size for 16-bit than for 8-bit. */\r
-\r
- size<<=1;              /* Double the size in case the first 2 buffers\r
-                           cross a 64KB or 128KB page boundary.\r
-                        */\r
- size=(size+15)>>4;     /* Convert to paragraphs */\r
-\r
- if((tmp=__dpmi_allocate_dos_memory(size,&LMSelector))<0)\r
-  return(0);\r
-\r
- LMBuffer=tmp<<=4;\r
-\r
- if(format)   /* Check for and fix 128KB page boundary crossing. */\r
- {\r
-  if((LMBuffer&0x20000) != ((LMBuffer+fragsize*2*2-1)&0x20000))\r
-   LMBuffer+=fragsize*2*2;\r
- }\r
- else   /* Check for and fix 64KB page boundary crossing. */\r
- {\r
-  if((LMBuffer&0x10000) != ((LMBuffer+fragsize*2-1)&0x10000))\r
-   LMBuffer+=fragsize*2;\r
- }\r
-\r
- DOSMemSet(LMBuffer, format?0:128, (fragsize*2)<<format);\r
-\r
- return(1);\r
-}\r
-\r
-static void ProgramDMA(void)\r
-{\r
- static int PPorts[8]={0x87,0x83,0x81,0x82,0,0x8b,0x89,0x8a};\r
- uint32 tmp;\r
-\r
- if(format)\r
- {\r
-  outportb(0xd4,(SBDMA16&0x3)|0x4);\r
-  outportb(0xd8,0x0);\r
-  outportb(0xd6,(SBDMA16&0x3)|0x58);\r
-  tmp=((SBDMA16&3)<<2)+0xC2;\r
- }\r
- else\r
- {\r
-  outportb(0xA,SBDMA|0x4);\r
-  outportb(0xC,0x0);\r
-  outportb(0xB,SBDMA|0x58);\r
-  tmp=(SBDMA<<1)+1;\r
- }\r
-\r
- /* Size of entire buffer. */\r
- outportb(tmp,(fragsize*2-1));\r
- outportb(tmp,(fragsize*2-1)>>8);\r
-\r
- /* Page of buffer. */\r
- outportb(PPorts[format?SBDMA16:SBDMA],LMBuffer>>16);\r
-\r
- /* Offset of buffer within page. */\r
- if(format)\r
-  tmp=((SBDMA16&3)<<2)+0xc0;\r
- else\r
-  tmp=SBDMA<<1;\r
-\r
- outportb(tmp,(LMBuffer>>format));\r
- outportb(tmp,(LMBuffer>>(8+format)));\r
-}\r
-\r
-int InitSB(int Rate, int bittage)\r
-{\r
- hsmode=hbusy=0;\r
- whichbuf=1;\r
- puts("Initializing Sound Blaster...");\r
-\r
- format=bittage?1:0;\r
- frags=8;\r
-\r
- if(Rate<=11025)\r
-  fragsize=1<<5;\r
- else if(Rate<=22050)\r
-  fragsize=1<<6;\r
- else\r
-  fragsize=1<<7;\r
-\r
- fragtotal=frags*fragsize;\r
- WaveBuffer=malloc(fragtotal<<format);\r
-\r
- if(format)\r
-  memset(WaveBuffer,0,fragtotal*2);\r
- else\r
-  memset(WaveBuffer,128,fragtotal);\r
-\r
- WritePtr=ReadPtr=0;\r
-\r
- if((Rate<8192) || (Rate>65535))\r
- {\r
-  printf(" Unsupported playback rate: %d samples per second\n",Rate);\r
-  return(0);\r
- }\r
-\r
- if(!GetBLASTER())\r
-  return(0);\r
\r
- /* Disable IRQ line in PIC0 or PIC1 */\r
- if(SBIRQ>7)\r
- {\r
-  PICMask=inportb(0xA1);\r
-  outportb(0xA1,PICMask|(1<<(SBIRQ&7)));\r
- }\r
- else\r
- {\r
-  PICMask=inportb(0x21);\r
-  outportb(0x21,PICMask|(1<<SBIRQ));\r
- }\r
- if(!ResetDSP())\r
- {\r
-  puts(" Error resetting the DSP.");\r
-  return(0);\r
- }\r
\r
- if(!(DSPV=GetDSPVersion()))\r
- {\r
-  puts(" Error getting the DSP version.");\r
-  return(0);\r
- }\r
-\r
- printf(" DSP Version: %d.%d\n",DSPV>>8,DSPV&0xFF);\r
- if(DSPV<0x201)\r
- {\r
-  printf(" DSP version number is too low.\n");\r
-  return(0);\r
- }\r
-\r
- if(DSPV<0x400)\r
-  format=0;\r
- if(!MakeDMABuffer())\r
- {\r
-  puts(" Error creating low-memory DMA buffer.");\r
-  return(0);\r
- }\r
-\r
- if(SBIRQ>7) IVector=SBIRQ+0x68;\r
- else IVector=SBIRQ+0x8;\r
-\r
- if(!SetVectors())\r
- {\r
-  puts(" Error setting interrupt vectors.");\r
-  KillDMABuffer();\r
-  return(0);\r
- }\r
-\r
- /* Reenable IRQ line. */\r
- if(SBIRQ>7)\r
-  outportb(0xA1,PICMask&(~(1<<(SBIRQ&7))));\r
- else\r
-  outportb(0x21,PICMask&(~(1<<SBIRQ)));\r
-\r
- ProgramDMA();\r
-\r
- /* Note that the speaker must always be turned on before the mode transfer\r
-    byte is sent to the DSP if we're going into high-speed mode, since\r
-    a real Sound Blaster(at least my SBPro) won't accept DSP commands(except\r
-    for the reset "command") after it goes into high-speed mode.\r
- */\r
- WriteDSP(0xD1);                 // Turn on DAC speaker\r
-\r
- if(DSPV>=0x400)\r
- {\r
-  WriteDSP(0x41);                // Set sampling rate\r
-  WriteDSP(Rate>>8);             // High byte\r
-  WriteDSP(Rate&0xFF);           // Low byte\r
-  if(!format)\r
-  {\r
-   WriteDSP(0xC6);                // 8-bit output\r
-   WriteDSP(0x00);                // 8-bit mono unsigned PCM\r
-  }\r
-  else\r
-  {\r
-   WriteDSP(0xB6);                // 16-bit output\r
-   WriteDSP(0x10);                // 16-bit mono signed PCM\r
-  }\r
-  WriteDSP((fragsize-1)&0xFF);// Low byte of size\r
-  WriteDSP((fragsize-1)>>8);  // High byte of size\r
- }\r
- else\r
- {\r
-  int tc,command;\r
-  if(Rate>22050)\r
-  {\r
-   tc=(65536-(256000000/Rate))>>8;\r
-   Rate=256000000/(65536-(tc<<8));\r
-   command=0x90;                  // High-speed auto-initialize DMA mode transfer\r
-   hsmode=1;\r
-  }\r
-  else\r
-  {\r
-   tc=256-(1000000/Rate);\r
-   Rate=1000000/(256-tc);\r
-   command=0x1c;                  // Auto-initialize DMA mode transfer\r
-  }\r
-  WriteDSP(0x40);       // Set DSP time constant\r
-  WriteDSP(tc);         // time constant\r
-  WriteDSP(0x48);       // Set DSP block transfer size\r
-  WriteDSP((fragsize-1)&0xFF);\r
-  WriteDSP((fragsize-1)>>8);\r
-\r
-  WriteDSP(command);\r
- }\r
-\r
- /* Enable DMA */\r
- if(format)\r
-  outportb(0xd4,SBDMA16&3);\r
- else\r
-  outportb(0xa,SBDMA);\r
-\r
- printf(" %d hz, %d-bit\n",Rate,8<<format);\r
- return(Rate);\r
-}\r
-\r
-extern volatile int soundjoyer;\r
-extern volatile int soundjoyeron;\r
-static int ssilence=0;\r
-\r
-static void SBIRQHandler(_go32_dpmi_registers *r)\r
-{\r
-        uint32 *src;\r
-       uint32 dest;\r
-       int32 x;\r
-\r
-\r
-        if(format)\r
-        {\r
-         uint8 status;\r
-\r
-         outportb(SBPort+4,0x82);\r
-         status=inportb(SBPort+5);\r
-         if(status&2)\r
-          inportb(SBPort+0x0F);\r
-        }\r
-        else\r
-         inportb(SBPort+0x0E);\r
-\r
-        #ifdef OLD\r
-        {\r
-         uint8 status;\r
-\r
-         outportb(SBPort+4,0x82);\r
-         status=inportb(SBPort+5);\r
-         if(status&1)\r
-          inportb(SBPort+0x0E);\r
-         else if(status&2)\r
-          inportb(SBPort+0x0F);\r
-         else\r
-          return;               // Mysterious interrupt source!  *eerie music*\r
-        }         \r
-        #endif\r
-\r
-        if(hbusy)\r
-        {\r
-         outportb(0x20,0x20);\r
-         if(SBIRQ>=8)\r
-          outportb(0xA0,0x20);\r
-         whichbuf^=1;         \r
-         return;\r
-        }\r
-        hbusy=1;\r
-\r
-        {\r
-         /* This code seems to fail on many SB emulators.  Bah.\r
-            SCREW SB EMULATORS. ^_^ */\r
-         uint32 count;\r
-        uint32 block;\r
-        uint32 port;\r
-       \r
-         if(format)\r
-          port=((SBDMA16&3)*4)+0xc2;\r
-         else\r
-          port=(SBDMA*2)+1;\r
-\r
-         count=inportb(port);\r
-         count|=inportb(port)<<8;\r
-\r
-         if(count>=fragsize)\r
-          block=1;\r
-         else\r
-          block=0;\r
-         dest=LMBuffer+((block*fragsize)<<format);\r
-\r
-         #ifdef MOO\r
-         dest=LMBuffer+((whichbuf*fragsize)<<format);\r
-         whichbuf^=1;\r
-         #endif\r
-        }\r
-\r
-        _farsetsel(_dos_ds);\r
-\r
-        src=(uint32 *)(WaveBuffer+(ReadPtr<<format));\r
-\r
-       if(ssilence)\r
-       {\r
-        uint32 sby;\r
-        if(format) sby=0;      /* 16-bit silence.  */\r
-        else sby=0x80808080;   /* 8-bit silence.   */\r
-\r
-         for(x=(fragsize<<format)>>2;x;x--,dest+=4)\r
-         {\r
-          _farnspokel(dest,sby);\r
-         }\r
-       }\r
-       else\r
-       {\r
-         for(x=(fragsize<<format)>>2;x;x--,dest+=4,src++)\r
-         {\r
-          _farnspokel(dest,*src);\r
-         }\r
-         ReadPtr=(ReadPtr+fragsize)&(fragtotal-1);\r
-       }\r
-\r
-        if(soundjoyeron)\r
-        {\r
-         static int coot=0;\r
-         if(!coot)\r
-         {\r
-          UpdateJoyData();\r
-          soundjoyer=1;\r
-         }\r
-         coot=(coot+1)&3;\r
-        }\r
-        hbusy=0;\r
-        outportb(0x20,0x20);\r
-        if(SBIRQ>=8)        \r
-         outportb(0xA0,0x20);\r
-}\r
-\r
-void SilenceSound(int s)\r
-{\r
- ssilence=s;\r
-}\r
-\r
-void WriteSBSound(int32 *Buffer, int Count, int NoBlocking)\r
-{\r
- int x;\r
-\r
- if(!format)\r
- {\r
-   for(x=0;x<Count;x++)\r
-   {\r
-    while(WritePtr==ReadPtr)\r
-     if(NoBlocking)\r
-      return;\r
-    WaveBuffer[WritePtr]=(uint8)((Buffer[x])>>8)^128;\r
-    WritePtr=(WritePtr+1)&(fragtotal-1);\r
-   }\r
- }     \r
- else // 16 bit\r
- {\r
-   for(x=0;x<Count;x++)\r
-   {\r
-    while(WritePtr==ReadPtr)\r
-     if(NoBlocking)\r
-      return;\r
-    ((int16 *)WaveBuffer)[WritePtr]=Buffer[x];\r
-    WritePtr=(WritePtr+1)&(fragtotal-1);\r
-   }\r
- }\r
-}\r
-\r
-void KillSB(void)\r
-{\r
- if(hsmode)\r
-  ResetDSP();                   /* High-speed mode requires a DSP reset. */\r
- else\r
-  WriteDSP(format?0xD9:0xDA);    /* Exit auto-init DMA transfer mode. */ \r
- WriteDSP(0xD3);                /* Turn speaker off. */\r
-\r
- outportb((SBIRQ>7)?0xA1:0x21,PICMask|(1<<(SBIRQ&7)));\r
- ResetVectors();\r
- outportb((SBIRQ>7)?0xA1:0x21,PICMask);\r
- KillDMABuffer();\r
-}\r
diff --git a/drivers/cli/dos-sound.h b/drivers/cli/dos-sound.h
deleted file mode 100644 (file)
index 7f5185a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-int InitSB(int Rate, int bittage);\r
-void KillSB(void);\r
-\r
-void WriteSBSound(int32 *Buffer, int Count, int NoBlocking);\r
-void SilenceSound(int s);\r
-\r
diff --git a/drivers/cli/dos-video.c b/drivers/cli/dos-video.c
deleted file mode 100644 (file)
index 574c824..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 1998 \Firebug\\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <dpmi.h>\r
-#include <sys/farptr.h>\r
-#include <go32.h>\r
-#include <pc.h>\r
-\r
-#include "dos.h"\r
-#include "dos-video.h"\r
-\r
-#define TEXT            3\r
-#define G320x200x256    0x13\r
-\r
-static void vga_waitretrace(void)\r
-{ \r
- while(inp(0x3da)&0x8); \r
- while(!(inp(0x3da)&0x8));\r
-}\r
-\r
-static void vga_setmode(int mode)\r
-{\r
- __dpmi_regs regs;\r
-\r
- memset(&regs,0,sizeof(regs));\r
- regs.x.ax=mode;\r
-\r
- __dpmi_int(0x10,&regs);\r
-}\r
-\r
-void vga_setpalette(int i, int r, int g, int b)\r
-{ \r
- outp(0x3c8,i);\r
- outp(0x3c9,r);\r
- outp(0x3c9,g);\r
- outp(0x3c9,b); \r
-}\r
-\r
-int FCEUDvmode=1;\r
-\r
-static int vidready=0;\r
-\r
-/*      Part of the VGA low-level mass register setting code derived from\r
-       code by \Firebug\.\r
-*/\r
-\r
-#include "vgatweak.c"\r
-\r
-void SetBorder(void)\r
-{\r
- inportb(0x3da);\r
- outportb(0x3c0,(0x11|0x20));\r
- outportb(0x3c0,0x80);\r
-}\r
-\r
-void TweakVGA(int VGAMode)\r
-{\r
-  int I;\r
-  \r
-  vga_waitretrace();\r
-\r
-  outportb(0x3C8,0x00);\r
-  for(I=0;I<768;I++) outportb(0x3C9,0x00);\r
-\r
-  outportb(0x3D4,0x11);\r
-  I=inportb(0x3D5)&0x7F;\r
-  outportb(0x3D4,0x11);\r
-  outportb(0x3D5,I);\r
-\r
-  switch(VGAMode)\r
-  {\r
-    case 1:  for(I=0;I<25;I++) VGAPortSet(v256x240[I]);break;\r
-    case 2:  for(I=0;I<25;I++) VGAPortSet(v256x256[I]);break;\r
-    case 3:  for(I=0;I<25;I++) VGAPortSet(v256x256S[I]);break;\r
-    case 6:  for(I=0;I<25;I++) VGAPortSet(v256x224S[I]);break;\r
-    case 8:  for(I=0;I<25;I++) VGAPortSet(v256x224_103[I]);break;\r
-    default: break;\r
-  }\r
-\r
-  outportb(0x3da,0);\r
-}\r
-\r
-\r
-static uint8 palettedbr[256],palettedbg[256],palettedbb[256];\r
-\r
-static void FlushPalette(void)\r
-{\r
- int x;\r
- for(x=0;x<256;x++)\r
- {\r
-  int z=x;\r
-  vga_setpalette(z,palettedbr[x]>>2,palettedbg[x]>>2,palettedbb[x]>>2);\r
- }\r
-}\r
-\r
-void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)\r
-{\r
-  palettedbr[index]=r;\r
-  palettedbg[index]=g;\r
-  palettedbb[index]=b;\r
-  if(vidready)\r
-  {\r
-   vga_setpalette(index,r>>2,g>>2,b>>2);\r
-  }\r
-}\r
-\r
-\r
-void FCEUD_GetPalette(uint8 i, uint8 *r, uint8 *g, uint8 *b)\r
-{\r
- *r=palettedbr[i];\r
- *g=palettedbg[i];\r
- *b=palettedbb[i];\r
-}\r
-\r
-static uint32 ScreenLoc;\r
-\r
-int InitVideo(void)\r
-{\r
- vidready=0;\r
- switch(FCEUDvmode)\r
- {\r
-  default:\r
-  case 1:\r
-  case 2:\r
-  case 3:\r
-  case 6:\r
-  case 8:\r
-         vga_setmode(G320x200x256);\r
-        vidready|=1;\r
-         ScreenLoc=0xa0000;\r
-         TweakVGA(FCEUDvmode);\r
-         SetBorder();\r
-         DOSMemSet(ScreenLoc, 128, 256*256);\r
-         break;\r
- }\r
- vidready|=2;\r
- FlushPalette();\r
- return 1;\r
-}\r
-\r
-void KillVideo(void)\r
-{\r
- if(vidready)\r
- {\r
-  vga_setmode(TEXT);\r
-  vidready=0;\r
- }\r
-}\r
-void LockConsole(void){}\r
-void UnlockConsole(void){}\r
-void BlitScreen(uint8 *XBuf)\r
-{\r
- uint32 dest;\r
- int tlines;\r
-\r
- if(eoptions&4 && !NoWaiting)\r
-  vga_waitretrace();\r
-\r
- tlines=erendline-srendline+1;\r
-\r
- dest=ScreenLoc;\r
-\r
- switch(FCEUDvmode)\r
- {\r
-  case 1:dest+=(((240-tlines)>>1)<<8);break;\r
-  case 2:\r
-  case 3:dest+=(((256-tlines)>>1)<<8);break;\r
-  case 4:\r
-  case 5:dest+=(((240-tlines)>>1)*640+((640-512)>>1));break;\r
-  case 8:\r
-  case 6:if(tlines>224) tlines=224;dest+=(((224-tlines)>>1)<<8);break;\r
- }\r
\r
- XBuf+=(srendline<<8)+(srendline<<4);\r
-           \r
-  _farsetsel(_dos_ds);\r
- if(eoptions&DO_CLIPSIDES)\r
- {\r
-  asm volatile(     \r
-     "agoop1:\n\t"\r
-     "movl $30,%%eax\n\t"\r
-     "agoop2:\n\t"\r
-     "movl (%%esi),%%edx\n\t"\r
-     "movl 4(%%esi),%%ecx\n\t"\r
-     ".byte 0x64 \n\t"\r
-     "movl %%edx,(%%edi)\n\t"\r
-     ".byte 0x64 \n\t"\r
-     "movl %%ecx,4(%%edi)\n\t"\r
-     "addl $8,%%esi\n\t"\r
-     "addl $8,%%edi\n\t"\r
-     "decl %%eax\n\t"\r
-     "jne agoop2\n\t"\r
-     "addl $32,%%esi\n\t"\r
-     "addl $16,%%edi\n\t"\r
-     "decb %%bl\n\t"\r
-     "jne agoop1\n\t"\r
-     :\r
-     : "S" (XBuf+8), "D" (dest+8), "b" (tlines)\r
-     : "%eax","%cc","%edx","%ecx" );\r
- }\r
- else\r
- {\r
-  asm volatile(     \r
-     "goop1:\n\t"\r
-     "movl $32,%%eax\n\t"\r
-     "goop2:\n\t"\r
-     "movl (%%esi),%%edx\n\t"\r
-     "movl 4(%%esi),%%ecx\n\t"\r
-     ".byte 0x64 \n\t"\r
-     "movl %%edx,(%%edi)\n\t"\r
-     ".byte 0x64 \n\t"\r
-     "movl %%ecx,4(%%edi)\n\t"\r
-     "addl $8,%%esi\n\t"\r
-     "addl $8,%%edi\n\t"\r
-     "decl %%eax\n\t"\r
-     "jne goop2\n\t"\r
-     "addl $16,%%esi\n\t"\r
-     "decb %%bl\n\t"\r
-     "jne goop1\n\t"\r
-     :\r
-     : "S" (XBuf), "D" (dest), "b" (tlines)\r
-     : "%eax","%cc","%edx","%ecx" );\r
- }\r
-}\r
-\r
-\r
diff --git a/drivers/cli/dos-video.h b/drivers/cli/dos-video.h
deleted file mode 100644 (file)
index ee09b51..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-extern int FCEUDvmode;\r
-\r
diff --git a/drivers/cli/dos.c b/drivers/cli/dos.c
deleted file mode 100644 (file)
index 8ba1578..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <crt0.h>
-#include <sys/farptr.h>
-#include <go32.h>
-
-#include "dos.h"
-#include "dos-joystick.h"
-#include "dos-video.h"
-#include "dos-sound.h"
-#include "../common/args.h"
-#include "../common/config.h"
-
-/* _CRT0_FLAG_LOCK_MEMORY might not always result in all memory being locked.
-   Bummer.  I'll add code to explicitly lock the data touched by the sound
-   interrupt handler(and the handler itself), if necessary(though that might
-   be tricky...).  I'll also to cover the data the keyboard
-   interrupt handler touches.
-*/
-
-int _crt0_startup_flags = _CRT0_FLAG_FILL_SBRK_MEMORY | _CRT0_FLAG_LOCK_MEMORY | _CRT0_FLAG_USE_DOS_SLASHES;
-
-static int f8bit=0;
-int soundo=44100;
-int doptions=0;
-
-
-CFGSTRUCT DriverConfig[]={
-        NAC("sound",soundo),
-        AC(doptions),
-        AC(f8bit),
-        AC(FCEUDvmode),
-        NACA("joybmap",joyBMap),
-        AC(joy),
-        ENDCFGSTRUCT
-};
-
-char *DriverUsage=
-"-vmode x        Select video mode(all are 8 bpp).\n\
-                 1 = 256x240                 6 = 256x224(with scanlines)\n\
-                 2 = 256x256                 8 = 256x224\n\
-                 3 = 256x256(with scanlines)\n\
--vsync x        Wait for the screen's vertical retrace before updating the\n\
-                screen.  Refer to the documentation for caveats.\n\
-                 0 = Disabled.\n\
-                 1 = Enabled.\n\
--sound x        Sound.\n\
-                 0 = Disabled.\n\
-                 Otherwise, x = playback rate.\n\
--f8bit x        Force 8-bit sound.\n\
-                 0 = Disabled.\n\
-                 1 = Enabled.\n\
--joy x          Joystick mapped to virtual joystick x(1-4).\n\
-                 0 = Disabled, reset configuration.\n\
-                 1 = Enabled.";
-
-ARGPSTRUCT DriverArgs[]={
-         {"-vmode",0,&FCEUDvmode,0},
-         {"-sound",0,&soundo,0},
-         {"-f8bit",0,&f8bit,0},
-         {"-joy",0,&joy,0},
-         {"-vsync",0,&eoptions,0x8004},
-         {0,0,0,0}
-};
-
-void DoDriverArgs(void)
-{
-        if(!joy) memset(joyBMap,0,4);
-}
-
-int InitSound(void)
-{
- if(soundo)
- {
-  if(soundo==1)
-   soundo=44100;
-  soundo=InitSB(soundo,f8bit?0:1);
-  FCEUI_Sound(soundo);
- }
- return(soundo?1:0);
-}
-
-void WriteSound(int32 *Buffer, int Count, int NoWaiting)
-{
- WriteSBSound(Buffer,Count,NoWaiting);
-}
-
-void KillSound(void)
-{
- if(soundo)
-  KillSB();
-}
-
-void DOSMemSet(uint32 A, uint8 V, uint32 count)
-{
- uint32 x;
-
- _farsetsel(_dos_ds);
- for(x=0;x<count;x++)
-  _farnspokeb(A+x,V);
-}
-
-static char *arg0;
-void GetBaseDirectory(char *BaseDirectory)
-{
- int x=0;
-
- if(arg0)
-  for(x=strlen(arg0);x>=0;x--)
-  {
-   if(arg0[x]=='/' || arg0[x]=='\\')
-   {
-    strncpy(BaseDirectory,arg0,x);
-    break;
-   }
-  }
-
- BaseDirectory[x]=0;
-}
-
-int main(int argc, char *argv[])
-{
-        puts("\nStarting FCE Ultra "VERSION_STRING"...\n");
-       arg0=argv[0];
-        return(CLImain(argc,argv));
-}
-
diff --git a/drivers/cli/dos.h b/drivers/cli/dos.h
deleted file mode 100644 (file)
index 05bc8e5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-#include "../../driver.h"\r
-#include "main.h"\r
-\r
-extern int eoptions;\r
-extern int soundo;\r
-void DOSMemSet(uint32 A, uint8 V, uint32 count);\r
-#define DO_CLIPSIDES    1\r
-\r
diff --git a/drivers/cli/minimal.c b/drivers/cli/minimal.c
new file mode 100644 (file)
index 0000000..193fa9e
--- /dev/null
@@ -0,0 +1,476 @@
+/*
+  GP2X minimal library v0.A by rlyeh, 2005. emulnation.info@rlyeh (swap it!)
+
+  + GP2X 920t/940t CPUs library with a FIFO message system.
+  + GP2X video library with double buffering.
+  + GP2X sound library with double buffering.
+  + GP2X blitter library.
+  + GP2X timer library.
+  + GP2X joystick library.
+
+  Thanks to Squidge, Robster, snaff, Reesy and NK, for the help & previous work! :-)
+
+
+  License
+  =======
+
+  Free for non-commercial projects (it would be nice receiving a mail from you).
+  Other cases, ask me first.
+
+  GamePark Holdings is not allowed to use this library and/or use parts from it.
+
+
+  Known projects using the library or parts from it
+  =================================================
+
+  REminiscence-0.1.8 (rlyeh)
+  Atari800 GP2X pre-release 3 (foft)
+  XUMP (kedo)
+  MAME2X (Franxis)
+  DrMD for GP2X (Reesy)
+
+
+  What's new
+  ==========
+
+  0.A: 940t disabled all time unless required
+       sound is paused by default now, use gp2x_sound_pause() to unlock it
+
+       fixed functions:
+        - gp2x_sound_play()                        ; increased the number of sampling buffers
+        - gp2x_timer_read()                        ; it should work again. broken at some point before
+        - gp2x_dualcore_launch_program_from_disk() ; it missed the code uploading call
+
+       added functions:
+        - gp2x_sound_pause()
+        - gp2x_timer_delay()
+        - gp2x_dualcore_pause()
+
+  0.9: initial FIFO message system for dual cpu cores.
+       initial 48 Mb support.
+       initial quadruple buffering in 8bbp mode.              
+
+       added functions:
+        - gp2x_dualcore_exec() ; initial FIFO message system for dual cpu cores. 
+        - gp2x_dualcore_sync() ; initial FIFO message system for dual cpu cores.
+
+       improved functions:
+        - gp2x_video_flip()    ; initial quadruple buffering in 8bbp mode.              
+
+  0.8: initial dual cores cpu support.
+       very basic blit functions by popular demand ;-)
+       vsync & hsync waiting code (thanks Reesy)
+
+       added functions:
+        - gp2x_launch_program()            ; initial dual cores cpu support.
+        - gp2x_launch_program_from_disk()  ; initial dual cores cpu support.
+        - gp2x_launch_subprogram()         ; initial dual cores cpu support.
+        - gp2x_blitter_rect15()            ; very basic blit function by popular demand ;-)
+        - gp2x_blitter_rect8()             ; very basic blit function by popular demand ;-)
+        - gp2x_video_hsync()               ; hsync waiting code (thanks Reesy)
+        - gp2x_video_vsync()               ; vsync waiting code (thanks Reesy)
+
+       fixed functions:
+        - gp2x_video_color8()              ; bugfixed a stupid typo (thanks Franxis for the bug report)
+
+  0.7: added functions:
+        - gp2x_sound_volume()
+
+       fixed functions:
+        - gp2x_deinit()           ; fixed menu launch code when exiting.
+
+       improved functions:
+        - gp2x_timer_read()       ; rewritten timer. it should be more accurate now.
+        - gp2x_init()             ; faster init code.
+
+  0.6: added functions:
+        - gp2x_timer_read()
+        - gp2x_sound_pause()
+
+       fixed functions:
+        - gp2x_video_setpalette() ; palette handling was incorrect. fixed.
+
+  0.5: improved functions:
+        - gp2x_init()             ; better and cleaner initalizing code.
+        - gp2x_init()             ; sound patched for real stereo output (by using NK's solution)
+
+  0.4: lots of cleanups.
+       sound is threaded and double buffered now.
+       8 bpp video support.
+
+       fixed functions:
+        - gp2x_deinit()           ; better and cleaner exiting code.
+
+  0.3: shorter library.
+
+       fixed functions:
+        - gp2x_joystick_read()    ; improved joystick diagonal detection.
+
+  0.2: better code layout.
+       public release.
+
+  0.1: beta release.
+*/
+
+#include "minimal.h"
+
+         unsigned char  *gp2x_screen8                 ,*gp2x_upperRAM;
+         unsigned long   gp2x_dev[8]={0,0,0,0,0,0,0,0}, gp2x_physvram[8], *gp2x_memregl,       gp2x_volume,                      gp2x_ticks_per_second;
+volatile unsigned long   gp2x_sound_pausei=1,           gp2x_ticks=0,      gp2x_sound=0,      *gp2x_dualcore_ram;
+         unsigned short *gp2x_memregs,                 *gp2x_screen15,    *gp2x_logvram15[4],  gp2x_sound_buffer[4+((44100/25)*2)*8]; //25 Hz gives our biggest supported sampling buffer
+volatile unsigned short  gp2x_palette[512];
+         pthread_t       gp2x_sound_thread=0;
+
+extern void gp2x_sound_frame(void *blah, void *buff, int samples);
+
+
+void gp2x_video_flip(void)
+{
+  unsigned long address=gp2x_physvram[gp2x_physvram[7]];
+
+  if(++gp2x_physvram[7]==4) gp2x_physvram[7]=0;
+  gp2x_screen15=gp2x_logvram15[gp2x_physvram[7]]; 
+  gp2x_screen8=(unsigned char *)gp2x_screen15; 
+  gp2x_memregs[0x290E>>1]=(unsigned short)(address & 0xFFFF);
+  gp2x_memregs[0x2910>>1]=(unsigned short)(address >> 16);
+  gp2x_memregs[0x2912>>1]=(unsigned short)(address & 0xFFFF);
+  gp2x_memregs[0x2914>>1]=(unsigned short)(address >> 16);
+}
+
+void gp2x_video_flip_single(void)
+{
+  unsigned long address=gp2x_physvram[0];
+
+  gp2x_screen15=gp2x_logvram15[0]; 
+  gp2x_screen8=(unsigned char *)gp2x_screen15; 
+  gp2x_memregs[0x290E>>1]=(unsigned short)(address & 0xFFFF);
+  gp2x_memregs[0x2910>>1]=(unsigned short)(address >> 16);
+  gp2x_memregs[0x2912>>1]=(unsigned short)(address & 0xFFFF);
+  gp2x_memregs[0x2914>>1]=(unsigned short)(address >> 16);
+}
+
+
+void gp2x_video_setgamma(unsigned short gamma) /*0..255*/
+{
+  int i=256*3; 
+  gp2x_memregs[0x295C>>1]=0;                                                     
+  while(i--) gp2x_memregs[0x295E>>1]=gamma; 
+}
+
+void gp2x_video_setpalette(void)
+{
+  unsigned short *g=(unsigned short *)gp2x_palette; int i=512;
+  gp2x_memregs[0x2958>>1]=0;                                                     
+  while(i--) gp2x_memregs[0x295A>>1]=*g++; 
+}
+
+void gp2x_blitter_rect15(gp2x_rect *r)
+{
+ int x, y; unsigned short *data=r->data15, *offset=&gp2x_screen15[r->x+r->y*320];
+
+ y=r->h; if(r->solid)
+         while(y--) { x=r->w; while(x--) *offset++=*data++; offset+=320-x; }
+         else
+         while(y--) { x=r->w; while(x--) { if(*data) *offset=*data; offset++, data++; }
+                      offset+=320-x; }
+}
+
+void gp2x_blitter_rect8(gp2x_rect *r)
+{
+ int x, y; unsigned char *data=r->data8,   *offset=&gp2x_screen8[r->x+r->y*320]; 
+
+ y=r->h; if(r->solid)
+         while(y--) { x=r->w; while(x--) *offset++=*data++; offset+=320-x; }
+         else
+         while(y--) { x=r->w; while(x--) { if(*data) *offset=*data; offset++, data++; }
+                      offset+=320-x; }
+}
+unsigned long gp2x_joystick_read(void)
+{
+  unsigned long value=(gp2x_memregs[0x1198>>1] & 0x00FF);
+
+  if(value==0xFD) value=0xFA;
+  if(value==0xF7) value=0xEB;
+  if(value==0xDF) value=0xAF;
+  if(value==0x7F) value=0xBE;
+  return ~((gp2x_memregs[0x1184>>1] & 0xFF00) | value | (gp2x_memregs[0x1186>>1] << 16));
+}
+
+void gp2x_sound_volume(int l, int r)
+{
+ l=(((l*0x50)/100)<<8)|((r*0x50)/100);          //0x5A, 0x60
+ ioctl(gp2x_dev[4], SOUND_MIXER_WRITE_PCM, &l); //SOUND_MIXER_WRITE_VOLUME
+}
+
+void gp2x_timer_delay(unsigned long ticks)
+{
+ unsigned long target=gp2x_memregl[0x0A00>>2]+ticks*gp2x_ticks_per_second;
+ while(gp2x_memregl[0x0A00>>2]<target); 
+}
+
+unsigned long gp2x_timer_read(void)
+{
+ return gp2x_memregl[0x0A00>>2]/gp2x_ticks_per_second;
+} 
+
+unsigned long gp2x_timer_read_ms(void)
+{
+ return gp2x_memregl[0x0A00>>2];
+} 
+
+
+void gp2x_sound_pause(int yes) { gp2x_sound_pausei=yes; }
+
+
+static void *gp2x_sound_play(void *blah)
+{
+  int flip=0, flyp=gp2x_sound_buffer[1];
+  struct timespec ts; ts.tv_sec=0, ts.tv_nsec=gp2x_sound_buffer[2];
+
+  while(!gp2x_sound)  
+  { 
+    nanosleep(&ts, NULL);
+                        
+                        
+   if(!gp2x_sound_pausei) 
+   { 
+     // [1] is sound buffer size     at 22050, 16, stereo, it is 1468 (367*4)
+     // [0] number of bytes?,  at 22050,16,stereo, it is 367
+     // first half of buffer
+
+     // first one is 368
+
+     
+    gp2x_sound_frame(blah, (void *)(&gp2x_sound_buffer[4+flip]), gp2x_sound_buffer[0]);
+    // write out to second half of buffer
+    write(gp2x_dev[3],     (void *)(&gp2x_sound_buffer[4+flyp]), gp2x_sound_buffer[1]);
+
+    flip+=gp2x_sound_buffer[1];
+         if(flip==gp2x_sound_buffer[1]*8) flip=0;
+   flyp+=gp2x_sound_buffer[1]; 
+   if(flyp==gp2x_sound_buffer[1]*8) flyp=0;
+   }              
+  }
+  return NULL;
+}
+
+static void gp2x_initqueue(gp2x_queue *q, unsigned long queue_items, unsigned long *position920t, unsigned long *position940t)
+{
+  q->head  = q->tail  = q->items = 0;
+  q->max_items = queue_items;
+  if(position920t) q->place920t=position920t; else q->place920t=(unsigned long *)malloc(sizeof(unsigned long) * queue_items);
+  if(position940t) q->place940t=position940t;
+  memset(q->place920t, 0, sizeof(unsigned long) * queue_items);
+}
+
+static void gp2x_enqueue(gp2x_queue *q, unsigned long data)
+{      
+  while(q->items==q->max_items); /*waiting for tail to decrease...*/
+  q->place920t[q->head = (q->head < q->max_items ? q->head+1 : 0)] = data;
+  q->items++;
+}
+
+/* UNUSED
+ static unsigned long gp2x_dequeue(gp2x_queue *q)
+{
+  while(!q->items); //waiting for head to increase...
+  q->items--;
+  return q->place920t[q->tail = (q->tail < q->max_items ? q->tail+1 : 0)];
+} */
+
+
+
+       void gp2x_dualcore_pause(int yes) { if(yes) gp2x_memregs[0x0904>>1] &= 0xFFFE; else gp2x_memregs[0x0904>>1] |= 1; }
+static void gp2x_940t_reset(int yes)     { gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (0x03); }
+static void gp2x_940t_pause(int yes)     { gp2x_dualcore_pause(yes); }
+
+static void gp2x_dualcore_registers(int save)
+{
+ static unsigned short regs[8];
+
+ if(save)
+ {
+  regs[0]=gp2x_memregs[0x0904>>1];  regs[1]=gp2x_memregs[0x0912>>1];
+  regs[2]=gp2x_memregs[0x091c>>1];  regs[3]=gp2x_memregs[0x3b40>>1];
+  regs[4]=gp2x_memregs[0x3b42>>1];  regs[5]=gp2x_memregs[0x3b48>>1];
+  regs[6]=gp2x_memregs[0x3b44>>1];  regs[7]=gp2x_memregs[0x3b46>>1];
+
+  gp2x_940t_reset(1);
+  gp2x_940t_pause(1);
+ }
+ else
+ {
+  gp2x_memregs[0x0904>>1]=regs[0];  gp2x_memregs[0x0912>>1]=regs[1];
+  gp2x_memregs[0x091c>>1]=regs[2];  gp2x_memregs[0x3b40>>1]=regs[3];
+  gp2x_memregs[0x3b42>>1]=regs[4];  gp2x_memregs[0x3b48>>1]=regs[5];
+  gp2x_memregs[0x3b44>>1]=regs[6];  gp2x_memregs[0x3b46>>1]=regs[7];
+ }
+}
+
+void gp2x_dualcore_sync(void)
+{
+  gp2x_queue *q=(gp2x_queue *)gp2x_1stcore_data_ptr(GP2X_QUEUE_ARRAY_PTR);
+  while(q->items);
+}
+
+void gp2x_dualcore_exec(unsigned long command) { gp2x_enqueue((gp2x_queue *)gp2x_1stcore_data_ptr(GP2X_QUEUE_ARRAY_PTR),command); }
+
+void gp2x_dualcore_launch_program(unsigned long *area, unsigned long size)
+{
+  unsigned long i=0, *arm940t_ram=(unsigned long *)gp2x_dualcore_ram;
+  
+  gp2x_940t_reset(1);
+
+  gp2x_memregs[0x3B40>>1] = 0;                               //disable interrupts
+  gp2x_memregs[0x3B42>>1] = 0;
+  gp2x_memregs[0x3B44>>1] = 0xffff;
+  gp2x_memregs[0x3B46>>1] = 0xffff;
+
+  gp2x_940t_pause(0);            
+                             
+  while(i < size) *arm940t_ram++=area[i++];
+
+  gp2x_initqueue((gp2x_queue *)gp2x_1stcore_data_ptr(GP2X_QUEUE_ARRAY_PTR), GP2X_QUEUE_MAX_ITEMS, (unsigned long *)gp2x_1stcore_data_ptr(GP2X_QUEUE_DATA_PTR), (unsigned long *)gp2x_2ndcore_data_ptr(GP2X_QUEUE_DATA_PTR));
+
+  gp2x_940t_reset(0);
+}
+
+void gp2x_dualcore_launch_program_from_disk(const char *file, unsigned long offset, unsigned long size)
+{
+ FILE *in; void *data;
+
+ if((in=fopen(file, "rb"))==NULL) return;
+ if((data=malloc(size))==NULL) { fclose(in); return; }
+ fseek(in, 0L, offset);
+ fread(data, 1, size, in);
+ gp2x_dualcore_launch_program((unsigned long *)data, size);
+ free(data);
+ fclose(in);
+}
+
+void gp2x_init(int ticks_per_second, int bpp, int rate, int bits, int stereo, int Hz)
+{
+  struct fb_fix_screeninfo fixed_info;
+  static int first=1;
+
+  // GP2X_DO_SOUND
+  int gp2x_do_sound=1;
+  int frag=0;
+  int channels=1;
+  int stereoLocal=0;
+
+  gp2x_ticks_per_second=7372800/ticks_per_second; 
+
+  if(!gp2x_dev[0])   gp2x_dev[0] = open("/dev/fb0",   O_RDWR);
+  if(!gp2x_dev[1])   gp2x_dev[1] = open("/dev/fb1",   O_RDWR);
+  if(!gp2x_dev[2])   gp2x_dev[2] = open("/dev/mem",   O_RDWR); 
+  
+  // don't run sound right now
+  if ( gp2x_do_sound)
+  {
+    if(!gp2x_dev[3])   gp2x_dev[3] = open("/dev/dsp",   O_WRONLY);
+    if(!gp2x_dev[4])   gp2x_dev[4] = open("/dev/mixer", O_RDWR);
+  }
+
+  gp2x_dualcore_ram=(unsigned long  *)mmap(0, 0x1000000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], 0x03000000);
+/*gp2x_dualcore_ram=(unsigned long  *)mmap(0, 0x2000000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], 0x02000000);*/
+       gp2x_memregl=(unsigned long  *)mmap(0, 0x10000,   PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], 0xc0000000);
+        gp2x_memregs=(unsigned short *)gp2x_memregl;
+
+  if(first) { printf(MINILIB_VERSION "\n");
+              gp2x_dualcore_registers(1); 
+              gp2x_sound_volume(100,100);
+              gp2x_memregs[0x0F16>>1] = 0x830a; usleep(100000);
+              gp2x_memregs[0x0F58>>1] = 0x100c; usleep(100000); }
+
+  ioctl(gp2x_dev[gp2x_physvram[7]=0], FBIOGET_FSCREENINFO, &fixed_info); 
+   gp2x_screen15=gp2x_logvram15[2]=gp2x_logvram15[0]=(unsigned short *)mmap(0, 320*240*2, PROT_WRITE, MAP_SHARED, gp2x_dev[0], 0);
+                                        gp2x_screen8=(unsigned char *)gp2x_screen15;
+                   gp2x_physvram[2]=gp2x_physvram[0]=fixed_info.smem_start;
+
+  ioctl(gp2x_dev[1], FBIOGET_FSCREENINFO, &fixed_info);
+                 gp2x_logvram15[3]=gp2x_logvram15[1]=(unsigned short *)mmap(0, 320*240*2, PROT_WRITE, MAP_SHARED, gp2x_dev[1], 0);
+                   gp2x_physvram[3]=gp2x_physvram[1]=fixed_info.smem_start;
+
+  gp2x_memregs[0x28DA>>1]=(((bpp+1)/8)<<9)|0xAB; /*8/15/16/24bpp...*/
+  gp2x_memregs[0x290C>>1]=320*((bpp+1)/8);       /*line width in bytes*/
+
+  memset(gp2x_screen15, 0, 320*240*2); gp2x_video_flip();
+  memset(gp2x_screen15, 0, 320*240*2); gp2x_video_flip();
+
+  if(bpp==8)  gp2x_physvram[2]+=320*240,    gp2x_physvram[3]+=320*240,
+             gp2x_logvram15[2]+=320*240/2, gp2x_logvram15[3]+=320*240/2; 
+
+
+ if ( gp2x_do_sound)
+ {
+   
+    ioctl(gp2x_dev[3], SNDCTL_DSP_SPEED,  &rate);
+    ioctl(gp2x_dev[3], SNDCTL_DSP_SETFMT, &bits);
+
+    ioctl(gp2x_dev[3], SNDCTL_DSP_CHANNELS, &channels);
+    ioctl(gp2x_dev[3], SNDCTL_DSP_STEREO, &stereoLocal);
+
+    frag = 0x40000|13;
+    ioctl(gp2x_dev[3], SNDCTL_DSP_SETFRAGMENT, &frag);
+  
+
+    printf("minimal() do sound, rate %d, bits %d, stereo %d, frag %d\n", rate, bits, stereo, frag);
+
+    if(first) 
+    {   
+      first=0; 
+    }
+  }  
+
+}
+
+
+extern int fcloseall(void);
+void gp2x_deinit(void)
+{
+  while((gp2x_sound++)<1000000);                               //wait arm920t threads to finish
+
+  gp2x_dualcore_registers(0);
+
+  gp2x_memregs[0x28DA>>1]=0x4AB;                               //set video mode
+  gp2x_memregs[0x290C>>1]=640;   
+  { int i; for(i=0;i<8;i++) if(gp2x_dev[i]) close(gp2x_dev[i]); }    //close all devices
+
+  fcloseall();                                                   //close all files
+
+}
+
+void SetVideoScaling(int pixels,int width,int height)
+{
+        float x, y;
+        float xscale,yscale;
+
+        int bpp=(gp2x_memregs[0x28DA>>1]>>9)&0x3;  /* bytes per pixel */
+
+        if(gp2x_memregs[0x2800>>1]&0x100) /* TV-Out ON? */
+        {
+                xscale=489.0; /* X-Scale with TV-Out (PAL or NTSC) */
+                if (gp2x_memregs[0x2818>>1]  == 287) /* PAL? */
+                        yscale=(pixels*274.0)/320.0; /* Y-Scale with PAL */
+                else if (gp2x_memregs[0x2818>>1]  == 239) /* NTSC? */
+                        yscale=(pixels*331.0)/320.0; /* Y-Scale with NTSC */
+        }
+        else /* TV-Out OFF? */ 
+        {
+                xscale=1024.0; /* X-Scale for LCD */
+                yscale=pixels; /* Y-Scale for LCD */
+        }
+
+        x=(xscale*width)/320.0;
+        y=(yscale*bpp*height)/240.0;
+        gp2x_memregs[0x2906>>1]=(unsigned short)x; /* scale horizontal */
+        gp2x_memregl[0x2908>>2]=(unsigned  long)y; /* scale vertical */
+        gp2x_memregs[0x290C>>1]=pixels*bpp; /* Set Video Width */
+}
diff --git a/drivers/cli/minimal.h b/drivers/cli/minimal.h
new file mode 100644 (file)
index 0000000..53127b9
--- /dev/null
@@ -0,0 +1,108 @@
+/*\r
+\r
+  GP2X minimal library v0.A by rlyeh, (c) 2005. emulnation.info@rlyeh (swap it!)\r
+\r
+  Thanks to Squidge, Robster, snaff, Reesy and NK, for the help & previous work! :-)\r
+\r
+  License\r
+  =======\r
+\r
+  Free for non-commercial projects (it would be nice receiving a mail from you).\r
+  Other cases, ask me first.\r
+\r
+  GamePark Holdings is not allowed to use this library and/or use parts from it.\r
+\r
+*/\r
+\r
+#include <fcntl.h>\r
+#include <linux/fb.h>\r
+#include <pthread.h>\r
+#include <signal.h>\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <sys/mman.h>\r
+//#include <sys/ioctl.h>\r
+#include <sys/soundcard.h>\r
+#include <linux/soundcard.h>\r
+\r
+#include <sys/time.h>\r
+#include <unistd.h>\r
+#include <sys/ioctl.h>\r
+\r
+#ifndef __MINIMAL_H__\r
+#define __MINIMAL_H__\r
+\r
+#define MINILIB_VERSION  "GP2X minimal library v0.A by rlyeh, (c) 2005."\r
+\r
+typedef struct gp2x_queue { volatile unsigned long head, tail, items, max_items; unsigned long *place920t, *place940t; } gp2x_queue;\r
+typedef struct gp2x_rect  { int x,y,w,h,solid; unsigned short *data15; unsigned char *data8; } gp2x_rect;\r
+\r
+extern void gp2x_timer_delay(unsigned long ticks);\r
+extern void gp2x_sound_pause(int yes);\r
+extern void gp2x_dualcore_pause(int yes);\r
+extern void             gp2x_blitter_rect15(gp2x_rect *r);\r
+extern void             gp2x_blitter_rect8(gp2x_rect *r);\r
+\r
+\r
+\r
+//extern void             gp2x_sound_frame (void *blah, void *bufferg, int samples);\r
+\r
+enum  { GP2X_UP=0x1,       GP2X_LEFT=0x4,       GP2X_DOWN=0x10,  GP2X_RIGHT=0x40,\r
+        GP2X_START=1<<8,   GP2X_SELECT=1<<9,    GP2X_L=1<<10,    GP2X_R=1<<11,\r
+        GP2X_A=1<<12,      GP2X_B=1<<13,        GP2X_X=1<<14,    GP2X_Y=1<<15,\r
+        GP2X_VOL_UP=1<<23, GP2X_VOL_DOWN=1<<22, GP2X_PUSH=1<<27                   };\r
+\r
+\r
+#define GP2X_QUEUE_MAX_ITEMS           16\r
+#define GP2X_QUEUE_ARRAY_PTR           ((0x1000-(sizeof(gp2x_queue)<<2)))\r
+#define GP2X_QUEUE_DATA_PTR            (GP2X_QUEUE_ARRAY_PTR-(GP2X_QUEUE_MAX_ITEMS<<2))\r
+\r
+#define gp2x_2ndcore_code(v)           (*(volatile unsigned long *)(v))\r
+#define gp2x_1stcore_code(v)           gp2x_dualcore_ram[(v)>>2]\r
+#define gp2x_2ndcore_data(v)           gp2x_2ndcore_code((v)+0x100000)\r
+#define gp2x_1stcore_data(v)           gp2x_1stcore_code((v)+0x100000)\r
+#define gp2x_dualcore_data(v)          gp2x_1stcore_data(v)\r
+\r
+#define gp2x_2ndcore_code_ptr(v)       ((volatile unsigned long *)(v))\r
+#define gp2x_1stcore_code_ptr(v)       (&gp2x_dualcore_ram[(v)>>2])\r
+#define gp2x_2ndcore_data_ptr(v)       gp2x_2ndcore_code_ptr((v)+0x100000)\r
+#define gp2x_1stcore_data_ptr(v)       gp2x_1stcore_code_ptr((v)+0x100000)\r
+                                            \r
+#define gp2x_video_wait_vsync()        while(gp2x_memregs[0x1182>>1]&(1<<4));\r
+#define gp2x_video_wait_hsync()        while(gp2x_memregs[0x1182>>1]&(1<<5));\r
+\r
+#define gp2x_video_color8(C,R,G,B)     do gp2x_palette[((C)<<1)+0]=((G)<<8)|(B),gp2x_palette[((C)<<1)+1]=(R); while(0)\r
+#define gp2x_video_color15(R,G,B,A)    ((((R)&0xF8)<<8)|(((G)&0xF8)<<3)|(((B)&0xF8)>>3)|((A)<<5))\r
+\r
+\r
+extern volatile unsigned short  gp2x_palette[512];\r
+extern          unsigned short *gp2x_screen15;\r
+extern          unsigned char  *gp2x_screen8;\r
+extern volatile unsigned long  *gp2x_dualcore_ram;\r
+\r
+extern void             gp2x_init(int tickspersecond, int bpp, int rate, int bits, int stereo, int hz);\r
+extern void             gp2x_deinit(void);\r
+\r
+extern void             gp2x_video_flip(void);\r
+extern void             gp2x_video_flip_single(void);\r
+extern void             gp2x_video_setpalette(void);\r
+\r
+extern unsigned long    gp2x_joystick_read(void);\r
+\r
+extern void             gp2x_sound_volume(int left, int right);\r
+\r
+extern unsigned long    gp2x_timer_read(void);\r
+extern unsigned long    gp2x_timer_read_ms(void);\r
+\r
+extern void             gp2x_dualcore_enable(int on);\r
+extern void             gp2x_dualcore_sync(void);\r
+extern void             gp2x_dualcore_exec(unsigned long command);\r
+extern void             gp2x_dualcore_launch_program(unsigned long *area, unsigned long size);\r
+extern void             gp2x_dualcore_launch_program_from_disk(const char *file, unsigned long offset, unsigned long size);\r
+\r
+#define gp2x_dualcore_declare_subprogram(name) extern void gp2x_dualcore_launch_## name ##_subprogram(void);\r
+#define gp2x_dualcore_launch_subprogram(name)  gp2x_dualcore_launch_## name ##_subprogram()\r
+\r
+#endif\r
+\r
diff --git a/drivers/cli/minimal_940t.h b/drivers/cli/minimal_940t.h
new file mode 100644 (file)
index 0000000..82cd1c0
--- /dev/null
@@ -0,0 +1,96 @@
+/*\r
+\r
+  GP2X minimal library v0.A by rlyeh, (c) 2005. emulnation.info@rlyeh (swap it!)\r
+\r
+  Thanks to Squidge, Robster, snaff, Reesy and NK, for the help & previous work! :-)\r
+\r
+  License\r
+  =======\r
+\r
+  Free for non-commercial projects (it would be nice receiving a mail from you).\r
+  Other cases, ask me first.\r
+\r
+  GamePark Holdings is not allowed to use this library and/or use parts from it.\r
+\r
+*/\r
+\r
+#include "minimal.h"\r
+\r
+#ifndef __MINIMAL_H_STUB_940T__\r
+#define __MINIMAL_H_STUB_940T__\r
+\r
+#undef    gp2x_dualcore_data\r
+#define   gp2x_dualcore_data(v)         gp2x_2ndcore_data(v)\r
+\r
+#define   main                          gp2x_2ndcore_run\r
+\r
+static void gp2x_2ndcore_start(void) __attribute__((naked));\r
+\r
+static void gp2x_2ndcore_start(void)\r
+{\r
+  unsigned long gp2x_dequeue(gp2x_queue *q)\r
+  {\r
+   unsigned long data;\r
+\r
+   while(!q->items); //waiting for head to increase...\r
+\r
+   data=q->place940t[q->tail = (q->tail < q->max_items ? q->tail+1 : 0)];\r
+   q->items--;\r
+\r
+   return data;\r
+  }\r
+\r
+#define gp2x_dualcore_name_subprogram(name) \\r
+/* 00000020 <_start>:                                                                             */ \\r
+/*    0:*/   asm volatile (".word 0xe59ff02c");  /*        ldr     pc, [pc, #44]  ; 34 <ioffset>  */ \\r
+/*    4:*/   asm volatile (".word 0xe59ff028");  /*        ldr     pc, [pc, #40]  ; 34 <ioffset>  */ \\r
+/*    8:*/   asm volatile (".word 0xe59ff024");  /*        ldr     pc, [pc, #36]  ; 34 <ioffset>  */ \\r
+/*    c:*/   asm volatile (".word 0xe59ff020");  /*        ldr     pc, [pc, #32]  ; 34 <ioffset>  */ \\r
+/*   10:*/   asm volatile (".word 0xe59ff01c");  /*        ldr     pc, [pc, #28]  ; 34 <ioffset>  */ \\r
+/*   14:*/   asm volatile (".word 0xe59ff018");  /*        ldr     pc, [pc, #24]  ; 34 <ioffset>  */ \\r
+/*   18:*/   asm volatile (".word 0xe59ff014");  /*        ldr     pc, [pc, #20]  ; 34 <ioffset>  */ \\r
+/*   1c:*/   asm volatile (".word 0xe59ff010");  /*        ldr     pc, [pc, #16]  ; 34 <ioffset>  */ \\r
+/* 00000020 <_init>:                                                                              */ \\r
+/*   20:*/   asm volatile (".word 0xe59fd010");  /*        ldr     sp, [pc, #16]   ; 38 <stack>         */ \\r
+/*   24:*/   asm volatile (".word 0xe59fc010");  /*        ldr     ip, [pc, #16]   ; 3c <deadbeef>      */ \\r
+/*   28:*/   asm volatile (".word 0xe59fb010");  /*        ldr     fp, [pc, #16]   ; 40 <leetface>      */ \\r
+/*   2c:*/   asm volatile (".word 0xe92d1800");  /*        stmdb   sp!, {fp, ip}                        */ \\r
+/*   30:*/   asm volatile (".word 0xea000004");  /*        b       48 <realinit>                        */ \\r
+/* 00000034 <ioffset>:                                                                                  */ \\r
+/*   34:*/   asm volatile (".word 0x00000020");  /*                                                     */ \\r
+/* 00000038 <stack>:                                                                                    */ \\r
+/*   38:*/   asm volatile (".word 0x000ffffc");  /*                                                     */ \\r
+/* 0000003c <deadbeef>:                                                                                 */ \\r
+/*   3c:*/   asm volatile (".word 0xdeadbeef");  /*                                                     */ \\r
+/* 00000040 <leetface>:                                                                                 */ \\r
+/*   40:*/   asm volatile (".word 0x1ee7face");  /*                                                     */ \\r
+/* 00000044 <area1>:                                                                                    */ \\r
+/*   44:*/   asm volatile (".word 0x00100019");  /*                                                     */ \\r
+/* 00000048 <realinit>:                                                                                 */ \\r
+/*  our main code starts here... */ \\r
+/*  48:*/   asm volatile (".word 0xe3a0003f"); /*        mov     r0, #63 ; 0x3f */ \\r
+/*  4c:*/   asm volatile (".word 0xee060f10"); /*        mcr     15, 0, r0, cr6, cr0, {0} */ \\r
+/*  50:*/   asm volatile (".word 0xee060f30"); /*        mcr     15, 0, r0, cr6, cr0, {1} */ \\r
+/*  54:*/   asm volatile (".word 0xe51f0018"); /*        ldr     r0, [pc, #-24]  ; 44 <area1> */ \\r
+/*  58:*/   asm volatile (".word 0xee060f11"); /*        mcr     15, 0, r0, cr6, cr1, {0} */ \\r
+/*  5c:*/   asm volatile (".word 0xee060f31"); /*        mcr     15, 0, r0, cr6, cr1, {1} */ \\r
+/*  60:*/   asm volatile (".word 0xe3a00001"); /*        mov     r0, #1  ; 0x1            */ \\r
+/*  64:*/   asm volatile (".word 0xee020f10"); /*        mcr     15, 0, r0, cr2, cr0, {0} */ \\r
+/*  68:*/   asm volatile (".word 0xee020f30"); /*        mcr     15, 0, r0, cr2, cr0, {1} */ \\r
+/*  6c:*/   asm volatile (".word 0xee030f10"); /*        mcr     15, 0, r0, cr3, cr0, {0} */ \\r
+/*  70:*/   asm volatile (".word 0xe3a0000f"); /*        mov     r0, #15 ; 0xf            */ \\r
+/*  74:*/   asm volatile (".word 0xee050f10"); /*        mcr     15, 0, r0, cr5, cr0, {0} */ \\r
+/*  78:*/   asm volatile (".word 0xee050f30"); /*        mcr     15, 0, r0, cr5, cr0, {1} */ \\r
+/*  7c:*/   asm volatile (".word 0xee110f10"); /*        mrc     15, 0, r0, cr1, cr0, {0} */ \\r
+/*  80:*/   asm volatile (".word 0xe3800001"); /*        orr     r0, r0, #1      ; 0x1    */ \\r
+/*  84:*/   asm volatile (".word 0xe3800004"); /*        orr     r0, r0, #4      ; 0x4    */ \\r
+/*  88:*/   asm volatile (".word 0xe3800a01"); /*        orr     r0, r0, #4096   ; 0x1000 */ \\r
+/*  8c:*/   asm volatile (".word 0xe3800103"); /*        orr     r0, r0, #-1073741824    ; 0xc0000000 */ \\r
+/*  90:*/   asm volatile (".word 0xee010f10"); /*        mcr     15, 0, r0, cr1, cr0, {0} */ \\r
+   while(1) gp2x_2ndcore_run(gp2x_dequeue((gp2x_queue *)gp2x_2ndcore_data_ptr(GP2X_QUEUE_ARRAY_PTR))); \\r
+} \\r
+void gp2x_dualcore_launch_##name##_subprogram(void) { gp2x_dualcore_launch_program((unsigned long *)&gp2x_2ndcore_start, ((int)&gp2x_dualcore_launch_##name##_subprogram)-((int)&gp2x_2ndcore_start)); }\r
+\r
+#endif\r
+\r
+\r
diff --git a/drivers/win/cheat.c b/drivers/win/cheat.c
deleted file mode 100644 (file)
index 3b53c2f..0000000
+++ /dev/null
@@ -1,471 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-#include "common.h"\r
-\r
-#include "cheat.h"\r
-\r
-static int selcheat;\r
-static int scheatmethod=0;\r
-static uint8 cheatval1=0;\r
-static uint8 cheatval2=0;\r
-\r
-static void ConfigAddCheat(HWND wnd);\r
-\r
-\r
-static uint16 StrToU16(char *s)\r
-{\r
- unsigned int ret=0;\r
- sscanf(s,"%4x",&ret);\r
- return ret;\r
-}\r
-\r
-static uint8 StrToU8(char *s)\r
-{\r
- unsigned int ret=0;\r
- sscanf(s,"%d",&ret);\r
- return ret;\r
-}\r
-\r
-\r
-/* Need to be careful where these functions are used. */\r
-static char *U16ToStr(uint16 a)\r
-{\r
- static char TempArray[16];\r
- sprintf(TempArray,"%04X",a);\r
- return TempArray;\r
-}\r
-\r
-static char *U8ToStr(uint8 a)\r
-{\r
- static char TempArray[16];\r
- sprintf(TempArray,"%03d",a);\r
- return TempArray;\r
-}\r
-\r
-\r
-static HWND RedoCheatsWND;\r
-static int RedoCheatsCallB(char *name, uint32 a, uint8 v, int s)\r
-{\r
- SendDlgItemMessage(RedoCheatsWND,101,LB_ADDSTRING,0,(LPARAM)(LPSTR)name);\r
- return(1);\r
-}\r
-\r
-static void RedoCheatsLB(HWND hwndDlg)\r
-{\r
- SendDlgItemMessage(hwndDlg,101,LB_RESETCONTENT,0,0);\r
- RedoCheatsWND=hwndDlg;\r
- FCEUI_ListCheats(RedoCheatsCallB);\r
-}\r
-\r
-\r
-BOOL CALLBACK CheatsConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  switch(uMsg)\r
-  {\r
-   case WM_INITDIALOG:                  \r
-                RedoCheatsLB(hwndDlg);\r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                switch(HIWORD(wParam))\r
-                {\r
-                 case BN_CLICKED:\r
-                        if(selcheat>=0)\r
-                        {\r
-                         if(LOWORD(wParam)==107)\r
-                          FCEUI_SetCheat(selcheat,0,-1,-1,1);\r
-                         else if(LOWORD(wParam)==108)\r
-                          FCEUI_SetCheat(selcheat,0,-1,-1,0);\r
-                        }\r
-                        break;\r
-                 case EN_KILLFOCUS:\r
-                        if(selcheat>=0)\r
-                        {\r
-                         char TempArray[256];\r
-                         int32 t;\r
-\r
-                         GetDlgItemText(hwndDlg,LOWORD(wParam),TempArray,256);\r
-                         switch(LOWORD(wParam))\r
-                         {\r
-                          case 102:FCEUI_SetCheat(selcheat,TempArray,-1,-1,-1);\r
-                                   SendDlgItemMessage(hwndDlg,101,LB_INSERTSTRING,selcheat,(LPARAM)(LPCTSTR)TempArray);\r
-                                   SendDlgItemMessage(hwndDlg,101,LB_DELETESTRING,selcheat+1,0);\r
-                                   SendDlgItemMessage(hwndDlg,101,LB_SETCURSEL,selcheat,0);\r
-                                   break;\r
-                          case 103:t=StrToU16(TempArray);\r
-                                   FCEUI_SetCheat(selcheat,0,t,-1,-1);\r
-                                   break;\r
-                          case 104:t=StrToU8(TempArray);\r
-                                   FCEUI_SetCheat(selcheat,0,-1,t,-1);\r
-                                   break;\r
-                         }\r
-                        }\r
-                        break;\r
-                }\r
-\r
-                switch(LOWORD(wParam))\r
-                {\r
-                 case 101:\r
-                        if(HIWORD(wParam)==LBN_SELCHANGE)\r
-                        {\r
-                         char *s;\r
-                         uint32 a;\r
-                         uint8 b;\r
-                        int status;\r
-\r
-                         selcheat=SendDlgItemMessage(hwndDlg,101,LB_GETCURSEL,0,(LPARAM)(LPSTR)0);\r
-                         if(selcheat<0) break;\r
-\r
-                         FCEUI_GetCheat(selcheat,&s,&a,&b,&status);\r
-                         SetDlgItemText(hwndDlg,102,(LPTSTR)s);\r
-                         SetDlgItemText(hwndDlg,103,(LPTSTR)U16ToStr(a));\r
-                         SetDlgItemText(hwndDlg,104,(LPTSTR)U8ToStr(b));\r
-\r
-                         CheckRadioButton(hwndDlg,107,108,status?107:108);\r
-                        }\r
-                        break;\r
-                }\r
-\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 106:\r
-                          if(selcheat>=0)\r
-                          {\r
-                           FCEUI_DelCheat(selcheat);\r
-                           SendDlgItemMessage(hwndDlg,101,LB_DELETESTRING,selcheat,0);\r
-                           selcheat=-1;\r
-                           SetDlgItemText(hwndDlg,102,(LPTSTR)"");\r
-                           SetDlgItemText(hwndDlg,103,(LPTSTR)"");\r
-                           SetDlgItemText(hwndDlg,104,(LPTSTR)"");\r
-                           CheckRadioButton(hwndDlg,107,108,0); // Is this correct?\r
-                          }\r
-                          break;\r
-                 case 105:\r
-                          ConfigAddCheat(hwndDlg);\r
-                          RedoCheatsLB(hwndDlg);\r
-                          break;\r
-                 case 1:\r
-                        gornk:\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-                }\r
-              }\r
-  return 0;\r
-}\r
-\r
-\r
-void ConfigCheats(HWND hParent)\r
-{\r
- if(!GI)\r
- {\r
-  FCEUD_PrintError("You must have a game loaded before you can manipulate cheats.");\r
-  return;\r
- }\r
-\r
- if(GI->type==GIT_NSF)\r
- {\r
-  FCEUD_PrintError("Sorry, you can't cheat with NSFs.");\r
-  return;\r
- }\r
-\r
- selcheat=-1;\r
- DialogBox(fceu_hInstance,"CHEATS",hParent,CheatsConCallB);\r
-}\r
-\r
-\r
-\r
-\r
-\r
-\r
-HWND cfcallbw;\r
-\r
-int cfcallb(uint32 a, uint8 last, uint8 current)\r
-{\r
- char temp[16];\r
-\r
- sprintf(temp,"%04X:%03d:%03d",(unsigned int)a,last,current);\r
- SendDlgItemMessage(cfcallbw,108,LB_ADDSTRING,0,(LPARAM)(LPSTR)temp);\r
- return(1);\r
-}\r
-\r
-static int scrollindex;\r
-static int scrollnum;\r
-static int scrollmax;\r
-\r
-int cfcallbinsert(uint32 a, uint8 last, uint8 current)\r
-{\r
- char temp[16];\r
-\r
- sprintf(temp,"%04X:%03d:%03d",(unsigned int)a,last,current);\r
- SendDlgItemMessage(cfcallbw,108,LB_INSERTSTRING,13,(LPARAM)(LPSTR)temp);\r
- return(1);\r
-}\r
-\r
-int cfcallbinsertt(uint32 a, uint8 last, uint8 current)\r
-{\r
- char temp[16];\r
-\r
- sprintf(temp,"%04X:%03d:%03d",(unsigned int)a,last,current);\r
- SendDlgItemMessage(cfcallbw,108,LB_INSERTSTRING,0,(LPARAM)(LPSTR)temp);\r
- return(1);\r
-}\r
-\r
-\r
-void AddTheThing(HWND hwndDlg, char *s, int a, int v)\r
-{\r
- if(FCEUI_AddCheat(s,a,v))\r
-  MessageBox(hwndDlg,"Cheat Added","Cheat Added",MB_OK);\r
-}\r
-\r
-\r
-static void DoGet(void)\r
-{\r
- int n=FCEUI_CheatSearchGetCount();\r
- int t;\r
- scrollnum=n;\r
- scrollindex=-32768;\r
-\r
- SendDlgItemMessage(cfcallbw,108,LB_RESETCONTENT,0,0);\r
- FCEUI_CheatSearchGetRange(0,13,cfcallb);\r
-\r
- t=-32768+n-1-13;\r
- if(t<-32768)\r
-  t=-32768;\r
- scrollmax=t;\r
- SendDlgItemMessage(cfcallbw,120,SBM_SETRANGE,-32768,t);\r
- SendDlgItemMessage(cfcallbw,120,SBM_SETPOS,-32768,1);\r
-}\r
-\r
-\r
-BOOL CALLBACK AddCheatCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  static int lbfocus;\r
-  static HWND hwndLB;\r
-  cfcallbw=hwndDlg;\r
-\r
-\r
-  switch(uMsg)\r
-  {                                                                               \r
-   case WM_VSCROLL:\r
-                if(scrollnum>13)\r
-                {\r
-                 switch((int)LOWORD(wParam))\r
-                 {\r
-                  case SB_TOP:\r
-                        scrollindex=-32768;\r
-                        SendDlgItemMessage(hwndDlg,120,SBM_SETPOS,scrollindex,1);\r
-                        SendDlgItemMessage(hwndDlg,108,LB_RESETCONTENT,13,0);\r
-                        FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+13,cfcallb);\r
-                        break;\r
-                  case SB_BOTTOM:\r
-                        scrollindex=scrollmax;\r
-                        SendDlgItemMessage(hwndDlg,120,SBM_SETPOS,scrollindex,1);\r
-                        SendDlgItemMessage(hwndDlg,108,LB_RESETCONTENT,13,0);\r
-                        FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+13,cfcallb);\r
-                        break;\r
-                  case SB_LINEUP:\r
-                        if(scrollindex>-32768)\r
-                        {\r
-                         scrollindex--;\r
-                         SendDlgItemMessage(hwndDlg,120,SBM_SETPOS,scrollindex,1);\r
-                         SendDlgItemMessage(hwndDlg,108,LB_DELETESTRING,13,0);\r
-                         FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768,cfcallbinsertt);\r
-                        }\r
-                        break;\r
-\r
-                  case SB_PAGEUP:\r
-                        scrollindex-=14;\r
-                        if(scrollindex<-32768) scrollindex=-32768;\r
-                        SendDlgItemMessage(hwndDlg,120,SBM_SETPOS,scrollindex,1);\r
-                        SendDlgItemMessage(hwndDlg,108,LB_RESETCONTENT,13,0);\r
-                        FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+13,cfcallb);\r
-                        break;\r
-\r
-                  case SB_LINEDOWN:\r
-                        if(scrollindex<scrollmax)\r
-                        {\r
-                         scrollindex++;\r
-                         SendDlgItemMessage(hwndDlg,120,SBM_SETPOS,scrollindex,1);\r
-                         SendDlgItemMessage(hwndDlg,108,LB_DELETESTRING,0,0);\r
-                         FCEUI_CheatSearchGetRange(scrollindex+32768+13,scrollindex+32768+13,cfcallbinsert);\r
-                        }\r
-                        break;\r
-\r
-                  case SB_PAGEDOWN:\r
-                        scrollindex+=14;\r
-                        if(scrollindex>scrollmax)\r
-                         scrollindex=scrollmax;\r
-                        SendDlgItemMessage(hwndDlg,120,SBM_SETPOS,scrollindex,1);\r
-                        SendDlgItemMessage(hwndDlg,108,LB_RESETCONTENT,0,0);\r
-                        FCEUI_CheatSearchGetRange(scrollindex+32768,scrollindex+32768+13,cfcallb);\r
-                        break;\r
-\r
-                  case SB_THUMBPOSITION:\r
-                  case SB_THUMBTRACK:\r
-                        scrollindex=(short int)HIWORD(wParam);\r
-                        SendDlgItemMessage(hwndDlg,120,SBM_SETPOS,scrollindex,1);\r
-                        SendDlgItemMessage(hwndDlg,108,LB_RESETCONTENT,0,0);\r
-                        FCEUI_CheatSearchGetRange(32768+scrollindex,32768+scrollindex+13,cfcallb);\r
-                        break;\r
-                 }\r
-\r
-                }                \r
-                break;\r
-\r
-   case WM_INITDIALOG:\r
-                SetDlgItemText(hwndDlg,110,(LPTSTR)U8ToStr(cheatval1));\r
-                SetDlgItemText(hwndDlg,111,(LPTSTR)U8ToStr(cheatval2));\r
-                DoGet();\r
-                CheckRadioButton(hwndDlg,115,118,scheatmethod+115);\r
-                lbfocus=0;\r
-                hwndLB=0;\r
-                break;\r
-\r
-   case WM_VKEYTOITEM:\r
-                if(lbfocus)\r
-                {\r
-                 int real;\r
-\r
-                 real=SendDlgItemMessage(hwndDlg,108,LB_GETCURSEL,0,(LPARAM)(LPSTR)0);\r
-                 switch((int)LOWORD(wParam))\r
-                 {\r
-                  case VK_UP: \r
-                              /* mmmm....recursive goodness */\r
-                              if(!real)\r
-                               SendMessage(hwndDlg,WM_VSCROLL,SB_LINEUP,0);\r
-                              return(-1);\r
-                              break;\r
-                  case VK_DOWN:\r
-                              if(real==13)\r
-                               SendMessage(hwndDlg,WM_VSCROLL,SB_LINEDOWN,0);\r
-                              return(-1);\r
-                              break;\r
-                  case VK_PRIOR:\r
-                              SendMessage(hwndDlg,WM_VSCROLL,SB_PAGEUP,0);\r
-                              break;\r
-                  case VK_NEXT:\r
-                              SendMessage(hwndDlg,WM_VSCROLL,SB_PAGEDOWN,0);\r
-                              break;\r
-                  case VK_HOME:\r
-                              SendMessage(hwndDlg,WM_VSCROLL,SB_TOP,0);\r
-                              break;\r
-                  case VK_END:\r
-                              SendMessage(hwndDlg,WM_VSCROLL,SB_BOTTOM,0);\r
-                              break;\r
-                 }\r
-                 return(-2);\r
-                }\r
-                break;\r
-\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                switch(LOWORD(wParam))\r
-                {\r
-                 case 108:\r
-                        switch(HIWORD(wParam))\r
-                        {\r
-                         case LBN_SELCHANGE:\r
-                                 {\r
-                                  char TempArray[32];\r
-                                  SendDlgItemMessage(hwndDlg,108,LB_GETTEXT,SendDlgItemMessage(hwndDlg,108,LB_GETCURSEL,0,(LPARAM)(LPSTR)0),(LPARAM)(LPCTSTR)TempArray);\r
-                                  TempArray[4]=0;\r
-                                  SetDlgItemText(hwndDlg,201,(LPTSTR)TempArray);                                 \r
-                                 }\r
-                                 break;\r
-                         case LBN_SETFOCUS:\r
-                                 lbfocus=1;\r
-                                 break;\r
-                         case LBN_KILLFOCUS:\r
-                                 lbfocus=0;\r
-                                 break;\r
-                        }\r
-                        break;\r
-                }\r
-\r
-                switch(HIWORD(wParam))\r
-                {\r
-                 case BN_CLICKED:\r
-                        if(LOWORD(wParam)>=115 && LOWORD(wParam)<=118)\r
-                         scheatmethod=LOWORD(wParam)-115;\r
-                        break;\r
-                 case EN_CHANGE:\r
-                        {\r
-                         char TempArray[256];\r
-                         GetDlgItemText(hwndDlg,LOWORD(wParam),TempArray,256);\r
-                         switch(LOWORD(wParam))\r
-                         {\r
-                          case 110:cheatval1=StrToU8(TempArray);break;\r
-                          case 111:cheatval2=StrToU8(TempArray);break;\r
-                         }\r
-                        }\r
-                        break;\r
-                }\r
-\r
-\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 112:\r
-                          FCEUI_CheatSearchBegin();\r
-                          DoGet();\r
-                          break;\r
-                 case 113:\r
-                          FCEUI_CheatSearchEnd(scheatmethod,cheatval1,cheatval2);\r
-                          DoGet();\r
-                          break;\r
-                 case 114:\r
-                          FCEUI_CheatSearchSetCurrentAsOriginal();\r
-                          DoGet();\r
-                          break;\r
-                 case 107:\r
-                          FCEUI_CheatSearchShowExcluded();\r
-                          DoGet();\r
-                          break;\r
-                 case 105:\r
-                          {\r
-                           int a,v;\r
-                           char temp[256];\r
-\r
-                           GetDlgItemText(hwndDlg,201,temp,4+1);\r
-                           a=StrToU16(temp);\r
-                           GetDlgItemText(hwndDlg,202,temp,3+1);\r
-                           v=StrToU8(temp);\r
-\r
-                           GetDlgItemText(hwndDlg,200,temp,256);\r
-                           AddTheThing(hwndDlg,temp,a,v);\r
-                          }\r
-                          break;\r
-                 case 106:\r
-                        gornk:\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-                }\r
-              }\r
-  return 0;\r
-}\r
-\r
-static void ConfigAddCheat(HWND wnd)\r
-{\r
- DialogBox(fceu_hInstance,"ADDCHEAT",wnd,AddCheatCallB);\r
-}\r
diff --git a/drivers/win/cheat.h b/drivers/win/cheat.h
deleted file mode 100644 (file)
index b3cd3cc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-void ConfigCheats(HWND hParent);\r
diff --git a/drivers/win/common.h b/drivers/win/common.h
deleted file mode 100644 (file)
index 91b8d3d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdio.h>\r
-#include <windows.h>\r
-#include <windowsx.h>\r
-\r
-#ifndef WIN32\r
-#define WIN32\r
-#endif\r
-#undef  WINNT\r
-#define NONAMELESSUNION\r
-\r
-#define DIRECTSOUND_VERSION  0x0700\r
-#define DIRECTDRAW_VERSION 0x0700\r
-#define DIRECTINPUT_VERSION     0x700\r
-#include "../../driver.h"\r
-\r
-extern HWND hAppWnd;\r
-extern HINSTANCE fceu_hInstance;\r
-\r
-extern int NoWaiting;\r
-extern FCEUGI *GI;\r
diff --git a/drivers/win/config.c b/drivers/win/config.c
deleted file mode 100644 (file)
index 761a7a9..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/****************************************************************/
-/*                     FCE Ultra                               */
-/*                                                             */
-/*     This file contains code to interface to the standard    */
-/*     FCE Ultra configuration file saving/loading code.       */
-/*                                                             */
-/****************************************************************/
-#include "../common/config.h"
-
-static CFGSTRUCT fceuconfig[]={
-
-        ACS(rfiles[0]),
-        ACS(rfiles[1]),
-        ACS(rfiles[2]),
-        ACS(rfiles[3]),
-        ACS(rfiles[4]),
-        ACS(rfiles[5]),
-        ACS(rfiles[6]),
-        ACS(rfiles[7]),
-        ACS(rfiles[8]),
-        ACS(rfiles[9]),
-
-        AC(ntsccol),AC(ntsctint),AC(ntschue),
-
-        AC(soundsleep),
-        NAC("palyo",palyo),
-       NAC("genie",genie),
-       NAC("fs",fullscreen),
-       NAC("vgamode",vmod),
-       NAC("sound",soundo),
-
-        ACS(gfsdir),
-
-        NACS("odcheats",DOvers[0]),
-        NACS("odmisc",DOvers[1]),
-        NACS("odnonvol",DOvers[2]),
-        NACS("odstates",DOvers[3]),
-        NACS("odsnaps",DOvers[4]),
-        NACS("odbase",DOvers[5]),
-
-       NAC("winsizemul",winsizemul),
-
-       AC(soundrate),
-        AC(soundbuftime),
-       AC(soundoptions),
-        AC(soundvolume),
-
-       NAC("eoptions",eoptions),
-        NACA("cpalette",cpalette),
-
-        ACA(joy),
-       ACA(joyA),ACA(joyB),ACA(joySelect),ACA(joyStart),
-
-        AC(joyOptions),
-        ACA(joyUp),ACA(joyDown),ACA(joyLeft),ACA(joyRight),
-
-        NACA("InputType",UsrInputType),
-       NAC("keyben",keybEnable),
-
-       NACA("keybm0",keyBMap[0]),
-       NACA("keybm1",keyBMap[1]),
-       NACA("keybm2",keyBMap[2]),
-       NACA("keybm3",keyBMap[3]),
-       NACA("ppasc0",powerpadsc[0]),
-       NACA("ppasc1",powerpadsc[1]),
-
-       NAC("ppaside",powerpadside),
-       NAC("vmcx",vmodes[0].x),
-       NAC("vmcy",vmodes[0].y),
-       NAC("vmcb",vmodes[0].bpp),
-       NAC("vmcf",vmodes[0].flags),
-       NAC("vmcxs",vmodes[0].xscale),
-       NAC("vmcys",vmodes[0].yscale),
-
-        NAC("srendline",srendlinen),
-        NAC("erendline",erendlinen),
-        NAC("srendlinep",srendlinep),
-        NAC("erendlinep",erendlinep),
-
-        AC(UsrInputTypeFC),
-       AC(winsync),
-        AC(fssync),
-        AC(NoFourScore),
-        ACA(fkbmap),
-        ENDCFGSTRUCT
-};
-
-static void SaveConfig(char *filename)
-{
-        DriverInterface(DES_GETNTSCTINT,&ntsctint);
-        DriverInterface(DES_GETNTSCHUE,&ntschue);
-        SaveFCEUConfig(filename,fceuconfig);
-}
-
-static void LoadConfig(char *filename)
-{
-        DriverInterface(DES_GETNTSCTINT,&ntsctint);
-        DriverInterface(DES_GETNTSCHUE,&ntschue);
-        LoadFCEUConfig(filename,fceuconfig);
-       DriverInterface(DES_NTSCCOL,&ntsccol);
-        DriverInterface(DES_SETNTSCTINT,&ntsctint);
-        DriverInterface(DES_SETNTSCHUE,&ntschue);
-
-       palyo&=1;
-       FCEUI_SetVidSystem(palyo);
-       genie&=1;
-       FCEUI_SetGameGenie(genie);
-       fullscreen&=1;
-        soundo&=1;
-        FCEUI_SetSoundVolume(soundvolume);
-}
-
diff --git a/drivers/win/input.c b/drivers/win/input.c
deleted file mode 100644 (file)
index aea3f47..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-#include "common.h"\r
-#include <dinput.h>\r
-\r
-#include "input.h"\r
-#include "keyboard.h"\r
-#include "joystick.h"\r
-\r
-\r
-int UsrInputType[2]={SI_GAMEPAD,SI_GAMEPAD};\r
-int UsrInputTypeFC=SIFC_NONE;\r
-int InputType[2];\r
-int InputTypeFC;\r
-\r
-int NoFourScore=0;\r
-\r
-static uint32 powerpadbuf[2];\r
-\r
-LPDIRECTINPUT7 lpDI;\r
-\r
-void FixGIGO(void)\r
-{\r
- InputType[0]=UsrInputType[0];\r
- InputType[1]=UsrInputType[1];\r
- InputTypeFC=UsrInputTypeFC;\r
-\r
- if(GI)\r
- {\r
-  if(GI->input[0]>=0)\r
-   InputType[0]=GI->input[0];\r
-  if(GI->input[1]>=0)\r
-   InputType[1]=GI->input[1];\r
-  if(GI->inputfc>=0)\r
-   InputTypeFC=GI->inputfc;\r
-  CreateInputStuff();\r
- }\r
-}\r
-\r
-static uint32 JSreturn;\r
-static uint32 mousedata[3];\r
-\r
-\r
-static void ConfigGamePad(HWND hParent, int port);\r
-\r
-int InitDInput(void)\r
-{\r
- HRESULT ddrval;\r
-\r
- ddrval=DirectInputCreateEx(fceu_hInstance,DIRECTINPUT_VERSION,&IID_IDirectInput7,(LPVOID *)&lpDI,0);\r
- if(ddrval!=DI_OK)\r
- {\r
-  FCEUD_PrintError("DirectInput: Error creating DirectInput object.");\r
-  return 0;\r
- }\r
- return 1;\r
-}\r
-\r
-static int screenmode=0;\r
-void InputScreenChanged(int fs)\r
-{\r
- int x;\r
- for(x=0;x<2;x++)\r
-  if(InputType[x]==SI_ZAPPER)\r
-   FCEUI_SetInput(x,SI_ZAPPER,mousedata,fs);\r
- if(InputTypeFC==SIFC_SHADOW)\r
-  FCEUI_SetInputFC(SIFC_SHADOW,mousedata,fs);\r
- screenmode=fs;\r
-}\r
-\r
-void InitInputStuff(void)\r
-{\r
-   KeyboardInitialize();\r
-   InitJoysticks(hAppWnd);\r
-}\r
-\r
-void CreateInputStuff(void)\r
-{ \r
-   void *InputDPtr=0;\r
-   int x;\r
-   int TAttrib;\r
-\r
-   for(x=0;x<2;x++)\r
-   {\r
-    TAttrib=0;\r
-    switch(InputType[x])\r
-    {\r
-     case SI_GAMEPAD:InputDPtr=((uint8 *)&JSreturn)+(x<<1);\r
-                                break;\r
-     case SI_POWERPAD:InputDPtr=&powerpadbuf[x];break;\r
-     case SI_ARKANOID:InputDPtr=mousedata;break;\r
-     case SI_ZAPPER:InputDPtr=mousedata;\r
-                                TAttrib=screenmode;\r
-                                break;\r
-    }   \r
-    FCEUI_SetInput(x,InputType[x],InputDPtr,TAttrib);\r
-   }\r
-\r
-   TAttrib=0;\r
-   switch(InputTypeFC)\r
-   {\r
-    case SIFC_SHADOW:InputDPtr=mousedata;TAttrib=screenmode;break;\r
-    case SIFC_ARKANOID:InputDPtr=mousedata;break;    \r
-    case SIFC_FKB:InputDPtr=fkbkeys;memset(fkbkeys,0,sizeof(fkbkeys));break;\r
-   }\r
-   FCEUI_SetInputFC(InputTypeFC,InputDPtr,TAttrib);\r
-   FCEUI_DisableFourScore(NoFourScore);\r
-}\r
-\r
-void DestroyInput(void)\r
-{\r
-   KillJoysticks();\r
-   KeyboardClose();\r
-}\r
-\r
-void FCEUD_UpdateInput(void)\r
-{\r
-  int x;\r
-  uint32 JS;\r
-  int t=0;\r
-\r
-  KeyboardUpdate();\r
-\r
-  for(x=0;x<2;x++)\r
-   switch(InputType[x])\r
-   {\r
-    case SI_GAMEPAD:t|=1;break;\r
-    case SI_ARKANOID:t|=2;break;\r
-    case SI_ZAPPER:t|=2;break;\r
-    case SI_POWERPAD:powerpadbuf[x]=UpdatePPadData(x);break;\r
-   }\r
-  switch(InputTypeFC)\r
-  {\r
-   case SIFC_ARKANOID:t|=2;break;\r
-   case SIFC_SHADOW:t|=2;break;\r
-   case SIFC_FKB: if(cidisabled) UpdateFKB();break;\r
-  }\r
-  if(t&1)\r
-  {\r
-   JS=KeyboardDodo();\r
-   if(joy[0]|joy[1]|joy[2]|joy[3])\r
-    JS|=(uint32)GetJSOr();\r
-   JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8);   \r
-  }\r
-  if(t&2)  \r
-   GetMouseData(&mousedata[0], &mousedata[1], &mousedata[2]);\r
-}\r
-\r
-\r
-BOOL CALLBACK InputConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  static void (*boopar[5])(HWND hParent, int port)={0,ConfigGamePad,0,ConfigKeyboardiePowerpad,0};\r
-  static void (*boopar2[5])(HWND hParent)={0,0,0,0,ConfigFKB};\r
-  static char *strn[5]={"<none>","Gamepad","Zapper","Power Pad","Arkanoid Paddle"};\r
-  static char *strf[5]={"<none>","Arkanoid Paddle","Hyper Shot gun","4-Player Adapter","Family Keyboard"};\r
-  int x;\r
-  \r
-  switch(uMsg) {\r
-   case WM_INITDIALOG:                \r
-                for(x=0;x<2;x++)        \r
-                {\r
-                 int y;\r
-\r
-                 for(y=0;y<5;y++)\r
-                  SendDlgItemMessage(hwndDlg,104+x,CB_ADDSTRING,0,(LPARAM)(LPSTR)strn[y]);\r
-\r
-                 SendDlgItemMessage(hwndDlg,104+x,CB_SETCURSEL,UsrInputType[x],(LPARAM)(LPSTR)0);\r
-                 EnableWindow(GetDlgItem(hwndDlg,106+x),boopar[InputType[x]]?1:0);\r
-                 SetDlgItemText(hwndDlg,200+x,(LPTSTR)strn[InputType[x]]);\r
-                }\r
-\r
-\r
-                {\r
-                 int y;\r
-                 for(y=0;y<5;y++)\r
-                  SendDlgItemMessage(hwndDlg,110,CB_ADDSTRING,0,(LPARAM)(LPSTR)strf[y]);\r
-                 SendDlgItemMessage(hwndDlg,110,CB_SETCURSEL,UsrInputTypeFC,(LPARAM)(LPSTR)0);                \r
-                 EnableWindow(GetDlgItem(hwndDlg,111),boopar2[InputTypeFC]?1:0);\r
-                 SetDlgItemText(hwndDlg,202,(LPTSTR)strf[InputTypeFC]);\r
-                }\r
-                \r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(HIWORD(wParam)==CBN_SELENDOK)\r
-                {\r
-                 switch(LOWORD(wParam))\r
-                 {\r
-                  case 104:\r
-                  case 105:UsrInputType[LOWORD(wParam)-104]=InputType[LOWORD(wParam)-104]=SendDlgItemMessage(hwndDlg,LOWORD(wParam),CB_GETCURSEL,0,(LPARAM)(LPSTR)0);\r
-                           EnableWindow( GetDlgItem(hwndDlg,LOWORD(wParam)+2),boopar[InputType[LOWORD(wParam)-104]]?1:0);\r
-                           SetDlgItemText(hwndDlg,200+LOWORD(wParam)-104,(LPTSTR)strn[InputType[LOWORD(wParam)-104]]);\r
-                           break;\r
-                  case 110:UsrInputTypeFC=InputTypeFC=SendDlgItemMessage(hwndDlg,110,CB_GETCURSEL,0,(LPARAM)(LPSTR)0);\r
-                           EnableWindow(GetDlgItem(hwndDlg,111),boopar2[InputTypeFC]?1:0);\r
-                           SetDlgItemText(hwndDlg,202,(LPTSTR)strf[InputTypeFC]);\r
-                           break;\r
-                           \r
-                 }\r
-\r
-                }\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 111:\r
-                  if(boopar2[InputTypeFC])\r
-                   boopar2[InputTypeFC](hwndDlg);\r
-                  break;\r
-\r
-                 case 107:\r
-                 case 106:\r
-                  {\r
-                   int t=(wParam&0xFFFF)-106;\r
-                   if(boopar[InputType[t]])\r
-                    boopar[InputType[t]](hwndDlg,t);\r
-                  }\r
-                  break;\r
-                 case 1:\r
-                        gornk:\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-               }\r
-              }\r
-  return 0;\r
-}\r
-\r
-void ConfigInput(HWND hParent)\r
-{\r
-  DialogBox(fceu_hInstance,"INPUTCONFIG",hParent,InputConCallB);\r
-  CreateInputStuff();\r
-}\r
-\r
-\r
-static int porttemp;\r
-\r
-BOOL CALLBACK GPConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  switch(uMsg) {\r
-   case WM_INITDIALOG:                \r
-                if(NoFourScore)\r
-                 CheckDlgButton(hwndDlg,200,BST_CHECKED);\r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 107:ConfigJoystickies(hwndDlg, porttemp);break;\r
-                 case 106:ConfigKeyboardie(hwndDlg, porttemp);break;\r
-                 case 1:\r
-                        gornk:\r
-                        NoFourScore=0;\r
-                        if(IsDlgButtonChecked(hwndDlg,200)==BST_CHECKED)\r
-                         NoFourScore=1;\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-               }\r
-              }\r
-  return 0;\r
-}\r
-\r
-static void ConfigGamePad(HWND hParent, int port)\r
-{\r
-  porttemp=port;\r
-  DialogBox(fceu_hInstance,"GAMEPADCONFIG",hParent,GPConCallB);\r
-}\r
-\r
-\r
diff --git a/drivers/win/input.h b/drivers/win/input.h
deleted file mode 100644 (file)
index 559f1af..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-void ConfigInput(HWND hParent);\r
-int InitDInput(void);\r
-void CreateInputStuff(void);\r
-void InitInputStuff(void);\r
-void DestroyInput(void);\r
-void InputScreenChanged(int fs);\r
-void FixGIGO(void);\r
-\r
-extern LPDIRECTINPUT7 lpDI;\r
-\r
-#define JOY_A   1\r
-#define JOY_B   2\r
-#define JOY_SELECT      4\r
-#define JOY_START       8\r
-#define JOY_UP  0x10\r
-#define JOY_DOWN        0x20\r
-#define JOY_LEFT        0x40\r
-#define JOY_RIGHT       0x80\r
-\r
-\r
-extern int InputType[2];\r
-extern int InputTypeFC;\r
-extern int NoFourScore;\r
-extern int UsrInputType[2];\r
-extern int UsrInputTypeFC;\r
diff --git a/drivers/win/joystick.c b/drivers/win/joystick.c
deleted file mode 100644 (file)
index 375b7af..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-#include "common.h"\r
-#include <dinput.h>\r
-\r
-#include "input.h"\r
-#include "joystick.h"\r
-\r
-\r
-HRESULT  ddrval;\r
-\r
-static GUID joyGUID[64];\r
-\r
-static int joycounter;\r
-\r
-static LPDIRECTINPUTDEVICE7 lpJoy[4]={0,0,0,0};\r
-\r
-int joyOptions[4]={0,0,0,0};\r
-int joyA[4]={1,1,1,1};\r
-int joyB[4]={0,0,0,0};\r
-int joySelect[4]={2,2,2,2};\r
-int joyStart[4]={3,3,3,3};\r
-int joyUp[4]={4,4,4,4};\r
-int joyDown[4]={5,5,5,5};\r
-int joyLeft[4]={6,6,6,6};\r
-int joyRight[4]={7,7,7,7};\r
-\r
-int joy[4]={0,0,0,0};\r
-\r
-static int JoyXMax[4];\r
-static int JoyXMin[4];\r
-\r
-static int JoyYMax[4];\r
-static int JoyYMin[4];\r
-\r
-static DIJOYSTATE2 JoyStatus;\r
-\r
-static void ShowDIJErr(int w, char *s)\r
-{\r
- char tempo[128];\r
- sprintf(tempo,"DirectInput: Joystick %d: %s",w+1,s);\r
- FCEUD_PrintError(tempo);\r
-}\r
-\r
-static void JoyAutoRestore(HRESULT ddrval,LPDIRECTINPUTDEVICE7 lpJJoy)\r
-{\r
-   switch(ddrval)\r
-    {\r
-     case DIERR_INPUTLOST:\r
-     case DIERR_NOTACQUIRED:\r
-                           IDirectInputDevice7_Acquire(lpJJoy);\r
-                           break;\r
-    }\r
-}\r
-\r
-static int GetJoystickButton(int x)\r
-{\r
- int errc=0;\r
- int z;\r
-\r
- if(lpJoy[x])\r
- {\r
-   doagaino:\r
-   if(errc>8) return(-1);\r
-\r
-   ddrval=IDirectInputDevice7_Poll(lpJoy[x]);\r
-   if(ddrval!=DI_OK && ddrval!=DI_NOEFFECT) {JoyAutoRestore(ddrval,lpJoy[x]);errc++;goto doagaino;}\r
-\r
-   ddrval=IDirectInputDevice7_GetDeviceState(lpJoy[x],sizeof(JoyStatus),&JoyStatus);\r
-   if(ddrval!=DI_OK) {JoyAutoRestore(ddrval,lpJoy[x]);errc++;goto doagaino;}\r
-\r
-   for(z=0;z<128;z++)\r
-    if(JoyStatus.rgbButtons[z]&0x80)\r
-     return z;\r
- }\r
- return(-1);\r
-}\r
-\r
-uint32 GetJSOr(void)\r
-{\r
-        unsigned long ret;\r
-        int x;\r
-        ret=0;\r
-\r
-        for(x=0;x<4;x++)\r
-        {\r
-         if(lpJoy[x])\r
-         {\r
-\r
-          ddrval=IDirectInputDevice7_Poll(lpJoy[x]);\r
-          if(ddrval!=DI_OK && ddrval!=DI_NOEFFECT) JoyAutoRestore(ddrval,lpJoy[x]);\r
-\r
-          ddrval=IDirectInputDevice7_GetDeviceState(lpJoy[x],sizeof(JoyStatus),&JoyStatus);\r
-          if(ddrval!=DI_OK) JoyAutoRestore(ddrval,lpJoy[x]);\r
-\r
-          if(joyOptions[x]&1)\r
-          {\r
-           if(JoyStatus.rgbButtons[joyUp[x]&127]&0x80) ret|=JOY_UP<<(x<<3);\r
-           if(JoyStatus.rgbButtons[joyDown[x]&127]&0x80) ret|=JOY_DOWN<<(x<<3);\r
-           if(JoyStatus.rgbButtons[joyLeft[x]&127]&0x80) ret|=JOY_LEFT<<(x<<3);\r
-           if(JoyStatus.rgbButtons[joyRight[x]&127]&0x80) ret|=JOY_RIGHT<<(x<<3);\r
-          }\r
-          else\r
-          {\r
-           if(JoyStatus.lX>=JoyXMax[x])\r
-            ret|=JOY_RIGHT<<(x<<3);\r
-           else if(JoyStatus.lX<=JoyXMin[x])\r
-            ret|=JOY_LEFT<<(x<<3);\r
-\r
-           if(JoyStatus.lY>=JoyYMax[x])\r
-            ret|=JOY_DOWN<<(x<<3);\r
-           else if(JoyStatus.lY<=JoyYMin[x])\r
-            ret|=JOY_UP<<(x<<3);\r
-          }\r
-          if(JoyStatus.rgbButtons[joyA[x]&127]&0x80) ret|=1<<(x<<3);\r
-          if(JoyStatus.rgbButtons[joyB[x]&127]&0x80) ret|=2<<(x<<3);\r
-          if(JoyStatus.rgbButtons[joySelect[x]&127]&0x80) ret|=4<<(x<<3);\r
-          if(JoyStatus.rgbButtons[joyStart[x]&127]&0x80) ret|=8<<(x<<3);\r
-         }\r
-        }\r
-\r
-        return ret;\r
-}\r
-\r
-static void KillJoystick(int w)\r
-{\r
- if(lpJoy[w])\r
- {\r
-  IDirectInputDevice7_Unacquire(lpJoy[w]);\r
-  IDirectInputDevice7_Release(lpJoy[w]);\r
-  lpJoy[w]=0;\r
- }\r
-}\r
-\r
-void KillJoysticks(void)\r
-{\r
- int x;\r
- for(x=0;x<4;x++)\r
-  KillJoystick(x);\r
-}\r
-\r
-static BOOL CALLBACK JoystickFound(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)\r
-{\r
-   if(joycounter<64)\r
-   {\r
-    joyGUID[joycounter]=lpddi->guidInstance;\r
-    joycounter++;\r
-    if(pvRef)\r
-    {\r
-     SendDlgItemMessage(pvRef,106,CB_ADDSTRING,0,(LPARAM)(LPSTR)lpddi->tszProductName);\r
-     SendDlgItemMessage(pvRef,112,CB_ADDSTRING,0,(LPARAM)(LPSTR)lpddi->tszProductName);\r
-    }\r
-    return DIENUM_CONTINUE;\r
-   }\r
-   else\r
-    return 0;   \r
-}\r
-\r
-void InitJoystick(int w, HWND wnd)\r
-{\r
-  if(joy[w])\r
-  {\r
-   if(joy[w]>joycounter)\r
-   {\r
-    ShowDIJErr(w,"Not found."); \r
-    joy[w]=0;\r
-    return;\r
-   }\r
-   ddrval=IDirectInput7_CreateDeviceEx(lpDI,&joyGUID[joy[w]-1],&IID_IDirectInputDevice7,(LPVOID *)&lpJoy[w],0);\r
-   if(ddrval != DI_OK)\r
-   {   \r
-    ShowDIJErr(w,"Error creating device.");\r
-    joy[w]=0;\r
-    return;\r
-   }\r
-   ddrval=IDirectInputDevice7_SetCooperativeLevel(lpJoy[w],wnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE);\r
-   if (ddrval != DI_OK)\r
-   {\r
-    ShowDIJErr(w,"Error setting cooperative level.");\r
-    KillJoystick(w);\r
-    joy[w]=0;\r
-    return;\r
-   }\r
-   ddrval=IDirectInputDevice7_SetDataFormat(lpJoy[w],&c_dfDIJoystick2);\r
-   if (ddrval != DI_OK)\r
-   {\r
-    ShowDIJErr(w,"Error setting data format.");\r
-    KillJoystick(w);\r
-    joy[w]=0;\r
-    return;\r
-   }\r
-\r
-   {\r
-    DIPROPRANGE diprg;\r
-    int r;\r
-\r
-    memset(&diprg,0,sizeof(DIPROPRANGE));\r
-    diprg.diph.dwSize=sizeof(DIPROPRANGE);\r
-    diprg.diph.dwHeaderSize=sizeof(DIPROPHEADER);\r
-    diprg.diph.dwHow=DIPH_BYOFFSET;\r
-    diprg.diph.dwObj=DIJOFS_X;\r
-    ddrval=IDirectInputDevice7_GetProperty(lpJoy[w],DIPROP_RANGE,&diprg.diph);\r
-    if(ddrval!=DI_OK)\r
-    {\r
-     ShowDIJErr(w,"Error getting X axis range.");\r
-     joy[w]=0;\r
-     KillJoystick(w);\r
-     joy[w]=0;\r
-     return;\r
-    }\r
-    r=diprg.lMax-diprg.lMin;\r
-    JoyXMax[w]=diprg.lMax-(r>>2);\r
-    JoyXMin[w]=diprg.lMin+(r>>2);\r
-\r
-    memset(&diprg,0,sizeof(DIPROPRANGE));\r
-    diprg.diph.dwSize=sizeof(DIPROPRANGE);\r
-    diprg.diph.dwHeaderSize=sizeof(DIPROPHEADER);\r
-    diprg.diph.dwHow=DIPH_BYOFFSET;\r
-    diprg.diph.dwObj=DIJOFS_Y;\r
-    ddrval=IDirectInputDevice7_GetProperty(lpJoy[w],DIPROP_RANGE,&diprg.diph);\r
-    if(ddrval!=DI_OK)\r
-    {\r
-     ShowDIJErr(w,"Error getting X axis range.");\r
-     KillJoystick(w);\r
-     joy[w]=0;\r
-     return;\r
-    }\r
-    r=diprg.lMax-diprg.lMin;\r
-    JoyYMax[w]=diprg.lMax-(r>>2);\r
-    JoyYMin[w]=diprg.lMin+(r>>2);\r
-   }\r
-\r
-  }\r
-}\r
-\r
-void InitJoysticks(HWND wnd)\r
-{\r
- int x;\r
-\r
- joycounter=0;\r
- IDirectInput7_EnumDevices(lpDI, DIDEVTYPE_JOYSTICK,JoystickFound,0,DIEDFL_ATTACHEDONLY);\r
\r
- for(x=0;x<4;x++)\r
-  InitJoystick(x,wnd);\r
-}\r
-\r
-\r
-static int joyconport;\r
-\r
-static BOOL CALLBACK JoyConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  char tempo[64];\r
-  int x;\r
-  static int bid;\r
-\r
-  switch(uMsg) {\r
-   case WM_TIMER:\r
-                 if(bid>=200 && bid<=215)\r
-                 {\r
-                  int z;\r
-\r
-                  /* GetJoystickButton() makes sure there is a joystick,\r
-                     so we don't need to here.\r
-                  */                     \r
-                  if(bid<=207)\r
-                  {\r
-                   if( (z=GetJoystickButton(joyconport))!=-1)\r
-                     SetDlgItemInt(hwndDlg,bid,z,0);\r
-                   }\r
-                   else\r
-                   {\r
-                    if( (z=GetJoystickButton(2+joyconport))!=-1)\r
-                     SetDlgItemInt(hwndDlg,bid,z,0);\r
-                   }\r
-                 }\r
-                break;\r
-   case WM_INITDIALOG:\r
-                bid=0;\r
-                SetTimer(hwndDlg,666,20,0);     /* Every 20ms(50x a second).*/\r
-\r
-                InitJoysticks(hwndDlg);\r
-\r
-                SendDlgItemMessage(hwndDlg,106,CB_ADDSTRING,0,(LPARAM)(LPSTR)"<none>");\r
-                SendDlgItemMessage(hwndDlg,112,CB_ADDSTRING,0,(LPARAM)(LPSTR)"<none>");\r
-\r
-                sprintf(tempo,"Virtual Gamepad %d",joyconport+1);\r
-                SetDlgItemText(hwndDlg,102,tempo);\r
-                sprintf(tempo,"Virtual Gamepad %d",joyconport+3);\r
-                SetDlgItemText(hwndDlg,104,tempo);\r
-\r
-                for(x=0;x<=2;x+=2)\r
-                {\r
-                 SetDlgItemInt(hwndDlg,200+(x<<2),joySelect[x+joyconport],0);\r
-                 SetDlgItemInt(hwndDlg,201+(x<<2),joyStart[x+joyconport],0);\r
-                 SetDlgItemInt(hwndDlg,202+(x<<2),joyB[x+joyconport],0);\r
-                 SetDlgItemInt(hwndDlg,203+(x<<2),joyA[x+joyconport],0);\r
-\r
-                 SetDlgItemInt(hwndDlg,204+(x<<2),joyUp[x+joyconport],0);\r
-                 SetDlgItemInt(hwndDlg,205+(x<<2),joyDown[x+joyconport],0);\r
-                 SetDlgItemInt(hwndDlg,206+(x<<2),joyLeft[x+joyconport],0);\r
-                 SetDlgItemInt(hwndDlg,207+(x<<2),joyRight[x+joyconport],0);\r
-\r
-                }\r
-                joycounter=0;\r
-                IDirectInput7_EnumDevices(lpDI, DIDEVTYPE_JOYSTICK,JoystickFound,hwndDlg,DIEDFL_ATTACHEDONLY);\r
-\r
-                SendDlgItemMessage(hwndDlg,106,CB_SETCURSEL,joy[0+joyconport],(LPARAM)(LPSTR)0);\r
-                SendDlgItemMessage(hwndDlg,112,CB_SETCURSEL,joy[2+joyconport],(LPARAM)(LPSTR)0);\r
-                \r
-                if(joyOptions[joyconport]&1)\r
-                 CheckDlgButton(hwndDlg,300,BST_CHECKED);\r
-                if(joyOptions[joyconport+2]&1)\r
-                 CheckDlgButton(hwndDlg,301,BST_CHECKED);               \r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(HIWORD(wParam)==EN_SETFOCUS)\r
-                {\r
-                 bid=LOWORD(wParam);\r
-                }\r
-                else if(HIWORD(wParam)==EN_KILLFOCUS)\r
-                {\r
-                 bid=0;\r
-                }\r
-                else if(HIWORD(wParam)==CBN_SELENDOK)\r
-                {\r
-                 switch(LOWORD(wParam))\r
-                 {\r
-                  case 106:\r
-                   KillJoystick(joyconport);\r
-                   joy[0+(joyconport)]=SendDlgItemMessage(hwndDlg,106,CB_GETCURSEL,0,(LPARAM)(LPSTR)0);\r
-                   InitJoystick(joyconport,hwndDlg);\r
-                   SendDlgItemMessage(hwndDlg,106,CB_SETCURSEL,joy[0+joyconport],(LPARAM)(LPSTR)0);\r
-                   break;\r
-                  case 112:\r
-                   KillJoystick(2+joyconport);\r
-                   joy[2+(joyconport)]=SendDlgItemMessage(hwndDlg,112,CB_GETCURSEL,0,(LPARAM)(LPSTR)0);\r
-                   InitJoystick(2+joyconport,hwndDlg);                                      \r
-                   SendDlgItemMessage(hwndDlg,112,CB_SETCURSEL,joy[2+joyconport],(LPARAM)(LPSTR)0);\r
-                   break;\r
-                 }\r
-                }\r
-\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 1:\r
-                        gornk:\r
-\r
-                        KillTimer(hwndDlg,666);\r
-                        KillJoysticks();\r
-\r
-                        for(x=0;x<=2;x+=2)\r
-                        {\r
-                         joySelect[x+(joyconport)]=GetDlgItemInt(hwndDlg,200+(x<<2),0,0);\r
-                         joyStart[x+(joyconport)]=GetDlgItemInt(hwndDlg,201+(x<<2),0,0);\r
-                         joyB[x+(joyconport)]=GetDlgItemInt(hwndDlg,202+(x<<2),0,0);\r
-                         joyA[x+(joyconport)]=GetDlgItemInt(hwndDlg,203+(x<<2),0,0);\r
-\r
-                         joyUp[x+(joyconport)]=GetDlgItemInt(hwndDlg,204+(x<<2),0,0);\r
-                         joyDown[x+(joyconport)]=GetDlgItemInt(hwndDlg,205+(x<<2),0,0);\r
-                         joyLeft[x+(joyconport)]=GetDlgItemInt(hwndDlg,206+(x<<2),0,0);\r
-                         joyRight[x+(joyconport)]=GetDlgItemInt(hwndDlg,207+(x<<2),0,0);\r
-                        }\r
-                        if(IsDlgButtonChecked(hwndDlg,300)==BST_CHECKED)\r
-                         joyOptions[joyconport]|=1;\r
-                        else\r
-                         joyOptions[joyconport]&=~1;\r
-                        if(IsDlgButtonChecked(hwndDlg,301)==BST_CHECKED)\r
-                         joyOptions[joyconport+2]|=1;\r
-                        else\r
-                         joyOptions[joyconport+2]&=~1;                        \r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-               }\r
-              }\r
-  return 0;\r
-}\r
-\r
-void ConfigJoystickies(HWND hParent, int port)\r
-{\r
- joyconport=port;\r
-\r
- KillJoysticks();\r
- DialogBox(fceu_hInstance,"JOYCONFIG",hParent,JoyConCallB);\r
- InitJoysticks(hAppWnd);\r
-}\r
-\r
diff --git a/drivers/win/joystick.h b/drivers/win/joystick.h
deleted file mode 100644 (file)
index a5cdb40..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-void ConfigJoystickies(HWND hParent, int port);\r
-void InitJoysticks(HWND wnd);\r
-void KillJoysticks(void);\r
-uint32 GetJSOr(void);\r
-\r
-extern int joyOptions[4];\r
-extern int joyA[4];\r
-extern int joyB[4];\r
-extern int joySelect[4];\r
-extern int joyStart[4];\r
-extern int joyUp[4];\r
-extern int joyDown[4];\r
-extern int joyLeft[4];\r
-extern int joyRight[4];\r
-extern int joy[4];\r
-\r
diff --git a/drivers/win/keyboard.c b/drivers/win/keyboard.c
deleted file mode 100644 (file)
index b521081..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "common.h"
-#include <dinput.h>
-
-
-#include "input.h"
-#include "keyboard.h"
-
-#include "keyscan.h"
-
-
-HRESULT  ddrval;
-
-static LPDIRECTINPUTDEVICE7 lpdid=0;
-static int porttemp;
-
-
-int keyBMap[4][8]={
-                   {SCAN_LEFTALT,SCAN_LEFTCONTROL,SCAN_TAB,SCAN_ENTER,SCAN_BL_CURSORUP,SCAN_BL_CURSORDOWN,SCAN_BL_CURSORLEFT,SCAN_BL_CURSORRIGHT},
-                   {SCAN_LEFTALT,SCAN_LEFTCONTROL,SCAN_TAB,SCAN_ENTER,SCAN_BL_CURSORUP,SCAN_BL_CURSORDOWN,SCAN_BL_CURSORLEFT,SCAN_BL_CURSORRIGHT},
-                   {SCAN_LEFTALT,SCAN_LEFTCONTROL,SCAN_TAB,SCAN_ENTER,SCAN_BL_CURSORUP,SCAN_BL_CURSORDOWN,SCAN_BL_CURSORLEFT,SCAN_BL_CURSORRIGHT},
-                   {SCAN_LEFTALT,SCAN_LEFTCONTROL,SCAN_TAB,SCAN_ENTER,SCAN_BL_CURSORUP,SCAN_BL_CURSORDOWN,SCAN_BL_CURSORLEFT,SCAN_BL_CURSORRIGHT}
-                  };
-int keybEnable=1;
-
-int powerpadside=0;
-int powerpadsc[2][12]={
-                              {
-                               SCAN_O,SCAN_P,SCAN_BRACKET_LEFT,
-                               SCAN_BRACKET_RIGHT,SCAN_K,SCAN_L,SCAN_SEMICOLON,SCAN_APOSTROPHE,
-                               SCAN_M,SCAN_COMMA,SCAN_PERIOD,SCAN_SLASH
-                              },
-                              {
-                               SCAN_O,SCAN_P,SCAN_BRACKET_LEFT,
-                               SCAN_BRACKET_RIGHT,SCAN_K,SCAN_L,SCAN_SEMICOLON,SCAN_APOSTROPHE,
-                               SCAN_M,SCAN_COMMA,SCAN_PERIOD,SCAN_SLASH
-                              }
-                             };
-
-
-
-
-void KeyboardClose(void)
-{
- if(lpdid) IDirectInputDevice7_Unacquire(lpdid);
- lpdid=0;
-}
-
-static char keys[256];
-static void KeyboardUpdateState(void)
-{
- ddrval=IDirectInputDevice7_GetDeviceState(lpdid,256,keys);
- switch(ddrval)
-  {
-   case DIERR_INPUTLOST:
-   case DIERR_NOTACQUIRED:
-                         IDirectInputDevice7_Acquire(lpdid);
-                         break;
-  }
-}
-
-int KeyboardInitialize(void)
-{
-
- if(lpdid)
-  return(1);
-
- ddrval=IDirectInput7_CreateDeviceEx(lpDI, &GUID_SysKeyboard,&IID_IDirectInputDevice7, (LPVOID *)&lpdid,0);
- if(ddrval != DI_OK)
- {
-  FCEUD_PrintError("DirectInput: Error creating keyboard device.");
-  return 0;
- }
-
- ddrval=IDirectInputDevice7_SetCooperativeLevel(lpdid, hAppWnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE);
- if(ddrval != DI_OK)
- {
-  FCEUD_PrintError("DirectInput: Error setting keyboard cooperative level.");
-  return 0;
- }
-
- ddrval=IDirectInputDevice7_SetDataFormat(lpdid,&c_dfDIKeyboard);
- if(ddrval != DI_OK)
- {
-  FCEUD_PrintError("DirectInput: Error setting keyboard data format.");
-  return 0;
- }
-
- ddrval=IDirectInputDevice7_Acquire(lpdid);
- if(ddrval != DI_OK)
- {
-  FCEUD_PrintError("DirectInput: Error acquiring keyboard.");
-  return 0;
- }
- return 1;
-}
-
-static int DIPS=0;
-static uint8 keyonce[256];
-#define KEY(__a) keys[SCAN_##__a]
-#define keyonly(__a,__z) {if(KEY(__a)){if(!keyonce[SCAN_##__a]) {keyonce[SCAN_##__a]=1;__z}} else{keyonce[SCAN_##__a]=0;}}
-int cidisabled=0;
-
-void KeyboardUpdate(void)
-{ 
- KeyboardUpdateState();
-
- if(InputTypeFC==SIFC_FKB && cidisabled)
-  return;
-
- NoWaiting&=~1;
- if(KEY(GRAVE))
-  NoWaiting|=1;
-
- if(GI)
- {
-  if(GI->type==GIT_FDS)
-  {
-   keyonly(S,DriverInterface(DES_FDSSELECT,0);)
-   keyonly(I,DriverInterface(DES_FDSINSERT,0);)
-   keyonly(E,DriverInterface(DES_FDSEJECT,0);)
-  }
-
-  if(GI->type!=GIT_NSF)
-  {
-   keyonly(F5,FCEUI_SaveState();)
-   keyonly(F7,FCEUI_LoadState();)
-  }
-  keyonly(F9,FCEUI_SaveSnapshot();)
-
-  if(GI->type==GIT_VSUNI)
-  {
-   keyonly(C,DriverInterface(DES_VSUNICOIN,0);)
-   keyonly(V,DIPS^=1;DriverInterface(DES_VSUNITOGGLEDIPVIEW,0);)
-   if(!(DIPS&1)) goto DIPSless;
-   keyonly(1,DriverInterface(DES_VSUNIDIPSET,(void *)1);)
-   keyonly(2,DriverInterface(DES_VSUNIDIPSET,(void *)2);)
-   keyonly(3,DriverInterface(DES_VSUNIDIPSET,(void *)3);)
-   keyonly(4,DriverInterface(DES_VSUNIDIPSET,(void *)4);)
-   keyonly(5,DriverInterface(DES_VSUNIDIPSET,(void *)5);)
-   keyonly(6,DriverInterface(DES_VSUNIDIPSET,(void *)6);)
-   keyonly(7,DriverInterface(DES_VSUNIDIPSET,(void *)7);)
-   keyonly(8,DriverInterface(DES_VSUNIDIPSET,(void *)8);)
-  }
-  else
-  {
-   keyonly(H,DriverInterface(DES_NTSCSELHUE,0);)
-   keyonly(T,DriverInterface(DES_NTSCSELTINT,0);)
-   if(KEY(KP_MINUS) || KEY(MINUS)) DriverInterface(DES_NTSCDEC,0);
-   if(KEY(KP_PLUS) || KEY(EQUAL)) DriverInterface(DES_NTSCINC,0);
-
-   DIPSless:
-   keyonly(0,FCEUI_SelectState(0);)
-   keyonly(1,FCEUI_SelectState(1);)
-   keyonly(2,FCEUI_SelectState(2);)
-   keyonly(3,FCEUI_SelectState(3);)
-   keyonly(4,FCEUI_SelectState(4);)
-   keyonly(5,FCEUI_SelectState(5);)
-   keyonly(6,FCEUI_SelectState(6);)
-   keyonly(7,FCEUI_SelectState(7);)
-   keyonly(8,FCEUI_SelectState(8);)
-   keyonly(9,FCEUI_SelectState(9);)
-  }
- }
-}
-
-uint32 KeyboardDodo(void)
-{
- uint32 JS=0;
-
-
- if(GI)
- if(GI->type!=GIT_NSF)
- {
-  int x,y,u,b;
-
-  for(u=0;u<4;u++)
-  {
-   if(keybEnable&(1<<u))
-   {
-    int *tmpo=keyBMap[u];
-    x=y=0;
-
-    for(b=3;b>=0;b--)
-     if(keys[tmpo[b]]) JS|=(1<<b)<<(u<<3);
-
-    if(keys[tmpo[4]])    y|= JOY_UP;
-    if(keys[tmpo[5]])  y|= JOY_DOWN;
-    if(keys[tmpo[6]])  x|= JOY_LEFT;
-    if(keys[tmpo[7]]) x|= JOY_RIGHT;
-
-    if(y!=(JOY_DOWN|JOY_UP)) JS|=y<<(u<<3);
-    if(x!=(JOY_LEFT|JOY_RIGHT)) JS|=x<<(u<<3);
-   }
-  }
- }
- return JS;
-}
-
-uint32 UpdatePPadData(int w)
-{
- static const char shifttableA[12]={8,9,0,1,11,7,4,2,10,6,5,3};
- static const char shifttableB[12]={1,0,9,8,2,4,7,11,3,5,6,10};
- uint32 r=0;
- int *ppadtsc=powerpadsc[w];
- int x;
-
- if(powerpadside&(1<<w))
- {
-  for(x=0;x<12;x++)
-   if(keys[ppadtsc[x]]) r|=1<<shifttableA[x];
- }
- else
- {
-  for(x=0;x<12;x++)
-   if(keys[ppadtsc[x]]) r|=1<<shifttableB[x];
- }
- return r;
-}
-
-int fkbmap[0x48]=
-{
- SCAN_F1,SCAN_F2,SCAN_F3,SCAN_F4,SCAN_F5,SCAN_F6,SCAN_F7,SCAN_F8,
- SCAN_1,SCAN_2,SCAN_3,SCAN_4,SCAN_5,SCAN_6,SCAN_7,SCAN_8,SCAN_9,SCAN_0,
-        SCAN_MINUS,SCAN_EQUAL,SCAN_BACKSLASH,SCAN_BACKSPACE,
- SCAN_ESCAPE,SCAN_Q,SCAN_W,SCAN_E,SCAN_R,SCAN_T,SCAN_Y,SCAN_U,SCAN_I,SCAN_O,
-        SCAN_P,SCAN_GRAVE,SCAN_BRACKET_LEFT,SCAN_ENTER,
- SCAN_LEFTCONTROL,SCAN_A,SCAN_S,SCAN_D,SCAN_F,SCAN_G,SCAN_H,SCAN_J,SCAN_K,
-        SCAN_L,SCAN_SEMICOLON,SCAN_APOSTROPHE,SCAN_BRACKET_RIGHT,SCAN_BL_INSERT,
- SCAN_LEFTSHIFT,SCAN_Z,SCAN_X,SCAN_C,SCAN_V,SCAN_B,SCAN_N,SCAN_M,SCAN_COMMA,
-        SCAN_PERIOD,SCAN_SLASH,SCAN_RIGHTALT,SCAN_RIGHTSHIFT,SCAN_LEFTALT,SCAN_SPACE,
- SCAN_BL_DELETE,SCAN_BL_END,SCAN_BL_PAGEDOWN,
- SCAN_BL_CURSORUP,SCAN_BL_CURSORLEFT,SCAN_BL_CURSORRIGHT,SCAN_BL_CURSORDOWN
-};
-
-uint8 fkbkeys[0x48];
-void UpdateFKB(void)
-{
- int x;
-
- for(x=0;x<0x48;x++)
- {
-  fkbkeys[x]=0;
-  if(keys[fkbmap[x]])
-   fkbkeys[x]=1;
- }
-}
-
-
-
-static int inkeyloop=0;
-
-static BOOL CALLBACK KeyConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-  int x,y;
-  char tempo[64];
-
-  switch(uMsg) {
-   case WM_USER+666:
-                   if(inkeyloop)
-                   {
-                    SetDlgItemInt(hwndDlg,inkeyloop,lParam,0);
-                    inkeyloop=0;
-                   }                   
-                   break;
-   case WM_INITDIALOG:
-                sprintf(tempo,"Virtual Gamepad %d",porttemp+1);
-                SetDlgItemText(hwndDlg,302,tempo);
-                sprintf(tempo,"Virtual Gamepad %d",porttemp+3);
-                SetDlgItemText(hwndDlg,311,tempo);
-
-                for(x=0;x<2;x++)
-                {
-                 for(y=0;y<8;y++)
-                  SetDlgItemInt(hwndDlg,600+y+x*10,keyBMap[porttemp+(x<<1)][y],0);
-                 if(keybEnable&(1<<((x<<1)+porttemp)))
-                  CheckDlgButton(hwndDlg,320+x,BST_CHECKED);
-                }
-                break;
-   case WM_CLOSE:
-   case WM_QUIT: goto gornk;
-   case WM_COMMAND:
-                  if(!(wParam>>16))
-                  {
-                   wParam&=0xFFFF;
-                   if((wParam>=600 && wParam<=607) || (wParam>=610 && wParam<=617))
-                    inkeyloop=wParam;
-                   else switch(wParam)
-                   {                    
-                    case 1:
-                           gornk:
-                           for(x=0;x<2;x++)
-                           {
-                            for(y=0;y<8;y++)
-                             keyBMap[porttemp+(x<<1)][y]=GetDlgItemInt(hwndDlg,600+y+x*10,0,0);
-
-                            if(IsDlgButtonChecked(hwndDlg,320+x)==BST_CHECKED)
-                             keybEnable|=(1<<((x<<1)+porttemp));
-                            else
-                             keybEnable&=~(1<<((x<<1)+porttemp));
-                           }
-
-                           EndDialog(hwndDlg,0);
-                           break;
-                   }  
-                  }
-              }
-  return 0;
-}
-
-static BOOL CALLBACK KeyPPConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-  int x;
-  char tempo[64];
-
-  switch(uMsg) {
-   case WM_USER+666:
-                   if(inkeyloop)
-                   {
-                    SetDlgItemInt(hwndDlg,inkeyloop,lParam,0);
-                    inkeyloop=0;
-                   }                   
-                   break;
-   case WM_INITDIALOG:
-                for(x=0;x<12;x++)
-                 SetDlgItemInt(hwndDlg,500+x,powerpadsc[porttemp][x],0);
-                CheckDlgButton(hwndDlg,300+((powerpadside>>porttemp)&1),BST_CHECKED);
-                sprintf(tempo,"Virtual Power Pad %d",porttemp+1);
-                SetDlgItemText(hwndDlg,302,tempo);
-                break;
-   case WM_CLOSE:
-   case WM_QUIT: goto gornk;
-   case WM_COMMAND:
-                  if(!(wParam>>16))
-                  {                   
-                   wParam&=0xFFFF;
-                   if(wParam>=500 && wParam<=511)
-                    inkeyloop=wParam;
-                   else switch(wParam)
-                   {                    
-                    case 1:
-                           gornk:
-                           for(x=0;x<12;x++)
-                            powerpadsc[porttemp][x]=GetDlgItemInt(hwndDlg,500+x,0,0);
-                           powerpadside&=~(1<<porttemp);
-                           if(IsDlgButtonChecked(hwndDlg,301)==BST_CHECKED)
-                            powerpadside|=1<<porttemp;
-                           EndDialog(hwndDlg,0);
-                           break;
-                   }  
-                  }
-              }
-  return 0;
-}
-
-static BOOL CALLBACK FKBConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-  int x;
-
-  switch(uMsg) {
-   case WM_USER+666:
-                   if(inkeyloop)
-                   {
-                    SetDlgItemInt(hwndDlg,inkeyloop,lParam,0);
-                    fkbmap[inkeyloop-300]=lParam;
-                    inkeyloop=0;
-                   }                   
-                   break;
-   case WM_INITDIALOG:
-                for(x=0;x<72;x++)
-                 SetDlgItemInt(hwndDlg,300+x,fkbmap[x],0);
-                break;
-   case WM_CLOSE:
-   case WM_QUIT: goto gornk;
-   case WM_COMMAND:
-                  if(!(wParam>>16))
-                  {                   
-                   wParam&=0xFFFF;
-                   if(wParam>=300 && wParam<=371)
-                    inkeyloop=wParam;
-                   else switch(wParam)
-                   {                    
-                    case 1:
-                           gornk:
-                           EndDialog(hwndDlg,0);
-                           break;
-                   }  
-                  }
-              }
-  return 0;
-}
-
-static HHOOK hHook;
-static LRESULT CALLBACK FilterFunc(int nCode, WORD wParam, DWORD lParam)
-{
- MSG FAR *ptrMsg;
- LPARAM tmpo;
-
- if(nCode>=0)
- {
-  if(nCode==MSGF_DIALOGBOX)
-  {
-   ptrMsg=(MSG FAR *)lParam;
-   if(ptrMsg->message==WM_KEYDOWN || ptrMsg->message==WM_SYSKEYDOWN)
-   {
-    tmpo=((ptrMsg->lParam>>16)&0x7F)|((ptrMsg->lParam>>17)&0x80);
-    PostMessage(GetParent(ptrMsg->hwnd),WM_USER+666,0,tmpo);
-    if(inkeyloop) return 1;
-   }
-  }
- }
- return CallNextHookEx(hHook,nCode,wParam,lParam);
-}
-
-
-void ConfigKeyboardie(HWND hParent, int port)
-{
- porttemp=port;
-
- hHook=SetWindowsHookEx(WH_MSGFILTER,(HOOKPROC)FilterFunc,fceu_hInstance,GetCurrentThreadId());
- DialogBox(fceu_hInstance,"KEYCONFIG",hParent,KeyConCallB);
- UnhookWindowsHookEx(hHook);
-}
-
-void ConfigKeyboardiePowerpad(HWND hParent, int port)
-{
- porttemp=port;
-
- hHook=SetWindowsHookEx(WH_MSGFILTER,(HOOKPROC)FilterFunc,fceu_hInstance,GetCurrentThreadId());
- DialogBox(fceu_hInstance,"KEYPPCONFIG",hParent,KeyPPConCallB);
- UnhookWindowsHookEx(hHook);
-}
-
-void ConfigFKB(HWND hParent)
-{
- hHook=SetWindowsHookEx(WH_MSGFILTER,(HOOKPROC)FilterFunc,fceu_hInstance,GetCurrentThreadId());
- DialogBox(fceu_hInstance,"FKBCONFIG",hParent,FKBConCallB);
- UnhookWindowsHookEx(hHook);
-}
diff --git a/drivers/win/keyboard.h b/drivers/win/keyboard.h
deleted file mode 100644 (file)
index f118fc6..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-void KeyboardClose(void);\r
-int KeyboardInitialize(void);\r
-void KeyboardUpdate(void);\r
-uint32 KeyboardDodo(void);\r
-uint32 UpdatePPadData(int w);\r
-void UpdateFKB(void);\r
-\r
-\r
-void ConfigFKB(HWND hParent);\r
-void ConfigKeyboardie(HWND hParent, int port);\r
-void ConfigKeyboardiePowerpad(HWND hParent, int port);\r
-\r
-extern int cidisabled;\r
-\r
-/* Config stuff: */\r
-extern int keyBMap[4][8];\r
-extern int keybEnable;\r
-extern int powerpadside;\r
-extern int powerpadsc[2][12];\r
-\r
-extern int fkbmap[0x48];\r
-extern uint8 fkbkeys[0x48];\r
diff --git a/drivers/win/keyscan.h b/drivers/win/keyscan.h
deleted file mode 100644 (file)
index 689d780..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#define SCAN_GRAVE     0x29
-#define SCAN_1         0x02
-#define SCAN_2         0x03
-#define SCAN_3         0x04
-#define SCAN_4          0x05
-#define SCAN_5          0x06
-#define SCAN_6          0x07
-#define SCAN_7          0x08
-#define SCAN_8          0x09
-#define SCAN_9          0x0A
-#define SCAN_0          0x0B
-#define SCAN_MINUS     0x0C
-#define SCAN_EQUAL     0x0D
-#define SCAN_BACKSLASH 0x2B
-#define SCAN_BACKSPACE 0x0E
-#define SCAN_TAB       0x0F
-#define SCAN_Q         0x10
-#define SCAN_W         0x11
-#define SCAN_E         0x12
-#define SCAN_R         0x13
-#define SCAN_T         0x14
-#define SCAN_Y         0x15
-#define SCAN_U         0x16
-#define SCAN_I         0x17
-#define SCAN_O         0x18
-#define SCAN_P         0x19
-#define SCAN_BRACKET_LEFT      0x1A
-#define SCAN_BRACKET_RIGHT     0x1B
-#define SCAN_LOWBACKSLASH      0x2B
-#define SCAN_CAPSLOCK  0x3A
-#define SCAN_A         0x1E
-#define SCAN_S         0x1F
-#define SCAN_D          0x20
-#define SCAN_F          0x21
-#define SCAN_G          0x22
-#define SCAN_H          0x23
-#define SCAN_J          0x24
-#define SCAN_K          0x25
-#define SCAN_L          0x26
-#define SCAN_SEMICOLON 0x27
-#define SCAN_APOSTROPHE        0x28
-#define SCAN_ENTER     0x1C
-#define SCAN_LEFTSHIFT 0x2A
-#define SCAN_Z         0x2C
-#define SCAN_X         0x2D
-#define SCAN_C          0x2E
-#define SCAN_V          0x2F
-#define SCAN_B          0x30
-#define SCAN_N          0x31
-#define SCAN_M          0x32
-#define SCAN_COMMA      0x33
-#define SCAN_PERIOD    0x34
-#define SCAN_SLASH     0x35
-#define SCAN_RIGHTSHIFT        0x36
-#define SCAN_LEFTCONTROL       0x1D
-#define SCAN_LEFTALT           0x38
-#define SCAN_SPACE             0x39
-
-#define SCAN_RIGHTALT          (0x38|0x80)
-#define SCAN_RIGHTCONTROL      (0x1D|0x80)
-#define SCAN_BL_INSERT         (0x52|0x80)
-#define SCAN_BL_DELETE         (0x53|0x80)
-#define SCAN_BL_CURSORLEFT     (0x4B|0x80)
-#define SCAN_BL_HOME           (0x47|0x80)
-#define SCAN_BL_END            (0x4F|0x80)
-#define SCAN_BL_CURSORUP       (0x48|0x80)
-#define SCAN_BL_CURSORDOWN     (0x50|0x80)
-#define SCAN_BL_PAGEUP         (0x49|0x80)
-#define SCAN_BL_PAGEDOWN       (0x51|0x80)
-#define SCAN_BL_CURSORRIGHT    (0x4D|0x80)
-
-#define SCAN_SCROLLLOCK         0x46
-/* Keys in the key pad area. */
-#define SCAN_NUMLOCK           0x45
-#define SCAN_HOME              0x47
-#define SCAN_CURSORLEFT                0x4B
-#define SCAN_END               0x4F
-#define SCAN_SLASH             0x35
-#define SCAN_CURSORUP          0x48
-#define SCAN_CENTER            0x4C
-#define SCAN_CURSORDOWN                0x50
-#define SCAN_INSERT            0x52
-#define SCAN_ASTERISK          0x37
-#define SCAN_PAGEUP            0x49
-#define SCAN_CURSORRIGHT       0x4D
-#define SCAN_PAGEDOWN           0x51
-#define SCAN_KP_DELETE          0x53
-#define SCAN_KP_MINUS           0x4A
-#define SCAN_KP_PLUS            0x4E
-#define SCAN_KP_ENTER           0x1C
-
-#define SCAN_ESCAPE            0x01
-#define SCAN_F1                        0x3B
-#define SCAN_F2                        0x3C
-#define SCAN_F3                 0x3D
-#define SCAN_F4                 0x3E
-#define SCAN_F5                 0x3F
-#define SCAN_F6                 0x40
-#define SCAN_F7                 0x41
-#define SCAN_F8                 0x42
-#define SCAN_F9                 0x43
-#define SCAN_F10                0x44
-#define SCAN_F11                0x57
-#define SCAN_F12                0x58
diff --git a/drivers/win/main.c b/drivers/win/main.c
deleted file mode 100644 (file)
index 2faf4eb..0000000
+++ /dev/null
@@ -1,338 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "common.h"
-
-#include <winsock.h>
-#include <mmsystem.h>
-#include <ddraw.h>
-#include <dsound.h>
-#include <dinput.h>
-#include <dir.h>
-#include <commctrl.h>
-#include <shlobj.h>     // For directories configuration dialog.
-
-#include "input.h"
-#include "joystick.h"
-#include "keyboard.h"
-#include "cheat.h"
-
-
-#define EO_BGRUN          1
-
-#define EO_CPALETTE       4
-#define EO_NOSPRLIM       8
-#define EO_BSAV          16
-#define EO_FSAFTERLOAD   32
-#define EO_FOAFTERSTART  64
-#define EO_NOTHROTTLE   128
-#define EO_CLIPSIDES    256
-#define EO_SNAPNAME    512
-
-/* EO_USERFORCE is something I've been playing with.
-   The code for it isn't finished.
-*/
-#define EO_USERFORCE   1024
-
-
-#define VNSCLIP  ((eoptions&EO_CLIPSIDES)?8:0)
-#define VNSWID   ((eoptions&EO_CLIPSIDES)?240:256)
-
-static int eoptions=EO_BGRUN;
-
-void ResetVideo(void);
-void ShowCursorAbs(int w);
-void HideFWindow(int h);
-int SetMainWindowStuff(void);
-int GetClientAbsRect(LPRECT lpRect);
-void UpdateFCEUWindow(void);
-
-
-HWND hAppWnd=0;
-HINSTANCE fceu_hInstance;
-
-HRESULT  ddrval;
-
-FCEUGI *GI=0;
-
-// cheats, misc, nonvol, states, snaps, base
-static char *DOvers[6]={0,0,0,0,0,0};
-static char *defaultds[5]={"cheats","gameinfo","sav","fcs","snaps"};
-
-static char TempArray[2048];
-static char BaseDirectory[2048];
-
-void SetDirs(void)
-{
- int x;
- static int jlist[5]=
-  {FCEUIOD_CHEATS,FCEUIOD_MISC,FCEUIOD_NV,FCEUIOD_STATE,FCEUIOD_SNAPS};
-
- for(x=0;x<5;x++)
-  FCEUI_SetDirOverride(jlist[x], DOvers[x]);  
- if(DOvers[5])
-  FCEUI_SetBaseDirectory(DOvers[5]);
- else
-  FCEUI_SetBaseDirectory(BaseDirectory);
- FCEUI_SaveExtraDataUnderBase(eoptions&EO_BSAV);
-}
-/* Remove empty, unused directories. */
-void RemoveDirs(void)
-{
- int x;
-
- for(x=0;x<5;x++)
-  if(!DOvers[x])
-  {
-   sprintf(TempArray,"%s\\%s",DOvers[5]?DOvers[5]:BaseDirectory,defaultds[x]);
-   RemoveDirectory(TempArray);
-  }
-}
-
-void CreateDirs(void)
-{
- int x;
-
- for(x=0;x<5;x++)
-  if(!DOvers[x])
-  {
-   sprintf(TempArray,"%s\\%s",DOvers[5]?DOvers[5]:BaseDirectory,defaultds[x]);
-   CreateDirectory(TempArray,0);
-  }
-}
-
-static char *gfsdir=0;
-void GetBaseDirectory(void)
-{
- int x;
- BaseDirectory[0]=0;
- GetModuleFileName(0,(LPTSTR)BaseDirectory,2047);
-
- for(x=strlen(BaseDirectory);x>=0;x--)
- {
-  if(BaseDirectory[x]=='\\' || BaseDirectory[x]=='/')
-   {BaseDirectory[x]=0;break;}
- }
-}
-
-static int exiting=0;
-int BlockingCheck(void)
-{
-  MSG msg;
-
-  while( PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ) ) {
-     if( GetMessage( &msg, 0,  0, 0)>0 )
-     {
-     TranslateMessage(&msg);
-     DispatchMessage(&msg);
-     }
-   }
-
- if(exiting) return(0);
-
- return(1);
-}
-
-int NoWaiting=0;
-static int fullscreen=0;
-static int soundflush=0;
-static int soundsleep=0;
-static int genie=0;
-static int palyo=0;
-static int windowedfailed;
-static int winsizemul=1;
-static int winwidth,winheight;
-
-static volatile int nofocus=0;
-static volatile int userpause=0;
-
-#define SO_FORCE8BIT  1
-#define SO_SECONDARY  2
-#define SO_GFOCUS     4
-#define SO_D16VOL     8
-
-static int soundrate=44100;
-static int soundbuftime=46;
-static int soundbufsize;
-static int soundoptions=0;
-static int soundvolume=100;
-
-static unsigned int srendline,erendline;
-static unsigned int srendlinen=8;
-static unsigned int erendlinen=239;
-static unsigned int srendlinep=0;
-static unsigned int erendlinep=239;
-
-
-static unsigned int totallines;
-
-static void FixFL(void)
-{
- FCEUI_GetCurrentVidSystem(&srendline,&erendline);
- totallines=erendline-srendline+1;
-}
-
-static void UpdateRendBounds(void)
-{ 
- FCEUI_SetRenderedLines(srendlinen,erendlinen,srendlinep,erendlinep);
- FixFL(); 
-}
-
-static uint8 cpalette[192];
-static int vmod=1;
-static int soundo=1;
-static int ntsccol=0,ntsctint,ntschue;
-
-void FCEUD_PrintError(char *s)
-{
- if(fullscreen) ShowCursorAbs(1);
- MessageBox(0,s,"FCE Ultra Error",MB_ICONERROR|MB_OK|MB_SETFOREGROUND|MB_TOPMOST);
- if(fullscreen)ShowCursorAbs(0);
-}
-
-void ShowAboutBox(void)
-{
- sprintf(TempArray,"FCE Ultra "VERSION_STRING"\n\nhttp://fceultra.sourceforge.net\n\n"__TIME__"\n"__DATE__"\n""gcc "__VERSION__);
- MessageBox(hAppWnd,TempArray,"About FCE Ultra",MB_OK);
-}
-
-void DoFCEUExit(void)
-{
- exiting=1;
- if(GI)
- {
-  FCEUI_CloseGame();
-  GI=0;
- }
-}
-
-static int changerecursive=0;
-
-#include "throttle.c"
-
-#include "netplay.c"
-#include "sound.c"
-#include "video.c"
-#include "window.c"
-#include "config.c"
-
-
-int DriverInitialize(void)
-{
-  if(!InitializeDDraw())
-   return(0);
-
-  if(soundo)
-   soundo=InitSound();
-
-  SetVideoMode(fullscreen);
-  InitInputStuff();             /* Initialize DInput interfaces. */
-  CreateInputStuff();           /* Create and set virtual NES/FC devices. */
-  return 1;
-}
-
-static void DriverKill(void)
-{ 
- sprintf(TempArray,"%s/fceu.cfg",BaseDirectory);
- SaveConfig(TempArray);
- DestroyInput();
- ResetVideo();
- if(soundo) TrashSound();
- CloseWave();
- ByebyeWindow();
-}
-
-
-int main(int argc,char *argv[])
-{
-  char *t;
-
-  if(!FCEUI_Initialize())
-   goto doexito;
-
-  fceu_hInstance=GetModuleHandle(0);
-
-  GetBaseDirectory();
-
-  sprintf(TempArray,"%s\\fceu.cfg",BaseDirectory);
-  LoadConfig(TempArray);
-  FixGIGO();      /* Since a game doesn't have to be
-                     loaded before the GUI can be used, make
-                     sure the temporary input type variables
-                     are set.
-                  */
-
-
-  CreateDirs();
-  SetDirs();
-
-  DoVideoConfigFix();
-  DoMiscConfigFix();
-
-  if(eoptions&EO_CPALETTE)
-   FCEUI_SetPaletteArray(cpalette);
-
-  t=0;
-  if(argc>1)
-   t=argv[1];
-  if(!t) fullscreen=0;
-
-  CreateMainWindow();
-
-  if(!InitDInput())
-   goto doexito;
-
-  if(!DriverInitialize())
-   goto doexito;
-  InitSpeedThrottle();
-  UpdateMenu();
-
-  if(t)
-   ALoad(t);
-  else if(eoptions&EO_FOAFTERSTART)
-   LoadNewGamey(hAppWnd);
-
-  doloopy:
-  UpdateFCEUWindow();
-  if(GI)
-  {
-   FCEUI_Emulate();
-   RedrawWindow(hAppWnd,0,0,RDW_ERASE|RDW_INVALIDATE);
-   StopSound();
-  }
-  Sleep(50);
-  if(!exiting)
-   goto doloopy;
-
-  doexito:
-  DriverKill();
-  return(0);
-}
-
-void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
-{
- FCEUD_BlitScreen(XBuf);
- if(Count)
-  FCEUD_WriteSoundData(Buffer,Count);
- FCEUD_UpdateInput();
-}
-
diff --git a/drivers/win/netplay.c b/drivers/win/netplay.c
deleted file mode 100644 (file)
index 6c7ac45..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-static char netplayhost[256]={0};\r
-static int netplayport=0xFCE;\r
-\r
-static int netplayon=0;\r
-static int netplaytype=0;\r
-\r
-static HWND hwndns=0;\r
-\r
-static SOCKET Socket=INVALID_SOCKET;\r
-static int wsainit=0;\r
-\r
-static volatile int abortnetplay=0;\r
-static volatile int concommand=0;\r
-\r
-static void WSE(char *ahh)\r
-{\r
- char tmp[256];\r
- sprintf(tmp,"Winsock: %s",ahh);\r
- FCEUD_PrintError(tmp);\r
-}\r
-\r
-int SetBlockingSock(SOCKET Socko)\r
-{\r
-   unsigned long t;\r
-   t=1;\r
-   if(ioctlsocket(Socko,FIONBIO,&t))\r
-   {\r
-    WSE("Error setting socket to non-blocking mode!\n");\r
-    return 0;\r
-   }\r
-  return 1;\r
-}\r
-\r
-BOOL CALLBACK BoogaDooga(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  switch(uMsg) {\r
-   case WM_USER+1:\r
-                if(WSAGETASYNCERROR(lParam))\r
-                 concommand=1;\r
-                else\r
-                 concommand=2;\r
-                break;\r
-   case WM_USER:\r
-                if(WSAGETSELECTEVENT(lParam)==FD_CONNECT)\r
-                 {\r
-                  if(WSAGETSELECTERROR(lParam))\r
-                   concommand=1;\r
-                  else\r
-                   concommand=2;\r
-                 }                \r
-                break;\r
-   case WM_INITDIALOG:\r
-                if(!netplaytype) SetDlgItemText(hwndDlg,100,(LPTSTR)"Waiting for a connection...");\r
-                else SetDlgItemText(hwndDlg,100,(LPTSTR)"Attempting to establish a connection...");                                 \r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                  case 1:\r
-                        gornk:\r
-                        abortnetplay=1;\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-               }\r
-              }\r
-  return 0;\r
-\r
-}\r
-\r
-static void CloseNSDialog(void)\r
-{\r
- if(hwndns)\r
-  {\r
-   SendMessage(hwndns,WM_COMMAND,1,0);\r
-   hwndns=0;\r
-  }\r
-}\r
-\r
-void CreateStatusDialog(void)\r
-{\r
- hwndns=CreateDialog(fceu_hInstance,"NETSTAT",hAppWnd,BoogaDooga);\r
-}\r
-\r
-void FCEUD_NetworkClose(void)\r
-{\r
- CloseNSDialog();\r
- if(Socket!=INVALID_SOCKET)\r
- {\r
-  closesocket(Socket);\r
-  Socket=INVALID_SOCKET;\r
- }\r
- if(wsainit)\r
- {\r
-  WSACleanup();\r
-  wsainit=0;\r
- }\r
- /* Make sure blocking is returned to normal once network play is stopped. */\r
- NoWaiting&=~2;\r
-}\r
-\r
-int FCEUD_NetworkConnect(void)\r
-{\r
- WSADATA WSAData;\r
- SOCKADDR_IN sockin;    /* I want to play with fighting robots. */\r
- SOCKET TSocket;\r
-\r
- if(WSAStartup(MAKEWORD(1,1),&WSAData))\r
- {\r
-  FCEUD_PrintError("Error initializing Windows Sockets.");\r
-  return(0);\r
- }\r
- wsainit=1;\r
- concommand=abortnetplay=0;\r
-\r
- if( (TSocket=socket(AF_INET,SOCK_STREAM,0))==INVALID_SOCKET)\r
- {\r
-  WSE("Error creating socket.");\r
-  FCEUD_NetworkClose();\r
-  return(0);\r
- }\r
-\r
- memset(&sockin,0,sizeof(sockin));\r
- sockin.sin_family=AF_INET;\r
- sockin.sin_port=htons(netplayport);\r
-\r
- if(!netplaytype)       /* Act as a server. */\r
- {\r
-\r
-  int sockin_len;\r
-  sockin.sin_addr.s_addr=INADDR_ANY;\r
-\r
-  sockin_len=sizeof(sockin);\r
-\r
-  if(bind(TSocket,(struct sockaddr *)&sockin,sizeof(sockin))==SOCKET_ERROR)\r
-  {\r
-   WSE("Error binding to socket.");\r
-   closesocket(TSocket);\r
-   FCEUD_NetworkClose();\r
-   return(0);\r
-  }\r
-\r
-  if(listen(TSocket,1)==SOCKET_ERROR)\r
-  {\r
-   WSE("Error listening on socket.");\r
-   closesocket(TSocket);\r
-   FCEUD_NetworkClose();\r
-   return(0);\r
-  }\r
-\r
-  CreateStatusDialog();\r
-  if(!SetBlockingSock(TSocket))\r
-  {\r
-   closesocket(TSocket);\r
-   FCEUD_NetworkClose();\r
-   return(0);\r
-  }\r
-\r
-  while( (Socket=accept(TSocket,(struct sockaddr *) &sockin,(int *)&sockin_len)) ==\r
-                INVALID_SOCKET)\r
-  {\r
-   if(abortnetplay || WSAGetLastError()!=WSAEWOULDBLOCK)\r
-   {\r
-    if(!abortnetplay)\r
-     WSE("Error accepting connection.");\r
-    closesocket(TSocket);\r
-    FCEUD_NetworkClose();\r
-    return(0);\r
-   }\r
-   else\r
-    BlockingCheck();\r
-  }\r
-\r
-  if(!SetBlockingSock(Socket))\r
-  {\r
-   FCEUD_NetworkClose();\r
-   return(0);\r
-  }\r
-\r
- }    \r
- else   /* We're a client... */\r
- {\r
-  char phostentb[MAXGETHOSTSTRUCT];\r
-  unsigned long hadr;\r
-\r
-  hadr=inet_addr(netplayhost);\r
-\r
-  CreateStatusDialog();\r
-\r
-  if(hadr!=INADDR_NONE)\r
-   sockin.sin_addr.s_addr=hadr;\r
-  else\r
-  {\r
-   if(!WSAAsyncGetHostByName(hwndns,WM_USER+1,(const char *)netplayhost,phostentb,MAXGETHOSTSTRUCT))\r
-   {\r
-    ghosterr:\r
-    WSE("Error getting host network information.");\r
-    closesocket(TSocket);\r
-    FCEUD_NetworkClose();\r
-    return(0);\r
-   }\r
-   while(concommand!=2)\r
-   {\r
-    BlockingCheck();\r
-    if(concommand==1 || abortnetplay)\r
-     goto ghosterr;\r
-   }\r
-   memcpy((char *)&sockin.sin_addr,((PHOSTENT)phostentb)->h_addr,((PHOSTENT)phostentb)->h_length);\r
-  }\r
-  concommand=0;\r
-\r
-  if(WSAAsyncSelect(TSocket,hwndns,WM_USER,FD_CONNECT|FD_CLOSE)==SOCKET_ERROR)\r
-  {\r
-   eventnoterr:\r
-   WSE("Error setting event notification on socket.");\r
-   closesocket(TSocket);\r
-   FCEUD_NetworkClose();\r
-   return(0);\r
-  }\r
-\r
-  if(!SetBlockingSock(TSocket))\r
-  {\r
-   closesocket(TSocket);\r
-   FCEUD_NetworkClose();\r
-   return(0);\r
-  }\r
-\r
-  if(connect(TSocket,(PSOCKADDR)&sockin,sizeof(sockin))==SOCKET_ERROR)\r
-  {\r
-   if(WSAGetLastError()!=WSAEWOULDBLOCK)\r
-   {\r
-    cerrav:\r
-    WSE("Error connecting to remote host.");\r
-\r
-    cerra:\r
-    closesocket(TSocket);\r
-    FCEUD_NetworkClose();\r
-    return(0);\r
-   }\r
-\r
-   while(concommand!=2)\r
-   {\r
-    BlockingCheck();        \r
-    if(abortnetplay) goto cerra;\r
-    if(concommand==1) goto cerrav;\r
-   }\r
-  }\r
-  if(WSAAsyncSelect(TSocket,hAppWnd,WM_USER,0)==SOCKET_ERROR)\r
-   goto eventnoterr;\r
-  Socket=TSocket;\r
-\r
- }\r
- CloseNSDialog();\r
- return(1);\r
-}\r
-\r
-\r
-int FCEUD_NetworkSendData(uint8 *data, uint32 len)\r
-{\r
-        int erc;\r
-\r
-        while((erc=send(Socket,data,len,0)))\r
-        {\r
-         if(erc!=SOCKET_ERROR)\r
-         {\r
-          len-=erc;\r
-          data+=erc;\r
-          if(!len)\r
-           return(1);   /* All data sent. */\r
-\r
-          if(!BlockingCheck()) return(0);\r
-         }\r
-         else\r
-         {\r
-          if(WSAGetLastError()==WSAEWOULDBLOCK)\r
-          {\r
-           if(!BlockingCheck()) return(0);\r
-           continue;\r
-          }\r
-          return(0);\r
-         }\r
-        }\r
-        return(0);\r
-}\r
-\r
-int FCEUD_NetworkRecvData(uint8 *data, uint32 len, int block)\r
-{\r
- int erc;\r
-\r
- if(block)      // TODO: Add code elsewhere to handle sound buffer underruns.\r
- {\r
-  while((erc=recv(Socket,data,len,0))!=len)\r
-  {         \r
-         if(!erc)\r
-          return(0);\r
-         if(WSAGetLastError()==WSAEWOULDBLOCK)\r
-         {\r
-          if(!BlockingCheck()) return(0);\r
-          continue;\r
-         }\r
-         return(0);\r
-  }\r
-\r
-  {\r
-   char buf[24];\r
-   if(recv(Socket,buf,24,MSG_PEEK)==SOCKET_ERROR)\r
-   {\r
-    if(WSAGetLastError()==WSAEWOULDBLOCK)\r
-     NoWaiting&=~2;\r
-    else\r
-     return(0);\r
-   }\r
-   else\r
-    NoWaiting|=2;       /* We're the client and we're lagging behind.\r
-                           disable blocking(particularly sound...) to *try*\r
-                           to catch up.\r
-                        */                          \r
-  }\r
-\r
-  return 1;\r
- }\r
-\r
- else   /* We're the server.  See if there's any new data\r
-           from player 2.  If not, then return(-1).\r
-        */\r
- {\r
-  erc=recv(Socket,data,len,0);\r
-  if(!erc)\r
-   return(0);\r
-  if(erc==SOCKET_ERROR)\r
-  {\r
-   if(WSAGetLastError()==WSAEWOULDBLOCK)\r
-    return(-1);\r
-   return(0);  // Some other(bad) error occurred.\r
-  }\r
-  return(1);\r
- } // end else to if(block)\r
-}\r
-\r
-BOOL CALLBACK NetConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  switch(uMsg) {\r
-   case WM_INITDIALOG:                \r
-\r
-                CheckDlgButton(hwndDlg,100,netplayon?BST_CHECKED:BST_UNCHECKED);\r
-                CheckRadioButton(hwndDlg,101,102,101+netplaytype);\r
-                SetDlgItemInt(hwndDlg,107,netplayport,0);\r
-\r
-                if(netplayhost[0])\r
-                 SetDlgItemText(hwndDlg,104,netplayhost);\r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 1:\r
-                        gornk:\r
-\r
-                        netplayport=GetDlgItemInt(hwndDlg,107,0,0);\r
-\r
-                        if(IsDlgButtonChecked(hwndDlg,100)==BST_CHECKED)\r
-                         netplayon=1;\r
-                        else\r
-                         netplayon=0;\r
-\r
-                        if(IsDlgButtonChecked(hwndDlg,101)==BST_CHECKED)\r
-                         netplaytype=0;\r
-                        else\r
-                         netplaytype=1;\r
-\r
-                        GetDlgItemText(hwndDlg,104,netplayhost,255);\r
-                        netplayhost[255]=0;\r
-\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-               }\r
-              }\r
-  return 0;\r
-}\r
-\r
-\r
-static void ConfigNetplay(void)\r
-{\r
- DialogBox(fceu_hInstance,"NETPLAYCONFIG",hAppWnd,NetConCallB);\r
-\r
- if(netplayon)\r
-  FCEUI_SetNetworkPlay(netplaytype+1);\r
- else\r
-  FCEUI_SetNetworkPlay(0);\r
-}\r
-\r
diff --git a/drivers/win/res.res b/drivers/win/res.res
deleted file mode 100644 (file)
index e7e533d..0000000
Binary files a/drivers/win/res.res and /dev/null differ
diff --git a/drivers/win/sound.c b/drivers/win/sound.c
deleted file mode 100644 (file)
index d9c29c5..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-FILE *soundlog=0;\r
-void WriteWaveData(int32 *Buffer, int Count);\r
-DWORD WINAPI DSThread(LPVOID lpParam);\r
-LPDIRECTSOUND ppDS=0;\r
-LPDIRECTSOUNDBUFFER ppbuf=0;\r
-LPDIRECTSOUNDBUFFER ppbufsec=0;\r
-LPDIRECTSOUNDBUFFER ppbufw;\r
-\r
-DSBUFFERDESC DSBufferDesc;\r
-WAVEFORMATEX wfa;\r
-WAVEFORMATEX wf;\r
-\r
-static int DSBufferSize=0;\r
-static int bittage;\r
-\r
-void TrashSound(void)\r
-{\r
- FCEUI_Sound(0);\r
- if(ppbufsec)\r
- {\r
-  IDirectSoundBuffer_Stop(ppbufsec);\r
-  IDirectSoundBuffer_Release(ppbufsec);\r
-  ppbufsec=0;\r
- }\r
- if(ppbuf)\r
- {\r
-  IDirectSoundBuffer_Stop(ppbuf);\r
-  IDirectSoundBuffer_Release(ppbuf);\r
-  ppbuf=0;\r
- }\r
- if(ppDS)\r
- {\r
-  IDirectSound_Release(ppDS);\r
-  ppDS=0;\r
- }\r
-}\r
-\r
-\r
- static VOID *feegle[2];\r
- static DWORD dook[2];\r
- static DWORD writepos=0,playpos=0,lplaypos=0;\r
-void CheckDStatus(void)\r
-{\r
-  DWORD status;\r
-  status=0;\r
-  IDirectSoundBuffer_GetStatus(ppbufw, &status);\r
-\r
-  if(status&DSBSTATUS_BUFFERLOST)\r
-  {\r
-   IDirectSoundBuffer_Restore(ppbufw);\r
-  }\r
-\r
-  if(!(status&DSBSTATUS_PLAYING))\r
-  {\r
-   lplaypos=0;\r
-   writepos=((soundbufsize)<<bittage);\r
-   IDirectSoundBuffer_SetFormat(ppbufw,&wf);\r
-   IDirectSoundBuffer_Play(ppbufw,0,0,DSBPLAY_LOOPING);\r
-  }\r
-}\r
-\r
-static int16 MBuffer[2048];\r
-void FCEUD_WriteSoundData(int32 *Buffer, int Count)\r
-{\r
- int P;\r
- int k=0;\r
-\r
- if(soundlog)\r
-  WriteWaveData(Buffer, Count);\r
-\r
- if(!bittage)\r
- {\r
-  for(P=0;P<Count;P++)\r
-   *(((uint8*)MBuffer)+P)=((int8)(Buffer[P]>>8))^128;\r
- }\r
- else\r
- {\r
-  for(P=0;P<Count;P++)\r
-   MBuffer[P]=Buffer[P];\r
- }\r
-  ilicpo:\r
-  CheckDStatus();\r
-  IDirectSoundBuffer_GetCurrentPosition(ppbufw,&playpos,0);\r
-\r
-  if(writepos>=DSBufferSize) \r
-   if(playpos<lplaypos)\r
-    writepos-=DSBufferSize;\r
-  lplaypos=playpos;\r
-\r
-  /* If the write position is beyond the fill buffer, block. */\r
-  if(writepos>=(playpos+(soundbufsize<<bittage)))\r
-  //if(!(writepos<playpos+((soundbufsize)<<bittage)))\r
-  {\r
-   if(!NoWaiting)\r
-   {\r
-    if(soundsleep==1)\r
-    {\r
-     if(!k)\r
-     {\r
-      int stime;      \r
-\r
-      stime=writepos-(playpos+(soundbufsize<<bittage));\r
-      stime*=1000;\r
-      stime/=soundrate;\r
-      stime>>=1;\r
-      if(stime>=5)\r
-       Sleep(stime);\r
-      k=1;\r
-     }     \r
-    }\r
-    else if(soundsleep==2)\r
-    {\r
-     int stime;      \r
-     stime=writepos-(playpos+(soundbufsize<<bittage));\r
-     stime*=1000;\r
-     stime/=soundrate;\r
-     stime>>=1;\r
-     if(stime>=2)\r
-      Sleep(stime);\r
-    }\r
-   }\r
-   BlockingCheck();\r
-   if(!soundo || NoWaiting) return;\r
-   goto ilicpo;\r
-  }\r
-\r
-  if(netplaytype && netplayon)\r
-  {\r
-   if(writepos<=playpos+128)\r
-   writepos=playpos+(soundbufsize<<bittage);\r
-  }\r
-\r
-  {\r
-   feegle[0]=feegle[1]=0;\r
-   dook[0]=dook[1]=0;\r
-\r
-   \r
-   ddrval=IDirectSoundBuffer_Lock(ppbufw,(writepos%DSBufferSize),Count<<bittage,&feegle[0],&dook[0],&feegle[1],&dook[1],0);\r
-   if(ddrval!=DS_OK)\r
-    goto nolock;\r
-\r
-   if(feegle[1]!=0 && feegle[1]!=feegle[0])\r
-   {\r
-    if(soundflush)\r
-    {\r
-     memset(feegle[0],0x80,dook[0]);\r
-     memset(feegle[1],0x80,dook[1]);\r
-    }\r
-    else\r
-    {\r
-     memcpy(feegle[0],(uint8 *)MBuffer,dook[0]);\r
-     memcpy(feegle[1],((uint8 *)MBuffer)+dook[0],dook[1]);\r
-    }\r
-   }\r
-   else\r
-   {\r
-    if(soundflush)\r
-     memset(feegle[0],0x80,dook[0]);\r
-    else\r
-     memcpy(feegle[0],(uint8 *)MBuffer,dook[0]);\r
-   }\r
-\r
-   IDirectSoundBuffer_Unlock(ppbufw,feegle[0],dook[0],feegle[1],dook[1]);\r
-   writepos+=Count<<bittage;\r
-  }\r
- nolock:\r
- ///////// Ending\r
-}\r
-\r
-int InitSound()\r
-{\r
- DSCAPS dscaps;\r
- DSBCAPS dsbcaps;\r
-\r
- memset(&wf,0x00,sizeof(wf));\r
- wf.wFormatTag = WAVE_FORMAT_PCM;\r
- wf.nChannels = 1;\r
- wf.nSamplesPerSec = soundrate;\r
-\r
- ddrval=DirectSoundCreate(0,&ppDS,0);\r
- if (ddrval != DS_OK)\r
- {\r
-  FCEUD_PrintError("DirectSound: Error creating DirectSound object.");\r
-  return 0;\r
- }\r
-\r
- if(soundoptions&SO_SECONDARY)\r
- {\r
-  trysecondary:\r
-  ddrval=IDirectSound_SetCooperativeLevel(ppDS,hAppWnd,DSSCL_PRIORITY);\r
-  if (ddrval != DS_OK)\r
-  {\r
-   FCEUD_PrintError("DirectSound: Error setting cooperative level to DDSCL_PRIORITY.");\r
-   TrashSound();\r
-   return 0;\r
-  }\r
- }\r
- else\r
- {\r
-  ddrval=IDirectSound_SetCooperativeLevel(ppDS,hAppWnd,DSSCL_WRITEPRIMARY);\r
-  if (ddrval != DS_OK)\r
-  {\r
-   FCEUD_PrintError("DirectSound: Error setting cooperative level to DDSCL_WRITEPRIMARY.  Forcing use of secondary sound buffer and trying again...");\r
-   soundoptions|=SO_SECONDARY;\r
-   goto trysecondary;\r
-  }\r
- }\r
- memset(&dscaps,0x00,sizeof(dscaps));\r
- dscaps.dwSize=sizeof(dscaps);\r
- ddrval=IDirectSound_GetCaps(ppDS,&dscaps);\r
- if(ddrval!=DS_OK)\r
- {\r
-  FCEUD_PrintError("DirectSound: Error getting capabilities.");\r
-  return 0;\r
- }\r
-\r
- if(dscaps.dwFlags&DSCAPS_EMULDRIVER)\r
-  FCEUD_PrintError("DirectSound: Sound device is being emulated through waveform-audio functions.  Sound quality will most likely be awful.  Try to update your sound device's sound drivers.");\r
-\r
- IDirectSound_Compact(ppDS);\r
-\r
- memset(&DSBufferDesc,0x00,sizeof(DSBUFFERDESC));\r
- DSBufferDesc.dwSize=sizeof(DSBufferDesc);\r
- if(soundoptions&SO_SECONDARY)\r
-  DSBufferDesc.dwFlags=DSBCAPS_PRIMARYBUFFER;\r
- else\r
-  DSBufferDesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_GETCURRENTPOSITION2;\r
-\r
- ddrval=IDirectSound_CreateSoundBuffer(ppDS,&DSBufferDesc,&ppbuf,0);\r
- if (ddrval != DS_OK)\r
- {\r
-  FCEUD_PrintError("DirectSound: Error creating primary buffer.");\r
-  TrashSound();\r
-  return 0;\r
- } \r
-\r
- memset(&wfa,0x00,sizeof(wfa));\r
-\r
- if(soundoptions&SO_FORCE8BIT)\r
-  bittage=0;\r
- else\r
- {\r
-  bittage=1;\r
-  if( (!(dscaps.dwFlags&DSCAPS_PRIMARY16BIT)) ||\r
-      (!(dscaps.dwFlags&DSCAPS_SECONDARY16BIT) && (soundoptions&SO_SECONDARY)))\r
-  {\r
-   FCEUD_PrintError("DirectSound: 16-bit sound is not supported.  Forcing 8-bit sound.");\r
-   bittage=0;\r
-   soundoptions|=SO_FORCE8BIT;\r
-  }\r
- }\r
-\r
- wf.wBitsPerSample=8<<bittage;\r
- wf.nBlockAlign = bittage+1;\r
- wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;\r
\r
- ddrval=IDirectSoundBuffer_SetFormat(ppbuf,&wf);\r
- if (ddrval != DS_OK)\r
- {\r
-  FCEUD_PrintError("DirectSound: Error setting primary buffer format.");\r
-  TrashSound();\r
-  return 0;\r
- }\r
-\r
- IDirectSoundBuffer_GetFormat(ppbuf,&wfa,sizeof(wfa),0);\r
-\r
- if(soundoptions&SO_SECONDARY)\r
- {\r
-  memset(&DSBufferDesc,0x00,sizeof(DSBUFFERDESC));  \r
-  DSBufferDesc.dwSize=sizeof(DSBufferDesc);\r
-  DSBufferDesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;\r
-  if(soundoptions&SO_GFOCUS)\r
-   DSBufferDesc.dwFlags|=DSBCAPS_GLOBALFOCUS;\r
-  DSBufferDesc.dwBufferBytes=32768;\r
-  DSBufferDesc.lpwfxFormat=&wfa;  \r
-  ddrval=IDirectSound_CreateSoundBuffer(ppDS, &DSBufferDesc, &ppbufsec, 0);\r
-  if (ddrval != DS_OK)\r
-  {\r
-   FCEUD_PrintError("DirectSound: Error creating secondary buffer.");\r
-   TrashSound();\r
-   return 0;\r
-  }\r
- }\r
-\r
- //sprintf(TempArray,"%d\n",wfa.nSamplesPerSec);\r
- //FCEUD_PrintError(TempArray);\r
-\r
- if(soundoptions&SO_SECONDARY)\r
- {\r
-  DSBufferSize=32768;\r
-  IDirectSoundBuffer_SetCurrentPosition(ppbufsec,0);\r
-  ppbufw=ppbufsec;\r
- }\r
- else\r
- {\r
-  memset(&dsbcaps,0,sizeof(dsbcaps));\r
-  dsbcaps.dwSize=sizeof(dsbcaps);\r
-  ddrval=IDirectSoundBuffer_GetCaps(ppbuf,&dsbcaps);\r
-  if (ddrval != DS_OK)\r
-  {\r
-   FCEUD_PrintError("DirectSound: Error getting buffer capabilities.");\r
-   TrashSound();\r
-   return 0;\r
-  }\r
-\r
-  DSBufferSize=dsbcaps.dwBufferBytes;\r
-\r
-  if(DSBufferSize<8192)\r
-  {\r
-   FCEUD_PrintError("DirectSound: Primary buffer size is too small!");\r
-   TrashSound();\r
-   return 0;\r
-  }\r
-  ppbufw=ppbuf;\r
- }\r
-\r
- soundbufsize=(soundbuftime*soundrate/1000);\r
- FCEUI_Sound(soundrate);\r
- return 1;\r
-}\r
-\r
-BOOL CALLBACK SoundConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  int x;\r
-\r
-  switch(uMsg) {\r
-   case WM_INITDIALOG:\r
-                if(soundo)\r
-                 CheckDlgButton(hwndDlg,126,BST_CHECKED);\r
-                if(soundoptions&SO_FORCE8BIT)\r
-                 CheckDlgButton(hwndDlg,122,BST_CHECKED);\r
-                if(soundoptions&SO_SECONDARY)\r
-                 CheckDlgButton(hwndDlg,123,BST_CHECKED);\r
-                if(soundoptions&SO_GFOCUS)\r
-                 CheckDlgButton(hwndDlg,124,BST_CHECKED);\r
-                SetDlgItemInt(hwndDlg,200,soundrate,0);\r
-\r
-                /* Volume Trackbar */\r
-                SendDlgItemMessage(hwndDlg,500,TBM_SETRANGE,1,MAKELONG(0,200));\r
-                SendDlgItemMessage(hwndDlg,500,TBM_SETTICFREQ,25,0);\r
-                SendDlgItemMessage(hwndDlg,500,TBM_SETPOS,1,200-soundvolume);\r
-\r
-                /* buffer size time trackbar */\r
-                SendDlgItemMessage(hwndDlg,128,TBM_SETRANGE,1,MAKELONG(15,200));\r
-                SendDlgItemMessage(hwndDlg,128,TBM_SETTICFREQ,1,0);\r
-                SendDlgItemMessage(hwndDlg,128,TBM_SETPOS,1,soundbuftime);\r
-\r
-                {\r
-                 char tbuf[8];\r
-                 sprintf(tbuf,"%d",soundbuftime);\r
-                 SetDlgItemText(hwndDlg,666,(LPTSTR)tbuf);\r
-                }\r
-                \r
-                SendDlgItemMessage(hwndDlg,129,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Mean");\r
-                SendDlgItemMessage(hwndDlg,129,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Nice");\r
-                SendDlgItemMessage(hwndDlg,129,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Nicest");\r
-                SendDlgItemMessage(hwndDlg,129,CB_SETCURSEL,soundsleep,(LPARAM)(LPSTR)0);\r
-                break;\r
-   case WM_HSCROLL:\r
-                // This doesn't seem to work.  Hmm...\r
-                //if((HWND)lParam==(HWND)128)\r
-                {\r
-                 char tbuf[8];\r
-                 soundbuftime=SendDlgItemMessage(hwndDlg,128,TBM_GETPOS,0,0);\r
-                 sprintf(tbuf,"%d",soundbuftime);\r
-                 SetDlgItemText(hwndDlg,666,(LPTSTR)tbuf);\r
-                }\r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 1:\r
-                        gornk:\r
-                        soundoptions=0;\r
-                        if(IsDlgButtonChecked(hwndDlg,122)==BST_CHECKED)\r
-                         soundoptions|=SO_FORCE8BIT;\r
-                        if(IsDlgButtonChecked(hwndDlg,123)==BST_CHECKED)\r
-                         soundoptions|=SO_SECONDARY;\r
-                        if(IsDlgButtonChecked(hwndDlg,124)==BST_CHECKED)\r
-                         soundoptions|=SO_GFOCUS;\r
-                        if(IsDlgButtonChecked(hwndDlg,126)==BST_CHECKED)\r
-                         soundo=1;\r
-                        else\r
-                         soundo=0;\r
-                        x=GetDlgItemInt(hwndDlg,200,0,0);\r
-                        if(x<8192 || x>65535)\r
-                        {\r
-                         FCEUD_PrintError("Sample rate is out of range(8192-65535).");\r
-                         break;\r
-                        }\r
-                        else\r
-                         soundrate=x;\r
-\r
-                        soundvolume=200-SendDlgItemMessage(hwndDlg,500,TBM_GETPOS,0,0);\r
-                        FCEUI_SetSoundVolume(soundvolume);\r
-                        soundsleep=SendDlgItemMessage(hwndDlg,129,CB_GETCURSEL,0,(LPARAM)(LPSTR)0);\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-               }\r
-              }\r
-  return 0;\r
-}\r
-\r
-\r
-void ConfigSound(void)\r
-{\r
- int backo=soundo,sr=soundrate;\r
- int so=soundoptions;\r
-\r
- DialogBox(fceu_hInstance,"SOUNDCONFIG",hAppWnd,SoundConCallB);\r
-\r
- if(((backo?1:0)!=(soundo?1:0)))\r
- {\r
-  if(!soundo)\r
-   TrashSound();\r
-  else\r
-   soundo=InitSound();\r
- }\r
- else if(( soundoptions!=so || (sr!=soundrate)) && soundo)\r
- {\r
-    TrashSound();\r
-    soundo=InitSound();\r
- }\r
- soundbufsize=(soundbuftime*soundrate/1000);\r
-}\r
-\r
-\r
-void StopSound(void)\r
-{\r
- if(soundo)\r
-  IDirectSoundBuffer_Stop(ppbufw);\r
-}\r
-\r
-#include "wave.c"\r
diff --git a/drivers/win/throttle.c b/drivers/win/throttle.c
deleted file mode 100644 (file)
index 1ccf271..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-static uint64 tmethod,tfreq;
-static uint64 desiredfps;
-
-static void RefreshThrottleFPS(void)
-{
- desiredfps=FCEUI_GetDesiredFPS()>>8;
-}
-
-static uint64 GetCurTime(void)
-{
- if(tmethod)
- {
-  uint64 tmp;
-
-  /* Practically, LARGE_INTEGER and uint64 differ only by signness and name. */
-  QueryPerformanceCounter((LARGE_INTEGER*)&tmp);
-
-  return(tmp);
- }
- else
-  return((uint64)GetTickCount());
-
-}
-
-static void InitSpeedThrottle(void)
-{
- tmethod=0;
- if(QueryPerformanceFrequency((LARGE_INTEGER*)&tfreq))
- {
-  tmethod=1;
- }
- else
-  tfreq=1000;
- tfreq<<=16;    /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */
-}
-
-
-static void SpeedThrottle(void)
-{
- static uint64 ttime,ltime;
-
- waiter:
-
- ttime=GetCurTime();
-
-                            
- if( (ttime-ltime) < (tfreq/desiredfps) )
-  goto waiter;
- if( (ttime-ltime) >= (tfreq*4/desiredfps))
-  ltime=ttime;
- else
-  ltime+=tfreq/desiredfps;
-}
diff --git a/drivers/win/video.c b/drivers/win/video.c
deleted file mode 100644 (file)
index a0438a0..0000000
+++ /dev/null
@@ -1,1174 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-static int RecalcCustom(void);
-
-#define VF_DDSTRETCHED     1
-
-#define VEF_LOSTSURFACE 1
-#define VEF____INTERNAL 2
-
-#define VMDF_DXBLT 1
-#define VMDF_STRFS 2
-
-typedef struct {
-        int x;
-        int y;
-        int bpp;
-        int flags;
-        int xscale;
-        int yscale;
-        RECT srect;
-        RECT drect;        
-} vmdef;
-
-// left, top, right, bottom
-static vmdef vmodes[11]={
-                         {320,240,8,0,1,1}, //0
-                         {320,240,8,0,1,1}, //1
-                         {512,384,8,0,1,1}, //2
-                         {640,480,8,0,1,1}, //3
-                         {640,480,8,0,1,1}, //4
-                         {640,480,8,0,1,1}, //5
-                         {640,480,8,VMDF_DXBLT,2,2}, //6
-                         {1024,768,8,VMDF_DXBLT,4,3}, //7
-                         {1280,1024,8,VMDF_DXBLT,5,4}, //8
-                         {1600,1200,8,VMDF_DXBLT,6,5}, //9
-                         {800,600,8,VMDF_DXBLT|VMDF_STRFS,0,0}    //10
-                       };
-static DDCAPS caps;
-static int mustrestore=0;
-static DWORD CBM[3];
-
-static int bpp;
-static int vflags;
-static int veflags;
-
-int fssync=0;
-int winsync=0;
-
-static uint32 *palettetranslate=0;
-
-PALETTEENTRY color_palette[256];
-static int PaletteChanged=0;
-
-LPDIRECTDRAWCLIPPER lpClipper=0;
-LPDIRECTDRAW  lpDD=0;
-LPDIRECTDRAW4 lpDD4=0;
-LPDIRECTDRAWPALETTE lpddpal;
-
-DDSURFACEDESC2 ddsd;
-
-DDSURFACEDESC2        ddsdback;
-LPDIRECTDRAWSURFACE4  lpDDSPrimary=0;
-LPDIRECTDRAWSURFACE4  lpDDSDBack=0;
-LPDIRECTDRAWSURFACE4  lpDDSBack=0;
-
-static void ShowDDErr(char *s)
-{
- char tempo[512];
- sprintf(tempo,"DirectDraw: %s",s);
- FCEUD_PrintError(tempo);
-}
-
-int RestoreDD(int w)
-{
- if(w)
-  {
-   if(!lpDDSBack) return 0;
-   if(IDirectDrawSurface4_Restore(lpDDSBack)!=DD_OK) return 0;
-  }
- else
-  {
-   if(!lpDDSPrimary) return 0;
-   if(IDirectDrawSurface4_Restore(lpDDSPrimary)!=DD_OK) return 0;
-  }
- veflags|=1;
- return 1;
-}
-
-void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g, unsigned char b)
-{
-        color_palette[index].peRed=r;
-        color_palette[index].peGreen=g;
-        color_palette[index].peBlue=b;
-        PaletteChanged=1;
-}
-
-void FCEUD_GetPalette(unsigned char i, unsigned char *r, unsigned char *g, unsigned char *b)
-{
-        *r=color_palette[i].peRed;
-        *g=color_palette[i].peGreen;
-        *b=color_palette[i].peBlue;
-}
-
-int InitializeDDraw(void)
-{
-        ddrval = DirectDrawCreate(NULL, &lpDD, NULL);
-        if (ddrval != DD_OK)
-        {
-         ShowDDErr("Error creating DirectDraw object.");
-         return 0;
-        }
-
-        ddrval = IDirectDraw_QueryInterface(lpDD,&IID_IDirectDraw4,(LPVOID *)&lpDD4);
-        IDirectDraw_Release(lpDD);
-
-        if (ddrval != DD_OK)
-        {
-         ShowDDErr("Error querying interface.");
-         return 0;
-        }
-
-        caps.dwSize=sizeof(caps);
-        if(IDirectDraw4_GetCaps(lpDD4,&caps,0)!=DD_OK)
-        {
-         ShowDDErr("Error getting capabilities.");
-         return 0;
-        }
-        return 1;
-}
-
-static int GetBPP(void)
-{
-        DDPIXELFORMAT ddpix;
-
-        memset(&ddpix,0,sizeof(ddpix));
-        ddpix.dwSize=sizeof(ddpix);
-
-        ddrval=IDirectDrawSurface4_GetPixelFormat(lpDDSPrimary,&ddpix);
-        if (ddrval != DD_OK)
-        {
-         ShowDDErr("Error getting primary surface pixel format.");
-         return 0;
-        }
-
-        if(ddpix.dwFlags&DDPF_RGB)
-        {
-         bpp=ddpix.DUMMYUNIONNAMEN(1).dwRGBBitCount;
-         CBM[0]=ddpix.DUMMYUNIONNAMEN(2).dwRBitMask;
-         CBM[1]=ddpix.DUMMYUNIONNAMEN(3).dwGBitMask;
-         CBM[2]=ddpix.DUMMYUNIONNAMEN(4).dwBBitMask;
-        }
-        else
-        {
-         ShowDDErr("RGB data not valid.");
-         return 0;
-        }
-        if(bpp==15) bpp=16;
-
-        return 1;
-}
-
-static int InitBPPStuff(void)
-{
-   if(bpp==16)
-    palettetranslate=malloc(65536*4);
-   else if(bpp>=24)
-    palettetranslate=malloc(256*4);
-   else if(bpp==8)
-   {
-    ddrval=IDirectDraw4_CreatePalette( lpDD4, DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_INITIALIZE,color_palette,&lpddpal,NULL);
-    if (ddrval != DD_OK)
-    {
-     ShowDDErr("Error creating palette object.");
-     return 0;
-    }
-    ddrval=IDirectDrawSurface4_SetPalette(lpDDSPrimary, lpddpal);
-    if (ddrval != DD_OK)
-    {
-     ShowDDErr("Error setting palette object.");
-     return 0;
-    }
-   }
-   return 1;
-}
-
-int SetVideoMode(int fs)
-{
-        if(!lpDD4)      // DirectDraw not initialized
-         return(1);
-
-        if(fs)
-         if(!vmod)
-          if(!RecalcCustom())
-           return(0);
-
-        vflags=0;
-        veflags=1;
-        PaletteChanged=1;
-
-        ResetVideo();
-
-        if(!fs)
-        { 
-         ShowCursorAbs(1);
-         windowedfailed=1;
-         HideFWindow(0);
-
-         ddrval = IDirectDraw4_SetCooperativeLevel ( lpDD4, hAppWnd, DDSCL_NORMAL);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error setting cooperative level.");
-          return 1;
-         }
-
-         /* Beginning */
-         memset(&ddsd,0,sizeof(ddsd));
-         ddsd.dwSize = sizeof(ddsd);
-         ddsd.dwFlags = DDSD_CAPS;
-         ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
-         ddrval = IDirectDraw4_CreateSurface ( lpDD4, &ddsd, &lpDDSPrimary,(IUnknown FAR*)NULL);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error creating primary surface.");
-          return 1;
-         }
-
-         memset(&ddsdback,0,sizeof(ddsdback));
-         ddsdback.dwSize=sizeof(ddsdback);
-         ddsdback.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
-         ddsdback.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN;
-
-         ddsdback.dwWidth=256;
-         ddsdback.dwHeight=240;
-
-         /* If no blit hardware is present, make sure buffer is created
-            in system memory.
-         */
-         if(!(caps.dwCaps&DDCAPS_BLT))
-          ddsdback.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY;
-        
-         ddrval = IDirectDraw4_CreateSurface ( lpDD4, &ddsdback, &lpDDSBack, (IUnknown FAR*)NULL);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error creating secondary surface.");
-          return 0;
-         }
-
-         if(!GetBPP())
-          return 0;
-
-         if(bpp!=16 && bpp!=24 && bpp!=32)
-         {
-          ShowDDErr("Current bit depth not supported!");
-          return 0;
-         }
-
-         if(!InitBPPStuff())
-          return 0;
-
-         ddrval=IDirectDraw4_CreateClipper(lpDD4,0,&lpClipper,0);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error creating clipper.");
-          return 0;
-         }
-
-         ddrval=IDirectDrawClipper_SetHWnd(lpClipper,0,hAppWnd);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error setting clipper window.");
-          return 0;
-         }
-         ddrval=IDirectDrawSurface4_SetClipper(lpDDSPrimary,lpClipper);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error attaching clipper to primary surface.");
-          return 0;
-         }
-
-         windowedfailed=0;
-         SetMainWindowStuff();
-        }
-        else
-        {
-         HideFWindow(1);
-
-         ddrval = IDirectDraw4_SetCooperativeLevel ( lpDD4, hAppWnd,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error setting cooperative level.");
-          return 0;
-         }
-
-         ddrval = IDirectDraw4_SetDisplayMode(lpDD4, vmodes[vmod].x, vmodes[vmod].y,vmodes[vmod].bpp,0,0);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error setting display mode.");
-          return 0;
-         }
-         if(vmodes[vmod].flags&VMDF_DXBLT)
-         {
-          memset(&ddsdback,0,sizeof(ddsdback));
-          ddsdback.dwSize=sizeof(ddsdback);
-          ddsdback.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
-          ddsdback.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN;
-
-          ddsdback.dwWidth=256; //vmodes[vmod].srect.right;
-          ddsdback.dwHeight=240; //vmodes[vmod].srect.bottom;
-
-          if(!(caps.dwCaps&DDCAPS_BLT))
-           ddsdback.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY;
-
-          ddrval = IDirectDraw4_CreateSurface ( lpDD4, &ddsdback, &lpDDSBack, (IUnknown FAR*)NULL);
-          if(ddrval!=DD_OK)
-          {
-           ShowDDErr("Error creating secondary surface.");
-           return 0;
-          }
-         }
-
-         // create foreground surface
-        
-         memset(&ddsd,0,sizeof(ddsd));
-         ddsd.dwSize = sizeof(ddsd);
-         ddsd.dwFlags = DDSD_CAPS;
-         ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
-         if(fssync==2) // Double buffering.
-         {
-          ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
-          ddsd.dwBackBufferCount = 1;
-          ddsd.ddsCaps.dwCaps |= DDSCAPS_COMPLEX | DDSCAPS_FLIP;
-         }
-
-         ddrval = IDirectDraw4_CreateSurface ( lpDD4, &ddsd, &lpDDSPrimary,(IUnknown FAR*)NULL);
-         if (ddrval != DD_OK)
-         {
-          ShowDDErr("Error creating primary surface.");
-          return 0;
-         } 
-
-         if(fssync==2)
-         {
-          DDSCAPS2 tmp;
-
-          memset(&tmp,0,sizeof(tmp));
-          tmp.dwCaps=DDSCAPS_BACKBUFFER;
-
-          if(IDirectDrawSurface4_GetAttachedSurface(lpDDSPrimary,&tmp,&lpDDSDBack)!=DD_OK)
-          {
-           ShowDDErr("Error getting attached surface.");
-           return 0;
-          }
-         }
-
-         if(!GetBPP())
-          return 0;
-         if(!InitBPPStuff())
-          return 0;
-
-         mustrestore=1;
-         ShowCursorAbs(0);
-        }
-
-        InputScreenChanged(fs);
-        fullscreen=fs;
-        return 1;
-}
-
-static void BlitScreenWindow(uint8 *XBuf);
-static void BlitScreenFull(uint8 *XBuf);
-
-void FCEUD_BlitScreen(uint8 *XBuf)
-{
- doagain:
-
- UpdateFCEUWindow();
-
- if(!(eoptions&EO_BGRUN))
-  while(nofocus)
-  {
-   Sleep(50);
-   BlockingCheck();
-  }
-
-
- /* This complex statement deserves some explanation.
-    Make sure this special speed throttling hasn't been disabled by the user
-    first. Second, we don't want to throttle the speed if the fast-forward
-    button is pressed down(or during certain network play conditions).
-       
-    Now, if we're at this point, we'll throttle speed if sound is disabled.
-    Otherwise, it gets a bit more complicated.  We'll throttle speed if focus
-    to FCE Ultra has been lost and we're writing to the primary sound buffer
-    because our sound code won't block.  Blocking does seem to work when
-    writing to a secondary buffer, so we won't throttle when a secondary
-    buffer is used.
- */
-
- if(!(eoptions&EO_NOTHROTTLE))
-  if(!NoWaiting)
-   if(!soundo || (soundo && nofocus && !(soundoptions&SO_SECONDARY)) )
-       SpeedThrottle();
-
- if(fullscreen)
- {
-  if(fssync==1 && !NoWaiting)
-   IDirectDraw4_WaitForVerticalBlank(lpDD4,DDWAITVB_BLOCKBEGIN,0);
-
-  BlitScreenFull(XBuf);
- }
- else
- {
-  if(winsync && !NoWaiting)
-   IDirectDraw4_WaitForVerticalBlank(lpDD4,DDWAITVB_BLOCKBEGIN,0);
-
-  if(!windowedfailed)
-   BlitScreenWindow(XBuf);
- }
- if(userpause)
- {
-  StopSound();
-  Sleep(50);
-  BlockingCheck();
-  goto doagain;
- }
-}
-
-static INLINE void BlitVidHi(uint8 *src, uint8 *dest, /*int xr,*/ int yr, int pitch)
-{
- int x,y;
- int pinc;
-
- if(!(eoptions&EO_CLIPSIDES))
-  switch(bpp)
-  {
-   case 32:
-
-   pinc=pitch-(256<<2);
-   for(y=yr;y;y--)
-   {
-    for(x=256;x;x--)
-    {
-     *(uint32 *)dest=palettetranslate[(uint32)*src];     
-     dest+=4;
-     src++;
-    }
-    dest+=pinc;
-    src+=16;
-   }
-   break;
-
-  case 24:
-   pinc=pitch-(256*3);
-   for(y=yr;y;y--)
-   {
-    for(x=256;x;x--)
-    {
-     uint32 tmp;
-     tmp=palettetranslate[(uint32)*src];
-     *(uint16*)dest=(uint16)tmp;
-     *&dest[2]=(uint8)(tmp>>16);
-     dest+=3;
-     src++;
-    }
-    dest+=pinc;
-    src+=16;
-   }
-   break;
-
-  case 16:
-   pinc=pitch-(256<<1);
-   for(y=yr;y;y--)
-   {
-    for(x=256>>1;x;x--)
-    {
-     *(unsigned long *)dest=palettetranslate[*(unsigned short *)src];
-     dest+=4;
-     src+=2;
-    }
-    dest+=pinc;
-    src+=16;
-   }
-   break;
- }
- else
-  switch(bpp)
-  {
-   case 32:
-
-   pinc=pitch-(240<<2);
-   for(y=yr;y;y--)
-   {
-    for(x=240;x;x--)
-    {
-     *(uint32 *)dest=palettetranslate[(uint32)*src];
-     dest+=4;
-     src++;
-    }
-    dest+=pinc;
-    src+=32;
-   }
-   break;
-
-  case 24:
-   pinc=pitch-(240*3);
-   for(y=yr;y;y--)
-   {
-    for(x=240;x;x--)
-    {
-     uint32 tmp;
-     tmp=palettetranslate[(uint32)*src];
-     *(uint16*)dest=(uint16)tmp;
-     *&dest[2]=(uint8)(tmp>>16);
-     dest+=3;
-     src++;
-    }
-    dest+=pinc;
-    src+=32;
-   }
-   break;
-  case 16:
-   pinc=pitch-(240<<1);
-   for(y=yr;y;y--)
-   {
-    for(x=240>>1;x;x--)
-    {
-     *(unsigned long *)dest=palettetranslate[*(unsigned short *)src];
-     dest+=4;
-     src+=2;
-    }
-    dest+=pinc;
-    src+=32;
-   }
-   break;
- }
-}
-
-static INLINE void FixPaletteHi(void)
-{
-   int x;
-
-   switch(bpp)
-   {
-    case 16:{
-             int cshiftr[3];
-             int cshiftl[3];
-             int a,x,z,y;
-        
-             cshiftl[0]=cshiftl[1]=cshiftl[2]=-1;
-             for(a=0;a<3;a++)
-             {
-              for(x=0,y=-1,z=0;x<16;x++)
-              {
-               if(CBM[a]&(1<<x))
-               {
-                if(cshiftl[a]==-1) cshiftl[a]=x;
-                z++;
-               }
-              }
-              cshiftr[a]=(8-z);
-             }
-
-             for(x=0;x<65536;x++)
-             { 
-              uint16 lower,upper;   
-              lower=(color_palette[x&255].peRed>>cshiftr[0])<<cshiftl[0];
-              lower|=(color_palette[x&255].peGreen>>cshiftr[1])<<cshiftl[1];
-              lower|=(color_palette[x&255].peBlue>>cshiftr[2])<<cshiftl[2];
-              upper=(color_palette[x>>8].peRed>>cshiftr[0])<<cshiftl[0];
-              upper|=(color_palette[x>>8].peGreen>>cshiftr[1])<<cshiftl[1];
-              upper|=(color_palette[x>>8].peBlue>>cshiftr[2])<<cshiftl[2];      
-              palettetranslate[x]=lower|(upper<<16);
-             }
-            }
-            break;
-    case 24:
-    case 32:
-            for(x=0;x<256;x++)
-            {
-             uint32 t;
-             t=0;
-             t=color_palette[x].peBlue;
-             t|=color_palette[x].peGreen<<8;
-             t|=color_palette[x].peRed<<16;
-             palettetranslate[x]=t;
-            }
-            break;
-   }
-}
-
-static void BlitScreenWindow(unsigned char *XBuf)
-{
- int pitch;
- unsigned char *ScreenLoc;
- static RECT srect;
- RECT drect;
-
- srect.top=srect.left=0;
- srect.right=VNSWID;
- srect.bottom=totallines;
-
- if(PaletteChanged==1)
- {
-  FixPaletteHi();
-  PaletteChanged=0;
- }
- if(!GetClientAbsRect(&drect)) return;
-
- ddrval=IDirectDrawSurface4_Lock(lpDDSBack,NULL,&ddsdback, 0, NULL);
- if(ddrval!=DD_OK)
- {
-  if(ddrval==DDERR_SURFACELOST) RestoreDD(1);
-  return;
- }
- pitch=ddsdback.DUMMYUNIONNAMEN(1).lPitch;
- ScreenLoc=ddsdback.lpSurface;
-
- if(veflags&1)
- {
-  memset(ScreenLoc,0,pitch*240);
-  veflags&=~1;
- }
-
- BlitVidHi(XBuf+srendline*272+VNSCLIP, ScreenLoc, /*VNSWID,*/ totallines, pitch);
-
- IDirectDrawSurface4_Unlock(lpDDSBack, NULL);
-
- if(IDirectDrawSurface4_Blt(lpDDSPrimary, &drect,lpDDSBack,&srect,DDBLT_ASYNC,0)!=DD_OK)
- {
-  ddrval=IDirectDrawSurface4_Blt(lpDDSPrimary, &drect,lpDDSBack,&srect,DDBLT_WAIT,0);
-  if(ddrval!=DD_OK)
-  {
-   if(ddrval==DDERR_SURFACELOST) {RestoreDD(1);RestoreDD(0);}
-   return;
-  }
- }
-}
-
-static void BlitScreenFull(uint8 *XBuf)
-{
-  static int pitch;
-  char *ScreenLoc;
-  unsigned long x;
-  uint8 y;
-  RECT srect,drect;
-  LPDIRECTDRAWSURFACE4 lpDDSVPrimary;
-
-
-  if(fssync==2)
-   lpDDSVPrimary=lpDDSDBack;
-  else
-   lpDDSVPrimary=lpDDSPrimary;
-
-  if(PaletteChanged==1)
-  {
-   if(bpp>=16)
-    FixPaletteHi();
-   else
-    for(x=0;x<=0x80;x+=0x80)
-    {
-     ddrval=IDirectDrawPalette_SetEntries(lpddpal,0,0x80^x,128,&color_palette[x]);
-     if(ddrval!=DD_OK)
-     {
-      if(ddrval==DDERR_SURFACELOST) RestoreDD(0);
-      return;
-     }
-    }
-   PaletteChanged=0;
-  }
-
- if(vmodes[vmod].flags&VMDF_DXBLT)
- {
-  ddrval=IDirectDrawSurface4_Lock(lpDDSBack,NULL,&ddsdback, 0, NULL);
-  if(ddrval!=DD_OK)
-  {
-   if(ddrval==DDERR_SURFACELOST) RestoreDD(1);
-   return;
-  }
-  ScreenLoc=ddsdback.lpSurface;
-  pitch=ddsdback.DUMMYUNIONNAMEN(1).lPitch;
-
-  srect.top=0;
-  srect.left=0;
-  srect.right=VNSWID;
-  srect.bottom=totallines;
-  if(vmodes[vmod].flags&VMDF_STRFS)
-  {
-   drect.top=0;
-   drect.left=0;
-   drect.right=vmodes[vmod].x;
-   drect.bottom=vmodes[vmod].y;
-  }
-  else
-  {
-   drect.top=(vmodes[vmod].y-(totallines*vmodes[vmod].yscale))>>1;
-   drect.bottom=drect.top+(totallines*vmodes[vmod].yscale);
-   drect.left=(vmodes[vmod].x-VNSWID*vmodes[vmod].xscale)>>1;
-   drect.right=drect.left+VNSWID*vmodes[vmod].xscale;
-  }
- }
- else
- {
-  ddrval=IDirectDrawSurface4_Lock(lpDDSVPrimary,NULL,&ddsd, 0, NULL);
-  if(ddrval!=DD_OK)
-  {
-   if(ddrval==DDERR_SURFACELOST) RestoreDD(0);
-   return;
-  }
-
-  ScreenLoc=ddsd.lpSurface;
-  pitch=ddsd.DUMMYUNIONNAMEN(1).lPitch;
- }
-
- if(veflags&1)
- {
-  if(vmodes[vmod].flags&VMDF_DXBLT)
-  {
-   veflags|=2;
-   memset((char *)ScreenLoc,0,pitch*srect.bottom);
-  }
-  else
-  {
-   memset((char *)ScreenLoc,0,pitch*vmodes[vmod].y);
-  }
-  PaletteChanged=1;
-  veflags&=~1;
- }
-
- if(vmod==5)
- {
-  if(eoptions&EO_CLIPSIDES)
-  {
-   asm volatile(
-      "xorl %%edx, %%edx\n\t"
-      "akoop1:\n\t"
-      "movb $120,%%al     \n\t"
-      "akoop2:\n\t"
-      "movb 1(%%esi),%%dl\n\t"
-      "shl  $16,%%edx\n\t"
-      "movb (%%esi),%%dl\n\t"
-      "xorl $0x00800080,%%edx\n\t"
-      "movl %%edx,(%%edi)\n\t"
-      "addl $2,%%esi\n\t"
-      "addl $4,%%edi\n\t"
-      "decb %%al\n\t"
-      "jne akoop2\n\t"
-      "addl $32,%%esi\n\t"
-      "addl %%ecx,%%edi\n\t"
-      "decb %%bl\n\t"
-      "jne akoop1\n\t"
-      :
-      : "S" (XBuf+srendline*272+VNSCLIP), "D" (ScreenLoc+((240-totallines)/2)*pitch+(640-(VNSWID<<1))/2),"b" (totallines), "c" ((pitch-VNSWID)<<1)
-      : "%al", "%edx", "%cc" );
-  }
-  else
-  {
-   asm volatile(
-     "xorl %%edx, %%edx\n\t"
-     "koop1:\n\t"
-     "movb $128,%%al     \n\t"
-     "koop2:\n\t"
-     "movb 1(%%esi),%%dl\n\t"
-     "shl  $16,%%edx\n\t"
-     "movb (%%esi),%%dl\n\t"
-     "xorl $0x00800080,%%edx\n\t"
-     "movl %%edx,(%%edi)\n\t"
-     "addl $2,%%esi\n\t"
-     "addl $4,%%edi\n\t"
-     "decb %%al\n\t"
-     "jne koop2\n\t"
-     "addl $16,%%esi\n\t"
-     "addl %%ecx,%%edi\n\t"
-     "decb %%bl\n\t"
-     "jne koop1\n\t"
-      :
-      : "S" (XBuf+srendline*272), "D" (ScreenLoc+((240-totallines)/2)*pitch+(640-512)/2),"b" (totallines), "c" (pitch-512+pitch)
-      : "%al", "%edx", "%cc" );
-  }
- }
- else if(vmod==4)
- {
-  if(eoptions&EO_CLIPSIDES)
-  {
-   asm volatile(
-      "ayoop1:\n\t"
-      "movb $120,%%al     \n\t"
-      "ayoop2:\n\t"
-      "movb 1(%%esi),%%dh\n\t"
-      "movb %%dh,%%dl\n\t"
-      "shl  $16,%%edx\n\t"
-      "movb (%%esi),%%dl\n\t"
-      "movb %%dl,%%dh\n\t"               // Ugh
-      "xorl $0x80808080,%%edx\n\t"
-      "movl %%edx,(%%edi)\n\t"
-      "addl $2,%%esi\n\t"
-      "addl $4,%%edi\n\t"
-      "decb %%al\n\t"
-      "jne ayoop2\n\t"
-      "addl $32,%%esi\n\t"
-      "addl %%ecx,%%edi\n\t"
-      "decb %%bl\n\t"
-      "jne ayoop1\n\t"
-      :
-      : "S" (XBuf+srendline*272+VNSCLIP), "D" (ScreenLoc+((240-totallines)/2)*pitch+(640-(VNSWID<<1))/2),"b" (totallines), "c" ((pitch-VNSWID)<<1)
-      : "%al", "%edx", "%cc" );
-  }
-  else
-  {
-   asm volatile(
-      "yoop1:\n\t"
-      "movb $128,%%al     \n\t"
-      "yoop2:\n\t"
-      "movb 1(%%esi),%%dh\n\t"
-      "movb %%dh,%%dl\n\t"
-      "shl  $16,%%edx\n\t"
-      "movb (%%esi),%%dl\n\t"
-      "movb %%dl,%%dh\n\t"               // Ugh
-      "xorl $0x80808080,%%edx\n\t"
-      "movl %%edx,(%%edi)\n\t"
-      "addl $2,%%esi\n\t"
-      "addl $4,%%edi\n\t"
-      "decb %%al\n\t"
-      "jne yoop2\n\t"
-      "addl $16,%%esi\n\t"
-      "addl %%ecx,%%edi\n\t"
-      "decb %%bl\n\t"
-      "jne yoop1\n\t"
-      :
-      : "S" (XBuf+srendline*272), "D" (ScreenLoc+((240-totallines)/2)*pitch+(640-512)/2),"b" (totallines), "c" (pitch-512+pitch)
-      : "%al", "%edx", "%cc" );
-  }
- }
- else
- {
-  if(!(vmodes[vmod].flags&VMDF_DXBLT))
-  {  
-   ScreenLoc+=((vmodes[vmod].x-VNSWID)>>1)*(bpp>>3)+(((vmodes[vmod].y-totallines)>>1))*pitch;
-  }
-  if(bpp>=16)
-  {
-   BlitVidHi(XBuf+srendline*272+VNSCLIP, ScreenLoc, /*VNSWID,*/ totallines, pitch);
-  }
-  else
-  {
-   XBuf+=srendline*272+VNSCLIP;
-   if(eoptions&EO_CLIPSIDES)
-   {
-    for(y=totallines;y;y--)
-    {
-     for(x=60;x;x--)
-     {
-      *(long *)ScreenLoc=(*(long *)XBuf)^0x80808080;
-      ScreenLoc+=4;
-      XBuf+=4;
-     }
-     ScreenLoc+=pitch-240;
-     XBuf+=32;
-    }
-   }
-   else
-   {
-    for(y=totallines;y;y--)
-    {
-     for(x=64;x;x--)
-     {
-      *(long *)ScreenLoc=(*(long *)XBuf)^0x80808080;
-      ScreenLoc+=4;
-      XBuf+=4;
-     }
-     ScreenLoc+=pitch-256;
-     XBuf+=16;
-    }
-   }
-  }
- }
-
- if(vmodes[vmod].flags&VMDF_DXBLT)
- { 
-  IDirectDrawSurface4_Unlock(lpDDSBack, NULL);
-
-  if(veflags&2)
-  {
-   if(IDirectDrawSurface4_Lock(lpDDSVPrimary,NULL,&ddsd, 0, NULL)==DD_OK)
-   {
-    memset(ddsd.lpSurface,0,ddsd.DUMMYUNIONNAMEN(1).lPitch*vmodes[vmod].y);
-    IDirectDrawSurface4_Unlock(lpDDSVPrimary, NULL);
-    veflags&=~2;
-   }
-  }
-
-  if(IDirectDrawSurface4_Blt(lpDDSVPrimary, &drect,lpDDSBack,&srect,DDBLT_ASYNC,0)!=DD_OK)
-  {
-   ddrval=IDirectDrawSurface4_Blt(lpDDSVPrimary, &drect,lpDDSBack,&srect,DDBLT_WAIT,0);
-   if(ddrval!=DD_OK)
-   {
-    if(ddrval==DDERR_SURFACELOST)
-    {
-     RestoreDD(0);
-     RestoreDD(1);
-    }
-    return;
-   }
-
-  }
- }
- else
-  IDirectDrawSurface4_Unlock(lpDDSVPrimary, NULL);
- if(fssync==2)
- {
-  IDirectDrawSurface4_Flip(lpDDSPrimary,0,0);
-
- }
-}
-
-void ResetVideo(void)
-{
- ShowCursorAbs(1);
- if(palettetranslate) {free(palettetranslate);palettetranslate=0;}
- if(lpDD4)
-  if(mustrestore)
-   {IDirectDraw4_RestoreDisplayMode(lpDD4);mustrestore=0;}
- if(lpDDSBack) {IDirectDrawSurface4_Release(lpDDSBack);lpDDSBack=0;}
- if(lpDDSPrimary) {IDirectDrawSurface4_Release(lpDDSPrimary);lpDDSPrimary=0;} 
- if(lpClipper) {IDirectDrawClipper_Release(lpClipper);lpClipper=0;}
-}
-
-static int RecalcCustom(void)
-{
- vmodes[0].flags&=~VMDF_DXBLT;
-
- if(vmodes[0].flags&VMDF_STRFS)
- {
-  vmodes[0].flags|=VMDF_DXBLT;
-
-  vmodes[0].srect.top=srendline;
-  vmodes[0].srect.left=VNSCLIP;
-  vmodes[0].srect.right=256-VNSCLIP;
-  vmodes[0].srect.bottom=erendline+1;
-
-  vmodes[0].drect.top=vmodes[0].drect.left=0;
-  vmodes[0].drect.right=vmodes[0].x;
-  vmodes[0].drect.bottom=vmodes[0].y;
- }
- else if(vmodes[0].xscale!=1 || vmodes[0].yscale!=1)
- {
-  vmodes[0].flags|=VMDF_DXBLT;
-  if(VNSWID*vmodes[0].xscale>vmodes[0].x)
-  {
-   FCEUD_PrintError("Scaled width is out of range.  Reverting to no horizontal scaling.");
-   vmodes[0].xscale=1;
-  }
-  if(totallines*vmodes[0].yscale>vmodes[0].y)
-  {
-   FCEUD_PrintError("Scaled height is out of range.  Reverting to no vertical scaling.");
-   vmodes[0].yscale=1;
-  }
-
-  vmodes[0].srect.left=VNSCLIP;
-  vmodes[0].srect.top=srendline;
-  vmodes[0].srect.right=256-VNSCLIP;
-  vmodes[0].srect.bottom=erendline+1;
-
-  vmodes[0].drect.top=(vmodes[0].y-(totallines*vmodes[0].yscale))>>1;
-  vmodes[0].drect.bottom=vmodes[0].drect.top+totallines*vmodes[0].yscale;
-  
-  vmodes[0].drect.left=(vmodes[0].x-(VNSWID*vmodes[0].xscale))>>1;
-  vmodes[0].drect.right=vmodes[0].drect.left+VNSWID*vmodes[0].xscale;
- }
-
- if(vmodes[0].x<VNSWID)
- {
-  FCEUD_PrintError("Horizontal resolution is too low.");
-  return(0);
- }
- if(vmodes[0].y<totallines && !(vmodes[0].flags&VMDF_STRFS))
- {
-  FCEUD_PrintError("Vertical resolution must not be less than the total number of drawn scanlines.");
-  return(0);
- }
-
- return(1);
-}
-
-BOOL CALLBACK VideoConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-        static char *vmstr[11]={
-                                "Custom",
-                                "320x240 Full Screen",
-                                "512x384 Centered",
-                                "640x480 Centered",
-                                "640x480 Scanlines",
-                                "640x480 \"4 per 1\"",
-                                "640x480 2x,2y",
-                                "1024x768 4x,3y",
-                                "1280x1024 5x,4y",
-                                "1600x1200 6x,5y",
-                                "800x600 Stretched"
-                               };
-        int x;
-
-        switch(uMsg)
-        {
-         case WM_INITDIALOG:                
-                for(x=0;x<11;x++)
-                 SendDlgItemMessage(hwndDlg,100,CB_ADDSTRING,0,(LPARAM)(LPSTR)vmstr[x]);
-                SendDlgItemMessage(hwndDlg,100,CB_SETCURSEL,vmod,(LPARAM)(LPSTR)0);
-
-                SendDlgItemMessage(hwndDlg,202,CB_ADDSTRING,0,(LPARAM)(LPSTR)"8");
-                SendDlgItemMessage(hwndDlg,202,CB_ADDSTRING,0,(LPARAM)(LPSTR)"16");
-                SendDlgItemMessage(hwndDlg,202,CB_ADDSTRING,0,(LPARAM)(LPSTR)"24");
-                SendDlgItemMessage(hwndDlg,202,CB_ADDSTRING,0,(LPARAM)(LPSTR)"32");
-                SendDlgItemMessage(hwndDlg,202,CB_SETCURSEL,(vmodes[0].bpp>>3)-1,(LPARAM)(LPSTR)0);
-
-                SetDlgItemInt(hwndDlg,200,vmodes[0].x,0);
-                SetDlgItemInt(hwndDlg,201,vmodes[0].y,0);
-
-                SetDlgItemInt(hwndDlg,302,vmodes[0].xscale,0);
-                SetDlgItemInt(hwndDlg,303,vmodes[0].yscale,0);
-                CheckRadioButton(hwndDlg,300,301,(vmodes[0].flags&VMDF_STRFS)?301:300);
-                if(eoptions&EO_FSAFTERLOAD)
-                 CheckDlgButton(hwndDlg,102,BST_CHECKED);
-
-                if(eoptions&EO_CLIPSIDES)
-                 CheckDlgButton(hwndDlg,106,BST_CHECKED);
-
-                SetDlgItemInt(hwndDlg,500,srendlinen,0);
-                SetDlgItemInt(hwndDlg,501,erendlinen,0);
-
-                SetDlgItemInt(hwndDlg,502,srendlinep,0);
-                SetDlgItemInt(hwndDlg,503,erendlinep,0);
-
-
-                SetDlgItemInt(hwndDlg,103,winsizemul,0);
-
-                SendDlgItemMessage(hwndDlg,104,CB_ADDSTRING,0,(LPARAM)(LPSTR)"<none>");
-                SendDlgItemMessage(hwndDlg,105,CB_ADDSTRING,0,(LPARAM)(LPSTR)"<none>");
-
-                SendDlgItemMessage(hwndDlg,104,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Wait for VBlank");
-                SendDlgItemMessage(hwndDlg,105,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Wait for VBlank");
-
-                SendDlgItemMessage(hwndDlg,105,CB_ADDSTRING,0,(LPARAM)(LPSTR)"Double Buffering");
-
-                SendDlgItemMessage(hwndDlg,104,CB_SETCURSEL,winsync,(LPARAM)(LPSTR)0);
-                SendDlgItemMessage(hwndDlg,105,CB_SETCURSEL,fssync,(LPARAM)(LPSTR)0);
-                break;
-         case WM_CLOSE:
-         case WM_QUIT: goto gornk;
-         case WM_COMMAND:
-                        if(!(wParam>>16))
-                        switch(wParam&0xFFFF)
-                        {
-                         case 1:
-                         gornk:
-         
-                         if(IsDlgButtonChecked(hwndDlg,106)==BST_CHECKED)
-                          eoptions|=EO_CLIPSIDES;
-                         else
-                          eoptions&=~EO_CLIPSIDES;
-
-                         srendlinen=GetDlgItemInt(hwndDlg,500,0,0);
-                         erendlinen=GetDlgItemInt(hwndDlg,501,0,0);
-                         srendlinep=GetDlgItemInt(hwndDlg,502,0,0);
-                         erendlinep=GetDlgItemInt(hwndDlg,503,0,0);
-
-
-                         if(erendlinen>239) erendlinen=239;
-                         if(srendlinen>erendlinen) srendlinen=erendlinen;
-
-                         if(erendlinep>239) erendlinep=239;
-                         if(srendlinep>erendlinen) srendlinep=erendlinep;
-
-                         UpdateRendBounds();
-
-                         if(IsDlgButtonChecked(hwndDlg,301)==BST_CHECKED)
-                          vmodes[0].flags|=VMDF_STRFS;
-                         else
-                          vmodes[0].flags&=~VMDF_STRFS;
-
-                         vmod=SendDlgItemMessage(hwndDlg,100,CB_GETCURSEL,0,(LPARAM)(LPSTR)0);
-                         vmodes[0].x=GetDlgItemInt(hwndDlg,200,0,0);
-                         vmodes[0].y=GetDlgItemInt(hwndDlg,201,0,0);
-                         vmodes[0].bpp=(SendDlgItemMessage(hwndDlg,202,CB_GETCURSEL,0,(LPARAM)(LPSTR)0)+1)<<3;
-
-                         vmodes[0].xscale=GetDlgItemInt(hwndDlg,302,0,0);
-                         vmodes[0].yscale=GetDlgItemInt(hwndDlg,303,0,0);
-        
-                         if(IsDlgButtonChecked(hwndDlg,101)==BST_CHECKED)
-                          fullscreen=1;
-                         else
-                          fullscreen=0;
-                         if(IsDlgButtonChecked(hwndDlg,102)==BST_CHECKED)
-                          eoptions|=EO_FSAFTERLOAD;
-                         else
-                          eoptions&=~EO_FSAFTERLOAD;
-
-                         {
-                          int t=GetDlgItemInt(hwndDlg,103,0,0);
-                          if(t>0 && t<60)
-                           winsizemul=t;
-                         }
-                         winsync=SendDlgItemMessage(hwndDlg,104,CB_GETCURSEL,0,(LPARAM)(LPSTR)0);
-                         fssync=SendDlgItemMessage(hwndDlg,105,CB_GETCURSEL,0,(LPARAM)(LPSTR)0);
-                         EndDialog(hwndDlg,0);
-                         break;
-               }
-              }
-  return 0;
-}
-
-static void SetFSVideoMode(void)
-{
- changerecursive=1;
- if(!SetVideoMode(1))
-  SetVideoMode(0);
- changerecursive=0;
-}
-
-
-
-void ConfigVideo(void)
-{
-        DialogBox(fceu_hInstance,"VIDEOCONFIG",hAppWnd,VideoConCallB); 
-        UpdateRendBounds();
-        if(fullscreen)
-         SetFSVideoMode();
-        else
-         SetMainWindowStuff();
-}
-
-void DoVideoConfigFix(void)
-{
-        UpdateRendBounds();
-}
-
-
-#ifdef moo
-                         if(!vmod)
-                         {
-                          if(vmodes[0].x<VNSWID)
-                          {
-                           FCEUD_PrintError("Horizontal resolution is too low.");
-                           return 0;
-                          }
-                          if(vmodes[0].y<totallines && !(vmodes[0].flags&VMDF_STRFS))
-                          {
-                           FCEUD_PrintError("Vertical resolution must not be less than the total number of drawn scanlines.");
-                           return 0;
-                          }
-                         }
-
-
-#endif
diff --git a/drivers/win/wave.c b/drivers/win/wave.c
deleted file mode 100644 (file)
index 70ac49c..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Ben Parnell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-static int16 MoBuffer[2048];
-static int wsize;
-void WriteWaveData(int32 *Buffer, int Count)
-{
-  int P;
-
-  for(P=0;P<Count;P++)
-   MoBuffer[P]=Buffer[P];
-  wsize+=fwrite(MoBuffer,1,Count<<1,soundlog);
-}
-
-static int CloseWave(void)
-{
- int s;
-
- if(!soundlog) return 0;
- s=ftell(soundlog)-8;
- fseek(soundlog,4,SEEK_SET);
- fputc(s&0xFF,soundlog);
- fputc((s>>8)&0xFF,soundlog);
- fputc((s>>16)&0xFF,soundlog);
- fputc((s>>24)&0xFF,soundlog);
-
- fseek(soundlog,0x28,SEEK_SET);
- s=wsize;
- fputc(s&0xFF,soundlog);
- fputc((s>>8)&0xFF,soundlog);
- fputc((s>>16)&0xFF,soundlog);
- fputc((s>>24)&0xFF,soundlog);
-
- fclose(soundlog);
- soundlog=0;
- return 1;
-}
-int WriteWaveHeader(FILE *fp)
-{
- int r;
- fputs("RIFF",fp);
- fseek(fp,4,SEEK_CUR);  // Skip size
- fputs("WAVEfmt ",fp);
- fputc(0x10,fp);
- fputc(0,fp);
- fputc(0,fp);
- fputc(0,fp);
-
- fputc(1,fp);           // PCM
- fputc(0,fp);
- fputc(1,fp);           // Monophonic
- fputc(0,fp);
-
- r=44100;
- fputc(r&0xFF,fp);
- fputc((r>>8)&0xFF,fp);
- fputc((r>>16)&0xFF,fp);
- fputc((r>>24)&0xFF,fp);
- r<<=1;
- fputc(r&0xFF,fp);
- fputc((r>>8)&0xFF,fp);
- fputc((r>>16)&0xFF,fp);
- fputc((r>>24)&0xFF,fp);
- fputc(2,fp);
- fputc(0,fp);
- fputc(16,fp);
- fputc(0,fp);
-
- fputs("data",fp);
- fseek(fp,4,SEEK_CUR);
-
- return 1;
-}
-
-int StartSoundLog(char *str)
-{
-  wsize=0;
-  soundlog=fopen(str,"wb");
-  if(soundlog)
-   return WriteWaveHeader(soundlog);
-  else
-   return 0;
-}
-int CreateSoundSave(void)
-{
- const char filter[]="MS WAVE(*.wav)\0*.wav\0";
- char nameo[2048];
- OPENFILENAME ofn;
-
- if(soundlog)
-  {
-   CloseWave();
-   return 0;
-  }
-
- memset(&ofn,0,sizeof(ofn));
- ofn.lStructSize=sizeof(ofn);
- ofn.hInstance=fceu_hInstance;
- ofn.lpstrTitle="Log Sound As...";
- ofn.lpstrFilter=filter;
- nameo[0]=0;
- ofn.lpstrFile=nameo;
- ofn.nMaxFile=256;
- ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
- if(GetSaveFileName(&ofn))
-  return StartSoundLog(nameo);
- return 0;
-}
diff --git a/drivers/win/window.c b/drivers/win/window.c
deleted file mode 100644 (file)
index 6ccd4e0..0000000
+++ /dev/null
@@ -1,855 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator\r
- *\r
- * Copyright notice for this file:\r
- *  Copyright (C) 2002 Ben Parnell\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
- */\r
-\r
-static void ConfigMisc(void);\r
-static void ConfigPalette(void);\r
-static void ConfigDirectories(void);\r
-\r
-static HMENU fceumenu=0;\r
-static HMENU recentmenu;\r
-\r
-static int tog=0;\r
-\r
-void ShowCursorAbs(int w)\r
-{\r
- static int stat=0;\r
- if(w)\r
- {\r
-  if(stat==-1) {stat++; ShowCursor(1);}\r
- }\r
- else\r
- {\r
-  if(stat==0) {stat--; ShowCursor(0);}\r
- }\r
-}\r
-\r
-\r
-RECT *CalcWindowSize(void)\r
-{\r
- static RECT al;\r
- al.left=0;\r
- al.right=VNSWID*winsizemul;\r
- al.top=0;\r
- al.bottom=totallines*winsizemul;\r
-\r
- AdjustWindowRectEx(&al,GetWindowLong(hAppWnd,GWL_STYLE),GetMenu(hAppWnd)!=NULL,GetWindowLong(hAppWnd,GWL_EXSTYLE));\r
-\r
- al.right-=al.left;\r
- al.left=0;\r
- al.bottom-=al.top;\r
- al.top=0;\r
-\r
- return(&al);\r
-}\r
-\r
-void UpdateMenu(void)\r
-{\r
- static int *polo[2]={&genie,&palyo};\r
- static int polo2[2]={310,311};\r
- int x;\r
-\r
- for(x=0;x<2;x++)\r
-  CheckMenuItem(fceumenu,polo2[x],*polo[x]?MF_CHECKED:MF_UNCHECKED);\r
- if(eoptions&EO_BGRUN)\r
-  CheckMenuItem(fceumenu,301,MF_CHECKED);\r
- else\r
-  CheckMenuItem(fceumenu,301,MF_UNCHECKED);\r
-}\r
-\r
-char *rfiles[10]={0,0,0,0,0,0,0,0,0,0};\r
-\r
-void UpdateRMenu(void)\r
-{\r
- MENUITEMINFO moo;\r
- int x;\r
-\r
- moo.cbSize=sizeof(moo);\r
- moo.fMask=MIIM_SUBMENU|MIIM_STATE;\r
-\r
- GetMenuItemInfo(GetSubMenu(fceumenu,0),102,FALSE,&moo);\r
- moo.hSubMenu=recentmenu;\r
- moo.fState=rfiles[0]?MFS_ENABLED:MFS_GRAYED;\r
-\r
- SetMenuItemInfo(GetSubMenu(fceumenu,0),102,FALSE,&moo);\r
-\r
- for(x=0;x<10;x++)\r
-  RemoveMenu(recentmenu,600+x,MF_BYCOMMAND);\r
- for(x=9;x>=0;x--)\r
- {  \r
-  char tmp[128+5];\r
-  if(!rfiles[x]) continue;\r
-\r
-  moo.cbSize=sizeof(moo);\r
-  moo.fMask=MIIM_DATA|MIIM_ID|MIIM_TYPE;\r
-\r
-  if(strlen(rfiles[x])<128)\r
-  {\r
-   sprintf(tmp,"&%d. %s",(x+1)%10,rfiles[x]);\r
-  }\r
-  else\r
-   sprintf(tmp,"&%d. %s",(x+1)%10,rfiles[x]+strlen(rfiles[x])-127);\r
-\r
-  moo.cch=strlen(tmp);\r
-  moo.fType=0;\r
-  moo.wID=600+x;\r
-  moo.dwTypeData=tmp;\r
-  InsertMenuItem(recentmenu,0,1,&moo);\r
- }\r
- DrawMenuBar(hAppWnd);\r
-}\r
-\r
-void AddRecent(char *fn)\r
-{\r
- int x;\r
-\r
- for(x=0;x<10;x++)\r
-  if(rfiles[x])\r
-   if(!strcmp(rfiles[x],fn))    // Item is already in list.\r
-   {\r
-    int y;\r
-    char *tmp;\r
-\r
-    tmp=rfiles[x];              // Save pointer.\r
-    for(y=x;y;y--)\r
-     rfiles[y]=rfiles[y-1];     // Move items down.\r
-\r
-    rfiles[0]=tmp;              // Put item on top.\r
-    UpdateRMenu();\r
-    return;\r
-   }\r
-\r
- if(rfiles[9]) free(rfiles[9]);\r
- for(x=9;x;x--) rfiles[x]=rfiles[x-1];\r
- rfiles[0]=malloc(strlen(fn)+1);\r
- strcpy(rfiles[0],fn);\r
- UpdateRMenu();\r
-}\r
-\r
-void HideMenu(int h)\r
-{\r
-  if(h)\r
-  {\r
-   SetMenu(hAppWnd,0);   \r
-  }\r
-  else\r
-  {\r
-   SetMenu(hAppWnd,fceumenu);\r
-  }\r
-}\r
-\r
-static LONG WindowXC=1<<30,WindowYC;\r
-void HideFWindow(int h)\r
-{\r
- LONG desa;\r
-\r
- if(h)\r
- {\r
-   RECT bo;\r
-   GetWindowRect(hAppWnd,&bo);\r
-   WindowXC=bo.left;\r
-   WindowYC=bo.top;\r
-\r
-   SetMenu(hAppWnd,0);\r
-   desa=WS_POPUP|WS_CLIPSIBLINGS;\r
- }\r
- else\r
- {\r
-   desa=WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS;\r
-   HideMenu(tog);\r
- }\r
\r
- SetWindowLong(hAppWnd,GWL_STYLE,desa|(GetWindowLong(hAppWnd,GWL_STYLE)&WS_VISIBLE));\r
- SetWindowPos(hAppWnd,0,0,0,0,0,SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE|SWP_NOZORDER);\r
-}\r
-\r
-void ToggleHideMenu(void)\r
-{ \r
- if(!fullscreen)\r
- {\r
-  tog^=1;\r
-  HideMenu(tog);\r
-  SetMainWindowStuff();\r
- }\r
-}\r
-\r
-static void ALoad(char *nameo)\r
-{\r
-  if((GI=FCEUI_LoadGame(nameo)))\r
-  {\r
-   FixFL();\r
-   FixGIGO();\r
-   SetMainWindowStuff();\r
-   AddRecent(nameo);\r
-   RefreshThrottleFPS();\r
-   if(eoptions&EO_FSAFTERLOAD)\r
-    SetFSVideoMode();\r
-  }\r
-  else\r
-   StopSound();\r
-}\r
-\r
-void LoadNewGamey(HWND hParent)\r
-{\r
- const char filter[]="All usable files(*.nes,*.nsf,*.fds,*.unf,*.zip,*.gz)\0*.nes;*.nsf;*.fds;*.unf;*.zip;*.gz\0All non-compressed usable files(*.nes,*.nsf,*.fds,*.unf)\0*.nes;*.nsf;*.fds;*.unf\0All files (*.*)\0*.*\0";\r
- char nameo[2048];\r
- OPENFILENAME ofn;\r
- memset(&ofn,0,sizeof(ofn));\r
- ofn.lStructSize=sizeof(ofn);\r
- ofn.hInstance=fceu_hInstance;\r
- ofn.lpstrTitle="FCE Ultra Open File...";\r
- ofn.lpstrFilter=filter;\r
- nameo[0]=0;\r
- ofn.hwndOwner=hParent;\r
- ofn.lpstrFile=nameo;\r
- ofn.nMaxFile=256;\r
- ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; //OFN_EXPLORER|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK;\r
- ofn.lpstrInitialDir=gfsdir;\r
- if(GetOpenFileName(&ofn))\r
- {\r
-  if(gfsdir) free(gfsdir);\r
-  if((gfsdir=malloc(ofn.nFileOffset+1)))\r
-  {\r
-   strncpy(gfsdir,ofn.lpstrFile,ofn.nFileOffset);\r
-   gfsdir[ofn.nFileOffset]=0;\r
-  }\r
-  ALoad(nameo);\r
- }\r
-}\r
-\r
-static uint32 mousex,mousey,mouseb;\r
-void GetMouseData(uint32 *x, uint32 *y, uint32 *b)\r
-{\r
- *x=mousex;\r
- *y=mousey;\r
- if(!fullscreen)\r
- {\r
-  if(eoptions&EO_USERFORCE)\r
-  {\r
-   RECT t;\r
-   GetClientRect(hAppWnd,&t);\r
-\r
-   *x=*x*VNSWID/(t.right?t.right:1);\r
-   *y=*y*totallines/(t.bottom?t.bottom:1);\r
-  }\r
-  else\r
-  {\r
-   *x/=winsizemul;\r
-   *y/=winsizemul;\r
-  }\r
-  *x+=VNSCLIP;\r
- }\r
-\r
- *y+=srendline;\r
- *b=((mouseb==MK_LBUTTON)?1:0)|((mouseb==MK_RBUTTON)?2:0);\r
-}\r
-\r
-static int sizchange=0;\r
-static int vchanged=0;\r
-\r
-LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)\r
-{\r
-  switch(msg) {   \r
-    case WM_LBUTTONDOWN:\r
-    case WM_LBUTTONUP:\r
-    case WM_RBUTTONDOWN:\r
-    case WM_RBUTTONUP:\r
-                  mouseb=wParam;\r
-                  goto proco;\r
-    case WM_MOUSEMOVE:\r
-                  {\r
-                   mousex=LOWORD(lParam);\r
-                   mousey=HIWORD(lParam);\r
-                  }\r
-                  goto proco;\r
-    case WM_SIZING:\r
-                 sizchange=1;\r
-                 goto proco;\r
-    case WM_DISPLAYCHANGE:\r
-                if(!fullscreen && !changerecursive)\r
-                 vchanged=1;\r
-                goto proco;\r
-    case WM_DROPFILES:\r
-                {\r
-                 UINT len;\r
-                 char *ftmp;\r
-\r
-                 len=DragQueryFile((HANDLE)wParam,0,0,0)+1;\r
-                 if((ftmp=malloc(len)))\r
-                 {\r
-                  DragQueryFile((HANDLE)wParam,0,ftmp,len);\r
-                  ALoad(ftmp);\r
-                  free(ftmp);\r
-                 }                 \r
-                }\r
-                break;\r
-    case WM_COMMAND:\r
-                if(!(wParam>>16))\r
-                {\r
-                 wParam&=0xFFFF;\r
-                 if(wParam>=600 && wParam<=609)\r
-                 {\r
-                  if(rfiles[wParam-600]) ALoad(rfiles[wParam-600]);\r
-                 }\r
-                 switch(wParam)\r
-                 {\r
-                  case 300:ToggleHideMenu();break;\r
-                  case 301:eoptions^=EO_BGRUN;UpdateMenu();break;\r
-\r
-                  case 310:genie^=1;FCEUI_SetGameGenie(genie);UpdateMenu();break;\r
-                  case 311:palyo^=1;\r
-                           FCEUI_SetVidSystem(palyo);\r
-                           RefreshThrottleFPS();\r
-                           UpdateMenu();\r
-                           FixFL();\r
-                           SetMainWindowStuff();\r
-                           break;\r
-\r
-                  case 320:StopSound();ConfigDirectories();break;\r
-                  case 321:StopSound();ConfigInput(hWnd);break;\r
-                  case 322:ConfigMisc();break;\r
-                  case 323:StopSound();ConfigNetplay();break;\r
-                  case 324:StopSound();ConfigPalette();break;\r
-                  case 325:StopSound();ConfigSound();break;\r
-                  case 326:ConfigVideo();break;\r
-\r
-                  case 200:DriverInterface(DES_RESET,0);break;\r
-                  case 201:DriverInterface(DES_POWER,0);break;\r
-                  case 202:ConfigCheats(hWnd);break;\r
-\r
-                  case 100:StopSound();\r
-                           LoadNewGamey(hWnd);\r
-                           break;\r
-                  case 101:if(GI)\r
-                           {\r
-                            FCEUI_CloseGame();                            \r
-                            GI=0;\r
-                           }\r
-                           break;\r
-                  case 110:FCEUI_SaveState();break;\r
-                  case 111:FCEUI_LoadState();break;\r
-\r
-                  case 120:\r
-                           {\r
-                            MENUITEMINFO mi;\r
-                            char *str;\r
-             \r
-                            StopSound();\r
-                            if(CreateSoundSave())\r
-                             str="Stop Sound Logging";\r
-                            else\r
-                             str="Log Sound As...";\r
-                            memset(&mi,0,sizeof(mi));\r
-                            mi.fMask=MIIM_DATA|MIIM_TYPE;\r
-                            mi.cbSize=sizeof(mi);\r
-                            GetMenuItemInfo(fceumenu,120,0,&mi);                           \r
-                            mi.fMask=MIIM_DATA|MIIM_TYPE;\r
-                            mi.cbSize=sizeof(mi);\r
-                            mi.dwTypeData=str;\r
-                            mi.cch=strlen(str);\r
-                            SetMenuItemInfo(fceumenu,120,0,&mi);\r
-                           }\r
-                           break;\r
-                  case 130:DoFCEUExit();break;\r
-\r
-                  case 400:StopSound();ShowAboutBox();break;\r
-                 }              \r
-                }\r
-                break;\r
-\r
-\r
-    case WM_SYSCOMMAND:\r
-               if(wParam==SC_KEYMENU)\r
-                if(GI && InputTypeFC==SIFC_FKB && cidisabled)\r
-                 break;\r
-               goto proco;\r
-    case WM_SYSKEYDOWN:\r
-               if(GI && InputTypeFC==SIFC_FKB && cidisabled)\r
-                break; /* Hopefully this won't break DInput... */\r
-\r
-               if(fullscreen || tog)\r
-               {\r
-                if(wParam==VK_MENU)\r
-                 break;\r
-               }\r
-               if(wParam==VK_F10)\r
-               {\r
-                if(!(lParam&0x40000000))\r
-                 DriverInterface(DES_RESET,0);\r
-                break;\r
-               }\r
-               goto proco;\r
-\r
-    case WM_KEYDOWN:\r
-              if(GI)\r
-             {\r
-              /* Only disable command keys if a game is loaded(and the other\r
-                 conditions are right, of course). */\r
-               if(InputTypeFC==SIFC_FKB)\r
-              {\r
-               if(wParam==VK_SCROLL)\r
-               {\r
-                cidisabled^=1;\r
-                FCEUI_DispMessage("Family Keyboard %sabled.",cidisabled?"en":"dis");\r
-               }\r
-               if(cidisabled)\r
-                 break; /* Hopefully this won't break DInput... */\r
-              }\r
-               if(GI->type==GIT_NSF)\r
-                switch(wParam)\r
-                {\r
-                 case VK_UP:DriverInterface(DES_NSFINC,0);break;\r
-                 case VK_DOWN:DriverInterface(DES_NSFDEC,0);break;\r
-                 case VK_RETURN:DriverInterface(DES_NSFRES,0);break;\r
-\r
-                 case VK_LEFT:if(!(lParam&0x40000000))\r
-                               DriverInterface(DES_NSFDEC,0); break;\r
-                 case VK_RIGHT:if(!(lParam&0x40000000))\r
-                                DriverInterface(DES_NSFINC,0); break;\r
-                }\r
-\r
-              }\r
-               if(!(lParam&0x40000000))\r
-                switch( wParam )\r
-                {\r
-                  case VK_F11:DriverInterface(DES_POWER,0);break;\r
-                  case VK_F12:DoFCEUExit();break;\r
-                  case VK_F2:userpause^=1;break;\r
-                  case VK_F3:ToggleHideMenu();break;\r
-                  case VK_F4:       UpdateMenu();\r
-                                    changerecursive=1;\r
-                                    if(!SetVideoMode(fullscreen^1))\r
-                                     SetVideoMode(fullscreen);\r
-                                    changerecursive=0;\r
-                                    break;\r
-                }\r
-                goto proco;\r
-\r
-\r
-    case WM_NCRBUTTONDOWN:\r
-    case WM_NCMBUTTONDOWN:StopSound();goto proco;\r
-    case WM_NCLBUTTONDOWN:StopSound();goto proco;\r
-\r
-    case WM_ENTERMENULOOP:StopSound();goto proco;\r
-    case WM_CLOSE:\r
-    case WM_DESTROY:\r
-    case WM_QUIT:DoFCEUExit();break;\r
-    case WM_ACTIVATEAPP:       \r
-       if((BOOL)wParam)\r
-       {\r
-        nofocus=0;\r
-       }\r
-       else\r
-       {\r
-        nofocus=1;\r
-       }\r
-    default:\r
-      proco:\r
-      return DefWindowProc(hWnd,msg,wParam,lParam);\r
-   }\r
-  return 0;\r
-}\r
-\r
-void UpdateFCEUWindow(void)\r
-{\r
-  int w,h;\r
-  RECT wrect;\r
-\r
-  if(vchanged && !fullscreen && !changerecursive && !nofocus)\r
-  {\r
-   SetVideoMode(0);\r
-   vchanged=0;\r
-  }\r
-\r
-  if(sizchange && !fullscreen && !(eoptions&EO_USERFORCE))\r
-  {      \r
-   GetWindowRect(hAppWnd,&wrect);\r
-   h=wrect.bottom-wrect.top;\r
-   w=wrect.right-wrect.left;\r
-   if(w!=winwidth)\r
-    winsizemul=(w-(winwidth-VNSWID*winsizemul)+(VNSWID>>1))>>8;\r
-   else\r
-   if(h!=winheight)\r
-    winsizemul=(h-(winheight-totallines*winsizemul)+(totallines>>1))>>8;\r
-\r
-   if(winsizemul<1)\r
-    winsizemul=1;\r
-   SetMainWindowStuff();\r
-  }\r
-  sizchange=0;\r
-\r
-  BlockingCheck();\r
-}\r
-\r
-void ByebyeWindow(void)\r
-{\r
- SetMenu(hAppWnd,0);\r
- DestroyMenu(fceumenu);\r
- DestroyWindow(hAppWnd);\r
-}\r
-\r
-int CreateMainWindow(void)\r
-{\r
-  WNDCLASSEX winclass;\r
-  RECT tmp;\r
-\r
-  memset(&winclass,0,sizeof(winclass));\r
-  winclass.cbSize=sizeof(WNDCLASSEX);\r
-  winclass.style=CS_OWNDC|CS_HREDRAW|CS_VREDRAW|CS_SAVEBITS;\r
-  winclass.lpfnWndProc=AppWndProc;\r
-  winclass.cbClsExtra=0;\r
-  winclass.cbWndExtra=0;\r
-  winclass.hInstance=fceu_hInstance;\r
-  winclass.hIcon=LoadIcon(fceu_hInstance, "ICON_1");\r
-  winclass.hIconSm=LoadIcon(fceu_hInstance, "ICON_1");\r
-  winclass.hCursor=LoadCursor(NULL, IDC_ARROW);\r
-  winclass.hbrBackground=GetStockObject(BLACK_BRUSH);\r
-  //winclass.lpszMenuName="FCEUMENU";\r
-  winclass.lpszClassName="FCEULTRA";\r
-\r
-  if(!RegisterClassEx(&winclass))\r
-    return FALSE;\r
-\r
-  AdjustWindowRectEx(&tmp,WS_OVERLAPPEDWINDOW,1,0);\r
-\r
-  fceumenu=LoadMenu(fceu_hInstance,"FCEUMENU");\r
-  recentmenu=CreateMenu();\r
-  UpdateRMenu();\r
-\r
-  hAppWnd = CreateWindowEx(0,"FCEULTRA","FCE Ultra",\r
-                        WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS,  /* Style */\r
-                        CW_USEDEFAULT,CW_USEDEFAULT,256,240,  /* X,Y ; Width, Height */\r
-                        NULL,fceumenu,fceu_hInstance,NULL );  \r
-  DragAcceptFiles(hAppWnd, 1);\r
-  SetMainWindowStuff();\r
-  return 1;\r
-}\r
-\r
-\r
-int SetMainWindowStuff(void)\r
-{\r
-  RECT *srect;\r
-  RECT tmp;\r
-\r
-  GetWindowRect(hAppWnd,&tmp);\r
-\r
-  if(WindowXC!=(1<<30))\r
-  {\r
-   /* Subtracting and adding for if(eoptions&EO_USERFORCE) below. */\r
-   tmp.bottom-=tmp.top;\r
-   tmp.bottom+=WindowYC;\r
-\r
-   tmp.right-=tmp.left;\r
-   tmp.right+=WindowXC;\r
-   \r
-\r
-   tmp.left=WindowXC;\r
-   tmp.top=WindowYC;\r
-   WindowXC=1<<30;\r
-  }\r
-\r
-  if(eoptions&EO_USERFORCE)\r
-  {\r
-   SetWindowPos(hAppWnd,HWND_TOP,tmp.left,tmp.top,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);\r
-   winwidth=tmp.right-tmp.left;\r
-   winheight=tmp.bottom-tmp.top;\r
-  }\r
-  else\r
-  {\r
-   srect=CalcWindowSize();\r
-   SetWindowPos(hAppWnd,HWND_TOP,tmp.left,tmp.top,srect->right,srect->bottom,SWP_SHOWWINDOW);\r
-   winwidth=srect->right;\r
-   winheight=srect->bottom;\r
-  }\r
-\r
-\r
-  ShowWindow(hAppWnd, SW_SHOWNORMAL);\r
-  return 1;\r
-}\r
-\r
-int GetClientAbsRect(LPRECT lpRect)\r
-{\r
-  POINT point;\r
-  point.x=point.y=0;\r
-  if(!ClientToScreen(hAppWnd,&point)) return 0;\r
-\r
-  lpRect->top=point.y;\r
-  lpRect->left=point.x;\r
-\r
-  if(eoptions&EO_USERFORCE)\r
-  {\r
-   RECT al;\r
-\r
-   GetClientRect(hAppWnd,&al);\r
-\r
-   lpRect->right=point.x+al.right;\r
-   lpRect->bottom=point.y+al.bottom;\r
-  }\r
-  else\r
-  {\r
-   lpRect->right=point.x+VNSWID*winsizemul;\r
-   lpRect->bottom=point.y+totallines*winsizemul;\r
-  }\r
-  return 1;\r
-}\r
-\r
-\r
-void LoadPaletteFile(void)\r
-{\r
- FILE *fp;\r
- const char filter[]="All usable files(*.pal)\0*.pal\0All files (*.*)\0*.*\0";\r
- char nameo[2048];\r
- OPENFILENAME ofn;\r
- memset(&ofn,0,sizeof(ofn));\r
- ofn.lStructSize=sizeof(ofn);\r
- ofn.hInstance=fceu_hInstance;\r
- ofn.lpstrTitle="FCE Ultra Open Palette File...";\r
- ofn.lpstrFilter=filter;\r
- nameo[0]=0;\r
- ofn.lpstrFile=nameo;\r
- ofn.nMaxFile=256;\r
- ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;\r
- ofn.lpstrInitialDir=0;\r
- if(GetOpenFileName(&ofn))\r
- {\r
-  if((fp=fopen(nameo,"rb")))\r
-  {\r
-   fread(cpalette,1,192,fp);\r
-   fclose(fp);\r
-   FCEUI_SetPaletteArray(cpalette);\r
-   eoptions|=EO_CPALETTE;\r
-  }\r
-  else\r
-   FCEUD_PrintError("Error opening palette file!");\r
- }\r
-}\r
-\r
-BOOL CALLBACK PaletteConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  switch(uMsg) {\r
-   case WM_INITDIALOG:                \r
-                if(ntsccol)\r
-                 CheckDlgButton(hwndDlg,100,BST_CHECKED);\r
-                SendDlgItemMessage(hwndDlg,500,TBM_SETRANGE,1,MAKELONG(0,128));\r
-                SendDlgItemMessage(hwndDlg,501,TBM_SETRANGE,1,MAKELONG(0,128));\r
-                DriverInterface(DES_GETNTSCTINT,&ntsctint);\r
-                DriverInterface(DES_GETNTSCHUE,&ntschue);\r
-                SendDlgItemMessage(hwndDlg,500,TBM_SETPOS,1,ntsctint);\r
-                SendDlgItemMessage(hwndDlg,501,TBM_SETPOS,1,ntschue);\r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 100:ntsccol^=1;DriverInterface(DES_NTSCCOL,&ntsccol);break;\r
-                 case 200:\r
-                          LoadPaletteFile();\r
-                          break;\r
-                 case 201:FCEUI_SetPaletteArray(0);\r
-                          eoptions&=~EO_CPALETTE;\r
-                          break;\r
-                 case 1:\r
-                        gornk:\r
-                        ntsctint=SendDlgItemMessage(hwndDlg,500,TBM_GETPOS,0,(LPARAM)(LPSTR)0);\r
-                        ntschue=SendDlgItemMessage(hwndDlg,501,TBM_GETPOS,0,(LPARAM)(LPSTR)0);\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-               }\r
-              }\r
-  return 0;\r
-}\r
-\r
-static void ConfigPalette(void)\r
-{\r
-  DialogBox(fceu_hInstance,"PALCONFIG",hAppWnd,PaletteConCallB);\r
-  DriverInterface(DES_SETNTSCTINT,&ntsctint);\r
-  DriverInterface(DES_SETNTSCHUE,&ntschue);\r
-}\r
-\r
-\r
-static BOOL CALLBACK MiscConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  switch(uMsg) {\r
-   case WM_INITDIALOG:                \r
-                if(eoptions&EO_NOSPRLIM)\r
-                 CheckDlgButton(hwndDlg,100,BST_CHECKED);\r
-                if(eoptions&EO_FOAFTERSTART)\r
-                 CheckDlgButton(hwndDlg,102,BST_CHECKED);\r
-                if(eoptions&EO_SNAPNAME)\r
-                 CheckDlgButton(hwndDlg,103,BST_CHECKED);\r
-                if(eoptions&EO_NOTHROTTLE)\r
-                 CheckDlgButton(hwndDlg,101,BST_CHECKED);\r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(!(wParam>>16))\r
-                switch(wParam&0xFFFF)\r
-                {\r
-                 case 1:\r
-                        gornk:\r
-                        if(IsDlgButtonChecked(hwndDlg,100)==BST_CHECKED)\r
-                         eoptions|=EO_NOSPRLIM;\r
-                        else\r
-                         eoptions&=~EO_NOSPRLIM;\r
-                        if(IsDlgButtonChecked(hwndDlg,102)==BST_CHECKED)\r
-                         eoptions|=EO_FOAFTERSTART;\r
-                        else\r
-                         eoptions&=~EO_FOAFTERSTART;\r
-                        if(IsDlgButtonChecked(hwndDlg,103)==BST_CHECKED)\r
-                         eoptions|=EO_SNAPNAME;\r
-                        else\r
-                         eoptions&=~EO_SNAPNAME;\r
-                        if(IsDlgButtonChecked(hwndDlg,101)==BST_CHECKED)\r
-                         eoptions|=EO_NOTHROTTLE;\r
-                        else\r
-                         eoptions&=~EO_NOTHROTTLE;\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-               }\r
-              }\r
-  return 0;\r
-}\r
-\r
-void DoMiscConfigFix(void)\r
-{\r
-  FCEUI_DisableSpriteLimitation(eoptions&EO_NOSPRLIM);\r
-  FCEUI_SetSnapName(eoptions&EO_SNAPNAME);\r
-}\r
-\r
-static void ConfigMisc(void)\r
-{\r
-  DialogBox(fceu_hInstance,"MISCCONFIG",hAppWnd,MiscConCallB);  \r
-  DoMiscConfigFix();\r
-}\r
-\r
-static int BrowseForFolder(HWND hParent, char *htext, char *buf)\r
-{\r
- BROWSEINFO bi;\r
- LPCITEMIDLIST pidl;\r
- int ret=1;\r
-\r
- buf[0]=0;\r
-\r
- memset(&bi,0,sizeof(bi));\r
-                \r
- bi.hwndOwner=hParent;\r
- bi.lpszTitle=htext;\r
- bi.ulFlags=BIF_RETURNONLYFSDIRS; \r
-\r
- if(FAILED(CoInitialize(0)))\r
-  return(0);\r
-\r
- if(!(pidl=SHBrowseForFolder(&bi)))\r
- {\r
-  ret=0;\r
-  goto end1;\r
- }\r
-\r
- if(!SHGetPathFromIDList(pidl,buf))\r
- {\r
-  ret=0;\r
-  goto end2;\r
- }\r
-\r
- end2:\r
- /* This probably isn't the best way to free the memory... */\r
- CoTaskMemFree((PVOID)pidl);\r
-\r
- end1:\r
- CoUninitialize();\r
- return(ret);\r
-}\r
-\r
-static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
-{\r
-  int x;\r
-\r
-  switch(uMsg){\r
-   case WM_INITDIALOG:                \r
-                for(x=0;x<6;x++)\r
-                 SetDlgItemText(hwndDlg,100+x,DOvers[x]);\r
-\r
-                if(eoptions&EO_BSAV)\r
-                 CheckDlgButton(hwndDlg,300,BST_CHECKED);\r
-                break;\r
-   case WM_CLOSE:\r
-   case WM_QUIT: goto gornk;\r
-   case WM_COMMAND:\r
-                if(!(wParam>>16))\r
-                {\r
-                 if((wParam&0xFFFF)>=200 && (wParam&0xFFFF)<=205)\r
-                 {\r
-                  static char *helpert[6]={"Cheats","Miscellaneous","Nonvolatile Game Data","Save States","Screen Snapshots","Base Directory"};\r
-                  char name[MAX_PATH];\r
-\r
-                  if(BrowseForFolder(hwndDlg,helpert[((wParam&0xFFFF)-200)],name))\r
-                   SetDlgItemText(hwndDlg,100+((wParam&0xFFFF)-200),name);\r
-                 }\r
-                 else switch(wParam&0xFFFF)\r
-                 {\r
-                  case 1:\r
-                        gornk:\r
-\r
-                        RemoveDirs();   // Remove empty directories.\r
-\r
-                        for(x=0;x<6;x++)\r
-                        {\r
-                         LONG len;\r
-                         len=SendDlgItemMessage(hwndDlg,100+x,WM_GETTEXTLENGTH,0,0);\r
-                         if(len<=0)\r
-                         {\r
-                          if(DOvers[x]) free(DOvers[x]);\r
-                          DOvers[x]=0;\r
-                          continue;\r
-                         }\r
-                         len++; // Add 1 for null character.\r
-                         if(!(DOvers[x]=malloc(len)))\r
-                          continue;\r
-                         if(!GetDlgItemText(hwndDlg,100+x,DOvers[x],len))\r
-                         {\r
-                          free(DOvers[x]);\r
-                          DOvers[x]=0;\r
-                          continue;\r
-                         }\r
-\r
-                        }\r
-                        if(IsDlgButtonChecked(hwndDlg,300)==BST_CHECKED)\r
-                         eoptions|=EO_BSAV;\r
-                        else\r
-                         eoptions&=~EO_BSAV;\r
-\r
-                        CreateDirs();   // Create needed directories.\r
-                        SetDirs();      // Set the directories in the core.\r
-                        EndDialog(hwndDlg,0);\r
-                        break;\r
-                 }\r
-                }\r
-              }\r
-  return 0;\r
-}\r
-\r
-\r
-\r
-static void ConfigDirectories(void)\r
-{\r
-  DialogBox(fceu_hInstance,"DIRCONFIG",hAppWnd,DirConCallB);\r
-}\r
diff --git a/palettes/conv.c b/palettes/conv.c
new file mode 100644 (file)
index 0000000..c0cd6b2
--- /dev/null
@@ -0,0 +1,74 @@
+/* Quick conversion stuff for MAME->FCE Ultra */
+
+#include <stdio.h>
+#include "../types.h"
+#include "../palette.h"
+#include "palettes.h"
+
+/* check 0x08 */
+static uint8 rp2c04001_colortable[] =
+{
+        0x35, 0x23, 0x16, 0x22, 0x1c, 0x09, 0xff, 0x15, /* 0x00 - 0x07 */
+        0x20, 0x00, 0x27, 0x05, 0x04, 0x27, 0x08, 0x30, /* 0x08 - 0x0f */
+        0x21, 0xff, 0xff, 0x29, 0x3c, 0x32, 0x36, 0x12, /* 0x10 - 0x17 */
+        0xff, 0x2b, 0x0f, 0xff, 0x20, 0x10, 0x24, 0x01, /* 0x18 - 0x1f */
+        0xff, 0x31, 0xff, 0x2a, 0x2c, 0x0c, 0xff, 0xff, /* 0x20 - 0x27 */   
+        0xff, 0x07, 0x34, 0x06, 0x13, 0x02, 0x26, 0x0f, /* 0x28 - 0x2f */
+        0xff, 0x19, 0x10, 0x0a, 0x39, 0xff, 0x37, 0x17, /* 0x30 - 0x37 */
+        0xff, 0x11, 0x09, 0xff, 0x39, 0x25, 0x18, 0xff  /* 0x38 - 0x3f */
+};
+
+/* RP2C04-002 */
+static uint8 rp2c04002_colortable[] =
+{
+        0x0f, 0x27, 0x18, 0xff, 0x3a, 0x25, 0xff, 0x31, /* 0x00 - 0x07 */
+        0x16, 0x13, 0x38, 0x34, 0x20, 0x23, 0xff, 0x0b, /* 0x08 - 0x0f */
+        0xff, 0x21, 0x06, 0xff, 0x1b, 0x29, 0xff, 0x22, /* 0x10 - 0x17 */
+        0xff, 0x24, 0xff, 0x2b, 0xff, 0x08, 0xff, 0x03, /* 0x18 - 0x1f */
+        0xff, 0x36, 0x26, 0x33, 0x11, 0xff, 0x10, 0x02, /* 0x20 - 0x27 */
+        0x14, 0xff, 0x00, 0x09, 0x12, 0x0f, 0x37, 0x30, /* 0x28 - 0x2f */
+        0xff, 0xff, 0x2a, 0x17, 0x0c, 0x01, 0x15, 0x19, /* 0x30 - 0x37 */
+        0xff, 0x2c, 0x07, 0x37, 0xff, 0x05, 0x0a, 0x00  /* 0x38 - 0x3f */
+};
+
+/* RP2C04-003 */
+/* Check 0x00.  Used in Dr Mario. */
+static uint8 rp2c04003_colortable[] =
+{
+        0x03, 0xff, 0xff, 0x00, 0x1a, 0x30, 0x31, 0x09, /* 0x00 - 0x07 */
+        0x01, 0x0f, 0x36, 0x08, 0x15, 0xff, 0xff, 0x30, /* 0x08 - 0x0f */
+        0x22, 0x1c, 0xff, 0x12, 0x19, 0x18, 0x17, 0x1b, /* 0x10 - 0x17 */
+        0x00, 0xff, 0xff, 0x02, 0x16, 0x06, 0xff, 0x35, /* 0x18 - 0x1f */
+        0x23, 0xff, 0x0f, 0x37, 0xff, 0x27, 0x26, 0x30, /* 0x20 - 0x27 */
+        0x29, 0xff, 0x21, 0x24, 0x11, 0xff, 0x0f, 0xff, /* 0x28 - 0x2f */   
+        0x2c, 0xff, 0xff, 0xff, 0x07, 0x2a, 0x28, 0xff, /* 0x30 - 0x37 */
+        0x0a, 0xff, 0x32, 0x37, 0x13, 0xff, 0xff, 0x0c  /* 0x38 - 0x3f */
+};
+  
+/* RP2C05-004 */
+/* check 0x1d, 0x38 */
+static uint8 rp2c05004_colortable[] =
+{
+        0x18, 0xff, 0x1c, 0x28, 0xff, 0xff, 0x01, 0x17, /* 0x00 - 0x07 */
+        0x10, 0x0f, 0x2a, 0x0f, 0x36, 0x37, 0x1a, 0xff, /* 0x08 - 0x0f */
+        0x25, 0xff, 0x12, 0xff, 0x0f, 0xff, 0xff, 0x26, /* 0x10 - 0x17 */
+        0xff, 0xff, 0x22, 0x19, 0xff, 0x0f, 0x3a, 0x21, /* 0x18 - 0x1f */
+        0x05, 0x0a, 0x07, 0x01, 0x13, 0xff, 0x00, 0x15, /* 0x20 - 0x27 */
+        0x0c, 0xff, 0x11, 0xff, 0xff, 0x38, 0xff, 0xff, /* 0x28 - 0x2f */
+        0xff, 0xff, 0x08, 0x16, 0xff, 0xff, 0x30, 0x3c, /* 0x30 - 0x37 */
+        0x0f, 0x27, 0xff, 0x31, 0x29, 0xff, 0x30, 0x09  /* 0x38 - 0x3f */
+};
+
+
+main()
+{
+ int x;
+ for(x=0;x<64;x++)
+ {
+ // if(x <= 0x20)
+//  if(rp2c04002_colortable[x] == 0xFF) rp2c04002_colortable[x]= 0x30;
+  printf("{0x%02x, 0x%02x, 0x%02x},\n",palette[rp2c04001_colortable[x]&0x3F].r,
+                                palette[rp2c04001_colortable[x]&0x3F].g,
+                                palette[rp2c04001_colortable[x]&0x3F].b);
+ }
+}
diff --git a/palettes/palettes.h b/palettes/palettes.h
new file mode 100644 (file)
index 0000000..ed6c2db
--- /dev/null
@@ -0,0 +1,94 @@
+pal rp2c04001[64] = {
+ #include "rp2c04001.h"
+};
+
+pal rp2c04002[64] = {
+ #include "rp2c04002.h"
+};
+
+pal rp2c04003[64] = {
+ #include "rp2c04003.h"
+};
+pal rp2c05004[64] = {
+ #include "rp2c05004.h"
+};
+
+pal unvpalette[7] = {
+{ 0x00<<2,0x00<<2,0x00<<2}, // Black
+{ 0x3F<<2,0x3F<<2,0x34<<2}, // White
+{ 0x00<<2,0x00<<2,0x00<<2}, // Black
+{ 0x1d<<2,0x1d<<2,0x24<<2}, // Greyish
+{ 190,0,0    }, // Redish
+{ 51,255,51}, // Bright green
+{ 49,14,200}, 
+};
+
+
+/* Default palette */
+pal palette[64] = {
+
+        { 0x1D<<2, 0x1D<<2, 0x1D<<2 }, /* Value 0 */
+        { 0x09<<2, 0x06<<2, 0x23<<2 }, /* Value 1 */
+        { 0x00<<2, 0x00<<2, 0x2A<<2 }, /* Value 2 */
+        { 0x11<<2, 0x00<<2, 0x27<<2 }, /* Value 3 */
+        { 0x23<<2, 0x00<<2, 0x1D<<2 }, /* Value 4 */
+        { 0x2A<<2, 0x00<<2, 0x04<<2 }, /* Value 5 */
+        { 0x29<<2, 0x00<<2, 0x00<<2 }, /* Value 6 */
+        { 0x1F<<2, 0x02<<2, 0x00<<2 }, /* Value 7 */
+        { 0x10<<2, 0x0B<<2, 0x00<<2 }, /* Value 8 */
+        { 0x00<<2, 0x11<<2, 0x00<<2 }, /* Value 9 */
+        { 0x00<<2, 0x14<<2, 0x00<<2 }, /* Value 10 */
+        { 0x00<<2, 0x0F<<2, 0x05<<2 }, /* Value 11 */
+        { 0x06<<2, 0x0F<<2, 0x17<<2 }, /* Value 12 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 13 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 14 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 15 */
+        { 0x2F<<2, 0x2F<<2, 0x2F<<2 }, /* Value 16 */
+        { 0x00<<2, 0x1C<<2, 0x3B<<2 }, /* Value 17 */
+        { 0x08<<2, 0x0E<<2, 0x3B<<2 }, /* Value 18 */
+        { 0x20<<2, 0x00<<2, 0x3C<<2 }, /* Value 19 */
+        { 0x2F<<2, 0x00<<2, 0x2F<<2 }, /* Value 20 */
+        { 0x39<<2, 0x00<<2, 0x16<<2 }, /* Value 21 */
+        { 0x36<<2, 0x0A<<2, 0x00<<2 }, /* Value 22 */
+        { 0x32<<2, 0x13<<2, 0x03<<2 }, /* Value 23 */
+        { 0x22<<2, 0x1C<<2, 0x00<<2 }, /* Value 24 */
+        { 0x00<<2, 0x25<<2, 0x00<<2 }, /* Value 25 */
+        { 0x00<<2, 0x2A<<2, 0x00<<2 }, /* Value 26 */
+        { 0x00<<2, 0x24<<2, 0x0E<<2 }, /* Value 27 */
+        { 0x00<<2, 0x20<<2, 0x22<<2 }, /* Value 28 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 29 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 30 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 31 */
+        { 0x3F<<2, 0x3F<<2, 0x3F<<2 }, /* Value 32 */
+        { 0x0F<<2, 0x2F<<2, 0x3F<<2 }, /* Value 33 */
+        { 0x17<<2, 0x25<<2, 0x3F<<2 }, /* Value 34 */
+        { 0x10<<2, 0x22<<2, 0x3F<<2 }, /* Value 35 */
+        { 0x3D<<2, 0x1E<<2, 0x3F<<2 }, /* Value 36 */
+        { 0x3F<<2, 0x1D<<2, 0x2D<<2 }, /* Value 37 */
+        { 0x3F<<2, 0x1D<<2, 0x18<<2 }, /* Value 38 */
+        { 0x3F<<2, 0x26<<2, 0x0E<<2 }, /* Value 39 */
+        { 0x3C<<2, 0x2F<<2, 0x0F<<2 }, /* Value 40 */
+        { 0x20<<2, 0x34<<2, 0x04<<2 }, /* Value 41 */
+        { 0x13<<2, 0x37<<2, 0x12<<2 }, /* Value 42 */
+        { 0x16<<2, 0x3E<<2, 0x26<<2 }, /* Value 43 */
+        { 0x00<<2, 0x3A<<2, 0x36<<2 }, /* Value 44 */
+        { 0x1E<<2, 0x1E<<2, 0x1E<<2 }, /* Value 45 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 46 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 47 */
+        { 0x3F<<2, 0x3F<<2, 0x3F<<2 }, /* Value 48 */
+        { 0x2A<<2, 0x39<<2, 0x3F<<2 }, /* Value 49 */
+        { 0x31<<2, 0x35<<2, 0x3F<<2 }, /* Value 50 */
+        { 0x35<<2, 0x32<<2, 0x3F<<2 }, /* Value 51 */
+        { 0x3F<<2, 0x31<<2, 0x3F<<2 }, /* Value 52 */
+        { 0x3F<<2, 0x31<<2, 0x36<<2 }, /* Value 53 */
+        { 0x3F<<2, 0x2F<<2, 0x2C<<2 }, /* Value 54 */
+        { 0x3F<<2, 0x36<<2, 0x2A<<2 }, /* Value 55 */
+        { 0x3F<<2, 0x39<<2, 0x28<<2 }, /* Value 56 */
+        { 0x38<<2, 0x3F<<2, 0x28<<2 }, /* Value 57 */
+        { 0x2A<<2, 0x3C<<2, 0x2F<<2 }, /* Value 58 */
+        { 0x2C<<2, 0x3F<<2, 0x33<<2 }, /* Value 59 */
+        { 0x27<<2, 0x3F<<2, 0x3C<<2 }, /* Value 60 */
+        { 0x31<<2, 0x31<<2, 0x31<<2 }, /* Value 61 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 62 */
+        { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 63 */
+};
diff --git a/palettes/rp2c04001.old b/palettes/rp2c04001.old
new file mode 100644 (file)
index 0000000..f2526b9
--- /dev/null
@@ -0,0 +1,64 @@
+{ 0x3f<<2, 0x31<<2, 0x36<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x36<<2, 0x0a<<2, 0x00<<2, },
+{ 0x17<<2, 0x25<<2, 0x3f<<2, },
+{ 0x00<<2, 0x20<<2, 0x22<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x39<<2, 0x00<<2, 0x16<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x1d<<2, 0x1d<<2, 0x1d<<2, },
+{ 0x3f<<2, 0x26<<2, 0x0e<<2, },
+{ 0x2a<<2, 0x00<<2, 0x04<<2, },
+{ 0x23<<2, 0x00<<2, 0x1d<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x10<<2, 0x0b<<2, 0x00<<2, },
+{ 0x3f<<2, 0x3f<<2, 0x3f<<2, },
+{ 0x0f<<2, 0x2f<<2, 0x3f<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x20<<2, 0x34<<2, 0x04<<2, },
+{ 0x27<<2, 0x3f<<2, 0x3c<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x3f<<2, 0x2f<<2, 0x2c<<2, },
+{ 0x08<<2, 0x0e<<2, 0x3b<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x16<<2, 0x3e<<2, 0x26<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x09<<2, 0x06<<2, 0x23<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x2a<<2, 0x39<<2, 0x3f<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x13<<2, 0x37<<2, 0x12<<2, },
+{ 0x00<<2, 0x3a<<2, 0x36<<2, },
+{ 0x06<<2, 0x0f<<2, 0x17<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x1f<<2, 0x02<<2, 0x00<<2, },
+{ 0x3f<<2, 0x31<<2, 0x3f<<2, },
+{ 0x29<<2, 0x00<<2, 0x00<<2, },
+{ 0x20<<2, 0x00<<2, 0x3c<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x3f<<2, 0x1d<<2, 0x18<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x25<<2, 0x00<<2, },
+{ 0x2f<<2, 0x2f<<2, 0x2f<<2, },
+{ 0x00<<2, 0x14<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x32<<2, 0x13<<2, 0x03<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x1c<<2, 0x3b<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
+{ 0x3f<<2, 0x1d<<2, 0x2d<<2, },
+{ 0x22<<2, 0x1c<<2, 0x00<<2, },
+{ 0x00<<2, 0x00<<2, 0x00<<2, },
diff --git a/palettes/rp2c04002.h b/palettes/rp2c04002.h
new file mode 100644 (file)
index 0000000..d0f46b9
--- /dev/null
@@ -0,0 +1,64 @@
+{0x00, 0x00, 0x00},
+{0xfc, 0x98, 0x38},
+{0x88, 0x70, 0x00},
+{0x00, 0x00, 0x00},
+{0xa8, 0xf0, 0xbc},
+{0xfc, 0x74, 0xb4},
+{0x00, 0x00, 0x00},
+{0xa8, 0xe4, 0xfc},
+{0xd8, 0x28, 0x00},
+{0x80, 0x00, 0xf0},
+{0xfc, 0xe4, 0xa0},
+{0xfc, 0xc4, 0xfc},
+{0xfc, 0xfc, 0xfc},
+{0x40, 0x88, 0xfc},
+{0x00, 0x00, 0x00},
+{0x00, 0x3c, 0x14},
+{0x00, 0x00, 0x00},
+{0x3c, 0xbc, 0xfc},
+{0xa4, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x90, 0x38},
+{0x80, 0xd0, 0x10},
+{0x00, 0x00, 0x00},
+{0x5c, 0x94, 0xfc},
+{0x00, 0x00, 0x00},
+{0xf4, 0x78, 0xfc},
+{0x00, 0x00, 0x00},
+{0x58, 0xf8, 0x98},
+{0x00, 0x00, 0x00},
+{0x40, 0x2c, 0x00},
+{0x00, 0x00, 0x00},
+{0x44, 0x00, 0x9c},
+{0x00, 0x00, 0x00},
+{0xfc, 0xbc, 0xb0},
+{0xfc, 0x74, 0x60},
+{0xd4, 0xc8, 0xfc},
+{0x00, 0x70, 0xec},
+{0x00, 0x00, 0x00},
+{0xbc, 0xbc, 0xbc},
+{0x00, 0x00, 0xa8},
+{0xbc, 0x00, 0xbc},
+{0x00, 0x00, 0x00},
+{0x74, 0x74, 0x74},
+{0x00, 0x44, 0x00},
+{0x20, 0x38, 0xec},
+{0x00, 0x00, 0x00},
+{0xfc, 0xd8, 0xa8},
+{0xfc, 0xfc, 0xfc},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x4c, 0xdc, 0x48},
+{0xc8, 0x4c, 0x0c},
+{0x18, 0x3c, 0x5c},
+{0x24, 0x18, 0x8c},
+{0xe4, 0x00, 0x58},
+{0x00, 0x94, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0xe8, 0xd8},
+{0x7c, 0x08, 0x00},
+{0xfc, 0xd8, 0xa8},
+{0x00, 0x00, 0x00},
+{0xa8, 0x00, 0x10},
+{0x00, 0x50, 0x00},
+{0x74, 0x74, 0x74},
diff --git a/palettes/rp2c04003.h b/palettes/rp2c04003.h
new file mode 100644 (file)
index 0000000..9a4717c
--- /dev/null
@@ -0,0 +1,64 @@
+{0x44, 0x00, 0x9c},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x74, 0x74, 0x74},
+{0x00, 0xa8, 0x00},
+{0xfc, 0xfc, 0xfc},
+{0xa8, 0xe4, 0xfc},
+{0x00, 0x44, 0x00},
+{0x24, 0x18, 0x8c},
+{0x00, 0x00, 0x00},
+{0xfc, 0xbc, 0xb0},
+{0x40, 0x2c, 0x00},
+{0xe4, 0x00, 0x58},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0xfc, 0xfc, 0xfc},
+{0x5c, 0x94, 0xfc},
+{0x00, 0x80, 0x88},
+{0x00, 0x00, 0x00},
+{0x20, 0x38, 0xec},
+{0x00, 0x94, 0x00},
+{0x88, 0x70, 0x00},
+{0xc8, 0x4c, 0x0c},
+{0x00, 0x90, 0x38},
+{0x74, 0x74, 0x74},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0xa8},
+{0xd8, 0x28, 0x00},
+{0xa4, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0xfc, 0xc4, 0xd8},
+{0x40, 0x88, 0xfc},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0xfc, 0xd8, 0xa8},
+{0x00, 0x00, 0x00},
+{0xfc, 0x98, 0x38},
+{0xfc, 0x74, 0x60},
+{0xfc, 0xfc, 0xfc},
+{0x80, 0xd0, 0x10},
+{0x00, 0x00, 0x00},
+{0x3c, 0xbc, 0xfc},
+{0xf4, 0x78, 0xfc},
+{0x00, 0x70, 0xec},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0xe8, 0xd8},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x7c, 0x08, 0x00},
+{0x4c, 0xdc, 0x48},
+{0xf0, 0xbc, 0x3c},
+{0x00, 0x00, 0x00},
+{0x00, 0x50, 0x00},
+{0x00, 0x00, 0x00},
+{0xc4, 0xd4, 0xfc},
+{0xfc, 0xd8, 0xa8},
+{0x80, 0x00, 0xf0},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x18, 0x3c, 0x5c},
diff --git a/palettes/rp2c05004.h b/palettes/rp2c05004.h
new file mode 100644 (file)
index 0000000..dc0a90a
--- /dev/null
@@ -0,0 +1,64 @@
+{0x88, 0x70, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x80, 0x88},
+{0xf0, 0xbc, 0x3c},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x24, 0x18, 0x8c},
+{0xc8, 0x4c, 0x0c},
+{0xbc, 0xbc, 0xbc},
+{0x00, 0x00, 0x00},
+{0x4c, 0xdc, 0x48},
+{0x00, 0x00, 0x00},
+{0xfc, 0xbc, 0xb0},
+{0xfc, 0xd8, 0xa8},
+{0x00, 0xa8, 0x00},
+{0x00, 0x00, 0x00},
+{0xfc, 0x74, 0xb4},
+{0x00, 0x00, 0x00},
+{0x20, 0x38, 0xec},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0xfc, 0x74, 0x60},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x5c, 0x94, 0xfc},
+{0x00, 0x94, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0xa8, 0xf0, 0xbc},
+{0x3c, 0xbc, 0xfc},
+{0xa8, 0x00, 0x10},
+{0x00, 0x50, 0x00},
+{0x7c, 0x08, 0x00},
+{0x00, 0x00, 0xa8},
+{0x80, 0x00, 0xf0},
+{0x00, 0x00, 0x00},
+{0x74, 0x74, 0x74},
+{0xe4, 0x00, 0x58},
+{0x18, 0x3c, 0x5c},
+{0x00, 0x00, 0x00},
+{0x00, 0x70, 0xec},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0xfc, 0xe4, 0xa0},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0x40, 0x2c, 0x00},
+{0xd8, 0x28, 0x00},
+{0x00, 0x00, 0x00},
+{0x00, 0x00, 0x00},
+{0xfc, 0xfc, 0xfc},
+{0x9c, 0xfc, 0xf0},
+{0x00, 0x00, 0x00},
+{0xfc, 0x98, 0x38},
+{0x00, 0x00, 0x00},
+{0xa8, 0xe4, 0xfc},
+{0x80, 0xd0, 0x10},
+{0x00, 0x00, 0x00},
+{0xfc, 0xfc, 0xfc},
+{0x00, 0x44, 0x00},
diff --git a/ppu.c b/ppu.c
new file mode 100644 (file)
index 0000000..0f2a47f
--- /dev/null
+++ b/ppu.c
@@ -0,0 +1,803 @@
+/**
+ *  For whatever reason, breaking this out of fce.c made sprites not corrupt
+ */
+
+
+#include        <string.h>
+#include       <stdio.h>
+#include       <stdlib.h>
+
+#include       "types.h"
+#include       "x6502.h"
+#include       "fce.h"
+#include       "sound.h"
+#include        "svga.h"
+#include       "netplay.h"
+#include       "general.h"
+#include       "endian.h"
+#include       "version.h"
+#include        "memory.h"
+
+#include       "cart.h"
+#include       "nsf.h"
+#include       "fds.h"
+#include       "ines.h"
+#include       "unif.h"
+#include        "cheat.h"
+
+#define MMC5SPRVRAMADR(V)      &MMC5SPRVPage[(V)>>10][(V)]
+//#define MMC5BGVRAMADR(V)      &MMC5BGVPage[(V)>>10][(V)]
+#define        VRAMADR(V)      &VPage[(V)>>10][(V)]
+
+#define        V_FLIP  0x80
+#define        H_FLIP  0x40
+#define        SP_BACK 0x20
+
+uint8 SPRAM[0x100];
+static uint8 SPRBUF[0x100];
+
+static uint8 sprlinebuf[256+8];        
+extern void BGRender(uint8 *target);
+extern int tosprite;
+
+
+static int maxsprites=8;
+
+
+void FCEUI_DisableSpriteLimitation(int a)
+{
+ maxsprites=a?64:8;
+}
+
+
+//int printed=1;
+typedef struct {
+        uint8 y,no,atr,x;
+} SPR __attribute__((aligned(1)));
+
+typedef struct {
+  //   uint8 ca[2],atr,x; 
+       uint8 ca[2],atr,x; 
+  //  union {  int z; }
+  
+
+} SPRB __attribute__((aligned(1)));
+
+
+
+static uint8 nosprites,SpriteBlurp;
+
+void FetchSpriteData(void)
+{
+       SPR *spr;
+       uint8 H;
+       int n,vofs;
+
+       spr=(SPR *)SPRAM;
+       H=8;
+
+       nosprites=SpriteBlurp=0;
+
+        vofs=(unsigned int)(PPU[0]&0x8&(((PPU[0]&0x20)^0x20)>>2))<<9;
+       H+=(PPU[0]&0x20)>>2;
+
+        if(!PPU_hook)
+         for(n=63;n>=0;n--,spr++)
+         {
+                if((unsigned int)(scanline-spr->y)>=H) continue;
+
+                if(nosprites<maxsprites)
+                {
+                 if(n==63) SpriteBlurp=1;
+
+                {
+                 SPRB dst;
+                 uint8 *C;
+                  int t;
+                  unsigned int vadr;
+
+                  t = (int)scanline-(spr->y);
+
+                  if (Sprite16)
+                   vadr = ((spr->no&1)<<12) + ((spr->no&0xFE)<<4);
+                  else
+                   vadr = (spr->no<<4)+vofs;
+
+                  if (spr->atr&V_FLIP)
+                  {
+                        vadr+=7;
+                        vadr-=t;
+                        vadr+=(PPU[0]&0x20)>>1;
+                        vadr-=t&8;
+                  }
+                  else
+                  {
+                        vadr+=t;
+                        vadr+=t&8;
+                  }
+
+                 /* Fix this geniestage hack */
+                 if(MMC5Hack && geniestage!=1) C = MMC5SPRVRAMADR(vadr);
+                  else C = VRAMADR(vadr);
+
+                 
+                 dst.ca[0]=C[0];
+                 dst.ca[1]=C[8];
+                 dst.x=spr->x;
+                 dst.atr=spr->atr;
+
+
+                 *(uint32 *)&SPRBUF[nosprites<<2]=*(uint32 *)&dst;
+                }
+
+                 nosprites++;
+                }
+                else
+                {
+                  PPU_status|=0x20;
+                  break;
+                }
+         }
+       else
+         for(n=63;n>=0;n--,spr++)
+         {
+                if((unsigned int)(scanline-spr->y)>=H) continue;
+
+                if(nosprites<maxsprites)
+                {
+                 if(n==63) SpriteBlurp=1;
+
+                 {
+                  SPRB dst;
+                  uint8 *C;
+                  int t;
+                  unsigned int vadr;
+
+                  t = (int)scanline-(spr->y);
+
+                  if (Sprite16)
+                   vadr = ((spr->no&1)<<12) + ((spr->no&0xFE)<<4);
+                  else
+                   vadr = (spr->no<<4)+vofs;
+
+                  if (spr->atr&V_FLIP)
+                  {
+                        vadr+=7;
+                        vadr-=t;
+                        vadr+=(PPU[0]&0x20)>>1;
+                        vadr-=t&8;
+                  }
+                  else
+                  {
+                        vadr+=t;
+                        vadr+=t&8;
+                  }
+
+                  if(MMC5Hack) C = MMC5SPRVRAMADR(vadr);
+                  else C = VRAMADR(vadr);
+                  dst.ca[0]=C[0];
+                 PPU_hook(vadr);
+                  dst.ca[1]=C[8];
+                 PPU_hook(vadr|8);
+                  dst.x=spr->x;
+                  dst.atr=spr->atr;
+
+
+                  *(uint32 *)&SPRBUF[nosprites<<2]=*(uint32 *)&dst;
+                 }
+
+                 nosprites++;
+                }
+                else
+                {
+                  PPU_status|=0x20;
+                  break;
+                }
+         }
+}
+
+#ifdef FRAMESKIP
+extern int FSkip;
+#endif
+
+void RefreshSprite(uint8 *target)
+{
+       int n;
+        SPRB *spr;
+        uint8 *P=target;
+
+        if(!nosprites) return;
+       #ifdef FRAMESKIP
+       if(FSkip)
+       {
+        if(!SpriteBlurp)
+        {
+         nosprites=0;
+         return;
+        }
+        else
+         nosprites=1;
+       }
+       #endif
+
+        FCEU_dwmemset(sprlinebuf,0x80808080,256);
+        nosprites--;
+        spr = (SPRB*)SPRBUF+nosprites;
+
+       for(n=nosprites;n>=0;n--,spr--)
+       {
+        register uint8 J,atr,c1,c2;
+       int x=spr->x;
+        uint8 *C;
+        uint8 *VB;
+                
+        P+=x;
+
+        c1=((spr->ca[0]>>1)&0x55)|(spr->ca[1]&0xAA);
+       c2=(spr->ca[0]&0x55)|((spr->ca[1]<<1)&0xAA);
+
+        J=spr->ca[0]|spr->ca[1];
+       atr=spr->atr;
+
+                       if(J)
+                       {        
+                        if(n==0 && SpriteBlurp && !(PPU_status&0x40))
+                        {  
+                        int z,ze=x+8;
+                        if(ze>256) {ze=256;}
+                        if(ScreenON && (scanline<FSettings.FirstSLine || scanline>FSettings.LastSLine
+                        #ifdef FRAMESKIP
+                        || FSkip
+                        #endif
+                        ))
+                         BGRender(target);
+
+                        if(!(atr&H_FLIP))
+                        {
+                         for(z=x;z<ze;z++)
+                         {
+                          if(J&(0x80>>(z-x)))
+                          {
+                           if(!(target[z]&64))
+                            tosprite=z;
+                          }
+                         }
+                        }
+                        else
+                        {
+                          for(z=x;z<ze;z++)
+                          {
+                           if(J&(1<<(z-x)))
+                           {
+                            if(!(target[z]&64))
+                             tosprite=z;
+                           }
+                          }
+                        }
+                        //FCEU_DispMessage("%d, %d:%d",scanline,x,tosprite);
+                        }
+
+        C = sprlinebuf+x;
+         VB = (PALRAM+0x10)+((atr&3)<<2);
+
+         if(atr&SP_BACK) 
+         {
+          if (atr&H_FLIP)
+          {
+           if (J&0x02)  C[1]=VB[c1&3]|0x40;
+           if (J&0x01)  *C=VB[c2&3]|0x40;
+           c1>>=2;c2>>=2;
+           if (J&0x08)  C[3]=VB[c1&3]|0x40;;
+           if (J&0x04)  C[2]=VB[c2&3]|0x40;;
+           c1>>=2;c2>>=2;
+           if (J&0x20)  C[5]=VB[c1&3]|0x40;;
+           if (J&0x10)  C[4]=VB[c2&3]|0x40;;
+           c1>>=2;c2>>=2;
+           if (J&0x80)  C[7]=VB[c1]|0x40;;
+           if (J&0x40)  C[6]=VB[c2]|0x40;;
+         } else  {
+           if (J&0x02)  C[6]=VB[c1&3]|0x40;
+           if (J&0x01)  C[7]=VB[c2&3]|0x40;
+          c1>>=2;c2>>=2;
+           if (J&0x08)  C[4]=VB[c1&3]|0x40;
+           if (J&0x04)  C[5]=VB[c2&3]|0x40;
+           c1>>=2;c2>>=2;
+           if (J&0x20)  C[2]=VB[c1&3]|0x40;
+           if (J&0x10)  C[3]=VB[c2&3]|0x40;
+           c1>>=2;c2>>=2;
+           if (J&0x80)  *C=VB[c1]|0x40;
+           if (J&0x40)  C[1]=VB[c2]|0x40;
+         }
+         } else {
+          if (atr&H_FLIP)
+         {
+           if (J&0x02)  C[1]=VB[(c1&3)];
+           if (J&0x01)  *C=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x08)  C[3]=VB[(c1&3)];
+           if (J&0x04)  C[2]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x20)  C[5]=VB[(c1&3)];
+           if (J&0x10)  C[4]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x80)  C[7]=VB[c1];
+           if (J&0x40)  C[6]=VB[c2];
+          }else{                 
+           if (J&0x02)  C[6]=VB[(c1&3)];
+           if (J&0x01)  C[7]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x08)  C[4]=VB[(c1&3)];
+           if (J&0x04)  C[5]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x20)  C[2]=VB[(c1&3)];
+           if (J&0x10)  C[3]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x80)  *C=VB[c1];
+           if (J&0x40)  C[1]=VB[c2];
+          }
+         }
+        }
+       P-=x;
+      }
+
+     nosprites=0;
+     #ifdef FRAMESKIP
+     if(FSkip) return;
+     #endif
+
+     {
+      uint8 n=((PPU[1]&4)^4)<<1;
+      loopskie:
+      {
+       uint32 t=*(uint32 *)(sprlinebuf+n);
+       if(t!=0x80808080)
+       {
+       #ifdef LSB_FIRST
+        if(!(t&0x80))
+        {
+         if(!(t&0x40))       // Normal sprite
+          P[n]=sprlinebuf[n];
+         else if(P[n]&64)        // behind bg sprite
+          P[n]=sprlinebuf[n];
+        }
+
+        if(!(t&0x8000))
+        {
+         if(!(t&0x4000))       // Normal sprite
+          P[n+1]=(sprlinebuf+1)[n];
+         else if(P[n+1]&64)        // behind bg sprite
+          P[n+1]=(sprlinebuf+1)[n];
+        }
+
+        if(!(t&0x800000))
+        {
+         if(!(t&0x400000))       // Normal sprite
+          P[n+2]=(sprlinebuf+2)[n];
+         else if(P[n+2]&64)        // behind bg sprite
+          P[n+2]=(sprlinebuf+2)[n];
+        }
+
+        if(!(t&0x80000000))
+        {
+         if(!(t&0x40000000))       // Normal sprite
+          P[n+3]=(sprlinebuf+3)[n];
+         else if(P[n+3]&64)        // behind bg sprite
+          P[n+3]=(sprlinebuf+3)[n];
+        }
+       #else
+        if(!(t&0x80000000))
+        {
+         if(!(t&0x40))       // Normal sprite
+          P[n]=sprlinebuf[n];
+         else if(P[n]&64)        // behind bg sprite
+          P[n]=sprlinebuf[n];
+        }
+
+        if(!(t&0x800000))
+        {
+         if(!(t&0x4000))       // Normal sprite
+          P[n+1]=(sprlinebuf+1)[n];
+         else if(P[n+1]&64)        // behind bg sprite
+          P[n+1]=(sprlinebuf+1)[n];
+        }
+
+        if(!(t&0x8000))
+        {
+         if(!(t&0x400000))       // Normal sprite
+          P[n+2]=(sprlinebuf+2)[n];
+         else if(P[n+2]&64)        // behind bg sprite
+          P[n+2]=(sprlinebuf+2)[n];
+        }
+
+        if(!(t&0x80))
+        {
+         if(!(t&0x40000000))       // Normal sprite
+          P[n+3]=(sprlinebuf+3)[n];
+         else if(P[n+3]&64)        // behind bg sprite
+          P[n+3]=(sprlinebuf+3)[n];
+        }
+       #endif
+       }
+      }
+      n+=4;
+      if(n) goto loopskie;
+     }
+}
+
+
+
+
+
+/*
+void FetchSpriteData(void)
+{
+        uint8 ns,sb;
+        SPR *spr;
+        uint8 H;
+       int n;
+       int vofs;
+        uint8 P0=PPU[0];
+
+        
+        spr=(SPR *)SPRAM;
+        H=8;
+
+        ns=sb=0;
+
+        vofs=(unsigned int)(P0&0x8&(((P0&0x20)^0x20)>>2))<<9;
+        H+=(P0&0x20)>>2;
+
+        if(!PPU_hook)
+         for(n=63;n>=0;n--,spr++)
+         {
+                if((unsigned int)(scanline-spr->y)>=H) continue;
+                //printf("%d, %u\n",scanline,(unsigned int)(scanline-spr->y));
+                if(ns<maxsprites)
+                {
+                 if(n==63) sb=1;
+
+                 {
+                  SPRB dst;
+                  uint8 *C;
+                  int t;
+                  unsigned int vadr;
+
+                  t = (int)scanline-(spr->y);
+
+                  if (Sprite16)
+                   vadr = ((spr->no&1)<<12) + ((spr->no&0xFE)<<4);
+                  else
+                   vadr = (spr->no<<4)+vofs;
+
+                  if (spr->atr&V_FLIP)
+                  {
+                        vadr+=7;
+                        vadr-=t;
+                        vadr+=(P0&0x20)>>1;
+                        vadr-=t&8;
+                  }
+                  else
+                  {
+                        vadr+=t;
+                        vadr+=t&8;
+                  }
+
+                  // Fix this geniestage hack 
+                  if(MMC5Hack && geniestage!=1) C = MMC5SPRVRAMADR(vadr);
+                  else C = VRAMADR(vadr);
+
+                  
+                  dst.ca[0]=C[0];
+                  dst.ca[1]=C[8];
+                  dst.x=spr->x;
+                  dst.atr=spr->atr;
+
+                  *(uint32 *)&SPRBUF[ns<<2]=*(uint32 *)&dst;
+                 }
+
+                 ns++;
+                }
+                else
+                {
+                  PPU_status|=0x20;
+                  break;
+                }
+         }
+        else
+         for(n=63;n>=0;n--,spr++)
+         {
+                if((unsigned int)(scanline-spr->y)>=H) continue;
+
+                if(ns<maxsprites)
+                {
+                 if(n==63) sb=1;
+
+                 {
+                  SPRB dst;
+                  uint8 *C;
+                  int t;
+                  unsigned int vadr;
+
+                  t = (int)scanline-(spr->y);
+
+                  if (Sprite16)
+                   vadr = ((spr->no&1)<<12) + ((spr->no&0xFE)<<4);
+                  else
+                   vadr = (spr->no<<4)+vofs;
+
+                  if (spr->atr&V_FLIP)
+                  {
+                        vadr+=7;
+                        vadr-=t;
+                        vadr+=(P0&0x20)>>1;
+                        vadr-=t&8;
+                  }
+                  else
+                  {
+                        vadr+=t;
+                        vadr+=t&8;
+                  }
+
+                  if(MMC5Hack) C = MMC5SPRVRAMADR(vadr);
+                  else C = VRAMADR(vadr);
+                  dst.ca[0]=C[0];
+                 if(ns<8)
+                 {
+                  PPU_hook(0x2000);
+                   PPU_hook(vadr);
+                 }
+                  dst.ca[1]=C[8];
+                  dst.x=spr->x;
+                  dst.atr=spr->atr;
+
+
+                  *(uint32 *)&SPRBUF[ns<<2]=*(uint32 *)&dst;
+                 }
+
+                 ns++;
+                }
+                else
+                {
+                  PPU_status|=0x20;
+                  break;
+                }
+         }
+        //if(ns>=7)
+        //printf("%d %d\n",scanline,ns);
+        if(ns>8) PPU_status|=0x20;     // Handle case when >8 sprites per
+//                                scanline option is enabled. 
+       else if(PPU_hook)
+       {
+        for(n=0;n<(8-ns);n++)
+        {
+                 PPU_hook(0x2000);
+                 PPU_hook(vofs);
+        }
+       }
+        numsprites=ns;
+        SpriteBlurp=sb;
+}
+
+
+
+void RefreshSprite(uint8 *target)
+{
+      
+       int n,sprindex;
+       SPRB *spr;
+        uint8 *P=target;
+
+        //if (printed) {  printf("SPRB: %d  SPR: %d\n", sizeof(SPRB), sizeof(SPR)); printed=0; }
+        if(!numsprites) return;
+
+        FCEU_dwmemset(sprlinebuf,0x80808080,256);
+
+        numsprites--;
+        sprindex=numsprites;
+        spr = (SPRB*)SPRBUF;
+
+       //       for(n=nosprites;n>=0;n--,spr--)
+       for(n=numsprites;n>=0;n--,sprindex--)
+       {
+        uint8 J,atr,c1,c2;
+       int x=spr[sprindex].x;
+        uint8 *C;
+        uint8 *VB;
+                
+        P+=x;
+
+        c1=((spr[sprindex].ca[0]>>1)&0x55)|(spr[sprindex].ca[1]&0xAA);
+       c2=(spr[sprindex].ca[0]&0x55)|((spr[sprindex].ca[1]<<1)&0xAA);
+
+        J=spr[sprindex].ca[0]|spr[sprindex].ca[1];
+       atr=spr[sprindex].atr;
+
+                       if(J)
+                       {        
+                        if(n==0 && SpriteBlurp && !(PPU_status&0x40))
+                        {  
+                        int z,ze=x+8;
+                        if(ze>256) {ze=256;}
+                        if(ScreenON && (scanline<FSettings.FirstSLine || scanline>FSettings.LastSLine
+                        #ifdef FRAMESKIP
+                        || FSkip
+                        #endif
+                        ))
+                          // nothing wrong with this
+                        BGRender(target);
+
+                        if(!(atr&H_FLIP))
+                        {
+                         for(z=x;z<ze;z++)
+                         {
+                          if(J&(0x80>>(z-x)))
+                          {
+                           if(!(target[z]&64))
+                            tosprite=z;
+                          }
+                         }
+                        }
+                        else
+                        {
+                          for(z=x;z<ze;z++)
+                          {
+                           if(J&(1<<(z-x)))
+                           {
+                            if(!(target[z]&64))
+                             tosprite=z;
+                           }
+                          }
+                        }
+                        //FCEU_DispMessage("%d, %d:%d",scanline,x,tosprite);
+                        }
+
+        //C = sprlinebuf+(uint8)x;
+        C = &(sprlinebuf[(uint8)x]);
+         VB = (PALRAM+0x10)+((atr&3)<<2);
+
+         if(atr&SP_BACK) 
+         {
+          if (atr&H_FLIP)
+          {
+           if (J&0x02)  C[1]=VB[c1&3]|0x40;
+           if (J&0x01)  *C=VB[c2&3]|0x40;
+           c1>>=2;c2>>=2;
+           if (J&0x08)  C[3]=VB[c1&3]|0x40;
+           if (J&0x04)  C[2]=VB[c2&3]|0x40;
+           c1>>=2;c2>>=2;
+           if (J&0x20)  C[5]=VB[c1&3]|0x40;
+           if (J&0x10)  C[4]=VB[c2&3]|0x40;
+           c1>>=2;c2>>=2;
+           if (J&0x80)  C[7]=VB[c1]|0x40;
+           if (J&0x40)  C[6]=VB[c2]|0x40;
+         } else  {
+           if (J&0x02)  C[6]=VB[c1&3]|0x40;
+           if (J&0x01)  C[7]=VB[c2&3]|0x40;
+          c1>>=2;c2>>=2;
+           if (J&0x08)  C[4]=VB[c1&3]|0x40;
+           if (J&0x04)  C[5]=VB[c2&3]|0x40;
+           c1>>=2;c2>>=2;
+           if (J&0x20)  C[2]=VB[c1&3]|0x40;
+           if (J&0x10)  C[3]=VB[c2&3]|0x40;
+           c1>>=2;c2>>=2;
+           if (J&0x80)  *C=VB[c1]|0x40;
+           if (J&0x40)  C[1]=VB[c2]|0x40;
+         }
+         } else {
+          if (atr&H_FLIP)
+         {
+           if (J&0x02)  C[1]=VB[(c1&3)];
+           if (J&0x01)  *C=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x08)  C[3]=VB[(c1&3)];
+           if (J&0x04)  C[2]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x20)  C[5]=VB[(c1&3)];
+           if (J&0x10)  C[4]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x80)  C[7]=VB[c1];
+           if (J&0x40)  C[6]=VB[c2];
+          }else{                 
+           if (J&0x02)  C[6]=VB[(c1&3)];
+           if (J&0x01)  C[7]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x08)  C[4]=VB[(c1&3)];
+           if (J&0x04)  C[5]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x20)  C[2]=VB[(c1&3)];
+           if (J&0x10)  C[3]=VB[(c2&3)];
+           c1>>=2;c2>>=2;
+           if (J&0x80)  *C=VB[c1];
+           if (J&0x40)  C[1]=VB[c2];
+          }
+         }
+        }
+       P-=x;
+      }
+
+     numsprites=0;
+     #ifdef FRAMESKIP
+     if(FSkip) return;
+     #endif
+
+     {
+      uint8 n=((PPU[1]&4)^4)<<1;
+      loopskie:
+      {
+       uint32 t=*((uint32 *)(&(sprlinebuf[n])));
+       if(t!=0x80808080)
+       {
+       #ifdef LSB_FIRST
+        if(!(t&0x80))
+        {
+         if(!(t&0x40))       // Normal sprite
+          P[n]=sprlinebuf[n];
+         else if(P[n]&64)        // behind bg sprite
+          P[n]=sprlinebuf[n];
+        }
+
+        if(!(t&0x8000))
+        {
+         if(!(t&0x4000))       // Normal sprite
+          P[n+1]=(sprlinebuf+1)[n];
+         else if(P[n+1]&64)        // behind bg sprite
+          P[n+1]=(sprlinebuf+1)[n];
+        }
+
+        if(!(t&0x800000))
+        {
+         if(!(t&0x400000))       // Normal sprite
+          P[n+2]=(sprlinebuf+2)[n];
+         else if(P[n+2]&64)        // behind bg sprite
+          P[n+2]=(sprlinebuf+2)[n];
+        }
+
+        if(!(t&0x80000000))
+        {
+         if(!(t&0x40000000))       // Normal sprite
+          P[n+3]=(sprlinebuf+3)[n];
+         else if(P[n+3]&64)        // behind bg sprite
+          P[n+3]=(sprlinebuf+3)[n];
+        }
+       #else
+        if(!(t&0x80000000))
+        {
+         if(!(t&0x40))       // Normal sprite
+          P[n]=sprlinebuf[n];
+         else if(P[n]&64)        // behind bg sprite
+          P[n]=sprlinebuf[n];
+        }
+
+        if(!(t&0x800000))
+        {
+         if(!(t&0x4000))       // Normal sprite
+          P[n+1]=(sprlinebuf+1)[n];
+         else if(P[n+1]&64)        // behind bg sprite
+          P[n+1]=(sprlinebuf+1)[n];
+        }
+
+        if(!(t&0x8000))
+        {
+         if(!(t&0x400000))       // Normal sprite
+          P[n+2]=(sprlinebuf+2)[n];
+         else if(P[n+2]&64)        // behind bg sprite
+          P[n+2]=(sprlinebuf+2)[n];
+        }
+
+        if(!(t&0x80))
+        {
+         if(!(t&0x40000000))       // Normal sprite
+          P[n+3]=(sprlinebuf+3)[n];
+         else if(P[n+3]&64)        // behind bg sprite
+          P[n+3]=(sprlinebuf+3)[n];
+        }
+       #endif
+       }
+      }
+      n+=4;
+      if(n) goto loopskie;
+     }
+}
+
+
+*/
diff --git a/ppu.h b/ppu.h
new file mode 100644 (file)
index 0000000..b1b30ba
--- /dev/null
+++ b/ppu.h
@@ -0,0 +1,5 @@
+
+extern uint8 SPRAM[0x100];
+//extern uint8 SPRBUF[0x100];
+extern void FetchSpriteData(void);
+extern void RefreshSprite(uint8 *target);