手機 - Blackberry Passport - Core Native (C/C++) - 移植NXEngine(Cave Story)



步驟如下:

$ source ~/bbndk/bbndk-env_10_3_1_995.sh
$ cd
$ cd clone https://github.com/EXL/NXEngine
$ cd NXEngine/
$ make clean
$ make

diff

diff -Nr old_nx/ai/ai.cpp new_nx/ai/ai.cpp
41c41
< 	FILE *fp = fileopen("data/npc.tbl", "rb");
---
> 	FILE *fp = fileopen(PREFIX"data/npc.tbl", "rb");
Binary files old_nx/app.bar and new_nx/app.bar differ
diff -Nr old_nx/bar-descriptor.xml new_nx/bar-descriptor.xml
0a1,21
> <?xml version="1.0" encoding="utf-8" standalone="no"?>
> <qnx xmlns="http://www.qnx.com/schemas/application/1.0">
>   <id>com.steward.app</id>
>   <name>cavestory</name>
>   <filename>cavestory</filename>
>   <versionNumber>1.0.0</versionNumber>
>   <buildId>1</buildId>
>   <description>Cave Story TW</description>
> 
>   <author>Steward</author>
>   <authorId>gYAAgGE4qaHzBnzEAu8JKe4G1OI</authorId>
> 
>   <asset path="cavestory/nx" entry="true" type="Qnx/Elf">cavestory/nx</asset>
>   <asset path="cavestory" type="Qnx/Elf"></asset>
>   <asset path="lib" type="Qnx/Elf">lib</asset>
> 
>   <permission system="true">run_native</permission>
>   <env var="LD_LIBRARY_PATH" value="app/native/lib"/>
>   <env var="PWD" value="app/native/cavestory"/>
>   <env var="HOME" value="app/native/cavestory"/>
> </qnx>
diff -Nr old_nx/debug.txt new_nx/debug.txt
1,36d0
< Loading settings...
< Couldn't open file settings.dat.
< No saved settings; using defaults.
< videoinfo: desktop bpp 32
< Graphics::SetResolution(2)
< Setting scaling 2 and fullscreen=no
<  error << NXSurface::SetScale: CONFIG_MUTABLE_SCALE not set >>
< SDL_SetVideoMode: 320x240 @ 16bpp
< Graphics::FlushAll()
< SIFLoader::LoadHeader: read index of 8 sections
< Loading SIF section 1 from address 004d
< Loading SIF section 2 from address 044c
< SIFSpritesSect: loading 490 sprites
< fonts: using bitmapped from smalfont.bmp
< safemode print: 'I need to extract some game data'
< safemode print: 'before I can start up for the first time.'
< safemode print: ''
< safemode print: 'Before beginning, you should have the Aeon Genesis'
< safemode print: 'English translation of version 1.0.0.6, and drop'
< safemode print: 'Doukutsu.exe and it's "data" directory into the same'
< safemode print: 'folder as the "nx" program you just ran.'
< safemode print: ''
< safemode print: 'If you haven't done that yet, please press ESCAPE now'
< safemode print: 'and come back in a moment. Otherwise, you can'
< safemode print: 'press any other key to start the extraction.'
< run_until_key()
< returning key 13
< safemode print: '= Extracting Files ='
< safemode print: 'cannot find executable Doukutsu.exe'
< safemode print: ''
< safemode print: ''
< safemode print: 'Please put it and it's "data" directory'
< safemode print: 'into the same folder as this program.'
< run_until_key()
< returning key 13
< Graphics::Close()
diff -Nr old_nx/extract/extract.cpp new_nx/extract/extract.cpp
8a9
> #include "../settings.h"
16c17
< static const char *filename = "Doukutsu.exe";
---
> static const char *filename = PREFIX"Doukutsu.exe";
65c66
< 	if (result == SDLK_ESCAPE)
---
> 	if (result == SDLK_q)
135,194c136,195
< 	"endpic/credit01.bmp", 25,
< 	"endpic/credit02.bmp", 25,
< 	"endpic/credit03.bmp", 25,
< 	"endpic/credit04.bmp", 25,
< 	"endpic/credit05.bmp", 25,
< 	"endpic/credit06.bmp", 25,
< 	"endpic/credit07.bmp", 25,
< 	"endpic/credit08.bmp", 25,
< 	"endpic/credit09.bmp", 25,
< 	"endpic/credit10.bmp", 25,
< 	"endpic/credit11.bmp", 25,
< 	"endpic/credit12.bmp", 25,
< 	"endpic/credit14.bmp", 25,
< 	"endpic/credit15.bmp", 25,
< 	"endpic/credit16.bmp", 25,
< 	"endpic/credit17.bmp", 25,
< 	"endpic/credit18.bmp", 25,
< 	"endpic/pixel.bmp", 25,
< 	"wavetable.dat", 0,
< 	"org/access.org", 0,
< 	"org/balcony.org", 0,
< 	"org/balrog.org", 0,
< 	"org/breakdown.org", 0,
< 	"org/cemetary.org", 0,
< 	"org/charge.org", 0,
< 	"org/credits.org", 0,
< 	"org/egg.org", 0,
< 	"org/eyesofflame.org", 0,
< 	"org/fanfale1.org", 0,
< 	"org/fanfale2.org", 0,
< 	"org/fanfale3.org", 0,
< 	"org/gameover.org", 0,
< 	"org/geothermal.org", 0,
< 	"org/gestation.org", 0,
< 	"org/gravity.org", 0,
< 	"org/grasstown.org", 0,
< 	"org/hell.org", 0,
< 	"org/heroend.org", 0,
< 	"org/jenka1.org", 0,
< 	"org/jenka2.org", 0,
< 	"org/labyrinth.org", 0,
< 	"org/lastbattle.org", 0,
< 	"org/lastcave.org", 0,
< 	"org/meltdown2.org", 0,
< 	"org/oppression.org", 0,
< 	"org/oside.org", 0,
< 	"org/plant.org", 0,
< 	"org/pulse.org", 0,
< 	"org/quiet.org", 0,
< 	"org/run.org", 0,
< 	"org/safety.org", 0,
< 	"org/scorching.org", 0,
< 	"org/seal.org", 0,
< 	"org/theme.org", 0,
< 	"org/toroko.org", 0,
< 	"org/town.org", 0,
< 	"org/tyrant.org", 0,
< 	"org/waterway.org", 0,
< 	"org/white.org", 0,
< 	"org/zombie.org", 0,
---
> 	PREFIX"endpic/credit01.bmp", 25,
> 	PREFIX"endpic/credit02.bmp", 25,
> 	PREFIX"endpic/credit03.bmp", 25,
> 	PREFIX"endpic/credit04.bmp", 25,
> 	PREFIX"endpic/credit05.bmp", 25,
> 	PREFIX"endpic/credit06.bmp", 25,
> 	PREFIX"endpic/credit07.bmp", 25,
> 	PREFIX"endpic/credit08.bmp", 25,
> 	PREFIX"endpic/credit09.bmp", 25,
> 	PREFIX"endpic/credit10.bmp", 25,
> 	PREFIX"endpic/credit11.bmp", 25,
> 	PREFIX"endpic/credit12.bmp", 25,
> 	PREFIX"endpic/credit14.bmp", 25,
> 	PREFIX"endpic/credit15.bmp", 25,
> 	PREFIX"endpic/credit16.bmp", 25,
> 	PREFIX"endpic/credit17.bmp", 25,
> 	PREFIX"endpic/credit18.bmp", 25,
> 	PREFIX"endpic/pixel.bmp", 25,
> 	PREFIX"wavetable.dat", 0,
> 	PREFIX"org/access.org", 0,
> 	PREFIX"org/balcony.org", 0,
> 	PREFIX"org/balrog.org", 0,
> 	PREFIX"org/breakdown.org", 0,
> 	PREFIX"org/cemetary.org", 0,
> 	PREFIX"org/charge.org", 0,
> 	PREFIX"org/credits.org", 0,
> 	PREFIX"org/egg.org", 0,
> 	PREFIX"org/eyesofflame.org", 0,
> 	PREFIX"org/fanfale1.org", 0,
> 	PREFIX"org/fanfale2.org", 0,
> 	PREFIX"org/fanfale3.org", 0,
> 	PREFIX"org/gameover.org", 0,
> 	PREFIX"org/geothermal.org", 0,
> 	PREFIX"org/gestation.org", 0,
> 	PREFIX"org/gravity.org", 0,
> 	PREFIX"org/grasstown.org", 0,
> 	PREFIX"org/hell.org", 0,
> 	PREFIX"org/heroend.org", 0,
> 	PREFIX"org/jenka1.org", 0,
> 	PREFIX"org/jenka2.org", 0,
> 	PREFIX"org/labyrinth.org", 0,
> 	PREFIX"org/lastbattle.org", 0,
> 	PREFIX"org/lastcave.org", 0,
> 	PREFIX"org/meltdown2.org", 0,
> 	PREFIX"org/oppression.org", 0,
> 	PREFIX"org/oside.org", 0,
> 	PREFIX"org/plant.org", 0,
> 	PREFIX"org/pulse.org", 0,
> 	PREFIX"org/quiet.org", 0,
> 	PREFIX"org/run.org", 0,
> 	PREFIX"org/safety.org", 0,
> 	PREFIX"org/scorching.org", 0,
> 	PREFIX"org/seal.org", 0,
> 	PREFIX"org/theme.org", 0,
> 	PREFIX"org/toroko.org", 0,
> 	PREFIX"org/town.org", 0,
> 	PREFIX"org/tyrant.org", 0,
> 	PREFIX"org/waterway.org", 0,
> 	PREFIX"org/white.org", 0,
> 	PREFIX"org/zombie.org", 0,
205c206
< 	fpo = fileopen("/tmp/files.dat", "wb");
---
> 	fpo = fileopen(PREFIX"/tmp/files.dat", "wb");
diff -Nr old_nx/graphics/font.cpp new_nx/graphics/font.cpp
28,29c28,29
< const char *bmpfontfile = "smalfont.bmp";
< const char *ttffontfile = "font.ttf";
---
> const char *bmpfontfile = PREFIX"smalfont.bmp";
> const char *ttffontfile = PREFIX"font.ttf";
48c48
< static unsigned short *sjis_2_utf16;
---
> //static unsigned short *sjis_2_utf16;
43581a43582
> unsigned short sjis_2_utf16[0xfefe - 0x8140 + 1];
43586c43587
<     sjis_2_utf16 = new unsigned short[0xfefe - 0x8140 + 1];
---
>     //sjis_2_utf16 = new unsigned short[0xfefe - 0x8140 + 1];
44036c44037
<           chFont = TTF_OpenFont("chfont.ttf", 12);
---
>           chFont = TTF_OpenFont(PREFIX"chfont.ttf", 12);
diff -Nr old_nx/graphics/graphics.cpp new_nx/graphics/graphics.cpp
21d20
< SDL_Surface *ScreenSurface;
92,94c91
< 	//sdl_screen = SDL_SetVideoMode(SCREEN_WIDTH*SCALE, /*SCREEN_HEIGHT*SCALE*/480, screen_bpp, flags);
< 	ScreenSurface = SDL_SetVideoMode(320, 480, 16, SDL_HWSURFACE);
<   sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH*SCALE, SCREEN_HEIGHT*SCALE, screen_bpp, 0, 0, 0, 0);
---
> 	sdl_screen = SDL_SetVideoMode(SCREEN_WIDTH*SCALE, SCREEN_HEIGHT*SCALE, screen_bpp, flags);
diff -Nr old_nx/graphics/nxsurface.cpp new_nx/graphics/nxsurface.cpp
14,15d13
< extern SDL_Surface *ScreenSurface;
< 
243,256c241
< 	//SDL_Flip(fSurface);
<   //SDL_SoftStretch(fSurface, NULL, ScreenSurface, NULL);
<   if(SDL_MUSTLOCK(ScreenSurface)) SDL_LockSurface(ScreenSurface);
<   int x, y;
<   uint32_t *s = (uint32_t*)fSurface->pixels;
<   uint32_t *d = (uint32_t*)ScreenSurface->pixels;
<   for(y=0; y<240; y++){
<     for(x=0; x<160; x++){
<       *d++ = *s++;
<     }
<     d+= 160;
<   }
<   if(SDL_MUSTLOCK(ScreenSurface)) SDL_UnlockSurface(ScreenSurface);
<   SDL_Flip(ScreenSurface);
---
> 	SDL_Flip(fSurface);
diff -Nr old_nx/graphics/sprites.cpp new_nx/graphics/sprites.cpp
31c31
< 	if (load_sif("sprites.sif"))
---
> 	if (load_sif(PREFIX"sprites.sif"))
diff -Nr old_nx/input.cpp new_nx/input.cpp
36,45c36,45
< 		mappings[SDLK_LEFT] = LEFTKEY;
< 		mappings[SDLK_RIGHT] = RIGHTKEY;
< 		mappings[SDLK_UP] = UPKEY;
< 		mappings[SDLK_DOWN] = DOWNKEY;
< 		mappings[SDLK_LCTRL] = JUMPKEY;
< 		mappings[SDLK_LALT] = FIREKEY;
< 		mappings[SDLK_SPACE] = PREVWPNKEY;
< 		mappings[SDLK_LSHIFT] = NEXTWPNKEY;
< 		mappings[SDLK_TAB] = INVENTORYKEY;
< 		mappings[SDLK_BACKSPACE] = MAPSYSTEMKEY;
---
> 		mappings[SDLK_a] = LEFTKEY;
> 		mappings[SDLK_d] = RIGHTKEY;
> 		mappings[SDLK_w] = UPKEY;
> 		mappings[SDLK_s] = DOWNKEY;
> 		mappings[SDLK_l] = JUMPKEY;
> 		mappings[SDLK_BACKSPACE] = FIREKEY;
> 		mappings[SDLK_o] = PREVWPNKEY;
> 		mappings[SDLK_p] = NEXTWPNKEY;
> 		mappings[SDLK_v] = INVENTORYKEY;
> 		mappings[SDLK_b] = MAPSYSTEMKEY;
47c47
< 		mappings[SDLK_ESCAPE] = ESCKEY;
---
> 		mappings[SDLK_SPACE] = ESCKEY;
62,64c62,64
< 		mappings[SDLK_a] = FREEZE_FRAME_KEY;
< 		mappings[SDLK_b] = FRAME_ADVANCE_KEY;
< 		mappings[SDLK_c] = DEBUG_FLY_KEY;
---
> 		mappings[SDLK_f] = FREEZE_FRAME_KEY;
> 		mappings[SDLK_g] = FRAME_ADVANCE_KEY;
> 		mappings[SDLK_h] = DEBUG_FLY_KEY;
Binary files old_nx/lib/libfreetype.a and new_nx/lib/libfreetype.a differ
Binary files old_nx/lib/libfreetype.so.11 and new_nx/lib/libfreetype.so.11 differ
Binary files old_nx/lib/libSDL-1.2.so.11 and new_nx/lib/libSDL-1.2.so.11 differ
Binary files old_nx/lib/libSDL.a and new_nx/lib/libSDL.a differ
Binary files old_nx/lib/libSDL_image-1.2.so.8 and new_nx/lib/libSDL_image-1.2.so.8 differ
Binary files old_nx/lib/libSDLmain.a and new_nx/lib/libSDLmain.a differ
Binary files old_nx/lib/libSDL_mixer.a and new_nx/lib/libSDL_mixer.a differ
Binary files old_nx/lib/libSDL_ttf-2.0.so.10 and new_nx/lib/libSDL_ttf-2.0.so.10 differ
Binary files old_nx/lib/libSDL_ttf.a and new_nx/lib/libSDL_ttf.a differ
Binary files old_nx/lib/libstdc++.a and new_nx/lib/libstdc++.a differ
Binary files old_nx/lib/libTouchControlOverlayS.a and new_nx/lib/libTouchControlOverlayS.a differ
Binary files old_nx/lib/libTouchControlOverlay.so.1 and new_nx/lib/libTouchControlOverlay.so.1 differ
diff -Nr old_nx/main.cpp new_nx/main.cpp
8,11c8,11
< const char *data_dir = "data";
< const char *stage_dir = "data/Stage";
< const char *pic_dir = "endpic";
< const char *nxdata_dir = ".";
---
> const char *data_dir = PREFIX"data";
> const char *stage_dir = PREFIX"data/Stage";
> const char *pic_dir = PREFIX"endpic";
> const char *nxdata_dir = PREFIX"";
28,29c28,29
< 	
< 	SetLogFilename("debug.txt");
---
> 
> 	SetLogFilename(PREFIX"debug.txt");
456c456,460
< 	if (file_exists(fname)) return 0;
---
> 	printf("steward, %s\n", fname);
> 	if(file_exists(fname)){
> 		printf("steward 1\n");
> 		return 0;
> 	}
458,459c462,463
< 	if (!safemode::init())
< 	{
---
> 	if(!safemode::init()){
> 		printf("steward 2\n");
470c474
< 	
---
> 		printf("steward 3\n");
diff -Nr old_nx/Makefile new_nx/Makefile
5,6c5,6
<   SDL_CONFIG = sdl-config
<   CFLAGS+= 
---
>   CFLAGS = `sdl-config --cflags`
> 	SDL_LIBS = -lSDL -lSDL_ttf 
8,10c8,10
<   CC = mipsel-linux-g++
<   SDL_CONFIG = /home/steward/Github/gh_retrogame_toolchain/mipsel-linux-gcc/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/bin/sdl-config
<   CFLAGS+= -I/home/steward/Github/gh_retrogame_toolchain/mipsel-linux-gcc/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/include -I/home/steward/Github/gh_retrogame_toolchain/mipsel-linux-gcc/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/include/SDL
---
>   CC = ntoarmv7-gcc
>   CFLAGS = -I/home/steward/Github/gh_q30_toolchain/target_10_3_1_995/qnx6/include/ -I/home/steward/Github/gh_q30_toolchain/target_10_3_1_995/qnx6/include/SDL
> 	SDL_LIBS = lib/libfreetype.so.11  lib/libSDL-1.2.so.11 lib/libstdc++.a -lm lib/libSDL_ttf-2.0.so.10
13a14,15
> 	mv nx cavestory/
> 	blackberry-nativepackager -package app.bar bar-descriptor.xml -devMode -debugToken ${HOME}/.rim/debugtoken_q30.bar
74,75c76
< 	 `$(SDL_CONFIG) --libs` -lSDL_ttf -lstdc++ -lm
< 
2557a2559
> 	rm app.bar
diff -Nr old_nx/map.cpp new_nx/map.cpp
286c286
< 	fp = fileopen("stage.dat", "rb");
---
> 	fp = fileopen(PREFIX"stage.dat", "rb");
308c308
< 	if (!(fp = fileopen("tilekey.dat", "rb")))
---
> 	if (!(fp = fileopen(PREFIX"tilekey.dat", "rb")))
Binary files old_nx/nx.core and new_nx/nx.core differ
diff -Nr old_nx/platform/Linux/vbesync.c new_nx/platform/Linux/vbesync.c
4c4
< #include <libdrm/drm.h>
---
> //#include <libdrm/drm.h>
diff -Nr old_nx/settings.cpp new_nx/settings.cpp
11c11
< const char *setfilename = "settings.dat";
---
> const char *setfilename = PREFIX"settings.dat";
diff -Nr old_nx/settings.h new_nx/settings.h
5a6
> #define PREFIX "app/native/cavestory/"
diff -Nr old_nx/sound/org.cpp new_nx/sound/org.cpp
7c7
< #include <endian.h>
---
> //#include <endian.h>
8a9
> #include "../settings.h"
113c114
< static const char *drum_cache = "drum.pcm";
---
> static const char *drum_cache = PREFIX"drum.pcm";
120c121
< 			sprintf(fname, "./drums/%s.wav", drum_names[d]);
---
> 			sprintf(fname, PREFIX"/drums/%s.wav", drum_names[d]);
157c158
< 				sprintf(fname, "%sfx%02x.pxt", pxt_path, drum_pxt[d]);
---
> 				sprintf(fname, PREFIX"%sfx%02x.pxt", pxt_path, drum_pxt[d]);
615c616
< 		final[cursample] = htole16(mixed_sample);
---
> 		final[cursample] = mixed_sample;
diff -Nr old_nx/sound/pxt.cpp new_nx/sound/pxt.cpp
9c9
< #include <endian.h>
---
> //#include <endian.h>
700c700
< 		value = htole16(value);
---
> 		value = value;
diff -Nr old_nx/sound/sound.cpp new_nx/sound/sound.cpp
37,40c37,40
< static const char *pxt_dir = "./pxt/";
< static const char *org_dir = "./org/";
< static const char *sndcache = "sndcache.pcm";
< static const char *org_wavetable = "wavetable.dat";
---
> static const char *pxt_dir = PREFIX"pxt/";
> static const char *org_dir = PREFIX"org/";
> static const char *sndcache = PREFIX"sndcache.pcm";
> static const char *org_wavetable = PREFIX"wavetable.dat";

完成