ttarchive.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /******************************************************************************
  2. *
  3. * project name: TI-68k Developer Utilities
  4. * file name: ttarchive.h
  5. * initial date: 20/08/2000
  6. * author: thomas.nussbaumer@gmx.net
  7. * description: structures, definitions and macros to use ttarchive
  8. *
  9. ******************************************************************************/
  10. /*
  11. This file is part of TI-68k Developer Utilities.
  12. This file is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU Lesser General Public
  14. License as published by the Free Software Foundation; either
  15. version 2.1 of the License, or (at your option) any later version.
  16. As a special exception, UNMODIFIED copies of ttarchive may also be
  17. redistributed or sold without source code, for any purpose. (The Lesser
  18. General Public License restrictions do apply in other respects; for example,
  19. they cover modification of the program.) This exception notice must be
  20. removed on modified copies of this file.
  21. This program is distributed in the hope that it will be useful,
  22. but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  24. Lesser General Public License for more details.
  25. You should have received a copy of the GNU Lesser General Public
  26. License along with this library; if not, write to the Free Software
  27. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #ifndef __TTARCHIVE_H__
  30. #define __TTARCHIVE_H__
  31. //-----------------------------------------------------------------------------
  32. // entry of archive structure
  33. //-----------------------------------------------------------------------------
  34. typedef struct {
  35. unsigned char offset[2]; // offset to the entry data (high byte first)
  36. unsigned char length[2]; // length of entry
  37. char name[8]; // entry name
  38. unsigned char misc1[2]; // info from cfg file (may be queried by a program)
  39. unsigned char misc2[2]; // info from cfg file (may be queried by a program)
  40. } TTAEntry;
  41. //-----------------------------------------------------------------------------
  42. // smart macros to access ttarchive
  43. //
  44. // pa ... pointer to archive start address
  45. // idx ... index of entry
  46. // entry ... pointer to TTAEntry structure
  47. //
  48. // NOTE: No checking is done in the macros !!
  49. //-----------------------------------------------------------------------------
  50. #define IsTTArchive(pa) (*(pa) == 't' && *((pa)+1) == 't' && *((pa)+2) == 'a' && *((pa)+3) == 0)
  51. #define GetNrEntries(pa) ((unsigned int)(*((pa)+4) << 8) | (unsigned int)(*((pa)+5)))
  52. #define GetEntryInfo(pa,idx) (TTAEntry*)((pa) + 6 + sizeof(TTAEntry)*(unsigned int)(idx))
  53. #define GetEntryStart(pa,entry) ((pa) + 6 + (unsigned int)(sizeof(TTAEntry)*GetNrEntries(pa)) + \
  54. (((unsigned int)entry->offset[0]) << 8 | (unsigned int)entry->offset[1]))
  55. #define GetEntrySize(entry) (((unsigned int)entry->length[0]) << 8 | (unsigned int)entry->length[1])
  56. #define TTA_DESC_LENGTH 20
  57. #endif
  58. //#############################################################################
  59. //###################### NO MORE FAKES BEYOND THIS LINE #######################
  60. //#############################################################################
  61. //
  62. //=============================================================================
  63. // Revision History
  64. //=============================================================================
  65. //
  66. // Revision 1.4 2002/02/07 09:35:11 tnussb
  67. // Macro GetEntrySize added (used in ttunarchive)
  68. //
  69. // Revision 1.3 2000/11/18 16:05:08 Thomas Nussbaumer
  70. // bug in GetEntryStart macro fixed
  71. //
  72. // Revision 1.2 2000/08/23 01:05:31 Thomas Nussbaumer
  73. // TTA_DESC_LENGTH added
  74. //
  75. // Revision 1.1 2000/08/20 15:23:18 Thomas Nussbaumer
  76. // initial version
  77. //
  78. //
  79. //