Previous 15994 Revisions Next

r10030 Friday 14th January, 2011 at 01:13:03 UTC by Angelo Salese
[PC-8801]: Some irq work
[src/mess/drivers]pc8801.c

src/mess/drivers/pc8801.c
r10029r10030
1010   - macros for the various rom / ram areas, it might require various attempts in order to finally get a reasonable arrangement ...
1111   - dipswitches are WRONG
1212   - currently it's too slow ... why?
13   - implement proper i8214 routing, also add irq latch mechanism.
1314   - below notes states that plain PC-8801 doesn't have a disk CPU, but the BIOS clearly checks the floppy ports. Wrong info?
1415
1516   Notes:
r10029r10030
103104#include "machine/i8255a.h"
104105#include "machine/upd1990a.h"
105106#include "machine/upd765.h"
107#include "machine/i8214.h"
106108#include "sound/2203intf.h"
107109#include "sound/beep.h"
108110
109111static UINT32 bankr[5],bankw[5];
110static UINT8 bank_wp[5];
111112static UINT8 i8255_0_pc,i8255_1_pc;
112113static UINT8 fdc_irq_opcode;
113static UINT8 ext_rom_bank,gfx_ctrl,vram_sel;
114static UINT8 vrtc_irq_mask;
114static UINT8 ext_rom_bank,gfx_ctrl,vram_sel,misc_ctrl;
115static UINT8 vrtc_irq_mask,sound_irq_mask;
115116static UINT8 window_offset_bank;
116117
117118#define NBASIC_BASE 0x20000
r10029r10030
171172{
172173   UINT8 *ram = space->machine->region("maincpu")->base();
173174
174   if(bank_wp[0])
175      return;
176
177175   ram[offset + bankw[0]] = data;
178176}
179177
r10029r10030
188186{
189187   UINT8 *ram = space->machine->region("maincpu")->base();
190188
191   if(bank_wp[1])
192      return;
193
194189   ram[offset + bankw[1]] = data;
195190}
196191
r10029r10030
207202{
208203   UINT8 *ram = space->machine->region("maincpu")->base();
209204
210   if(bank_wp[2])
211      return;
212
213205   offset &= 0x3ff;
214206
215207   ram[offset + bankw[2]] = data;
r10029r10030
226218{
227219   UINT8 *ram = space->machine->region("maincpu")->base();
228220
229   if(bank_wp[3])
230      return;
231
232221   ram[offset + bankw[3]] = data;
233222}
234223
r10029r10030
243232{
244233   UINT8 *ram = space->machine->region("maincpu")->base();
245234
246   if(bank_wp[4])
247      return;
248
249235   ram[offset + bankw[4]] = data;
250236}
251237
r10029r10030
266252      return WRAM_BASE + 0x6000;
267253
268254   if(gfx_ctrl & 0x4) //n basic select
269   {
270255      return NBASIC_BASE + 0x6000;
271   }
272256
273257   if(ext_rom_bank & 1) // NOT ext ROM bank
274258      return N88BASIC_BASE + 0x6000;
r10029r10030
326310   if(vram_sel == 3)
327311      return WRAM_BASE + 0xf000;
328312
329   return GRAM_BASE + 0x3000 + 0x4000 * vram_sel;
313   return GRAM_BASE + 0x3000 + (0x4000 * vram_sel);
330314}
331315
332316
r10029r10030
389373   bankw[1] = pc8801_bankswitch_1_w(space->machine);
390374}
391375
376static READ8_HANDLER( pc8801_vram_select_r )
377{
378   return (0xf8) | (vram_sel << 1);
379}
380
392381static WRITE8_HANDLER( pc8801_vram_select_w )
393382{
394383   vram_sel = offset & 3;
r10029r10030
418407static WRITE8_HANDLER( pc8801_window_bank_inc_w )
419408{
420409   window_offset_bank++;
410   window_offset_bank&=0xff;
421411   bankr[2] = pc8801_bankswitch_2_r(space->machine);
422412   bankw[2] = pc8801_bankswitch_2_w(space->machine);
423413}
424414
415static READ8_HANDLER( pc8801_misc_ctrl_r )
416{
417   return misc_ctrl;
418}
419
420static WRITE8_HANDLER( pc8801_misc_ctrl_w )
421{
422   misc_ctrl = data;
423
424   if(!(data & 0x80))
425      sound_irq_mask = ((data & 0x80) == 0);
426}
427
428
425429static ADDRESS_MAP_START( pc8801_io, ADDRESS_SPACE_IO, 8 )
426430   ADDRESS_MAP_GLOBAL_MASK(0xff)
427431   ADDRESS_MAP_UNMAP_HIGH
r10029r10030
445449//  AM_RANGE(0x20, 0x21) AM_NOP                                     /* RS-232C and cassette */
446450   AM_RANGE(0x30, 0x30) AM_READ_PORT("DSW1") //AM_WRITE(pc88sr_outport_30)
447451   AM_RANGE(0x31, 0x31) AM_READ_PORT("DSW2") AM_WRITE(pc8801_gfx_ctrl_w)
448//   AM_RANGE(0x32, 0x32) AM_READWRITE(pc88sr_inport_32, pc88sr_outport_32)
452   AM_RANGE(0x32, 0x32) AM_READWRITE(pc8801_misc_ctrl_r, pc8801_misc_ctrl_w)
449453//   AM_RANGE(0x34, 0x35) AM_WRITE(pc88sr_alu)
450454   AM_RANGE(0x40, 0x40) AM_READ(pc8801_ctrl_r) //, pc88sr_outport_40)
451455   AM_RANGE(0x44, 0x45) AM_DEVREADWRITE("ym2203", ym2203_r,ym2203_w)
452456//  AM_RANGE(0x46, 0x47) AM_NOP                                     /* OPNA extra port */
453457//   AM_RANGE(0x50, 0x51) AM_READWRITE(pc88_crtc_r, pc88_crtc_w)
454458//   AM_RANGE(0x52, 0x5b) AM_WRITE(pc88_palette_w)
455//   AM_RANGE(0x5c, 0x5c) AM_READ(pc88_vramtest_r)
459   AM_RANGE(0x5c, 0x5c) AM_READ(pc8801_vram_select_r)
456460   AM_RANGE(0x5c, 0x5f) AM_WRITE(pc8801_vram_select_w)
457461//   AM_RANGE(0x60, 0x68) AM_READWRITE(pc88_dmac_r, pc88_dmac_w)
458462//  AM_RANGE(0x6e, 0x6e) AM_NOP                                     /* CPU clock info */
r10029r10030
470474//  AM_RANGE(0xd8, 0xd8) AM_NOP                                     /* GP-IB */
471475//  AM_RANGE(0xdc, 0xdf) AM_NOP                                     /* MODEM */
472476//   AM_RANGE(0xe2, 0xe3) AM_READWRITE(pc88_extmem_r, pc88_extmem_w) /* expand RAM select */
473//   AM_RANGE(0xe4, 0xe4) AM_WRITE(pc8801_write_interrupt_level)
477   AM_RANGE(0xe4, 0xe4) AM_WRITENOP //AM_WRITE(pc8801_write_interrupt_level)
474478   AM_RANGE(0xe6, 0xe6) AM_WRITE(pc8801_irq_mask_w)
475479//  AM_RANGE(0xe7, 0xe7) AM_NOP                                     /* (unknown) */
476480//   AM_RANGE(0xe8, 0xeb) AM_READWRITE(pc88_kanji_r, pc88_kanji_w)
r10029r10030
484488
485489static READ8_DEVICE_HANDLER( cpu_8255_c_r )
486490{
491   timer_call_after_resynch(device->machine, NULL, 0, 0); // force resync
492
487493   return i8255_1_pc >> 4;
488494}
489495
490496static WRITE8_DEVICE_HANDLER( cpu_8255_c_w )
491497{
498   timer_call_after_resynch(device->machine, NULL, 0, 0); // force resync
499
492500   i8255_0_pc = data;
493501}
494502
r10029r10030
504512
505513static READ8_DEVICE_HANDLER( fdc_8255_c_r )
506514{
515   timer_call_after_resynch(device->machine, NULL, 0, 0); // force resync
516
507517   return i8255_0_pc >> 4;
508518}
509519
510520static WRITE8_DEVICE_HANDLER( fdc_8255_c_w )
511521{
522   timer_call_after_resynch(device->machine, NULL, 0, 0); // force resync
523
512524   i8255_1_pc = data;
513525}
514526
r10029r10030
847859};
848860
849861/* YM2203 Interface */
862static void pc8801_sound_irq( device_t *device, int irq )
863{
864   if(sound_irq_mask)
865      cputag_set_input_line_and_vector(device->machine, "maincpu", 0, HOLD_LINE, 4*2);
866}
850867
868
851869static READ8_DEVICE_HANDLER( opn_dummy_input ) { return 0xff; }
852870
853871static const ym2203_interface pc88_ym2203_intf =
r10029r10030
860878      DEVCB_NULL,
861879      DEVCB_NULL
862880   },
863   NULL//pc88sr_sound_interupt
881   pc8801_sound_irq
864882};
865883
866884/* Floppy Configuration */
r10029r10030
897915   ext_rom_bank = 0xff;
898916   gfx_ctrl = 0x31;
899917   window_offset_bank = 0x00;
918   misc_ctrl = 0x90;
900919   bankr[0] = pc8801_bankswitch_0_r(machine);
901920   bankr[1] = pc8801_bankswitch_1_r(machine);
902921   bankw[0] = pc8801_bankswitch_0_w(machine);
r10029r10030
911930   bankw[3] = pc8801_bankswitch_3_w(machine);
912931   bankw[4] = pc8801_bankswitch_4_w(machine);
913932
914   bank_wp[0] = 0;
915   bank_wp[1] = 0;
916   bank_wp[2] = 0;
917   bank_wp[3] = 0;
918   bank_wp[4] = 0;
933   fdc_irq_opcode = 0; //TODO: copied from PC-88VA, could be wrong here ... should be 0x7f ld a,a in the latter case
919934
920   fdc_irq_opcode = 0; //TODO: copied from PC-88VA, could be wrong here ... should be 0x7f ld a,a in the latter case
935   vrtc_irq_mask = 0;
936   sound_irq_mask = 0;
937
938   cpu_set_input_line_vector(machine->device("fdccpu"), 0, 0);
921939}
922940
923941static PALETTE_INIT( pc8801 )
r10029r10030
928946      palette_set_color_rgb(machine, i, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0));
929947}
930948
931static WRITE_LINE_DEVICE_HANDLER(pc8801_upd765_interrupt)
932{
933   cputag_set_input_line_and_vector(device->machine, "fdccpu", 0, HOLD_LINE, fdc_irq_opcode);
934};
935
936949static const struct upd765_interface pc8801_upd765_interface =
937950{
938   DEVCB_LINE(pc8801_upd765_interrupt),
951   DEVCB_CPU_INPUT_LINE("fdccpu", INPUT_LINE_IRQ0),
939952   DEVCB_NULL, //DRQ, TODO
940953   NULL,
941954   UPD765_RDY_PIN_CONNECTED,

Previous 15994 Revisions Next


© 1998-2018 The MESS Team