Example #1
0
static INT32 DrvFrame()
{
	INT32 nCyclesVBlank;
	INT32 nInterleave = 8;

	if (DrvReset) {														// Reset machine
		DrvDoReset();
	}

	// Compile digital inputs
	DrvInput[0] = 0;  												// Player 1
	DrvInput[1] = 0;  												// Player 2
	for (INT32 i = 0; i < 16; i++) {
		DrvInput[0] |= (DrvJoy1[i] & 1) << i;
		DrvInput[1] |= (DrvJoy2[i] & 1) << i;
	}
	CaveClearOpposites(&DrvInput[0]);
	CaveClearOpposites(&DrvInput[1]);
	DrvInput[0] ^= 0xffff;
	DrvInput[1] ^= 0xffff;  

	SekNewFrame();

	nCyclesTotal[0] = (INT32)((INT64)16000000 * nBurnCPUSpeedAdjust / (0x0100 * CAVE_REFRESHRATE));
	nCyclesDone[0] = 0;

	nCyclesVBlank = nCyclesTotal[0] - (INT32)((nCyclesTotal[0] * CAVE_VBLANK_LINES) / 271.5);
	bVBlank = false;

	INT32 nSoundBufferPos = 0;

	SekOpen(0);

	for (INT32 i = 1; i <= nInterleave; i++) {
		INT32 nNext;

		// Render sound segment
		if ((i & 1) == 0) {
			if (pBurnSoundOut) {
				INT32 nSegmentEnd = nBurnSoundLen * i / nInterleave;
				INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
				YMZ280BRender(pSoundBuf, nSegmentEnd - nSoundBufferPos);
				nSoundBufferPos = nSegmentEnd;
			}
		}

		// Run 68000
		nCurrentCPU = 0;
		nNext = i * nCyclesTotal[nCurrentCPU] / nInterleave;

		// See if we need to trigger the VBlank interrupt
		if (!bVBlank && nNext > nCyclesVBlank) {
			if (nCyclesDone[nCurrentCPU] < nCyclesVBlank) {
				nCyclesSegment = nCyclesVBlank - nCyclesDone[nCurrentCPU];
				if (!CheckSleep(nCurrentCPU)) {							// See if this CPU is busywaiting
					nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
				} else {
					nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment);
				}
			}

			if (pBurnDraw != NULL) {
				DrvDraw();												// Draw screen if needed
			}

			bVBlank = true;
			nVideoIRQ = 0;
			UpdateIRQStatus();
		}

		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
		if (!CheckSleep(nCurrentCPU)) {									// See if this CPU is busywaiting
			nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
		} else {
			nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment);
		}

		nCurrentCPU = -1;
	}

	{
		// Make sure the buffer is entirely filled.
		if (pBurnSoundOut) {
			INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
			INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
			if (nSegmentLength) {
				YMZ280BRender(pSoundBuf, nSegmentLength);
			}
		}
	}

	SekClose();

	return 0;
}
Example #2
0
static int DrvFrame()
{
	int nCyclesVBlank;
	int nInterleave = 8;

	int nCyclesTotal[2];
	int nCyclesDone[2];

	int nCyclesSegment;

	if (DrvReset) {														// Reset machine
		DrvDoReset();
	}

	// Compile digital inputs
	DrvInput[0] = 0x0000;  												// Player 1
	DrvInput[1] = 0x0000;  												// Player 2
	for (int i = 0; i < 10; i++) {
		DrvInput[0] |= (DrvJoy1[i] & 1) << i;
		DrvInput[1] |= (DrvJoy2[i] & 1) << i;
	}
	CaveClearOpposites(&DrvInput[0]);
	CaveClearOpposites(&DrvInput[1]);

	SekNewFrame();

	nCyclesTotal[0] = (int)((long long)16000000 * nBurnCPUSpeedAdjust / (0x0100 * CAVE_REFRESHRATE));
	nCyclesDone[0] = 0;

	nCyclesVBlank = nCyclesTotal[0] - (int)((nCyclesTotal[0] * CAVE_VBLANK_LINES) / 271.5);
	bVBlank = false;

	int nSoundBufferPos = 0;

	SekOpen(0);

	for (int i = 1; i <= nInterleave; i++) {
    	int nCurrentCPU = 0;
		int nNext = i * nCyclesTotal[nCurrentCPU] / nInterleave;

		// Run 68000

		// See if we need to trigger the VBlank interrupt
		if (!bVBlank && nNext > nCyclesVBlank) {
			if (nCyclesDone[nCurrentCPU] < nCyclesVBlank) {
				nCyclesSegment = nCyclesVBlank - nCyclesDone[nCurrentCPU];
				if (!CheckSleep(nCurrentCPU)) {							// See if this CPU is busywaiting
					nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
				} else {
					nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment);
				}
			}

			if (pBurnDraw != NULL) {
				DrvDraw();												// Draw screen if needed
			}

			bVBlank = true;
			nVideoIRQ = 0;
			UpdateIRQStatus();
		}

		nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
		if (!CheckSleep(nCurrentCPU)) {									// See if this CPU is busywaiting
			nCyclesDone[nCurrentCPU] += SekRun(nCyclesSegment);
		} else {
			nCyclesDone[nCurrentCPU] += SekIdle(nCyclesSegment);
		}
	}

	// Make sure the buffer is entirely filled.
	{
		if (pBurnSoundOut) {
			int nSegmentLength = nBurnSoundLen - nSoundBufferPos;
			short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
			if (nSegmentLength) {
				MSM6295Render(0, pSoundBuf, nSegmentLength);
				MSM6295Render(1, pSoundBuf, nSegmentLength);
			}
		}
	}

	SekClose();

	return 0;
}
Example #3
0
static INT32 DrvFrame()
{
	INT32 nCyclesVBlank;
	INT32 nInterleave = 8;
    
	if (DrvReset) {														// Reset machine
        //HACK
        wait_control=60;
        glob_framecpt=0;
        glob_replay_last_dx16=glob_replay_last_dy16=0;
        glob_replay_last_fingerOn=0;
        //
		DrvDoReset();
	}
    
    //	bprintf(PRINT_NORMAL, "\n");
    
    if (glob_replay_mode==REPLAY_PLAYBACK_MODE) { //REPLAY
        unsigned int next_frame_event;
        next_frame_event=(unsigned int)(glob_replay_data_stream[glob_replay_data_index])|((unsigned int)(glob_replay_data_stream[glob_replay_data_index+1])<<8)
        |((unsigned int)(glob_replay_data_stream[glob_replay_data_index+2])<<16)|((unsigned int)(glob_replay_data_stream[glob_replay_data_index+3])<<24);
        
        
        if (glob_framecpt==next_frame_event) {
            glob_replay_data_index+=4;
            glob_replay_flag=glob_replay_data_stream[glob_replay_data_index++];
            if (glob_replay_flag&REPLAY_FLAG_TOUCHONOFF) {
                glob_replay_last_fingerOn^=1;
            }
            if (glob_replay_flag&REPLAY_FLAG_POSX) {
                glob_replay_last_dx16=(unsigned int)(glob_replay_data_stream[glob_replay_data_index])|((unsigned int)(glob_replay_data_stream[glob_replay_data_index+1])<<8);
                glob_replay_data_index+=2;
            }
            if (glob_replay_flag&REPLAY_FLAG_POSY) {
                glob_replay_last_dy16=(unsigned int)(glob_replay_data_stream[glob_replay_data_index])|((unsigned int)(glob_replay_data_stream[glob_replay_data_index+1])<<8);
                glob_replay_data_index+=2;
            }
            if (glob_replay_flag&REPLAY_FLAG_IN0) {
                last_DrvInput[0]=(unsigned int)(glob_replay_data_stream[glob_replay_data_index])|((unsigned int)(glob_replay_data_stream[glob_replay_data_index+1])<<8);
                glob_replay_data_index+=2;
            }
            if (glob_replay_flag&REPLAY_FLAG_IN1) {
                last_DrvInput[1]=(unsigned int)(glob_replay_data_stream[glob_replay_data_index])|((unsigned int)(glob_replay_data_stream[glob_replay_data_index+1])<<8);
                glob_replay_data_index+=2;
            }
        }
        DrvInput[0]=last_DrvInput[0];
        DrvInput[1]=last_DrvInput[1];
        
    } else {
        // Compile digital inputs
        DrvInput[0] = 0x0000;  												// Player 1
        DrvInput[1] = 0x0000;  												// Player 2
        for (INT32 i = 0; i < 10; i++) {
            DrvInput[0] |= (DrvJoy1[i] & 1) << i;
            DrvInput[1] |= (DrvJoy2[i] & 1) << i;
        }
        
        //HACK
        if (glob_ffingeron&&virtual_stick_on) {
            if (glob_mov_y>0) DrvInput[0]|=1;
            if (glob_mov_y<0) DrvInput[0]|=2;
            if (glob_mov_x<0) DrvInput[0]|=4;
            if (glob_mov_x>0) DrvInput[0]|=8;
            
            if (cur_ifba_conf->vpad_followfinger_firemode==0) {
            DrvInput[0]&=~((1<<4)); //clear fire 1
            if (glob_shooton) {
                switch (glob_shootmode) {
                    case 0: //shoot
                        if ((glob_autofirecpt%10)==0) DrvInput[0]|=1<<4;
                        glob_autofirecpt++;
                        break;
                    case 1: //laser
                        DrvInput[0]|=1<<4;
                        break;
                }
            }
            }
        }
        //
        CaveClearOpposites(&DrvInput[0]);
        CaveClearOpposites(&DrvInput[1]);
        
        //HACK
        //replay data - drvinputs
        
        if ((glob_replay_mode==REPLAY_RECORD_MODE)&&(glob_replay_data_index<MAX_REPLAY_DATA_BYTES-MAX_REPLAY_FRAME_SIZE)) {//SAVE REPLAY
            glob_replay_flag=0;
            if (glob_framecpt==0) {//first frame
                //STORE FRAME_INDEX (0)
                glob_replay_data_stream[glob_replay_data_index++]=glob_framecpt&0xFF; //frame index
                glob_replay_data_stream[glob_replay_data_index++]=(glob_framecpt>>8)&0xFF; //frame index
                glob_replay_data_stream[glob_replay_data_index++]=(glob_framecpt>>16)&0xFF; //frame index
                glob_replay_data_stream[glob_replay_data_index++]=(glob_framecpt>>24)&0xFF; //frame index
                //STORE FLAG (00001100b)
                glob_replay_data_stream[glob_replay_data_index++]=REPLAY_FLAG_IN0|REPLAY_FLAG_IN1;
                //STORE INPUT0 & INPUT1
                glob_replay_data_stream[glob_replay_data_index++]=DrvInput[0]&0xFF;
                glob_replay_data_stream[glob_replay_data_index++]=(DrvInput[0]>>8)&0xFF;
                glob_replay_data_stream[glob_replay_data_index++]=DrvInput[1]&0xFF;
                glob_replay_data_stream[glob_replay_data_index++]=(DrvInput[1]>>8)&0xFF;
                
                last_DrvInput[0]=DrvInput[0];
                last_DrvInput[1]=DrvInput[1];
            } else {
                
                if (last_DrvInput[0]!=DrvInput[0]) {