(nw) super80: reworked the address maps again

This commit is contained in:
Robbbert 2020-05-16 23:03:29 +10:00
parent 2a68e0d707
commit f4a8709caa
4 changed files with 63 additions and 62 deletions

View File

@ -234,28 +234,21 @@ ToDo:
void super80_state::super80_map(address_map &map)
{
map(0x0000, 0xbfff).lrw8(NAME([this](u16 offset) { return m_ram[offset]; }),
NAME([this](u16 offset, u8 data) { m_ram[offset] = data; }));
map(0x0000, 0x07ff).lr8 (NAME([this](u16 offset) { if(m_boot_in_progress) offset |= 0xc000; return m_ram[offset]; }));
map(0xc000, 0xc7ff).lr8 (NAME([this](u16 offset) { if (!machine().side_effects_disabled()) m_boot_in_progress = false; return m_ram[offset | 0xc000]; }));
map(0xc800, 0xffff).lr8 (NAME([this](u16 offset) { return m_ram[offset+0xc800]; }));
map(0xc000, 0xffff).nopw();
map(0x0000, 0xbfff).ram().share("mainram");
map(0xc000, 0xefff).rom().region("maincpu", 0).nopw();
map(0xf000, 0xffff).lr8(NAME([] () { return 0xff; })).nopw();
}
void super80_state::super80m_map(address_map &map)
{
super80_map(map);
map(0xf000, 0xffff).lrw8(NAME([this](u16 offset) { return m_ram[offset+0xf000]; }),
NAME([this](u16 offset, u8 data) { m_ram[offset+0xf000] = data; }));
map(0x0000, 0xffff).ram().share("mainram");
map(0xc000, 0xefff).rom().region("maincpu", 0).nopw();
}
void super80v_state::super80v_map(address_map &map)
{
map(0x0000, 0x07ff).lrw8(NAME([this](u16 offset) { if(m_boot_in_progress) return m_rom[offset]; else return m_ram[offset]; }),
NAME([this](u16 offset, u8 data) { m_ram[offset] = data; }));
map(0x0800, 0xbfff).ram();
map(0xc000, 0xc7ff).lr8 (NAME([this](u16 offset) { if (!machine().side_effects_disabled()) m_boot_in_progress = false; return m_rom[offset]; }));
map(0xc800, 0xefff).lr8 (NAME([this](u16 offset) { return m_rom[offset+0x0800]; }));
map(0x0000, 0xbfff).ram().share("mainram");
map(0xc000, 0xefff).rom().region("maincpu", 0).nopw();
map(0xf000, 0xf7ff).rw(FUNC(super80v_state::low_r), FUNC(super80v_state::low_w));
map(0xf800, 0xffff).rw(FUNC(super80v_state::high_r), FUNC(super80v_state::high_w));
}
@ -638,7 +631,7 @@ WRITE_LINE_MEMBER( super80v_state::busreq_w )
{
// since our Z80 has no support for BUSACK, we assume it is granted immediately
m_maincpu->set_input_line(Z80_INPUT_LINE_BUSRQ, state);
m_maincpu->set_input_line(INPUT_LINE_HALT, state); // do we need this?
m_maincpu->set_input_line(INPUT_LINE_HALT, state);
m_dma->bai_w(state); // tell dma that bus has been granted
}

View File

@ -38,6 +38,7 @@ public:
, m_screen(*this, "screen")
, m_maincpu(*this, "maincpu")
, m_rom(*this, "maincpu")
, m_ram(*this, "mainram")
, m_p_chargen(*this, "chargen")
, m_pio(*this, "z80pio")
, m_cassette(*this, "cassette")
@ -74,7 +75,6 @@ protected:
u8 m_key_pressed;
u8 m_last_data;
bool m_boot_in_progress;
std::unique_ptr<u8[]> m_ram;
void super80m_palette(palette_device &palette) const;
TIMER_DEVICE_CALLBACK_MEMBER(timer_k);
TIMER_DEVICE_CALLBACK_MEMBER(kansas_r);
@ -84,6 +84,8 @@ protected:
required_device<screen_device> m_screen;
required_device<z80_device> m_maincpu;
required_region_ptr<u8> m_rom;
memory_passthrough_handler *m_rom_shadow_tap;
required_shared_ptr<u8> m_ram;
required_region_ptr<u8> m_p_chargen;
required_device<z80pio_device> m_pio;
required_device<cassette_image_device> m_cassette;
@ -137,8 +139,11 @@ public:
protected:
void super80v_map(address_map &map);
void super80v_io(address_map &map);
void machine_reset() override;
void machine_start() override;
void port3f_w(u8 data);
u8 port3e_r();
std::unique_ptr<u8[]> m_vram;
DECLARE_WRITE_LINE_MEMBER(busreq_w);
uint8_t memory_read_byte(offs_t offset);
void memory_write_byte(offs_t offset, uint8_t data);
@ -155,8 +160,6 @@ protected:
required_device<floppy_connector> m_floppy3;
private:
void machine_reset() override;
void machine_start() override;
void low_w(offs_t offset, u8 data);
void high_w(offs_t offset, u8 data);
u8 low_r(offs_t offset);
@ -171,12 +174,9 @@ public:
void super80r(machine_config &config);
private:
void machine_reset() override;
void machine_start() override;
void super80r_map(address_map &map);
void low_w(offs_t offset, u8 data);
void high_w(offs_t offset, u8 data);
void super80r_map(address_map &map);
u8 low_r(offs_t offset);
u8 high_r(offs_t offset);
};

View File

@ -191,12 +191,9 @@ void super80_state::portf0_w(u8 data)
void super80_state::machine_start_common()
{
// zerofill
m_ram = make_unique_clear<u8[]>(0x10000);
m_cass_led.resolve();
// register for savestates
save_pointer(NAME(m_ram), 0x10000);
save_item(NAME(m_portf0));
save_item(NAME(m_s_options));
save_item(NAME(m_palette_index));
@ -213,17 +210,13 @@ void super80_state::machine_start()
save_item(NAME(m_int_sw));
save_item(NAME(m_vidpg));
save_item(NAME(m_current_charset));
std::copy_n(&m_rom[0], 0x3000, &m_ram[0xc000]); // make 0 F1 C0 work
std::fill_n(&m_ram[0xf000], 0x1000, 0xff); // make O F1 FF work
}
void super80r_state::machine_start()
{
machine_start_common();
}
void super80v_state::machine_start()
{
// zerofill
m_vram = make_unique_clear<u8[]>(0x3000);
save_pointer(NAME(m_vram), 0x3000);
machine_start_common();
}
@ -234,21 +227,31 @@ void super80_state::machine_reset_common()
m_keylatch = 0xff;
m_key_pressed = 0;
m_palette_index = 0;
address_space &program = m_maincpu->space(AS_PROGRAM);
program.install_rom(0x0000, 0x0fff, m_rom); // do it here for F3
m_rom_shadow_tap = program.install_read_tap(0xc000, 0xcfff, "rom_shadow_r",[this](offs_t offset, u8 &data, u8 mem_mask)
{
if (!machine().side_effects_disabled())
{
// delete this tap
m_rom_shadow_tap->remove();
// reinstall ram over the rom shadow
m_maincpu->space(AS_PROGRAM).install_ram(0x0000, 0x0fff, m_ram);
}
// return the original data
return data;
});
}
void super80_state::machine_reset()
{
std::copy_n(&m_rom[0], 0x3000, &m_ram[0xc000]); // make 0 F1 C0 work
std::fill_n(&m_ram[0xf000], 0x1000, 0xff); // make O F1 FF work
machine_reset_common();
m_vidpg = 0xfe00;
}
void super80r_state::machine_reset()
{
machine_reset_common();
}
void super80v_state::machine_reset()
{
machine_reset_common();

View File

@ -63,6 +63,8 @@ void super80_state::screen_vblank_super80m(bool state)
uint32_t super80_state::screen_update_super80(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
address_space& program = m_maincpu->space(AS_PROGRAM);
m_cass_led = BIT(m_portf0, 5);
const uint8_t options = m_io_config->read();
@ -90,7 +92,7 @@ uint32_t super80_state::screen_update_super80(screen_device &screen, bitmap_ind1
uint8_t chr = 32;
if (screen_on)
{
chr = m_ram[ma | x] & 0x7f;
chr = program.read_byte(ma | x) & 0x7f;
if ((chr >= 0x61) && (chr <= 0x7a))
chr &= 0x1f;
else
@ -118,6 +120,7 @@ uint32_t super80_state::screen_update_super80(screen_device &screen, bitmap_ind1
uint32_t super80_state::screen_update_super80d(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
address_space& program = m_maincpu->space(AS_PROGRAM);
m_cass_led = BIT(m_portf0, 5);
const uint8_t options = m_io_config->read();
@ -144,7 +147,7 @@ uint32_t super80_state::screen_update_super80d(screen_device &screen, bitmap_ind
{
uint8_t chr = 32;
if (screen_on)
chr = m_ram[ma | x];
chr = program.read_byte(ma | x);
// get pattern of pixels for that character scanline
const uint8_t gfx = m_p_chargen[((chr & 0x7f)<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)] ^ ((chr & 0x80) ? 0xff : 0);
@ -167,6 +170,7 @@ uint32_t super80_state::screen_update_super80d(screen_device &screen, bitmap_ind
uint32_t super80_state::screen_update_super80e(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
address_space& program = m_maincpu->space(AS_PROGRAM);
m_cass_led = BIT(m_portf0, 5);
const uint8_t options = m_io_config->read();
@ -193,7 +197,7 @@ uint32_t super80_state::screen_update_super80e(screen_device &screen, bitmap_ind
{
uint8_t chr = 32;
if (screen_on)
chr = m_ram[ma | x];
chr = program.read_byte(ma | x);
// get pattern of pixels for that character scanline
const uint8_t gfx = m_p_chargen[(chr<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)];
@ -216,6 +220,7 @@ uint32_t super80_state::screen_update_super80e(screen_device &screen, bitmap_ind
uint32_t super80_state::screen_update_super80m(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
address_space& program = m_maincpu->space(AS_PROGRAM);
m_cass_led = BIT(m_portf0, 5);
const uint8_t options = m_io_config->read();
@ -246,12 +251,12 @@ uint32_t super80_state::screen_update_super80m(screen_device &screen, bitmap_ind
{
uint8_t chr = 32;
if (screen_on)
chr = m_ram[ma | x];
chr = program.read_byte(ma | x);
uint8_t bg = 0;
if (!(options & 0x40))
{
const uint8_t col = m_ram[0xfe00 | ma | x]; // byte of colour to display
const uint8_t col = program.read_byte(0xfe00 | ma | x); // byte of colour to display
fg = m_palette_index + (col & 0x0f);
bg = m_palette_index + (col >> 4);
}
@ -294,51 +299,51 @@ void super80_state::portf1_w(u8 data)
---------------------------------------------------------------*/
// we place the colour ram at m_ram[0x9000], and the videoram at m_ram[0x8000].
// we place videoram at 0x0000, colour ram at 0x1000, pcg at 0x2000
u8 super80r_state::low_r(offs_t offset)
{
return m_ram[offset+0x8000];
return m_vram[offset];
}
void super80r_state::low_w(offs_t offset, u8 data)
{
m_ram[offset+0x8000] = data; // video
m_vram[offset] = data; // video
}
u8 super80r_state::high_r(offs_t offset)
{
return m_ram[offset+0x8800]; // video
return m_vram[offset+0x0800]; // video
}
void super80r_state::high_w(offs_t offset, u8 data)
{
m_ram[offset+0x8800] = data; // video
m_ram[offset+0xf800] = data; // pcg
m_vram[offset+0x0800] = data; // video
m_vram[offset+0x2800] = data; // pcg
}
u8 super80v_state::low_r(offs_t offset)
{
if (BIT(m_portf0, 2))
return m_ram[offset+0x8000]; // video
return m_vram[offset]; // video
else
return m_ram[offset+0x9000]; // colour
return m_vram[offset+0x1000]; // colour
}
void super80v_state::low_w(offs_t offset, u8 data)
{
if (BIT(m_portf0, 2))
m_ram[offset+0x8000] = data; // video
m_vram[offset] = data; // video
else
m_ram[offset+0x9000] = data; // colour
m_vram[offset+0x1000] = data; // colour
}
u8 super80v_state::high_r(offs_t offset)
{
if (!BIT(m_portf0, 2))
return m_ram[offset+0x9800]; // colour
return m_vram[offset+0x1800]; // colour
else
if (BIT(m_portf0, 4))
return m_ram[offset+0x8800]; // video
return m_vram[offset+0x0800]; // video
else
return m_p_chargen[offset]; // char rom
}
@ -346,13 +351,13 @@ u8 super80v_state::high_r(offs_t offset)
void super80v_state::high_w(offs_t offset, u8 data)
{
if (!BIT(m_portf0, 2))
m_ram[offset+0x9800] = data; // colour
m_vram[offset+0x1800] = data; // colour
else
{
m_ram[offset+0x8800] = data; // video
m_vram[offset+0x0800] = data; // video
if (BIT(m_portf0, 4))
m_ram[offset+0xf800] = data; // pcg
m_vram[offset+0x2800] = data; // pcg
}
}
@ -374,7 +379,7 @@ MC6845_UPDATE_ROW( super80v_state::crtc_update_row )
uint8_t inv = 0;
if (x == cursor_x) inv=0xff;
const uint16_t mem = (ma + x) & 0xfff;
uint8_t chr = m_ram[mem+0x8000];
uint8_t chr = m_vram[mem];
/* get colour or b&w */
uint8_t fg = 5; // green
@ -384,7 +389,7 @@ MC6845_UPDATE_ROW( super80v_state::crtc_update_row )
uint8_t bg = 0;
if (~m_s_options & 0x40)
{
const uint8_t col = m_ram[mem+0x9000]; // byte of colour to display
const uint8_t col = m_vram[mem+0x1000]; // byte of colour to display
fg = m_palette_index + (col & 0x0f);
bg = m_palette_index + (col >> 4);
}
@ -398,7 +403,7 @@ MC6845_UPDATE_ROW( super80v_state::crtc_update_row )
// get pattern of pixels for that character scanline
const uint8_t gfx = BIT(chr, 7)
? m_ram[0xf000 | ((chr << 4) | ra)] ^ inv
? m_vram[0x2000 | ((chr << 4) | ra)] ^ inv
: m_p_chargen[((chr << 4) | ra)] ^ inv;
// Display a scanline of a character