X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=nsf.c;h=52da5e5ac842ca6de45345dc323f881e81f83258;hp=9e09cfb3727767d25b6a57924bbfd86d5c7cc976;hb=158d88bade9b4fc038e1c9cee3924f3c89a70caa;hpb=d97315ac0bca825d2d50a44453bc5652946e2c67 diff --git a/nsf.c b/nsf.c index 9e09cfb..52da5e5 100644 --- a/nsf.c +++ b/nsf.c @@ -42,6 +42,9 @@ #define M_PI 3.14159265358979323846 #endif +#define SCREEN_WIDTH 320 +#define SCREEN_OFFS 32 + static uint8 SongReload; static int CurrentSong; @@ -97,7 +100,7 @@ static NSF_HEADER NSFHeader; void NSFMMC5_Close(void); static uint8 *ExWRAM=0; -void NSFGI(int h) +void NSFGI(int h, void *param) { switch(h) { @@ -120,6 +123,9 @@ void NSFGI(int h) break; case GI_RESETM2: case GI_POWER: NSF_init();break; + case GI_INFOSTRING: + sprintf(param, "NSF, %s", PAL?"PAL":"NTSC"); + break; } } @@ -297,6 +303,7 @@ void NSF_init(void) SetReadHandler(0x2000,0x37ff,0); SetReadHandler(0x3836,0x3FFF,0); SetReadHandler(0x3800,0x3835,NSFROMRead); + Page[0x3800>>11]=NSFROM-0x3800; // this is required for asm core to work. SetWriteHandler(0x5ff6,0x5fff,NSF_write); @@ -399,36 +406,35 @@ static int special=0; void DrawNSF(uint8 *XBuf) { char snbuf[16]; + int32 mul=0; int x; if(vismode==0) return; - memset(XBuf,0,256*240); + for (x=0;x<240;x++) + memset(XBuf+SCREEN_OFFS+x*SCREEN_WIDTH,0,256); + if(FSettings.SoundVolume) + mul=8192*240/(16384*FSettings.SoundVolume/50); { - int32 *Bufpl; - int32 mul=0; + int16 *Bufpl; int l; l=GetSoundBuffer(&Bufpl); if(special==0) { - if(FSettings.SoundVolume) - mul=8192*240/(16384*FSettings.SoundVolume/50); for(x=0;x<256;x++) { uint32 y; y=142+((Bufpl[(x*l)>>8]*mul)>>14); if(y<240) - XBuf[x+y*256]=3; + XBuf[x+y*SCREEN_WIDTH+SCREEN_OFFS]=3; } } else if(special==1) { - if(FSettings.SoundVolume) - mul=8192*240/(8192*FSettings.SoundVolume/50); for(x=0;x<256;x++) { double r; @@ -439,14 +445,12 @@ void DrawNSF(uint8 *XBuf) yp=120+r*sin(x*M_PI*2/256); xp&=255; yp%=240; - XBuf[xp+yp*256]=3; + XBuf[xp+yp*SCREEN_WIDTH+SCREEN_OFFS]=3; } } else if(special==2) { static double theta=0; - if(FSettings.SoundVolume) - mul=8192*240/(16384*FSettings.SoundVolume/50); for(x=0;x<128;x++) { double xc,yc; @@ -463,7 +467,7 @@ void DrawNSF(uint8 *XBuf) n=120+r*sin(t); if(m<256 && n<240) - XBuf[m+n*256]=3; + XBuf[m+n*SCREEN_WIDTH+SCREEN_OFFS]=3; } for(x=128;x<256;x++) @@ -482,20 +486,20 @@ void DrawNSF(uint8 *XBuf) n=120+r*sin(t); if(m<256 && n<240) - XBuf[m+n*256]=3; + XBuf[m+n*SCREEN_WIDTH+SCREEN_OFFS]=3; } theta+=(double)M_PI/256; } } - DrawTextTrans(XBuf+10*256+4+(((31-strlen((char*)NSFHeader.SongName))<<2)), 256, NSFHeader.SongName, 6); - DrawTextTrans(XBuf+26*256+4+(((31-strlen((char*)NSFHeader.Artist))<<2)), 256,NSFHeader.Artist, 6); - DrawTextTrans(XBuf+42*256+4+(((31-strlen((char*)NSFHeader.Copyright))<<2)), 256,NSFHeader.Copyright, 6); + DrawTextTrans(XBuf+10*SCREEN_WIDTH+SCREEN_OFFS+4+(((31-strlen((char*)NSFHeader.SongName))<<2)), SCREEN_WIDTH, NSFHeader.SongName, 6); + DrawTextTrans(XBuf+26*SCREEN_WIDTH+SCREEN_OFFS+4+(((31-strlen((char*)NSFHeader.Artist))<<2)), SCREEN_WIDTH,NSFHeader.Artist, 6); + DrawTextTrans(XBuf+42*SCREEN_WIDTH+SCREEN_OFFS+4+(((31-strlen((char*)NSFHeader.Copyright))<<2)), SCREEN_WIDTH,NSFHeader.Copyright, 6); - DrawTextTrans(XBuf+70*256+4+(((31-strlen("Song:"))<<2)), 256, (uint8*)"Song:", 6); + DrawTextTrans(XBuf+70*SCREEN_WIDTH+SCREEN_OFFS+4+(((31-strlen("Song:"))<<2)), SCREEN_WIDTH, (uint8*)"Song:", 6); sprintf(snbuf,"<%d/%d>",CurrentSong,NSFHeader.TotalSongs); - DrawTextTrans(XBuf+82*256+4+(((31-strlen(snbuf))<<2)), 256, (uint8*)snbuf, 6); + DrawTextTrans(XBuf+82*SCREEN_WIDTH+SCREEN_OFFS+4+(((31-strlen(snbuf))<<2)), SCREEN_WIDTH, (uint8*)snbuf, 6); { static uint8 last=0;