星をみるひと 攻略 - 解析ツール


はじめに 基礎データ 乱数解析 戦闘システム MAPイベント パスワード解析 解析ツール
 
ソース
 

(1)コード変換

星をみるひとのコード体系は次の通り。パスワード画面とは異なり、カタカナは使えない。

0123456789ABCDEF
0
1
2
3
4_
5
6
7
8
9
A
B
C
D
E
F

変換プログラム

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

/*星をみるひとROMからテキストデータ取得*/
/*Linux 3.10.0-1127.13.1.el7.x86_64 + gcc (GCC) 4.8.5 で動作確認。*/
/*雑に gcc hoshimiru_kaiseki.c で a.outが生成されるので ./a.out 星をみるひと.nes でテキスト生成されました。*/


int fd, rb, cc, romc;
char outbuf[4096], *otp;
char binbuf[4096], *btp;
unsigned char *buf, *p, *fin;
char *hoshicode[] = {
	" ","”",":","力", "."," "," "," ",  " "," "," "," ", " "," "," "," ", 
	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," "," ", 
	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," "," ", 
	"0","1","2","3", "4","5","6","7",  "8","9","゛","゜", "、","。","!","?", 

	"_","A","B","C", "D","E","F","G",  "H","I","J","K", "L","M","N","O", 
	"P","Q","R","S", "T","U","V","W",  "X","Y","Z","あ", "い","う","え","お", 
	"か","き","く","け", "こ","さ","し","す",  "せ","そ","た","ち", "つ","て","と","な", 
	"に","ぬ","ね","の", "は","ひ","ふ","へ",  "ほ","ま","み","む", "め","も","や","ゆ", 
	"よ","ら","り","る", "れ","ろ","わ","を",  "ん","ゃ","ゅ","ょ", "っ","ぁ","ぇ","ー", 
	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," "," ", 
	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," "," ", 
	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," "," ", 

	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," "," ", 
	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," "," ", 
	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," "," ", 
	" "," "," "," ", " "," "," "," ",  " "," "," "," ", " "," "," ","/"
};

int main(int argc, char * argv[])
{
	if((fd = open(argv[1], O_RDONLY) ) < 0) return 1;
	buf = calloc(1024 * 1024 , sizeof(char));
	
	for(p = buf; (rb = read(fd, p, 256)) != 0 ; p += rb);
	fin = p;
	otp = outbuf;
	*otp = 0;
	btp = binbuf;
	*btp = 0;

	for(romc = 0, cc = 0, p = buf; p < fin; cc++, p++, romc++){
		
		if(cc == 16){
			romc = 0;
		}
		if(cc % 16 == 0){
			if(cc > 0){
				printf("%s %s \n", binbuf, outbuf);
				printf("%07x: BANK%02d:%04x: ", cc, romc / (16 * 1024) ,  romc % (16 * 1024) );
			}else{
				printf("%07x: HEADER:%04x: ", cc, romc / (16 * 1024) );
			}
			
			btp = binbuf;
			*btp = 0;
			
			otp = outbuf;
			*otp = 0;
		}
		btp += sprintf(btp, "%02x", *p);
		if(cc % 2 == 1)btp += sprintf(btp, " ");
		*btp = 0;
		
		otp += sprintf(otp, hoshicode[*p]);
		*otp = 0;
	}
	printf("%s %s \n", binbuf, outbuf);
	free(buf);
	close(fd);
	return 0;
}

(2)乱数解析

敵パーティの解析に使ったプログラム

#include 

/*ほしみる乱数で敵パーティ解析 はじめの世界*/
int nextrand(int i0505, int i56)
{
	int A, tmpA, i06;
	A = (i0505 + i56) & 0xFF;
	i06 = A;
	A = A & 0x81;
	tmpA = A ^ 0x81; 
	if(A==0 || tmpA == 0){
		A = i06 + i06 + 1;
	}else{
		A = i06 + i06 ;
	}
	A = A & 0xFF;
	i0505 = A;
	return i0505;
}

int main(int argc, char * argv[])
{
	int a, b, t, h;
	int ene[4]; /*敵パーティ*/
	
	char *nam[]={
		" 1:じゃんく  "," 2:ふらっか  ","12:さらまんど ","15:ぺるぜでぶ "," 9:らむじ   ",
		"10:ちぇいさ  "," 8:くらっしゃ ","23:ふっかつしゃ"," 1:じゃんく  "," 2:ふらっか  ",
		"12:さらまんど ","15:ぺるぜでぶ "," 9:らむじ   "," 1:じゃんく  "," 2:ふらっか  ",
		"12:さらまんど ","**:      "
	};
	/* アークCITYは以下
	char *nam[]={
		" 4:しゅーた  "," 3:すとーか  ","12:のーずあい ","19:さんふらん ","24:ばたりあん ",
		"25:えるみねーた","11:めしあ   ","20:ゆりげーる "," 7:くれおぱとら"," 4:しゅーた  ",
		" 3:すとーか  ","12:のーずあい ","19:さんふらん ","24:ばたりあん "," 4:しゅーた  ",
		" 3:すとーか  ","**:      "
	}; */
	/* 宇宙タワーは以下
	char *nam[]={
		" 5:らんじゃ  ","17:ぽいすん  ","18:ゆりだぬす ","16:ばーすとのう","14:もっこし  ",
		" 6:しろいわに ","22:どな    ","21:すりーぱ  "," 5:らんじゃ  "," 5:らんじゃ  ",
		"17:ぽいすん  ","17:ぽいすん  ","18:ゆりだぬす ","18:ゆりだぬす ","16:ばーすとのう",
		"14:もっこし  ","**:      "
	}; */
	for(t = 0; t < 256; t++){
		for(b = 0; b < 256; b++){
			/*直前の乱数値設定*/
			a = b;
			/*敵パーティ初期化*/
			ene[0] = 16; ene[1] = 16; ene[2] = 16; ene[3] = 16;
			
			/*エンカウント判定*/
			a = nextrand(a, t);
			h = a & 0x1E; /*アークCITYは 0x0E 宇宙タワーは 0x06 */
			if(h == 0x04){
				/*2番目のID抽選*/
				a = nextrand(a, t);
				ene[1] = a & 0x0f;
				/*1番目が出現するか判定*/
				a = nextrand(a, t);
				h = a & 0x07;
				if(h == 0){
					ene[0] = ene[1];
				}
				/*3番目の出現判定*/
				a = nextrand(a, t);
				h = a & 0x0e;  /*アークCITYは 0x06 宇宙タワーは 0x06 */
				if(h == 0x04){
					/*3番目のID抽選*/
					a = nextrand(a, t);
					ene[2] = a & 0x0f;
					/*4番目の出現判定*/
					a = nextrand(a, t);
					h = a & 0x0e;
					if(h == 0){
						ene[3] = ene[2];
					}
				}
				printf("%s %s %s %s\n", nam[ene[0]], nam[ene[1]], nam[ene[2]], nam[ene[3]]);
			}
		}
	}
	return 0;
}


[▲]