From 13624c8f3ac5cd1b255a5078c5401b0f97037964 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 30 Apr 2007 23:52:47 +0000 Subject: [PATCH] asm compatibility re-fixed, nsf for asm fixed, msg displ git-svn-id: file:///home/notaz/opt/svn/fceu@121 be3aeb3a-fb24-0410-a615-afba39da0efa --- cart.c | 5 +++ drawing.h | 49 ++++++++++++++++-------------- drivers/gp2x/input.c | 72 +++++++++++++++++++------------------------- fce.c | 3 +- general.c | 1 + ncpu.S | 4 +-- nsf.c | 5 +-- video.c | 4 +-- 8 files changed, 72 insertions(+), 71 deletions(-) diff --git a/cart.c b/cart.c index ff9aceb..1113f35 100644 --- a/cart.c +++ b/cart.c @@ -167,6 +167,7 @@ void FASTAPASS(3) setprg2r(int r, unsigned int A, unsigned int V) { V&=PRGmask2[r]; setpageptr(2,A,PRGptr[r]?(&PRGptr[r][V<<11]):0,PRGram[r]); + X6502_Rebase(); } void FASTAPASS(2) setprg2(uint32 A, uint32 V) @@ -178,6 +179,7 @@ void FASTAPASS(3) setprg4r(int r, unsigned int A, unsigned int V) { V&=PRGmask4[r]; setpageptr(4,A,PRGptr[r]?(&PRGptr[r][V<<12]):0,PRGram[r]); + X6502_Rebase(); } void FASTAPASS(2) setprg4(uint32 A, uint32 V) @@ -199,6 +201,7 @@ void FASTAPASS(3) setprg8r(int r, unsigned int A, unsigned int V) for(x=0;x<4;x++) setpageptr(2,A+(x<<11),PRGptr[r]?(&PRGptr[r][((VA+x)&PRGmask2[r])<<11]):0,PRGram[r]); } + X6502_Rebase(); } void FASTAPASS(2) setprg8(uint32 A, uint32 V) @@ -221,6 +224,7 @@ void FASTAPASS(3) setprg16r(int r, unsigned int A, unsigned int V) for(x=0;x<8;x++) setpageptr(2,A+(x<<11),PRGptr[r]?(&PRGptr[r][((VA+x)&PRGmask2[r])<<11]):0,PRGram[r]); } + X6502_Rebase(); } void FASTAPASS(2) setprg16(uint32 A, uint32 V) @@ -243,6 +247,7 @@ void FASTAPASS(3) setprg32r(int r,unsigned int A, unsigned int V) for(x=0;x<16;x++) setpageptr(2,A+(x<<11),PRGptr[r]?(&PRGptr[r][((VA+x)&PRGmask2[r])<<11]):0,PRGram[r]); } + X6502_Rebase(); } void FASTAPASS(2) setprg32(uint32 A, uint32 V) diff --git a/drawing.h b/drawing.h index 22506a3..3d9b29d 100644 --- a/drawing.h +++ b/drawing.h @@ -1,3 +1,6 @@ +#define SCREEN_WIDTH 320 +#define SCREEN_OFFS 32 + void DrawTextLineBG(uint8 *dest) { int x,y; @@ -8,12 +11,12 @@ void DrawTextLineBG(uint8 *dest) int offs; if(y>=7) offs=otable[13-y]; - else offs=otable[y]; - + else offs=otable[y]; + for(x=offs;x<(256-offs);x++) - dest[y*256+x]=(dest[y*256+x]&0x0f)|0xC0;//&=0xe0; //0x80; + dest[y*SCREEN_WIDTH+x]=(dest[y*SCREEN_WIDTH+x]&0x0f)|0xC0;//&=0xe0; //0x80; } -} +} static void DrawMessage(void) { @@ -21,11 +24,11 @@ static void DrawMessage(void) { uint8 *t; howlong--; - t=XBuf+(FSettings.LastSLine-16)*256; + t=XBuf+(FSettings.LastSLine-16)*SCREEN_WIDTH+SCREEN_OFFS; if(t>=XBuf) { DrawTextLineBG(t); - DrawTextTrans(t+256*3+(128-strlen(errmsg)*4),256,(uint8 *)errmsg,4); + DrawTextTrans(t+3*SCREEN_WIDTH+(128-strlen(errmsg)*4),SCREEN_WIDTH,(uint8 *)errmsg,128+4); } } } @@ -49,9 +52,9 @@ void DrawTextTrans(uint8 *dest, uint32 width, uint8 *textmsg, uint8 fgcolor) uint8 y; uint8 z; - for(x=0;x>z)&1) dest[y*width+(x<<3)+z]=fgcolor; } @@ -78,39 +81,39 @@ void FCEU_DrawNumberRow(uint8 *XBuf, int *nstatus, int cur) { uint8 *XBaf; int z,x,y; - - XBaf=XBuf - 4 + (FSettings.LastSLine-34)*256; + + XBaf=XBuf - 4 + (FSettings.LastSLine-34)*SCREEN_WIDTH+SCREEN_OFFS; if(XBaf>=XBuf) for(z=1;z<11;z++) - { + { if(nstatus[z%10]) { for(y=0;y<13;y++) for(x=0;x<21;x++) - XBaf[y*256+x+z*21+z]=sstat[y*21+x+(z-1)*21*12]^0x80; + XBaf[y*SCREEN_WIDTH+x+z*21+z]=sstat[y*21+x+(z-1)*21*12]^0x80; } else { for(y=0;y<13;y++) for(x=0;x<21;x++) if(sstat[y*21+x+(z-1)*21*12]!=0x83) - XBaf[y*256+x+z*21+z]=sstat[y*21+x+(z-1)*21*12]^0x80; + XBaf[y*SCREEN_WIDTH+x+z*21+z]=sstat[y*21+x+(z-1)*21*12]^0x80; else - XBaf[y*256+x+z*21+z]=(XBaf[y*256+x+z*21+z]&0xF)|0xC0; + XBaf[y*SCREEN_WIDTH+x+z*21+z]=(XBaf[y*SCREEN_WIDTH+x+z*21+z]&0xF)|0xC0; } - if(cur==z%10) + if(cur==z%10) { for(x=0;x<21;x++) XBaf[x+z*21+z*1]=4; for(x=1;x<12;x++) { - XBaf[256*x+z*21+z*1]= - XBaf[256*x+z*21+z*1+20]=4; + XBaf[SCREEN_WIDTH*x+z*21+z*1]= + XBaf[SCREEN_WIDTH*x+z*21+z*1+20]=4; } for(x=0;x<21;x++) - XBaf[12*256+x+z*21+z*1]=4; + XBaf[12*SCREEN_WIDTH+x+z*21+z*1]=4; } } -} +} static uint8 play_slines[]= { @@ -206,11 +209,11 @@ void FCEU_DrawRecordingStatusN(uint8* XBuf, int n) uint8* slines=sline_icons[n]; int i; - XBuf += (FSettings.LastSLine-28)*256 + 240 + 255; + XBuf += (FSettings.LastSLine-28)*SCREEN_WIDTH+SCREEN_OFFS + 240 + 255; for(i=0; slines[i]!=99; i+=3) { int y=slines[i]; - uint8* dest=XBuf+(y*256); + uint8* dest=XBuf+(y*SCREEN_WIDTH); int x; for(x=slines[i+1]; x!=slines[i+2]; ++x) dest[x]=0; @@ -220,7 +223,7 @@ void FCEU_DrawRecordingStatusN(uint8* XBuf, int n) for(i=0; slines[i]!=99; i+=3) { int y=slines[i]; - uint8* dest=XBuf+(y*256); + uint8* dest=XBuf+(y*SCREEN_WIDTH); int x; for(x=slines[i+1]; x!=slines[i+2]; ++x) dest[x]=4; diff --git a/drivers/gp2x/input.c b/drivers/gp2x/input.c index 704cb3a..9ba438a 100644 --- a/drivers/gp2x/input.c +++ b/drivers/gp2x/input.c @@ -27,14 +27,14 @@ #define JOY_LEFT 0x40 #define JOY_RIGHT 0x80 - #include "minimal.h" + + extern int swapbuttons; extern int scaled_display; extern int FSkip_setting; extern void SetVideoScaling(int pixels,int width,int height); -static INLINE long UpdateGamepadGP2X(void); @@ -58,35 +58,6 @@ static uint32 MouseData[3]; static uint8 fkbkeys[0x48]; unsigned long lastpad=0; -void FCEUD_UpdateInput(void) -{ - int t=0; - long lastpad2=lastpad; - long pad = UpdateGamepadGP2X(); - t=1; - // JSreturn=(JSreturn&0xFF000000)|(JSreturn&0xFF)|((JSreturn&0xFF0000)>>8)|((JSreturn&0xFF00)<<8); - if(gametype==GIT_FDS) - { - NoWaiting&=~1; - if ((pad & GP2X_PUSH) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_R)) && (!(lastpad2 & GP2X_PUSH))) - { - DriverInterface(DES_FDSSELECT,0); - } - else if ((pad & GP2X_L) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_PUSH)) && (!(pad & GP2X_R))&& (!(lastpad2 & GP2X_L))) - { - DriverInterface(DES_FDSINSERT,0); - } - else if ((pad & GP2X_R) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_PUSH)) && (!(lastpad2 & GP2X_R))) - { - DriverInterface(DES_FDSEJECT,0); - } - } - -} - - -//#ifdef GP2X - extern void ResetNES(void); extern void CleanSurface(void); @@ -101,6 +72,7 @@ int TurboFireBottom=0; int turbo_toggle_A=0; int turbo_toggle_B=0; + static void setsoundvol(int soundvolume) { //FCEUI_SetSoundVolume(soundvol); @@ -121,15 +93,15 @@ static void setsoundvol(int soundvolume) soundvolmeter[20]=0; FCEU_DispMessage("|%s|", soundvolmeter); } -/** - * GP2x joystick reader - * - */ -static INLINE long UpdateGamepadGP2X(void) + + + +void FCEUD_UpdateInput(void) { + long lastpad2=lastpad; + unsigned long pad=gp2x_joystick_read(); uint32 JS=0; - unsigned long pad=gp2x_joystick_read(); #define down(b) (pad & GP2X_##b) #define last_down(b) (lastpad & GP2X_##b) #define L_down (pad & GP2X_L) @@ -370,18 +342,36 @@ static INLINE long UpdateGamepadGP2X(void) //padTmp=(pad & GP2X_START) >> 8; // 2^8, JS |= (((pad & GP2X_START) >> 8) << 3); // 0x8 is 2^3 - JSreturn = JS; lastpad=pad; - return pad; //JSreturn=(JS&0xFF000000)|(JS&0xFF)|((JS&0xFF0000)>>8)|((JS&0xFF00)<<8); + + + // JSreturn=(JSreturn&0xFF000000)|(JSreturn&0xFF)|((JSreturn&0xFF0000)>>8)|((JSreturn&0xFF00)<<8); + // TODO: make these bindable, use new interface + if(gametype==GIT_FDS) + { + NoWaiting&=~1; + if ((pad & GP2X_PUSH) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_R)) && (!(lastpad2 & GP2X_PUSH))) + { + DriverInterface(DES_FDSSELECT,0); + } + else if ((pad & GP2X_L) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_PUSH)) && (!(pad & GP2X_R))&& (!(lastpad2 & GP2X_L))) + { + DriverInterface(DES_FDSINSERT,0); + } + else if ((pad & GP2X_R) && (!(pad & GP2X_SELECT)) && (!(pad & GP2X_L)) && (!(pad & GP2X_PUSH)) && (!(lastpad2 & GP2X_R))) + { + DriverInterface(DES_FDSEJECT,0); + } + } + return; + no_pad: JSreturn=0; lastpad=pad; - return 0; } -//#endif static void InitOtherInput(void) diff --git a/fce.c b/fce.c index 4db2a0a..89c4285 100644 --- a/fce.c +++ b/fce.c @@ -1288,7 +1288,8 @@ void EmLoop(void) if(FCEUGameInfo.type==GIT_NSF) { - X6502_Run((256+85)*240); + for(scanline=0;scanline<240;scanline++) + X6502_Run(256+85); } #ifdef FRAMESKIP else if(FSkip) diff --git a/general.c b/general.c index eabb5ed..96bb73b 100644 --- a/general.c +++ b/general.c @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _GNU_SOURCE // for asprintf #include #include #include diff --git a/ncpu.S b/ncpu.S index fcf8fed..8a18b75 100644 --- a/ncpu.S +++ b/ncpu.S @@ -269,10 +269,10 @@ ldmfd sp!,{r0-r3,r12,lr} @@@ REG_ADDR¤òÊѹ¹¤¹¤ë¤¬µ¤¤Ë¤¹¤ë¤Ê @@@ .macro READ_WORD - READ + bl read_byte mov REG_PC, r0 add REG_ADDR, REG_ADDR, #1 - READ + bl read_byte orr r0, REG_PC, r0, lsl #8 .endm diff --git a/nsf.c b/nsf.c index 7e8d3cb..cff242b 100644 --- a/nsf.c +++ b/nsf.c @@ -300,6 +300,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); @@ -406,8 +407,8 @@ void DrawNSF(uint8 *XBuf) if(vismode==0) return; - memset(XBuf,0,320*240); - + for (x=0;x<240;x++) + memset(XBuf+SCREEN_OFFS+x*SCREEN_WIDTH,0,256); { int32 *Bufpl; diff --git a/video.c b/video.c index e9d3c2d..01a54e1 100644 --- a/video.c +++ b/video.c @@ -167,7 +167,7 @@ int SaveSnapshot(void) int x,u,y; FILE *pp=NULL; uint8 *compmem=NULL; - uint32 compmemsize=totallines*263+12; + unsigned long compmemsize=totallines*263+12; if(!(compmem=FCEU_malloc(compmemsize))) return 0; @@ -236,7 +236,7 @@ int SaveSnapshot(void) tmp+=16; } - if(compress(compmem,(unsigned long *)&compmemsize,mork,(totallines<<8)+totallines)!=Z_OK) + if(compress(compmem,&compmemsize,mork,(totallines<<8)+totallines)!=Z_OK) { if(mal) free(mal); goto PNGerr; -- 2.39.2