src/mess/drivers/pc8801.c
| r15673 | r15674 | |
| 22 | 22 | |
| 23 | 23 | per-game specific TODO: |
| 24 | 24 | - 177: gameplay is too fast (parent pc8801 only); |
| 25 | | - Acro Jet: hangs waiting for an irq; |
| 25 | - Acro Jet: hangs waiting for an irq (floppy issue); |
| 26 | 26 | - Advanced Fantasian: wants an irq that can't happen (I is equal to 0x3f) |
| 27 | 27 | - American Success: reads the light pen? |
| 28 | | - Alpha (demo): crashes with "illegal function" msg; |
| 29 | | - Aploon: crashes because it doesn't clear irqs when it's supposed to do so; |
| 28 | - Alpha (demo): stuck note in title screen, doesn't seem to go further; |
| 30 | 29 | - Balance of Power: attempt to use the SIO port for mouse polling, worked around for now; |
| 31 | 30 | - Battle Entry: moans with a JP msg then dies if you try to press either numpad 1 or 2 (asks if the user wants to use the sound board (yes 1 / no 2) |
| 32 | 31 | - Bishoujo Baseball Gakuen: checks ym2608 after intro screen; |
| r15673 | r15674 | |
| 162 | 161 | |
| 163 | 162 | //#define USE_PROPER_I8214 |
| 164 | 163 | |
| 164 | |
| 165 | #define IRQ_DEBUG (0) |
| 166 | #define IRQ_LOG(x) do { if (IRQ_DEBUG) printf x; } while (0) |
| 167 | |
| 165 | 168 | #define MASTER_CLOCK XTAL_4MHz |
| 166 | 169 | |
| 167 | 170 | #define I8214_TAG "i8214" |
| r15673 | r15674 | |
| 1049 | 1052 | m_i8214_irq_level = 7; |
| 1050 | 1053 | else |
| 1051 | 1054 | m_i8214_irq_level = data & 7; |
| 1055 | |
| 1056 | IRQ_LOG(("%02x LV\n",m_i8214_irq_level)); |
| 1052 | 1057 | } |
| 1053 | 1058 | |
| 1054 | 1059 | |
| r15673 | r15674 | |
| 1063 | 1068 | if(m_vrtc_irq_mask == 0) |
| 1064 | 1069 | m_vrtc_irq_latch = 0; |
| 1065 | 1070 | |
| 1071 | if(m_timer_irq_mask == 0 && m_vrtc_irq_mask == 0) |
| 1072 | cputag_set_input_line(machine(),"maincpu",0,CLEAR_LINE); |
| 1073 | |
| 1074 | IRQ_LOG(("%02x MASK\n",data)); |
| 1075 | |
| 1066 | 1076 | //if(data & 4) |
| 1067 | 1077 | // printf("IRQ mask %02x\n",data); |
| 1068 | 1078 | } |
| r15673 | r15674 | |
| 1274 | 1284 | WRITE8_MEMBER(pc8801_state::pc8801_pcg8100_w) |
| 1275 | 1285 | { |
| 1276 | 1286 | if(data) |
| 1277 | | printf("Write to PCG-8100 %02x %02x\n",offset,data); |
| 1287 | printf("Write to PCG-8100 %02x %02x\n",offset,data); |
| 1278 | 1288 | } |
| 1279 | 1289 | |
| 1280 | 1290 | /* Balance of Power temp work-around */ |
| r15673 | r15674 | |
| 1566 | 1576 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 1567 | 1577 | AM_RANGE(0xf0, 0xf0) AM_WRITE(fdc_irq_vector_w) // Interrupt Opcode Port |
| 1568 | 1578 | AM_RANGE(0xf4, 0xf4) AM_WRITE(fdc_drive_mode_w) // Drive mode, 2d, 2dd, 2hd |
| 1569 | | // AM_RANGE(0xf7, 0xf7) AM_WRITENOP // printer port output |
| 1579 | AM_RANGE(0xf7, 0xf7) AM_WRITENOP // printer port output |
| 1570 | 1580 | AM_RANGE(0xf8, 0xf8) AM_READWRITE(upd765_tc_r,upd765_mc_w) // (R) Terminal Count Port (W) Motor Control Port |
| 1571 | 1581 | AM_RANGE(0xfa, 0xfa) AM_DEVREAD_LEGACY("upd765", upd765_status_r ) |
| 1572 | 1582 | AM_RANGE(0xfb, 0xfb) AM_DEVREADWRITE_LEGACY("upd765", upd765_data_r, upd765_data_w ) |
| r15673 | r15674 | |
| 1984 | 1994 | } |
| 1985 | 1995 | |
| 1986 | 1996 | #else |
| 1997 | |
| 1998 | #include "debugger.h" |
| 1999 | |
| 1987 | 2000 | static IRQ_CALLBACK( pc8801_irq_callback ) |
| 1988 | 2001 | { |
| 1989 | 2002 | pc8801_state *state = device->machine().driver_data<pc8801_state>(); |
| 1990 | | if(state->m_i8214_irq_level >= 5 && state->m_sound_irq_latch) |
| 2003 | if(state->m_sound_irq_latch) |
| 1991 | 2004 | { |
| 1992 | 2005 | state->m_sound_irq_latch = 0; |
| 1993 | 2006 | return 4*2; |
| 1994 | 2007 | } |
| 1995 | | else if(state->m_i8214_irq_level >= 2 && state->m_vrtc_irq_latch) |
| 2008 | else if(state->m_vrtc_irq_latch) |
| 1996 | 2009 | { |
| 1997 | 2010 | state->m_vrtc_irq_latch = 0; |
| 1998 | 2011 | return 1*2; |
| 1999 | 2012 | } |
| 2000 | | else if(state->m_i8214_irq_level >= 3 && state->m_timer_irq_latch) |
| 2013 | else if(state->m_timer_irq_latch) |
| 2001 | 2014 | { |
| 2002 | 2015 | state->m_timer_irq_latch = 0; |
| 2003 | 2016 | return 2*2; |
| 2004 | 2017 | } |
| 2005 | 2018 | |
| 2006 | 2019 | printf("IRQ triggered but no vector on the bus! %02x %02x %02x %02x\n",state->m_i8214_irq_level,state->m_sound_irq_latch,state->m_vrtc_irq_latch,state->m_timer_irq_latch); |
| 2020 | debugger_break(device->machine()); |
| 2007 | 2021 | |
| 2008 | | return 2*2; //TODO: mustn't happen, it does if you press shift on N88-BASIC |
| 2022 | return 4*2; //TODO: mustn't happen |
| 2009 | 2023 | } |
| 2010 | 2024 | |
| 2011 | 2025 | static void pc8801_sound_irq( device_t *device, int irq ) |
| 2012 | 2026 | { |
| 2013 | 2027 | pc8801_state *state = device->machine().driver_data<pc8801_state>(); |
| 2014 | | if(state->m_sound_irq_mask) |
| 2028 | if(state->m_sound_irq_mask && state->m_i8214_irq_level >= 5 && irq) |
| 2015 | 2029 | { |
| 2016 | | state->m_sound_irq_latch = irq; |
| 2017 | | cputag_set_input_line(device->machine(),"maincpu",0,irq); |
| 2030 | state->m_sound_irq_latch = 1; |
| 2031 | //IRQ_LOG(("sound\n")); |
| 2032 | cputag_set_input_line(device->machine(),"maincpu",0,HOLD_LINE); |
| 2018 | 2033 | } |
| 2019 | 2034 | } |
| 2020 | 2035 | |
| 2021 | 2036 | static TIMER_DEVICE_CALLBACK( pc8801_rtc_irq ) |
| 2022 | 2037 | { |
| 2023 | 2038 | pc8801_state *state = timer.machine().driver_data<pc8801_state>(); |
| 2024 | | if(state->m_timer_irq_mask) |
| 2039 | if(state->m_timer_irq_mask && state->m_i8214_irq_level >= 3) |
| 2025 | 2040 | { |
| 2026 | 2041 | state->m_timer_irq_latch = 1; |
| 2042 | //IRQ_LOG(("timer\n")); |
| 2027 | 2043 | cputag_set_input_line(timer.machine(),"maincpu",0,HOLD_LINE); |
| 2028 | 2044 | } |
| 2029 | 2045 | } |
| r15673 | r15674 | |
| 2031 | 2047 | static INTERRUPT_GEN( pc8801_vrtc_irq ) |
| 2032 | 2048 | { |
| 2033 | 2049 | pc8801_state *state = device->machine().driver_data<pc8801_state>(); |
| 2034 | | if(state->m_vrtc_irq_mask) |
| 2050 | if(state->m_vrtc_irq_mask && state->m_i8214_irq_level >= 2) |
| 2035 | 2051 | { |
| 2036 | 2052 | state->m_vrtc_irq_latch = 1; |
| 2053 | //IRQ_LOG(("vrtc\n")); |
| 2037 | 2054 | device_set_input_line(device,0,HOLD_LINE); |
| 2038 | 2055 | } |
| 2039 | 2056 | } |