Previous 199869 Revisions Next

r20493 Saturday 26th January, 2013 at 15:44:48 UTC by Wilbert Pol
(MESS) zx.c: tagmap cleanups
[src/mess/includes]zx.h
[src/mess/machine]zx.c
[src/mess/video]zx.c

trunk/src/mess/machine/zx.c
r20492r20493
2020
2121WRITE8_MEMBER(zx_state::zx_ram_w)
2222{
23   UINT8 *RAM = memregion("maincpu")->base();
23   UINT8 *RAM = m_region_maincpu->base();
2424   RAM[offset + 0x4000] = data;
2525
2626   if (data & 0x40)
r20492r20493
3838/* I know this looks really pointless... but it has to be here */
3939READ8_MEMBER( zx_state::zx_ram_r )
4040{
41   UINT8 *RAM = memregion("maincpu")->base();
41   UINT8 *RAM = m_region_maincpu->base();
4242   return RAM[offset | 0xc000];
4343}
4444
4545DRIVER_INIT_MEMBER(zx_state,zx)
4646{
47   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
47   address_space &space = m_maincpu->space(AS_PROGRAM);
4848
49   space.install_read_bank(0x4000, 0x4000 + machine().device<ram_device>(RAM_TAG)->size() - 1, "bank1");
50   space.install_write_handler(0x4000, 0x4000 + machine().device<ram_device>(RAM_TAG)->size() - 1, write8_delegate(FUNC(zx_state::zx_ram_w),this));
51   membank("bank1")->set_base(memregion("maincpu")->base() + 0x4000);
49   space.install_read_bank(0x4000, 0x4000 + m_ram->size() - 1, "bank1");
50   space.install_write_handler(0x4000, 0x4000 + m_ram->size() - 1, write8_delegate(FUNC(zx_state::zx_ram_w),this));
51   membank("bank1")->set_base(m_region_maincpu->base() + 0x4000);
5252}
5353
5454DIRECT_UPDATE_MEMBER(zx_state::zx_setdirect)
5555{
5656   if (address & 0xc000)
57      zx_ula_r(machine(), address, "maincpu", 0);
57      zx_ula_r(address, m_region_maincpu, 0);
5858   return address;
5959}
6060
6161DIRECT_UPDATE_MEMBER(zx_state::pc8300_setdirect)
6262{
6363   if (address & 0xc000)
64      zx_ula_r(machine(), address, "gfx1", 0);
64      zx_ula_r(address, m_region_gfx1, 0);
6565   return address;
6666}
6767
6868DIRECT_UPDATE_MEMBER(zx_state::pow3000_setdirect)
6969{
7070   if (address & 0xc000)
71      zx_ula_r(machine(), address, "gfx1", 1);
71      zx_ula_r(address, m_region_gfx1, 1);
7272   return address;
7373}
7474
7575void zx_state::machine_reset()
7676{
77   machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::zx_setdirect), this));
77   m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::zx_setdirect), this));
7878   m_tape_bit = 0x80;
7979}
8080
8181MACHINE_RESET_MEMBER(zx_state,pow3000)
8282{
83   machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::pow3000_setdirect), this));
83   m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::pow3000_setdirect), this));
8484   m_tape_bit = 0x80;
8585}
8686
8787MACHINE_RESET_MEMBER(zx_state,pc8300)
8888{
89   machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::pc8300_setdirect), this));
89   m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(zx_state::pc8300_setdirect), this));
9090   m_tape_bit = 0x80;
9191}
9292
r20492r20493
106106   if (offs == 0xfe)
107107   {
108108      if ((offset & 0x0100) == 0)
109         data &= ioport("ROW0")->read();
109         data &= m_io_row0->read();
110110      if ((offset & 0x0200) == 0)
111         data &= ioport("ROW1")->read();
111         data &= m_io_row1->read();
112112      if ((offset & 0x0400) == 0)
113         data &= ioport("ROW2")->read();
113         data &= m_io_row2->read();
114114      if ((offset & 0x0800) == 0)
115         data &= ioport("ROW3")->read();
115         data &= m_io_row3->read();
116116      if ((offset & 0x1000) == 0)
117         data &= ioport("ROW4")->read();
117         data &= m_io_row4->read();
118118      if ((offset & 0x2000) == 0)
119         data &= ioport("ROW5")->read();
119         data &= m_io_row5->read();
120120      if ((offset & 0x4000) == 0)
121         data &= ioport("ROW6")->read();
121         data &= m_io_row6->read();
122122      if ((offset & 0x8000) == 0)
123         data &= ioport("ROW7")->read();
123         data &= m_io_row7->read();
124124
125      if (!ioport("CONFIG")->read())
125      if (!m_io_config->read())
126126         data &= ~0x40;
127127
128      machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0);
128      m_cassette->output(+1.0);
129129
130130      if (m_ula_irq_active)
131131      {
r20492r20493
134134      }
135135//      else
136136//      {
137         if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
137         if ((m_cassette->input() < -0.75) && m_tape_bit)
138138         {
139139            m_tape_bit = 0x00;
140140            machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
r20492r20493
163163   if (offs == 0xfe)
164164   {
165165      if ((offset & 0x0100) == 0)
166         data &= ioport("ROW0")->read();
166         data &= m_io_row0->read();
167167      if ((offset & 0x0200) == 0)
168         data &= ioport("ROW1")->read();
168         data &= m_io_row1->read();
169169      if ((offset & 0x0400) == 0)
170         data &= ioport("ROW2")->read();
170         data &= m_io_row2->read();
171171      if ((offset & 0x0800) == 0)
172         data &= ioport("ROW3")->read();
172         data &= m_io_row3->read();
173173      if ((offset & 0x1000) == 0)
174         data &= ioport("ROW4")->read();
174         data &= m_io_row4->read();
175175      if ((offset & 0x2000) == 0)
176         data &= ioport("ROW5")->read();
176         data &= m_io_row5->read();
177177      if ((offset & 0x4000) == 0)
178         data &= ioport("ROW6")->read();
178         data &= m_io_row6->read();
179179      if ((offset & 0x8000) == 0)
180         data &= ioport("ROW7")->read();
180         data &= m_io_row7->read();
181181
182      if (!ioport("CONFIG")->read())
182      if (!m_io_config->read())
183183         data &= ~0x40;
184184
185      machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0);
185      m_cassette->output(+1.0);
186186
187187      if (m_ula_irq_active)
188188      {
r20492r20493
191191      }
192192      else
193193      {
194         if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
194         if ((m_cassette->input() < -0.75) && m_tape_bit)
195195         {
196196            m_tape_bit = 0x00;
197197            machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
r20492r20493
219219
220220   UINT8 data = 0xff;
221221   UINT8 offs = offset & 0xff;
222   device_t *speaker = machine().device(SPEAKER_TAG);
223222
224223   if (offs == 0xf5)
225224   {
226225      m_speaker_state ^= 1;
227      speaker_level_w(speaker, m_speaker_state);
226      speaker_level_w(m_speaker, m_speaker_state);
228227   }
229228   else
230229   if (offs == 0xfe)
231230   {
232231      if ((offset & 0x0100) == 0)
233         data &= ioport("ROW0")->read();
232         data &= m_io_row0->read();
234233      if ((offset & 0x0200) == 0)
235         data &= ioport("ROW1")->read();
234         data &= m_io_row1->read();
236235      if ((offset & 0x0400) == 0)
237         data &= ioport("ROW2")->read();
236         data &= m_io_row2->read();
238237      if ((offset & 0x0800) == 0)
239         data &= ioport("ROW3")->read();
238         data &= m_io_row3->read();
240239      if ((offset & 0x1000) == 0)
241         data &= ioport("ROW4")->read();
240         data &= m_io_row4->read();
242241      if ((offset & 0x2000) == 0)
243         data &= ioport("ROW5")->read();
242         data &= m_io_row5->read();
244243      if ((offset & 0x4000) == 0)
245         data &= ioport("ROW6")->read();
244         data &= m_io_row6->read();
246245      if ((offset & 0x8000) == 0)
247         data &= ioport("ROW7")->read();
246         data &= m_io_row7->read();
248247
249      machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0);
248      m_cassette->output(+1.0);
250249
251250      if (m_ula_irq_active)
252251      {
r20492r20493
255254      }
256255      else
257256      {
258         if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
257         if ((m_cassette->input() < -0.75) && m_tape_bit)
259258         {
260259            m_tape_bit = 0x00;
261260            machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
r20492r20493
283282
284283   UINT8 data = 0xff;
285284   UINT8 offs = offset & 0xff;
286   device_t *speaker = machine().device(SPEAKER_TAG);
287285
288286   if (offs == 0x7e)
289287   {
290      data = (ioport("CONFIG")->read());
288      data = (m_io_config->read());
291289   }
292290   else
293291   if (offs == 0xf5)
294292   {
295293      m_speaker_state ^= 1;
296      speaker_level_w(speaker, m_speaker_state);
294      speaker_level_w(m_speaker, m_speaker_state);
297295   }
298296   else
299297   if (offs == 0xfe)
300298   {
301299      if ((offset & 0x0100) == 0)
302         data &= ioport("ROW0")->read();
300         data &= m_io_row0->read();
303301      if ((offset & 0x0200) == 0)
304         data &= ioport("ROW1")->read();
302         data &= m_io_row1->read();
305303      if ((offset & 0x0400) == 0)
306         data &= ioport("ROW2")->read();
304         data &= m_io_row2->read();
307305      if ((offset & 0x0800) == 0)
308         data &= ioport("ROW3")->read();
306         data &= m_io_row3->read();
309307      if ((offset & 0x1000) == 0)
310         data &= ioport("ROW4")->read();
308         data &= m_io_row4->read();
311309      if ((offset & 0x2000) == 0)
312         data &= ioport("ROW5")->read();
310         data &= m_io_row5->read();
313311      if ((offset & 0x4000) == 0)
314         data &= ioport("ROW6")->read();
312         data &= m_io_row6->read();
315313      if ((offset & 0x8000) == 0)
316         data &= ioport("ROW7")->read();
314         data &= m_io_row7->read();
317315
318      machine().device<cassette_image_device>(CASSETTE_TAG)->output(+1.0);
316      m_cassette->output(+1.0);
319317
320318      if (m_ula_irq_active)
321319      {
r20492r20493
324322      }
325323      else
326324      {
327         if (((machine().device<cassette_image_device>(CASSETTE_TAG))->input() < -0.75) && m_tape_bit)
325         if ((m_cassette->input() < -0.75) && m_tape_bit)
328326         {
329327            m_tape_bit = 0x00;
330328            machine().scheduler().timer_set(attotime::from_usec(362), timer_expired_delegate(FUNC(zx_state::zx_tape_pulse),this));
r20492r20493
348346   UINT8 offs = offset & 0xff;
349347
350348   if (offs == 0xff)
351      machine().device<cassette_image_device>(CASSETTE_TAG)->output(-1.0);
349      m_cassette->output(-1.0);
352350}
353351
354352WRITE8_MEMBER( zx_state::zx81_io_w )
355353{
356   address_space &mem = machine().device("maincpu")->memory().space(AS_PROGRAM);
357354/* port F5 = unknown, pc8300/pow3000/lambda only
358355    F6 = unknown, pc8300/pow3000/lambda only
359356    FB = write data to printer, not emulated
r20492r20493
361358    FE = turn on NMI generator
362359    FF = write HSYNC and cass data */
363360
364   screen_device *screen = machine().first_screen();
365   int height = screen->height();
361   int height = m_screen->height();
366362   UINT8 offs = offset & 0xff;
367363
368364   if (offs == 0xfd)
r20492r20493
372368   else
373369   if (offs == 0xfe)
374370   {
375      m_ula_nmi->adjust(attotime::zero, 0, machine().device<cpu_device>("maincpu")->cycles_to_attotime(207));
371      m_ula_nmi->adjust(attotime::zero, 0, m_maincpu->cycles_to_attotime(207));
376372
377373      /* remove the IRQ */
378374      m_ula_irq_active = 0;
r20492r20493
380376   else
381377   if (offs == 0xff)
382378   {
383      machine().device<cassette_image_device>(CASSETTE_TAG)->output(-1.0);
379      m_cassette->output(-1.0);
384380      zx_ula_bkgnd(1);
385381      if (m_ula_frame_vsync == 2)
386382      {
387         mem.device().execute().spin_until_time(machine().primary_screen->time_until_pos(height - 1, 0));
383         m_maincpu->spin_until_time(m_screen->time_until_pos(height - 1, 0));
388384         m_ula_scanline_count = height - 1;
389         logerror ("S: %d B: %d\n", machine().primary_screen->vpos(), machine().primary_screen->hpos());
385         logerror ("S: %d B: %d\n", m_screen->vpos(), m_screen->hpos());
390386      }
391387   }
392388}
trunk/src/mess/includes/zx.h
r20492r20493
2020{
2121public:
2222   zx_state(const machine_config &mconfig, device_type type, const char *tag)
23      : driver_device(mconfig, type, tag) { }
23      : driver_device(mconfig, type, tag)
24      , m_maincpu(*this, "maincpu")
25      , m_ram(*this, RAM_TAG)
26      , m_screen(*this, "screen")
27      , m_cassette(*this, CASSETTE_TAG)
28      , m_speaker(*this, SPEAKER_TAG)
29      , m_region_maincpu(*this, "maincpu")
30      , m_region_gfx1(*this, "gfx1")
31      , m_io_row0(*this, "ROW0")
32      , m_io_row1(*this, "ROW1")
33      , m_io_row2(*this, "ROW2")
34      , m_io_row3(*this, "ROW3")
35      , m_io_row4(*this, "ROW4")
36      , m_io_row5(*this, "ROW5")
37      , m_io_row6(*this, "ROW6")
38      , m_io_row7(*this, "ROW7")
39      , m_io_config(*this, "CONFIG")
40   { }
2441
2542   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
2643
r20492r20493
6178   TIMER_CALLBACK_MEMBER(zx_tape_pulse);
6279   TIMER_CALLBACK_MEMBER(zx_ula_nmi);
6380   TIMER_CALLBACK_MEMBER(zx_ula_irq);
81
82protected:
83   required_device<cpu_device> m_maincpu;
84   required_device<ram_device> m_ram;
85   required_device<screen_device> m_screen;
86   required_device<cassette_image_device> m_cassette;
87   required_device<device_t> m_speaker;
88   required_memory_region m_region_maincpu;
89   optional_memory_region m_region_gfx1;
90   required_ioport m_io_row0;
91   required_ioport m_io_row1;
92   required_ioport m_io_row2;
93   required_ioport m_io_row3;
94   required_ioport m_io_row4;
95   required_ioport m_io_row5;
96   required_ioport m_io_row6;
97   required_ioport m_io_row7;
98   optional_ioport m_io_config;
99
100   void zx_ula_r(int offs, memory_region *region, const UINT8 param);
64101};
65/*----------- defined in video/zx.c -----------*/
66102
67void zx_ula_bkgnd(running_machine &machine, int color);
68void zx_ula_r(running_machine &machine, int offs, const char *region, const UINT8 param);
69
70103#endif /* ZX_H_ */
trunk/src/mess/video/zx.c
r20492r20493
120120   }
121121}
122122
123void zx_ula_r(running_machine &machine, int offs, const char *region, const UINT8 param)
123void zx_state::zx_ula_r(int offs, memory_region *region, const UINT8 param)
124124{
125   zx_state *state = machine.driver_data<zx_state>();
126   screen_device *screen = machine.first_screen();
127125   int offs0 = offs & 0x7fff;
128   UINT8 *rom = machine.root_device().memregion("maincpu")->base();
126   UINT8 *rom = m_region_maincpu->base();
129127   UINT8 chr = rom[offs0];
130128
131   if ((!state->m_ula_irq_active) && (chr == 0x76))
129   if ((!m_ula_irq_active) && (chr == 0x76))
132130   {
133      bitmap_ind16 &bitmap = state->m_bitmap;
131      bitmap_ind16 &bitmap = m_bitmap;
134132      UINT16 y, *scanline;
135      UINT16 ireg = machine.device("maincpu")->state().state_int(Z80_I) << 8;
133      UINT16 ireg = m_maincpu->state_int(Z80_I) << 8;
136134      UINT8 data, *chrgen, creg;
137135
138136      if (param)
139         creg = machine.device("maincpu")->state().state_int(Z80_B);
137         creg = m_maincpu->state_int(Z80_B);
140138      else
141         creg = machine.device("maincpu")->state().state_int(Z80_C);
139         creg = m_maincpu->state_int(Z80_C);
142140
143      chrgen = state->memregion(region)->base();
141      chrgen = region->base();
144142
145      if ((++state->m_ula_scanline_count == screen->height()) || (creg == 32))
143      if ((++m_ula_scanline_count == m_screen->height()) || (creg == 32))
146144      {
147         state->m_ula_scanline_count = 0;
148         state->m_offs1 = offs0;
145         m_ula_scanline_count = 0;
146         m_offs1 = offs0;
149147      }
150148
151      state->m_ula_frame_vsync = 3;
149      m_ula_frame_vsync = 3;
152150
153      state->m_charline_ptr = 0;
151      m_charline_ptr = 0;
154152
155      for (y = state->m_offs1+1; ((y < offs0) && (state->m_charline_ptr < ARRAY_LENGTH(state->m_charline))); y++)
153      for (y = m_offs1+1; ((y < offs0) && (m_charline_ptr < ARRAY_LENGTH(m_charline))); y++)
156154      {
157         state->m_charline[state->m_charline_ptr] = rom[y];
158         state->m_charline_ptr++;
155         m_charline[m_charline_ptr] = rom[y];
156         m_charline_ptr++;
159157      }
160      for (y = state->m_charline_ptr; y < ARRAY_LENGTH(state->m_charline); y++)
161         state->m_charline[y] = 0;
158      for (y = m_charline_ptr; y < ARRAY_LENGTH(m_charline); y++)
159         m_charline[y] = 0;
162160
163      machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(((32 - state->m_charline_ptr) << 2)), timer_expired_delegate(FUNC(zx_state::zx_ula_irq),state));
164      state->m_ula_irq_active++;
161      machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(((32 - m_charline_ptr) << 2)), timer_expired_delegate(FUNC(zx_state::zx_ula_irq),this));
162      m_ula_irq_active++;
165163
166      scanline = &bitmap.pix16(state->m_ula_scanline_count);
164      scanline = &bitmap.pix16(m_ula_scanline_count);
167165      y = 0;
168166
169      for (state->m_charline_ptr = 0; state->m_charline_ptr < ARRAY_LENGTH(state->m_charline); state->m_charline_ptr++)
167      for (m_charline_ptr = 0; m_charline_ptr < ARRAY_LENGTH(m_charline); m_charline_ptr++)
170168      {
171         chr = state->m_charline[state->m_charline_ptr];
169         chr = m_charline[m_charline_ptr];
172170         data = chrgen[ireg | ((chr & 0x3f) << 3) | ((8 - creg)&7) ];
173171         if (chr & 0x80) data ^= 0xff;
174172
r20492r20493
180178         scanline[y++] = (data >> 2) & 1;
181179         scanline[y++] = (data >> 1) & 1;
182180         scanline[y++] = (data >> 0) & 1;
183         state->m_charline[state->m_charline_ptr] = 0;
181         m_charline[m_charline_ptr] = 0;
184182      }
185183
186      if (creg == 1) state->m_offs1 = offs0;
184      if (creg == 1) m_offs1 = offs0;
187185   }
188186}
189187
r20492r20493
191189{
192190   m_ula_nmi = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(zx_state::zx_ula_nmi),this));
193191   m_ula_irq_active = 0;
194   machine().primary_screen->register_screen_bitmap(m_bitmap);
192   m_screen->register_screen_bitmap(m_bitmap);
195193}
196194
197195void zx_state::screen_eof_zx(screen_device &screen, bool state)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team