- discarding all of the dos stuff... go to the attic if you want it back
This commit is contained in:
parent
da3c1f6b29
commit
31feffda2f
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
@ -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];
|
|
@ -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);
|
||||
}
|
|
@ -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(®s,0,sizeof(regs));
|
||||
regs.x.ax=0;
|
||||
__dpmi_int(0x33,®s);
|
||||
if(regs.x.ax!=0xFFFF)
|
||||
return(0);
|
||||
|
||||
memset(®s,0,sizeof(regs));
|
||||
regs.x.ax=0x7;
|
||||
regs.x.cx=0; // Min X
|
||||
regs.x.dx=260; // Max X
|
||||
__dpmi_int(0x33,®s);
|
||||
|
||||
memset(®s,0,sizeof(regs));
|
||||
regs.x.ax=0x8;
|
||||
regs.x.cx=0; // Min Y
|
||||
regs.x.dx=260; // Max Y
|
||||
__dpmi_int(0x33,®s);
|
||||
|
||||
memset(®s,0,sizeof(regs));
|
||||
regs.x.ax=0xF;
|
||||
regs.x.cx=8; // Mickey X
|
||||
regs.x.dx=8; // Mickey Y
|
||||
__dpmi_int(0x33,®s);
|
||||
|
||||
memset(®s,0,sizeof(regs));
|
||||
regs.x.ax=0x2;
|
||||
__dpmi_int(0x33,®s);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
uint32 GetMouseData(uint32 *x, uint32 *y)
|
||||
{
|
||||
if(FCEUI_IsMovieActive()<0)
|
||||
return;
|
||||
|
||||
__dpmi_regs regs;
|
||||
|
||||
memset(®s,0,sizeof(regs));
|
||||
regs.x.ax=0x3;
|
||||
__dpmi_int(0x33,®s);
|
||||
|
||||
*x=regs.x.cx;
|
||||
*y=regs.x.dx;
|
||||
return(regs.x.bx&3);
|
||||
}
|
||||
|
||||
void KillMouse(void)
|
||||
{
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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);
|
||||
|
|
@ -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(®s,0,sizeof(regs));
|
||||
regs.x.ax=mode;
|
||||
|
||||
__dpmi_int(0x10,®s);
|
||||
}
|
||||
|
||||
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" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
|
128
drivers/pc/dos.c
128
drivers/pc/dos.c
|
@ -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));
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifdef SDL
|
||||
#include <SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#define SDLK_A SDLK_a
|
||||
#define SDLK_B SDLK_b
|
||||
#define SDLK_C SDLK_c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <SDL.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include "main.h"
|
||||
#include "dface.h"
|
||||
#include "input.h"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue