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__
void UpdateSound(void *userdata, Uint8 *stream, int len);
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();
@@ -448,59 +453,32 @@ int InitSound (void)
PrevSoundQuality = SoundQuality;
PrevStereoSound = StereoSound;
switch(SoundQuality) {
case 0:
wanted.freq = 8000;
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 (SoundQuality > 6)
SoundQuality = 1;
wanted.freq = freqtab[SoundQuality];
if (StereoSound) {
wanted.channels = 2;
wanted.samples *= 2;
} else {
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.userdata = NULL;
wanted.callback = UpdateSound;
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;
return FALSE;
}
SDL_PauseAudio(0);
SDL_UnlockAudio();
return TRUE;
}
#else // __WIN32__
@@ -1256,8 +1234,6 @@ void UnlockSurface(void)
void WinUpdateDevices();
DWORD NeedBuffer=1;
short Buffer[1800*2];
int Running=0;
unsigned char Noise[]={
@@ -1561,8 +1537,7 @@ SM_CYSCREEN )-WindowHeight);
extern unsigned int vidbuffer;
extern void SoundProcess();
extern int DSPBuffer;
int * DSPBuffer1;
extern int DSPBuffer[];
DWORD ScreenPtr;
DWORD ScreenPtr2;
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__
void UpdateSound(void *userdata, Uint8 *stream, int len)
{
int SPCSize = 256;
const int SPCSize = 256;
int DataNeeded;
int i;
Uint8 *ptr;
len /= 2; /* only 16bit here */
ptr = stream;
DataNeeded = len;
//DataNeeded /= (SPCSize * 2);
//DataNeeded *= (SPCSize * 2);
/* take care of the things we left behind last time */
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) {
SoundProcess();
DSPBuffer1=(int *)&DSPBuffer;
for (i = 0; i < SPCSize; i++) {
if (T36HZEnabled) {
Buffer[i]=0;
} else {
if(DSPBuffer1[i]>32767)Buffer[i]=32767;
else if(DSPBuffer1[i]<-32767)Buffer[i]=-32767;
else Buffer[i]=DSPBuffer1[i];
if(DSPBuffer[i]>32767)Buffer[i]=32767;
else if(DSPBuffer[i]<-32767)Buffer[i]=-32767;
else Buffer[i]=DSPBuffer[i];
}
}
memcpy(ptr, &Buffer[0], 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

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,10 @@ EXTSYM romloadskip
EXTSYM cfgloadgdir,cfgloadsdir
EXTSYM init18_2hz
%ifdef __LINUX__
EXTSYM SDL_Quit
%endif
NEWSYM UIAsmStart
%include "betauser.mac"
@@ -43,6 +47,7 @@ NEWSYM UIAsmStart
extern puts
; Function 0501h
; User Interface
@@ -52,6 +57,9 @@ SECTION .text
NEWSYM zstart
call StartUp
mov edx,mydebug
call PrintStr
mov edx,welcome ;welcome message
call PrintStr
@@ -64,11 +72,11 @@ NEWSYM zstart
mov byte[soundon],1
call allocmem ;allocate memory
; xor eax,eax
; mov al,[soundon]
; call printnum
; xor eax,eax
; mov al,[soundon]
; call printnum
; jmp DosExit
; jmp DosExit
cmp byte[soundon],0
jne .yessound
@@ -117,6 +125,7 @@ NEWSYM outofmemory
jmp DosExit
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
%define ZVERSION '18 '
;%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 'PRIVATE BETA VERSION!!! PLEASE DO NOT DISTRIBUTE!!! Thank you!',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
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
%endif
%endif
db ' Programmers : zsKnight, _Demo_',13,10
db ' Assistant Coder : Pharos',13,10,13,10
@@ -278,6 +293,7 @@ SECTION .text
;*******************************************************
NEWSYM AllocMem
%ifndef __LINUX__
mov ax,0501h
mov cx,bx
shr ebx,16
@@ -286,6 +302,7 @@ NEWSYM AllocMem
mov ax,bx
shl eax,16
mov ax,cx
%endif
ret
;*******************************************************
@@ -1250,17 +1267,30 @@ SECTION .text
NEWSYM displayparams
mov edx,.noparams ;use extended
call PrintStr
%ifndef __LINUX__
call WaitForKey
%endif
mov edx,.noparms2 ;use extended
call PrintStr
%ifndef __LINUX__
call WaitForKey
%endif
mov edx,.noparms3 ;use extended
call PrintStr
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
%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
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 ' -1 #/-2 # Select Player 1/2 Input :',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 ' -9 Off by 1 line fix',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
%endif
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
; debugger not available in linux version
; because of bios interrupt code
%ifndef __LINUX__
db ' -d Start with debugger',13,10
%endif
db ' -dd Disable sound DSP emulation',13,10
%ifndef __LINUX__
db ' -e Skip enter key press at the beginning',13,10
%endif
db ' -f # Turn on frame skip [0..9]',13,10
db ' -g # Set Gamma Correction [0..5, 0 = Normal]',13,10
db ' -h Force HiROM',13,10
@@ -1285,17 +1327,26 @@ SECTION .data
.noparms2 db 13,' -l Force LoROM ',13,10
db ' -m Disable GUI',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
%endif
db ' -om Enable MMX copy',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 ' 0 = 8000Hz 1 = 11025Hz 2 = 22050Hz 3 = 44100Hz',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
%endif
db ' -sa Show all extensions in GUI (*.*)',13,10
db ' -sn Enable Snowy GUI Background',13,10
db ' -t Force NTSC timing',13,10
db ' -u Force PAL timing',13,10
%ifndef __LINUX__
db ' -v # Select Video Mode :',13,10
db ' 0 = 320x240x256 1 = 256x256x256',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 ' 8 = 640x480x16b(VESA1.2) 9 = 320x480x256(VESA2) ',13,10
db ' 10 = 320x480x65536(VESA2)',13,10
%endif
db ' -w Enable VSync',13,10
db 'Press any key to continue.',0
.noparms3 db 13,' -y Enable EAGLE (640x480x256 only) or Interpolation (640x480x65536 only)',13,10
@@ -1314,6 +1366,7 @@ SECTION .data
SECTION .text
NEWSYM obtaindir
%ifndef __LINUX__
cmp byte[cfgloadsdir],1
je .nosdriveb
mov ebx,SRAMDir
@@ -1326,6 +1379,7 @@ NEWSYM obtaindir
mov edx,LoadDrive
call Get_Dir
.noldriveb
%endif
ret
NEWSYM preparedir
@@ -1337,6 +1391,7 @@ NEWSYM preparedir
; DS:ESI -> 64 byte buffer to receive ASCIZ pathname
; get current drive, ah = 19h, al = A=0,B=1, etc.
%ifndef __LINUX__
cmp byte[cfgloadsdir],0
je near .nosdrivec
; verify sram drive/directory exists
@@ -1373,6 +1428,7 @@ NEWSYM preparedir
mov ebx,InitDir
call Change_Dir
.nosdrivec
%endif
ret
SECTION .data
@@ -1387,16 +1443,25 @@ NEWSYM SRAMDir, times 512 db 0
NEWSYM LoadDrive, db 2
NEWSYM LoadDir, times 512 db 0
%ifdef __LINUX__
NEWSYM gotoroot, db '/',0
%else
NEWSYM gotoroot, db '\',0
%endif
SECTION .text
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
mov ebx,memfreearray
.nextdeallocate
.nextdeallocate
mov eax,[ebx]
or eax,eax
jz .nodeallocate
@@ -1411,5 +1476,5 @@ NEWSYM DosExit ; Terminate Program
call init18_2hz
mov ax,4c00h ;terminate
int 21h
%endif
NEWSYM UIAsmEnd