timex.cpp: Separate state class a little (nw)

This commit is contained in:
AJR 2019-05-16 00:00:01 -04:00
parent 0260b77e70
commit a5d54d8a16
4 changed files with 100 additions and 79 deletions

View File

@ -165,23 +165,23 @@ http://www.z88forever.org.uk/zxplus3e/
/* TS2048 specific functions */
READ8_MEMBER( spectrum_state::ts2068_port_f4_r )
READ8_MEMBER( timex_state::ts2068_port_f4_r )
{
return m_port_f4_data;
}
WRITE8_MEMBER( spectrum_state::ts2068_port_f4_w )
WRITE8_MEMBER( timex_state::ts2068_port_f4_w )
{
m_port_f4_data = data;
ts2068_update_memory();
}
READ8_MEMBER( spectrum_state::ts2068_port_ff_r )
READ8_MEMBER( timex_state::ts2068_port_ff_r )
{
return m_port_ff_data;
}
WRITE8_MEMBER( spectrum_state::ts2068_port_ff_w )
WRITE8_MEMBER( timex_state::ts2068_port_ff_w )
{
/* Bits 0-2 Video Mode Select
Bits 3-5 64 column mode ink/paper selection
@ -212,7 +212,7 @@ WRITE8_MEMBER( spectrum_state::ts2068_port_ff_w )
* at the same time.
*
*******************************************************************/
void spectrum_state::ts2068_update_memory()
void timex_state::ts2068_update_memory()
{
uint8_t *messram = nullptr;
if (m_ram) messram = m_ram->pointer();
@ -525,16 +525,16 @@ void spectrum_state::ts2068_update_memory()
}
}
void spectrum_state::ts2068_io(address_map &map)
void timex_state::ts2068_io(address_map &map)
{
map(0xf4, 0xf4).rw(FUNC(spectrum_state::ts2068_port_f4_r), FUNC(spectrum_state::ts2068_port_f4_w)).mirror(0xff00);
map(0xf4, 0xf4).rw(FUNC(timex_state::ts2068_port_f4_r), FUNC(timex_state::ts2068_port_f4_w)).mirror(0xff00);
map(0xf5, 0xf5).w("ay8912", FUNC(ay8910_device::address_w)).mirror(0xff00);
map(0xf6, 0xf6).rw("ay8912", FUNC(ay8910_device::data_r), FUNC(ay8910_device::data_w)).mirror(0xff00);
map(0xfe, 0xfe).rw(FUNC(spectrum_state::spectrum_port_fe_r), FUNC(spectrum_state::spectrum_port_fe_w)).select(0xff00);
map(0xff, 0xff).rw(FUNC(spectrum_state::ts2068_port_ff_r), FUNC(spectrum_state::ts2068_port_ff_w)).mirror(0xff00);
map(0xfe, 0xfe).rw(FUNC(timex_state::spectrum_port_fe_r), FUNC(timex_state::spectrum_port_fe_w)).select(0xff00);
map(0xff, 0xff).rw(FUNC(timex_state::ts2068_port_ff_r), FUNC(timex_state::ts2068_port_ff_w)).mirror(0xff00);
}
void spectrum_state::ts2068_mem(address_map &map)
void timex_state::ts2068_mem(address_map &map)
{
map(0x0000, 0x1fff).bankr("bank1").bankw("bank9");
map(0x2000, 0x3fff).bankr("bank2").bankw("bank10");
@ -547,7 +547,7 @@ void spectrum_state::ts2068_mem(address_map &map)
}
MACHINE_RESET_MEMBER(spectrum_state,ts2068)
MACHINE_RESET_MEMBER(timex_state,ts2068)
{
m_port_ff_data = 0;
m_port_f4_data = 0;
@ -565,25 +565,25 @@ MACHINE_RESET_MEMBER(spectrum_state,ts2068)
/* TC2048 specific functions */
WRITE8_MEMBER( spectrum_state::tc2048_port_ff_w )
WRITE8_MEMBER( timex_state::tc2048_port_ff_w )
{
m_port_ff_data = data;
logerror("Port %04x write %02x\n", offset, data);
}
void spectrum_state::tc2048_io(address_map &map)
void timex_state::tc2048_io(address_map &map)
{
map(0x00, 0x00).rw(FUNC(spectrum_state::spectrum_port_fe_r), FUNC(spectrum_state::spectrum_port_fe_w)).select(0xfffe);
map(0xff, 0xff).rw(FUNC(spectrum_state::ts2068_port_ff_r), FUNC(spectrum_state::tc2048_port_ff_w)).mirror(0xff00);
map(0x00, 0x00).rw(FUNC(timex_state::spectrum_port_fe_r), FUNC(timex_state::spectrum_port_fe_w)).select(0xfffe);
map(0xff, 0xff).rw(FUNC(timex_state::ts2068_port_ff_r), FUNC(timex_state::tc2048_port_ff_w)).mirror(0xff00);
}
void spectrum_state::tc2048_mem(address_map &map)
void timex_state::tc2048_mem(address_map &map)
{
map(0x0000, 0x3fff).rom();
map(0x4000, 0xffff).bankr("bank1").bankw("bank2");
}
MACHINE_RESET_MEMBER(spectrum_state,tc2048)
MACHINE_RESET_MEMBER(timex_state,tc2048)
{
uint8_t *messram = m_ram->pointer();
@ -595,7 +595,7 @@ MACHINE_RESET_MEMBER(spectrum_state,tc2048)
}
DEVICE_IMAGE_LOAD_MEMBER( spectrum_state, timex_cart )
DEVICE_IMAGE_LOAD_MEMBER( timex_state, timex_cart )
{
uint32_t size = m_dock->common_get_size("rom");
@ -686,27 +686,27 @@ static GFXDECODE_START( gfx_ts2068 )
GFXDECODE_ENTRY( "maincpu", 0x13d00, ts2068_charlayout, 0, 8 )
GFXDECODE_END
MACHINE_CONFIG_START(spectrum_state::ts2068)
MACHINE_CONFIG_START(timex_state::ts2068)
spectrum_128(config);
Z80(config.replace(), m_maincpu, XTAL(14'112'000)/4); /* From Schematic; 3.528 MHz */
m_maincpu->set_addrmap(AS_PROGRAM, &spectrum_state::ts2068_mem);
m_maincpu->set_addrmap(AS_IO, &spectrum_state::ts2068_io);
m_maincpu->set_vblank_int("screen", FUNC(spectrum_state::spec_interrupt));
m_maincpu->set_addrmap(AS_PROGRAM, &timex_state::ts2068_mem);
m_maincpu->set_addrmap(AS_IO, &timex_state::ts2068_io);
m_maincpu->set_vblank_int("screen", FUNC(timex_state::spec_interrupt));
config.m_minimum_quantum = attotime::from_hz(60);
MCFG_MACHINE_RESET_OVERRIDE(spectrum_state, ts2068 )
MCFG_MACHINE_RESET_OVERRIDE(timex_state, ts2068 )
/* video hardware */
m_screen->set_refresh_hz(60);
m_screen->set_size(TS2068_SCREEN_WIDTH, TS2068_SCREEN_HEIGHT);
m_screen->set_visarea(0, TS2068_SCREEN_WIDTH-1, 0, TS2068_SCREEN_HEIGHT-1);
m_screen->set_screen_update(FUNC(spectrum_state::screen_update_ts2068));
m_screen->screen_vblank().set(FUNC(spectrum_state::screen_vblank_timex));
m_screen->set_screen_update(FUNC(timex_state::screen_update_ts2068));
m_screen->screen_vblank().set(FUNC(timex_state::screen_vblank_timex));
subdevice<gfxdecode_device>("gfxdecode")->set_info(gfx_ts2068);
MCFG_VIDEO_START_OVERRIDE(spectrum_state, ts2068 )
MCFG_VIDEO_START_OVERRIDE(timex_state, ts2068 )
/* sound */
AY8912(config.replace(), "ay8912", XTAL(14'112'000)/8).add_route(ALL_OUTPUTS, "mono", 0.25); /* From Schematic; 1.764 MHz */
@ -714,7 +714,7 @@ MACHINE_CONFIG_START(spectrum_state::ts2068)
/* cartridge */
MCFG_GENERIC_CARTSLOT_ADD("dockslot", generic_plain_slot, "timex_cart")
MCFG_GENERIC_EXTENSIONS("dck,bin")
MCFG_GENERIC_LOAD(spectrum_state, timex_cart)
MCFG_GENERIC_LOAD(timex_state, timex_cart)
/* Software lists */
SOFTWARE_LIST(config, "cart_list").set_original("timex_dock");
@ -724,29 +724,29 @@ MACHINE_CONFIG_START(spectrum_state::ts2068)
MACHINE_CONFIG_END
void spectrum_state::uk2086(machine_config &config)
void timex_state::uk2086(machine_config &config)
{
ts2068(config);
m_screen->set_refresh_hz(50);
}
void spectrum_state::tc2048(machine_config &config)
void timex_state::tc2048(machine_config &config)
{
spectrum(config);
m_maincpu->set_addrmap(AS_PROGRAM, &spectrum_state::tc2048_mem);
m_maincpu->set_addrmap(AS_IO, &spectrum_state::tc2048_io);
m_maincpu->set_addrmap(AS_PROGRAM, &timex_state::tc2048_mem);
m_maincpu->set_addrmap(AS_IO, &timex_state::tc2048_io);
MCFG_MACHINE_RESET_OVERRIDE(spectrum_state, tc2048 )
MCFG_MACHINE_RESET_OVERRIDE(timex_state, tc2048 )
/* video hardware */
m_screen->set_refresh_hz(50);
m_screen->set_size(TS2068_SCREEN_WIDTH, SPEC_SCREEN_HEIGHT);
m_screen->set_visarea(0, TS2068_SCREEN_WIDTH-1, 0, SPEC_SCREEN_HEIGHT-1);
m_screen->set_screen_update(FUNC(spectrum_state::screen_update_tc2048));
m_screen->screen_vblank().set(FUNC(spectrum_state::screen_vblank_timex));
m_screen->set_screen_update(FUNC(timex_state::screen_update_tc2048));
m_screen->screen_vblank().set(FUNC(timex_state::screen_vblank_timex));
MCFG_VIDEO_START_OVERRIDE(spectrum_state, spectrum_128 )
MCFG_VIDEO_START_OVERRIDE(timex_state, spectrum_128 )
/* internal ram */
m_ram->set_default_size("48K");
@ -777,7 +777,7 @@ ROM_START(uk2086)
ROM_LOAD("ts2068_x.rom",0x14000,0x2000, CRC(ae16233a) SHA1(7e265a2c1f621ed365ea23bdcafdedbc79c1299c))
ROM_END
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1984, tc2048, spectrum, 0, tc2048, spectrum, spectrum_state, empty_init, "Timex of Portugal", "TC-2048" , 0 )
COMP( 1983, ts2068, spectrum, 0, ts2068, spectrum, spectrum_state, empty_init, "Timex Sinclair", "TS-2068" , 0 )
COMP( 1986, uk2086, spectrum, 0, uk2086, spectrum, spectrum_state, empty_init, "Unipolbrit", "UK-2086 ver. 1.2" , 0 )
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1984, tc2048, spectrum, 0, tc2048, spectrum, timex_state, empty_init, "Timex of Portugal", "TC-2048" , 0 )
COMP( 1983, ts2068, spectrum, 0, ts2068, spectrum, timex_state, empty_init, "Timex Sinclair", "TS-2068" , 0 )
COMP( 1986, uk2086, spectrum, 0, uk2086, spectrum, timex_state, empty_init, "Unipolbrit", "UK-2086 ver. 1.2" , 0 )

View File

@ -14,8 +14,6 @@
#include "machine/spec_snqk.h"
#include "bus/spectrum/exp.h"
#include "bus/generic/carts.h"
#include "bus/generic/slot.h"
#include "imagedev/cassette.h"
#include "imagedev/snapquik.h"
#include "machine/ram.h"
@ -73,7 +71,6 @@ public:
m_ram(*this, RAM_TAG),
m_speaker(*this, "speaker"),
m_exp(*this, "exp"),
m_dock(*this, "dockslot"),
m_io_line0(*this, "LINE0"),
m_io_line1(*this, "LINE1"),
m_io_line2(*this, "LINE2"),
@ -95,9 +92,6 @@ public:
void spectrum_common(machine_config &config);
void spectrum(machine_config &config);
void ts2068(machine_config &config);
void uk2086(machine_config &config);
void tc2048(machine_config &config);
void spectrum_128(machine_config &config);
void init_spectrum();
@ -154,32 +148,15 @@ protected:
DECLARE_WRITE8_MEMBER(spectrum_128_port_7ffd_w);
DECLARE_READ8_MEMBER(spectrum_128_ula_r);
DECLARE_READ8_MEMBER(ts2068_port_f4_r);
DECLARE_WRITE8_MEMBER(ts2068_port_f4_w);
DECLARE_READ8_MEMBER(ts2068_port_ff_r);
DECLARE_WRITE8_MEMBER(ts2068_port_ff_w);
DECLARE_WRITE8_MEMBER(tc2048_port_ff_w);
DECLARE_MACHINE_RESET(spectrum);
DECLARE_VIDEO_START(spectrum);
void spectrum_palette(palette_device &palette) const;
DECLARE_MACHINE_RESET(tc2048);
DECLARE_VIDEO_START(spectrum_128);
DECLARE_MACHINE_RESET(spectrum_128);
DECLARE_MACHINE_RESET(ts2068);
DECLARE_VIDEO_START(ts2068);
uint32_t screen_update_spectrum(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_tc2048(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_ts2068(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(screen_vblank_spectrum);
DECLARE_WRITE_LINE_MEMBER(screen_vblank_timex);
INTERRUPT_GEN_MEMBER(spec_interrupt);
// for timex cart only
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(timex_cart);
int m_dock_cart_type, m_ram_chunks;
memory_region *m_dock_crt;
unsigned int m_previous_border_x, m_previous_border_y;
bitmap_ind16 m_border_bitmap;
unsigned int m_previous_screen_x, m_previous_screen_y;
@ -187,7 +164,7 @@ protected:
void spectrum_128_update_memory();
virtual void plus3_update_memory() { }
void ts2068_update_memory();
virtual void ts2068_update_memory() { }
DECLARE_SNAPSHOT_LOAD_MEMBER(spectrum);
DECLARE_QUICKLOAD_LOAD_MEMBER(spectrum);
@ -201,16 +178,11 @@ protected:
void spectrum_io(address_map &map);
void spectrum_mem(address_map &map);
void spectrum_fetch(address_map &map);
void tc2048_io(address_map &map);
void tc2048_mem(address_map &map);
void ts2068_io(address_map &map);
void ts2068_mem(address_map &map);
required_device<cassette_image_device> m_cassette;
required_device<ram_device> m_ram;
required_device<speaker_sound_device> m_speaker;
optional_device<spectrum_expansion_slot_device> m_exp;
optional_device<generic_slot_device> m_dock;
// Regular spectrum ports; marked as optional because of other subclasses
optional_ioport m_io_line0;
@ -239,9 +211,6 @@ protected:
void spectrum_UpdateScreenBitmap(bool eof = false);
inline unsigned char get_display_color(unsigned char color, int invert);
inline void spectrum_plot_pixel(bitmap_ind16 &bitmap, int x, int y, uint32_t color);
void ts2068_hires_scanline(bitmap_ind16 &bitmap, int y, int borderlines);
void ts2068_64col_scanline(bitmap_ind16 &bitmap, int y, int borderlines, unsigned short inkcolor);
void ts2068_lores_scanline(bitmap_ind16 &bitmap, int y, int borderlines, int screen);
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
// snapshot helpers

View File

@ -9,6 +9,11 @@
#ifndef MAME_INCLUDES_TIMEX_H
#define MAME_INCLUDES_TIMEX_H
#pragma once
#include "bus/generic/carts.h"
#include "bus/generic/slot.h"
/* Border sizes for TS2068. These are guesses based on the number of cycles
available per frame. */
#define TS2068_TOP_BORDER 32
@ -30,4 +35,51 @@ enum
};
class timex_state : public spectrum_state
{
public:
timex_state(const machine_config &mconfig, device_type type, const char *tag) :
spectrum_state(mconfig, type, tag),
m_dock(*this, "dockslot")
{
}
void ts2068(machine_config &config);
void uk2086(machine_config &config);
void tc2048(machine_config &config);
private:
DECLARE_READ8_MEMBER(ts2068_port_f4_r);
DECLARE_WRITE8_MEMBER(ts2068_port_f4_w);
DECLARE_READ8_MEMBER(ts2068_port_ff_r);
DECLARE_WRITE8_MEMBER(ts2068_port_ff_w);
DECLARE_WRITE8_MEMBER(tc2048_port_ff_w);
DECLARE_MACHINE_RESET(tc2048);
DECLARE_MACHINE_RESET(ts2068);
DECLARE_VIDEO_START(ts2068);
uint32_t screen_update_tc2048(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint32_t screen_update_ts2068(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(screen_vblank_timex);
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(timex_cart);
int m_dock_cart_type, m_ram_chunks;
memory_region *m_dock_crt;
virtual void ts2068_update_memory() override;
void tc2048_io(address_map &map);
void tc2048_mem(address_map &map);
void ts2068_io(address_map &map);
void ts2068_mem(address_map &map);
optional_device<generic_slot_device> m_dock;
inline void spectrum_plot_pixel(bitmap_ind16 &bitmap, int x, int y, uint32_t color);
void ts2068_hires_scanline(bitmap_ind16 &bitmap, int y, int borderlines);
void ts2068_64col_scanline(bitmap_ind16 &bitmap, int y, int borderlines, unsigned short inkcolor);
void ts2068_lores_scanline(bitmap_ind16 &bitmap, int y, int borderlines, int screen);
};
#endif // MAME_INCLUDES_TIMEX_H

View File

@ -20,13 +20,13 @@
#include "includes/timex.h"
#include "machine/ram.h"
inline void spectrum_state::spectrum_plot_pixel(bitmap_ind16 &bitmap, int x, int y, uint32_t color)
inline void timex_state::spectrum_plot_pixel(bitmap_ind16 &bitmap, int x, int y, uint32_t color)
{
bitmap.pix16(y, x) = (uint16_t)color;
}
/* Update FLASH status for ts2068. Assumes flash update every 1/2s. */
VIDEO_START_MEMBER(spectrum_state,ts2068)
VIDEO_START_MEMBER(timex_state,ts2068)
{
m_frame_invert_count = 30;
@ -45,7 +45,7 @@ VIDEO_START_MEMBER(spectrum_state,ts2068)
m_irq_off_timer = timer_alloc(TIMER_IRQ_OFF);
}
WRITE_LINE_MEMBER(spectrum_state::screen_vblank_timex)
WRITE_LINE_MEMBER(timex_state::screen_vblank_timex)
{
// rising edge
if (state)
@ -86,7 +86,7 @@ WRITE_LINE_MEMBER(spectrum_state::screen_vblank_timex)
*******************************************************************/
/* Draw a scanline in TS2068/TC2048 hires mode (code modified from COUPE.C) */
void spectrum_state::ts2068_hires_scanline(bitmap_ind16 &bitmap, int y, int borderlines)
void timex_state::ts2068_hires_scanline(bitmap_ind16 &bitmap, int y, int borderlines)
{
int x,b,scrx,scry;
unsigned short ink,pap;
@ -131,7 +131,7 @@ void spectrum_state::ts2068_hires_scanline(bitmap_ind16 &bitmap, int y, int bord
}
/* Draw a scanline in TS2068/TC2048 64-column mode */
void spectrum_state::ts2068_64col_scanline(bitmap_ind16 &bitmap, int y, int borderlines, unsigned short inkcolor)
void timex_state::ts2068_64col_scanline(bitmap_ind16 &bitmap, int y, int borderlines, unsigned short inkcolor)
{
int x,b,scrx,scry;
unsigned char *scr1, *scr2;
@ -165,7 +165,7 @@ void spectrum_state::ts2068_64col_scanline(bitmap_ind16 &bitmap, int y, int bord
}
/* Draw a scanline in TS2068/TC2048 lores (normal Spectrum) mode */
void spectrum_state::ts2068_lores_scanline(bitmap_ind16 &bitmap, int y, int borderlines, int screen)
void timex_state::ts2068_lores_scanline(bitmap_ind16 &bitmap, int y, int borderlines, int screen)
{
int x,b,scrx,scry;
unsigned short ink,pap;
@ -209,7 +209,7 @@ void spectrum_state::ts2068_lores_scanline(bitmap_ind16 &bitmap, int y, int bord
}
}
uint32_t spectrum_state::screen_update_ts2068(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
uint32_t timex_state::screen_update_ts2068(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
/* for now TS2068 will do a full-refresh */
int count;
@ -246,7 +246,7 @@ uint32_t spectrum_state::screen_update_ts2068(screen_device &screen, bitmap_ind1
return 0;
}
uint32_t spectrum_state::screen_update_tc2048(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
uint32_t timex_state::screen_update_tc2048(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
/* for now TS2068 will do a full-refresh */
int count;