Previous 199869 Revisions Next

r20473 Friday 25th January, 2013 at 21:16:16 UTC by Wilbert Pol
(MESS) oric.c: Some cleanups (nw)
[src/mess/includes]oric.h
[src/mess/machine]oric.c
[src/mess/video]oric.c

trunk/src/mess/machine/oric.c
r20472r20473
4949};
5050
5151/* called when ints are changed - cleared/set */
52static void oric_refresh_ints(running_machine &machine)
52void oric_state::oric_refresh_ints()
5353{
54   oric_state *state = machine.driver_data<oric_state>();
5554   /* telestrat has floppy hardware built-in! */
56   if (state->m_is_telestrat==0)
55   if (m_is_telestrat==0)
5756   {
5857      /* oric 1 or oric atmos */
5958
6059      /* if floppy disc hardware is disabled, do not allow interrupts from it */
61      if ((machine.root_device().ioport("FLOPPY")->read() & 0x07) == ORIC_FLOPPY_INTERFACE_NONE)
62         state->m_irqs &=~(1<<1);
60      if ((m_io_floppy->read() & 0x07) == ORIC_FLOPPY_INTERFACE_NONE)
61      {
62         m_irqs &=~(1<<1);
63      }
6364   }
6465
6566   /* any irq set? */
66   if (state->m_irqs & 0x0f)
67      machine.device("maincpu")->execute().set_input_line(0, HOLD_LINE);
67   if (m_irqs & 0x0f)
68   {
69      m_maincpu->set_input_line(0, HOLD_LINE);
70   }
6871   else
69      machine.device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
72   {
73      m_maincpu->set_input_line(0, CLEAR_LINE);
74   }
7075}
7176
7277
r20472r20473
8085
8186
8287/* refresh keyboard sense */
83static void oric_keyboard_sense_refresh(running_machine &machine)
88void oric_state::oric_keyboard_sense_refresh()
8489{
85   oric_state *state = machine.driver_data<oric_state>();
8690   /* The following assumes that if a 0 is written, it can be used to detect if any key has been pressed.. */
8791   /* for each bit that is 0, it combines it's pressed state with the pressed state so far */
8892
r20472r20473
9094   unsigned char key_bit = 0;
9195
9296   /* what if data is 0, can it sense if any of the keys on a line are pressed? */
93   int input_port_data;
94   static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7" };
97   int input_port_data = 0;
9598
96   input_port_data = machine.root_device().ioport(keynames[state->m_keyboard_line])->read();
99   switch ( m_keyboard_line )
100   {
101      case 0: input_port_data = m_io_row0->read(); break;
102      case 1: input_port_data = m_io_row1->read(); break;
103      case 2: input_port_data = m_io_row2->read(); break;
104      case 3: input_port_data = m_io_row3->read(); break;
105      case 4: input_port_data = m_io_row4->read(); break;
106      case 5: input_port_data = m_io_row5->read(); break;
107      case 6: input_port_data = m_io_row6->read(); break;
108      case 7: input_port_data = m_io_row7->read(); break;
109   }
97110
98111   /* go through all bits in line */
99112   for (i=0; i<8; i++)
100113   {
101114      /* sense this bit? */
102      if (((~state->m_keyboard_mask) & (1<<i)) != 0)
115      if (((~m_keyboard_mask) & (1<<i)) != 0)
103116      {
104117         /* is key pressed? */
105118         if (input_port_data & (1<<i))
r20472r20473
111124   }
112125
113126   /* clear sense result */
114   state->m_key_sense_bit = 0;
127   m_key_sense_bit = 0;
115128
116129   /* any keys pressed on this line? */
117130   if (key_bit!=0)
118131   {
119132      /* set sense result */
120      state->m_key_sense_bit = (1<<3);
133      m_key_sense_bit = (1<<3);
121134   }
122135}
123136
r20472r20473
143156   {
144157      /* if psg is in read register state return reg data */
145158      if (m_psg_control==0x01)
146         return ay8910_r(machine().device("ay8912"), space, 0);
159      {
160         return ay8910_r(m_ay8912, space, 0);
161      }
147162
148163      /* return high-impedance */
149164      return 0x0ff;
r20472r20473
157172{
158173   int data;
159174
160   oric_keyboard_sense_refresh(machine());
175   oric_keyboard_sense_refresh();
161176
162177   data = m_key_sense_bit;
163178   data |= m_keyboard_line & 0x07;
r20472r20473
167182
168183
169184/* read/write data depending on state of bdir, bc1 pins and data output to psg */
170static void oric_psg_connection_refresh(address_space &space)
185void oric_state::oric_psg_connection_refresh(address_space &space)
171186{
172   oric_state *state = space.machine().driver_data<oric_state>();
173   if (state->m_psg_control!=0)
187   if (m_psg_control!=0)
174188   {
175      switch (state->m_psg_control)
189      switch (m_psg_control)
176190      {
177191         /* PSG inactive */
178192         case 0:
179         break;
193            break;
194
180195         /* read register data */
181196         case 1:
182         {
183            //state->m_via_port_a_data = ay8910_read_port_0_r(space, 0);
184         }
185         break;
197            //m_via_port_a_data = ay8910_read_port_0_r(space, 0);
198            break;
199
186200         /* write register data */
187201         case 2:
188         {
189            device_t *ay8912 = space.machine().device("ay8912");
190            ay8910_data_w(ay8912, space, 0, state->m_via_port_a_data);
191         }
192         break;
202            ay8910_data_w(m_ay8912, space, 0, m_via_port_a_data);
203            break;
204
193205         /* write register index */
194206         case 3:
195         {
196            device_t *ay8912 = space.machine().device("ay8912");
197            ay8910_address_w(ay8912, space, 0, state->m_via_port_a_data);
198         }
199         break;
207            ay8910_address_w(m_ay8912, space, 0, m_via_port_a_data);
208            break;
200209
201210         default:
202211            break;
r20472r20473
212221
213222   oric_psg_connection_refresh(space);
214223
215
216224   if (m_psg_control==0)
217225   {
218226      /* if psg not selected, write to printer */
219      centronics_device *centronics = machine().device<centronics_device>("centronics");
220      centronics->write(machine().driver_data()->generic_space(), 0, data);
227      m_centronics->write(space, 0, data);
221228   }
222229}
223230
r20472r20473
243250 */
244251
245252
246static cassette_image_device *cassette_device_image(running_machine &machine)
247{
248   return machine.device<cassette_image_device>(CASSETTE_TAG);
249}
250
251253/* not called yet - this will update the via with the state of the tape data.
252254This allows the via to trigger on bit changes and issue interrupts */
253255TIMER_CALLBACK_MEMBER(oric_state::oric_refresh_tape)
254256{
255257   int data;
256258   int input_port_9;
257   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
258259
259260   data = 0;
260261
261   if ((cassette_device_image(machine()))->input() > 0.0038)
262   if (m_cassette->input() > 0.0038)
263   {
262264      data |= 1;
265   }
263266
264267   /* "A simple cable to catch the vertical retrace signal !
265268       This cable connects the video output for the television/monitor
266269   to the via cb1 input. Interrupts can be generated from the vertical
267270   sync, and flicker free games can be produced */
268271
269   input_port_9 = machine().root_device().ioport("FLOPPY")->read();
272   input_port_9 = m_io_floppy->read();
270273   /* cable is enabled? */
271274   if ((input_port_9 & 0x08)!=0)
272275   {
r20472r20473
274277      data = input_port_9>>4;
275278   }
276279
277   via_0->write_cb1(data);
280   m_via6522_0->write_cb1(data);
278281}
279282
280283WRITE8_MEMBER(oric_state::oric_via_out_b_func)
281284{
282   centronics_device *centronics = machine().device<centronics_device>("centronics");
283
284285   /* KEYBOARD */
285286   m_keyboard_line = data & 0x07;
286287
287288   /* CASSETTE */
288289   /* cassette motor control */
289   cassette_device_image(machine())->change_state(
290   m_cassette->change_state(
290291      (data & 0x40) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,
291292      CASSETTE_MOTOR_DISABLED);
292293
293294   /* cassette data out */
294   cassette_device_image(machine())->output((data & (1<<7)) ? -1.0 : +1.0);
295   m_cassette->output((data & (1<<7)) ? -1.0 : +1.0);
295296
296297   /* centronics STROBE is connected to PB4 */
297   centronics->strobe_w(BIT(data, 4));
298   m_centronics->strobe_w(BIT(data, 4));
298299
299300   oric_psg_connection_refresh(space);
300301   m_previous_portb_data = data;
r20472r20473
332333}
333334
334335
335static void oric_via_irq_func(device_t *device, int state)
336WRITE_LINE_MEMBER(oric_state::oric_via_irq_func)
336337{
337   oric_state *drvstate = device->machine().driver_data<oric_state>();
338   drvstate->m_irqs &= ~(1<<0);
338   m_irqs &= ~(1<<0);
339339
340340   if (state)
341      drvstate->m_irqs |=(1<<0);
341   {
342      m_irqs |=(1<<0);
343   }
342344
343   oric_refresh_ints(device->machine());
345   oric_refresh_ints();
344346}
345347
346348
r20472r20473
397399   DEVCB_NULL,
398400   DEVCB_DRIVER_MEMBER(oric_state,oric_via_out_ca2_func),
399401   DEVCB_DRIVER_MEMBER(oric_state,oric_via_out_cb2_func),
400   DEVCB_LINE(oric_via_irq_func),
402   DEVCB_DRIVER_LINE_MEMBER(oric_state,oric_via_irq_func),
401403};
402404
403405
r20472r20473
414416CALL &320 to start, or use BOBY rom.
415417*/
416418
417static void oric_install_apple2_interface(running_machine &machine)
419void oric_state::oric_install_apple2_interface()
418420{
419   oric_state *state = machine.driver_data<oric_state>();
420   applefdc_base_device *fdc = machine.device<applefdc_base_device>("fdc");
421   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
421   applefdc_base_device *fdc = machine().device<applefdc_base_device>("fdc");
422   address_space &space = m_maincpu->space(AS_PROGRAM);
422423
423   if (state->m_is_telestrat)
424   if (m_is_telestrat)
425   {
424426      return;
427   }
425428
426   space.install_read_handler(0x0300, 0x030f, read8_delegate(FUNC(oric_state::oric_IO_r), state));
429   space.install_read_handler(0x0300, 0x030f, read8_delegate(FUNC(oric_state::oric_IO_r), this));
427430   space.install_read_handler(0x0310, 0x031f, read8_delegate(FUNC(applefdc_base_device::read), fdc));
428431   space.install_read_bank(0x0320, 0x03ff, "bank4");
432   m_bank4 = membank("bank4");
429433
430   space.install_write_handler(0x0300, 0x030f, write8_delegate(FUNC(oric_state::oric_IO_w), state));
434   space.install_write_handler(0x0300, 0x030f, write8_delegate(FUNC(oric_state::oric_IO_w), this));
431435   space.install_write_handler(0x0310, 0x031f, write8_delegate(FUNC(applefdc_base_device::write), fdc));
432   state->membank("bank4")->set_base(  state->memregion("maincpu")->base() + 0x014000 + 0x020);
436   m_bank4->set_base(  m_region_maincpu->base() + 0x014000 + 0x020);
433437}
434438
435439
436static void oric_enable_memory(running_machine &machine, int low, int high, int rd, int wr)
440void oric_state::oric_enable_memory(int low, int high, int rd, int wr)
437441{
438   oric_state *state = machine.driver_data<oric_state>();
439442   int i;
440   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
443   address_space &space = m_maincpu->space(AS_PROGRAM);
441444
442   if (state->m_is_telestrat)
445   if (m_is_telestrat)
446   {
443447      return;
448   }
449
444450   for (i = low; i <= high; i++)
445451   {
446452      switch(i) {
r20472r20473
502508/*  logerror("apple 2 interface v2 rom page: %01x\n",(offset & 0x02)>>1); */
503509
504510   /* bit 0 is 0 for page 0, 1 for page 1 */
505   membank("bank4")->set_base(machine().root_device().memregion("maincpu")->base() + 0x014000 + 0x0100 + (((offset & 0x02)>>1)<<8));
511   m_bank4->set_base(m_region_maincpu->base() + 0x014000 + 0x0100 + (((offset & 0x02)>>1)<<8));
506512
507   oric_enable_memory(machine(), 1, 3, TRUE, TRUE);
513   oric_enable_memory(1, 3, TRUE, TRUE);
508514
509515   /* bit 1 is 0, rom enabled, bit 1 is 1 ram enabled */
510516   if ((offset & 0x01)==0)
r20472r20473
514520      /* logerror("apple 2 interface v2: rom enabled\n"); */
515521
516522      /* enable rom */
517      rom_ptr = memregion("maincpu")->base() + 0x010000;
518      membank("bank1")->set_base(rom_ptr);
519      membank("bank2")->set_base(rom_ptr+0x02000);
520      membank("bank3")->set_base(rom_ptr+0x03800);
521      membank("bank5")->set_base(m_ram_0x0c000);
522      membank("bank6")->set_base(m_ram_0x0c000+0x02000);
523      membank("bank7")->set_base(m_ram_0x0c000+0x03800);
523      rom_ptr = m_region_maincpu->base() + 0x010000;
524      m_bank1->set_base(rom_ptr);
525      m_bank2->set_base(rom_ptr+0x02000);
526      m_bank3->set_base(rom_ptr+0x03800);
527      m_bank5->set_base(m_ram_0x0c000);
528      m_bank6->set_base(m_ram_0x0c000+0x02000);
529      m_bank7->set_base(m_ram_0x0c000+0x03800);
524530   }
525531   else
526532   {
527533      /*logerror("apple 2 interface v2: ram enabled\n"); */
528534
529535      /* enable ram */
530      membank("bank1")->set_base(m_ram_0x0c000);
531      membank("bank2")->set_base(m_ram_0x0c000+0x02000);
532      membank("bank3")->set_base(m_ram_0x0c000+0x03800);
533      membank("bank5")->set_base(m_ram_0x0c000);
534      membank("bank6")->set_base(m_ram_0x0c000+0x02000);
535      membank("bank7")->set_base(m_ram_0x0c000+0x03800);
536      m_bank1->set_base(m_ram_0x0c000);
537      m_bank2->set_base(m_ram_0x0c000+0x02000);
538      m_bank3->set_base(m_ram_0x0c000+0x03800);
539      m_bank5->set_base(m_ram_0x0c000);
540      m_bank6->set_base(m_ram_0x0c000+0x02000);
541      m_bank7->set_base(m_ram_0x0c000+0x03800);
536542   }
537543}
538544
539545
540546/* APPLE 2 INTERFACE V2 */
541static void oric_install_apple2_v2_interface(running_machine &machine)
547void oric_state::oric_install_apple2_v2_interface()
542548{
543   oric_state *state = machine.driver_data<oric_state>();
544   applefdc_base_device *fdc = machine.device<applefdc_base_device>("fdc");
545   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
549   applefdc_base_device *fdc = machine().device<applefdc_base_device>("fdc");
550   address_space &space = m_maincpu->space(AS_PROGRAM);
546551
547   space.install_read_handler(0x0300, 0x030f, read8_delegate(FUNC(oric_state::oric_IO_r), state));
552   space.install_read_handler(0x0300, 0x030f, read8_delegate(FUNC(oric_state::oric_IO_r), this));
548553   space.install_read_handler(0x0310, 0x031f, read8_delegate(FUNC(applefdc_base_device::read), fdc));
549554   space.install_read_bank(0x0320, 0x03ff, "bank4");
555   m_bank4 = membank("bank4");
550556
551   space.install_write_handler(0x0300, 0x030f, write8_delegate(FUNC(oric_state::oric_IO_w), state));
557   space.install_write_handler(0x0300, 0x030f, write8_delegate(FUNC(oric_state::oric_IO_w), this));
552558   space.install_write_handler(0x0310, 0x031f, write8_delegate(FUNC(applefdc_base_device::write), fdc));
553   space.install_write_handler(0x0380, 0x0383, write8_delegate(FUNC(oric_state::apple2_v2_interface_w),state));
559   space.install_write_handler(0x0380, 0x0383, write8_delegate(FUNC(oric_state::apple2_v2_interface_w),this));
554560
555   state->apple2_v2_interface_w(space, 0, 0);
561   apple2_v2_interface_w(space, 0, 0);
556562}
557563
558564/********************/
r20472r20473
564570/* bit 0: ROMDIS (1 means internal Basic rom disabled) */
565571
566572
567static void oric_jasmin_set_mem_0x0c000(running_machine &machine)
573void oric_state::oric_jasmin_set_mem_0x0c000()
568574{
569   oric_state *state = machine.driver_data<oric_state>();
570575   /* assumption:
571576   1. It is possible to access all 16k overlay ram.
572577   2. If os is enabled, and overlay ram is enabled, all 16k can be accessed.
573578   3. if os is disabled, and overlay ram is enabled, jasmin rom takes priority.
574579   */
575   if (state->m_is_telestrat)
580   if (m_is_telestrat)
581   {
576582      return;
583   }
577584
578585   /* the ram is disabled in the jasmin rom which indicates that jasmin takes
579586   priority over the ram */
580587
581588   /* basic rom disabled? */
582   if ((state->m_port_3fb_w & 0x01)==0)
589   if ((m_port_3fb_w & 0x01)==0)
583590   {
584591      /* no, it is enabled! */
585592
586593      /* overlay ram enabled? */
587      if ((state->m_port_3fa_w & 0x01)==0)
594      if ((m_port_3fa_w & 0x01)==0)
588595      {
589596         unsigned char *rom_ptr;
590597
591598         /* no it is disabled */
592599         /*logerror("&c000-&ffff is os rom\n"); */
593600
594         oric_enable_memory(machine, 1, 3, TRUE, FALSE);
601         oric_enable_memory(1, 3, TRUE, FALSE);
595602
596         rom_ptr = state->memregion("maincpu")->base() + 0x010000;
597         state->membank("bank1")->set_base(rom_ptr);
598         state->membank("bank2")->set_base(rom_ptr+0x02000);
599         state->membank("bank3")->set_base(rom_ptr+0x03800);
603         rom_ptr = m_region_maincpu->base() + 0x010000;
604         m_bank1->set_base(rom_ptr);
605         m_bank2->set_base(rom_ptr+0x02000);
606         m_bank3->set_base(rom_ptr+0x03800);
600607      }
601608      else
602609      {
603610         /*logerror("&c000-&ffff is ram\n"); */
604611
605         oric_enable_memory(machine, 1, 3, TRUE, TRUE);
612         oric_enable_memory(1, 3, TRUE, TRUE);
606613
607         state->membank("bank1")->set_base(state->m_ram_0x0c000);
608         state->membank("bank2")->set_base(state->m_ram_0x0c000+0x02000);
609         state->membank("bank3")->set_base(state->m_ram_0x0c000+0x03800);
610         state->membank("bank5")->set_base(state->m_ram_0x0c000);
611         state->membank("bank6")->set_base(state->m_ram_0x0c000+0x02000);
612         state->membank("bank7")->set_base(state->m_ram_0x0c000+0x03800);
614         m_bank1->set_base(m_ram_0x0c000);
615         m_bank2->set_base(m_ram_0x0c000+0x02000);
616         m_bank3->set_base(m_ram_0x0c000+0x03800);
617         m_bank5->set_base(m_ram_0x0c000);
618         m_bank6->set_base(m_ram_0x0c000+0x02000);
619         m_bank7->set_base(m_ram_0x0c000+0x03800);
613620      }
614621   }
615622   else
616623   {
617624      /* yes, basic rom is disabled */
618625
619      if ((state->m_port_3fa_w & 0x01)==0)
626      if ((m_port_3fa_w & 0x01)==0)
620627      {
621628         /* overlay ram disabled */
622629
623630         /*logerror("&c000-&f8ff is nothing!\n"); */
624         oric_enable_memory(machine, 1, 2, FALSE, FALSE);
631         oric_enable_memory(1, 2, FALSE, FALSE);
625632      }
626633      else
627634      {
628635         /*logerror("&c000-&f8ff is ram!\n"); */
629         oric_enable_memory(machine, 1, 2, TRUE, TRUE);
636         oric_enable_memory(1, 2, TRUE, TRUE);
630637
631         state->membank("bank1")->set_base(state->m_ram_0x0c000);
632         state->membank("bank2")->set_base(state->m_ram_0x0c000+0x02000);
633         state->membank("bank5")->set_base(state->m_ram_0x0c000);
634         state->membank("bank6")->set_base(state->m_ram_0x0c000+0x02000);
638         m_bank1->set_base(m_ram_0x0c000);
639         m_bank2->set_base(m_ram_0x0c000+0x02000);
640         m_bank5->set_base(m_ram_0x0c000);
641         m_bank6->set_base(m_ram_0x0c000+0x02000);
635642      }
636643
637644      {
r20472r20473
640647
641648         /*logerror("&f800-&ffff is jasmin rom\n"); */
642649         /* jasmin rom enabled */
643         oric_enable_memory(machine, 3, 3, TRUE, TRUE);
644         rom_ptr = machine.root_device().memregion("maincpu")->base() + 0x010000+0x04000+0x02000;
645         state->membank("bank3")->set_base(rom_ptr);
646         state->membank("bank7")->set_base(rom_ptr);
650         oric_enable_memory(3, 3, TRUE, TRUE);
651         rom_ptr = m_region_maincpu->base() + 0x010000+0x04000+0x02000;
652         m_bank3->set_base(rom_ptr);
653         m_bank7->set_base(rom_ptr);
647654      }
648655   }
649656}
r20472r20473
656663   else
657664      m_irqs &=~(1<<1);
658665
659   oric_refresh_ints(machine());
666   oric_refresh_ints();
660667}
661668
662669READ8_MEMBER(oric_state::oric_jasmin_r)
663670{
664   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
665671   device_t *fdc = machine().device("wd179x");
666672   unsigned char data = 0x0ff;
667673
r20472r20473
681687         data = wd17xx_data_r(fdc, space, 0);
682688         break;
683689      default:
684         data = via_0->read(space,offset & 0x0f);
690         data = m_via6522_0->read(space,offset & 0x0f);
685691         //logerror("unhandled io read: %04x %02x\n", offset, data);
686692         break;
687693
r20472r20473
692698
693699WRITE8_MEMBER(oric_state::oric_jasmin_w)
694700{
695   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
696701   device_t *fdc = machine().device("wd179x");
697702   switch (offset & 0x0f)
698703   {
r20472r20473
718723         wd17xx_reset(fdc);
719724         break;
720725      case 0x0a:
721         //logerror("jasmin overlay ram w: %02x PC: %04x\n", data, machine().device("maincpu")->safe_pc());
726         //logerror("jasmin overlay ram w: %02x PC: %04x\n", data, m_maincpu->pc());
722727         m_port_3fa_w = data;
723         oric_jasmin_set_mem_0x0c000(machine());
728         oric_jasmin_set_mem_0x0c000();
724729         break;
725730      case 0x0b:
726         //logerror("jasmin romdis w: %02x PC: %04x\n", data, machine().device("maincpu")->safe_pc());
731         //logerror("jasmin romdis w: %02x PC: %04x\n", data, m_maincpu->pc());
727732         m_port_3fb_w = data;
728         oric_jasmin_set_mem_0x0c000(machine());
733         oric_jasmin_set_mem_0x0c000();
729734         break;
730735      /* bit 0,1 of addr is the drive */
731736      case 0x0c:
r20472r20473
736741         break;
737742
738743      default:
739         via_0->write(space,offset & 0x0f, data);
744         m_via6522_0->write(space,offset & 0x0f, data);
740745         break;
741746   }
742747}
743748
744749
745static void oric_install_jasmin_interface(running_machine &machine)
750void oric_state::oric_install_jasmin_interface()
746751{
747   oric_state *state = machine.driver_data<oric_state>();
748   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
752   address_space &space = m_maincpu->space(AS_PROGRAM);
749753   /* romdis */
750   state->m_port_3fb_w = 1;
751   oric_jasmin_set_mem_0x0c000(machine);
754   m_port_3fb_w = 1;
755   oric_jasmin_set_mem_0x0c000();
752756
753   space.install_read_handler(0x0300, 0x03ef, read8_delegate(FUNC(oric_state::oric_IO_r),state));
754   space.install_read_handler(0x03f0, 0x03ff, read8_delegate(FUNC(oric_state::oric_jasmin_r),state));
757   space.install_read_handler(0x0300, 0x03ef, read8_delegate(FUNC(oric_state::oric_IO_r),this));
758   space.install_read_handler(0x03f0, 0x03ff, read8_delegate(FUNC(oric_state::oric_jasmin_r),this));
755759
756   space.install_write_handler(0x0300, 0x03ef, write8_delegate(FUNC(oric_state::oric_IO_w),state));
757   space.install_write_handler(0x03f0, 0x03ff, write8_delegate(FUNC(oric_state::oric_jasmin_w),state));
760   space.install_write_handler(0x0300, 0x03ef, write8_delegate(FUNC(oric_state::oric_IO_w),this));
761   space.install_write_handler(0x03f0, 0x03ff, write8_delegate(FUNC(oric_state::oric_jasmin_w),this));
758762}
759763
760764/*********************************/
r20472r20473
770774/* bit 0: enable FDC IRQ to trigger IRQ on CPU */
771775
772776
773static void oric_microdisc_refresh_wd179x_ints(running_machine &machine)
777void oric_state::oric_microdisc_refresh_wd179x_ints()
774778{
775   oric_state *state = machine.driver_data<oric_state>();
776   state->m_irqs &=~(1<<1);
779   m_irqs &=~(1<<1);
777780
778   if ((state->m_wd179x_int_state) && (state->m_port_314_w & (1<<0)))
781   if ((m_wd179x_int_state) && (m_port_314_w & (1<<0)))
779782   {
780783      /*logerror("oric microdisc interrupt\n"); */
781784
782      state->m_irqs |=(1<<1);
785      m_irqs |=(1<<1);
783786   }
784787
785   oric_refresh_ints(machine);
788   oric_refresh_ints();
786789}
787790
788791WRITE_LINE_MEMBER(oric_state::oric_microdisc_wd179x_intrq_w)
r20472r20473
794797   else
795798      m_port_314_r |=(1<<7);
796799
797   oric_microdisc_refresh_wd179x_ints(machine());
800   oric_microdisc_refresh_wd179x_ints();
798801}
799802
800803WRITE_LINE_MEMBER(oric_state::oric_microdisc_wd179x_drq_w)
r20472r20473
805808      m_port_318_r |= (1<<7);
806809}
807810
808static void oric_microdisc_set_mem_0x0c000(running_machine &machine)
811void oric_state::oric_microdisc_set_mem_0x0c000()
809812{
810   oric_state *state = machine.driver_data<oric_state>();
811   if (state->m_is_telestrat)
813   if (m_is_telestrat)
814   {
812815      return;
816   }
813817
814818   /* for 0x0c000-0x0dfff: */
815819   /* if os disabled, ram takes priority */
816820   /* /ROMDIS */
817   if ((state->m_port_314_w & (1<<1))==0)
821   if ((m_port_314_w & (1<<1))==0)
818822   {
819823      /*logerror("&c000-&dfff is ram\n"); */
820824      /* rom disabled enable ram */
821      oric_enable_memory(machine, 1, 1, TRUE, TRUE);
822      state->membank("bank1")->set_base(state->m_ram_0x0c000);
823      state->membank("bank5")->set_base(state->m_ram_0x0c000);
825      oric_enable_memory(1, 1, TRUE, TRUE);
826      m_bank1->set_base(m_ram_0x0c000);
827      m_bank5->set_base(m_ram_0x0c000);
824828   }
825829   else
826830   {
827831      unsigned char *rom_ptr;
828832      /*logerror("&c000-&dfff is os rom\n"); */
829833      /* basic rom */
830      oric_enable_memory(machine, 1, 1, TRUE, FALSE);
831      rom_ptr = machine.root_device().memregion("maincpu")->base() + 0x010000;
832      state->membank("bank1")->set_base(rom_ptr);
833      state->membank("bank5")->set_base(rom_ptr);
834      oric_enable_memory(1, 1, TRUE, FALSE);
835      rom_ptr = m_region_maincpu->base() + 0x010000;
836      m_bank1->set_base(rom_ptr);
837      m_bank5->set_base(rom_ptr);
834838   }
835839
836840   /* for 0x0e000-0x0ffff */
837841   /* if not disabled, os takes priority */
838   if ((state->m_port_314_w & (1<<1))!=0)
842   if ((m_port_314_w & (1<<1))!=0)
839843   {
840844      unsigned char *rom_ptr;
841845      /*logerror("&e000-&ffff is os rom\n"); */
842846      /* basic rom */
843      oric_enable_memory(machine, 2, 3, TRUE, FALSE);
844      rom_ptr = machine.root_device().memregion("maincpu")->base() + 0x010000;
845      state->membank("bank2")->set_base(rom_ptr+0x02000);
846      state->membank("bank3")->set_base(rom_ptr+0x03800);
847      state->membank("bank6")->set_base(rom_ptr+0x02000);
848      state->membank("bank7")->set_base(rom_ptr+0x03800);
847      oric_enable_memory(2, 3, TRUE, FALSE);
848      rom_ptr = m_region_maincpu->base() + 0x010000;
849      m_bank2->set_base(rom_ptr+0x02000);
850      m_bank3->set_base(rom_ptr+0x03800);
851      m_bank6->set_base(rom_ptr+0x02000);
852      m_bank7->set_base(rom_ptr+0x03800);
849853
850854   }
851855   else
852856   {
853857      /* if eprom is enabled, it takes priority over ram */
854      if ((state->m_port_314_w & (1<<7))==0)
858      if ((m_port_314_w & (1<<7))==0)
855859      {
856860         unsigned char *rom_ptr;
857861         /*logerror("&e000-&ffff is disk rom\n"); */
858         oric_enable_memory(machine, 2, 3, TRUE, FALSE);
862         oric_enable_memory(2, 3, TRUE, FALSE);
859863         /* enable rom of microdisc interface */
860         rom_ptr = machine.root_device().memregion("maincpu")->base() + 0x014000;
861         state->membank("bank2")->set_base(rom_ptr);
862         state->membank("bank3")->set_base(rom_ptr+0x01800);
864         rom_ptr = m_region_maincpu->base() + 0x014000;
865         m_bank2->set_base(rom_ptr);
866         m_bank3->set_base(rom_ptr+0x01800);
863867      }
864868      else
865869      {
866870         /*logerror("&e000-&ffff is ram\n"); */
867871         /* rom disabled enable ram */
868         oric_enable_memory(machine, 2, 3, TRUE, TRUE);
869         state->membank("bank2")->set_base(state->m_ram_0x0c000+0x02000);
870         state->membank("bank3")->set_base(state->m_ram_0x0c000+0x03800);
871         state->membank("bank6")->set_base(state->m_ram_0x0c000+0x02000);
872         state->membank("bank7")->set_base(state->m_ram_0x0c000+0x03800);
872         oric_enable_memory(2, 3, TRUE, TRUE);
873         m_bank2->set_base(m_ram_0x0c000+0x02000);
874         m_bank3->set_base(m_ram_0x0c000+0x03800);
875         m_bank6->set_base(m_ram_0x0c000+0x02000);
876         m_bank7->set_base(m_ram_0x0c000+0x03800);
873877      }
874878   }
875879}
r20472r20473
906910         break;
907911
908912      default:
909         {
910            via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
911            data = via_0->read(space, offset & 0x0f);
912         }
913         data = m_via6522_0->read(space, offset & 0x0f);
913914         break;
914915
915916   }
r20472r20473
949950         wd17xx_set_side(fdc,(data>>4) & 0x01);
950951         wd17xx_dden_w(fdc, !BIT(data, 3));
951952
952         oric_microdisc_set_mem_0x0c000(machine());
953         oric_microdisc_refresh_wd179x_ints(machine());
953         oric_microdisc_set_mem_0x0c000();
954         oric_microdisc_refresh_wd179x_ints();
954955      }
955956      break;
956957
957958      default:
958         {
959            via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
960            via_0->write(space, offset & 0x0f, data);
961         }
959         m_via6522_0->write(space, offset & 0x0f, data);
962960         break;
963961   }
964962}
965963
966static void oric_install_microdisc_interface(running_machine &machine)
964void oric_state::oric_install_microdisc_interface()
967965{
968   oric_state *state = machine.driver_data<oric_state>();
969   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
966   address_space &space = m_maincpu->space(AS_PROGRAM);
970967
971   space.install_read_handler(0x0300, 0x030f, read8_delegate(FUNC(oric_state::oric_IO_r),state));
972   space.install_read_handler(0x0310, 0x031f, read8_delegate(FUNC(oric_state::oric_microdisc_r),state));
973   space.install_read_handler(0x0320, 0x03ff, read8_delegate(FUNC(oric_state::oric_IO_r),state));
968   space.install_read_handler(0x0300, 0x030f, read8_delegate(FUNC(oric_state::oric_IO_r),this));
969   space.install_read_handler(0x0310, 0x031f, read8_delegate(FUNC(oric_state::oric_microdisc_r),this));
970   space.install_read_handler(0x0320, 0x03ff, read8_delegate(FUNC(oric_state::oric_IO_r),this));
974971
975   space.install_write_handler(0x0300, 0x030f, write8_delegate(FUNC(oric_state::oric_IO_w),state));
976   space.install_write_handler(0x0310, 0x031f, write8_delegate(FUNC(oric_state::oric_microdisc_w),state));
977   space.install_write_handler(0x0320, 0x03ff, write8_delegate(FUNC(oric_state::oric_IO_w),state));
972   space.install_write_handler(0x0300, 0x030f, write8_delegate(FUNC(oric_state::oric_IO_w),this));
973   space.install_write_handler(0x0310, 0x031f, write8_delegate(FUNC(oric_state::oric_microdisc_w),this));
974   space.install_write_handler(0x0320, 0x03ff, write8_delegate(FUNC(oric_state::oric_IO_w),this));
978975
979976   /* disable os rom, enable microdisc rom */
980977   /* 0x0c000-0x0dfff will be ram, 0x0e000-0x0ffff will be microdisc rom */
981   state->m_port_314_w = 0x0ff^((1<<7) | (1<<1));
978   m_port_314_w = 0x0ff^((1<<7) | (1<<1));
982979
983   oric_microdisc_set_mem_0x0c000(machine);
980   oric_microdisc_set_mem_0x0c000();
984981}
985982
986983
r20472r20473
989986
990987WRITE_LINE_MEMBER(oric_state::oric_wd179x_intrq_w)
991988{
992   if ((machine().root_device().ioport("FLOPPY")->read() & 0x07) == ORIC_FLOPPY_INTERFACE_MICRODISC)
989   if ((m_io_floppy->read() & 0x07) == ORIC_FLOPPY_INTERFACE_MICRODISC)
990   {
993991      oric_microdisc_wd179x_intrq_w(state);
992   }
994993}
995994
996995WRITE_LINE_MEMBER(oric_state::oric_wd179x_drq_w)
997996{
998   switch (machine().root_device().ioport("FLOPPY")->read() &  0x07)
997   switch (m_io_floppy->read() &  0x07)
999998   {
1000999      default:
10011000      case ORIC_FLOPPY_INTERFACE_NONE:
r20472r20473
10181017   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
10191018};
10201019
1021static void oric_common_init_machine(running_machine &machine)
1020void oric_state::oric_common_init_machine()
10221021{
1023   oric_state *state = machine.driver_data<oric_state>();
10241022   /* clear all irqs */
1025   state->m_irqs = 0;
1026   state->m_ram_0x0c000 = NULL;
1027   state->m_keyboard_line = 0;
1028   state->m_key_sense_bit = 0;
1029   state->m_keyboard_mask = 0;
1030   state->m_via_port_a_data = 0;
1031   state->m_psg_control = 0;
1032   state->m_previous_portb_data = 0;
1033   state->m_port_3fa_w = 0;
1034   state->m_port_3fb_w = 0;
1035   state->m_wd179x_int_state = 0;
1036   state->m_port_314_r = 0;
1037   state->m_port_318_r = 0;
1038   state->m_port_314_w = 0;
1039   machine.scheduler().timer_pulse(attotime::from_hz(4800), timer_expired_delegate(FUNC(oric_state::oric_refresh_tape),state));
1023   m_irqs = 0;
1024   m_ram_0x0c000 = NULL;
1025   m_keyboard_line = 0;
1026   m_key_sense_bit = 0;
1027   m_keyboard_mask = 0;
1028   m_via_port_a_data = 0;
1029   m_psg_control = 0;
1030   m_previous_portb_data = 0;
1031   m_port_3fa_w = 0;
1032   m_port_3fb_w = 0;
1033   m_wd179x_int_state = 0;
1034   m_port_314_r = 0;
1035   m_port_318_r = 0;
1036   m_port_314_w = 0;
1037   machine().scheduler().timer_pulse(attotime::from_hz(4800), timer_expired_delegate(FUNC(oric_state::oric_refresh_tape),this));
10401038}
10411039
10421040void oric_state::machine_start()
10431041{
1044   oric_common_init_machine(machine());
1042   oric_common_init_machine();
10451043
10461044   m_is_telestrat = 0;
10471045
r20472r20473
10511049
10521050void oric_state::machine_reset()
10531051{
1054   int disc_interface_id = machine().root_device().ioport("FLOPPY")->read() & 0x07;
1055   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
1052   int disc_interface_id = m_io_floppy->read() & 0x07;
1053   address_space &space = m_maincpu->space(AS_PROGRAM);
10561054   if (m_is_telestrat)
10571055      return;
10581056
r20472r20473
10671065         unsigned char *rom_ptr;
10681066
10691067         /* os rom */
1070         oric_enable_memory(machine(), 1, 3, TRUE, FALSE);
1071         rom_ptr = memregion("maincpu")->base() + 0x010000;
1072         membank("bank1")->set_base(rom_ptr);
1073         membank("bank2")->set_base(rom_ptr+0x02000);
1074         membank("bank3")->set_base(rom_ptr+0x03800);
1075         membank("bank5")->set_base(rom_ptr);
1076         membank("bank6")->set_base(rom_ptr+0x02000);
1077         membank("bank7")->set_base(rom_ptr+0x03800);
1068         oric_enable_memory(1, 3, TRUE, FALSE);
1069         rom_ptr = m_region_maincpu->base() + 0x010000;
1070         m_bank1->set_base(rom_ptr);
1071         m_bank2->set_base(rom_ptr+0x02000);
1072         m_bank3->set_base(rom_ptr+0x03800);
1073         m_bank5->set_base(rom_ptr);
1074         m_bank6->set_base(rom_ptr+0x02000);
1075         m_bank7->set_base(rom_ptr+0x03800);
10781076
10791077
10801078         if (disc_interface_id==ORIC_FLOPPY_INTERFACE_APPLE2)
10811079         {
1082            oric_install_apple2_interface(machine());
1080            oric_install_apple2_interface();
10831081         }
10841082         else
10851083         {
r20472r20473
10911089
10921090      case ORIC_FLOPPY_INTERFACE_APPLE2_V2:
10931091      {
1094         oric_install_apple2_v2_interface(machine());
1092         oric_install_apple2_v2_interface();
10951093      }
10961094      break;
10971095
10981096
10991097      case ORIC_FLOPPY_INTERFACE_MICRODISC:
11001098      {
1101         oric_install_microdisc_interface(machine());
1099         oric_install_microdisc_interface();
11021100      }
11031101      break;
11041102
11051103      case ORIC_FLOPPY_INTERFACE_JASMIN:
11061104      {
1107         oric_install_jasmin_interface(machine());
1105         oric_install_jasmin_interface();
11081106      }
11091107      break;
11101108   }
1111   machine().device("maincpu")->reset();
1109   m_maincpu->reset();
11121110}
11131111
11141112
11151113READ8_MEMBER(oric_state::oric_IO_r)
11161114{
1117   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
1118   switch (ioport("FLOPPY")->read() & 0x07)
1115   switch (m_io_floppy->read() & 0x07)
11191116   {
11201117      default:
11211118      case ORIC_FLOPPY_INTERFACE_NONE:
r20472r20473
11411138   }
11421139
11431140   /* it is repeated */
1144   return via_0->read(space, offset & 0x0f);
1141   return m_via6522_0->read(space, offset & 0x0f);
11451142}
11461143
11471144WRITE8_MEMBER(oric_state::oric_IO_w)
11481145{
1149   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
1150   switch (ioport("FLOPPY")->read() & 0x07)
1146   switch (m_io_floppy->read() & 0x07)
11511147   {
11521148      default:
11531149      case ORIC_FLOPPY_INTERFACE_NONE:
r20472r20473
11751171      break;
11761172   }
11771173
1178   via_0->write(space, offset & 0x0f, data);
1174   m_via6522_0->write(space, offset & 0x0f, data);
11791175}
11801176
11811177
r20472r20473
12311227*/
12321228
12331229
1234static void telestrat_refresh_mem(running_machine &machine)
1230void oric_state::telestrat_refresh_mem()
12351231{
1236   oric_state *state = machine.driver_data<oric_state>();
1237   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
1232   address_space &space = m_maincpu->space(AS_PROGRAM);
12381233
1239   telestrat_mem_block *mem_block = &state->m_telestrat_blocks[state->m_telestrat_bank_selection];
1234   telestrat_mem_block *mem_block = &m_telestrat_blocks[m_telestrat_bank_selection];
12401235
12411236   switch (mem_block->MemType)
12421237   {
12431238      case TELESTRAT_MEM_BLOCK_RAM:
12441239      {
1245         state->membank("bank1")->set_base(mem_block->ptr);
1246         state->membank("bank2")->set_base(mem_block->ptr);
1240         m_bank1->set_base(mem_block->ptr);
1241         m_bank2->set_base(mem_block->ptr);
12471242         space.install_read_bank(0xc000, 0xffff, "bank1");
12481243         space.install_write_bank(0xc000, 0xffff, "bank2");
12491244      }
r20472r20473
12511246
12521247      case TELESTRAT_MEM_BLOCK_ROM:
12531248      {
1254         state->membank("bank1")->set_base(mem_block->ptr);
1249         m_bank1->set_base(mem_block->ptr);
12551250         space.install_read_bank(0xc000, 0xffff, "bank1");
12561251         space.nop_write(0xc000, 0xffff);
12571252      }
r20472r20473
12831278   {
12841279      m_telestrat_bank_selection = data & 0x07;
12851280
1286      telestrat_refresh_mem(machine());
1281      telestrat_refresh_mem();
12871282   }
12881283}
12891284
r20472r20473
13141309}
13151310
13161311
1317static void telestrat_via2_irq_func(device_t *device, int state)
1312WRITE_LINE_MEMBER(oric_state::telestrat_via2_irq_func)
13181313{
1319   oric_state *drvstate = device->machine().driver_data<oric_state>();
1320   drvstate->m_irqs &=~(1<<2);
1314   m_irqs &=~(1<<2);
13211315
13221316   if (state)
13231317   {
13241318      //logerror("telestrat via2 interrupt\n");
13251319
1326      drvstate->m_irqs |=(1<<2);
1320      m_irqs |=(1<<2);
13271321   }
13281322
1329   oric_refresh_ints(device->machine());
1323   oric_refresh_ints();
13301324}
13311325
13321326const via6522_interface telestrat_via2_interface=
r20472r20473
13431337   DEVCB_NULL,
13441338   DEVCB_NULL,
13451339   DEVCB_NULL,
1346   DEVCB_LINE(telestrat_via2_irq_func),
1340   DEVCB_DRIVER_LINE_MEMBER(oric_state,telestrat_via2_irq_func),
13471341};
13481342
13491343#if 0
r20472r20473
13581352      state->m_irqs |= (1<<3);
13591353   }
13601354
1361   oric_refresh_ints(machine);
1355   oric_refresh_ints();
13621356}
13631357#endif
13641358
13651359MACHINE_START_MEMBER(oric_state,telestrat)
13661360{
1367   UINT8 *mem = memregion("maincpu")->base();
1361   UINT8 *mem = m_region_maincpu->base();
13681362
1369   oric_common_init_machine(machine());
1363   oric_common_init_machine();
13701364
13711365   m_telestrat_via2_port_a_data = 0;
13721366   m_telestrat_via2_port_b_data = 0;
r20472r20473
14021396   m_telestrat_blocks[7].ptr = mem+0x01c000; // telmon24.rom
14031397
14041398   m_telestrat_bank_selection = 7;
1405   telestrat_refresh_mem(machine());
1399   telestrat_refresh_mem();
14061400
14071401   /* disable os rom, enable microdisc rom */
14081402   /* 0x0c000-0x0dfff will be ram, 0x0e000-0x0ffff will be microdisc rom */
trunk/src/mess/includes/oric.h
r20472r20473
7070{
7171public:
7272   oric_state(const machine_config &mconfig, device_type type, const char *tag)
73      : driver_device(mconfig, type, tag),
74         m_ram(*this, "ram") { }
73      : driver_device(mconfig, type, tag)
74      , m_ram(*this, "ram")
75      , m_maincpu(*this, "maincpu")
76      , m_ay8912(*this, "ay8912")
77      , m_centronics(*this, "centronics")
78      , m_cassette(*this, CASSETTE_TAG)
79      , m_via6522_0(*this, "via6522_0")
80      , m_region_maincpu(*this, "maincpu")
81      , m_bank1(*this, "bank1")
82      , m_bank2(*this, "bank2")
83      , m_bank3(*this, "bank3")
84      , m_bank4(NULL)
85      , m_bank5(*this, "bank5")
86      , m_bank6(*this, "bank6")
87      , m_bank7(*this, "bank7")
88      , m_io_row0(*this, "ROW0")
89      , m_io_row1(*this, "ROW1")
90      , m_io_row2(*this, "ROW2")
91      , m_io_row3(*this, "ROW3")
92      , m_io_row4(*this, "ROW4")
93      , m_io_row5(*this, "ROW5")
94      , m_io_row6(*this, "ROW6")
95      , m_io_row7(*this, "ROW7")
96      , m_io_floppy(*this, "FLOPPY")
97   { }
7598
7699   optional_shared_ptr<UINT8> m_ram;
77100   bool m_is_telestrat;
r20472r20473
123146   DECLARE_WRITE_LINE_MEMBER(oric_microdisc_wd179x_drq_w);
124147   DECLARE_WRITE_LINE_MEMBER(oric_wd179x_intrq_w);
125148   DECLARE_WRITE_LINE_MEMBER(oric_wd179x_drq_w);
149   DECLARE_WRITE_LINE_MEMBER(oric_via_irq_func);
126150   DECLARE_READ8_MEMBER(telestrat_via2_in_a_func);
127151   DECLARE_WRITE8_MEMBER(telestrat_via2_out_a_func);
128152   DECLARE_READ8_MEMBER(telestrat_via2_in_b_func);
129153   DECLARE_WRITE8_MEMBER(telestrat_via2_out_b_func);
154   DECLARE_WRITE_LINE_MEMBER(telestrat_via2_irq_func);
155
156protected:
157   required_device<cpu_device> m_maincpu;
158   required_device<device_t> m_ay8912;
159   required_device<centronics_device> m_centronics;
160   required_device<cassette_image_device> m_cassette;
161   required_device<via6522_device> m_via6522_0;
162   required_memory_region m_region_maincpu;
163   required_memory_bank m_bank1;
164   required_memory_bank m_bank2;
165   optional_memory_bank m_bank3;
166   memory_bank *m_bank4;
167   optional_memory_bank m_bank5;
168   optional_memory_bank m_bank6;
169   optional_memory_bank m_bank7;
170   required_ioport m_io_row0;
171   required_ioport m_io_row1;
172   required_ioport m_io_row2;
173   required_ioport m_io_row3;
174   required_ioport m_io_row4;
175   required_ioport m_io_row5;
176   required_ioport m_io_row6;
177   required_ioport m_io_row7;
178   required_ioport m_io_floppy;
179
180   void oric_microdisc_refresh_wd179x_ints();
181   void oric_refresh_ints();
182   void oric_keyboard_sense_refresh();
183   void oric_psg_connection_refresh(address_space &space);
184   void oric_common_init_machine();
185   void oric_install_apple2_interface();
186   void oric_install_apple2_v2_interface();
187   void oric_install_microdisc_interface();
188   void oric_install_jasmin_interface();
189   void oric_microdisc_set_mem_0x0c000();
190   void telestrat_refresh_mem();
191   void oric_enable_memory(int low, int high, int rd, int wr);
192   void oric_jasmin_set_mem_0x0c000();
193
194   void oric_vh_update_attribute(UINT8 c);
195   void oric_vh_update_flash();
196   void oric_refresh_charset();
130197};
131198
132199/*----------- defined in machine/oric.c -----------*/
trunk/src/mess/video/oric.c
r20472r20473
1818   m_vh_state.flash_count++;
1919}
2020
21static void oric_vh_update_flash(oric_state *state)
21void oric_state::oric_vh_update_flash()
2222{
2323   /* flash active? */
24   if (BIT(state->m_vh_state.text_attributes, 2))
24   if (BIT(m_vh_state.text_attributes, 2))
2525   {
2626      /* yes */
2727
2828      /* show or hide text? */
29      if (BIT(state->m_vh_state.flash_count, 4))
29      if (BIT(m_vh_state.flash_count, 4))
3030      {
3131         /* hide */
3232         /* set foreground and background to be the same */
33         state->m_vh_state.active_foreground_colour = state->m_vh_state.background_colour;
34         state->m_vh_state.active_background_colour = state->m_vh_state.background_colour;
33         m_vh_state.active_foreground_colour = m_vh_state.background_colour;
34         m_vh_state.active_background_colour = m_vh_state.background_colour;
3535         return;
3636      }
3737   }
3838
3939
4040   /* show */
41   state->m_vh_state.active_foreground_colour = state->m_vh_state.foreground_colour;
42   state->m_vh_state.active_background_colour = state->m_vh_state.background_colour;
41   m_vh_state.active_foreground_colour = m_vh_state.foreground_colour;
42   m_vh_state.active_background_colour = m_vh_state.background_colour;
4343}
4444
4545/* the alternate charset follows from the standard charset.
4646Each charset holds 128 chars with 8 bytes for each char.
4747
4848The start address for the standard charset is dependant on the video mode */
49static void oric_refresh_charset(oric_state *state)
49void oric_state::oric_refresh_charset()
5050{
5151   /* alternate char set? */
52   if (BIT(state->m_vh_state.text_attributes, 0))
52   if (BIT(m_vh_state.text_attributes, 0))
5353   {
5454      /* yes */
55      state->m_vh_state.char_data = state->m_vh_state.char_base + (128*8);
55      m_vh_state.char_data = m_vh_state.char_base + (128*8);
5656   }
5757   else
5858   {
5959      /* no */
60      state->m_vh_state.char_data = state->m_vh_state.char_base;
60      m_vh_state.char_data = m_vh_state.char_base;
6161   }
6262}
6363
6464/* update video hardware state depending on the new attribute */
65static void oric_vh_update_attribute(running_machine &machine, UINT8 c)
65void oric_state::oric_vh_update_attribute(UINT8 c)
6666{
67   oric_state *state = machine.driver_data<oric_state>();
6867   /* attribute */
6968   UINT8 attribute = c & 0x03f;
70   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
69   address_space &space = m_maincpu->space(AS_PROGRAM);
7170
7271   switch ((attribute>>3) & 0x03)
7372   {
7473      case 0:
7574      {
7675         /* set foreground colour 00-07 = black,red,green,yellow,blue,magenta,cyan,white */
77         state->m_vh_state.foreground_colour = attribute & 0x07;
78         oric_vh_update_flash(state);
76         m_vh_state.foreground_colour = attribute & 0x07;
77         oric_vh_update_flash();
7978      }
8079      break;
8180
8281      case 1:
8382      {
84         state->m_vh_state.text_attributes = attribute & 0x07;
83         m_vh_state.text_attributes = attribute & 0x07;
8584
86         oric_refresh_charset(state);
85         oric_refresh_charset();
8786
8887         /* text attributes */
89         oric_vh_update_flash(state);
88         oric_vh_update_flash();
9089      }
9190      break;
9291
9392      case 2:
9493      {
9594         /* set background colour */
96         state->m_vh_state.background_colour = attribute & 0x07;
97         oric_vh_update_flash(state);
95         m_vh_state.background_colour = attribute & 0x07;
96         oric_vh_update_flash();
9897      }
9998      break;
10099
101100      case 3:
102101      {
103102         /* set video mode */
104         state->m_vh_state.mode = attribute & 0x07;
103         m_vh_state.mode = attribute & 0x07;
105104
106105         // a different charset base is used depending on the video mode
107106         // hires takes all the data from 0x0a000 through to about 0x0bf68,
108107         // so the charset is moved to 0x09800 */
109108         // text mode starts at 0x0bb80 and so the charset is in a different location
110         if (BIT(state->m_vh_state.mode, 2))
109         if (BIT(m_vh_state.mode, 2))
111110         {
112111            /* set screen memory base and standard charset location for this mode */
113            state->m_vh_state.read_addr = 0x0a000;
114            if (state->m_ram)
115               state->m_vh_state.char_base = state->m_ram + (offs_t)0x09800;
112            m_vh_state.read_addr = 0x0a000;
113            if (m_ram)
114               m_vh_state.char_base = m_ram + (offs_t)0x09800;
116115            else
117               state->m_vh_state.char_base = (UINT8 *)space.get_read_ptr(0x09800);
116               m_vh_state.char_base = (UINT8 *)space.get_read_ptr(0x09800);
118117         }
119118         else
120119         {
121120            /* set screen memory base and standard charset location for this mode */
122            state->m_vh_state.read_addr = 0x0bb80;
123            if (state->m_ram)
124               state->m_vh_state.char_base = state->m_ram + (offs_t)0x0b400;
121            m_vh_state.read_addr = 0x0bb80;
122            if (m_ram)
123               m_vh_state.char_base = m_ram + (offs_t)0x0b400;
125124            else
126               state->m_vh_state.char_base = (UINT8 *)space.get_read_ptr(0x0b400);
125               m_vh_state.char_base = (UINT8 *)space.get_read_ptr(0x0b400);
127126         }
128127         /* changing the mode also changes the position of the standard charset and alternative charset */
129         oric_refresh_charset(state);
128         oric_refresh_charset();
130129      }
131130      break;
132131
r20472r20473
167166   UINT8 *RAM, y;
168167   offs_t byte_offset, read_addr_base;
169168   bool hires_active;
169   address_space &space = m_maincpu->space(AS_PROGRAM);
170170
171171   RAM = m_ram;
172172
r20472r20473
181181      int x = 0;
182182
183183      /* foreground colour white */
184      oric_vh_update_attribute(machine(),7);
184      oric_vh_update_attribute(7);
185185      /* background colour black */
186      oric_vh_update_attribute(machine(),(1<<3));
187      oric_vh_update_attribute(machine(),(1<<4));
186      oric_vh_update_attribute((1<<3));
187      oric_vh_update_attribute((1<<4));
188188
189189      for (byte_offset=0; byte_offset<40; byte_offset++)
190190      {
r20472r20473
212212         }
213213
214214         /* fetch data */
215         c = RAM ? RAM[read_addr] : machine().device("maincpu")->memory().space(AS_PROGRAM).read_byte(read_addr);
215         c = RAM ? RAM[read_addr] : space.read_byte(read_addr);
216216
217217         /* if bits 6 and 5 are zero, the byte contains a serial attribute */
218218         if ((c & ((1 << 6) | (1 << 5))) == 0)
219219         {
220            oric_vh_update_attribute(machine(), c);
220            oric_vh_update_attribute(c);
221221
222222            /* display background colour when attribute has been found */
223223            oric_vh_render_6pixels(bitmap, x, y, m_vh_state.active_foreground_colour, m_vh_state.active_background_colour, 0, (c & 0x080));
r20472r20473
300300   m_vh_state.flash_count = 0;
301301   machine().scheduler().timer_pulse(attotime::from_hz(50), timer_expired_delegate(FUNC(oric_state::oric_vh_timer_callback),this));
302302   /* mode */
303   oric_vh_update_attribute(machine(),(1<<3)|(1<<4));
303   oric_vh_update_attribute((1<<3)|(1<<4));
304304}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team