]> git.sur5r.net Git - cc65/blobdiff - src/co65/o65.h
Normalized code.
[cc65] / src / co65 / o65.h
index 4cb395fa66a66087f075882bb7b9e47abc75098f..d2361d34803b3a9cb6214e0b25cb65e73fcbb8d9 100644 (file)
@@ -1,6 +1,6 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                  o65.h                                   */
+/*                                   o65.h                                   */
 /*                                                                           */
 /*               Definitions and code for the o65 file format                */
 /*                                                                           */
 
 
 /* Define a structure for the o65 file header */
-typedef struct {
+typedef struct O65Header O65Header;
+struct O65Header {
     char            marker[2];  /* Non-C64 marker */
     char            magic[3];   /* o65 magic */
-    char            version;   /* Version number */
+    char            version;    /* Version number */
     unsigned        mode;       /* Mode word */
     unsigned long   tbase;      /* Original text (code) segment address */
     unsigned long   tlen;       /* Size of text (code) segment */
@@ -74,38 +75,43 @@ typedef struct {
     unsigned long   zbase;      /* Original zp segment address */
     unsigned long   zlen;       /* Size of zp segment */
     unsigned long   stack;      /* Stacksize needed */
-} O65Header;
+};
 
 /* o65 option */
-typedef struct {
+typedef struct O65Option O65Option;
+struct O65Option {
     unsigned char   Len;        /* Option length */
     unsigned char   Type;       /* Option type */
     unsigned char   Data[1];    /* Option data (dynamically allocated) */
-} O65Option;
+};
 
 /* o65 relocation entry */
-typedef struct {
+typedef struct O65Reloc O65Reloc;
+struct O65Reloc {
     unsigned long   Offs;       /* Offset in segment */
     unsigned char   Type;       /* Relocation type */
     unsigned char   SegID;      /* Segment ID */
     unsigned        Val;        /* Any offset value needed for relocation */
     unsigned long   SymIdx;     /* Index into list of imported symbols */
-} O65Reloc;
+};
 
 /* o65 import */
-typedef struct {
+typedef struct O65Import O65Import;
+struct O65Import {
     char            Name[1];    /* Name of the import (dynamically allocated) */
-} O65Import;
+};
 
 /* o65 export */
-typedef struct {
+typedef struct O65Export O65Export;
+struct O65Export {
     unsigned char   SegID;      /* Segment ID */
     unsigned long   Val;        /* Relocation value */
     char            Name[1];    /* Name of the export (dynamically allocated) */
-} O65Export;
+};
 
 /* Complete o65 file data */
-typedef struct {
+typedef struct O65Data O65Data;
+struct O65Data {
     O65Header       Header;     /* File header */
     Collection      Options;    /* O65 options */
     unsigned char*  Text;       /* Text segment data (unrelocated) */
@@ -114,7 +120,7 @@ typedef struct {
     Collection      DataReloc;  /* Relocation entries for the data segment */
     Collection      Imports;    /* Imported symbols */
     Collection      Exports;    /* Exported symbols */
-} O65Data;
+};
 
 
 
@@ -127,7 +133,7 @@ typedef struct {
 #define O65_VERSION             0x00
 
 /* Defines for the mode word */
-#define O65_CPU_65816           0x8000         /* Executable is for 65816 */
+#define O65_CPU_65816           0x8000  /* Executable is for 65816 */
 #define O65_CPU_6502            0x0000  /* Executable is for the 6502 */
 #define O65_CPU_MASK            0x8000  /* Mask to extract CPU type */
 
@@ -135,7 +141,7 @@ typedef struct {
 #define O65_RELOC_BYTE          0x0000  /* Byte wise relocation */
 #define O65_RELOC_MASK          0x4000  /* Mask to extract relocation type */
 
-#define O65_SIZE_32BIT          0x2000         /* All size words are 32bit */
+#define O65_SIZE_32BIT          0x2000  /* All size words are 32bit */
 #define O65_SIZE_16BIT          0x0000  /* All size words are 16bit */
 #define O65_SIZE_MASK           0x2000  /* Mask to extract size */
 
@@ -162,9 +168,9 @@ typedef struct {
                                  O65_ALIGN_1)
 
 /* The four o65 segment types. */
-#define O65_SEGID_UNDEF                0x00
+#define O65_SEGID_UNDEF         0x00
 #define O65_SEGID_ABS           0x01
-#define O65_SEGID_TEXT                 0x02
+#define O65_SEGID_TEXT          0x02
 #define O65_SEGID_DATA          0x03
 #define O65_SEGID_BSS           0x04
 #define O65_SEGID_ZP            0x05
@@ -189,20 +195,20 @@ typedef struct {
 
 /* Option tags */
 #define O65_OPT_FILENAME        0
-#define O65_OPT_OS                     1
-#define O65_OPT_ASM            2
-#define O65_OPT_AUTHOR         3
-#define O65_OPT_TIMESTAMP      4
+#define O65_OPT_OS              1
+#define O65_OPT_ASM             2
+#define O65_OPT_AUTHOR          3
+#define O65_OPT_TIMESTAMP       4
 
 /* Operating system codes for O65_OPT_OS */
-#define O65_OS_OSA65           1
-#define O65_OS_LUNIX           2
+#define O65_OS_OSA65            1
+#define O65_OS_LUNIX            2
 #define O65_OS_CC65_MODULE      3
 
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -212,11 +218,17 @@ O65Data* ReadO65File (const char* Name);
  * created O65Data struct.
  */
 
+const char* GetO65OSName (unsigned char OS);
+/* Return the name of the operating system given by OS */
 
-
-/* End of o65.h */
-#endif
+const char* GetO65OptionText (const O65Option* O);
+/* Return the data of the given option as a readable text. The function returns
+ * a pointer to a static buffer that is reused on the next call, so if in doubt,
+ * make a copy (and no, the function is not thread safe).
+ */
 
 
 
+/* End of o65.h */
 
+#endif