LOCALPROC SixtiethSecondNotify(void) { #if dbglog_HAVE && 0 dbglog_WriteNote("begin new Sixtieth"); #endif Mouse_Update(); InterruptReset_Update(); #if EmClassicKbrd KeyBoard_Update(); #endif #if EmADB ADB_Update(); #endif Sixtieth_PulseNtfy(); /* Vertical Blanking Interrupt */ Sony_Update(); #if EmLocalTalk LocalTalkTick(); #endif #if EmRTC RTC_Interrupt(); #endif #if EmVidCard Vid_Update(); #endif SubTickTaskStart(); }
LOCALPROC SixtiethEndNotify(void) { SubTickTaskEnd(); Mouse_EndTickNotify(); Screen_EndTickNotify(); #if dbglog_HAVE && 0 dbglog_WriteNote("end Sixtieth"); #endif }
GLOBALFUNC ui5b ASC_Access(ui5b Data, blnr WriteMem, CPTR addr) { if (addr < 0x800) { if (WriteMem) { if (1 == SoundReg801) { if (0 == (addr & 0x400)) { if (((ui4b)(ASC_FIFO_InA - ASC_FIFO_Out)) >= 0x400) { #if 0 /* seems to happen in tetris */ ReportAbnormal("ASC - Channel A Overflow"); #endif SoundReg804 |= 0x02; } else { ASC_SampBuff[ASC_FIFO_InA & 0x3FF] = Data; ++ASC_FIFO_InA; if (((ui4b)(ASC_FIFO_InA - ASC_FIFO_Out)) >= 0x200) { if (0 != (SoundReg804 & 0x01)) { /* happens normally */ SoundReg804 &= ~ 0x01; } } else { #if 0 /* doesn't seem to be necessary, but doesn't hurt either */ SoundReg804 |= 0x01; #endif } if (((ui4b)(ASC_FIFO_InA - ASC_FIFO_Out)) >= 0x400) { SoundReg804 |= 0x02; #if ASC_dolog dbglog_WriteNote("ASC : setting full flag A"); #endif } else { if (0 != (SoundReg804 & 0x02)) { ReportAbnormal("ASC_Access : " "full flag A not already clear"); SoundReg804 &= ~ 0x02; } } } } else { if (0 == (SoundReg802 & 2)) { ReportAbnormal("ASC - Channel B for Mono"); } if (((ui4b)(ASC_FIFO_InB - ASC_FIFO_Out)) >= 0x400) { ReportAbnormal("ASC - Channel B Overflow"); SoundReg804 |= 0x08; } else { ASC_SampBuff[0x400 + (ASC_FIFO_InB & 0x3FF)] = Data; ++ASC_FIFO_InB; if (((ui4b)(ASC_FIFO_InB - ASC_FIFO_Out)) >= 0x200) { if (0 != (SoundReg804 & 0x04)) { /* happens normally */ SoundReg804 &= ~ 0x04; } } else { #if 0 /* doesn't seem to be necessary, but doesn't hurt either */ SoundReg804 |= 0x04; #endif } if (((ui4b)(ASC_FIFO_InB - ASC_FIFO_Out)) >= 0x400) { SoundReg804 |= 0x08; #if ASC_dolog dbglog_WriteNote("ASC : setting full flag B"); #endif } else { if (0 != (SoundReg804 & 0x08)) { ReportAbnormal("ASC_Access : " "full flag B not already clear"); SoundReg804 &= ~ 0x08; } } } } #if ASC_dolog && 0 dbglog_writeCStr("ASC_InputIndex ="); dbglog_writeNum(ASC_InputIndex); dbglog_writeReturn(); #endif } else { ASC_SampBuff[addr] = Data; } } else { Data = ASC_SampBuff[addr]; } #if ASC_dolog && 1 #if 0 if (((addr & 0x1FF) >= 0x04) && ((addr & 0x1FF) < (0x200 - 0x04))) { /* don't report them all */ } else #endif { dbglog_AddrAccess("ASC_Access SampBuff", Data, WriteMem, addr); } #endif } else if (addr < 0x810) { switch (addr) { case 0x800: /* VERSION */ if (WriteMem) { ReportAbnormal("ASC - writing VERSION"); } else { Data = 0; } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (VERSION)", Data, WriteMem, addr); #endif break; case 0x801: /* ENABLE */ if (WriteMem) { if (1 == Data) { if (1 != SoundReg801) { ASC_ClearFIFO(); } } else { if (Data > 2) { ReportAbnormal("ASC - unexpected ENABLE"); } } SoundReg801 = Data; } else { Data = SoundReg801; /* happens in LodeRunner */ } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (ENABLE)", Data, WriteMem, addr); #endif break; case 0x802: /* CONTROL */ if (WriteMem) { #if 1 if (0 != SoundReg801) { if (SoundReg802 == Data) { /* this happens normally, such as in Lunar Phantom */ } else { if (1 == SoundReg801) { /* happens in dark castle, if play other sound first, such as by changing beep sound in sound control panel. */ ASC_ClearFIFO(); } #if 0 ReportAbnormal( "ASC - changing CONTROL while ENABLEd"); #endif } } #endif if (0 != (Data & ~ 2)) { ReportAbnormal( "ASC - unexpected CONTROL value"); } SoundReg802 = Data; } else { Data = SoundReg802; ReportAbnormal( "ASC - reading CONTROL value"); } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (CONTROL)", Data, WriteMem, addr); #endif break; case 0x803: if (WriteMem) { if (0 != (Data & ~ 0x80)) { ReportAbnormal( "ASC - unexpected FIFO MODE"); } if (0 != (Data & 0x80)) { if (0 != (SoundReg803 & 0x80)) { ReportAbnormal( "ASC - set clear FIFO again"); } else if (1 != SoundReg801) { #if 0 /* happens in system 6, such as with Lunar Phantom */ ReportAbnormal( "ASC - clear FIFO when not FIFO mode"); #endif } else { ASC_ClearFIFO(); /* ASC_interrupt_PulseNtfy(); Doesn't seem to be needed, but doesn't hurt either. */ } } SoundReg803 = Data; } else { Data = SoundReg803; } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (FIFO MODE)", Data, WriteMem, addr); #endif break; case 0x804: if (WriteMem) { #if 0 if ((0 != SoundReg804) && (0 != Data)) { ReportAbnormal( "ASC - set FIFO IRQ STATUS when not 0"); } #endif SoundReg804 = Data; if (0 != SoundReg804) { ASC_interrupt_PulseNtfy(); /* Generating this interrupt seems to be the point of writing to this register. */ } #if ASC_dolog && 1 dbglog_AddrAccess( "ASC_Access Control (FIFO IRQ STATUS)", Data, WriteMem, addr); #endif } else { Data = SoundReg804; #if 0 if (1 != SoundReg801) { /* no, ok, part of normal interrupt handling */ ReportAbnormal( "ASC - read STATUS when not FIFO"); } #endif /* SoundReg804 = 0; */ SoundReg804 &= ~ 0x01; SoundReg804 &= ~ 0x04; /* In lunar phantom, observe checking full flag before first write, but status was read previous. */ #if ASC_dolog && 1 #if 0 if (0 != Data) #endif { dbglog_AddrAccess( "ASC_Access Control (FIFO IRQ STATUS)", Data, WriteMem, addr); } #endif } break; case 0x805: if (WriteMem) { SoundReg805 = Data; /* cleared in LodeRunner */ } else { Data = SoundReg805; ReportAbnormal( "ASC - readingWAVE CONTROL register"); } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (WAVE CONTROL)", Data, WriteMem, addr); #endif break; case 0x806: /* VOLUME */ if (WriteMem) { SoundReg_Volume = Data >> 5; if (0 != (Data & 0x1F)) { ReportAbnormal("ASC - unexpected volume value"); } } else { Data = SoundReg_Volume << 5; ReportAbnormal("ASC - reading volume register"); } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (VOLUME)", Data, WriteMem, addr); #endif break; case 0x807: /* CLOCK RATE */ if (WriteMem) { /* SoundReg807 = Data; */ if (0 != Data) { ReportAbnormal("ASC - nonstandard CLOCK RATE"); } } else { /* Data = SoundReg807; */ ReportAbnormal("ASC - reading CLOCK RATE"); } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (CLOCK RATE)", Data, WriteMem, addr); #endif break; case 0x808: /* CONTROL */ if (WriteMem) { ReportAbnormal("ASC - write to 808"); } else { /* happens on boot System 7.5.5 */ Data = 0; } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (CONTROL)", Data, WriteMem, addr); #endif break; case 0x80A: /* ? */ if (WriteMem) { ReportAbnormal("ASC - write to 80A"); } else { /* happens in system 6, Lunar Phantom, soon after new game. */ Data = 0; } #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (80A)", Data, WriteMem, addr); #endif break; default: if (WriteMem) { } else { Data = 0; } ReportAbnormal("ASC - unknown ASC reg"); #if ASC_dolog && 1 dbglog_AddrAccess("ASC_Access Control (?)", Data, WriteMem, addr); #endif break; } } else if (addr < 0x830) {