RetroGame

移植GnuBoy


相當經典的GB/GBC模擬器,由於它也被移植到Dingoo A320掌機身上,因此,司徒也在第一時間移植這款模擬器,效果呈現還算不錯, 而目前主要的移植部分仍然是畫面的拉伸,程式碼部分如下說明:

diff -Nr old_gnuboy/sys/sdl/sdl.c new_gnuboy/sys/sdl/sdl.c
24,26c24,26
< static int fullscreen = 0;
< static int use_altenter = 1;
< static int use_joy = 1, sdl_joy_num;
---
> static int fullscreen = 1;
> static int use_altenter = -1;
> static int use_joy = -1, sdl_joy_num;
30a31
> static SDL_Surface *ScreenSurface;
162a164,165
> 
>     scale = 2; // fix for retrogame
167c170
< 	flags = SDL_ANYFORMAT | SDL_HWPALETTE | SDL_HWSURFACE;
---
> 	flags = SDL_HWPALETTE | SDL_SWSURFACE;
172c175
< 	if (SDL_Init(SDL_INIT_VIDEO))
---
> 	if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO))
175c178
< 	if (!(screen = SDL_SetVideoMode(vmode[0], vmode[1], vmode[2], flags)))
---
> 	if (!(ScreenSurface = SDL_SetVideoMode(320, 480, 16, flags)))
177a181
>   screen = SDL_CreateRGBSurface(SDL_SWSURFACE, vmode[0], vmode[1], vmode[2], 0, 0, 0, 0);
415a420,438
> void
> quick_copy(SDL_Surface *src, SDL_Surface *dst)
> {
> #if 0
>   int x, y;
>   uint32_t *s = src->pixels;
>   uint32_t *d = dst->pixels;
> 
>   for(y=0; y<240; y++){
>     for(x=0; x<160; x++){
>       *d++ = *s++;
>     }
>     d+= 160;
>   }
> #else
>   SDL_SoftStretch(src, NULL, dst, NULL);
> #endif
> }
> 
426c449,453
< 	if (fb.enabled) SDL_Flip(screen);
---
> 	if (fb.enabled){
>     //SDL_Flip(screen);
>     quick_copy(screen, ScreenSurface);
>     SDL_Flip(ScreenSurface);
>   }

完成


返回上一頁