cscg22-gearboy

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

obj_data.h (2621B)


      1// This is free and unencumbered software released into the public domain.
      2// For more information, please refer to <https://unlicense.org>
      3// bbbbbr 2020
      4
      5#ifndef _AREAS_H
      6#define _AREAS_H
      7
      8#include "list.h"
      9
     10#define OBJ_NAME_MAX_STR_LEN 255
     11#define AREA_LINE_RECORDS      2 // Bank number, Size
     12#define SYMBOL_LINE_RECORDS    2 // Name, DefVal
     13#define SYMBOL_REWRITE_RECORDS 2 // Name, DefVal
     14
     15#define PLATFORM_GB                 0
     16#define PLATFORM_SMS                1
     17#define PLATFORM_DEFAULT            PLATFORM_GB
     18
     19#define PLATFORM_STR_GB             "gb"
     20#define PLATFORM_STR_AP             "ap"     // Uses PLATFORM_GB
     21#define PLATFORM_STR_DUCK           "duck"   // Uses PLATFORM_GB
     22#define PLATFORM_STR_SMS            "sms"
     23#define PLATFORM_STR_GG             "gg"     // Uses PLATFORM_SMS
     24#define PLATFORM_STR_MSXDOS         "msxdos" // Uses PLATFORM_SMS
     25
     26#define BANK_TYPE_UNSET             0
     27#define BANK_TYPE_DEFAULT           1
     28#define BANK_TYPE_LIT_EXCLUSIVE     2
     29
     30
     31typedef struct bank_item {
     32    uint32_t size;
     33    uint32_t free;
     34    uint32_t type;
     35    uint16_t item_count;
     36} bank_item;
     37
     38
     39typedef struct area_item {
     40    uint32_t file_id;
     41    char     name[OBJ_NAME_MAX_STR_LEN];
     42    uint32_t size;         // uint32_t to avoid mingw sscanf() buffer overflow
     43    uint32_t bank_num_in;  // uint32_t to avoid mingw sscanf() buffer overflow
     44    uint32_t bank_num_out; // uint32_t to avoid mingw sscanf() buffer overflow
     45    uint32_t type;
     46} area_item;
     47
     48typedef struct symbol_item {
     49    uint32_t file_id;
     50    char     name[OBJ_NAME_MAX_STR_LEN];
     51    bool     is_banked_def;
     52    uint32_t bank_num_in;   // uint32_t to avoid mingw sscanf() buffer overflow
     53    bool     found_matching_symbol;
     54} symbol_item;
     55
     56typedef struct symbol_match_item {
     57    char     name[OBJ_NAME_MAX_STR_LEN];
     58} symbol_match_item;
     59
     60void banks_set_platform(char * platform_str);
     61int banks_get_platform(void);
     62int banks_get_mbc_type(void);
     63void banks_set_mbc(int);
     64void banks_set_mbc_by_rom_byte_149(int);
     65
     66uint32_t banks_calc_cart_size(void);
     67
     68bool banks_set_min(uint16_t bank_num);
     69bool banks_set_max(uint16_t bank_num);
     70
     71void banks_set_random(bool is_random);
     72
     73void obj_data_init(void);
     74void obj_data_cleanup(void);
     75
     76int areas_add(char * area_str, uint32_t file_id);
     77int symbols_add(char * area_str, uint32_t file_id);
     78void symbol_match_add(char *);
     79
     80void obj_data_process(list_type *);
     81
     82bool area_modify_and_write_to_file(char * strline_in, FILE * out_file, uint16_t bank_num);
     83bool symbol_modify_and_write_to_file(char * strline_in, FILE * out_file, uint16_t bank_num, uint32_t file_id);
     84
     85void banks_show(void);
     86
     87
     88#endif // _AREAS_H