-tools/imgtool/modules: Fixed remaining calss memory access warnings.

-tools/imgtool/modules/vzdos.cpp: Fixed function returning floperr_t
 value as imgtoolerr_t.

-devices: Fixed a bunch more #include guards that don't match file
 paths.
This commit is contained in:
Vas Crabb 2024-11-26 07:17:40 +11:00
parent 68565024c7
commit 858fd229b2
34 changed files with 201 additions and 190 deletions

View File

@ -9,8 +9,8 @@
*******************************************************************************/
#ifndef MAME_BUS_TI99_INTERNAL_BRAM_H
#define MAME_BUS_TI99_INTERNAL_BRAM_H
#ifndef MAME_BUS_TI99_INTERNAL_BUFFRAM_H
#define MAME_BUS_TI99_INTERNAL_BUFFRAM_H
#pragma once
@ -46,4 +46,4 @@ private:
DECLARE_DEVICE_TYPE_NS(BUFF_RAM, bus::ti99::internal, buffered_ram_device)
#endif // MAME_BUS_TI99_INTERNAL_BRAM_H
#endif // MAME_BUS_TI99_INTERNAL_BUFFRAM_H

View File

@ -11,8 +11,8 @@
*****************************************************************************/
#ifndef MAME_BUS_TI99_PED_BWG_H
#define MAME_BUS_TI99_PED_BWG_H
#ifndef MAME_BUS_TI99_PEB_BWG_H
#define MAME_BUS_TI99_PEB_BWG_H
#pragma once
@ -135,4 +135,4 @@ private:
DECLARE_DEVICE_TYPE_NS(TI99_BWG, bus::ti99::peb, snug_bwg_device)
#endif // MAME_BUS_TI99_PED_BWG_H
#endif // MAME_BUS_TI99_PEB_BWG_H

View File

@ -10,8 +10,8 @@
*****************************************************************************/
#ifndef MAME_BUS_TI99_PEB_CORCOMP_H
#define MAME_BUS_TI99_PEB_CORCOMP_H
#ifndef MAME_BUS_TI99_PEB_CC_FDC_H
#define MAME_BUS_TI99_PEB_CC_FDC_H
#pragma once
@ -246,4 +246,4 @@ DECLARE_DEVICE_TYPE_NS(CCDCC_PALU1, bus::ti99::peb, ccdcc_palu1_device)
DECLARE_DEVICE_TYPE_NS(CCFDC_PALU12, bus::ti99::peb, ccfdc_palu12_device)
DECLARE_DEVICE_TYPE_NS(CCFDC_PALU6, bus::ti99::peb, ccfdc_palu6_device)
#endif // MAME_BUS_TI99_PEB_CORCOMP_H
#endif // MAME_BUS_TI99_PEB_CC_FDC_H

View File

@ -9,8 +9,8 @@
*****************************************************************************/
#ifndef MAME_BUS_TI99_PEB_DDCC_H
#define MAME_BUS_TI99_PEB_DDCC_H
#ifndef MAME_BUS_TI99_PEB_MYARCFDC_H
#define MAME_BUS_TI99_PEB_MYARCFDC_H
#pragma once
@ -134,4 +134,4 @@ private:
DECLARE_DEVICE_TYPE_NS(TI99_DDCC1, bus::ti99::peb, myarc_fdc_device)
DECLARE_DEVICE_TYPE_NS(DDCC1_PAL, bus::ti99::peb, ddcc1_pal_device)
#endif // MAME_BUS_TI99_PEB_DDCC_H
#endif // MAME_BUS_TI99_PEB_MYARCFDC_H

View File

@ -10,8 +10,8 @@
*****************************************************************************/
#ifndef MAME_BUS_TI99_PEB_SCSI_H
#define MAME_BUS_TI99_PEB_SCSI_H
#ifndef MAME_BUS_TI99_PEB_SCSICARD_H
#define MAME_BUS_TI99_PEB_SCSICARD_H
#pragma once
@ -142,4 +142,4 @@ private:
DECLARE_DEVICE_TYPE_NS(TI99_WHTSCSI, bus::ti99::peb, whtech_scsi_card_device)
DECLARE_DEVICE_TYPE_NS(WHTSCSI_PLD, bus::ti99::peb, whtscsi_pld_device)
#endif // MAME_BUS_TI99_PEB_SCSI_H
#endif // MAME_BUS_TI99_PEB_SCSICARD_H

View File

@ -42,8 +42,8 @@
**********************************************************************/
#ifndef MAME_DEVICES_TMC600_EURO_H
#define MAME_DEVICES_TMC600_EURO_H
#ifndef MAME_BUS_TMC600_EURO_H
#define MAME_BUS_TMC600_EURO_H
#pragma once
@ -104,5 +104,4 @@ void tmc600_eurobus_cards(device_slot_interface &device);
typedef device_type_enumerator<tmc600_eurobus_slot_device> tmc600_eurobus_slot_enumerator;
#endif // MAME_DEVICES_TMC600_EURO_H
#endif // MAME_BUS_TMC600_EURO_H

View File

@ -9,8 +9,8 @@
**********************************************************************/
#ifndef MAME_BUS_CVS_CTRL_CTRL_H
#define MAME_BUS_CVS_CTRL_CTRL_H
#ifndef MAME_BUS_VCS_CTRL_CTRL_H
#define MAME_BUS_VCS_CTRL_CTRL_H
#pragma once
@ -115,4 +115,4 @@ DECLARE_DEVICE_TYPE(VCS_CONTROL_PORT, vcs_control_port_device)
void vcs_control_port_devices(device_slot_interface &device);
void a800_control_port_devices(device_slot_interface &device);
#endif // MAME_BUS_CVS_CTRL_CTRL_H
#endif // MAME_BUS_VCS_CTRL_CTRL_H

View File

@ -1,11 +1,11 @@
// license:BSD-3-Clause
// copyright-holders:Patrick Mackinlay
#ifndef MAME_BUS_VME_CARDS_H
#define MAME_BUS_VME_CARDS_H
#ifndef MAME_BUS_VME_VME_CARDS_H
#define MAME_BUS_VME_VME_CARDS_H
#pragma once
void vme_cards(device_slot_interface &device);
#endif // MAME_BUS_VME_CARDS_H
#endif // MAME_BUS_VME_VME_CARDS_H

View File

@ -6,8 +6,8 @@
***************************************************************************/
#ifndef MAME_BUS_WYSEKBD_KEYBOARD_H
#define MAME_BUS_WYSEKBD_KEYBOARD_H
#ifndef MAME_BUS_WYSEKBD_WYSEKBD_H
#define MAME_BUS_WYSEKBD_WYSEKBD_H
#pragma once
@ -91,4 +91,4 @@ inline int wyse_keyboard_port_device::data_r()
return 1;
}
#endif // MAME_BUS_WYSEKBD_KEYBOARD_H
#endif // MAME_BUS_WYSEKBD_WYSEKBD_H

View File

@ -1,8 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:David Haywood
#ifndef MAME_CPU_ARM7_LPC2103_H
#define MAME_CPU_ARM7_LPC2103_H
#ifndef MAME_CPU_ARM7_LPC210X_H
#define MAME_CPU_ARM7_LPC210X_H
#pragma once
@ -87,4 +87,4 @@ private:
// device type definition
DECLARE_DEVICE_TYPE(LPC2103, lpc210x_device)
#endif // MAME_CPU_ARM7_LPC2103_H
#endif // MAME_CPU_ARM7_LPC210X_H

View File

@ -1,8 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Steve Ellenoff, Manuel Abadia, Couriersud, David Haywood
#ifndef MAME_CPU_SFR_SFR_H
#define MAME_CPU_SFR_SFR_H
#ifndef MAME_CPU_AXC51_AXC51_H
#define MAME_CPU_AXC51_AXC51_H
#pragma once
@ -541,5 +541,4 @@ protected:
virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD;
};
#endif // MAME_CPU_SFR_SFR_H
#endif // MAME_CPU_AXC51_AXC51_H

View File

@ -1,8 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Steve Ellenoff, David Haywood
#ifndef MAME_CPU_SFR_AXC51DASM_H
#define MAME_CPU_SFR_AXC51DASM_H
#ifndef MAME_CPU_AXC51_AXC51DASM_H
#define MAME_CPU_AXC51_AXC51DASM_H
#pragma once
@ -90,5 +90,4 @@ protected:
virtual void disassemble_op_lcall(std::ostream& stream, unsigned &PC, const data_buffer& params) override;
};
#endif
#endif // MAME_CPU_AXC51_AXC51DASM_H

View File

@ -4,8 +4,8 @@
Epson S1C33209/221/222 CMOS 32-bit single chip microcomputer
*/
#ifndef MAME_CPU_C33_S2C33209_H
#define MAME_CPU_C33_S2C33209_H
#ifndef MAME_CPU_C33_S1C33209_H
#define MAME_CPU_C33_S1C33209_H
#pragma once
@ -54,4 +54,4 @@ DECLARE_DEVICE_TYPE(S1C33209, s1c33209_device)
DECLARE_DEVICE_TYPE(S1C33221, s1c33221_device)
DECLARE_DEVICE_TYPE(S1C33222, s1c33222_device)
#endif // MAME_CPU_C33_S2C33209_H
#endif // MAME_CPU_C33_S1C33209_H

View File

@ -1,8 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Patrick Mackinlay
#ifndef MAME_CPU_CLIPPER_CLIPPERDASM_H
#define MAME_CPU_CLIPPER_CLIPPERDASM_H
#ifndef MAME_CPU_CLIPPER_CLIPPERD_H
#define MAME_CPU_CLIPPER_CLIPPERD_H
#pragma once
@ -20,4 +20,4 @@ private:
std::string address (offs_t pc, const data_buffer &opcodes);
};
#endif
#endif // MAME_CPU_CLIPPER_CLIPPERD_H

View File

@ -8,8 +8,8 @@
***************************************************************************/
#ifndef MAME_DEVICES_CPU_COP400_H
#define MAME_DEVICES_CPU_COP400_H
#ifndef MAME_CPU_COP400_COP400_H
#define MAME_CPU_COP400_COP400_H
#pragma once
@ -528,4 +528,4 @@ DECLARE_DEVICE_TYPE(COP444C, cop444c_cpu_device)
DECLARE_DEVICE_TYPE(COP445C, cop445c_cpu_device)
DECLARE_DEVICE_TYPE(COP446C, cop446c_cpu_device)
#endif // MAME_DEVICES_CPU_COP400_H
#endif // MAME_CPU_COP400_COP400_H

View File

@ -8,8 +8,8 @@
***************************************************************************/
#ifndef MAME_CPU_COP410_COP410DS_H
#define MAME_CPU_COP410_COP410DS_H
#ifndef MAME_CPU_COP400_COP410DS_H
#define MAME_CPU_COP400_COP410DS_H
#pragma once
@ -23,4 +23,4 @@ public:
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
};
#endif
#endif // MAME_CPU_COP400_COP410DS_H

View File

@ -8,8 +8,8 @@
***************************************************************************/
#ifndef MAME_CPU_COP420_COP420DS_H
#define MAME_CPU_COP420_COP420DS_H
#ifndef MAME_CPU_COP400_COP420DS_H
#define MAME_CPU_COP400_COP420DS_H
#pragma once
@ -23,4 +23,4 @@ public:
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
};
#endif
#endif // MAME_CPU_COP400_COP420DS_H

View File

@ -8,8 +8,8 @@
***************************************************************************/
#ifndef MAME_CPU_COP424_COP424DS_H
#define MAME_CPU_COP424_COP424DS_H
#ifndef MAME_CPU_COP400_COP424DS_H
#define MAME_CPU_COP400_COP424DS_H
#pragma once
@ -23,4 +23,4 @@ public:
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
};
#endif
#endif // MAME_CPU_COP400_COP424DS_H

View File

@ -8,8 +8,8 @@
***************************************************************************/
#ifndef MAME_CPU_COP444_COP444DS_H
#define MAME_CPU_COP444_COP444DS_H
#ifndef MAME_CPU_COP400_COP444DS_H
#define MAME_CPU_COP400_COP444DS_H
#pragma once
@ -23,4 +23,4 @@ public:
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
};
#endif
#endif // MAME_CPU_COP400_COP444DS_H

View File

@ -1,8 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Frank Palazzolo
#ifndef MAME_CPU_CP1610_CP1610DASM_H
#define MAME_CPU_CP1610_CP1610DASM_H
#ifndef MAME_CPU_CP1610_1610DASM_H
#define MAME_CPU_CP1610_1610DASM_H
#pragma once
@ -16,4 +16,4 @@ public:
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
};
#endif
#endif // MAME_CPU_CP1610_1610DASM_H

View File

@ -8,10 +8,10 @@
***************************************************************************/
#pragma once
#ifndef MAME_CPU_DRCBEUT_H
#define MAME_CPU_DRCBEUT_H
#ifndef __DRCBEUT_H__
#define __DRCBEUT_H__
#pragma once
#include "drcuml.h"
@ -163,4 +163,4 @@ private:
};
#endif /* __DRCBEUT_H__ */
#endif // MAME_CPU_DRCBEUT_H

View File

@ -4,13 +4,15 @@
// All the macros that are fit to print. //
///////////////////////////////////////////
#ifndef __DSP56_DEF_H__
#define __DSP56_DEF_H__
#ifndef MAME_CPU_DSP56156_DSP56DEF_H
#define MAME_CPU_DSP56156_DSP56DEF_H
#pragma once
#include "dsp56156.h"
namespace DSP_56156
{
namespace DSP_56156 {
/***************************************************************************
ALU
***************************************************************************/
@ -53,4 +55,4 @@ namespace DSP_56156
} // namespace DSP_56156
#endif
#endif // MAME_CPU_DSP56156_DSP56DEF_H

View File

@ -8,8 +8,8 @@
***************************************************************************/
#ifndef MAME_CPU_DSP56156_DSP56156DSM_H
#define MAME_CPU_DSP56156_DSP56156DSM_H
#ifndef MAME_CPU_DSP56156_DSP56DSM_H
#define MAME_CPU_DSP56156_DSP56DSM_H
#pragma once
@ -23,4 +23,4 @@ public:
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
};
#endif
#endif // MAME_CPU_DSP56156_DSP56DSM_H

View File

@ -1,12 +1,14 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#ifndef DSP56156_PCU_H
#define DSP56156_PCU_H
#ifndef MAME_CPU_DSP56156_DSP56PCU_H
#define MAME_CPU_DSP56156_DSP56PCU_H
#pragma once
#include "dsp56156.h"
namespace DSP_56156
{
namespace DSP_56156 {
/***************************************************************************
PCU
***************************************************************************/
@ -148,4 +150,4 @@ int8_t dsp56156_get_irq_priority(dsp56156_core* cpustate, int index);
} // namespace DSP_56156
#endif
#endif // MAME_CPU_DSP56156_DSP56PCU_H

View File

@ -1,7 +1,9 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#ifndef DSP56156_INSTRUCTION_H
#define DSP56156_INSTRUCTION_H
#ifndef MAME_CPU_DSP56156_INST_H
#define MAME_CPU_DSP56156_INST_H
#pragma once
#include "opcode.h"
#include "tables.h"
@ -13,8 +15,8 @@
//
// An Instruction is the base class all regular ops inherit from.
//
namespace DSP_56156
{
namespace DSP_56156 {
#define UNIMPLEMENTED_OPCODE() osd_printf_error("Unimplemented opcode: PC=%04x | %s;\n", PC, __PRETTY_FUNCTION__);
class Opcode;
@ -3482,5 +3484,6 @@ private:
reg_id m_source2;
};
}
#endif
} // namespace DSP_56156
#endif // MAME_CPU_DSP56156_INST_H

View File

@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#ifndef DSP56156_OPCODE_H
#define DSP56156_OPCODE_H
#ifndef MAME_CPU_DSP56156_OPCODE_H
#define MAME_CPU_DSP56156_OPCODE_H
#include "inst.h"
#include "pmove.h"
@ -42,4 +42,4 @@ private:
} // namespace DSP_56156
#endif
#endif // MAME_CPU_DSP56156_OPCODE_H

View File

@ -1,7 +1,9 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#ifndef DSP56156_PMOVE_H
#define DSP56156_PMOVE_H
#ifndef MAME_CPU_DSP56156_PMOVE_H
#define MAME_CPU_DSP56156_PMOVE_H
#pragma once
#include "opcode.h"
#include "tables.h"
@ -9,8 +11,8 @@
//
// A ParallelMove Object is what all parallel move classes inherit from.
//
namespace DSP_56156
{
namespace DSP_56156 {
class Opcode;
class ParallelMove
@ -316,5 +318,6 @@ private:
std::string m_destination;
};
}
#endif
} // namespace DSP_56156
#endif // MAME_CPU_DSP56156_PMOVE_H

View File

@ -1,16 +1,16 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#ifndef DSP56156_TABLES_H
#define DSP56156_TABLES_H
#ifndef MAME_CPU_DSP56156_TABLES_H
#define MAME_CPU_DSP56156_TABLES_H
#pragma once
#include "dsp56156.h"
#include <cstdio>
#include <cstdlib>
#include "dsp56156.h"
namespace DSP_56156
{
#define BITSn(CUR,MASK) (dsp56156_op_maskn(CUR,MASK))
namespace DSP_56156 {
enum bitsModified {BM_NONE = 0x0, BM_LOW = 0x1, BM_MIDDLE = 0x2, BM_HIGH = 0x4};
@ -77,6 +77,7 @@ int8_t get_6_bit_signed_value(uint16_t bits);
// Helpers
uint16_t dsp56156_op_maskn(uint16_t cur, uint16_t mask);
inline uint16_t BITSn(uint16_t cur, uint16_t mask) { return dsp56156_op_maskn(cur, mask); }
bool registerOverlap(const reg_id& r0, const size_t bmd, const reg_id& r1);
@ -88,6 +89,6 @@ std::string opMnemonicAsString(const op_mnem& mnem);
reg_id stringAsRegID(const std::string& str);
uint8_t regIDAsNum(const reg_id& regId);
} // namespace DSP_56156
}
#endif
#endif // MAME_CPU_DSP56156_TABLES_H

View File

@ -8,8 +8,10 @@
***************************************************************************/
#ifndef DEVICES_CPU_DSPP_DSPPFE_H
#define DEVICES_CPU_DSPP_DSPPFE_H
#ifndef MAME_CPU_DSPP_DSPPFE_H
#define MAME_CPU_DSPP_DSPPFE_H
#pragma once
#include "dspp.h"
#include "cpu/drcfe.h"
@ -69,5 +71,4 @@ private:
dspp_device *m_dspp;
};
#endif /* DEVICES_CPU_DSPP_DSPPFE_H */
#endif // MAME_CPU_DSPP_DSPPFE_H

View File

@ -1,7 +1,9 @@
// license:BSD-3-Clause
// copyright-holders:Pierpaolo Prazzoli
#ifndef MAME_CPU_E132XS_XS32DEFS_H
#define MAME_CPU_E132XS_XS32DEFS_H
#ifndef MAME_CPU_E132XS_32XSDEFS_H
#define MAME_CPU_E132XS_32XSDEFS_H
#pragma once
/***************************************************************************
COMPILE-TIME DEFINITIONS
@ -225,6 +227,4 @@
//other bits are reversed, in particular 7 - 5 for the operating system.
//the user program can only change the above 2 flags
#endif // MAME_CPU_E132XS_XS32DEFS_H
#endif // MAME_CPU_E132XS_32XSDEFS_H

View File

@ -7,8 +7,8 @@
*
***************************************************************************/
#ifndef MAME_CPU_ES5510_ES5510DASM_H
#define MAME_CPU_ES5510_ES5510DASM_H
#ifndef MAME_CPU_ES5510_ES5510D_H
#define MAME_CPU_ES5510_ES5510D_H
#pragma once
@ -22,4 +22,4 @@ public:
virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
};
#endif
#endif // MAME_CPU_ES5510_ES5510D_H

View File

@ -1,8 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:David Haywood
#ifndef MAME_CPU_EVO_EVO_H
#define MAME_CPU_EVO_EVO_H
#ifndef MAME_CPU_EVOLUTION_EVO_H
#define MAME_CPU_EVOLUTION_EVO_H
#pragma once
@ -36,4 +36,4 @@ private:
DECLARE_DEVICE_TYPE(EVOLUTION_CPU, evo_cpu_device)
#endif // MAME_CPU_EVO_EVO_H
#endif // MAME_CPU_EVOLUTION_EVO_H

View File

@ -140,6 +140,7 @@
#include "multibyte.h"
#include "unicode.h"
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <ctime>
@ -179,6 +180,18 @@ struct fat_file
struct fat_dirent
{
fat_dirent() :
directory(0),
eof(0),
filesize(0),
first_cluster(0),
dirent_sector_index(0),
dirent_sector_offset(0)
{
std::fill(std::begin(long_filename), std::end(long_filename), 0);
std::fill(std::begin(short_filename), std::end(short_filename), 0);
}
char long_filename[512];
char short_filename[13];
unsigned int directory : 1;
@ -1273,15 +1286,16 @@ static uint32_t fat_setup_time(time_t ansi_time)
static imgtoolerr_t fat_read_dirent(imgtool::partition &partition, fat_file *file,
fat_dirent &ent, fat_freeentry_info *freeent)
static imgtoolerr_t fat_read_dirent(
imgtool::partition &partition,
fat_file *file,
fat_dirent &ent,
fat_freeentry_info *freeent)
{
imgtoolerr_t err;
//const fat_partition_info *disk_info;
uint8_t entry[FAT_DIRENT_SIZE];
size_t bytes_read;
int i, j;
char32_t ch;
char16_t lfn_buf[512];
size_t lfn_len = 0;
int lfn_lastentry = 0;
@ -1290,7 +1304,7 @@ static imgtoolerr_t fat_read_dirent(imgtool::partition &partition, fat_file *fil
assert(file->directory);
lfn_buf[0] = '\0';
memset(&ent, 0, sizeof(ent));
ent = fat_dirent();
//disk_info = fat_get_partition_info(partition);
/* The first eight bytes of a FAT directory entry is a blank padded name
@ -1351,7 +1365,7 @@ static imgtoolerr_t fat_read_dirent(imgtool::partition &partition, fat_file *fil
}
}
}
while((entry[0] == 0x2E) || (entry[0] == 0xE5) || (entry[11] == 0x0F));
while ((entry[0] == 0x2E) || (entry[0] == 0xE5) || (entry[11] == 0x0F));
/* no more directory entries? */
if (entry[0] == '\0')
@ -1369,14 +1383,14 @@ static imgtoolerr_t fat_read_dirent(imgtool::partition &partition, fat_file *fil
/* only use the LFN if the checksum passes */
if (lfn_checksum == fat_calc_filename_checksum(entry))
{
i = 0;
j = 0;
int i = 0, j = 0;
char32_t ch;
do
{
i += uchar_from_utf16(&ch, &lfn_buf[i], std::size(lfn_buf) - i);
j += utf8_from_uchar(&ent.long_filename[j], std::size(ent.long_filename) - j, ch);
}
while(ch != 0);
while (ch != 0);
}
}

View File

@ -19,6 +19,7 @@
#include "multibyte.h"
#include "opresolv.h"
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
@ -51,20 +52,21 @@ as track map, with one bit for each sector used.
/* vzdos directry entry */
struct vzdos_dirent
{
char ftype;
char delimitor;
char fname[8];
struct {
char ftype;
char delimitor;
char fname[8];
} node;
uint8_t start_track;
uint8_t start_sector;
uint16_t start_address;
uint16_t end_address;
vzdos_dirent()
vzdos_dirent() :
start_track(0), start_sector(0),
start_address(0), end_address(0)
{
ftype = delimitor = '\0';
fname[0] = '\0';
start_track = start_sector = 0;
start_address = end_address = 0;
memset(&node, 0, sizeof(node));
}
};
@ -160,8 +162,7 @@ static imgtoolerr_t vzdos_write_sector_data(imgtool::image &img, int track, int
static imgtoolerr_t vzdos_clear_sector(imgtool::image &img, int track, int sector)
{
uint8_t data[DATA_SIZE + 2];
memset(data, 0x00, sizeof(data));
std::fill(std::begin(data), std::end(data), 0x00);
return vzdos_write_sector_data(img, track, sector, data);
}
@ -169,21 +170,21 @@ static imgtoolerr_t vzdos_clear_sector(imgtool::image &img, int track, int secto
/* return a directory entry for an index */
static imgtoolerr_t vzdos_get_dirent(imgtool::image &img, int index, vzdos_dirent *ent)
{
int ret, entry;
uint8_t buffer[DATA_SIZE + 2];
ret = vzdos_read_sector_data(img, 0, (int) index / 8, buffer);
if (ret) return (imgtoolerr_t)ret;
imgtoolerr_t const ret = vzdos_read_sector_data(img, 0, int(index) / 8, buffer);
if (IMGTOOLERR_SUCCESS != ret)
return ret;
entry = ((index % 8) * sizeof(vzdos_dirent));
int const entry = ((index % 8) * sizeof(vzdos_dirent));
memcpy(ent, &buffer[entry], 10);
memcpy(&ent->node, &buffer[entry], 10);
ent->start_track = buffer[entry + 10];
ent->start_sector = buffer[entry + 11];
ent->start_address = get_u16le(&buffer[entry + 12]);
ent->end_address = get_u16le(&buffer[entry + 14]);
if (ent->ftype == 0x00)
if (ent->node.ftype == 0x00)
return IMGTOOLERR_FILENOTFOUND;
/* check values */
@ -224,20 +225,12 @@ static imgtoolerr_t vzdos_set_dirent(imgtool::image &img, int index, vzdos_diren
/* clear a directory entry */
static imgtoolerr_t vzdos_clear_dirent(imgtool::image &img, int index)
{
int ret;
vzdos_dirent entry;
memset(&entry, 0x00, sizeof(vzdos_dirent));
ret = vzdos_set_dirent(img, index, entry);
if (ret) return (imgtoolerr_t)ret;
return IMGTOOLERR_SUCCESS;
return vzdos_set_dirent(img, index, entry);
}
/* search the index for a directory entry */
static imgtoolerr_t vzdos_searchentry(imgtool::image &image, const char *fname, int *entry) {
int i, len, ret;
vzdos_dirent ent;
char filename[9];
@ -249,23 +242,23 @@ static imgtoolerr_t vzdos_searchentry(imgtool::image &image, const char *fname,
*entry = -1;
for (i = 0; i < MAX_DIRENTS; i++) {
ret = vzdos_get_dirent(image, i, &ent);
if (ret) return (imgtoolerr_t)ret;
for (int i = 0; i < MAX_DIRENTS; i++) {
imgtoolerr_t const ret = vzdos_get_dirent(image, i, &ent);
if (IMGTOOLERR_SUCCESS != ret)
return ret;
len = vzdos_get_fname_len(ent.fname) + 1;
int const len = vzdos_get_fname_len(ent.node.fname) + 1;
if (strlen(fname) != len)
continue;
memset(filename, 0x00, sizeof(filename));
memcpy(filename, ent.fname, len);
std::fill(std::begin(filename), std::end(filename), 0x00);
memcpy(filename, ent.node.fname, len);
if (!core_stricmp(fname, filename)) {
*entry = i;
break;
}
}
if (*entry == -1)
@ -362,7 +355,6 @@ static imgtoolerr_t vzdos_free_trackmap(imgtool::image &img, int *track, int *se
static imgtoolerr_t vzdos_write_formatted_sector(imgtool::image &img, int track, int sector)
{
int ret;
uint8_t sector_data[DATA_SIZE + 4 + 24];
static const uint8_t sector_header[24] = {
@ -371,15 +363,16 @@ static imgtoolerr_t vzdos_write_formatted_sector(imgtool::image &img, int track,
0x80, 0x80, 0x80, 0x00, 0xC3, 0x18, 0xE7, 0xFE
};
memset(sector_data, 0x00, sizeof(sector_data));
std::fill(std::begin(sector_data), std::end(sector_data), 0x00);
memcpy(sector_data, sector_header, sizeof(sector_header));
sector_data[10] = (uint8_t) track; /* current track */
sector_data[11] = (uint8_t) sector; /* current sector */
sector_data[12] = (uint8_t) track + sector; /* checksum-8 */
ret = floppy_write_sector(imgtool_floppy(img), 0, track, sector_order[sector], 0, sector_data, sizeof(sector_data), 0); /* TODO: pass ddam argument from imgtool */
if (ret) return (imgtoolerr_t)ret;
floperr_t const ret = floppy_write_sector(imgtool_floppy(img), 0, track, sector_order[sector], 0, sector_data, sizeof(sector_data), 0); /* TODO: pass ddam argument from imgtool */
if (FLOPPY_ERROR_SUCCESS != ret)
return IMGTOOLERR_WRITEERROR;
return IMGTOOLERR_SUCCESS;
}
@ -427,15 +420,15 @@ static imgtoolerr_t vzdos_diskimage_nextenum(imgtool::directory &enumeration, im
/* kill trailing spaces */
for (len = 7; len > 0; len--) {
if (dirent.fname[len] != 0x20) {
if (dirent.node.fname[len] != 0x20) {
break;
}
}
memcpy(ent.filename, &dirent.fname, len + 1);
memcpy(ent.filename, &dirent.node.fname, len + 1);
ent.filesize = dirent.end_address - dirent.start_address;
switch (dirent.ftype)
switch (dirent.node.ftype)
{
case 0x01: type = "Deleted"; break;
case 'T': type = "Basic"; break;
@ -620,8 +613,8 @@ static imgtoolerr_t vzdos_writefile(imgtool::partition &partition, int offset, i
return IMGTOOLERR_READONLY;
/* check for already existing filename -> overwrite */
strcpy(filename, entry->fname);
filename[vzdos_get_fname_len(entry->fname) + 1] = 0x00;
strcpy(filename, entry->node.fname);
filename[vzdos_get_fname_len(entry->node.fname) + 1] = 0x00;
ret = vzdos_get_dirent_fname(img, filename, &temp_entry);
if (!ret) {
/* file already exists, delete it */
@ -705,8 +698,6 @@ static imgtoolerr_t vzdos_writefile(imgtool::partition &partition, int offset, i
/* create a new file or overwrite a file */
static imgtoolerr_t vzdos_diskimage_writefile(imgtool::partition &partition, const char *filename, const char *fork, imgtool::stream &sourcef, util::option_resolution *opts)
{
imgtoolerr_t ret;
int ftype;
vzdos_dirent entry;
/* TODO: check for leading spaces and strip */
@ -714,34 +705,31 @@ static imgtoolerr_t vzdos_diskimage_writefile(imgtool::partition &partition, con
return IMGTOOLERR_BADFILENAME;
/* prepare directory entry */
ftype = opts->lookup_int('T');
int const ftype = opts->lookup_int('T');
switch (ftype) {
case 0:
entry.ftype = 'T';
entry.node.ftype = 'T';
entry.start_address = 31465;
break;
case 1:
entry.ftype = 'B';
entry.node.ftype = 'B';
entry.start_address = 31465; /* ??? */
break;
case 2:
entry.ftype = 'D';
entry.node.ftype = 'D';
entry.start_address = 31465; /* ??? */
break;
default:
break;
}
entry.delimitor = ':';
memset(&entry.fname, 0x20, 8); /* pad with spaces */
memcpy(&entry.fname, filename, strlen(filename));
entry.node.delimitor = ':';
memset(&entry.node.fname, 0x20, 8); /* pad with spaces */
memcpy(&entry.node.fname, filename, strlen(filename));
/* write file to disk */
ret = vzdos_writefile(partition, 0, sourcef, &entry);
if (ret) return ret;
return IMGTOOLERR_SUCCESS;
return vzdos_writefile(partition, 0, sourcef, &entry);
}
static imgtoolerr_t vzdos_diskimage_suggesttransfer(imgtool::partition &partition, const char *fname, imgtool::transfer_suggestion *suggestions, size_t suggestions_length)
@ -754,7 +742,7 @@ static imgtoolerr_t vzdos_diskimage_suggesttransfer(imgtool::partition &partitio
ret = vzdos_get_dirent_fname(image, fname, &entry);
if (ret) return ret;
switch (entry.ftype) {
switch (entry.node.ftype) {
case 'B':
suggestions[0].viability = imgtool::SUGGESTION_RECOMMENDED;
suggestions[0].filter = filter_vzsnapshot_getinfo;
@ -827,7 +815,7 @@ static imgtoolerr_t vzsnapshot_readfile(imgtool::partition &partition, const cha
header[1] = 'Z';
header[2] = 'F';
switch (entry.ftype) {
switch (entry.node.ftype) {
case 'B':
header[3] = '1';
header[21] = 0xF1;
@ -842,7 +830,7 @@ static imgtoolerr_t vzsnapshot_readfile(imgtool::partition &partition, const cha
}
memset(header + 4, 0x00, 17);
memcpy(header + 4, entry.fname, vzdos_get_fname_len(entry.fname) + 1);
memcpy(header + 4, entry.node.fname, vzdos_get_fname_len(entry.node.fname) + 1);
put_u16le(&header[22], entry.start_address);
/* write header to file */
@ -866,21 +854,21 @@ static imgtoolerr_t vzsnapshot_writefile(imgtool::partition &partition, const ch
sourcef.read(header, sizeof(header));
/* prepare directory entry */
entry.ftype = header[21] == 0xF1 ? 'B' : 'T';
entry.delimitor = ':';
entry.start_address = get_u16le(&header[22]);
entry.node.ftype = (header[21] == 0xF1) ? 'B' : 'T';
entry.node.delimitor = ':';
entry.start_address = get_u16le(&header[22]);
/* filename from header or directly? */
fnameopt = opts->lookup_int('F');
if (fnameopt == 0) {
memcpy(&entry.fname, &header[4], 8);
memcpy(&entry.node.fname, &header[4], 8);
} else {
/* TODO: check for leading spaces and strip */
if (strlen(filename) > 8 || strlen(filename) < 1)
return IMGTOOLERR_BADFILENAME;
memcpy(&entry.fname, filename, strlen(filename) - 3);
memcpy(&entry.node.fname, filename, strlen(filename) - 3);
}
/* write file to disk */