|
Post by daid on Nov 25, 2007 19:15:38 GMT
I was looking at your patch, then gave up when I noticed that 90% of it is you messing up the spacing on the source. Please make some other that isn't full of crap on it too and I'll try to fix it. 90% of it is the HQ3X file. So you are overreacting a bit. Also, it's all ugly hacks which produces all some unwanted sideeffects. Currently I can play up to the level "core" in EP4. Which works fine, until I get to the boss, at which the screen turns black and I get killed because the boss flies into me (I guess) but that might be because of my scaling hack. Index: E:/gp2x/tyrian21/src/Copy of src/tyrian2.c =================================================================== --- E:/gp2x/tyrian21/src/Copy of src/tyrian2.c (revision 595) +++ E:/gp2x/tyrian21/src/Copy of src/tyrian2.c (working copy) @@ -436,6 +436,8 @@ s_limit += VGAScreen->h * VGAScreen->w; p = enemy[i].shapeseg; +if (p) +{ p += SDL_SwapLE16(((JE_word *)p)[enemy[i].egr[enemy[i].enemycycle - 1] - 1]); while (*p != 0x0f) @@ -459,6 +461,7 @@ } p++; } +} } } enemy_draw_overflow: @@ -2886,7 +2889,8 @@ temp3 = fxPlayVol / 2; } } - JE_multiSamplePlay(digiFx[temp-1], fxSize[temp-1], temp2, temp3); + if (temp - 1 < SOUND_NUM + 9) + JE_multiSamplePlay(digiFx[temp-1], fxSize[temp-1], temp2, temp3); soundQueue[temp2] = 0; } } @@ -7552,6 +7556,7 @@ void JE_loadCubes( void ) { +#if 0 char s[256], s2[256], s3[256]; int cube; JE_word x, y; @@ -7688,6 +7693,7 @@ fclose(f); } +#endif } void JE_drawItem( int itemType, JE_word itemNum, JE_word x, JE_word y )
I did these hacks to stop crashes. Note that one of them disables the datacube loading, which seems to crash multiple levels. And this is the scaling/HQ3X patch: (without the HQ3X.c file) Index: E:/gp2x/tyrian21/src/Copy of src/starfade.c =================================================================== --- E:/gp2x/tyrian21/src/Copy of src/starfade.c (revision 595) +++ E:/gp2x/tyrian21/src/Copy of src/starfade.c (working copy) @@ -44,7 +44,7 @@ p[i].b = (*colorBuffer)[i].b << 2; } - SDL_SetColors(VGAScreenSeg, p, 0, 256); + JE_setPal(p, 0, 256); } void JE_fadeColors( JE_ColorType *fromColors, JE_ColorType *toColors, int startCol, int noColors, int noSteps ) @@ -60,7 +60,7 @@ p[i].g = ((*fromColors)[i].g + ((((*toColors)[i].g - (*fromColors)[i].g) * s) / noSteps)) << 2; p[i].b = ((*fromColors)[i].b + ((((*toColors)[i].b - (*fromColors)[i].b) * s) / noSteps)) << 2; } - SDL_SetColors(VGAScreenSeg, p, startCol, noColors + 1); + JE_setPal(p, startCol, noColors + 1); wait_delay(); } } Index: E:/gp2x/tyrian21/src/Copy of src/vga256d.c =================================================================== --- E:/gp2x/tyrian21/src/Copy of src/vga256d.c (revision 595) +++ E:/gp2x/tyrian21/src/Copy of src/vga256d.c (working copy) @@ -30,6 +30,10 @@ #include <stdio.h> #include <string.h> + +#define VIDEOSCALE 3 +//#define HQ3X + #define surface_width 320 #ifdef TARGET_GP2X #define surface_height 240 @@ -41,6 +45,10 @@ SDL_Surface *game_screen; SDL_Surface *VGAScreen2; +#if defined(VIDEOSCALE) || defined(HQ3X) +SDL_Surface *RealScreen; +#endif + /* JE: From Nortsong */ JE_word speed; /* JE: holds timer speed for 70Hz */ @@ -54,6 +62,11 @@ 16, 64, 0, 0, 64, 0, 0, 64, 16, 0, 64, 32, 0, 64, 48, 0, 64, 64, 0, 48, 64, 0, 32, 64, 0, 16, 64, 32, 32, 64, 40, 32, 64, 48, 32, 64, 56, 32, 64, 64, 32, 64, 64, 32, 56, 64, 32, 48, 64, 32, 40, 64, 32, 32, 64, 40, 32, 64, 48, 32, 64, 56, 32, 64, 64, 32, 56, 64, 32, 48, 64, 32, 40, 64, 32, 32, 64, 32, 32, 64, 40, 32, 64, 48, 32, 64, 56, 32, 64, 64, 32, 56, 64, 32, 48, 64, 32, 40, 64, 44, 44, 64, 48, 44, 64, 52, 44, 64, 60, 44, 64, 64, 44, 64, 64, 44, 60, 64, 44, 52, 64, 44, 48, 64, 44, 44, 64, 48, 44, 64, 52, 44, 64, 60, 44, 64, 64, 44, 60, 64, 44, 52, 64, 44, 48, 64, 44, 44, 64, 44, 44, 64, 48, 44, 64, 52, 44, 64, 60, 44, 64, 64, 44, 60, 64, 44, 52, 64, 44, 48, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +unsigned long RealPal[256]; + +void InitLUTs(void); +void hq3x_32( unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); + void JE_initVGA256( void ) { static bool initd = false; @@ -63,10 +76,23 @@ { initd = true; fullscreen_enabled = fullscreen_set; - +#ifdef VIDEOSCALE if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1 + || (VGAScreen = VGAScreenSeg = SDL_CreateRGBSurface(SDL_SWSURFACE, surface_width, surface_height, 8, 0, 0, 0, 0)) == 0 + || (RealScreen = SDL_SetVideoMode(surface_width*VIDEOSCALE, surface_height*VIDEOSCALE, 32, + SDL_SWSURFACE | (fullscreen_enabled ? SDL_FULLSCREEN : 0))) == 0) +#else +#ifdef HQ3X + if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1 + || (VGAScreen = VGAScreenSeg = SDL_CreateRGBSurface(SDL_SWSURFACE, surface_width, surface_height, 8, 0, 0, 0, 0)) == 0 + || (RealScreen = SDL_SetVideoMode(surface_width*3, surface_height*3, 32, + SDL_SWSURFACE | (fullscreen_enabled ? SDL_FULLSCREEN : 0))) == 0) +#else + if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1 || (VGAScreen = VGAScreenSeg = SDL_SetVideoMode(surface_width, surface_height, 8, SDL_SWSURFACE | SDL_HWPALETTE | (fullscreen_enabled ? SDL_FULLSCREEN : 0))) == 0) +#endif +#endif { printf("Display initialization failed: %s\n", SDL_GetError()); exit(1); @@ -90,13 +116,32 @@ col_buf[j].b = VGA_pal[i+2]; } - SDL_SetColors(VGAScreenSeg, col_buf, 0, 256); + JE_setPal(col_buf, 0, 256); free(col_buf); SDL_FillRect(VGAScreenSeg, NULL, 0x0); + + InitLUTs(); } +void JE_setPal(SDL_Color* c, int start, int count) +{ + SDL_SetColors(VGAScreenSeg, c, start, count); +#ifdef VIDEOSCALE + for(int i=0;i<count;i++) + { + RealPal[start+i] = ((unsigned long)c[i].r) << 16 | ((unsigned long)c[i].g) << 8 | ((unsigned long)c[i].b); + } +#endif +#ifdef HQ3X + for(int i=0;i<count;i++) + { + RealPal[start+i] = ((unsigned long)c[i].r >> 3) << 11 | ((unsigned long)c[i].g >> 2) << 5 | ((unsigned long)c[i].b >> 3); + } +#endif +} + void JE_closeVGA256( void ) { SDL_QuitSubSystem(SDL_INIT_VIDEO); @@ -109,7 +154,48 @@ void JE_showVGA( void ) { +#ifdef VIDEOSCALE + unsigned char* in = VGAScreen->pixels; + unsigned long* out = RealScreen->pixels; + for(int y=0;y<200;y++) + { + for(int x=0;x<320;x++) + { + for(int i=0;i<VIDEOSCALE;i++) + { + *(out++) = RealPal[*in]; + } + in++; + } + out += (RealScreen->pitch / 4) - RealScreen->w; + for(int i=1;i<VIDEOSCALE;i++) + { + memcpy(out, out-(RealScreen->pitch/4), RealScreen->w*4); + out += RealScreen->pitch/4; + } + in += VGAScreen->pitch - VGAScreen->w; + } + SDL_Flip(RealScreen); +#else +#ifdef HQ3X + static unsigned short Tmp[320*200]; + unsigned char* in = VGAScreen->pixels; + unsigned short* out = Tmp; + for(int y=0;y<200;y++) + { + for(int x=0;x<320;x++) + { + *(out++) = RealPal[*in]; + in++; + } + in += VGAScreen->pitch - VGAScreen->w; + } + hq3x_32(Tmp, RealScreen->pixels, 320, 200, RealScreen->w*4); + SDL_Flip(RealScreen); +#else SDL_Flip(VGAScreen); +#endif +#endif } void JE_pix( JE_word x, JE_word y, Uint8 c ) @@ -346,7 +432,7 @@ color.g = green << 2; color.b = blue << 2; - SDL_SetColors(VGAScreenSeg, &color, col, 1); + JE_setPal(&color, col, 1); } void JE_drawGraphic( JE_word x, JE_word y, JE_ShapeTypeOne s ) Index: E:/gp2x/tyrian21/src/Copy of src/vga256d.h =================================================================== --- E:/gp2x/tyrian21/src/Copy of src/vga256d.h (revision 595) +++ E:/gp2x/tyrian21/src/Copy of src/vga256d.h (working copy) @@ -60,4 +60,6 @@ void JE_getPalette( Uint8 col, Uint8 *red, Uint8 *green, Uint8 *blue ); void JE_setPalette( Uint8 col, Uint8 red, Uint8 green, Uint8 blue ); +void JE_setPal(SDL_Color* c, int start, int count); + #endif /* VGA256D_H */
Note that is very ugly code, and causes problems. The first screen for example is all white.
|
|