Previous 199869 Revisions Next

r20820 Thursday 7th February, 2013 at 22:14:18 UTC by Wilbert Pol
(MESS) galaxy.c: Reduce tagmap lookups. (nw)
[src/mess/includes]galaxy.h
[src/mess/machine]galaxy.c
[src/mess/video]galaxy.c

trunk/src/mess/machine/galaxy.c
r20819r20820
1010#include "emu.h"
1111#include "cpu/z80/z80.h"
1212#include "includes/galaxy.h"
13#include "imagedev/cassette.h"
14#include "machine/ram.h"
1513
1614/***************************************************************************
1715  I/O devices
r20819r20820
1917
2018READ8_MEMBER(galaxy_state::galaxy_keyboard_r)
2119{
22   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
23
2420   if (offset == 0)
2521   {
26      double level = (machine().device<cassette_image_device>(CASSETTE_TAG)->input());
22      double level = m_cassette->input();
2723      return (level >  0) ? 0xfe : 0xff;
2824   }
2925   else
3026   {
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;
3228   }
3329}
3430
r20819r20820
3632{
3733   double val = (((data >>6) & 1 ) + ((data >> 2) & 1) - 1) * 32000;
3834   m_latch_value = data;
39   machine().device<cassette_image_device>(CASSETTE_TAG)->output(val);
35   m_cassette->output(val);
4036}
4137
4238
r20819r20820
155151
156152DRIVER_INIT_MEMBER(galaxy_state,galaxy)
157153{
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" };
161155
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
162160   if (machine().device<ram_device>(RAM_TAG)->size() < (6 + 48) * 1024)
163161   {
164162      space.nop_readwrite( 0x2800 + machine().device<ram_device>(RAM_TAG)->size(), 0xffff);
165163   }
164
165   for ( int i = 0; i < 8; i++ )
166   {
167      m_io_ports[i] = ioport( keynames[i] );
168   }
166169}
167170
168171/***************************************************************************
r20819r20820
171174
172175MACHINE_RESET_MEMBER(galaxy_state,galaxy)
173176{
174   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
177   address_space &space = m_maincpu->space(AS_PROGRAM);
175178
176179   /* ROM 2 enable/disable */
177   if (machine().root_device().ioport("ROM2")->read()) {
180   if (ioport("ROM2")->read()) {
178181      space.install_read_bank(0x1000, 0x1fff, "bank10");
179182   } else {
180183      space.nop_read(0x1000, 0x1fff);
181184   }
182185   space.nop_write(0x1000, 0x1fff);
183186
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);
186189
187   machine().device("maincpu")->execute().set_irq_acknowledge_callback(galaxy_irq_callback);
190   m_maincpu->set_irq_acknowledge_callback(galaxy_irq_callback);
188191   m_interrupts_enabled = TRUE;
189192}
190193
r20819r20820
195198
196199MACHINE_RESET_MEMBER(galaxy_state,galaxyp)
197200{
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);
200203
201   machine().device("maincpu")->execute().set_irq_acknowledge_callback(galaxy_irq_callback);
204   m_maincpu->set_irq_acknowledge_callback(galaxy_irq_callback);
202205
203206   ROM[0x0037] = 0x29;
204207   ROM[0x03f9] = 0xcd;
trunk/src/mess/includes/galaxy.h
r20819r20820
88#define GALAXY_H_
99
1010#include "imagedev/snapquik.h"
11#include "imagedev/cassette.h"
12#include "machine/ram.h"
1113
1214
1315class galaxy_state : public driver_device
1416{
1517public:
1618   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   { }
1824
1925   int m_interrupts_enabled;
2026   UINT8 m_latch_value;
r20819r20820
3440   UINT32 screen_update_galaxy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3541   INTERRUPT_GEN_MEMBER(galaxy_interrupt);
3642   TIMER_CALLBACK_MEMBER(gal_video);
43
44protected:
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];
3749};
3850
3951
trunk/src/mess/video/galaxy.c
r20819r20820
1515
1616TIMER_CALLBACK_MEMBER(galaxy_state::gal_video)
1717{
18   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
18   address_space &space = m_maincpu->space(AS_PROGRAM);
1919   int y, x;
2020   if (m_interrupts_enabled == TRUE)
2121   {
r20819r20820
2424      if ((m_gal_cnt >= 48 * 2) && (m_gal_cnt < 48 * 210))  // display on screen just m_first 208 lines
2525      {
2626         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);
2828         if (mode == 0)
2929         {
3030            // 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)
3232            {
3333               // Due to a fact that on real processor latch value is set at
3434               // the end of last cycle we need to skip dusplay of double
r20819r20820
5757         }
5858         else
5959         { // 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)
6161            {
6262               // Due to a fact that on real processor latch value is set at
6363               // the end of last cycle we need to skip dusplay of 4 times

Previous 199869 Revisions Next


© 1997-2024 The MAME Team