mirror of
https://github.com/holub/mame
synced 2025-04-19 15:11:37 +03:00
Got rid of global_alloc/global_free.
The global_alloc/global_free functions have outlived their usefulness. They don't allow consistently overriding the default memory allocation behaviour because they aren't used consistently, and we don't have standard library allocator wrappers for them that we'd need to use them consistently with all the standard library containers we're using. If you need to change the default allocator behaviour, you can override the new/delete operators, and there are ways to get more fine-grained control that way. We're already doing that to pre-fill memory in debug builds. Code was already starting to depend on global_alloc/global_free wrapping new/delete. For example some parts of the code (including the UI and Windows debugger) was putting the result of global_alloc in a std::unique_ptr wrappers without custom deleters, and the SPU sound device was assuming it could use global_free to release memory allocated with operator new. There was also code misunderstanding the behaviour of global_alloc, for example the GROM port cartridge code was checking for nullptr when a failure will actually throw std::bad_alloc. As well as substituting new/delete, I've made several things use smart pointers to reduce the chance of leaks, and fixed a couple of leaks, too.
This commit is contained in:
parent
3340fc0d21
commit
4f05917494
@ -113,7 +113,7 @@ void adamnet_device::device_stop()
|
||||
|
||||
void adamnet_device::add_device(device_t *target)
|
||||
{
|
||||
auto entry = global_alloc(daisy_entry(target));
|
||||
auto entry = new daisy_entry(target);
|
||||
|
||||
entry->m_interface->m_bus = this;
|
||||
|
||||
|
@ -338,7 +338,7 @@ void cbm_iec_device::device_stop()
|
||||
|
||||
void cbm_iec_device::add_device(cbm_iec_slot_device *slot, device_t *target)
|
||||
{
|
||||
auto entry = global_alloc(daisy_entry(target));
|
||||
auto entry = new daisy_entry(target);
|
||||
|
||||
entry->m_interface->m_slot = slot;
|
||||
entry->m_interface->m_bus = this;
|
||||
|
@ -223,7 +223,7 @@ void econet_device::device_stop()
|
||||
|
||||
void econet_device::add_device(device_t *target, int address)
|
||||
{
|
||||
auto entry = global_alloc(daisy_entry(target));
|
||||
auto entry = new daisy_entry(target);
|
||||
|
||||
entry->m_interface->m_econet = this;
|
||||
entry->m_interface->m_address = address;
|
||||
|
@ -164,7 +164,7 @@ void ieee488_device::device_stop()
|
||||
|
||||
void ieee488_device::add_device(ieee488_slot_device *slot, device_t *target)
|
||||
{
|
||||
auto entry = global_alloc(daisy_entry(target));
|
||||
auto entry = new daisy_entry(target);
|
||||
|
||||
entry->m_interface->m_bus = this;
|
||||
entry->m_interface->m_slot = slot;
|
||||
|
@ -1558,13 +1558,13 @@ void ti99_cartridge_device::rpk::close()
|
||||
not a network socket)
|
||||
***************************************************************/
|
||||
|
||||
ti99_cartridge_device::rpk_socket::rpk_socket(const char* id, int length, uint8_t* contents, std::string &&pathname)
|
||||
: m_id(id), m_length(length), m_contents(contents), m_pathname(std::move(pathname))
|
||||
ti99_cartridge_device::rpk_socket::rpk_socket(const char* id, int length, std::unique_ptr<uint8_t []> &&contents, std::string &&pathname)
|
||||
: m_id(id), m_length(length), m_contents(std::move(contents)), m_pathname(std::move(pathname))
|
||||
{
|
||||
}
|
||||
|
||||
ti99_cartridge_device::rpk_socket::rpk_socket(const char* id, int length, uint8_t* contents)
|
||||
: rpk_socket(id, length, contents, "")
|
||||
ti99_cartridge_device::rpk_socket::rpk_socket(const char* id, int length, std::unique_ptr<uint8_t []> &&contents)
|
||||
: rpk_socket(id, length, std::move(contents), "")
|
||||
{
|
||||
}
|
||||
|
||||
@ -1609,7 +1609,7 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re
|
||||
util::archive_file::error ziperr;
|
||||
uint32_t crc;
|
||||
int length;
|
||||
uint8_t* contents;
|
||||
std::unique_ptr<uint8_t []> contents;
|
||||
int header;
|
||||
|
||||
// find the file attribute (required)
|
||||
@ -1635,11 +1635,11 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re
|
||||
length = zip.current_uncompressed_length();
|
||||
|
||||
// Allocate storage
|
||||
contents = global_alloc_array_clear<uint8_t>(length);
|
||||
if (contents==nullptr) throw rpk_exception(RPK_OUT_OF_MEMORY);
|
||||
try { contents = make_unique_clear<uint8_t []>(length); }
|
||||
catch (std::bad_alloc const &) { throw rpk_exception(RPK_OUT_OF_MEMORY); }
|
||||
|
||||
// and unzip file from the zip file
|
||||
ziperr = zip.decompress(contents, length);
|
||||
ziperr = zip.decompress(contents.get(), length);
|
||||
if (ziperr != util::archive_file::error::NONE)
|
||||
{
|
||||
if (ziperr == util::archive_file::error::UNSUPPORTED) throw rpk_exception(RPK_ZIP_UNSUPPORTED);
|
||||
@ -1651,7 +1651,7 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re
|
||||
if (sha1 != nullptr)
|
||||
{
|
||||
util::hash_collection actual_hashes;
|
||||
actual_hashes.compute((const uint8_t *)contents, length, util::hash_collection::HASH_TYPES_CRC_SHA1);
|
||||
actual_hashes.compute(contents.get(), length, util::hash_collection::HASH_TYPES_CRC_SHA1);
|
||||
|
||||
util::hash_collection expected_hashes;
|
||||
expected_hashes.add_from_string(util::hash_collection::HASH_SHA1, sha1, strlen(sha1));
|
||||
@ -1660,7 +1660,7 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re
|
||||
}
|
||||
|
||||
// Create a socket instance
|
||||
return std::make_unique<rpk_socket>(socketname, length, contents);
|
||||
return std::make_unique<rpk_socket>(socketname, length, std::move(contents));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1673,7 +1673,7 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re
|
||||
const char* ram_filename;
|
||||
std::string ram_pname;
|
||||
unsigned int length;
|
||||
uint8_t* contents;
|
||||
std::unique_ptr<uint8_t []> contents;
|
||||
|
||||
// find the length attribute
|
||||
length_string = ram_resource_node->get_attribute_string("length", nullptr);
|
||||
@ -1701,8 +1701,8 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re
|
||||
}
|
||||
|
||||
// Allocate memory for this resource
|
||||
contents = global_alloc_array_clear<uint8_t>(length);
|
||||
if (contents==nullptr) throw rpk_exception(RPK_OUT_OF_MEMORY);
|
||||
try { contents = make_unique_clear<uint8_t []>(length); }
|
||||
catch (std::bad_alloc const &) { throw rpk_exception(RPK_OUT_OF_MEMORY); }
|
||||
|
||||
LOGMASKED(LOG_RPK, "[RPK handler] Allocating RAM buffer (%d bytes) for socket '%s'\n", length, socketname);
|
||||
|
||||
@ -1717,10 +1717,8 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re
|
||||
// Get the file name (required if persistent)
|
||||
ram_filename = ram_resource_node->get_attribute_string("file", nullptr);
|
||||
if (ram_filename==nullptr)
|
||||
{
|
||||
global_free_array(contents);
|
||||
throw rpk_exception(RPK_INVALID_RAM_SPEC, "<ram type='persistent'> must have a 'file' attribute");
|
||||
}
|
||||
|
||||
ram_pname = std::string(system_name).append(PATH_SEPARATOR).append(ram_filename);
|
||||
// load, and fill rest with 00
|
||||
LOGMASKED(LOG_RPK, "[RPK handler] Loading NVRAM contents from '%s'\n", ram_pname.c_str());
|
||||
@ -1734,15 +1732,15 @@ std::unique_ptr<ti99_cartridge_device::rpk_socket> ti99_cartridge_device::rpk_re
|
||||
osd_file::error filerr = file.open(ram_pname);
|
||||
int bytes_read = 0;
|
||||
if (filerr == osd_file::error::NONE)
|
||||
bytes_read = file.read(contents, length);
|
||||
bytes_read = file.read(contents.get(), length);
|
||||
|
||||
// fill remaining bytes (if necessary)
|
||||
memset(((char *) contents) + bytes_read, 0x00, length - bytes_read);
|
||||
std::fill_n(&contents[bytes_read], length - bytes_read, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a socket instance
|
||||
return std::make_unique<rpk_socket>(socketname, length, contents, std::move(ram_pname));
|
||||
return std::make_unique<rpk_socket>(socketname, length, std::move(contents), std::move(ram_pname));
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
|
@ -170,21 +170,21 @@ private:
|
||||
class rpk_socket
|
||||
{
|
||||
public:
|
||||
rpk_socket(const char *id, int length, uint8_t *contents);
|
||||
rpk_socket(const char *id, int length, uint8_t *contents, std::string &&pathname);
|
||||
rpk_socket(const char *id, int length, std::unique_ptr<uint8_t []> &&contents);
|
||||
rpk_socket(const char *id, int length, std::unique_ptr<uint8_t []> &&contents, std::string &&pathname);
|
||||
~rpk_socket() {}
|
||||
|
||||
const char* id() { return m_id; }
|
||||
int get_content_length() { return m_length; }
|
||||
uint8_t* get_contents() { return m_contents; }
|
||||
uint8_t* get_contents() { return m_contents.get(); }
|
||||
bool persistent_ram() { return !m_pathname.empty(); }
|
||||
const char* get_pathname() { return m_pathname.c_str(); }
|
||||
void cleanup() { if (m_contents != nullptr) global_free_array(m_contents); }
|
||||
void cleanup() { m_contents.reset(); }
|
||||
|
||||
private:
|
||||
const char* m_id;
|
||||
uint32_t m_length;
|
||||
uint8_t* m_contents;
|
||||
std::unique_ptr<uint8_t []> m_contents;
|
||||
const std::string m_pathname;
|
||||
};
|
||||
|
||||
|
@ -121,24 +121,22 @@ void horizon_ramdisk_device::nvram_read(emu_file &file)
|
||||
int size = 2097152*(1 << ioport("HORIZONSIZE")->read());
|
||||
|
||||
// NVRAM plus ROS
|
||||
uint8_t* buffer = global_alloc_array_clear<uint8_t>(MAXSIZE + ROSSIZE);
|
||||
auto buffer = make_unique_clear<uint8_t []>(MAXSIZE + ROSSIZE);
|
||||
|
||||
memset(m_nvram->pointer(), 0, size);
|
||||
memset(m_ros->pointer(), 0, ROSSIZE);
|
||||
|
||||
// We assume the last 8K is ROS
|
||||
int filesize = file.read(buffer, MAXSIZE+ROSSIZE);
|
||||
int filesize = file.read(&buffer[0], MAXSIZE+ROSSIZE);
|
||||
int nvramsize = filesize - ROSSIZE;
|
||||
|
||||
// If there is a reasonable size
|
||||
if (nvramsize >= 0)
|
||||
{
|
||||
// Copy from buffer to NVRAM and ROS
|
||||
memcpy(m_nvram->pointer(), buffer, nvramsize);
|
||||
memcpy(m_ros->pointer(), buffer + nvramsize, ROSSIZE);
|
||||
memcpy(m_nvram->pointer(), &buffer[0], nvramsize);
|
||||
memcpy(m_ros->pointer(), &buffer[nvramsize], ROSSIZE);
|
||||
}
|
||||
|
||||
global_free_array(buffer);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -150,11 +148,11 @@ void horizon_ramdisk_device::nvram_write(emu_file &file)
|
||||
{
|
||||
int nvramsize = 2097152*(1 << ioport("HORIZONSIZE")->read());
|
||||
|
||||
uint8_t* buffer = global_alloc_array_clear<uint8_t>(nvramsize + ROSSIZE);
|
||||
memcpy(buffer, m_nvram->pointer(), nvramsize);
|
||||
memcpy(buffer + nvramsize, m_ros->pointer(), ROSSIZE);
|
||||
auto buffer = make_unique_clear<uint8_t []>(nvramsize + ROSSIZE);
|
||||
memcpy(&buffer[0], m_nvram->pointer(), nvramsize);
|
||||
memcpy(&buffer[nvramsize], m_ros->pointer(), ROSSIZE);
|
||||
|
||||
file.write(buffer, nvramsize + ROSSIZE);
|
||||
file.write(buffer.get(), nvramsize + ROSSIZE);
|
||||
}
|
||||
|
||||
void horizon_ramdisk_device::readz(offs_t offset, uint8_t *value)
|
||||
|
@ -37,7 +37,7 @@ x86log_context *x86log_create_context(const char *filename)
|
||||
x86log_context *log;
|
||||
|
||||
/* allocate the log */
|
||||
log = global_alloc_clear<x86log_context>();
|
||||
log = new x86log_context;
|
||||
|
||||
/* allocate the filename */
|
||||
log->filename.assign(filename);
|
||||
@ -59,7 +59,7 @@ void x86log_free_context(x86log_context *log) noexcept
|
||||
fclose(log->file);
|
||||
|
||||
/* free the structure */
|
||||
global_free(log);
|
||||
delete log;
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_CPU_X86LOG_H
|
||||
#define MAME_CPU_X86LOG_H
|
||||
|
||||
#ifndef __X86LOG_H__
|
||||
#define __X86LOG_H__
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cassert>
|
||||
@ -38,34 +38,34 @@ typedef uint8_t x86code;
|
||||
/* code logging info */
|
||||
struct log_comment
|
||||
{
|
||||
x86code* base;
|
||||
const char* string;
|
||||
x86code* base = nullptr;
|
||||
const char* string = nullptr;
|
||||
};
|
||||
|
||||
|
||||
/* data ranges */
|
||||
struct data_range_t
|
||||
{
|
||||
x86code* base;
|
||||
x86code* end;
|
||||
int size;
|
||||
x86code* base = nullptr;
|
||||
x86code* end = nullptr;
|
||||
int size = 0;
|
||||
};
|
||||
|
||||
|
||||
/* the code logging context */
|
||||
struct x86log_context
|
||||
{
|
||||
std::string filename; /* name of the file */
|
||||
FILE* file; /* file we are logging to */
|
||||
std::string filename; // name of the file
|
||||
FILE* file = nullptr; // file we are logging to
|
||||
|
||||
data_range_t data_range[MAX_DATA_RANGES]; /* list of data ranges */
|
||||
int data_range_count; /* number of data ranges */
|
||||
data_range_t data_range[MAX_DATA_RANGES]; // list of data ranges
|
||||
int data_range_count = 0; // number of data ranges
|
||||
|
||||
log_comment comment_list[MAX_COMMENTS]; /* list of comments */
|
||||
int comment_count; /* number of live comments */
|
||||
log_comment comment_list[MAX_COMMENTS]; // list of comments
|
||||
int comment_count = 0; // number of live comments
|
||||
|
||||
char comment_pool[COMMENT_POOL_SIZE]; /* string pool to hold comments */
|
||||
char* comment_pool_next; /* pointer to next string pool location */
|
||||
char comment_pool[COMMENT_POOL_SIZE]; // string pool to hold comments
|
||||
char* comment_pool_next = nullptr; // pointer to next string pool location
|
||||
};
|
||||
|
||||
|
||||
@ -160,4 +160,4 @@ inline void x86log_printf(x86log_context* log, const char* format, Ts&&... xs)
|
||||
fflush(log->file);
|
||||
}
|
||||
|
||||
#endif /* __X86LOG_H__ */
|
||||
#endif // MAME_CPU_X86LOG_H
|
||||
|
@ -178,7 +178,7 @@ floppy_image_device::floppy_image_device(const machine_config &mconfig, device_t
|
||||
device_image_interface(mconfig, *this),
|
||||
input_format(nullptr),
|
||||
output_format(nullptr),
|
||||
image(nullptr),
|
||||
image(),
|
||||
fif_list(nullptr),
|
||||
index_timer(nullptr),
|
||||
tracks(0),
|
||||
@ -307,7 +307,7 @@ void floppy_image_device::commit_image()
|
||||
if (err != osd_file::error::NONE)
|
||||
popmessage("Error, unable to truncate image: %d", int(err));
|
||||
|
||||
output_format->save(&io, image);
|
||||
output_format->save(&io, image.get());
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -473,12 +473,11 @@ image_init_result floppy_image_device::call_load()
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
image = global_alloc(floppy_image(tracks, sides, form_factor));
|
||||
if (!best_format->load(&io, form_factor, image))
|
||||
image = std::make_unique<floppy_image>(tracks, sides, form_factor);
|
||||
if (!best_format->load(&io, form_factor, image.get()))
|
||||
{
|
||||
seterror(IMAGE_ERROR_UNSUPPORTED, "Incompatible image format or corrupted data");
|
||||
global_free(image);
|
||||
image = nullptr;
|
||||
image.reset();
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
output_format = is_readonly() ? nullptr : best_format;
|
||||
@ -501,8 +500,7 @@ void floppy_image_device::call_unload()
|
||||
if (image) {
|
||||
if(image_dirty)
|
||||
commit_image();
|
||||
global_free(image);
|
||||
image = nullptr;
|
||||
image.reset();
|
||||
}
|
||||
|
||||
wpt = 1; // disk sleeve is covering the sensor
|
||||
@ -526,7 +524,7 @@ void floppy_image_device::call_unload()
|
||||
|
||||
image_init_result floppy_image_device::call_create(int format_type, util::option_resolution *format_options)
|
||||
{
|
||||
image = global_alloc(floppy_image(tracks, sides, form_factor));
|
||||
image = std::make_unique<floppy_image>(tracks, sides, form_factor);
|
||||
output_format = nullptr;
|
||||
|
||||
// search for a suitable format based on the extension
|
||||
|
@ -154,7 +154,7 @@ protected:
|
||||
|
||||
floppy_image_format_t *input_format;
|
||||
floppy_image_format_t *output_format;
|
||||
floppy_image *image;
|
||||
std::unique_ptr<floppy_image> image;
|
||||
char extension_list[256];
|
||||
floppy_image_format_t *fif_list;
|
||||
emu_timer *index_timer;
|
||||
|
@ -366,7 +366,7 @@ void mfm_harddisk_device::device_start()
|
||||
m_current_cylinder = m_landing_zone; // Park position
|
||||
m_spinup_timer->adjust(attotime::from_msec(m_spinupms));
|
||||
|
||||
m_cache = global_alloc(mfmhd_trackimage_cache(machine()));
|
||||
m_cache = std::make_unique<mfmhd_trackimage_cache>(machine());
|
||||
|
||||
// In 5 second periods, check whether the cache has dirty lines
|
||||
m_cache_timer->adjust(attotime::from_msec(5000), 0, attotime::from_msec(5000));
|
||||
@ -411,7 +411,7 @@ void mfm_harddisk_device::device_reset()
|
||||
|
||||
void mfm_harddisk_device::device_stop()
|
||||
{
|
||||
if (m_cache!=nullptr) global_free(m_cache);
|
||||
m_cache.reset();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1010,9 +1010,8 @@ mfmhd_trackimage_cache::~mfmhd_trackimage_cache()
|
||||
|
||||
while (current != nullptr)
|
||||
{
|
||||
global_free_array(current->encdata);
|
||||
mfmhd_trackimage* currenttmp = current->next;
|
||||
global_free(current);
|
||||
delete current;
|
||||
current = currenttmp;
|
||||
}
|
||||
}
|
||||
@ -1025,7 +1024,7 @@ void mfmhd_trackimage_cache::write_back_one()
|
||||
{
|
||||
if (current->dirty)
|
||||
{
|
||||
m_mfmhd->write_track(current->encdata, current->cylinder, current->head);
|
||||
m_mfmhd->write_track(current->encdata.get(), current->cylinder, current->head);
|
||||
current->dirty = false;
|
||||
break;
|
||||
}
|
||||
@ -1045,7 +1044,7 @@ void mfmhd_trackimage_cache::cleanup()
|
||||
if (TRACE_CACHE) m_machine.logerror("[%s:cache] MFM HD cache: evict line cylinder=%d head=%d\n", m_mfmhd->tag(), current->cylinder, current->head);
|
||||
if (current->dirty)
|
||||
{
|
||||
m_mfmhd->write_track(current->encdata, current->cylinder, current->head);
|
||||
m_mfmhd->write_track(current->encdata.get(), current->cylinder, current->head);
|
||||
current->dirty = false;
|
||||
}
|
||||
mfmhd_trackimage* currenttmp = current->next;
|
||||
@ -1087,11 +1086,11 @@ void mfmhd_trackimage_cache::init(mfm_harddisk_device* mfmhd, int tracksize, int
|
||||
{
|
||||
if (TRACE_DETAIL) m_machine.logerror("[%s:cache] MFM HD allocate cache slot\n", mfmhd->tag());
|
||||
previous = current;
|
||||
current = global_alloc(mfmhd_trackimage);
|
||||
current->encdata = global_alloc_array(uint16_t, tracksize);
|
||||
current = new mfmhd_trackimage;
|
||||
current->encdata = std::make_unique<uint16_t []>(tracksize);
|
||||
|
||||
// Load the first tracks into the slots
|
||||
state = m_mfmhd->load_track(current->encdata, cylinder, head);
|
||||
state = m_mfmhd->load_track(current->encdata.get(), cylinder, head);
|
||||
if (state != CHDERR_NONE) throw emu_fatalerror("Cannot load (c=%d,h=%d) from hard disk", cylinder, head);
|
||||
|
||||
current->dirty = false;
|
||||
@ -1148,7 +1147,7 @@ uint16_t* mfmhd_trackimage_cache::get_trackimage(int cylinder, int head)
|
||||
current->next = m_tracks; // put the previous head into the next field
|
||||
m_tracks = current; // set this line as new head
|
||||
}
|
||||
return current->encdata;
|
||||
return current->encdata.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1168,11 +1167,11 @@ uint16_t* mfmhd_trackimage_cache::get_trackimage(int cylinder, int head)
|
||||
|
||||
if (current->dirty)
|
||||
{
|
||||
m_mfmhd->write_track(current->encdata, current->cylinder, current->head);
|
||||
m_mfmhd->write_track(current->encdata.get(), current->cylinder, current->head);
|
||||
current->dirty = false;
|
||||
}
|
||||
|
||||
state = m_mfmhd->load_track(current->encdata, cylinder, head);
|
||||
state = m_mfmhd->load_track(current->encdata.get(), cylinder, head);
|
||||
|
||||
current->dirty = false;
|
||||
current->cylinder = cylinder;
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
bool dirty;
|
||||
int cylinder;
|
||||
int head;
|
||||
uint16_t* encdata; // MFM encoding per byte
|
||||
std::unique_ptr<uint16_t []> encdata; // MFM encoding per byte
|
||||
mfmhd_trackimage* next;
|
||||
};
|
||||
|
||||
@ -152,7 +152,7 @@ private:
|
||||
attotime m_settle_time;
|
||||
attotime m_step_time;
|
||||
|
||||
mfmhd_trackimage_cache* m_cache;
|
||||
std::unique_ptr<mfmhd_trackimage_cache> m_cache;
|
||||
mfmhd_image_format_t* m_format;
|
||||
|
||||
void head_move();
|
||||
|
@ -26,7 +26,7 @@ midiin_device::midiin_device(const machine_config &mconfig, const char *tag, dev
|
||||
: device_t(mconfig, MIDIIN, tag, owner, clock),
|
||||
device_image_interface(mconfig, *this),
|
||||
device_serial_interface(mconfig, *this),
|
||||
m_midi(nullptr),
|
||||
m_midi(),
|
||||
m_timer(nullptr),
|
||||
m_input_cb(*this),
|
||||
m_xmit_read(0),
|
||||
@ -43,7 +43,7 @@ void midiin_device::device_start()
|
||||
{
|
||||
m_input_cb.resolve_safe();
|
||||
m_timer = timer_alloc(0);
|
||||
m_midi = nullptr;
|
||||
m_midi.reset();
|
||||
m_timer->enable(false);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ void midiin_device::device_timer(emu_timer &timer, device_timer_id id, int param
|
||||
uint8_t buf[8192*4];
|
||||
int bytesRead;
|
||||
|
||||
if (m_midi == nullptr) {
|
||||
if (!m_midi) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -91,14 +91,13 @@ void midiin_device::device_timer(emu_timer &timer, device_timer_id id, int param
|
||||
call_load
|
||||
-------------------------------------------------*/
|
||||
|
||||
image_init_result midiin_device::call_load(void)
|
||||
image_init_result midiin_device::call_load()
|
||||
{
|
||||
m_midi = machine().osd().create_midi_device();
|
||||
|
||||
if (!m_midi->open_input(filename()))
|
||||
{
|
||||
global_free(m_midi);
|
||||
m_midi = nullptr;
|
||||
m_midi.reset();
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
@ -111,15 +110,14 @@ image_init_result midiin_device::call_load(void)
|
||||
call_unload
|
||||
-------------------------------------------------*/
|
||||
|
||||
void midiin_device::call_unload(void)
|
||||
void midiin_device::call_unload()
|
||||
{
|
||||
if (m_midi)
|
||||
{
|
||||
m_midi->close();
|
||||
global_free(m_midi);
|
||||
}
|
||||
m_timer->enable(false);
|
||||
m_midi = nullptr;
|
||||
m_midi.reset();
|
||||
m_timer->enable(false);
|
||||
}
|
||||
|
||||
void midiin_device::tra_complete()
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
|
||||
void xmit_char(uint8_t data);
|
||||
|
||||
osd_midi_device *m_midi;
|
||||
std::unique_ptr<osd_midi_device> m_midi;
|
||||
emu_timer *m_timer;
|
||||
devcb_write_line m_input_cb;
|
||||
uint8_t m_xmitring[XMIT_RING_SIZE];
|
||||
|
@ -26,7 +26,7 @@ midiout_device::midiout_device(const machine_config &mconfig, const char *tag, d
|
||||
: device_t(mconfig, MIDIOUT, tag, owner, clock),
|
||||
device_image_interface(mconfig, *this),
|
||||
device_serial_interface(mconfig, *this),
|
||||
m_midi(nullptr)
|
||||
m_midi()
|
||||
{
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ midiout_device::midiout_device(const machine_config &mconfig, const char *tag, d
|
||||
|
||||
void midiout_device::device_start()
|
||||
{
|
||||
m_midi = nullptr;
|
||||
m_midi.reset();
|
||||
}
|
||||
|
||||
void midiout_device::device_reset()
|
||||
@ -51,14 +51,13 @@ void midiout_device::device_reset()
|
||||
call_load
|
||||
-------------------------------------------------*/
|
||||
|
||||
image_init_result midiout_device::call_load(void)
|
||||
image_init_result midiout_device::call_load()
|
||||
{
|
||||
m_midi = machine().osd().create_midi_device();
|
||||
|
||||
if (!m_midi->open_output(filename()))
|
||||
{
|
||||
global_free(m_midi);
|
||||
m_midi = nullptr;
|
||||
m_midi.reset();
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
@ -69,13 +68,12 @@ image_init_result midiout_device::call_load(void)
|
||||
call_unload
|
||||
-------------------------------------------------*/
|
||||
|
||||
void midiout_device::call_unload(void)
|
||||
void midiout_device::call_unload()
|
||||
{
|
||||
if (m_midi)
|
||||
{
|
||||
m_midi->close();
|
||||
global_free(m_midi);
|
||||
m_midi = nullptr;
|
||||
m_midi.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ protected:
|
||||
virtual void rcv_complete() override; // Rx completed receiving byte
|
||||
|
||||
private:
|
||||
osd_midi_device *m_midi;
|
||||
std::unique_ptr<osd_midi_device> m_midi;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
|
@ -272,7 +272,8 @@ public:
|
||||
invalid_end,
|
||||
loopaddr,
|
||||
last_update_end;
|
||||
signed short *data,*loop,*dend;
|
||||
std::unique_ptr<signed short []> data;
|
||||
signed short *loop,*dend;
|
||||
adpcm_decoder decoder, update_decoder;
|
||||
mutable int ref_count;
|
||||
bool valid,
|
||||
@ -301,8 +302,8 @@ public:
|
||||
ref_count--;
|
||||
if (ref_count==0)
|
||||
{
|
||||
cache_size-=(dend-data)<<1;
|
||||
global_free(this);
|
||||
cache_size-=(dend-data.get())<<1;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,7 +522,7 @@ public:
|
||||
head=xam->offset;
|
||||
marker_tail=xam->prev;
|
||||
if (marker_tail) marker_tail->next=nullptr;
|
||||
global_free(xam);
|
||||
delete xam;
|
||||
}
|
||||
|
||||
// Set marker head to nullptr if the list is now empty
|
||||
@ -544,7 +545,7 @@ public:
|
||||
{
|
||||
stream_marker *m=marker_head;
|
||||
marker_head=marker_head->next;
|
||||
global_free(m);
|
||||
delete m;
|
||||
}
|
||||
|
||||
marker_head=marker_tail=nullptr;
|
||||
@ -566,7 +567,7 @@ public:
|
||||
|
||||
stream_marker *xam=marker_head;
|
||||
marker_head=xam->next;
|
||||
global_free(xam);
|
||||
delete xam;
|
||||
if (marker_head) marker_head->prev=nullptr;
|
||||
}
|
||||
|
||||
@ -606,12 +607,12 @@ static inline int clamp(const int v)
|
||||
|
||||
spu_device::sample_cache::~sample_cache()
|
||||
{
|
||||
global_free_array(data);
|
||||
data.reset();
|
||||
while (loop_cache)
|
||||
{
|
||||
sample_loop_cache *lc=loop_cache;
|
||||
loop_cache=lc->next;
|
||||
global_free(lc);
|
||||
delete lc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -623,7 +624,7 @@ signed short *spu_device::sample_cache::get_sample_pointer(const unsigned int ad
|
||||
{
|
||||
if ((addr>=start) && (addr<end))
|
||||
{
|
||||
return data+(((addr-start)>>4)*28);
|
||||
return &data[((addr-start)>>4)*28];
|
||||
} else
|
||||
{
|
||||
return nullptr;
|
||||
@ -668,9 +669,9 @@ bool spu_device::sample_cache::get_loop_pointer(cache_pointer *cp)
|
||||
|
||||
unsigned int spu_device::sample_cache::get_sample_address(const signed short *ptr) const
|
||||
{
|
||||
if ((ptr>=data) && (ptr<=dend))
|
||||
if ((ptr>=data.get()) && (ptr<=dend))
|
||||
{
|
||||
return start+(((ptr-data)/28)<<4);
|
||||
return start+(((ptr-data.get())/28)<<4);
|
||||
} else
|
||||
{
|
||||
return -1;
|
||||
@ -705,7 +706,7 @@ void spu_device::sample_cache::add_loop_cache(sample_loop_cache *lc)
|
||||
|
||||
bool spu_device::sample_cache::is_valid_pointer(signed short *ptr) const
|
||||
{
|
||||
if ((ptr>=data) && (data<=dend)) return true;
|
||||
if ((ptr>=data.get()) && (data.get()<=dend)) return true;
|
||||
for (sample_loop_cache *slc=loop_cache; slc; slc=slc->next)
|
||||
if ((ptr>=slc->data) && (ptr<(slc->data+num_loop_cache_samples)))
|
||||
return true;
|
||||
@ -720,7 +721,7 @@ bool spu_device::sample_cache::try_update(spu_device *spu)
|
||||
{
|
||||
if ((invalid_start>=start) && (invalid_end<=end))
|
||||
{
|
||||
adpcm_packet *ap=(adpcm_packet *)(spu->spu_ram+start);
|
||||
adpcm_packet *ap=(adpcm_packet *)&spu->spu_ram[start];
|
||||
unsigned int a;
|
||||
unsigned int loop=0;
|
||||
|
||||
@ -756,8 +757,8 @@ bool spu_device::sample_cache::try_update(spu_device *spu)
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
signed short *dp=data+(((invalid_start-start)>>4)*28);
|
||||
ap=(adpcm_packet *)(spu->spu_ram+invalid_start);
|
||||
signed short *dp=&data[((invalid_start-start)>>4)*28];
|
||||
ap=(adpcm_packet *)&spu->spu_ram[invalid_start];
|
||||
for (a=invalid_start; a<invalid_end; a+=16, ap++)
|
||||
dp=update_decoder.decode_packet(ap,dp);
|
||||
|
||||
@ -779,7 +780,7 @@ bool spu_device::sample_cache::try_update(spu_device *spu)
|
||||
signed short *dpend=dp+lc->len;
|
||||
unsigned int adr=lc->loopstart;
|
||||
for (unsigned int i=0; ((i<num_loop_cache_packets) && (dp<dpend)); i++, adr+=16)
|
||||
dp=tmp.decode_packet((adpcm_packet *)(spu->spu_ram+adr),dp);
|
||||
dp=tmp.decode_packet((adpcm_packet *)&spu->spu_ram[adr],dp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -847,7 +848,7 @@ bool spu_device::cache_pointer::update(spu_device *spu)
|
||||
// Cache is invalid, calculate play address offset from start of
|
||||
// old cache block
|
||||
|
||||
unsigned int off=ptr-cache->data,
|
||||
unsigned int off=ptr-cache->data.get(),
|
||||
addr=cache->start;
|
||||
|
||||
// Release cache block and get updated one
|
||||
@ -856,7 +857,7 @@ bool spu_device::cache_pointer::update(spu_device *spu)
|
||||
|
||||
// Calculate play address in new cache block
|
||||
|
||||
ptr=cache->data+off;
|
||||
ptr=&cache->data[off];
|
||||
|
||||
if (ptr>=cache->dend)
|
||||
{
|
||||
@ -870,7 +871,7 @@ bool spu_device::cache_pointer::update(spu_device *spu)
|
||||
|
||||
// Return false if we do not have a cache block or the play address is invalid
|
||||
|
||||
if ((cache) && ((ptr>=cache->data) && (ptr<cache->dend)))
|
||||
if ((cache) && ((ptr>=cache->data.get()) && (ptr<cache->dend)))
|
||||
{
|
||||
return true;
|
||||
} else
|
||||
@ -967,15 +968,15 @@ void spu_device::device_start()
|
||||
m_irq_handler.resolve_safe();
|
||||
|
||||
voice=new voiceinfo [24];
|
||||
spu_ram=new unsigned char [spu_ram_size];
|
||||
spu_ram=std::make_unique<unsigned char []>(spu_ram_size);
|
||||
|
||||
xa_buffer=new spu_stream_buffer(xa_sector_size,xa_buffer_sectors);
|
||||
cdda_buffer=new spu_stream_buffer(cdda_sector_size,cdda_buffer_sectors);
|
||||
|
||||
init_stream();
|
||||
|
||||
cache=new sample_cache *[spu_ram_size>>4];
|
||||
memset(cache,0,(spu_ram_size>>4)*sizeof(sample_cache *));
|
||||
cache=std::make_unique<sample_cache * []>(spu_ram_size>>4);
|
||||
std::fill_n(cache.get(), spu_ram_size>>4, nullptr);
|
||||
|
||||
// register save state stuff
|
||||
save_item(NAME(reg)); // this covers all spureg.* plus the reverb parameter block
|
||||
@ -1031,16 +1032,16 @@ void spu_device::device_reset()
|
||||
cdda_playing=false;
|
||||
m_cd_out_ptr = 0;
|
||||
|
||||
memset(spu_ram,0,spu_ram_size);
|
||||
memset(spu_ram.get(),0,spu_ram_size);
|
||||
memset(reg,0,0x200);
|
||||
memset(voice,0,sizeof(voiceinfo)*24);
|
||||
|
||||
spureg.status|=(1<<7)|(1<<10);
|
||||
|
||||
memset(cache,0,(spu_ram_size>>4)*sizeof(sample_cache *));
|
||||
std::fill_n(cache.get(), spu_ram_size>>4, nullptr);
|
||||
|
||||
for (auto & elem : output_buf)
|
||||
elem=new unsigned char [output_buffer_size];
|
||||
elem=std::make_unique<unsigned char []>(output_buffer_size);
|
||||
output_head=output_tail=output_size=0;
|
||||
|
||||
noise_t=0;
|
||||
@ -1058,7 +1059,7 @@ void spu_device::device_post_load()
|
||||
dirty_flags = -1;
|
||||
|
||||
// kill and reallocate reverb to avoid artifacts
|
||||
global_free(rev);
|
||||
delete rev;
|
||||
rev = new reverb(44100);
|
||||
|
||||
// and do some update processing
|
||||
@ -1074,16 +1075,16 @@ void spu_device::device_post_load()
|
||||
void spu_device::device_stop()
|
||||
{
|
||||
for (auto & elem : output_buf)
|
||||
global_free_array(elem);
|
||||
elem.reset();
|
||||
|
||||
kill_stream();
|
||||
|
||||
global_free_array(spu_ram);
|
||||
spu_ram.reset();
|
||||
invalidate_cache(0,spu_ram_size);
|
||||
global_free_array(cache);
|
||||
global_free(xa_buffer);
|
||||
global_free(cdda_buffer);
|
||||
global_free_array(voice);
|
||||
cache.reset();
|
||||
delete xa_buffer;
|
||||
delete cdda_buffer;
|
||||
delete [] voice;
|
||||
}
|
||||
//
|
||||
//
|
||||
@ -1107,7 +1108,7 @@ void spu_device::init_stream()
|
||||
|
||||
void spu_device::kill_stream()
|
||||
{
|
||||
global_free(rev);
|
||||
delete rev;
|
||||
rev=nullptr;
|
||||
}
|
||||
|
||||
@ -1262,7 +1263,7 @@ void spu_device::write_data(const unsigned short data)
|
||||
|
||||
assert(taddr<spu_ram_size);
|
||||
if (cache[taddr>>4]) flush_cache(cache[taddr>>4],taddr,taddr+2);
|
||||
*((unsigned short *)(spu_ram+taddr))=data;
|
||||
*((unsigned short *)&spu_ram[taddr])=data;
|
||||
taddr+=2;
|
||||
}
|
||||
|
||||
@ -1342,7 +1343,7 @@ spu_device::sample_cache *spu_device::get_sample_cache(const unsigned int addr)
|
||||
sc->start=addr;
|
||||
sc->loop=nullptr;
|
||||
|
||||
adpcm_packet *ap=(adpcm_packet *)(spu_ram+sc->start);
|
||||
adpcm_packet *ap=(adpcm_packet *)&spu_ram[sc->start];
|
||||
unsigned int a;
|
||||
for (a=addr; a<(512*1024); a+=16, ap++)
|
||||
{
|
||||
@ -1358,13 +1359,13 @@ spu_device::sample_cache *spu_device::get_sample_cache(const unsigned int addr)
|
||||
sc->end=(std::min)(spu_ram_size,a+16);
|
||||
|
||||
unsigned int sz=((sc->end-sc->start)>>4)*28;
|
||||
sc->data=new signed short [sz];
|
||||
sc->data=std::make_unique<signed short []>(sz);
|
||||
sample_cache::cache_size+=sz<<1;
|
||||
sc->loopaddr=loop;
|
||||
if (loop) sc->loop=sc->data+(((loop-sc->start)>>4)*28);
|
||||
if (loop) sc->loop=&sc->data[((loop-sc->start)>>4)*28];
|
||||
|
||||
signed short *dp=sc->data;
|
||||
ap=(adpcm_packet *)(spu_ram+sc->start);
|
||||
signed short *dp=sc->data.get();
|
||||
ap=(adpcm_packet *)&spu_ram[sc->start];
|
||||
|
||||
for (a=sc->start; a<sc->end; a+=16, ap++)
|
||||
dp=sc->decoder.decode_packet(ap,dp);
|
||||
@ -1389,7 +1390,7 @@ bool spu_device::translate_sample_addr(const unsigned int addr, cache_pointer *c
|
||||
cp->reset();
|
||||
if ((cp->cache=get_sample_cache(addr)))
|
||||
{
|
||||
cp->ptr=cp->cache->data+(((addr-cp->cache->start)>>4)*28);
|
||||
cp->ptr=&cp->cache->data[((addr-cp->cache->start)>>4)*28];
|
||||
cp->cache->add_ref();
|
||||
return true;
|
||||
}
|
||||
@ -1530,7 +1531,7 @@ spu_device::sample_loop_cache *spu_device::get_loop_cache(sample_cache *cache, c
|
||||
signed short *dp=lc->data;
|
||||
for (unsigned int i=0; ((i<num_loop_cache_packets) &&
|
||||
(adr<lpcache->end)); i++, adr+=16)
|
||||
dp=tmp.decode_packet((adpcm_packet *)(spu_ram+adr),dp);
|
||||
dp=tmp.decode_packet((adpcm_packet *)&spu_ram[adr],dp);
|
||||
|
||||
#ifdef log_loop_cache
|
||||
log(log_spu,"spu: add loop cache %08x %08x->%08x (end at %08x)\n",lc,lpen,lpst,adr);
|
||||
@ -1572,7 +1573,7 @@ void spu_device::update_voice_loop(const unsigned int v)
|
||||
{
|
||||
ra=spureg.voice[v].repaddr<<3;
|
||||
ra=(ra+0xf)&~0xf;
|
||||
const adpcm_packet *ap=ra?(adpcm_packet *)(spu_ram+ra):nullptr;
|
||||
const adpcm_packet *ap=ra?(adpcm_packet *)&spu_ram[ra]:nullptr;
|
||||
|
||||
if (ap)
|
||||
{
|
||||
@ -2393,8 +2394,8 @@ void spu_device::generate_xa(void *ptr, const unsigned int sz)
|
||||
// Write to SPU XA buffer (for emulation purposes - some games read this
|
||||
// back to do analysers, etc...)
|
||||
|
||||
*(signed short *)(spu_ram+xa_out_ptr)=vl;
|
||||
*(signed short *)(spu_ram+xa_out_ptr+0x800)=vr;
|
||||
*(signed short *)&spu_ram[xa_out_ptr]=vl;
|
||||
*(signed short *)&spu_ram[xa_out_ptr+0x800]=vr;
|
||||
xa_out_ptr=(xa_out_ptr+2)&0x7ff;
|
||||
|
||||
// Mix samples into output buffer
|
||||
@ -2430,7 +2431,7 @@ void spu_device::generate_xa(void *ptr, const unsigned int sz)
|
||||
{
|
||||
xa_playing=false;
|
||||
|
||||
memset(spu_ram,0,0x1000);
|
||||
memset(spu_ram.get(),0,0x1000);
|
||||
xa_out_ptr=0;
|
||||
}
|
||||
}
|
||||
@ -2465,8 +2466,8 @@ void spu_device::generate_cdda(void *ptr, const unsigned int sz)
|
||||
int16_t vr = ((sp[1]*volr)>>15);
|
||||
|
||||
// if the volume adjusted samples are stored here, vibribbon does nothing
|
||||
*(signed short *)(spu_ram+m_cd_out_ptr)=sp[0];
|
||||
*(signed short *)(spu_ram+m_cd_out_ptr+0x400)=sp[1];
|
||||
*(signed short *)&spu_ram[m_cd_out_ptr]=sp[0];
|
||||
*(signed short *)&spu_ram[m_cd_out_ptr+0x400]=sp[1];
|
||||
m_cd_out_ptr=(m_cd_out_ptr+2)&0x3ff;
|
||||
|
||||
//if((m_cd_out_ptr == ((spureg.irq_addr << 3) & ~0x400)) && (spureg.ctrl & spuctrl_irq_enable))
|
||||
@ -2575,10 +2576,10 @@ void spu_device::generate(void *ptr, const unsigned int sz)
|
||||
while ((left) && (output_size))
|
||||
{
|
||||
unsigned int n=(std::min)((std::min)(left,output_buffer_size-output_head),output_size);
|
||||
memcpy(dp,output_buf[0]+output_head,n);
|
||||
memcpy(dp,&output_buf[0][output_head],n);
|
||||
|
||||
rev->process((signed short *)dp,
|
||||
(signed short *)(output_buf[1]+output_head),
|
||||
(signed short *)&output_buf[1][output_head],
|
||||
spu_reverb_cfg,
|
||||
(signed short)spureg.rvol_l,
|
||||
(signed short)spureg.rvol_r,
|
||||
@ -2683,10 +2684,10 @@ void spu_device::process_until(const unsigned int tsample)
|
||||
process_samples=(std::min)(process_samples,
|
||||
(output_buffer_size-output_tail)>>2);
|
||||
|
||||
unsigned char *outptr=output_buf[0]+output_tail,
|
||||
*reverbptr=output_buf[1]+output_tail,
|
||||
*fmptr=output_buf[2]+output_tail,
|
||||
*noiseptr=output_buf[3]+output_tail;
|
||||
unsigned char *outptr=&output_buf[0][output_tail],
|
||||
*reverbptr=&output_buf[1][output_tail],
|
||||
*fmptr=&output_buf[2][output_tail],
|
||||
*noiseptr=&output_buf[3][output_tail];
|
||||
|
||||
output_tail+=process_samples<<2;
|
||||
output_tail&=(output_buffer_size-1);
|
||||
@ -2796,13 +2797,13 @@ void spu_device::start_dma(uint8_t *mainram, bool to_spu, uint32_t size)
|
||||
{
|
||||
invalidate_cache(st,en);
|
||||
|
||||
memcpy(spu_ram+(spureg.trans_addr<<3), mainram, size);
|
||||
memcpy(&spu_ram[spureg.trans_addr<<3], mainram, size);
|
||||
|
||||
dirty_flags|=dirtyflag_ram;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(mainram, spu_ram+(spureg.trans_addr<<3), size);
|
||||
memcpy(mainram, &spu_ram[spureg.trans_addr<<3], size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ protected:
|
||||
// internal state
|
||||
devcb_write_line m_irq_handler;
|
||||
|
||||
unsigned char *spu_ram;
|
||||
std::unique_ptr<unsigned char []> spu_ram;
|
||||
reverb *rev;
|
||||
unsigned int taddr;
|
||||
unsigned int sample_t;
|
||||
@ -73,13 +73,13 @@ protected:
|
||||
bool status_enabled, xa_playing, cdda_playing;
|
||||
int xa_voll, xa_volr, changed_xa_vol;
|
||||
voiceinfo *voice;
|
||||
sample_cache **cache;
|
||||
std::unique_ptr<sample_cache * []> cache;
|
||||
float samples_per_frame;
|
||||
float samples_per_cycle;
|
||||
|
||||
static float freq_multiplier;
|
||||
|
||||
unsigned char *output_buf[4];
|
||||
std::unique_ptr<unsigned char []> output_buf[4];
|
||||
unsigned int output_head;
|
||||
unsigned int output_tail;
|
||||
unsigned int output_size;
|
||||
|
@ -34,15 +34,11 @@ spu_device::reverb::reverb(const int hz, const int maxdelay)
|
||||
for (int c=0; c<2; c++)
|
||||
{
|
||||
for (int f=0; f<4; f++) {
|
||||
y[c][f]=new signed short [maxdelay];
|
||||
memset(y[c][f], 0, sizeof(signed short) * maxdelay);
|
||||
y[c][f]=make_unique_clear<signed short []>(maxdelay);
|
||||
}
|
||||
x[c]=new signed short [maxdelay];
|
||||
memset(x[c], 0, sizeof(signed short) * maxdelay);
|
||||
ax[c]=new signed short [maxdelay];
|
||||
memset(ax[c], 0, sizeof(signed short) * maxdelay);
|
||||
ay[c]=new signed short [maxdelay];
|
||||
memset(ay[c], 0, sizeof(signed short) * maxdelay);
|
||||
x[c]=make_unique_clear<signed short []>(maxdelay);
|
||||
ax[c]=make_unique_clear<signed short []>(maxdelay);
|
||||
ay[c]=make_unique_clear<signed short []>(maxdelay);
|
||||
}
|
||||
memset(bx1,0,sizeof(bx1));
|
||||
memset(by1,0,sizeof(by1));
|
||||
@ -54,14 +50,6 @@ spu_device::reverb::reverb(const int hz, const int maxdelay)
|
||||
|
||||
spu_device::reverb::~reverb()
|
||||
{
|
||||
for (int c=0; c<2; c++)
|
||||
{
|
||||
for (int f=0; f<4; f++)
|
||||
global_free_array(y[c][f]);
|
||||
global_free_array(x[c]);
|
||||
global_free_array(ax[c]);
|
||||
global_free_array(ay[c]);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -29,12 +29,12 @@ struct spu_device::reverb_preset
|
||||
|
||||
class spu_device::reverb
|
||||
{
|
||||
signed short
|
||||
*y[2][4],
|
||||
*x[2],
|
||||
*ax[2],
|
||||
*ay[2],
|
||||
bx1[2][2],by1[2];
|
||||
std::unique_ptr<signed short []>
|
||||
y[2][4],
|
||||
x[2],
|
||||
ax[2],
|
||||
ay[2];
|
||||
signed short bx1[2][2],by1[2];
|
||||
int yp, max_delay, sound_hz;
|
||||
typedef int comb_param[2][4];
|
||||
|
||||
|
@ -873,7 +873,7 @@ void address_map::global_mask(offs_t mask)
|
||||
|
||||
address_map_entry &address_map::operator()(offs_t start, offs_t end)
|
||||
{
|
||||
address_map_entry *ptr = global_alloc(address_map_entry(*m_device, *this, start, end));
|
||||
address_map_entry *ptr = new address_map_entry(*m_device, *this, start, end);
|
||||
m_entrylist.append(*ptr);
|
||||
return *ptr;
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ debug_view_manager::~debug_view_manager()
|
||||
{
|
||||
debug_view *oldhead = m_viewlist;
|
||||
m_viewlist = oldhead->m_next;
|
||||
global_free(oldhead);
|
||||
delete oldhead;
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,25 +340,25 @@ debug_view *debug_view_manager::alloc_view(debug_view_type type, debug_view_osd_
|
||||
switch (type)
|
||||
{
|
||||
case DVT_CONSOLE:
|
||||
return append(global_alloc(debug_view_console(machine(), osdupdate, osdprivate)));
|
||||
return append(new debug_view_console(machine(), osdupdate, osdprivate));
|
||||
|
||||
case DVT_STATE:
|
||||
return append(global_alloc(debug_view_state(machine(), osdupdate, osdprivate)));
|
||||
return append(new debug_view_state(machine(), osdupdate, osdprivate));
|
||||
|
||||
case DVT_DISASSEMBLY:
|
||||
return append(global_alloc(debug_view_disasm(machine(), osdupdate, osdprivate)));
|
||||
return append(new debug_view_disasm(machine(), osdupdate, osdprivate));
|
||||
|
||||
case DVT_MEMORY:
|
||||
return append(global_alloc(debug_view_memory(machine(), osdupdate, osdprivate)));
|
||||
return append(new debug_view_memory(machine(), osdupdate, osdprivate));
|
||||
|
||||
case DVT_LOG:
|
||||
return append(global_alloc(debug_view_log(machine(), osdupdate, osdprivate)));
|
||||
return append(new debug_view_log(machine(), osdupdate, osdprivate));
|
||||
|
||||
case DVT_BREAK_POINTS:
|
||||
return append(global_alloc(debug_view_breakpoints(machine(), osdupdate, osdprivate)));
|
||||
return append(new debug_view_breakpoints(machine(), osdupdate, osdprivate));
|
||||
|
||||
case DVT_WATCH_POINTS:
|
||||
return append(global_alloc(debug_view_watchpoints(machine(), osdupdate, osdprivate)));
|
||||
return append(new debug_view_watchpoints(machine(), osdupdate, osdprivate));
|
||||
|
||||
default:
|
||||
fatalerror("Attempt to create invalid debug view type %d\n", type);
|
||||
@ -378,7 +378,7 @@ void debug_view_manager::free_view(debug_view &view)
|
||||
if (*viewptr == &view)
|
||||
{
|
||||
*viewptr = view.m_next;
|
||||
global_free(&view);
|
||||
delete &view;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ void resource_pool::remove(void *ptr)
|
||||
// delete the object and break
|
||||
if (LOG_ALLOCS)
|
||||
fprintf(stderr, "#%06d, delete %d bytes\n", u32(deleteme->m_id), u32(deleteme->m_size));
|
||||
global_free(deleteme);
|
||||
delete deleteme;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,10 @@
|
||||
//**************************************************************************
|
||||
|
||||
// pool allocation helpers
|
||||
#define pool_alloc(_pool, _type) (_pool).add_object(global_alloc(_type))
|
||||
#define pool_alloc_clear(_pool, _type) (_pool).add_object(global_alloc_clear _type)
|
||||
#define pool_alloc_array(_pool, _type, _num) (_pool).add_array(global_alloc_array(_type,_num), (_num))
|
||||
#define pool_alloc_array_clear(_pool, _type, _num) (_pool).add_array(global_alloc_array_clear<_type>(_num), (_num))
|
||||
#define pool_alloc(_pool, _type) (_pool).add_object(new _type)
|
||||
#define pool_alloc_clear(_pool, _type) (_pool).add_object(make_unique_clear _type .release())
|
||||
#define pool_alloc_array(_pool, _type, _num) (_pool).add_array(new _type [_num], (_num))
|
||||
#define pool_alloc_array_clear(_pool, _type, _num) (_pool).add_array(make_unique_clear<_type []>(_num).release(), (_num))
|
||||
#define pool_free(_pool, v) (_pool).remove(v)
|
||||
|
||||
|
||||
|
@ -1282,7 +1282,7 @@ void ioport_field::expand_diplocation(const char *location, std::string &errorbu
|
||||
errorbuf.append(string_format("Switch location '%s' has invalid format!\n", location));
|
||||
|
||||
// allocate a new entry
|
||||
m_diploclist.append(*global_alloc(ioport_diplocation(name.c_str(), swnum, invert)));
|
||||
m_diploclist.append(*new ioport_diplocation(name.c_str(), swnum, invert));
|
||||
entries++;
|
||||
|
||||
// advance to the next item
|
||||
@ -1618,15 +1618,15 @@ ioport_port_live::ioport_port_live(ioport_port &port)
|
||||
// allocate analog state if it's analog
|
||||
analog_field *analog = nullptr;
|
||||
if (field.is_analog())
|
||||
analog = &analoglist.append(*global_alloc(analog_field(field)));
|
||||
analog = &analoglist.append(*new analog_field(field));
|
||||
|
||||
// allocate a dynamic field for reading
|
||||
if (field.has_dynamic_read())
|
||||
readlist.append(*global_alloc(dynamic_field(field)));
|
||||
readlist.append(*new dynamic_field(field));
|
||||
|
||||
// allocate a dynamic field for writing
|
||||
if (field.has_dynamic_write())
|
||||
writelist.append(*global_alloc(dynamic_field(field)));
|
||||
writelist.append(*new dynamic_field(field));
|
||||
|
||||
// let the field initialize its live state
|
||||
field.init_live_state(analog);
|
||||
@ -1956,7 +1956,7 @@ digital_joystick &ioport_manager::digjoystick(int player, int number)
|
||||
return joystick;
|
||||
|
||||
// create a new one
|
||||
return m_joystick_list.append(*global_alloc(digital_joystick(player, number)));
|
||||
return m_joystick_list.append(*new digital_joystick(player, number));
|
||||
}
|
||||
|
||||
|
||||
@ -3011,7 +3011,7 @@ ioport_configurer& ioport_configurer::field_alloc(ioport_type type, ioport_value
|
||||
// append the field
|
||||
if (type != IPT_UNKNOWN && type != IPT_UNUSED)
|
||||
m_curport->m_active |= mask;
|
||||
m_curfield = &m_curport->m_fieldlist.append(*global_alloc(ioport_field(*m_curport, type, defval, mask, string_from_token(name))));
|
||||
m_curfield = &m_curport->m_fieldlist.append(*new ioport_field(*m_curport, type, defval, mask, string_from_token(name)));
|
||||
|
||||
// reset the current setting
|
||||
m_cursetting = nullptr;
|
||||
@ -3068,7 +3068,7 @@ ioport_configurer& ioport_configurer::setting_alloc(ioport_value value, const ch
|
||||
if (m_curfield == nullptr)
|
||||
throw emu_fatalerror("alloc_setting called with no active field (value=%X name=%s)\n", value, name);
|
||||
|
||||
m_cursetting = global_alloc(ioport_setting(*m_curfield, value & m_curfield->mask(), string_from_token(name)));
|
||||
m_cursetting = new ioport_setting(*m_curfield, value & m_curfield->mask(), string_from_token(name));
|
||||
// append a new setting
|
||||
m_curfield->m_settinglist.append(*m_cursetting);
|
||||
return *this;
|
||||
|
@ -337,11 +337,10 @@ void render_texture::reset(render_manager &manager, texture_scaler_func scaler,
|
||||
void render_texture::release()
|
||||
{
|
||||
// free all scaled versions
|
||||
for (auto & elem : m_scaled)
|
||||
for (auto &elem : m_scaled)
|
||||
{
|
||||
m_manager->invalidate_all(elem.bitmap);
|
||||
global_free(elem.bitmap);
|
||||
elem.bitmap = nullptr;
|
||||
m_manager->invalidate_all(elem.bitmap.get());
|
||||
elem.bitmap.reset();
|
||||
elem.seqid = 0;
|
||||
}
|
||||
|
||||
@ -378,12 +377,9 @@ void render_texture::set_bitmap(bitmap_t &bitmap, const rectangle &sbounds, text
|
||||
// invalidate all scaled versions
|
||||
for (auto & elem : m_scaled)
|
||||
{
|
||||
if (elem.bitmap != nullptr)
|
||||
{
|
||||
m_manager->invalidate_all(elem.bitmap);
|
||||
global_free(elem.bitmap);
|
||||
}
|
||||
elem.bitmap = nullptr;
|
||||
if (elem.bitmap)
|
||||
m_manager->invalidate_all(elem.bitmap.get());
|
||||
elem.bitmap.reset();
|
||||
elem.seqid = 0;
|
||||
}
|
||||
}
|
||||
@ -460,21 +456,21 @@ void render_texture::get_scaled(u32 dwidth, u32 dheight, render_texinfo &texinfo
|
||||
|
||||
// didn't find one -- take the entry with the lowest seqnum
|
||||
for (scalenum = 0; scalenum < ARRAY_LENGTH(m_scaled); scalenum++)
|
||||
if ((lowest == -1 || m_scaled[scalenum].seqid < m_scaled[lowest].seqid) && !primlist.has_reference(m_scaled[scalenum].bitmap))
|
||||
if ((lowest == -1 || m_scaled[scalenum].seqid < m_scaled[lowest].seqid) && !primlist.has_reference(m_scaled[scalenum].bitmap.get()))
|
||||
lowest = scalenum;
|
||||
if (-1 == lowest)
|
||||
throw emu_fatalerror("render_texture::get_scaled: Too many live texture instances!");
|
||||
|
||||
// throw out any existing entries
|
||||
scaled = &m_scaled[lowest];
|
||||
if (scaled->bitmap != nullptr)
|
||||
if (scaled->bitmap)
|
||||
{
|
||||
m_manager->invalidate_all(scaled->bitmap);
|
||||
global_free(scaled->bitmap);
|
||||
m_manager->invalidate_all(scaled->bitmap.get());
|
||||
scaled->bitmap.reset();
|
||||
}
|
||||
|
||||
// allocate a new bitmap
|
||||
scaled->bitmap = global_alloc(bitmap_argb32(dwidth, dheight));
|
||||
scaled->bitmap = std::make_unique<bitmap_argb32>(dwidth, dheight);
|
||||
scaled->seqid = ++m_curseq;
|
||||
|
||||
// let the scaler do the work
|
||||
@ -482,7 +478,7 @@ void render_texture::get_scaled(u32 dwidth, u32 dheight, render_texinfo &texinfo
|
||||
}
|
||||
|
||||
// finally fill out the new info
|
||||
primlist.add_reference(scaled->bitmap);
|
||||
primlist.add_reference(scaled->bitmap.get());
|
||||
texinfo.base = &scaled->bitmap->pix(0);
|
||||
texinfo.rowpixels = scaled->bitmap->rowpixels();
|
||||
texinfo.width = dwidth;
|
||||
@ -3051,11 +3047,11 @@ done:
|
||||
//-------------------------------------------------
|
||||
|
||||
render_manager::render_manager(running_machine &machine)
|
||||
: m_machine(machine),
|
||||
m_ui_target(nullptr),
|
||||
m_live_textures(0),
|
||||
m_texture_id(0),
|
||||
m_ui_container(global_alloc(render_container(*this)))
|
||||
: m_machine(machine)
|
||||
, m_ui_target(nullptr)
|
||||
, m_live_textures(0)
|
||||
, m_texture_id(0)
|
||||
, m_ui_container(new render_container(*this))
|
||||
{
|
||||
// register callbacks
|
||||
machine.configuration().config_register("video", config_load_delegate(&render_manager::config_load, this), config_save_delegate(&render_manager::config_save, this));
|
||||
@ -3129,12 +3125,12 @@ float render_manager::max_update_rate() const
|
||||
|
||||
render_target *render_manager::target_alloc(const internal_layout *layoutfile, u32 flags)
|
||||
{
|
||||
return &m_targetlist.append(*global_alloc(render_target(*this, layoutfile, flags)));
|
||||
return &m_targetlist.append(*new render_target(*this, layoutfile, flags));
|
||||
}
|
||||
|
||||
render_target *render_manager::target_alloc(util::xml::data_node const &layout, u32 flags)
|
||||
{
|
||||
return &m_targetlist.append(*global_alloc(render_target(*this, layout, flags)));
|
||||
return &m_targetlist.append(*new render_target(*this, layout, flags));
|
||||
}
|
||||
|
||||
|
||||
@ -3251,19 +3247,9 @@ void render_manager::texture_free(render_texture *texture)
|
||||
// font_alloc - allocate a new font instance
|
||||
//-------------------------------------------------
|
||||
|
||||
render_font *render_manager::font_alloc(const char *filename)
|
||||
std::unique_ptr<render_font> render_manager::font_alloc(const char *filename)
|
||||
{
|
||||
return global_alloc(render_font(*this, filename));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// font_free - release a font instance
|
||||
//-------------------------------------------------
|
||||
|
||||
void render_manager::font_free(render_font *font)
|
||||
{
|
||||
global_free(font);
|
||||
return std::unique_ptr<render_font>(new render_font(*this, filename));
|
||||
}
|
||||
|
||||
|
||||
@ -3301,7 +3287,7 @@ void render_manager::resolve_tags()
|
||||
|
||||
render_container *render_manager::container_alloc(screen_device *screen)
|
||||
{
|
||||
auto container = global_alloc(render_container(*this, screen));
|
||||
auto container = new render_container(*this, screen);
|
||||
if (screen != nullptr)
|
||||
m_screen_container_list.append(*container);
|
||||
return container;
|
||||
|
@ -411,8 +411,8 @@ private:
|
||||
// a scaled_texture contains a single scaled entry for a texture
|
||||
struct scaled_texture
|
||||
{
|
||||
bitmap_argb32 * bitmap; // final bitmap
|
||||
u32 seqid; // sequence number
|
||||
std::unique_ptr<bitmap_argb32> bitmap; // final bitmap
|
||||
u32 seqid; // sequence number
|
||||
};
|
||||
|
||||
// internal state
|
||||
@ -1192,8 +1192,7 @@ public:
|
||||
void texture_free(render_texture *texture);
|
||||
|
||||
// fonts
|
||||
render_font *font_alloc(const char *filename = nullptr);
|
||||
void font_free(render_font *font);
|
||||
std::unique_ptr<render_font> font_alloc(const char *filename = nullptr);
|
||||
|
||||
// reference tracking
|
||||
void invalidate_all(void *refptr);
|
||||
|
@ -27,9 +27,10 @@ class render_font
|
||||
|
||||
// construction/destruction
|
||||
render_font(render_manager &manager, const char *filename);
|
||||
virtual ~render_font();
|
||||
|
||||
public:
|
||||
virtual ~render_font();
|
||||
|
||||
// getters
|
||||
render_manager &manager() const { return m_manager; }
|
||||
|
||||
|
@ -1587,9 +1587,8 @@ protected:
|
||||
// overrides
|
||||
virtual void draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
|
||||
{
|
||||
render_font *font = machine.render().font_alloc("default");
|
||||
auto font = machine.render().font_alloc("default");
|
||||
draw_text(*font, dest, bounds, m_string.c_str(), m_textalign, color(state));
|
||||
machine.render().font_free(font);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -2278,9 +2277,8 @@ protected:
|
||||
|
||||
virtual void draw(running_machine &machine, bitmap_argb32 &dest, const rectangle &bounds, int state) override
|
||||
{
|
||||
render_font *const font = machine.render().font_alloc("default");
|
||||
auto font = machine.render().font_alloc("default");
|
||||
draw_text(*font, dest, bounds, string_format("%0*d", m_digits, state).c_str(), m_textalign, color(state));
|
||||
machine.render().font_free(font);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -2375,7 +2373,7 @@ protected:
|
||||
u32 const a = c.a * 255.0f;
|
||||
|
||||
// get the width of the string
|
||||
render_font *font = machine.render().font_alloc("default");
|
||||
auto font = machine.render().font_alloc("default");
|
||||
float aspect = 1.0f;
|
||||
s32 width;
|
||||
|
||||
@ -2517,7 +2515,6 @@ protected:
|
||||
}
|
||||
|
||||
// free the temporary bitmap and font
|
||||
machine.render().font_free(font);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -2537,7 +2534,7 @@ private:
|
||||
u32 const a = c.a * 255.0f;
|
||||
|
||||
// get the width of the string
|
||||
render_font *font = machine.render().font_alloc("default");
|
||||
auto font = machine.render().font_alloc("default");
|
||||
float aspect = 1.0f;
|
||||
s32 width;
|
||||
int currx = 0;
|
||||
@ -2678,7 +2675,6 @@ private:
|
||||
}
|
||||
|
||||
// free the temporary bitmap and font
|
||||
machine.render().font_free(font);
|
||||
}
|
||||
|
||||
void load_reel_bitmap(int number)
|
||||
|
@ -1611,14 +1611,14 @@ tilemap_manager::~tilemap_manager()
|
||||
tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_mapper_delegate mapper, u16 tilewidth, u16 tileheight, u32 cols, u32 rows, tilemap_t *allocated)
|
||||
{
|
||||
if (!allocated)
|
||||
allocated = global_alloc(tilemap_t)(machine().root_device());
|
||||
allocated = new tilemap_t(machine().root_device());
|
||||
return m_tilemap_list.append(allocated->init(*this, decoder, tile_get_info, mapper, tilewidth, tileheight, cols, rows));
|
||||
}
|
||||
|
||||
tilemap_t &tilemap_manager::create(device_gfx_interface &decoder, tilemap_get_info_delegate tile_get_info, tilemap_standard_mapper mapper, u16 tilewidth, u16 tileheight, u32 cols, u32 rows, tilemap_t *allocated)
|
||||
{
|
||||
if (!allocated)
|
||||
allocated = global_alloc(tilemap_t)(machine().root_device());
|
||||
allocated = new tilemap_t(machine().root_device());
|
||||
return m_tilemap_list.append(allocated->init(*this, decoder, tile_get_info, mapper, tilewidth, tileheight, cols, rows));
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ int cli_frontend::execute(std::vector<std::string> &args)
|
||||
}
|
||||
|
||||
util::archive_file::cache_clear();
|
||||
global_free(manager);
|
||||
delete manager;
|
||||
|
||||
return m_result;
|
||||
}
|
||||
|
@ -10,38 +10,44 @@
|
||||
|
||||
#include "emu.h"
|
||||
#include "mame.h"
|
||||
#include "emuopts.h"
|
||||
#include "mameopts.h"
|
||||
#include "pluginopts.h"
|
||||
#include "osdepend.h"
|
||||
#include "validity.h"
|
||||
#include "clifront.h"
|
||||
#include "luaengine.h"
|
||||
#include <ctime>
|
||||
#include "ui/ui.h"
|
||||
|
||||
#include "ui/inifile.h"
|
||||
#include "ui/selgame.h"
|
||||
#include "ui/simpleselgame.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
#include "cheat.h"
|
||||
#include "ui/inifile.h"
|
||||
#include "clifront.h"
|
||||
#include "emuopts.h"
|
||||
#include "luaengine.h"
|
||||
#include "mameopts.h"
|
||||
#include "pluginopts.h"
|
||||
#include "validity.h"
|
||||
|
||||
#include "xmlfile.h"
|
||||
|
||||
#include "osdepend.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MACHINE MANAGER
|
||||
//**************************************************************************
|
||||
|
||||
mame_machine_manager* mame_machine_manager::m_manager = nullptr;
|
||||
mame_machine_manager *mame_machine_manager::s_manager = nullptr;
|
||||
|
||||
mame_machine_manager* mame_machine_manager::instance(emu_options &options, osd_interface &osd)
|
||||
{
|
||||
if (!m_manager)
|
||||
m_manager = global_alloc(mame_machine_manager(options, osd));
|
||||
if (!s_manager)
|
||||
s_manager = new mame_machine_manager(options, osd);
|
||||
|
||||
return m_manager;
|
||||
return s_manager;
|
||||
}
|
||||
|
||||
mame_machine_manager* mame_machine_manager::instance()
|
||||
{
|
||||
return m_manager;
|
||||
return s_manager;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -51,7 +57,7 @@ mame_machine_manager* mame_machine_manager::instance()
|
||||
mame_machine_manager::mame_machine_manager(emu_options &options,osd_interface &osd) :
|
||||
machine_manager(options, osd),
|
||||
m_plugins(std::make_unique<plugin_options>()),
|
||||
m_lua(global_alloc(lua_engine)),
|
||||
m_lua(std::make_unique<lua_engine>()),
|
||||
m_new_driver_pending(nullptr),
|
||||
m_firstrun(true),
|
||||
m_autoboot_timer(nullptr)
|
||||
@ -65,8 +71,8 @@ mame_machine_manager::mame_machine_manager(emu_options &options,osd_interface &o
|
||||
|
||||
mame_machine_manager::~mame_machine_manager()
|
||||
{
|
||||
global_free(m_lua);
|
||||
m_manager = nullptr;
|
||||
m_lua.reset();
|
||||
s_manager = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
~mame_machine_manager();
|
||||
|
||||
plugin_options &plugins() const { return *m_plugins; }
|
||||
lua_engine *lua() { return m_lua; }
|
||||
lua_engine *lua() { return m_lua.get(); }
|
||||
|
||||
virtual void update_machine() override;
|
||||
|
||||
@ -72,12 +72,12 @@ private:
|
||||
mame_machine_manager &operator=(mame_machine_manager &&) = delete;
|
||||
|
||||
std::unique_ptr<plugin_options> m_plugins; // pointer to plugin options
|
||||
lua_engine * m_lua;
|
||||
std::unique_ptr<lua_engine> m_lua;
|
||||
|
||||
const game_driver * m_new_driver_pending; // pointer to the next pending driver
|
||||
bool m_firstrun;
|
||||
|
||||
static mame_machine_manager* m_manager;
|
||||
static mame_machine_manager *s_manager;
|
||||
emu_timer *m_autoboot_timer; // autoboot timer
|
||||
std::unique_ptr<mame_ui_manager> m_ui; // internal data from ui.cpp
|
||||
std::unique_ptr<cheat_manager> m_cheat; // internal data from cheat.cpp
|
||||
|
@ -1234,7 +1234,7 @@ uint32_t menu::ui_handler(render_container &container, mame_ui_manager &mui)
|
||||
|
||||
// if we have no menus stacked up, start with the main menu
|
||||
if (!state->topmost_menu<menu>())
|
||||
state->stack_push(std::unique_ptr<menu>(global_alloc_clear<menu_main>(mui, container)));
|
||||
state->stack_push(std::unique_ptr<menu>(make_unique_clear<menu_main>(mui, container)));
|
||||
|
||||
// update the menu state
|
||||
if (state->topmost_menu<menu>())
|
||||
|
@ -100,12 +100,12 @@ public:
|
||||
template <typename T, typename... Params>
|
||||
static void stack_push(Params &&... args)
|
||||
{
|
||||
stack_push(std::unique_ptr<menu>(global_alloc_clear<T>(std::forward<Params>(args)...)));
|
||||
stack_push(std::unique_ptr<menu>(make_unique_clear<T>(std::forward<Params>(args)...)));
|
||||
}
|
||||
template <typename T, typename... Params>
|
||||
static void stack_push_special_main(Params &&... args)
|
||||
{
|
||||
std::unique_ptr<menu> ptr(global_alloc_clear<T>(std::forward<Params>(args)...));
|
||||
std::unique_ptr<menu> ptr(make_unique_clear<T>(std::forward<Params>(args)...));
|
||||
ptr->set_special_main_menu(true);
|
||||
stack_push(std::move(ptr));
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ float text_layout::actual_height() const
|
||||
void text_layout::start_new_line(text_layout::text_justify justify, float height)
|
||||
{
|
||||
// create a new line
|
||||
std::unique_ptr<line> new_line(global_alloc_clear<line>(*this, justify, actual_height(), height * yscale()));
|
||||
std::unique_ptr<line> new_line(std::make_unique<line>(*this, justify, actual_height(), height * yscale()));
|
||||
|
||||
// update the current line
|
||||
m_current_line = new_line.get();
|
||||
@ -303,7 +303,7 @@ void text_layout::start_new_line(text_layout::text_justify justify, float height
|
||||
m_truncating = false;
|
||||
|
||||
// append it
|
||||
m_lines.push_back(std::move(new_line));
|
||||
m_lines.emplace_back(std::move(new_line));
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,16 +7,17 @@
|
||||
Text functionality for MAME's crude user interface
|
||||
|
||||
***************************************************************************/
|
||||
#ifndef MAME_FRONTEND_UI_TEXT_H
|
||||
#define MAME_FRONTEND_UI_TEXT_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MAME_FRONTEND_UI_TEXT_H
|
||||
#define MAME_FRONTEND_UI_TEXT_H
|
||||
|
||||
class render_font;
|
||||
class render_container;
|
||||
|
||||
namespace ui {
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
@ -164,7 +164,7 @@ static uint32_t const mouse_bitmap[32*32] =
|
||||
|
||||
mame_ui_manager::mame_ui_manager(running_machine &machine)
|
||||
: ui_manager(machine)
|
||||
, m_font(nullptr)
|
||||
, m_font()
|
||||
, m_handler_callback(nullptr)
|
||||
, m_handler_callback_type(ui_callback_type::GENERAL)
|
||||
, m_handler_param(0)
|
||||
@ -244,11 +244,7 @@ void mame_ui_manager::exit()
|
||||
m_mouse_arrow_texture = nullptr;
|
||||
|
||||
// free the font
|
||||
if (m_font != nullptr)
|
||||
{
|
||||
machine().render().font_free(m_font);
|
||||
m_font = nullptr;
|
||||
}
|
||||
m_font.reset();
|
||||
}
|
||||
|
||||
|
||||
@ -640,9 +636,9 @@ void mame_ui_manager::update_and_render(render_container &container)
|
||||
render_font *mame_ui_manager::get_font()
|
||||
{
|
||||
// allocate the font and messagebox string
|
||||
if (m_font == nullptr)
|
||||
if (!m_font)
|
||||
m_font = machine().render().font_alloc(machine().options().ui_font());
|
||||
return m_font;
|
||||
return m_font.get();
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,7 +271,7 @@ private:
|
||||
using device_feature_set = std::set<std::pair<std::string, std::string> >;
|
||||
|
||||
// instance variables
|
||||
render_font * m_font;
|
||||
std::unique_ptr<render_font> m_font;
|
||||
handler_callback_func m_handler_callback;
|
||||
ui_callback_type m_handler_callback_type;
|
||||
uint32_t m_handler_param;
|
||||
|
@ -158,18 +158,18 @@ static floperr_t imd_expand_file(floppy_image_legacy *floppy , uint64_t offset ,
|
||||
return FLOPPY_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
auto buffer = global_alloc_array(uint8_t , size_after_off);
|
||||
auto buffer = std::make_unique<uint8_t []>(size_after_off);
|
||||
|
||||
// Read the part of file after offset
|
||||
floppy_image_read(floppy , buffer , offset , size_after_off);
|
||||
floppy_image_read(floppy, buffer.get(), offset, size_after_off);
|
||||
|
||||
// Add zeroes
|
||||
floppy_image_write_filler(floppy , 0 , offset , amount);
|
||||
floppy_image_write_filler(floppy, 0, offset, amount);
|
||||
|
||||
// Write back the part of file after offset
|
||||
floppy_image_write(floppy, buffer, offset + amount, size_after_off);
|
||||
floppy_image_write(floppy, buffer.get(), offset + amount, size_after_off);
|
||||
|
||||
global_free_array(buffer);
|
||||
buffer.reset();
|
||||
|
||||
// Update track offsets
|
||||
struct imddsk_tag *tag = get_tag(floppy);
|
||||
@ -528,7 +528,7 @@ bool imd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
|
||||
sects[i].bad_crc = stype == 5 || stype == 6 || stype == 7 || stype == 8;
|
||||
|
||||
if(stype == 2 || stype == 4 || stype == 6 || stype == 8) {
|
||||
sects[i].data = global_alloc_array(uint8_t, actual_size);
|
||||
sects[i].data = new uint8_t [actual_size];
|
||||
memset(sects[i].data, img[pos++], actual_size);
|
||||
} else {
|
||||
sects[i].data = &img[pos];
|
||||
@ -547,7 +547,7 @@ bool imd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
|
||||
|
||||
for(int i=0; i< m_sector_count.back(); i++)
|
||||
if(sects[i].data && (sects[i].data < &img[0] || sects[i].data >= (&img[0] + size)))
|
||||
global_free_array(sects[i].data);
|
||||
delete [] sects[i].data;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,12 +1,27 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Olivier Galibert
|
||||
#include <cassert>
|
||||
#include "ipf_dsk.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
||||
const floppy_format_type FLOPPY_IPF_FORMAT = &floppy_image_format_creator<ipf_format>;
|
||||
|
||||
ipf_format::ipf_format(): tinfos(nullptr), tcount(0), type(0), release(0), revision(0), encoder_type(0),
|
||||
encoder_revision(0), origin(0), min_cylinder(0), max_cylinder(0), min_head(0), max_head(0), credit_day(0), credit_time(0)
|
||||
ipf_format::ipf_format() :
|
||||
tinfos(),
|
||||
tcount(0),
|
||||
type(0),
|
||||
release(0),
|
||||
revision(0),
|
||||
encoder_type(0),
|
||||
encoder_revision(0),
|
||||
origin(0),
|
||||
min_cylinder(0),
|
||||
max_cylinder(0),
|
||||
min_head(0),
|
||||
max_head(0),
|
||||
credit_day(0),
|
||||
credit_time(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -84,12 +99,11 @@ bool ipf_format::parse(std::vector<uint8_t> &data, floppy_image *image)
|
||||
{
|
||||
image->set_variant(floppy_image::DSDD); // Not handling anything else yet
|
||||
tcount = 84*2+1; // Usual max
|
||||
tinfos = global_alloc_array_clear<track_info>(tcount);
|
||||
tinfos.resize(tcount);
|
||||
bool res = scan_all_tags(data);
|
||||
if(res)
|
||||
res = generate_tracks(image);
|
||||
global_free_array(tinfos);
|
||||
tinfos = nullptr;
|
||||
tinfos.clear();
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -121,14 +135,11 @@ ipf_format::track_info *ipf_format::get_index(uint32_t idx)
|
||||
if(idx > 1000)
|
||||
return nullptr;
|
||||
if(idx >= tcount) {
|
||||
auto ti1 = global_alloc_array_clear<track_info>(idx+1);
|
||||
memcpy(ti1, tinfos, tcount*sizeof(tinfos));
|
||||
global_free_array(tinfos);
|
||||
tinfos.resize(idx+1);
|
||||
tcount = idx+1;
|
||||
tinfos = ti1;
|
||||
}
|
||||
|
||||
return tinfos+idx;
|
||||
return &tinfos[idx];
|
||||
}
|
||||
|
||||
bool ipf_format::parse_imge(const uint8_t *imge)
|
||||
@ -246,7 +257,7 @@ bool ipf_format::scan_all_tags(std::vector<uint8_t> &data)
|
||||
bool ipf_format::generate_tracks(floppy_image *image)
|
||||
{
|
||||
for(uint32_t i = 0; i != tcount; i++) {
|
||||
track_info *t = tinfos + i;
|
||||
track_info *t = &tinfos[i];
|
||||
if(t->info_set && t->data) {
|
||||
if(!generate_track(t, image))
|
||||
return false;
|
||||
|
@ -24,22 +24,22 @@ public:
|
||||
|
||||
private:
|
||||
struct track_info {
|
||||
uint32_t cylinder, head, type;
|
||||
uint32_t sigtype, process, reserved[3];
|
||||
uint32_t size_bytes, size_cells;
|
||||
uint32_t index_bytes, index_cells;
|
||||
uint32_t datasize_cells, gapsize_cells;
|
||||
uint32_t block_count, weak_bits;
|
||||
uint32_t cylinder = 0, head = 0, type = 0;
|
||||
uint32_t sigtype = 0, process = 0, reserved[3] = { 0, 0, 0 };
|
||||
uint32_t size_bytes = 0, size_cells = 0;
|
||||
uint32_t index_bytes = 0, index_cells = 0;
|
||||
uint32_t datasize_cells = 0, gapsize_cells = 0;
|
||||
uint32_t block_count = 0, weak_bits = 0;
|
||||
|
||||
uint32_t data_size_bits;
|
||||
uint32_t data_size_bits = 0;
|
||||
|
||||
bool info_set;
|
||||
bool info_set = false;
|
||||
|
||||
const uint8_t *data;
|
||||
uint32_t data_size;
|
||||
const uint8_t *data = nullptr;
|
||||
uint32_t data_size = 0;
|
||||
};
|
||||
|
||||
track_info *tinfos;
|
||||
std::vector<track_info> tinfos;
|
||||
uint32_t tcount;
|
||||
|
||||
uint32_t type, release, revision;
|
||||
|
@ -187,8 +187,8 @@ bool mfi_format::save(io_generic *io, floppy_image *image)
|
||||
|
||||
int pos = sizeof(header) + (tracks << resolution)*heads*sizeof(entry);
|
||||
int epos = 0;
|
||||
auto precomp = global_alloc_array(uint32_t, max_track_size);
|
||||
auto postcomp = global_alloc_array(uint8_t, max_track_size*4 + 1000);
|
||||
auto precomp = std::make_unique<uint32_t []>(max_track_size);
|
||||
auto postcomp = std::make_unique<uint8_t []>(max_track_size*4 + 1000);
|
||||
|
||||
for(int track=0; track <= (tracks-1) << 2; track += 4 >> resolution)
|
||||
for(int head=0; head<heads; head++) {
|
||||
@ -199,7 +199,7 @@ bool mfi_format::save(io_generic *io, floppy_image *image)
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(precomp, &buffer[0], tsize*4);
|
||||
memcpy(&precomp[0], &buffer[0], tsize*4);
|
||||
for(int j=0; j<tsize-1; j++)
|
||||
precomp[j] = (precomp[j] & floppy_image::MG_MASK) |
|
||||
((precomp[j+1] & floppy_image::TIME_MASK) -
|
||||
@ -208,11 +208,8 @@ bool mfi_format::save(io_generic *io, floppy_image *image)
|
||||
(200000000 - (precomp[tsize-1] & floppy_image::TIME_MASK));
|
||||
|
||||
uLongf csize = max_track_size*4 + 1000;
|
||||
if(compress(postcomp, &csize, (const Bytef *)precomp, tsize*4) != Z_OK) {
|
||||
global_free_array(precomp);
|
||||
global_free_array(postcomp);
|
||||
if(compress(postcomp.get(), &csize, (const Bytef *)precomp.get(), tsize*4) != Z_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
entries[epos].offset = pos;
|
||||
entries[epos].uncompressed_size = tsize*4;
|
||||
@ -220,13 +217,11 @@ bool mfi_format::save(io_generic *io, floppy_image *image)
|
||||
entries[epos].write_splice = image->get_write_splice_position(track >> 2, head, track & 3);
|
||||
epos++;
|
||||
|
||||
io_generic_write(io, postcomp, pos, csize);
|
||||
io_generic_write(io, postcomp.get(), pos, csize);
|
||||
pos += csize;
|
||||
}
|
||||
|
||||
io_generic_write(io, entries, sizeof(header), (tracks << resolution)*heads*sizeof(entry));
|
||||
global_free_array(precomp);
|
||||
global_free_array(postcomp);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8,54 +8,24 @@
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef MAME_LIB_UTIL_COREALLOC_H
|
||||
#define MAME_LIB_UTIL_COREALLOC_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "osdcore.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// MACROS
|
||||
//**************************************************************************
|
||||
|
||||
// global allocation helpers -- use these instead of new and delete
|
||||
#define global_alloc(Type) new Type
|
||||
#define global_alloc_array(Type, Num) new Type[Num]
|
||||
#define global_free(Ptr) do { delete Ptr; } while (0)
|
||||
#define global_free_array(Ptr) do { delete[] Ptr; } while (0)
|
||||
|
||||
|
||||
|
||||
template<typename T, typename... Params>
|
||||
inline T* global_alloc_clear(Params &&... args)
|
||||
{
|
||||
void *const ptr = ::operator new(sizeof(T)); // allocate memory
|
||||
std::memset(ptr, 0, sizeof(T));
|
||||
return new(ptr) T(std::forward<Params>(args)...);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T* global_alloc_array_clear(std::size_t num)
|
||||
{
|
||||
auto const size = sizeof(T) * num;
|
||||
void *const ptr = new unsigned char[size]; // allocate memory
|
||||
std::memset(ptr, 0, size);
|
||||
return new(ptr) T[num]();
|
||||
}
|
||||
|
||||
|
||||
// global allocation helpers
|
||||
|
||||
template<typename Tp> struct MakeUniqClearT { typedef std::unique_ptr<Tp> single_object; };
|
||||
|
||||
|
@ -202,7 +202,7 @@ public:
|
||||
if (m_tail == &toreplace)
|
||||
m_tail = &object;
|
||||
object.m_next = toreplace.m_next;
|
||||
global_free(&toreplace);
|
||||
delete &toreplace;
|
||||
return object;
|
||||
}
|
||||
return append(object);
|
||||
@ -253,7 +253,7 @@ public:
|
||||
// remove the given object and free its memory
|
||||
void remove(ElementType &object) noexcept
|
||||
{
|
||||
global_free(&detach(object));
|
||||
delete &detach(object);
|
||||
}
|
||||
|
||||
// find an object by index in the list
|
||||
@ -305,7 +305,7 @@ public:
|
||||
{
|
||||
ItemType *result = m_freelist.detach_head();
|
||||
if (result == nullptr)
|
||||
result = global_alloc(ItemType);
|
||||
result = new ItemType;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -438,7 +438,7 @@ public:
|
||||
protected:
|
||||
required_device<screen_device> m_screen;
|
||||
|
||||
apollo_graphics_15i(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type);
|
||||
apollo_graphics_15i(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// device-level overrides
|
||||
virtual void device_start() override;
|
||||
@ -544,8 +544,8 @@ protected:
|
||||
|
||||
uint32_t m_color_lookup_table[16];
|
||||
|
||||
lut_fifo *m_lut_fifo;
|
||||
bt458 *m_bt458;
|
||||
std::unique_ptr<lut_fifo> m_lut_fifo;
|
||||
std::unique_ptr<bt458> m_bt458;
|
||||
};
|
||||
|
||||
|
||||
|
@ -146,12 +146,12 @@ void psxcd_device::device_stop()
|
||||
for (int i = 0; i < MAX_PSXCD_TIMERS; i++)
|
||||
{
|
||||
if(m_timerinuse[i] && m_timers[i]->ptr())
|
||||
global_free((command_result *)m_timers[i]->ptr());
|
||||
delete (command_result *)m_timers[i]->ptr();
|
||||
}
|
||||
while(res_queue)
|
||||
{
|
||||
command_result *res = res_queue->next;
|
||||
global_free(res_queue);
|
||||
delete res_queue;
|
||||
res_queue = res;
|
||||
}
|
||||
}
|
||||
@ -164,7 +164,7 @@ void psxcd_device::device_reset()
|
||||
for (int i = 0; i < MAX_PSXCD_TIMERS; i++)
|
||||
{
|
||||
if(m_timerinuse[i] && m_timers[i]->ptr())
|
||||
global_free((command_result *)m_timers[i]->ptr());
|
||||
delete (command_result *)m_timers[i]->ptr();
|
||||
m_timers[i]->adjust(attotime::never, 0, attotime::never);
|
||||
m_timerinuse[i] = false;
|
||||
}
|
||||
@ -175,7 +175,7 @@ void psxcd_device::device_reset()
|
||||
while(res_queue)
|
||||
{
|
||||
command_result *res = res_queue->next;
|
||||
global_free(res_queue);
|
||||
delete res_queue;
|
||||
res_queue = res;
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ void psxcd_device::write(offs_t offset, uint8_t data)
|
||||
m_int1 = nullptr;
|
||||
|
||||
res_queue = res->next;
|
||||
global_free(res);
|
||||
delete res;
|
||||
m_regs.sr &= ~0x20;
|
||||
rdp = 0;
|
||||
if(res_queue)
|
||||
@ -867,7 +867,7 @@ void psxcd_device::cmd_complete(command_result *res)
|
||||
|
||||
psxcd_device::command_result *psxcd_device::prepare_result(uint8_t res, uint8_t *data, int sz, uint8_t errcode)
|
||||
{
|
||||
auto cr=global_alloc(command_result);
|
||||
auto cr=new command_result;
|
||||
|
||||
cr->res=res;
|
||||
if (sz)
|
||||
@ -1072,7 +1072,7 @@ void psxcd_device::play_sector()
|
||||
|
||||
if ((mode&mode_report) && !(sector & 15)) // slow the int rate
|
||||
{
|
||||
auto res=global_alloc(command_result);
|
||||
auto res=new command_result;
|
||||
uint8_t track = cdrom_get_track(m_cdrom_handle, sector) + 1;
|
||||
res->res=intr_dataready;
|
||||
|
||||
|
@ -1725,25 +1725,18 @@ void apollo_graphics_15i::device_add_mconfig(machine_config &config)
|
||||
DEFINE_DEVICE_TYPE(APOLLO_GRAPHICS, apollo_graphics_15i, "apollo_graphics_15i", "Apollo Screen")
|
||||
|
||||
apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig,const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, APOLLO_GRAPHICS, tag, owner, clock),
|
||||
m_screen(*this, VIDEO_SCREEN_TAG),
|
||||
m_lut_fifo(nullptr),
|
||||
m_bt458(nullptr)
|
||||
apollo_graphics_15i(mconfig, APOLLO_GRAPHICS, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig,const char *tag, device_t *owner, uint32_t clock, device_type type) :
|
||||
apollo_graphics_15i::apollo_graphics_15i(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, type, tag, owner, clock),
|
||||
m_screen(*this, VIDEO_SCREEN_TAG),
|
||||
m_lut_fifo(nullptr),
|
||||
m_bt458(nullptr)
|
||||
m_screen(*this, VIDEO_SCREEN_TAG)
|
||||
{
|
||||
}
|
||||
|
||||
apollo_graphics_15i::~apollo_graphics_15i()
|
||||
{
|
||||
if (m_lut_fifo) global_free(m_lut_fifo);
|
||||
if (m_bt458) global_free(m_bt458);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -1798,8 +1791,8 @@ void apollo_graphics_15i::device_start()
|
||||
|
||||
memset(m_color_lookup_table, 0, sizeof(m_color_lookup_table));
|
||||
|
||||
m_lut_fifo = nullptr;
|
||||
m_bt458 = nullptr;
|
||||
m_lut_fifo.reset();
|
||||
m_bt458.reset();
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -1852,12 +1845,9 @@ void apollo_graphics_15i::device_reset()
|
||||
m_buffer_width = 1024;
|
||||
m_buffer_height = 1024;
|
||||
|
||||
if (m_lut_fifo) global_free(m_lut_fifo);
|
||||
if (m_bt458) global_free(m_bt458);
|
||||
m_lut_fifo = std::make_unique<lut_fifo>();
|
||||
|
||||
m_lut_fifo = global_alloc(lut_fifo);
|
||||
|
||||
m_bt458 = global_alloc(bt458(machine()));
|
||||
m_bt458 = std::make_unique<bt458>(machine());
|
||||
m_bt458->start();
|
||||
m_bt458->reset();
|
||||
}
|
||||
@ -1899,7 +1889,7 @@ void apollo_graphics_19i::device_add_mconfig(machine_config &config)
|
||||
DEFINE_DEVICE_TYPE(APOLLO_MONO19I, apollo_graphics_19i, "apollo_graphics_19i", "Apollo 19\" Monochrome Screen")
|
||||
|
||||
apollo_graphics_19i::apollo_graphics_19i(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
apollo_graphics_15i(mconfig, tag, owner, clock, APOLLO_MONO19I)
|
||||
apollo_graphics_15i(mconfig, APOLLO_MONO19I, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -225,11 +225,7 @@ static void view_list_remove(debug_area* item)
|
||||
|
||||
static debug_area *dview_alloc(running_machine &machine, debug_view_type type)
|
||||
{
|
||||
debug_area *dv;
|
||||
|
||||
dv = global_alloc(debug_area(machine, type));
|
||||
|
||||
return dv;
|
||||
return new debug_area(machine, type);
|
||||
}
|
||||
|
||||
static inline void map_attr_to_fg_bg(unsigned char attr, rgb_t *fg, rgb_t *bg)
|
||||
@ -1406,7 +1402,7 @@ void debug_imgui::update()
|
||||
if(to_delete != nullptr)
|
||||
{
|
||||
view_list_remove(to_delete);
|
||||
global_free(to_delete);
|
||||
delete to_delete;
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(12);
|
||||
|
@ -30,10 +30,10 @@ consolewin_info::consolewin_info(debugger_windows_interface &debugger) :
|
||||
goto cleanup;
|
||||
|
||||
// create the views
|
||||
m_views[1].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_STATE)));
|
||||
m_views[1].reset(new debugview_info(debugger, *this, window(), DVT_STATE));
|
||||
if (!m_views[1]->is_valid())
|
||||
goto cleanup;
|
||||
m_views[2].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_CONSOLE)));
|
||||
m_views[2].reset(new debugview_info(debugger, *this, window(), DVT_CONSOLE));
|
||||
if (!m_views[2]->is_valid())
|
||||
goto cleanup;
|
||||
|
||||
|
@ -26,7 +26,7 @@ disasmbasewin_info::disasmbasewin_info(debugger_windows_interface &debugger, boo
|
||||
if (!window())
|
||||
return;
|
||||
|
||||
m_views[0].reset(global_alloc(disasmview_info(debugger, *this, window())));
|
||||
m_views[0].reset(new disasmview_info(debugger, *this, window()));
|
||||
if ((m_views[0] == nullptr) || !m_views[0]->is_valid())
|
||||
{
|
||||
m_views[0].reset();
|
||||
|
@ -19,7 +19,7 @@ logwin_info::logwin_info(debugger_windows_interface &debugger) :
|
||||
if (!window())
|
||||
return;
|
||||
|
||||
m_views[0].reset(global_alloc(logview_info(debugger, *this, window())));
|
||||
m_views[0].reset(new logview_info(debugger, *this, window()));
|
||||
if ((m_views[0] == nullptr) || !m_views[0]->is_valid())
|
||||
{
|
||||
m_views[0].reset();
|
||||
|
@ -23,7 +23,7 @@ memorywin_info::memorywin_info(debugger_windows_interface &debugger) :
|
||||
if (!window())
|
||||
return;
|
||||
|
||||
m_views[0].reset(global_alloc(memoryview_info(debugger, *this, window())));
|
||||
m_views[0].reset(new memoryview_info(debugger, *this, window()));
|
||||
if ((m_views[0] == nullptr) || !m_views[0]->is_valid())
|
||||
{
|
||||
m_views[0].reset();
|
||||
|
@ -20,7 +20,7 @@ pointswin_info::pointswin_info(debugger_windows_interface &debugger) :
|
||||
if (!window())
|
||||
return;
|
||||
|
||||
m_views[0].reset(global_alloc(debugview_info(debugger, *this, window(), DVT_BREAK_POINTS)));
|
||||
m_views[0].reset(new debugview_info(debugger, *this, window(), DVT_BREAK_POINTS));
|
||||
if ((m_views[0] == nullptr) || !m_views[0]->is_valid())
|
||||
{
|
||||
m_views[0].reset();
|
||||
@ -96,7 +96,7 @@ bool pointswin_info::handle_command(WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
case ID_SHOW_BREAKPOINTS:
|
||||
m_views[0].reset();
|
||||
m_views[0].reset(global_alloc(debugview_info(debugger(), *this, window(), DVT_BREAK_POINTS)));
|
||||
m_views[0].reset(new debugview_info(debugger(), *this, window(), DVT_BREAK_POINTS));
|
||||
if (!m_views[0]->is_valid())
|
||||
m_views[0].reset();
|
||||
win_set_window_text_utf8(window(), "All Breakpoints");
|
||||
@ -105,7 +105,7 @@ bool pointswin_info::handle_command(WPARAM wparam, LPARAM lparam)
|
||||
|
||||
case ID_SHOW_WATCHPOINTS:
|
||||
m_views[0].reset();
|
||||
m_views[0].reset(global_alloc(debugview_info(debugger(), *this, window(), DVT_WATCH_POINTS)));
|
||||
m_views[0].reset(new debugview_info(debugger(), *this, window(), DVT_WATCH_POINTS));
|
||||
if (!m_views[0]->is_valid())
|
||||
m_views[0].reset();
|
||||
win_set_window_text_utf8(window(), "All Watchpoints");
|
||||
|
@ -290,42 +290,42 @@ void osd_common_t::register_options()
|
||||
int num;
|
||||
std::vector<const char *> dnames;
|
||||
|
||||
m_mod_man.get_module_names(OSD_MONITOR_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_MONITOR_PROVIDER, 20, num, names);
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
update_option(OSD_MONITOR_PROVIDER, dnames);
|
||||
|
||||
m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
update_option(OSD_FONT_PROVIDER, dnames);
|
||||
|
||||
m_mod_man.get_module_names(OSD_KEYBOARDINPUT_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_KEYBOARDINPUT_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
update_option(OSD_KEYBOARDINPUT_PROVIDER, dnames);
|
||||
|
||||
m_mod_man.get_module_names(OSD_MOUSEINPUT_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_MOUSEINPUT_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
update_option(OSD_MOUSEINPUT_PROVIDER, dnames);
|
||||
|
||||
m_mod_man.get_module_names(OSD_LIGHTGUNINPUT_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_LIGHTGUNINPUT_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
update_option(OSD_LIGHTGUNINPUT_PROVIDER, dnames);
|
||||
|
||||
m_mod_man.get_module_names(OSD_JOYSTICKINPUT_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_JOYSTICKINPUT_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
update_option(OSD_JOYSTICKINPUT_PROVIDER, dnames);
|
||||
|
||||
m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
@ -333,7 +333,7 @@ void osd_common_t::register_options()
|
||||
|
||||
#if 0
|
||||
// Register midi options and update options
|
||||
m_mod_man.get_module_names(OSD_MIDI_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_MIDI_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
@ -341,13 +341,13 @@ void osd_common_t::register_options()
|
||||
#endif
|
||||
|
||||
// Register debugger options and update options
|
||||
m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
update_option(OSD_DEBUG_PROVIDER, dnames);
|
||||
|
||||
m_mod_man.get_module_names(OSD_OUTPUT_PROVIDER, 20, &num, names);
|
||||
m_mod_man.get_module_names(OSD_OUTPUT_PROVIDER, 20, num, names);
|
||||
dnames.clear();
|
||||
for (int i = 0; i < num; i++)
|
||||
dnames.push_back(names[i]);
|
||||
|
@ -216,7 +216,7 @@ public:
|
||||
virtual osd_font::ptr font_alloc() override { return m_font_module->font_alloc(); }
|
||||
virtual bool get_font_families(std::string const &font_path, std::vector<std::pair<std::string, std::string> > &result) override { return m_font_module->get_font_families(font_path, result); }
|
||||
|
||||
virtual osd_midi_device *create_midi_device() override { return m_midi->create_midi_device(); }
|
||||
virtual std::unique_ptr<osd_midi_device> create_midi_device() override { return m_midi->create_midi_device(); }
|
||||
|
||||
// FIXME: everything below seems to be osd specific and not part of
|
||||
// this INTERFACE but part of the osd IMPLEMENTATION
|
||||
@ -311,10 +311,10 @@ private:
|
||||
|
||||
|
||||
// this template function creates a stub which constructs a debugger
|
||||
template<class _DeviceClass>
|
||||
template<class DeviceClass>
|
||||
debug_module *osd_debugger_creator()
|
||||
{
|
||||
return global_alloc(_DeviceClass());
|
||||
return new DeviceClass();
|
||||
}
|
||||
|
||||
#endif // MAME_OSD_LIB_OSDOBJ_COMMON_H
|
||||
|
@ -4,13 +4,17 @@
|
||||
* midi_module.h
|
||||
*
|
||||
*/
|
||||
#ifndef MAME_OSD_MODULES_MIDI_MIDI_MODULE_H
|
||||
#define MAME_OSD_MODULES_MIDI_MIDI_MODULE_H
|
||||
|
||||
#ifndef MIDI_MODULE_H_
|
||||
#define MIDI_MODULE_H_
|
||||
#pragma once
|
||||
|
||||
#include "osdepend.h"
|
||||
#include "modules/osdmodule.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
//============================================================
|
||||
// CONSTANTS
|
||||
//============================================================
|
||||
@ -23,10 +27,9 @@ public:
|
||||
virtual ~midi_module() { }
|
||||
// specific routines
|
||||
|
||||
virtual osd_midi_device *create_midi_device() = 0;
|
||||
virtual std::unique_ptr<osd_midi_device> create_midi_device() = 0;
|
||||
// FIXME: should return a list of strings ...
|
||||
virtual void list_midi_devices(void) = 0;
|
||||
virtual void list_midi_devices() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MIDI_MODULE_H_ */
|
||||
#endif // MAME_OSD_MODULES_MIDI_MIDI_MODULE_H
|
||||
|
@ -17,8 +17,7 @@ class none_module : public osd_module, public midi_module
|
||||
{
|
||||
public:
|
||||
|
||||
none_module()
|
||||
: osd_module(OSD_MIDI_PROVIDER, "pm"), midi_module()
|
||||
none_module() : osd_module(OSD_MIDI_PROVIDER, "pm"), midi_module()
|
||||
{
|
||||
}
|
||||
virtual ~none_module() { }
|
||||
@ -26,7 +25,7 @@ public:
|
||||
virtual int init(const osd_options &options) override;
|
||||
virtual void exit() override;
|
||||
|
||||
virtual osd_midi_device *create_midi_device() override;
|
||||
virtual std::unique_ptr<osd_midi_device> create_midi_device() override;
|
||||
virtual void list_midi_devices() override;
|
||||
};
|
||||
|
||||
@ -43,9 +42,9 @@ public:
|
||||
virtual void write(uint8_t data) override;
|
||||
};
|
||||
|
||||
osd_midi_device *none_module::create_midi_device()
|
||||
std::unique_ptr<osd_midi_device> none_module::create_midi_device()
|
||||
{
|
||||
return global_alloc(osd_midi_device_none());
|
||||
return std::make_unique<osd_midi_device_none>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
virtual int init(const osd_options &options)override;
|
||||
virtual void exit()override;
|
||||
|
||||
virtual osd_midi_device *create_midi_device() override;
|
||||
virtual std::unique_ptr<osd_midi_device> create_midi_device() override;
|
||||
virtual void list_midi_devices() override;
|
||||
};
|
||||
|
||||
@ -60,9 +60,9 @@ private:
|
||||
bool rx_sysex;
|
||||
};
|
||||
|
||||
osd_midi_device *pm_module::create_midi_device()
|
||||
std::unique_ptr<osd_midi_device> pm_module::create_midi_device()
|
||||
{
|
||||
return global_alloc(osd_midi_device_pm());
|
||||
return std::make_unique<osd_midi_device_pm>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -250,7 +250,7 @@ netdev_pcap::~netdev_pcap()
|
||||
|
||||
static CREATE_NETDEV(create_pcap)
|
||||
{
|
||||
auto *dev = global_alloc(netdev_pcap(ifname, ifdev, rate));
|
||||
auto *dev = new netdev_pcap(ifname, ifdev, rate);
|
||||
return dynamic_cast<osd_netdev *>(dev);
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ int netdev_tap::recv_dev(uint8_t **buf)
|
||||
|
||||
static CREATE_NETDEV(create_tap)
|
||||
{
|
||||
auto *dev = global_alloc(netdev_tap(ifname, ifdev, rate));
|
||||
auto *dev = new netdev_tap(ifname, ifdev, rate);
|
||||
return dynamic_cast<osd_netdev *>(dev);
|
||||
}
|
||||
|
||||
|
@ -12,36 +12,23 @@
|
||||
|
||||
osd_module_manager::osd_module_manager()
|
||||
{
|
||||
for (int i=0; i<MAX_MODULES; i++)
|
||||
{
|
||||
m_modules[i] = nullptr;
|
||||
m_selected[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
osd_module_manager::~osd_module_manager()
|
||||
{
|
||||
for (int i = 0; m_modules[i] != nullptr; i++)
|
||||
{
|
||||
global_free(m_modules[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void osd_module_manager::register_module(const module_type &mod_type)
|
||||
{
|
||||
auto const slot = std::find(std::begin(m_modules), std::end(m_modules), nullptr);
|
||||
if (std::end(m_modules) == slot)
|
||||
throw emu_fatalerror("osd_module_manager::register_module: Module registration beyond MAX_MODULES!");
|
||||
|
||||
osd_module *module = mod_type();
|
||||
std::unique_ptr<osd_module> module = mod_type();
|
||||
if (module->probe())
|
||||
{
|
||||
osd_printf_verbose("===> registered module %s %s\n", module->name(), module->type());
|
||||
*slot = module;
|
||||
m_modules.emplace_back(std::move(module));
|
||||
}
|
||||
else
|
||||
{
|
||||
osd_printf_verbose("===> not supported %s %s\n", module->name(), module->type());
|
||||
global_free(module);
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +41,7 @@ osd_module *osd_module_manager::get_module_generic(const char *type, const char
|
||||
{
|
||||
int const i = get_module_index(type, name);
|
||||
if (i >= 0)
|
||||
return m_modules[i];
|
||||
return m_modules[i].get();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
@ -64,54 +51,43 @@ osd_module *osd_module_manager::select_module(const char *type, const char *name
|
||||
osd_module *m = get_module_generic(type, name);
|
||||
|
||||
// FIXME: check if already exists!
|
||||
int i;
|
||||
for (i = 0; m_selected[i] != nullptr; i++)
|
||||
;
|
||||
m_selected[i] = m;
|
||||
if (m)
|
||||
m_selected.emplace_back(*m);
|
||||
return m;
|
||||
}
|
||||
|
||||
void osd_module_manager::init(const osd_options &options)
|
||||
{
|
||||
for (int i = 0; m_selected[i] != nullptr; i++)
|
||||
{
|
||||
m_selected[i]->init(options);
|
||||
}
|
||||
for (osd_module &m : m_selected)
|
||||
m.init(options);
|
||||
}
|
||||
|
||||
void osd_module_manager::exit()
|
||||
{
|
||||
// Find count
|
||||
int cnt;
|
||||
for (cnt = 0; m_selected[cnt] != nullptr; cnt++)
|
||||
;
|
||||
for (int i = cnt - 1; i >= 0; i--)
|
||||
while (!m_selected.empty())
|
||||
{
|
||||
m_selected[i]->exit();
|
||||
m_selected[i] = nullptr;
|
||||
m_selected.back().get().exit();
|
||||
m_selected.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
int osd_module_manager::get_module_index(const char *type, const char *name) const
|
||||
{
|
||||
for (int i = 0; m_modules[i] != nullptr; i++)
|
||||
for (int i = 0; m_modules.size() > i; i++)
|
||||
{
|
||||
if (strcmp(m_modules[i]->type(), type) == 0 && ((name[0] == 0) || (strcmp(name, m_modules[i]->name())==0)))
|
||||
if ((m_modules[i]->type() == type) && (!name[0] || (m_modules[i]->name() == name)))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void osd_module_manager::get_module_names(const char *type, const int max, int *num, const char *names[]) const
|
||||
void osd_module_manager::get_module_names(const char *type, const int max, int &num, const char *names[]) const
|
||||
{
|
||||
*num = 0;
|
||||
for (int i = 0; m_modules[i] != nullptr; i++)
|
||||
num = 0;
|
||||
for (int i = 0; (m_modules.size() > i) && (max > num); i++)
|
||||
{
|
||||
if ((strcmp(m_modules[i]->type(), type) == 0) && (*num < max))
|
||||
{
|
||||
names[*num] = m_modules[i]->name();
|
||||
*num = *num + 1;
|
||||
}
|
||||
|
||||
if (m_modules[i]->type() == type)
|
||||
names[num++] = m_modules[i]->name().c_str();
|
||||
}
|
||||
}
|
||||
|
@ -7,62 +7,63 @@
|
||||
OSD module management
|
||||
|
||||
*******************************************************************c********/
|
||||
|
||||
//#pragma once
|
||||
|
||||
#ifndef MAME_OSD_MODULES_OSDMODULE_H
|
||||
#define MAME_OSD_MODULES_OSDMODULE_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "osdcore.h"
|
||||
#include "osdepend.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
//============================================================
|
||||
// TYPE DEFINITIONS
|
||||
//============================================================
|
||||
|
||||
class osd_options;
|
||||
class osd_module;
|
||||
|
||||
// ======================> osd_module
|
||||
|
||||
class osd_module
|
||||
{
|
||||
public:
|
||||
|
||||
osd_module(const char *type, const char *name)
|
||||
: m_name(name), m_type(type)
|
||||
{}
|
||||
virtual ~osd_module() { }
|
||||
|
||||
const char * name() const { return m_name.c_str(); }
|
||||
const char * type() const { return m_type.c_str(); }
|
||||
std::string const &name() const { return m_name; }
|
||||
std::string const &type() const { return m_type; }
|
||||
|
||||
virtual bool probe() { return true; }
|
||||
|
||||
virtual int init(const osd_options &options) = 0;
|
||||
virtual void exit() { }
|
||||
|
||||
protected:
|
||||
osd_module(const char *type, const char *name) : m_name(name), m_type(type) { }
|
||||
osd_module(osd_module const &) = delete;
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::string m_type;
|
||||
std::string const m_name;
|
||||
std::string const m_type;
|
||||
};
|
||||
|
||||
// a module_type is simply a pointer to its alloc function
|
||||
typedef osd_module *(*module_type)();
|
||||
typedef std::unique_ptr<osd_module> (*module_type)();
|
||||
|
||||
// this template function creates a stub which constructs a module
|
||||
template<class ModuleClass>
|
||||
osd_module *module_creator()
|
||||
template <class ModuleClass>
|
||||
std::unique_ptr<osd_module> module_creator()
|
||||
{
|
||||
return global_alloc(ModuleClass());
|
||||
return std::unique_ptr<osd_module>(new ModuleClass);
|
||||
}
|
||||
|
||||
class osd_module_manager
|
||||
{
|
||||
public:
|
||||
|
||||
static const int MAX_MODULES = 64;
|
||||
|
||||
osd_module_manager();
|
||||
~osd_module_manager();
|
||||
|
||||
@ -79,7 +80,7 @@ public:
|
||||
|
||||
osd_module *select_module(const char *type, const char *name = "");
|
||||
|
||||
void get_module_names(const char *type, const int max, int *num, const char *names[]) const;
|
||||
void get_module_names(const char *type, const int max, int &num, const char *names[]) const;
|
||||
|
||||
void init(const osd_options &options);
|
||||
|
||||
@ -88,8 +89,8 @@ public:
|
||||
private:
|
||||
int get_module_index(const char *type, const char *name) const;
|
||||
|
||||
osd_module *m_modules[MAX_MODULES];
|
||||
osd_module *m_selected[MAX_MODULES];
|
||||
std::vector<std::unique_ptr<osd_module> > m_modules;
|
||||
std::vector<std::reference_wrapper<osd_module> > m_selected;
|
||||
};
|
||||
|
||||
#define MODULE_DEFINITION(mod_id, mod_class) \
|
||||
|
@ -162,7 +162,7 @@ void output_win32::exit()
|
||||
{
|
||||
registered_client *temp = m_clientlist;
|
||||
m_clientlist = temp->next;
|
||||
global_free(temp);
|
||||
delete temp;
|
||||
}
|
||||
|
||||
// broadcast a shutdown message
|
||||
@ -266,7 +266,7 @@ LRESULT output_win32::register_client(HWND hwnd, LPARAM id)
|
||||
}
|
||||
|
||||
// add us to the end
|
||||
*client = global_alloc(registered_client);
|
||||
*client = new registered_client;
|
||||
(*client)->next = nullptr;
|
||||
(*client)->id = id;
|
||||
(*client)->hwnd = hwnd;
|
||||
@ -293,7 +293,7 @@ LRESULT output_win32::unregister_client(HWND hwnd, LPARAM id)
|
||||
{
|
||||
registered_client *temp = *client;
|
||||
*client = (*client)->next;
|
||||
global_free(temp);
|
||||
delete temp;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ shaders::~shaders()
|
||||
|
||||
if (options != nullptr)
|
||||
{
|
||||
global_free(options);
|
||||
delete options;
|
||||
options = nullptr;
|
||||
}
|
||||
}
|
||||
@ -499,7 +499,7 @@ bool shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r
|
||||
snap_width = winoptions.d3d_snap_width();
|
||||
snap_height = winoptions.d3d_snap_height();
|
||||
|
||||
this->options = (hlsl_options*)global_alloc_clear<hlsl_options>();
|
||||
this->options = make_unique_clear<hlsl_options>().release();
|
||||
this->options->params_init = false;
|
||||
|
||||
// copy last options if initialized
|
||||
|
@ -335,7 +335,7 @@ int renderer_sdl2::RendererSupportsFormat(Uint32 format, Uint32 access, const ch
|
||||
|
||||
void renderer_sdl2::add_list(copy_info_t **head, const copy_info_t *element, Uint32 bm)
|
||||
{
|
||||
copy_info_t *newci = global_alloc(copy_info_t);
|
||||
copy_info_t *newci = new copy_info_t;
|
||||
*newci = *element;
|
||||
|
||||
newci->bm_mask = bm;
|
||||
@ -917,7 +917,7 @@ void renderer_sdl2::exit()
|
||||
(int) bi->perf);
|
||||
copy_info_t *freeme = bi;
|
||||
bi = bi->next;
|
||||
global_free(freeme);
|
||||
delete freeme;
|
||||
}
|
||||
s_blit_info[i] = nullptr;
|
||||
}
|
||||
@ -942,7 +942,7 @@ texture_info * renderer_sdl2::texture_update(const render_primitive &prim)
|
||||
// if we didn't find one, create a new texture
|
||||
if (texture == nullptr && prim.texture.base != nullptr)
|
||||
{
|
||||
texture = global_alloc(texture_info(this, prim.texture, setup, prim.flags));
|
||||
texture = new texture_info(this, prim.texture, setup, prim.flags);
|
||||
/* add us to the texture list */
|
||||
m_texlist.prepend(*texture);
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_OSD_MODULES_RENDER_DRAW13_H
|
||||
#define MAME_OSD_MODULES_RENDER_DRAW13_H
|
||||
|
||||
#ifndef __DRAW20__
|
||||
#define __DRAW20__
|
||||
#pragma once
|
||||
|
||||
// OSD headers
|
||||
#ifndef OSD_WINDOWS
|
||||
@ -210,4 +210,4 @@ private:
|
||||
static const copy_info_t s_blit_info_default[];
|
||||
};
|
||||
|
||||
#endif // __DRAW20__
|
||||
#endif // MAME_OSD_MODULES_RENDER_DRAW13_H
|
||||
|
@ -118,7 +118,7 @@ static inline uint32_t ycc_to_rgb(uint8_t y, uint8_t cb, uint8_t cr)
|
||||
// drawd3d_init
|
||||
//============================================================
|
||||
|
||||
static d3d_base * d3dintf; // FIX ME
|
||||
static d3d_base *d3dintf = nullptr; // FIX ME
|
||||
|
||||
|
||||
//============================================================
|
||||
@ -202,14 +202,15 @@ render_primitive_list *renderer_d3d9::get_primitives()
|
||||
|
||||
bool renderer_d3d9::init(running_machine &machine)
|
||||
{
|
||||
d3dintf = global_alloc(d3d_base);
|
||||
d3dintf = new d3d_base;
|
||||
|
||||
d3dintf->d3d9_dll = osd::dynamic_module::open({ "d3d9.dll" });
|
||||
|
||||
d3d9_create_fn d3d9_create_ptr = d3dintf->d3d9_dll->bind<d3d9_create_fn>("Direct3DCreate9");
|
||||
if (d3d9_create_ptr == nullptr)
|
||||
{
|
||||
global_free(d3dintf);
|
||||
delete d3dintf;
|
||||
d3dintf = nullptr;
|
||||
osd_printf_verbose("Direct3D: Unable to find Direct3D 9 runtime library\n");
|
||||
return true;
|
||||
}
|
||||
@ -217,7 +218,8 @@ bool renderer_d3d9::init(running_machine &machine)
|
||||
d3dintf->d3dobj = (*d3d9_create_ptr)(D3D_SDK_VERSION);
|
||||
if (d3dintf->d3dobj == nullptr)
|
||||
{
|
||||
global_free(d3dintf);
|
||||
delete d3dintf;
|
||||
d3dintf = nullptr;
|
||||
osd_printf_verbose("Direct3D: Unable to initialize Direct3D 9\n");
|
||||
return true;
|
||||
}
|
||||
@ -462,7 +464,7 @@ void d3d_texture_manager::create_resources()
|
||||
void d3d_texture_manager::delete_resources()
|
||||
{
|
||||
// is part of m_texlist and will be free'd there
|
||||
//global_free(m_default_texture);
|
||||
//delete m_default_texture;
|
||||
m_default_texture = nullptr;
|
||||
|
||||
// free all textures
|
||||
@ -505,7 +507,7 @@ renderer_d3d9::renderer_d3d9(std::shared_ptr<osd_window> window)
|
||||
: osd_renderer(window, FLAG_NONE), m_adapter(0), m_width(0), m_height(0), m_refresh(0), m_create_error_count(0), m_device(nullptr), m_gamma_supported(0), m_pixformat(),
|
||||
m_vertexbuf(nullptr), m_lockedbuf(nullptr), m_numverts(0), m_vectorbatch(nullptr), m_batchindex(0), m_numpolys(0), m_toggle(false),
|
||||
m_screen_format(), m_last_texture(nullptr), m_last_texture_flags(0), m_last_blendenable(0), m_last_blendop(0), m_last_blendsrc(0), m_last_blenddst(0), m_last_filter(0),
|
||||
m_last_wrap(), m_last_modmode(0), m_shaders(nullptr), m_texture_manager(nullptr)
|
||||
m_last_wrap(), m_last_modmode(0), m_shaders(nullptr), m_texture_manager()
|
||||
{
|
||||
}
|
||||
|
||||
@ -811,7 +813,7 @@ int renderer_d3d9::device_create(HWND hwnd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_texture_manager = global_alloc(d3d_texture_manager(this));
|
||||
m_texture_manager = std::make_unique<d3d_texture_manager>(this);
|
||||
|
||||
// try for XRGB first
|
||||
m_screen_format = D3DFMT_X8R8G8B8;
|
||||
@ -871,7 +873,7 @@ int renderer_d3d9::device_create_resources()
|
||||
// create shaders only once
|
||||
if (m_shaders == nullptr)
|
||||
{
|
||||
m_shaders = (shaders*)global_alloc_clear<shaders>();
|
||||
m_shaders = new shaders;
|
||||
}
|
||||
|
||||
if (m_shaders->init(d3dintf, &win->machine(), this))
|
||||
@ -962,7 +964,7 @@ renderer_d3d9::~renderer_d3d9()
|
||||
//if (m_shaders != nullptr)
|
||||
//{
|
||||
// // delete the HLSL interface
|
||||
// global_free(m_shaders);
|
||||
// delete m_shaders;
|
||||
// m_shaders = nullptr;
|
||||
//}
|
||||
}
|
||||
@ -972,7 +974,7 @@ void renderer_d3d9::exit()
|
||||
if (d3dintf != nullptr)
|
||||
{
|
||||
d3dintf->d3dobj->Release();
|
||||
global_free(d3dintf);
|
||||
delete d3dintf;
|
||||
d3dintf = nullptr;
|
||||
}
|
||||
}
|
||||
@ -984,11 +986,7 @@ void renderer_d3d9::device_delete()
|
||||
|
||||
// we do not delete the HLSL interface here
|
||||
|
||||
if (m_texture_manager != nullptr)
|
||||
{
|
||||
global_free(m_texture_manager);
|
||||
m_texture_manager = nullptr;
|
||||
}
|
||||
m_texture_manager.reset();
|
||||
|
||||
// free the device itself
|
||||
if (m_device != nullptr)
|
||||
|
@ -5,11 +5,11 @@
|
||||
// drawd3d.h - Win32 Direct3D header
|
||||
//
|
||||
//============================================================
|
||||
#ifndef MAME_OSD_MODULES_RENDER_DRAWD3D_H
|
||||
#define MAME_OSD_MODULES_RENDER_DRAWD3D_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __WIN_DRAWD3D__
|
||||
#define __WIN_DRAWD3D__
|
||||
|
||||
#ifdef OSD_WINDOWS
|
||||
|
||||
@ -127,7 +127,7 @@ public:
|
||||
|
||||
uint32_t get_last_texture_flags() const { return m_last_texture_flags; }
|
||||
|
||||
d3d_texture_manager * get_texture_manager() const { return m_texture_manager; }
|
||||
d3d_texture_manager * get_texture_manager() const { return m_texture_manager.get(); }
|
||||
texture_info * get_default_texture();
|
||||
|
||||
shaders * get_shaders() const { return m_shaders; }
|
||||
@ -171,9 +171,9 @@ private:
|
||||
|
||||
shaders * m_shaders; // HLSL interface
|
||||
|
||||
d3d_texture_manager * m_texture_manager; // texture manager
|
||||
std::unique_ptr<d3d_texture_manager> m_texture_manager; // texture manager
|
||||
};
|
||||
|
||||
#endif // OSD_WINDOWS
|
||||
|
||||
#endif // __WIN_DRAWD3D__
|
||||
#endif // MAME_OSD_MODULES_RENDER_DRAWD3D_H
|
||||
|
@ -16,9 +16,6 @@
|
||||
|
||||
renderer_gdi::~renderer_gdi()
|
||||
{
|
||||
// free the bitmap memory
|
||||
if (m_bmdata != nullptr)
|
||||
global_free_array(m_bmdata);
|
||||
}
|
||||
|
||||
//============================================================
|
||||
@ -83,13 +80,13 @@ int renderer_gdi::draw(const int update)
|
||||
if (pitch * height * 4 > m_bmsize)
|
||||
{
|
||||
m_bmsize = pitch * height * 4 * 2;
|
||||
global_free_array(m_bmdata);
|
||||
m_bmdata = global_alloc_array(uint8_t, m_bmsize);
|
||||
m_bmdata.reset();
|
||||
m_bmdata = std::make_unique<uint8_t []>(m_bmsize);
|
||||
}
|
||||
|
||||
// draw the primitives to the bitmap
|
||||
win->m_primlist->acquire_lock();
|
||||
software_renderer<uint32_t, 0,0,0, 16,8,0>::draw_primitives(*win->m_primlist, m_bmdata, width, height, pitch);
|
||||
software_renderer<uint32_t, 0,0,0, 16,8,0>::draw_primitives(*win->m_primlist, m_bmdata.get(), width, height, pitch);
|
||||
win->m_primlist->release_lock();
|
||||
|
||||
// fill in bitmap-specific info
|
||||
@ -97,8 +94,9 @@ int renderer_gdi::draw(const int update)
|
||||
m_bminfo.bmiHeader.biHeight = -height;
|
||||
|
||||
// blit to the screen
|
||||
StretchDIBits(win->m_dc, 0, 0, width, height,
|
||||
0, 0, width, height,
|
||||
m_bmdata, &m_bminfo, DIB_RGB_COLORS, SRCCOPY);
|
||||
StretchDIBits(
|
||||
win->m_dc, 0, 0, width, height,
|
||||
0, 0, width, height,
|
||||
m_bmdata.get(), &m_bminfo, DIB_RGB_COLORS, SRCCOPY);
|
||||
return 0;
|
||||
}
|
||||
|
@ -5,11 +5,11 @@
|
||||
// drawgdi.h - Win32 GDI drawing
|
||||
//
|
||||
//============================================================
|
||||
#ifndef MAME_OSD_MODULES_RENDER_DRAWGDI_H
|
||||
#define MAME_OSD_MODULES_RENDER_DRAWGDI_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWGDI__
|
||||
#define __DRAWGDI__
|
||||
|
||||
// standard windows headers
|
||||
#include <windows.h>
|
||||
@ -47,9 +47,9 @@ public:
|
||||
virtual void toggle_fsfx() override {};
|
||||
|
||||
private:
|
||||
BITMAPINFO m_bminfo;
|
||||
uint8_t * m_bmdata;
|
||||
size_t m_bmsize;
|
||||
BITMAPINFO m_bminfo;
|
||||
std::unique_ptr<uint8_t []> m_bmdata;
|
||||
size_t m_bmsize;
|
||||
};
|
||||
|
||||
#endif // __DRAWGDI__
|
||||
#endif // MAME_OSD_MODULES_RENDER_DRAWGDI_H
|
||||
|
@ -307,7 +307,7 @@ renderer_ogl::~renderer_ogl()
|
||||
// free the memory in the window
|
||||
destroy_all_textures();
|
||||
|
||||
global_free(m_gl_context);
|
||||
delete m_gl_context;
|
||||
m_gl_context = nullptr;
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ static void loadgl_functions(osd_gl_context *context)
|
||||
//============================================================
|
||||
|
||||
#ifdef USE_DISPATCH_GL
|
||||
osd_gl_dispatch *gl_dispatch;
|
||||
osd_gl_dispatch *gl_dispatch = nullptr;
|
||||
#endif
|
||||
|
||||
void renderer_ogl::load_gl_lib(running_machine &machine)
|
||||
@ -394,7 +394,7 @@ void renderer_ogl::load_gl_lib(running_machine &machine)
|
||||
#endif
|
||||
#endif
|
||||
#ifdef USE_DISPATCH_GL
|
||||
gl_dispatch = global_alloc(osd_gl_dispatch);
|
||||
gl_dispatch = new osd_gl_dispatch;
|
||||
#endif
|
||||
s_dll_loaded = true;
|
||||
}
|
||||
@ -566,12 +566,12 @@ int renderer_ogl::create()
|
||||
|
||||
// create renderer
|
||||
#if defined(OSD_WINDOWS)
|
||||
m_gl_context = global_alloc(win_gl_context(std::static_pointer_cast<win_window_info>(win)->platform_window()));
|
||||
m_gl_context = new win_gl_context(std::static_pointer_cast<win_window_info>(win)->platform_window());
|
||||
#elif defined(OSD_MAC)
|
||||
// TODO
|
||||
// m_gl_context = global_alloc(mac_gl_context(std::static_pointer_cast<mac_window_info>(win)->platform_window()));
|
||||
// m_gl_context = new mac_gl_context(std::static_pointer_cast<mac_window_info>(win)->platform_window());
|
||||
#else
|
||||
m_gl_context = global_alloc(sdl_gl_context(std::static_pointer_cast<sdl_window_info>(win)->platform_window()));
|
||||
m_gl_context = new sdl_gl_context(std::static_pointer_cast<sdl_window_info>(win)->platform_window());
|
||||
#endif
|
||||
if (m_gl_context->LastErrorMsg() != nullptr)
|
||||
{
|
||||
@ -696,7 +696,7 @@ void renderer_ogl::destroy_all_textures()
|
||||
texture->data=nullptr;
|
||||
texture->data_own=false;
|
||||
}
|
||||
global_free(texture);
|
||||
delete texture;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@ -1907,7 +1907,7 @@ ogl_texture_info *renderer_ogl::texture_create(const render_texinfo *texsource,
|
||||
ogl_texture_info *texture;
|
||||
|
||||
// allocate a new texture
|
||||
texture = global_alloc(ogl_texture_info);
|
||||
texture = new ogl_texture_info;
|
||||
|
||||
// fill in the core data
|
||||
texture->hash = texture_compute_hash(texsource, flags);
|
||||
@ -1979,7 +1979,7 @@ ogl_texture_info *renderer_ogl::texture_create(const render_texinfo *texsource,
|
||||
{
|
||||
if ( texture_shader_create(texsource, texture, flags) )
|
||||
{
|
||||
global_free(texture);
|
||||
delete texture;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,11 @@
|
||||
// SDLMAME by Olivier Galibert and R. Belmont
|
||||
//
|
||||
//============================================================
|
||||
#ifndef MAME_OSD_MODULES_RENDER_DRAWOGL_H
|
||||
#define MAME_OSD_MODULES_RENDER_DRAWOGL_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DRAWOGL__
|
||||
#define __DRAWOGL__
|
||||
|
||||
// OSD headers
|
||||
#ifndef OSD_WINDOWS
|
||||
#ifdef OSD_MAC
|
||||
@ -239,4 +238,4 @@ private:
|
||||
static bool s_dll_loaded;
|
||||
};
|
||||
|
||||
#endif // __DRAWOGL__
|
||||
#endif // MAME_OSD_MODULES_RENDER_DRAWOGL_H
|
||||
|
@ -111,11 +111,7 @@ void renderer_sdl1::setup_texture(const osd_dim &size)
|
||||
// Determine preferred pixelformat and set up yuv if necessary
|
||||
SDL_GetCurrentDisplayMode(win->monitor()->oshandle(), &mode);
|
||||
|
||||
if (m_yuv_bitmap)
|
||||
{
|
||||
global_free_array(m_yuv_bitmap);
|
||||
m_yuv_bitmap = nullptr;
|
||||
}
|
||||
m_yuv_bitmap.reset();
|
||||
|
||||
fmt = (sdl_sm->pixel_format ? sdl_sm->pixel_format : mode.format);
|
||||
|
||||
@ -134,7 +130,7 @@ void renderer_sdl1::setup_texture(const osd_dim &size)
|
||||
m_hw_scale_width = (m_hw_scale_width + 1) & ~1;
|
||||
}
|
||||
if (sdl_sm->is_yuv)
|
||||
m_yuv_bitmap = global_alloc_array(uint16_t, m_hw_scale_width * m_hw_scale_height);
|
||||
m_yuv_bitmap = std::make_unique<uint16_t []>(m_hw_scale_width * m_hw_scale_height);
|
||||
|
||||
int w = m_hw_scale_width * sdl_sm->mult_w;
|
||||
int h = m_hw_scale_height * sdl_sm->mult_h;
|
||||
@ -257,16 +253,6 @@ renderer_sdl1::~renderer_sdl1()
|
||||
{
|
||||
destroy_all_textures();
|
||||
|
||||
if (m_yuv_lookup != nullptr)
|
||||
{
|
||||
global_free_array(m_yuv_lookup);
|
||||
m_yuv_lookup = nullptr;
|
||||
}
|
||||
if (m_yuv_bitmap != nullptr)
|
||||
{
|
||||
global_free_array(m_yuv_bitmap);
|
||||
m_yuv_bitmap = nullptr;
|
||||
}
|
||||
SDL_DestroyRenderer(m_sdl_renderer);
|
||||
}
|
||||
|
||||
@ -448,8 +434,8 @@ int renderer_sdl1::draw(int update)
|
||||
{
|
||||
assert (m_yuv_bitmap != nullptr);
|
||||
assert (surfptr != nullptr);
|
||||
software_renderer<uint16_t, 3,3,3, 10,5,0>::draw_primitives(*win->m_primlist, m_yuv_bitmap, mamewidth, mameheight, mamewidth);
|
||||
sm->yuv_blit((uint16_t *)m_yuv_bitmap, surfptr, pitch, m_yuv_lookup, mamewidth, mameheight);
|
||||
software_renderer<uint16_t, 3,3,3, 10,5,0>::draw_primitives(*win->m_primlist, m_yuv_bitmap.get(), mamewidth, mameheight, mamewidth);
|
||||
sm->yuv_blit(m_yuv_bitmap.get(), surfptr, pitch, m_yuv_lookup.get(), mamewidth, mameheight);
|
||||
}
|
||||
|
||||
win->m_primlist->release_lock();
|
||||
@ -525,12 +511,11 @@ void renderer_sdl1::yuv_lookup_set(unsigned int pen, unsigned char red,
|
||||
|
||||
void renderer_sdl1::yuv_init()
|
||||
{
|
||||
unsigned char r,g,b;
|
||||
if (m_yuv_lookup == nullptr)
|
||||
m_yuv_lookup = global_alloc_array(uint32_t, 65536);
|
||||
for (r = 0; r < 32; r++)
|
||||
for (g = 0; g < 32; g++)
|
||||
for (b = 0; b < 32; b++)
|
||||
if (!m_yuv_lookup)
|
||||
m_yuv_lookup = std::make_unique<uint32_t []>(65536);
|
||||
for (unsigned char r = 0; r < 32; r++)
|
||||
for (unsigned char g = 0; g < 32; g++)
|
||||
for (unsigned char b = 0; b < 32; b++)
|
||||
{
|
||||
int idx = (r << 10) | (g << 5) | b;
|
||||
yuv_lookup_set(idx,
|
||||
|
@ -10,10 +10,10 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef MAME_OSD_MODULES_RENDER_DRAWSDL_H
|
||||
#define MAME_OSD_MODULES_RENDER_DRAWSDL_H
|
||||
|
||||
#ifndef __DRAWSDL1__
|
||||
#define __DRAWSDL1__
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
@ -26,8 +26,8 @@ public:
|
||||
: osd_renderer(w, FLAG_NEEDS_OPENGL | extra_flags)
|
||||
, m_sdl_renderer(nullptr)
|
||||
, m_texture_id(nullptr)
|
||||
, m_yuv_lookup(nullptr)
|
||||
, m_yuv_bitmap(nullptr)
|
||||
, m_yuv_lookup()
|
||||
, m_yuv_bitmap()
|
||||
//, m_hw_scale_width(0)
|
||||
//, m_hw_scale_height(0)
|
||||
, m_last_hofs(0)
|
||||
@ -61,8 +61,8 @@ private:
|
||||
SDL_Texture *m_texture_id;
|
||||
|
||||
// YUV overlay
|
||||
uint32_t *m_yuv_lookup;
|
||||
uint16_t *m_yuv_bitmap;
|
||||
std::unique_ptr<uint32_t []> m_yuv_lookup;
|
||||
std::unique_ptr<uint16_t []> m_yuv_bitmap;
|
||||
|
||||
// if we leave scaling to SDL and the underlying driver, this
|
||||
// is the render_target_width/height to use
|
||||
@ -85,4 +85,4 @@ struct sdl_scale_mode
|
||||
void (*yuv_blit)(const uint16_t *bitmap, uint8_t *ptr, const int pitch, const uint32_t *lookup, const int width, const int height);
|
||||
};
|
||||
|
||||
#endif // __DRAWSDL1__
|
||||
#endif // MAME_OSD_MODULES_RENDER_DRAWSDL_H
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
virtual bool execute_command(const char *command) = 0;
|
||||
|
||||
// midi interface
|
||||
virtual osd_midi_device *create_midi_device() = 0;
|
||||
virtual std::unique_ptr<osd_midi_device> create_midi_device() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~osd_interface() { }
|
||||
|
@ -1137,12 +1137,11 @@ sdl_window_info::sdl_window_info(
|
||||
m_prescale = video_config.prescale;
|
||||
|
||||
m_windowed_dim = osd_dim(config->width, config->height);
|
||||
m_original_mode = global_alloc(SDL_DM_Wrapper);
|
||||
m_original_mode = std::make_unique<SDL_DM_Wrapper>();
|
||||
}
|
||||
|
||||
sdl_window_info::~sdl_window_info()
|
||||
{
|
||||
global_free(m_original_mode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
//
|
||||
//============================================================
|
||||
|
||||
#ifndef __SDLWINDOW__
|
||||
#define __SDLWINDOW__
|
||||
#ifndef MAME_OSD_SDL_WINDOW_H
|
||||
#define MAME_OSD_SDL_WINDOW_H
|
||||
|
||||
#include "osdsdl.h"
|
||||
#include "video.h"
|
||||
@ -87,7 +87,7 @@ private:
|
||||
render_target * m_target;
|
||||
|
||||
// Original display_mode
|
||||
SDL_DM_Wrapper *m_original_mode;
|
||||
std::unique_ptr<SDL_DM_Wrapper> m_original_mode;
|
||||
|
||||
int m_extra_flags;
|
||||
|
||||
@ -152,4 +152,4 @@ int drawsdl2_init(running_machine &machine, osd_draw_callbacks *callbacks);
|
||||
|
||||
int drawbgfx_init(running_machine &machine, osd_draw_callbacks *callbacks);
|
||||
|
||||
#endif /* __SDLWINDOW__ */
|
||||
#endif // MAME_OSD_SDL_WINDOW_H
|
||||
|
@ -866,7 +866,7 @@ namespace {
|
||||
tape_image_85& get_tape_image(tape_state_t& ts)
|
||||
{
|
||||
if (ts.img == nullptr) {
|
||||
ts.img = global_alloc(tape_image_85);
|
||||
ts.img = new tape_image_85;
|
||||
}
|
||||
|
||||
return *(ts.img);
|
||||
@ -916,7 +916,7 @@ namespace {
|
||||
delete state.stream;
|
||||
|
||||
// Free tape_image
|
||||
global_free(&tape_image);
|
||||
delete &tape_image;
|
||||
}
|
||||
|
||||
imgtoolerr_t hp85_tape_begin_enum (imgtool::directory &enumeration, const char *path)
|
||||
|
@ -985,7 +985,7 @@ static tape_state_t& get_tape_state(imgtool::image &img)
|
||||
static tape_image_t& get_tape_image(tape_state_t& ts)
|
||||
{
|
||||
if (ts.img == nullptr) {
|
||||
ts.img = global_alloc(tape_image_t);
|
||||
ts.img = new tape_image_t;
|
||||
}
|
||||
|
||||
return *(ts.img);
|
||||
@ -1034,7 +1034,7 @@ static void hp9845_tape_close(imgtool::image &image)
|
||||
delete state.stream;
|
||||
|
||||
// Free tape_image
|
||||
global_free(&tape_image);
|
||||
delete &tape_image;
|
||||
}
|
||||
|
||||
static imgtoolerr_t hp9845_tape_begin_enum (imgtool::directory &enumeration, const char *path)
|
||||
|
Loading…
Reference in New Issue
Block a user