parameters: (YBN)
docstring: u32 'YSTB'
  	u32 ver
  	u32 count
  	u32 Code_Size=count*4
  	u32 Arg_Size=count*12
  	u32 Resource_Size
  	u32 T4_Size=count*4
  	u32 reserved==0
  	====================
  	Code:
  		u8 [0x1b, 0x1c]
  		u8 nArg(sizeof()=0xC)
  		u16 Reserved
  	Arg:u8
  		u8
  		u16
  		u32 ResLength
  		u32 ResOffset(of Resource_section)
  	Resource:
  		struct{
  			u8 Type
  			u16 ResLen
  			char[] ResStr
  			}[]
  	JmpList: u32[]
docstring_summary: u32 'YSTB'
  	u32 ver
  	u32 count
  	u32 Code_Size=count*4
  	u32 Arg_Size=count*12
  	u32 Resource_Size
  	u32 T4_Size=count*4
  	u32 reserved==0
  	====================
  	Code:
  		u8 [0x1b, 0x1c]
  		u8 nArg(sizeof()=0xC)
  		u16 Reserved
  	Arg:u8
  		u8
  		u16
  		u32 ResLength
  		u32 ResOffset(of Resource_section)
  	Resource:
  		struct{
  			u8 Type
  			u16 ResLen
  			char[] ResStr
  			}[]
  	JmpList: u32[]
docstring_tokens: u32 YSTB u32 ver u32 count u32 Code_Size = count * 4 u32 Arg_Size = count * 12 u32 Resource_Size u32 T4_Size = count * 4 u32 reserved == 0 ==================== Code : u8 [ 0x1b 0x1c ] u8 nArg ( sizeof () = 0xC ) u16 Reserved Arg : u8 u8 u16 u32 ResLength u32 ResOffset ( of Resource_section ) Resource : struct { u8 Type u16 ResLen char [] ResStr } [] JmpList : u32 []
function: def YSTB(YBN):
  	'''u32 'YSTB'
  	u32 ver
  	u32 count
  	u32 Code_Size=count*4
  	u32 Arg_Size=count*12
  	u32 Resource_Size
  	u32 T4_Size=count*4
  	u32 reserved==0
  	====================
  	Code:
  		u8 [0x1b, 0x1c]
  		u8 nArg(sizeof()=0xC)
  		u16 Reserved
  	Arg:u8
  		u8
  		u16
  		u32 ResLength
  		u32 ResOffset(of Resource_section)
  	Resource:
  		struct{
  			u8 Type
  			u16 ResLen
  			char[] ResStr
  			}[]
  	JmpList: u32[]
  	'''
  	TXT=open(sys.argv[1]+'.code','w')
  	ver, count, Code_Size, Arg_Size, Res_Size, OffList_Size, reserved = \
  		struct.unpack('IIIIIII', YBN.read(28))
  	TXT.write('#YSTB v%.2f\n\n'%(ver/100.))
  	Code=MyStr(YBN.read(Code_Size))
  	Args=MyStr(YBN.read(Arg_Size))
  	Res=MyStr(YBN.read(Res_Size))
  	OffList=struct.unpack('I'*count, YBN.read(OffList_Size))
  	Text=[]
  	Count=0
  	CodeStr=[]
  	for n in range(count):
  		OP, nArg, Reserved=struct.unpack('BBH',Code.read(4))
  		CodeStr.append('OP%02X'%OP)
  		if Reserved:
  			print 'Warning: Reserved value is used !'
  			os.system('pause')
  		for n in range(nArg):
  			Arg, ArgType, ResLen, ResOff = struct.unpack('HHII',Args.read(12))
  			Res.seek(ResOff)
  			ResStr=[]
  			if ResOff+ResLen>len(Res): ResLen=len(Res)-ResOff
  			IsText=0
  			while Res.tell()<ResOff+ResLen:
  				Type=ord(Res.read(1))
  				if Type>0x7f:
  					Res.seek(-1,1)
  					Count+=1
  					Text.append(Res.read(ResLen))
  					ResStr=['<%04d>'%Count]
  				else:
  					StrLen=struct.unpack('H',Res.read(2))[0]
  					#if StrLen>ResLen: pdb.set_trace()
  					Resource=Res.read(StrLen)
  					if not Type==0x4d:
  						Resource=''.join(['%02X'%ord(n) for n in Resource])
  					elif Resource[0]==Resource[-1]=='"':
  						for n in Resource:
  							if ord(n)>0x7f:
  								IsText=1
  								break
  					if IsText:
  						Count+=1
  						Text.append(Resource[1:-1])
  						Resource='"<%04d>"'%Count
  						IsText=0
  					ResStr.append('%X:'%Type+Resource)
  			CodeStr.append('\t%X:%X\t%s'%(Arg, ArgType, ', '.join(ResStr)))
  	TXT.write('\n'.join(CodeStr))
  	TXT.write('\n\n#Program\n'+', '.join(['%d'%n for n in OffList]))
  	if Text: open(sys.argv[1]+'.txt', 'w').write('\n'.join(Text))
  	TXT.close()
function_tokens: def YSTB ( YBN ) : TXT = open ( sys . argv [ 1 ] + '.code' , 'w' ) ver , count , Code_Size , Arg_Size , Res_Size , OffList_Size , reserved = struct . unpack ( 'IIIIIII' , YBN . read ( 28 ) ) TXT . write ( '#YSTB v%.2f\n\n' % ( ver / 100. ) ) Code = MyStr ( YBN . read ( Code_Size ) ) Args = MyStr ( YBN . read ( Arg_Size ) ) Res = MyStr ( YBN . read ( Res_Size ) ) OffList = struct . unpack ( 'I' * count , YBN . read ( OffList_Size ) ) Text = [ ] Count = 0 CodeStr = [ ] for n in range ( count ) : OP , nArg , Reserved = struct . unpack ( 'BBH' , Code . read ( 4 ) ) CodeStr . append ( 'OP%02X' % OP ) if Reserved : print 'Warning: Reserved value is used !' os . system ( 'pause' ) for n in range ( nArg ) : Arg , ArgType , ResLen , ResOff = struct . unpack ( 'HHII' , Args . read ( 12 ) ) Res . seek ( ResOff ) ResStr = [ ] if ResOff + ResLen > len ( Res ) : ResLen = len ( Res ) - ResOff IsText = 0 while Res . tell ( ) < ResOff + ResLen : Type = ord ( Res . read ( 1 ) ) if Type > 0x7f : Res . seek ( - 1 , 1 ) Count += 1 Text . append ( Res . read ( ResLen ) ) ResStr = [ '<%04d>' % Count ] else : StrLen = struct . unpack ( 'H' , Res . read ( 2 ) ) [ 0 ] #if StrLen>ResLen: pdb.set_trace() Resource = Res . read ( StrLen ) if not Type == 0x4d : Resource = '' . join ( [ '%02X' % ord ( n ) for n in Resource ] ) elif Resource [ 0 ] == Resource [ - 1 ] == '"' : for n in Resource : if ord ( n ) > 0x7f : IsText = 1 break if IsText : Count += 1 Text . append ( Resource [ 1 : - 1 ] ) Resource = '"<%04d>"' % Count IsText = 0 ResStr . append ( '%X:' % Type + Resource ) CodeStr . append ( '\t%X:%X\t%s' % ( Arg , ArgType , ', ' . join ( ResStr ) ) ) TXT . write ( '\n' . join ( CodeStr ) ) TXT . write ( '\n\n#Program\n' + ', ' . join ( [ '%d' % n for n in OffList ] ) ) if Text : open ( sys . argv [ 1 ] + '.txt' , 'w' ) . write ( '\n' . join ( Text ) ) TXT . close ( )