summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaronsgiles@users.noreply.github.com>2021-06-22 00:58:05 -0700
committer GitHub <noreply@github.com>2021-06-22 09:58:05 +0200
commit9b7f0f499f0fedf9176499b0a8710736e20f6e6f (patch)
tree821ea3c25328d8ae1718d9ddc525854840f5205e
parent86d1ef260440adbd0db84a897d624383f23526ed (diff)
Eliminate remaining uses of auto_alloc and friends (#8210)
* Split off auto_alloc changes from deprecated branch. * Make the keymap reader non-static so it can access the unique_ptr. * Fix SDL input for real.
-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
-rw-r--r--src/emu/machine.h16
-rw-r--r--src/mame/audio/acan.cpp9
-rw-r--r--src/mame/audio/acan.h1
-rw-r--r--src/mame/audio/exidy440.cpp59
-rw-r--r--src/mame/audio/exidy440.h10
-rw-r--r--src/mame/drivers/aquarium.cpp13
-rw-r--r--src/mame/drivers/cobra.cpp34
-rw-r--r--src/mame/drivers/cps3.cpp6
-rw-r--r--src/mame/drivers/crystal.cpp9
-rw-r--r--src/mame/drivers/freekick.cpp16
-rw-r--r--src/mame/drivers/mitchell.cpp8
-rw-r--r--src/mame/drivers/ninjakd2.cpp6
-rw-r--r--src/mame/drivers/pc6001.cpp6
-rw-r--r--src/mame/drivers/pc88va.cpp6
-rw-r--r--src/mame/drivers/qix.cpp16
-rw-r--r--src/mame/drivers/segae.cpp9
-rw-r--r--src/mame/drivers/slapshot.cpp6
-rw-r--r--src/mame/drivers/taito_f2.cpp6
-rw-r--r--src/mame/drivers/taito_f3.cpp14
-rw-r--r--src/mame/etc/fddebug.cpp4
-rw-r--r--src/mame/includes/aquarium.h3
-rw-r--r--src/mame/includes/cps3.h2
-rw-r--r--src/mame/includes/freekick.h1
-rw-r--r--src/mame/includes/hp48.h2
-rw-r--r--src/mame/includes/jedi.h5
-rw-r--r--src/mame/includes/konamigx.h7
-rw-r--r--src/mame/includes/mitchell.h1
-rw-r--r--src/mame/includes/model3.h57
-rw-r--r--src/mame/includes/n64.h5
-rw-r--r--src/mame/includes/namcos22.h3
-rw-r--r--src/mame/includes/ninjakd2.h2
-rw-r--r--src/mame/includes/pc6001.h3
-rw-r--r--src/mame/includes/pc88va.h2
-rw-r--r--src/mame/includes/qix.h2
-rw-r--r--src/mame/includes/slapshot.h1
-rw-r--r--src/mame/includes/taito_f2.h1
-rw-r--r--src/mame/includes/taito_f3.h2
-rw-r--r--src/mame/includes/tatsumi.h1
-rw-r--r--src/mame/includes/wecleman.h11
-rw-r--r--src/mame/machine/atarigen.cpp6
-rw-r--r--src/mame/machine/atarigen.h2
-rw-r--r--src/mame/machine/hp48.cpp18
-rw-r--r--src/mame/video/jedi.cpp12
-rw-r--r--src/mame/video/k001005.cpp2
-rw-r--r--src/mame/video/k001005.h2
-rw-r--r--src/mame/video/k053246_k053247_k055673.cpp3
-rw-r--r--src/mame/video/k053246_k053247_k055673.h2
-rw-r--r--src/mame/video/konamigx.cpp15
-rw-r--r--src/mame/video/model3.cpp64
-rw-r--r--src/mame/video/n64.cpp6
-rw-r--r--src/mame/video/n64.h3
-rw-r--r--src/mame/video/namcos22.cpp4
-rw-r--r--src/mame/video/pc6001.cpp39
-rw-r--r--src/mame/video/tatsumi.cpp8
-rw-r--r--src/mame/video/tc0100scn.cpp6
-rw-r--r--src/mame/video/tc0100scn.h1
-rw-r--r--src/mame/video/wecleman.cpp45
-rw-r--r--src/osd/modules/input/input_sdl.cpp14
74 files changed, 416 insertions, 471 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
diff --git a/src/emu/machine.h b/src/emu/machine.h
index e7988010d89..39e09d9fb89 100644
--- a/src/emu/machine.h
+++ b/src/emu/machine.h
@@ -62,18 +62,6 @@ constexpr int DEBUG_FLAG_OSD_ENABLED = 0x00001000; // The OSD debugger
//**************************************************************************
-// MACROS
-//**************************************************************************
-
-// global allocation helpers
-#define auto_alloc(m, t) pool_alloc(static_cast<running_machine &>(m).respool(), t)
-#define auto_alloc_clear(m, t) pool_alloc_clear(static_cast<running_machine &>(m).respool(), t)
-#define auto_alloc_array(m, t, c) pool_alloc_array(static_cast<running_machine &>(m).respool(), t, c)
-#define auto_alloc_array_clear(m, t, c) pool_alloc_array_clear(static_cast<running_machine &>(m).respool(), t, c)
-#define auto_free(m, v) pool_free(static_cast<running_machine &>(m).respool(), v)
-
-
-//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@@ -125,9 +113,6 @@ class running_machine
typedef std::function<void (const char*)> logerror_callback;
- // must be at top of member variables
- resource_pool m_respool; // pool of resources for this machine
-
public:
// construction/destruction
running_machine(const machine_config &config, machine_manager &manager);
@@ -139,7 +124,6 @@ public:
const game_driver &system() const { return m_system; }
osd_interface &osd() const;
machine_manager &manager() const { return m_manager; }
- [[deprecated("use smart pointers to manage object lifecycles")]] resource_pool &respool() { return m_respool; }
device_scheduler &scheduler() { return m_scheduler; }
save_manager &save() { return m_save; }
memory_manager &memory() { return m_memory; }
diff --git a/src/mame/audio/acan.cpp b/src/mame/audio/acan.cpp
index 2f53ca751b2..b881f2e65ac 100644
--- a/src/mame/audio/acan.cpp
+++ b/src/mame/audio/acan.cpp
@@ -34,6 +34,7 @@ acan_sound_device::acan_sound_device(const machine_config &mconfig, const char *
void acan_sound_device::device_start()
{
m_stream = stream_alloc(0, 2, clock() / 16 / 5);
+ m_mix = std::make_unique<int32_t[]>((clock() / 16 / 5) * 2);
m_timer = timer_alloc(0);
m_timer_irq_handler.resolve_safe();
@@ -84,16 +85,14 @@ void acan_sound_device::device_timer(emu_timer &timer, device_timer_id id, int p
void acan_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- int32_t mix[(clock() / 16 / 5) * 2];
-
- std::fill_n(&mix[0], outputs[0].samples() * 2, 0);
+ std::fill_n(&m_mix[0], outputs[0].samples() * 2, 0);
for (int i = 0; i < 16 && m_active_channels != 0; i++)
{
if (BIT(m_active_channels, i))
{
acan_channel &channel = m_channels[i];
- int32_t *mixp = &mix[0];
+ int32_t *mixp = &m_mix[0];
for (int s = 0; s < outputs[0].samples(); s++)
{
@@ -127,7 +126,7 @@ void acan_sound_device::sound_stream_update(sound_stream &stream, std::vector<re
}
}
- int32_t *mixp = &mix[0];
+ int32_t *mixp = &m_mix[0];
for (int i = 0; i < outputs[0].samples(); i++)
{
outputs[0].put_int(i, *mixp++, 32768 << 4);
diff --git a/src/mame/audio/acan.h b/src/mame/audio/acan.h
index 72aaa729ad9..0f6ac312a2d 100644
--- a/src/mame/audio/acan.h
+++ b/src/mame/audio/acan.h
@@ -61,6 +61,7 @@ private:
uint16_t m_dma_channels;
acan_channel m_channels[16];
uint8_t m_regs[256];
+ std::unique_ptr<int32_t[]> m_mix;
};
DECLARE_DEVICE_TYPE(ACANSND, acan_sound_device)
diff --git a/src/mame/audio/exidy440.cpp b/src/mame/audio/exidy440.cpp
index a5a40cae628..7d92dd02b8e 100644
--- a/src/mame/audio/exidy440.cpp
+++ b/src/mame/audio/exidy440.cpp
@@ -21,7 +21,6 @@
/* internal caching */
-#define MAX_CACHE_ENTRIES 1024 /* maximum separate samples we expect to ever see */
#define SAMPLE_BUFFER_LENGTH 1024 /* size of temporary decode buffer on the stack */
/* FIR digital filter parameters */
@@ -74,9 +73,6 @@ exidy440_sound_device::exidy440_sound_device(const machine_config &mconfig, cons
m_samples(*this, "samples"),
m_sound_command(0),
m_sound_command_ack(0),
- m_sound_cache(nullptr),
- m_sound_cache_end(nullptr),
- m_sound_cache_max(nullptr),
m_m6844_priority(0x00),
m_m6844_interrupt(0x00),
m_m6844_chain(0x00),
@@ -116,7 +112,7 @@ void exidy440_sound_device::device_add_mconfig(machine_config &config)
void exidy440_sound_device::device_start()
{
- int i, length;
+ int i;
/* reset the system */
m_sound_command = 0;
@@ -146,14 +142,6 @@ void exidy440_sound_device::device_start()
/* get stream channels */
m_stream = stream_alloc(0, 2, clock());
- /* allocate the sample cache */
- length = m_samples.bytes() * 16 + MAX_CACHE_ENTRIES * sizeof(sound_cache_entry);
- m_sound_cache = (sound_cache_entry *)auto_alloc_array_clear(machine(), uint8_t, length);
-
- /* determine the hard end of the cache and reset */
- m_sound_cache_max = (sound_cache_entry *)((uint8_t *)m_sound_cache + length);
- reset_sound_cache();
-
/* allocate the mixer buffer */
m_mixer_buffer_left.resize(clock()/50);
m_mixer_buffer_right.resize(clock()/50);
@@ -545,46 +533,26 @@ void exidy440_sound_device::m6844_w(offs_t offset, uint8_t data)
*
*************************************/
-void exidy440_sound_device::reset_sound_cache()
-{
- m_sound_cache_end = m_sound_cache;
-}
-
-
int16_t *exidy440_sound_device::add_to_sound_cache(uint8_t *input, int address, int length, int bits, int frequency)
{
- sound_cache_entry *current = m_sound_cache_end;
-
- /* compute where the end will be once we add this entry */
- m_sound_cache_end = (sound_cache_entry *)((uint8_t *)current + sizeof(sound_cache_entry) + length * 16);
-
- /* if this will overflow the cache, reset and re-add */
- if (m_sound_cache_end > m_sound_cache_max)
- {
- reset_sound_cache();
- return add_to_sound_cache(input, address, length, bits, frequency);
- }
-
/* fill in this entry */
- current->next = m_sound_cache_end;
- current->address = address;
- current->length = length;
- current->bits = bits;
- current->frequency = frequency;
+ auto &current = m_sound_cache.emplace_back();
+ current.address = address;
+ current.length = length;
+ current.bits = bits;
+ current.frequency = frequency;
/* decode the data into the cache */
- decode_and_filter_cvsd(input, length, bits, frequency, current->data);
- return current->data;
+ decode_and_filter_cvsd(input, length, bits, frequency, current.data);
+ return &current.data[0];
}
int16_t *exidy440_sound_device::find_or_add_to_sound_cache(int address, int length, int bits, int frequency)
{
- sound_cache_entry *current;
-
- for (current = m_sound_cache; current < m_sound_cache_end; current = current->next)
- if (current->address == address && current->length == length && current->bits == bits && current->frequency == frequency)
- return current->data;
+ for (auto &current : m_sound_cache)
+ if (current.address == address && current.length == length && current.bits == bits && current.frequency == frequency)
+ return &current.data[0];
return add_to_sound_cache(&m_samples[address], address, length, bits, frequency);
}
@@ -698,7 +666,7 @@ void exidy440_sound_device::fir_filter(int32_t *input, int16_t *output, int coun
*
*************************************/
-void exidy440_sound_device::decode_and_filter_cvsd(uint8_t *input, int bytes, int maskbits, int frequency, int16_t *output)
+void exidy440_sound_device::decode_and_filter_cvsd(uint8_t *input, int bytes, int maskbits, int frequency, std::vector<int16_t> &output)
{
int32_t buffer[SAMPLE_BUFFER_LENGTH + FIR_HISTORY_LENGTH];
int total_samples = bytes * 8;
@@ -725,6 +693,7 @@ void exidy440_sound_device::decode_and_filter_cvsd(uint8_t *input, int bytes, in
integrator = 0.0;
/* loop over chunks */
+ output.resize(total_samples);
for (chunk_start = 0; chunk_start < total_samples; chunk_start += SAMPLE_BUFFER_LENGTH)
{
int32_t *bufptr = &buffer[FIR_HISTORY_LENGTH];
@@ -809,7 +778,7 @@ void exidy440_sound_device::decode_and_filter_cvsd(uint8_t *input, int bytes, in
int16_t *data;
chunk_start = (total_samples > 512) ? total_samples - 512 : 0;
- data = output + chunk_start;
+ data = &output[chunk_start];
for ( ; chunk_start < total_samples; chunk_start++)
{
*data = (*data * ((total_samples - chunk_start) >> 9));
diff --git a/src/mame/audio/exidy440.h b/src/mame/audio/exidy440.h
index e3920be90a2..6e2a56c0460 100644
--- a/src/mame/audio/exidy440.h
+++ b/src/mame/audio/exidy440.h
@@ -58,12 +58,11 @@ private:
/* sound_cache_entry structure contains info on each decoded sample */
struct sound_cache_entry
{
- struct sound_cache_entry *next;
int address;
int length;
int bits;
int frequency;
- int16_t data[1];
+ std::vector<int16_t> data;
};
required_device<cpu_device> m_audiocpu;
@@ -78,9 +77,7 @@ private:
uint8_t m_sound_volume[0x10];
std::vector<int32_t> m_mixer_buffer_left;
std::vector<int32_t> m_mixer_buffer_right;
- sound_cache_entry *m_sound_cache;
- sound_cache_entry *m_sound_cache_end;
- sound_cache_entry *m_sound_cache_max;
+ std::list<sound_cache_entry> m_sound_cache;
/* 6844 description */
m6844_channel_data m_m6844_channel[4];
@@ -103,11 +100,10 @@ private:
void play_cvsd(int ch);
void stop_cvsd(int ch);
- void reset_sound_cache();
int16_t *add_to_sound_cache(uint8_t *input, int address, int length, int bits, int frequency);
int16_t *find_or_add_to_sound_cache(int address, int length, int bits, int frequency);
- void decode_and_filter_cvsd(uint8_t *data, int bytes, int maskbits, int frequency, int16_t *dest);
+ void decode_and_filter_cvsd(uint8_t *data, int bytes, int maskbits, int frequency, std::vector<int16_t> &output);
void fir_filter(int32_t *input, int16_t *output, int count);
void add_and_scale_samples(int ch, int32_t *dest, int samples, int volume);
diff --git a/src/mame/drivers/aquarium.cpp b/src/mame/drivers/aquarium.cpp
index 0433ffcd5b5..f761c21728a 100644
--- a/src/mame/drivers/aquarium.cpp
+++ b/src/mame/drivers/aquarium.cpp
@@ -326,7 +326,7 @@ ROM_START( aquariumj )
ROM_LOAD( "excellent_4.7d", 0x000000, 0x80000, CRC(9a4af531) SHA1(bb201b7a6c9fd5924a0d79090257efffd8d4aba1) )
ROM_END
-void aquarium_state::expand_gfx(int low, int hi)
+std::unique_ptr<u8[]> aquarium_state::expand_gfx(int low, int hi)
{
/* The BG tiles are 5bpp, this rearranges the data from
the roms containing the 1bpp data so we can decode it
@@ -335,10 +335,10 @@ void aquarium_state::expand_gfx(int low, int hi)
gfx_element *gfx_h = m_gfxdecode->gfx(hi);
// allocate memory for the assembled data
- u8 *srcdata = auto_alloc_array(machine(), u8, gfx_l->elements() * gfx_l->width() * gfx_l->height());
+ auto decoded = std::make_unique<u8[]>(gfx_l->elements() * gfx_l->width() * gfx_l->height());
// loop over elements
- u8 *dest = srcdata;
+ u8 *dest = decoded.get();
for (int c = 0; c < gfx_l->elements(); c++)
{
const u8 *c0base = gfx_l->get_data(c);
@@ -360,15 +360,16 @@ void aquarium_state::expand_gfx(int low, int hi)
}
}
- gfx_l->set_raw_layout(srcdata, gfx_l->width(), gfx_l->height(), gfx_l->elements(), 8 * gfx_l->width(), 8 * gfx_l->width() * gfx_l->height());
+ gfx_l->set_raw_layout(decoded.get(), gfx_l->width(), gfx_l->height(), gfx_l->elements(), 8 * gfx_l->width(), 8 * gfx_l->width() * gfx_l->height());
gfx_l->set_granularity(32);
m_gfxdecode->set_gfx(hi, nullptr);
+ return decoded;
}
void aquarium_state::init_aquarium()
{
- expand_gfx(1, 4);
- expand_gfx(2, 3);
+ m_decoded_gfx[0] = expand_gfx(1, 4);
+ m_decoded_gfx[1] = expand_gfx(2, 3);
u8 *Z80 = memregion("audiocpu")->base();
diff --git a/src/mame/drivers/cobra.cpp b/src/mame/drivers/cobra.cpp
index 9fcd2d39ca6..541d27aeaf0 100644
--- a/src/mame/drivers/cobra.cpp
+++ b/src/mame/drivers/cobra.cpp
@@ -777,10 +777,10 @@ public:
std::unique_ptr<cobra_renderer> m_renderer;
- cobra_fifo *m_gfxfifo_in;
- cobra_fifo *m_gfxfifo_out;
- cobra_fifo *m_m2sfifo;
- cobra_fifo *m_s2mfifo;
+ std::unique_ptr<cobra_fifo> m_gfxfifo_in;
+ std::unique_ptr<cobra_fifo> m_gfxfifo_out;
+ std::unique_ptr<cobra_fifo> m_m2sfifo;
+ std::unique_ptr<cobra_fifo> m_s2mfifo;
void gfxfifo_in_event_callback(cobra_fifo::EventType event);
void gfxfifo_out_event_callback(cobra_fifo::EventType event);
@@ -2234,8 +2234,8 @@ void cobra_renderer::gfx_fifo_exec()
const rectangle& visarea = screen().visible_area();
vertex_t vert[32];
- cobra_fifo *fifo_in = cobra->m_gfxfifo_in;
- cobra_fifo *fifo_out = cobra->m_gfxfifo_out;
+ cobra_fifo *fifo_in = cobra->m_gfxfifo_in.get();
+ cobra_fifo *fifo_out = cobra->m_gfxfifo_out.get();
while (fifo_in->current_num() >= 2)
{
@@ -3080,7 +3080,7 @@ void cobra_state::gfx_cpu_dc_store(offs_t offset, uint32_t data)
if (addr == 0x10 || addr == 0x18 || addr == 0x1e)
{
uint64_t i = (uint64_t)(m_gfx_fifo_cache_addr) << 32;
- cobra_fifo *fifo_in = m_gfxfifo_in;
+ cobra_fifo *fifo_in = m_gfxfifo_in.get();
uint32_t a = (offset / 8) & 0xff;
@@ -3332,36 +3332,32 @@ void cobra_state::cobra(machine_config &config)
void cobra_state::init_cobra()
{
- m_gfxfifo_in = auto_alloc(machine(),
- cobra_fifo(machine(),
+ m_gfxfifo_in = std::make_unique<cobra_fifo>(machine(),
8192,
"GFXFIFO_IN",
GFXFIFO_IN_VERBOSE != 0,
- cobra_fifo::event_delegate(&cobra_state::gfxfifo_in_event_callback, this))
+ cobra_fifo::event_delegate(&cobra_state::gfxfifo_in_event_callback, this)
);
- m_gfxfifo_out = auto_alloc(machine(),
- cobra_fifo(machine(),
+ m_gfxfifo_out = std::make_unique<cobra_fifo>(machine(),
8192,
"GFXFIFO_OUT",
GFXFIFO_OUT_VERBOSE != 0,
- cobra_fifo::event_delegate(&cobra_state::gfxfifo_out_event_callback, this))
+ cobra_fifo::event_delegate(&cobra_state::gfxfifo_out_event_callback, this)
);
- m_m2sfifo = auto_alloc(machine(),
- cobra_fifo(machine(),
+ m_m2sfifo = std::make_unique<cobra_fifo>(machine(),
2048,
"M2SFIFO",
M2SFIFO_VERBOSE != 0,
- cobra_fifo::event_delegate(&cobra_state::m2sfifo_event_callback, this))
+ cobra_fifo::event_delegate(&cobra_state::m2sfifo_event_callback, this)
);
- m_s2mfifo = auto_alloc(machine(),
- cobra_fifo(machine(),
+ m_s2mfifo = std::make_unique<cobra_fifo>(machine(),
2048,
"S2MFIFO",
S2MFIFO_VERBOSE != 0,
- cobra_fifo::event_delegate(&cobra_state::s2mfifo_event_callback, this))
+ cobra_fifo::event_delegate(&cobra_state::s2mfifo_event_callback, this)
);
m_maincpu->ppc_set_dcstore_callback(write32sm_delegate(*this, FUNC(cobra_state::main_cpu_dc_store)));
diff --git a/src/mame/drivers/cps3.cpp b/src/mame/drivers/cps3.cpp
index 315b41a18dd..5708e0a6a18 100644
--- a/src/mame/drivers/cps3.cpp
+++ b/src/mame/drivers/cps3.cpp
@@ -887,7 +887,8 @@ void cps3_state::init_crypt(u32 key1, u32 key2, int altEncryption)
}
else
{
- m_user4 = auto_alloc_array(machine(), u8, USER4REGION_LENGTH);
+ m_user4_allocated = std::make_unique<u8[]>(USER4REGION_LENGTH);
+ m_user4 = m_user4_allocated.get();
}
if (m_user5_region)
@@ -896,7 +897,8 @@ void cps3_state::init_crypt(u32 key1, u32 key2, int altEncryption)
}
else
{
- m_user5 = auto_alloc_array(machine(), u8, USER5REGION_LENGTH);
+ m_user5_allocated = std::make_unique<u8[]>(USER5REGION_LENGTH);
+ m_user5 = m_user5_allocated.get();
}
m_cps3sound->set_base((s8*)m_user5);
diff --git a/src/mame/drivers/crystal.cpp b/src/mame/drivers/crystal.cpp
index 584afe59af9..7975089efcb 100644
--- a/src/mame/drivers/crystal.cpp
+++ b/src/mame/drivers/crystal.cpp
@@ -186,6 +186,7 @@ private:
uint32_t m_Bank;
uint32_t m_maxbank;
uint32_t m_FlashCmd;
+ std::unique_ptr<uint8_t[]> m_dummy_region;
uint32_t system_input_r();
void Banksw_w(uint32_t data);
@@ -365,15 +366,15 @@ void crystal_state::machine_start()
if (m_mainbank)
{
m_maxbank = (m_flash) ? m_flash.bytes() / 0x1000000 : 0;
- uint8_t *dummy_region = auto_alloc_array(machine(), uint8_t, 0x1000000);
- std::fill_n(&dummy_region[0], 0x1000000, 0xff); // 0xff Filled at Unmapped area
- uint8_t *ROM = (m_flash) ? (uint8_t *)&m_flash[0] : dummy_region;
+ m_dummy_region = std::make_unique<uint8_t[]>(0x1000000);
+ std::fill_n(&m_dummy_region[0], 0x1000000, 0xff); // 0xff Filled at Unmapped area
+ uint8_t *ROM = (m_flash) ? (uint8_t *)&m_flash[0] : &m_dummy_region[0];
for (int i = 0; i < 8; i++)
{
if ((i < m_maxbank))
m_mainbank->configure_entry(i, ROM + i * 0x1000000);
else
- m_mainbank->configure_entry(i, dummy_region);
+ m_mainbank->configure_entry(i, m_dummy_region.get());
}
}
}
diff --git a/src/mame/drivers/freekick.cpp b/src/mame/drivers/freekick.cpp
index 2341bbcd2b3..b80f0441d0b 100644
--- a/src/mame/drivers/freekick.cpp
+++ b/src/mame/drivers/freekick.cpp
@@ -1599,10 +1599,10 @@ void freekick_state::init_gigasb()
void freekick_state::init_pbillrds()
{
- uint8_t *decrypted_opcodes = auto_alloc_array(machine(), uint8_t, 0x10000);
- downcast<mc8123_device &>(*m_maincpu).decode(memregion("maincpu")->base(), decrypted_opcodes, 0x10000);
- membank("bank0d")->set_base(decrypted_opcodes);
- m_bank1d->configure_entries(0, 2, decrypted_opcodes + 0x8000, 0x4000);
+ m_decrypted_opcodes = std::make_unique<uint8_t[]>(0x10000);
+ downcast<mc8123_device &>(*m_maincpu).decode(memregion("maincpu")->base(), m_decrypted_opcodes.get(), 0x10000);
+ membank("bank0d")->set_base(m_decrypted_opcodes.get());
+ m_bank1d->configure_entries(0, 2, &m_decrypted_opcodes[0x8000], 0x4000);
}
@@ -1615,10 +1615,10 @@ void freekick_state::init_pbillrdbl()
void freekick_state::init_gigas()
{
- uint8_t *decrypted_opcodes = auto_alloc_array(machine(), uint8_t, 0xc000);
- downcast<mc8123_device &>(*m_maincpu).decode(memregion("maincpu")->base(), decrypted_opcodes, 0xc000);
- membank("bank0d")->set_base(decrypted_opcodes);
- m_bank1d->set_base(decrypted_opcodes + 0x8000);
+ m_decrypted_opcodes = std::make_unique<uint8_t[]>(0xc000);
+ downcast<mc8123_device &>(*m_maincpu).decode(memregion("maincpu")->base(), m_decrypted_opcodes.get(), 0xc000);
+ membank("bank0d")->set_base(m_decrypted_opcodes.get());
+ m_bank1d->set_base(&m_decrypted_opcodes[0x8000]);
}
diff --git a/src/mame/drivers/mitchell.cpp b/src/mame/drivers/mitchell.cpp
index 2f356f7e57b..4a960d3dd2b 100644
--- a/src/mame/drivers/mitchell.cpp
+++ b/src/mame/drivers/mitchell.cpp
@@ -2616,11 +2616,11 @@ void mitchell_state::configure_banks(void (*decode)(uint8_t *src, uint8_t *dst,
{
uint8_t *src = memregion("maincpu")->base();
int size = memregion("maincpu")->bytes();
- uint8_t *dst = auto_alloc_array(machine(), uint8_t, size);
- decode(src, dst, size);
+ m_decoded = std::make_unique<uint8_t[]>(size);
+ decode(src, m_decoded.get(), size);
m_bank1->configure_entries(0, 16, src + 0x10000, 0x4000);
- m_bank0d->set_base(dst);
- m_bank1d->configure_entries(0, 16, dst + 0x10000, 0x4000);
+ m_bank0d->set_base(m_decoded.get());
+ m_bank1d->configure_entries(0, 16, &m_decoded[0x10000], 0x4000);
}
diff --git a/src/mame/drivers/ninjakd2.cpp b/src/mame/drivers/ninjakd2.cpp
index 71726f50671..27464bde788 100644
--- a/src/mame/drivers/ninjakd2.cpp
+++ b/src/mame/drivers/ninjakd2.cpp
@@ -183,15 +183,13 @@ SAMPLES_START_CB_MEMBER(ninjakd2_state::ninjakd2_init_samples)
const uint8_t* const rom = m_pcm_region->base();
const int length = m_pcm_region->bytes();
- int16_t* sampledata = auto_alloc_array(machine(), int16_t, length);
+ m_sampledata = std::make_unique<int16_t[]>(length);
// convert unsigned 8-bit PCM to signed 16-bit
for (int i = 0; i < length; ++i)
{
- sampledata[i] = rom[i] << 7;
+ m_sampledata[i] = rom[i] << 7;
}
-
- m_sampledata = sampledata;
}
void ninjakd2_state::ninjakd2_pcm_play_w(uint8_t data)
diff --git a/src/mame/drivers/pc6001.cpp b/src/mame/drivers/pc6001.cpp
index 901cf30ecf9..3672fc61228 100644
--- a/src/mame/drivers/pc6001.cpp
+++ b/src/mame/drivers/pc6001.cpp
@@ -186,7 +186,7 @@ void pc6001_state::system_latch_w(uint8_t data)
{
static const uint16_t startaddr[] = {0xC000, 0xE000, 0x8000, 0xA000 };
- m_video_ram = &m_ram[startaddr[(data >> 1) & 0x03] - 0x8000];
+ m_video_base = &m_ram[startaddr[(data >> 1) & 0x03] - 0x8000];
cassette_latch_control((data & 8) == 8);
m_sys_latch = data;
@@ -622,7 +622,7 @@ void pc6001mk2_state::mk2_vram_bank_w(uint8_t data)
// popmessage("%02x",data);
-// m_video_ram = work_ram + startaddr[(data >> 1) & 0x03];
+// m_video_base = work_ram + startaddr[(data >> 1) & 0x03];
}
void pc6001mk2_state::mk2_col_bank_w(uint8_t data)
@@ -1341,7 +1341,7 @@ void pc6001_state::machine_start()
inline void pc6001_state::set_videoram_bank(uint32_t offs)
{
- m_video_ram = m_region_maincpu->base() + offs;
+ m_video_base = m_region_maincpu->base() + offs;
}
void pc6001_state::machine_reset()
diff --git a/src/mame/drivers/pc88va.cpp b/src/mame/drivers/pc88va.cpp
index 40f6b218055..7e6bc817e80 100644
--- a/src/mame/drivers/pc88va.cpp
+++ b/src/mame/drivers/pc88va.cpp
@@ -32,9 +32,9 @@
void pc88va_state::video_start()
{
- m_kanjiram = auto_alloc_array(machine(), uint8_t, 0x4000);
- m_gfxdecode->gfx(2)->set_source(m_kanjiram);
- m_gfxdecode->gfx(3)->set_source(m_kanjiram);
+ m_kanjiram = std::make_unique<uint8_t[]>(0x4000);
+ m_gfxdecode->gfx(2)->set_source(m_kanjiram.get());
+ m_gfxdecode->gfx(3)->set_source(m_kanjiram.get());
}
void pc88va_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect)
diff --git a/src/mame/drivers/qix.cpp b/src/mame/drivers/qix.cpp
index 42ba6422858..9e8533fd9ba 100644
--- a/src/mame/drivers/qix.cpp
+++ b/src/mame/drivers/qix.cpp
@@ -1416,30 +1416,30 @@ void qix_state::init_kram3()
//patch = memregion("user1")->base();
uint8_t *rom = memregion("maincpu")->base();
- uint8_t *decrypted = auto_alloc_array(machine(), uint8_t, 0x6000);
+ m_decrypted = std::make_unique<uint8_t[]>(0x6000);
- memcpy(decrypted,&rom[0xa000],0x6000);
+ memcpy(m_decrypted.get(),&rom[0xa000],0x6000);
for (int i = 0xa000; i < 0x10000; ++i)
{
- decrypted[i-0xa000] = kram3_decrypt(i, rom[i]);
+ m_decrypted[i-0xa000] = kram3_decrypt(i, rom[i]);
}
m_bank0->configure_entry(0, memregion("maincpu")->base() + 0xa000);
- m_bank0->configure_entry(1, decrypted);
+ m_bank0->configure_entry(1, m_decrypted.get());
m_bank0->set_entry(0);
//patch = memregion("user2")->base();
rom = memregion("videocpu")->base();
- decrypted = auto_alloc_array(machine(), uint8_t, 0x6000);
+ m_decrypted2 = std::make_unique<uint8_t[]>(0x6000);
- memcpy(decrypted,&rom[0xa000],0x6000);
+ memcpy(m_decrypted2.get(),&rom[0xa000],0x6000);
for (int i = 0xa000; i < 0x10000; ++i)
{
- decrypted[i-0xa000] = kram3_decrypt(i, rom[i]);
+ m_decrypted2[i-0xa000] = kram3_decrypt(i, rom[i]);
}
m_bank1->configure_entry(0, memregion("videocpu")->base() + 0xa000);
- m_bank1->configure_entry(1, decrypted);
+ m_bank1->configure_entry(1, m_decrypted2.get());
m_bank1->set_entry(0);
}
diff --git a/src/mame/drivers/segae.cpp b/src/mame/drivers/segae.cpp
index e9d547ebe07..f4ebeb4bf59 100644
--- a/src/mame/drivers/segae.cpp
+++ b/src/mame/drivers/segae.cpp
@@ -374,6 +374,7 @@ private:
optional_memory_bank m_bank1d;
optional_ioport_array<2> m_analog_ports;
output_finder<> m_lamp;
+ std::unique_ptr<uint8_t[]> m_banked_decrypted_opcodes;
// Analog input related
uint8_t m_port_select;
@@ -971,11 +972,11 @@ void systeme_state::systemeb(machine_config &config)
void systeme_state::init_opaopa()
{
- uint8_t *banked_decrypted_opcodes = auto_alloc_array(machine(), uint8_t, m_maincpu_region->bytes());
- downcast<mc8123_device &>(*m_maincpu).decode(m_maincpu_region->base(), banked_decrypted_opcodes, m_maincpu_region->bytes());
+ m_banked_decrypted_opcodes = std::make_unique<uint8_t[]>(m_maincpu_region->bytes());
+ downcast<mc8123_device &>(*m_maincpu).decode(m_maincpu_region->base(), m_banked_decrypted_opcodes.get(), m_maincpu_region->bytes());
- m_bank0d->set_base(banked_decrypted_opcodes);
- m_bank1d->configure_entries(0, 16, banked_decrypted_opcodes + 0x10000, 0x4000);
+ m_bank0d->set_base(m_banked_decrypted_opcodes.get());
+ m_bank1d->configure_entries(0, 16, &m_banked_decrypted_opcodes[0x10000], 0x4000);
}
diff --git a/src/mame/drivers/slapshot.cpp b/src/mame/drivers/slapshot.cpp
index f4e733af497..6bd98ed409a 100644
--- a/src/mame/drivers/slapshot.cpp
+++ b/src/mame/drivers/slapshot.cpp
@@ -687,10 +687,10 @@ void slapshot_state::driver_init()
gfx_element *gx1 = m_gfxdecode->gfx(1);
// allocate memory for the assembled data
- u8 *srcdata = auto_alloc_array(machine(), u8, gx0->elements() * gx0->width() * gx0->height());
+ m_decoded_gfx = std::make_unique<u8[]>(gx0->elements() * gx0->width() * gx0->height());
// loop over elements
- u8 *dest = srcdata;
+ u8 *dest = m_decoded_gfx.get();
for (int c = 0; c < gx0->elements(); c++)
{
const u8 *c0base = gx0->get_data(c);
@@ -712,7 +712,7 @@ void slapshot_state::driver_init()
}
}
- gx0->set_raw_layout(srcdata, gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
+ gx0->set_raw_layout(m_decoded_gfx.get(), gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
gx0->set_colors(4096 / 64);
gx0->set_granularity(64);
m_gfxdecode->set_gfx(1, nullptr);
diff --git a/src/mame/drivers/taito_f2.cpp b/src/mame/drivers/taito_f2.cpp
index bfcf2214bdd..8a42929eb21 100644
--- a/src/mame/drivers/taito_f2.cpp
+++ b/src/mame/drivers/taito_f2.cpp
@@ -5387,10 +5387,10 @@ void taitof2_state::init_finalb()
gfx_element *gx1 = m_gfxdecode->gfx(1);
// allocate memory for the assembled data
- u8 *srcdata = auto_alloc_array(machine(), u8, gx0->elements() * gx0->width() * gx0->height());
+ m_decoded_gfx = std::make_unique<u8[]>(gx0->elements() * gx0->width() * gx0->height());
// loop over elements
- u8 *dest = srcdata;
+ u8 *dest = m_decoded_gfx.get();
for (int c = 0; c < gx0->elements(); c++)
{
const u8 *c0base = gx0->get_data(c);
@@ -5412,7 +5412,7 @@ void taitof2_state::init_finalb()
}
}
- gx0->set_raw_layout(srcdata, gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
+ gx0->set_raw_layout(m_decoded_gfx.get(), gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
gx0->set_colors(4096 / 64);
gx0->set_granularity(64);
m_gfxdecode->set_gfx(1, nullptr);
diff --git a/src/mame/drivers/taito_f3.cpp b/src/mame/drivers/taito_f3.cpp
index d87e5c1ed43..3138dc16e99 100644
--- a/src/mame/drivers/taito_f3.cpp
+++ b/src/mame/drivers/taito_f3.cpp
@@ -4314,7 +4314,7 @@ void taito_f3_state::tile_decode()
*/
- u8 *srcdata, *dest;
+ u8 *dest;
// all but bubsymphb (bootleg board with different sprite gfx layout), 2mindril (no sprite gfx roms)
if (m_gfxdecode->gfx(5) != nullptr)
{
@@ -4322,10 +4322,10 @@ void taito_f3_state::tile_decode()
gfx_element *spr_gfx_hi = m_gfxdecode->gfx(5);
// allocate memory for the assembled data
- srcdata = auto_alloc_array(machine(), u8, spr_gfx->elements() * spr_gfx->width() * spr_gfx->height());
+ m_decoded_gfx5 = std::make_unique<u8[]>(spr_gfx->elements() * spr_gfx->width() * spr_gfx->height());
// loop over elements
- dest = srcdata;
+ dest = m_decoded_gfx5.get();
for (int c = 0; c < spr_gfx->elements(); c++)
{
const u8 *c1base = spr_gfx->get_data(c);
@@ -4346,7 +4346,7 @@ void taito_f3_state::tile_decode()
}
}
- spr_gfx->set_raw_layout(srcdata, spr_gfx->width(), spr_gfx->height(), spr_gfx->elements(), 8 * spr_gfx->width(), 8 * spr_gfx->width() * spr_gfx->height());
+ spr_gfx->set_raw_layout(m_decoded_gfx5.get(), spr_gfx->width(), spr_gfx->height(), spr_gfx->elements(), 8 * spr_gfx->width(), 8 * spr_gfx->width() * spr_gfx->height());
m_gfxdecode->set_gfx(5, nullptr);
}
@@ -4356,10 +4356,10 @@ void taito_f3_state::tile_decode()
gfx_element *pf_gfx_hi = m_gfxdecode->gfx(4);
// allocate memory for the assembled data
- srcdata = auto_alloc_array(machine(), u8, pf_gfx->elements() * pf_gfx->width() * pf_gfx->height());
+ m_decoded_gfx4 = std::make_unique<u8[]>(pf_gfx->elements() * pf_gfx->width() * pf_gfx->height());
// loop over elements
- dest = srcdata;
+ dest = m_decoded_gfx4.get();
for (int c = 0; c < pf_gfx->elements(); c++)
{
const u8 *c0base = pf_gfx->get_data(c);
@@ -4379,7 +4379,7 @@ void taito_f3_state::tile_decode()
}
}
- pf_gfx->set_raw_layout(srcdata, pf_gfx->width(), pf_gfx->height(), pf_gfx->elements(), 8 * pf_gfx->width(), 8 * pf_gfx->width() * pf_gfx->height());
+ pf_gfx->set_raw_layout(m_decoded_gfx4.get(), pf_gfx->width(), pf_gfx->height(), pf_gfx->elements(), 8 * pf_gfx->width(), 8 * pf_gfx->width() * pf_gfx->height());
m_gfxdecode->set_gfx(4, nullptr);
}
}
diff --git a/src/mame/etc/fddebug.cpp b/src/mame/etc/fddebug.cpp
index 572741083c9..3e800de4dce 100644
--- a/src/mame/etc/fddebug.cpp
+++ b/src/mame/etc/fddebug.cpp
@@ -222,7 +222,7 @@ static uint8_t * ignorepc;
static uint8_t ignore_all;
/* array of information about each opcode */
-static optable_entry * optable;
+static std::unique_ptr<optable_entry[]> optable;
/* buffer for undoing operations */
static uint8_t * undobuff;
@@ -2087,7 +2087,7 @@ static void build_optable(running_machine &machine)
int opnum, inum;
/* allocate and initialize the opcode table */
- optable = auto_alloc_array(machine, optable_entry, 65536);
+ optable = std::make_unique<optable_entry[]>(65536);
for (opnum = 0; opnum < 65536; opnum++)
{
optable[opnum].flags = OF_INVALID;
diff --git a/src/mame/includes/aquarium.h b/src/mame/includes/aquarium.h
index cf2c03e4f48..ccbdbe04e04 100644
--- a/src/mame/includes/aquarium.h
+++ b/src/mame/includes/aquarium.h
@@ -53,6 +53,7 @@ private:
tilemap_t *m_txt_tilemap;
tilemap_t *m_mid_tilemap;
tilemap_t *m_bak_tilemap;
+ std::unique_ptr<u8[]> m_decoded_gfx[2];
/* devices */
required_device<cpu_device> m_maincpu;
@@ -70,7 +71,7 @@ private:
u8 oki_r();
void oki_w(u8 data);
- void expand_gfx(int low, int hi);
+ std::unique_ptr<u8[]> expand_gfx(int low, int hi);
void txt_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void mid_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
void bak_videoram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
diff --git a/src/mame/includes/cps3.h b/src/mame/includes/cps3.h
index 1db58e099dd..3d3d2472e67 100644
--- a/src/mame/includes/cps3.h
+++ b/src/mame/includes/cps3.h
@@ -118,6 +118,7 @@ private:
bitmap_rgb32 m_renderbuffer_bitmap;
rectangle m_renderbuffer_clip;
u8* m_user4;
+ std::unique_ptr<u8[]> m_user4_allocated;
u32 m_key1;
u32 m_key2;
int m_altEncryption;
@@ -138,6 +139,7 @@ private:
u16 m_lastb;
u16 m_lastb2;
u8* m_user5;
+ std::unique_ptr<u8[]> m_user5_allocated;
u8 ssram_r(offs_t offset);
void ssram_w(offs_t offset, u8 data);
diff --git a/src/mame/includes/freekick.h b/src/mame/includes/freekick.h
index d841a3051c2..3f1c5a8b0c2 100644
--- a/src/mame/includes/freekick.h
+++ b/src/mame/includes/freekick.h
@@ -50,6 +50,7 @@ private:
int m_spinner;
int m_nmi_en;
int m_ff_data;
+ std::unique_ptr<uint8_t[]> m_decrypted_opcodes;
DECLARE_WRITE_LINE_MEMBER(flipscreen_x_w);
DECLARE_WRITE_LINE_MEMBER(flipscreen_y_w);
DECLARE_WRITE_LINE_MEMBER(flipscreen_w);
diff --git a/src/mame/includes/hp48.h b/src/mame/includes/hp48.h
index 990592b5e9d..cf9eae50458 100644
--- a/src/mame/includes/hp48.h
+++ b/src/mame/includes/hp48.h
@@ -174,6 +174,8 @@ private:
emu_timer *m_1st_timer;
emu_timer *m_2nd_timer;
emu_timer *m_kbd_timer;
+ std::unique_ptr<uint8_t[]> m_allocated_ram;
+ std::unique_ptr<uint8_t[]> m_allocated_rom;
};
diff --git a/src/mame/includes/jedi.h b/src/mame/includes/jedi.h
index a632d829b35..871ca1b224e 100644
--- a/src/mame/includes/jedi.h
+++ b/src/mame/includes/jedi.h
@@ -46,7 +46,7 @@ public:
m_sacklatch(*this, "sacklatch"),
m_tms(*this, "tms"),
m_novram(*this, "novram12%c", 'b'),
-#ifdef DEBUG_GFXDECODE
+#if DEBUG_GFXDECODE
m_gfxdecode(*this, "gfxdecode"),
#endif
m_palette(*this, "palette"),
@@ -115,8 +115,9 @@ private:
required_device<generic_latch_8_device> m_sacklatch;
required_device<tms5220_device> m_tms;
required_device_array<x2212_device, 2> m_novram;
-#ifdef DEBUG_GFXDECODE
+#if DEBUG_GFXDECODE
required_device<gfxdecode_device> m_gfxdecode;
+ std::unique_ptr<u8[]> m_gfxdata;
#endif
required_device<palette_device> m_palette;
required_device<screen_device> m_screen;
diff --git a/src/mame/includes/konamigx.h b/src/mame/includes/konamigx.h
index 47bed7e1d74..9bed09fa896 100644
--- a/src/mame/includes/konamigx.h
+++ b/src/mame/includes/konamigx.h
@@ -119,6 +119,8 @@ public:
K055673_CB_MEMBER(salmndr2_sprite_callback);
K055673_CB_MEMBER(le2_sprite_callback);
+ struct GX_OBJ { int order, offs, code, color; };
+
void common_init();
uint32_t k_6bpp_rom_long_r(offs_t offset, uint32_t mem_mask = ~0);
void konamigx_mixer (screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect,tilemap_t *sub1, int sub1flags,tilemap_t *sub2, int sub2flags,int mixerflags, bitmap_ind16 *extra_bitmap, int rushingheroes_hack);
@@ -126,7 +128,7 @@ public:
tilemap_t *sub1, int sub1flags,
tilemap_t *sub2, int sub2flags,
int mixerflags, bitmap_ind16 *extra_bitmap, int rushingheroes_hack,
- struct GX_OBJ *objpool,
+ GX_OBJ *objpool,
int *objbuf,
int nobj
);
@@ -240,6 +242,7 @@ protected:
uint16_t m_prot_data[0x20];
uint16_t *m_gx_spriteram;
+ std::unique_ptr<uint16_t[]> m_gx_spriteram_alloc;
// mirrored K054338 settings
int *m_K054338_shdRGB;
@@ -291,6 +294,8 @@ protected:
std::unique_ptr<bitmap_ind16> m_gxtype1_roz_dstbitmap2;
rectangle m_gxtype1_roz_dstbitmapclip;
+ std::unique_ptr<GX_OBJ[]> m_gx_objpool;
+
u8 m_type3_psac2_bank;
u8 m_type3_spriteram_bank;
//int m_konamigx_type3_psac2_actual_last_bank = 0;
diff --git a/src/mame/includes/mitchell.h b/src/mame/includes/mitchell.h
index 462a77b2db4..4db1f46ff39 100644
--- a/src/mame/includes/mitchell.h
+++ b/src/mame/includes/mitchell.h
@@ -105,6 +105,7 @@ private:
int m_dial_selected;
int m_dir[2];
int m_keymatrix;
+ std::unique_ptr<uint8_t[]> m_decoded;
uint8_t m_irq_source;
uint8_t pang_port5_r();
diff --git a/src/mame/includes/model3.h b/src/mame/includes/model3.h
index 07c712937bc..ed7afad7dbc 100644
--- a/src/mame/includes/model3.h
+++ b/src/mame/includes/model3.h
@@ -28,12 +28,19 @@ typedef float VECTOR3[3];
struct cached_texture
{
+ cached_texture(int texwidth, int texheight, int texformat) :
+ next(nullptr),
+ width(texwidth),
+ height(texheight),
+ format(texformat),
+ alpha(~0),
+ data(new rgb_t[(32 << texwidth) * (32 << texheight) * 4]) { }
cached_texture *next;
uint8_t width;
uint8_t height;
uint8_t format;
uint8_t alpha;
- rgb_t data[1];
+ std::unique_ptr<rgb_t[]> data;
};
struct m3_vertex
@@ -60,7 +67,45 @@ struct m3_triangle
int color;
};
-class model3_renderer;
+struct model3_polydata
+{
+ cached_texture *texture;
+ uint32_t color;
+ uint32_t texture_param;
+ int transparency;
+ int intensity;
+};
+
+class model3_state;
+
+class model3_renderer : public poly_manager<float, model3_polydata, 6, 50000>
+{
+public:
+ model3_renderer(running_machine &machine, int width, int height)
+ : poly_manager<float, model3_polydata, 6, 50000>(machine)
+ {
+ m_fb = std::make_unique<bitmap_rgb32>(width, height);
+ m_zb = std::make_unique<bitmap_ind32>(width, height);
+ }
+
+ void draw(bitmap_rgb32 &bitmap, const rectangle &cliprect);
+ void draw_opaque_triangles(const m3_triangle* tris, int num_tris);
+ void draw_alpha_triangles(const m3_triangle* tris, int num_tris);
+ void clear_fb();
+ void clear_zb();
+ void draw_scanline_solid(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
+ void draw_scanline_solid_trans(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
+ void draw_scanline_tex(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
+ void draw_scanline_tex_colormod(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
+ void draw_scanline_tex_contour(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
+ void draw_scanline_tex_trans(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
+ void draw_scanline_tex_alpha(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
+ void wait_for_polys();
+
+private:
+ std::unique_ptr<bitmap_rgb32> m_fb;
+ std::unique_ptr<bitmap_ind32> m_zb;
+};
class model3_state : public driver_device
{
@@ -241,7 +286,7 @@ private:
uint64_t m_vid_reg0;
int m_matrix_stack_ptr;
int m_list_depth;
- MATRIX *m_matrix_stack;
+ std::unique_ptr<MATRIX[]> m_matrix_stack;
MATRIX m_coordinate_system;
MATRIX m_projection_matrix;
float m_viewport_x;
@@ -253,9 +298,9 @@ private:
uint32_t m_matrix_base_address;
cached_texture *m_texcache[2][1024/32][2048/32];
- model3_renderer *m_renderer;
- m3_triangle* m_tri_buffer;
- m3_triangle* m_tri_alpha_buffer;
+ std::unique_ptr<model3_renderer> m_renderer;
+ std::unique_ptr<m3_triangle[]> m_tri_buffer;
+ std::unique_ptr<m3_triangle[]> m_tri_alpha_buffer;
int m_tri_buffer_ptr;
int m_tri_alpha_buffer_ptr;
int m_viewport_tri_index[4];
diff --git a/src/mame/includes/n64.h b/src/mame/includes/n64.h
index ced1597a25e..4dbfc7fe0aa 100644
--- a/src/mame/includes/n64.h
+++ b/src/mame/includes/n64.h
@@ -8,6 +8,7 @@
#include "cpu/rsp/rsp.h"
#include "cpu/mips/mips3.h"
#include "sound/dmadac.h"
+#include "video/n64.h"
/*----------- driver state -----------*/
@@ -38,7 +39,7 @@ public:
DECLARE_WRITE_LINE_MEMBER(screen_vblank_n64);
// Getters
- n64_rdp* rdp() { return m_rdp; }
+ n64_rdp* rdp() { return m_rdp.get(); }
uint32_t* rdram() { return m_rdram; }
uint32_t* sram() { return m_sram; }
uint32_t* rsp_imem() { return m_rsp_imem; }
@@ -56,7 +57,7 @@ protected:
required_device<n64_periphs> m_rcp_periphs;
/* video-related */
- n64_rdp *m_rdp;
+ std::unique_ptr<n64_rdp> m_rdp;
};
/*----------- devices -----------*/
diff --git a/src/mame/includes/namcos22.h b/src/mame/includes/namcos22.h
index ab7108696a0..cc522119297 100644
--- a/src/mame/includes/namcos22.h
+++ b/src/mame/includes/namcos22.h
@@ -152,6 +152,7 @@ private:
struct namcos22_scenenode m_scenenode_root;
struct namcos22_scenenode *m_scenenode_cur;
+ std::list<namcos22_scenenode> m_scenenode_alloc;
float m_clipx;
float m_clipy;
@@ -451,7 +452,7 @@ protected:
u16 m_keycus_rng;
int m_gametype;
int m_cz_adjust;
- namcos22_renderer *m_poly;
+ std::unique_ptr<namcos22_renderer> m_poly;
u16 m_dspram_bank;
u16 m_dspram16_latch;
bool m_slave_simulation_active;
diff --git a/src/mame/includes/ninjakd2.h b/src/mame/includes/ninjakd2.h
index 26d0de824e7..6fea518c9cb 100644
--- a/src/mame/includes/ninjakd2.h
+++ b/src/mame/includes/ninjakd2.h
@@ -95,7 +95,7 @@ private:
required_memory_bank m_mainbank;
- const int16_t* m_sampledata;
+ std::unique_ptr<int16_t[]> m_sampledata;
int m_next_sprite_overdraw_enabled;
uint8_t m_rom_bank_mask;
diff --git a/src/mame/includes/pc6001.h b/src/mame/includes/pc6001.h
index bd688de3369..d0e065707cf 100644
--- a/src/mame/includes/pc6001.h
+++ b/src/mame/includes/pc6001.h
@@ -117,7 +117,8 @@ protected:
void pc6001_screen_draw(bitmap_ind16 &bitmap,const rectangle &cliprect, int has_mc6847);
emu_timer *m_timer_irq_timer;
- uint8_t *m_video_ram;
+ uint8_t *m_video_base;
+ std::unique_ptr<uint8_t[]> m_video_ram;
uint8_t m_irq_vector;
uint8_t m_cas_switch;
uint8_t m_sys_latch;
diff --git a/src/mame/includes/pc88va.h b/src/mame/includes/pc88va.h
index 2b758bac118..94ffc3696ab 100644
--- a/src/mame/includes/pc88va.h
+++ b/src/mame/includes/pc88va.h
@@ -101,7 +101,7 @@ private:
required_device<address_map_bank_device> m_sysbank;
required_shared_ptr<uint16_t> m_tvram;
required_shared_ptr<uint16_t> m_gvram;
- uint8_t *m_kanjiram;
+ std::unique_ptr<uint8_t[]> m_kanjiram;
uint16_t m_bank_reg;
uint16_t m_screen_ctrl_reg;
uint8_t m_timer3_io_reg;
diff --git a/src/mame/includes/qix.h b/src/mame/includes/qix.h
index fcdf40f23b4..f100c93f14b 100644
--- a/src/mame/includes/qix.h
+++ b/src/mame/includes/qix.h
@@ -101,6 +101,8 @@ protected:
optional_memory_bank m_bank0;
optional_memory_bank m_bank1;
required_device<screen_device> m_screen;
+ std::unique_ptr<uint8_t[]> m_decrypted;
+ std::unique_ptr<uint8_t[]> m_decrypted2;
pen_t m_pens[0x400];
void qix_data_firq_w(uint8_t data);
diff --git a/src/mame/includes/slapshot.h b/src/mame/includes/slapshot.h
index 68deee608d3..e08769ba5e7 100644
--- a/src/mame/includes/slapshot.h
+++ b/src/mame/includes/slapshot.h
@@ -93,6 +93,7 @@ private:
#endif
emu_timer *m_int6_timer;
+ std::unique_ptr<u8[]> m_decoded_gfx;
// generic
u16 service_input_r(offs_t offset);
diff --git a/src/mame/includes/taito_f2.h b/src/mame/includes/taito_f2.h
index 904471b4a22..819c63ac7fd 100644
--- a/src/mame/includes/taito_f2.h
+++ b/src/mame/includes/taito_f2.h
@@ -159,6 +159,7 @@ protected:
int m_nibble;
s32 m_driveout_sound_latch;
emu_timer *m_int6_timer;
+ std::unique_ptr<u8[]> m_decoded_gfx;
/* devices */
required_device<cpu_device> m_maincpu;
diff --git a/src/mame/includes/taito_f3.h b/src/mame/includes/taito_f3.h
index e474778c70f..b7abf603d00 100644
--- a/src/mame/includes/taito_f3.h
+++ b/src/mame/includes/taito_f3.h
@@ -167,6 +167,8 @@ protected:
emu_timer *m_interrupt3_timer;
u32 m_coin_word[2];
+ std::unique_ptr<u8[]> m_decoded_gfx4;
+ std::unique_ptr<u8[]> m_decoded_gfx5;
struct tempsprite
{
diff --git a/src/mame/includes/tatsumi.h b/src/mame/includes/tatsumi.h
index 4dc8e8f9b82..c47c5532b4d 100644
--- a/src/mame/includes/tatsumi.h
+++ b/src/mame/includes/tatsumi.h
@@ -254,6 +254,7 @@ private:
uint16_t m_road_color_bank, m_prev_road_bank;
uint16_t m_layer_page_size[4];
bool m_layer1_can_be_road;
+ std::unique_ptr<uint8_t[]> m_decoded_gfx;
void tile_expand();
void draw_bg(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, tilemap_t *src, const uint16_t* scrollx, const uint16_t* scrolly, const uint16_t layer_page_size, bool is_road, int hi_priority);
diff --git a/src/mame/includes/wecleman.h b/src/mame/includes/wecleman.h
index 6b067ec34db..84591f4bde4 100644
--- a/src/mame/includes/wecleman.h
+++ b/src/mame/includes/wecleman.h
@@ -77,14 +77,10 @@ protected:
tilemap_t *m_bg_tilemap;
tilemap_t *m_fg_tilemap;
tilemap_t *m_txt_tilemap;
- int *m_spr_idx_list;
- int *m_spr_pri_list;
- int *m_t32x32pm;
int m_gameid;
int m_spr_offsx;
int m_spr_offsy;
int m_spr_count;
- uint16_t *m_rgb_half;
int m_cloud_blend;
int m_cloud_ds;
int m_cloud_visible;
@@ -135,6 +131,7 @@ protected:
void wecleman_sound_map(address_map &map);
void wecleman_sub_map(address_map &map);
+ static constexpr int NUM_SPRITES = 256;
struct sprite_t
{
sprite_t() { }
@@ -155,8 +152,10 @@ protected:
template<class BitmapClass> void do_blit_zoom32(BitmapClass &bitmap, const rectangle &cliprect, const sprite_t &sprite);
template<class BitmapClass> void sprite_draw(BitmapClass &bitmap, const rectangle &cliprect);
- std::unique_ptr<sprite_t []> m_sprite_list;
- sprite_t **m_spr_ptr_list;
+ sprite_t *m_spr_ptr_list[NUM_SPRITES];
+ int m_spr_idx_list[NUM_SPRITES];
+ int m_spr_pri_list[NUM_SPRITES];
+ sprite_t m_sprite_list[NUM_SPRITES];
};
class hotchase_state : public wecleman_state
diff --git a/src/mame/machine/atarigen.cpp b/src/mame/machine/atarigen.cpp
index 092fe5226cb..057af93511c 100644
--- a/src/mame/machine/atarigen.cpp
+++ b/src/mame/machine/atarigen.cpp
@@ -89,10 +89,10 @@ void atarigen_state::blend_gfx(int gfx0, int gfx1, int mask0, int mask1)
gfx_element *gx1 = m_gfxdecode->gfx(gfx1);
// allocate memory for the assembled data
- u8 *srcdata = auto_alloc_array(machine(), u8, gx0->elements() * gx0->width() * gx0->height());
+ m_blended_data = std::make_unique<u8[]>(gx0->elements() * gx0->width() * gx0->height());
// loop over elements
- u8 *dest = srcdata;
+ u8 *dest = m_blended_data.get();
for (int c = 0; c < gx0->elements(); c++)
{
const u8 *c0base = gx0->get_data(c);
@@ -113,7 +113,7 @@ void atarigen_state::blend_gfx(int gfx0, int gfx1, int mask0, int mask1)
// int newdepth = gx0->depth() * gx1->depth();
int granularity = gx0->granularity();
- gx0->set_raw_layout(srcdata, gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
+ gx0->set_raw_layout(m_blended_data.get(), gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
gx0->set_granularity(granularity);
// free the second graphics element
diff --git a/src/mame/machine/atarigen.h b/src/mame/machine/atarigen.h
index 0c71ada79d7..2110928411f 100644
--- a/src/mame/machine/atarigen.h
+++ b/src/mame/machine/atarigen.h
@@ -47,6 +47,8 @@ protected:
optional_device<gfxdecode_device> m_gfxdecode;
optional_device<screen_device> m_screen;
+
+ std::unique_ptr<u8[]> m_blended_data;
};
diff --git a/src/mame/machine/hp48.cpp b/src/mame/machine/hp48.cpp
index f47d9a0b727..ac33d8b1f07 100644
--- a/src/mame/machine/hp48.cpp
+++ b/src/mame/machine/hp48.cpp
@@ -924,19 +924,19 @@ void hp48_state::base_machine_start(hp48_models model)
HP49_G_MODEL ? (512 * 1024) :
HP48_GX_MODEL ? (128 * 1024) : (32 * 1024);
- uint8_t *ram = auto_alloc_array(machine(), uint8_t, 2 * ram_size);
- subdevice<nvram_device>("nvram")->set_base(ram, 2 * ram_size);
+ m_allocated_ram = std::make_unique<uint8_t[]>(2 * ram_size);
+ subdevice<nvram_device>("nvram")->set_base(m_allocated_ram.get(), 2 * ram_size);
/* ROM load */
uint32_t rom_size =
HP49_G_MODEL ? (2048 * 1024) :
HP48_S_SERIES ? (256 * 1024) : (512 * 1024);
- m_rom = auto_alloc_array(machine(), uint8_t, 2 * rom_size);
- decode_nibble(m_rom, memregion("maincpu")->base(), rom_size);
+ m_allocated_rom = std::make_unique<uint8_t[]>(2 * rom_size);
+ decode_nibble(m_allocated_rom.get(), memregion("maincpu")->base(), rom_size);
/* init state */
- memset(ram, 0, 2 * ram_size);
+ std::fill_n(&m_allocated_ram[0], 2 * ram_size, 0);
memset(m_io, 0, sizeof(m_io));
m_out = 0;
m_kdn = 0;
@@ -954,16 +954,16 @@ void hp48_state::base_machine_start(hp48_models model)
if (HP49_G_MODEL)
{
m_modules[HP48_NCE2].off_mask = 2 * 256 * 1024 - 1;
- m_modules[HP48_NCE2].data = ram;
+ m_modules[HP48_NCE2].data = &m_allocated_ram[0];
m_modules[HP48_CE2].off_mask = 2 * 128 * 1024 - 1;
- m_modules[HP48_CE2].data = ram + 2 * 256 * 1024;
+ m_modules[HP48_CE2].data = &m_allocated_ram[2 * 256 * 1024];
m_modules[HP48_NCE3].off_mask = 2 * 128 * 1024 - 1;
- m_modules[HP48_NCE3].data = ram + 2 * (128+256) * 1024;
+ m_modules[HP48_NCE3].data = &m_allocated_ram[2 * (128+256) * 1024];
}
else
{
m_modules[HP48_NCE2].off_mask = 2 * ram_size - 1;
- m_modules[HP48_NCE2].data = ram;
+ m_modules[HP48_NCE2].data = &m_allocated_ram[0];
}
/* bank switcher */
diff --git a/src/mame/video/jedi.cpp b/src/mame/video/jedi.cpp
index 709ea5dd73c..11ee7c4e752 100644
--- a/src/mame/video/jedi.cpp
+++ b/src/mame/video/jedi.cpp
@@ -30,15 +30,15 @@
void jedi_state::video_start()
{
-#ifdef DEBUG_GFXDECODE
+#if DEBUG_GFXDECODE
/* the sprite pixel determines pen address bits A4-A7 */
gfx_element *gx0 = m_gfxdecode->gfx(2);
// allocate memory for the assembled data
- u8 *srcdata = auto_alloc_array(machine(), u8, gx0->elements() * gx0->width() * gx0->height());
+ m_gfxdata = std::make_unique<u8[]>(gx0->elements() * gx0->width() * gx0->height());
// loop over elements
- u8 *dest = srcdata;
+ u8 *dest = m_gfxdata.get();
for (int c = 0; c < gx0->elements(); c++)
{
const u8 *c0base = gx0->get_data(c);
@@ -57,7 +57,7 @@ void jedi_state::video_start()
}
}
- gx0->set_raw_layout(srcdata, gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
+ gx0->set_raw_layout(m_gfxdata.get(), gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
gx0->set_granularity(1);
#endif
@@ -350,7 +350,7 @@ u32 jedi_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const
*
*************************************/
-#ifdef DEBUG_GFXDECODE
+#if DEBUG_GFXDECODE
static const gfx_layout text_layout =
{
8, 8,
@@ -393,7 +393,7 @@ GFXDECODE_END
void jedi_state::jedi_video(machine_config &config)
{
-#ifdef DEBUG_GFXDECODE
+#if DEBUG_GFXDECODE
GFXDECODE(config, m_gfxdecode, m_palette, gfx_jedi);
#endif
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
diff --git a/src/mame/video/k001005.cpp b/src/mame/video/k001005.cpp
index 954bb159571..4491546bcca 100644
--- a/src/mame/video/k001005.cpp
+++ b/src/mame/video/k001005.cpp
@@ -1205,7 +1205,7 @@ void k001005_device::device_start()
m_fifo = std::make_unique<uint32_t[]>(0x800);
- m_renderer = auto_alloc(machine(), k001005_renderer(*this, screen(), m_k001006));
+ m_renderer = std::make_unique<k001005_renderer>(*this, screen(), m_k001006);
save_pointer(NAME(m_ram[0]), 0x140000);
save_pointer(NAME(m_ram[1]), 0x140000);
diff --git a/src/mame/video/k001005.h b/src/mame/video/k001005.h
index 12bed551c95..8d41b61eae3 100644
--- a/src/mame/video/k001005.h
+++ b/src/mame/video/k001005.h
@@ -140,7 +140,7 @@ private:
uint32_t m_reg_far_z;
- k001005_renderer *m_renderer;
+ std::unique_ptr<k001005_renderer> m_renderer;
};
DECLARE_DEVICE_TYPE(K001005, k001005_device)
diff --git a/src/mame/video/k053246_k053247_k055673.cpp b/src/mame/video/k053246_k053247_k055673.cpp
index f54f0cd8e5b..fcd27f1f065 100644
--- a/src/mame/video/k053246_k053247_k055673.cpp
+++ b/src/mame/video/k053246_k053247_k055673.cpp
@@ -978,7 +978,8 @@ void k055673_device::device_start()
size4 = (m_gfxrom.length()/(1024*1024))/5;
size4 *= 4*1024*1024;
/* set the # of tiles based on the 4bpp section */
- alt_k055673_rom = auto_alloc_array(machine(), u16, size4 * 5 / 2);
+ m_combined_gfx = std::make_unique<u16[]>(size4 * 5 / 2);
+ alt_k055673_rom = m_combined_gfx.get();
d = (u8 *)alt_k055673_rom;
// now combine the graphics together to form 5bpp
s1 = (u8 *)&m_gfxrom[0]; // 4bpp area
diff --git a/src/mame/video/k053246_k053247_k055673.h b/src/mame/video/k053246_k053247_k055673.h
index e9d97608c7c..0be6f634af9 100644
--- a/src/mame/video/k053246_k053247_k055673.h
+++ b/src/mame/video/k053246_k053247_k055673.h
@@ -462,7 +462,7 @@ protected:
virtual void device_start() override;
// virtual void device_reset();
private:
-
+ std::unique_ptr<u16[]> m_combined_gfx;
};
DECLARE_DEVICE_TYPE(K055673, k055673_device)
diff --git a/src/mame/video/konamigx.cpp b/src/mame/video/konamigx.cpp
index 31cc3ea82fb..313555b111f 100644
--- a/src/mame/video/konamigx.cpp
+++ b/src/mame/video/konamigx.cpp
@@ -277,8 +277,6 @@ void konamigx_state::wipezbuf(int noshadow)
#define GX_MAX_LAYERS 6
#define GX_MAX_OBJECTS (GX_MAX_SPRITES + GX_MAX_LAYERS)
-static struct GX_OBJ { int order, offs, code, color; } *gx_objpool;
-
void konamigx_state::konamigx_mixer_init(screen_device &screen, int objdma)
{
m_gx_objdma = 0;
@@ -286,13 +284,14 @@ void konamigx_state::konamigx_mixer_init(screen_device &screen, int objdma)
m_gx_objzbuf = &screen.priority().pix(0);
m_gx_shdzbuf = std::make_unique<uint8_t[]>(GX_ZBUFSIZE);
- gx_objpool = auto_alloc_array(machine(), struct GX_OBJ, GX_MAX_OBJECTS);
+ m_gx_objpool = std::make_unique<GX_OBJ[]>(GX_MAX_OBJECTS);
m_k054338->export_config(&m_K054338_shdRGB);
if (objdma)
{
- m_gx_spriteram = auto_alloc_array(machine(), uint16_t, 0x2000/2);
+ m_gx_spriteram_alloc = std::make_unique<uint16_t[]>(0x2000/2);
+ m_gx_spriteram = m_gx_spriteram_alloc.get();
m_gx_objdma = 1;
}
else
@@ -323,14 +322,14 @@ void konamigx_state::konamigx_mixer(screen_device &screen, bitmap_rgb32 &bitmap,
int objbuf[GX_MAX_OBJECTS];
int shadowon[3], shdpri[3], layerid[6], layerpri[6];
- struct GX_OBJ *objpool, *objptr;
+ GX_OBJ *objpool, *objptr;
int cltc_shdpri, /*prflp,*/ disp;
// buffer can move when it's resized, so refresh the pointer
m_gx_objzbuf = &screen.priority().pix(0);
// abort if object database failed to initialize
- objpool = gx_objpool;
+ objpool = m_gx_objpool.get();
if (!objpool) return;
// clear screen with backcolor and update flicker pulse
@@ -818,7 +817,7 @@ void konamigx_state::konamigx_mixer_draw(screen_device &screen, bitmap_rgb32 &bi
int mixerflags, bitmap_ind16 *extra_bitmap, int rushingheroes_hack,
/* passed from above function */
- struct GX_OBJ *objpool,
+ GX_OBJ *objpool,
int *objbuf,
int nobj
)
@@ -828,7 +827,7 @@ void konamigx_state::konamigx_mixer_draw(screen_device &screen, bitmap_rgb32 &bi
for (int count=0; count<nobj; count++)
{
- struct GX_OBJ *objptr = objpool + objbuf[count];
+ GX_OBJ *objptr = objpool + objbuf[count];
int order = objptr->order;
int offs = objptr->offs;
int code = objptr->code;
diff --git a/src/mame/video/model3.cpp b/src/mame/video/model3.cpp
index 7966cd293ac..e8d7e5ed773 100644
--- a/src/mame/video/model3.cpp
+++ b/src/mame/video/model3.cpp
@@ -28,45 +28,6 @@
#define TRI_BUFFER_SIZE 50000
#define TRI_ALPHA_BUFFER_SIZE 15000
-struct model3_polydata
-{
- cached_texture *texture;
- uint32_t color;
- uint32_t texture_param;
- int transparency;
- int intensity;
-};
-
-class model3_renderer : public poly_manager<float, model3_polydata, 6, 50000>
-{
-public:
- model3_renderer(model3_state &state, int width, int height)
- : poly_manager<float, model3_polydata, 6, 50000>(state.machine())
- {
- m_fb = std::make_unique<bitmap_rgb32>(width, height);
- m_zb = std::make_unique<bitmap_ind32>(width, height);
- }
-
- void draw(bitmap_rgb32 &bitmap, const rectangle &cliprect);
- void draw_opaque_triangles(const m3_triangle* tris, int num_tris);
- void draw_alpha_triangles(const m3_triangle* tris, int num_tris);
- void clear_fb();
- void clear_zb();
- void draw_scanline_solid(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
- void draw_scanline_solid_trans(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
- void draw_scanline_tex(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
- void draw_scanline_tex_colormod(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
- void draw_scanline_tex_contour(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
- void draw_scanline_tex_trans(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
- void draw_scanline_tex_alpha(int32_t scanline, const extent_t &extent, const model3_polydata &extradata, int threadid);
- void wait_for_polys();
-
-private:
- std::unique_ptr<bitmap_rgb32> m_fb;
- std::unique_ptr<bitmap_ind32> m_zb;
-};
-
-
/*****************************************************************************/
@@ -141,8 +102,8 @@ void model3_state::model3_exit()
fclose(file);
#endif
-// invalidate_texture(0, 0, 0, 6, 5);
-// invalidate_texture(1, 0, 0, 6, 5);
+ invalidate_texture(0, 0, 0, 6, 5);
+ invalidate_texture(1, 0, 0, 6, 5);
}
void model3_state::video_start()
@@ -172,10 +133,10 @@ void model3_state::video_start()
int width = m_screen->width();
int height = m_screen->height();
- m_renderer = auto_alloc(machine(), model3_renderer(*this, width, height));
+ m_renderer = std::make_unique<model3_renderer>(machine(), width, height);
- m_tri_buffer = auto_alloc_array_clear(machine(), m3_triangle, TRI_BUFFER_SIZE);
- m_tri_alpha_buffer = auto_alloc_array_clear(machine(), m3_triangle, TRI_ALPHA_BUFFER_SIZE);
+ m_tri_buffer = std::make_unique<m3_triangle[]>(TRI_BUFFER_SIZE);
+ m_tri_alpha_buffer = std::make_unique<m3_triangle[]>(TRI_ALPHA_BUFFER_SIZE);
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&model3_state::model3_exit, this));
@@ -553,7 +514,7 @@ void model3_state::invalidate_texture(int page, int texx, int texy, int texwidth
{
cached_texture *freeme = m_texcache[page][texy + y][texx + x];
m_texcache[page][texy + y][texx + x] = freeme->next;
- auto_free(machine(), freeme);
+ delete freeme;
}
}
@@ -571,10 +532,7 @@ cached_texture *model3_state::get_texture(int page, int texx, int texy, int texw
return tex;
/* create a new texture */
- tex = (cached_texture *)auto_alloc_array(machine(), uint8_t, sizeof(cached_texture) + (2 * pixwidth * 2 * pixheight) * sizeof(rgb_t));
- tex->width = texwidth;
- tex->height = texheight;
- tex->format = format;
+ tex = new cached_texture(texwidth, texheight, format);
/* set the new texture */
tex->next = m_texcache[page][texy][texx];
@@ -584,7 +542,7 @@ cached_texture *model3_state::get_texture(int page, int texx, int texy, int texw
for (y = 0; y < pixheight; y++)
{
const uint16_t *texsrc = &m_texture_ram[page][(texy * 32 + y) * 2048 + texx * 32];
- rgb_t *dest = tex->data + 2 * pixwidth * y;
+ rgb_t *dest = &tex->data[2 * pixwidth * y];
switch (format)
{
@@ -663,7 +621,7 @@ cached_texture *model3_state::get_texture(int page, int texx, int texy, int texw
/* create the vertical mirror of the texture */
for (y = 0; y < pixheight; y++)
- memcpy(tex->data + 2 * pixwidth * (pixheight * 2 - 1 - y), tex->data + 2 * pixwidth * y, sizeof(rgb_t) * pixwidth * 2);
+ memcpy(&tex->data[2 * pixwidth * (pixheight * 2 - 1 - y)], &tex->data[2 * pixwidth * y], sizeof(rgb_t) * pixwidth * 2);
/* remember the overall alpha */
tex->alpha = alpha >> 24;
@@ -1398,8 +1356,8 @@ static void matrix_multiply(MATRIX a, MATRIX b, MATRIX *out)
void model3_state::init_matrix_stack()
{
- MATRIX *matrix_stack;
- matrix_stack = m_matrix_stack = auto_alloc_array_clear(machine(), MATRIX, MATRIX_STACK_SIZE);
+ m_matrix_stack = std::make_unique<MATRIX[]>(MATRIX_STACK_SIZE);
+ MATRIX *matrix_stack = &m_matrix_stack[0];
/* initialize the first matrix as identity */
matrix_stack[0][0][0] = 1.0f;
diff --git a/src/mame/video/n64.cpp b/src/mame/video/n64.cpp
index e0723dfa953..88f0548c060 100644
--- a/src/mame/video/n64.cpp
+++ b/src/mame/video/n64.cpp
@@ -25,7 +25,7 @@ TODO:
*******************************************************************************/
#include "emu.h"
-#include "video/n64.h"
+#include "includes/n64.h"
#include "video/rdpblend.h"
#include "video/rdptpipe.h"
@@ -91,14 +91,14 @@ int32_t n64_rdp::get_alpha_cvg(int32_t comb_alpha, rdp_span_aux* userdata, const
void n64_state::video_start()
{
- m_rdp = auto_alloc(machine(), n64_rdp(*this, m_rdram, m_rsp_dmem));
+ m_rdp = std::make_unique<n64_rdp>(*this, m_rdram, m_rsp_dmem);
m_rdp->set_machine(machine());
m_rdp->init_internal_state();
m_rdp->set_n64_periphs(m_rcp_periphs);
m_rdp->m_blender.set_machine(machine());
- m_rdp->m_blender.set_processor(m_rdp);
+ m_rdp->m_blender.set_processor(m_rdp.get());
m_rdp->m_tex_pipe.set_machine(machine());
diff --git a/src/mame/video/n64.h b/src/mame/video/n64.h
index d8ab0fa9eb7..8aaa6d6d6f1 100644
--- a/src/mame/video/n64.h
+++ b/src/mame/video/n64.h
@@ -3,7 +3,6 @@
#ifndef _VIDEO_N64_H_
#define _VIDEO_N64_H_
-#include "includes/n64.h"
#include "video/poly.h"
#include "pin64.h"
@@ -130,6 +129,8 @@ class n64_rdp;
typedef void (*rdp_command_t)(uint64_t w1);
+class n64_state;
+
class n64_rdp : public poly_manager<uint32_t, rdp_poly_state, 8, 32000>
{
public:
diff --git a/src/mame/video/namcos22.cpp b/src/mame/video/namcos22.cpp
index 483acb7ca12..ddf12f188dd 100644
--- a/src/mame/video/namcos22.cpp
+++ b/src/mame/video/namcos22.cpp
@@ -530,7 +530,7 @@ struct namcos22_scenenode *namcos22_renderer::alloc_scenenode(running_machine &m
}
else
{
- node = auto_alloc(machine, struct namcos22_scenenode);
+ node = &m_scenenode_alloc.emplace_back();
}
memset(node, 0, sizeof(*node));
return node;
@@ -2580,5 +2580,5 @@ void namcos22_state::video_start()
m_gfxdecode->gfx(0)->set_source((u8 *)m_cgram.target());
- m_poly = auto_alloc(machine(), namcos22_renderer(*this));
+ m_poly = std::make_unique<namcos22_renderer>(*this);
}
diff --git a/src/mame/video/pc6001.cpp b/src/mame/video/pc6001.cpp
index 0de586a2982..e5943be7514 100644
--- a/src/mame/video/pc6001.cpp
+++ b/src/mame/video/pc6001.cpp
@@ -81,7 +81,7 @@ void pc6001mk2_state::pc6001mk2_palette(palette_device &palette) const
ATTR_CONST pc6001_state::uint8_t pc6001_get_attributes(uint8_t c,int scanline, int pos)
{
uint8_t result = 0x00;
- uint8_t val = m_video_ram [(scanline / 12) * 0x20 + pos];
+ uint8_t val = m_video_base [(scanline / 12) * 0x20 + pos];
if (val & 0x01) {
result |= M6847_INV;
@@ -95,7 +95,7 @@ ATTR_CONST pc6001_state::uint8_t pc6001_get_attributes(uint8_t c,int scanline, i
const pc6001_state::uint8_t *pc6001_get_video_ram(int scanline)
{
- return m_video_ram +0x0200+ (scanline / 12) * 0x20;
+ return m_video_base +0x0200+ (scanline / 12) * 0x20;
}
uint8_t pc6001_state::pc6001_get_char_rom(uint8_t ch, int line)
@@ -117,7 +117,8 @@ void pc6001_state::video_start()
cfg.get_char_rom = pc6001_get_char_rom;
m6847_init(machine(), &cfg);
#endif
- m_video_ram = auto_alloc_array_clear(machine(), uint8_t, 0x4000);
+ m_video_ram = make_unique_clear<uint8_t[]>(0x4000);
+ m_video_base = &m_video_ram[0];
}
void pc6001mk2_state::video_start()
@@ -127,7 +128,7 @@ void pc6001mk2_state::video_start()
void pc6001sr_state::video_start()
{
-// m_video_ram = auto_alloc_array_clear(machine(), uint8_t, 0x4000);
+// m_video_ram = std::make_unique<uint8_t[]>(0x4000);
m_gvram = std::make_unique<uint8_t []>(320*256*8); // TODO: size
std::fill_n(m_gvram.get(), 320*256*8, 0);
save_pointer(NAME(m_gvram), 320*256*8);
@@ -157,7 +158,7 @@ void pc6001_state::draw_gfx_mode4(bitmap_ind16 &bitmap,const rectangle &cliprect
{
for(int x=0;x<32;x++)
{
- int tile = m_video_ram[(x+(y*32))+0x200];
+ int tile = m_video_base[(x+(y*32))+0x200];
if(col_setting == 0x00) //monochrome
{
@@ -199,7 +200,7 @@ void pc6001_state::draw_bitmap_2bpp(bitmap_ind16 &bitmap,const rectangle &clipre
{
for(int x=0;x<w;x++)
{
- int tile = m_video_ram[(x+(y*32))+0x200];
+ int tile = m_video_base[(x+(y*32))+0x200];
for(int yi=0;yi<shrink_y;yi++)
{
@@ -221,7 +222,7 @@ void pc6001_state::draw_bitmap_2bpp(bitmap_ind16 &bitmap,const rectangle &clipre
{
for(int x=0;x<w;x++)
{
- int tile = m_video_ram[(x+((y/3)*32))+0x200];
+ int tile = m_video_base[(x+((y/3)*32))+0x200];
for(int yi=0;yi<shrink_y;yi++)
{
@@ -330,7 +331,7 @@ void pc6001_state::draw_border(bitmap_ind16 &bitmap,const rectangle &cliprect,in
void pc6001_state::pc6001_screen_draw(bitmap_ind16 &bitmap,const rectangle &cliprect, int has_mc6847)
{
- int attr = m_video_ram[0];
+ int attr = m_video_base[0];
draw_border(bitmap,cliprect,attr,has_mc6847);
@@ -351,8 +352,8 @@ void pc6001_state::pc6001_screen_draw(bitmap_ind16 &bitmap,const rectangle &clip
{
for(int x=0;x<32;x++)
{
- int tile = m_video_ram[(x+(y*32))+0x200];
- attr = m_video_ram[(x+(y*32)) & 0x1ff];
+ int tile = m_video_base[(x+(y*32))+0x200];
+ attr = m_video_base[(x+(y*32)) & 0x1ff];
if(attr & 0x40)
{
@@ -398,8 +399,8 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
color |= pal_num[(pen[0] & 3) | ((pen[1] & 3) << 2)];
#endif
- pen[0] = m_video_ram[count+0x0000] >> (6-i*2) & 3;
- pen[1] = m_video_ram[count+0x2000] >> (6-i*2) & 3;
+ pen[0] = m_video_base[count+0x0000] >> (6-i*2) & 3;
+ pen[1] = m_video_base[count+0x2000] >> (6-i*2) & 3;
int color = 0x10;
color |= ((pen[0] & 1) << 2);
@@ -435,8 +436,8 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
color |= pal_num[(pen[0] & 1) | ((pen[1] & 1) << 1)];
#endif
- pen[0] = m_video_ram[count+0x0000] >> (7-i) & 1;
- pen[1] = m_video_ram[count+0x2000] >> (7-i) & 1;
+ pen[0] = m_video_base[count+0x0000] >> (7-i) & 1;
+ pen[1] = m_video_base[count+0x2000] >> (7-i) & 1;
int color;
if(m_bgcol_bank & 4) //PC-6001 emulation mode
@@ -478,8 +479,8 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
---- xxxx fg color
Note that the exgfx banks a different gfx ROM
*/
- int tile = m_video_ram[(x+(y*40))+0x400] + 0x200;
- int attr = m_video_ram[(x+(y*40)) & 0x3ff];
+ int tile = m_video_base[(x+(y*40))+0x400] + 0x200;
+ int attr = m_video_base[(x+(y*40)) & 0x3ff];
tile += ((attr & 0x80) << 1);
for(int yi=0;yi<12;yi++)
@@ -502,7 +503,7 @@ uint32_t pc6001mk2_state::screen_update_pc6001mk2(screen_device &screen, bitmap_
}
else
{
- //attr = m_video_ram[0];
+ //attr = m_video_base[0];
pc6001_screen_draw(bitmap,cliprect,0);
}
@@ -521,8 +522,8 @@ uint32_t pc6001sr_state::screen_update_pc6001sr(screen_device &screen, bitmap_in
{
for(int x=0;x<40;x++)
{
- int tile = m_video_ram[(x+(y*40))*2+0];
- int attr = m_video_ram[(x+(y*40))*2+1];
+ int tile = m_video_base[(x+(y*40))*2+0];
+ int attr = m_video_base[(x+(y*40))*2+1];
tile += ((attr & 0x80) << 1);
for(int yi=0;yi<12;yi++)
diff --git a/src/mame/video/tatsumi.cpp b/src/mame/video/tatsumi.cpp
index cf9c9272170..173f6611a30 100644
--- a/src/mame/video/tatsumi.cpp
+++ b/src/mame/video/tatsumi.cpp
@@ -1105,13 +1105,13 @@ void cyclwarr_state::tile_expand()
*/
gfx_element *gx0 = m_gfxdecode->gfx(1);
m_mask.resize(gx0->elements() << 3,0);
- uint8_t *srcdata, *dest;
+ uint8_t *dest;
// allocate memory for the assembled data
- srcdata = auto_alloc_array(machine(), uint8_t, gx0->elements() * gx0->width() * gx0->height());
+ m_decoded_gfx = std::make_unique<uint8_t[]>(gx0->elements() * gx0->width() * gx0->height());
// loop over elements
- dest = srcdata;
+ dest = m_decoded_gfx.get();
for (int c = 0; c < gx0->elements(); c++)
{
const uint8_t *c0base = gx0->get_data(c);
@@ -1133,7 +1133,7 @@ void cyclwarr_state::tile_expand()
}
}
- gx0->set_raw_layout(srcdata, gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
+ gx0->set_raw_layout(m_decoded_gfx.get(), gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
gx0->set_granularity(256);
}
diff --git a/src/mame/video/tc0100scn.cpp b/src/mame/video/tc0100scn.cpp
index 3fa49244a91..f265565fecd 100644
--- a/src/mame/video/tc0100scn.cpp
+++ b/src/mame/video/tc0100scn.cpp
@@ -350,10 +350,10 @@ void tc0620scc_device::device_start()
gfx_element *gx1 = gfx(1);
// allocate memory for the assembled data
- u8 *srcdata = auto_alloc_array(machine(), u8, gx0->elements() * gx0->width() * gx0->height());
+ m_decoded_gfx = std::make_unique<u8[]>(gx0->elements() * gx0->width() * gx0->height());
// loop over elements
- u8 *dest = srcdata;
+ u8 *dest = m_decoded_gfx.get();
for (int c = 0; c < gx0->elements(); c++)
{
const u8 *c0base = gx0->get_data(c);
@@ -373,7 +373,7 @@ void tc0620scc_device::device_start()
}
}
- gx0->set_raw_layout(srcdata, gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
+ gx0->set_raw_layout(m_decoded_gfx.get(), gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height());
gx0->set_granularity(64);
tc0100scn_base_device::device_start();
}
diff --git a/src/mame/video/tc0100scn.h b/src/mame/video/tc0100scn.h
index 8b99eb7b9a2..0e9e0948ec3 100644
--- a/src/mame/video/tc0100scn.h
+++ b/src/mame/video/tc0100scn.h
@@ -137,6 +137,7 @@ protected:
private:
// decoding info
DECLARE_GFXDECODE_MEMBER(gfxinfo_6bpp);
+ std::unique_ptr<u8[]> m_decoded_gfx;
};
DECLARE_DEVICE_TYPE(TC0100SCN, tc0100scn_device)
diff --git a/src/mame/video/wecleman.cpp b/src/mame/video/wecleman.cpp
index b6c39d1dc8e..8754ef00d2f 100644
--- a/src/mame/video/wecleman.cpp
+++ b/src/mame/video/wecleman.cpp
@@ -21,7 +21,6 @@
#define SPRITE_FLIPX 0x01
#define SPRITE_FLIPY 0x02
-#define NUM_SPRITES 256
/***************************************************************************
@@ -66,7 +65,7 @@ void wecleman_state::get_sprite_info()
uint16_t *source = m_spriteram;
- sprite_t *sprite = m_sprite_list.get();
+ sprite_t *sprite = &m_sprite_list[0];
sprite_t *const finish = sprite + NUM_SPRITES;
int bank, code, gfx, zoom;
@@ -653,8 +652,6 @@ void wecleman_state::draw_cloud(bitmap_rgb32 &bitmap,
pen_t const *const pal_base = m_palette->pens() + pal_offset * gfx->granularity();
- alpha <<= 6;
-
dst_base += 8;
for (int i = 0; i < ycount; i++)
{
@@ -694,9 +691,9 @@ void wecleman_state::draw_cloud(bitmap_rgb32 &bitmap,
int dg = (dstrgb >> 11) & 0x1f;
int db = (dstrgb >> 19) & 0x1f;
- dr = (m_t32x32pm[dr - sr + alpha] >> 5) + dr;
- dg = (m_t32x32pm[dg - sg + alpha] >> 5) + dg;
- db = (m_t32x32pm[db - sb + alpha] >> 5) + db;
+ dr = (((dr - sr) * alpha) >> 5) + dr;
+ dg = (((dg - sg) * alpha) >> 5) + dg;
+ db = (((db - sb) * alpha) >> 5) + db;
dst_ptr[tx] = rgb_t(pal5bit(db), pal5bit(dg), pal5bit(dr));
}
@@ -852,11 +849,7 @@ void wecleman_state::video_start()
8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15
};
- uint8_t *buffer;
- int i, j;
-
assert(m_screen->format() == BITMAP_FORMAT_RGB32);
- buffer = auto_alloc_array(machine(), uint8_t, 0x12c00); // working buffer for sprite operations
m_gameid = WECLEMAN_ID;
m_gfx_bank = bank;
@@ -869,28 +862,6 @@ void wecleman_state::video_start()
std::fill(std::begin(m_bgpage), std::end(m_bgpage), 0);
std::fill(std::begin(m_fgpage), std::end(m_fgpage), 0);
- m_rgb_half = (uint16_t*)(buffer + 0x00000);
- m_t32x32pm = (int*)(buffer + 0x10020);
- m_spr_ptr_list = (sprite_t **)(buffer + 0x12000);
- m_spr_idx_list = (int *)(buffer + 0x12400);
- m_spr_pri_list = (int *)(buffer + 0x12800);
-
- for (i=0; i<0x8000; i++)
- {
- j = i>>1;
- m_rgb_half[i] = (j&0xf) | (j&0x1e0) | (j&0x3c00);
- }
-
- for (j=0; j<0x20; j++)
- {
- for (i=-0x1f; i<0x20; i++)
- {
- *(m_t32x32pm + (j<<6) + i) = i * j;
- }
- }
-
- m_sprite_list = std::make_unique<sprite_t []>(NUM_SPRITES);
-
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(wecleman_state::wecleman_get_bg_tile_info)),
TILEMAP_SCAN_ROWS,
/* We draw part of the road below */
@@ -956,10 +927,6 @@ void hotchase_state::video_start()
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
};
- uint8_t *buffer;
-
- buffer = auto_alloc_array(machine(), uint8_t, 0x400); // reserve 1k for sprite list
-
m_gameid = HOTCHASE_ID;
m_gfx_bank = bank;
m_spr_offsx = -0xc0;
@@ -967,10 +934,6 @@ void hotchase_state::video_start()
m_black_pen = m_palette->black_pen();
std::fill(std::begin(m_bgpage), std::end(m_bgpage), 0);
std::fill(std::begin(m_fgpage), std::end(m_fgpage), 0);
-
- m_spr_ptr_list = (sprite_t **)buffer;
-
- m_sprite_list = std::make_unique<sprite_t []>(NUM_SPRITES);
}
diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp
index 5ecab0a479b..9612b9d3700 100644
--- a/src/osd/modules/input/input_sdl.cpp
+++ b/src/osd/modules/input/input_sdl.cpp
@@ -845,7 +845,7 @@ public:
}
private:
- static keyboard_trans_table* sdlinput_read_keymap(running_machine &machine)
+ keyboard_trans_table* sdlinput_read_keymap(running_machine &machine)
{
char *keymap_filename;
FILE *keymap_file;
@@ -875,7 +875,7 @@ private:
key_trans_entries[i] = default_table[i];
// Allocate the trans table to be associated with the machine so we don't have to free it
- keyboard_trans_table *custom_table = auto_alloc(machine, keyboard_trans_table(std::move(key_trans_entries), default_table.size()));
+ m_custom_table = std::make_unique<keyboard_trans_table>(std::move(key_trans_entries), default_table.size());
while (!feof(keymap_file))
{
@@ -907,10 +907,9 @@ private:
if (sk >= 0 && index >= 0)
{
- key_trans_entry &entry = (*custom_table)[index];
+ key_trans_entry &entry = (*m_custom_table)[index];
entry.sdl_scancode = sk;
- entry.ui_name = auto_alloc_array(machine, char, strlen(kns) + 1);
- strcpy(entry.ui_name, kns);
+ entry.ui_name = const_cast<char *>(m_ui_names.emplace_back(kns).c_str());
osd_printf_verbose("Keymap: Mapped <%s> to <%s> with ui-text <%s>\n", sks, mks, kns);
}
else
@@ -922,8 +921,11 @@ private:
fclose(keymap_file);
osd_printf_verbose("Keymap: Processed %d lines\n", line);
- return custom_table;
+ return m_custom_table.get();
}
+
+ std::unique_ptr<keyboard_trans_table> m_custom_table;
+ std::list<std::string> m_ui_names;
};
//============================================================