summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/cpu/alto2/a2disp.h6
-rw-r--r--src/devices/cpu/alto2/a2ether.h6
-rw-r--r--src/devices/cpu/alto2/a2mouse.h2
-rw-r--r--src/devices/cpu/alto2/a2roms.cpp25
-rw-r--r--src/devices/cpu/alto2/a2roms.h2
-rw-r--r--src/devices/cpu/alto2/alto2cpu.cpp6
-rw-r--r--src/devices/cpu/alto2/alto2cpu.h22
-rw-r--r--src/devices/machine/smartmed.cpp34
-rw-r--r--src/devices/machine/smartmed.h3
-rw-r--r--src/devices/machine/sonydriv.cpp44
-rw-r--r--src/devices/video/polylgcy.cpp93
-rw-r--r--src/devices/video/polylgcy.h12
-rw-r--r--src/devices/video/tms34061.cpp8
-rw-r--r--src/devices/video/tms34061.h2
-rw-r--r--src/devices/video/voodoo.cpp3
-rw-r--r--src/devices/video/voodoo.h2
16 files changed, 136 insertions, 134 deletions
diff --git a/src/devices/cpu/alto2/a2disp.h b/src/devices/cpu/alto2/a2disp.h
index 48c51578954..eee5af359b2 100644
--- a/src/devices/cpu/alto2/a2disp.h
+++ b/src/devices/cpu/alto2/a2disp.h
@@ -238,7 +238,7 @@ struct {
* O3 (010) = MBEMPTY'
* </PRE>
*/
-uint8_t* m_disp_a38;
+std::unique_ptr<uint8_t[]> m_disp_a38;
//! output bits of PROM A38
enum {
@@ -273,7 +273,7 @@ enum {
* which happens to be very close to every 7th CPU microcycle.
* </PRE>
*/
-uint8_t* m_disp_a63;
+std::unique_ptr<uint8_t[]> m_disp_a63;
enum {
disp_a63_HBLANK = (1 << 0), //!< PROM a63 B0 is latched as HBLANK signal
@@ -293,7 +293,7 @@ enum {
* Address lines are driven by H[1] to H[128] of the horz. line counters.
* The PROM is enabled whenever H[256] and H[512] are both 0.
*/
-uint8_t* m_disp_a66;
+std::unique_ptr<uint8_t[]> m_disp_a66;
enum {
disp_a66_VSYNC_ODD = (1 << 0), //!< Q1 (001) is VSYNC for the odd field (with H1024=1)
diff --git a/src/devices/cpu/alto2/a2ether.h b/src/devices/cpu/alto2/a2ether.h
index 48b29f6ea9b..7d0ab567215 100644
--- a/src/devices/cpu/alto2/a2ether.h
+++ b/src/devices/cpu/alto2/a2ether.h
@@ -37,9 +37,9 @@ enum {
//!< f2 (1111): undefined
};
-uint8_t* m_ether_a41; //!< BPROM; P3601-1; 256x4; enet.a41 "PE1"
-uint8_t* m_ether_a42; //!< BPROM; P3601-1; 256x4; enet.a42 "PE2"
-uint8_t* m_ether_a49; //!< BPROM; P3601-1; 265x4 enet.a49 "AFIFO"
+std::unique_ptr<uint8_t[]> m_ether_a41; //!< BPROM; P3601-1; 256x4; enet.a41 "PE1"
+std::unique_ptr<uint8_t[]> m_ether_a42; //!< BPROM; P3601-1; 256x4; enet.a42 "PE2"
+std::unique_ptr<uint8_t[]> m_ether_a49; //!< BPROM; P3601-1; 265x4 enet.a49 "AFIFO"
enum {
ether_a49_BE = (1 << 0), //!< buffer empty
ether_a49_BNE = (1 << 1), //!< buffer next empty
diff --git a/src/devices/cpu/alto2/a2mouse.h b/src/devices/cpu/alto2/a2mouse.h
index ad9de9cb5e9..628b73f671e 100644
--- a/src/devices/cpu/alto2/a2mouse.h
+++ b/src/devices/cpu/alto2/a2mouse.h
@@ -51,7 +51,7 @@
* sequence: 10 -> 70 -> e0 -> 80
* </PRE>
*/
-uint8_t* m_madr_a32;
+std::unique_ptr<uint8_t[]> m_madr_a32;
//! mouse context
struct {
diff --git a/src/devices/cpu/alto2/a2roms.cpp b/src/devices/cpu/alto2/a2roms.cpp
index 7eab1e34212..53decc730a0 100644
--- a/src/devices/cpu/alto2/a2roms.cpp
+++ b/src/devices/cpu/alto2/a2roms.cpp
@@ -104,28 +104,17 @@ static void write_type_and_xor(void *base, int type, uint32_t addr, uint32_t dan
* @param segments number of segments in one page of the result
* @return pointer to the newly allocated memory filled with source bits
*/
-uint8_t* prom_load(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages, int segments)
+std::unique_ptr<uint8_t[]> prom_load(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages, int segments)
{
- void* array = nullptr;
size_t type = prom->type;
size_t size = prom->size;
#if DEBUG_PROM_LOAD
uint8_t width = prom->width;
#endif
- switch (type) {
- case sizeof(uint8_t):
- array = auto_alloc_array(machine, uint8_t, pages * size);
- break;
- case sizeof(uint16_t):
- array = auto_alloc_array(machine, uint16_t, pages * size);
- break;
- case sizeof(uint32_t):
- array = auto_alloc_array(machine, uint32_t, pages * size);
- break;
- }
+ std::unique_ptr<uint8_t[]> array = std::make_unique<uint8_t[]>(pages * size * type);
- uint8_t* base = reinterpret_cast<uint8_t*>(array);
+ uint8_t* base = array.get();
for (int page = 0; page < pages; page++)
{
uint8_t* dst = base + (prom->type * prom->size * page);
@@ -154,7 +143,7 @@ uint8_t* prom_load(running_machine& machine, const prom_load_t* prom, const uint
switch (type) {
case sizeof(uint8_t):
{
- uint8_t* data = reinterpret_cast<uint8_t*>(array);
+ uint8_t* data = reinterpret_cast<uint8_t*>(array.get());
for (int addr = 0; addr < pages*size; addr++) {
if (0 == (addr % 16))
printf("%04x:", addr);
@@ -169,7 +158,7 @@ uint8_t* prom_load(running_machine& machine, const prom_load_t* prom, const uint
break;
case sizeof(uint16_t):
{
- uint16_t* data = reinterpret_cast<uint16_t*>(array);
+ uint16_t* data = reinterpret_cast<uint16_t*>(array.get());
for (int addr = 0; addr < pages*size; addr++) {
if (0 == (addr % 8))
printf("%04x:", addr);
@@ -181,7 +170,7 @@ uint8_t* prom_load(running_machine& machine, const prom_load_t* prom, const uint
break;
case sizeof(uint32_t):
{
- uint32_t* data = reinterpret_cast<uint32_t*>(array);
+ uint32_t* data = reinterpret_cast<uint32_t*>(array.get());
for (int addr = 0; addr < pages*size; addr++) {
if (0 == (addr % 4))
printf("%04x:", addr);
@@ -193,5 +182,5 @@ uint8_t* prom_load(running_machine& machine, const prom_load_t* prom, const uint
break;
}
#endif
- return reinterpret_cast<uint8_t *>(array);
+ return array;
}
diff --git a/src/devices/cpu/alto2/a2roms.h b/src/devices/cpu/alto2/a2roms.h
index 1c9edd71791..4fcc010cc80 100644
--- a/src/devices/cpu/alto2/a2roms.h
+++ b/src/devices/cpu/alto2/a2roms.h
@@ -38,5 +38,5 @@ typedef struct {
#define DMAP_DEFAULT {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
#define DMAP_REVERSE_0_3 {3,2,1,0,}
-extern uint8_t* prom_load(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages = 1, int segments = 1);
+extern std::unique_ptr<uint8_t[]> prom_load(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages = 1, int segments = 1);
#endif // MAME_CPU_ALTO2_A2ROMS_H
diff --git a/src/devices/cpu/alto2/alto2cpu.cpp b/src/devices/cpu/alto2/alto2cpu.cpp
index 8506e946882..43e747e4283 100644
--- a/src/devices/cpu/alto2/alto2cpu.cpp
+++ b/src/devices/cpu/alto2/alto2cpu.cpp
@@ -1009,7 +1009,7 @@ void alto2_cpu_device::state_string_export(const device_state_entry &entry, std:
uint32_t alto2_cpu_device::crom_cram_r(offs_t offset)
{
if (offset < m_ucode_ram_base)
- return *reinterpret_cast<uint32_t *>(m_ucode_crom + offset * 4);
+ return *reinterpret_cast<uint32_t *>(m_ucode_crom.get() + offset * 4);
return *reinterpret_cast<uint32_t *>(m_ucode_cram.get() + (offset - m_ucode_ram_base) * 4);
}
@@ -1024,12 +1024,12 @@ void alto2_cpu_device::crom_cram_w(offs_t offset, uint32_t data)
//! read constants PROM
uint16_t alto2_cpu_device::const_r(offs_t offset)
{
- return *reinterpret_cast<uint16_t *>(m_const_data + offset * 2);
+ return *reinterpret_cast<uint16_t *>(m_const_data.get() + offset * 2);
}
//! direct read access to the microcode CROM or CRAM
#define RD_UCODE(addr) (addr < m_ucode_ram_base ? \
- *reinterpret_cast<uint32_t *>(m_ucode_crom + addr * 4) : \
+ *reinterpret_cast<uint32_t *>(m_ucode_crom.get() + addr * 4) : \
*reinterpret_cast<uint32_t *>(m_ucode_cram.get() + (addr - m_ucode_ram_base) * 4))
//-------------------------------------------------
diff --git a/src/devices/cpu/alto2/alto2cpu.h b/src/devices/cpu/alto2/alto2cpu.h
index 172305574bd..3d1216beaed 100644
--- a/src/devices/cpu/alto2/alto2cpu.h
+++ b/src/devices/cpu/alto2/alto2cpu.h
@@ -251,9 +251,9 @@ private:
uint32_t m_ucode_size; //!< Size of both, CROM and CRAM together
uint32_t m_sreg_banks; //!< Number of S register banks; derived from m_cram_config
- uint8_t* m_ucode_crom;
+ std::unique_ptr<uint8_t[]> m_ucode_crom;
std::unique_ptr<uint8_t[]> m_ucode_cram;
- uint8_t* m_const_data;
+ std::unique_ptr<uint8_t[]> m_const_data;
void ucode_map(address_map &map);
void const_map(address_map &map);
@@ -655,7 +655,7 @@ private:
* access it. Also both, address and data lines, are inverted.
* </PRE>
*/
- uint8_t* m_ctl2k_u3;
+ std::unique_ptr<uint8_t[]> m_ctl2k_u3;
/**
* @brief 2KCTL PROM u38; 82S23; 32x8 bit
@@ -704,7 +704,7 @@ private:
* B7 9 NEXT[06]'
* </PRE>
*/
- uint8_t* m_ctl2k_u38;
+ std::unique_ptr<uint8_t[]> m_ctl2k_u38;
//! output lines of the 2KCTL U38 PROM
enum {
@@ -776,22 +776,22 @@ private:
* depending on the current NEXT[01]' level.
* </PRE>
*/
- uint8_t* m_ctl2k_u76;
+ std::unique_ptr<uint8_t[]> m_ctl2k_u76;
/**
* @brief 3k CRAM PROM a37
*/
- uint8_t* m_cram3k_a37;
+ std::unique_ptr<uint8_t[]> m_cram3k_a37;
/**
* @brief memory addressing PROM a64
*/
- uint8_t* m_madr_a64;
+ std::unique_ptr<uint8_t[]> m_madr_a64;
/**
* @brief memory addressing PROM a65
*/
- uint8_t* m_madr_a65;
+ std::unique_ptr<uint8_t[]> m_madr_a65;
/**
* @brief unused PROM a90
@@ -806,7 +806,7 @@ private:
*
* I haven't found yet where KP3-KP5 are used
*/
- uint8_t* m_madr_a90;
+ std::unique_ptr<uint8_t[]> m_madr_a90;
/**
* @brief unused PROM a91
@@ -833,12 +833,12 @@ private:
* KE(6) KB(^L) KB(RTN) KB(") KB(/) KB(S3) KB(<-) KB(]) KB(\)
* KE(7) KB(S1) KB(DEL) KB(S2) KB(LF) KB(S4) KB(S5) KB(BW) KB(BS)
*/
- uint8_t* m_madr_a91;
+ std::unique_ptr<uint8_t[]> m_madr_a91;
/**
* @brief ALU function to 74181 operation lookup PROM
*/
- uint8_t* m_alu_a10;
+ std::unique_ptr<uint8_t[]> m_alu_a10;
//! output lines of the ALU a10 PROM
enum {
diff --git a/src/devices/machine/smartmed.cpp b/src/devices/machine/smartmed.cpp
index 5b2fc3bb882..0a7c8911571 100644
--- a/src/devices/machine/smartmed.cpp
+++ b/src/devices/machine/smartmed.cpp
@@ -100,7 +100,7 @@ nand_device::nand_device(const machine_config &mconfig, device_type type, const
*/
void nand_device::device_start()
{
- m_data_ptr = nullptr;
+ m_feeprom_data = nullptr;
m_data_uid_ptr = nullptr;
m_mode = SM_M_INIT;
m_pointer_mode = SM_PM_A;
@@ -140,7 +140,8 @@ image_init_result smartmedia_image_device::smartmedia_format_1()
m_page_total_size = get_UINT32BE(custom_header.page_total_size);
m_num_pages = get_UINT32BE(custom_header.num_pages);
m_log2_pages_per_block = get_UINT32BE(custom_header.log2_pages_per_block);
- m_data_ptr = auto_alloc_array(machine(), uint8_t, m_page_total_size*m_num_pages);
+ m_feeprom_data_alloc = std::make_unique<uint8_t[]>(m_page_total_size*m_num_pages);
+ m_feeprom_data = &m_feeprom_data_alloc[0];
m_data_uid_ptr = std::make_unique<uint8_t[]>(256 + 16);
m_mode = SM_M_INIT;
m_pointer_mode = SM_PM_A;
@@ -170,7 +171,7 @@ image_init_result smartmedia_image_device::smartmedia_format_1()
fread(&m_mp_opcode, 1);
fread(m_data_uid_ptr.get(), 256 + 16);
}
- fread(m_data_ptr, m_page_total_size*m_num_pages);
+ fread(m_feeprom_data, m_page_total_size*m_num_pages);
#ifdef SMARTMEDIA_IMAGE_SAVE
m_image_format = 1;
@@ -235,7 +236,8 @@ image_init_result smartmedia_image_device::smartmedia_format_2()
return image_init_result::FAIL;
}
- m_data_ptr = auto_alloc_array(machine(), uint8_t, m_page_total_size * m_num_pages);
+ m_feeprom_data_alloc = std::make_unique<uint8_t[]>(m_page_total_size*m_num_pages);
+ m_feeprom_data = &m_feeprom_data_alloc[0];
m_data_uid_ptr = std::make_unique<uint8_t[]>(256 + 16);
m_mode = SM_M_INIT;
m_pointer_mode = SM_PM_A;
@@ -261,7 +263,7 @@ image_init_result smartmedia_image_device::smartmedia_format_2()
}
memcpy(m_data_uid_ptr.get() + 256, custom_header.data3, 16);
- fread(m_data_ptr, m_page_total_size * m_num_pages);
+ fread(m_feeprom_data, m_page_total_size*m_num_pages);
#ifdef SMARTMEDIA_IMAGE_SAVE
m_image_format = 2;
@@ -303,20 +305,20 @@ void smartmedia_image_device::call_unload()
{
if (custom_header.version == 0)
{
- fseek(2 + 1, SEEK_CUR);
- fwrite(m_data_ptr, m_page_total_size * m_num_pages);
+ fseek( 2 + 1, SEEK_CUR);
+ fwrite( m_feeprom_data, m_page_total_size * m_num_pages);
}
else if (custom_header.version == 1)
{
- fseek(3 + 1 + 256 + 16, SEEK_CUR);
- fwrite(m_data_ptr, m_page_total_size * m_num_pages);
+ fseek( 3 + 1 + 256 + 16, SEEK_CUR);
+ fwrite( m_feeprom_data, m_page_total_size * m_num_pages);
}
}
}
else if (m_image_format == 2)
{
- fseek(sizeof(disk_image_format_2_header), SEEK_SET);
- fwrite(m_data_ptr, m_page_total_size * m_num_pages);
+ fseek( sizeof( disk_image_format_2_header), SEEK_SET);
+ fwrite( m_feeprom_data, m_page_total_size * m_num_pages);
}
}
#endif
@@ -325,7 +327,7 @@ void smartmedia_image_device::call_unload()
m_page_total_size = 0;
m_num_pages = 0;
m_log2_pages_per_block = 0;
- m_data_ptr = nullptr;
+ m_feeprom_data = nullptr;
m_data_uid_ptr = nullptr;
m_mode = SM_M_INIT;
m_pointer_mode = SM_PM_A;
@@ -366,7 +368,7 @@ int nand_device::is_busy()
void nand_device::set_data_ptr(void *ptr)
{
- m_data_ptr = (uint8_t *)ptr;
+ m_feeprom_data = (uint8_t *)ptr;
}
/*
@@ -444,7 +446,7 @@ void nand_device::command_w(uint8_t data)
m_status = (m_status & 0x80) | m_accumulated_status;
//logerror( "smartmedia: program, page_addr %08X\n", m_page_addr);
for (int i = 0; i < m_page_total_size; i++)
- m_data_ptr[m_page_addr * m_page_total_size + i] &= m_pagereg[i];
+ m_feeprom_data[m_page_addr * m_page_total_size + i] &= m_pagereg[i];
m_status |= 0x40;
if (data == 0x15)
m_accumulated_status = m_status & 0x1f;
@@ -474,7 +476,7 @@ void nand_device::command_w(uint8_t data)
else
{
m_status &= 0x80;
- memset(m_data_ptr + ((m_page_addr & (-1 << m_log2_pages_per_block)) * m_page_total_size), 0xFF, (size_t)(1 << m_log2_pages_per_block) * m_page_total_size);
+ memset(m_feeprom_data + ((m_page_addr & (-1 << m_log2_pages_per_block)) * m_page_total_size), 0xFF, (size_t)(1 << m_log2_pages_per_block) * m_page_total_size);
//logerror( "smartmedia: erase, page_addr %08X, offset %08X, length %08X\n", m_page_addr, (m_page_addr & (-1 << m_log2_pages_per_block)) * m_page_total_size, (1 << m_log2_pages_per_block) * m_page_total_size);
m_status |= 0x40;
m_mode = SM_M_INIT;
@@ -679,7 +681,7 @@ uint8_t nand_device::data_r()
if (m_byte_addr < m_page_total_size)
{
if (m_page_addr < m_num_pages)
- reply = m_data_ptr[m_page_addr * m_page_total_size + m_byte_addr];
+ reply = m_feeprom_data[m_page_addr * m_page_total_size + m_byte_addr];
else
reply = 0xff;
}
diff --git a/src/devices/machine/smartmed.h b/src/devices/machine/smartmed.h
index 708449cd36a..3c9eeeca54e 100644
--- a/src/devices/machine/smartmed.h
+++ b/src/devices/machine/smartmed.h
@@ -156,7 +156,8 @@ protected:
// 0 means no card loaded
int m_log2_pages_per_block; // log2 of number of pages per erase block (usually 4 or 5)
- uint8_t* m_data_ptr; // FEEPROM data area
+ uint8_t *m_feeprom_data; // FEEPROM data area
+ std::unique_ptr<uint8_t[]> m_feeprom_data_alloc;
std::unique_ptr<uint8_t[]> m_data_uid_ptr;
sm_mode_t m_mode; // current operation mode
diff --git a/src/devices/machine/sonydriv.cpp b/src/devices/machine/sonydriv.cpp
index 8f23a832c36..d65c1146359 100644
--- a/src/devices/machine/sonydriv.cpp
+++ b/src/devices/machine/sonydriv.cpp
@@ -77,7 +77,7 @@ struct floppy_t
unsigned int loadedtrack_dirty : 1; /* has data in track buffer been modified? */
size_t loadedtrack_size; /* size of loaded track */
size_t loadedtrack_pos; /* position within loaded track */
- uint8_t *loadedtrack_data; /* pointer to track buffer */
+ std::vector<uint8_t> loadedtrack_data; /* pointer to track buffer */
int is_fdhd; /* is drive an FDHD? */
int is_400k; /* drive is single-sided, which means 400K */
@@ -149,7 +149,6 @@ static void load_track_data(device_t *device,int floppy_select)
{
int track_size;
legacy_floppy_image_device *cur_image;
- uint8_t *new_data;
floppy_t *f;
f = &sony.floppy[floppy_select];
@@ -163,36 +162,29 @@ static void load_track_data(device_t *device,int floppy_select)
}
track_size = floppy_get_track_size(fimg, f->head, cur_image->floppy_drive_get_current_track());
- if (f->loadedtrack_data) auto_free(device->machine(),f->loadedtrack_data);
- new_data = auto_alloc_array(device->machine(),uint8_t,track_size);
- if (!new_data)
- {
- return;
- }
-
- cur_image->floppy_drive_read_track_data_info_buffer(f->head, new_data, &track_size);
+ f->loadedtrack_data.resize(track_size);
+ cur_image->floppy_drive_read_track_data_info_buffer(f->head, &f->loadedtrack_data[0], &track_size);
f->loadedtrack_valid = 1;
f->loadedtrack_dirty = 0;
f->loadedtrack_size = track_size;
- f->loadedtrack_data = new_data;
f->loadedtrack_pos = 0;
}
-static void save_track_data(device_t *device, int floppy_select)
+static void save_track_data(running_machine &machine, int floppy_select)
{
legacy_floppy_image_device *cur_image;
floppy_t *f;
int len;
f = &sony.floppy[floppy_select];
- cur_image = floppy_get_device_by_type(device->machine(), FLOPPY_TYPE_SONY, floppy_select);
+ cur_image = floppy_get_device_by_type(machine, FLOPPY_TYPE_SONY, floppy_select);
if (f->loadedtrack_dirty)
{
len = f->loadedtrack_size;
- cur_image->floppy_drive_write_track_data_info_buffer(f->head, f->loadedtrack_data, &len);
+ cur_image->floppy_drive_write_track_data_info_buffer(f->head, &f->loadedtrack_data[0], &len);
f->loadedtrack_dirty = 0;
}
}
@@ -216,12 +208,12 @@ uint8_t sony_read_data(device_t *device)
if (!f->loadedtrack_valid)
load_track_data(device, sony.floppy_select);
- if (!f->loadedtrack_data)
+ if (f->loadedtrack_data.empty())
{
return 0xFF;
}
- result = sony_fetchtrack(f->loadedtrack_data, f->loadedtrack_size, &f->loadedtrack_pos);
+ result = sony_fetchtrack(&f->loadedtrack_data[0], f->loadedtrack_size, &f->loadedtrack_pos);
return result;
}
@@ -240,12 +232,12 @@ void sony_write_data(device_t *device,uint8_t data)
if (!f->loadedtrack_valid)
load_track_data(device,sony.floppy_select);
- if (!f->loadedtrack_data)
+ if (f->loadedtrack_data.empty())
{
return;
}
- sony_filltrack(f->loadedtrack_data, f->loadedtrack_size, &f->loadedtrack_pos, data);
+ sony_filltrack(&f->loadedtrack_data[0], f->loadedtrack_size, &f->loadedtrack_pos, data);
f->loadedtrack_dirty = 1;
}
@@ -333,7 +325,7 @@ int sony_read_status(device_t *device)
case 0x01: /* Lower head activate */
if (f->head != 0)
{
- save_track_data(device,sony.floppy_select);
+ save_track_data(device->machine(),sony.floppy_select);
f->head = 0;
f->loadedtrack_valid = 0;
}
@@ -345,7 +337,7 @@ int sony_read_status(device_t *device)
case 0x03: /* Upper head activate (not on 400k) */
if ((f->head != 1) && !(f->is_400k))
{
- save_track_data(device,sony.floppy_select);
+ save_track_data(device->machine(),sony.floppy_select);
f->head = 1;
f->loadedtrack_valid = 0;
}
@@ -482,7 +474,7 @@ static void sony_doaction(device_t *device)
case 0x04: /* Step disk */
if (cur_image)
{
- save_track_data(device,sony.floppy_select);
+ save_track_data(device->machine(),sony.floppy_select);
if (f->step)
cur_image->floppy_drive_seek(-1);
else
@@ -599,8 +591,8 @@ void sonydriv_floppy_image_device::device_start()
sony.floppy[1].is_fdhd = 0;
sony.floppy[0].is_400k = 0;
sony.floppy[1].is_400k = 0;
- sony.floppy[0].loadedtrack_data = nullptr;
- sony.floppy[1].loadedtrack_data = nullptr;
+ sony.floppy[0].loadedtrack_data.clear();
+ sony.floppy[1].loadedtrack_data.clear();
sony.floppy[0].head = 0;
sony.floppy[1].head = 0;
sony.rotation_speed = 0;
@@ -609,13 +601,9 @@ void sonydriv_floppy_image_device::device_start()
void sonydriv_floppy_image_device::call_unload()
{
int id;
- device_t *fdc;
-
- /* locate the FDC */
- fdc = machine().device("fdc");
id = floppy_get_drive_by_type(this,FLOPPY_TYPE_SONY);
- save_track_data(fdc, id);
+ save_track_data(machine(), id);
memset(&sony.floppy[id], 0, sizeof(sony.floppy[id]));
legacy_floppy_image_device::call_unload();
diff --git a/src/devices/video/polylgcy.cpp b/src/devices/video/polylgcy.cpp
index e605220ffbf..0f6c206e76c 100644
--- a/src/devices/video/polylgcy.cpp
+++ b/src/devices/video/polylgcy.cpp
@@ -150,7 +150,7 @@ struct legacy_poly_manager
osd_work_queue * queue; /* work queue */
/* triangle work units */
- work_unit ** unit; /* array of work unit pointers */
+ std::vector<work_unit *> unit; /* array of work unit pointers */
uint32_t unit_next; /* index of next unit to allocate */
uint32_t unit_count; /* number of work units available */
size_t unit_size; /* size of each work unit, in bytes */
@@ -161,13 +161,13 @@ struct legacy_poly_manager
size_t quadunit_size; /* size of each work unit, in bytes */
/* poly data */
- polygon_info ** polygon; /* array of polygon pointers */
+ std::vector<polygon_info *> polygon; /* array of polygon pointers */
uint32_t polygon_next; /* index of next polygon to allocate */
uint32_t polygon_count; /* number of polygon items available */
size_t polygon_size; /* size of each polygon, in bytes */
/* extra data */
- void ** extra; /* array of extra data pointers */
+ std::vector<void *> extra; /* array of extra data pointers */
uint32_t extra_next; /* index of next extra data to allocate */
uint32_t extra_count; /* number of extra data items available */
size_t extra_size; /* size of each extra data, in bytes */
@@ -192,6 +192,10 @@ struct legacy_poly_manager
uint32_t conflicts[WORK_MAX_THREADS]; /* number of conflicts found, per thread */
uint32_t resolved[WORK_MAX_THREADS]; /* number of conflicts resolved, per thread */
#endif
+
+ std::vector<uint8_t> m_work_unit_alloc;
+ std::vector<uint8_t> m_polygon_alloc;
+ std::vector<uint8_t> m_extra_alloc;
};
@@ -200,7 +204,6 @@ struct legacy_poly_manager
FUNCTION PROTOTYPES
***************************************************************************/
-static void **allocate_array(running_machine &machine, size_t *itemsize, uint32_t itemcount);
static void *poly_item_callback(void *param, int threadid);
static void poly_state_presave(legacy_poly_manager &poly);
@@ -311,36 +314,74 @@ static inline polygon_info *allocate_polygon(legacy_poly_manager *poly, int miny
INITIALIZATION/TEARDOWN
***************************************************************************/
+legacy_poly_manager_owner::legacy_poly_manager_owner() : m_poly(nullptr)
+{
+}
+
+
+legacy_poly_manager_owner::~legacy_poly_manager_owner()
+{
+ delete m_poly;
+}
+
+/*-------------------------------------------------
+ allocate_array - allocate an array of pointers
+-------------------------------------------------*/
+
+template<typename T>
+static void allocate_array(running_machine &machine, std::vector<uint8_t> &buffer, std::vector<T *> &ptrarray, size_t *itemsize, uint32_t itemcount)
+{
+ int itemnum;
+
+ /* fail if 0 */
+ if (itemcount == 0)
+ return;
+
+ /* round to a cache line boundary */
+ *itemsize = ((*itemsize + CACHE_LINE_SIZE - 1) / CACHE_LINE_SIZE) * CACHE_LINE_SIZE;
+
+ /* allocate the array */
+ ptrarray.resize(itemcount);
+
+ /* allocate the actual items */
+ buffer.resize(*itemsize * itemcount);
+
+ /* initialize the pointer array */
+ for (itemnum = 0; itemnum < itemcount; itemnum++)
+ ptrarray[itemnum] = reinterpret_cast<T *>(&buffer[*itemsize * itemnum]);
+}
+
+
+
/*-------------------------------------------------
poly_alloc - initialize a new polygon
manager
-------------------------------------------------*/
-legacy_poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t extra_data_size, uint8_t flags)
+void poly_alloc(legacy_poly_manager_owner &owner, running_machine &machine, int max_polys, size_t extra_data_size, uint8_t flags)
{
- legacy_poly_manager *poly;
-
/* allocate the manager itself */
- poly = auto_alloc_clear(machine, <legacy_poly_manager>());
+ legacy_poly_manager *poly = new legacy_poly_manager;
+ owner.m_poly = poly;
poly->flags = flags;
/* allocate polygons */
poly->polygon_size = sizeof(polygon_info);
poly->polygon_count = std::max(max_polys, 1);
poly->polygon_next = 0;
- poly->polygon = (polygon_info **)allocate_array(machine, &poly->polygon_size, poly->polygon_count);
+ allocate_array(machine, poly->m_polygon_alloc, poly->polygon, &poly->polygon_size, poly->polygon_count);
/* allocate extra data */
poly->extra_size = extra_data_size;
poly->extra_count = poly->polygon_count;
poly->extra_next = 1;
- poly->extra = allocate_array(machine, &poly->extra_size, poly->extra_count);
+ allocate_array(machine, poly->m_extra_alloc, poly->extra, &poly->extra_size, poly->extra_count);
/* allocate triangle work units */
poly->unit_size = (flags & POLYLGCY_FLAG_ALLOW_QUADS) ? sizeof(quad_work_unit) : sizeof(tri_work_unit);
poly->unit_count = std::min(poly->polygon_count * UNITS_PER_POLY, 65535U);
poly->unit_next = 0;
- poly->unit = (work_unit **)allocate_array(machine, &poly->unit_size, poly->unit_count);
+ allocate_array(machine, poly->m_work_unit_alloc, poly->unit, &poly->unit_size, poly->unit_count);
/* create the work queue */
if (!(flags & POLYLGCY_FLAG_NO_WORK_QUEUE))
@@ -348,7 +389,6 @@ legacy_poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t
/* request a pre-save callback for synchronization */
machine.save().register_presave(save_prepost_delegate(FUNC(poly_state_presave), poly));
- return poly;
}
@@ -1254,35 +1294,6 @@ int poly_zclip_if_less(int numverts, const poly_vertex *v, poly_vertex *outv, in
***************************************************************************/
/*-------------------------------------------------
- allocate_array - allocate an array of pointers
--------------------------------------------------*/
-
-static void **allocate_array(running_machine &machine, size_t *itemsize, uint32_t itemcount)
-{
- void **ptrarray;
- int itemnum;
-
- /* fail if 0 */
- if (itemcount == 0)
- return nullptr;
-
- /* round to a cache line boundary */
- *itemsize = ((*itemsize + CACHE_LINE_SIZE - 1) / CACHE_LINE_SIZE) * CACHE_LINE_SIZE;
-
- /* allocate the array */
- ptrarray = auto_alloc_array_clear(machine, void *, itemcount);
-
- /* allocate the actual items */
- ptrarray[0] = auto_alloc_array_clear(machine, uint8_t, *itemsize * itemcount);
-
- /* initialize the pointer array */
- for (itemnum = 1; itemnum < itemcount; itemnum++)
- ptrarray[itemnum] = (uint8_t *)ptrarray[0] + *itemsize * itemnum;
- return ptrarray;
-}
-
-
-/*-------------------------------------------------
poly_item_callback - callback for each poly
item
-------------------------------------------------*/
diff --git a/src/devices/video/polylgcy.h b/src/devices/video/polylgcy.h
index 142ca5c073b..c8079b93816 100644
--- a/src/devices/video/polylgcy.h
+++ b/src/devices/video/polylgcy.h
@@ -58,6 +58,16 @@ static constexpr uint8_t POLYLGCY_FLAG_ALLOW_QUADS = 0x08;
/* opaque reference to the poly manager */
struct legacy_poly_manager;
+class legacy_poly_manager_owner
+{
+public:
+ legacy_poly_manager_owner();
+ ~legacy_poly_manager_owner();
+
+ operator legacy_poly_manager *() { return m_poly; }
+
+ legacy_poly_manager *m_poly;
+};
/* input vertex data */
@@ -99,7 +109,7 @@ typedef void (*poly_draw_scanline_func)(void *dest, int32_t scanline, const poly
/* ----- initialization/teardown ----- */
/* allocate a new poly manager that can render triangles */
-legacy_poly_manager *poly_alloc(running_machine &machine, int max_polys, size_t extra_data_size, uint8_t flags);
+void poly_alloc(legacy_poly_manager_owner &owner, running_machine &machine, int max_polys, size_t extra_data_size, uint8_t flags);
/* free a poly manager */
void poly_free(legacy_poly_manager *poly);
diff --git a/src/devices/video/tms34061.cpp b/src/devices/video/tms34061.cpp
index d324fe91200..16d7ba65fa8 100644
--- a/src/devices/video/tms34061.cpp
+++ b/src/devices/video/tms34061.cpp
@@ -64,14 +64,14 @@ void tms34061_device::device_start()
m_vrammask = m_vramsize - 1;
/* allocate memory for VRAM */
- m_vram = auto_alloc_array_clear(machine(), u8, m_vramsize + 256 * 2);
+ m_vram_alloc = std::make_unique<u8[]>(m_vramsize + 256 * 2);
/* allocate memory for latch RAM */
- m_latchram = auto_alloc_array_clear(machine(), u8, m_vramsize + 256 * 2);
+ m_latchram_alloc = std::make_unique<u8[]>(m_vramsize + 256 * 2);
/* add some buffer space for VRAM and latch RAM */
- m_vram += 256;
- m_latchram += 256;
+ m_vram = &m_vram_alloc[256];
+ m_latchram = &m_latchram_alloc[256];
/* point the shift register to the base of VRAM for now */
m_shiftreg = m_vram;
diff --git a/src/devices/video/tms34061.h b/src/devices/video/tms34061.h
index 3b3e3d5f552..47cd6e68c60 100644
--- a/src/devices/video/tms34061.h
+++ b/src/devices/video/tms34061.h
@@ -99,6 +99,8 @@ private:
u8 m_latchdata;
u8 * m_shiftreg;
emu_timer * m_timer;
+ std::unique_ptr<u8[]> m_vram_alloc;
+ std::unique_ptr<u8[]> m_latchram_alloc;
void update_interrupts();
TIMER_CALLBACK_MEMBER( interrupt );
diff --git a/src/devices/video/voodoo.cpp b/src/devices/video/voodoo.cpp
index dc028f656a3..2b57e67e3de 100644
--- a/src/devices/video/voodoo.cpp
+++ b/src/devices/video/voodoo.cpp
@@ -5652,7 +5652,7 @@ void voodoo_device::device_start()
m_pciint.resolve();
/* create a multiprocessor work queue */
- poly = poly_alloc(machine(), 64, sizeof(poly_extra_data), 0);
+ poly_alloc(poly, machine(), 64, sizeof(poly_extra_data), 0);
thread_stats = std::make_unique<stats_block[]>(WORK_MAX_THREADS);
/* create a table of precomputed 1/n and log2(n) values */
@@ -6477,7 +6477,6 @@ voodoo_device::voodoo_device(const machine_config &mconfig, device_type type, co
, regaccess(nullptr)
, regnames(nullptr)
, alt_regmap(0)
- , poly(nullptr)
, thread_stats(nullptr)
, last_status_pc(0)
, last_status_value(0)
diff --git a/src/devices/video/voodoo.h b/src/devices/video/voodoo.h
index 1be7f0a1a85..e33928ce78b 100644
--- a/src/devices/video/voodoo.h
+++ b/src/devices/video/voodoo.h
@@ -1337,7 +1337,7 @@ public:
tmu_shared_state tmushare; // TMU shared state
banshee_info banshee; // Banshee state
- legacy_poly_manager * poly; // polygon manager
+ legacy_poly_manager_owner poly; // polygon manager
std::unique_ptr<stats_block[]> thread_stats; // per-thread statistics
voodoo_stats stats; // internal statistics