-static const char *_z80_linkCmd[] =
-{
- "link-z80",
- "-n", // Don't echo output
- "-c", // Command line input
- "--", // Again, command line input...
- "-b_CODE=0x200", // Code starts at 0x200
- "-b_DATA=0x8000", // RAM starts at 0x8000
- "-j", // Output a symbol file as well
- "-k" SDCC_LIB_DIR "/z80", // Library path
- "-lz80.lib", // Library to use
- "-i", // Output Intel IHX
- "$1.ihx", // Output to
- SDCC_LIB_DIR "/z80/crt0.o", // Link in crt0 first
- "$1.o", // Actual code
- NULL
-};
-
-static const char *_gbz80_asmCmd[] =
-{
- "as-gbz80",
- "-plosgff",
- "$1.o",
- "$1.asm",
- NULL
-};
-
-static const char *_gbz80_linkCmd[] =
-{
- "link-gbz80",
- "-n", // Don't echo output
- "-c", // Command line input
- "--", // Again, command line input...
- "-b_CODE=0x200", // Code starts at 0x200
- "-b_DATA=0xC000", // RAM starts at 0xC000
- "-j", // Output a symbol file as well
- "-k" SDCC_LIB_DIR "/gbz80", // Library path
- "-lgbz80.lib", // Library to use
- "-z", // Output Gameboy image
- "$1.gb", // Output to
- SDCC_LIB_DIR "/gbz80/crt0.o",// Link in crt0 first
- "$1.o", // Actual code
- NULL
-};
-
-/* sprintf that appends to the string. */
-static void
-_saprintf(char *pinto, const char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
-
- vsprintf(pinto + strlen(pinto), format, ap);
- va_end(ap);
-}
-
-static void
-_link(const char *portName, const char *portExt, const char *portOutputType)
-{
- int i;
- // PENDING
- char buffer[2048];
-
- sprintf(buffer,
- "link-%s "
- "-n " // Don't echo output
- "-c " // Command line input
- "-- " // Again, command line input...
- "-b_CODE=0x%04X " // Code starts at 0x200
- "-b_DATA=0x%04X " // RAM starts at 0x8000
- "-m " // Map file
- "-j ", // Output a symbol file as well
- portName,
- options.code_loc,
- options.data_loc
- );
-
- // Add the standard lib in.
- if (options.nostdlib == FALSE) {
- _saprintf(buffer,
- "-k" SDCC_LIB_DIR "/%s " // Library path
- "-l%s.lib ", // Library to use
- portName, portName
- );
- }
-
- // Add in the library paths and libraries
- for (i = 0; i < nlibFiles; i++) {
- _saprintf(buffer, "-k%s ", libFiles[i]);
- }
- for (i = 0; i < nlibPaths; i++) {
- _saprintf(buffer, "-l%s ", libPaths[i]);
- }
-
- _saprintf(buffer,
- "-%s " // Output type
- "%s.%s ", // Output to
- portOutputType, srcFileName, portExt
- );
-
- if (options.nostdlib == FALSE) {
- _saprintf(buffer,
- SDCC_LIB_DIR "/%s/crt0.o ", // Link in crt0 first
- portName
- );
- }
-
- _saprintf(buffer,
- "%s.o ", // Actual code
- srcFileName
- );
-
- // Append all the other targets
- for (i = 0; i < nrelFiles; i++) {
- _saprintf(buffer, "%s ", relFiles[i]);
- }
-
- // Do it.
- if (my_system (buffer)) {
- exit(1);
- }
-}
-
-static void
-_z80_link(void)
-{
- _link("z80", "ihx", "i");
-}
-
-static void
-_gbz80_link(void)
-{
- _link("gbz80", "gb", "z");
-}