trunk/src/mess/machine/galaxy.c
| r20819 | r20820 | |
| 10 | 10 | #include "emu.h" |
| 11 | 11 | #include "cpu/z80/z80.h" |
| 12 | 12 | #include "includes/galaxy.h" |
| 13 | | #include "imagedev/cassette.h" |
| 14 | | #include "machine/ram.h" |
| 15 | 13 | |
| 16 | 14 | /*************************************************************************** |
| 17 | 15 | I/O devices |
| r20819 | r20820 | |
| 19 | 17 | |
| 20 | 18 | READ8_MEMBER(galaxy_state::galaxy_keyboard_r) |
| 21 | 19 | { |
| 22 | | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" }; |
| 23 | | |
| 24 | 20 | if (offset == 0) |
| 25 | 21 | { |
| 26 | | double level = (machine().device<cassette_image_device>(CASSETTE_TAG)->input()); |
| 22 | double level = m_cassette->input(); |
| 27 | 23 | return (level > 0) ? 0xfe : 0xff; |
| 28 | 24 | } |
| 29 | 25 | else |
| 30 | 26 | { |
| 31 | | return ioport(keynames[(offset>>3) & 0x07])->read() & (0x01<<(offset & 0x07)) ? 0xfe : 0xff; |
| 27 | return m_io_ports[(offset>>3) & 0x07]->read() & (0x01<<(offset & 0x07)) ? 0xfe : 0xff; |
| 32 | 28 | } |
| 33 | 29 | } |
| 34 | 30 | |
| r20819 | r20820 | |
| 36 | 32 | { |
| 37 | 33 | double val = (((data >>6) & 1 ) + ((data >> 2) & 1) - 1) * 32000; |
| 38 | 34 | m_latch_value = data; |
| 39 | | machine().device<cassette_image_device>(CASSETTE_TAG)->output(val); |
| 35 | m_cassette->output(val); |
| 40 | 36 | } |
| 41 | 37 | |
| 42 | 38 | |
| r20819 | r20820 | |
| 155 | 151 | |
| 156 | 152 | DRIVER_INIT_MEMBER(galaxy_state,galaxy) |
| 157 | 153 | { |
| 158 | | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 159 | | space.install_readwrite_bank( 0x2800, 0x2800 + machine().device<ram_device>(RAM_TAG)->size() - 1, "bank1"); |
| 160 | | membank("bank1")->set_base(machine().device<ram_device>(RAM_TAG)->pointer()); |
| 154 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" }; |
| 161 | 155 | |
| 156 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 157 | space.install_readwrite_bank( 0x2800, 0x2800 + m_ram->size() - 1, "bank1"); |
| 158 | membank("bank1")->set_base(m_ram->pointer()); |
| 159 | |
| 162 | 160 | if (machine().device<ram_device>(RAM_TAG)->size() < (6 + 48) * 1024) |
| 163 | 161 | { |
| 164 | 162 | space.nop_readwrite( 0x2800 + machine().device<ram_device>(RAM_TAG)->size(), 0xffff); |
| 165 | 163 | } |
| 164 | |
| 165 | for ( int i = 0; i < 8; i++ ) |
| 166 | { |
| 167 | m_io_ports[i] = ioport( keynames[i] ); |
| 168 | } |
| 166 | 169 | } |
| 167 | 170 | |
| 168 | 171 | /*************************************************************************** |
| r20819 | r20820 | |
| 171 | 174 | |
| 172 | 175 | MACHINE_RESET_MEMBER(galaxy_state,galaxy) |
| 173 | 176 | { |
| 174 | | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 177 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 175 | 178 | |
| 176 | 179 | /* ROM 2 enable/disable */ |
| 177 | | if (machine().root_device().ioport("ROM2")->read()) { |
| 180 | if (ioport("ROM2")->read()) { |
| 178 | 181 | space.install_read_bank(0x1000, 0x1fff, "bank10"); |
| 179 | 182 | } else { |
| 180 | 183 | space.nop_read(0x1000, 0x1fff); |
| 181 | 184 | } |
| 182 | 185 | space.nop_write(0x1000, 0x1fff); |
| 183 | 186 | |
| 184 | | if (machine().root_device().ioport("ROM2")->read()) |
| 185 | | membank("bank10")->set_base(machine().root_device().memregion("maincpu")->base() + 0x1000); |
| 187 | if (ioport("ROM2")->read()) |
| 188 | membank("bank10")->set_base(memregion("maincpu")->base() + 0x1000); |
| 186 | 189 | |
| 187 | | machine().device("maincpu")->execute().set_irq_acknowledge_callback(galaxy_irq_callback); |
| 190 | m_maincpu->set_irq_acknowledge_callback(galaxy_irq_callback); |
| 188 | 191 | m_interrupts_enabled = TRUE; |
| 189 | 192 | } |
| 190 | 193 | |
| r20819 | r20820 | |
| 195 | 198 | |
| 196 | 199 | MACHINE_RESET_MEMBER(galaxy_state,galaxyp) |
| 197 | 200 | { |
| 198 | | UINT8 *ROM = machine().root_device().memregion("maincpu")->base(); |
| 199 | | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 201 | UINT8 *ROM = memregion("maincpu")->base(); |
| 202 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 200 | 203 | |
| 201 | | machine().device("maincpu")->execute().set_irq_acknowledge_callback(galaxy_irq_callback); |
| 204 | m_maincpu->set_irq_acknowledge_callback(galaxy_irq_callback); |
| 202 | 205 | |
| 203 | 206 | ROM[0x0037] = 0x29; |
| 204 | 207 | ROM[0x03f9] = 0xcd; |
trunk/src/mess/includes/galaxy.h
| r20819 | r20820 | |
| 8 | 8 | #define GALAXY_H_ |
| 9 | 9 | |
| 10 | 10 | #include "imagedev/snapquik.h" |
| 11 | #include "imagedev/cassette.h" |
| 12 | #include "machine/ram.h" |
| 11 | 13 | |
| 12 | 14 | |
| 13 | 15 | class galaxy_state : public driver_device |
| 14 | 16 | { |
| 15 | 17 | public: |
| 16 | 18 | galaxy_state(const machine_config &mconfig, device_type type, const char *tag) |
| 17 | | : driver_device(mconfig, type, tag) { } |
| 19 | : driver_device(mconfig, type, tag) |
| 20 | , m_maincpu(*this, "maincpu") |
| 21 | , m_cassette(*this, CASSETTE_TAG) |
| 22 | , m_ram(*this, RAM_TAG) |
| 23 | { } |
| 18 | 24 | |
| 19 | 25 | int m_interrupts_enabled; |
| 20 | 26 | UINT8 m_latch_value; |
| r20819 | r20820 | |
| 34 | 40 | UINT32 screen_update_galaxy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 35 | 41 | INTERRUPT_GEN_MEMBER(galaxy_interrupt); |
| 36 | 42 | TIMER_CALLBACK_MEMBER(gal_video); |
| 43 | |
| 44 | protected: |
| 45 | required_device<cpu_device> m_maincpu; |
| 46 | required_device<cassette_image_device> m_cassette; |
| 47 | required_device<ram_device> m_ram; |
| 48 | ioport_port *m_io_ports[8]; |
| 37 | 49 | }; |
| 38 | 50 | |
| 39 | 51 | |
trunk/src/mess/video/galaxy.c
| r20819 | r20820 | |
| 15 | 15 | |
| 16 | 16 | TIMER_CALLBACK_MEMBER(galaxy_state::gal_video) |
| 17 | 17 | { |
| 18 | | address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 18 | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 19 | 19 | int y, x; |
| 20 | 20 | if (m_interrupts_enabled == TRUE) |
| 21 | 21 | { |
| r20819 | r20820 | |
| 24 | 24 | if ((m_gal_cnt >= 48 * 2) && (m_gal_cnt < 48 * 210)) // display on screen just m_first 208 lines |
| 25 | 25 | { |
| 26 | 26 | UINT8 mode = (m_latch_value >> 1) & 1; // bit 2 latch represents mode |
| 27 | | UINT16 addr = (machine().device("maincpu")->state().state_int(Z80_I) << 8) | machine().device("maincpu")->state().state_int(Z80_R) | ((m_latch_value & 0x80) ^ 0x80); |
| 27 | UINT16 addr = (m_maincpu->state_int(Z80_I) << 8) | m_maincpu->state_int(Z80_R) | ((m_latch_value & 0x80) ^ 0x80); |
| 28 | 28 | if (mode == 0) |
| 29 | 29 | { |
| 30 | 30 | // Text mode |
| 31 | | if (m_first == 0 && (machine().device("maincpu")->state().state_int(Z80_R) & 0x1f) == 0) |
| 31 | if (m_first == 0 && (m_maincpu->state_int(Z80_R) & 0x1f) == 0) |
| 32 | 32 | { |
| 33 | 33 | // Due to a fact that on real processor latch value is set at |
| 34 | 34 | // the end of last cycle we need to skip dusplay of double |
| r20819 | r20820 | |
| 57 | 57 | } |
| 58 | 58 | else |
| 59 | 59 | { // Graphics mode |
| 60 | | if (m_first < 4 && (machine().device("maincpu")->state().state_int(Z80_R) & 0x1f) == 0) |
| 60 | if (m_first < 4 && (m_maincpu->state_int(Z80_R) & 0x1f) == 0) |
| 61 | 61 | { |
| 62 | 62 | // Due to a fact that on real processor latch value is set at |
| 63 | 63 | // the end of last cycle we need to skip dusplay of 4 times |