Miscellaneous clean-up.

* Replaced several uses of auto_alloc.
* Removed a trampoline in bus/isa/xtide.cpp.
This commit is contained in:
Vas Crabb 2020-10-29 00:36:55 +11:00
parent 51041dce09
commit ffd9b00eeb
17 changed files with 155 additions and 158 deletions

View File

@ -30,7 +30,6 @@ dio16_98620_device::dio16_98620_device(const machine_config &mconfig, device_typ
m_control{0},
m_data{0},
m_irq_state{false},
m_regs {{0}},
m_dmar {false}
{
}

View File

@ -104,22 +104,22 @@ private:
bool m_irq_state;
struct dma_regs {
uint32_t address;
uint32_t tc;
uint32_t control;
uint32_t address = 0;
uint32_t tc = 0;
uint32_t control = 0;
/* control register */
int irq_level;
int tsz;
int subcount;
int irq_level = 0;
int tsz = 0;
int subcount = 0;
bool irq;
bool ie;
bool armed;
bool irq = false;
bool ie = false;
bool armed = false;
bool dma_out;
bool dma_pri; // TODO
bool lword;
bool word;
bool dma_out = false;
bool dma_pri = false; // TODO
bool lword = false;
bool word = false;
} m_regs[2];
bool m_dmar[2];

View File

@ -258,7 +258,7 @@ void isa8_device::device_reset()
}
template<typename R, typename W> void isa8_device::install_space(int spacenum, offs_t start, offs_t end, R rhandler, W whandler)
template <typename R, typename W> void isa8_device::install_space(int spacenum, offs_t start, offs_t end, R rhandler, W whandler)
{
int buswidth;
address_space *space;
@ -278,24 +278,35 @@ template<typename R, typename W> void isa8_device::install_space(int spacenum, o
fatalerror("Unknown space passed to isa8_device::install_space!\n");
}
switch(buswidth)
switch (buswidth)
{
case 8:
space->install_readwrite_handler(start, end, rhandler, whandler, 0);
space->install_read_handler(start, end, rhandler, 0);
space->install_write_handler(start, end, whandler, 0);
break;
case 16:
space->install_readwrite_handler(start, end, rhandler, whandler, 0xffff);
space->install_read_handler(start, end, rhandler, 0xffff);
space->install_write_handler(start, end, whandler, 0xffff);
break;
case 32:
if ((start % 4) == 0) {
if ((end-start)==1) {
space->install_readwrite_handler(start, end+2, rhandler, whandler, 0x0000ffff);
} else {
space->install_readwrite_handler(start, end, rhandler, whandler, 0xffffffff);
if ((start % 4) == 0)
{
if ((end - start) == 1)
{
space->install_read_handler(start, end + 2, rhandler, 0x0000ffff);
space->install_write_handler(start, end + 2, whandler, 0x0000ffff);
}
} else {
else
{
space->install_read_handler(start, end, rhandler, 0xffffffff);
space->install_write_handler(start, end, whandler, 0xffffffff);
}
}
else
{
// we handle just misaligned by 2
space->install_readwrite_handler(start-2, end, rhandler, whandler, 0xffff0000);
space->install_read_handler(start - 2, end, rhandler, 0xffff0000);
space->install_write_handler(start - 2, end, whandler, 0xffff0000);
}
break;
default:
@ -303,38 +314,48 @@ template<typename R, typename W> void isa8_device::install_space(int spacenum, o
}
}
template<typename R, typename W> void isa8_device::install_memory(offs_t start, offs_t end, R rhandler, W whandler)
{
install_space(AS_ISA_MEM, start, end, rhandler, whandler);
}
template<typename R, typename W> void isa8_device::install_device(offs_t start, offs_t end, R rhandler, W whandler)
{
install_space(AS_ISA_IO, start, end, rhandler, whandler);
}
template void isa8_device::install_space<read8_delegate, write8_delegate >(int spacenum, offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
template void isa8_device::install_space<read8_delegate, write8m_delegate >(int spacenum, offs_t start, offs_t end, read8_delegate rhandler, write8m_delegate whandler);
template void isa8_device::install_space<read8_delegate, write8s_delegate >(int spacenum, offs_t start, offs_t end, read8_delegate rhandler, write8s_delegate whandler);
template void isa8_device::install_space<read8_delegate, write8sm_delegate >(int spacenum, offs_t start, offs_t end, read8_delegate rhandler, write8sm_delegate whandler);
template void isa8_device::install_space<read8_delegate, write8mo_delegate >(int spacenum, offs_t start, offs_t end, read8_delegate rhandler, write8mo_delegate whandler);
template void isa8_device::install_space<read8_delegate, write8smo_delegate>(int spacenum, offs_t start, offs_t end, read8_delegate rhandler, write8smo_delegate whandler);
template void isa8_device::install_space<read8m_delegate, write8_delegate >(int spacenum, offs_t start, offs_t end, read8m_delegate rhandler, write8_delegate whandler);
template void isa8_device::install_space<read8m_delegate, write8m_delegate >(int spacenum, offs_t start, offs_t end, read8m_delegate rhandler, write8m_delegate whandler);
template void isa8_device::install_space<read8m_delegate, write8s_delegate >(int spacenum, offs_t start, offs_t end, read8m_delegate rhandler, write8s_delegate whandler);
template void isa8_device::install_space<read8m_delegate, write8sm_delegate >(int spacenum, offs_t start, offs_t end, read8m_delegate rhandler, write8sm_delegate whandler);
template void isa8_device::install_space<read8m_delegate, write8mo_delegate >(int spacenum, offs_t start, offs_t end, read8m_delegate rhandler, write8mo_delegate whandler);
template void isa8_device::install_space<read8m_delegate, write8smo_delegate>(int spacenum, offs_t start, offs_t end, read8m_delegate rhandler, write8smo_delegate whandler);
template void isa8_device::install_space<read8s_delegate, write8_delegate >(int spacenum, offs_t start, offs_t end, read8s_delegate rhandler, write8_delegate whandler);
template void isa8_device::install_space<read8s_delegate, write8m_delegate >(int spacenum, offs_t start, offs_t end, read8s_delegate rhandler, write8m_delegate whandler);
template void isa8_device::install_space<read8s_delegate, write8s_delegate >(int spacenum, offs_t start, offs_t end, read8s_delegate rhandler, write8s_delegate whandler);
template void isa8_device::install_space<read8s_delegate, write8sm_delegate >(int spacenum, offs_t start, offs_t end, read8s_delegate rhandler, write8sm_delegate whandler);
template void isa8_device::install_space<read8s_delegate, write8mo_delegate >(int spacenum, offs_t start, offs_t end, read8s_delegate rhandler, write8mo_delegate whandler);
template void isa8_device::install_space<read8s_delegate, write8smo_delegate>(int spacenum, offs_t start, offs_t end, read8s_delegate rhandler, write8smo_delegate whandler);
template void isa8_device::install_space<read8sm_delegate, write8_delegate >(int spacenum, offs_t start, offs_t end, read8sm_delegate rhandler, write8_delegate whandler);
template void isa8_device::install_space<read8sm_delegate, write8m_delegate >(int spacenum, offs_t start, offs_t end, read8sm_delegate rhandler, write8m_delegate whandler);
template void isa8_device::install_space<read8sm_delegate, write8s_delegate >(int spacenum, offs_t start, offs_t end, read8sm_delegate rhandler, write8s_delegate whandler);
template void isa8_device::install_space<read8sm_delegate, write8sm_delegate >(int spacenum, offs_t start, offs_t end, read8sm_delegate rhandler, write8sm_delegate whandler);
template void isa8_device::install_space<read8sm_delegate, write8mo_delegate >(int spacenum, offs_t start, offs_t end, read8sm_delegate rhandler, write8mo_delegate whandler);
template void isa8_device::install_space<read8sm_delegate, write8smo_delegate>(int spacenum, offs_t start, offs_t end, read8sm_delegate rhandler, write8smo_delegate whandler);
template void isa8_device::install_space<read8mo_delegate, write8_delegate >(int spacenum, offs_t start, offs_t end, read8mo_delegate rhandler, write8_delegate whandler);
template void isa8_device::install_space<read8mo_delegate, write8m_delegate >(int spacenum, offs_t start, offs_t end, read8mo_delegate rhandler, write8m_delegate whandler);
template void isa8_device::install_space<read8mo_delegate, write8s_delegate >(int spacenum, offs_t start, offs_t end, read8mo_delegate rhandler, write8s_delegate whandler);
template void isa8_device::install_space<read8mo_delegate, write8sm_delegate >(int spacenum, offs_t start, offs_t end, read8mo_delegate rhandler, write8sm_delegate whandler);
template void isa8_device::install_space<read8mo_delegate, write8mo_delegate >(int spacenum, offs_t start, offs_t end, read8mo_delegate rhandler, write8mo_delegate whandler);
template void isa8_device::install_space<read8mo_delegate, write8smo_delegate>(int spacenum, offs_t start, offs_t end, read8mo_delegate rhandler, write8smo_delegate whandler);
template void isa8_device::install_space<read8smo_delegate, write8_delegate >(int spacenum, offs_t start, offs_t end, read8smo_delegate rhandler, write8_delegate whandler);
template void isa8_device::install_space<read8smo_delegate, write8m_delegate >(int spacenum, offs_t start, offs_t end, read8smo_delegate rhandler, write8m_delegate whandler);
template void isa8_device::install_space<read8smo_delegate, write8s_delegate >(int spacenum, offs_t start, offs_t end, read8smo_delegate rhandler, write8s_delegate whandler);
template void isa8_device::install_space<read8smo_delegate, write8sm_delegate >(int spacenum, offs_t start, offs_t end, read8smo_delegate rhandler, write8sm_delegate whandler);
template void isa8_device::install_space<read8smo_delegate, write8mo_delegate >(int spacenum, offs_t start, offs_t end, read8smo_delegate rhandler, write8mo_delegate whandler);
template void isa8_device::install_space<read8smo_delegate, write8smo_delegate>(int spacenum, offs_t start, offs_t end, read8smo_delegate rhandler, write8smo_delegate whandler);
template void isa8_device::install_memory<read8_delegate, write8_delegate >(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
template void isa8_device::install_memory<read8m_delegate, write8m_delegate >(offs_t start, offs_t end, read8m_delegate rhandler, write8m_delegate whandler);
template void isa8_device::install_memory<read8s_delegate, write8s_delegate >(offs_t start, offs_t end, read8s_delegate rhandler, write8s_delegate whandler);
template void isa8_device::install_memory<read8sm_delegate, write8sm_delegate >(offs_t start, offs_t end, read8sm_delegate rhandler, write8sm_delegate whandler);
template void isa8_device::install_memory<read8mo_delegate, write8mo_delegate >(offs_t start, offs_t end, read8mo_delegate rhandler, write8mo_delegate whandler);
template void isa8_device::install_memory<read8smo_delegate, write8smo_delegate>(offs_t start, offs_t end, read8smo_delegate rhandler, write8smo_delegate whandler);
template void isa8_device::install_device<read8_delegate, write8_delegate >(offs_t start, offs_t end, read8_delegate rhandler, write8_delegate whandler);
template void isa8_device::install_device<read8m_delegate, write8m_delegate >(offs_t start, offs_t end, read8m_delegate rhandler, write8m_delegate whandler);
template void isa8_device::install_device<read8s_delegate, write8s_delegate >(offs_t start, offs_t end, read8s_delegate rhandler, write8s_delegate whandler);
template void isa8_device::install_device<read8sm_delegate, write8sm_delegate >(offs_t start, offs_t end, read8sm_delegate rhandler, write8sm_delegate whandler);
template void isa8_device::install_device<read8mo_delegate, write8mo_delegate >(offs_t start, offs_t end, read8mo_delegate rhandler, write8mo_delegate whandler);
template void isa8_device::install_device<read8smo_delegate, write8smo_delegate>(offs_t start, offs_t end, read8smo_delegate rhandler, write8smo_delegate whandler);
void isa8_device::install_bank(offs_t start, offs_t end, const char *tag, uint8_t *data)
{
m_memspace->install_readwrite_bank(start, end, 0, tag );

View File

@ -143,14 +143,20 @@ public:
// for ISA8, put the 8-bit configs in the primary slots and the 16-bit configs in the secondary
virtual space_config_vector memory_space_config() const override;
template<typename R, typename W> void install_device(offs_t start, offs_t end, R rhandler, W whandler);
template<typename R, typename W> void install_device(offs_t start, offs_t end, R rhandler, W whandler)
{
install_space(AS_ISA_IO, start, end, rhandler, whandler);
}
template<typename T> void install_device(offs_t addrstart, offs_t addrend, T &device, void (T::*map)(class address_map &map), uint64_t unitmask = ~u64(0))
{
m_iospace->install_device(addrstart, addrend, device, map, unitmask);
}
void install_bank(offs_t start, offs_t end, const char *tag, uint8_t *data);
void install_rom(device_t *dev, offs_t start, offs_t end, const char *tag, const char *region);
template<typename R, typename W> void install_memory(offs_t start, offs_t end, R rhandler, W whandler);
template<typename R, typename W> void install_memory(offs_t start, offs_t end, R rhandler, W whandler)
{
install_space(AS_ISA_MEM, start, end, rhandler, whandler);
}
void unmap_device(offs_t start, offs_t end) const { m_iospace->unmap_readwrite(start, end); }
void unmap_bank(offs_t start, offs_t end);

View File

@ -109,13 +109,6 @@ void xtide_device::write(offs_t offset, uint8_t data)
}
}
uint8_t xtide_device::eeprom_read(offs_t offset)
{
address_space &space = m_isa->memspace();
return m_eeprom->read(space, offset);
}
WRITE_LINE_MEMBER(xtide_device::ide_interrupt)
{
switch (m_irq_number)
@ -329,7 +322,7 @@ void xtide_device::device_reset()
int io_address = ((ioport("IO_ADDRESS")->read() & 0x0F) * 0x20) + 0x200;
m_irq_number = (ioport("IRQ")->read() & 0x07);
m_isa->install_memory(base_address, base_address + 0x1fff, read8sm_delegate(*this, FUNC(xtide_device::eeprom_read)), write8sm_delegate(*m_eeprom, FUNC(eeprom_parallel_28xx_device::write)));
m_isa->install_memory(base_address, base_address + 0x1fff, read8m_delegate(*m_eeprom, FUNC(eeprom_parallel_28xx_device::read)), write8sm_delegate(*m_eeprom, FUNC(eeprom_parallel_28xx_device::write)));
m_isa->install_device(io_address, io_address + 0xf, read8sm_delegate(*this, FUNC(xtide_device::read)), write8sm_delegate(*this, FUNC(xtide_device::write)));
//logerror("xtide_device::device_reset(), bios_base=0x%5X to 0x%5X, I/O=0x%3X, IRQ=%d\n",base_address,base_address + (16*1024) -1 ,io_address,irq);

View File

@ -34,7 +34,6 @@ protected:
private:
DECLARE_WRITE_LINE_MEMBER(ide_interrupt);
uint8_t eeprom_read(offs_t offset);
required_device<ata_interface_device> m_ata;
required_device<eeprom_parallel_28xx_device> m_eeprom;

View File

@ -258,7 +258,7 @@ void alto2_cpu_device::update_framebuf_word(uint16_t* framebuf, int x, int y, ui
if (word == framebuf[x])
return;
framebuf[x] = word;
draw_scanline8(*m_dsp.bitmap, x * 16, y, 16, m_dsp.patterns + 16 * word, nullptr);
draw_scanline8(*m_dsp.bitmap, x * 16, y, 16, &m_dsp.patterns[16 * word], nullptr);
}
/**
@ -524,9 +524,9 @@ void alto2_cpu_device::init_disp()
m_dsp.hlc = A2_DISP_HLC_START;
m_dsp.framebuf = std::make_unique<uint16_t[]>(A2_DISP_TOTAL_HEIGHT * A2_DISP_SCANLINE_WORDS);
m_dsp.patterns = auto_alloc_array(machine(), uint8_t, 65536 * 16);
m_dsp.patterns = std::make_unique<uint8_t[]>(65536 * 16);
for (int y = 0; y < 65536; y++) {
uint8_t* dst = m_dsp.patterns + y * 16;
uint8_t* dst = &m_dsp.patterns[y * 16];
for (int x = 0; x < 16; x++)
*dst++ = (~y >> (15 - x)) & 1;
}

View File

@ -193,26 +193,26 @@
#ifndef MAME_CPU_ALTO2_A2DISP_H
#define MAME_CPU_ALTO2_A2DISP_H
struct {
uint32_t state; //!< current state of the display_state_machine()
uint32_t hlc; //!< horizontal line counter
uint32_t setmode; //!< value written by last SETMODE<-
uint32_t inverse; //!< set to 0xffff if line is inverse, 0x0000 otherwise
uint32_t scanline; //!< current scanline
uint32_t state; //!< current state of the display_state_machine()
uint32_t hlc; //!< horizontal line counter
uint32_t setmode; //!< value written by last SETMODE<-
uint32_t inverse; //!< set to 0xffff if line is inverse, 0x0000 otherwise
uint32_t scanline; //!< current scanline
bool halfclock; //!< false for normal pixel clock, true for half pixel clock
bool vblank; //!< true during vblank, false otherwise
uint16_t fifo[A2_DISP_FIFO]; //!< display word fifo
uint32_t wa; //!< fifo input pointer (write address; 4-bit)
uint32_t ra; //!< fifo output pointer (read address; 4-bit)
uint32_t a63; //!< most recent value read from the PROM a63
uint32_t a66; //!< most recent value read from the PROM a66
uint16_t fifo[A2_DISP_FIFO]; //!< display word fifo
uint32_t wa; //!< fifo input pointer (write address; 4-bit)
uint32_t ra; //!< fifo output pointer (read address; 4-bit)
uint32_t a63; //!< most recent value read from the PROM a63
uint32_t a66; //!< most recent value read from the PROM a66
bool dht_blocks; //!< set true, if the DHT executed BLOCK
bool dwt_blocks; //!< set true, if the DWT executed BLOCK
bool curt_blocks; //!< set true, if the CURT executed BLOCK
bool curt_wakeup; //!< set true, if CURT wakeups are generated
uint32_t xpreg; //!< cursor cursor x position register (10-bit)
uint32_t csr; //!< cursor shift register (16-bit)
std::unique_ptr<uint16_t[]> framebuf; //!< array of words of the raw bitmap that is displayed
uint8_t *patterns; //!< array of 65536 patterns (16 bytes) with 1 byte per pixel
uint32_t xpreg; //!< cursor cursor x position register (10-bit)
uint32_t csr; //!< cursor shift register (16-bit)
std::unique_ptr<uint16_t[]> framebuf; //!< array of words of the raw bitmap that is displayed
std::unique_ptr<uint8_t[]> patterns; //!< array of 65536 patterns (16 bytes) with 1 byte per pixel
std::unique_ptr<bitmap_ind16> bitmap; //!< MAME bitmap with 16 bit indices
} m_dsp;

View File

@ -155,22 +155,21 @@ void vrender0soc_device::device_add_mconfig(machine_config &config)
void vrender0soc_device::device_start()
{
int i;
m_textureram = auto_alloc_array_clear(machine(), uint16_t, 0x00800000/2);
m_frameram = auto_alloc_array_clear(machine(), uint16_t, 0x00800000/2);
m_textureram = make_unique_clear<uint16_t []>(0x00800000/2);
m_frameram = make_unique_clear<uint16_t []>(0x00800000/2);
m_vr0vid->set_areas(m_textureram, m_frameram);
m_vr0vid->set_areas(m_textureram.get(), m_frameram.get());
m_host_space = &m_host_cpu->space(AS_PROGRAM);
if (this->clock() == 0)
fatalerror("%s: bus clock not setup properly",this->tag());
for (i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
m_Timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vrender0soc_device::Timercb),this), (void*)(uintptr_t)i);
write_tx.resolve_all_safe();
for (i = 0; i < 2; i++)
for (int i = 0; i < 2; i++)
{
m_uart[i]->set_channel_num(i);
m_uart[i]->set_parent(this);

View File

@ -27,12 +27,6 @@
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@ -128,8 +122,8 @@ private:
required_device <speaker_device> m_rspeaker;
required_device_array <vr0uart_device, 2> m_uart;
required_shared_ptr <uint32_t> m_crtcregs;
uint16_t *m_textureram = nullptr;
uint16_t *m_frameram = nullptr;
std::unique_ptr<uint16_t []> m_textureram;
std::unique_ptr<uint16_t []> m_frameram;
address_space *m_host_space = nullptr;
uint32_t m_ext_vclk = 0;

View File

@ -191,7 +191,8 @@ void vic3_device::device_start()
m_lightpen_x_cb.resolve_safe(0);
m_lightpen_y_cb.resolve_safe(0);
m_screenptr[0] = auto_alloc_array(machine(), uint8_t, 216 * 656 / 8);
m_screendata = std::make_unique<uint8_t []>(216 * 656 / 8);
m_screenptr[0] = m_screendata.get();
for (int i = 1; i < 216; i++)
m_screenptr[i] = m_screenptr[i - 1] + 656 / 8;

View File

@ -197,6 +197,7 @@ private:
int m_columns, m_rows;
/* background/foreground for sprite collision */
std::unique_ptr<uint8_t []> m_screendata;
uint8_t *m_screenptr[216], m_shift[216];
/* convert multicolor byte to background/foreground for sprite collision */

View File

@ -231,20 +231,20 @@ void dfs500_state::machine_reset()
uint32_t dfs500_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, rectangle const &cliprect)
{
const bitmap_argb32 *input_bitmap = &m_input[m_input_sel_A & 3]->get_bitmap();
const bitmap_argb32 &input_bitmap = m_input[m_input_sel_A & 3]->get_bitmap();
// FIXME: This is simply bypassing the inputs directly into the output.
// Emulation of the video hardware (DSP signal path) for GFX processing is still needed here.
if (input_bitmap->valid())
if (input_bitmap.valid())
{
// convert arbitrary sized ARGB32 image to a full-screen image
double stepx = double (input_bitmap->width()) / VIDEO_WIDTH;
double stepy = double (input_bitmap->height()) / VIDEO_HEIGHT;
double stepx = double (input_bitmap.width()) / VIDEO_WIDTH;
double stepy = double (input_bitmap.height()) / VIDEO_HEIGHT;
for (unsigned screen_y = screen.visible_area().min_y; screen_y <= screen.visible_area().max_y; screen_y++)
{
for (unsigned screen_x = screen.visible_area().min_x; screen_x <= screen.visible_area().max_x; screen_x++)
{
bitmap.pix(screen_y, screen_x) = input_bitmap->pix(
bitmap.pix(screen_y, screen_x) = input_bitmap.pix(
int(double (screen_y % VIDEO_HEIGHT) * stepy),
int(double (screen_x % VIDEO_WIDTH) * stepx));
}

View File

@ -138,7 +138,7 @@ private:
void menghong_shared_w(offs_t offset, uint8_t data);
uint8_t crzyddz2_shared_r(offs_t offset);
void crzyddz2_shared_w(offs_t offset, uint8_t data);
uint8_t *m_sharedram;
std::unique_ptr<uint8_t []> m_sharedram;
};
@ -335,7 +335,7 @@ void menghong_state::crzyddz2_mem(address_map &map)
void menghong_state::machine_start()
{
m_sharedram = auto_alloc_array_clear(machine(), uint8_t, 0x10000);
m_sharedram = make_unique_clear<uint8_t []>(0x10000);
if (m_mainbank)
{

View File

@ -51,7 +51,7 @@ private:
required_region_ptr<uint8_t> m_video_bios;
required_region_ptr<uint8_t> m_ex_bios;
uint8_t *m_shadow_ram;
std::unique_ptr<uint8_t []> m_shadow_ram;
uint8_t bios_r(offs_t offset);
void bios_w(offs_t offset, uint8_t data);
@ -230,8 +230,8 @@ INPUT_PORTS_END
void photoply_state::machine_start()
{
m_shadow_ram = auto_alloc_array(machine(), uint8_t, 0x40000);
save_pointer(NAME(m_shadow_ram),0x40000);
m_shadow_ram = std::make_unique<uint8_t []>(0x40000);
save_pointer(NAME(m_shadow_ram), 0x40000);
}
void photoply_state::machine_reset()

View File

@ -92,7 +92,7 @@ private:
// for the 128 lines.
struct planet
{
uint8_t *frames[256];
std::unique_ptr<uint8_t []> frames[256];
};
void init_planet(planet &liberatr_planet, uint8_t *planet_rom);

View File

@ -68,52 +68,42 @@ void liberatr_state::bitmap_w(offs_t offset, uint8_t data)
void liberatr_state::init_planet(planet &liberatr_planet, uint8_t *planet_rom)
{
uint16_t longitude;
const uint8_t *const latitude_scale = memregion("user1")->base();
const uint8_t *const longitude_scale = memregion("user2")->base();
const uint8_t *latitude_scale = memregion("user1")->base();
const uint8_t *longitude_scale = memregion("user2")->base();
/* for each starting longitude */
for (longitude = 0; longitude < 0x100; longitude++)
// for each starting longitude
for (uint16_t longitude = 0; longitude < 0x100; longitude++)
{
uint8_t i, latitude, start_segment, segment_count;
uint8_t *buffer;
planet_frame frame;
planet_frame_line *line = nullptr;
uint16_t total_segment_count = 0;
/* for each latitude */
for (latitude = 0; latitude < 0x80; latitude++)
// for each latitude
for (uint8_t latitude = 0; latitude < 0x80; latitude++)
{
uint8_t segment, longitude_scale_factor, latitude_scale_factor, color, x=0;
uint8_t x_array[32], color_array[32], visible_array[32];
/* point to the structure which will hold the data for this line */
line = &frame.lines[latitude];
// point to the structure which will hold the data for this line
planet_frame_line *line = &frame.lines[latitude];
latitude_scale_factor = latitude_scale[latitude];
uint8_t latitude_scale_factor = latitude_scale[latitude];
/* for this latitude, load the 32 segments into the arrays */
for (segment = 0; segment < 0x20; segment++)
// for this latitude, load the 32 segments into the arrays
for (uint8_t segment = 0; segment < 0x20; segment++)
{
uint16_t length, planet_data, address;
uint16_t address;
/*
read the planet picture ROM and get the
latitude and longitude scaled from the scaling PROMS
*/
// read the planet picture ROM and get the latitude and longitude scaled from the scaling PROMS
address = (latitude << 5) + segment;
planet_data = (planet_rom[address] << 8) | planet_rom[address + 0x1000];
uint16_t planet_data = (planet_rom[address] << 8) | planet_rom[address + 0x1000];
color = (planet_data >> 8) & 0x0f;
length = ((planet_data << 1) & 0x1fe) + ((planet_data >> 15) & 0x01);
uint8_t color = (planet_data >> 8) & 0x0f;
uint16_t length = ((planet_data << 1) & 0x1fe) + ((planet_data >> 15) & 0x01);
/* scale the longitude limit (adding the starting longitude) */
address = longitude + ( length >> 1 ) + ( length & 1 ); /* shift with rounding */
visible_array[segment] = (( address & 0x100 ) ? 1 : 0);
// scale the longitude limit (adding the starting longitude)
address = longitude + (length >> 1) + (length & 1); // shift with rounding
visible_array[segment] = BIT(address, 8);
uint8_t longitude_scale_factor;
if (address & 0x80)
{
longitude_scale_factor = 0xff;
@ -128,29 +118,28 @@ void liberatr_state::init_planet(planet &liberatr_planet, uint8_t *planet_rom)
color_array[segment] = color;
}
/*
determine which segment is the western horizon and
leave 'segment' indexing it.
*/
for (segment = 0; segment < 0x1f; segment++) /* if not found, 'segment' = 0x1f */
if (visible_array[segment]) break;
// determine which segment is the western horizon and leave 'start_segment' indexing it.
uint8_t start_segment;
for (start_segment = 0; start_segment < 0x1f; start_segment++) // if not found, 'start_segment' = 0x1f
if (visible_array[start_segment]) break;
/* transfer from the temporary arrays to the structure */
// transfer from the temporary arrays to the structure
line->max_x = (latitude_scale_factor * 0xc0) >> 8;
if (line->max_x & 1)
line->max_x += 1; /* make it even */
line->max_x += 1; // make it even
/*
as part of the quest to reduce memory usage (and to a lesser degree
execution time), stitch together segments that have the same color
*/
segment_count = 0;
i = 0;
start_segment = segment;
uint8_t segment = start_segment;
uint8_t segment_count = 0;
uint8_t i = 0;
uint8_t x = 0;
do
{
color = color_array[segment];
uint8_t color = color_array[segment];
while (color == color_array[segment])
{
x = x_array[segment];
@ -173,25 +162,20 @@ void liberatr_state::init_planet(planet &liberatr_planet, uint8_t *planet_rom)
many segments it will take to store the description, allocate the
space for it and copy the data to it.
*/
buffer = auto_alloc_array(machine(), uint8_t, 2*(128 + total_segment_count));
liberatr_planet.frames[longitude] = std::make_unique<uint8_t []>(2 * (128 + total_segment_count));
uint8_t *buffer = liberatr_planet.frames[longitude].get();
liberatr_planet.frames[longitude] = buffer;
for (latitude = 0; latitude < 0x80; latitude++)
for (uint8_t latitude = 0; latitude < 0x80; latitude++)
{
uint8_t last_x;
line = &frame.lines[latitude];
segment_count = line->segment_count;
planet_frame_line *line = &frame.lines[latitude];
uint8_t segment_count = line->segment_count;
*buffer++ = segment_count;
last_x = 0;
/* calculate the bitmap's x coordinate for the western horizon
center of bitmap - (the number of planet pixels) / 4 */
*buffer++ = (m_screen->width() / 2) - ((line->max_x + 2) / 4);
for (i = 0; i < segment_count; i++)
for (uint8_t i = 0, last_x = 0; i < segment_count; i++)
{
uint8_t current_x = (line->x_array[i] + 1) / 2;
@ -249,7 +233,7 @@ void liberatr_state::get_pens(pen_t *pens)
void liberatr_state::draw_planet(bitmap_rgb32 &bitmap, pen_t *pens)
{
uint8_t const *buffer = m_planets[m_planet_select].frames[*m_planet_frame];
uint8_t const *buffer = m_planets[m_planet_select].frames[*m_planet_frame].get();
/* for each latitude */
for (uint8_t latitude = 0; latitude < 0x80; latitude++)