Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ussr/bk: quickload and switchable b&w/color output #12911

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/mame/ussr/1801vp014.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static INPUT_PORTS_START(ms7008)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ЗАГЛ/СТР / Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) PORT_TOGGLE
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("mono/color monitor toggle") PORT_CODE(KEYCODE_ASTERISK) PORT_TOGGLE PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(k1801vp014_device::monitor_type_button), 0)
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("СТОП / Stop") PORT_CODE(KEYCODE_PAUSE) PORT_CHAR(UCHAR_MAMEKEY(PAUSE)) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(k1801vp014_device::stop_button), 0)

PORT_START("LINE0") // X0
Expand Down Expand Up @@ -158,6 +158,11 @@ INPUT_CHANGED_MEMBER(k1801vp014_device::stop_button)
m_write_halt(newval ? ASSERT_LINE : CLEAR_LINE);
}

INPUT_CHANGED_MEMBER(k1801vp014_device::monitor_type_button)
{
m_write_monitor_type(newval ? ASSERT_LINE : CLEAR_LINE);
}


//-------------------------------------------------
// k1801vp014_device - constructor
Expand All @@ -171,6 +176,7 @@ k1801vp014_device::k1801vp014_device(const machine_config &mconfig, const char *
, m_write_virq(*this)
, m_write_keydown(*this)
, m_write_halt(*this)
, m_write_monitor_type(*this)
{
}

Expand Down
3 changes: 3 additions & 0 deletions src/mame/ussr/1801vp014.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ class k1801vp014_device : public device_t,
auto virq_wr_callback() { return m_write_virq.bind(); }
auto keydown_wr_callback() { return m_write_keydown.bind(); }
auto halt_wr_callback() { return m_write_halt.bind(); }
auto monitor_type_wr_callback() { return m_write_monitor_type.bind(); }

uint16_t read(offs_t offset);
void write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);

DECLARE_INPUT_CHANGED_MEMBER(stop_button);
DECLARE_INPUT_CHANGED_MEMBER(monitor_type_button);

protected:
// device-level overrides
Expand All @@ -60,6 +62,7 @@ class k1801vp014_device : public device_t,
devcb_write_line m_write_virq;
devcb_write_line m_write_keydown;
devcb_write_line m_write_halt;
devcb_write_line m_write_monitor_type;

uint8_t m_rxrdy;

Expand Down
12 changes: 9 additions & 3 deletions src/mame/ussr/bk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ void bk_state::bk0010fd_mem(address_map &map)

/* Input ports */
static INPUT_PORTS_START( bk0010 )
PORT_START("CONFIG")
PORT_CONFNAME(0x01, 0x00, "Monitor type") PORT_WRITE_LINE_MEMBER(FUNC(bk_state::update_monitor_type))
PORT_CONFSETTING(0x00, "B&W")
PORT_CONFSETTING(0x01, "Color")
INPUT_PORTS_END

static const z80_daisy_config daisy_chain[] =
Expand Down Expand Up @@ -90,17 +94,18 @@ void bk_state::bk0010(machine_config &config)
m_sel1 |= SEL1_KEYDOWN;
});
m_kbd->halt_wr_callback().set_inputline(m_maincpu, t11_device::HLT_LINE);
m_kbd->monitor_type_wr_callback().set([this] (int state) { m_monitor ^= 1; });

/* video hardware */
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh_hz(4000000.0/81920.0);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); /* not accurate */
screen.set_size(512, 256);
screen.set_visarea(0, 512-1, 0, 256-1);
screen.set_screen_update(FUNC(bk_state::screen_update));
screen.set_palette("palette");
screen.set_screen_update(FUNC(bk_state::screen_update_10));
screen.set_palette(m_palette);

PALETTE(config, "palette", palette_device::MONOCHROME);
PALETTE(config, m_palette, FUNC(bk_state::bk0010_palette), 5);

SPEAKER(config, "mono").front_center();
DAC_1BIT(config, m_dac, 0).add_route(ALL_OUTPUTS, "mono", 0.25);
Expand All @@ -111,6 +116,7 @@ void bk_state::bk0010(machine_config &config)
m_cassette->set_interface("bk0010_cass");

SOFTWARE_LIST(config, "cass_list").set_original("bk0010");
QUICKLOAD(config, "quickload", "bin", attotime::from_seconds(6)).set_load_callback(FUNC(bk_state::quickload_cb));
}

void bk_state::bk0010fd(machine_config &config)
Expand Down
23 changes: 17 additions & 6 deletions src/mame/ussr/bk.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
#include "bus/qbus/qbus.h"
#include "cpu/t11/t11.h"
#include "imagedev/cassette.h"
#include "imagedev/snapquik.h"
#include "sound/dac.h"

#include "emupal.h"

class bk_state : public driver_device
{
public:
bk_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_vram(*this, "videoram")
, m_maincpu(*this, "maincpu")
, m_palette(*this, "palette")
, m_cassette(*this, "cassette")
, m_dac(*this, "dac")
, m_kbd(*this, "keyboard")
Expand All @@ -32,6 +36,7 @@ class bk_state : public driver_device

void bk0010(machine_config &config);
void bk0010fd(machine_config &config);
void update_monitor_type(int state);

protected:
virtual void machine_start() override ATTR_COLD;
Expand All @@ -48,28 +53,34 @@ class bk_state : public driver_device
SEL1_MOTOR = 0200,
};

uint16_t m_scroll;
uint16_t m_sel1;
int m_monitor;

uint16_t vid_scroll_r();
uint16_t sel1_r();
uint16_t trap_r();
void vid_scroll_w(uint16_t data);
void sel1_w(uint16_t data);
void trap_w(uint16_t data);
void reset_w(int state);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);

void bk0010_mem(address_map &map) ATTR_COLD;
void bk0010fd_mem(address_map &map) ATTR_COLD;
uint32_t screen_update_10(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);

required_shared_ptr<uint16_t> m_vram;
required_device<k1801vm1_device> m_maincpu;
required_device<palette_device> m_palette;
required_device<cassette_image_device> m_cassette;
required_device<dac_bit_interface> m_dac;
required_device<k1801vp014_device> m_kbd;
required_device<qbus_device> m_qbus;

uint16_t m_scroll = 0U;
uint16_t m_sel1 = 0U;
uint16_t m_drive = 0U;
DECLARE_QUICKLOAD_LOAD_MEMBER(quickload_cb);

void bk0010_mem(address_map &map) ATTR_COLD;
void bk0010fd_mem(address_map &map) ATTR_COLD;

void bk0010_palette(palette_device &palette);
};

#endif // MAME_USSR_BK_H
66 changes: 62 additions & 4 deletions src/mame/ussr/bk_m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ void bk_state::machine_start()
{
save_item(NAME(m_scroll));
save_item(NAME(m_sel1));
save_item(NAME(m_drive));
}

void bk_state::machine_reset()
{
m_sel1 = SEL1_KEYDOWN | SEL1_MOTOR;
m_scroll = 01330;
m_monitor = ioport("CONFIG")->read();
}

void bk_state::reset_w(int state)
Expand Down Expand Up @@ -90,7 +90,53 @@ void bk_state::trap_w(uint16_t data)
m_maincpu->pulse_input_line(t11_device::BUS_ERROR, attotime::zero);
}

u32 bk_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
QUICKLOAD_LOAD_MEMBER(bk_state::quickload_cb)
{
if (image.length() > 0100000)
return std::make_pair(image_error::INVALIDLENGTH, "File too long (must be no larger than 32 KB)");

address_space &space = m_maincpu->space(AS_PROGRAM);
uint16_t addr, size, offset;

image.fread(&addr, 2);
addr = little_endianize_int16(addr);
image.fread(&size, 2);
size = little_endianize_int16(size);
logerror("bk bin load: addr %06o size %06o\n", addr, size);

std::vector<uint16_t> buffer((size+1)/2);
image.fread(&buffer[0], size);

space.write_word(0264, addr);
space.write_word(0266, size);

offset = 0;
size /= 2;
while (size-- > 0)
{
space.write_word(addr, little_endianize_int16(buffer[offset]));
addr += 2;
offset++;
}

return std::make_pair(std::error_condition(), std::string());
}

void bk_state::bk0010_palette(palette_device &palette)
{
palette.set_pen_color(0, rgb_t(0, 0, 0));
palette.set_pen_color(1, rgb_t(0, 0, 255));
palette.set_pen_color(2, rgb_t(0, 255, 0));
palette.set_pen_color(3, rgb_t(255, 0, 0));
palette.set_pen_color(4, rgb_t(255, 255, 255));
}

void bk_state::update_monitor_type(int state)
{
m_monitor = state;
}

u32 bk_state::screen_update_10(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
u16 const mini = !BIT(m_scroll, 9);
u16 const nOfs = (m_scroll & 255) + (mini ? 40 : -216);
Expand All @@ -100,8 +146,20 @@ u32 bk_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const r
for (u16 x = 0; x < 32; x++)
{
u16 const code = (y > 63 && mini) ? 0 : m_vram[((y+nOfs) %256)*32 + x];
for (u8 b = 0; b < 16; b++)
bitmap.pix(y, x*16 + b) = BIT(code, b);
if (m_monitor)
{
for (u8 b = 0; b < 16; b += 2)
{
int pixel = (code >> b) & 3;
bitmap.pix(y, x*16 + b) = pixel;
bitmap.pix(y, x*16 + b + 1) = pixel;
}
}
else
{
for (u8 b = 0; b < 16; b++)
bitmap.pix(y, x*16 + b) = BIT(code, b) << 2;
}
}
}
return 0;
Expand Down
Loading