1 /******************************************************************************/
2 /* Mednafen Sega Saturn Emulation Module                                      */
3 /******************************************************************************/
4 /* scu_dsp_misc.cpp - SCU DSP Miscellaneous Instructions Emulation
5 **  Copyright (C) 2015-2018 Mednafen Team
6 **
7 ** This program is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU General Public License
9 ** as published by the Free Software Foundation; either version 2
10 ** of the License, or (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software Foundation, Inc.,
19 ** 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 */
21 
22 #include "ss.h"
23 #include "scu.h"
24 
25 #pragma GCC optimize("Os")
26 
27 namespace MDFN_IEN_SS
28 {
29 #include "scu_dsp_common.inc"
30 
31 template<bool looped, unsigned op>
MiscInstr(void)32 static NO_INLINE NO_CLONE void MiscInstr(void)
33 {
34  DSP_InstrPre<looped>();
35 
36  //
37  // END/ENDI
38  //
39  if(op == 2 || op == 3)
40  {
41   if(op & 0x1)
42   {
43    DSP.FlagEnd = true;
44    SCU_SetInt(SCU_INT_DSP, true);
45   }
46 
47   if(DSP.PRAMDMABufCount)
48    DSP_FinishPRAMDMA();
49   else
50   {
51    DSP.State &= ~DSPS::STATE_MASK_EXECUTE;
52    DSP.CycleCounter -= DSP_EndCCSubVal;	// Break out of execution loop(also remember to handle this case for manual stepping via port writes).
53   }
54  }
55  else if(op == 0)	// BTM
56  {
57   if(DSP.LOP)
58    DSP.PC = DSP.TOP;
59 
60   DSP.LOP = (DSP.LOP - 1) & 0x0FFF;
61  }
62  else if(op == 1)	// LPS
63  {
64   DSP.NextInstr = DSP_DecodeInstruction<true>(DSP.NextInstr >> 32);
65  }
66 }
67 
68 MDFN_HIDE extern void (*const DSP_MiscFuncTable[2][4])(void) =
69 {
70  #include "scu_dsp_misctab.inc"
71 };
72 
73 }
74