Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cartridges: fix help for fill value, treat fill value as byte #137

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cartridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ cartridge_set_desc(const char *name)
namelen = CART_DESCRIPTION_SIZE;
}

memset(Cartridge_info.description, 0x20202020, CART_DESCRIPTION_SIZE);
memset(Cartridge_info.description, 0x20, CART_DESCRIPTION_SIZE);
memcpy(Cartridge_info.description, name, namelen);
}

Expand All @@ -175,7 +175,7 @@ cartridge_set_author(const char *name)
namelen = CART_AUTHOR_SIZE;
}

memset(Cartridge_info.author, 0x20202020, CART_AUTHOR_SIZE);
memset(Cartridge_info.author, 0x20, CART_AUTHOR_SIZE);
memcpy(Cartridge_info.author, name, namelen);
}

Expand All @@ -191,7 +191,7 @@ cartridge_set_copyright(const char *name)
namelen = CART_COPYRIGHT_SIZE;
}

memset(Cartridge_info.copyright, 0x20202020, CART_COPYRIGHT_SIZE);
memset(Cartridge_info.copyright, 0x20, CART_COPYRIGHT_SIZE);
memcpy(Cartridge_info.copyright, name, namelen);

}
Expand All @@ -208,7 +208,7 @@ cartridge_set_program_version(const char *name)
namelen = CART_PROGRAM_VERSION_SIZE;
}

memset(Cartridge_info.prg_version, 0x20202020, CART_PROGRAM_VERSION_SIZE);
memset(Cartridge_info.prg_version, 0x20, CART_PROGRAM_VERSION_SIZE);
memcpy(Cartridge_info.prg_version, name, namelen);
}

Expand Down Expand Up @@ -330,7 +330,7 @@ cartridge_define_bank_range(uint8_t start_bank, uint8_t end_bank, uint8_t bank_t
}

bool
cartridge_import_files(char **bin_files, int num_files, uint8_t start_bank, uint8_t bank_type, uint32_t fill_value)
cartridge_import_files(char **bin_files, int num_files, uint8_t start_bank, uint8_t bank_type, uint8_t fill_value)
{
if(start_bank < 32) {
return false;
Expand Down Expand Up @@ -376,7 +376,7 @@ cartridge_import_files(char **bin_files, int num_files, uint8_t start_bank, uint
}

bool
cartridge_fill(uint8_t start_bank, uint8_t end_bank, uint8_t bank_type, uint32_t fill_value)
cartridge_fill(uint8_t start_bank, uint8_t end_bank, uint8_t bank_type, uint8_t fill_value)
{
if(start_bank < 32) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/cartridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void cartridge_get_copyright(char *buffer, size_t buffer_size);
void cartridge_get_program_version(char *buffer, size_t buffer_size);

bool cartridge_define_bank_range(uint8_t start_bank, uint8_t end_bank, uint8_t bank_type);
bool cartridge_import_files(char **bin_files, int num_files, uint8_t start_bank, uint8_t bank_type, uint32_t fill_value);
bool cartridge_fill(uint8_t start_bank, uint8_t end_bank, uint8_t bank_type, uint32_t fill_value);
bool cartridge_import_files(char **bin_files, int num_files, uint8_t start_bank, uint8_t bank_type, uint8_t fill_value);
bool cartridge_fill(uint8_t start_bank, uint8_t end_bank, uint8_t bank_type, uint8_t fill_value);

bool cartridge_save(const char *cartridge_file);
bool cartridge_save_nvram();
Expand Down
14 changes: 3 additions & 11 deletions src/makecart.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

extern uint8_t *CART;

uint32_t fill_value = 0;
uint8_t fill_value = 0;

static void parse_cmdline(int argc, char **argv);

Expand Down Expand Up @@ -94,9 +94,8 @@ usage()
printf("\n");
printf("-fill <value>\n");
printf("\tSet the fill value to use with any partially-filled banks of cartridge\n");
printf("\tmemory. Value can be defined in decimal, or in hexadecimal with a '$' or\n");
printf("\t'0x' prefix. 8-bit values will be repeated every byte, 16-bit values every two\n");
printf("\tbytes, and 32-bit values every 4 bytes.\n");
printf("\tmemory. Value can be defined in decimal, in hexadecimal with a '$' or\n");
printf("\t'0x' prefix, in octal with a leading 0, or in binary with a leading 0b or %%.\n");
printf("\n");
printf("-rom_file <start_bank> [<filenames.bin>...]\n");
printf("\tDefine rom banks from the specified list of files. File data is tightly\n");
Expand Down Expand Up @@ -428,13 +427,6 @@ parse_cmdline(int argc, char **argv)
++argv;
--argc;

if((fill_value & 0xffffff00) == 0) {
fill_value |= (fill_value << 8);
}
if((fill_value & 0xffff0000) == 0) {
fill_value |= (fill_value << 16);
}

} else if(!strcmp(argv[0], "-rom_file")) {
++argv;
--argc;
Expand Down