From 6587f34612d28a36fede21bd6293c4e0e383b343 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 1 May 2007 21:34:29 +0000 Subject: [PATCH] palette change to reflect .15 code git-svn-id: file:///home/notaz/opt/svn/fceu@123 be3aeb3a-fb24-0410-a615-afba39da0efa --- bench.txt | 2 ++ drawing.h | 2 +- drivers/gp2x/asmutils.h | 2 ++ drivers/gp2x/asmutils.s | 47 ++++++++++++++++++++++++++++++++ drivers/gp2x/gp2x-video.c | 10 +++---- drivers/gp2x/main.c | 14 ++++++++++ fce.c | 57 +++++++++++++-------------------------- ines.c | 6 +++++ ines.h | 2 ++ palette.c | 6 ++--- video.c | 2 +- 11 files changed, 101 insertions(+), 49 deletions(-) diff --git a/bench.txt b/bench.txt index 61e7c92..4305a99 100644 --- a/bench.txt +++ b/bench.txt @@ -12,3 +12,5 @@ bm 87-88 kage 83-84 cvn3 ~88 +-- +v03+merge diff --git a/drawing.h b/drawing.h index 3d9b29d..a59d1a3 100644 --- a/drawing.h +++ b/drawing.h @@ -28,7 +28,7 @@ static void DrawMessage(void) if(t>=XBuf) { DrawTextLineBG(t); - DrawTextTrans(t+3*SCREEN_WIDTH+(128-strlen(errmsg)*4),SCREEN_WIDTH,(uint8 *)errmsg,128+4); + DrawTextTrans(t+3*SCREEN_WIDTH+(128-strlen(errmsg)*4),SCREEN_WIDTH,(uint8 *)errmsg,4); } } } diff --git a/drivers/gp2x/asmutils.h b/drivers/gp2x/asmutils.h index 94c89ea..91dc24c 100644 --- a/drivers/gp2x/asmutils.h +++ b/drivers/gp2x/asmutils.h @@ -1,2 +1,4 @@ void flushcache(unsigned int beginning_addr, unsigned int end_addr, unsigned int flags); +void block_or(void *src, size_t n, int pat); +void block_andor(void *src, size_t n, int andpat, int orpat); diff --git a/drivers/gp2x/asmutils.s b/drivers/gp2x/asmutils.s index 917bb08..a7f123f 100644 --- a/drivers/gp2x/asmutils.s +++ b/drivers/gp2x/asmutils.s @@ -8,6 +8,53 @@ flushcache: mov pc, lr +.global block_or @ void *src, size_t n, int pat + +block_or: + stmfd sp!, {r4-r5} + orr r2, r2, r2, lsl #8 + orr r2, r2, r2, lsl #16 + mov r1, r1, lsr #4 +block_loop_or: + ldmia r0, {r3-r5,r12} + subs r1, r1, #1 + orr r3, r3, r2 + orr r4, r4, r2 + orr r5, r5, r2 + orr r12,r12,r2 + stmia r0!, {r3-r5,r12} + bne block_loop_or + ldmfd sp!, {r4-r5} + bx lr + + +.global block_andor @ void *src, size_t n, int andpat, int orpat + +block_andor: + stmfd sp!, {r4-r6} + orr r2, r2, r2, lsl #8 + orr r2, r2, r2, lsl #16 + orr r3, r3, r3, lsl #8 + orr r3, r3, r3, lsl #16 + mov r1, r1, lsr #4 +block_loop_andor: + ldmia r0, {r4-r6,r12} + subs r1, r1, #1 + and r4, r4, r2 + orr r4, r4, r3 + and r5, r5, r2 + orr r5, r5, r3 + and r6, r6, r2 + orr r6, r6, r3 + and r12,r12,r2 + orr r12,r12,r3 + stmia r0!, {r4-r6,r12} + bne block_loop_andor + ldmfd sp!, {r4-r6} + bx lr + + + /* buggy and slow, probably because function call overhead @ renderer helper, based on bitbank's method .global draw8pix @ uint8 *P, uint8 *C, uint8 *PALRAM @ dest, src, pal diff --git a/drivers/gp2x/gp2x-video.c b/drivers/gp2x/gp2x-video.c index f7f09bd..03d4abc 100644 --- a/drivers/gp2x/gp2x-video.c +++ b/drivers/gp2x/gp2x-video.c @@ -32,7 +32,7 @@ static int framesEmulated, framesRendered; int scaled_display=0; int paletterefresh; -#define FPS_COLOR 61 +#define FPS_COLOR 1 static unsigned char fontdata8x8[] = @@ -135,7 +135,7 @@ void CleanSurface(void) int c=4; while (c--) { - memset (gp2x_screen8, 0x80, 320*240); + memset (gp2x_screen8, 0, 320*240); gp2x_video_flip(); } XBuf = gp2x_screen8; @@ -157,7 +157,7 @@ int InitVideo(void) srendline=0; erendline=239; - XBuf = gp2x_screen8; // TODO: use mmuhacked upper mem + XBuf = gp2x_screen8; return 1; } @@ -205,8 +205,8 @@ static INLINE void printFps(uint8 *screen) int y, *destt = (int *) screen; for (y = 20/*240*/; y; y--) { - *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; - *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; + *destt++ = 0; *destt++ = 0; *destt++ = 0; *destt++ = 0; + *destt++ = 0; *destt++ = 0; *destt++ = 0; *destt++ = 0; destt += 64+8; //*destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; diff --git a/drivers/gp2x/main.c b/drivers/gp2x/main.c index 95ed4bd..4437dc6 100644 --- a/drivers/gp2x/main.c +++ b/drivers/gp2x/main.c @@ -45,6 +45,10 @@ #include "dface.h" +// just for printing some iNES info for user.. +#include "../../fce.h" +#include "../../ines.h" + static int ntsccol=0,ntschue=-1,ntsctint=-1; int soundvol=70; int inited=0; @@ -336,6 +340,16 @@ int CLImain(int argc, char *argv[]) ParseGI(tmp); //RefreshThrottleFPS(); InitOtherInput(); + + // additional print for gpfce + { + int MapperNo; + iNES_HEADER *head = iNESGetHead(); + MapperNo = (head->ROM_type>>4); + MapperNo|=(head->ROM_type2&0xF0); + FCEU_DispMessage("%s, Mapper: %d%s%s", PAL?"PAL":"NTSC", MapperNo, (head->ROM_type&2)?", BB":"", (head->ROM_type&4)?", T":""); + } + FCEUI_Emulate(); dk: diff --git a/fce.c b/fce.c index 89c4285..d3a0f61 100644 --- a/fce.c +++ b/fce.c @@ -53,6 +53,10 @@ #include "dprintf.h" +#ifdef GP2X +#include "drivers/gp2x/asmutils.h" +#endif + #define Pal (PALRAM) @@ -582,7 +586,7 @@ static void Loop6502(void) #endif if(ScreenON) { - if(scanline>=FSettings.FirstSLine && scanline<=FSettings.LastSLine) + if(scanline>=FSettings.FirstSLine && scanline<=Settings.LastSLine) BGRender(target); else { @@ -610,17 +614,24 @@ static void Loop6502(void) for(x=63;x>=0;x--) ((uint32 *)target)[x]=((uint32*)target)[x]&0xF0F0F0F0; } +#ifdef GP2X + if((PPU[1]>>5)==0x7) block_or(target, 256, 0xc0); + else if(PPU[1]&0xE0) block_andor(target, 256, 0x3f, 0x40); + else block_andor(target, 256, 0x3f, 0x80); +#else if((PPU[1]>>5)==0x7) for(x=63;x>=0;x--) - ((uint32 *)target)[x]=(((uint32*)target)[x]&0x3f3f3f3f)|0x40404040; + ((uint32 *)target)[x]=(((uint32*)target)[x])|0xc0c0c0c0; else if(PPU[1]&0xE0) for(x=63;x>=0;x--) - ((uint32 *)target)[x]=((uint32*)target)[x]|0xC0C0C0C0; + ((uint32 *)target)[x]=(((uint32*)target)[x]&0x3f3f3f3f)|0x40404040; else for(x=63;x>=0;x--) - ((uint32 *)target)[x]=((uint32*)target)[x]&0x3f3f3f3f; - FCEU_dwmemset(target- 8,0x3f3f3f3f,8); - FCEU_dwmemset(target+256,0x3f3f3f3f,8); + ((uint32 *)target)[x]=(((uint32*)target)[x]&0x3f3f3f3f)|0x80808080; +#endif + // black borders + ((uint32 *)target)[-2]=((uint32 *)target)[-1]=0; + ((uint32 *)target)[64]=((uint32 *)target)[65]=0; #ifdef FRAMESKIP } #endif @@ -1228,7 +1239,7 @@ void EmLoop(void) // FCEUPPU_Loop: if(ppudead) /* Needed for Knight Rider, possibly others. */ { - memset(XBuf, 0x80, 320*240); + //memset(XBuf, 0, 320*240); X6502_Run(scanlines_per_frame*(256+85)); ppudead--; goto update; @@ -1288,40 +1299,10 @@ void EmLoop(void) if(FCEUGameInfo.type==GIT_NSF) { + // run scanlines for asm core to fuction for(scanline=0;scanline<240;scanline++) X6502_Run(256+85); } - #ifdef FRAMESKIP - else if(FSkip) - { - int y; - - y=SPRAM[0]; - y++; - - PPU_status|=0x20; // Fixes "Bee 52". Does it break anything? - if(GameHBIRQHook) - { - X6502_Run(256); - for(scanline=0;scanline<240;scanline++) - { - if(ScreenON || SpriteON) - GameHBIRQHook(); - if(scanline==y && SpriteON) PPU_status|=0x40; - X6502_Run((scanline==239)?85:(256+85)); - ResetRL(); // ?? - } - } - else if(y<240) - { - X6502_Run((256+85)*y); - if(SpriteON) PPU_status|=0x40; // Quick and very dirty hack. - X6502_Run((256+85)*(240-y)); - } - else - X6502_Run((256+85)*240); - } - #endif else { int x,max,maxref; diff --git a/ines.c b/ines.c index e804c26..71de2ba 100644 --- a/ines.c +++ b/ines.c @@ -1053,3 +1053,9 @@ static int NewiNES_Init(int num) } return(0); } + +iNES_HEADER *iNESGetHead(void) +{ + return &head; +} + diff --git a/ines.h b/ines.h index aaa44ca..5811d32 100644 --- a/ines.h +++ b/ines.h @@ -99,6 +99,8 @@ void FASTAPASS(1) onemir(uint8 V); void FASTAPASS(1) MIRROR_SET2(uint8 V); void FASTAPASS(1) MIRROR_SET(uint8 V); +iNES_HEADER *iNESGetHead(void); + void Mapper0_init(void); void Mapper1_init(void); //void Mapper2_init(void); diff --git a/palette.c b/palette.c index 27342fd..d15f4c4 100644 --- a/palette.c +++ b/palette.c @@ -253,18 +253,16 @@ void WritePalette(void) int x; for(x=0;x<7;x++) - FCEUD_SetPalette(128+x,unvpalette[x].r,unvpalette[x].g,unvpalette[x].b); + FCEUD_SetPalette(x,unvpalette[x].r,unvpalette[x].g,unvpalette[x].b); if(FCEUGameInfo.type==GIT_NSF) { //for(x=0;x<128;x++) // FCEUD_SetPalette(x,x,0,x); - for(x=0;x<7;x++) - FCEUD_SetPalette(x,unvpalette[x].r,unvpalette[x].g,unvpalette[x].b); } else { for(x=0;x<64;x++) - FCEUD_SetPalette(x,palo[x].r,palo[x].g,palo[x].b); + FCEUD_SetPalette(x+128,palo[x].r,palo[x].g,palo[x].b); SetNESDeemph(lastd,1); } } diff --git a/video.c b/video.c index 01a54e1..b4e137f 100644 --- a/video.c +++ b/video.c @@ -57,7 +57,7 @@ int InitVirtualVideo(void) XBuf=(uint8 *)m; } */ - memset(XBuf,128,320*240); + memset(XBuf,0,320*240); return 1; } -- 2.39.5