RetroGame

移植Hugo


目前移植的重點擺在畫面的縮放上(320x240 ⇒ 320x480),因此,只要針對Pixel操作就可以完成初步的移植工作,而Hugo模擬器比較特別的地方在於,它有針對丁果A320硬體做一些特殊處理,因此,這一部分目前都先註解掉就可以

diff -Nr old_hugo/src/cpudingux.c new_hugo/src/cpudingux.c
1,42d0
< /*  
<     This program is free software; you can redistribute it and/or modify
<     it under the terms of the GNU General Public License as published by
<     the Free Software Foundation; either version 2 of the License, or
<     (at your option) any later version.
< 
<     This program is distributed in the hope that it will be useful,
<     but WITHOUT ANY WARRANTY; without even the implied warranty of
<     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<     GNU General Public License for more details.
< 
<     You should have received a copy of the GNU General Public License
<     along with this program; if not, write to the Free Software
<     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
< */
< 
< 
< #include <stdio.h>
< #include <stdlib.h>
< #include <sys/mman.h>
< #include <unistd.h>
< #include <fcntl.h>
< 
< #include "cpudingux.h"
< 
< /* Define this to the CPU frequency */
< #define CPU_FREQ 336000000    /* CPU clock: 336 MHz */
< #define CFG_EXTAL 12000000    /* EXT clock: 12 Mhz */
< 
< // SDRAM Timings, unit: ns
< #define SDRAM_TRAS    45  /* RAS# Active Time */
< #define SDRAM_RCD    20  /* RAS# to CAS# Delay */
< #define SDRAM_TPC    20  /* RAS# Precharge Time */
< #define SDRAM_TRWL    7  /* Write Latency Time */
< #define SDRAM_TREF          15625  /* Refresh period: 4096 refresh cycles/64ms */ 
< //#define SDRAM_TREF      7812  /* Refresh period: 8192 refresh cycles/64ms */
< 
< #include "jz4740.h"
< 
< static unsigned long jz_dev=0;
< static volatile unsigned long  *jz_cpmregl, *jz_emcregl;
< volatile unsigned short *jz_emcregs; 
44,109d1
< static inline int sdram_convert(unsigned int pllin,unsigned int *sdram_freq)
< {
<   register unsigned int ns, tmp;
<  
<   ns = 1000000000 / pllin;
<   /* Set refresh registers */
<   tmp = SDRAM_TREF/ns;
<   tmp = tmp/64 + 1;
<   if (tmp > 0xff) tmp = 0xff;
<         *sdram_freq = tmp; 
< 
<   return 0;
< 
< }
<  
< static int 
< pll_init(unsigned int clock)
< {
<   register unsigned int cfcr, plcr1;
<   unsigned int sdramclock = 0;
<   int n2FR[33] = {
<     0, 0, 1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 0, 0,
<     7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
<     9
<   };
<   //int div[5] = {1, 4, 4, 4, 4}; /* divisors of I:S:P:L:M */
<     int div[5] = {1, 3, 3, 3, 3}; /* divisors of I:S:P:L:M */
<   int nf, pllout2;
< 
<   cfcr = CPM_CPCCR_CLKOEN |
<     (n2FR[div[0]] << CPM_CPCCR_CDIV_BIT) | 
<     (n2FR[div[1]] << CPM_CPCCR_HDIV_BIT) | 
<     (n2FR[div[2]] << CPM_CPCCR_PDIV_BIT) |
<     (n2FR[div[3]] << CPM_CPCCR_MDIV_BIT) |
<     (n2FR[div[4]] << CPM_CPCCR_LDIV_BIT);
< 
<   pllout2 = (cfcr & CPM_CPCCR_PCS) ? clock : (clock / 2);
< 
<   /* Init UHC clock */
<   //  REG_CPM_UHCCDR = pllout2 / 48000000 - 1;
<   jz_cpmregl[0x6C>>2] = pllout2 / 48000000 - 1;
< 
<   nf = clock * 2 / CFG_EXTAL;
<   plcr1 = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
<     (0 << CPM_CPPCR_PLLN_BIT) |  /* RD=0, NR=2 */
<     (0 << CPM_CPPCR_PLLOD_BIT) |    /* OD=0, NO=1 */
<     (0x20 << CPM_CPPCR_PLLST_BIT) | /* PLL stable time */
<     CPM_CPPCR_PLLEN;                /* enable PLL */          
< 
<   /* init PLL */
<   //  REG_CPM_CPCCR = cfcr;
<   //  REG_CPM_CPPCR = plcr1;
<   jz_cpmregl[0] = cfcr;
<   jz_cpmregl[0x10>>2] = plcr1;
<   
<   sdram_convert(clock,&sdramclock);
<   if (sdramclock > 0) {
< //  REG_EMC_RTCOR = sdramclock;
< //  REG_EMC_RTCNT = sdramclock;    
<     jz_emcregs[0x8C>>1] = sdramclock;
<     jz_emcregs[0x88>>1] = sdramclock;  
< 
<   }
< }
< 
< void 
112,115c4,7
<   jz_dev = open("/dev/mem", O_RDWR);
<   jz_cpmregl=(unsigned long  *)mmap(0, 0x80, PROT_READ|PROT_WRITE, MAP_SHARED, jz_dev, 0x10000000);
<   jz_emcregl=(unsigned long  *)mmap(0, 0x90, PROT_READ|PROT_WRITE, MAP_SHARED, jz_dev, 0x13010000);
<   jz_emcregs=(unsigned short *)jz_emcregl;
---
>   //jz_dev = open("/dev/mem", O_RDWR);
>   //jz_cpmregl=(unsigned long  *)mmap(0, 0x80, PROT_READ|PROT_WRITE, MAP_SHARED, jz_dev, 0x10000000);
>   //jz_emcregl=(unsigned long  *)mmap(0, 0x90, PROT_READ|PROT_WRITE, MAP_SHARED, jz_dev, 0x13010000);
>   //jz_emcregs=(unsigned short *)jz_emcregl;
122,127c14,19
<   cpu_set_clock( GP2X_DEF_CLOCK );
<   munmap((void *)jz_cpmregl, 0x80); 
<   munmap((void *)jz_emcregl, 0x90);   
<   close(jz_dev);
<   fcloseall();
<   sync();
---
>   //cpu_set_clock( GP2X_DEF_CLOCK );
>   //munmap((void *)jz_cpmregl, 0x80); 
>   //munmap((void *)jz_emcregl, 0x90);   
>   //close(jz_dev);
>   //fcloseall();
>   //sync();
133,135c25,27
<   if (clock_in_mhz >= GP2X_MIN_CLOCK && clock_in_mhz <= GP2X_MAX_CLOCK) {
<     pll_init( clock_in_mhz * 1000000 );
<   }
---
>   //if (clock_in_mhz >= GP2X_MIN_CLOCK && clock_in_mhz <= GP2X_MAX_CLOCK) {
>     //pll_init( clock_in_mhz * 1000000 );
>   //}
138c30
< static unsigned int loc_clock_in_mhz = GP2X_DEF_CLOCK;
---
> //static unsigned int loc_clock_in_mhz = GP2X_DEF_CLOCK;
143,144c35,36
<   if (clock_in_mhz == loc_clock_in_mhz) return;
<   loc_clock_in_mhz = clock_in_mhz;
---
>   //if (clock_in_mhz == loc_clock_in_mhz) return;
>   //loc_clock_in_mhz = clock_in_mhz;
146c38
<   loc_set_clock(clock_in_mhz);
---
>   //loc_set_clock(clock_in_mhz);
148c40
<   return;
---
>   //return;
154c46
<   return loc_clock_in_mhz;
---
>   //return loc_clock_in_mhz;
Binary files old_hugo/src/cpuwiz.o and new_hugo/src/cpuwiz.o differ
Binary files old_hugo/src/dingux-hugo.exe and new_hugo/src/dingux-hugo.exe differ
diff -Nr old_hugo/src/global.h new_hugo/src/global.h
39c39
< # define SNAP_HEIGHT  106
---
> # define SNAP_HEIGHT  (106*2)
diff -Nr old_hugo/src/gp2x_psp.c new_hugo/src/gp2x_psp.c
26c26
< static int    loc_Volume = 50;
---
> static int    loc_Volume = 100;
diff -Nr old_hugo/src/Hugo.c new_hugo/src/Hugo.c
71a72
> #if 1
81c82
<   dstRect.h = 240;
---
>   dstRect.h = 480;
85a87,100
> #else
> 	// will crash
>   // for retrogame device
> 	int x, y;
>   uint32_t *src = blit_surface->pixels;
>   uint32_t *dst = back_surface->pixels;
> 
>   for(y=0; y<240; y++){
>     for(x=0; x<160; x++){
>       *dst++ = *src++;
>     }
>     dst+= 160;
>   }
> #endif
103a119,120
> 	
> 	printf("%s, %d %d\n", __func__, screen_h, screen_w);
120a138
>     tgt += 160; // fix for retrogame
155a174
>       tgt += 160; // fix for retrogame
200d218
< 
217c235
<       u16 *tgt_next = tgt + 320;
---
>       u16 *tgt_next = tgt + 320 + 320; // fix for retrogame
676c694
<   HUGO.hugo_render_mode       = HUGO_RENDER_FAST_MAX;
---
>   HUGO.hugo_render_mode       = HUGO_RENDER_FAST;
714a733
>     printf("Failed to open: %s\n", chFileName);
1166c1185
<   strcpy(HUGO.hugo_home_dir,".");
---
>   strcpy(HUGO.hugo_home_dir,"/mnt/game/hugo");
diff -Nr old_hugo/src/Makefile new_hugo/src/Makefile
1,3d0
< #
< # HUGO port on PSP 
< #
4a2
> TARGET = hugo
6,7c4,10
< TARGET = dingux-hugo
< SDL_CONFIG = sdl-config
---
> CROSS_COMPILE ?= mipsel-linux-
> CC          := $(CROSS_COMPILE)gcc
> STRIP       := $(CROSS_COMPILE)strip
> 
> SYSROOT     := $(shell $(CC) --print-sysroot)
> SDL_CFLAGS  := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags)
> SDL_LIBS    := $(shell $(SYSROOT)/usr/bin/sdl-config --libs)
10,78c13,74
< cpudingux.o \
< Hugo.o \
< psp_main.o \
< psp_sdl.o \
< psp_font.o \
< psp_kbd.o \
< psp_menu.o \
< psp_danzeff.o \
< psp_menu_set.o \
< psp_menu_help.o \
< psp_menu_cheat.o \
< psp_menu_list.o \
< psp_menu_kbd.o \
< psp_menu_joy.o \
< psp_editor.o \
< psp_fmgr.o \
< psp_audio.o \
< psp_joy.o \
< core/psp/osd_psp_cd.o \
< core/psp/osd_psp_mix.o \
< core/psp/osd_psp_gfx.o \
< core/psp/osd_psp_snd.o \
< core/psp/osd_psp_machine.o \
< core/psp/osd_psp_keyboard.o \
< core/cd.o \
< core/dis.o \
< core/edit_ram.o \
< core/followop.o \
< core/format.o \
< core/gfx.o \
< core/h6280.o \
< core/hard_pce.o \
< core/hugo.o \
< core/list_rom.o \
< core/lsmp3.o \
< core/mix.o \
< core/optable.o \
< core/pce.o \
< core/pcecd.o \
< core/sound.o \
< core/sprite.o \
< core/utils.o \
< core/hcd.o  \
< core/miniunz.o  \
< core/unzip.o  \
< core/bios.o core/cheat.o core/debug.o core/iniconfig.o core/bp.o
< 
< CC=gcc
< STRIP=strip
< 
< DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
< 
< MORE_CFLAGS = -I. -I/usr/include -I/usr/include/SDL -static \
< -Icore -Icore/psp \
< -DDINGUX_MODE -DNO_STDIO_REDIRECT -DMPU_JZ4740 -DHUGO_VERSION=\"$(HUGO_VERSION)\" \
< -O3 -D_GNU_SOURCE=1 -D_REENTRANT -DIS_LITTLE_ENDIAN -DFINAL_RELEASE \
< -fsigned-char -ffast-math -fomit-frame-pointer \
< -fexpensive-optimizations -fno-strength-reduce 
< # -funroll-loops  -finline-functions 
< 
< # -DHUGO_OPTIM_IDLE
< 
< # -ffast-math -fomit-frame-pointer -fno-strength-reduce 
< #  -funroll-loops  -finline-functions
< 
< # -funroll-loops -ffast-math -fomit-frame-pointer -fno-strength-reduce -finline-functions \
< # -pipe -D_GNU_SOURCE=1 -D_REENTRANT -DIS_LITTLE_ENDIAN \
< -DUNIX -DBPP16 -DLSB_FIRST -DSOUND  -DNO_STDIO_REDIRECT  \
< -DDINGUX_MODE -O2
---
>   cpudingux.o \
>   Hugo.o \
>   psp_main.o \
>   psp_sdl.o \
>   psp_font.o \
>   psp_kbd.o \
>   psp_menu.o \
>   psp_danzeff.o \
>   psp_menu_set.o \
>   psp_menu_help.o \
>   psp_menu_cheat.o \
>   psp_menu_list.o \
>   psp_menu_kbd.o \
>   psp_menu_joy.o \
>   psp_editor.o \
>   psp_fmgr.o \
>   psp_audio.o \
>   psp_joy.o \
>   core/psp/osd_psp_cd.o \
>   core/psp/osd_psp_mix.o \
>   core/psp/osd_psp_gfx.o \
>   core/psp/osd_psp_snd.o \
>   core/psp/osd_psp_machine.o \
>   core/psp/osd_psp_keyboard.o \
>   core/cd.o \
>   core/dis.o \
>   core/edit_ram.o \
>   core/followop.o \
>   core/format.o \
>   core/gfx.o \
>   core/h6280.o \
>   core/hard_pce.o \
>   core/hugo.o \
>   core/list_rom.o \
>   core/lsmp3.o \
>   core/mix.o \
>   core/optable.o \
>   core/pce.o \
>   core/pcecd.o \
>   core/sound.o \
>   core/sprite.o \
>   core/utils.o \
>   core/hcd.o  \
>   core/miniunz.o  \
>   core/unzip.o  \
>   core/bios.o core/cheat.o core/debug.o core/iniconfig.o core/bp.o
> 
> DEFAULT_CFLAGS = -I. \
>   -Icore -Icore/psp \
>   -DDINGUX_MODE -DHUGO_VERSION=\"$(HUGO_VERSION)\" \
>   -O3 -D_GNU_SOURCE=1 -D_REENTRANT -DIS_LITTLE_ENDIAN -DFINAL_RELEASE \
>   -fsigned-char -ffast-math -fomit-frame-pointer \
>   -fexpensive-optimizations -fno-strength-reduce 
>   #-DDINGUX_MODE -DNO_STDIO_REDIRECT -DMPU_JZ4740 -DHUGO_VERSION=\"$(HUGO_VERSION)\" \
>   # -funroll-loops  -finline-functions 
>   # -DHUGO_OPTIM_IDLE
>   # -ffast-math -fomit-frame-pointer -fno-strength-reduce 
>   #  -funroll-loops  -finline-functions
>   # -funroll-loops -ffast-math -fomit-frame-pointer -fno-strength-reduce -finline-functions \
>   # -pipe -D_GNU_SOURCE=1 -D_REENTRANT -DIS_LITTLE_ENDIAN \
>   -DUNIX -DBPP16 -DLSB_FIRST -DSOUND  -DNO_STDIO_REDIRECT  \
>   -DDINGUX_MODE -O2
80,84c76,77
< CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) 
< LDFLAGS = -static -s
< 
< LIBS += -lSDL_image -lSDL \
< -lpng -lz -lm -lpthread -ldl
---
> CFLAGS = $(DEFAULT_CFLAGS) $(SDL_CFLAGS) 
> LDFLAGS = $(SDL_LIBS) -lSDL_image -lpng -lz
90,93c83
< 	$(CC) $(LDFLAGS) $(CFLAGS) $(OBJS) $(LIBS) -o $(TARGET) && $(STRIP) $(TARGET)
< 
< install: $(TARGET)
< 	cp $< /media/dingux/local/emulators/dingux-hugo/
---
> 	$(CC) $(LDFLAGS) $(CFLAGS) $(OBJS) -o $(TARGET) && $(STRIP) $(TARGET)
Binary files old_hugo/src/psp_battery.o and new_hugo/src/psp_battery.o differ
Binary files old_hugo/src/psp_gu.o and new_hugo/src/psp_gu.o differ
diff -Nr old_hugo/src/psp_main.c new_hugo/src/psp_main.c
80,83c80,83
<   freopen(STDOUT_FILE, "w", stdout);
<   freopen(STDERR_FILE, "w", stderr);
<   setvbuf(stdout, NULL, _IOLBF, BUFSIZ);  /* Line buffered */
<   setbuf(stderr, NULL);          /* No buffering */
---
>   //freopen(STDOUT_FILE, "w", stdout);
>   //freopen(STDERR_FILE, "w", stderr);
>   //setvbuf(stdout, NULL, _IOLBF, BUFSIZ);  /* Line buffered */
>   //setbuf(stderr, NULL);          /* No buffering */
Binary files old_hugo/src/pspsdk_linux.o and new_hugo/src/pspsdk_linux.o differ
diff -Nr old_hugo/src/psp_sdl.c new_hugo/src/psp_sdl.c
212d211
< 
230a230
>   y*= 2;
238c238
<         if (drawfg) vram[cx + cy * PSP_LINE_SIZE] = color;
---
>         if (drawfg) vram[cx + cy * PSP_LINE_SIZE * 2] = color;
240c240
<         if (drawbg) vram[cx + cy * PSP_LINE_SIZE] = bgcolor;
---
>         if (drawbg) vram[cx + cy * PSP_LINE_SIZE * 2] = bgcolor;
260a261
>   y*= 2;
262d262
< 
269c269
<         vram[cx + cy * PSP_LINE_SIZE] = color;
---
>         vram[cx + cy * PSP_LINE_SIZE * 2] = color;
271c271
<         vram[cx + cy * PSP_LINE_SIZE] = psp_sdl_get_back2_color(x + cx, y + cy);
---
>         vram[cx + cy * PSP_LINE_SIZE * 2] = psp_sdl_get_back2_color(x + cx, y + cy);
360a361,362
> 
>   dst_y*= 2;
368a371,386
> psp_sdl_quick_copy(SDL_Surface *src, SDL_Surface *dst)
> {
>   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;
>   }
>   //SDL_SoftStretch(src, NULL, dst, NULL);
> }
> 
> void
395c413
<   int col = psp_sdl_rgb(0x0, 0x0, 0x0);
---
>   int col = psp_sdl_rgb(0xff, 0xff, 0x00);
405d422
< 
551,553c568,573
<   png_uint_32 width = info_ptr->width;
<   png_uint_32 height = info_ptr->height;
<   int color_type = info_ptr->color_type;
---
>   //png_uint_32 width = info_ptr->width;
>   //png_uint_32 height = info_ptr->height;
>   //int color_type = info_ptr->color_type;
>   png_int_32 width = png_get_image_width( png_ptr,  info_ptr);
>   png_int_32 height = png_get_image_height( png_ptr,  info_ptr);
>   int color_type = png_get_color_type( png_ptr,  info_ptr);
562c582,583
<   png_byte **pRowTable = info_ptr->row_pointers;
---
>   //png_byte **pRowTable = info_ptr->row_pointers;
>   png_byte **pRowTable = png_get_rows( png_ptr,  info_ptr);
666,668c687
<   back_surface=SDL_SetVideoMode(PSP_SDL_SCREEN_WIDTH,PSP_SDL_SCREEN_HEIGHT, 16 , 
<                                 SDL_SWSURFACE);
< 
---
>   back_surface=SDL_SetVideoMode(PSP_SDL_SCREEN_WIDTH, PSP_SDL_SCREEN_HEIGHT, 16 , SDL_SWSURFACE);
672d690
< 
diff -Nr old_hugo/src/psp_sdl.h new_hugo/src/psp_sdl.h
31c31
< # define PSP_SDL_SCREEN_HEIGHT   240
---
> # define PSP_SDL_SCREEN_HEIGHT   480

完成


返回上一頁