IMGTOOL: Added Dragon DOS module [tlindner]

This commit is contained in:
tim lindner 2020-05-17 09:04:31 -07:00 committed by GitHub
parent f4a7525acd
commit eb2db91c65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1279 additions and 18 deletions

View File

@ -686,6 +686,7 @@ files {
MAME_DIR .. "src/tools/imgtool/modules/amiga.cpp",
MAME_DIR .. "src/tools/imgtool/modules/macbin.cpp",
MAME_DIR .. "src/tools/imgtool/modules/rsdos.cpp",
MAME_DIR .. "src/tools/imgtool/modules/dgndos.cpp",
MAME_DIR .. "src/tools/imgtool/modules/os9.cpp",
MAME_DIR .. "src/tools/imgtool/modules/mac.cpp",
MAME_DIR .. "src/tools/imgtool/modules/ti99.cpp",

View File

@ -51,7 +51,9 @@ struct basictoken_tableent
struct basictokens
{
uint16_t baseaddress;
uint8_t size_pos;
unsigned int skip_bytes : 15;
unsigned char bytes[20];
unsigned int be : 1;
const basictoken_tableent *entries;
int num_entries;
@ -181,7 +183,7 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
int i, j, pos, in_quotes;
uint16_t line_number;
uint8_t line_header[4];
uint8_t file_header[3];
uint8_t file_size[2];
const basictoken_tableent *token_table;
const char *token;
uint8_t token_shift, token_value;
@ -192,9 +194,8 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
if (!mem_stream)
return IMGTOOLERR_OUTOFMEMORY;
/* skip first few bytes */
mem_stream->fill(0x00, tokens->skip_bytes);
/* write header */
mem_stream->write(tokens->bytes, tokens->skip_bytes);
/* loop until the file is complete */
while(!eof)
{
@ -320,22 +321,20 @@ static imgtoolerr_t basic_writefile(const basictokens *tokens,
mem_stream->fill(0x00, 2);
/* reset stream */
mem_stream->seek(0, SEEK_SET);
mem_stream->seek(tokens->size_pos, SEEK_SET);
/* this is somewhat gross */
if (tokens->skip_bytes >= 3)
{
if (tokens->be)
{
place_integer_be(file_header, 0, 1, 0xFF);
place_integer_be(file_header, 1, 2, mem_stream->size());
place_integer_be(file_size, 0, 2, mem_stream->size());
}
else
{
place_integer_le(file_header, 0, 1, 0xFF);
place_integer_le(file_header, 1, 2, mem_stream->size());
place_integer_le(file_size, 0, 2, mem_stream->size());
}
mem_stream->write(file_header, 3);
mem_stream->write(file_size, 2);
mem_stream->seek(0, SEEK_SET);
}
@ -2942,7 +2941,9 @@ static const basictoken_tableent cocobas_tokenents[] =
static const basictokens cocobas_tokens =
{
0x2600,
1,
3,
{0xFF, 0x00, 0x00},
true,
cocobas_tokenents,
ARRAY_LENGTH(cocobas_tokenents)
@ -2985,8 +2986,10 @@ static const basictoken_tableent dragonbas_tokenents[] =
static const basictokens dragonbas_tokens =
{
0x2600,
0x2415,
4,
9,
{0x55, 0x01, 0x24, 0x01, 0x00, 0x2A, 0x8B, 0x8D, 0xAA},
true,
dragonbas_tokenents,
ARRAY_LENGTH(dragonbas_tokenents)
@ -3032,6 +3035,8 @@ static const basictokens vzbas_tokens =
{
0x7ae9,
0,
0,
{0x00},
false,
vzbas_tokenents,
ARRAY_LENGTH(vzbas_tokenents)
@ -3075,7 +3080,9 @@ static const basictoken_tableent bml3bas_tokenents[] =
static const basictokens bml3bas_tokens =
{
0x2600,
1,
3,
{0xFF, 0x00, 0x00},
true,
bml3bas_tokenents,
ARRAY_LENGTH(bml3bas_tokenents)

View File

@ -83,10 +83,11 @@ char *strncpyz(char *dest, const char *source, size_t len)
// extract_padded_string
//-------------------------------------------------
static std::string extract_padded_string(const char *source, size_t len)
static std::string extract_padded_string(const char *source, size_t len, char pad)
{
while ((len > 0) && (source[len - 1] == ' '))
while ((len > 0) && (source[len - 1] == pad))
len--;
return std::string(source, len);
}
@ -97,10 +98,10 @@ static std::string extract_padded_string(const char *source, size_t len)
// this in common code
//-------------------------------------------------
std::string extract_padded_filename(const char *source, size_t filename_length, size_t extension_length)
std::string extract_padded_filename(const char *source, size_t filename_length, size_t extension_length, char pad)
{
std::string filename = extract_padded_string(source, filename_length);
std::string extension = extract_padded_string(source + filename_length, extension_length);
std::string filename = extract_padded_string(source, filename_length, pad);
std::string extension = extract_padded_string(source + filename_length, extension_length, pad);
return extension.empty() ? filename : filename + "." + extension;
}

View File

@ -264,6 +264,6 @@ void unknown_partition_get_info(const imgtool_class *imgclass, uint32_t state, u
char *strncpyz(char *dest, const char *source, size_t len);
void rtrim(char *buf);
std::string extract_padded_filename(const char *source, size_t filename_length, size_t extension_length);
std::string extract_padded_filename(const char *source, size_t filename_length, size_t extension_length, char pad = ' ');
#endif /* IMGTOOL_H */

View File

@ -81,6 +81,7 @@ MODULE(mac_mfs)
MODULE(mac_hfs)
MODULE(hd)
MODULE(rsdos)
MODULE(dgndos)
MODULE(vzdos)
MODULE(os9)
MODULE(ti99_old)

File diff suppressed because it is too large Load Diff

View File

@ -320,7 +320,7 @@ eof:
}
else
{
/* Not the end of file */
/* Note the end of file */
err = process_rsdos_file(&rsent, image, nullptr, filesize);
if (err)
return err;