//static STREAM_UPDATE( ym2612_stream_update ) void ym2612_stream_update(UINT8 ChipID, stream_sample_t **outputs, int samples) { //ym2612_state *info = (ym2612_state *)param; ym2612_state *info = &YM2612Data[ChipID]; #ifdef ENABLE_ALL_CORES int i; #endif switch(EMU_CORE) { case EC_MAME: ym2612_update_one(info->chip, outputs, samples); break; #ifdef ENABLE_ALL_CORES case EC_GENS: YM2612_ClearBuffer(GensBuf, samples); YM2612_Update(info->chip, GensBuf, samples); YM2612_DacAndTimers_Update(info->chip, GensBuf, samples); for (i = 0x00; i < samples; i ++) { outputs[0x00][i] = (stream_sample_t)GensBuf[0x00][i]; outputs[0x01][i] = (stream_sample_t)GensBuf[0x01][i]; } break; #endif } }
/* update request from fm.c */ void ym2612_update_request(void *param) { ym2612_state *info = (ym2612_state *)param; //stream_update(info->stream); switch(EMU_CORE) { case EC_MAME: ym2612_update_one(info->chip, DUMMYBUF, 0); break; #ifdef ENABLE_ALL_CORES case EC_GENS: YM2612_Update(info->chip, DUMMYBUF, 0); YM2612_DacAndTimers_Update(info->chip, DUMMYBUF, 0); break; #endif } }
unsigned char *GYM_Next(unsigned char *gym_start, unsigned char *gym_pos, unsigned int gym_size, unsigned int gym_loop) { unsigned char c, c2; unsigned char dac_data[1600]; int *buf[2]; int dacMax = 0, i = 0; int oldPos = 0; double curPos = 0; double dacSize; int step; int *dacBuf[2]; int retCode = 1; YM_Buf[0] = PSG_Buf[0] = buf[0] = Seg_L; YM_Buf[1] = PSG_Buf[1] = buf[1] = Seg_R; YM_Len = PSG_Len = 0; memset(dac_data, 0, sizeof(dac_data)); if (!gym_pos) { return 0; } if ((unsigned int)(gym_pos - gym_start) >= gym_size) { if (gym_loop) { gym_pos = jump_gym_time_pos(gym_start, gym_size, gym_loop - 1); } else { return 0; } } do { c = *gym_pos++; switch(c) { case 0: if (YM2612_Enable) { // if dacMax is zero, dacSize will be NaN - so what, we won't // be using it in that case anyway :p dacSize = (double)Seg_Lenght / dacMax; for (i = 0; i < dacMax; i++) { oldPos = (int)curPos; YM2612_Write(0, 0x2A); YM2612_Write(1, dac_data[i]); if (i == dacMax - 1) { step = Seg_Lenght - oldPos; } else { curPos += dacSize; step = (int)curPos - oldPos; } dacBuf[0] = buf[0] + (int)oldPos; dacBuf[1] = buf[1] + (int)oldPos; YM2612_DacAndTimers_Update(dacBuf, step); } YM2612_Update(buf, Seg_Lenght); } if (PSG_Enable) { if (PSG_Improv) { PSG_Update_SIN(buf, Seg_Lenght); } else { PSG_Update(buf, Seg_Lenght); } } break; case 1: c2 = *gym_pos++; if (c2 == 0x2A) { c2 = *gym_pos++; dac_data[dacMax++] = c2; } else { YM2612_Write(0, c2); c2 = *gym_pos++; YM2612_Write(1, c2); } break; case 2: c2 = *gym_pos++; YM2612_Write(2, c2); c2 = *gym_pos++; YM2612_Write(3, c2); break; case 3: c2 = *gym_pos++; PSG_Write(c2); break; } } while (c); return gym_pos; }
static inline int T_gens_do_MD_frame(void) { int *buf[2]; int HInt_Counter; // Set the number of visible lines. VDP_SET_VISIBLE_LINES(); YM_Buf[0] = PSG_Buf[0] = Seg_L; YM_Buf[1] = PSG_Buf[1] = Seg_R; YM_Len = PSG_Len = 0; Cycles_M68K = Cycles_Z80 = 0; Last_BUS_REQ_Cnt = -1000; main68k_tripOdometer(); mdZ80_clear_odo(&M_Z80); // Raise the MDP_EVENT_PRE_FRAME event. EventMgr::RaiseEvent(MDP_EVENT_PRE_FRAME, NULL); VRam_Flag = 1; VDP_Status &= 0xFFF7; // Clear V Blank if (VDP_Reg.Set4 & 0x2) VDP_Status ^= 0x0010; HInt_Counter = VDP_Reg.H_Int; // Hint_Counter = step H interrupt for (VDP_Current_Line = 0; VDP_Current_Line < VDP_Num_Vis_Lines; VDP_Current_Line++) { buf[0] = Seg_L + Sound_Extrapol[VDP_Current_Line][0]; buf[1] = Seg_R + Sound_Extrapol[VDP_Current_Line][0]; YM2612_DacAndTimers_Update(buf, Sound_Extrapol[VDP_Current_Line][1]); YM_Len += Sound_Extrapol[VDP_Current_Line][1]; PSG_Len += Sound_Extrapol[VDP_Current_Line][1]; Fix_Controllers(); Cycles_M68K += CPL_M68K; Cycles_Z80 += CPL_Z80; if (DMAT_Length) main68k_addCycles(Update_DMA()); VDP_Status |= 0x0004; // HBlank = 1 main68k_exec (Cycles_M68K - 404); VDP_Status &= 0xFFFB; // HBlank = 0 if (--HInt_Counter < 0) { HInt_Counter = VDP_Reg.H_Int; VDP_Int |= 0x4; VDP_Update_IRQ_Line(); } if (VDP) { // VDP needs to be updated. Render_Line(); } main68k_exec(Cycles_M68K); Z80_EXEC(0); } buf[0] = Seg_L + Sound_Extrapol[VDP_Current_Line][0]; buf[1] = Seg_R + Sound_Extrapol[VDP_Current_Line][0]; YM2612_DacAndTimers_Update (buf, Sound_Extrapol[VDP_Current_Line][1]); YM_Len += Sound_Extrapol[VDP_Current_Line][1]; PSG_Len += Sound_Extrapol[VDP_Current_Line][1]; Fix_Controllers(); Cycles_M68K += CPL_M68K; Cycles_Z80 += CPL_Z80; if (DMAT_Length) main68k_addCycles(Update_DMA()); if (--HInt_Counter < 0) { VDP_Int |= 0x4; VDP_Update_IRQ_Line(); } CONGRATULATIONS_PRECHECK; VDP_Status |= 0x000C; // VBlank = 1 et HBlank = 1 (retour de balayage vertical en cours) main68k_exec(Cycles_M68K - 360); Z80_EXEC(168); CONGRATULATIONS_POSTCHECK; VDP_Status &= 0xFFFB; // HBlank = 0 VDP_Status |= 0x0080; // V Int happened VDP_Int |= 0x8; VDP_Update_IRQ_Line(); mdZ80_interrupt(&M_Z80, 0xFF); main68k_exec(Cycles_M68K); Z80_EXEC(0); for (VDP_Current_Line++; VDP_Current_Line < VDP_Num_Lines; VDP_Current_Line++) { buf[0] = Seg_L + Sound_Extrapol[VDP_Current_Line][0]; buf[1] = Seg_R + Sound_Extrapol[VDP_Current_Line][0]; YM2612_DacAndTimers_Update (buf, Sound_Extrapol[VDP_Current_Line][1]); YM_Len += Sound_Extrapol[VDP_Current_Line][1]; PSG_Len += Sound_Extrapol[VDP_Current_Line][1]; Fix_Controllers(); Cycles_M68K += CPL_M68K; Cycles_Z80 += CPL_Z80; if (DMAT_Length) main68k_addCycles(Update_DMA()); VDP_Status |= 0x0004; // HBlank = 1 main68k_exec(Cycles_M68K - 404); VDP_Status &= 0xFFFB; // HBlank = 0 main68k_exec(Cycles_M68K); Z80_EXEC(0); } PSG_Special_Update(); YM2612_Special_Update(); // If WAV or GYM is being dumped, update the WAV or GYM. // TODO: VGM dumping if (WAV_Dumping) wav_dump_update(); if (GYM_Dumping) gym_dump_update(0, 0, 0); // Raise the MDP_EVENT_POST_FRAME event. mdp_event_post_frame_t post_frame; if (bppMD == 32) post_frame.md_screen = &MD_Screen32[8]; else post_frame.md_screen = &MD_Screen[8]; post_frame.width = (vdp_isH40() ? 320 : 256); post_frame.height = VDP_Num_Vis_Lines; post_frame.pitch = 336; post_frame.bpp = bppMD; EventMgr::RaiseEvent(MDP_EVENT_POST_FRAME, &post_frame); return 1; }