Added eviltypeguy's significant patch to fixup command line arguments.

Added a __NO_GETOPT define until we can find a resolution for ragweed's problems
Added a patch from relnev to fix some sound problems where too many sounds are
playing at once.
This commit is contained in:
theoddone33
2001-04-14 19:07:38 +00:00
parent d5edeac915
commit 3d00b7f21a
3 changed files with 2193 additions and 2044 deletions

View File

@@ -435,11 +435,16 @@ void ShutdownApplication()
} }
#ifdef __LINUX__ #ifdef __LINUX__
void UpdateSound(void *userdata, Uint8 *stream, int len); void UpdateSound(void *userdata, Uint8 *stream, int len);
int InitSound (void) int InitSound (void)
{ {
static SDL_AudioSpec wanted; SDL_AudioSpec wanted;
const int freqtab[7] = { 8000, 11025, 22050, 44100, 16000, 32000, 48000 };
const int samptab[7] = { 64, 64, 128, 256, 128, 256, 256 };
SDL_LockAudio(); /* wait for callback to finish */
SDL_CloseAudio(); SDL_CloseAudio();
@@ -448,59 +453,32 @@ int InitSound (void)
PrevSoundQuality = SoundQuality; PrevSoundQuality = SoundQuality;
PrevStereoSound = StereoSound; PrevStereoSound = StereoSound;
switch(SoundQuality) { if (SoundQuality > 6)
case 0: SoundQuality = 1;
wanted.freq = 8000; wanted.freq = freqtab[SoundQuality];
wanted.samples = 1024*2;
break;
case 1:
wanted.freq = 11025;
wanted.samples = 1024*2;
break;
case 2:
wanted.freq = 22050;
wanted.samples = 1024*4;
break;
case 3:
wanted.freq = 44100;
wanted.samples = 1024*8;
break;
case 4:
wanted.freq = 16000;
wanted.samples = 1024*4;
break;
case 5:
wanted.freq = 32000;
wanted.samples = 1024*8;
break;
case 6:
wanted.freq = 48000;
wanted.samples = 1024*8;
break;
default:
wanted.freq = 11025;
wanted.samples = 1024*2;
break;
}
if (StereoSound) { if (StereoSound) {
wanted.channels = 2; wanted.channels = 2;
wanted.samples *= 2;
} else { } else {
wanted.channels = 1; wanted.channels = 1;
} }
wanted.samples /= 8; //wanted.samples = (wanted.freq / 60) * 2 * wanted.channels;
wanted.samples = samptab[SoundQuality] * 2 * wanted.channels;
wanted.format = AUDIO_S16LSB; wanted.format = AUDIO_S16LSB;
wanted.userdata = NULL; wanted.userdata = NULL;
wanted.callback = UpdateSound; wanted.callback = UpdateSound;
if (SDL_OpenAudio(&wanted, NULL) < 0) { if (SDL_OpenAudio(&wanted, NULL) < 0) {
fprintf(stderr, "Sound init failed!\n");
fprintf(stderr, "freq: %d, channels: %d, samples: %d\n", wanted.freq, wanted.channels, wanted.samples);
SoundEnabled = 0; SoundEnabled = 0;
return FALSE; return FALSE;
} }
SDL_PauseAudio(0); SDL_PauseAudio(0);
SDL_UnlockAudio();
return TRUE; return TRUE;
} }
#else // __WIN32__ #else // __WIN32__
@@ -1256,8 +1234,6 @@ void UnlockSurface(void)
void WinUpdateDevices(); void WinUpdateDevices();
DWORD NeedBuffer=1;
short Buffer[1800*2];
int Running=0; int Running=0;
unsigned char Noise[]={ unsigned char Noise[]={
@@ -1561,8 +1537,7 @@ SM_CYSCREEN )-WindowHeight);
extern unsigned int vidbuffer; extern unsigned int vidbuffer;
extern void SoundProcess(); extern void SoundProcess();
extern int DSPBuffer; extern int DSPBuffer[];
int * DSPBuffer1;
DWORD ScreenPtr; DWORD ScreenPtr;
DWORD ScreenPtr2; DWORD ScreenPtr2;
extern int GUI36hzcall(void); extern int GUI36hzcall(void);
@@ -1628,39 +1603,73 @@ void CheckTimers(void)
} }
} }
/* should we clear these on sound reset? */
DWORD BufferLeftOver=0;
short Buffer[1800*2];
#ifdef __LINUX__ #ifdef __LINUX__
void UpdateSound(void *userdata, Uint8 *stream, int len) void UpdateSound(void *userdata, Uint8 *stream, int len)
{ {
int SPCSize = 256; const int SPCSize = 256;
int DataNeeded; int DataNeeded;
int i; int i;
Uint8 *ptr; Uint8 *ptr;
len /= 2; /* only 16bit here */
ptr = stream; ptr = stream;
DataNeeded = len; DataNeeded = len;
//DataNeeded /= (SPCSize * 2); /* take care of the things we left behind last time */
//DataNeeded *= (SPCSize * 2); if (BufferLeftOver) {
DataNeeded -= BufferLeftOver;
memcpy(ptr, &Buffer[BufferLeftOver], (SPCSize-BufferLeftOver)*2);
ptr += (SPCSize-BufferLeftOver)*2;
BufferLeftOver = 0;
}
if (len & 255) { /* we'll save the rest first */
DataNeeded -= 256;
}
while (DataNeeded > 0) { while (DataNeeded > 0) {
SoundProcess(); SoundProcess();
DSPBuffer1=(int *)&DSPBuffer;
for (i = 0; i < SPCSize; i++) { for (i = 0; i < SPCSize; i++) {
if (T36HZEnabled) { if (T36HZEnabled) {
Buffer[i]=0; Buffer[i]=0;
} else { } else {
if(DSPBuffer1[i]>32767)Buffer[i]=32767; if(DSPBuffer[i]>32767)Buffer[i]=32767;
else if(DSPBuffer1[i]<-32767)Buffer[i]=-32767; else if(DSPBuffer[i]<-32767)Buffer[i]=-32767;
else Buffer[i]=DSPBuffer1[i]; else Buffer[i]=DSPBuffer[i];
} }
} }
memcpy(ptr, &Buffer[0], SPCSize*2); memcpy(ptr, &Buffer[0], SPCSize*2);
ptr += SPCSize*2; ptr += SPCSize*2;
DataNeeded -= (SPCSize*2); DataNeeded -= SPCSize;
}
if (DataNeeded) {
DataNeeded += 256;
BufferLeftOver = DataNeeded;
SoundProcess();
for (i = 0; i < SPCSize; i++) {
if (T36HZEnabled) {
Buffer[i] = 0;
} else {
if(DSPBuffer[i]>32767)Buffer[i]=32767;
else if(DSPBuffer[i]<-32767)Buffer[i]=-32767;
else Buffer[i]=DSPBuffer[i];
}
}
memcpy(ptr, &Buffer[0], DataNeeded*2);
} }
} }
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,10 @@ EXTSYM romloadskip
EXTSYM cfgloadgdir,cfgloadsdir EXTSYM cfgloadgdir,cfgloadsdir
EXTSYM init18_2hz EXTSYM init18_2hz
%ifdef __LINUX__
EXTSYM SDL_Quit
%endif
NEWSYM UIAsmStart NEWSYM UIAsmStart
%include "betauser.mac" %include "betauser.mac"
@@ -43,6 +47,7 @@ NEWSYM UIAsmStart
extern puts
; Function 0501h ; Function 0501h
; User Interface ; User Interface
@@ -52,6 +57,9 @@ SECTION .text
NEWSYM zstart NEWSYM zstart
call StartUp call StartUp
mov edx,mydebug
call PrintStr
mov edx,welcome ;welcome message mov edx,welcome ;welcome message
call PrintStr call PrintStr
@@ -64,11 +72,11 @@ NEWSYM zstart
mov byte[soundon],1 mov byte[soundon],1
call allocmem ;allocate memory call allocmem ;allocate memory
; xor eax,eax ; xor eax,eax
; mov al,[soundon] ; mov al,[soundon]
; call printnum ; call printnum
; jmp DosExit ; jmp DosExit
cmp byte[soundon],0 cmp byte[soundon],0
jne .yessound jne .yessound
@@ -117,6 +125,7 @@ NEWSYM outofmemory
jmp DosExit jmp DosExit
SECTION .data SECTION .data
NEWSYM mydebug, db '',13,10,0
NEWSYM outofmem, db 'You don',39,'t have enough memory to run this program!',13,10,0 NEWSYM outofmem, db 'You don',39,'t have enough memory to run this program!',13,10,0
%define ZVERSION '18 ' %define ZVERSION '18 '
;%define ZBETA 0 ;%define ZBETA 0
@@ -127,9 +136,15 @@ NEWSYM welcome
db 'ZSNES v1.',ZVERSION,' beta (c)1997-2001, Compiled under NASM, GCC, and WDOSX',13,10 db 'ZSNES v1.',ZVERSION,' beta (c)1997-2001, Compiled under NASM, GCC, and WDOSX',13,10
db 'PRIVATE BETA VERSION!!! PLEASE DO NOT DISTRIBUTE!!! Thank you!',13,10 db 'PRIVATE BETA VERSION!!! PLEASE DO NOT DISTRIBUTE!!! Thank you!',13,10
db 'Private Beta is Registered to : ',USERNAMEN,13,10 db 'Private Beta is Registered to : ',USERNAMEN,13,10
%else
%ifdef __LINUX__
db 'ZSNES v1.',ZVERSION,' beta (c)1997-2001 ZSNES Team (zsKnight - _Demo_)',13,10
db 'LINUX BETA VERSION!!! EXPECT CRASHES!!! Thank you!',13,10
db 'Compiled under NASM, GCC',13,10,13,10
%else %else
db 'ZSNES v1.',ZVERSION,' beta (c)1997-2001 ZSNES Team (zsKnight - _Demo_)',13,10 db 'ZSNES v1.',ZVERSION,' beta (c)1997-2001 ZSNES Team (zsKnight - _Demo_)',13,10
db 'Compiled under NASM, GCC, and WDOSX',13,10,13,10 db 'Compiled under NASM, GCC, and WDOSX',13,10,13,10
%endif
%endif %endif
db ' Programmers : zsKnight, _Demo_',13,10 db ' Programmers : zsKnight, _Demo_',13,10
db ' Assistant Coder : Pharos',13,10,13,10 db ' Assistant Coder : Pharos',13,10,13,10
@@ -278,6 +293,7 @@ SECTION .text
;******************************************************* ;*******************************************************
NEWSYM AllocMem NEWSYM AllocMem
%ifndef __LINUX__
mov ax,0501h mov ax,0501h
mov cx,bx mov cx,bx
shr ebx,16 shr ebx,16
@@ -286,6 +302,7 @@ NEWSYM AllocMem
mov ax,bx mov ax,bx
shl eax,16 shl eax,16
mov ax,cx mov ax,cx
%endif
ret ret
;******************************************************* ;*******************************************************
@@ -1250,17 +1267,30 @@ SECTION .text
NEWSYM displayparams NEWSYM displayparams
mov edx,.noparams ;use extended mov edx,.noparams ;use extended
call PrintStr call PrintStr
%ifndef __LINUX__
call WaitForKey call WaitForKey
%endif
mov edx,.noparms2 ;use extended mov edx,.noparms2 ;use extended
call PrintStr call PrintStr
%ifndef __LINUX__
call WaitForKey call WaitForKey
%endif
mov edx,.noparms3 ;use extended mov edx,.noparms3 ;use extended
call PrintStr call PrintStr
jmp DosExit jmp DosExit
; yes it sucks, i had to change the one character options to have at least two characters
; that way i could distinguish from the other two character options that share the same
; first letter...only way getopt works correctly :|
; EvilTypeGuy
SECTION .data SECTION .data
%ifdef __LINUX__
.noparams db 'Usage : zsnes [-d,-f #, ... ] <filename.smc>',13,10
db ' Eg : zsnes -s -r 2 game.smc',13,10,13,10
%else
.noparams db 'Usage : ZSNES [-d,-f #, ... ] <filename.SMC>',13,10 .noparams db 'Usage : ZSNES [-d,-f #, ... ] <filename.SMC>',13,10
db ' Eg : ZSNES -s -r 2 game.smc',13,10,13,10 db ' Eg : ZSNES -s -r 2 game.smc',13,10,13,10
%endif
db ' -0 Disable Color 0 modification in 256 color modes',13,10 db ' -0 Disable Color 0 modification in 256 color modes',13,10
db ' -1 #/-2 # Select Player 1/2 Input :',13,10 db ' -1 #/-2 # Select Player 1/2 Input :',13,10
db ' 0 = None 1 = Keyboard 2 = Joystick 3 = Gamepad',13,10 db ' 0 = None 1 = Keyboard 2 = Joystick 3 = Gamepad',13,10
@@ -1269,12 +1299,24 @@ SECTION .data
db ' -8 Force 8-bit sound',13,10 db ' -8 Force 8-bit sound',13,10
db ' -9 Off by 1 line fix',13,10 db ' -9 Off by 1 line fix',13,10
db ' -a Turn on auto frame skip',13,10 db ' -a Turn on auto frame skip',13,10
%ifdef __LINUX__
db ' -cs Scale to fit screen (320x240 VESA2/640x480 VESA2)',13,10
%else
db ' -c Scale to fit screen (320x240 VESA2/640x480 VESA2)',13,10 db ' -c Scale to fit screen (320x240 VESA2/640x480 VESA2)',13,10
%endif
db ' -cb Remove Background Color in 256 color video modes',13,10 db ' -cb Remove Background Color in 256 color video modes',13,10
db ' -cc No image scale and center image in screen (640x480 VESA2)',13,10 db ' -cc No image scale and center image in screen (640x480 VESA2)',13,10
; debugger not available in linux version
; because of bios interrupt code
%ifndef __LINUX__
db ' -d Start with debugger',13,10 db ' -d Start with debugger',13,10
%endif
db ' -dd Disable sound DSP emulation',13,10 db ' -dd Disable sound DSP emulation',13,10
%ifndef __LINUX__
db ' -e Skip enter key press at the beginning',13,10 db ' -e Skip enter key press at the beginning',13,10
%endif
db ' -f # Turn on frame skip [0..9]',13,10 db ' -f # Turn on frame skip [0..9]',13,10
db ' -g # Set Gamma Correction [0..5, 0 = Normal]',13,10 db ' -g # Set Gamma Correction [0..5, 0 = Normal]',13,10
db ' -h Force HiROM',13,10 db ' -h Force HiROM',13,10
@@ -1285,17 +1327,26 @@ SECTION .data
.noparms2 db 13,' -l Force LoROM ',13,10 .noparms2 db 13,' -l Force LoROM ',13,10
db ' -m Disable GUI',13,10 db ' -m Disable GUI',13,10
db ' -n Turn scanlines on (256x256 and 640x480 only)',13,10 db ' -n Turn scanlines on (256x256 and 640x480 only)',13,10
%ifdef __LINUX__
db ' -of Enable FPU copy ',13,10
%else
db ' -o Enable FPU copy ',13,10 db ' -o Enable FPU copy ',13,10
%endif
db ' -om Enable MMX copy',13,10 db ' -om Enable MMX copy',13,10
db ' -p # Percentage of instructions to execute [50..120]',13,10 db ' -p # Percentage of instructions to execute [50..120]',13,10
db ' -r # Set Sampling Sound Blaster Sampling Rate & Bit :',13,10 db ' -r # Set Sampling Sound Blaster Sampling Rate & Bit :',13,10
db ' 0 = 8000Hz 1 = 11025Hz 2 = 22050Hz 3 = 44100Hz',13,10 db ' 0 = 8000Hz 1 = 11025Hz 2 = 22050Hz 3 = 44100Hz',13,10
db ' 4 = 16000Hz 5 = 32000Hz',13,10 db ' 4 = 16000Hz 5 = 32000Hz',13,10
%ifdef __LINUX__
db ' -se Enable SPC700/DSP emulation (Sound)',13,10
%else
db ' -s Enable SPC700/DSP emulation (Sound)',13,10 db ' -s Enable SPC700/DSP emulation (Sound)',13,10
%endif
db ' -sa Show all extensions in GUI (*.*)',13,10 db ' -sa Show all extensions in GUI (*.*)',13,10
db ' -sn Enable Snowy GUI Background',13,10 db ' -sn Enable Snowy GUI Background',13,10
db ' -t Force NTSC timing',13,10 db ' -t Force NTSC timing',13,10
db ' -u Force PAL timing',13,10 db ' -u Force PAL timing',13,10
%ifndef __LINUX__
db ' -v # Select Video Mode :',13,10 db ' -v # Select Video Mode :',13,10
db ' 0 = 320x240x256 1 = 256x256x256',13,10 db ' 0 = 320x240x256 1 = 256x256x256',13,10
db ' 2 = 320x240x256(VESA2) 3 = 320x240x16b(VESA2) ',13,10 db ' 2 = 320x240x256(VESA2) 3 = 320x240x16b(VESA2) ',13,10
@@ -1303,6 +1354,7 @@ SECTION .data
db ' 6 = 512x384x256(VESA2) 7 = 512x384x16b(VESA2) ',13,10 db ' 6 = 512x384x256(VESA2) 7 = 512x384x16b(VESA2) ',13,10
db ' 8 = 640x480x16b(VESA1.2) 9 = 320x480x256(VESA2) ',13,10 db ' 8 = 640x480x16b(VESA1.2) 9 = 320x480x256(VESA2) ',13,10
db ' 10 = 320x480x65536(VESA2)',13,10 db ' 10 = 320x480x65536(VESA2)',13,10
%endif
db ' -w Enable VSync',13,10 db ' -w Enable VSync',13,10
db 'Press any key to continue.',0 db 'Press any key to continue.',0
.noparms3 db 13,' -y Enable EAGLE (640x480x256 only) or Interpolation (640x480x65536 only)',13,10 .noparms3 db 13,' -y Enable EAGLE (640x480x256 only) or Interpolation (640x480x65536 only)',13,10
@@ -1314,6 +1366,7 @@ SECTION .data
SECTION .text SECTION .text
NEWSYM obtaindir NEWSYM obtaindir
%ifndef __LINUX__
cmp byte[cfgloadsdir],1 cmp byte[cfgloadsdir],1
je .nosdriveb je .nosdriveb
mov ebx,SRAMDir mov ebx,SRAMDir
@@ -1326,6 +1379,7 @@ NEWSYM obtaindir
mov edx,LoadDrive mov edx,LoadDrive
call Get_Dir call Get_Dir
.noldriveb .noldriveb
%endif
ret ret
NEWSYM preparedir NEWSYM preparedir
@@ -1337,6 +1391,7 @@ NEWSYM preparedir
; DS:ESI -> 64 byte buffer to receive ASCIZ pathname ; DS:ESI -> 64 byte buffer to receive ASCIZ pathname
; get current drive, ah = 19h, al = A=0,B=1, etc. ; get current drive, ah = 19h, al = A=0,B=1, etc.
%ifndef __LINUX__
cmp byte[cfgloadsdir],0 cmp byte[cfgloadsdir],0
je near .nosdrivec je near .nosdrivec
; verify sram drive/directory exists ; verify sram drive/directory exists
@@ -1373,6 +1428,7 @@ NEWSYM preparedir
mov ebx,InitDir mov ebx,InitDir
call Change_Dir call Change_Dir
.nosdrivec .nosdrivec
%endif
ret ret
SECTION .data SECTION .data
@@ -1387,16 +1443,25 @@ NEWSYM SRAMDir, times 512 db 0
NEWSYM LoadDrive, db 2 NEWSYM LoadDrive, db 2
NEWSYM LoadDir, times 512 db 0 NEWSYM LoadDir, times 512 db 0
%ifdef __LINUX__
NEWSYM gotoroot, db '/',0
%else
NEWSYM gotoroot, db '\',0 NEWSYM gotoroot, db '\',0
%endif
SECTION .text SECTION .text
NEWSYM DosExit ; Terminate Program NEWSYM DosExit ; Terminate Program
%ifdef __LINUX__
call SDL_Quit ; Properly terminate video stuff
mov ebx,0 ; first syscall argument: exit code
mov eax,1 ; system call number (sys_exit)
int 0x80 ; call kernel
%else
jmp .nodeallocate jmp .nodeallocate
mov ebx,memfreearray mov ebx,memfreearray
.nextdeallocate .nextdeallocate
mov eax,[ebx] mov eax,[ebx]
or eax,eax or eax,eax
jz .nodeallocate jz .nodeallocate
@@ -1411,5 +1476,5 @@ NEWSYM DosExit ; Terminate Program
call init18_2hz call init18_2hz
mov ax,4c00h ;terminate mov ax,4c00h ;terminate
int 21h int 21h
%endif
NEWSYM UIAsmEnd NEWSYM UIAsmEnd