Advertisement
Arcorann

Concealed the Conclusion TTH_*.dat viewer

Feb 17th, 2012
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. #TouhouDanmakufu
  2. #Title[TTHTest]
  3. #Text[Testing for reading CtC TTH files]
  4. #Player[FREE]
  5. #ScriptVersion[2]
  6.  
  7. script_enemy_main {
  8.  
  9. #include_function ".\DATA\TT.dnh" //For InitializePreLoadTTH, plus constants
  10. #include_function ".\Font.dnh" //For __CreateTexTextCache, AddTexTextHandle, AddTexTextHandleList, plus some constants
  11.  
  12. let ImgBoss = "script\img\ExRumia.png"; //default Rumia graphic
  13. let CSD = GetCurrentScriptDirectory;
  14. let prefix = CSD ~ "DATA\TTH_";
  15. let suffix = [ "MENU", "ED", "SPELL", "KOUMA", "EIYA", "KAEI", "LOTUS", "EXPH"];
  16. let filelist = [];
  17. ascent(i in 0..length(suffix)){
  18. filelist = filelist ~ [(prefix ~ suffix[i] ~ ".DAT")];
  19. }
  20. let category = "TEX_TEXT_CACHE";
  21. let filenum = 0;
  22. let item = 0;
  23. let item_str = "0";
  24. let length_str = "0";
  25. let itema = [];
  26. let itemaa = [];
  27. let itemaastr = [];
  28.  
  29. let frame = 0;
  30.  
  31. let DIR_CL_IMAGE_FONT = CSD ~ "IMAGE\FONT\";
  32. let IMAGE_CL_FONT_ASCII = DIR_CL_IMAGE_FONT ~ "Font.png";
  33. let IMAGE_CL_FONT_SJIS16 = [
  34. DIR_CL_IMAGE_FONT ~ "Sjis16_1.png",
  35. DIR_CL_IMAGE_FONT ~ "Sjis16_2.png",
  36. DIR_CL_IMAGE_FONT ~ "Sjis16_3.png"];
  37.  
  38. @Initialize {
  39. CreateDebugWindow;
  40. CreateCommonDataArea(CL_CDNS_MESSAGE);
  41. FontInitialize( IMAGE_CL_FONT_ASCII, IMAGE_CL_FONT_SJIS16);
  42. LoadTTC(filenum);
  43. SetLife(50000);
  44. //SetTimer(50);
  45. SetScore(1000000);
  46. AddGraze(100);
  47. SetMovePosition02(GetCenterX, GetCenterY - 100, 120);
  48.  
  49. LoadGraphic(ImgBoss); // this loads the boss's graphic
  50. SetTexture(ImgBoss);
  51. SetGraphicRect(0, 0, 64, 64); // this sets the dimensions of the boss's graphic
  52.  
  53. LoadGraphic(m_szCLFontImageAscii);
  54. ascent(let i in 0..3){LoadGraphic(m_aszCLFontImageSjis16[i]);}
  55.  
  56. SetRateScoreSystemEnable(false);
  57. RefreshStrings();
  58. }
  59.  
  60. @MainLoop {
  61. SetCollisionA(GetX, GetY, 32);
  62. SetCollisionB(GetX, GetY, 0);
  63. if(frame>0){
  64. if(GetKeyState(VK_USER)==KEY_PUSH){
  65. filenum = (filenum + 1) % 8;
  66. LoadTTC(filenum);
  67. item %= length(m_aCLTTCBeUsed);
  68. RefreshStrings();
  69. }
  70. if(GetKeyState(VK_RIGHT)==KEY_HOLD){
  71. item++;
  72. if(item==length( m_aCLTTCBeUsed )){item = 0;}
  73. RefreshStrings();
  74. frame = [0,-20][GetKeyState(VK_SLOWMOVE)==KEY_HOLD];
  75. break;
  76. }
  77. if(GetKeyState(VK_LEFT)==KEY_HOLD){
  78. item--;
  79. if(item<0){item += length( m_aCLTTCBeUsed );}
  80. RefreshStrings();
  81. frame = [0,-20][GetKeyState(VK_SLOWMOVE)==KEY_HOLD];
  82. break;
  83. }
  84. }
  85. frame++;
  86. }
  87.  
  88. @DrawLoop {
  89. DrawText(filelist[filenum],48,48,16,255);
  90. DrawText(item_str,48,80,16,255);
  91. DrawText(length_str,148,80,16,255);
  92. ascent(i in 0..7){DrawText(itemaastr[i],40+32*i,112,16,255);}
  93. DrawText(length_str,148,80,16,255);
  94. //DrawGraphic(GetX, GetY); // this draws the boss's graphic
  95. DrawTexTextOnCache( item, 0, 0, [42, 64][itemaa[4]>32] , GetCenterY() - 16);
  96. }
  97.  
  98. @Finalize {
  99. DeleteGraphic(ImgBoss); // unloads the boss's graphic
  100. DeleteGraphic(m_szCLFontImageAscii);
  101. ascent(let i in 0..3){DeleteGraphic(m_aszCLFontImageSjis16[i]);}
  102. }
  103.  
  104. function RefreshStrings(){
  105. item_str = ToIntString(item);
  106. length_str = ToIntString(length(m_aCLTTCBeUsed));
  107. itema = m_aCLTTCValue[item];
  108. itemaa = [];
  109. itemaastr = [];
  110. ascent(let i in 0..7){ itemaa = itemaa ~ [ itema[i][0] ];}
  111. ascent(let i in 0..7){ itemaastr = itemaastr ~ [ToIntString(itemaa[i])];}
  112. }
  113.  
  114. function ToIntString(let n1){
  115. let n1_str = ToString(n1);
  116. loop(7){n1_str = erase(n1_str, length(n1_str)-1);}
  117. return n1_str;
  118. }
  119.  
  120. // Copied from IO.dnh - CL_CDNS_MESSAGE and CL_CD_TTC are defined in TT.dnh
  121. function LoadTTC( let nCDID ){
  122. InitializePreLoadTTH( nCDID );
  123. LoadCommonDataEx( CL_CDNS_MESSAGE, filelist[nCDID] );
  124. ClearTexTextHandle();
  125. AddTexTextHandleList( GetCommonDataDefaultEx( CL_CDNS_MESSAGE, CL_CD_TTC, [] ) );
  126. DeleteCommonDataEx( CL_CDNS_MESSAGE, CL_CD_TTC );
  127. }
  128.  
  129. // given TTC, return string - this is key to reading, but doability is questionable
  130. function DecodeTexTextCache( let aszImageID, let anSrcX, let anSrcY ){
  131. let szText = "";
  132. let i = 0;
  133. while(i < length( aszImageID)){
  134. let nGap = 0;
  135. alternative( anSrcX[ i ] )
  136. case( CL_FONT_CODE_SPACE ){
  137. szText = szText ~ " ";
  138. }
  139. case( CL_FONT_CODE_CRLF ){
  140. szText = szText ~ "\n";
  141. }
  142. others {
  143. if( aszImageID[ i ] == -1 ){ // ASCII
  144. // compute ASCII value
  145. }
  146. else { // SJIS
  147. // compute SJIS value
  148. }
  149. }
  150. }
  151. // return szText;
  152. }
  153.  
  154. function Max(let n1, let n2){return [n1, n2][n2 > n1];}
  155. function Min(let n1, let n2){return [n1, n2][n2 < n1];}
  156. function MinMax(let n, let min, let max){ return Min(Max(n, min), max) }
  157. function Animation(let n1, let n2, let n3, let n4, let a5) { return (n1+n2)/2; } // dummy function, only used in DrawTexTextOnCacheEx
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement