cleanups, warning fixes
authornotaz <notasas@gmail.com>
Sat, 7 Apr 2007 23:39:07 +0000 (23:39 +0000)
committernotaz <notasas@gmail.com>
Sat, 7 Apr 2007 23:39:07 +0000 (23:39 +0000)
git-svn-id: file:///home/notaz/opt/svn/fceu@98 be3aeb3a-fb24-0410-a615-afba39da0efa

14 files changed:
Makefile.gp2x
driver.h
drivers/gp2x/dface.h
drivers/gp2x/gp2x-sound.c [new file with mode: 0644]
drivers/gp2x/gp2x-video.c [moved from drivers/gp2x/sdl-video.c with 98% similarity]
drivers/gp2x/gp2x-video.h [moved from drivers/gp2x/sdl-video.h with 100% similarity]
drivers/gp2x/gp2x.c [moved from drivers/gp2x/sdl.c with 95% similarity]
drivers/gp2x/gp2x.h [moved from drivers/gp2x/sdl.h with 100% similarity]
drivers/gp2x/main.c
drivers/gp2x/minimal.c
drivers/gp2x/minimal.h
drivers/gp2x/sdl-sound.c [deleted file]
state.c
svga.c

index be2070a..b376ce6 100644 (file)
@@ -2,7 +2,7 @@ CC      = arm-linux-gcc
 STRIP  = arm-linux-strip
 TFLAGS  = -mcpu=arm920t -Izlib -DGP2X=1 -DLSB_FIRST -DSDL -DUNIX -DPSS_STYLE=1 -DZLIB -DFRAMESKIP -D_REENTRANT
 RM     = rm -f
-B      = drivers/pc/
+B      = drivers/gp2x/
 ifdef DEBUG
 TFLAGS += -ggdb
 else
@@ -16,18 +16,17 @@ gpfce: fceu
 
 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}lnx-joystick.o drivers/common/cheat.o drivers/common/config.o drivers/common/args.o drivers/common/vidblit.o ${UNZIPOBJS} ppu.o
+OBJDRIVER      = ${B}minimal.o ${B}gp2x.o ${B}main.o ${B}throttle.o ${B}unix-netplay.o ${B}gp2x-sound.o ${B}gp2x-video.o ${B}lnx-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}lnx-joystick.o:    ${B}lnx-joystick.c
 ${B}main.o:            ${B}main.c ${B}main.h ${B}usage.h ${B}input.c
-${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}gp2x.o:            ${B}gp2x.c ${B}gp2x.h
+${B}gp2x-video.o:      ${B}gp2x-video.c
+${B}gp2x-video.o:      ${B}minimal.c
+${B}gp2x-sound.o:      ${B}gp2x-sound.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
index 9a298c6..f5c06c1 100644 (file)
--- a/driver.h
+++ b/driver.h
@@ -3,7 +3,7 @@
 
 /* Prototypes for platform interface functions follow: */
 
-void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
+void FCEUD_Update(uint8 *XBuf, int16 *Buffer, int Count);
 
 /* Video interface */
 void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b);
index 92df082..6ff4459 100644 (file)
@@ -6,7 +6,7 @@ void DoDriverArgs(void);
 void GetBaseDirectory(char *BaseDirectory);
 
 int InitSound(void);
-void WriteSound(int32 *Buffer, int Count, int NoWaiting);
+void WriteSound(int16 *Buffer, int Count, int NoWaiting);
 void KillSound(void);
 void SilenceSound(int s); /* DOS and SDL */
 
diff --git a/drivers/gp2x/gp2x-sound.c b/drivers/gp2x/gp2x-sound.c
new file mode 100644 (file)
index 0000000..30934bc
--- /dev/null
@@ -0,0 +1,80 @@
+/* FCE Ultra - NES/Famicom Emulator
+ *
+ * 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 <string.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <linux/soundcard.h>
+
+#include "gp2x.h"
+#include "minimal.h"
+#include "throttle.h"
+
+
+extern int soundvol;
+extern unsigned long gp2x_dev[8];
+
+// always have this call
+INLINE void gp2x_sound_frame(void *blah, void *buff, int samples)
+{
+}
+
+void WriteSound(int16 *Buffer, int Count)
+{
+       write(gp2x_dev[3], Buffer, Count<<1);
+       SpeedThrottle();
+}
+
+void* gp2x_write_sound(void* blah)
+{
+       return NULL;
+}
+
+void SilenceSound(int n)
+{
+       soundvol=0;
+}
+
+int InitSound(FCEUGI *gi)
+{
+       Settings.sound=22050;
+       FCEUI_Sound(Settings.sound);
+       gp2x_sound_volume(soundvol, soundvol);
+       printf("InitSound() sound_rate: %d\n", Settings.sound);
+       return 1;
+}
+
+uint32 GetMaxSound(void)
+{
+       return(4096);
+}
+
+uint32 GetWriteSound(void)
+{
+       return 1024;
+}
+
+int KillSound(void)
+{
+       FCEUI_Sound(0);
+
+       return 1;
+}
+
similarity index 98%
rename from drivers/gp2x/sdl-video.c
rename to drivers/gp2x/gp2x-video.c
index 9a4e787..6433724 100644 (file)
 #include <string.h>
 #include <sys/time.h>
 
-#include "sdl.h"
-//#include "../common/vidblit.h"
-
-
+#include "gp2x.h"
 #include "minimal.h"
 
 extern int showfps;
@@ -191,7 +188,7 @@ static INLINE void printFps(uint8 *screen)
        gettimeofday(&tv_now, 0);
        if (prevsec != tv_now.tv_sec)
        {
-               sprintf(fps_str, "%i/%i", framesRendered, framesEmulated);
+               sprintf(fps_str, "%2i/%2i", framesRendered, framesEmulated);
                framesEmulated = framesRendered = 0;
                needfpsflip = 4;
                prevsec = tv_now.tv_sec;
similarity index 95%
rename from drivers/gp2x/sdl.c
rename to drivers/gp2x/gp2x.c
index 7826c8c..0f3b9aa 100644 (file)
@@ -1,18 +1,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <pthread.h>
 
-#include "sdl.h"
-#include "sdl-video.h"
+#include "gp2x.h"
+#include "gp2x-video.h"
 #ifdef NETWORK
 #include "unix-netplay.h"
 #endif
 #include "minimal.h"
-//extern int soundvol;
+
 int CLImain(int argc, char *argv[]);
-extern int gp2x_in_sound_thread;
-extern void pthread_yield(void);
 extern void SetVideoScaling(int, int, int);
 
 //#define SOUND_RATE 44100
@@ -229,8 +226,6 @@ int main(int argc, char *argv[])
 
         gp2x_deinit();
         // make sure sound thread has exited cleanly
-        while (gp2x_in_sound_thread) pthread_yield();
-        printf("Sound thread exited\n");
         printf("Exiting main().  terminated");
         if (showfps && swapbuttons)
         {
similarity index 100%
rename from drivers/gp2x/sdl.h
rename to drivers/gp2x/gp2x.h
index d2be777..fc9c7b6 100644 (file)
@@ -373,7 +373,7 @@ static void DriverKill(void)
  inited=0;
 }
 
-void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
+void FCEUD_Update(uint8 *XBuf, int16 *Buffer, int Count)
 {
  if(!Count && !NoWaiting && !(eoptions&EO_NOTHROTTLE))
   SpeedThrottle();
index 193fa9e..369a1c9 100644 (file)
 
   0.9: initial FIFO message system for dual cpu cores.
        initial 48 Mb support.
-       initial quadruple buffering in 8bbp mode.              
+       initial quadruple buffering in 8bbp mode.
 
        added functions:
-        - gp2x_dualcore_exec() ; initial FIFO message system for dual cpu cores. 
+        - 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.              
+        - gp2x_video_flip()    ; initial quadruple buffering in 8bbp mode.
 
   0.8: initial dual cores cpu support.
        very basic blit functions by popular demand ;-)
 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);
 
@@ -129,9 +128,9 @@ 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_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);
@@ -142,9 +141,9 @@ void gp2x_video_flip_single(void)
 {
   unsigned long address=gp2x_physvram[0];
 
-  gp2x_screen15=gp2x_logvram15[0]; 
-  gp2x_screen8=(unsigned char *)gp2x_screen15; 
+  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);
@@ -154,16 +153,16 @@ void gp2x_video_flip_single(void)
 
 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; 
+  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++; 
+  gp2x_memregs[0x2958>>1]=0;
+  while(i--) gp2x_memregs[0x295A>>1]=*g++;
 }
 
 void gp2x_blitter_rect15(gp2x_rect *r)
@@ -179,7 +178,7 @@ void gp2x_blitter_rect15(gp2x_rect *r)
 
 void gp2x_blitter_rect8(gp2x_rect *r)
 {
- int x, y; unsigned char *data=r->data8,   *offset=&gp2x_screen8[r->x+r->y*320]; 
+ 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; }
@@ -187,7 +186,7 @@ void gp2x_blitter_rect8(gp2x_rect *r)
          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);
@@ -196,7 +195,7 @@ unsigned long gp2x_joystick_read(void)
   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));
 }
 
@@ -209,54 +208,55 @@ void gp2x_sound_volume(int l, int r)
 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); 
+ 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; }
 
-
+#if 0
 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)  
-  { 
+  while(!gp2x_sound)
+  {
     nanosleep(&ts, NULL);
-                        
-                        
-   if(!gp2x_sound_pausei) 
-   { 
+
+
+   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]; 
+   flyp+=gp2x_sound_buffer[1];
    if(flyp==gp2x_sound_buffer[1]*8) flyp=0;
-   }              
+   }
   }
   return NULL;
 }
+#endif
 
 static void gp2x_initqueue(gp2x_queue *q, unsigned long queue_items, unsigned long *position920t, unsigned long *position940t)
 {
@@ -268,7 +268,7 @@ static void gp2x_initqueue(gp2x_queue *q, unsigned long queue_items, unsigned lo
 }
 
 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++;
@@ -322,7 +322,7 @@ void gp2x_dualcore_exec(unsigned long command) { gp2x_enqueue((gp2x_queue *)gp2x
 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
@@ -330,8 +330,8 @@ void gp2x_dualcore_launch_program(unsigned long *area, unsigned long size)
   gp2x_memregs[0x3B44>>1] = 0xffff;
   gp2x_memregs[0x3B46>>1] = 0xffff;
 
-  gp2x_940t_pause(0);            
-                             
+  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));
@@ -363,16 +363,16 @@ void gp2x_init(int ticks_per_second, int bpp, int rate, int bits, int stereo, in
   int channels=1;
   int stereoLocal=0;
 
-  gp2x_ticks_per_second=7372800/ticks_per_second; 
+  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); 
-  
+  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[3])   gp2x_dev[3] = open("/dev/dsp",   O_WRONLY|O_ASYNC);
     if(!gp2x_dev[4])   gp2x_dev[4] = open("/dev/mixer", O_RDWR);
   }
 
@@ -382,12 +382,12 @@ void gp2x_init(int ticks_per_second, int bpp, int rate, int bits, int stereo, in
         gp2x_memregs=(unsigned short *)gp2x_memregl;
 
   if(first) { printf(MINILIB_VERSION "\n");
-              gp2x_dualcore_registers(1); 
+              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); 
+  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;
@@ -403,12 +403,12 @@ void gp2x_init(int ticks_per_second, int bpp, int rate, int bits, int stereo, in
   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; 
+             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);
 
@@ -417,15 +417,15 @@ void gp2x_init(int ticks_per_second, int bpp, int rate, int bits, int stereo, in
 
     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; 
+    if(first)
+    {
+      first=0;
     }
-  }  
+  }
 
 }
 
@@ -438,19 +438,19 @@ void gp2x_deinit(void)
   gp2x_dualcore_registers(0);
 
   gp2x_memregs[0x28DA>>1]=0x4AB;                               //set video mode
-  gp2x_memregs[0x290C>>1]=640;   
+  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;
+        float xscale,yscale=0;
 
         int bpp=(gp2x_memregs[0x28DA>>1]>>9)&0x3;  /* bytes per pixel */
 
@@ -462,7 +462,7 @@ void SetVideoScaling(int pixels,int width,int height)
                 else if (gp2x_memregs[0x2818>>1]  == 239) /* NTSC? */
                         yscale=(pixels*331.0)/320.0; /* Y-Scale with NTSC */
         }
-        else /* TV-Out OFF? */ 
+        else /* TV-Out OFF? */
         {
                 xscale=1024.0; /* X-Scale for LCD */
                 yscale=pixels; /* Y-Scale for LCD */
index 53127b9..ecafd75 100644 (file)
@@ -16,7 +16,6 @@
 \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
@@ -68,7 +67,7 @@ enum  { GP2X_UP=0x1,       GP2X_LEFT=0x4,       GP2X_DOWN=0x10,  GP2X_RIGHT=0x40
 #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
+\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
diff --git a/drivers/gp2x/sdl-sound.c b/drivers/gp2x/sdl-sound.c
deleted file mode 100644 (file)
index 6693222..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/* FCE Ultra - NES/Famicom Emulator
- *
- * Copyright notice for this file:
- *  Copyright (C) 2002 Xodnizel
- *
- * 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 <string.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <linux/soundcard.h>
-
-#include "sdl.h"
-#include "minimal.h"
-
-#define GP2X_SOUND 1
-
-extern void pthread_yield(void);
-extern void FCEUI_FrameSkip(int x);
-
-//extern int dosound;
-extern int soundvol;
-
-// always have this call
-INLINE void gp2x_sound_frame(void *blah, void *buff, int samples)
- {
-}
-
-
-
-
-
-//static int sexy_in_function=0;
-#define NumSexyBufferBuffers 2
-struct timespec gp2x_sleep_ts;
-int firstentry=1;
-//int firstprint=1;
-struct timeval sleeptimer;
-
-
-
-pthread_t       gp2x_sexy_sound_thread=0;
-int**  SexyBufferBuffers=NULL;
-int    SexyBufferBufferCounts[NumSexyBufferBuffers];
-int  gp2x_sound_inited=0;
-int gp2x_in_sound_thread=0;
-extern unsigned long   gp2x_dev[8];
-
-pthread_cond_t gp2x_sound_cond=PTHREAD_COND_INITIALIZER;
-pthread_mutex_t gp2x_sound_mutex = PTHREAD_MUTEX_INITIALIZER;
-int zzdebug01_entry=0;
-int zzdebug01_wait=0;
-int hasSound=0;
-extern unsigned long fps;
-extern unsigned long avg_fps;
-extern unsigned long ticks;
-
-int throttlecount=0;
-
-void WriteSound(int32 *Buffer, int Count)
-  {
-  write(gp2x_dev[3], Buffer, Count<<1);
-  pthread_yield();
-  SpeedThrottle();
-  }
-
-void* gp2x_write_sound(void* blah)
-  {
-  gp2x_in_sound_thread=1;
-  {
-    if (hasSound)
-  {
-      hasSound=0;
-  }
-    else
-  {
-  }
-
- }
-  gp2x_in_sound_thread=0;
-  return NULL;
-}
-
-void SilenceSound(int n)
-{
-  soundvol=0;
-}
-
-int InitSound(FCEUGI *gi)
-{
-  Settings.sound=22050;
-  FCEUI_Sound(Settings.sound);
-  gp2x_sound_volume(soundvol, soundvol);
-  printf("InitSound() sound_rate: %d\n", Settings.sound);
-  if(firstentry)
-  {
-      firstentry=0;
-      gp2x_sound_inited=1;
-  }
-  return 1 ;
-}
-
-uint32 GetMaxSound(void)
-{
- return(4096);
-}
-
-uint32 GetWriteSound(void)
-        {
- return 1024;
-}
-
-int KillSound(void)
-{
-  FCEUI_Sound(0);
-  gp2x_sound_inited=0;
-
-  return 1;
-}
-
-
-
-
diff --git a/state.c b/state.c
index 058b30c..871ef80 100644 (file)
--- a/state.c
+++ b/state.c
@@ -120,7 +120,7 @@ int WriteStateChunk(FILE *st, int type, SFORMAT *sf, int count)
  int x;
 
  fputc(type,st);
+
  for(x=bsize=0;x<count;x++)
   bsize+=sf[x].s&(~RLSB);
  bsize+=count<<3;
@@ -195,7 +195,7 @@ int ReadStateChunk(FILE *st, SFORMAT *sf, int count, int size)
      if(sf[x].s&RLSB)
      {
       int z;
-       for(z=(sf[x].s&(~RLSB))-1;z>=0;z--)       
+       for(z=(sf[x].s&(~RLSB))-1;z>=0;z--)
         *(uint8*)sf[x].v=fgetc(st);
      }
      else
@@ -305,7 +305,7 @@ void SaveState(void)
        //  totalsize+=WriteStateChunk(st,4,SFCTLR,SFCTLRELEMENTS);
          totalsize+=WriteStateChunk(st,5,SFSND,SFSNDELEMENTS);
          totalsize+=WriteStateChunk(st,0x10,SFMDATA,SFEXINDEX);
-       
+
          fseek(st,4,SEEK_SET);
          write32(totalsize,st);
          SaveStateStatus[CurrentState]=1;
@@ -337,7 +337,7 @@ void LoadState(void)
          fread(&header,1,16,st);
          if(memcmp(header,"FCS",3))
          {
-          fseek(st,0,SEEK_SET);    
+          fseek(st,0,SEEK_SET);
           if(!LoadStateOld(st))
            goto lerror;
           goto okload;
@@ -379,7 +379,7 @@ void CheckStates(void)
        FILE *st=NULL;
        int ssel;
 
-       if(SaveStateStatus[0]==-1)
+       if(SaveStateStatus[0]==(char)-1)
         for(ssel=0;ssel<10;ssel++)
         {
          st=fopen(FCEU_MakeFName(FCEUMKF_STATE,ssel,0),"rb");
@@ -484,7 +484,7 @@ static int LoadStateOld(FILE *st)
        int32 nada;
         uint8 version;
        nada=0;
-       
+
        StateBuffer=FCEU_malloc(59999);
        if(StateBuffer==NULL)
          return 0;
@@ -523,7 +523,7 @@ static int LoadStateOld(FILE *st)
        afread(&nada,1,1);
        afread(&nada,1,1);
        afread(&nada,1,1);
-       
+
        for(x=0;x<8;x++)
                areadupper8of16((int8 *)&CHRBankList[x]);
        afread(PRGBankList,4,1);
@@ -549,7 +549,7 @@ static int LoadStateOld(FILE *st)
        aread16((int8 *)&scanline);
        aread16((int8 *)&RefreshAddr);
        afread(&VRAMBuffer,1,1);
-       
+
        afread(&IRQa,1,1);
        aread32((int8 *)&IRQCount);
        aread32((int8 *)&IRQLatch);
@@ -577,16 +577,16 @@ static int LoadStateOld(FILE *st)
         {
          nada=0;
          afread(&nada,1,1);
-         PPUCHRRAM|=(nada?1:0)<<x;         
+         PPUCHRRAM|=(nada?1:0)<<x;
         }
-                       
+
          afread(mapbyte1,1,8);
          afread(mapbyte2,1,8);
          afread(mapbyte3,1,8);
          afread(mapbyte4,1,8);
          for(x=0;x<4;x++)
           aread16((int8 *)&nada);
-                
+
          PPUNTARAM=0;
          for(x=0;x<4;x++)
          {
@@ -598,7 +598,7 @@ static int LoadStateOld(FILE *st)
          afread(&vtoggle,1,1);
          aread16((int8 *)&TempAddrT);
          aread16((int8 *)&RefreshAddrT);
-                               
+
          if(GameStateRestore) GameStateRestore(version);
          free(StateBuffer);
         FixOldSaveStateSFreq();
diff --git a/svga.c b/svga.c
index a52e035..b632336 100644 (file)
--- a/svga.c
+++ b/svga.c
@@ -1,7 +1,7 @@
 /* FCE Ultra - NES/Famicom Emulator
  *
  * Copyright notice for this file:
- *  Copyright (C) 1998 BERO 
+ *  Copyright (C) 1998 BERO
  *  Copyright (C) 2002 Ben Parnell
  *
  * This program is free software; you can redistribute it and/or modify
@@ -35,7 +35,7 @@
 #endif
 
 #include "types.h"
-#include "svga.h" 
+#include "svga.h"
 #include "fce.h"
 #include "general.h"
 #include "video.h"
@@ -193,7 +193,7 @@ void FCEUI_SetPaletteArray(uint8 *pal)
 
 void FCEUI_SelectState(int w)
 {
- if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF) 
+ if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
   CommandQueue=42+w;
 }
 
@@ -205,7 +205,7 @@ void FCEUI_SaveState(void)
 
 void FCEUI_LoadState(void)
 {
- if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF) 
+ if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
   CommandQueue=41;
 }
 
@@ -251,7 +251,7 @@ void DriverInterface(int w, void *d)
 
   case DES_NSFINC:NSFControl(1);break;
   case DES_NSFDEC:NSFControl(2);break;
-  case DES_NSFRES:NSFControl(0);break;  
+  case DES_NSFRES:NSFControl(0);break;
 
   case DES_VSUNIDIPSET:CommandQueue=10+(int)d;break;
   case DES_VSUNITOGGLEDIPVIEW:CommandQueue=10;break;
@@ -270,16 +270,16 @@ void DriverInterface(int w, void *d)
                     which=controlselect==1?ntschue:ntsctint;
                     which--;
                     if(which<0) which=0;
-                        if(controlselect==1) 
-                         ntschue=which;                     
-                        else ntsctint=which;                
+                        if(controlselect==1)
+                         ntschue=which;
+                        else ntsctint=which;
                     CalculatePalette();
                    }
                   controllength=360;
                    }
                   }
                  break;
-  case DES_NTSCINC:    
+  case DES_NTSCINC:
                   if(ntsccol && FCEUGameInfo.type!=GIT_VSUNI && !PAL && FCEUGameInfo.type!=GIT_NSF)
                     if(controlselect)
                     {
@@ -312,12 +312,12 @@ void SetNESDeemph(uint8 d, int force)
  uint32 r,g,b;
  int x;
 
- /* If it's not forced(only forced when the palette changes), 
-    don't waste cpu time if the same deemphasis bits are set as the last call. 
+ /* If it's not forced(only forced when the palette changes),
+    don't waste cpu time if the same deemphasis bits are set as the last call.
  */
- if(!force) 
+ if(!force)
  {
-  if(d==lastd) 
+  if(d==lastd)
    return;
  }
  else  /* Only set this when palette has changed. */
@@ -366,7 +366,7 @@ void SetNESDeemph(uint8 d, int force)
      FCEUD_SetPalette(x|0xC0,m,n,o);
 
     }
+
  lastd=d;
 }
 
@@ -382,25 +382,25 @@ static void CalculatePalette(void)
  static uint8 br1[4]={6,9,12,12};
  static double br2[4]={.29,.45,.73,.9};
  static double br3[4]={0,.24,.47,.77};
-  
+
  for(x=0;x<=3;x++)
   for(z=0;z<16;z++)
   {
    s=(double)TINTVAL;
    y=(double)br2[x];
    if(z==0)  {s=0;y=((double)br1[x])/12;}
-   
+
    if(z>=13)
    {
     s=y=0;
     if(z==13)
-     y=(double)br3[x];     
+     y=(double)br3[x];
    }
 
    theta=(double)M_PI*(double)(((double)cols[z]*10+HUEVAL)/(double)180);
    r=(int)(((double)y+(double)s*(double)sin(theta))*(double)256);
    g=(int)(((double)y-(double)((double)27/(double)53)*s*(double)sin(theta)+(double)((double)10/(double)53)*s*cos(theta))*(double)256);
-   b=(int)(((double)y-(double)s*(double)cos(theta))*(double)256);  
+   b=(int)(((double)y-(double)s*(double)cos(theta))*(double)256);
 
    // TODO:  Fix RGB to compensate for phosphor changes(add to red??).
 
@@ -410,7 +410,7 @@ static void CalculatePalette(void)
    if(r<0) r=0;
    if(g<0) g=0;
    if(b<0) b=0;
-    
+
    paletten[(x<<4)+z].r=r;
    paletten[(x<<4)+z].g=g;
    paletten[(x<<4)+z].b=b;
@@ -453,14 +453,14 @@ void FCEU_PutImage(void)
          }
        }
         else
-        {      
+        {
         /* Save snapshot before overlay stuff is written. */
          if(dosnapsave)
          {
           ReallySnap();
           dosnapsave=0;
          }
-        if(FCEUGameInfo.type==GIT_VSUNI && DIPS&2)         
+        if(FCEUGameInfo.type==GIT_VSUNI && DIPS&2)
          DrawDips();
          if(StateShow) DrawState();
          if(controllength) {controllength--;DrawBars();}
@@ -506,7 +506,7 @@ void FCEU_ResetPalette(void)
 static void ChoosePalette(void)
 {
     if(FCEUGameInfo.type==GIT_NSF)
-     palo=NSFPalette;   
+     palo=NSFPalette;
     else if(ipalette)
      palo=palettei;
     else if(ntsccol && !PAL && FCEUGameInfo.type!=GIT_VSUNI)
@@ -515,7 +515,7 @@ static void ChoosePalette(void)
       CalculatePalette();
      }
     else
-     palo=palpoint[pale];  
+     palo=palpoint[pale];
 }
 
 void WritePalette(void)
@@ -527,7 +527,7 @@ void WritePalette(void)
     if(FCEUGameInfo.type==GIT_NSF)
     {
      for(x=0;x<39;x++)
-      FCEUD_SetPalette(x,palo[x].r,palo[x].g,palo[x].b); 
+      FCEUD_SetPalette(x,palo[x].r,palo[x].g,palo[x].b);
     }
     else
     {