(nw) fix stuff:

* Add per-language compiler flag options to help with exotic setups
* Get rid of a potention buffer overrun in NuBus image card
* CHAR_WIDTH and LONG_WIDTH are preprocessor macros in limits.h with glibc if __GLIBC_USE (IEC_60559_BFP_EXT) is enabled - avoid using them as names
* Make formats/upd765_dsk.h slightly safer with defualt initialisers for key format members
* Don't rely on random BSS data being zero in imagedev/floppy.cpp
This commit is contained in:
Vas Crabb 2018-11-29 14:10:27 +11:00
parent b568e6deab
commit c2dc4316bd
16 changed files with 142 additions and 70 deletions

View File

@ -52,6 +52,10 @@
# MAP = 1
# PROFILE = 1
# ARCHOPTS =
# ARCHOPTS_C =
# ARCHOPTS_CXX =
# ARCHOPTS_OBJC =
# ARCHOPTS_OBJCXX =
# OPT_FLAGS =
# LDOPTS =
@ -627,6 +631,22 @@ ifdef ARCHOPTS
PARAMS += --ARCHOPTS='$(ARCHOPTS)'
endif
ifdef ARCHOPTS_C
PARAMS += --ARCHOPTS_C='$(ARCHOPTS_C)'
endif
ifdef ARCHOPTS_CXX
PARAMS += --ARCHOPTS_CXX='$(ARCHOPTS_CXX)'
endif
ifdef ARCHOPTS_OBJC
PARAMS += --ARCHOPTS_OBJC='$(ARCHOPTS_OBJC)'
endif
ifdef ARCHOPTS_OBJCXX
PARAMS += --ARCHOPTS_OBJCXX='$(ARCHOPTS_OBJCXX)'
endif
ifdef OPT_FLAGS
PARAMS += --OPT_FLAGS='$(OPT_FLAGS)'
endif

View File

@ -219,7 +219,27 @@ newoption {
newoption {
trigger = "ARCHOPTS",
description = "ARCHOPTS.",
description = "Additional options for target C/C++/Objective-C/Objective-C++ compilers and linker.",
}
newoption {
trigger = "ARCHOPTS_C",
description = "Additional options for target C++ compiler.",
}
newoption {
trigger = "ARCHOPTS_CXX",
description = "Additional options for target C++ compiler.",
}
newoption {
trigger = "ARCHOPTS_OBJC",
description = "Additional options for target Objective-C compiler.",
}
newoption {
trigger = "ARCHOPTS_OBJCXX",
description = "Additional options for target Objective-C++ compiler.",
}
newoption {
@ -869,6 +889,30 @@ if _OPTIONS["ARCHOPTS"] then
}
end
if _OPTIONS["ARCHOPTS_C"] then
buildoptions_c {
_OPTIONS["ARCHOPTS_C"]
}
end
if _OPTIONS["ARCHOPTS_CXX"] then
buildoptions_cpp {
_OPTIONS["ARCHOPTS_CXX"]
}
end
if _OPTIONS["ARCHOPTS_OBJC"] then
buildoptions_objc {
_OPTIONS["ARCHOPTS_OBJC"]
}
end
if _OPTIONS["ARCHOPTS_OBJCXX"] then
buildoptions_objcpp {
_OPTIONS["ARCHOPTS_OBJCXX"]
}
end
if _OPTIONS["SHLIB"] then
buildoptions {
"-fPIC"

View File

@ -16,7 +16,7 @@ newoption {
description = "Choose GCC flavor",
allowed = {
{ "android-arm", "Android - ARM" },
{ "android-arm64", "Android - ARM64" },
{ "android-arm64", "Android - ARM64" },
{ "android-mips", "Android - MIPS" },
{ "android-mips64","Android - MIPS64" },
{ "android-x86", "Android - x86" },

View File

@ -84,7 +84,7 @@ image_init_result nubus_image_device::messimg_disk_image_device::call_load()
m_size = (uint32_t)ftell();
if (m_size > (256*1024*1024))
{
printf("Mac image too large: must be 256MB or less!\n");
osd_printf_error("Mac image too large: must be 256MB or less!\n");
m_size = 0;
return image_init_result::FAIL;
}
@ -247,10 +247,6 @@ READ32_MEMBER( nubus_image_device::image_super_r )
WRITE32_MEMBER( nubus_image_device::file_cmd_w )
{
const osd::directory::entry *dp;
char fullpath[1024];
uint64_t filesize;
// data = ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
filectx.curcmd = data;
switch(data) {
@ -269,7 +265,7 @@ WRITE32_MEMBER( nubus_image_device::file_cmd_w )
filectx.dirp = osd::directory::open((const char *)filectx.curdir);
case kFileCmdGetNextListing:
if (filectx.dirp) {
dp = filectx.dirp->read();
osd::directory::entry const *const dp = filectx.dirp->read();
if(dp) {
strncpy((char*)filectx.filename, dp->name, sizeof(filectx.filename));
} else {
@ -281,20 +277,29 @@ WRITE32_MEMBER( nubus_image_device::file_cmd_w )
}
break;
case kFileCmdGetFile:
memset(fullpath, 0, sizeof(fullpath));
strcpy(fullpath, (const char *)filectx.curdir);
strcat(fullpath, "/");
strcat(fullpath, (const char*)filectx.filename);
if(osd_file::open(std::string(fullpath), OPEN_FLAG_READ, filectx.fd, filectx.filelen) != osd_file::error::NONE) printf("Error opening %s\n", fullpath);
filectx.bytecount = 0;
{
std::string fullpath;
fullpath.reserve(1024);
fullpath.assign((const char *)filectx.curdir);
fullpath.append(PATH_SEPARATOR);
fullpath.append((const char*)filectx.filename);
if(osd_file::open(fullpath, OPEN_FLAG_READ, filectx.fd, filectx.filelen) != osd_file::error::NONE)
osd_printf_error("Error opening %s\n", fullpath.c_str());
filectx.bytecount = 0;
}
break;
case kFileCmdPutFile:
memset(fullpath, 0, sizeof(fullpath));
strcpy(fullpath, (const char *)filectx.curdir);
strcat(fullpath, "/");
strcat(fullpath, (const char*)filectx.filename);
if(osd_file::open(std::string(fullpath), OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, filectx.fd, filesize) != osd_file::error::NONE) printf("Error opening %s\n", fullpath);
filectx.bytecount = 0;
{
std::string fullpath;
fullpath.reserve(1024);
fullpath.assign((const char *)filectx.curdir);
fullpath.append(PATH_SEPARATOR);
fullpath.append((const char*)filectx.filename);
uint64_t filesize; // unused, but it's an output from the open call
if(osd_file::open(fullpath, OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, filectx.fd, filesize) != osd_file::error::NONE)
osd_printf_error("Error opening %s\n", fullpath.c_str());
filectx.bytecount = 0;
}
break;
}
}

View File

@ -252,7 +252,11 @@ void floppy_image_device::set_formats(const floppy_format_type *formats)
{
extension_list[0] = '\0';
fif_list = nullptr;
for(int cnt=0; formats[cnt]; cnt++)
// FIXME: this code previously treated formats as an array, but none of the actual formats in src/lib/formats provide an array - they all just supply a single function pointer
// This happens to work by chance if the next poitner-sized piece of BSS data happens to be zero, which it is most of the time.
// However, for some reason on a Linux clang 6 build it sometimes isn't, causing a lovely crash here.
// If this is supposed to be a nullptr-terminated array of function pointers, the code needs to be changed to better enforce it.
for(int cnt=0; /*formats[cnt]*/ !cnt; cnt++)
{
// allocate a new format
floppy_image_format_t *fif = formats[cnt]();

View File

@ -578,7 +578,7 @@ void cdp1869_device::draw_line(bitmap_rgb32 &bitmap, const rectangle &rect, int
data <<= 2;
for (i = 0; i < CHAR_WIDTH; i++)
for (i = 0; i < CH_WIDTH; i++)
{
if (data & 0x80)
{
@ -972,7 +972,7 @@ uint32_t cdp1869_device::screen_update(screen_device &screen, bitmap_rgb32 &bitm
if (!m_dispoff)
{
int width = CHAR_WIDTH;
int width = CH_WIDTH;
int height = get_lines();
if (!m_freshorz)

View File

@ -146,17 +146,17 @@ public:
static constexpr auto CPU_CLK_PAL = DOT_CLK_PAL / 2;
static constexpr auto CPU_CLK_NTSC = DOT_CLK_NTSC / 2;
static constexpr unsigned CHAR_WIDTH = 6;
static constexpr unsigned CH_WIDTH = 6;
static constexpr unsigned HSYNC_START = 56 * CHAR_WIDTH;
static constexpr unsigned HSYNC_END = 60 * CHAR_WIDTH;
static constexpr unsigned HBLANK_START = 54 * CHAR_WIDTH;
static constexpr unsigned HBLANK_END = 5 * CHAR_WIDTH;
static constexpr unsigned SCREEN_START_PAL = 9 * CHAR_WIDTH;
static constexpr unsigned SCREEN_START_NTSC = 10 * CHAR_WIDTH;
static constexpr unsigned SCREEN_START = 10 * CHAR_WIDTH;
static constexpr unsigned SCREEN_END = 50 * CHAR_WIDTH;
static constexpr unsigned SCREEN_WIDTH = 60 * CHAR_WIDTH;
static constexpr unsigned HSYNC_START = 56 * CH_WIDTH;
static constexpr unsigned HSYNC_END = 60 * CH_WIDTH;
static constexpr unsigned HBLANK_START = 54 * CH_WIDTH;
static constexpr unsigned HBLANK_END = 5 * CH_WIDTH;
static constexpr unsigned SCREEN_START_PAL = 9 * CH_WIDTH;
static constexpr unsigned SCREEN_START_NTSC = 10 * CH_WIDTH;
static constexpr unsigned SCREEN_START = 10 * CH_WIDTH;
static constexpr unsigned SCREEN_END = 50 * CH_WIDTH;
static constexpr unsigned SCREEN_WIDTH = 60 * CH_WIDTH;
static constexpr unsigned TOTAL_SCANLINES_PAL = 312;
static constexpr unsigned SCANLINE_VBLANK_START_PAL = 304;

View File

@ -33,7 +33,7 @@
#define IBM8514_LINE_LENGTH (m_vga->offset())
#define CHAR_WIDTH ((vga.sequencer.data[1]&1)?8:9)
#define VGA_CH_WIDTH ((vga.sequencer.data[1]&1)?8:9)
#define TEXT_COLUMNS (vga.crtc.horz_disp_end+1)
#define TEXT_START_ADDRESS (vga.crtc.start_addr<<3)

View File

@ -90,7 +90,7 @@ enum
#define IBM8514_LINE_LENGTH (m_vga->offset())
#define CHAR_WIDTH ((vga.sequencer.data[1]&1)?8:9)
#define VGA_CH_WIDTH ((vga.sequencer.data[1]&1)?8:9)
#define TEXT_COLUMNS (vga.crtc.horz_disp_end+1)
#define TEXT_START_ADDRESS (vga.crtc.start_addr<<3)
@ -452,7 +452,7 @@ void vga_device::vga_vh_text(bitmap_rgb32 &bitmap, const rectangle &cliprect)
uint8_t bits;
uint32_t font_base;
uint32_t *bitmapline;
int width=CHAR_WIDTH, height = (vga.crtc.maximum_scan_line) * (vga.crtc.scan_doubling + 1);
int width=VGA_CH_WIDTH, height = (vga.crtc.maximum_scan_line) * (vga.crtc.scan_doubling + 1);
int pos, line, column, mask, w, h, addr;
uint8_t blink_en,fore_col,back_col;
pen_t pen;
@ -1392,7 +1392,7 @@ void vga_device::recompute_params_clock(int divisor, int xtal)
{
int vblank_period,hblank_period;
attoseconds_t refresh;
uint8_t hclock_m = (!GRAPHIC_MODE) ? CHAR_WIDTH : 8;
uint8_t hclock_m = (!GRAPHIC_MODE) ? VGA_CH_WIDTH : 8;
int pixel_clock;
/* safety check */

View File

@ -73,7 +73,7 @@ enum
#define EXPMEM_OFFSET 0x20000
#define LONG_WIDTH (512 + 32)
#define V9938_LONG_WIDTH (512 + 32)
static const char *const v9938_modes[] = {
"TEXT 1", "MULTICOLOR", "GRAPHIC 1", "GRAPHIC 2", "GRAPHIC 3",
@ -909,7 +909,7 @@ void v99x8_device::default_border(uint32_t *ln)
int i;
pen = pen16(m_cont_reg[7] & 0x0f);
i = LONG_WIDTH;
i = V9938_LONG_WIDTH;
while (i--) *ln++ = pen;
}
@ -919,7 +919,7 @@ void v99x8_device::graphic7_border(uint32_t *ln)
int i;
pen = pen256(m_cont_reg[7]);
i = LONG_WIDTH;
i = V9938_LONG_WIDTH;
while (i--) *ln++ = pen;
}
@ -931,7 +931,7 @@ void v99x8_device::graphic5_border(uint32_t *ln)
pen1 = pen16(m_cont_reg[7] & 0x03);
pen0 = pen16((m_cont_reg[7] >> 2) & 0x03);
i = LONG_WIDTH / 2;
i = V9938_LONG_WIDTH / 2;
while (i--) { *ln++ = pen0; *ln++ = pen1; }
}

View File

@ -11,9 +11,8 @@
#include "emu.h" // emu_fatalerror
#include "formats/upd765_dsk.h"
upd765_format::upd765_format(const format *_formats) : file_header_skip_bytes(0), file_footer_skip_bytes(0)
upd765_format::upd765_format(const format *_formats) : file_header_skip_bytes(0), file_footer_skip_bytes(0), formats(_formats)
{
formats = _formats;
}
int upd765_format::find_size(io_generic *io, uint32_t form_factor) const

View File

@ -17,9 +17,9 @@ class upd765_format : public floppy_image_format_t
{
public:
struct format {
uint32_t form_factor; // See floppy_image for possible values
uint32_t variant; // See floppy_image for possible values
uint32_t encoding; // See floppy_image for possible values
uint32_t form_factor = 0U; // See floppy_image for possible values
uint32_t variant = 0U; // See floppy_image for possible values
uint32_t encoding = 0U; // See floppy_image for possible values
int cell_size; // See floppy_image_format_t for details
int sector_count;
@ -56,7 +56,7 @@ protected:
void extract_sectors(floppy_image *image, const format &f, desc_s *sdesc, int track, int head);
private:
const format *formats;
format const *const formats;
};
#endif /* UPD765_DSK_H */

View File

@ -23,7 +23,7 @@ the PCB, which go so far as to include the standard 8224 clock generator.
#include "video/tms9927.h"
#include "screen.h"
#define CHAR_WIDTH 7
#define AMPEX_CH_WIDTH 7
class ampex_state : public driver_device
{
@ -364,11 +364,11 @@ void ampex_state::ampex(machine_config &config)
m_maincpu->set_addrmap(AS_PROGRAM, &ampex_state::mem_map);
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_raw(23.814_MHz_XTAL / 2, 105 * CHAR_WIDTH, 0, 80 * CHAR_WIDTH, 270, 0, 250);
screen.set_raw(23.814_MHz_XTAL / 2, 105 * AMPEX_CH_WIDTH, 0, 80 * AMPEX_CH_WIDTH, 270, 0, 250);
screen.set_screen_update(FUNC(ampex_state::screen_update));
CRT5037(config, m_vtac, 23.814_MHz_XTAL / 2 / CHAR_WIDTH);
m_vtac->set_char_width(CHAR_WIDTH);
CRT5037(config, m_vtac, 23.814_MHz_XTAL / 2 / AMPEX_CH_WIDTH);
m_vtac->set_char_width(AMPEX_CH_WIDTH);
m_vtac->vsyn_callback().set(FUNC(ampex_state::vsyn_w));
m_vtac->set_screen("screen");

View File

@ -219,8 +219,8 @@ static const z80_daisy_config daisy_chain[] =
void facit4440_state::facit4440(machine_config &config)
{
constexpr u32 CHAR_WIDTH = 8;
constexpr u32 FAKE_DOT_CLOCK = 65 * 103 * 621 * CHAR_WIDTH;
constexpr u32 CH_WIDTH = 8;
constexpr u32 FAKE_DOT_CLOCK = 65 * 103 * 621 * CH_WIDTH;
Z80(config, m_maincpu, 32_MHz_XTAL / 8); // clock unknown
m_maincpu->set_addrmap(AS_PROGRAM, &facit4440_state::mem_map);
@ -257,12 +257,12 @@ void facit4440_state::facit4440(machine_config &config)
// Channel B is not used
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_raw(FAKE_DOT_CLOCK, 103 * CHAR_WIDTH, 0, 80 * CHAR_WIDTH, 621, 0, 500);
//screen.set_raw(FAKE_DOT_CLOCK, 103 * CHAR_WIDTH, 0, 80 * CHAR_WIDTH, 621, 0, 560);
screen.set_raw(FAKE_DOT_CLOCK, 103 * CH_WIDTH, 0, 80 * CH_WIDTH, 621, 0, 500);
//screen.set_raw(FAKE_DOT_CLOCK, 103 * CH_WIDTH, 0, 80 * CH_WIDTH, 621, 0, 560);
screen.set_screen_update("crtc", FUNC(mc6845_device::screen_update));
MC6845(config, m_crtc, FAKE_DOT_CLOCK / CHAR_WIDTH); // HD46505SP-2
m_crtc->set_char_width(CHAR_WIDTH);
MC6845(config, m_crtc, FAKE_DOT_CLOCK / CH_WIDTH); // HD46505SP-2
m_crtc->set_char_width(CH_WIDTH);
m_crtc->set_show_border_area(false);
m_crtc->set_update_row_callback(FUNC(facit4440_state::update_row), this);
m_crtc->out_hsync_callback().set("ctc", FUNC(z80ctc_device::trg3));

View File

@ -62,7 +62,7 @@
#include "screen.h"
#include "speaker.h"
#define CHAR_WIDTH 14
#define TV912_CH_WIDTH 14
#define CHARSET_TEST 0
class tv912_state : public driver_device
@ -306,7 +306,7 @@ u32 tv912_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, cons
dots ^= 0xff;
}
for (int d = 0; d < CHAR_WIDTH / 2; d++)
for (int d = 0; d < TV912_CH_WIDTH / 2; d++)
{
if (x >= cliprect.left() && x <= cliprect.right())
bitmap.pix(y, x) = BIT(dots, 7) ? rgb_t::white() : rgb_t::black();
@ -891,11 +891,11 @@ void tv912_state::tv912(machine_config &config)
m_bankdev->set_stride(0x100);
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_raw(23.814_MHz_XTAL, 105 * CHAR_WIDTH, 0, 80 * CHAR_WIDTH, 270, 0, 240);
screen.set_raw(23.814_MHz_XTAL, 105 * TV912_CH_WIDTH, 0, 80 * TV912_CH_WIDTH, 270, 0, 240);
screen.set_screen_update(FUNC(tv912_state::screen_update));
TMS9927(config, m_crtc, 23.814_MHz_XTAL / CHAR_WIDTH);
m_crtc->set_char_width(CHAR_WIDTH);
TMS9927(config, m_crtc, 23.814_MHz_XTAL / TV912_CH_WIDTH);
m_crtc->set_char_width(TV912_CH_WIDTH);
m_crtc->vsyn_callback().set_inputline(m_maincpu, MCS48_INPUT_IRQ);
m_crtc->set_screen("screen");

View File

@ -22,7 +22,7 @@
#include "screen.h"
// character matrix is supposed to be only 7x7, but 15 produces correct timings
#define CHAR_WIDTH 15
#define V100_CH_WIDTH 15
class v100_state : public driver_device
{
@ -83,8 +83,8 @@ u32 v100_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const
unsigned row0 = cliprect.top() / 10;
unsigned x0 = cliprect.left();
unsigned px0 = x0 % CHAR_WIDTH;
unsigned columns = screen.visible_area().width() / CHAR_WIDTH;
unsigned px0 = x0 % V100_CH_WIDTH;
unsigned columns = screen.visible_area().width() / V100_CH_WIDTH;
u16 start = 0;
unsigned y = 0;
@ -116,7 +116,7 @@ u32 v100_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const
px++;
if ((px & 1) == 0)
gfxdata <<= 1;
if (px >= CHAR_WIDTH)
if (px >= V100_CH_WIDTH)
{
addr = (addr + 1) & 0xfff;
gfxdata = m_p_chargen[((m_videoram[addr] & 0x7f) << 4) | scan];
@ -362,12 +362,12 @@ MACHINE_CONFIG_START(v100_state::v100)
brg2.ft_handler().set(m_usart[1], FUNC(i8251_device::write_txc));
MCFG_SCREEN_ADD("screen", RASTER)
//MCFG_SCREEN_RAW_PARAMS(XTAL(47'736'000) / 2, 102 * CHAR_WIDTH, 0, 80 * CHAR_WIDTH, 260, 0, 240)
MCFG_SCREEN_RAW_PARAMS(XTAL(47'736'000), 170 * CHAR_WIDTH, 0, 132 * CHAR_WIDTH, 312, 0, 240)
//MCFG_SCREEN_RAW_PARAMS(XTAL(47'736'000) / 2, 102 * V100_CH_WIDTH, 0, 80 * V100_CH_WIDTH, 260, 0, 240)
MCFG_SCREEN_RAW_PARAMS(XTAL(47'736'000), 170 * V100_CH_WIDTH, 0, 132 * V100_CH_WIDTH, 312, 0, 240)
MCFG_SCREEN_UPDATE_DRIVER(v100_state, screen_update)
CRT5037(config, m_vtac, XTAL(47'736'000) / CHAR_WIDTH);
m_vtac->set_char_width(CHAR_WIDTH);
CRT5037(config, m_vtac, XTAL(47'736'000) / V100_CH_WIDTH);
m_vtac->set_char_width(V100_CH_WIDTH);
m_vtac->set_screen("screen");
m_vtac->hsyn_callback().set(FUNC(v100_state::picu_r_w<7>)).invert();
m_vtac->vsyn_callback().set(FUNC(v100_state::picu_r_w<6>)).invert();