void block_or(void *src, size_t n, int pat);\r
void block_and(void *src, size_t n, int pat);\r
void block_andor(void *src, size_t n, int andpat, int orpat);\r
+void memset32(int *dest, int c, int count);\r
void spend_cycles(int c); // utility\r
-void soft_scale(void *dst, unsigned short *pal, int offs, int lines);\r
+void soft_scale(void *dst, unsigned short *pal, int line_offs, int lines);\r
\r
bx lr
-.global soft_scale @ void *dst, unsigned short *pal, int offs, int lines
+.global memset32 @ int *dest, int c, int count
+
+memset32:
+ stmfd sp!, {lr}
+
+ mov r3, r1
+ subs r2, r2, #4
+ bmi mst32_fin
+
+ mov r12,r1
+ mov lr, r1
+
+mst32_loop:
+ subs r2, r2, #4
+ stmia r0!, {r1,r3,r12,lr}
+ bpl mst32_loop
+
+mst32_fin:
+ tst r2, #1
+ strne r1, [r0], #4
+
+ tst r2, #2
+ stmneia r0!, {r1,r3}
+
+ ldmfd sp!, {lr}
+ bx lr
+
+
+
+.global soft_scale @ void *dst, unsigned short *pal, int line_offs, int lines
soft_scale:
stmfd sp!,{r4-r11,lr}
int paletterefresh;
+extern int eoptions;
+
#define FPS_COLOR 1
for (l=0;l<8;l++)
{
- screen[l*320+0]=(fontdata8x8[((text[i])*8)+l]&0x80)?color:screen[l*320+0];
- screen[l*320+1]=(fontdata8x8[((text[i])*8)+l]&0x40)?color:screen[l*320+1];
- screen[l*320+2]=(fontdata8x8[((text[i])*8)+l]&0x20)?color:screen[l*320+2];
- screen[l*320+3]=(fontdata8x8[((text[i])*8)+l]&0x10)?color:screen[l*320+3];
- screen[l*320+4]=(fontdata8x8[((text[i])*8)+l]&0x08)?color:screen[l*320+4];
- screen[l*320+5]=(fontdata8x8[((text[i])*8)+l]&0x04)?color:screen[l*320+5];
- screen[l*320+6]=(fontdata8x8[((text[i])*8)+l]&0x02)?color:screen[l*320+6];
- screen[l*320+7]=(fontdata8x8[((text[i])*8)+l]&0x01)?color:screen[l*320+7];
+ screen[l*320+0]=(fontdata8x8[((text[i])*8)+l]&0x80)?color:0;
+ screen[l*320+1]=(fontdata8x8[((text[i])*8)+l]&0x40)?color:0;
+ screen[l*320+2]=(fontdata8x8[((text[i])*8)+l]&0x20)?color:0;
+ screen[l*320+3]=(fontdata8x8[((text[i])*8)+l]&0x10)?color:0;
+ screen[l*320+4]=(fontdata8x8[((text[i])*8)+l]&0x08)?color:0;
+ screen[l*320+5]=(fontdata8x8[((text[i])*8)+l]&0x04)?color:0;
+ screen[l*320+6]=(fontdata8x8[((text[i])*8)+l]&0x02)?color:0;
+ screen[l*320+7]=(fontdata8x8[((text[i])*8)+l]&0x01)?color:0;
}
screen+=8;
int c=4;
while (c--)
{
- memset(gp2x_screen, 0, 320*240);
+ memset32(gp2x_screen, 0, 320*240*2/4);
gp2x_video_flip();
}
XBuf = gp2x_screen;
prevsec = tv_now.tv_sec;
}
+ if (!Settings.showfps || !screen) return;
+
if (Settings.scaling == 0)
{
if (needfpsflip)
{
- int y, *destt = (int *) screen;
- for (y = 20/*240*/; y; y--)
- {
- *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;
- //*destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F; *destt++ = 0x3F3F3F3F;
- }
- if (Settings.showfps)
- {
- int sep;
- for (sep=1; sep < 5; sep++)
- if (fps_str[sep] == '/' || fps_str[sep] == 0) break;
- fps_str[sep] = 0;
- gp2x_text(screen, 0, 0, fps_str, FPS_COLOR, 0);
- gp2x_text(screen, 0, 10, fps_str+sep+1, FPS_COLOR, 0);
- }
+ int sep;
+ for (sep=1; sep < 5; sep++)
+ if (fps_str[sep] == '/' || fps_str[sep] == 0) break;
+ fps_str[sep] = 0;
+ gp2x_text(screen, 0, 0, fps_str, FPS_COLOR, 0);
+ gp2x_text(screen, 0, 10, fps_str+sep+1, FPS_COLOR, 0);
needfpsflip--;
}
}
else
{
- if (Settings.showfps)
- {
- gp2x_text(screen+32, 0, 0, fps_str, FPS_COLOR, 0); // TODO: firstline
- }
+ gp2x_text(screen+32, 0, srendline, fps_str, FPS_COLOR, 0);
}
}
{
framesEmulated++;
- if (!buf) return;
+ if (!buf) {
+ printFps(0);
+ return;
+ }
framesRendered++;
printFps(gp2x_screen);
+ if (eoptions & EO_CLIPSIDES)
+ {
+ int i, *p = (int *) ((char *)gp2x_screen + 32);
+ for (i = 240; i; i--, p += 320/4)
+ {
+ p[0] = p[1] = p[62] = p[63] = 0;
+ }
+ }
+
if (Settings.scaling == 3)
- soft_scale((char *)gp2x_screen + 32, gp2x_palette16, 0, 240);
+ {
+ soft_scale((char *)gp2x_screen + 32, gp2x_palette16, srendline, erendline-srendline);
+ if (srendline)
+ memset32((int *)((char *)gp2x_screen + 32), 0, srendline*320*2/4);
+ }
gp2x_video_flip();
XBuf = gp2x_screen;
#define down(b) (keys & GP2X_##b)
static void do_fake_mouse(unsigned long keys)
{
- static int x=0, y=0;
+ static int x=256/2, y=240/2;
int speed = 3;
if (down(A)) speed = 1;
#include "../common/unixdsp.h"
#include "../common/cheat.h"
+#include "../../fce.h"
+
#include "dface.h"
-// just for printing some iNES info for user..
-#include "../../fce.h"
-#include "../../ines.h"
+
+// TODO! broken fs0, sram saves
+
+void CleanSurface(void);
// internals
extern char lastLoadedGameName[2048];
void CloseGame(void);
FCEUGI *fceugi = NULL;
-static int ntsccol=0,ntschue=-1,ntsctint=-1;
+int ntsccol=0,ntschue=-1,ntsctint=-1;
int soundvol=70;
int inited=0;
-int srendlinev[2]={0,0};
-int erendlinev[2]={239,239};
+int srendlinev[2]={8,0};
+int erendlinev[2]={231,239};
int srendline,erendline;
InputType[1]=gi->input[1];
if(gi->inputfc>=0)
InputTypeFC=gi->inputfc;
- FCEUI_GetCurrentVidSystem(&srendline,&erendline);
}
void FCEUD_PrintError(char *s)
if (name)
sprintf(tdir,"%s"PSS"cfg"PSS"%s.cfg",BaseDirectory,name);
else sprintf(tdir,"%s"PSS"fceu2.cfg",BaseDirectory);
- DriverInterface(DES_GETNTSCTINT,&ntsctint);
- DriverInterface(DES_GETNTSCHUE,&ntschue);
+ FCEUI_GetNTSCTH(&ntsctint, &ntschue);
SaveFCEUConfig(tdir,fceuconfig);
}
if (name)
sprintf(tdir,"%s"PSS"cfg"PSS"%s.cfg",BaseDirectory,name);
else sprintf(tdir,"%s"PSS"fceu2.cfg",BaseDirectory);
+ FCEUI_GetNTSCTH(&ntsctint, &ntschue); /* Get default settings for if no config file exists. */
LoadFCEUConfig(tdir,fceuconfig);
- if(ntsctint>=0) DriverInterface(DES_SETNTSCTINT,&ntsctint);
- if(ntschue>=0) DriverInterface(DES_SETNTSCHUE,&ntschue);
+ FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue);
}
static void LoadLLGN(void)
if(erendlinev[x]<srendlinev[x] || erendlinev[x]>239) erendlinev[x]=239;
}
- printf("main() setrendered lines: %d, %d, %d, %d\n",srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]);
- printf("main() clip sides %d\n", eoptions&EO_CLIPSIDES);
- srendlinev[0]=0;
+ printf("FCEUI_SetRenderedLines: %d, %d, %d, %d\n",srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]);
+ printf("clip sides: %d\n", eoptions&EO_CLIPSIDES);
FCEUI_SetRenderedLines(srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]);
- FCEUI_SetRenderedLines(0,erendlinev[0],srendlinev[1],erendlinev[1]);
FCEUI_SetSoundVolume(soundvol);
- DriverInterface(DES_NTSCCOL,&ntsccol); // TODO
DoDriverArgs();
if(fcexp)
gp2x_opt_setup();
gp2x_cpuclock_gamma_update();
LoadLLGN();
+ FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue);
if(cpalette)
- LoadCPalette();
+ LoadCPalette(); // TODO
if(InitSound())
inited|=1;
}
PrepareOtherInput();
+ FCEUI_GetCurrentVidSystem(&srendline,&erendline);
gp2x_video_changemode(Settings.scaling == 3 ? 15 : 8);
switch (Settings.scaling & 3) {
- case 0: gp2x_video_RGB_setscaling(0, 320, 240); gp2x_video_set_offs(0); break;
- case 1: gp2x_video_RGB_setscaling(0, 256, 240); gp2x_video_set_offs(32); break;
- case 2: gp2x_video_RGB_setscaling(0, 256, 240); gp2x_video_set_offs(32); break; // TODO
- case 3: gp2x_video_RGB_setscaling(0, 320, 240); gp2x_video_set_offs(32); break;
+ case 0: gp2x_video_set_offs(0); gp2x_video_RGB_setscaling(0, 320, 240); break;
+ case 1: gp2x_video_set_offs(32); gp2x_video_RGB_setscaling(0, 256, 240); break;
+ case 2: gp2x_video_set_offs(32); gp2x_video_RGB_setscaling(srendline, 256, erendline-srendline); break;
+ case 3: gp2x_video_set_offs(32); gp2x_video_RGB_setscaling(0, 320, 240); break;
}
+ CleanSurface();
gp2x_start_sound(Settings.sound_rate, 16, 0);
FCEUI_Emulate();
}
\r
// --------- FCEU options ----------\r
\r
+extern int ntsccol,ntschue,ntsctint;\r
+extern int srendlinev[2];\r
+extern int erendlinev[2];\r
+extern int eoptions;\r
+\r
+\r
+static void int_incdec(int *p, int inc, int min, int max)\r
+{\r
+ *p += inc;\r
+ if (*p < min) *p = min;\r
+ else if (*p > max) *p = max;\r
+}\r
+\r
static void draw_fcemenu_options(int menu_sel)\r
{\r
int tl_x = 25, tl_y = 60, y;\r
y = tl_y;\r
gp2x_fceu_copy_bg();\r
\r
- gp2x_text_out15(tl_x, y, " %s", "OFF"); // 0\r
- gp2x_text_out15(tl_x, (y+=10), "Done");\r
+ gp2x_text_out15(tl_x, y, "NTSC Color Emulation %s", ntsccol?"ON":"OFF"); // 0\r
+ gp2x_text_out15(tl_x, (y+=10), " Tint (default: 56) %i", ntsctint);\r
+ gp2x_text_out15(tl_x, (y+=10), " Hue (default: 72) %i", ntschue);\r
+ gp2x_text_out15(tl_x, (y+=10), "First visible line (NTSC) %i", srendlinev[0]);\r
+ gp2x_text_out15(tl_x, (y+=10), "Last visible line (NTSC) %i", erendlinev[0]);\r
+ gp2x_text_out15(tl_x, (y+=10), "First visible line (PAL) %i", srendlinev[1]); // 5\r
+ gp2x_text_out15(tl_x, (y+=10), "Last visible line (PAL) %i", erendlinev[1]);\r
+ gp2x_text_out15(tl_x, (y+=10), "Clip 8 left/right columns %s", (eoptions&EO_CLIPSIDES)?"ON":"OFF");\r
+ gp2x_text_out15(tl_x, (y+=10), "Disable 8 sprite limit %s", "TODO");\r
+ gp2x_text_out15(tl_x, (y+=10), "Done"); // 9\r
\r
// draw cursor\r
gp2x_text_out15(tl_x - 16, tl_y + menu_sel*10, ">");\r
\r
static void fcemenu_loop_options(void)\r
{\r
- int menu_sel = 0, menu_sel_max = 1;\r
+ int menu_sel = 0, menu_sel_max = 9, i;\r
unsigned long inp = 0;\r
\r
+ FCEUI_GetNTSCTH(&ntsctint, &ntschue);\r
+\r
for(;;)\r
{\r
draw_fcemenu_options(menu_sel);\r
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options\r
switch (menu_sel) {\r
- case 0: break;\r
- case 1: return;\r
+ case 0: ntsccol = !ntsccol; break;\r
+ case 7: eoptions^=EO_CLIPSIDES; break;\r
+ case 9: return;\r
+ }\r
+ }\r
+ if(inp & (GP2X_X|GP2X_A)) {\r
+ for(i=0;i<2;i++)\r
+ {\r
+ if(srendlinev[i]<0 || srendlinev[i]>239) srendlinev[i]=0;\r
+ if(erendlinev[i]<srendlinev[i] || erendlinev[i]>239) erendlinev[i]=239;\r
}\r
+ FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue);\r
+ FCEUI_SetRenderedLines(srendlinev[0],erendlinev[0],srendlinev[1],erendlinev[1]);\r
+ return;\r
}\r
- if(inp & (GP2X_X|GP2X_A)) return;\r
if(inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choise\r
switch (menu_sel) {\r
- case 0:\r
- break;\r
+ case 1: int_incdec(&ntsctint, (inp & GP2X_LEFT) ? -1 : 1, 0, 128); break;\r
+ case 2: int_incdec(&ntschue, (inp & GP2X_LEFT) ? -1 : 1, 0, 128); break;\r
+ case 3: int_incdec(&srendlinev[0], (inp & GP2X_LEFT) ? -1 : 1, 0, 239); break;\r
+ case 4: int_incdec(&erendlinev[0], (inp & GP2X_LEFT) ? -1 : 1, 0, 239); break;\r
+ case 5: int_incdec(&srendlinev[1], (inp & GP2X_LEFT) ? -1 : 1, 0, 239); break;\r
+ case 6: int_incdec(&erendlinev[1], (inp & GP2X_LEFT) ? -1 : 1, 0, 239); break;\r
}\r
}\r
}\r
return rates[i];\r
}\r
\r
-static void int_incdec(int *p, int inc, int min, int max)\r
-{\r
- *p += inc;\r
- if (*p < min) *p = min;\r
- else if (*p > max) *p = max;\r
-}\r
-\r
static void config_commit(void)\r
{\r
gp2x_cpuclock_gamma_update();\r
selfname = romsel_loop(curr_path);\r
if (selfname) {\r
printf("selected file: %s\n", selfname);\r
+ while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000);\r
return 2;\r
}\r
break;\r
{
uint32 tem;
- if(FSkip)
+ if(FSkip || scanline < FSettings.FirstSLine || scanline > FSettings.LastSLine)
{
if(PPU_hook)
PRefreshLine();
{
if(ScreenON)
{
- if(scanline>=FSettings.FirstSLine && scanline<=FSettings.LastSLine)
- BGRender(target);
- else
- {
- if(PPU_hook)
- PRefreshLine();
- }
+ BGRender(target);
}
else
{
#ifdef FRAMESKIP
if(!FSkip)
#endif
- if(SpriteON && spork)
- CopySprites(target);
+ if(scanline>=FSettings.FirstSLine && scanline<=FSettings.LastSLine)
+ {
+ if(SpriteON && spork)
+ CopySprites(target);
-#ifdef FRAMESKIP
- if(!FSkip)
-#endif
- LineUpdateEnd(target);
+ LineUpdateEnd(target);
+ }
sphitx=0x100;
if(ScreenON || SpriteON)
memset(XBuf+SCREEN_OFFS+x*SCREEN_WIDTH,0,256);\r
\r
if(FSettings.SoundVolume)\r
- mul=8192*240/(16384*FSettings.SoundVolume/50)/8;\r
+ mul=8192*240/(16384*FSettings.SoundVolume/50);\r
\r
{\r
int16 *Bufpl;\r
uint8 CommandQueue=0;
-static int controlselect=0;
-static int ntsccol=0;
-static int ntsctint=46+10;
-static int ntschue=72;
-static int controllength=0;
-
void FCEUI_SetSnapName(int a)
{
{
switch(w)
{
- case DES_NTSCCOL:ntsccol=*(int *)d;FCEU_ResetPalette();break;
case DES_RESET:if(netplay!=2) CommandQueue=30;break;
case DES_POWER:if(netplay!=2) CommandQueue=31;break;
- case DES_GETNTSCTINT:*(int*)d=ntsctint;break;
- case DES_GETNTSCHUE:*(int*)d=ntschue;break;
- case DES_SETNTSCTINT:ntsctint=*(int*)d;if(ntsccol)FCEU_ResetPalette();break;
- case DES_SETNTSCHUE:ntschue=*(int*)d;if(ntsccol)FCEU_ResetPalette();break;
-
- case DES_FDSINSERT:if(netplay!=2) CommandQueue=2;break;
- case DES_FDSEJECT:if(netplay!=2) CommandQueue=3;break;
- case DES_FDSSELECT:if(netplay!=2) CommandQueue=1;break;
-/*
- case DES_NSFINC:NSFControl(1);break;
- case DES_NSFDEC:NSFControl(2);break;
- case DES_NSFRES:NSFControl(0);break;
-*/
+
case DES_VSUNIDIPSET:CommandQueue=10+(int)d;break;
case DES_VSUNITOGGLEDIPVIEW:CommandQueue=10;break;
case DES_VSUNICOIN:CommandQueue=19;break;
- case DES_NTSCSELHUE:if(ntsccol && FCEUGameInfo.type!=GIT_VSUNI && !PAL && FCEUGameInfo.type!=GIT_NSF){controlselect=1;controllength=360;}break;
- case DES_NTSCSELTINT:if(ntsccol && FCEUGameInfo.type!=GIT_VSUNI && !PAL && FCEUGameInfo.type!=GIT_NSF){controlselect=2;controllength=360;}break;
#if 0
case DES_NTSCDEC:
if(ntsccol && FCEUGameInfo.type!=GIT_VSUNI && !PAL && FCEUGameInfo.type!=GIT_NSF)
#ifdef FRAMESKIP
void FCEU_PutImageDummy(void)
{
- if(FCEUGameInfo.type!=GIT_NSF)
- {
- if(controllength) controllength--;
- }
if(howlong) howlong--; /* DrawMessage() */
#ifdef FPS
{