electron: now uses RAM device instead of ROM_REGION

- added CSW cassette format
- pressing BREAK will now hold until released
This commit is contained in:
Nigel Barnes 2016-08-28 17:14:23 +01:00
parent 2d8bd39134
commit 2239e5d4c3
3 changed files with 48 additions and 12 deletions

View File

@ -54,6 +54,7 @@ that can be done through BASIC programs seem to behave properly (most of the tim
Incomplete:
- Sound (sound is too high?)
- Graphics (seems to be wrong for several games)
- 1 MHz bus is not emulated
- Bus claiming by ULA is not implemented
- Currently the cartridge support always loads the upper rom in page 12
@ -70,6 +71,7 @@ Missing:
#include "includes/electron.h"
#include "imagedev/cassette.h"
#include "formats/uef_cas.h"
#include "formats/csw_cas.h"
#include "sound/beep.h"
#include "softlist.h"
@ -91,7 +93,7 @@ PALETTE_INIT_MEMBER(electron_state, electron)
}
static ADDRESS_MAP_START(electron_mem, AS_PROGRAM, 8, electron_state )
AM_RANGE(0x0000, 0x7fff) AM_RAM AM_REGION("maincpu", 0x00000) /* 32KB of RAM */
AM_RANGE(0x0000, 0x7fff) AM_READWRITE(electron_mem_r, electron_mem_w) /* 32KB of RAM */
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank2") /* Banked ROM pages */
AM_RANGE(0xc000, 0xfbff) AM_ROM AM_REGION("user1", 0x40000) /* OS ROM */
AM_RANGE(0xfc00, 0xfcff) AM_READWRITE(electron_fred_r, electron_fred_w ) /* FRED */
@ -102,7 +104,7 @@ ADDRESS_MAP_END
INPUT_CHANGED_MEMBER(electron_state::trigger_reset)
{
m_maincpu->set_input_line(INPUT_LINE_RESET, PULSE_LINE);
m_maincpu->set_input_line(INPUT_LINE_RESET, newval ? ASSERT_LINE : CLEAR_LINE);
}
static INPUT_PORTS_START( electron )
@ -197,7 +199,7 @@ INPUT_PORTS_END
static MACHINE_CONFIG_START( electron, electron_state )
MCFG_CPU_ADD( "maincpu", M6502, XTAL_16MHz/8 )
MCFG_CPU_PROGRAM_MAP( electron_mem)
MCFG_CPU_PROGRAM_MAP( electron_mem )
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE( 50.08 )
@ -214,8 +216,11 @@ static MACHINE_CONFIG_START( electron, electron_state )
MCFG_SOUND_ADD( "beeper", BEEP, 300 )
MCFG_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
MCFG_RAM_ADD(RAM_TAG)
MCFG_RAM_DEFAULT_SIZE("32K")
MCFG_CASSETTE_ADD( "cassette" )
MCFG_CASSETTE_FORMATS(uef_cassette_formats)
MCFG_CASSETTE_FORMATS(bbc_cassette_formats)
MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_PLAY)
MCFG_CASSETTE_INTERFACE("electron_cass")
@ -226,7 +231,6 @@ static MACHINE_CONFIG_START( electron, electron_state )
MCFG_ELECTRON_EXPANSION_SLOT_ADD("exp", electron_expansion_devices, nullptr)
MCFG_ELECTRON_EXPANSION_SLOT_IRQ_HANDLER(INPUTLINE("maincpu", M6502_IRQ_LINE))
MCFG_ELECTRON_EXPANSION_SLOT_NMI_HANDLER(INPUTLINE("maincpu", M6502_NMI_LINE))
MCFG_ELECTRON_EXPANSION_SLOT_RES_HANDLER(INPUTLINE("maincpu", INPUT_LINE_RESET))
/* software lists */
MCFG_SOFTWARE_LIST_ADD("cass_list", "electron_cass")
@ -249,7 +253,6 @@ MACHINE_CONFIG_END
/* Electron Rom Load */
ROM_START(electron)
ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
ROM_REGION( 0x44000, "user1", 0 ) /* OS Rom */
ROM_LOAD( "os.rom", 0x40000, 0x4000, CRC(bf63fb1f) SHA1(a48b8fa0cfb09140e808ac8a187316c605a0b32e) ) /* OS rom */
/* 00000 0 Second external socket on the expansion module (SK2) */

View File

@ -13,6 +13,7 @@
#ifndef ELECTRON_H_
#define ELECTRON_H_
#include "machine/ram.h"
#include "imagedev/cassette.h"
#include "sound/beep.h"
@ -76,7 +77,8 @@ public:
m_beeper(*this, "beeper"),
m_cart(*this, "cartslot"),
m_keybd(*this, "LINE.%u", 0),
m_exp(*this, "exp")
m_exp(*this, "exp"),
m_ram(*this, RAM_TAG)
{ }
ULA m_ula;
@ -85,12 +87,15 @@ public:
int m_map16[256];
emu_timer *m_scanline_timer;
DECLARE_READ8_MEMBER(electron_read_keyboard);
DECLARE_READ8_MEMBER(electron_mem_r);
DECLARE_WRITE8_MEMBER(electron_mem_w);
DECLARE_READ8_MEMBER(electron_fred_r);
DECLARE_WRITE8_MEMBER(electron_fred_w);
DECLARE_READ8_MEMBER(electron_jim_r);
DECLARE_WRITE8_MEMBER(electron_jim_w);
DECLARE_READ8_MEMBER(electron_sheila_r);
DECLARE_WRITE8_MEMBER(electron_sheila_w);
void waitforramsync();
void electron_tape_start();
void electron_tape_stop();
virtual void machine_start() override;
@ -107,6 +112,7 @@ public:
required_device<generic_slot_device> m_cart;
required_ioport_array<14> m_keybd;
required_device<electron_expansion_slot_device> m_exp;
required_device<ram_device> m_ram;
inline UINT8 read_vram( UINT16 addr );
inline void electron_plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT32 color);
void electron_interrupt_handler(int mode, int interrupt);

View File

@ -15,6 +15,20 @@
#include "imagedev/cassette.h"
void electron_state::waitforramsync()
{
int cycles = 0;
if (!(m_ula.screen_mode & 4) && machine().first_screen()->hpos()<640)
{
cycles += (640 - machine().first_screen()->hpos()) / 8;
}
if (cycles & 1) cycles++;
m_maincpu->adjust_icount(-cycles);
}
void electron_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
switch (id)
@ -145,8 +159,21 @@ READ8_MEMBER(electron_state::electron_read_keyboard)
return data;
}
READ8_MEMBER(electron_state::electron_mem_r)
{
//waitforramsync();
return m_ram->read(offset);
}
WRITE8_MEMBER(electron_state::electron_mem_w)
{
//waitforramsync();
m_ram->write(offset, data);
}
READ8_MEMBER(electron_state::electron_fred_r)
{
logerror("FRED: read fc%02x\n", offset);
return 0xff;
}
@ -156,6 +183,7 @@ WRITE8_MEMBER(electron_state::electron_fred_w)
READ8_MEMBER(electron_state::electron_jim_r)
{
logerror("JIM: read fd%02x\n", offset);
return 0xff;
}
@ -174,7 +202,7 @@ READ8_MEMBER(electron_state::electron_sheila_r)
break;
case 0x01: /* Unknown */
break;
case 0x04: /* Casette data shift register */
case 0x04: /* Cassette data shift register */
electron_interrupt_handler(INT_CLEAR, INT_RECEIVE_FULL );
data = m_ula.tape_byte;
break;
@ -201,7 +229,7 @@ WRITE8_MEMBER(electron_state::electron_sheila_w)
m_ula.screen_start = ( m_ula.screen_start & 0x7e00 ) | ( ( data & 0xe0 ) << 1 );
logerror( "screen_start changed to %04x\n", m_ula.screen_start );
break;
case 0x03: /* Screen start addres #2 */
case 0x03: /* Screen start address #2 */
m_ula.screen_start = ( m_ula.screen_start & 0x1c0 ) | ( ( data & 0x3f ) << 9 );
logerror( "screen_start changed to %04x\n", m_ula.screen_start );
break;
@ -279,7 +307,7 @@ WRITE8_MEMBER(electron_state::electron_sheila_w)
m_ula.screen_mode = ( data >> 3 ) & 0x07;
m_ula.screen_base = electron_screen_base[ m_ula.screen_mode ];
m_ula.screen_size = 0x8000 - m_ula.screen_base;
m_ula.vram = (UINT8 *)space.get_read_ptr(m_ula.screen_base );
m_ula.vram = (UINT8 *)m_ram->pointer() + m_ula.screen_base;
logerror( "ULA: screen mode set to %d\n", m_ula.screen_mode );
m_ula.cassette_motor_mode = ( data >> 6 ) & 0x01;
m_cassette->change_state(m_ula.cassette_motor_mode ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MOTOR_DISABLED );
@ -342,13 +370,12 @@ void electron_state::machine_reset()
m_ula.screen_mode = 0;
m_ula.cassette_motor_mode = 0;
m_ula.capslock_mode = 0;
m_ula.screen_mode = 0;
m_ula.screen_start = 0x3000;
m_ula.screen_base = 0x3000;
m_ula.screen_size = 0x8000 - 0x3000;
m_ula.screen_addr = 0;
m_ula.tape_running = 0;
m_ula.vram = (UINT8 *)m_maincpu->space(AS_PROGRAM).get_read_ptr(m_ula.screen_base);
m_ula.vram = (UINT8 *)m_ram->pointer() + m_ula.screen_base;
}
void electron_state::machine_start()