示例#1
0
def list_tagF00B_symbol(lm_data):

	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF00B,)):
		res = tag_reader.read_tag(format.DATA[0xF00B], tag)
		assert res["unk"] == 1
		return		
	assert False, "Missing tag F00B"
示例#2
0
def list_tag0025_symbol(lm_data):
	data = lm_data[0x40:]
	symbol_list = get_symbol_list(data)
	
	box_list = list_tagF004_symbol(lm_data)
	
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF00D, 0x0025)):
		d = tag_reader.read_tag(format.DATA[tag_type], tag)
		if tag_type == 0xF00D:
			tag0025_cnt = d["0025_cnt"]
		elif tag_type == 0x0025:
			tag0025_cnt -= 1
			print "0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x" % (d["unk1"], d["unk3"], d["unk7"], d["unk8"], d["unk9"], d["unk10"])
			
			# A neat print for all known fields of tag 0x0025
			flags = (d["unk9"] << 32) + d["unk10"]
			fHTML = flags & 0x1
			
			
			box = box_list[d["rect_idx"]]
			var_name = symbol_list[d["var_name_idx"]]
			init_text = symbol_list[d["init_txt_idx"]]
			print "ID=%d, rect:(%.2f, %.2f, %.2f, %.2f), font_size=%.2f, spacing=(%.2f, %.2f, %.2f, %.2f), var=%s, init_text=%s," % ((d["character_id"],) + tuple(box) + (d["font_size"], d["left_margin"], d["right_margin"], d["indent"], d["leading"], var_name, init_text))
			
		if tag0025_cnt == 0:
			break
示例#3
0
def list_tag0007_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF00D, 0x0007, )):
		d = tag_reader.read_tag(format.DATA[tag_type], tag)
		if tag_type == 0xF00D:
			tag0007_cnt = d["0007_cnt"]
		elif tag_type == 0x0007:
			tag0007_cnt -= 1
			print "%x, %x, %x" % (d["unk2"], d["unk3"], d["unk5"], )
			if tag0007_cnt == 0:
				break
示例#4
0
def list_tagF00C_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF00C,)):
		res = tag_reader.read_tag(format.DATA[0xF00C], tag)

		assert res["v"] == 0 and res["e"] == 1 and res["r"] == 2
		assert res["max_character_id"] == res["start_character_id"]
		assert res["reserved"] == -1
		assert res["reserved2"] == 0
		
		return res
	assert False, "Missing tag F00C"
示例#5
0
def list_tagF007_symbol(lm_data, prefix_for_noname=""):
	symbol_list = get_symbol_list(lm_data[0x40:])
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF007,)):
		res = tag_reader.read_tag(format.DATA[0xF007], tag)
		image_list = []
		for image_info in res["img_list"]:
			if symbol_list[image_info["name_idx"]] == "":
				fname = "noname_%s_0x%x.png" % (prefix_for_noname, 
					image_info["img_idx"])
			else:
				fname = symbol_list[image_info["name_idx"]]
			image_list.append((image_info["img_idx"], image_info["name_idx"], image_info["width"], image_info["height"], fname))
		return image_list
	assert False, "Missing tag F007"
示例#6
0
def read_tagF022(tag):
	tag_size, = struct.unpack(">I", tag[0x4: 0x8])
	tag_size_bytes = tag_size * 4 + 8

	res = tag_reader.read_tag(format.DATA[0xF022], tag)
	character_id = res["character_id"]
	unk1 = res["const0_0"]
	assert unk1 == 0
	size_idx = res["size_idx"]
	f023_cnt = res["f023_cnt"]
	f024_cnt = res["f024_cnt"]
	if f024_cnt is None:
		f024_cnt = 0
	
	return character_id, unk1, size_idx, f023_cnt, f024_cnt
示例#7
0
def list_tagF005_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF005,)):
		res = tag_reader.read_tag(format.DATA[0xF005], tag)
		as_list = []
		off = 0xc
		idx = 0
		for abc in res["as_list"]:
			as_list.append((off+0x4, abc["as_len"]))
#			print "%x\toff=0x%x len=0x%x" % ((idx, ) + as_list[-1])
			abc["padding"] = abc["padding"] or ""
			off += 0x4 + abc["as_len"] + len(abc["padding"])
			idx += 1

		as_list = [(abc["as_len"], abc["bytecode"]) for abc in res["as_list"]]
		return as_list
	assert False, "Missing tag F005"
示例#8
0
def list_tag0027_symbol(lm_data, fname=""):
	data = lm_data[0x40:]
	symbol_list = get_symbol_list(data)
	
	ret = []
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0x0027, )):
		res = tag_reader.read_tag(format.DATA[0x0027], tag)

		characterID = res["character_id"]
		unk1, class_name_idx, frame_label_cnt = res["const0_0"], res["class_name_idx"], res["frame_label_cnt"]
		tag0001_cnt = res["0001_cnt"]
		key_frame_cnt = res["key_frame_cnt"]
		max_depth, unk2 = res["max_depth"], res["const1_0"]
		class_name = symbol_list[class_name_idx]
		ret.append((tag_type, off, tag_size_bytes, characterID, tag0001_cnt, frame_label_cnt, max_depth, class_name, key_frame_cnt, unk1, unk2))
		
#		assert unk1 == 0
#		assert text in range(15), fname
#		assert unk2 == 0
			
	return ret
示例#9
0
def get_symbol_list(tag):
	res = tag_reader.read_tag(format.DATA[0xF001], tag)
	ret = [symbol["symbol"] or "" for symbol in res["symbol_list"]]

	return ret
示例#10
0
def list_tagF00D_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF00D,)):
		res = tag_reader.read_tag(format.DATA[0xF00D], tag)
#		assert res["unk6"] in (0, ), "%d" % res["unk6"]
		
		return res
示例#11
0
def list_tagF003_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF003,)):
		res = tag_reader.read_tag(format.DATA[0xF003], tag)
		mat_list = [(mat["trans_x"], mat["trans_y"], mat["rotateskew_x"], mat["rotateskew_y"], mat["scale_x"], mat["scale_y"]) for mat in res["mat_list"]]
		return mat_list
	assert False, "Missing tag F003"
示例#12
0
def list_tagF002_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF002,)):
		res = tag_reader.read_tag(format.DATA[0xF002], tag)
		color_list = [(color["R"], color["G"], color["B"], color["A"]) for color in res["color_list"]]
		return color_list
	assert False, "Missing tag F002"
示例#13
0
def list_tagF024_img(lm_data):
	data = lm_data[0x40:]
	symbol_list = get_symbol_list(data)
	ori_pic_list = list_tagF007_symbol(lm_data)	
	off = 0x40
	
	tex_size_list = list_tagF004_symbol(lm_data)
	
	x_min = y_min = 1000000000000
	x_max = y_max = -1000000000000
	size = (x_min, y_min, x_max, y_max)
					
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF022, 0xF023, 0xF024)):
		
		if tag_type == 0xF022:

			BOUND_ERR_MSG = "texture boundary not match boundary table!"
			assert x_min >= size[0], BOUND_ERR_MSG
			assert y_min >= size[1], BOUND_ERR_MSG
	   		assert x_max <= size[2], BOUND_ERR_MSG
			assert y_max <= size[3], BOUND_ERR_MSG

			x_min = y_min = 1000000000000
   			x_max = y_max = -1000000000000			

			res = read_tagF022(tag)
			id = res[0]
			size_idx = res[2]
			size = tex_size_list[size_idx]
			print "CharacterID=%d, size: (%d, %d, %d, %d)" % (id, size[0], size[1], size[2], size[3])
					
		elif tag_type == 0xF024:
			
			idx, flag, unk1, unk2 = struct.unpack(">IHHI", data[0x8:0x14])
			
			fv_list = []
			for off1 in xrange(0x14, 0x54, 0x4):
				fv = struct.unpack(">f", data[off1:off1+0x4])[0]
				fv_list.append(fv)	# (x, y, u, v)
				
			unk3, unk4, unk5, unk6 = struct.unpack(">IHHI", data[0x54: 0x60])

			x_min = min(x_min, fv_list[0], fv_list[4], fv_list[8], fv_list[12])
			x_max = max(x_max, fv_list[0], fv_list[4], fv_list[8], fv_list[12])
			y_min = min(y_min, fv_list[1], fv_list[5], fv_list[9], fv_list[13])
			y_max = max(y_max, fv_list[1], fv_list[5], fv_list[9], fv_list[13])
				
			if flag == 0x41:
			
				ori_pic_list = list_tagF007_symbol(lm_data)
#				print ori_pic_list, idx
				ori_pic_fname_idx = ori_pic_list[idx][1]
				ori_pic_tga_idx = ori_pic_list[idx][0]
				sb = symbol_list[ori_pic_fname_idx]

				print "\ttag:0x%04x, off=0x%x,\tsize=0x%x,\tfill_img=%s" \
					% (tag_type, off, tag_size_bytes, sb)
				print "\t\t",fv_list[:4]
				print "\t\t",fv_list[4:8]
				print "\t\t",fv_list[8:12]
				print "\t\t",fv_list[12:]

			else:
				pass
				print "\ttag:0x%04x, off=0x%x,\tsize=0x%x,fill_color_idx=0x%x" \
					% (tag_type, off, tag_size_bytes,idx)
				print "\t\t",fv_list[:4]
				print "\t\t",fv_list[4:8]
				print "\t\t",fv_list[8:12]
				print "\t\t",fv_list[12:]			
				
			print "unk = 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x" % (unk1, unk2, unk3, unk4, unk5, unk6)
			
		if tag_type == 0xF023:
			
			d = tag_reader.read_tag(format.DATA[0xF023], tag)
			fv_list = [
						d["x0"], d["y0"], d["u0"], d["v0"],
						d["x1"], d["y1"], d["u1"], d["v1"],
						d["x2"], d["y2"], d["u2"], d["v2"],
						d["x3"], d["y3"], d["u3"], d["v3"],
						]
			flag, idx = d["fill_style"], d["fill_idx"]
			unk = d["const0_0"]

			x_min = min(x_min, fv_list[0], fv_list[4], fv_list[8], fv_list[12])
			x_max = max(x_max, fv_list[0], fv_list[4], fv_list[8], fv_list[12])
			y_min = min(y_min, fv_list[1], fv_list[5], fv_list[9], fv_list[13])
			y_max = max(y_max, fv_list[1], fv_list[5], fv_list[9], fv_list[13])
				
			if flag in (0x41, 0x40):
			
				ori_pic_fname_idx = ori_pic_list[idx][1]
				ori_pic_tga_idx = ori_pic_list[idx][0]
				sb = symbol_list[ori_pic_fname_idx]
				if not sb:
					sb = "[IMAGE%d]" % ori_pic_list[idx][0]

				print "\ttag:0x%04x, off=0x%x,\tsize=0x%x,\tfill_img=%s" \
					% (tag_type, off, tag_size_bytes, sb)
				print "\t\t",fv_list[:4]
				print "\t\t",fv_list[4:8]
				print "\t\t",fv_list[8:12]
				print "\t\t",fv_list[12:]
				
			else:
				pass
				print "\ttag:0x%04x, off=0x%x,\tsize=0x%x,fill_color_idx=0x%x" \
					% (tag_type, off, tag_size_bytes, idx)
				print "\t\t",fv_list[:4]
				print "\t\t",fv_list[4:8]
				print "\t\t",fv_list[8:12]
				print "\t\t",fv_list[12:]			

		elif tag_type == 0x0027:
			break
		elif tag_type == 0xFF00:
			break
示例#14
0
def list_tag000C_symbol(lm_data):
	as_list = list_tagF005_symbol(lm_data)
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0x000C,)):
		res = tag_reader.read_tag(format.DATA[0x000C], tag)
#		assert res["unk1"] == 0, "%d" % res["unk1"]
		assert res["unk0"] < len(as_list)
示例#15
0
def list_tag000A_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0x000A,)):
		res = tag_reader.read_tag(format.DATA[0x000A], tag)
		return		
	assert False, "Missing tag 000A"
示例#16
0
def list_tagF004_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF004,)):
		res = tag_reader.read_tag(format.DATA[0xF004], tag)
		box_list = [(box["xmin"], box["ymin"], box["xmax"], box["ymax"]) for box in res["box_list"]]
		return box_list
	assert False, "Missing tag F004"
示例#17
0
def list_tagF103_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0xF103,)):
		res = tag_reader.read_tag(format.DATA[0xF103], tag)
		pos_list = [(pos["x"], pos["y"]) for pos in res["pos_list"]]
		return pos_list
	assert False, "Missing tag F103"
示例#18
0
def list_tag0004_symbol(lm_data):
	ref_table = get_xref(lm_data)
	
	xy_list = list_tagF103_symbol(lm_data)
	data = lm_data[0x40:]
	symbol_list = get_symbol_list(data)
	color_list = list_tagF002_symbol(lm_data)
	as_list = list_tagF005_symbol(lm_data)
	matrix_list = list_tagF003_symbol(lm_data)

	for off, tag_type, tag_size_bytes, data in iter_tag(lm_data):
		if tag_type == 0x0027:
			d = tag_reader.read_tag(format.DATA[0x0027], data)
			id = d["character_id"]
			max_depth = d["max_depth"]
			print "===================== offset=0x%x, CharacterID=%d, max_depth=%d %s" % (off, id, max_depth, id in ref_table and "Ref As %s" % (",".join(list(ref_table[id]))) or "")
		elif tag_type == 0x0001:
			d = tag_reader.read_tag(format.DATA[0x0001], data)
			print "Frame %d, cmd_cnt=%d" % (d["frame_id"], d["cmd_cnt"])
		elif tag_type == 0xf014:
			d = tag_reader.read_tag(format.DATA[0xF014], data)		
			print ">>>>>>>>>Do ClipAction: %d" % d["as_idx"]
		elif tag_type == 0xf105:
			d = tag_reader.read_tag(format.DATA[0xF105], data)
			print ">>>>>>>>>KeyFrame: v=%d" % d["frame_id"]
		elif tag_type == 0x000c:
			print ">>>>>>>>>Do Action %d" % struct.unpack(">I", data[0x8:0xc])
		elif tag_type == 0x0005:
			d = tag_reader.read_tag(format.DATA[0x0005], data)
			print ">>>>>>>>>RemoveObject at depth%d" % d["depth"]
			assert d["unk1"] == 0
			assert d["unk0"] == 0
			assert d["depth"] < max_depth
		elif tag_type == 0x002b:
			d = tag_reader.read_tag(format.DATA[0x002B], data)
			print ">>>>>>>>>FrameLabel: %s@%d" % (symbol_list[d["name_idx"]], d["frame_id"])
			assert d["unk0"] == 0
		if tag_type == 0x0004:
			res = tag_reader.read_tag(format.DATA[0x0004], data)
			
			character_id = res["character_id"]
			inst_id = res["inst_id"]
			unk1, name_idx = res["unk1"], res["name_idx"]
			flags, blend_mode, = res["flags"], res["blend_mode"]
			depth, unk3, ratio, unk5 = res["depth"], res["unk3"], res["ratio"], res["unk5"]
			trans_idx, color_mul_idx ,color_add_idx, unk6, clip_action_cnt = res["trans_idx"], res["color_mul_idx"], res["color_add_idx"], res["unk6"], res["clip_action_cnt"]

			blend_mode_name = blend_mode_2_name[blend_mode]
			if trans_idx == 0xFFFFFFFF:
				translate = scale = rotateskew = "null"
			elif (trans_idx & 0x80000000) == 0:
				translate = "(%.1f, %.1f)" % (matrix_list[trans_idx][4],
					matrix_list[trans_idx][5])
				scale = "(%.1f, %.1f)" % (matrix_list[trans_idx][0],
					matrix_list[trans_idx][3])
				rotateskew = "(%.1f, %.1f)" % (
					matrix_list[trans_idx][1], 
					matrix_list[trans_idx][2])
			else:
				translate = "(%.1f, %.1f)" % xy_list[trans_idx & 0xFFFFFFF]
				scale = rotateskew = ""
			if name_idx >= 0:
				name = symbol_list[name_idx]
			else:
				name = ""

			flags_str = ""
			flags_str += (flags & 0x1) and "N" or "-"
			flags_str += (flags & 0x2) and "M" or "-"
			if flags & (~0x3) != 0:
				assert False, "==============#new flags ! 0x%x " % flags

			if color_mul_idx < 0:
				color_mul_str = ""
			else:
				color_mul = color_list[color_mul_idx]
				color_mul_str = "(%.1f,%.1f,%.1f,%.1f)" % tuple([c/256.0 for c in color_mul])
			if color_add_idx < 0:
				color_add_str = ""
			else:
				color_add = color_list[color_add_idx]
				color_add_str = "(%d,%d,%d,%d)" % tuple(color_add)

			print "PlaceObject, off=0x%x,\tsize=0x%x" % (off, tag_size_bytes)
			print ("\tID=%d,\tdepth=%d,\tpos=%s,\tscale=%s,\tskew=%s,\tInstID=%d," \
				+"\tflags=%s,\tcolMul=%s,\tcolAdd=%s,\tclipAction=%d,\tname=%s,\tratio=%d\tblend_mode=%s") % \
				(character_id, depth, translate, scale, rotateskew, inst_id,
					flags_str, color_mul_str, color_add_str, clip_action_cnt, name, ratio, blend_mode_name)

			assert unk1 == 0 and unk3 == 0 and unk5 == 0 and unk6 == 0
			
		if tag_type == 0xFF00:
			break
		off += tag_size_bytes
		data = data[tag_size_bytes:]
示例#19
0
def list_tag0001_symbol(lm_data):
	for off, tag_type, tag_size_bytes, tag in iter_tag(lm_data, (0x0001,)):
		d = tag_reader.read_tag(format.DATA[0x0001], tag)
		print "tag:0x%04x, off=0x%x,\tsize=0x%x,\tframe=0x%x,\tsub_tag_cnt_cnt=%d" % \
			(tag_type, off, tag_size_bytes, d["frame_id"], d["cmd_cnt"])