- O65Data* D = ReadO65File (InFilename);
-
- /* For now, we do only accept o65 files generated by the ld65 linker which
- * have a specific format.
- */
- if (D->Header.mode != O65_MODE_CC65) {
- Error ("Cannot convert o65 files of this type");
- }
-
- printf ("Textsize: %lu\n", D->Header.tlen);
- printf ("Datasize: %lu\n", D->Header.dlen);
- printf ("Imports: %u\n", CollCount (&D->Imports));
- printf ("Exports: %u\n", CollCount (&D->Exports));
- printf ("Textrelocs: %u\n", CollCount (&D->TextReloc));
- printf ("Datarelocs: %u\n", CollCount (&D->DataReloc));
-
- /* Open the output file */
- F = fopen (OutFilename, "wb");
- if (F == 0) {
- Error ("Cannot open `%s': %s", OutFilename, strerror (errno));
- }
-
- /* Create a header */
- if ((D->Header.mode & O65_CPU_MASK) == O65_CPU_65816) {
- fprintf (F, "\t.p816\n");
- }
- fprintf (F, ";\n; File generated by co65 v %u.%u.%u\n;\n",
- VER_MAJOR, VER_MINOR, VER_PATCH);
- fprintf (F, "\t.fopt\t\tcompiler,\"co65 v %u.%u.%u\"\n",
- VER_MAJOR, VER_MINOR, VER_PATCH);
- fprintf (F, "\t.case\t\ton\n");
- fprintf (F, "\t.debuginfo\t%s\n", (DebugInfo != 0)? "on" : "off");
- fprintf (F, "\n");
-
- /* Imported identifiers */
- if (CollCount (&D->Imports) > 0) {
- for (I = 0; I < CollCount (&D->Imports); ++I) {
-
- /* Get the next import */
- O65Import* Import = CollAtUnchecked (&D->Imports, I);
-
- /* Import it by name */
- fprintf (F, "\t.import\t%s\n", Import->Name);
- }
- fprintf (F, "\n");
- }
-
- /* Exported identifiers */
- if (CollCount (&D->Exports) > 0) {
- for (I = 0; I < CollCount (&D->Exports); ++I) {
-
- /* Get the next import */
- O65Export* Export = CollAtUnchecked (&D->Exports, I);
-
- /* Import it by name */
- fprintf (F, "\t.export\t%s\n", Export->Name);
- }
- fprintf (F, "\n");
- }