migration tidying

This commit is contained in:
zeromus 2018-04-08 17:31:44 -05:00
parent 23efe1ed7f
commit 4d2e8eee53
502 changed files with 0 additions and 121350 deletions

21
.gitignore vendored
View File

@ -1,21 +0,0 @@
# A simulation of Subversion default ignores, generated by reposurgeon.
*.o
*.lo
*.la
*.al
*.libs
*.so
*.so.[0-9]*
*.a
*.pyc
*.pyo
*.rej
*~
*.#*
.*.swp
.DS_store
# Simulated Subversion default ignores end here
# The contents of the svn:ignore property on the branch root.
/.sconsign.dblite
/config.log
/.sconf_temp

View File

@ -1,76 +0,0 @@
file_list = Split("""
cart.cpp
cheat.cpp
crc32.cpp
config.cpp
debug.cpp
endian.cpp
fceu.cpp
fds.cpp
file.cpp
filter.cpp
general.cpp
ines.cpp
input.cpp
md5.cpp
memory.cpp
netplay.cpp
nsf.cpp
palette.cpp
ppu.cpp
sound.cpp
state.cpp
unif.cpp
video.cpp
vsuni.cpp
wave.cpp
x6502.cpp
movie.cpp
unzip.c""")
Export('file_list')
SConscript(Split("""
boards/SConscript
input/SConscript
fir/SConscript
mappers/SConscript
drivers/common/SConscript
drivers/pc/SConscript
"""))
#palettes/SConscript
Import('file_list')
# XXX path separator fixed right now
opts = Options()
opts.Add('PSS_STYLE', 'Path separator style', 1)
opts.Add('LSB_FIRST', 'Least significant byte first?', 1)
env = Environment(options = opts,
CPPDEFINES={'PSS_STYLE' : '${PSS_STYLE}',
'LSB_FIRST' : '${LSB_FIRST}'})
# use sdl-config to get the cflags and libpath
import os;
sdl_cflags_pipe = os.popen("sdl-config --cflags");
sdl_cflags = sdl_cflags_pipe.read();
sdl_cflags = sdl_cflags.rstrip(os.linesep);
sdl_cflags_pipe.close();
sdl_libpath = [];
sdl_libs = [];
sdl_libflags_pipe = os.popen("sdl-config --libs");
sdl_libflags = sdl_libflags_pipe.read();
for flag in sdl_libflags.split(' '):
if flag.find("-L") == 0:
sdl_libpath.append(flag.strip("-L"));
else:
sdl_libs.append(flag.strip("-l"));
sdl_libflags_pipe.close();
# add zlib
libs = sdl_libs;
libs.append('z');
env.Program('fceu', file_list, CCFLAGS=sdl_cflags, LIBS=libs, LIBPATH=sdl_libpath)

View File

@ -1,27 +0,0 @@
#include <string.h>
#include <stdlib.h>
#include "types.h"
#include "fceustr.h"
/* Creates a fceustr from a C-style string. */
fceustr *fceustr_create(const char *str)
{
fceustr *ret;
ret=malloc(sizeof(fceustr));
ret->data=malloc(strlen(str)+1);
strcpy(ret->data,str);
ret->len=strlen(str);
return(ret);
}
void fceustr_destroy(fceustr *str)
{
if(str->data) free(str->data);
free(str);
}

View File

@ -1,4 +0,0 @@
typedef struct {
uint8 *data;
uint32 len; /* Not including extra NULL character. */
} fceustr;

Binary file not shown.

View File

@ -1,72 +0,0 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/args.h"
#include "../common/config.h"
#include "input.h"
extern FCEUGI *CurGame;
extern CFGSTRUCT DriverConfig[];
extern ARGPSTRUCT DriverArgs[];
extern char *DriverUsage;
void DoDriverArgs(void);
uint8 *GetBaseDirectory(void);
int InitSound(FCEUGI *gi);
void WriteSound(int32 *Buffer, int Count);
int KillSound(void);
uint32 GetMaxSound(void);
uint32 GetWriteSound(void);
void SilenceSound(int s); /* DOS and SDL */
int InitMouse(void);
void KillMouse(void);
void GetMouseData(uint32 *MouseData);
int InitJoysticks(void);
int KillJoysticks(void);
uint32 *GetJSOr(void);
int InitKeyboard(void);
int UpdateKeyboard(void);
char *GetKeyboard(void);
void KillKeyboard(void);
int InitVideo(FCEUGI *gi);
int KillVideo(void);
void BlitScreen(uint8 *XBuf);
void LockConsole(void);
void UnlockConsole(void);
void ToggleFS(); /* SDL */
int LoadGame(const char *path);
int CloseGame(void);
int GUI_Init(int argc, char **argv, int (*dofunc)(void));
int GUI_Idle(void);
int GUI_Update(void);
void GUI_Hide(int);
void GUI_RequestExit(void);
int GUI_SetVideo(int fullscreen, int width, int height);
char *GUI_GetKeyboard(void);
void GUI_GetMouseState(uint32 *b, int *x, int *y);
void UpdatePhysicalInput(void);
int DTestButton(ButtConfig *bc);
int DWaitButton(const uint8 *text, ButtConfig *bc, int wb);
int ButtonConfigBegin(void);
void ButtonConfigEnd(void);
void Giggles(int);
void DoFun(void);
int FCEUD_NetworkConnect(void);
#ifdef __cplusplus
}
#endif

View File

@ -1,200 +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 <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[6];
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;
static int rtoggle=0;
ret=0;
rtoggle^=1;
if(!soundo)
UpdateJoyData();
for(y=0;y<6;y++)
if((y>=4 && rtoggle) || y<4)
if(joybuttons&joyBMap[y]) ret|=(1<<y&3)<<((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);
printf("%s\"Rapid fire B\".\n",genb);
BConfig(5);
printf("%s\"Rapid fire A\".\n",genb);
BConfig(4);
}

View File

@ -1,27 +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
*/
void UpdateJoyData(void);
uint32 GetJSOr(void);
int InitJoysticks(void);
/* Variables to save in config file. */
extern int joy;
extern int joyBMap[6];

View File

@ -1,131 +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 <signal.h>
#include <string.h>
#include <pc.h>
#include <dpmi.h>
#include <go32.h>
#include "keyscan.h"
static unsigned char lastsc;
static char keybuf[256];
int newk;
/* Read scan code from port $60 */
/* Acknowledge interrupt( output $20 to port $20) */
static void ihandler(_go32_dpmi_registers *r)
{
unsigned char scode=inp(0x60); /* Get scan code. */
if(scode!=0xE0)
{
int offs=0;
/* I'm only interested in preserving the independent status of the
right ALT and CONTROL keys.
*/
if(lastsc==0xE0)
if((scode&0x7F)==SCAN_LEFTALT || (scode&0x7F)==SCAN_LEFTCONTROL)
offs=0x80;
keybuf[(scode&0x7f)|offs]=((scode&0x80)^0x80);
newk++;
}
lastsc=scode;
outp(0x20,0x20); /* Acknowledge interrupt. */
}
static _go32_dpmi_seginfo KBIBack,KBIBackRM;
static _go32_dpmi_seginfo KBI,KBIRM;
static _go32_dpmi_registers KBIRMRegs;
static int initdone=0;
int InitKeyboard(void)
{
/* I'll assume that the keyboard is in the correct scancode mode(translated
mode 2, I think).
*/
newk=0;
memset(keybuf,0,sizeof(keybuf));
KBIRM.pm_offset=KBI.pm_offset=(int)ihandler;
KBIRM.pm_selector=KBI.pm_selector=_my_cs();
_go32_dpmi_get_real_mode_interrupt_vector(9,&KBIBackRM);
_go32_dpmi_allocate_real_mode_callback_iret(&KBIRM, &KBIRMRegs);
_go32_dpmi_set_real_mode_interrupt_vector(9,&KBIRM);
_go32_dpmi_get_protected_mode_interrupt_vector(9,&KBIBack);
_go32_dpmi_allocate_iret_wrapper(&KBI);
_go32_dpmi_set_protected_mode_interrupt_vector(9,&KBI);
lastsc=0;
initdone=1;
return(1);
}
void KillKeyboard(void)
{
if(initdone)
{
_go32_dpmi_set_protected_mode_interrupt_vector(9,&KBIBack);
_go32_dpmi_free_iret_wrapper(&KBI);
_go32_dpmi_set_real_mode_interrupt_vector(9,&KBIBackRM);
_go32_dpmi_free_real_mode_callback(&KBIRM);
initdone=0;
}
}
/* In FCE Ultra, it doesn't matter if the key states change
in the middle of the keyboard handling code. If you want
to use this code elsewhere, you may want to memcpy() keybuf
to another buffer and return that when GetKeyboard() is
called.
*/
char *GetKeyboard(void)
{
return keybuf;
}
/* Returns 1 on new scan codes generated, 0 on no new scan codes. */
int UpdateKeyboard(void)
{
int t=newk;
if(t)
{
asm volatile(
"subl %%eax,_newk\n\t"
:
: "a" (t)
);
if(keybuf[SCAN_LEFTCONTROL] && keybuf[SCAN_C])
raise(SIGINT);
return(1);
}
return(0);
}

View File

@ -1,80 +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 <dpmi.h>
#include <string.h>
#include "dos.h"
int InitMouse(void)
{
__dpmi_regs regs;
memset(&regs,0,sizeof(regs));
regs.x.ax=0;
__dpmi_int(0x33,&regs);
if(regs.x.ax!=0xFFFF)
return(0);
memset(&regs,0,sizeof(regs));
regs.x.ax=0x7;
regs.x.cx=0; // Min X
regs.x.dx=260; // Max X
__dpmi_int(0x33,&regs);
memset(&regs,0,sizeof(regs));
regs.x.ax=0x8;
regs.x.cx=0; // Min Y
regs.x.dx=260; // Max Y
__dpmi_int(0x33,&regs);
memset(&regs,0,sizeof(regs));
regs.x.ax=0xF;
regs.x.cx=8; // Mickey X
regs.x.dx=8; // Mickey Y
__dpmi_int(0x33,&regs);
memset(&regs,0,sizeof(regs));
regs.x.ax=0x2;
__dpmi_int(0x33,&regs);
return(1);
}
uint32 GetMouseData(uint32 *x, uint32 *y)
{
if(FCEUI_IsMovieActive()<0)
return;
__dpmi_regs regs;
memset(&regs,0,sizeof(regs));
regs.x.ax=0x3;
__dpmi_int(0x33,&regs);
*x=regs.x.cx;
*y=regs.x.dx;
return(regs.x.bx&3);
}
void KillMouse(void)
{
}

View File

@ -1,567 +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 <stdlib.h>
#include <string.h>
#include <sys/farptr.h>
#include <pc.h>
#include <dos.h>
#include <dpmi.h>
#include <go32.h>
#include <ctype.h>
#include "dos.h"
#include "dos-sound.h"
#include "dos-joystick.h"
static void SBIRQHandler(_go32_dpmi_registers *r);
static uint32 LMBuffer; /* Address of low memory DMA playback buffer. */
static int LMSelector;
static uint8 *WaveBuffer;
static unsigned int IVector, SBIRQ, SBDMA, SBDMA16, SBPort;
static int DSPV,hsmode;
static int format;
static int frags, fragsize, fragtotal;
static volatile int WritePtr, ReadPtr;
static volatile int hbusy;
static volatile int whichbuf;
static uint8 PICMask;
/* Protected mode interrupt vector info. */
static _go32_dpmi_seginfo SBIH,SBIHOld;
/* Real mode interrupt vector info. */
static _go32_dpmi_seginfo SBIHRM,SBIHRMOld;
static _go32_dpmi_registers SBIHRMRegs;
static int WriteDSP(uint8 V)
{
int x;
for(x=65536;x;x--)
{
if(!(inportb(SBPort+0xC)&0x80))
{
outportb(SBPort+0xC,V);
return(1);
}
}
return(0);
}
static int ReadDSP(uint8 *V)
{
int x;
for(x=65536;x;x--) /* Should be more than enough time... */
{
if(inportb(SBPort+0xE)&0x80)
{
*V=inportb(SBPort+0xA);
return(1);
}
}
return(0);
}
static int SetVectors(void)
{
SBIH.pm_offset=SBIHRM.pm_offset=(int)SBIRQHandler;
SBIH.pm_selector=SBIHRM.pm_selector=_my_cs();
/* Get and set real mode interrupt vector. */
_go32_dpmi_get_real_mode_interrupt_vector(IVector,&SBIHRMOld);
_go32_dpmi_allocate_real_mode_callback_iret(&SBIHRM, &SBIHRMRegs);
_go32_dpmi_set_real_mode_interrupt_vector(IVector,&SBIHRM);
/* Get and set protected mode interrupt vector. */
_go32_dpmi_get_protected_mode_interrupt_vector(IVector,&SBIHOld);
_go32_dpmi_allocate_iret_wrapper(&SBIH);
_go32_dpmi_set_protected_mode_interrupt_vector(IVector,&SBIH);
return(1);
}
static void ResetVectors(void)
{
_go32_dpmi_set_protected_mode_interrupt_vector(IVector,&SBIHOld);
_go32_dpmi_free_iret_wrapper(&SBIH);
_go32_dpmi_set_real_mode_interrupt_vector(IVector,&SBIHRMOld);
_go32_dpmi_free_real_mode_callback(&SBIHRM);
}
int GetBLASTER(void)
{
int check=0;
char *s;
if(!(s=getenv("BLASTER")))
{
puts(" Error getting BLASTER environment variable.");
return(0);
}
while(*s)
{
switch(toupper(*s))
{
case 'A': check|=(sscanf(s+1,"%x",&SBPort)==1)?1:0;break;
case 'I': check|=(sscanf(s+1,"%d",&SBIRQ)==1)?2:0;break;
case 'D': check|=(sscanf(s+1,"%d",&SBDMA)==1)?4:0;break;
case 'H': check|=(sscanf(s+1,"%d",&SBDMA16)==1)?8:0;break;
}
s++;
}
if((check^7)&7 || SBDMA>=4 || (SBDMA16<=4 && check&8) || SBIRQ>15)
{
puts(" Invalid or incomplete BLASTER environment variable.");
return(0);
}
if(!(check&8))
format=0;
return(1);
}
static int ResetDSP(void)
{
uint8 b;
outportb(SBPort+0x6,0x1);
delay(10);
outportb(SBPort+0x6,0x0);
delay(10);
if(ReadDSP(&b))
if(b==0xAA)
return(1);
return(0);
}
static int GetDSPVersion(void)
{
int ret;
uint8 t;
if(!WriteDSP(0xE1))
return(0);
if(!ReadDSP(&t))
return(0);
ret=t<<8;
if(!ReadDSP(&t))
return(0);
ret|=t;
return(ret);
}
static void KillDMABuffer(void)
{
__dpmi_free_dos_memory(LMSelector);
}
static int MakeDMABuffer(void)
{
uint32 size;
int32 tmp;
size=fragsize*2; /* Two buffers in the DMA buffer. */
size<<=format; /* Twice the size for 16-bit than for 8-bit. */
size<<=1; /* Double the size in case the first 2 buffers
cross a 64KB or 128KB page boundary.
*/
size=(size+15)>>4; /* Convert to paragraphs */
if((tmp=__dpmi_allocate_dos_memory(size,&LMSelector))<0)
return(0);
LMBuffer=tmp<<=4;
if(format) /* Check for and fix 128KB page boundary crossing. */
{
if((LMBuffer&0x20000) != ((LMBuffer+fragsize*2*2-1)&0x20000))
LMBuffer+=fragsize*2*2;
}
else /* Check for and fix 64KB page boundary crossing. */
{
if((LMBuffer&0x10000) != ((LMBuffer+fragsize*2-1)&0x10000))
LMBuffer+=fragsize*2;
}
DOSMemSet(LMBuffer, format?0:128, (fragsize*2)<<format);
return(1);
}
static void ProgramDMA(void)
{
static int PPorts[8]={0x87,0x83,0x81,0x82,0,0x8b,0x89,0x8a};
uint32 tmp;
if(format)
{
outportb(0xd4,(SBDMA16&0x3)|0x4);
outportb(0xd8,0x0);
outportb(0xd6,(SBDMA16&0x3)|0x58);
tmp=((SBDMA16&3)<<2)+0xC2;
}
else
{
outportb(0xA,SBDMA|0x4);
outportb(0xC,0x0);
outportb(0xB,SBDMA|0x58);
tmp=(SBDMA<<1)+1;
}
/* Size of entire buffer. */
outportb(tmp,(fragsize*2-1));
outportb(tmp,(fragsize*2-1)>>8);
/* Page of buffer. */
outportb(PPorts[format?SBDMA16:SBDMA],LMBuffer>>16);
/* Offset of buffer within page. */
if(format)
tmp=((SBDMA16&3)<<2)+0xc0;
else
tmp=SBDMA<<1;
outportb(tmp,(LMBuffer>>format));
outportb(tmp,(LMBuffer>>(8+format)));
}
int InitSB(int Rate, int bittage)
{
hsmode=hbusy=0;
whichbuf=1;
puts("Initializing Sound Blaster...");
format=bittage?1:0;
frags=8;
if(Rate<=11025)
fragsize=1<<5;
else if(Rate<=22050)
fragsize=1<<6;
else
fragsize=1<<7;
fragtotal=frags*fragsize;
WaveBuffer=malloc(fragtotal<<format);
if(format)
memset(WaveBuffer,0,fragtotal*2);
else
memset(WaveBuffer,128,fragtotal);
WritePtr=ReadPtr=0;
if((Rate<8192) || (Rate>65535))
{
printf(" Unsupported playback rate: %d samples per second\n",Rate);
return(0);
}
if(!GetBLASTER())
return(0);
/* Disable IRQ line in PIC0 or PIC1 */
if(SBIRQ>7)
{
PICMask=inportb(0xA1);
outportb(0xA1,PICMask|(1<<(SBIRQ&7)));
}
else
{
PICMask=inportb(0x21);
outportb(0x21,PICMask|(1<<SBIRQ));
}
if(!ResetDSP())
{
puts(" Error resetting the DSP.");
return(0);
}
if(!(DSPV=GetDSPVersion()))
{
puts(" Error getting the DSP version.");
return(0);
}
printf(" DSP Version: %d.%d\n",DSPV>>8,DSPV&0xFF);
if(DSPV<0x201)
{
printf(" DSP version number is too low.\n");
return(0);
}
if(DSPV<0x400)
format=0;
if(!MakeDMABuffer())
{
puts(" Error creating low-memory DMA buffer.");
return(0);
}
if(SBIRQ>7) IVector=SBIRQ+0x68;
else IVector=SBIRQ+0x8;
if(!SetVectors())
{
puts(" Error setting interrupt vectors.");
KillDMABuffer();
return(0);
}
/* Reenable IRQ line. */
if(SBIRQ>7)
outportb(0xA1,PICMask&(~(1<<(SBIRQ&7))));
else
outportb(0x21,PICMask&(~(1<<SBIRQ)));
ProgramDMA();
/* Note that the speaker must always be turned on before the mode transfer
byte is sent to the DSP if we're going into high-speed mode, since
a real Sound Blaster(at least my SBPro) won't accept DSP commands(except
for the reset "command") after it goes into high-speed mode.
*/
WriteDSP(0xD1); // Turn on DAC speaker
if(DSPV>=0x400)
{
WriteDSP(0x41); // Set sampling rate
WriteDSP(Rate>>8); // High byte
WriteDSP(Rate&0xFF); // Low byte
if(!format)
{
WriteDSP(0xC6); // 8-bit output
WriteDSP(0x00); // 8-bit mono unsigned PCM
}
else
{
WriteDSP(0xB6); // 16-bit output
WriteDSP(0x10); // 16-bit mono signed PCM
}
WriteDSP((fragsize-1)&0xFF);// Low byte of size
WriteDSP((fragsize-1)>>8); // High byte of size
}
else
{
int tc,command;
if(Rate>22050)
{
tc=(65536-(256000000/Rate))>>8;
Rate=256000000/(65536-(tc<<8));
command=0x90; // High-speed auto-initialize DMA mode transfer
hsmode=1;
}
else
{
tc=256-(1000000/Rate);
Rate=1000000/(256-tc);
command=0x1c; // Auto-initialize DMA mode transfer
}
WriteDSP(0x40); // Set DSP time constant
WriteDSP(tc); // time constant
WriteDSP(0x48); // Set DSP block transfer size
WriteDSP((fragsize-1)&0xFF);
WriteDSP((fragsize-1)>>8);
WriteDSP(command);
}
/* Enable DMA */
if(format)
outportb(0xd4,SBDMA16&3);
else
outportb(0xa,SBDMA);
printf(" %d hz, %d-bit\n",Rate,8<<format);
return(Rate);
}
extern volatile int soundjoyer;
extern volatile int soundjoyeron;
static int ssilence=0;
static void SBIRQHandler(_go32_dpmi_registers *r)
{
uint32 *src;
uint32 dest;
int32 x;
if(format)
{
uint8 status;
outportb(SBPort+4,0x82);
status=inportb(SBPort+5);
if(status&2)
inportb(SBPort+0x0F);
}
else
inportb(SBPort+0x0E);
#ifdef OLD
{
uint8 status;
outportb(SBPort+4,0x82);
status=inportb(SBPort+5);
if(status&1)
inportb(SBPort+0x0E);
else if(status&2)
inportb(SBPort+0x0F);
else
return; // Mysterious interrupt source! *eerie music*
}
#endif
if(hbusy)
{
outportb(0x20,0x20);
if(SBIRQ>=8)
outportb(0xA0,0x20);
whichbuf^=1;
return;
}
hbusy=1;
{
/* This code seems to fail on many SB emulators. Bah.
SCREW SB EMULATORS. ^_^ */
uint32 count;
uint32 block;
uint32 port;
if(format)
port=((SBDMA16&3)*4)+0xc2;
else
port=(SBDMA*2)+1;
count=inportb(port);
count|=inportb(port)<<8;
if(count>=fragsize)
block=1;
else
block=0;
dest=LMBuffer+((block*fragsize)<<format);
#ifdef MOO
dest=LMBuffer+((whichbuf*fragsize)<<format);
whichbuf^=1;
#endif
}
_farsetsel(_dos_ds);
src=(uint32 *)(WaveBuffer+(ReadPtr<<format));
if(ssilence)
{
uint32 sby;
if(format) sby=0; /* 16-bit silence. */
else sby=0x80808080; /* 8-bit silence. */
for(x=(fragsize<<format)>>2;x;x--,dest+=4)
{
_farnspokel(dest,sby);
}
}
else
{
for(x=(fragsize<<format)>>2;x;x--,dest+=4,src++)
{
_farnspokel(dest,*src);
}
ReadPtr=(ReadPtr+fragsize)&(fragtotal-1);
}
if(soundjoyeron)
{
static int coot=0;
if(!coot)
{
UpdateJoyData();
soundjoyer=1;
}
coot=(coot+1)&3;
}
hbusy=0;
outportb(0x20,0x20);
if(SBIRQ>=8)
outportb(0xA0,0x20);
}
void SilenceSound(int s)
{
ssilence=s;
}
void WriteSBSound(int32 *Buffer, int Count, int NoBlocking)
{
int x;
if(!format)
{
for(x=0;x<Count;x++)
{
while(WritePtr==ReadPtr)
if(NoBlocking)
return;
WaveBuffer[WritePtr]=(uint8)((Buffer[x])>>8)^128;
WritePtr=(WritePtr+1)&(fragtotal-1);
}
}
else // 16 bit
{
for(x=0;x<Count;x++)
{
while(WritePtr==ReadPtr)
if(NoBlocking)
return;
((int16 *)WaveBuffer)[WritePtr]=Buffer[x];
WritePtr=(WritePtr+1)&(fragtotal-1);
}
}
}
void KillSB(void)
{
if(hsmode)
ResetDSP(); /* High-speed mode requires a DSP reset. */
else
WriteDSP(format?0xD9:0xDA); /* Exit auto-init DMA transfer mode. */
WriteDSP(0xD3); /* Turn speaker off. */
outportb((SBIRQ>7)?0xA1:0x21,PICMask|(1<<(SBIRQ&7)));
ResetVectors();
outportb((SBIRQ>7)?0xA1:0x21,PICMask);
KillDMABuffer();
}

View File

@ -1,26 +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
*/
int InitSB(int Rate, int bittage);
void KillSB(void);
void WriteSBSound(int32 *Buffer, int Count, int NoBlocking);
void SilenceSound(int s);

View File

@ -1,246 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 1998 \Firebug\
* 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 <dpmi.h>
#include <sys/farptr.h>
#include <go32.h>
#include <pc.h>
#include "dos.h"
#include "dos-video.h"
#define TEXT 3
#define G320x200x256 0x13
static void vga_waitretrace(void)
{
while(inp(0x3da)&0x8);
while(!(inp(0x3da)&0x8));
}
static void vga_setmode(int mode)
{
__dpmi_regs regs;
memset(&regs,0,sizeof(regs));
regs.x.ax=mode;
__dpmi_int(0x10,&regs);
}
void vga_setpalette(int i, int r, int g, int b)
{
outp(0x3c8,i);
outp(0x3c9,r);
outp(0x3c9,g);
outp(0x3c9,b);
}
int FCEUDvmode=1;
static int vidready=0;
/* Part of the VGA low-level mass register setting code derived from
code by \Firebug\.
*/
#include "vgatweak.c"
void SetBorder(void)
{
inportb(0x3da);
outportb(0x3c0,(0x11|0x20));
outportb(0x3c0,0x80);
}
void TweakVGA(int VGAMode)
{
int I;
vga_waitretrace();
outportb(0x3C8,0x00);
for(I=0;I<768;I++) outportb(0x3C9,0x00);
outportb(0x3D4,0x11);
I=inportb(0x3D5)&0x7F;
outportb(0x3D4,0x11);
outportb(0x3D5,I);
switch(VGAMode)
{
case 1: for(I=0;I<25;I++) VGAPortSet(v256x240[I]);break;
case 2: for(I=0;I<25;I++) VGAPortSet(v256x256[I]);break;
case 3: for(I=0;I<25;I++) VGAPortSet(v256x256S[I]);break;
case 6: for(I=0;I<25;I++) VGAPortSet(v256x224S[I]);break;
case 8: for(I=0;I<25;I++) VGAPortSet(v256x224_103[I]);break;
default: break;
}
outportb(0x3da,0);
}
static uint8 palettedbr[256],palettedbg[256],palettedbb[256];
static void FlushPalette(void)
{
int x;
for(x=0;x<256;x++)
{
int z=x;
vga_setpalette(z,palettedbr[x]>>2,palettedbg[x]>>2,palettedbb[x]>>2);
}
}
void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
{
palettedbr[index]=r;
palettedbg[index]=g;
palettedbb[index]=b;
if(vidready)
{
vga_setpalette(index,r>>2,g>>2,b>>2);
}
}
void FCEUD_GetPalette(uint8 i, uint8 *r, uint8 *g, uint8 *b)
{
*r=palettedbr[i];
*g=palettedbg[i];
*b=palettedbb[i];
}
static uint32 ScreenLoc;
int InitVideo(void)
{
vidready=0;
switch(FCEUDvmode)
{
default:
case 1:
case 2:
case 3:
case 6:
case 8:
vga_setmode(G320x200x256);
vidready|=1;
ScreenLoc=0xa0000;
TweakVGA(FCEUDvmode);
SetBorder();
DOSMemSet(ScreenLoc, 128, 256*256);
break;
}
vidready|=2;
FlushPalette();
return 1;
}
void KillVideo(void)
{
if(vidready)
{
vga_setmode(TEXT);
vidready=0;
}
}
void LockConsole(void){}
void UnlockConsole(void){}
void BlitScreen(uint8 *XBuf)
{
uint32 dest;
int tlines;
if(eoptions&4 && !NoWaiting)
vga_waitretrace();
tlines=erendline-srendline+1;
dest=ScreenLoc;
switch(FCEUDvmode)
{
case 1:dest+=(((240-tlines)>>1)<<8);break;
case 2:
case 3:dest+=(((256-tlines)>>1)<<8);break;
case 4:
case 5:dest+=(((240-tlines)>>1)*640+((640-512)>>1));break;
case 8:
case 6:if(tlines>224) tlines=224;dest+=(((224-tlines)>>1)<<8);break;
}
XBuf+=(srendline<<8)+(srendline<<4);
_farsetsel(_dos_ds);
if(eoptions&DO_CLIPSIDES)
{
asm volatile(
"agoop1:\n\t"
"movl $30,%%eax\n\t"
"agoop2:\n\t"
"movl (%%esi),%%edx\n\t"
"movl 4(%%esi),%%ecx\n\t"
".byte 0x64 \n\t"
"movl %%edx,(%%edi)\n\t"
".byte 0x64 \n\t"
"movl %%ecx,4(%%edi)\n\t"
"addl $8,%%esi\n\t"
"addl $8,%%edi\n\t"
"decl %%eax\n\t"
"jne agoop2\n\t"
"addl $32,%%esi\n\t"
"addl $16,%%edi\n\t"
"decb %%bl\n\t"
"jne agoop1\n\t"
:
: "S" (XBuf+8), "D" (dest+8), "b" (tlines)
: "%eax","%cc","%edx","%ecx" );
}
else
{
asm volatile(
"goop1:\n\t"
"movl $32,%%eax\n\t"
"goop2:\n\t"
"movl (%%esi),%%edx\n\t"
"movl 4(%%esi),%%ecx\n\t"
".byte 0x64 \n\t"
"movl %%edx,(%%edi)\n\t"
".byte 0x64 \n\t"
"movl %%ecx,4(%%edi)\n\t"
"addl $8,%%esi\n\t"
"addl $8,%%edi\n\t"
"decl %%eax\n\t"
"jne goop2\n\t"
"addl $16,%%esi\n\t"
"decb %%bl\n\t"
"jne goop1\n\t"
:
: "S" (XBuf), "D" (dest), "b" (tlines)
: "%eax","%cc","%edx","%ecx" );
}
}

View File

@ -1,22 +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
*/
extern int FCEUDvmode;

View File

@ -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.";
ARGPSTRUCT DriverArgs[]={
{"-vmode",0,&FCEUDvmode,0},
{"-sound",0,&soundo,0},
{"-f8bit",0,&f8bit,0},
{"-vsync",0,&doptions,DO_VSYNC},
{0,0,0,0}
};
void DoDriverArgs(void)
{
if(!joy) memset(joyBMap,0,sizeof(joyBMap));
}
int InitSound(void)
{
if(soundo)
{
if(soundo==1)
soundo=44100;
soundo=InitSB(soundo,f8bit?0:1);
FCEUI_Sound(soundo);
}
return(soundo);
}
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;
uint8 *GetBaseDirectory(void)
{
int x=0;
uint8 *ret = 0;
if(arg0)
for(x=strlen(arg0);x>=0;x--)
{
if(arg0[x]=='/' || arg0[x]=='\\')
{
ret = malloc(x + 1);
strncpy(ret,arg0,x);
break;
}
}
if(!ret) { x=0; ret = malloc(1); }
BaseDirectory[x]=0;
}
int main(int argc, char *argv[])
{
puts("\nStarting FCE Ultra "VERSION_STRING"...\n");
arg0=argv[0];
return(CLImain(argc,argv));
}

View File

@ -1,27 +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 "main.h"
#include "dface.h"
#include "input.h"
void DOSMemSet(uint32 A, uint8 V, uint32 count);
#define DO_VSYNC 1

View File

@ -1,720 +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 <string.h>
#include "main.h"
#include "dface.h"
#include "input.h"
#include "../common/cheat.h"
/* UsrInputType[] is user-specified. InputType[] is current
(game loading can override user settings)
*/
int UsrInputType[3]={SI_GAMEPAD,SI_GAMEPAD,SIFC_NONE};
int InputType[3]={0,0,0};
static int cspec=0;
int gametype=0;
/* Necessary for proper GUI functioning(configuring when a game isn't loaded). */
void InputUserActiveFix(void)
{
int x;
for(x=0;x<3;x++) InputType[x]=UsrInputType[x];
}
void ParseGIInput(FCEUGI *gi)
{
gametype=gi->type;
InputType[0]=UsrInputType[0];
InputType[1]=UsrInputType[1];
InputType[2]=UsrInputType[2];
if(gi->input[0]>=0)
InputType[0]=gi->input[0];
if(gi->input[1]>=0)
InputType[1]=gi->input[1];
if(gi->inputfc>=0)
InputType[2]=gi->inputfc;
cspec = gi->cspecial;
#ifdef EXTGUI
Giggles(gi->cspecial);
#endif
}
static uint8 QuizKingData=0;
static uint8 HyperShotData=0;
static uint32 MahjongData=0;
static uint32 FTrainerData=0;
static uint8 TopRiderData=0;
static uint8 BWorldData[1+13+1];
static void UpdateFKB(void);
static void UpdateGamepad(void);
static void UpdateQuizKing(void);
static void UpdateHyperShot(void);
static void UpdateMahjong(void);
static void UpdateFTrainer(void);
static void UpdateTopRider(void);
static uint32 JSreturn=0;
int NoWaiting=1;
#ifndef EXTGUI
static void DoCheatSeq(void)
{
#if defined(DOS) || defined(SDL)
SilenceSound(1);
#endif
KillKeyboard();
KillVideo();
DoConsoleCheatConfig();
InitVideo(CurGame);
InitKeyboard();
#if defined(DOS) || defined(SDL)
SilenceSound(0);
#endif
}
#endif
#include "keyscan.h"
static char *keys=0;
static int DIPS=0;
static uint8 keyonce[MKK_COUNT];
#define KEY(__a) keys[MKK(__a)]
static int _keyonly(int a)
{
if(keys[a])
{
if(!keyonce[a])
{
keyonce[a]=1;
return(1);
}
}
else
keyonce[a]=0;
return(0);
}
#define keyonly(__a) _keyonly(MKK(__a))
static int cidisabled=0;
static void KeyboardCommands(void)
{
int is_shift, is_alt;
keys=GetKeyboard();
if(InputType[2]==SIFC_FKB)
{
if(keyonly(SCROLLLOCK))
{
cidisabled^=1;
FCEUI_DispMessage("Family Keyboard %sabled.",cidisabled?"en":"dis");
}
#ifdef SDL
SDL_WM_GrabInput(cidisabled?SDL_GRAB_ON:SDL_GRAB_OFF);
#endif
if(cidisabled) return;
}
is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT);
is_alt = KEY(LEFTALT) | KEY(RIGHTALT);
if(keyonly(F4))
{
if(is_shift) FCEUI_SetRenderDisable(-1, 2);
else FCEUI_SetRenderDisable(2, -1);
}
#ifdef SDL
if(keyonly(ENTER) && is_alt) ToggleFS();
#endif
NoWaiting&=~1;
if(KEY(GRAVE))
NoWaiting|=1;
if(gametype==GIT_FDS)
{
if(keyonly(F6)) FCEUI_FDSSelect();
if(keyonly(F8)) FCEUI_FDSInsert();
}
if(keyonly(F9)) FCEUI_SaveSnapshot();
if(gametype!=GIT_NSF)
{
#ifndef EXTGUI
if(keyonly(F2)) DoCheatSeq();
#endif
if(keyonly(F5))
{
if(is_shift)
FCEUI_SaveMovie(NULL,0,NULL);
else
FCEUI_SaveState(NULL);
}
if(keyonly(F7))
{
if(is_shift)
FCEUI_LoadMovie(NULL,0);
else
FCEUI_LoadState(NULL);
}
}
if(keyonly(F1)) FCEUI_ToggleTileView();
if(keyonly(MINUS)) DecreaseEmulationSpeed();
if(keyonly(EQUAL)) IncreaseEmulationSpeed();
if(keyonly(BACKSPACE)) FCEUI_MovieToggleFrameDisplay();
if(keyonly(BACKSLASH)) FCEUI_ToggleEmulationPause();
if(keyonly(RIGHTCONTROL)) FCEUI_FrameAdvance();
if(keyonly(F10)) FCEUI_ResetNES();
if(keyonly(F11)) FCEUI_PowerNES();
#ifdef EXTGUI
if(keyonly(F3)) GUI_Hide(-1);
if(KEY(F12)) GUI_RequestExit();
if(KEY(ESCAPE)) CloseGame();
#else
if(KEY(F12) || KEY(ESCAPE)) CloseGame();
#endif
if(gametype==GIT_VSUNI)
{
if(keyonly(F8)) FCEUI_VSUniCoin();
if(keyonly(F6))
{
DIPS^=1;
FCEUI_VSUniToggleDIPView();
}
if(!(DIPS&1)) goto DIPSless;
if(keyonly(1)) FCEUI_VSUniToggleDIP(0);
if(keyonly(2)) FCEUI_VSUniToggleDIP(1);
if(keyonly(3)) FCEUI_VSUniToggleDIP(2);
if(keyonly(4)) FCEUI_VSUniToggleDIP(3);
if(keyonly(5)) FCEUI_VSUniToggleDIP(4);
if(keyonly(6)) FCEUI_VSUniToggleDIP(5);
if(keyonly(7)) FCEUI_VSUniToggleDIP(6);
if(keyonly(8)) FCEUI_VSUniToggleDIP(7);
}
else
{
static uint8 bbuf[32];
static int bbuft;
static int barcoder = 0;
if(keyonly(H)) FCEUI_NTSCSELHUE();
if(keyonly(T)) FCEUI_NTSCSELTINT();
if(KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC();
if(KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC();
if((InputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH))
{
if(keyonly(F8))
{
barcoder ^= 1;
if(!barcoder)
{
if(InputType[2] == SIFC_BWORLD)
{
strcpy(&BWorldData[1],bbuf);
BWorldData[0]=1;
}
else
FCEUI_DatachSet(bbuf);
FCEUI_DispMessage("Barcode Entered");
}
else { bbuft = 0; FCEUI_DispMessage("Enter Barcode");}
}
} else barcoder = 0;
#define SSM(x) \
{ if(barcoder) { if(bbuft < 13) {bbuf[bbuft++] = '0' + x; bbuf[bbuft] = 0;} FCEUI_DispMessage("Barcode: %s",bbuf);} \
else { \
if(is_shift) FCEUI_SelectMovie(x,1); \
else FCEUI_SelectState(x,1); \
} }
DIPSless:
if(keyonly(0)) SSM(0);
if(keyonly(1)) SSM(1);
if(keyonly(2)) SSM(2);
if(keyonly(3)) SSM(3);
if(keyonly(4)) SSM(4);
if(keyonly(5)) SSM(5);
if(keyonly(6)) SSM(6);
if(keyonly(7)) SSM(7);
if(keyonly(8)) SSM(8);
if(keyonly(9)) SSM(9);
#undef SSM
}
}
#define MK(x) {{BUTTC_KEYBOARD},{0},{MKK(x)},1}
#define MK2(x1,x2) {{BUTTC_KEYBOARD},{0},{MKK(x1),MKK(x2)},2}
#define MKZ() {{0},{0},{0},0}
#define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()}
ButtConfig GamePadConfig[4][10]={
/* Gamepad 1 */
{
MK(KP3), MK(KP2), MK(TAB), MK(ENTER), MK(W),MK(Z),
MK(A), MK(S), MKZ(), MKZ()
},
/* Gamepad 2 */
GPZ(),
/* Gamepad 3 */
GPZ(),
/* Gamepad 4 */
GPZ()
};
static void UpdateGamepad(void)
{
if(FCEUI_IsMovieActive()<0)
return;
static int rapid=0;
uint32 JS=0;
int x;
int wg;
rapid^=1;
for(wg=0;wg<4;wg++)
{
for(x=0;x<8;x++)
if(DTestButton(&GamePadConfig[wg][x]))
JS|=(1<<x)<<(wg<<3);
if(rapid)
for(x=0;x<2;x++)
if(DTestButton(&GamePadConfig[wg][8+x]))
JS|=(1<<x)<<(wg<<3);
}
// for(x=0;x<32;x+=8) /* Now, test to see if anything weird(up+down at same time)
// is happening, and correct */
// {
// if((JS & (0xC0<<x) ) == (0xC0<<x) ) JS&=~(0xC0<<x);
// if((JS & (0x30<<x) ) == (0x30<<x) ) JS&=~(0x30<<x);
// }
JSreturn=JS;
}
ButtConfig powerpadsc[2][12]={
{
MK(O),MK(P),MK(BRACKET_LEFT),
MK(BRACKET_RIGHT),MK(K),MK(L),MK(SEMICOLON),
MK(APOSTROPHE),
MK(M),MK(COMMA),MK(PERIOD),MK(SLASH)
},
{
MK(O),MK(P),MK(BRACKET_LEFT),
MK(BRACKET_RIGHT),MK(K),MK(L),MK(SEMICOLON),
MK(APOSTROPHE),
MK(M),MK(COMMA),MK(PERIOD),MK(SLASH)
}
};
static uint32 powerpadbuf[2]={0,0};
static uint32 UpdatePPadData(int w)
{
if(FCEUI_IsMovieActive()<0)
return;
uint32 r=0;
ButtConfig *ppadtsc=powerpadsc[w];
int x;
for(x=0;x<12;x++)
if(DTestButton(&ppadtsc[x])) r|=1<<x;
return r;
}
static uint32 MouseData[3]={0,0,0};
static uint8 fkbkeys[0x48];
void FCEUD_UpdateInput(void)
{
int x;
int t=0;
UpdatePhysicalInput();
KeyboardCommands();
for(x=0;x<2;x++)
switch(InputType[x])
{
case SI_GAMEPAD:t|=1;break;
case SI_ARKANOID:t|=2;break;
case SI_ZAPPER:t|=2;break;
case SI_POWERPADA:
case SI_POWERPADB:powerpadbuf[x]=UpdatePPadData(x);break;
}
switch(InputType[2])
{
case SIFC_ARKANOID:t|=2;break;
case SIFC_SHADOW:t|=2;break;
case SIFC_FKB:if(cidisabled) UpdateFKB();break;
case SIFC_HYPERSHOT: UpdateHyperShot();break;
case SIFC_MAHJONG: UpdateMahjong();break;
case SIFC_QUIZKING: UpdateQuizKing();break;
case SIFC_FTRAINERB:
case SIFC_FTRAINERA: UpdateFTrainer();break;
case SIFC_TOPRIDER: UpdateTopRider();break;
case SIFC_OEKAKIDS:t|=2;break;
}
if(t&1)
UpdateGamepad();
if(t&2)
GetMouseData(MouseData);
}
void InitOtherInput(void)
{
void *InputDPtr;
int t;
int x;
int attrib;
for(t=0,x=0;x<2;x++)
{
attrib=0;
InputDPtr=0;
switch(InputType[x])
{
case SI_POWERPADA:
case SI_POWERPADB:InputDPtr=&powerpadbuf[x];break;
case SI_GAMEPAD:InputDPtr=&JSreturn;break;
case SI_ARKANOID:InputDPtr=MouseData;t|=1;break;
case SI_ZAPPER:InputDPtr=MouseData;
t|=1;
attrib=1;
break;
}
FCEUI_SetInput(x,InputType[x],InputDPtr,attrib);
}
attrib=0;
InputDPtr=0;
switch(InputType[2])
{
case SIFC_SHADOW:InputDPtr=MouseData;t|=1;attrib=1;break;
case SIFC_OEKAKIDS:InputDPtr=MouseData;t|=1;attrib=1;break;
case SIFC_ARKANOID:InputDPtr=MouseData;t|=1;break;
case SIFC_FKB:InputDPtr=fkbkeys;break;
case SIFC_HYPERSHOT:InputDPtr=&HyperShotData;break;
case SIFC_MAHJONG:InputDPtr=&MahjongData;break;
case SIFC_QUIZKING:InputDPtr=&QuizKingData;break;
case SIFC_TOPRIDER:InputDPtr=&TopRiderData;break;
case SIFC_BWORLD:InputDPtr=BWorldData;break;
case SIFC_FTRAINERA:
case SIFC_FTRAINERB:InputDPtr=&FTrainerData;break;
}
FCEUI_SetInputFC(InputType[2],InputDPtr,attrib);
FCEUI_DisableFourScore(eoptions&EO_NOFOURSCORE);
if(t)
InitMouse();
}
ButtConfig fkbmap[0x48]=
{
MK(F1),MK(F2),MK(F3),MK(F4),MK(F5),MK(F6),MK(F7),MK(F8),
MK(1),MK(2),MK(3),MK(4),MK(5),MK(6),MK(7),MK(8),MK(9),MK(0),
MK(MINUS),MK(EQUAL),MK(BACKSLASH),MK(BACKSPACE),
MK(ESCAPE),MK(Q),MK(W),MK(E),MK(R),MK(T),MK(Y),MK(U),MK(I),MK(O),
MK(P),MK(GRAVE),MK(BRACKET_LEFT),MK(ENTER),
MK(LEFTCONTROL),MK(A),MK(S),MK(D),MK(F),MK(G),MK(H),MK(J),MK(K),
MK(L),MK(SEMICOLON),MK(APOSTROPHE),MK(BRACKET_RIGHT),MK(INSERT),
MK(LEFTSHIFT),MK(Z),MK(X),MK(C),MK(V),MK(B),MK(N),MK(M),MK(COMMA),
MK(PERIOD),MK(SLASH),MK(RIGHTALT),MK(RIGHTSHIFT),MK(LEFTALT),MK(SPACE),
MK(DELETE),MK(END),MK(PAGEDOWN),
MK(CURSORUP),MK(CURSORLEFT),MK(CURSORRIGHT),MK(CURSORDOWN)
};
static void UpdateFKB(void)
{
int x;
for(x=0;x<0x48;x++)
{
fkbkeys[x]=0;
if(DTestButton(&fkbmap[x]))
fkbkeys[x]=1;
}
}
static ButtConfig HyperShotButtons[4]=
{
MK(Q),MK(W),MK(E),MK(R)
};
static void UpdateHyperShot(void)
{
int x;
HyperShotData=0;
for(x=0;x<0x4;x++)
{
if(DTestButton(&HyperShotButtons[x]))
HyperShotData|=1<<x;
}
}
static ButtConfig MahjongButtons[21]=
{
MK(Q),MK(W),MK(E),MK(R),MK(T),
MK(A),MK(S),MK(D),MK(F),MK(G),MK(H),MK(J),MK(K),MK(L),
MK(Z),MK(X),MK(C),MK(V),MK(B),MK(N),MK(M)
};
static void UpdateMahjong(void)
{
int x;
MahjongData=0;
for(x=0;x<21;x++)
{
if(DTestButton(&MahjongButtons[x]))
MahjongData|=1<<x;
}
}
ButtConfig QuizKingButtons[6]=
{
MK(Q),MK(W),MK(E),MK(R),MK(T),MK(Y)
};
static void UpdateQuizKing(void)
{
int x;
QuizKingData=0;
for(x=0;x<6;x++)
{
if(DTestButton(&QuizKingButtons[x]))
QuizKingData|=1<<x;
}
}
ButtConfig TopRiderButtons[8]=
{
MK(Q),MK(W),MK(E),MK(R),MK(T),MK(Y),MK(U),MK(I)
};
static void UpdateTopRider(void)
{
int x;
TopRiderData=0;
for(x=0;x<8;x++)
if(DTestButton(&TopRiderButtons[x]))
TopRiderData|=1<<x;
}
ButtConfig FTrainerButtons[12]=
{
MK(O),MK(P),MK(BRACKET_LEFT),
MK(BRACKET_RIGHT),MK(K),MK(L),MK(SEMICOLON),
MK(APOSTROPHE),
MK(M),MK(COMMA),MK(PERIOD),MK(SLASH)
};
static void UpdateFTrainer(void)
{
int x;
FTrainerData=0;
for(x=0;x<12;x++)
{
if(DTestButton(&FTrainerButtons[x]))
FTrainerData|=1<<x;
}
}
static void subcon(char *text, ButtConfig *bc)
{
uint8 buf[256];
int wc;
for(wc=0;wc<MAXBUTTCONFIG;wc++)
{
sprintf(buf,"%s (%d)",text,wc+1);
DWaitButton(buf,bc,wc);
if(wc && bc->ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] &&
bc->ButtonNum[wc]==bc->ButtonNum[wc-1])
break;
}
bc->NumC=wc;
}
void ConfigDevice(int which, int arg)
{
uint8 buf[256];
int x;
ButtonConfigBegin();
switch(which)
{
case FCFGD_QUIZKING:
for(x=0;x<6;x++)
{
sprintf(buf,"Quiz King Buzzer #%d", x+1);
subcon(buf,&QuizKingButtons[x]);
}
break;
case FCFGD_HYPERSHOT:
for(x=0;x<4;x++)
{
sprintf(buf,"Hyper Shot %d: %s",((x&2)>>1)+1,(x&1)?"JUMP":"RUN");
subcon(buf,&HyperShotButtons[x]);
}
break;
case FCFGD_POWERPAD:
for(x=0;x<12;x++)
{
sprintf(buf,"PowerPad %d: %d", (arg&1)+1,x+11);
subcon(buf,&powerpadsc[arg&1][x]);
}
break;
case FCFGD_GAMEPAD:
{
char *str[10]={"A","B","SELECT","START","UP","DOWN","LEFT","RIGHT","Rapid A","Rapid B"};
for(x=0;x<10;x++)
{
sprintf(buf,"GamePad #%d: %s",arg+1,str[x]);
subcon(buf,&GamePadConfig[arg][x]);
}
}
break;
}
ButtonConfigEnd();
}
CFGSTRUCT InputConfig[]={
ACA(UsrInputType),
AC(powerpadsc),
AC(QuizKingButtons),
AC(FTrainerButtons),
AC(HyperShotButtons),
AC(MahjongButtons),
AC(GamePadConfig),
AC(fkbmap),
ENDCFGSTRUCT
};
static void InputCfg(char *text)
{
if(!strncasecmp(text,"gamepad",strlen("gamepad")))
{
ConfigDevice(FCFGD_GAMEPAD,(text[strlen("gamepad")]-'1')&3);
}
else if(!strncasecmp(text,"powerpad",strlen("powerpad")))
{
ConfigDevice(FCFGD_POWERPAD,(text[strlen("powerpad")]-'1')&1);
}
else if(!strcasecmp(text,"hypershot"))
ConfigDevice(FCFGD_HYPERSHOT,0);
else if(!strcasecmp(text,"quizking"))
ConfigDevice(FCFGD_QUIZKING,0);
}
static void FCExp(char *text)
{
static char *fccortab[11]={"none","arkanoid","shadow","4player","fkb","hypershot",
"mahjong","quizking","ftrainera","ftrainerb","oekakids"};
static int fccortabi[11]={SIFC_NONE,SIFC_ARKANOID,SIFC_SHADOW,
SIFC_4PLAYER,SIFC_FKB,SIFC_HYPERSHOT,SIFC_MAHJONG,SIFC_QUIZKING,
SIFC_FTRAINERA,SIFC_FTRAINERB,SIFC_OEKAKIDS};
int y;
for(y=0;y<11;y++)
if(!strcmp(fccortab[y],text))
UsrInputType[2]=fccortabi[y];
}
static char *cortab[6]={"none","gamepad","zapper","powerpada","powerpadb","arkanoid"};
static int cortabi[6]={SI_NONE,SI_GAMEPAD,
SI_ZAPPER,SI_POWERPADA,SI_POWERPADB,SI_ARKANOID};
static void Input1(char *text)
{
int y;
for(y=0;y<6;y++)
if(!strcmp(cortab[y],text))
UsrInputType[0]=cortabi[y];
}
static void Input2(char *text)
{
int y;
for(y=0;y<6;y++)
if(!strcmp(cortab[y],text))
UsrInputType[1]=cortabi[y];
}
ARGPSTRUCT InputArgs[]={
{"-inputcfg",0,(void *)InputCfg,0x2000},
{"-fcexp",0,(void *)FCExp,0x2000},
{"-input1",0,(void *)Input1,0x2000},
{"-input2",0,(void *)Input2,0x2000},
{0,0,0,0}
};

View File

@ -1,38 +0,0 @@
#ifndef _aosdfjk02fmasf
#define _aosdfjk02fmasf
#define MAXBUTTCONFIG 4
typedef struct {
uint8 ButtType[MAXBUTTCONFIG];
uint8 DeviceNum[MAXBUTTCONFIG];
uint16 ButtonNum[MAXBUTTCONFIG];
uint32 NumC;
//uint64 DeviceID[MAXBUTTCONFIG]; /* TODO */
} ButtConfig;
extern CFGSTRUCT InputConfig[];
extern ARGPSTRUCT InputArgs[];
void ParseGIInput(FCEUGI *GI);
#define BUTTC_KEYBOARD 0x00
#define BUTTC_JOYSTICK 0x01
#define BUTTC_MOUSE 0x02
#define FCFGD_GAMEPAD 1
#define FCFGD_POWERPAD 2
#define FCFGD_HYPERSHOT 3
#define FCFGD_QUIZKING 4
void InitOtherInput(void);
void InputUserActiveFix(void);
#ifdef EXTGUI
extern ButtConfig GamePadConfig[4][10];
extern ButtConfig powerpadsc[2][12];
extern ButtConfig QuizKingButtons[6];
extern ButtConfig FTrainerButtons[12];
#endif
void IncreaseEmulationSpeed(void);
void DecreaseEmulationSpeed(void);
void FCEUD_UpdateInput(void);
#endif

View File

@ -1,161 +0,0 @@
#ifdef SDL
#include <SDL.h>
#define SDLK_A SDLK_a
#define SDLK_B SDLK_b
#define SDLK_C SDLK_c
#define SDLK_D SDLK_d
#define SDLK_E SDLK_e
#define SDLK_F SDLK_f
#define SDLK_G SDLK_g
#define SDLK_H SDLK_h
#define SDLK_I SDLK_i
#define SDLK_J SDLK_j
#define SDLK_K SDLK_k
#define SDLK_L SDLK_l
#define SDLK_M SDLK_m
#define SDLK_N SDLK_n
#define SDLK_O SDLK_o
#define SDLK_P SDLK_p
#define SDLK_Q SDLK_q
#define SDLK_R SDLK_r
#define SDLK_S SDLK_s
#define SDLK_T SDLK_t
#define SDLK_U SDLK_u
#define SDLK_V SDLK_v
#define SDLK_W SDLK_w
#define SDLK_X SDLK_x
#define SDLK_Y SDLK_y
#define SDLK_Z SDLK_z
#define SDLK_LEFTCONTROL SDLK_LCTRL
#define SDLK_RIGHTCONTROL SDLK_RCTRL
#define SDLK_LEFTALT SDLK_LALT
#define SDLK_RIGHTALT SDLK_RALT
#define SDLK_LEFTSHIFT SDLK_LSHIFT
#define SDLK_RIGHTSHIFT SDLK_RSHIFT
#define SDLK_CURSORDOWN SDLK_DOWN
#define SDLK_CURSORUP SDLK_UP
#define SDLK_CURSORLEFT SDLK_LEFT
#define SDLK_CURSORRIGHT SDLK_RIGHT
#define SDLK_ENTER SDLK_RETURN
#define SDLK_EQUAL SDLK_EQUALS
#define SDLK_APOSTROPHE SDLK_QUOTE
#define SDLK_BRACKET_LEFT SDLK_LEFTBRACKET
#define SDLK_BRACKET_RIGHT SDLK_RIGHTBRACKET
#define SDLK_SCROLLLOCK SDLK_SCROLLOCK /* I guess the SDL people don't like lots of Ls... */
#define SDLK_GRAVE SDLK_BACKQUOTE
#define MKK(k) SDLK_##k
#define MKK_COUNT (SDLK_LAST+1)
#elif DOS
#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
/* Extended keys. */
#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 often found 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_PAUSE 0xC5
#define SCAN_ASTERISK 0x37
#define SCAN_PAGEUP 0x49
#define SCAN_CURSORRIGHT 0x4D
#define SCAN_PAGEDOWN 0x51
#define SCAN_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
#define MK_COUNT 256
#define MK(k) SCAN_##k
#endif

View File

@ -1,553 +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 <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
#include "throttle.h"
#include "../common/cheat.h"
#include "input.h"
#include "dface.h"
extern int32 fps_scale;
int CloseGame(void);
static char *soundrecfn=0; /* File name of sound recording. */
static int ntsccol=0,ntschue=0,ntsctint=0;
int soundvol=100;
long soundq=0;
int _sound=1;
long soundrate=48000;
#ifdef WIN32
long soundbufsize=52;
#else
long soundbufsize=24;
#endif
#ifdef FRAMESKIP
static int frameskip=0;
#endif
static int inited=0;
static int isloaded=0; // Is game loaded?
int srendlinev[2]={8,0};
int erendlinev[2]={231,239};
static uint8 *DrBaseDirectory;
int eoptions=0;
static void DriverKill(void);
static int DriverInitialize(FCEUGI *gi);
int gametype;
FCEUGI *CurGame=NULL;
static void ParseGI(FCEUGI *gi)
{
ParseGIInput(gi);
gametype=gi->type;
}
#ifndef EXTGUI
void FCEUD_PrintError(char *s)
{
puts(s);
}
void FCEUD_Message(char *s)
{
fputs(s,stdout);
}
#endif
static char *cpalette=0;
static void LoadCPalette(void)
{
uint8 tmpp[192];
FILE *fp;
if(!(fp=FCEUD_UTF8fopen(cpalette,"rb")))
{
printf(" Error loading custom palette from file: %s\n",cpalette);
return;
}
fread(tmpp,1,192,fp);
FCEUI_SetPaletteArray(tmpp);
fclose(fp);
}
#ifdef EXTGUI
extern CFGSTRUCT GUIConfig;
#endif
static CFGSTRUCT fceuconfig[]={
AC(soundrate),
AC(soundq),
AC(_sound),
AC(soundvol),
AC(soundbufsize),
ACS(cpalette),
AC(ntsctint),
AC(ntschue),
AC(ntsccol),
AC(eoptions),
ACA(srendlinev),
ACA(erendlinev),
ADDCFGSTRUCT(InputConfig),
ADDCFGSTRUCT(DriverConfig),
#ifdef EXTGUI
ADDCFGSTRUCT(GUIConfig),
#endif
ENDCFGSTRUCT
};
static void SaveConfig(void)
{
char tdir[2048];
sprintf(tdir,"%s"PSS"fceu98.cfg",DrBaseDirectory);
FCEUI_GetNTSCTH(&ntsctint, &ntschue);
SaveFCEUConfig(tdir,fceuconfig);
}
static void LoadConfig(void)
{
char tdir[2048];
sprintf(tdir,"%s"PSS"fceu98.cfg",DrBaseDirectory);
FCEUI_GetNTSCTH(&ntsctint, &ntschue); /* Get default settings for if
no config file exists. */
LoadFCEUConfig(tdir,fceuconfig);
InputUserActiveFix();
}
static void CreateDirs(void)
{
char *subs[7]={"fcs","fcm","snaps","gameinfo","sav","cheats","movie"};
char tdir[2048];
int x;
#ifdef WIN32
mkdir(DrBaseDirectory);
for(x=0;x<6;x++)
{
sprintf(tdir,"%s"PSS"%s",DrBaseDirectory,subs[x]);
mkdir(tdir);
}
#else
mkdir(DrBaseDirectory,S_IRWXU);
for(x=0;x<6;x++)
{
sprintf(tdir,"%s"PSS"%s",DrBaseDirectory,subs[x]);
mkdir(tdir,S_IRWXU);
}
#endif
}
#ifndef WIN32
static void SetSignals(void (*t)(int))
{
int sigs[11]={SIGINT,SIGTERM,SIGHUP,SIGPIPE,SIGSEGV,SIGFPE,SIGKILL,SIGALRM,SIGABRT,SIGUSR1,SIGUSR2};
int x;
for(x=0;x<11;x++)
signal(sigs[x],t);
}
static void CloseStuff(int signum)
{
DriverKill();
printf("\nSignal %d has been caught and dealt with...\n",signum);
switch(signum)
{
case SIGINT:printf("How DARE you interrupt me!\n");break;
case SIGTERM:printf("MUST TERMINATE ALL HUMANS\n");break;
case SIGHUP:printf("Reach out and hang-up on someone.\n");break;
case SIGPIPE:printf("The pipe has broken! Better watch out for floods...\n");break;
case SIGSEGV:printf("Iyeeeeeeeee!!! A segmentation fault has occurred. Have a fluffy day.\n");break;
/* So much SIGBUS evil. */
#ifdef SIGBUS
#if(SIGBUS!=SIGSEGV)
case SIGBUS:printf("I told you to be nice to the driver.\n");break;
#endif
#endif
case SIGFPE:printf("Those darn floating points. Ne'er know when they'll bite!\n");break;
case SIGALRM:printf("Don't throw your clock at the meowing cats!\n");break;
case SIGABRT:printf("Abort, Retry, Ignore, Fail?\n");break;
case SIGUSR1:
case SIGUSR2:printf("Killing your processes is not nice.\n");break;
}
exit(1);
}
#endif
static void DoArgs(int argc, char *argv[])
{
int x;
static ARGPSTRUCT FCEUArgs[]={
{"-soundbufsize",0,&soundbufsize,0},
{"-soundrate",0,&soundrate,0},
{"-soundq",0,&soundq,0},
#ifdef FRAMESKIP
{"-frameskip",0,&frameskip,0},
#endif
{"-sound",0,&_sound,0},
{"-soundvol",0,&soundvol,0},
{"-cpalette",0,&cpalette,0x4001},
{"-soundrecord",0,&soundrecfn,0x4001},
{"-ntsccol",0,&ntsccol,0},
{"-pal",0,&eoptions,0x8000|EO_PAL},
{"-lowpass",0,&eoptions,0x8000|EO_LOWPASS},
{"-gg",0,&eoptions,0x8000|EO_GAMEGENIE},
{"-no8lim",0,&eoptions,0x8001},
{"-snapname",0,&eoptions,0x8000|EO_SNAPNAME},
{"-nofs",0,&eoptions,0x8000|EO_NOFOURSCORE},
{"-clipsides",0,&eoptions,0x8000|EO_CLIPSIDES},
{"-nothrottle",0,&eoptions,0x8000|EO_NOTHROTTLE},
{"-slstart",0,&srendlinev[0],0},{"-slend",0,&erendlinev[0],0},
{"-slstartp",0,&srendlinev[1],0},{"-slendp",0,&erendlinev[1],0},
{0,(int *)InputArgs,0,0},
{0,(int *)DriverArgs,0,0},
{0,0,0,0}
};
ParseArguments(argc, argv, FCEUArgs);
if(cpalette)
{
if(cpalette[0]=='0')
if(cpalette[1]==0)
{
free(cpalette);
cpalette=0;
}
}
FCEUI_SetVidSystem((eoptions&EO_PAL)?1:0);
FCEUI_SetGameGenie((eoptions&EO_GAMEGENIE)?1:0);
FCEUI_SetLowPass((eoptions&EO_LOWPASS)?1:0);
FCEUI_DisableSpriteLimitation(eoptions&1);
FCEUI_SetSnapName(eoptions&EO_SNAPNAME);
for(x=0;x<2;x++)
{
if(srendlinev[x]<0 || srendlinev[x]>239) srendlinev[x]=0;
if(erendlinev[x]<srendlinev[x] || erendlinev[x]>239) erendlinev[x]=239;
}
FCEUI_SetRenderedLines(srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]);
DoDriverArgs();
}
#include "usage.h"
/* Loads a game, given a full path/filename. The driver code must be
initialized after the game is loaded, because the emulator code
provides data necessary for the driver code(number of scanlines to
render, what virtual input devices to use, etc.).
*/
int LoadGame(const char *path)
{
FCEUGI *tmp;
CloseGame();
if(!(tmp=FCEUI_LoadGame(path,1)))
return 0;
CurGame=tmp;
ParseGI(tmp);
RefreshThrottleFPS();
if(!DriverInitialize(tmp))
return(0);
if(soundrecfn)
{
if(!FCEUI_BeginWaveRecord(soundrecfn))
{
free(soundrecfn);
soundrecfn=0;
}
}
isloaded=1;
#ifdef EXTGUI
if(eoptions&EO_AUTOHIDE) GUI_Hide(1);
#endif
FCEUD_NetworkConnect();
return 1;
}
/* Closes a game. Frees memory, and deinitializes the drivers. */
int CloseGame(void)
{
if(!isloaded) return(0);
FCEUI_CloseGame();
DriverKill();
isloaded=0;
CurGame=0;
if(soundrecfn)
FCEUI_EndWaveRecord();
#ifdef EXTGUI
GUI_Hide(0);
#endif
InputUserActiveFix();
return(1);
}
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
void DoFun(void)
{
uint8 *gfx;
int32 *sound;
int32 ssize;
static int fskipc=0;
static int opause=0;
#ifdef FRAMESKIP
fskipc=(fskipc+1)%(frameskip+1);
#endif
if(NoWaiting) {gfx=0;}
FCEUI_Emulate(&gfx, &sound, &ssize, fskipc);
FCEUD_Update(gfx, sound, ssize);
if(opause!=FCEUI_EmulationPaused())
{
opause=FCEUI_EmulationPaused();
SilenceSound(opause);
}
}
int CLImain(int argc, char *argv[])
{
int ret;
if(!(ret=FCEUI_Initialize()))
return(0);
DrBaseDirectory=GetBaseDirectory();
FCEUI_SetBaseDirectory(DrBaseDirectory);
CreateDirs();
#ifdef EXTGUI
if(argc==2 && !strcmp(argv[1],"-help")) // I hope no one has a game named "-help" :b
#else
if(argc<=1)
#endif
{
ShowUsage(argv[0]);
return(0);
}
LoadConfig();
DoArgs(argc-2,&argv[1]);
FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue);
if(cpalette)
LoadCPalette();
/* All the config files and arguments are parsed now. */
#ifdef EXTGUI
return(1);
#else
if(!LoadGame(argv[argc-1]))
{
DriverKill();
return(0);
}
while(CurGame)
DoFun();
#if(0)
{
int x;
for(x=1;x<argc;x++)
{ LoadGame(argv[x]); while(CurGame) DoFun(); }
}
#endif
CloseGame();
SaveConfig();
FCEUI_Kill();
#endif
return(1);
}
static int DriverInitialize(FCEUGI *gi)
{
#ifndef WIN32
SetSignals(CloseStuff);
#endif
/* Initialize video before all else, due to some wacko dependencies
in the SexyAL code(DirectSound) that need to be fixed.
*/
if(!InitVideo(gi)) return 0;
inited|=4;
if(InitSound(gi))
inited|=1;
if(InitJoysticks())
inited|=2;
if(!InitKeyboard()) return 0;
inited|=8;
InitOtherInput();
return 1;
}
static void DriverKill(void)
{
SaveConfig();
#ifndef WIN32
SetSignals(SIG_IGN);
#endif
if(inited&2)
KillJoysticks();
if(inited&8)
KillKeyboard();
if(inited&4)
KillVideo();
if(inited&1)
KillSound();
if(inited&16)
KillMouse();
inited=0;
}
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
{
#ifdef NETWORK
extern int FCEUDnetplay;
#endif
int ocount = Count;
// apply frame scaling to Count
Count = (Count<<8)/fps_scale;
if(Count)
{
int32 can=GetWriteSound();
static int uflow=0;
int32 tmpcan;
// don't underflow when scaling fps
if(can >= GetMaxSound() && fps_scale<=256) uflow=1; /* Go into massive underflow mode. */
if(can > Count) can=Count;
else uflow=0;
WriteSound(Buffer,can);
//if(uflow) puts("Underflow");
tmpcan = GetWriteSound();
// don't underflow when scaling fps
if(fps_scale>256 || ((tmpcan < Count*0.90) && !uflow))
{
if(XBuf && (inited&4) && !(NoWaiting & 2))
BlitScreen(XBuf);
Buffer+=can;
Count-=can;
if(Count)
{
if(NoWaiting)
{
can=GetWriteSound();
if(Count>can) Count=can;
WriteSound(Buffer,Count);
}
else
{
while(Count>0)
{
WriteSound(Buffer,(Count<ocount) ? Count : ocount);
Count -= ocount;
}
}
}
} //else puts("Skipped");
#ifdef NETWORK
else if(!NoWaiting && FCEUDnetplay && (uflow || tmpcan >= (Count * 1.8)))
{
if(Count > tmpcan) Count=tmpcan;
while(tmpcan > 0)
{
// printf("Overwrite: %d\n", (Count <= tmpcan)?Count : tmpcan);
WriteSound(Buffer, (Count <= tmpcan)?Count : tmpcan);
tmpcan -= Count;
}
}
#endif
}
else
{
if(!NoWaiting && (!(eoptions&EO_NOTHROTTLE) || FCEUI_EmulationPaused()))
SpeedThrottle();
if(XBuf && (inited&4))
{
BlitScreen(XBuf);
}
}
FCEUD_UpdateInput();
//if(!Count && !NoWaiting && !(eoptions&EO_NOTHROTTLE))
// SpeedThrottle();
//if(XBuf && (inited&4))
//{
// BlitScreen(XBuf);
//}
//if(Count)
// WriteSound(Buffer,Count,NoWaiting);
//FCEUD_UpdateInput();
}
/* Maybe ifndef WXWINDOWS would be better? ^_^ */
#ifndef EXTGUI
FILE *FCEUD_UTF8fopen(const char *fn, const char *mode)
{
return(fopen(fn,mode));
}
#endif

View File

@ -1,55 +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
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "../../driver.h"
#include "../common/config.h"
#include "../common/args.h"
extern int eoptions;
#define EO_NO8LIM 1
#define EO_SUBASE 2
#define EO_CLIPSIDES 8
#define EO_SNAPNAME 16
#define EO_NOFOURSCORE 32
#define EO_NOTHROTTLE 64
#define EO_GAMEGENIE 128
#define EO_PAL 256
#define EO_LOWPASS 512
#define EO_AUTOHIDE 1024
extern int srendlinev[2],erendlinev[2];
extern int NoWaiting;
extern int soundvol;
extern long soundq;
extern int _sound;
extern long soundrate;
extern long soundbufsize;
int CLImain(int argc, char *argv[]);
#ifdef __cplusplus
}
#endif

View File

@ -1,134 +0,0 @@
static const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
uint8 pixel_data[32 * 32 * 3 + 1];
} fceu_playicon = {
32, 32, 3,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\0\0\0\0\0\0\0\0\0\\\223\373\\\223\373\267\317\373"
"\246\304\373\260\312\373\222\267\373\246\304\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\267\317\373\246\304\373\260\312\373\210\261\373\246\304\373\\\223\373\\"
"\223\373\210\261\373\222\267\373\267\317\373\241\301\373\\\223\373\\\223"
"\373\0\0\0\0\0\0\\\223\373\\\223\373\227\272\373\227\272\373\227\272\373"
"\227\272\373\227\272\373\227\272\373\\\223\373\\\223\373z`sr\242\373\227"
"\272\373\227\272\373\\\223\373\\\223\373\\\223\373\\\223\373\213\261\373"
"z\247\373\213\261\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\"
"\223\373\\\223\373\313i=\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40"
"\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40"
"\315Z\40\315Z\40\315Z\40\315Z\40\315Z\40\257T*\\\223\373\\\223\373\\\223"
"\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\315Z\40"
"\355\235\203\355\235\203\341\232\205\341\232\205\365\255\233\355\235\203"
"\355\235\203\350\250\232\365\255\233\355\235\203\307L\14\307L\14\307L\14"
"\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\256B\12\\\223\373"
"\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373"
"\\\223\373\315Z\40\273zc\233l_\325\225\205\325\225\205\325\225\205\273\212"
"\201\325\225\205\237qd\325\225\205\317\231\216\307L\14\307L\14\307L\14\307"
"L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\256B\12\\\223\373\\"
"\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\"
"\223\373\315Z\40\344\232\203\301\215\201\344\232\203\273\212\201\325\225"
"\205\2114\10\344\232\203\350\250\232\325\225\205\333\230\205\307L\14\307"
"L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\256"
"B\12\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223"
"\373\\\223\373\\\223\373\315Z\40\2259\11}0\10\2259\11}0\10}0\10\307L\14\225"
"9\11d&\6}0\10}0\10\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14\307L\14"
"\307L\14\307L\14\307L\14\256B\12\\\223\373\\\223\373\\\223\373\\\223\373"
"\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\315Z\40\355\235\203"
"\355\233\201\355\235\203\355\235\203\355\235\203\365\255\233\355\235\203"
"\341\232\205\355\235\203\355\235\203\307L\14\365\255\233\355\235\203\365"
"\255\233\355\235\203\355\235\203\355\235\203\355\235\203\355\235\203\307"
"L\14\256B\12\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373"
"\\\223\373\\\223\373\\\223\373\315Z\40\325\225\205\311\221\204\311\221\204"
"\325\225\205\311\221\204\325\225\205\311\221\204\325\225\205\325\225\205"
"\311\221\204\307L\14\325\225\205\311\221\204\325\225\205\311\221\204\325"
"\225\205\311\221\204\325\225\205\311\221\204\307L\14\256B\12\\\223\373\\"
"\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\"
"\223\373\315Z\40\325\225\205\325\225\205\325\225\205\325\225\205\325\225"
"\205\325\225\205\317\231\216\325\225\205\325\225\205\325\225\205\307L\14"
"\325\225\205\317\231\216\325\225\205\317\231\216\325\225\205\325\225\205"
"\273zc\241n_\307L\14\256B\12\\\223\373\\\223\373\\\223\373\\\223\373\0\0"
"\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\315Z\40\325\225\205\325"
"\225\205\325\225\205\365\255\233\333\243\231\325\225\205\333\230\205\325"
"\225\205\325\225\205\325\225\205\307L\14\325\225\205\317\223\204\325\225"
"\205\333\230\205\325\225\205\325\225\205\333\230\205\317\223\204\307L\14"
"\256B\12\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\"
"\223\373\\\223\373\\\223\373\315Z\40\325\225\205\325\225\205\325\225\205"
"\325\225\205\311\221\204\325\225\205\325\225\205\325\225\205\344\232\203"
"\273\212\201\307L\14\325\225\205\273\212\201\325\225\205\325\225\205\344"
"\232\203\273\212\201\344\232\203\273\212\201\341\232\205\256B\12\\\223\373"
"\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373"
"\\\223\373\257T*d&\6d&\6d&\6d&\6d&\6d&\6d&\6d&\6}0\10d&\6\256B\12d&\6p+\7"
"d&\6d&\6}0\10d&\6}0\10d&\6d&\6\223@\26\\\223\373\\\223\373\\\223\373\\\223"
"\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\234\243"
"\335\213\237\344\237\244\333\251\247\326\237\244\333\\\223\373\267\252\317"
"\222\241\341\267\252\317\210\237\346\241\245\332\267\252\317\246\246\327"
"\246\246\327\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\0"
"\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\257hT\\\223\373\213\261\373\\\223"
"\373\241\301\373\210\261\373\246\304\373\222\267\373\241\301\373\260\312"
"\373\\\223\373\237\277\373\246\304\373\267\317\373\241\301\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\0\0\0\0\0\0\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\\\223\373\246\304\373\\\223\373\241"
"\301\373\210\261\373\246\304\373\222\267\373\241\301\373\260\312\373\\\223"
"\373\237\277\373\246\304\373\267\317\373\241\301\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\0\0\0\0\0\0\\\223\373"
"\\\223\373\\\223\373D\203\270D\203\270\\\223\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\0\0"
"\0\0\0\0\\\223\373\\\223\373(\211n\0\247\0\0n\0(\211n\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\0\0\0\0\0\0\\\223\373(\211n\0\247\0\0\247\0\0\247\0\0\247\0(\211n\\\223"
"\373\\\223\373\\\223\373\\\223\373\210\261\373\246\304\373\241\301\373z\247"
"\373\\\223\373\227\272\373\227\272\373\227\272\373\227\272\373\227\272\373"
"\227\272\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\0\0\0\0\0\0(\211n\0\247\0\0n\0\0\247\0\\\215\12fs\16"
"\0\247\0(\211n\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\"
"\223\373\\\223\373Z\231Z[\230SZ\231Z[\230SZ\231Z[\230S\\\223\373\0\0\0\0"
"\0\0\0\247\0\0\247\0\0\247\0\0\247\0vy\7p|\7\0\247\0\0\247\0(\211n\\\223"
"\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373"
"\\\223\373\\\223\373\\\223\373\\\223\373\\\223\373b\237L\200\317\20\200\317"
"\20\200\317\20\200\317\20\200\317\20\200\317\20[\223H\0\0\0\0\0\0\230P.\323"
"d0\230P.\323d0\221M&\313`%\230P.\323d0\230P.\323d0\230P.\323d0\230P.\323"
"d0\230P.\323d0\230P.\323d0\230P.\323d0\230P.\323d0\230P.\323d0\230P.\323"
"d0\230P.\323d0\230P.\323d0\0\0\0\0\0\0\0\0\0\237N(\225E\35\237N(\225E\35"
"\237N(\225E\35\237N(\225E\35\237N(\225E\35\237N(\225E\35\237N(\225E\35\237"
"N(\225E\35\237N(\225E\35\237N(\225E\35\237N(\225E\35\237N(\225E\35\237N("
"\225E\35\237N(\225E\35\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
};

View File

@ -1,99 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
* Copyright (C) 2002 Paul Kuliniewicz
*
* 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
*/
/* PK: SDL joystick input stuff */
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "sdl.h"
#define MAX_JOYSTICKS 32
static SDL_Joystick *Joysticks[MAX_JOYSTICKS] = {NULL};
int DTestButtonJoy(ButtConfig *bc)
{
int x;
for(x=0;x<bc->NumC;x++)
{
if(bc->ButtonNum[x]&0x8000) /* Axis "button" */
{
int pos;
pos = SDL_JoystickGetAxis(Joysticks[bc->DeviceNum[x]], bc->ButtonNum[x]&16383);
if ((bc->ButtonNum[x]&0x4000) && pos <= -16383)
return(1);
else if (!(bc->ButtonNum[x]&0x4000) && pos >= 16363)
return(1);
}
else if(bc->ButtonNum[x]&0x2000) /* Hat "button" */
{
if( SDL_JoystickGetHat(Joysticks[bc->DeviceNum[x]],(bc->ButtonNum[x]>>8)&0x1F) & (bc->ButtonNum[x]&0xFF))
return(1);
}
else
if(SDL_JoystickGetButton(Joysticks[bc->DeviceNum[x]], bc->ButtonNum[x] ))
return(1);
}
return(0);
}
static int jinited=0;
/* Cleanup opened joysticks. */
int KillJoysticks (void)
{
int n; /* joystick index */
if(!jinited) return(0);
for (n = 0; n < MAX_JOYSTICKS; n++)
{
if (Joysticks[n] != 0)
SDL_JoystickClose(Joysticks[n]);
Joysticks[n]=0;
}
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return(1);
}
/* Initialize joysticks. */
int InitJoysticks (void)
{
int n; /* joystick index */
int total;
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
total=SDL_NumJoysticks();
if(total>MAX_JOYSTICKS) total=MAX_JOYSTICKS;
for (n = 0; n < total; n++)
{
/* Open the joystick under SDL. */
Joysticks[n] = SDL_JoystickOpen(n);
//printf("Could not open joystick %d: %s.\n",
//joy[n] - 1, SDL_GetError());
continue;
}
jinited=1;
return(1);
}

View File

@ -1,224 +0,0 @@
#include "sdl.h"
#include <SDL/SDL_net.h>
#include "sdl-netplay.h"
char *ServerHost;
static int LocalPortTCP=0xFCE;
static int LocalPortUDP=0xFCE;
static int RemotePortTCP=0xFCE;
static int RemotePortUDP; /* Not configurable, figured out during handshake. */
static TCPsocket Socket;
static UDPsocket UDPSocket;
static SDLNet_SocketSet set;
static void en32(uint8 *buf, uint32 morp)
{
buf[0]=morp;
buf[1]=morp>>8;
buf[2]=morp>>16;
buf[3]=morp>>24;
}
static uint32 de32(uint8 *morp)
{
return(morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24));
}
int FCEUD_NetworkConnect(void)
{
IPaddress rip;
SDLNet_Init();
if(netplay==1) /* Be a server. */
{
TCPsocket tmp;
Uint16 p=LocalPortUDP;
SDLNet_ResolveHost(&rip,NULL,LocalPortTCP);
UDPSocket=SDLNet_UDP_Open(&p);
tmp=SDLNet_TCP_Open(&rip);
Socket=SDLNet_TCP_Accept(&tmp);
memcpy(&rip,SDLNet_TCP_GetPeerAddress(Socket),sizeof(IPaddress));
{
uint8 buf[12];
uint32 player=1;
magic=SDL_GetTicks();
SDLNet_Write32(buf,uport);
SDLNet_Write32(buf+4,1);
SDLNet_Write32(buf+8,magic);
SDLNet_TCP_Send(Socket, buf, 12);
/* Get the UDP port the client is waiting for data on. */
SDLNet_TCP_Recv(Socket, buf, 2);
RemotePortUDP=de32(buf);
}
}
else /* Be a client */
{
SDLNet_ResolveHost(&rip,ServerHost,RemotePortTCP);
Socket=SDLNet_TCP_Open(&rip);
{
Uint16 p=LocalPortUDP;
uint8 buf[12];
UDPSocket=SDLNet_UDP_Open(&p);
/* Now, tell the server what local UDP port it should send to. */
en32(buf,p);
SDLNet_TCP_Send(Socket, buf, 4);
/* Get the UDP port from the server we should send data to. */
SDLNet_TCP_Recv(Socket, buf, 12);
RemotePortUDP=de32(buf);
magic=de32(buf+8);
}
set=SDLNet_AllocSocketSet(1);
SDLNet_TCP_AddSocket(set,TCPSocket);
SDLNet_UDP_AddSocket(set,UDPSocket);
} // End client connect code.
rip.port=RemotePortUDP;
SDLNet_UDP_Bind(UDPSocket, 0, &rip);
}
static int CheckUDP(uint8 *packet, int32 len, int32 alt)
{
uint32 crc;
uint32 repcrc;
crc=FCEUI_CRC32(0,packet+4,len+8);
repcrc=de32(packet);
if(crc!=repcrc) return(0); /* CRC32 mismatch, bad packet. */
packet+=4;
if(de32(packet)!=magic) /* Magic number mismatch, bad or spoofed packet. */
return(0);
packet+=4;
if(alt)
{
if(de32(packet)<incounter) /* Time warped packet. */
return(0);
}
else
if(de32(packet)!=incounter) /* Time warped packet. */
return(0);
return(1);
}
/* Be careful where these MakeXXX() functions are used. */
static uint8 *MakeUDP(uint8 *data, int32 len)
{
/* UDP packet data header is 12 bytes in length. */
static uint8 buf[12+32]; // arbitrary 32.
en32(buf+4,magic);
en32(buf+8,outcounter);
memcpy(buf+12,data,len);
en32(buf,FCEUI_CRC32(0,buf+4,8+len));
return(buf);
}
static uint8 *MakeTCP(uint8 *data, int32 len)
{
/* TCP packet data header is 4 bytes in length. */
static uint8 buf[4+32]; // arbitrary 32.
en32(buf,outcounter);
memcpy(buf+4,data,len);
return(buf);
}
#define UDPHEADSIZE 12
#define TCPHEADSIZE 4
void FCEUD_NetworkClose(void)
{
SDLNet_Quit();
}
/* 1 byte to server */
int FCEUD_SendDataToServer(uint8 v,uint8 cmd)
{
UDPpacket upack;
upack.channel=0;
upack.data=MakeUDP(data,1);
upack.len=upack.maxlen=UDPHEADSIZE+1;
upack.status=0;
SDLNet_UDP_Send(UDPSocket,0,&upack);
outcounter++;
return(1);
}
void FCEUD_SendDataToClients(uint8 *data)
{
UDPpacket upack;
SDLNet_TCP_Send(Socket,MakeTCP(data,5),TCPHEADSIZE+5);
upack.channel=0;
upack.data=MakeUDP(data,5);
upack.len=upack.maxlen=UDPHEADSIZE+5;
upack.status=0;
SDLNet_UDP_Send(UDPSocket,0,&upack);
outcounter++;
return(1);
}
int FCEUD_GetDataFromServer(uint8 *data)
{
uint8 buf[128];
NoWaiting&=~2;
while(SDLNet_CheckSockets(set,1)==0)
{
// do something here.
}
if(SDLNet_SocketReady(Socket))
{
SDLNet_TCP_Recv
if(de32(buf)==incounter) /* New packet, keep. */
{
unsigned long beefie;
memcpy(data,buf+TCPHEADSIZE,5);
incounter++;
if(!ioctl(Socket,FIONREAD,&beefie))
if(beefie)
NoWaiting|=2;
return(1);
}
}
if(SDLNet_SocketReady(UDPSocket)
{
}
}

View File

View File

@ -1,241 +0,0 @@
#define GL_GLEXT_LEGACY
#ifdef APPLEOPENGL
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#endif
#include <string.h>
#include <stdlib.h>
#include "sdl.h"
#include "sdl-opengl.h"
#include "../common/vidblit.h"
#ifndef APIENTRY
#define APIENTRY
#endif
static GLuint textures[2]={0,0}; // Normal image, scanline overlay.
static int left,right,top,bottom; // right and bottom are not inclusive.
static int scanlines;
static void *HiBuffer;
void APIENTRY (*p_glBindTexture)(GLenum target,GLuint texture);
void APIENTRY (*p_glColorTableEXT)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
void APIENTRY (*p_glTexImage2D)( GLenum target, GLint level,
GLint internalFormat,
GLsizei width, GLsizei height, GLint border,
GLenum format, GLenum type,
const GLvoid *pixels );
void APIENTRY (*p_glBegin)(GLenum mode);
void APIENTRY (*p_glVertex2f)(GLfloat x, GLfloat y);
void APIENTRY (*p_glTexCoord2f)(GLfloat s, GLfloat t);
void APIENTRY (*p_glEnd)(void);
void APIENTRY (*p_glEnable)(GLenum cap);
void APIENTRY (*p_glBlendFunc)(GLenum sfactor, GLenum dfactor);
const GLubyte* APIENTRY (*p_glGetString)(GLenum name);
void APIENTRY (*p_glViewport)(GLint x, GLint y,GLsizei width, GLsizei height);
void APIENTRY (*p_glGenTextures)(GLsizei n, GLuint *textures);
void APIENTRY (*p_glDeleteTextures)(GLsizei n,const GLuint *textures);
void APIENTRY (*p_glTexParameteri)(GLenum target, GLenum pname, GLint param);
void APIENTRY (*p_glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void APIENTRY (*p_glLoadIdentity)(void);
void APIENTRY (*p_glClear)(GLbitfield mask);
void APIENTRY (*p_glMatrixMode)(GLenum mode);
void APIENTRY (*p_glDisable)(GLenum cap);
void SetOpenGLPalette(uint8 *data)
{
if(!HiBuffer)
{
p_glBindTexture(GL_TEXTURE_2D, textures[0]);
p_glColorTableEXT(GL_TEXTURE_2D,GL_RGB,256,GL_RGBA,GL_UNSIGNED_BYTE,data);
}
else
SetPaletteBlitToHigh((uint8*)data);
}
void BlitOpenGL(uint8 *buf)
{
p_glBindTexture(GL_TEXTURE_2D, textures[0]);
if(HiBuffer)
{
static int xo=0;
xo=(xo+1)&3;
Blit8ToHigh(buf,(uint8*)HiBuffer,256,240,256*4,1,1);
if(!xo)
p_glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,256,256, 0, GL_RGBA,GL_UNSIGNED_BYTE,
HiBuffer);
}
else
{
//glPixelStorei(GL_UNPACK_ROW_LENGTH, 256);
p_glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256, 0,
GL_COLOR_INDEX,GL_UNSIGNED_BYTE,buf);
}
p_glBegin(GL_QUADS);
p_glTexCoord2f(1.0f*left/256, 1.0f*bottom/256); // Bottom left of our picture.
p_glVertex2f(-1.0f, -1.0f); // Bottom left of target.
p_glTexCoord2f(1.0f*right/256, 1.0f*bottom/256); // Bottom right of our picture.
p_glVertex2f( 1.0f, -1.0f); // Bottom right of target.
p_glTexCoord2f(1.0f*right/256, 1.0f*top/256); // Top right of our picture.
p_glVertex2f( 1.0f, 1.0f); // Top right of target.
p_glTexCoord2f(1.0f*left/256, 1.0f*top/256); // Top left of our picture.
p_glVertex2f(-1.0f, 1.0f); // Top left of target.
p_glEnd();
//glDisable(GL_BLEND);
if(scanlines)
{
p_glEnable(GL_BLEND);
p_glBindTexture(GL_TEXTURE_2D, textures[1]);
p_glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
p_glBegin(GL_QUADS);
p_glTexCoord2f(1.0f*left/256, 1.0f*bottom/256); // Bottom left of our picture.
p_glVertex2f(-1.0f, -1.0f); // Bottom left of target.
p_glTexCoord2f(1.0f*right/256, 1.0f*bottom/256); // Bottom right of our picture.
p_glVertex2f( 1.0f, -1.0f); // Bottom right of target.
p_glTexCoord2f(1.0f*right/256, 1.0f*top/256); // Top right of our picture.
p_glVertex2f( 1.0f, 1.0f); // Top right of target.
p_glTexCoord2f(1.0f*left/256, 1.0f*top/256); // Top left of our picture.
p_glVertex2f(-1.0f, 1.0f); // Top left of target.
p_glEnd();
p_glDisable(GL_BLEND);
}
SDL_GL_SwapBuffers();
}
void KillOpenGL(void)
{
if(textures[0])
p_glDeleteTextures(2, &textures[0]);
textures[0]=0;
if(HiBuffer)
{
free(HiBuffer);
HiBuffer=0;
}
}
/* Rectangle, left, right(not inclusive), top, bottom(not inclusive). */
int InitOpenGL(int l, int r, int t, int b, double xscale,double yscale, int efx, int ipolate,
int stretchx, int stretchy, SDL_Surface *screen)
{
const char *extensions;
#define LFG(x) if(!(p_##x = SDL_GL_GetProcAddress(#x))) return(0);
#define LFGN(x) p_##x = SDL_GL_GetProcAddress(#x)
LFG(glBindTexture);
LFGN(glColorTableEXT);
LFG(glTexImage2D);
LFG(glBegin);
LFG(glVertex2f);
LFG(glTexCoord2f);
LFG(glEnd);
LFG(glEnable);
LFG(glBlendFunc);
LFG(glGetString);
LFG(glViewport);
LFG(glGenTextures);
LFG(glDeleteTextures);
LFG(glTexParameteri);
LFG(glClearColor);
LFG(glLoadIdentity);
LFG(glClear);
LFG(glMatrixMode);
LFG(glDisable);
left=l;
right=r;
top=t;
bottom=b;
HiBuffer=0;
extensions=(const char*)p_glGetString(GL_EXTENSIONS);
if((efx&2) || !extensions || !p_glColorTableEXT || !strstr(extensions,"GL_EXT_paletted_texture"))
{
if(!(efx&2)) // Don't want to print out a warning message in this case...
FCEU_printf("Paletted texture extension not found. Using slower texture format...");
HiBuffer=malloc(4*256*256);
memset(HiBuffer,0x00,4*256*256);
#ifndef LSB_FIRST
InitBlitToHigh(4,0xFF000000,0xFF0000,0xFF00,efx&2,0);
#else
InitBlitToHigh(4,0xFF,0xFF00,0xFF0000,efx&2,0);
#endif
}
{
int rw=(r-l)*xscale;
int rh=(b-t)*yscale;
int sx=(screen->w-rw)/2; // Start x
int sy=(screen->h-rh)/2; // Start y
if(stretchx) { sx=0; rw=screen->w; }
if(stretchy) { sy=0; rh=screen->h; }
p_glViewport(sx, sy, rw, rh);
}
p_glGenTextures(2, &textures[0]);
scanlines=0;
if(efx&1)
{
uint8 *buf;
int x,y;
scanlines=1;
p_glBindTexture(GL_TEXTURE_2D, textures[1]);
p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,ipolate?GL_LINEAR:GL_NEAREST);
p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,ipolate?GL_LINEAR:GL_NEAREST);
buf=(uint8*)malloc(256*(256*2)*4);
for(y=0;y<(256*2);y++)
for(x=0;x<256;x++)
{
buf[y*256*4+x*4]=0;
buf[y*256*4+x*4+1]=0;
buf[y*256*4+x*4+2]=0;
buf[y*256*4+x*4+3]=(y&1)?0x00:0xFF; //?0xa0:0xFF; // <-- Pretty
//buf[y*256+x]=(y&1)?0x00:0xFF;
}
p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 256, (scanlines==2)?256*4:512, 0,
GL_RGBA,GL_UNSIGNED_BYTE,buf);
free(buf);
}
p_glBindTexture(GL_TEXTURE_2D, textures[0]);
p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,ipolate?GL_LINEAR:GL_NEAREST);
p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,ipolate?GL_LINEAR:GL_NEAREST);
p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
p_glEnable(GL_TEXTURE_2D);
p_glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Background color to black.
p_glMatrixMode(GL_MODELVIEW);
p_glClear(GL_COLOR_BUFFER_BIT);
p_glLoadIdentity();
return(1);
}

View File

@ -1,6 +0,0 @@
void SetOpenGLPalette(uint8 *data);
void BlitOpenGL(uint8 *buf);
void KillOpenGL(void);
int InitOpenGL(int l, int r, int t, int b, double xscale,double yscale, int efx, int ipolate,
int stretchx, int stretchy, SDL_Surface *screen);

View File

@ -1,373 +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 "sdl.h"
#ifdef USE_SEXYAL
#include "../sexyal/sexyal.h"
static SexyAL *Interface;
static SexyAL_device *Output;
static SexyAL_format format;
static SexyAL_buffering buffering;
uint32 GetMaxSound(void)
{
return(buffering.totalsize);
}
uint32 GetWriteSound(void)
{
return(Output->CanWrite(Output));
}
void WriteSound(int32 *Buffer, int Count)
{
//printf("%d\n",Output->CanWrite(Output));
Output->Write(Output, Buffer, Count);
}
int InitSound(FCEUGI *gi)
{
if(!_sound) return(0);
memset(&format,0,sizeof(format));
memset(&buffering,0,sizeof(buffering));
FCEUI_SetSoundVolume(soundvol);
FCEUI_SetSoundQuality(soundq);
Interface=SexyAL_Init(0);
format.sampformat=SEXYAL_FMT_PCMS32S16;
format.channels=gi->soundchan?gi->soundchan:1;
format.rate=gi->soundrate?gi->soundrate:soundrate;
buffering.fragcount=buffering.fragsize=0;
buffering.ms=soundbufsize;
FCEUI_printf("\nInitializing sound...");
if(!(Output=Interface->Open(Interface,SEXYAL_ID_UNUSED,&format,&buffering)))
{
FCEUD_PrintError("Error opening a sound device.");
Interface->Destroy(Interface);
Interface=0;
return(0);
}
if(soundq && format.rate!=48000 && format.rate!=44100 && format.rate!=96000)
{
FCEUD_PrintError("Set sound playback rate neither 44100, 48000, nor 96000, but needs to be when in high-quality sound mode.");
KillSound();
return(0);
}
if(format.rate<8192 || format.rate > 96000)
{
FCEUD_PrintError("Set rate is out of range [8192-96000]");
KillSound();
return(0);
}
FCEUI_printf("\n Bits: %u\n Rate: %u\n Channels: %u\n Byte order: CPU %s\n Buffer size: %u sample frames(%f ms)\n",(format.sampformat>>4)*8,format.rate,format.channels,format.byteorder?"Reversed":"Native",buffering.totalsize,(double)buffering.totalsize*1000/format.rate);
format.sampformat=SEXYAL_FMT_PCMS32S16;
format.channels=gi->soundchan?gi->soundchan:1;
format.byteorder=0;
//format.rate=gi->soundrate?gi->soundrate:soundrate;
Output->SetConvert(Output,&format);
FCEUI_Sound(format.rate);
return(1);
}
void SilenceSound(int n)
{
}
int KillSound(void)
{
FCEUI_Sound(0);
if(Output)
Output->Close(Output);
if(Interface)
Interface->Destroy(Interface);
Interface=0;
if(!Output) return(0);
Output=0;
return(1);
}
#elif USE_JACKACK /* Use JACK Audio Connection Kit */
#include <jack/jack.h>
#include <jack/ringbuffer.h>
static jack_port_t *output_port = NULL;
static jack_client_t *client = NULL;
static jack_ringbuffer_t *tmpbuf = NULL;
static unsigned int BufferSize;
static int process(jack_nframes_t nframes, void *arg)
{
jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer(output_port, nframes);
size_t canread;
canread = jack_ringbuffer_read_space(tmpbuf) / sizeof(jack_default_audio_sample_t);
if(canread > nframes)
canread = nframes;
jack_ringbuffer_read(tmpbuf, out,canread * sizeof(jack_default_audio_sample_t));
nframes -= canread;
if(nframes) /* Buffer underflow. Hmm. */
{
}
}
uint32 GetMaxSound(void)
{
return(BufferSize);
}
uint32 GetWriteSound(void)
{
return(jack_readbuffer_write_space / sizeof(jack_default_audio_sample_t));
}
static void DeadSound(void *arg)
{
puts("AGH! Sound server hates us! Let's go on a rampage.");
}
int InitSound(FCEUGI *gi)
{
const char **ports;
client = jack_client_new("FCE Ultra");
jack_set_process_callback(client, process, 0);
jack_on_shutdown(client, DeadSound, 0);
printf("%ld\n",jack_get_sample_rate(client));
output_port = jack_port_register(client, "output", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
BufferSize = soundbufsize * soundrate / 1000;
tmpbuf = jack_ringbuffer_create(BufferSize * sizeof(jack_default_audio_sample_t));
jack_activate(client);
ports = jack_get_ports(client, NULL, NULL, JackPortIsPhysical | JackPortIsInput);
jack_connect(client, jack_port_name(output_port), ports[0]);
free(ports);
}
void WriteSound(int32 *buf, int Count)
{
jack_default_audio_sample_t jbuf[Count];
int x;
for(x=0;x<Count;x++,buf++)
jbuf[x] = *buf;
jack_ringbuffer_write(tmpbuf, jbuf, sizeof(jack_default_audio_sample_t) * Count);
}
void SilenceSound(int n)
{
}
int KillSound(void)
{
if(tmpbuf)
{
jack_ringbuffer_free(tmpbuf);
tmpbuf = NULL;
}
if(client)
{
jack_client_close(client);
client = NULL;
}
return(1);
}
#else /* So we'll use SDL's evil sound support. Ok. */
static volatile int *Buffer = 0;
static unsigned int BufferSize;
static unsigned int BufferRead;
static unsigned int BufferWrite;
static volatile unsigned int BufferIn;
static void fillaudio(void *udata, uint8 *stream, int len)
{
int16 *tmps = (int16*)stream;
len >>= 1;
while(len)
{
int16 sample = 0;
if(BufferIn)
{
sample = Buffer[BufferRead];
BufferRead = (BufferRead + 1) % BufferSize;
BufferIn--;
}
else sample = 0;
*tmps = sample;
tmps++;
len--;
}
}
int InitSound(FCEUGI *gi)
{
SDL_AudioSpec spec;
if(!_sound) return(0);
memset(&spec,0,sizeof(spec));
if(SDL_InitSubSystem(SDL_INIT_AUDIO)<0)
{
puts(SDL_GetError());
KillSound();
return(0);
}
spec.freq = soundrate;
spec.format = AUDIO_S16SYS;
spec.channels = 1;
spec.samples = 256;
spec.callback = fillaudio;
spec.userdata = 0;
BufferSize = soundbufsize * soundrate / 1000;
BufferSize -= spec.samples * 2; /* SDL uses at least double-buffering, so
multiply by 2. */
if(BufferSize < spec.samples) BufferSize = spec.samples;
Buffer = malloc(sizeof(int) * BufferSize);
BufferRead = BufferWrite = BufferIn = 0;
//printf("SDL Size: %d, Internal size: %d\n",spec.samples,BufferSize);
if(SDL_OpenAudio(&spec,0)<0)
{
puts(SDL_GetError());
KillSound();
return(0);
}
SDL_PauseAudio(0);
FCEUI_Sound(soundrate);
return(1);
}
uint32 GetMaxSound(void)
{
return(BufferSize);
}
uint32 GetWriteSound(void)
{
return(BufferSize - BufferIn);
}
void WriteSound(int32 *buf, int Count)
{
while(Count)
{
while(BufferIn == BufferSize) SDL_Delay(1);
Buffer[BufferWrite] = *buf;
Count--;
BufferWrite = (BufferWrite + 1) % BufferSize;
BufferIn++;
buf++;
}
}
void SilenceSound(int n)
{
SDL_PauseAudio(n);
}
int KillSound(void)
{
FCEUI_Sound(0);
SDL_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
if(Buffer)
{
free(Buffer);
Buffer = 0;
}
return(0);
}
#endif
static int mute=0;
static int soundvolume=100;
void FCEUD_SoundVolumeAdjust(int n)
{
switch(n)
{
case -1: soundvolume-=10; if(soundvolume<0) soundvolume=0; break;
case 0: soundvolume=100; break;
case 1: soundvolume+=10; if(soundvolume>150) soundvolume=150; break;
}
mute=0;
FCEUI_SetSoundVolume(soundvolume);
FCEU_DispMessage("Sound volume %d.", soundvolume);
}
void FCEUD_SoundToggle(void)
{
if(mute)
{
mute=0;
FCEUI_SetSoundVolume(soundvolume);
FCEU_DispMessage("Sound mute off.");
}
else
{
mute=1;
FCEUI_SetSoundVolume(0);
FCEU_DispMessage("Sound mute on.");
}
}

View File

@ -1,86 +0,0 @@
#include "sdl.h"
#include "throttle.h"
static uint64 tfreq;
static uint64 desiredfps;
static int32 fps_scale_table[]=
{ 3, 3, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 2048 };
int32 fps_scale = 256;
#define fps_table_size (sizeof(fps_scale_table)/sizeof(fps_scale_table[0]))
void RefreshThrottleFPS(void)
{
desiredfps=FCEUI_GetDesiredFPS()>>8;
desiredfps=(desiredfps*fps_scale)>>8;
tfreq=10000000;
tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */
}
void SpeedThrottle(void)
{
static uint64 ttime,ltime=0;
waiter:
ttime=SDL_GetTicks();
ttime*=10000;
if( (ttime-ltime) < (tfreq/desiredfps) )
{
int64 delay;
delay=(tfreq/desiredfps)-(ttime-ltime);
if(delay>0)
SDL_Delay(delay/10000);
//printf("%d\n",(tfreq/desiredfps)-(ttime-ltime));
//SDL_Delay((tfreq/desiredfps)-(ttime-ltime));
goto waiter;
}
if( (ttime-ltime) >= (tfreq*4/desiredfps))
ltime=ttime;
else
ltime+=tfreq/desiredfps;
}
void IncreaseEmulationSpeed(void)
{
int i;
for(i=1; fps_scale_table[i]<fps_scale; i++)
;
fps_scale = fps_scale_table[i+1];
RefreshThrottleFPS();
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
}
void DecreaseEmulationSpeed(void)
{
int i;
for(i=1; fps_scale_table[i]<fps_scale; i++)
;
fps_scale = fps_scale_table[i-1];
RefreshThrottleFPS();
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
}
void FCEUD_SetEmulationSpeed(int cmd)
{
switch(cmd)
{
case EMUSPEED_SLOWEST: fps_scale=fps_scale_table[0]; break;
case EMUSPEED_SLOWER: DecreaseEmulationSpeed(); break;
case EMUSPEED_NORMAL: fps_scale=256; break;
case EMUSPEED_FASTER: IncreaseEmulationSpeed(); break;
case EMUSPEED_FASTEST: fps_scale=fps_scale_table[fps_table_size-1]; break;
default:
return;
}
RefreshThrottleFPS();
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
}

View File

@ -1,432 +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 "sdl.h"
#include "sdl-opengl.h"
#include "../common/vidblit.h"
#include "sdl-icon.h"
#include "dface.h"
SDL_Surface *screen;
SDL_Surface *BlitBuf; // Used as a buffer when using hardware-accelerated blits.
SDL_Surface *IconSurface=NULL;
static int curbpp;
static int srendline,erendline;
static int tlines;
static int inited=0;
#ifdef OPENGL
extern int sdlhaveogl;
static int usingogl;
static double exs,eys;
#else
static int exs,eys;
#endif
static int eefx;
#define NWIDTH (256-((eoptions&EO_CLIPSIDES)?16:0))
#define NOFFSET (eoptions&EO_CLIPSIDES?8:0)
static int paletterefresh;
/* Return 1 if video was killed, 0 otherwise(video wasn't initialized). */
int KillVideo(void)
{
if(IconSurface)
{
SDL_FreeSurface(IconSurface);
IconSurface=0;
}
if(inited&1)
{
#ifdef OPENGL
if(usingogl)
KillOpenGL();
else
#endif
if(curbpp>8)
KillBlitToHigh();
SDL_QuitSubSystem(SDL_INIT_VIDEO);
inited&=~1;
return(1);
}
inited=0;
return(0);
}
static int sponge;
int InitVideo(FCEUGI *gi)
{
const SDL_VideoInfo *vinf;
int flags=0;
FCEUI_printf("Initializing video...");
FCEUI_GetCurrentVidSystem(&srendline,&erendline);
if(_fullscreen) sponge=Settings.specialfs;
else sponge=Settings.special;
#ifdef OPENGL
usingogl=0;
if(_opengl && sdlhaveogl && !sponge)
{
flags=SDL_OPENGL;
usingogl=1;
}
#endif
#ifdef EXTGUI
GUI_SetVideo(_fullscreen, 0, 0);
#endif
if(!(SDL_WasInit(SDL_INIT_VIDEO)&SDL_INIT_VIDEO))
if(SDL_InitSubSystem(SDL_INIT_VIDEO)==-1)
{
FCEUD_PrintError(SDL_GetError());
return(0);
}
inited|=1;
SDL_ShowCursor(0);
tlines=erendline-srendline+1;
vinf=SDL_GetVideoInfo();
if(vinf->hw_available)
flags|=SDL_HWSURFACE;
if(_fullscreen)
flags|=SDL_FULLSCREEN;
flags|=SDL_HWPALETTE;
//flags|=SDL_DOUBLEBUF;
#ifdef OPENGL
if(usingogl)
{
FCEU_printf("\n Initializing with OpenGL(Use \"-opengl 0\" to disable).\n");
if(_doublebuf)
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
}
else
#endif
if(_doublebuf && (flags&SDL_HWSURFACE))
flags|=SDL_DOUBLEBUF;
if(_fullscreen)
{
int desbpp=_bpp;
exs=_xscalefs;
eys=_yscalefs;
eefx=_efxfs;
#ifdef OPENGL
if(!usingogl) {exs=(int)exs;eys=(int)eys;}
else desbpp=0;
if(sponge)
{
exs=eys=2;
if(sponge == 3 || sponge == 4) exs = eys = 3;
eefx=0;
if(sponge == 1 || sponge == 3) desbpp = 32;
}
if( (usingogl && !_stretchx) || !usingogl)
#endif
if(_xres<NWIDTH*exs || exs <= 0.01)
{
FCEUD_PrintError("xscale out of bounds.");
KillVideo();
return(0);
}
#ifdef OPENGL
if( (usingogl && !_stretchy) || !usingogl)
#endif
if(_yres<tlines*eys || eys <= 0.01)
{
FCEUD_PrintError("yscale out of bounds.");
KillVideo();
return(0);
}
#ifdef EXTGUI
GUI_SetVideo(_fullscreen, _xres, _yres);
#endif
#ifdef OPENGL
if(!(screen = SDL_SetVideoMode(_xres, _yres, desbpp, flags)))
#else
if(!(screen = SDL_SetVideoMode(_xres, _yres, desbpp, flags)))
#endif
{
FCEUD_PrintError(SDL_GetError());
return(0);
}
}
else
{
int desbpp=0;
exs=_xscale;
eys=_yscale;
eefx=_efx;
if(sponge)
{
exs=eys=2;
if(sponge >= 3) exs=eys=3;
eefx=0;
// SDL's 32bpp->16bpp code is slighty faster than mine, at least :/
if(sponge == 1 || sponge == 3) desbpp=32;
}
#ifdef OPENGL
if(!usingogl) {exs=(int)exs;eys=(int)eys;}
if(exs <= 0.01)
{
FCEUD_PrintError("xscale out of bounds.");
KillVideo();
return(0);
}
if(eys <= 0.01)
{
FCEUD_PrintError("yscale out of bounds.");
KillVideo();
return(0);
}
#endif
#ifdef EXTGUI
GUI_SetVideo(_fullscreen, (NWIDTH*exs), tlines*eys);
#endif
screen = SDL_SetVideoMode((NWIDTH*exs), tlines*eys, desbpp, flags);
}
curbpp=screen->format->BitsPerPixel;
if(!screen)
{
FCEUD_PrintError(SDL_GetError());
KillVideo();
return(0);
}
//BlitBuf=SDL_CreateRGBSurface(SDL_HWSURFACE,256,240,screen->format->BitsPerPixel,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,0);
inited=1;
FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n",screen->w,screen->h,screen->format->BitsPerPixel,_fullscreen?"full screen":"");
if(curbpp!=16 && curbpp!=24 && curbpp!=8 && curbpp!=32)
{
FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n",curbpp);
KillVideo();
return(0);
}
if(gi->name)
SDL_WM_SetCaption(gi->name,gi->name);
else
SDL_WM_SetCaption("FCE Ultra","FCE Ultra");
#ifdef LSB_FIRST
IconSurface=SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,32,32,24,32*3,0xFF,0xFF00,0xFF0000,0x00);
#else
IconSurface=SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,32,32,24,32*3,0xFF0000,0xFF00,0xFF,0x00);
#endif
SDL_WM_SetIcon(IconSurface,0);
paletterefresh=1;
if(curbpp>8)
#ifdef OPENGL
if(!usingogl)
#endif
InitBlitToHigh(curbpp>>3,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,eefx,sponge);
#ifdef OPENGL
if(usingogl)
if(!InitOpenGL((eoptions&EO_CLIPSIDES)?8:0,256-((eoptions&EO_CLIPSIDES)?8:0),srendline,erendline+1,exs,eys,eefx,_openglip,_stretchx,_stretchy,screen))
{
FCEUD_PrintError("Error initializing OpenGL.");
KillVideo();
return(0);
}
#endif
return 1;
}
void ToggleFS(void)
{
extern FCEUGI *CurGame;
KillVideo();
_fullscreen=!_fullscreen;
if(!InitVideo(CurGame))
{
_fullscreen=!_fullscreen;
InitVideo(CurGame);
}
}
static SDL_Color psdl[256];
void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
{
psdl[index].r=r;
psdl[index].g=g;
psdl[index].b=b;
paletterefresh=1;
}
void FCEUD_GetPalette(uint8 index, uint8 *r, uint8 *g, uint8 *b)
{
*r=psdl[index].r;
*g=psdl[index].g;
*b=psdl[index].b;
}
static void RedoPalette(void)
{
#ifdef OPENGL
if(usingogl)
SetOpenGLPalette((uint8*)psdl);
else
#endif
{
if(curbpp>8)
SetPaletteBlitToHigh((uint8*)psdl);
else
{
SDL_SetPalette(screen,SDL_PHYSPAL,psdl,0,256);
}
}
}
void LockConsole(){}
void UnlockConsole(){}
void BlitScreen(uint8 *XBuf)
{
SDL_Surface *TmpScreen;
uint8 *dest;
int xo=0,yo=0;
if(!screen) return;
if(paletterefresh)
{
RedoPalette();
paletterefresh=0;
}
#ifdef OPENGL
if(usingogl)
{
BlitOpenGL(XBuf);
return;
}
#endif
XBuf+=srendline*256;
if(BlitBuf) TmpScreen=BlitBuf;
else TmpScreen=screen;
if(SDL_MUSTLOCK(TmpScreen))
if(SDL_LockSurface(TmpScreen))
{
return;
}
dest=(uint8*)TmpScreen->pixels;
if(_fullscreen)
{
xo=(((TmpScreen->w-NWIDTH*exs))/2);
dest+=xo*(curbpp>>3);
if(TmpScreen->h>(tlines*eys))
{
yo=((TmpScreen->h-tlines*eys)/2);
dest+=yo*TmpScreen->pitch;
}
}
if(curbpp>8)
{
if(BlitBuf)
Blit8ToHigh(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,1,1);
else
Blit8ToHigh(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,exs,eys);
}
else
{
if(BlitBuf)
Blit8To8(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,1,1,0,sponge);
else
Blit8To8(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,exs,eys,eefx,sponge);
}
if(SDL_MUSTLOCK(TmpScreen))
SDL_UnlockSurface(TmpScreen);
if(BlitBuf)
{
SDL_Rect srect;
SDL_Rect drect;
srect.x=0;
srect.y=0;
srect.w=NWIDTH;
srect.h=tlines;
drect.x=0;
drect.y=0;
drect.w=exs*NWIDTH;
drect.h=eys*tlines;
SDL_BlitSurface(BlitBuf, &srect,screen,&drect);
}
SDL_UpdateRect(screen, xo, yo, NWIDTH*exs, tlines*eys);
if(screen->flags&SDL_DOUBLEBUF)
SDL_Flip(screen);
}
uint32 PtoV(uint16 x, uint16 y)
{
y=(double)y/eys;
x=(double)x/exs;
if(eoptions&EO_CLIPSIDES)
x+=8;
y+=srendline;
return(x|(y<<16));
}

View File

@ -1 +0,0 @@
uint32 PtoV(uint16 x, uint16 y);

View File

@ -1,429 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sdl.h"
#include "sdl-video.h"
#ifdef NETWORK
#include "unix-netplay.h"
#endif
DSETTINGS Settings;
CFGSTRUCT DriverConfig[]={
#ifdef OPENGL
AC(_stretchx),
AC(_stretchy),
AC(_opengl),
AC(_openglip),
#endif
AC(Settings.special),
AC(Settings.specialfs),
AC(_doublebuf),
AC(_xscale),
AC(_yscale),
AC(_xscalefs),
AC(_yscalefs),
AC(_bpp),
AC(_efx),
AC(_efxfs),
AC(_fullscreen),
AC(_xres),
AC(_yres),
#ifdef NETWORK
ACS(netplaynick),
AC(netlocalplayers),
AC(tport),
ACS(netpassword),
ACS(netgamekey),
#endif
ENDCFGSTRUCT
};
//-fshack x Set the environment variable SDL_VIDEODRIVER to \"x\" when
// entering full screen mode and x is not \"0\".
char *DriverUsage=
"-xres x Set horizontal resolution to x for full screen mode.\n\
-yres x Set vertical resolution to x for full screen mode.\n\
-xscale(fs) x Multiply width by x(Real numbers >0 with OpenGL, otherwise integers >0).\n\
-yscale(fs) x Multiply height by x(Real numbers >0 with OpenGL, otherwise integers >0).\n\
-bpp(fs) x Bits per pixel for SDL surface(and video mode in fs). 8, 16, 32.\n\
-opengl x Enable OpenGL support if x is 1.\n\
-openglip x Enable OpenGL linear interpolation if x is 1.\n\
-doublebuf x \n\
-special(fs) x Specify special scaling filter.\n\
-stretch(x/y) x Stretch to fill surface on x or y axis(fullscreen, only with OpenGL).\n\
-efx(fs) x Enable special effects. Logically OR the following together:\n\
1 = scanlines(for yscale>=2).\n\
2 = TV blur(for bpp of 16 or 32).\n\
-fs x Select full screen mode if x is non zero.\n\
-connect s Connect to server 's' for TCP/IP network play.\n\
-netnick s Set the nickname to use in network play.\n\
-netgamekey s Use key 's' to create a unique session for the game loaded.\n\
-netpassword s Password to use for connecting to the server.\n\
-netlocalplayers x Set the number of local players.\n\
-netport x Use TCP/IP port x for network play.";
ARGPSTRUCT DriverArgs[]={
#ifdef OPENGL
{"-opengl",0,&_opengl,0},
{"-openglip",0,&_openglip,0},
{"-stretchx",0,&_stretchx,0},
{"-stretchy",0,&_stretchy,0},
#endif
{"-special",0,&Settings.special,0},
{"-specialfs",0,&Settings.specialfs,0},
{"-doublebuf",0,&_doublebuf,0},
{"-bpp",0,&_bpp,0},
{"-xscale",0,&_xscale,2},
{"-yscale",0,&_yscale,2},
{"-efx",0,&_efx,0},
{"-xscalefs",0,&_xscalefs,2},
{"-yscalefs",0,&_yscalefs,2},
{"-efxfs",0,&_efxfs,0},
{"-xres",0,&_xres,0},
{"-yres",0,&_yres,0},
{"-fs",0,&_fullscreen,0},
//{"-fshack",0,&_fshack,0x4001},
#ifdef NETWORK
{"-connect",0,&netplayhost,0x4001},
{"-netport",0,&tport,0},
{"-netlocalplayers",0,&netlocalplayers,0},
{"-netnick",0,&netplaynick,0x4001},
{"-netpassword",0,&netpassword,0x4001},
#endif
{0,0,0,0}
};
static void SetDefaults(void)
{
Settings.special=Settings.specialfs=0;
_bpp=8;
_xres=640;
_yres=480;
_fullscreen=0;
_xscale=2.50;
_yscale=2;
_xscalefs=_yscalefs=2;
_efx=_efxfs=0;
//_fshack=_fshacksave=0;
#ifdef OPENGL
_opengl=1;
_stretchx=1;
_stretchy=0;
_openglip=1;
#endif
}
void DoDriverArgs(void)
{
#ifdef BROKEN
if(_fshack)
{
if(_fshack[0]=='0')
if(_fshack[1]==0)
{
free(_fshack);
_fshack=0;
}
}
#endif
}
int InitMouse(void)
{
return(0);
}
void KillMouse(void){}
void GetMouseData(uint32 *d)
{
if(FCEUI_IsMovieActive()<0)
return;
int x,y;
uint32 t;
t=SDL_GetMouseState(&x,&y);
#ifdef EXTGUI
GUI_GetMouseState(&t,&x,&y);
#endif
d[2]=0;
if(t&SDL_BUTTON(1))
d[2]|=1;
if(t&SDL_BUTTON(3))
d[2]|=2;
t=PtoV(x,y);
d[0]=t&0xFFFF;
d[1]=(t>>16)&0xFFFF;
}
int InitKeyboard(void)
{
return(1);
}
int UpdateKeyboard(void)
{
return(1);
}
void KillKeyboard(void)
{
}
void UpdatePhysicalInput(void)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
//case SDL_SYSWMEVENT: puts("Nifty keen");break;
//case SDL_VIDEORESIZE: puts("Okie dokie");break;
case SDL_QUIT: CloseGame();puts("Quit");break;
}
//printf("Event: %d\n",event.type);
//fflush(stdout);
}
//SDL_PumpEvents();
}
static uint8 *KeyState=NULL;
char *GetKeyboard(void)
{
KeyState=SDL_GetKeyState(0);
#ifdef EXTGUI
{ char *tmp=GUI_GetKeyboard(); if(tmp) KeyState=tmp; }
#endif
return((char *)KeyState);
}
#ifdef WIN32
#include <windows.h>
/* Stupid SDL */
#ifdef main
#undef main
#endif
#endif
#ifndef EXTGUI
uint8 *GetBaseDirectory(void)
{
uint8 *ol;
uint8 *ret;
ol=getenv("HOME");
if(ol)
{
ret=malloc(strlen(ol)+1+strlen("./fceultra"));
strcpy(ret,ol);
strcat(ret,"/.fceultra");
}
else
{
#ifdef WIN32
char *sa;
ret=malloc(MAX_PATH+1);
GetModuleFileName(NULL,ret,MAX_PATH+1);
sa=strrchr(ret,'\\');
if(sa)
*sa = 0;
#else
ret=malloc(1);
ret[0]=0;
#endif
printf("%s\n",ret);
}
return(ret);
}
#endif
#ifdef OPENGL
int sdlhaveogl;
#endif
int DTestButton(ButtConfig *bc)
{
int x;
for(x=0;x<bc->NumC;x++)
{
if(bc->ButtType[x]==BUTTC_KEYBOARD)
{
if(KeyState[bc->ButtonNum[x]])
return(1);
}
else if(bc->ButtType[x]==BUTTC_JOYSTICK)
{
if(DTestButtonJoy(bc))
return(1);
}
}
return(0);
}
static int bcpv,bcpj;
int ButtonConfigBegin(void)
{
SDL_Surface *screen;
SDL_QuitSubSystem(SDL_INIT_VIDEO);
bcpv=KillVideo();
bcpj=KillJoysticks();
if(!(SDL_WasInit(SDL_INIT_VIDEO)&SDL_INIT_VIDEO))
if(SDL_InitSubSystem(SDL_INIT_VIDEO)==-1)
{
FCEUD_Message(SDL_GetError());
return(0);
}
screen = SDL_SetVideoMode(300, 1, 8, 0);
SDL_WM_SetCaption("Button Config",0);
InitJoysticks();
return(1);
}
void ButtonConfigEnd(void)
{
extern FCEUGI *CurGame;
KillJoysticks();
SDL_QuitSubSystem(SDL_INIT_VIDEO);
if(bcpv) InitVideo(CurGame);
if(bcpj) InitJoysticks();
}
int DWaitButton(const uint8 *text, ButtConfig *bc, int wb)
{
SDL_Event event;
static int32 LastAx[64][64];
int x,y;
SDL_WM_SetCaption(text,0);
#ifndef EXTGUI
puts(text);
#endif
for(x=0;x<64;x++)
for(y=0;y<64;y++)
LastAx[x][y]=0x100000;
while(SDL_WaitEvent(&event))
{
switch(event.type)
{
case SDL_KEYDOWN:bc->ButtType[wb]=BUTTC_KEYBOARD;
bc->DeviceNum[wb]=0;
bc->ButtonNum[wb]=event.key.keysym.sym;
return(1);
case SDL_JOYBUTTONDOWN:bc->ButtType[wb]=BUTTC_JOYSTICK;
bc->DeviceNum[wb]=event.jbutton.which;
bc->ButtonNum[wb]=event.jbutton.button;
return(1);
case SDL_JOYHATMOTION:if(event.jhat.value != SDL_HAT_CENTERED)
{
bc->ButtType[wb]=BUTTC_JOYSTICK;
bc->DeviceNum[wb]=event.jhat.which;
bc->ButtonNum[wb]=0x2000|((event.jhat.hat&0x1F)<<8)|event.jhat.value;
return(1);
}
break;
case SDL_JOYAXISMOTION:
if(LastAx[event.jaxis.which][event.jaxis.axis]==0x100000)
{
if(abs(event.jaxis.value)<1000)
LastAx[event.jaxis.which][event.jaxis.axis]=event.jaxis.value;
}
else
{
if(abs(LastAx[event.jaxis.which][event.jaxis.axis]-event.jaxis.value)>=8192)
{
bc->ButtType[wb]=BUTTC_JOYSTICK;
bc->DeviceNum[wb]=event.jaxis.which;
bc->ButtonNum[wb]=0x8000|(event.jaxis.axis)|((event.jaxis.value<0)?0x4000:0);
return(1);
}
}
break;
}
}
return(0);
}
#ifdef EXTGUI
int FCEUSDLmain(int argc, char *argv[])
#else
int main(int argc, char *argv[])
#endif
{
FCEUD_Message("\nStarting FCE Ultra "FCEU_VERSION"...\n");
#ifdef WIN32
/* Taken from win32 sdl_main.c */
SDL_SetModuleHandle(GetModuleHandle(NULL));
#endif
if(SDL_Init(SDL_INIT_VIDEO)) /* SDL_INIT_VIDEO Needed for (joystick config) event processing? */
{
printf("Could not initialize SDL: %s.\n", SDL_GetError());
return(-1);
}
#ifdef OPENGL
#ifdef APPLEOPENGL
sdlhaveogl = 1; /* Stupid something... Hack. */
#else
if(!SDL_GL_LoadLibrary(0)) sdlhaveogl=1;
else sdlhaveogl=0;
#endif
#endif
SetDefaults();
{
int ret=CLImain(argc,argv);
SDL_Quit();
return(ret?0:-1);
}
}
uint64 FCEUD_GetTime(void)
{
return(SDL_GetTicks());
}
uint64 FCEUD_GetTimeFreq(void)
{
return(1000);
}
// dummy functions
#define DUMMY(f) void f(void) {FCEU_DispMessage("Not implemented.");}
DUMMY(FCEUD_HideMenuToggle)
DUMMY(FCEUD_TurboOn)
DUMMY(FCEUD_TurboOff)
DUMMY(FCEUD_SaveStateAs)
DUMMY(FCEUD_LoadStateFrom)
DUMMY(FCEUD_MovieRecordTo)
DUMMY(FCEUD_MovieReplayFrom)
DUMMY(FCEUD_ToggleStatusIcon)
DUMMY(FCEUD_AviRecordTo)
DUMMY(FCEUD_AviStop)
void FCEUI_AviVideoUpdate(const unsigned char* buffer) {FCEU_DispMessage("Not implemented.");}
int FCEUD_ShowStatusIcon(void) {FCEU_DispMessage("Not implemented."); return 0; }
int FCEUI_AviIsRecording(void) {return 0;}

View File

@ -1,50 +0,0 @@
#include <SDL.h>
#include "main.h"
#include "dface.h"
#include "input.h"
int DTestButtonJoy(ButtConfig *bc);
typedef struct {
int xres;
int yres;
double xscale,yscale;
double xscalefs,yscalefs;
int efx,efxfs;
int bpp;
int fullscreen;
int doublebuf;
char *fshack;
char *fshacksave;
#ifdef OPENGL
int opengl;
int openglip;
int stretchx,stretchy;
#endif
int special,specialfs;
} DSETTINGS;
extern DSETTINGS Settings;
#define _doublebuf Settings.doublebuf
#define _bpp Settings.bpp
#define _xres Settings.xres
#define _yres Settings.yres
#define _fullscreen Settings.fullscreen
#define _xscale Settings.xscale
#define _yscale Settings.yscale
#define _xscalefs Settings.xscalefs
#define _yscalefs Settings.yscalefs
#define _efx Settings.efx
#define _efxfs Settings.efxfs
#define _ebufsize Settings.ebufsize
#define _fshack Settings.fshack
#define _fshacksave Settings.fshacksave
#ifdef OPENGL
#define _opengl Settings.opengl
#define _openglip Settings.openglip
#define _stretchx Settings.stretchx
#define _stretchy Settings.stretchy
#endif

View File

@ -1,41 +0,0 @@
#include <sys/time.h>
#include "main.h"
#include "throttle.h"
static uint64 tfreq;
static uint64 desiredfps;
void RefreshThrottleFPS(void)
{
desiredfps=FCEUI_GetDesiredFPS()>>8;
tfreq=1000000;
tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */
}
static uint64 GetCurTime(void)
{
uint64 ret;
struct timeval tv;
gettimeofday(&tv,0);
ret=(uint64)tv.tv_sec*1000000;
ret+=tv.tv_usec;
return(ret);
}
void SpeedThrottle(void)
{
static uint64 ttime,ltime=0;
waiter:
ttime=GetCurTime();
if( (ttime-ltime) < (tfreq/desiredfps) )
goto waiter;
if( (ttime-ltime) >= (tfreq*4/desiredfps))
ltime=ttime;
else
ltime+=tfreq/desiredfps;
}

View File

@ -1,2 +0,0 @@
void RefreshThrottleFPS(void);
void SpeedThrottle(void);

View File

@ -1,292 +0,0 @@
#ifdef NETWORK
/* 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 <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <unistd.h>
#include <netdb.h>
#include <errno.h>
#include <fcntl.h>
#include "main.h"
#include "dface.h"
#include "unix-netplay.h"
#include "../../md5.h"
#ifndef socklen_t
#define socklen_t int
#endif
#ifndef SOL_TCP
#define SOL_TCP IPPROTO_TCP
#endif
char *netplayhost=0;
char *netplaynick=0;
char *netgamekey = 0;
char *netpassword = 0;
int netlocalplayers = 1;
int Port=0xFCE;
int FCEUDnetplay=0;
int tport=0xFCE;
static int Socket=-1;
static void en32(uint8 *buf, uint32 morp)
{
buf[0]=morp;
buf[1]=morp>>8;
buf[2]=morp>>16;
buf[3]=morp>>24;
}
/*
static uint32 de32(uint8 *morp)
{
return(morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24));
}
*/
int FCEUD_NetworkConnect(void)
{
struct sockaddr_in sockin; /* I want to play with fighting robots. */
struct hostent *phostentb;
unsigned long hadr;
int TSocket;
int netdivisor;
if(!netplayhost) return(0);
if( (TSocket=socket(AF_INET,SOCK_STREAM,0))==-1)
{
puts("Error creating stream socket.");
FCEUD_NetworkClose();
return(0);
}
{
int tcpopt = 1;
#ifdef BEOS
if(setsockopt(TSocket, SOL_SOCKET, TCP_NODELAY, &tcpopt, sizeof(int)))
#else
if(setsockopt(TSocket, SOL_TCP, TCP_NODELAY, &tcpopt, sizeof(int)))
#endif
puts("Nodelay fail");
}
memset(&sockin,0,sizeof(sockin));
sockin.sin_family=AF_INET;
hadr=inet_addr(netplayhost);
if(hadr!=INADDR_NONE)
sockin.sin_addr.s_addr=hadr;
else
{
puts("*** Looking up host name...");
if(!(phostentb=gethostbyname((const char *)netplayhost)))
{
puts("Error getting host network information.");
close(TSocket);
FCEUD_NetworkClose();
return(0);
}
memcpy(&sockin.sin_addr,phostentb->h_addr,phostentb->h_length);
}
sockin.sin_port=htons(tport);
puts("*** Connecting to remote host...");
if(connect(TSocket,(struct sockaddr *)&sockin,sizeof(sockin))==-1)
{
puts("Error connecting to remote host.");
close(TSocket);
FCEUD_NetworkClose();
return(0);
}
Socket=TSocket;
puts("*** Sending initialization data to server...");
{
uint8 *sendbuf;
uint8 buf[5];
uint32 sblen;
sblen = 4 + 16 + 16 + 64 + 1 + (netplaynick?strlen(netplaynick):0);
sendbuf = malloc(sblen);
memset(sendbuf, 0, sblen);
en32(sendbuf, sblen - 4);
if(netgamekey)
{
struct md5_context md5;
uint8 md5out[16];
md5_starts(&md5);
md5_update(&md5, CurGame->MD5, 16);
md5_update(&md5, netgamekey, strlen(netgamekey));
md5_finish(&md5, md5out);
memcpy(sendbuf + 4, md5out, 16);
}
else
memcpy(sendbuf + 4, CurGame->MD5, 16);
if(netpassword)
{
struct md5_context md5;
uint8 md5out[16];
md5_starts(&md5);
md5_update(&md5, netpassword, strlen(netpassword));
md5_finish(&md5, md5out);
memcpy(sendbuf + 4 + 16, md5out, 16);
}
memset(sendbuf + 4 + 16 + 16, 0, 64);
sendbuf[4 + 16 + 16 + 64] = netlocalplayers;
if(netplaynick)
memcpy(sendbuf + 4 + 16 + 16 + 64 + 1,netplaynick,strlen(netplaynick));
send(Socket, sendbuf, sblen, 0);
free(sendbuf);
recv(Socket, buf, 1, MSG_WAITALL);
netdivisor = buf[0];
}
puts("*** Connection established.");
FCEUDnetplay = 1;
FCEUI_NetplayStart(netlocalplayers, netdivisor);
return(1);
}
int FCEUD_SendData(void *data, uint32 len)
{
int check;
if(!ioctl(fileno(stdin),FIONREAD,&check))
if(check)
{
char buf[1024];
char *f;
fgets(buf,1024,stdin);
if((f=strrchr(buf,'\n')))
*f=0;
FCEUI_NetplayText(buf);
}
send(Socket, data, len ,0);
return(1);
}
int FCEUD_RecvData(void *data, uint32 len)
{
NoWaiting&=~2;
for(;;)
{
fd_set funfun;
struct timeval popeye;
popeye.tv_sec=0;
popeye.tv_usec=100000;
FD_ZERO(&funfun);
FD_SET(Socket,&funfun);
switch(select(Socket + 1,&funfun,0,0,&popeye))
{
case 0: continue;
case -1:return(0);
}
if(FD_ISSET(Socket,&funfun))
{
if(recv(Socket,data,len,MSG_WAITALL) == len)
{
//unsigned long beefie;
FD_ZERO(&funfun);
FD_SET(Socket, &funfun);
popeye.tv_sec = popeye.tv_usec = 0;
if(select(Socket + 1, &funfun, 0, 0, &popeye) == 1)
//if(!ioctl(Socket,FIONREAD,&beefie))
// if(beefie)
{
NoWaiting|=2;
//puts("Yaya");
}
return(1);
}
else
return(0);
}
}
return 0;
}
void FCEUD_NetworkClose(void)
{
if(Socket>0)
{
#ifdef BEOS
closesocket(Socket);
#else
close(Socket);
#endif
}
Socket=-1;
if(FCEUDnetplay)
FCEUI_NetplayStop();
FCEUDnetplay = 0;
}
void FCEUD_NetplayText(uint8 *text)
{
char *tot = malloc(strlen(text) + 1);
char *tmp;
strcpy(tot, text);
tmp = tot;
while(*tmp)
{
if(*tmp < 0x20) *tmp = ' ';
tmp++;
}
puts(tot);
free(tot);
}
#endif

View File

@ -1,9 +0,0 @@
#ifdef NETWORK
extern char *netplaynick;
extern char *netplayhost;
extern char *netpassword;
extern char *netgamekey;
extern int tport;
extern int netlocalplayers;
#endif

View File

@ -1,60 +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
*/
void ShowUsage(char *prog)
{
printf("\nUsage is as follows:\n%s <options> filename\n\n",prog);
puts("Options:");
puts(DriverUsage);
puts("-cpalette x Load a custom global palette from file x.\n\
-ntsccol x Emulate an NTSC's TV's colors.\n\
0 = Disabled.\n\
1 = Enabled.\n\
-pal x Emulate a PAL NES if x is 1.\n\
-sound x Sound.\n\
0 = Disabled.\n\
Otherwise, x = playback rate.\n\
-soundvol x Sound volume. x is an integral percentage value.\n\
-soundq x Sets sound quality.\n\
0 = Low quality.\n\
1 = High quality.\n\
-inputx str Select device mapped to virtual input port x(1-2).\n\
str may be: none, gamepad, zapper, powerpada, powerpadb,\n\
arkanoid\n\
-fcexp str Select Famicom expansion port device.\n\
str may be: none, shadow, arkanoid, 4player, fkb\n\
-inputcfg s Configure virtual input device \"s\".\n\
-nofs x Disables Four-Score emulation if x is 1.\n\
-gg x Enable Game Genie emulation if x is 1.\n\
-no8lim x Disables the 8 sprites per scanline limitation.\n\
0 = Limitation enabled.\n\
1 = Limitation disabled.\n\
-snapname x Selects what type of file name snapshots will have.\n\
0 = Numeric(0.png)\n\
1 = File base and numeric(mario-0.png)\n\
-nothrottle x Disable artificial speed throttling if x is non-zero.\n\
-clipsides x Clip leftmost and rightmost 8 columns of pixels of video output.\n\
0 = No clipping.\n\
1 = Clipping.\n\
-slstart x Set the first drawn emulated scanline. Valid values for x are\n\
0 through 239.\n\
-slend x Set the last drawn emulated scanline. Valid values for x are\n\
0 through 239.");
}

View File

@ -1,168 +0,0 @@
/* This file is "#include"d from dos-video.c and svga-video.c */
typedef struct {
uint8 p;
uint8 i;
uint8 v;
} vgareg;
vgareg v256x224_103[25] =
{
{ 0xc2, 0x0, 0xe7},
{ 0xd4, 0x0, 0x45},
{ 0xd4, 0x1, 0x3f},
{ 0xd4, 0x2, 0x40},
{ 0xd4, 0x3, 0x86},
{ 0xd4, 0x4, 0x3f},
{ 0xd4, 0x5, 0x10},
{ 0xd4, 0x6, 0xcd},
{ 0xd4, 0x7, 0x1f},
{ 0xd4, 0x8, 0x0},
{ 0xd4, 0x9, 0x41},
{ 0xd4, 0x10, 0xc0},
{ 0xd4, 0x11, 0xac},
{ 0xd4, 0x12, 0xbf},
{ 0xd4, 0x13, 0x20},
{ 0xd4, 0x14, 0x40}, //
{ 0xd4, 0x15, 0xe7},
{ 0xd4, 0x16, 0x06}, //
{ 0xd4, 0x17, 0xa3},
{ 0xc4, 0x1, 0x1},
{ 0xc4, 0x4, 0xe}, //
{ 0xce, 0x5, 0x40},
{ 0xce, 0x6, 0x5},
{ 0xc0, 0x10, 0x41},
{ 0xc0, 0x13, 0x0},
};
vgareg v256x240[25] =
{
{ 0xc2, 0x0, 0xe3},
{ 0xd4, 0x0, 0x4f},
{ 0xd4, 0x1, 0x3f},
{ 0xd4, 0x2, 0x40},
{ 0xd4, 0x3, 0x92},
{ 0xd4, 0x4, 0x44},
{ 0xd4, 0x5, 0x10},
{ 0xd4, 0x6, 0x0a},
{ 0xd4, 0x7, 0x3e},
{ 0xd4, 0x8, 0x00},
{ 0xd4, 0x9, 0x41},
{ 0xd4, 0x10, 0xea},
{ 0xd4, 0x11, 0xac},
{ 0xd4, 0x12, 0xdf},
{ 0xd4, 0x13, 0x20},
{ 0xd4, 0x14, 0x40},
{ 0xd4, 0x15, 0xe7},
{ 0xd4, 0x16, 0x06},
{ 0xd4, 0x17, 0xa3},
{ 0xc4, 0x1, 0x1},
{ 0xc4, 0x4, 0xe},
{ 0xce, 0x5, 0x40},
{ 0xce, 0x6, 0x5},
{ 0xc0, 0x10, 0x41},
{ 0xc0, 0x13, 0x0}
};
vgareg v256x224S[25] =
{
{ 0xc2, 0x0, 0xe3},
{ 0xd4, 0x0, 0x5f},
{ 0xd4, 0x1, 0x3f},
{ 0xd4, 0x2, 0x40},
{ 0xd4, 0x3, 0x82},
{ 0xd4, 0x4, 0x4e},
{ 0xd4, 0x5, 0x96},
{ 0xd4, 0x6, 0x5},
{ 0xd4, 0x7, 0x1},
{ 0xd4, 0x8, 0x0},
{ 0xd4, 0x9, 0x40},
{ 0xd4, 0x10, 0xea},
{ 0xd4, 0x11, 0xac},
{ 0xd4, 0x12, 0xdf},
{ 0xd4, 0x13, 0x20},
{ 0xd4, 0x14, 0x40},
{ 0xd4, 0x15, 0xe7},
{ 0xd4, 0x16, 0x0},
{ 0xd4, 0x17, 0xe3},
{ 0xc4, 0x1, 0x1},
{ 0xc4, 0x4, 0xe},
{ 0xce, 0x5, 0x40},
{ 0xce, 0x6, 0x5},
{ 0xc0, 0x10, 0x41},
{ 0xc0, 0x13, 0x0}
};
vgareg v256x256[25] =
{
{ 0xc2, 0x0, 0xe7},
{ 0xd4, 0x0, 0x5f},
{ 0xd4, 0x1, 0x3f},
{ 0xd4, 0x2, 0x40},
{ 0xd4, 0x3, 0x82},
{ 0xd4, 0x4, 0x4a},
{ 0xd4, 0x5, 0x9a},
{ 0xd4, 0x6, 0x23},
{ 0xd4, 0x7, 0xb2},
{ 0xd4, 0x8, 0x0},
{ 0xd4, 0x9, 0x61},
{ 0xd4, 0x10, 0xa},
{ 0xd4, 0x11, 0xac},
{ 0xd4, 0x12, 0xff},
{ 0xd4, 0x13, 0x20},
{ 0xd4, 0x14, 0x40},
{ 0xd4, 0x15, 0x7},
{ 0xd4, 0x16, 0x1a},
{ 0xd4, 0x17, 0xa3},
{ 0xc4, 0x1, 0x1},
{ 0xc4, 0x4, 0xe},
{ 0xce, 0x5, 0x40},
{ 0xce, 0x6, 0x5},
{ 0xc0, 0x10, 0x41},
{ 0xc0, 0x13, 0x0}
};
vgareg v256x256S[25] =
{
{ 0xc2, 0x00, 0xe7},{ 0xd4, 0x00, 0x5F},{ 0xd4, 0x01, 0x3f},
{ 0xd4, 0x02, 0x40},{ 0xd4, 0x03, 0x82},{ 0xd4, 0x04, 0x4a},
{ 0xd4, 0x05, 0x9a},{ 0xd4, 0x06, 0x25},{ 0xd4, 0x07, 0x15},
{ 0xd4, 0x08, 0x00},{ 0xd4, 0x09, 0x60},{ 0xd4, 0x10, 0x0a},
{ 0xd4, 0x11, 0xac},{ 0xd4, 0x12, 0xff},{ 0xd4, 0x13, 0x20},
{ 0xd4, 0x14, 0x40},{ 0xd4, 0x15, 0x07},{ 0xd4, 0x16, 0x1a},
{ 0xd4, 0x17, 0xa3},{ 0xc4, 0x01, 0x01},{ 0xc4, 0x04, 0x0e},
{ 0xce, 0x05, 0x40},{ 0xce, 0x06, 0x05},{ 0xc0, 0x10, 0x41},
{ 0xc0, 0x13, 0x00}
};
static void VGAPortSet(vgareg R)
{
int p,i,v;
p=0x300|R.p;
i=R.i;
v=R.v;
switch(p)
{
case 0x3C0: inportb(0x3DA);
outportb(0x3C0,i);
outportb(0x3C0,v);
break;
case 0x3C2:
case 0x3C3:
default: outportb(p, v);
break;
case 0x3C4: if(i==1)
{
outportw(0x3c4,0x100);
outportw(0x3c4,(v<<8)|1);
outportw(0x3c4,0x300);
break;
}
case 0x3CE:
case 0x3D4: outportw(p,i|(v<<8));
break;
}
}

View File

@ -1,14 +0,0 @@
#include "sexyal.h"
#include "convert.h"
static inline uint16_t FLIP16(uint16_t b)
{
return((b<<8)|((b>>8)&0xFF));
}
static inline uint32_t FLIP32(uint32_t b)
{
return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) );
}
#include "convert.inc"

View File

@ -1,2 +0,0 @@
void SexiALI_Convert(SexyAL_format *srcformat, SexyAL_format *destformat, void *vdest, void *vsrc, uint32_t frames);

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,155 +0,0 @@
#include <stdio.h>
char *check[]={"SEXYAL_FMT_PCMS8","SEXYAL_FMT_PCMU8","SEXYAL_FMT_PCMS16",
"SEXYAL_FMT_PCMU16","SEXYAL_FMT_PCMS32S16","SEXYAL_FMT_PCMU32U16","SEXYAL_FMT_PCMS32S24","SEXYAL_FMT_PCMU32U24"};
char *str[]={"int8_t","uint8_t","int16_t","uint16_t","int32_t","uint32_t","int32_t","uint32_t"};
int bitss[]={8,8,16,16,16,16,24,24};
int bitsreal[]={8,8,16,16,32,32,32,32};
void Fetch(int x,char *wt)
{
//printf(" int32_t tmp%s=*src;\n",wt);
printf("tmp%s=*src;\n",wt);
printf(" src++;\n");
}
void BitConv(int src, int dest, char *wt)
{
if((src^dest)&1) /* signed/unsigned change. */
if(src&1) /* Source unsigned, dest signed. */
{
if(src==1) printf(" tmp%s-=128;\n",wt);
else if(src==3) printf(" tmp%s-=32768;\n",wt);
else if(src==5) printf(" tmp%s-=32768;\n",wt);
else if(src==7) printf(" tmp%s-=(1<<23);\n",wt);
}
else /* Source signed, dest unsigned */
{
if(src==0) printf(" tmp%s+=128;\n",wt);
else if(src==2) printf(" tmp%s+=32768;\n",wt);
else if(src==4) printf(" tmp%s+=32768;\n",wt);
else if(src==6) printf(" tmp%s+=(1<<23);\n",wt);
}
if((src>>1) != (dest>>1))
{
int shifty=bitss[src]-bitss[dest];
if(shifty>0)
printf(" tmp%s >>= %d;\n",wt,shifty);
else
printf(" tmp%s <<= %d;\n",wt,-shifty);
}
}
void Save(int x, char *wt)
{
printf(" *dest=tmp%s;\n",wt);
printf(" dest++;\n");
}
main()
{
int srcbits,destbits,srcchannels,destchannels;
int srcbo,destbo;
puts("void SexiALI_Convert(SexyAL_format *srcformat, SexyAL_format *destformat, void *vdest, void *vsrc, uint32_t frames)");
puts("{");
for(srcbits=0;srcbits<8;srcbits++)
{
printf("if(srcformat->sampformat == %s)\n{\n",check[srcbits]);
printf("%s* src=vsrc;\n",str[srcbits]);
for(destbits=0;destbits<8;destbits++)
{
printf("if(destformat->sampformat == %s)\n{\n",check[destbits]);
printf("%s* dest=vdest;\n",str[destbits]);
for(srcchannels=0;srcchannels<2;srcchannels++)
{
printf("if(srcformat->channels == %c)\n{\n",'1'+srcchannels);
for(destchannels=0;destchannels<2;destchannels++)
{
printf("if(destformat->channels == %c)\n{\n",'1'+destchannels);
for(srcbo=0;srcbo<2;srcbo++)
{
printf("if(srcformat->byteorder == %d)\n{\n",srcbo);
for(destbo=0;destbo<2;destbo++)
{
printf("if(destformat->byteorder == %d)\n{\n",destbo);
//printf("if(srcformat->sampformat==%s && destformat->sameck[srcbits],check[destbits]);
printf("while(frames--)\n{\n");
puts("int32_t tmp;");
if(srcchannels)
puts("int32_t tmp2;");
Fetch(srcbits,"");
if(srcbo)
{
if(bitsreal[srcbits]==16)
puts("FLIP16(tmp);");
else
puts("FLIP32(tmp);");
}
if(srcchannels)
{
Fetch(srcbits,"2");
if(srcbo)
{
if(bitsreal[srcbits]==16)
puts("FLIP16(tmp2);");
else
puts("FLIP32(tmp2);");
}
}
BitConv(srcbits,destbits,"");
if(srcchannels) BitConv(srcbits,destbits,"2");
if(destbo)
{
if(bitsreal[srcbits]==16)
puts("FLIP16(tmp);");
else
puts("FLIP32(tmp);");
if(srcchannels && destchannels && destbo)
{
if(bitsreal[srcbits]==16)
puts("FLIP16(tmp2);");
else
puts("FLIP32(tmp2);");
}
}
if(srcchannels && !destchannels)
printf("tmp = (tmp+tmp2)>>1;\n");
Save(destbits,"");
if(!srcchannels && destchannels)
Save(destbits,"");
if(srcchannels && destchannels)
Save(destbits,"2");
puts("}");
puts("}");
} // destbo
puts("}");
} // srcbo
puts("}");
}
puts("}");
}
puts("}");
}
puts("}");
}
puts("}");
}

View File

@ -1,276 +0,0 @@
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#undef WINNT
#define NONAMELESSUNION
#define DIRECTSOUND_VERSION 0x0300
#include <dsound.h>
#include "../sexyal.h"
typedef struct
{
LPDIRECTSOUND ppDS; /* DirectSound interface object. */
LPDIRECTSOUNDBUFFER ppbuf; /* Primary buffer. */
LPDIRECTSOUNDBUFFER ppbufsec; /* Secondary buffer. */
LPDIRECTSOUNDBUFFER ppbufw; /* Buffer to do writes to. */
WAVEFORMATEX wf; /* Format of the primary and secondary buffers. */
long DSBufferSize; /* The size of the buffer that we can write to, in bytes. */
long BufHowMuch; /* How many bytes we should try to buffer. */
DWORD ToWritePos; /* Position which the next write to the buffer
should write to.
*/
} DSFobby;
static void CheckStatus(DSFobby *tmp)
{
DWORD status=0;
IDirectSoundBuffer_GetStatus(tmp->ppbufw, &status);
if(status&DSBSTATUS_BUFFERLOST)
IDirectSoundBuffer_Restore(tmp->ppbufw);
if(!(status&DSBSTATUS_PLAYING))
{
tmp->ToWritePos=0;
IDirectSoundBuffer_SetCurrentPosition(tmp->ppbufsec,0);
IDirectSoundBuffer_SetFormat(tmp->ppbufw,&tmp->wf);
IDirectSoundBuffer_Play(tmp->ppbufw,0,0,DSBPLAY_LOOPING);
}
}
SexyAL_device *SexyALI_DSound_Open(uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering)
{
SexyAL_device *dev;
DSFobby *fobby;
DSBUFFERDESC DSBufferDesc;
DSCAPS dscaps;
DSBCAPS dsbcaps;
dev=malloc(sizeof(SexyAL_device));
fobby=malloc(sizeof(DSFobby));
memset(fobby,0,sizeof(DSFobby));
memset(&fobby->wf,0,sizeof(WAVEFORMATEX));
fobby->wf.wFormatTag = WAVE_FORMAT_PCM;
fobby->wf.nChannels = format->channels;
fobby->wf.nSamplesPerSec = format->rate;
if(DirectSoundCreate(0,&fobby->ppDS,0) != DS_OK)
{
free(dev);
free(fobby);
return(0);
}
{
//HWND hWnd = GetForegroundWindow(); // Ugly.
//if(!hWnd)
//{ hWnd=GetDesktopWindow(); exit(1); }
HWND hWnd;
hWnd=GetDesktopWindow();
IDirectSound_SetCooperativeLevel(fobby->ppDS,hWnd,DSSCL_PRIORITY);
}
memset(&dscaps,0x00,sizeof(dscaps));
dscaps.dwSize=sizeof(dscaps);
IDirectSound_GetCaps(fobby->ppDS,&dscaps);
IDirectSound_Compact(fobby->ppDS);
/* Create primary buffer */
memset(&DSBufferDesc,0x00,sizeof(DSBUFFERDESC));
DSBufferDesc.dwSize=sizeof(DSBufferDesc);
DSBufferDesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
if(IDirectSound_CreateSoundBuffer(fobby->ppDS,&DSBufferDesc,&fobby->ppbuf,0) != DS_OK)
{
IDirectSound_Release(fobby->ppDS);
free(dev);
free(fobby);
return(0);
}
/* Set primary buffer format. */
if(format->sampformat == SEXYAL_FMT_PCMU8)
fobby->wf.wBitsPerSample=8;
else // if(format->sampformat == SEXYAL_FMT_PCMS16)
{
fobby->wf.wBitsPerSample=16;
format->sampformat=SEXYAL_FMT_PCMS16;
}
fobby->wf.nBlockAlign=fobby->wf.wBitsPerSample>>3;
fobby->wf.nAvgBytesPerSec=fobby->wf.nSamplesPerSec*fobby->wf.nBlockAlign;
if(IDirectSoundBuffer_SetFormat(fobby->ppbuf,&fobby->wf) != DS_OK)
{
IDirectSound_Release(fobby->ppbuf);
IDirectSound_Release(fobby->ppDS);
free(dev);
free(fobby);
return(0);
}
/* Create secondary sound buffer */
IDirectSoundBuffer_GetFormat(fobby->ppbuf,&fobby->wf,sizeof(WAVEFORMATEX),0);
memset(&DSBufferDesc,0x00,sizeof(DSBUFFERDESC));
DSBufferDesc.dwSize=sizeof(DSBufferDesc);
DSBufferDesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
DSBufferDesc.dwFlags|=DSBCAPS_GLOBALFOCUS;
DSBufferDesc.dwBufferBytes=65536;
DSBufferDesc.lpwfxFormat=&fobby->wf;
if(IDirectSound_CreateSoundBuffer(fobby->ppDS, &DSBufferDesc, &fobby->ppbufsec, 0) != DS_OK)
{
IDirectSound_Release(fobby->ppbuf);
IDirectSound_Release(fobby->ppDS);
free(dev);
free(fobby);
return(0);
}
fobby->DSBufferSize=65536;
IDirectSoundBuffer_SetCurrentPosition(fobby->ppbufsec,0);
fobby->ppbufw=fobby->ppbufsec;
memcpy(&dev->format,format,sizeof(SexyAL_format));
if(!buffering->ms)
buffering->ms=53;
buffering->totalsize=(int64_t)format->rate*buffering->ms/1000;
fobby->BufHowMuch=buffering->totalsize* format->channels * (format->sampformat>>4);
//printf("%d\n",fobby->BufHowMuch);
//fflush(stdout);
dev->private=fobby;
timeBeginPeriod(1);
return(dev);
}
uint32_t SexyALI_DSound_RawCanWrite(SexyAL_device *device)
{
DSFobby *tmp=device->private;
DWORD CurWritePos,CurPlayPos=0;
CheckStatus(tmp);
CurWritePos=0;
if(IDirectSoundBuffer_GetCurrentPosition(tmp->ppbufw,&CurPlayPos,&CurWritePos)==DS_OK)
{
//FCEU_DispMessage("%d",CurWritePos-CurPlayPos);
}
CurWritePos=(CurPlayPos+tmp->BufHowMuch)%tmp->DSBufferSize;
/* If the current write pos is >= half the buffer size less than the to write pos,
assume DirectSound has wrapped around.
*/
if(((int32_t)tmp->ToWritePos-(int32_t)CurWritePos) >= (tmp->DSBufferSize/2))
{
CurWritePos+=tmp->DSBufferSize;
//printf("Fixit: %d,%d,%d\n",tmp->ToWritePos,CurWritePos,CurWritePos-tmp->DSBufferSize);
}
if(tmp->ToWritePos<CurWritePos)
{
int32_t howmuch=(int32_t)CurWritePos-(int32_t)tmp->ToWritePos;
if(howmuch > tmp->BufHowMuch) /* Oopsie. Severe buffer overflow... */
{
tmp->ToWritePos=CurWritePos%tmp->DSBufferSize;
//IDirectSoundBuffer_Stop(tmp->ppbufsec);
//IDirectSoundBuffer_SetCurrentPosition(tmp->ppbufsec,tmp->ToWritePos);
//puts("Oops");
//fflush(stdout);
//return(0);
}
return(CurWritePos-tmp->ToWritePos);
}
else
return(0);
}
int SexyALI_DSound_RawWrite(SexyAL_device *device, void *data, uint32_t len)
{
DSFobby *tmp=device->private;
// uint32_t cw;
//printf("Pre: %d\n",SexyALI_DSound_RawCanWrite(device));
//fflush(stdout);
CheckStatus(tmp);
/* In this block, we write as much data as we can, then we write
the rest of it in >=1ms chunks.
*/
while(len)
{
VOID *LockPtr[2]={0,0};
DWORD LockLen[2]={0,0};
int32_t curlen;
while(!(curlen=SexyALI_DSound_RawCanWrite(device)))
{
Sleep(1);
}
if(curlen>len) curlen=len;
if(DS_OK == IDirectSoundBuffer_Lock(tmp->ppbufw,tmp->ToWritePos,curlen,&LockPtr[0],&LockLen[0],&LockPtr[1],&LockLen[1],0))
{
}
if(LockPtr[1] != 0 && LockPtr[1] != LockPtr[0])
{
memcpy(LockPtr[0],data,LockLen[0]);
memcpy(LockPtr[1],data+LockLen[0],len-LockLen[0]);
}
else if(LockPtr[0])
{
memcpy(LockPtr[0],data,curlen);
}
IDirectSoundBuffer_Unlock(tmp->ppbufw,LockPtr[0],LockLen[0],LockPtr[1],LockLen[1]);
tmp->ToWritePos=(tmp->ToWritePos+curlen)%tmp->DSBufferSize;
len-=curlen;
(uint8_t *) data+=curlen;
if(len)
Sleep(1);
} // end while(len) loop
return(1);
}
int SexyALI_DSound_Close(SexyAL_device *device)
{
if(device)
{
if(device->private)
{
DSFobby *tmp=device->private;
if(tmp->ppbufsec)
{
IDirectSoundBuffer_Stop(tmp->ppbufsec);
IDirectSoundBuffer_Release(tmp->ppbufsec);
}
if(tmp->ppbuf)
{
IDirectSoundBuffer_Stop(tmp->ppbuf);
IDirectSoundBuffer_Release(tmp->ppbuf);
}
if(tmp->ppDS)
{
IDirectSound_Release(tmp->ppDS);
}
free(device->private);
}
free(device);
timeEndPeriod(1);
return(1);
}
return(0);
}

View File

@ -1,241 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sched.h>
#include <sys/soundcard.h>
#include "../sexyal.h"
#include "../md5.h"
#include "../smallc.h"
#include "oss.h"
#define IDBASE 0x1000
void SexyALI_OSS_Enumerate(int (*func)(uint8_t *name, uint64_t id, void *udata), void *udata)
{
struct stat buf;
char fn[64];
unsigned int n;
n=0;
do
{
sal_strcpy(fn,"/dev/dsp");
sal_strcat(fn,sal_uinttos(n));
if(stat(fn,&buf)!=0) break;
} while(func(fn,n+IDBASE,udata));
}
static int FODevice(uint64_t id)
{
char fn[64];
if(id==SEXYAL_ID_DEFAULT)
{
sal_strcpy(fn,"/dev/dsp");
return(open(fn,O_WRONLY));
}
else if(id==SEXYAL_ID_UNUSED)
{
int x=-1;
int dspfd;
do
{
sal_strcpy(fn,"/dev/dsp");
if(x!=-1)
sal_strcat(fn,sal_uinttos(x));
dspfd=open(fn,O_WRONLY|O_NONBLOCK);
if(dspfd!=-1) break;
x++;
} while(errno!=ENOENT);
if(dspfd==-1) return(0);
fcntl(dspfd,F_SETFL,fcntl(dspfd,F_GETFL)&~O_NONBLOCK);
return(dspfd);
}
else
{
sal_strcpy(fn,"/dev/dsp");
sal_strcat(fn,sal_uinttos(id-IDBASE));
return(open(fn,O_WRONLY));
}
}
unsigned int Log2(unsigned int value)
{
int x=0;
value>>=1;
while(value)
{
value>>=1;
x++;
}
return(x?x:1);
}
SexyAL_device *SexyALI_OSS_Open(uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering)
{
SexyAL_device *device;
int fd;
unsigned int temp;
if(!(fd=FODevice(id))) return(0);
/* Set sample format. */
/* TODO: Handle devices with byte order different from native byte order. */
/* TODO: Fix fragment size calculation to work well with lower/higher playback rates,
as reported by OSS.
*/
if(format->sampformat == SEXYAL_FMT_PCMU8)
temp=AFMT_U8;
else if(format->sampformat == SEXYAL_FMT_PCMS8)
temp=AFMT_S8;
else if(format->sampformat == SEXYAL_FMT_PCMU16)
temp=AFMT_U16_LE;
else
temp=AFMT_S16_NE;
format->byteorder=0;
ioctl(fd,SNDCTL_DSP_SETFMT,&temp);
switch(temp)
{
case AFMT_U8: format->sampformat = SEXYAL_FMT_PCMU8;break;
case AFMT_S8: format->sampformat = SEXYAL_FMT_PCMS8;break;
case AFMT_U16_LE:
#ifndef LSB_FIRST
format->byteorder=1;
#endif
format->sampformat = SEXYAL_FMT_PCMU16;break;
case AFMT_U16_BE:
#ifdef LSB_FIRST
format->byteorder=1;
#endif
format->sampformat = SEXYAL_FMT_PCMU16;break;
case AFMT_S16_LE:
#ifndef LSB_FIRST
format->byteorder=1;
#endif
format->sampformat = SEXYAL_FMT_PCMS16;break;
case AFMT_S16_BE:
#ifdef LSB_FIRST
format->byteorder=1;
#endif
format->sampformat = SEXYAL_FMT_PCMS16;break;
default: close(fd); return(0);
}
/* Set number of channels. */
temp=format->channels;
if(ioctl(fd,SNDCTL_DSP_CHANNELS,&temp)==-1)
{
close(fd);
return(0);
}
if(temp<1 || temp>2)
{
close(fd);
return(0);
}
format->channels=temp;
/* Set frame rate. */
temp=format->rate;
if(ioctl(fd,SNDCTL_DSP_SPEED,&temp)==-1)
{
close(fd);
return(0);
}
format->rate=temp;
device=malloc(sizeof(SexyAL_device));
sal_memcpy(&device->format,format,sizeof(SexyAL_format));
sal_memcpy(&device->buffering,buffering,sizeof(SexyAL_buffering));
if(buffering->fragcount == 0 || buffering->fragsize == 0)
{
buffering->fragcount=16;
buffering->fragsize=64;
}
else
{
if(buffering->fragsize<32) buffering->fragsize=32;
if(buffering->fragcount<2) buffering->fragcount=2;
}
if(buffering->ms)
{
int64_t tc;
//printf("%d\n",buffering->ms);
/* 2*, >>1, |1 for crude rounding(it will always round 0.5 up, so it is a bit biased). */
tc=2*buffering->ms * format->rate / 1000 / buffering->fragsize;
//printf("%f\n",(double)buffering->ms * format->rate / 1000 / buffering->fragsize);
buffering->fragcount=(tc>>1)+(tc&1); //1<<Log2(tc);
//printf("%d\n",buffering->fragcount);
}
temp=Log2(buffering->fragsize*(format->sampformat>>4)*format->channels);
temp|=buffering->fragcount<<16;
ioctl(fd,SNDCTL_DSP_SETFRAGMENT,&temp);
{
audio_buf_info info;
ioctl(fd,SNDCTL_DSP_GETOSPACE,&info);
buffering->fragsize=info.fragsize/(format->sampformat>>4)/format->channels;
buffering->fragcount=info.fragments;
buffering->totalsize=buffering->fragsize*buffering->fragcount;
//printf("Actual: %d, %d\n",buffering->fragsize,buffering->fragcount);
}
device->private=malloc(sizeof(int));
*(int*)device->private=fd;
return(device);
}
int SexyALI_OSS_Close(SexyAL_device *device)
{
if(device)
{
if(device->private)
{
close(*(int*)device->private);
free(device->private);
}
free(device);
return(1);
}
return(0);
}
uint32_t SexyALI_OSS_RawWrite(SexyAL_device *device, void *data, uint32_t len)
{
ssize_t bytes;
bytes = write(*(int *)device->private,data,len);
if(bytes <= 0) return(0); /* FIXME: What to do on -1? */
return(bytes);
}
uint32_t SexyALI_OSS_RawCanWrite(SexyAL_device *device)
{
struct audio_buf_info ai;
if(!ioctl(*(int *)device->private,SNDCTL_DSP_GETOSPACE,&ai))
return(ai.bytes);
else
return(0);
}

View File

@ -1,6 +0,0 @@
void SexyALI_OSS_Enumerate(int (*func)(uint8_t *name, uint64_t id, void *udata), void *udata);
SexyAL_device *SexyALI_OSS_Open(uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering);
int SexyALI_OSS_Close(SexyAL_device *device);
uint32_t SexyALI_OSS_RawWrite(SexyAL_device *device, void *data, uint32_t len);
uint32_t SexyALI_OSS_RawCanWrite(SexyAL_device *device);

View File

@ -1,5 +0,0 @@
#include <AudioHardware.h>
#include <CoreAudioTypes.h>
#include <HostTime.h>

View File

@ -1,229 +0,0 @@
/*
* RFC 1321 compliant MD5 implementation,
* by Christophe Devine <devine@cr0.net>;
* this program is licensed under the GPL.
*/
/* Modified October 3, 2003, to remove testing code, and add
include of "types.h".
-Xodnizel
*/
#include <string.h>
#include "inttypes.h"
#include "md5.h"
#define GET_UINT32(n,b,i) \
{ \
(n) = ( (uint32_t) (b)[(i) + 3] << 24 ) \
| ( (uint32_t) (b)[(i) + 2] << 16 ) \
| ( (uint32_t) (b)[(i) + 1] << 8 ) \
| ( (uint32_t) (b)[(i) ] ); \
}
#define PUT_UINT32(n,b,i) \
{ \
(b)[(i) ] = (uint8_t) ( (n) ); \
(b)[(i) + 1] = (uint8_t) ( (n) >> 8 ); \
(b)[(i) + 2] = (uint8_t) ( (n) >> 16 ); \
(b)[(i) + 3] = (uint8_t) ( (n) >> 24 ); \
}
void sal_md5_starts( struct sal_md5_context *ctx )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xEFCDAB89;
ctx->state[2] = 0x98BADCFE;
ctx->state[3] = 0x10325476;
}
void sal_md5_process( struct sal_md5_context *ctx, uint8_t data[64] )
{
uint32_t A, B, C, D, X[16];
GET_UINT32( X[0], data, 0 );
GET_UINT32( X[1], data, 4 );
GET_UINT32( X[2], data, 8 );
GET_UINT32( X[3], data, 12 );
GET_UINT32( X[4], data, 16 );
GET_UINT32( X[5], data, 20 );
GET_UINT32( X[6], data, 24 );
GET_UINT32( X[7], data, 28 );
GET_UINT32( X[8], data, 32 );
GET_UINT32( X[9], data, 36 );
GET_UINT32( X[10], data, 40 );
GET_UINT32( X[11], data, 44 );
GET_UINT32( X[12], data, 48 );
GET_UINT32( X[13], data, 52 );
GET_UINT32( X[14], data, 56 );
GET_UINT32( X[15], data, 60 );
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
#define P(a,b,c,d,k,s,t) \
{ \
a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \
}
A = ctx->state[0];
B = ctx->state[1];
C = ctx->state[2];
D = ctx->state[3];
#define F(x,y,z) (z ^ (x & (y ^ z)))
P( A, B, C, D, 0, 7, 0xD76AA478 );
P( D, A, B, C, 1, 12, 0xE8C7B756 );
P( C, D, A, B, 2, 17, 0x242070DB );
P( B, C, D, A, 3, 22, 0xC1BDCEEE );
P( A, B, C, D, 4, 7, 0xF57C0FAF );
P( D, A, B, C, 5, 12, 0x4787C62A );
P( C, D, A, B, 6, 17, 0xA8304613 );
P( B, C, D, A, 7, 22, 0xFD469501 );
P( A, B, C, D, 8, 7, 0x698098D8 );
P( D, A, B, C, 9, 12, 0x8B44F7AF );
P( C, D, A, B, 10, 17, 0xFFFF5BB1 );
P( B, C, D, A, 11, 22, 0x895CD7BE );
P( A, B, C, D, 12, 7, 0x6B901122 );
P( D, A, B, C, 13, 12, 0xFD987193 );
P( C, D, A, B, 14, 17, 0xA679438E );
P( B, C, D, A, 15, 22, 0x49B40821 );
#undef F
#define F(x,y,z) (y ^ (z & (x ^ y)))
P( A, B, C, D, 1, 5, 0xF61E2562 );
P( D, A, B, C, 6, 9, 0xC040B340 );
P( C, D, A, B, 11, 14, 0x265E5A51 );
P( B, C, D, A, 0, 20, 0xE9B6C7AA );
P( A, B, C, D, 5, 5, 0xD62F105D );
P( D, A, B, C, 10, 9, 0x02441453 );
P( C, D, A, B, 15, 14, 0xD8A1E681 );
P( B, C, D, A, 4, 20, 0xE7D3FBC8 );
P( A, B, C, D, 9, 5, 0x21E1CDE6 );
P( D, A, B, C, 14, 9, 0xC33707D6 );
P( C, D, A, B, 3, 14, 0xF4D50D87 );
P( B, C, D, A, 8, 20, 0x455A14ED );
P( A, B, C, D, 13, 5, 0xA9E3E905 );
P( D, A, B, C, 2, 9, 0xFCEFA3F8 );
P( C, D, A, B, 7, 14, 0x676F02D9 );
P( B, C, D, A, 12, 20, 0x8D2A4C8A );
#undef F
#define F(x,y,z) (x ^ y ^ z)
P( A, B, C, D, 5, 4, 0xFFFA3942 );
P( D, A, B, C, 8, 11, 0x8771F681 );
P( C, D, A, B, 11, 16, 0x6D9D6122 );
P( B, C, D, A, 14, 23, 0xFDE5380C );
P( A, B, C, D, 1, 4, 0xA4BEEA44 );
P( D, A, B, C, 4, 11, 0x4BDECFA9 );
P( C, D, A, B, 7, 16, 0xF6BB4B60 );
P( B, C, D, A, 10, 23, 0xBEBFBC70 );
P( A, B, C, D, 13, 4, 0x289B7EC6 );
P( D, A, B, C, 0, 11, 0xEAA127FA );
P( C, D, A, B, 3, 16, 0xD4EF3085 );
P( B, C, D, A, 6, 23, 0x04881D05 );
P( A, B, C, D, 9, 4, 0xD9D4D039 );
P( D, A, B, C, 12, 11, 0xE6DB99E5 );
P( C, D, A, B, 15, 16, 0x1FA27CF8 );
P( B, C, D, A, 2, 23, 0xC4AC5665 );
#undef F
#define F(x,y,z) (y ^ (x | ~z))
P( A, B, C, D, 0, 6, 0xF4292244 );
P( D, A, B, C, 7, 10, 0x432AFF97 );
P( C, D, A, B, 14, 15, 0xAB9423A7 );
P( B, C, D, A, 5, 21, 0xFC93A039 );
P( A, B, C, D, 12, 6, 0x655B59C3 );
P( D, A, B, C, 3, 10, 0x8F0CCC92 );
P( C, D, A, B, 10, 15, 0xFFEFF47D );
P( B, C, D, A, 1, 21, 0x85845DD1 );
P( A, B, C, D, 8, 6, 0x6FA87E4F );
P( D, A, B, C, 15, 10, 0xFE2CE6E0 );
P( C, D, A, B, 6, 15, 0xA3014314 );
P( B, C, D, A, 13, 21, 0x4E0811A1 );
P( A, B, C, D, 4, 6, 0xF7537E82 );
P( D, A, B, C, 11, 10, 0xBD3AF235 );
P( C, D, A, B, 2, 15, 0x2AD7D2BB );
P( B, C, D, A, 9, 21, 0xEB86D391 );
#undef F
ctx->state[0] += A;
ctx->state[1] += B;
ctx->state[2] += C;
ctx->state[3] += D;
}
void sal_md5_update( struct sal_md5_context *ctx, uint8_t *input, uint32_t length )
{
uint32_t left, fill;
if( ! length ) return;
left = ( ctx->total[0] >> 3 ) & 0x3F;
fill = 64 - left;
ctx->total[0] += length << 3;
ctx->total[1] += length >> 29;
ctx->total[0] &= 0xFFFFFFFF;
ctx->total[1] += ctx->total[0] < ( length << 3 );
if( left && length >= fill )
{
memcpy( (void *) (ctx->buffer + left), (void *) input, fill );
sal_md5_process( ctx, ctx->buffer );
length -= fill;
input += fill;
left = 0;
}
while( length >= 64 )
{
sal_md5_process( ctx, input );
length -= 64;
input += 64;
}
if( length )
{
memcpy( (void *) (ctx->buffer + left), (void *) input, length );
}
}
static uint8_t md5_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
void sal_md5_finish( struct sal_md5_context *ctx, uint8_t digest[16] )
{
uint32_t last, padn;
uint8_t msglen[8];
PUT_UINT32( ctx->total[0], msglen, 0 );
PUT_UINT32( ctx->total[1], msglen, 4 );
last = ( ctx->total[0] >> 3 ) & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
sal_md5_update( ctx, md5_padding, padn );
sal_md5_update( ctx, msglen, 8 );
PUT_UINT32( ctx->state[0], digest, 0 );
PUT_UINT32( ctx->state[1], digest, 4 );
PUT_UINT32( ctx->state[2], digest, 8 );
PUT_UINT32( ctx->state[3], digest, 12 );
}

View File

@ -1,15 +0,0 @@
#ifndef _MD5_H
#define _MD5_H
struct sal_md5_context
{
uint32_t total[2];
uint32_t state[4];
uint8_t buffer[64];
};
void sal_md5_starts( struct sal_md5_context *ctx );
void sal_md5_update( struct sal_md5_context *ctx, uint8_t *input, uint32_t length );
void sal_md5_finish( struct sal_md5_context *ctx, uint8_t digest[16] );
#endif /* md5.h */

View File

@ -1,115 +0,0 @@
#include <stdlib.h>
#include <string.h>
#include "sexyal.h"
#include "convert.h"
#ifdef WIN32
#else
#include "drivers/oss.h"
#endif
static uint32_t FtoB(const SexyAL_format *format, uint32_t frames)
{
return(frames*format->channels*(format->sampformat>>4));
}
/*
static uint32_t BtoF(const SexyAL_format *format, uint32_t bytes)
{
return(bytes / (format->channels * (format->sampformat>>4)));
}
*/
static uint32_t CanWrite(SexyAL_device *device)
{
uint32_t bytes,frames;
#ifdef WIN32
bytes=SexyALI_DSound_RawCanWrite(device);
#else
bytes=SexyALI_OSS_RawCanWrite(device);
#endif
frames=bytes / device->format.channels / (device->format.sampformat>>4);
return(frames);
}
static uint32_t Write(SexyAL_device *device, void *data, uint32_t frames)
{
uint8_t buffer[2048*4];
while(frames)
{
int32_t tmp;
tmp=frames;
if(tmp>2048)
{
tmp=2048;
frames-=2048;
}
else frames-=tmp;
SexiALI_Convert(&device->srcformat, &device->format, buffer, data, tmp);
//printf("%02x, %02x, %02x\n", device->srcformat.sampformat, device->srcformat.byteorder, device->srcformat.channels);
//printf("buffer: %d\n",buffer[0]);
/* FIXME: Return the actual number of frame written. It should always equal
the number of frames requested to be written, except in cases of sound device
failures.
*/
#ifdef WIN32
SexyALI_DSound_RawWrite(device,buffer,FtoB(&device->format,tmp));
#else
SexyALI_OSS_RawWrite(device,buffer,FtoB(&device->format,tmp));
#endif
}
return(frames);
}
static int Close(SexyAL_device *device)
{
#ifdef WIN32
return(SexyALI_DSound_Close(device));
#else
return(SexyALI_OSS_Close(device));
#endif
}
int SetConvert(struct __SexyAL_device *device, SexyAL_format *format)
{
memcpy(&device->srcformat,format,sizeof(SexyAL_format));
return(1);
}
static SexyAL_device *Open(SexyAL *iface, uint64_t id, SexyAL_format *format, SexyAL_buffering *buffering)
{
SexyAL_device *ret;
#ifdef WIN32
if(!(ret=SexyALI_DSound_Open(id,format,buffering))) return(0);
#else
if(!(ret=SexyALI_OSS_Open(id,format,buffering))) return(0);
#endif
ret->Write=Write;
ret->Close=Close;
ret->CanWrite=CanWrite;
ret->SetConvert=SetConvert;
return(ret);
}
void Destroy(SexyAL *iface)
{
free(iface);
}
void *SexyAL_Init(int version)
{
SexyAL *iface;
if(!version != 1) return(0);
iface=malloc(sizeof(SexyAL));
iface->Open=Open;
iface->Destroy=Destroy;
return((void *)iface);
}

View File

@ -1,52 +0,0 @@
#include <inttypes.h>
typedef struct
{
uint32_t sampformat;
uint32_t channels; /* 1 = mono, 2 = stereo */
uint32_t rate; /* Number of frames per second, 22050, 44100, etc. */
uint32_t byteorder; /* 0 = Native(to CPU), 1 = Reversed. PDP can go to hell. */
} SexyAL_format;
typedef struct
{
uint32_t fragcount;
uint32_t fragsize;
uint32_t totalsize; /* Shouldn't be filled in by application code. */
uint32_t ms; /* Milliseconds of buffering, approximate. */
} SexyAL_buffering;
#define SEXYAL_ID_DEFAULT 0
#define SEXYAL_ID_UNUSED 1
#define SEXYAL_FMT_PCMU8 0x10
#define SEXYAL_FMT_PCMS8 0x11
#define SEXYAL_FMT_PCMU16 0x20
#define SEXYAL_FMT_PCMS16 0x21
#define SEXYAL_FMT_PCMU32U24 0x40
#define SEXYAL_FMT_PCMS32S24 0x41
#define SEXYAL_FMT_PCMU32U16 0x42
#define SEXYAL_FMT_PCMS32S16 0x43
typedef struct __SexyAL_device {
int (*SetConvert)(struct __SexyAL_device *, SexyAL_format *);
uint32_t (*Write)(struct __SexyAL_device *, void *data, uint32_t frames);
uint32_t (*CanWrite)(struct __SexyAL_device *);
int (*Close)(struct __SexyAL_device *);
SexyAL_format format;
SexyAL_format srcformat;
SexyAL_buffering buffering;
void *private;
} SexyAL_device;
typedef struct __SexyAL {
SexyAL_device * (*Open)(struct __SexyAL *, uint64_t id, SexyAL_format *, SexyAL_buffering *buffering);
void (*Enumerate)(struct __SexyAL *, int (*func)(uint8_t *name, uint64_t id, void *udata));
void (*Destroy)(struct __SexyAL *);
} SexyAL;
/* Initializes the library, requesting the interface of the version specified. */
void *SexyAL_Init(int version);

View File

@ -1,63 +0,0 @@
#include "smallc.h"
void sal_memcpy(void *dest, const void *src, uint32_t n)
{
while(n--)
{
*(uint8_t*)dest=*(uint8_t *)src;
(uint8_t*)dest++;
(uint8_t*)src++;
}
}
uint32_t sal_strlen(const char *buf)
{
uint32_t size=0;
while(*buf++) size++;
return(size);
}
void sal_strcpy(char *dest, const char *src)
{
while(*src)
*dest++ = *src++;
*dest=0;
}
void sal_strcat(char *dest, const char *src)
{
while(*dest)
dest++;
while(*src)
*dest++ = *src++;
*dest=0;
}
const char *sal_uinttos(int value)
{
static char buf[64],buf2[64];
char *tmp;
int len=0;
tmp=buf;
while(value)
{
*tmp='0'+(value%10);
len++;
tmp++;
value/=10;
}
tmp=buf2;
while(len-- >= 0)
{
*tmp=buf[len];
tmp++;
}
*tmp=0;
return(buf2);
}

View File

@ -1,7 +0,0 @@
#include <inttypes.h>
void sal_memcpy(void *dest, const void *src, uint32_t n);
void sal_strcpy(char *dest, const char *src);
const char *sal_uinttos(int value);
void sal_strcat(char *dest, const char *src);

View File

@ -1,42 +0,0 @@
#include <stdio.h>
#include <vorbis/vorbisfile.h>
#include "types.h"
#include "fceu.h"
static OggVorbis_File cursong;
void InstallSoundExp(void)
{
FILE *fp=fopen("test.ogg","rb");
ov_open(fp,&cursong,NULL,0);
FCEUGameInfo->soundrate=44100;
FCEUGameInfo->soundchan=2;
}
int cur=0;
void UpdateSoundExp(int32 *buf, int32 len)
{
int16 boo[8192];
int32 offset=0;
int x;
int32 tlen=len;
while(len)
{
int32 t=ov_read(&cursong,(char *)boo+offset*4,len*4,0,2,1,&cur)/4;
len-=t;
offset+=t;
}
// printf("%d\n",inboo);
for(x=0;x<tlen*2;x++)
{
buf[x]=boo[x];
//buf[x]=(x&4)*4096; //(x&3)?0x3FFF:0;
}//buf[x]+=boo[x];
// inboo-=len;
}

View File

@ -1,75 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 CaH4e3
*
* 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 "mapinc.h"
static uint8 reg[4];
static SFORMAT StateRegs[]=
{
{reg, 4, "REGS"},
{0}
};
static void Sync(void)
{
setprg32(0x8000,(reg[2]>>2)&1);
setchr8(reg[2]&3);
}
static DECLFW(UNL22211WriteLo)
{
// FCEU_printf("bs %04x %02x\n",A,V);
reg[A&3]=V;
}
static DECLFW(UNL22211WriteHi)
{
// FCEU_printf("bs %04x %02x\n",A,V);
Sync();
}
static DECLFR(UNL22211ReadLo)
{
if(reg[3])
return reg[2];
else
return X.DB;
}
static void UNL22211Power(void)
{
Sync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetReadHandler(0x4100,0x4100,UNL22211ReadLo);
SetWriteHandler(0x4100,0x4103,UNL22211WriteLo);
SetWriteHandler(0x8000,0xFFFF,UNL22211WriteHi);
}
static void StateRestore(int version)
{
Sync();
}
void UNL22211_Init(CartInfo *info)
{
info->Power=UNL22211Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,92 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint8 reg[8];
static uint8 mirror, cmd;
static uint8 *WRAM=NULL;
static SFORMAT StateRegs[]=
{
{&cmd, 1, "CMD"},
{&mirror, 1, "MIRR"},
{reg, 8, "REGS"},
{0}
};
static void Sync(void)
{
setmirror(mirror^1);
setprg8(0x8000,reg[0]);
setprg8(0xA000,reg[1]);
setchr2(0x0000,reg[2]>>1);
setchr2(0x0800,reg[3]>>1);
setchr1(0x1000,reg[4]);
setchr1(0x1400,reg[5]);
setchr1(0x1800,reg[6]);
setchr1(0x1C00,reg[7]);
}
static DECLFW(M112Write)
{
// FCEU_printf("bs %04x %02x\n",A,V);
switch(A)
{
case 0xe000: mirror=V&1; Sync(); ;break;
case 0x8000: cmd=V&7; break;
case 0xa000: reg[cmd]=V; Sync(); break;
// default: FCEU_printf("bs %04x %02x\n",A,V);
}
}
static void M112Close(void)
{
if(WRAM)
FCEU_gfree(WRAM);
WRAM = NULL;
}
static void M112Power(void)
{
setprg16(0xC000,~0);
setprg8r(0x10,0x6000,0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M112Write);
SetWriteHandler(0x4020,0x5FFF,M112Write);
SetReadHandler(0x6000,0x7FFF,CartBR);
SetWriteHandler(0x6000,0x7FFF,CartBW);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper112_Init(CartInfo *info)
{
info->Power=M112Power;
info->Close=M112Close;
GameStateRestore=StateRestore;
WRAM=(uint8*)FCEU_gmalloc(8192);
SetupCartPRGMapping(0x10,WRAM,8192,1);
AddExState(WRAM, 8192, 0, "WRAM");
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,101 +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 "mapinc.h"
static uint8 prgreg[4], chrreg[8];
static uint8 IRQa, IRQCount, IRQLatch;
static SFORMAT StateRegs[]=
{
{&IRQa, 1, "IRQA"},
{&IRQCount, 1, "IRQC"},
{&IRQLatch, 1, "IRQL"},
{prgreg, 4, "PREGS"},
{chrreg, 8, "CREGS"},
{0}
};
static void Sync(void)
{
int i;
setprg8(0x8000,prgreg[0]);
setprg8(0xa000,prgreg[1]);
setprg8(0xc000,prgreg[2]);
setprg8(0xe000,prgreg[3]);
for(i=0; i<8; i++)
setchr1(i<<10,chrreg[i]);
}
static DECLFW(M117Write)
{
if(A<0x8004)
{
prgreg[A&3]=V;
Sync();
}
else if((A>=0xA000)&&(A<=0xA007))
{
chrreg[A&7]=V;
Sync();
}
else switch(A)
{
case 0xc001: IRQLatch=V; break;
case 0xc003: IRQCount=IRQLatch; IRQa|=2; break;
case 0xe000: IRQa&=~1; IRQa|=V&1; X6502_IRQEnd(FCEU_IQEXT); break;
case 0xc002: X6502_IRQEnd(FCEU_IQEXT); break;
}
}
static void M117Power(void)
{
prgreg[0]=~3; prgreg[1]=~2; prgreg[2]=~1; prgreg[3]=~0;
Sync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M117Write);
}
static void M117IRQHook(void)
{
if(IRQa==3&&IRQCount)
{
IRQCount--;
if(!IRQCount)
{
IRQa&=1;
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
static void StateRestore(int version)
{
Sync();
}
void Mapper117_Init(CartInfo *info)
{
info->Power=M117Power;
GameHBIRQHook=M117IRQHook;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,117 +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 "mapinc.h"
static uint8 cmd;
static uint8 DRegs[8];
static SFORMAT StateRegs[]=
{
{&cmd, 1, "CMD"},
{DRegs, 8, "DREG"},
{0}
};
static void Sync(void)
{
setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF));
setchr8(0);
}
static void StateRestore(int version)
{
Sync();
}
static DECLFW(Write)
{
switch (A&0x7300)
{
case 0x5100: DRegs[0]=V; Sync(); break;
case 0x5000: DRegs[1]=V; Sync(); break;
}
}
static DECLFW(Write2)
{
// FCEU_printf("bs %04x %02x\n",A,V);
switch (A&0x7300)
{
case 0x5200: DRegs[0]=V; Sync(); break;
case 0x5000: DRegs[1]=V; Sync(); break;
}
}
static uint8 WRAM[8192];
static DECLFR(AWRAM)
{
return(WRAM[A-0x6000]);
}
static DECLFW(BWRAM)
{
WRAM[A-0x6000]=V;
}
static void Power(void)
{
memset(DRegs,0,8);
DRegs[1]=0xFF;
cmd=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4020,0xFFFF,Write);
SetReadHandler(0x6000,0x7FFF,AWRAM);
SetWriteHandler(0x6000,0x7FFF,BWRAM);
Sync();
}
static void M163HB(void)
{
if(scanline==127&&DRegs[1]&0x80)
setchr4(0x0000,1);
}
static void Power2(void)
{
memset(DRegs,0,8);
DRegs[1]=0xFF;
cmd=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x4020,0xFFFF,Write2);
SetReadHandler(0x6000,0x7FFF,AWRAM);
SetWriteHandler(0x6000,0x7FFF,BWRAM);
Sync();
}
void Mapper164_Init(CartInfo *info)
{
info->Power=Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void Mapper163_Init(CartInfo *info)
{
info->Power=Power2;
GameHBIRQHook=M163HB;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,117 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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
*
* Gimmick Bootleg
*/
#include "mapinc.h"
static uint8 prg[4];
static uint8 chr[8];
static uint8 IRQCount;
static uint8 IRQPre;
static uint8 IRQa;
static SFORMAT StateRegs[]=
{
{prg, 4, "PRG"},
{chr, 8, "CHR"},
{&IRQCount, 1, "IRQCOUNT"},
{&IRQPre, 1, "IRQPRE"},
{&IRQa, 1, "IRQA"},
{0}
};
static void SyncPrg(void)
{
setprg8(0x6000,0);
setprg8(0x8000,prg[0]);
setprg8(0xA000,prg[1]);
setprg8(0xC000,prg[2]);
setprg8(0xE000,~0);
}
static void SyncChr(void)
{
int i;
for(i=0; i<8; i++)
setchr1(i<<10,chr[i]);
}
static void StateRestore(int version)
{
SyncPrg();
SyncChr();
}
static DECLFW(M183Write)
{
if(((A&0xF80C)>=0xB000)&&((A&0xF80C)<=0xE00C))
{
uint8 index=(((A>>11)-6)|(A>>3))&7;
chr[index]=(chr[index]&(0xF0>>(A&4)))|((V&0x0F)<<(A&4));
SyncChr();
}
else switch (A&0xF80C)
{
case 0x8800: prg[0]=V; SyncPrg(); break;
case 0xA800: prg[1]=V; SyncPrg(); break;
case 0xA000: prg[2]=V; SyncPrg(); break;
case 0x9800: switch (V&3)
{
case 0: setmirror(MI_V); break;
case 1: setmirror(MI_H); break;
case 2: setmirror(MI_0); break;
case 3: setmirror(MI_1); break;
}
break;
case 0xF000: IRQCount=((IRQCount&0xF0)|(V&0xF)); break;
case 0xF004: IRQCount=((IRQCount&0x0F)|((V&0xF)<<4)); break;
case 0xF008: IRQa=V; if(!V)IRQPre=0; X6502_IRQEnd(FCEU_IQEXT); break;
case 0xF00C: IRQPre=16; break;
}
}
static void M183IRQCounter(void)
{
if(IRQa)
{
IRQCount++;
if((IRQCount-IRQPre)==238)
X6502_IRQBegin(FCEU_IQEXT);
}
}
static void M183Power(void)
{
IRQPre=IRQCount=IRQa=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M183Write);
SetReadHandler(0x6000,0x7FFF,CartBR);
SyncPrg();
SyncChr();
}
void Mapper183_Init(CartInfo *info)
{
info->Power=M183Power;
GameHBIRQHook=M183IRQCounter;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,115 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint8 *DummyCHR=NULL;
static uint8 datareg;
static void(*Sync)(void);
static SFORMAT StateRegs[]=
{
{&datareg, 1, "DREG"},
{0}
};
// on off
//1 0x0F, 0xF0 - Bird Week
//2 0x33, 0x00 - B-Wings
//3 0x11, 0x00 - Mighty Bomb Jack
//4 0x22, 0x20 - Sansuu 1 Nen, Sansuu 2 Nen
//5 0xFF, 0x00 - Sansuu 3 Nen
//6 0x21, 0x13 - Spy vs Spy
//7 0x20, 0x21 - Seicross
static void Sync185(void)
{
// little dirty eh? ;_)
if((datareg&3)&&(datareg!=0x13)) // 1, 2, 3, 4, 5, 6
setchr8(0);
else
setchr8r(0x10,0);
}
static void Sync181(void)
{
if(!(datareg&1)) // 7
setchr8(0);
else
setchr8r(0x10,0);
}
static DECLFW(MWrite)
{
datareg=V;
Sync();
}
static void MPower(void)
{
datareg=0;
Sync();
setprg16(0x8000,0);
setprg16(0xC000,~0);
SetWriteHandler(0x8000,0xFFFF,MWrite);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void MClose(void)
{
if(DummyCHR)
FCEU_gfree(DummyCHR);
DummyCHR=NULL;
}
static void MRestore(int version)
{
Sync();
}
void Mapper185_Init(CartInfo *info)
{
int x;
Sync=Sync185;
info->Power=MPower;
info->Close=MClose;
GameStateRestore=MRestore;
DummyCHR=(uint8*)FCEU_gmalloc(8192);
for(x=0;x<8192;x++)
DummyCHR[x]=0xff;
SetupCartCHRMapping(0x10,DummyCHR,8192,0);
AddExState(StateRegs, ~0, 0, 0);
}
void Mapper181_Init(CartInfo *info)
{
int x;
Sync=Sync181;
info->Power=MPower;
info->Close=MClose;
GameStateRestore=MRestore;
DummyCHR=(uint8*)FCEU_gmalloc(8192);
for(x=0;x<8192;x++)
DummyCHR[x]=0xff;
SetupCartCHRMapping(0x10,DummyCHR,8192,0);
AddExState(StateRegs, ~0, 0, 0);
}

View File

@ -1,104 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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
*
* Family Study Box by Fukutake Shoten
*/
#include "mapinc.h"
static uint8 SWRAM[2816];
static uint8 *WRAM=NULL;
static uint8 regs[4];
static SFORMAT StateRegs[]=
{
{regs, 4, "DREG"},
{SWRAM, 2816, "SWRAM"},
{0}
};
static void Sync(void)
{
setprg8r(0x10,0x6000,regs[0]>>6);
setprg16(0x8000,regs[1]);
setprg16(0xc000,0);
}
static DECLFW(M186Write)
{
if(A&0x4203) regs[A&3]=V;
Sync();
}
static DECLFR(M186Read)
{
switch(A)
{
case 0x4200: return 0x00; break;
case 0x4201: return 0x00; break;
case 0x4202: return 0x40; break;
case 0x4203: return 0x00; break;
}
return 0xFF;
}
static DECLFR(ASWRAM)
{
return(SWRAM[A-0x4400]);
}
static DECLFW(BSWRAM)
{
SWRAM[A-0x4400]=V;
}
static void M186Power(void)
{
setchr8(0);
SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0xFFFF,CartBW);
SetReadHandler(0x4200,0x43FF,M186Read);
SetWriteHandler(0x4200,0x43FF,M186Write);
SetReadHandler(0x4400,0x4EFF,ASWRAM);
SetWriteHandler(0x4400,0x4EFF,BSWRAM);
regs[0]=regs[1]=regs[2]=regs[3];
Sync();
}
static void M186Close(void)
{
if(WRAM)
FCEU_gfree(WRAM);
WRAM=NULL;
}
static void M186Restore(int version)
{
Sync();
}
void Mapper186_Init(CartInfo *info)
{
info->Power=M186Power;
info->Close=M186Close;
GameStateRestore=M186Restore;
WRAM=(uint8*)FCEU_gmalloc(32768);
SetupCartPRGMapping(0x10,WRAM,32768,1);
AddExState(WRAM, 32768, 0, "WRAM");
AddExState(StateRegs, ~0, 0, 0);
}

View File

@ -1,105 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
#include "../sound.h"
static void M187CW(uint32 A, uint8 V)
{
if((A&0x1000)==((MMC3_cmd&0x80)<<5))
setchr1(A,V|0x100);
else
setchr1(A,V);
}
static void M187PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x80)
{
uint8 bank=EXPREGS[0]&0x1F;
if(EXPREGS[0]&0x20)
setprg32(0x8000,bank>>2);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(M187Write8000)
{
EXPREGS[2]=1;
MMC3_CMDWrite(A,V);
}
static DECLFW(M187Write8001)
{
if(EXPREGS[2])
MMC3_CMDWrite(A,V);
}
static DECLFW(M187Write8003)
{
EXPREGS[2]=0;
if(V==0x28)setprg8(0xC000,0x17);
else if(V==0x2A)setprg8(0xA000,0x0F);
}
static DECLFW(M187WriteLo)
{
EXPREGS[1]=V;
if(A==0x5000)
{
EXPREGS[0]=V;
FixMMC3PRG(MMC3_cmd);
}
}
static uint8 prot_data[4] = { 0x83, 0x83, 0x42, 0x00 };
static DECLFR(M187Read)
{
return prot_data[EXPREGS[1]&3];
}
static void M187Power(void)
{
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0;
GenMMC3Power();
Write_IRQFM(0x4017,0x40);
SetReadHandler(0x5000,0x5FFF,M187Read);
SetWriteHandler(0x5000,0x5FFF,M187WriteLo);
SetWriteHandler(0x8000,0x8000,M187Write8000);
SetWriteHandler(0x8001,0x8001,M187Write8001);
SetWriteHandler(0x8003,0x8003,M187Write8003);
}
void Mapper187_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
pwrap=M187PW;
cwrap=M187CW;
info->Power=M187Power;
AddExState(EXPREGS, 3, 0, "EXPR");
}

View File

@ -1,48 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
static void M189PW(uint32 A, uint8 V)
{
setprg32(0x8000,EXPREGS[0]&3);
}
static DECLFW(M189Write)
{
EXPREGS[0]=V|(V>>4); //actually, there is a two versions of 189 mapper with hi or lo bits bankswitching.
FixMMC3PRG(MMC3_cmd);
}
static void M189Power(void)
{
EXPREGS[0]=EXPREGS[1]=0;
GenMMC3Power();
SetWriteHandler(0x4120,0x7FFF,M189Write);
}
void Mapper189_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
pwrap=M189PW;
info->Power=M189Power;
AddExState(EXPREGS, 2, 0, "EXPR");
}

View File

@ -1,95 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 CaH4e3
*
* 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
*
* Dragon Ball Z 2 - Gekishin Freeza! (C)
* Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C)
* San Guo Zhi 2 (C)
*
*/
#include "mapinc.h"
#include "mmc3.h"
static void M199PW(uint32 A, uint8 V)
{
setprg8(A,V);
setprg8(0xC000,EXPREGS[0]);
setprg8(0xE000,EXPREGS[1]);
}
static void M199CW(uint32 A, uint8 V)
{
setchr1r((V<8)?0x10:0x00,A,V);
setchr1r((DRegBuf[0]<8)?0x10:0x00,0x0000,DRegBuf[0]);
setchr1r((EXPREGS[2]<8)?0x10:0x00,0x0400,EXPREGS[2]);
setchr1r((DRegBuf[1]<8)?0x10:0x00,0x0800,DRegBuf[1]);
setchr1r((EXPREGS[3]<8)?0x10:0x00,0x0c00,EXPREGS[3]);
}
static void M199MW(uint8 V)
{
// FCEU_printf("%02x\n",V);
switch(V&3)
{
case 0: setmirror(MI_V); break;
case 1: setmirror(MI_H); break;
case 2: setmirror(MI_0); break;
case 3: setmirror(MI_1); break;
}
}
static DECLFW(M199Write)
{
if((A==0x8001)&&(MMC3_cmd&8))
{
// FCEU_printf("%02x=>%02x\n",MMC3_cmd,V);
EXPREGS[MMC3_cmd&3]=V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
else
if(A<0xC000)
MMC3_CMDWrite(A,V);
else
MMC3_IRQWrite(A,V);
}
static void M199Power(void)
{
EXPREGS[0]=~1;
EXPREGS[1]=~0;
EXPREGS[2]=1;
EXPREGS[3]=3;
GenMMC3Power();
SetWriteHandler(0x8000,0xFFFF,M199Write);
}
void Mapper199_Init(CartInfo *info)
{
int CHRRAMSize=1024*8;
GenMMC3_Init(info, 512, 256, 8, info->battery);
cwrap=M199CW;
pwrap=M199PW;
mwrap=M199MW;
info->Power=M199Power;
CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize);
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1);
AddExState(CHRRAM, CHRRAMSize, 0, "CHRR");
AddExState(EXPREGS, 4, 0, "EXPR");
}

View File

@ -1,83 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
static uint8 lut[256]={
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01,
0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08,
0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00,
0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void M208PW(uint32 A, uint8 V)
{
setprg32(0x8000,EXPREGS[5]);
}
static DECLFW(M208Write)
{
EXPREGS[5]=(V&0x1)|((V>>3)&0x2);
FixMMC3PRG(MMC3_cmd);
}
static DECLFW(M208ProtWrite)
{
if(A<=0x57FF)
EXPREGS[4]=V;
else
EXPREGS[(A&0x03)]=V^lut[EXPREGS[4]];
}
static DECLFR(M208ProtRead)
{
return(EXPREGS[(A&0x3)]);
}
static void M208Power(void)
{
EXPREGS[5]=3;
GenMMC3Power();
SetWriteHandler(0x4800,0x4FFF,M208Write);
SetWriteHandler(0x5000,0x5fff,M208ProtWrite);
SetReadHandler(0x5800,0x5FFF,M208ProtRead);
SetReadHandler(0x8000,0xffff,CartBR);
}
void Mapper208_Init(CartInfo *info)
{
GenMMC3_Init(info, 128, 256, 0, 0);
pwrap=M208PW;
info->Power=M208Power;
AddExState(EXPREGS, 6, 0, "EXPR");
}

View File

@ -1,103 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint8 IRQCount, IRQPre;
static uint8 IRQa;
static uint8 prg_reg[2];
static uint8 chr_reg[8];
static SFORMAT StateRegs[]=
{
{&IRQCount, 1, "IRQC"},
{&IRQa, 1, "IRQA"},
{prg_reg, 2, "PRG"},
{chr_reg, 8, "CHR"},
{0}
};
static void M222IRQ(void)
{
if(IRQa)
{
IRQCount++;
if((IRQCount)>=240)
{
X6502_IRQBegin(FCEU_IQEXT);
IRQa=0;
}
}
}
static void Sync(void)
{
int i;
setprg8(0x8000,prg_reg[0]);
setprg8(0xA000,prg_reg[1]);
for(i=0; i<8; i++)
setchr1(i<<10,chr_reg[i]);
}
static DECLFW(M222Write)
{
switch(A&0xF003)
{
case 0x8000: prg_reg[0]=V; break;
case 0xA000: prg_reg[1]=V; break;
case 0xB000: chr_reg[0]=V; break;
case 0xB002: chr_reg[1]=V; break;
case 0xC000: chr_reg[2]=V; break;
case 0xC002: chr_reg[3]=V; break;
case 0xD000: chr_reg[4]=V; break;
case 0xD002: chr_reg[5]=V; break;
case 0xE000: chr_reg[6]=V; break;
case 0xE002: chr_reg[7]=V; break;
// case 0xF000: FCEU_printf("%04x:%02x %d\n",A,V,scanline); IRQa=V; if(!V)IRQPre=0; X6502_IRQEnd(FCEU_IQEXT); break;
// / case 0xF001: FCEU_printf("%04x:%02x %d\n",A,V,scanline); IRQCount=V; break;
// case 0xF002: FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;
// case 0xD001: IRQa=V; X6502_IRQEnd(FCEU_IQEXT); FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;
case 0xC001: IRQPre=0; FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;
case 0xF000: IRQPre=8; IRQCount=V; IRQa=V; X6502_IRQEnd(FCEU_IQEXT); FCEU_printf("%04x:%02x %d\n",A,V,scanline); break;
default: FCEU_printf("%04x:%02x %d\n",A,V,scanline);
}
Sync();
}
static void M222Power(void)
{
setprg16(0xC000,~0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M222Write);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper222_Init(CartInfo *info)
{
info->Power=M222Power;
GameHBIRQHook=M222IRQ;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,70 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint16 cmdreg;
static SFORMAT StateRegs[]=
{
{&cmdreg, 2, "CMDREG"},
{0}
};
static void Sync(void)
{
if(cmdreg&0x400)
setmirror(MI_0);
else
setmirror(((cmdreg>>13)&1)^1);
if(cmdreg&0x800)
{
setprg16(0x8000,((cmdreg&0x300)>>3)|((cmdreg&0x1F)<<1)|((cmdreg>>12)&1));
setprg16(0xC000,((cmdreg&0x300)>>3)|((cmdreg&0x1F)<<1)|((cmdreg>>12)&1));
}
else
setprg32(0x8000,((cmdreg&0x300)>>4)|(cmdreg&0x1F));
}
static DECLFW(M235Write)
{
cmdreg=A;
Sync();
}
static void M235Power(void)
{
setchr8(0);
SetWriteHandler(0x8000,0xFFFF,M235Write);
SetReadHandler(0x8000,0xFFFF,CartBR);
cmdreg=0;
Sync();
}
static void M235Restore(int version)
{
Sync();
}
void Mapper235_Init(CartInfo *info)
{
info->Power=M235Power;
GameStateRestore=M235Restore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,91 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 CaH4e3
*
* 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 "mapinc.h"
static uint8 reg;
static uint8 IRQCount, IRQa;
static SFORMAT StateRegs[]=
{
{&IRQCount, 1, "IRQC"},
{&IRQa, 1, "IRQA"},
{&reg, 1, "REG"},
{0}
};
static void Sync(void)
{
setprg4(0x5000,16);
setprg8(0x6000,2);
setprg8(0x8000,1);
setprg8(0xa000,0);
setprg8(0xc000,reg);
setprg8(0xe000,9);
setchr8(0);
}
static DECLFW(M43Write)
{
int transo[8]={4,3,4,4,4,7,5,6};
switch(A&0xf1ff)
{
case 0x4022: reg=transo[V&7]; Sync(); break;
case 0x8122: IRQa=V&1; IRQCount=0; break;
}
}
static void M43Power(void)
{
reg=0;
Sync();
// SetReadHandler(0x5000,0x5fff,CartBR);
SetReadHandler(0x5000,0xffff,CartBR);
SetWriteHandler(0x4020,0xffff,M43Write);
}
static void M43Reset(void)
{
}
static void FP_FASTAPASS(1) M43IRQHook(int a)
{
IRQCount+=a;
if(IRQa)
if(IRQCount>=4096)
{
IRQa=0;
X6502_IRQBegin(FCEU_IQEXT);
}
}
static void StateRestore(int version)
{
Sync();
}
void Mapper43_Init(CartInfo *info)
{
info->Reset=M43Reset;
info->Power=M43Power;
MapIRQHook=M43IRQHook;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,92 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint8 prg_reg;
static uint8 chr_reg;
static uint8 hrd_flag;
static SFORMAT StateRegs[]=
{
{&hrd_flag, 1, "DIPSW"},
{&prg_reg, 1, "PRG"},
{&chr_reg, 1, "CHR"},
{0}
};
static void Sync(void)
{
if(prg_reg&0x80)
setprg32(0x8000,prg_reg>>6);
else
{
setprg16(0x8000,(prg_reg>>5)&3);
setprg16(0xC000,(prg_reg>>5)&3);
}
setmirror((prg_reg&8)>>3);
setchr8((chr_reg&3)|(prg_reg&7)|((prg_reg&0x10)>>1));
}
static DECLFR(M57Read)
{
return hrd_flag;
}
static DECLFW(M57Write)
{
if((A&0x8800)==0x8800)
prg_reg=V;
else
chr_reg=V;
Sync();
}
static void M57Power(void)
{
prg_reg=0;
chr_reg=0;
hrd_flag=0;
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M57Write);
SetReadHandler(0x6000,0x6000,M57Read);
Sync();
}
static void M57Reset()
{
hrd_flag++;
hrd_flag&=3;
FCEU_printf("Select Register = %02x\n",hrd_flag);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper57_Init(CartInfo *info)
{
info->Power=M57Power;
info->Reset=M57Reset;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,48 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
static uint8 lut[4] = { 0x00, 0x02, 0x02, 0x03 };
static DECLFW(UNL6035052ProtWrite)
{
EXPREGS[0]=lut[V&3];
}
static DECLFR(UNL6035052ProtRead)
{
return EXPREGS[0];
}
static void UNL6035052Power(void)
{
GenMMC3Power();
SetWriteHandler(0x4020,0x7FFF,UNL6035052ProtWrite);
SetReadHandler(0x4020,0x7FFF,UNL6035052ProtRead);
}
void UNL6035052_Init(CartInfo *info)
{
GenMMC3_Init(info, 128, 256, 0, 0);
info->Power=UNL6035052Power;
AddExState(EXPREGS, 6, 0, "EXPR");
}

View File

@ -1,81 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint16 cmdreg;
static uint8 invalid_data;
static SFORMAT StateRegs[]=
{
{&invalid_data, 1, "INVD"},
{&cmdreg, 2, "CMDREG"},
{0}
};
static void Sync(void)
{
setprg16r((cmdreg&0x060)>>5,0x8000,(cmdreg&0x01C)>>2);
setprg16r((cmdreg&0x060)>>5,0xC000,(cmdreg&0x200)?(~0):0);
setmirror(((cmdreg&2)>>1)^1);
}
static DECLFR(UNL8157Read)
{
if(invalid_data&&cmdreg&0x100)
return 0xFF;
else
return CartBR(A);
}
static DECLFW(UNL8157Write)
{
cmdreg=A;
Sync();
}
static void UNL8157Power(void)
{
setchr8(0);
SetWriteHandler(0x8000,0xFFFF,UNL8157Write);
SetReadHandler(0x8000,0xFFFF,UNL8157Read);
cmdreg=0x200;
invalid_data=1;
Sync();
}
static void UNL8157Reset(void)
{
cmdreg=0;
invalid_data^=1;
Sync();
}
static void UNL8157Restore(int version)
{
Sync();
}
void UNL8157_Init(CartInfo *info)
{
info->Power=UNL8157Power;
info->Reset=UNL8157Reset;
GameStateRestore=UNL8157Restore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,93 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
static uint8 cmdin;
static uint8 UNL8237_perm[8] = {0, 2, 6, 1, 7, 3, 4, 5};
static void UNL8237CW(uint32 A, uint8 V)
{
setchr1(A,((EXPREGS[1]&4)<<6)|V);
}
static void UNL8237PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x80)
{
if(EXPREGS[0]&0x20)
setprg32(0x8000,(EXPREGS[0]&0xF)>>1);
else
{
setprg16(0x8000,(EXPREGS[0]&0x1F));
setprg16(0xC000,(EXPREGS[0]&0x1F));
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(UNL8237Write)
{
if((A&0xF000)==0xF000)
IRQCount=V;
else if((A&0xF000)==0xE000)
X6502_IRQEnd(FCEU_IQEXT);
else switch(A&0xE001)
{
case 0x8000: setmirror(((V|(V>>7))&1)^1); break;
case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(UNL8237_perm[V&7])); cmdin=1; break;
case 0xC000: if(cmdin)
{
MMC3_CMDWrite(0x8001,V);
cmdin=0;
}
break;
}
}
static DECLFW(UNL8237ExWrite)
{
switch(A)
{
case 0x5000: EXPREGS[0]=V; FixMMC3PRG(MMC3_cmd); break;
case 0x5001: EXPREGS[1]=V; FixMMC3CHR(MMC3_cmd); break;
}
}
static void UNL8237Power(void)
{
IRQa=1;
EXPREGS[0]=EXPREGS[1]=0;
GenMMC3Power();
SetWriteHandler(0x8000,0xFFFF,UNL8237Write);
SetWriteHandler(0x5000,0x7FFF,UNL8237ExWrite);
}
void UNL8237_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
cwrap=UNL8237CW;
pwrap=UNL8237PW;
info->Power=UNL8237Power;
AddExState(EXPREGS, 3, 0, "EXPR");
AddExState(&cmdin, 1, 0, "CMDIN");
}

View File

@ -1,87 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint8 reg[8];
static uint8 mirror, cmd, is154;
static SFORMAT StateRegs[]=
{
{&cmd, 1, "CMD"},
{&mirror, 1, "MIRR"},
{reg, 8, "REGS"},
{0}
};
static void Sync(void)
{
setchr2(0x0000,reg[0]>>1);
setchr2(0x0800,reg[1]>>1);
setchr1(0x1000,reg[2]|0x40);
setchr1(0x1400,reg[3]|0x40);
setchr1(0x1800,reg[4]|0x40);
setchr1(0x1C00,reg[5]|0x40);
setprg8(0x8000,reg[6]);
setprg8(0xA000,reg[7]);
}
static void MSync(void)
{
if(is154)setmirror(MI_0+(mirror&1));
}
static DECLFW(M88Write)
{
switch(A&0x8001)
{
case 0x8000: cmd=V&7; mirror=V>>6; MSync(); break;
case 0x8001: reg[cmd]=V; Sync(); break;
}
}
static void M88Power(void)
{
setprg16(0xC000,~0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M88Write);
}
static void StateRestore(int version)
{
Sync();
MSync();
}
void Mapper88_Init(CartInfo *info)
{
is154=0;
info->Power=M88Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void Mapper154_Init(CartInfo *info)
{
is154=1;
info->Power=M88Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,512 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#define DEBUG90
// Mapper 090 is simpliest mapper hardware and have not extended nametable control and latched chr banks in 4k mode
// Mapper 209 much compicated hardware with decribed above features disabled by default and switchable by command
// Mapper 211 the same mapper 209 but with forced nametable control
static int is209;
static int is211;
static uint8 IRQMode; // from $c001
static uint8 IRQPre; // from $c004
static uint8 IRQPreSize; // from $c007
static uint8 IRQCount; // from $c005
static uint8 IRQXOR; // Loaded from $C006
static uint8 IRQa; // $c002, $c003, and $c000
static uint8 mul[2];
static uint8 regie;
static uint8 regie2;
static uint8 tkcom[4];
static uint8 prgb[4];
static uint8 chrlow[8];
static uint8 chrhigh[8];
static uint8 chr[2];
static uint16 names[4];
static uint8 tekker;
static SFORMAT Tek_StateRegs[]={
{&IRQMode, 1, "IRQMODE"},
{&IRQPre, 1, "IRQPRE"},
{&IRQPreSize, 1, "IRQPRESIZE"},
{&IRQCount, 1, "IRQC"},
{&IRQXOR, 1, "IRQXOR"},
{&IRQa, 1, "IRQa"},
{mul, 2, "MUL"},
{&regie, 1, "REGI"},
{tkcom, 4, "TKCO"},
{prgb, 4, "PRGB"},
{chr, 2, "CHRLATCH"},
{chrlow, 4, "CHRL"},
{chrhigh, 8, "CHRH"},
{&names[0], 2|FCEUSTATE_RLSB, "NMS0"},
{&names[1], 2|FCEUSTATE_RLSB, "NMS1"},
{&names[2], 2|FCEUSTATE_RLSB, "NMS2"},
{&names[3], 2|FCEUSTATE_RLSB, "NMS3"},
{&tekker, 1, "TEKR"},
{0}
};
static void mira(void)
{
if((tkcom[0]&0x20&&is209)||is211)
{
int x;
if(tkcom[0]&0x40) // Name tables are ROM-only
{
for(x=0;x<4;x++)
setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10),0,x);
}
else // Name tables can be RAM or ROM.
{
for(x=0;x<4;x++)
{
if((tkcom[1]&0x80)==(names[x]&0x80)) // RAM selected.
setntamem(NTARAM+((names[x]&0x1)<<10),1,x);
else
setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10),0,x);
}
}
}
else
{
switch(tkcom[1]&3)
{
case 0: setmirror(MI_V); break;
case 1: setmirror(MI_H); break;
case 2: setmirror(MI_0); break;
case 3: setmirror(MI_1); break;
}
}
}
static void tekprom(void)
{
uint32 bankmode=((tkcom[3]&6)<<5);
switch(tkcom[0]&7)
{
case 00: if(tkcom[0]&0x80)
setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode);
setprg32(0x8000,0x0F|((tkcom[3]&6)<<3));
break;
case 01: if(tkcom[0]&0x80)
setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode);
setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4));
setprg16(0xC000,0x1F|((tkcom[3]&6)<<4));
break;
case 03: // bit reversion
case 02: if(tkcom[0]&0x80)
setprg8(0x6000,(prgb[3]&0x3F)|bankmode);
setprg8(0x8000,(prgb[0]&0x3F)|bankmode);
setprg8(0xa000,(prgb[1]&0x3F)|bankmode);
setprg8(0xc000,(prgb[2]&0x3F)|bankmode);
setprg8(0xe000,0x3F|bankmode);
break;
case 04: if(tkcom[0]&0x80)
setprg8(0x6000,(((prgb[3]<<2)+3)&0x3F)|bankmode);
setprg32(0x8000,(prgb[3]&0x0F)|((tkcom[3]&6)<<3));
break;
case 05: if(tkcom[0]&0x80)
setprg8(0x6000,(((prgb[3]<<1)+1)&0x3F)|bankmode);
setprg16(0x8000,(prgb[1]&0x1F)|((tkcom[3]&6)<<4));
setprg16(0xC000,(prgb[3]&0x1F)|((tkcom[3]&6)<<4));
break;
case 07: // bit reversion
case 06: if(tkcom[0]&0x80)
setprg8(0x6000,(prgb[3]&0x3F)|bankmode);
setprg8(0x8000,(prgb[0]&0x3F)|bankmode);
setprg8(0xa000,(prgb[1]&0x3F)|bankmode);
setprg8(0xc000,(prgb[2]&0x3F)|bankmode);
setprg8(0xe000,(prgb[3]&0x3F)|bankmode);
break;
}
}
static void tekvrom(void)
{
int x, bank=0, mask=0xFFFF;
if(!(tkcom[3]&0x20))
{
bank=(tkcom[3]&1)|((tkcom[3]&0x18)>>2);
switch (tkcom[0]&0x18)
{
case 0x00: bank<<=5; mask=0x1F; break;
case 0x08: bank<<=6; mask=0x3F; break;
case 0x10: bank<<=7; mask=0x7F; break;
case 0x18: bank<<=8; mask=0xFF; break;
}
}
switch(tkcom[0]&0x18)
{
case 0x00: // 8KB
setchr8(((chrlow[0]|(chrhigh[0]<<8))&mask)|bank);
break;
case 0x08: // 4KB
// for(x=0;x<8;x+=4)
// setchr4(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank);
setchr4(0x0000,((chrlow[chr[0]]|(chrhigh[chr[0]]<<8))&mask)|bank);
setchr4(0x1000,((chrlow[chr[1]]|(chrhigh[chr[1]]<<8))&mask)|bank);
break;
case 0x10: // 2KB
for(x=0;x<8;x+=2)
setchr2(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank);
break;
case 0x18: // 1KB
for(x=0;x<8;x++)
setchr1(x<<10,((chrlow[x]|(chrhigh[x]<<8))&mask)|bank);
break;
}
}
static DECLFW(M90TekWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
switch(A&0x5805)
{
case 0x5800: mul[0]=V; break;
case 0x5801: mul[1]=V; break;
case 0x5803: regie=V; break;
// case 0x5803: regie2=V; break;
// default: regie=V; break;
}
}
static DECLFR(M90TekRead)
{
switch(A&0x5805)
{
case 0x5000: return tekker;
case 0x5800: return (mul[0]*mul[1]);
case 0x5801: return((mul[0]*mul[1])>>8);
case 0x5803: return (regie);
// case 0x5804: return (regie2);
}
return(0xff);
}
static DECLFW(M90PRGWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
prgb[A&3]=V;
tekprom();
}
static DECLFW(M90CHRlowWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
chrlow[A&7]=V;
tekvrom();
}
static DECLFW(M90CHRhiWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
chrhigh[A&7]=V;
tekvrom();
}
static DECLFW(M90NTWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
if(A&4)
{
names[A&3]&=0x00FF;
names[A&3]|=V<<8;
}
else
{
names[A&3]&=0xFF00;
names[A&3]|=V;
}
mira();
}
static DECLFW(M90IRQWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
switch(A&7)
{
case 00: //FCEU_printf("%s IRQ (C000)\n",V&1?"Enable":"Disable");
IRQa=V&1;if(!(V&1)) X6502_IRQEnd(FCEU_IQEXT);break;
case 02: //FCEU_printf("Disable IRQ (C002) scanline=%d\n", scanline);
IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break;
case 03: //FCEU_printf("Enable IRQ (C003) scanline=%d\n", scanline);
IRQa=1;break;
case 01: IRQMode=V;
// FCEU_printf("IRQ Count method: ");
// switch (IRQMode&3)
// {
// case 00: FCEU_printf("M2 cycles\n");break;
// case 01: FCEU_printf("PPU A12 toggles\n");break;
// case 02: FCEU_printf("PPU reads\n");break;
// case 03: FCEU_printf("Writes to CPU space\n");break;
// }
// FCEU_printf("Counter prescaler size: %s\n",(IRQMode&4)?"3 bits":"8 bits");
// FCEU_printf("Counter prescaler size adjust: %s\n",(IRQMode&8)?"Used C007":"Normal Operation");
// if((IRQMode>>6)==2) FCEU_printf("Counter Down\n");
// else if((IRQMode>>6)==1) FCEU_printf("Counter Up\n");
// else FCEU_printf("Counter Stopped\n");
break;
case 04: //FCEU_printf("Pre Counter Loaded and Xored wiht C006: %d\n",V^IRQXOR);
IRQPre=V^IRQXOR;break;
case 05: //FCEU_printf("Main Counter Loaded and Xored wiht C006: %d\n",V^IRQXOR);
IRQCount=V^IRQXOR;break;
case 06: //FCEU_printf("Xor Value: %d\n",V);
IRQXOR=V;break;
case 07: //if(!(IRQMode&8)) FCEU_printf("C001 is clear, no effect applied\n");
// else if(V==0xFF) FCEU_printf("Prescaler is changed for 12bits\n");
// else FCEU_printf("Counter Stopped\n");
IRQPreSize=V;break;
}
}
static DECLFW(M90ModeWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
tkcom[A&3]=V;
tekprom();
tekvrom();
mira();
#ifdef DEBUG90
switch (A&3)
{
case 00: FCEU_printf("Main Control Register:\n");
FCEU_printf(" PGR Banking mode: %d\n",V&7);
FCEU_printf(" CHR Banking mode: %d\n",(V>>3)&3);
FCEU_printf(" 6000-7FFF addresses mapping: %s\n",(V&0x80)?"Yes":"No");
FCEU_printf(" Nametable control: %s\n",(V&0x20)?"Enabled":"Disabled");
if(V&0x20)
FCEU_printf(" Nametable can be: %s\n",(V&0x40)?"ROM Only":"RAM or ROM");
break;
case 01: FCEU_printf("Mirroring mode: ");
switch (V&3)
{
case 0: FCEU_printf("Vertical\n");break;
case 1: FCEU_printf("Horizontal\n");break;
case 2: FCEU_printf("Nametable 0 only\n");break;
case 3: FCEU_printf("Nametable 1 only\n");break;
}
FCEU_printf("Mirroring flag: %s\n",(V&0x80)?"On":"Off");
break;
case 02: if((((tkcom[0])>>5)&3)==1)
FCEU_printf("Nametable ROM/RAM select mode: %d\n",V>>7);
break;
case 03:
FCEU_printf("CHR Banking mode: %s\n",(V&0x20)?"Entire CHR ROM":"256Kb Switching mode");
if(!(V&0x20)) FCEU_printf("256K CHR bank number: %02x\n",(V&1)|((V&0x18)>>2));
FCEU_printf("512K PRG bank number: %d\n",(V&6)>>1);
FCEU_printf("CHR Bank mirroring: %s\n",(V&0x80)?"Swapped":"Normal operate");
}
#endif
}
static DECLFW(M90DummyWrite)
{
FCEU_printf("bs %04x %02x\n",A,V);
}
static void CCL(void)
{
if((IRQMode>>6) == 1) // Count Up
{
IRQCount++;
if((IRQCount == 0) && IRQa)
{
X6502_IRQBegin(FCEU_IQEXT);
}
}
else if((IRQMode>>6) == 2) // Count down
{
IRQCount--;
if((IRQCount == 0xFF) && IRQa)
{
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
static void ClockCounter(void)
{
uint8 premask;
if(IRQMode & 0x4)
premask = 0x7;
else
premask = 0xFF;
if((IRQMode>>6) == 1) // Count up
{
IRQPre++;
if((IRQPre & premask) == 0) CCL();
}
else if((IRQMode>>6) == 2) // Count down
{
IRQPre--;
if((IRQPre & premask) == premask) CCL();
}
}
void FP_FASTAPASS(1) CPUWrap(int a)
{
int x;
if((IRQMode&3)==0) for(x=0;x<a;x++) ClockCounter();
}
static void SLWrap(void)
{
int x;
if((IRQMode&3)==1) for(x=0;x<8;x++) ClockCounter();
}
static uint32 lastread;
static void FP_FASTAPASS(1) M90PPU(uint32 A)
{
if((IRQMode&3)==2)
{
if(lastread!=A)
{
ClockCounter();
ClockCounter();
}
lastread=A;
}
if(is209)
{
uint8 l,h;
h=A>>8;
if(h<0x20&&((h&0x0F)==0xF))
{
l=A&0xF0;
if(l==0xD0)
{
chr[(h&0x10)>>4]=((h&0x10)>>2);
tekvrom();
}
else if(l==0xE0)
{
chr[(h&0x10)>>4]=((h&0x10)>>2)|2;
tekvrom();
}
}
}
else
{
chr[0]=0;
chr[1]=4;
}
}
static void togglie()
{
tekker+=0x40;
tekker&=0xC0;
FCEU_printf("tekker=%02x\n",tekker);
memset(tkcom,0x00,sizeof(tkcom));
memset(prgb,0xff,sizeof(prgb));
tekprom();
tekvrom();
}
static void M90Restore(int version)
{
tekprom();
tekvrom();
mira();
}
static void M90Power(void)
{
SetWriteHandler(0x5000,0x5fff,M90TekWrite);
SetWriteHandler(0x8000,0x8ff0,M90PRGWrite);
SetWriteHandler(0x9000,0x9fff,M90CHRlowWrite);
SetWriteHandler(0xA000,0xAfff,M90CHRhiWrite);
SetWriteHandler(0xB000,0xBfff,M90NTWrite);
SetWriteHandler(0xC000,0xCfff,M90IRQWrite);
SetWriteHandler(0xD000,0xD5ff,M90ModeWrite);
SetWriteHandler(0xE000,0xFfff,M90DummyWrite);
SetReadHandler(0x5000,0x5fff,M90TekRead);
SetReadHandler(0x6000,0xffff,CartBR);
mul[0]=mul[1]=regie=0xFF;
memset(tkcom,0x00,sizeof(tkcom));
memset(prgb,0xff,sizeof(prgb));
memset(chrlow,0xff,sizeof(chrlow));
memset(chrhigh,0xff,sizeof(chrhigh));
memset(names,0x00,sizeof(names));
if(is211)
tekker=0xC0;
else
tekker=0x00;
tekprom();
tekvrom();
}
void Mapper90_Init(CartInfo *info)
{
is211=0;
is209=0;
info->Reset=togglie;
info->Power=M90Power;
PPU_hook=M90PPU;
MapIRQHook=CPUWrap;
GameHBIRQHook2=SLWrap;
GameStateRestore=M90Restore;
AddExState(Tek_StateRegs, ~0, 0, 0);
}
void Mapper209_Init(CartInfo *info)
{
is211=0;
is209=1;
info->Reset=togglie;
info->Power=M90Power;
PPU_hook=M90PPU;
MapIRQHook=CPUWrap;
GameHBIRQHook2=SLWrap;
GameStateRestore=M90Restore;
AddExState(Tek_StateRegs, ~0, 0, 0);
}
void Mapper211_Init(CartInfo *info)
{
is211=1;
info->Reset=togglie;
info->Power=M90Power;
PPU_hook=M90PPU;
MapIRQHook=CPUWrap;
GameHBIRQHook2=SLWrap;
GameStateRestore=M90Restore;
AddExState(Tek_StateRegs, ~0, 0, 0);
}

View File

@ -1,125 +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 "mapinc.h"
#include "../ines.h"
static uint8 lastA;
static uint8 DRegs[8];
static uint8 cmd;
static uint8 MirCache[8];
static SFORMAT DB_StateRegs[]={
{DRegs, 8, "DREG"},
{&cmd, 1, "CMD"},
{&lastA, 1, "LAST"},
{0}
};
static void toot(void)
{
int x;
MirCache[0]=MirCache[1]=(DRegs[0]>>4)&1;
MirCache[2]=MirCache[3]=(DRegs[1]>>4)&1;
for(x=0;x<4;x++)
MirCache[4+x]=(DRegs[2+x]>>5)&1;
onemir(MirCache[lastA]);
}
static void Sync()
{
setchr2(0x0000,DRegs[0]&0x1F);
setchr2(0x0800,DRegs[1]&0x1F);
setchr1(0x1000,DRegs[2]&0x1F);
setchr1(0x1400,DRegs[3]&0x1F);
setchr1(0x1800,DRegs[4]&0x1F);
setchr1(0x1C00,DRegs[5]&0x1F);
setprg8(0x8000,DRegs[6]&0x1F);
setprg8(0xa000,DRegs[7]&0x1F);
toot();
}
static DECLFW(Mapper95_write)
{
switch(A&0xF001)
{
case 0x8000: cmd = V; break;
case 0x8001:
switch(cmd&0x07)
{
case 0: DRegs[0]=(V&0x3F)>>1; break;
case 1: DRegs[1]=(V&0x3F)>>1; break;
case 2: DRegs[2]=V&0x3F; break;
case 3: DRegs[3]=V&0x3F; break;
case 4: DRegs[4]=V&0x3F; break;
case 5: DRegs[5]=V&0x3F; break;
case 6: DRegs[6]=V&0x3F; break;
case 7: DRegs[7]=V&0x3F; break;
}
Sync();
}
}
static void FP_FASTAPASS(1) dragonbust_ppu(uint32 A)
{
static int last=-1;
static uint8 z;
if(A>=0x2000) return;
A>>=10;
lastA=A;
z=MirCache[A];
if(z!=last)
{
onemir(z);
last=z;
}
}
static void DBPower(void)
{
memset(DRegs,0x3F,8);
DRegs[0]=DRegs[1]=0x1F;
Sync();
setprg8(0xc000,0x3E);
setprg8(0xe000,0x3F);
SetReadHandler(0x8000,0xffff,CartBR);
SetWriteHandler(0x8000,0xffff,Mapper95_write);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper95_Init(CartInfo *info)
{
info->Power=DBPower;
AddExState(DB_StateRegs, ~0, 0, 0);
PPU_hook=dragonbust_ppu;
GameStateRestore=StateRestore;
}

View File

@ -1,55 +0,0 @@
fceu_SOURCES += boards/01-222.cpp
fceu_SOURCES += boards/112.cpp
fceu_SOURCES += boards/117.cpp
fceu_SOURCES += boards/164.cpp
fceu_SOURCES += boards/183.cpp
fceu_SOURCES += boards/185.cpp
fceu_SOURCES += boards/186.cpp
fceu_SOURCES += boards/187.cpp
fceu_SOURCES += boards/189.cpp
fceu_SOURCES += boards/199.cpp
fceu_SOURCES += boards/208.cpp
fceu_SOURCES += boards/222.cpp
fceu_SOURCES += boards/235.cpp
fceu_SOURCES += boards/43.cpp
fceu_SOURCES += boards/57.cpp
fceu_SOURCES += boards/603-5052.cpp
fceu_SOURCES += boards/8157.cpp
fceu_SOURCES += boards/8237.cpp
fceu_SOURCES += boards/88.cpp
fceu_SOURCES += boards/90.cpp
fceu_SOURCES += boards/95.cpp
fceu_SOURCES += boards/__dummy_mapper.cpp
fceu_SOURCES += boards/a9711.cpp
fceu_SOURCES += boards/addrlatch.cpp
fceu_SOURCES += boards/bmc13in1jy110.cpp
fceu_SOURCES += boards/bmc42in1r.cpp
fceu_SOURCES += boards/bmc64in1nr.cpp
fceu_SOURCES += boards/bmc70in1.cpp
fceu_SOURCES += boards/bonza.cpp
fceu_SOURCES += boards/datalatch.cpp
fceu_SOURCES += boards/deirom.cpp
fceu_SOURCES += boards/dream.cpp
fceu_SOURCES += boards/edu2000.cpp
fceu_SOURCES += boards/fk23c.cpp
fceu_SOURCES += boards/h2288.cpp
fceu_SOURCES += boards/karaoke.cpp
fceu_SOURCES += boards/kof97.cpp
fceu_SOURCES += boards/konami-qtai.cpp
fceu_SOURCES += boards/malee.cpp
fceu_SOURCES += boards/mapinc.h"
fceu_SOURCES += boards/mmc1.cpp
fceu_SOURCES += boards/mmc3.cpp
fceu_SOURCES += boards/mmc3.h"
fceu_SOURCES += boards/mmc5.cpp
fceu_SOURCES += boards/n-c22m.cpp
fceu_SOURCES += boards/n106.cpp
fceu_SOURCES += boards/novel.cpp
fceu_SOURCES += boards/sachen.cpp
fceu_SOURCES += boards/sheroes.cpp
fceu_SOURCES += boards/sl1632.cpp
fceu_SOURCES += boards/subor.cpp
fceu_SOURCES += boards/super24.cpp
fceu_SOURCES += boards/supervision.cpp
fceu_SOURCES += boards/t-262.cpp
fceu_SOURCES += boards/tengen.cpp

View File

@ -1,61 +0,0 @@
Import('file_list')
my_list = Split("""
01-222.cpp
112.cpp
117.cpp
164.cpp
183.cpp
185.cpp
186.cpp
187.cpp
189.cpp
199.cpp
208.cpp
222.cpp
235.cpp
43.cpp
57.cpp
603-5052.cpp
8157.cpp
8237.cpp
88.cpp
90.cpp
95.cpp
a9711.cpp
addrlatch.cpp
bmc13in1jy110.cpp
bmc42in1r.cpp
bmc64in1nr.cpp
bmc70in1.cpp
bonza.cpp
datalatch.cpp
deirom.cpp
dream.cpp
__dummy_mapper.cpp
edu2000.cpp
fk23c.cpp
h2288.cpp
karaoke.cpp
kof97.cpp
konami-qtai.cpp
malee.cpp
mmc1.cpp
mmc3.cpp
mmc5.cpp
n106.cpp
n-c22m.cpp
novel.cpp
sachen.cpp
sheroes.cpp
sl1632.cpp
subor.cpp
super24.cpp
supervision.cpp
t-262.cpp
tengen.cpp
""")
for x in range(len(my_list)):
my_list[x] = 'boards/' + my_list[x]
file_list = my_list + file_list
Export('file_list')

View File

@ -1,96 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 CaH4e3
*
* 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 "mapinc.h"
static uint8 reg[8];
/*
static uint8 *WRAM=NULL;
static uint32 WRAMSIZE;
static uint8 *CHRRAM=NULL;
static uint32 CHRRAMSIZE;
*/
static SFORMAT StateRegs[]=
{
{reg, 8, "REGS"},
{0}
};
static void Sync(void)
{
}
static DECLFW(MNNNWrite)
{
}
static void MNNNPower(void)
{
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,MNNNWrite);
}
static void MNNNReset(void)
{
}
/*
static void MNNNClose(void)
{
if(WRAM)
FCEU_gfree(WRAM);
if(CHRRAM)
FCEU_gfree(CHRRAM);
WRAM=CHRRAM=NULL;
}
*/
static void MNNNIRQHook(void)
{
X6502_IRQBegin(FCEU_IQEXT);
}
static void StateRestore(int version)
{
Sync();
}
void MapperNNN_Init(CartInfo *info)
{
info->Reset=MNNNReset;
info->Power=MNNNPower;
// info->Close=MNNNClose;
GameHBIRQHook=MNNNIRQHook;
GameStateRestore=StateRestore;
/*
CHRRAMSIZE=8192;
CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSIZE);
SetupCartPRGMapping(0x10,CHRRAM,CHRRAMSIZE,1);
AddExState(CHRRAM, CHRRAMSIZE, 0, "WRAM");
*/
/*
WRAMSIZE=8192;
WRAM=(uint8*)FCEU_gmalloc(WRAMSIZE);
SetupCartPRGMapping(0x10,WRAM,WRAMSIZE,1);
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
*/
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,74 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
static uint8 m_perm[8] = {0, 1, 0, 3, 0, 5, 6, 7};
static void UNLA9711PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x20)
{
uint8 bank=EXPREGS[0]&0x1F;
if(EXPREGS[0]&0x20)
setprg32(0x8000,bank>>2);
else
{
// setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(UNLA9711Write8000)
{
// FCEU_printf("bs %04x %02x\n",A,V);
// if(V&0x80)
// MMC3_CMDWrite(A,V);
// else
// MMC3_CMDWrite(A,m_perm[V&7]);
if(V!=0x86) MMC3_CMDWrite(A,V);
}
static DECLFW(UNLA9711WriteLo)
{
FCEU_printf("bs %04x %02x\n",A,V);
EXPREGS[0]=V;
FixMMC3PRG(MMC3_cmd);
}
static void UNLA9711Power(void)
{
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=0;
GenMMC3Power();
SetWriteHandler(0x5000,0x5FFF,UNLA9711WriteLo);
// SetWriteHandler(0x8000,0xbfff,UNLA9711Write8000);
}
void UNLA9711_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
pwrap=UNLA9711PW;
info->Power=UNLA9711Power;
AddExState(EXPREGS, 3, 0, "EXPR");
}

View File

@ -1,151 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 CaH4e3
*
* 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 "mapinc.h"
static uint16 latche, latcheinit;
static uint16 addrreg0, addrreg1;
static void(*WSync)(void);
static readfunc defread;
static DECLFW(LatchWrite)
{
// FCEU_printf("%04x:%02x\n",A,V);
latche=A;
WSync();
}
static void LatchPower(void)
{
latche=latcheinit;
WSync();
SetReadHandler(0x8000,0xFFFF,defread);
SetWriteHandler(addrreg0,addrreg1,LatchWrite);
}
static void StateRestore(int version)
{
WSync();
}
static void Latch_Init(CartInfo *info, void (*proc)(void), readfunc func, uint16 init, uint16 adr0, uint16 adr1)
{
latcheinit=init;
addrreg0=adr0;
addrreg1=adr1;
WSync=proc;
if(func)
defread=func;
else
defread=CartBR;
info->Power=LatchPower;
GameStateRestore=StateRestore;
AddExState(&latche, 2, 0, "LATC");
}
//------------------ UNLCC21 ---------------------------
static void UNLCC21Sync(void)
{
setprg32(0x8000,0);
setchr8(latche&1);
setmirror(MI_0+((latche&2)>>1));
}
void UNLCC21_Init(CartInfo *info)
{
Latch_Init(info, UNLCC21Sync, 0, 0, 0x8000, 0xFFFF);
}
//------------------ BMCD1038 ---------------------------
static uint8 dipswitch;
static void BMCD1038Sync(void)
{
if(latche&0x80)
{
setprg16(0x8000,(latche&0x70)>>4);
setprg16(0xC000,(latche&0x70)>>4);
}
else
setprg32(0x8000,(latche&0x60)>>5);
setchr8(latche&7);
setmirror(((latche&8)>>3)^1);
}
static DECLFR(BMCD1038Read)
{
if(latche&0x100)
return dipswitch;
else
return CartBR(A);
}
static void BMCD1038Reset(void)
{
dipswitch++;
dipswitch&=3;
}
void BMCD1038_Init(CartInfo *info)
{
Latch_Init(info, BMCD1038Sync, BMCD1038Read, 0, 0x8000, 0xFFFF);
info->Reset=BMCD1038Reset;
AddExState(&dipswitch, 1, 0, "DIPSW");
}
//------------------ Map 058 ---------------------------
static void BMCGK192Sync(void)
{
if(latche&0x40)
{
setprg16(0x8000,latche&7);
setprg16(0xC000,latche&7);
}
else
setprg32(0x8000,(latche>>1)&3);
setchr8((latche>>3)&7);
setmirror(((latche&0x80)>>7)^1);
}
void BMCGK192_Init(CartInfo *info)
{
Latch_Init(info, BMCGK192Sync, 0, 0, 0x8000, 0xFFFF);
}
//------------------ Map 200 ---------------------------
static void M200Sync(void)
{
// FCEU_printf("A\n");
setprg16(0x8000,latche&7);
setprg16(0xC000,latche&7);
setchr8(latche&7);
setmirror((latche&8)>>3);
}
void Mapper200_Init(CartInfo *info)
{
Latch_Init(info, M200Sync, 0, 0xff, 0x8000, 0xFFFF);
}

View File

@ -1,103 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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
*
* BMC 42-in-1 reset switch
*/
#include "mapinc.h"
static uint8 bank_mode;
static uint8 bank_value;
static uint8 prgb[4];
static SFORMAT StateRegs[]=
{
{0}
};
static void Sync(void)
{
FCEU_printf("%02x: %02x %02x\n", bank_mode, bank_value, prgb[0]);
switch(bank_mode&7)
{
case 0:
setprg32(0x8000,bank_value&7); break;
case 1:
setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]);
setprg16(0xC000,(bank_value&7)>>1);
case 4:
setprg32(0x8000,8+(bank_value&7)); break;
case 5:
setprg16(0x8000,((8+(bank_value&7))>>1)+prgb[1]);
setprg16(0xC000,((8+(bank_value&7))>>1)+prgb[3]);
case 2:
setprg8(0x8000,prgb[0]>>2);
setprg8(0xa000,prgb[1]);
setprg8(0xc000,prgb[2]);
setprg8(0xe000,~0);
break;
case 3:
setprg8(0x8000,prgb[0]);
setprg8(0xa000,prgb[1]);
setprg8(0xc000,prgb[2]);
setprg8(0xe000,prgb[3]);
break;
}
}
static DECLFW(BMC13in1JY110Write)
{
FCEU_printf("%04x:%04x\n",A,V);
switch(A)
{
case 0x8000:
case 0x8001:
case 0x8002:
case 0x8003: prgb[A&3]=V; break;
case 0xD000: bank_mode=V; break;
case 0xD001: setmirror(V&3);
case 0xD002: break;
case 0xD003: bank_value=V; break;
}
Sync();
}
static void BMC13in1JY110Power(void)
{
prgb[0]=prgb[1]=prgb[2]=prgb[3]=0;
bank_mode=0;
bank_value=0;
setprg32(0x8000,0);
setchr8(0);
SetWriteHandler(0x8000,0xFFFF,BMC13in1JY110Write);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void StateRestore(int version)
{
Sync();
}
void BMC13in1JY110_Init(CartInfo *info)
{
info->Power=BMC13in1JY110Power;
AddExState(&StateRegs, ~0, 0, 0);
GameStateRestore=StateRestore;
}

View File

@ -1,110 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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
*
* BMC 42-in-1 reset switch
*/
#include "mapinc.h"
extern uint32 ROM_size;
static uint8 hrd_sw;
static uint8 latche;
static SFORMAT StateRegs[]=
{
{&hrd_sw, 1, "DIPSW"},
{&latche, 1, "LATCHE"},
{&hrd_sw, 1, "HRDSW"},
{0}
};
static void Sync(void)
{
/* if(!(latche&0x02))
setprg32r(0,0x8000,(latche&0x3F)>>1);
else
{
setprg16r(0,0x8000,latche&0x3f);
setprg16r(0,0xC000,latche&0x3f);
}
*/
if(!(latche&0x20))
setprg32r(hrd_sw,0x8000,(latche>>1)&0x0f);
else
{
setprg16r(hrd_sw,0x8000,latche&0x1f);
setprg16r(hrd_sw,0xC000,latche&0x1f);
}
setmirror((latche>>6)&1);
}
static DECLFW(BMC42in1rWrite)
{
latche=V;
Sync();
}
static void BMC42in1rReset(void)
{
hrd_sw^=1;
Sync();
}
static void BMC42in1rPower(void)
{
latche=0;
hrd_sw=0;
setchr8(0);
Sync();
SetWriteHandler(0x8000,0xFFFF,BMC42in1rWrite);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void StateRestore(int version)
{
Sync();
}
void BMC42in1r_Init(CartInfo *info)
{
info->Power=BMC42in1rPower;
info->Reset=BMC42in1rReset;
AddExState(&StateRegs, ~0, 0, 0);
GameStateRestore=StateRestore;
}
static void M226Power(void)
{
if(ROM_size==64)
SetupCartPRGMapping(1,PRGptr[0]+512*1024,512,0);
latche=0;
hrd_sw=0;
setchr8(0);
Sync();
SetWriteHandler(0x8000,0xFFFF,BMC42in1rWrite);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
void Mapper226_Init(CartInfo *info)
{
info->Power=M226Power;
info->Reset=BMC42in1rReset;
AddExState(&StateRegs, ~0, 0, 0);
GameStateRestore=StateRestore;
}

View File

@ -1,93 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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
*
* BMC 42-in-1 reset switch
*/
#include "mapinc.h"
static uint8 regs[4];
static SFORMAT StateRegs[]=
{
{regs, 4, "REGS"},
{0}
};
static void Sync(void)
{
if(regs[0]&0x80)
{
if(regs[1]&0x80)
setprg32(0x8000,regs[1]&0x1F);
else
{
int bank=((regs[1]&0x1f)<<1)|((regs[1]>>6)&1);
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
{
int bank=((regs[1]&0x1f)<<1)|((regs[1]>>6)&1);
setprg16(0xC000,bank);
}
if(regs[0]&0x20)
setmirror(MI_H);
else
setmirror(MI_V);
setchr8((regs[2]<<2)|((regs[0]>>1)&3));
}
static DECLFW(BMC64in1nrWriteLo)
{
regs[A&3]=V;
Sync();
}
static DECLFW(BMC64in1nrWriteHi)
{
regs[3]=V;
Sync();
}
static void BMC64in1nrPower(void)
{
regs[0]=0x80;
regs[1]=0x43;
regs[2]=regs[3]=0;
Sync();
SetWriteHandler(0x5000,0x5003,BMC64in1nrWriteLo);
SetWriteHandler(0x8000,0xFFFF,BMC64in1nrWriteHi);
SetReadHandler(0x8000,0xFFFF,CartBR);
}
static void StateRestore(int version)
{
Sync();
}
void BMC64in1nr_Init(CartInfo *info)
{
info->Power=BMC64in1nrPower;
AddExState(&StateRegs, ~0, 0, 0);
GameStateRestore=StateRestore;
}

View File

@ -1,130 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint8 is_large_banks, hw_switch;
static uint8 large_bank;
static uint8 prg_bank;
static uint8 chr_bank;
static uint8 bank_mode;
static uint8 mirroring;
static SFORMAT StateRegs[]=
{
{&large_bank, 1, "LB"},
{&hw_switch, 1, "DIPSW"},
{&prg_bank, 1, "PRG"},
{&chr_bank, 1, "CHR"},
{&bank_mode, 1, "BM"},
{&mirroring, 1, "MIRR"},
{0}
};
static void Sync(void)
{
switch (bank_mode)
{
case 0x00:
case 0x10: setprg16(0x8000,large_bank|prg_bank);
setprg16(0xC000,large_bank|7);
break;
case 0x20: setprg32(0x8000,(large_bank|prg_bank)>>1);
break;
case 0x30: setprg16(0x8000,large_bank|prg_bank);
setprg16(0xC000,large_bank|prg_bank);
break;
}
setmirror(mirroring);
if(!is_large_banks)
setchr8(chr_bank);
}
static DECLFR(BMC70in1Read)
{
if(bank_mode==0x10)
// if(is_large_banks)
return CartBR((A&0xFFF0)|hw_switch);
// else
// return CartBR((A&0xFFF0)|hw_switch);
else
return CartBR(A);
}
static DECLFW(BMC70in1Write)
{
if(A&0x4000)
{
bank_mode=A&0x30;
prg_bank=A&7;
}
else
{
mirroring=((A&0x20)>>5)^1;
if(is_large_banks)
large_bank=(A&3)<<3;
else
chr_bank=A&7;
}
Sync();
}
static void BMC70in1Reset(void)
{
bank_mode=0;
large_bank=0;
Sync();
hw_switch++;
hw_switch&=0xf;
}
static void BMC70in1Power(void)
{
setchr8(0);
bank_mode=0;
large_bank=0;
Sync();
SetReadHandler(0x8000,0xFFFF,BMC70in1Read);
SetWriteHandler(0x8000,0xffff,BMC70in1Write);
}
static void StateRestore(int version)
{
Sync();
}
void BMC70in1_Init(CartInfo *info)
{
is_large_banks=0;
hw_switch=0xd;
info->Power=BMC70in1Power;
info->Reset=BMC70in1Reset;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
void BMC70in1B_Init(CartInfo *info)
{
is_large_banks=1;
hw_switch=0x6;
info->Power=BMC70in1Power;
info->Reset=BMC70in1Reset;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,139 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 CaH4e3
*
* 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 "mapinc.h"
static uint8 prg_reg;
static uint8 chr_reg;
static uint8 sim0reg, sim0bit, sim0byte, sim0parity, sim0bcnt;
static uint16 sim0data;
static uint8 sim0array[128] =
{
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xAA,
};
static SFORMAT StateRegs[]=
{
{&prg_reg, 1, "PREG"},
{&chr_reg, 1, "CREG"},
{0}
};
static void Sync(void)
{
setprg32(0x8000, prg_reg);
setchr8(chr_reg);
}
static void StateRestore(int version)
{
Sync();
}
static DECLFW(M216WriteHi)
{
// FCEU_printf("%04x:%04x\n",A,V);
prg_reg=A&1;
chr_reg=(A&0x0E)>>1;
Sync();
}
static DECLFW(M216Write5000)
{
// FCEU_printf("WRITE: %04x:%04x\n",A,V);
sim0reg=V;
if(!sim0reg)
{
sim0bit=sim0byte=sim0parity=0;
sim0data=sim0array[0];
sim0bcnt=0x80;
}
else if(sim0reg&0x20)
{
sim0bcnt=0x20;
}
}
static DECLFR(M216Read5000)
{
if(sim0reg&0x60)
{
sim0reg=(sim0reg^(sim0reg<<1))&0x40;
return sim0reg;
}
else
{
uint8 sim0out=0;
if(sim0bit<8)
{
// sim0data=((sim0array[sim0byte]<<(sim0bit))&0x80)>>1;
sim0out=(sim0data&1)<<6;
sim0data>>=1;
sim0bit++;
sim0parity+=sim0data;
}
else if(sim0bit==8)
{
sim0bit++;
sim0out=sim0parity&1;
}
else if(sim0bit==9)
{
if(sim0byte==sim0bcnt)
sim0out=0x60;
else
{
sim0bit=0;
sim0byte++;
sim0data=sim0array[sim0byte];
sim0out=0;
}
}
// FCEU_printf("READ: %04x (%04x-%02x,%04x)\n",A,X.PC,sim0out,sim0byte);
return sim0out;
}
}
static void Power(void)
{
prg_reg = 0;
chr_reg = 0;
Sync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M216WriteHi);
SetWriteHandler(0x5000,0x5000,M216Write5000);
SetReadHandler(0x5000,0x5000,M216Read5000);
}
void Mapper216_Init(CartInfo *info)
{
info->Power=Power;
GameStateRestore=StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,350 +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 "mapinc.h"
static uint8 latche, latcheinit;
static uint16 addrreg0, addrreg1;
static void(*WSync)(void);
static DECLFW(LatchWrite)
{
// FCEU_printf("bs %04x %02x\n",A,V);
latche=V;
WSync();
}
static void LatchPower(void)
{
latche=latcheinit;
WSync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(addrreg0,addrreg1,LatchWrite);
}
static void StateRestore(int version)
{
WSync();
}
static void Latch_Init(CartInfo *info, void (*proc)(void), uint8 init, uint16 adr0, uint16 adr1)
{
latcheinit=init;
addrreg0=adr0;
addrreg1=adr1;
WSync=proc;
info->Power=LatchPower;
GameStateRestore=StateRestore;
AddExState(&latche, 1, 0, "LATC");
}
//------------------ CPROM ---------------------------
static void CPROMSync(void)
{
setchr4(0x0000,0);
setchr4(0x1000,latche&3);
setprg16(0x8000,0);
setprg16(0xC000,1);
}
void CPROM_Init(CartInfo *info)
{
Latch_Init(info, CPROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 184 ---------------------------
static void M184Sync(void)
{
setchr4(0x0000,latche);
setchr4(0x1000,latche>>4);
setprg16(0x8000,0);
setprg16(0xC000,1);
}
void Mapper184_Init(CartInfo *info)
{
Latch_Init(info, M184Sync, 0, 0x6000, 0x7FFF);
}
//------------------ CNROM ---------------------------
static void CNROMSync(void)
{
setchr8(latche&3);
setprg16(0x8000,0);
setprg16(0xC000,1);
}
void CNROM_Init(CartInfo *info)
{
Latch_Init(info, CNROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ ANROM ---------------------------
static void ANROMSync()
{
setprg32(0x8000,latche&0xf);
setmirror(MI_0+((latche>>4)&1));
setchr8(0);
}
void ANROM_Init(CartInfo *info)
{
Latch_Init(info, ANROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 70 ---------------------------
static void M70Sync()
{
setprg16(0x8000,latche>>4);
setprg16(0xc000,~0);
setchr8(latche&0xf);
}
void Mapper70_Init(CartInfo *info)
{
Latch_Init(info, M70Sync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 152 ---------------------------
static void M152Sync()
{
setprg16(0x8000,(latche>>4)&7);
setprg16(0xc000,~0);
setchr8(latche&0xf);
setmirror(MI_0+((latche>>7)&1)); /* Saint Seiya...hmm. */
}
void Mapper152_Init(CartInfo *info)
{
Latch_Init(info, M152Sync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 78 ---------------------------
/* Should be two separate emulation functions for this "mapper". Sigh. URGE TO KILL RISING. */
static void M78Sync()
{
setprg16(0x8000,(latche&7));
setprg16(0xc000,~0);
setchr8(latche>>4);
setmirror(MI_0+((latche>>3)&1));
}
void Mapper78_Init(CartInfo *info)
{
Latch_Init(info, M78Sync, 0, 0x8000, 0xFFFF);
}
//------------------ MHROM ---------------------------
static void MHROMSync(void)
{
setprg32(0x8000,latche>>4);
setchr8(latche&0xf);
}
void MHROM_Init(CartInfo *info)
{
Latch_Init(info, MHROMSync, 0, 0x8000, 0xFFFF);
}
void Mapper140_Init(CartInfo *info)
{
Latch_Init(info, MHROMSync, 0, 0x6000, 0x7FFF);
}
void Mapper240_Init(CartInfo *info)
{
Latch_Init(info, MHROMSync, 0, 0x4020, 0x5FFF);
// need SRAM.
}
//------------------ Map 87 ---------------------------
static void M87Sync(void)
{
setprg16(0x8000,0);
setprg16(0xC000,1);
setchr8(latche>>1);
}
void Mapper87_Init(CartInfo *info)
{
Latch_Init(info, M87Sync, ~0, 0x6000, 0xFFFF);
}
//------------------ Map 11 ---------------------------
static void M11Sync(void)
{
setprg32(0x8000,latche&0xf);
setchr8(latche>>4);
}
void Mapper11_Init(CartInfo *info)
{
Latch_Init(info, M11Sync, 0, 0x8000, 0xFFFF);
}
void Mapper144_Init(CartInfo *info)
{
Latch_Init(info, M11Sync, 0, 0x8001, 0xFFFF);
}
//------------------ UNROM ---------------------------
static void UNROMSync(void)
{
setprg16(0x8000,latche);
setprg16(0xc000,~0);
setchr8(0);
}
void UNROM_Init(CartInfo *info)
{
Latch_Init(info, UNROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 93 ---------------------------
static void SSUNROMSync(void)
{
setprg16(0x8000,latche>>4);
setprg16(0xc000,~0);
setchr8(0);
}
void SUNSOFT_UNROM_Init(CartInfo *info)
{
Latch_Init(info, SSUNROMSync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 94 ---------------------------
static void M94Sync(void)
{
setprg16(0x8000,latche>>2);
setprg16(0xc000,~0);
setchr8(0);
}
void Mapper94_Init(CartInfo *info)
{
Latch_Init(info, M94Sync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 180 ---------------------------
static void M180Sync(void)
{
setprg16(0x8000,0);
setprg16(0xc000,latche);
setchr8(0);
}
void Mapper180_Init(CartInfo *info)
{
Latch_Init(info, M180Sync, 0, 0x8000, 0xFFFF);
}
//------------------ Map 107 ---------------------------
static void M107Sync(void)
{
setprg32(0x8000,(latche>>1)&3);
setchr8(latche&7);
}
void Mapper107_Init(CartInfo *info)
{
Latch_Init(info, M107Sync, ~0, 0x8000, 0xFFFF);
}
//------------------ Map 113 ---------------------------
static void M113Sync(void)
{
setprg32(0x8000,(latche>>3)&7);
setchr8(((latche>>3)&8)|(latche&7));
// setmirror(latche>>7); // only for HES 6in1
}
void Mapper113_Init(CartInfo *info)
{
Latch_Init(info, M113Sync, 0, 0x4100, 0x7FFF);
}
//------------------ A65AS ---------------------------
// actually, there is two cart in one... First have extra mirroring
// mode (one screen) and 32K bankswitching, second one have only
// 16 bankswitching mode and normal mirroring... But there is no any
// correlations between modes and they can be used in one mapper code.
static void BMCA65ASSync(void)
{
if(latche&0x40)
setprg32(0x8000,(latche>>1)&0x0F);
else
{
setprg16(0x8000,((latche&0x30)>>1)|(latche&7));
setprg16(0xC000,((latche&0x30)>>1)|7);
}
setchr8(0);
if(latche&0x80)
setmirror(MI_0+(((latche>>5)&1)));
else
setmirror(((latche>>3)&1)^1);
}
void BMCA65AS_Init(CartInfo *info)
{
Latch_Init(info, BMCA65ASSync, 0, 0x8000, 0xFFFF);
}
//------------------ NROM ---------------------------
#ifdef DEBUG_MAPPER
static DECLFW(WriteHandler)
{
FCEU_printf("bs %04x %02x\n",A,V);
}
#endif
static void NROMPower(void)
{
setprg16(0x8000,0);
setprg16(0xC000,~0);
setchr8(0);
SetReadHandler(0x8000,0xFFFF,CartBR);
#ifdef DEBUG_MAPPER
SetWriteHandler(0x4020,0xFFFF,WriteHandler);
#endif
}
void NROM_Init(CartInfo *info)
{
info->Power=NROMPower;
}

View File

@ -1,82 +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 "mapinc.h"
static uint8 cmd;
static uint8 DRegs[8];
static SFORMAT DEI_StateRegs[]=
{
{&cmd, 1, "CMD"},
{DRegs, 8, "DREG"},
{0}
};
static void Sync(void)
{
int x;
setchr2(0x0000,DRegs[0]);
setchr2(0x0800,DRegs[1]);
for(x=0;x<4;x++)
setchr1(0x1000+(x<<10),DRegs[2+x]);
setprg8(0x8000,DRegs[6]);
setprg8(0xa000,DRegs[7]);
}
static void StateRestore(int version)
{
Sync();
}
static DECLFW(DEIWrite)
{
switch(A&0x8001)
{
case 0x8000: cmd=V&0x07; break;
case 0x8001: if(cmd<=0x05)
V&=0x3F;
else
V&=0x0F;
if(cmd<=0x01) V>>=1;
DRegs[cmd&0x07]=V;
Sync();
break;
}
}
static void DEIPower(void)
{
setprg8(0xc000,0xE);
setprg8(0xe000,0xF);
cmd=0;
memset(DRegs,0,8);
Sync();
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,DEIWrite);
}
void DEIROM_Init(CartInfo *info)
{
info->Power=DEIPower;
GameStateRestore=StateRestore;
AddExState(&DEI_StateRegs, ~0, 0, 0);
}

View File

@ -1,56 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
static uint8 latche;
static void Sync(void)
{
setprg16(0x8000,latche);
setprg16(0xC000,8);
}
static DECLFW(DREAMWrite)
{
latche=V&7;
Sync();
}
static void DREAMPower(void)
{
latche=0;
Sync();
setchr8(0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x5020,0x5020,DREAMWrite);
}
static void Restore(int version)
{
Sync();
}
void DreamTech01_Init(CartInfo *info)
{
GameStateRestore=Restore;
info->Power=DREAMPower;
AddExState(&latche, 1, 0, "LATCH");
}

View File

@ -1,81 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 CaH4e3
*
* 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 "mapinc.h"
static uint8 *WRAM=NULL;
static uint8 reg;
static SFORMAT StateRegs[]=
{
{&reg, 1, "REG"},
{0}
};
static void Sync(void)
{
setchr8(0);
setprg8r(0x10,0x6000,(reg&0xC0)>>6);
setprg32(0x8000,reg&0x1F);
// setmirror(((reg&0x20)>>5));
}
static DECLFW(UNLEDU2000HiWrite)
{
// FCEU_printf("%04x:%02x\n",A,V);
reg=V;
Sync();
}
static void UNLEDU2000Power(void)
{
setmirror(MI_0);
SetReadHandler(0x6000,0xFFFF,CartBR);
SetWriteHandler(0x6000,0xFFFF,CartBW);
SetWriteHandler(0x8000,0xFFFF,UNLEDU2000HiWrite);
reg=0;
Sync();
}
static void UNLEDU2000Close(void)
{
if(WRAM)
FCEU_gfree(WRAM);
WRAM=NULL;
}
static void UNLEDU2000Restore(int version)
{
Sync();
}
void UNLEDU2000_Init(CartInfo *info)
{
info->Power=UNLEDU2000Power;
info->Close=UNLEDU2000Close;
GameStateRestore=UNLEDU2000Restore;
WRAM=(uint8*)FCEU_gmalloc(32768);
SetupCartPRGMapping(0x10,WRAM,32768,1);
info->SaveGame[0]=WRAM;
info->SaveGameLen[0]=32768;
AddExState(WRAM, 32768, 0, "WRAM");
AddExState(StateRegs, ~0, 0, 0);
}

View File

@ -1,127 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2006 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
static uint8 unromchr;
static uint8 dipswitch;
static void BMCFK23CCW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
setchr8(EXPREGS[2]|unromchr);
else
{
uint16 base=(EXPREGS[2]&0x7F)<<3;
setchr1(A,V|base);
if(EXPREGS[3]&2)
{
setchr1(0x0400,EXPREGS[6]|base);
setchr1(0x0C00,EXPREGS[7]|base);
}
}
}
static void BMCFK23CPW(uint32 A, uint8 V)
{
if(EXPREGS[0]&4)
setprg32(0x8000,EXPREGS[1]>>1);
else
{
if(EXPREGS[0]&2)
setprg8(A,(V&(0x3F>>(EXPREGS[0]&3)))|(EXPREGS[1]<<1));
else
setprg8(A,V);
if(EXPREGS[3]&2)
{
setprg8(0xC000,EXPREGS[4]);
setprg8(0xE000,EXPREGS[5]);
}
}
}
static DECLFW(BMCFK23CHiWrite)
{
if(EXPREGS[0]&0x40)
{
if(EXPREGS[0]&0x20)
unromchr=0;
else
{
unromchr=V&3;
FixMMC3CHR(MMC3_cmd);
}
}
else
{
if((A==0x8001)&&(EXPREGS[3]&2&&MMC3_cmd&8))
{
EXPREGS[4|(MMC3_cmd&3)]=V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
else
if(A<0xC000)
MMC3_CMDWrite(A,V);
else
MMC3_IRQWrite(A,V);
}
}
static DECLFW(BMCFK23CWrite)
{
if(A&(1<<(dipswitch+4)))
{
EXPREGS[A&3]=V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
}
static void BMCFK23CReset(void)
{
dipswitch++;
dipswitch&=3;
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0;
EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF;
MMC3RegReset();
}
static void BMCFK23CPower(void)
{
EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=0;
EXPREGS[4]=EXPREGS[5]=EXPREGS[6]=EXPREGS[7]=0xFF;
GenMMC3Power();
SetWriteHandler(0x5001,0x5fff,BMCFK23CWrite);
SetWriteHandler(0x8000,0xFFFF,BMCFK23CHiWrite);
}
void BMCFK23C_Init(CartInfo *info)
{
GenMMC3_Init(info, 512, 256, 8, 0);
cwrap=BMCFK23CCW;
pwrap=BMCFK23CPW;
info->Power=BMCFK23CPower;
info->Reset=BMCFK23CReset;
AddExState(EXPREGS, 8, 0, "EXPR");
AddExState(&unromchr, 1, 0, "UNCHR");
AddExState(&dipswitch, 1, 0, "DIPSW");
}

View File

@ -1,89 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
extern uint8 m114_perm[8];
static void H2288PW(uint32 A, uint8 V)
{
if(EXPREGS[0]&0x40)
{
uint8 bank=(EXPREGS[0]&5)|((EXPREGS[0]&8)>>2)|((EXPREGS[0]&0x20)>>2);
if(EXPREGS[0]&2)
setprg32(0x8000,bank>>1);
else
{
setprg16(0x8000,bank);
setprg16(0xC000,bank);
}
}
else
setprg8(A,V&0x3F);
}
static DECLFW(H2288WriteHi)
{
switch (A&0x8001)
{
case 0x8000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m114_perm[V&7])); break;
case 0x8001: MMC3_CMDWrite(0x8001,V); break;
}
}
static DECLFW(H2288WriteLo)
{
if(A&0x800)
{
if(A&1)
EXPREGS[1]=V;
else
EXPREGS[0]=V;
FixMMC3PRG(MMC3_cmd);
}
}
static DECLFR(H2288Read)
{
int bit;
bit=(A&1)^1;
bit&=((A>>8)&1);
bit^=1;
return((X.DB&0xFE)|bit);
}
static void H2288Power(void)
{
EXPREGS[0]=EXPREGS[1]=0;
GenMMC3Power();
SetReadHandler(0x5000,0x5FFF,H2288Read);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x5000,0x5FFF,H2288WriteLo);
SetWriteHandler(0x8000,0x8FFF,H2288WriteHi);
}
void UNLH2288_Init(CartInfo *info)
{
GenMMC3_Init(info, 256, 256, 0, 0);
pwrap=H2288PW;
info->Power=H2288Power;
AddExState(EXPREGS, 2, 0, "EXPR");
}

View File

@ -1,71 +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 "mapinc.h"
extern uint32 ROM_size;
static uint8 latche;
static void Sync(void)
{
if(latche)
{
if(latche&0x10)
setprg16(0x8000,(latche&7));
else
setprg16(0x8000,(latche&7)|8);
}
else
setprg16(0x8000,7+(ROM_size>>4));
}
static DECLFW(M188Write)
{
latche=V;
Sync();
}
static DECLFR(ExtDev)
{
return(3);
}
static void Power(void)
{
latche=0;
Sync();
setchr8(0);
setprg16(0xc000,0x7);
SetReadHandler(0x6000,0x7FFF,ExtDev);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M188Write);
}
static void StateRestore(int version)
{
Sync();
}
void Mapper188_Init(CartInfo *info)
{
info->Power=Power;
GameStateRestore=StateRestore;
AddExState(&latche, 1, 0, "LATCH");
}

View File

@ -1,50 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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 "mapinc.h"
#include "mmc3.h"
static DECLFW(UNLKOF97CMDWrite)
{
V=(V&0xD8)|((V&0x20)>>4)|((V&4)<<3)|((V&2)>>1)|((V&1)<<2); //76143502
if(A==0x9000) A=0x8001;
MMC3_CMDWrite(A,V);
}
static DECLFW(UNLKOF97IRQWrite)
{
V=(V&0xD8)|((V&0x20)>>4)|((V&4)<<3)|((V&2)>>1)|((V&1)<<2);
if(A==0xD000) A=0xC001;
else if(A==0xF000) A=0xE001;
MMC3_IRQWrite(A,V);
}
static void UNLKOF97Power(void)
{
GenMMC3Power();
SetWriteHandler(0x8000,0xA000,UNLKOF97CMDWrite);
SetWriteHandler(0xC000,0xF000,UNLKOF97IRQWrite);
}
void UNLKOF97_Init(CartInfo *info)
{
GenMMC3_Init(info, 128, 256, 0, 0);
info->Power=UNLKOF97Power;
}

View File

@ -1,128 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2005 CaH4e3
*
* 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
*
* CAI Shogakko no Sansu
*/
#include "mapinc.h"
static uint8 *CHRRAM=NULL;
static uint8 SWRAM[4096];
static uint8 regs[16];
static uint8 WRAM[4096];
static SFORMAT StateRegs[]=
{
{&regs, 16, "REGS"},
{WRAM, 4096, "WRAM"},
{0}
};
static void Sync(void)
{
if(regs[5]&0x40)
{
setchr4r(0,0x1000,regs[5]&0x3F);
}
else
{
setchr4r(0x10,0x0000,regs[5]);
setchr4r(0x10,0x1000,regs[5]^1);
}
setprg8r((regs[2]>>6)&1,0x8000,(regs[2]&0x3F));
setprg8r((regs[3]>>6)&1,0xA000,(regs[3]&0x3F));
setprg8r((regs[4]>>6)&1,0xC000,(regs[4]&0x3F));
setprg8r(1,0xE000,~0);
setmirror((regs[0xA]&3));
}
static DECLFW(M190Write)
{
// FCEU_printf("write %04x:%04x %d, %d\n",A,V,scanline,timestamp);
regs[(A&0x0F00)>>8]=V;
Sync();
}
static DECLFR(M190Read)
{
// FCEU_printf("read %04x:%04x %d, %d\n",A,regs[(A&0x0F00)>>8],scanline,timestamp);
return regs[(A&0x0F00)>>8];
}
static DECLFR(AWRAM)
{
return(WRAM[A-0x7000]);
}
static DECLFW(BWRAM)
{
WRAM[A-0x7000]=V;
}
static DECLFR(ASWRAM)
{
return(SWRAM[A-0x6000]);
}
static DECLFW(BSWRAM)
{
SWRAM[A-0x6000]=V;
}
static void M190Power(void)
{
setvram8(CHRRAM);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetWriteHandler(0x8000,0xFFFF,M190Write);
// SetReadHandler(0xDA00,0xDA00,M190Read);
// SetReadHandler(0xDB00,0xDB00,M190Read);
SetReadHandler(0xDC00,0xDC00,M190Read);
SetReadHandler(0xDD00,0xDD00,M190Read);
SetReadHandler(0x7000,0x7FFF,AWRAM);
SetWriteHandler(0x7000,0x7FFF,BWRAM);
SetReadHandler(0x6000,0x6FFF,ASWRAM);
SetWriteHandler(0x6000,0x6FFF,BSWRAM);
Sync();
}
static void M190Close(void)
{
if(CHRRAM)
FCEU_gfree(CHRRAM);
CHRRAM=NULL;
}
static void StateRestore(int version)
{
Sync();
}
void Mapper190_Init(CartInfo *info)
{
info->Power=M190Power;
info->Close=M190Close;
if(info->battery)
{
info->SaveGame[0]=SWRAM;
info->SaveGameLen[0]=4096;
}
GameStateRestore=StateRestore;
CHRRAM=(uint8*)FCEU_gmalloc(8192);
SetupCartCHRMapping(0x10,CHRRAM,8192,1);
AddExState(CHRRAM, 8192, 0, "CHRRAM");
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@ -1,41 +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 "mapinc.h"
static uint8 WRAM[2048];
static void MALEEPower(void)
{
setprg2r(0x10,0x7000,0);
SetReadHandler(0x8000,0xFFFF,CartBR);
SetReadHandler(0x6000,0x67FF,CartBR);
SetReadHandler(0x7000,0x77FF,CartBR);
setprg2r(1,0x6000,0);
setprg32(0x8000,0);
setchr8(0);
}
void MALEE_Init(CartInfo *info)
{
info->Power=MALEEPower;
SetupCartPRGMapping(0x10, WRAM, 2048, 1);
AddExState(WRAM, 2048, 0,"RAM");
}

View File

@ -1,11 +0,0 @@
#include "../types.h"
#include "../x6502.h"
#include "../fceu.h"
#include "../ppu.h"
#include "../memory.h"
#include "../sound.h"
#include "../state.h"
#include "../cart.h"
#include "../cheat.h"
#include "../unif.h"
#include <string.h>

View File

@ -1,423 +0,0 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 1998 BERO
* 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 "mapinc.h"
static void GenMMC1Power(void);
static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery);
static uint8 DRegs[4];
static uint8 Buffer,BufferShift;
static int mmc1opts;
static void (*MMC1CHRHook4)(uint32 A, uint8 V);
static void (*MMC1PRGHook16)(uint32 A, uint8 V);
static uint8 *WRAM=NULL;
static uint8 *CHRRAM=NULL;
static int is155;
static DECLFW(MBWRAM)
{
if(!(DRegs[3]&0x10)||is155)
Page[A>>11][A]=V; // WRAM is enabled.
}
static DECLFR(MAWRAM)
{
if((DRegs[3]&0x10)&&!is155)
return X.DB; // WRAM is disabled
return(Page[A>>11][A]);
}
static void MMC1CHR(void)
{
if(mmc1opts&4)
{
if(DRegs[0]&0x10)
setprg8r(0x10,0x6000,(DRegs[1]>>4)&1);
else
setprg8r(0x10,0x6000,(DRegs[1]>>3)&1);
}
if(MMC1CHRHook4)
{
if(DRegs[0]&0x10)
{
MMC1CHRHook4(0x0000,DRegs[1]);
MMC1CHRHook4(0x1000,DRegs[2]);
}
else
{
MMC1CHRHook4(0x0000,(DRegs[1]&0xFE));
MMC1CHRHook4(0x1000,DRegs[1]|1);
}
}
else
{
if(DRegs[0]&0x10)
{
setchr4(0x0000,DRegs[1]);
setchr4(0x1000,DRegs[2]);
}
else
setchr8(DRegs[1]>>1);
}
}
static void MMC1PRG(void)
{
uint8 offs=DRegs[1]&0x10;
if(MMC1PRGHook16)
{
switch(DRegs[0]&0xC)
{
case 0xC: MMC1PRGHook16(0x8000,(DRegs[3]+offs));
MMC1PRGHook16(0xC000,0xF+offs);
break;
case 0x8: MMC1PRGHook16(0xC000,(DRegs[3]+offs));
MMC1PRGHook16(0x8000,offs);
break;
case 0x0:
case 0x4:
MMC1PRGHook16(0x8000,((DRegs[3]&~1)+offs));
MMC1PRGHook16(0xc000,((DRegs[3]&~1)+offs+1));
break;
}
}
else switch(DRegs[0]&0xC)
{
case 0xC: setprg16(0x8000,(DRegs[3]+offs));
setprg16(0xC000,0xF+offs);
break;
case 0x8: setprg16(0xC000,(DRegs[3]+offs));
setprg16(0x8000,offs);
break;
case 0x0:
case 0x4:
setprg16(0x8000,((DRegs[3]&~1)+offs));
setprg16(0xc000,((DRegs[3]&~1)+offs+1));
break;
}
}
static void MMC1MIRROR(void)
{
switch(DRegs[0]&3)
{
case 2: setmirror(MI_V); break;
case 3: setmirror(MI_H); break;
case 0: setmirror(MI_0); break;
case 1: setmirror(MI_1); break;
}
}
static uint64 lreset;
static DECLFW(MMC1_write)
{
int n=(A>>13)-4;
//FCEU_DispMessage("%016x",timestampbase+timestamp);
//printf("$%04x:$%02x, $%04x\n",A,V,X.PC);
//DumpMem("out",0xe000,0xffff);
/* The MMC1 is busy so ignore the write. */
/* As of version FCE Ultra 0.81, the timestamp is only
increased before each instruction is executed(in other words
precision isn't that great), but this should still work to
deal with 2 writes in a row from a single RMW instruction. */
if((timestampbase+timestamp)<(lreset+2)) return;
if(V&0x80)
{
DRegs[0]|=0xC;
BufferShift=Buffer=0;
MMC1PRG();
lreset=timestampbase+timestamp;
return;
}
Buffer|=(V&1)<<(BufferShift++);
if(BufferShift==5)
{
DRegs[n] = Buffer;
BufferShift = Buffer = 0;
switch(n)
{
case 0: MMC1MIRROR(); MMC1CHR(); MMC1PRG(); break;
case 1: MMC1CHR(); MMC1PRG(); break;
case 2: MMC1CHR(); break;
case 3: MMC1PRG(); break;
}
}
}
static void MMC1_Restore(int version)
{
MMC1MIRROR();
MMC1CHR();
MMC1PRG();
lreset=0; /* timestamp(base) is not stored in save states. */
}
static void MMC1CMReset(void)
{
int i;
for(i=0;i<4;i++)
DRegs[i]=0;
Buffer = BufferShift = 0;
DRegs[0]=0x1F;
DRegs[1]=0;
DRegs[2]=0; // Should this be something other than 0?
DRegs[3]=0;
MMC1MIRROR();
MMC1CHR();
MMC1PRG();
}
static int DetectMMC1WRAMSize(uint32 crc32)
{
switch(crc32)
{
case 0xc6182024: /* Romance of the 3 Kingdoms */
case 0x2225c20f: /* Genghis Khan */
case 0x4642dda6: /* Nobunaga's Ambition */
case 0x29449ba9: /* "" "" (J) */
case 0x2b11e0b0: /* "" "" (J) */
case 0xb8747abf: /* Best Play Pro Yakyuu Special (J) */
case 0xc9556b36: /* Final Fantasy I & II (J) [!] */
FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n");
return(16);
break;
default:return(8);
}
}
static uint32 NWCIRQCount;
static uint8 NWCRec;
#define NWCDIP 0xE
static void FP_FASTAPASS(1) NWCIRQHook(int a)
{
if(!(NWCRec&0x10))
{
NWCIRQCount+=a;
if((NWCIRQCount|(NWCDIP<<25))>=0x3e000000)
{
NWCIRQCount=0;
X6502_IRQBegin(FCEU_IQEXT);
}
}
}
static void NWCCHRHook(uint32 A, uint8 V)
{
if((V&0x10)) // && !(NWCRec&0x10))
{
NWCIRQCount=0;
X6502_IRQEnd(FCEU_IQEXT);
}
NWCRec=V;
if(V&0x08)
MMC1PRG();
else
setprg32(0x8000,(V>>1)&3);
}
static void NWCPRGHook(uint32 A, uint8 V)
{
if(NWCRec&0x8)
setprg16(A,8|(V&0x7));
else
setprg32(0x8000,(NWCRec>>1)&3);
}
static void NWCPower(void)
{
GenMMC1Power();
setchr8r(0,0);
}
void Mapper105_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 256, 8, 0);
MMC1CHRHook4=NWCCHRHook;
MMC1PRGHook16=NWCPRGHook;
MapIRQHook=NWCIRQHook;
info->Power=NWCPower;
}
static void GenMMC1Power(void)
{
lreset=0;
if(mmc1opts&1)
{
FCEU_CheatAddRAM(8,0x6000,WRAM);
if(mmc1opts&4)
FCEU_dwmemset(WRAM,0,8192)
else if(!(mmc1opts&2))
FCEU_dwmemset(WRAM,0,8192);
}
SetWriteHandler(0x8000,0xFFFF,MMC1_write);
SetReadHandler(0x8000,0xFFFF,CartBR);
if(mmc1opts&1)
{
SetReadHandler(0x6000,0x7FFF,MAWRAM);
SetWriteHandler(0x6000,0x7FFF,MBWRAM);
setprg8r(0x10,0x6000,0);
}
MMC1CMReset();
}
static void GenMMC1Close(void)
{
if(CHRRAM)
FCEU_gfree(CHRRAM);
if(WRAM)
FCEU_gfree(WRAM);
CHRRAM=WRAM=NULL;
}
static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery)
{
is155=0;
info->Close=GenMMC1Close;
MMC1PRGHook16=MMC1CHRHook4=0;
mmc1opts=0;
PRGmask16[0]&=(prg>>14)-1;
CHRmask4[0]&=(chr>>12)-1;
CHRmask8[0]&=(chr>>13)-1;
if(wram)
{
WRAM=(uint8*)FCEU_gmalloc(wram*1024);
mmc1opts|=1;
if(wram>8) mmc1opts|=4;
SetupCartPRGMapping(0x10,WRAM,wram*1024,1);
AddExState(WRAM, wram*1024, 0, "WRAM");
if(battery)
{
mmc1opts|=2;
info->SaveGame[0]=WRAM+((mmc1opts&4)?8192:0);
info->SaveGameLen[0]=8192;
}
}
if(!chr)
{
CHRRAM=(uint8*)FCEU_gmalloc(8192);
SetupCartCHRMapping(0, CHRRAM, 8192, 1);
AddExState(CHRRAM, 8192, 0, "CHRR");
}
AddExState(DRegs, 4, 0, "DREG");
info->Power=GenMMC1Power;
GameStateRestore=MMC1_Restore;
AddExState(&lreset, 8, 1, "LRST");
}
void Mapper1_Init(CartInfo *info)
{
int ws=DetectMMC1WRAMSize(info->CRC32);
GenMMC1Init(info, 512, 256, ws, info->battery);
}
/* Same as mapper 1, without respect for WRAM enable bit. */
void Mapper155_Init(CartInfo *info)
{
GenMMC1Init(info,512,256,8,info->battery);
is155=1;
}
void SAROM_Init(CartInfo *info)
{
GenMMC1Init(info, 128, 64, 8, info->battery);
}
void SBROM_Init(CartInfo *info)
{
GenMMC1Init(info, 128, 64, 0, 0);
}
void SCROM_Init(CartInfo *info)
{
GenMMC1Init(info, 128, 128, 0, 0);
}
void SEROM_Init(CartInfo *info)
{
GenMMC1Init(info, 32, 64, 0, 0);
}
void SGROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 0, 0, 0);
}
void SKROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 64, 8, info->battery);
}
void SLROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 128, 0, 0);
}
void SL1ROM_Init(CartInfo *info)
{
GenMMC1Init(info, 128, 128, 0, 0);
}
/* Begin unknown - may be wrong - perhaps they use different MMC1s from the
similarly functioning boards?
*/
void SL2ROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 256, 0, 0);
}
void SFROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 256, 0, 0);
}
void SHROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 256, 0, 0);
}
/* End unknown */
/* */
/* */
void SNROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 0, 8, info->battery);
}
void SOROM_Init(CartInfo *info)
{
GenMMC1Init(info, 256, 0, 16, info->battery);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
extern uint8 MMC3_cmd;
extern uint8 *WRAM;
extern uint8 *CHRRAM;
extern uint8 EXPREGS[8];
extern uint8 DRegBuf[8];
#undef IRQCount
#undef IRQLatch
#undef IRQa
extern uint8 IRQCount,IRQLatch,IRQa;
extern uint8 IRQReload;
extern void (*pwrap)(uint32 A, uint8 V);
extern void (*cwrap)(uint32 A, uint8 V);
extern void (*mwrap)(uint8 V);
void GenMMC3Power(void);
void GenMMC3Restore(int version);
void MMC3RegReset(void);
void FixMMC3PRG(int V);
void FixMMC3CHR(int V);
DECLFW(MMC3_CMDWrite);
DECLFW(MMC3_IRQWrite);
void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery);

Some files were not shown because too many files have changed in this diff Show More