tpr.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. ktigcc - TIGCC IDE for KDE
  3. tpr handling routines adapted from tprbuilder
  4. Copyright (C) 2002 Romain Liévin
  5. Copyright (C) 2002-2006 Kevin Kofler
  6. Copyright (C) 2006 Joey Adams
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software Foundation,
  17. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. */
  19. /*Structure definitions from tprbuilder source; slightly modified
  20. to work under C++
  21. */
  22. typedef unsigned char Boolean;
  23. /* global enumerations */
  24. enum SectionType_ { SECTION_NONE, SECTION_SETTINGS, SECTION_LIBOPTS,
  25. SECTION_FILEEDIT, SECTION_FILES };
  26. typedef enum SectionType_ SectionType;
  27. /* definitions */
  28. typedef struct tprsettings tprSettings;
  29. struct tprsettings
  30. {
  31. tprsettings() : archive(0),pack(0),debug_info(0),std_lib(1),
  32. use_data_var(0),copy_data_var(1),copy_data_var_arc(1),
  33. optimize_nops(1),optimize_returns(1),optimize_branches(1),
  34. optimize_moves(1),optimize_tests(1),optimize_calcs(1),
  35. remove_unused(1),outputbin(0),fargo(0),flash_os(0),
  36. cut_ranges(1),reorder_sections(1),merge_constants(1),
  37. initialize_bss(1),
  38. cc_switches("-Os -Wall -W -Wwrite-strings -ffunction-sections -fdata-sections"),
  39. as_switches(""),
  40. a68k_switches("-g -t")
  41. {}
  42. Boolean archive; // we want to build an archive
  43. Boolean pack; // we want to pack the executable
  44. Boolean debug_info; // pass -g option to tigcc
  45. Boolean std_lib; // link against tigcc.a
  46. Boolean use_data_var;
  47. Boolean copy_data_var;
  48. Boolean copy_data_var_arc;
  49. Boolean optimize_nops;
  50. Boolean optimize_returns;
  51. Boolean optimize_branches;
  52. Boolean optimize_moves;
  53. Boolean optimize_tests;
  54. Boolean optimize_calcs;
  55. Boolean remove_unused;
  56. Boolean outputbin;
  57. Boolean fargo;
  58. Boolean flash_os;
  59. Boolean cut_ranges;
  60. Boolean reorder_sections;
  61. Boolean merge_constants;
  62. Boolean initialize_bss;
  63. QString pack_name;
  64. QString cc_switches;
  65. QString as_switches;
  66. QString a68k_switches;
  67. QString cmd_line;
  68. QString post_build;
  69. QString data_var;
  70. };
  71. enum tprreloctypes {
  72. RT_NONE, // None (BSS, data var)
  73. RT_DIRECT, // Direct (ROM_CALLs)
  74. RT_AMS, // AMS (relocs)
  75. RT_PRECOMP, // ROM_CALLs only: Precomputed (Optimized)
  76. RT_KERNEL, // Kernel
  77. RT_COMPRESSED, // Compressed
  78. RT_MLINK, // MLink
  79. RT_FLINE // ROM_CALLs only: F-Line
  80. };
  81. typedef enum tprreloctypes tprRelocType;
  82. typedef struct tprlibopts tprLibOpts;
  83. struct tprlibopts
  84. {
  85. tprlibopts() : use_ti89(1),use_ti92p(1),use_v200(1),opt_calc_consts(0),
  86. use_kernel(0),use_preos(0),use_minams(1),
  87. unofficial_os(0),use_fline_jumps(0),use_4b_fline_jumps(0),
  88. use_internal_fline_emu(0),use_return_value(0),
  89. enable_error_return(0),save_screen(1),opt_rom_calls(0),
  90. minams(100),reloc_format(RT_AMS),rom_call_format(RT_DIRECT),
  91. bss_ref_format(RT_KERNEL),data_ref_format(RT_KERNEL)
  92. {}
  93. Boolean use_ti89;
  94. Boolean use_ti92p;
  95. Boolean use_v200;
  96. Boolean opt_calc_consts;
  97. Boolean use_kernel;
  98. Boolean use_preos;
  99. Boolean use_minams;
  100. Boolean unofficial_os;
  101. Boolean use_fline_jumps;
  102. Boolean use_4b_fline_jumps;
  103. Boolean use_internal_fline_emu;
  104. Boolean use_return_value;
  105. Boolean enable_error_return;
  106. Boolean save_screen;
  107. Boolean opt_rom_calls;
  108. int minams;
  109. tprRelocType reloc_format;
  110. tprRelocType rom_call_format;
  111. tprRelocType bss_ref_format;
  112. tprRelocType data_ref_format;
  113. };
  114. typedef struct
  115. {
  116. QStringList path;
  117. QStringList folder;
  118. } TPRFileList;
  119. typedef struct
  120. {
  121. QString prj_name;
  122. QString open_file;
  123. tprSettings settings;
  124. tprLibOpts libopts;
  125. TPRFileList h_files;
  126. TPRFileList c_files;
  127. TPRFileList s_files;
  128. TPRFileList asm_files;
  129. TPRFileList o_files;
  130. TPRFileList a_files;
  131. TPRFileList txt_files;
  132. TPRFileList oth_files;
  133. TPRFileList quill_files;
  134. } TPRDataStruct;
  135. enum {PATH_ERROR,PATH_FILE,PATH_FOLDER}; //return types for getPathType
  136. const char *smartAscii(const QString &s);
  137. void newSettings(tprSettings *settings,tprLibOpts *libopts);
  138. int loadTPR(const QString &fileName,TPRDataStruct *dest);
  139. QString loadFileText(const char *fileName);
  140. int saveTPR(const QString &fileName,TPRDataStruct *src);
  141. int saveFileText(const char *fileName,const QString &fileText);
  142. void kurlNewFileName(KURL &dir,const QString &newFileName);
  143. int checkFileName(const QString &fileName,const QStringList &fileNameList);
  144. int copyFile(const char *src, const char *dest);
  145. int getPathType(const QString &thePath);