cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

targets.c (5532B)


      1// targets.c
      2
      3#include "gb.h"
      4#include "targets.h"
      5
      6// Default Linker list arguments
      7//
      8// These get processed in Fixllist()
      9//
     10// NOTE: Only -g and -b entries are supported by Fixllist() right now
     11
     12// Game Boy / Analogue Pocket / Megaduck
     13arg_entry llist0_defaults_gb[] = {
     14    {.searchkey= "_shadow_OAM=", .addflag= "-g",.addvalue= "_shadow_OAM=0xC000", .found= false},
     15    {.searchkey= ".STACK=",      .addflag= "-g",.addvalue= ".STACK=0xE000",      .found= false},
     16    {.searchkey= ".refresh_OAM=",.addflag= "-g",.addvalue= ".refresh_OAM=0xFF80",.found= false},
     17    {.searchkey= "_DATA=",       .addflag= "-b",.addvalue= "_DATA=0xC0A0",       .found= false},
     18    {.searchkey= "_CODE=",       .addflag= "-b",.addvalue= "_CODE=0x0200",       .found= false},
     19};
     20
     21// SMS / GG
     22arg_entry llist0_defaults_sms[] = {
     23    {.searchkey= "_shadow_OAM=", .addflag= "-g",.addvalue= "_shadow_OAM=0xC000", .found= false},
     24    {.searchkey= ".STACK=",      .addflag= "-g",.addvalue= ".STACK=0xDFF0",      .found= false},
     25    {.searchkey= "_DATA=",       .addflag= "-b",.addvalue= "_DATA=0xC0C0",       .found= false},
     26    {.searchkey= "_CODE=",       .addflag= "-b",.addvalue= "_CODE=0x0100",       .found= false},
     27};
     28
     29// MSX
     30arg_entry llist0_defaults_msxdos[] = {
     31    {.searchkey= "_DATA=",       .addflag= "-b",.addvalue= "_DATA=0x8000",       .found= false},
     32    {.searchkey= "_CODE=",       .addflag= "-b",.addvalue= "_CODE=0x0100",       .found= false},
     33};
     34
     35// Port/Platform specific settings
     36//
     37// $1 are extra parameters passed using -W
     38// $2 is the list of objects passed as parameters
     39// $3 is the output file
     40CLASS classes[] = {
     41    // GB
     42    { "sm83",      // port
     43        "gb",       // plat
     44        "gb",       // default_plat
     45        EXT_GB,     // ROM file extension
     46        "%cpp% %cppdefault% -DINT_16_BITS $1 $2 $3",
     47        "%includedefault%",
     48        "%com% %comdefault% -Wa%asdefault% -DINT_16_BITS $1 %comflag% $2 -o $3",
     49        "%as_gb% %asdefault% $1 $3 $2",
     50        "%bankpack% $1 $2",
     51        "%ld_gb% -n -i $1 %libs_include% $3 %crt0dir% $2",
     52        "%ihxcheck% $2 $1",
     53        "%mkbin% -yN -Z $1 $2 $3",  // -yN: Don't paste in the Nintendo logo bytes for gameboy and clones (-Z)
     54        "",
     55        llist0_defaults_gb, ARRAY_LEN(llist0_defaults_gb),
     56    },
     57    // Analogue Pocket
     58    { "sm83",      // port
     59        "ap",       // plat
     60        "ap",       // default_plat
     61        EXT_AP,     // ROM file extension
     62        "%cpp% %cppdefault% -DINT_16_BITS $1 $2 $3",
     63        "%includedefault%",
     64        "%com% %comdefault% -Wa%asdefault% -DINT_16_BITS $1 %comflag% $2 -o $3",
     65        "%as_gb% %asdefault% $1 $3 $2",
     66        "%bankpack% $1 $2",
     67        "%ld_gb% -n -i $1 %libs_include% $3 %crt0dir% $2",
     68        "%ihxcheck% $2 $1",
     69        "%mkbin% -yN -Z $1 $2 $3",  // -yN: Don't paste in the Nintendo logo bytes for gameboy and clones (-Z)
     70        "",
     71        llist0_defaults_gb, ARRAY_LEN(llist0_defaults_gb), // Use GB linker list defaults
     72    },
     73    // Megaduck
     74    { "sm83",      // port
     75        "duck",     // plat
     76        "duck",     // default_plat
     77        EXT_DUCK,   // ROM file extension
     78        "%cpp% %cppdefault% -DINT_16_BITS $1 $2 $3",
     79        "%includedefault%",
     80        "%com% %comdefault% -Wa%asdefault% -DINT_16_BITS $1 %comflag% $2 -o $3",
     81        "%as_gb% %asdefault% $1 $3 $2",
     82        "%bankpack% $1 $2",
     83        "%ld_gb% -n -i $1 %libs_include% $3 %crt0dir% $2",
     84        "%ihxcheck% $2 $1",
     85        "%mkbin% -yN -Z $1 $2 $3",  // -yN: Don't paste in the Nintendo logo bytes for gameboy and clones (-Z)
     86        "",
     87        llist0_defaults_gb, ARRAY_LEN(llist0_defaults_gb), // Use GB linker list defaults
     88    },
     89
     90    // SMS
     91    { "z80",        // port
     92        "sms",      // plat
     93        "sms",      // default_plat
     94        EXT_SMS,    // ROM file extension
     95        "%cpp% %cppdefault% -DINT_16_BITS $1 $2 $3",
     96        "%includedefault%",
     97        "%com% %comdefault% -Wa%asdefault% -DINT_16_BITS $1 %comflag% $2 -o $3",
     98        "%as_z80% %asdefault% $1 $3 $2",
     99        "%bankpack% -plat=sms $1 $2",
    100        "%ld_z80% -a sms -n -i $1 %libs_include% $3 %crt0dir% $2",
    101        "%ihxcheck% $2 $1",
    102        "%mkbin% -S -xj 4 $1 $2 $3",
    103        "",
    104        llist0_defaults_sms, ARRAY_LEN(llist0_defaults_sms),
    105    },
    106    // GG
    107    { "z80",        // port
    108        "gg",       // plat
    109        "gg",       // default_plat
    110        EXT_GG,     // ROM file extension
    111        "%cpp% %cppdefault% -DINT_16_BITS $1 $2 $3",
    112        "%includedefault%",
    113        "%com% %comdefault% -Wa%asdefault% -DINT_16_BITS $1 %comflag% $2 -o $3",
    114        "%as_z80% %asdefault% $1 $3 $2",
    115        "%bankpack% -plat=sms $1 $2",
    116        "%ld_z80% -a sms -n -i $1 %libs_include% $3 %crt0dir% $2",
    117        "%ihxcheck% $2 $1",
    118        "%mkbin% -S $1 $2 $3",
    119        "",
    120        llist0_defaults_sms, ARRAY_LEN(llist0_defaults_sms),  // Use SMS linker list defaults
    121    },
    122
    123    // MSX
    124    { "z80",        // port
    125        "msxdos",   // plat
    126        "msxdos",   // default_plat
    127        EXT_MSXDOS, // ROM file extension
    128        "%cpp% %cppdefault% -DINT_16_BITS $1 $2 $3",
    129        "%includedefault%",
    130        "%com% %comdefault% -Wa%asdefault% -DINT_16_BITS $1 %comflag% $2 -o $3",
    131        "%as_z80% %asdefault% $1 $3 $2",
    132        "%bankpack% -plat=sms $1 $2",
    133        "%ld_z80% -a sms -n -i -j $1 %libs_include% $3 %crt0dir% $2",
    134        "%ihxcheck% $2 $1",
    135        "%mkbin% $1 $2 $3",
    136        "%mkcom% $1 $2",
    137        llist0_defaults_msxdos, ARRAY_LEN(llist0_defaults_msxdos),
    138    }
    139
    140};
    141
    142int classes_count = ARRAY_LEN(classes);
    143