X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=fds.c;h=501aefcc86a2ef3c8d86d2835c003b4bd7af9956;hp=f0640a0f2ff98ebe0aa5a732bcd1a0b41172777d;hb=642070a99a18726024c5b214263221a0340e6987;hpb=d97315ac0bca825d2d50a44453bc5652946e2c67 diff --git a/fds.c b/fds.c index f0640a0..501aefc 100644 --- a/fds.c +++ b/fds.c @@ -22,6 +22,10 @@ #include #include +#ifdef GP2X +#include // for sync() +#endif + #include "types.h" #include "x6502.h" #include "fce.h" @@ -85,12 +89,13 @@ static uint8 SelectDisk,InDisk; #define DC_INC 1 -void FDSGI(int h) +void FDSGI(int h, void *param) { switch(h) { case GI_CLOSE: FDSClose();break; case GI_POWER: FDSInit();break; + case GI_INFOSTRING: sprintf(param, "FDS, Sides: %d", TotalSides);break; } } @@ -144,6 +149,17 @@ static void FDSInit(void) FDSSoundReset(); InDisk=0; SelectDisk=0; + +#ifdef ASM_6502 + { + int page; + // asm code needs pages to be set again.. + for (page=12; page<28; page++) // 0x6000-0xdfff 32K RAM + Page[page]=FDSRAM - (12<<11); + for (; page<32; page++) // 0xe000-0xffff 8K BIOS + Page[page]=FDSBIOS - (28<<11); + } +#endif } void FCEU_FDSInsert(void) @@ -188,7 +204,7 @@ void FCEU_FDSSelect(void) static void FP_FASTAPASS(1) FDSFix(int a) { - if((IRQa&2) && IRQCount) + if(IRQCount && (IRQa&2)) { IRQCount-=a; if(IRQCount<=0) @@ -224,8 +240,13 @@ static DECLFR(FDSRead4030) uint8 ret=0; /* Cheap hack. */ +#ifndef ASM_6502 if(X.IRQlow&FCEU_IQEXT) ret|=1; if(X.IRQlow&FCEU_IQEXT2) ret|=2; +#else + if((nes_registers[4]>>8)&FCEU_IQEXT) ret|=1; + if((nes_registers[4]>>8)&FCEU_IQEXT2) ret|=2; +#endif if(!fceuindbg) { @@ -485,7 +506,7 @@ static INLINE void ClockFall(void) clockcount=(clockcount+1)&7; } -static INLINE int32 FDSDoSound(void) +static INLINE int32 FDSDoSound(int32 mul) { fdso.count+=fdso.cycles; if(fdso.count>=((int64)1<<40)) @@ -504,11 +525,14 @@ static INLINE int32 FDSDoSound(void) if(fdso.count>=32768) goto dogk; // Might need to emulate applying the amplitude to the waveform a bit better... +/* { int k=amplitude[0]; if(k>0x20) k=0x20; return (fdso.cwave[b24latch68>>19]*k)*4/((SPSG[0x9]&0x3)+2); } +*/ + return (fdso.cwave[b24latch68>>19]*mul)>>16; } static int32 FBC=0; @@ -517,6 +541,7 @@ static void RenderSound(void) { int32 end, start; int32 x; + int32 mul; start=FBC; end=(SOUNDTS<<16)/soundtsinc; @@ -524,10 +549,27 @@ static void RenderSound(void) return; FBC=end; + // hack for performance, might produce bad results.. + if (!amplitude[0]) + return; + + switch (SPSG[0x9]&0x3) + { + default:mul = (4<<16)/2; + case 1: mul = (4<<16)/3; + case 2: mul = (4<<16)/4; + case 3: mul = (4<<16)/5; + } + { + int k=amplitude[0]; + if(k>0x20) k=0x20; + mul *= k; + } + if(!(SPSG[0x9]&0x80)) for(x=start;x>1; t>>=4; Wave[x>>4]+=t; //(t>>2)-(t>>3); //>>3; @@ -782,6 +824,7 @@ int FDSLoad(const char *name, int fp) FCEU_PrintError("FDS BIOS ROM image missing!"); FreeFDSMemory(); free(fn); + LoadGameLastError = 10; return 0; } @@ -792,6 +835,7 @@ int FDSLoad(const char *name, int fp) fclose(zp); FreeFDSMemory(); FCEU_PrintError("Error reading FDS BIOS ROM image."); + LoadGameLastError = 10; return 0; } @@ -816,6 +860,7 @@ int FDSLoad(const char *name, int fp) { FCEU_PrintError("Error reading auxillary FDS file."); free(fn); + LoadGameLastError = 11; return(0); } FCEU_fclose(tp); @@ -870,26 +915,41 @@ void FDSClose(void) { FILE *fp; int x; - char *fn=FCEU_MakeFName(FCEUMKF_FDS,0,0); - - if(!DiskWritten) return; + char *fn; - if(!(fp=FCEUD_UTF8fopen(fn,"wb"))) + if(!DiskWritten) { - free(fn); - return; - } - free(fn); + fn=FCEU_MakeFName(FCEUMKF_FDS,0,0); - for(x=0;x