Previous 15994 Revisions Next

r8847 Sunday 22nd August, 2010 at 07:55:51 UTC by Miodrag Milanović
Another sync with MAME
[src/emu]addrmap.h diexec.c diexec.h drawgfxm.h emu.h inptport.c input.c machine.c machine.h memory.c profiler.c profiler.h schedule.c sound.c streams.c tilemap.c timer.c ui.c uiinput.c video.c
[src/emu/cpu/dsp56k]inst.h tables.c tables.h
[src/emu/cpu/mips]mips3drc.c
[src/emu/cpu/powerpc]ppcdrc.c
[src/emu/cpu/rsp]rspdrc.c
[src/emu/cpu/sh2]sh2comn.c sh2drc.c
[src/emu/video]vooddefs.h voodoo.c voodoo.h
[src/mame/machine]n64.c
[src/mame/video]dc.c jaguar.c ppu2c0x.c snes.c stvvdp2.c
[src/mess/machine]apple2.c
[src/mess/video]gb.c

src/mame/machine/n64.c
r8846r8847
764764
765765      case 0x04/4:      // DP_END_REG
766766         state->m_rdp.SetEndReg(data);
767         profiler_mark_start(PROFILER_USER1);
767         g_profiler.start(PROFILER_USER1);
768768         state->m_rdp.ProcessList();
769         profiler_mark_end();
769         g_profiler.stop();
770770         break;
771771
772772      case 0x0c/4:      // DP_STATUS_REG
src/mame/video/stvvdp2.c
r8846r8847
49124912      stv2_current_tilemap.window_control = 0;
49134913      fade_control = stv2_current_tilemap.fade_control;
49144914      stv2_current_tilemap.fade_control = 0;
4915      profiler_mark_start(PROFILER_USER1);
4915      g_profiler.start(PROFILER_USER1);
49164916      if ( LOG_VDP2 ) logerror( "Checking for cached RBG bitmap, cache_dirty = %d, memcmp() = %d\n", stv_rbg_cache_data.is_cache_dirty, memcmp(&stv_rbg_cache_data.layer_data[iRP-1],&stv2_current_tilemap,sizeof(stv2_current_tilemap)));
49174917      if ( (stv_rbg_cache_data.is_cache_dirty & iRP) ||
49184918         memcmp(&stv_rbg_cache_data.layer_data[iRP-1],&stv2_current_tilemap,sizeof(stv2_current_tilemap)) != 0 )
r8846r8847
49314931            stv_rbg_cache_data.map_offset_max[iRP-1], stv_rbg_cache_data.tile_offset_min[iRP-1], stv_rbg_cache_data.tile_offset_max[iRP-1] );
49324932      }
49334933
4934      profiler_mark_end();
4934      g_profiler.stop();
49354935
49364936      stv2_current_tilemap.colour_calculation_enabled = colour_calculation_enabled;
49374937      if ( colour_calculation_enabled )
r8846r8847
49524952
49534953      stv2_current_tilemap.fade_control = fade_control;
49544954
4955      profiler_mark_start(PROFILER_USER2);
4955      g_profiler.start(PROFILER_USER2);
49564956      stv_vdp2_copy_roz_bitmap(bitmap, stv_vdp2_roz_bitmap[iRP-1], &mycliprect, iRP, planesizex, planesizey, planerenderedsizex, planerenderedsizey );
4957      profiler_mark_end();
4957      g_profiler.stop();
49584958   }
49594959
49604960}
src/mame/video/dc.c
r8846r8847
10751075      }
10761076      break;
10771077   case STARTRENDER:
1078      profiler_mark_start(PROFILER_USER1);
1078      g_profiler.start(PROFILER_USER1);
10791079      #if DEBUG_PVRTA
10801080      mame_printf_verbose("Start Render Received:\n");
10811081      mame_printf_verbose("  Region Array at %08x\n",pvrta_regs[REGION_BASE]);
r8846r8847
12371237         state_ta.grab[state_ta.grabsel].verts_size=0;
12381238         state_ta.grab[state_ta.grabsel].strips_size=0;
12391239
1240         profiler_mark_end();
1240         g_profiler.stop();
12411241      }
12421242      break;
12431243//#define TA_YUV_TEX_BASE       ((0x005f8148-0x005f8000)/4)
src/mame/video/snes.c
r8846r8847
15081508   UINT16 prev_colour = 0;
15091509   int blurring = input_port_read_safe(machine, "OPTIONS", 0) & 0x01;
15101510
1511   profiler_mark_start(PROFILER_VIDEO);
1511   g_profiler.start(PROFILER_VIDEO);
15121512
15131513   if (snes_ppu.screen_disabled) /* screen is forced blank */
15141514      for (x = 0; x < SNES_SCR_WIDTH * 2; x++)
r8846r8847
15561556#ifdef SNES_LAYER_DEBUG
15571557      if (snes_dbg_video(machine, curline))
15581558      {
1559         profiler_mark_end();
1559         g_profiler.stop();
15601560         return;
15611561      }
15621562
r8846r8847
16541654      }
16551655   }
16561656
1657   profiler_mark_end();
1657   g_profiler.stop();
16581658}
16591659
16601660VIDEO_START( snes )
src/mame/video/jaguar.c
r8846r8847
511511   UINT32 a1flags = blitter_regs[A1_FLAGS] & STATIC_FLAGS_MASK;
512512   UINT32 a2flags = blitter_regs[A2_FLAGS] & STATIC_FLAGS_MASK;
513513
514   profiler_mark_start(PROFILER_USER1);
514   g_profiler.start(PROFILER_USER1);
515515
516516   if (a1flags == a2flags)
517517   {
r8846r8847
600600}
601601
602602   generic_blitter(machine, blitter_regs[B_CMD], blitter_regs[A1_FLAGS], blitter_regs[A2_FLAGS]);
603   profiler_mark_end();
603   g_profiler.stop();
604604}
605605
606606static TIMER_CALLBACK( blitter_done )
src/mame/video/ppu2c0x.c
r8846r8847
717717   int *ppu_regs = &ppu2c0x->regs[0];
718718
719719   /* lets see how long it takes */
720   profiler_mark_start(PROFILER_USER1);
720   g_profiler.start(PROFILER_USER1);
721721
722722   /* clear the line priority for this scanline */
723723   memset(line_priority, 0, VISIBLE_SCREEN_WIDTH);
r8846r8847
751751   draw_sprites(device, line_priority);
752752
753753   /* done updating, whew */
754   profiler_mark_end();
754   g_profiler.stop();
755755}
756756
757757static void update_scanline( running_device *device )
src/emu/cpu/dsp56k/tables.c
r8846r8847
2424   return BBB_INVALID;
2525}
2626
27void decode_cccc_table(const UINT16 cccc, std::string& mnemonic)
27void decode_cccc_table(const UINT16 cccc, op_mnem& mnemonic)
2828{
2929   switch (cccc)
3030   {
31      case 0x0: mnemonic = "cc"; break;
32      case 0x1: mnemonic = "ge"; break;
33      case 0x2: mnemonic = "ne"; break;
34      case 0x3: mnemonic = "pl"; break;
35      case 0x4: mnemonic = "nn"; break;
36      case 0x5: mnemonic = "ec"; break;
37      case 0x6: mnemonic = "lc"; break;
38      case 0x7: mnemonic = "gt"; break;
39      case 0x8: mnemonic = "cs"; break;
40      case 0x9: mnemonic = "lt"; break;
41      case 0xa: mnemonic = "eq"; break;
42      case 0xb: mnemonic = "mi"; break;
43      case 0xc: mnemonic = "nr"; break;
44      case 0xd: mnemonic = "es"; break;
45      case 0xe: mnemonic = "ls"; break;
46      case 0xf: mnemonic = "le"; break;
31      case 0x0: mnemonic = oCC; break;
32      case 0x1: mnemonic = oGE; break;
33      case 0x2: mnemonic = oNE; break;
34      case 0x3: mnemonic = oPL; break;
35      case 0x4: mnemonic = oNN; break;
36      case 0x5: mnemonic = oEC; break;
37      case 0x6: mnemonic = oLC; break;
38      case 0x7: mnemonic = oGT; break;
39      case 0x8: mnemonic = oCS; break;
40      case 0x9: mnemonic = oLT; break;
41      case 0xa: mnemonic = oEQ; break;
42      case 0xb: mnemonic = oMI; break;
43      case 0xc: mnemonic = oNR; break;
44      case 0xd: mnemonic = oES; break;
45      case 0xe: mnemonic = oLS; break;
46      case 0xf: mnemonic = oLE; break;
4747   }
4848
4949// NEW //   switch (cccc)
r8846r8847
412412    }
413413}
414414
415void decode_s_table(const UINT16 s, std::string& arithmetic)
415void decode_s_table(const UINT16 s, op_mnem& arithmetic)
416416{
417417   switch(s)
418418   {
419      case 0x0: arithmetic = "su"; break;
420      case 0x1: arithmetic = "uu"; break;
419      case 0x0: arithmetic = oSU; break;
420      case 0x1: arithmetic = oUU; break;
421421   }
422422}
423423
424void decode_ss_table(const UINT16 ss, std::string& arithmetic)
424void decode_ss_table(const UINT16 ss, op_mnem& arithmetic)
425425{
426426   switch(ss)
427427   {
428      case 0x0: arithmetic = "ss"; break;
429      case 0x1: arithmetic = "!!"; break;
430     //case 0x1: arithmetic = "ss"; break;
431      case 0x2: arithmetic = "su"; break;
432      case 0x3: arithmetic = "uu"; break;
428      case 0x0: arithmetic = oSS; break;
429      case 0x1: arithmetic = oINVALID; break;
430      // NEW // case 0x1: arithmetic = "ss"; break;
431      case 0x2: arithmetic = oSU; break;
432      case 0x3: arithmetic = oUU; break;
433433   }
434434}
435435
r8846r8847
801801    return "INVALID_REG_ID";
802802}
803803
804std::string opMnemonicAsString(const op_mnem& mnem)
805{
806    switch(mnem)
807    {
808        case oCC: return "cc"; break;
809        case oGE: return "ge"; break;
810        case oNE: return "ne"; break;
811        case oPL: return "pl"; break;
812        case oNN: return "nn"; break;
813        case oEC: return "ec"; break;
814        case oLC: return "lc"; break;
815        case oGT: return "gt"; break;
816        case oCS: return "cs"; break;
817        case oLT: return "lt"; break;
818        case oEQ: return "eq"; break;
819        case oMI: return "mi"; break;
820        case oNR: return "nr"; break;
821        case oES: return "es"; break;
822        case oLS: return "ls"; break;
823        case oLE: return "le"; break;
824       
825        case oSS: return "ss"; break;
826        case oSU: return "su"; break;
827        case oUU: return "uu"; break;
828        case oINVALID: return "!!"; break;
829    }
830   
831    return "INVALID_OPCODE_MNEMONIC";
832}
833
804834reg_id stringAsRegID(const std::string& str)
805835{
806836    if (str == "X") return iX;
src/emu/cpu/dsp56k/tables.h
r8846r8847
2626             iLC, iSR, iOMR, iSP, iSSH, iSSL, iLA, iMR, iCCR,
2727             iF, iFHAT,
2828             iINVALID, iWEIRD};
29               
3029
30enum op_mnem {oCC, oGE, oNE, oPL,
31              oNN, oEC, oLC, oGT,
32              oCS, oLT, oEQ, oMI,
33              oNR, oES, oLS, oLE,
34              oSS, oSU, oUU, oINVALID};
3135
36
3237bfShift decode_BBB_table(UINT16 BBB);
33void decode_cccc_table(const UINT16 cccc, std::string& mnemonic);
38void decode_cccc_table(const UINT16 cccc, op_mnem& mnemonic);
3439void decode_DDDDD_table(const UINT16 DDDDD, reg_id& SD);
3540void decode_DD_table(const UINT16 DD, reg_id& SD);
3641void decode_DDF_table(const UINT16 DD, const UINT16 F, reg_id& S, reg_id& D);
r8846r8847
5257void decode_QQQF_table(const UINT16 QQQ, const UINT16 F, reg_id& S1, reg_id& S2, reg_id& D);
5358void decode_RR_table(UINT16 RR, reg_id& ret);
5459void decode_rr_table(UINT16 rr, reg_id& ret);
55void decode_s_table(const UINT16 s, std::string& arithmetic);
56void decode_ss_table(const UINT16 ss, std::string& arithmetic);
60void decode_s_table(const UINT16 s, op_mnem& arithmetic);
61void decode_ss_table(const UINT16 ss, op_mnem& arithmetic);
5762void decode_uuuuF_table(const UINT16 uuuu, const UINT16 F, std::string& arg, reg_id& S, reg_id& D);
5863void decode_Z_table(const UINT16 Z, std::string& ea);
5964
r8846r8847
8085void setReg16(dsp56k_core* cpustate, const UINT16& value, const reg_id& reg);
8186
8287std::string regIdAsString(const reg_id& regId);
88std::string opMnemonicAsString(const op_mnem& mnem);
8389reg_id stringAsRegID(const std::string& str);
8490UINT8 regIDAsNum(const reg_id& regId);
8591
src/emu/cpu/dsp56k/inst.h
r8846r8847
2626   Instruction(const Opcode* oco) : m_valid(false),
2727                            m_oco(oco),
2828                            m_sizeIncrement(0),
29                            m_opcode(""),
3029                            m_source(iINVALID),
3130                            m_destination(iINVALID) { }
3231   virtual ~Instruction() {}
r8846r8847
5857   size_t m_sizeIncrement;
5958
6059   // Parameters nearly everyone has
61   std::string m_opcode;
6260   reg_id m_source;
6361   reg_id m_destination;
6462};
r8846r8847
7977   bool decode(const UINT16 word0, const UINT16 word1)
8078   {
8179      decode_F_table(BITSn(word0,0x08), m_destination);
82      m_opcode = "abs";
8380      return true;
8481   }
8582   void disassemble(std::string& retString) const
8683   {
87      retString = m_opcode + " " + regIdAsString(m_destination);
84      retString = "abs " + regIdAsString(m_destination);
8885   }
8986   void evaluate(dsp56k_core* cpustate) {}
9087   size_t size() const { return 1; }
r8846r8847
103100   {
104101      decode_JF_table(BITSn(word0,0x0001), BITSn(word0,0x0008),
105102                  m_source, m_destination);
106      m_opcode = "adc";
107103      return true;
108104   }
109105   void disassemble(std::string& retString) const
110106   {
111      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
107      retString = "adc " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
112108   }
113109   void evaluate(dsp56k_core* cpustate) {}
114110   size_t size() const { return 1; }
r8846r8847
127123   {
128124      decode_JJJF_table(BITSn(word0,0x07), BITSn(word0,0x08),
129125                    m_source, m_destination);
130      m_opcode = "add";
131126      return true;
132127   }
133128   void disassemble(std::string& retString) const
134129   {
135      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
130      retString = "add " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
136131   }
137132   void evaluate(dsp56k_core* cpustate) {}
138133   size_t size() const { return 1; }
r8846r8847
147142   Add_2(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
148143   {
149144      m_arg = "";
145        m_opcode = "";
150146      m_valid = decode(word0, word1);
151147   }
152148   bool decode(const UINT16 word0, const UINT16 word1)
r8846r8847
165161   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
166162
167163private:
164    std::string m_opcode;
168165   std::string m_arg;  // TODO: get rid of this Add|Sub thing.
169166};
170167
r8846r8847
180177   {
181178      decode_JJF_table(BITSn(word0,0x03),BITSn(word0,0x08),
182179                   m_source, m_destination);
183      m_opcode = "and";
184180      return true;
185181   }
186182   void disassemble(std::string& retString) const
187183   {
188      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
184      retString = "and " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
189185   }
190186   void evaluate(dsp56k_core* cpustate) {}
191187   size_t size() const { return 1; }
r8846r8847
205201   {
206202      m_immediate = BITSn(word0,0x00ff);
207203      decode_EE_table(BITSn(word0,0x0600), m_destination);
208     
209      m_opcode = "andi";
210      // NEW // sprintf(opcode_str, "and(i)");
211204      return true;
212205   }
213206   void disassemble(std::string& retString) const
214207   {
215208      char temp[32];
216209      sprintf(temp, "#$%x,%s", m_immediate, regIdAsString(m_destination).c_str());
217      retString = m_opcode + " " + std::string(temp);
210      retString = "andi " + std::string(temp);
211      // NEW // sprintf(opcode_str, "and(i)");
218212   }
219213   void evaluate(dsp56k_core* cpustate) {}
220214   size_t size() const { return 1; }
r8846r8847
235229   bool decode(const UINT16 word0, const UINT16 word1)
236230   {
237231      decode_F_table(BITSn(word0,0x08), m_destination);
238      m_opcode = "asl";
239232      return true;
240233   }
241234   void disassemble(std::string& retString) const
242235   {
243      retString = m_opcode + " " + regIdAsString(m_destination);
236      retString = "asl " + regIdAsString(m_destination);
244237   }
245238   void evaluate(dsp56k_core* cpustate) {}
246239   size_t size() const { return 1; }
r8846r8847
258251   bool decode(const UINT16 word0, const UINT16 word1)
259252   {
260253      decode_F_table(BITSn(word0,0x0008), m_destination);
261      m_opcode = "asl4";
262254      return true;
263255   }
264256   void disassemble(std::string& retString) const
265257   {
266      retString = m_opcode + " " + regIdAsString(m_destination);
258      retString = "asl4 " + regIdAsString(m_destination);
267259   }
268260   void evaluate(dsp56k_core* cpustate) {}
269261   size_t size() const { return 1; }
r8846r8847
281273   bool decode(const UINT16 word0, const UINT16 word1)
282274   {
283275      decode_F_table(BITSn(word0,0x08), m_destination);
284      m_opcode = "asr";
285276      return true;
286277   }
287278   void disassemble(std::string& retString) const
288279   {
289      retString = m_opcode + " " + regIdAsString(m_destination);
280      retString = "asr " + regIdAsString(m_destination);
290281   }
291282   void evaluate(dsp56k_core* cpustate) {}
292283   size_t size() const { return 1; }
r8846r8847
304295   bool decode(const UINT16 word0, const UINT16 word1)
305296   {
306297      decode_F_table(BITSn(word0,0x0008), m_destination);
307      m_opcode = "asr4";
308298      return true;
309299   }
310300   void disassemble(std::string& retString) const
311301   {
312      retString = m_opcode + " " + regIdAsString(m_destination);
302      retString = "asr4 " + regIdAsString(m_destination);
313303   }
314304   void evaluate(dsp56k_core* cpustate) {}
315305   size_t size() const { return 1; }
r8846r8847
327317   bool decode(const UINT16 word0, const UINT16 word1)
328318   {
329319      decode_F_table(BITSn(word0,0x0008), m_destination);
330      m_opcode = "asr16";
331320      return true;
332321   }
333322   void disassemble(std::string& retString) const
334323   {
335      retString = m_opcode + " " + regIdAsString(m_destination);
324      retString = "asr16 " + regIdAsString(m_destination);
336325   }
337326   void evaluate(dsp56k_core* cpustate) {}
338327   size_t size() const { return 1; }
r8846r8847
350339   BfInstruction(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
351340   {
352341        dString = "";
342        m_opcode = "";
353343        m_iVal = 0x0000;
354344      m_valid = decode(word0, word1);
355345   }
r8846r8847
387377   {
388378      char temp[32];
389379      sprintf(temp, "#$%x", m_iVal);
380      retString = m_opcode + " " + std::string(temp) + "," + dString;
390381      // NEW // sprintf(temp, "#$%04x", iVal);
391      std::string source = temp;
392
393      retString = m_opcode + " " + source + "," + dString;
394382   }
395383   void evaluate(dsp56k_core* cpustate) {}
396384   size_t size() const { return 2; }
397385   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
398386private:
399387    UINT16 m_iVal;
388    std::string m_opcode;
400389    std::string dString;
401390};
402391
r8846r8847
410399public:
411400   BfInstruction_2(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
412401   {
402        m_opcode = "";
413403        m_r = iINVALID;
414404        m_iVal = 0x0000;
415405      m_valid = decode(word0, word1);
r8846r8847
448438   {
449439      char temp[32];
450440      sprintf(temp, "#$%x", m_iVal);
451      // NEW // sprintf(temp, "#$%04x", m_iVal);
452441      std::string source = temp;
453442
454443      sprintf(temp, "X:(%s)", regIdAsString(m_r).c_str());
455444      std::string destination = temp;
456445
457446      retString = m_opcode + " " + source + "," + destination;
447      // NEW // sprintf(temp, "#$%04x", m_iVal);
458448   }
459449   void evaluate(dsp56k_core* cpustate) {}
460450   size_t size() const { return 2; }
r8846r8847
463453private:
464454    reg_id m_r;
465455    UINT16 m_iVal;
456    std::string m_opcode;
466457};
467458
468459/* BFCHG  : 0001 0100 100D DDDD BBB1 0010 iiii iiii : A-38 */
r8846r8847
475466public:
476467   BfInstruction_3(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
477468   {
469        m_opcode = "";
478470        m_iVal = 0x0000;
479471      m_valid = decode(word0, word1);
480472   }
r8846r8847
512504   {
513505      char temp[32];
514506      sprintf(temp, "#$%x", m_iVal);
515      // NEW // sprintf(temp, "#$%04x", m_iVal);
516507      std::string source = temp;
517508
518509      retString = m_opcode + " " + source + "," + regIdAsString(m_destination);
510      // NEW // sprintf(temp, "#$%04x", m_iVal);
519511   }
520512   void evaluate(dsp56k_core* cpustate) {}
521513   size_t size() const { return 2; }
r8846r8847
523515
524516private:
525517    UINT16 m_iVal;
518    std::string m_opcode;
526519};
527520
528521// Bcc : 0000 0111 --11 cccc xxxx xxxx xxxx xxxx : A-48 ////////////////////////
r8846r8847
531524public:
532525   Bcc(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
533526   {
527        m_mnem = oINVALID;
534528      m_immediate = 0;
535529      m_valid = decode(word0, word1);
536530   }
537531   bool decode(const UINT16 word0, const UINT16 word1)
538532   {
539533      m_immediate = (INT16)word1;
540     
541      std::string M;
542      decode_cccc_table(BITSn(word0,0x000f), M);
543      m_opcode = "b" + M;
544      // NEW // sprintf(opcode_str, "b.%s", M);
534      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
545535      return true;
546536   }
547537   void disassemble(std::string& retString) const
548538   {
539        std::string opcode = "b" + opMnemonicAsString(m_mnem);
540      // NEW // sprintf(opcode_str, "b.%s", M);
541       
549542      char temp[32];
550543      sprintf(temp, ">*+$%x", 2 + m_immediate);
551544      // NEW // sprintf(temp, "$%04x (%d)", pc + 2 + (INT16)word1, (INT16)word1);
552      retString = m_opcode + " " + std::string(temp);
545      retString = opcode + " " + std::string(temp);
553546   }
554547   void evaluate(dsp56k_core* cpustate) {}
555548   size_t size() const { return 2; }
556549   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
557550   
558551private:
552    op_mnem m_mnem;
559553   INT16 m_immediate;
560554};
561555
r8846r8847
566560   Bcc_2(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
567561   {
568562      m_immediate = 0;
563        m_mnem = oINVALID;
569564      m_valid = decode(word0, word1);
570565   }
571566   bool decode(const UINT16 word0, const UINT16 word1)
572567   {
573      std::string M;
574      decode_cccc_table(BITSn(word0,0x3c0), M);
568      decode_cccc_table(BITSn(word0,0x3c0), m_mnem);
575569      m_immediate = get_6_bit_signed_value(BITSn(word0,0x003f));
576      m_opcode = "b" + M;
577      // NEW // sprintf(opcode_str, "b.%s", M);
578570      return true;
579571   }
580572   void disassemble(std::string& retString) const
581573   {
574        std::string opcode = "b" + opMnemonicAsString(m_mnem);
575      // NEW // sprintf(opcode_str, "b.%s", M);
576       
582577      char temp[32];
583578      if (m_immediate >= 0) sprintf(temp, "<*+$%x", m_immediate + 1);
584579      else                  sprintf(temp, "<*-$%x", 1 - m_immediate - 2);
585580      // NEW // sprintf(temp, "$%04x (%d)", pc + 1 + relativeInt, relativeInt);
586      retString = m_opcode + " " + std::string(temp);
581
582      retString = opcode + " " + std::string(temp);
587583   }
588584   void evaluate(dsp56k_core* cpustate) {}
589585   size_t size() const { return 1; }
590586   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
591587
592588private:
589    op_mnem m_mnem;
593590   INT8 m_immediate;
594591};
595592
r8846r8847
599596public:
600597   Bcc_3(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
601598   {
599        m_mnem = oINVALID;
602600      m_valid = decode(word0, word1);
603601   }
604602   bool decode(const UINT16 word0, const UINT16 word1)
605603   {
606604      decode_RR_table(BITSn(word0,0x00c0), m_destination);
607
608      std::string M;
609      decode_cccc_table(BITSn(word0,0x000f), M);
610      m_opcode = "b" + M;
611      // NEW // sprintf(opcode_str, "b.%s", M);
605      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
612606      return true;
613607   }
614608   void disassemble(std::string& retString) const
615609   {
616      retString = m_opcode + " " + regIdAsString(m_destination);
610        std::string opcode = "b" + opMnemonicAsString(m_mnem);
611      retString = opcode + " " + regIdAsString(m_destination);
612      // NEW // sprintf(opcode_str, "b.%s", M);
617613   }
618614   void evaluate(dsp56k_core* cpustate) {}
619615   size_t size() const { return 1; }
620616   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
617
618private:
619    op_mnem m_mnem;
621620};
622621
623622// BRA : 0000 0001 0011 11-- xxxx xxxx xxxx xxxx : A-50 ////////////////////////
r8846r8847
632631   bool decode(const UINT16 word0, const UINT16 word1)
633632   {
634633      m_immediate = (INT16)word1;
635     
636      m_opcode = "bra";
637634      return true;
638635   }
639636   void disassemble(std::string& retString) const
r8846r8847
641638      char temp[32];
642639      sprintf(temp, ">*+$%x", 2 + m_immediate);
643640      // NEW // sprintf(temp, "$%04x (%d)", pc + 2 + word1, (INT16)word1);
644      retString = m_opcode + " " + std::string(temp);
641      retString = "bra " + std::string(temp);
645642   }
646643   void evaluate(dsp56k_core* cpustate) {}
647644   size_t size() const { return 2; }
r8846r8847
663660   bool decode(const UINT16 word0, const UINT16 word1)
664661   {
665662      m_immediate = (INT8)BITSn(word0,0x00ff);
666      m_opcode = "bra";
667663      return true;
668664   }
669665   void disassemble(std::string& retString) const
r8846r8847
672668      if (m_immediate >= 0) sprintf(temp, "<*+$%x", 1 + m_immediate);
673669      else                  sprintf(temp, "<*-$%x", 1 - m_immediate - 2);
674670      // NEW // sprintf(temp, "$%04x (%d)", pc + 1 + iVal, iVal);
675      retString = m_opcode + " " + std::string(temp);
671      retString = "bra " + std::string(temp);
676672   }
677673   void evaluate(dsp56k_core* cpustate) {}
678674   size_t size() const { return 1; }
r8846r8847
693689   bool decode(const UINT16 word0, const UINT16 word1)
694690   {
695691      decode_RR_table(BITSn(word0,0x0003), m_destination);
696     
697      m_opcode = "bra";
698692      return true;
699693   }
700694   void disassemble(std::string& retString) const
701695   {
702      retString = m_opcode + " " + regIdAsString(m_destination);
696      retString = "bra " + regIdAsString(m_destination);
703697   }
704698   void evaluate(dsp56k_core* cpustate) {}
705699   size_t size() const { return 1; }
r8846r8847
712706public:
713707   Brkcc(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
714708   {
709        m_mnem = oINVALID;
715710      m_valid = decode(word0, word1);
716711   }
717712   bool decode(const UINT16 word0, const UINT16 word1)
718713   {
719      std::string M;
720      decode_cccc_table(BITSn(word0,0x000f), M);
721      m_opcode = "brk" + M;
722      // NEW // sprintf(opcode_str, "brk.%s", M);
714      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
723715      return true;
724716   }
725717   void disassemble(std::string& retString) const
726718   {
727      retString = m_opcode;
719        std::string opcode = "brk" + opMnemonicAsString(m_mnem);
720      retString = opcode;
721      // NEW // sprintf(opcode_str, "brk.%s", M);
728722   }
729723   void evaluate(dsp56k_core* cpustate) {}
730724   size_t size() const { return 1; }
731725   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
726
727private:
728    op_mnem m_mnem;
732729};
733730
734731// BScc : 0000 0111 --01 cccc xxxx xxxx xxxx xxxx : A-54 ///////////////////////
r8846r8847
738735   Bscc(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
739736   {
740737      m_immediate = 0;
738        m_mnem = oINVALID;
741739      m_valid = decode(word0, word1);
742740   }
743741   bool decode(const UINT16 word0, const UINT16 word1)
744742   {
745743      m_immediate = (INT16)word1;
746     
747      std::string M;
748      decode_cccc_table(BITSn(word0,0x000f), M);
749      m_opcode = "bs" + M;
750      // NEW // sprintf(opcode_str, "bs.%s", M);
744      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
751745      return true;
752746   }
753747   void disassemble(std::string& retString) const
754748   {
749        std::string opcode = "bs" + opMnemonicAsString(m_mnem);
750      // NEW // sprintf(opcode_str, "bs.%s", M);
751
755752      char temp[32];
756753      if (m_immediate >= 0) sprintf(temp, ">*+$%x", 2 + m_immediate);
757754      else                  sprintf(temp, ">*-$%x", 1 - m_immediate - 1 - 2);
758755      //sprintf(temp, ">*+$%x", 2 + m_immediate);
759756      // NEW // sprintf(temp, "$%04x (%d)", pc + 2 + (INT16)word1, (INT16)word1);
760      retString = m_opcode + " " + std::string(temp);
757      retString = opcode + " " + std::string(temp);
761758   }
762759   void evaluate(dsp56k_core* cpustate) {}
763760   size_t size() const { return 2; }
r8846r8847
765762   size_t flags() { return DASMFLAG_STEP_OVER; }
766763   
767764private:
765    op_mnem m_mnem;
768766   INT16 m_immediate;
769767};
770768
r8846r8847
774772public:
775773   Bscc_2(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
776774   {
775        m_mnem = oINVALID;
777776      m_valid = decode(word0, word1);
778777   }
779778   bool decode(const UINT16 word0, const UINT16 word1)
780779   {
781780      decode_RR_table(BITSn(word0,0x00c0), m_destination);
782
783      std::string M;
784      decode_cccc_table(BITSn(word0,0x000f), M);
785     
786      m_opcode = "bs" + M;
787      // NEW // sprintf(opcode_str, "bs.%s", M);
781      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
788782      return true;
789783   }
790784   void disassemble(std::string& retString) const
791785   {
792      retString = m_opcode + " " + regIdAsString(m_destination);
786        std::string opcode = "bs" + opMnemonicAsString(m_mnem);
787      retString = opcode + " " + regIdAsString(m_destination);
788      // NEW // sprintf(opcode_str, "bs.%s", M);
793789   }
794790   void evaluate(dsp56k_core* cpustate) {}
795791   size_t size() const { return 1; }
796792   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
797793   size_t flags() { return DASMFLAG_STEP_OVER; }
794
795private:
796    op_mnem m_mnem;
798797};
799798
800799// BSR : 0000 0001 0011 10-- xxxx xxxx xxxx xxxx : A-56 ////////////////////////
r8846r8847
809808   bool decode(const UINT16 word0, const UINT16 word1)
810809   {
811810      m_immediate = (INT16)word1;
812           
813      m_opcode = "bsr";
814811      return true;
815812   }
816813   void disassemble(std::string& retString) const
r8846r8847
819816      if (m_immediate >= 0) sprintf(temp, ">*+$%x", 2 + m_immediate);
820817      else                  sprintf(temp, ">*-$%x", 1 - m_immediate - 1 - 2);
821818      // NEW // sprintf(temp, "$%04x (%d)", pc + 2 + (INT16)word1, (INT16)word1);
822      retString = m_opcode + " " + std::string(temp);
819      retString = "bsr " + std::string(temp);
823820   }
824821   void evaluate(dsp56k_core* cpustate) {}
825822   size_t size() const { return 2; }
r8846r8847
841838   bool decode(const UINT16 word0, const UINT16 word1)
842839   {
843840      decode_RR_table(BITSn(word0,0x0003), m_destination);
844     
845      m_opcode = "bsr";
846841      return true;
847842   }
848843   void disassemble(std::string& retString) const
849844   {
850      retString = m_opcode + " " + regIdAsString(m_destination);
845      retString = "bsr " + regIdAsString(m_destination);
851846   }
852847   void evaluate(dsp56k_core* cpustate) {}
853848   size_t size() const { return 1; }
r8846r8847
865860   }
866861   bool decode(const UINT16 word0, const UINT16 word1)
867862   {
868      m_opcode = "chkaau";
869863      return true;
870864   }
871865   void disassemble(std::string& retString) const
872866   {
873      retString = m_opcode;
867      retString = "chkaau";
874868   }
875869   void evaluate(dsp56k_core* cpustate) {}
876870   size_t size() const { return 1; }
r8846r8847
888882   bool decode(const UINT16 word0, const UINT16 word1)
889883   {
890884      decode_F_table(BITSn(word0,0x08), m_destination);
891      m_opcode = "clr";
892885      return true;
893886   }
894887   void disassemble(std::string& retString) const
895888   {
896      retString = m_opcode + " " + regIdAsString(m_destination);
889      retString = "clr " + regIdAsString(m_destination);
897890   }
898891   void evaluate(dsp56k_core* cpustate) {}
899892   size_t size() const { return 1; }
r8846r8847
911904   bool decode(const UINT16 word0, const UINT16 word1)
912905   {
913906      decode_F_table(BITSn(word0,0x08), m_destination);
914      m_opcode = "clr24";
915907      return true;
916908   }
917909   void disassemble(std::string& retString) const
918910   {
919      retString = m_opcode + " " + regIdAsString(m_destination);
911      retString = "clr24 " + regIdAsString(m_destination);
920912   }
921913   void evaluate(dsp56k_core* cpustate) {}
922914   size_t size() const { return 1; }
r8846r8847
937929             in before cmp, so the same decode function can be used. */
938930      decode_JJJF_table(BITSn(word0,0x07), BITSn(word0,0x08),
939931                    m_source, m_destination);
940      m_opcode = "cmp";
941932      return true;
942933   }
943934   void disassemble(std::string& retString) const
944935   {
945      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
936      retString = "cmp " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
946937   }
947938   void evaluate(dsp56k_core* cpustate) {}
948939   size_t size() const { return 1; }
r8846r8847
963954             in before cmp, so the same decode function can be used. */
964955      decode_JJJF_table(BITSn(word0,0x07), BITSn(word0,0x08),
965956                    m_source, m_destination);
966      m_opcode = "cmpm";
967957      return true;
968958   }
969959   void disassemble(std::string& retString) const
970960   {
971      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
961      retString = "cmpm " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
972962   }
973963   void evaluate(dsp56k_core* cpustate) {}
974964   size_t size() const { return 1; }
r8846r8847
985975   }
986976   bool decode(const UINT16 word0, const UINT16 word1)
987977   {
988      m_opcode = "debug";
989978      return true;
990979   }
991980   void disassemble(std::string& retString) const
992981   {
993      retString = m_opcode;
982      retString = "debug";
994983   }
995984   void evaluate(dsp56k_core* cpustate) {}
996985   size_t size() const { return 1; }
r8846r8847
1003992public:
1004993   Debugcc(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
1005994   {
995        m_mnem = oINVALID;
1006996      m_valid = decode(word0, word1);
1007997   }
1008998   bool decode(const UINT16 word0, const UINT16 word1)
1009999   {
1010      std::string M;
1011      decode_cccc_table(BITSn(word0,0x000f), M);
1012      m_opcode = "debug" + M;
1013      // NEW // sprintf(opcode_str, "debug.%s", M);
1000      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
10141001      return true;
10151002   }
10161003   void disassemble(std::string& retString) const
10171004   {
1018      retString = m_opcode;
1005        std::string opcode = "debug" + opMnemonicAsString(m_mnem);
1006      retString = opcode;
1007      // NEW // sprintf(opcode_str, "debug.%s", M);
10191008   }
10201009   void evaluate(dsp56k_core* cpustate) {}
10211010   size_t size() const { return 1; }
10221011   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
1012
1013private:
1014    op_mnem m_mnem;
10231015};
10241016
10251017// DEC : .... .... 0110 F010 : A-72 ////////////////////////////////////////////
r8846r8847
10331025   bool decode(const UINT16 word0, const UINT16 word1)
10341026   {
10351027      decode_F_table(BITSn(word0,0x08), m_destination);
1036      m_opcode = "dec";
10371028      return true;
10381029   }
10391030   void disassemble(std::string& retString) const
10401031   {
1041      retString = m_opcode + " " + regIdAsString(m_destination);
1032      retString = "dec " + regIdAsString(m_destination);
10421033   }
10431034   void evaluate(dsp56k_core* cpustate) {}
10441035   size_t size() const { return 1; }
r8846r8847
10561047   bool decode(const UINT16 word0, const UINT16 word1)
10571048   {
10581049      decode_F_table(BITSn(word0,0x08), m_destination);
1059      m_opcode = "dec24";
10601050      return true;
10611051   }
10621052   void disassemble(std::string& retString) const
10631053   {
1064      retString = m_opcode + " " + regIdAsString(m_destination);
1054      retString = "dec24 " + regIdAsString(m_destination);
10651055   }
10661056   void evaluate(dsp56k_core* cpustate) {}
10671057   size_t size() const { return 1; }
r8846r8847
10801070   {
10811071      decode_DDF_table(BITSn(word0,0x0003), BITSn(word0,0x0008),
10821072                   m_source, m_destination);
1083      m_opcode = "div";
10841073      return true;
10851074   }
10861075   void disassemble(std::string& retString) const
10871076   {
1088      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
1077      retString = "div " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
10891078   }
10901079   void evaluate(dsp56k_core* cpustate) {}
10911080   size_t size() const { return 1; }
r8846r8847
10981087public:
10991088   Dmac(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
11001089   {
1090        m_mnem = oINVALID;
11011091      m_source2 = iINVALID;
11021092      m_valid = decode(word0, word1);
11031093   }
r8846r8847
11061096      decode_QQF_special_table(BITSn(word0,0x0003), BITSn(word0,0x0008),
11071097                         m_source, m_source2, m_destination);
11081098
1109      std::string a;
1110      decode_ss_table(BITSn(word0,0x0024), a);
1111      if (a == "!!") return false;
1112     
1113      m_opcode = "dmac" + a;
1114      // NEW // sprintf(opcode_str, "dmac(%s)", A);
1099      decode_ss_table(BITSn(word0,0x0024), m_mnem);
1100      if (m_mnem == oINVALID) return false;
11151101      return true;
11161102   }
11171103   void disassemble(std::string& retString) const
11181104   {
1119      retString = m_opcode + " " +
1105        std::string opcode = "dmac" + opMnemonicAsString(m_mnem);
1106       
1107      retString = opcode + " " +
11201108               regIdAsString(m_source) + "," +
11211109               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
1110      // NEW // sprintf(opcode_str, "dmac(%s)", A);
11221111   }
11231112   void evaluate(dsp56k_core* cpustate) {}
11241113   size_t size() const { return 1; }
11251114   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
11261115   
11271116private:
1117    op_mnem m_mnem;
11281118   reg_id m_source2;
11291119};
11301120
r8846r8847
11401130   bool decode(const UINT16 word0, const UINT16 word1)
11411131   {
11421132      m_immediate = word1;
1143
11441133      decode_RR_table(BITSn(word0,0x0003), m_source);
1145     
1146      m_opcode = "do";
11471134      return true;
11481135   }
11491136   void disassemble(std::string& retString) const
r8846r8847
11561143      sprintf(temp, "X:(%s)", regIdAsString(m_source).c_str());
11571144      std::string source = temp;
11581145       
1159      retString = m_opcode + " " + source + "," + destination;
1146      retString = "do " + source + "," + destination;
11601147   }
11611148   void evaluate(dsp56k_core* cpustate) {}
11621149   size_t size() const { return 2; }
r8846r8847
11801167   {
11811168      m_immediate = BITSn(word0,0x00ff);
11821169      m_displacement = word1;
1183     
1184      m_opcode = "do";
11851170      return true;
11861171   }
11871172   void disassemble(std::string& retString) const
r8846r8847
11891174      char temp[32];
11901175      sprintf(temp, "#<$%x,*+$%x", m_immediate, 2 + m_displacement);
11911176      // NEW // sprintf(temp, "#$%02x,$%04x", BITSn(word0,0x00ff), pc + 2 + word1);
1192      retString = m_opcode + " " + std::string(temp);
1177      retString = "do " + std::string(temp);
11931178   }
11941179   void evaluate(dsp56k_core* cpustate) {}
11951180   size_t size() const { return 2; }
r8846r8847
12141199      m_displacement = word1;
12151200     
12161201      decode_DDDDD_table(BITSn(word0,0x001f), m_source);
1217      if (m_source == iSSH) return false; // NEW //
1218      if (m_source == iINVALID) return false;  // NEW //
1219      m_opcode = "do";
1202      if (m_source == iSSH) return false;
1203      if (m_source == iINVALID) return false;
12201204      return true;
12211205   }
12221206   void disassemble(std::string& retString) const
r8846r8847
12241208      char temp[32];
12251209      sprintf(temp, "*+$%x", 2 + m_displacement);
12261210      // NEW // sprintf(temp, "%s,$%04x", S1, pc + 2 + word1);
1227      retString = m_opcode + " " + regIdAsString(m_source) + "," + std::string(temp);
1211      retString = "do " + regIdAsString(m_source) + "," + std::string(temp);
12281212   }
12291213   void evaluate(dsp56k_core* cpustate) {}
12301214   size_t size() const { return 2; }
r8846r8847
12461230   bool decode(const UINT16 word0, const UINT16 word1)
12471231   {
12481232      m_displacement = word1;
1249      m_opcode = "do forever";
12501233      return true;
12511234   }
12521235   void disassemble(std::string& retString) const
r8846r8847
12551238      sprintf(temp, "*+$%x", m_displacement + 2);
12561239      // NEW // sprintf(temp, "*+$%x", pc + word1);
12571240      // NEW // sprintf(temp, "$%04x", pc + 2 + word1);
1258      retString = m_opcode + ", " + std::string(temp);
1241      retString = "do forever, " + std::string(temp);
12591242   }
12601243   void evaluate(dsp56k_core* cpustate) {}
12611244   size_t size() const { return 2; }
r8846r8847
12751258   }
12761259   bool decode(const UINT16 word0, const UINT16 word1)
12771260   {
1278      m_opcode = "enddo";
12791261      return true;
12801262   }
12811263   void disassemble(std::string& retString) const
12821264   {
1283      retString = m_opcode;
1265      retString = "enddo";
12841266   }
12851267   void evaluate(dsp56k_core* cpustate) {}
12861268   size_t size() const { return 1; }
r8846r8847
12991281   {
13001282      decode_JJF_table(BITSn(word0,0x03),BITSn(word0,0x08),
13011283                   m_source, m_destination);
1302      m_opcode = "eor";
13031284      return true;
13041285   }
13051286   void disassemble(std::string& retString) const
13061287   {
1307      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
1288      retString = "eor " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
13081289   }
13091290   void evaluate(dsp56k_core* cpustate) {}
13101291   size_t size() const { return 1; }
r8846r8847
13221303   bool decode(const UINT16 word0, const UINT16 word1)
13231304   {
13241305      decode_F_table(BITSn(word0,0x0008), m_destination);
1325      m_opcode = "ext";
13261306      return true;
13271307   }
13281308   void disassemble(std::string& retString) const
13291309   {
1330      retString = m_opcode + " " + regIdAsString(m_destination);
1310      retString = "ext " + regIdAsString(m_destination);
13311311   }
13321312   void evaluate(dsp56k_core* cpustate) {}
13331313   size_t size() const { return 1; }
r8846r8847
13441324   }
13451325   bool decode(const UINT16 word0, const UINT16 word1)
13461326   {
1347      m_opcode = "illegal";
13481327      return true;
13491328   }
13501329   void disassemble(std::string& retString) const
13511330   {
1352      retString = m_opcode;
1331      retString = "illegal";
13531332   }
13541333   void evaluate(dsp56k_core* cpustate) {}
13551334   size_t size() const { return 1; }
r8846r8847
13691348   {
13701349      decode_QQQF_table(BITSn(word0,0x0007), BITSn(word0,0x0008),
13711350                    m_source, m_source2, m_destination);
1372      m_opcode = "imac";
13731351      return true;
13741352   }
13751353   void disassemble(std::string& retString) const
13761354   {
1377      retString = m_opcode + " " +
1355      retString = "imac " +
13781356               regIdAsString(m_source) + "," +
13791357               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
13801358   }
r8846r8847
13991377   {
14001378      decode_QQQF_table(BITSn(word0,0x0007), BITSn(word0,0x0008),
14011379                    m_source, m_source2, m_destination);
1402      m_opcode = "impy";
14031380      return true;
14041381   }
14051382   void disassemble(std::string& retString) const
14061383   {
1407      retString = m_opcode + " " +
1384      retString = "impy " +
14081385               regIdAsString(m_source) + "," +
14091386               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
14101387   }
r8846r8847
14271404   bool decode(const UINT16 word0, const UINT16 word1)
14281405   {
14291406      decode_F_table(BITSn(word0,0x08), m_destination);
1430      m_opcode = "inc";
14311407      return true;
14321408   }
14331409   void disassemble(std::string& retString) const
14341410   {
1435      retString = m_opcode + " " + regIdAsString(m_destination);
1411      retString = "inc " + regIdAsString(m_destination);
14361412   }
14371413   void evaluate(dsp56k_core* cpustate) {}
14381414   size_t size() const { return 1; }
r8846r8847
14501426   bool decode(const UINT16 word0, const UINT16 word1)
14511427   {
14521428      decode_F_table(BITSn(word0,0x08), m_destination);
1453      m_opcode = "inc24";
14541429      return true;
14551430   }
14561431   void disassemble(std::string& retString) const
14571432   {
1458      retString = m_opcode + " " + regIdAsString(m_destination);
1433      retString = "inc24 " + regIdAsString(m_destination);
14591434   }
14601435   void evaluate(dsp56k_core* cpustate) {}
14611436   size_t size() const { return 1; }
r8846r8847
14681443public:
14691444   Jcc(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
14701445   {
1446        m_mnem = oINVALID;
14711447      m_displacement = 0;
14721448      m_valid = decode(word0, word1);
14731449   }
14741450   bool decode(const UINT16 word0, const UINT16 word1)
14751451   {
14761452      m_displacement = word1;
1477     
1478      std::string M;
1479      decode_cccc_table(BITSn(word0,0x000f), M);
1480      m_opcode = "j" + M;
1481      // NEW // sprintf(opcode_str, "j.%s", M);
1453      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
14821454      return true;
14831455   }
14841456   void disassemble(std::string& retString) const
14851457   {
1458        std::string opcode = "j" + opMnemonicAsString(m_mnem);
1459      // NEW // sprintf(opcode_str, "j.%s", M);
1460       
14861461      char temp[32];
14871462      sprintf(temp, ">$%x", m_displacement);
14881463      // NEW // sprintf(temp, "$%04x", word1);
1489      retString = m_opcode + " " + std::string(temp);
1464      retString = opcode + " " + std::string(temp);
14901465   }
14911466   void evaluate(dsp56k_core* cpustate) {}
14921467   size_t size() const { return 2; }
14931468   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
14941469
14951470private:
1471    op_mnem m_mnem;
14961472   UINT16 m_displacement;
14971473};
14981474
r8846r8847
15021478public:
15031479   Jcc_2(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
15041480   {
1481        m_mnem = oINVALID;
15051482      m_valid = decode(word0, word1);
15061483   }
15071484   bool decode(const UINT16 word0, const UINT16 word1)
15081485   {
15091486      decode_RR_table(BITSn(word0,0x00c0), m_destination);
1510
1511      std::string M;
1512      decode_cccc_table(BITSn(word0,0x000f), M);
1513      m_opcode = "j" + M;
1514      // NEW // sprintf(opcode_str, "j.%s", M);
1487      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
15151488      return true;
15161489   }
15171490   void disassemble(std::string& retString) const
15181491   {
1519      retString = m_opcode + " " + regIdAsString(m_destination);
1492        std::string opcode = "j" + opMnemonicAsString(m_mnem);
1493      retString = opcode + " " + regIdAsString(m_destination);
1494      // NEW // sprintf(opcode_str, "j.%s", M);
15201495   }
15211496   void evaluate(dsp56k_core* cpustate) {}
15221497   size_t size() const { return 1; }
15231498   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
1499
1500private:
1501    op_mnem m_mnem;
15241502};
15251503
15261504// JMP : 0000 0001 0011 01-- xxxx xxxx xxxx xxxx : A-110 ///////////////////////
r8846r8847
15351513   bool decode(const UINT16 word0, const UINT16 word1)
15361514   {
15371515      m_displacement = word1;
1538     
1539      m_opcode = "jmp";
15401516      return true;
15411517   }
15421518   void disassemble(std::string& retString) const
r8846r8847
15441520      char temp[32];
15451521      sprintf(temp, ">$%x", m_displacement);
15461522      // NEW // sprintf(temp, "$%04x", word1);
1547      retString = m_opcode + " " + std::string(temp);
1523      retString = "jmp " + std::string(temp);
15481524   }
15491525   void evaluate(dsp56k_core* cpustate)
15501526   {
r8846r8847
15731549   bool decode(const UINT16 word0, const UINT16 word1)
15741550   {
15751551      decode_RR_table(BITSn(word0,0x0003), m_destination);
1576     
1577      m_opcode = "jmp";
15781552      return true;
15791553   }
15801554   void disassemble(std::string& retString) const
15811555   {
1582      retString = m_opcode + " " + regIdAsString(m_destination);
1556      retString = "jmp " + regIdAsString(m_destination);
15831557   }
15841558   void evaluate(dsp56k_core* cpustate)
15851559   {
r8846r8847
16021576public:
16031577   Jscc(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
16041578   {
1579        m_mnem = oINVALID;
16051580      m_displacement = 0;
16061581      m_valid = decode(word0, word1);
16071582   }
16081583   bool decode(const UINT16 word0, const UINT16 word1)
16091584   {
16101585      m_displacement = word1;
1611     
1612      std::string M;
1613      decode_cccc_table(BITSn(word0,0x000f), M);
1614      m_opcode = "js" + M;
1615      // NEW // sprintf(opcode_str, "js.%s", M);
1586      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
16161587      return true;
16171588   }
16181589   void disassemble(std::string& retString) const
16191590   {
1591        std::string opcode = "js" + opMnemonicAsString(m_mnem);
1592      // NEW // sprintf(opcode_str, "js.%s", M);
1593       
16201594      char temp[32];
16211595      sprintf(temp, ">$%x", m_displacement);
16221596      // NEW // sprintf(temp, "$%04x", word1);
1623      retString = m_opcode + " " + std::string(temp);
1597      retString = opcode + " " + std::string(temp);
16241598   }
16251599   void evaluate(dsp56k_core* cpustate) {}
16261600   size_t size() const { return 2; }
r8846r8847
16281602   size_t flags() { return DASMFLAG_STEP_OVER; }
16291603
16301604private:
1605    op_mnem m_mnem;
16311606   UINT16 m_displacement;
16321607};
16331608
r8846r8847
16371612public:
16381613   Jscc_2(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
16391614   {
1615        m_mnem = oINVALID;
16401616      m_valid = decode(word0, word1);
16411617   }
16421618   bool decode(const UINT16 word0, const UINT16 word1)
16431619   {
16441620      decode_RR_table(BITSn(word0,0x00c0), m_destination);
1645
1646      std::string M;
1647      decode_cccc_table(BITSn(word0,0x000f), M);
1648      m_opcode = "js" + M;
1649      // NEW // sprintf(opcode_str, "js.%s", M);
1621      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
16501622      return true;
16511623   }
16521624   void disassemble(std::string& retString) const
16531625   {
1654      retString = m_opcode + " " + regIdAsString(m_destination);
1626        std::string opcode = "js" + opMnemonicAsString(m_mnem);
1627      retString = opcode + " " + regIdAsString(m_destination);
1628      // NEW // sprintf(opcode_str, "js.%s", M);
16551629   }
16561630   void evaluate(dsp56k_core* cpustate) {}
16571631   size_t size() const { return 1; }
16581632   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
16591633   size_t flags() { return DASMFLAG_STEP_OVER; }
1634
1635private:
1636    op_mnem m_mnem;
16601637};
16611638
16621639// JSR : 0000 0001 0011 00-- xxxx xxxx xxxx xxxx : A-114 ///////////////////////
r8846r8847
16711648   bool decode(const UINT16 word0, const UINT16 word1)
16721649   {
16731650      m_displacement = word1;
1674     
1675      m_opcode = "jsr";
16761651      return true;
16771652   }
16781653   void disassemble(std::string& retString) const
r8846r8847
16801655      char temp[32];
16811656      sprintf(temp, ">$%x", m_displacement);
16821657      // NEW // sprintf(temp, "$%04x", word1);
1683      retString = m_opcode + " " + std::string(temp);
1658      retString = "jsr " + std::string(temp);
16841659   }
16851660   void evaluate(dsp56k_core* cpustate) {}
16861661   size_t size() const { return 2; }
r8846r8847
17031678   bool decode(const UINT16 word0, const UINT16 word1)
17041679   {
17051680      m_bAddr = BITSn(word0,0x00ff);
1706     
1707      m_opcode = "jsr";
17081681      return true;
17091682   }
17101683   void disassemble(std::string& retString) const
r8846r8847
17121685      char temp[32];
17131686      sprintf(temp, "<$%x", m_bAddr);
17141687      // NEW // sprintf(temp, "#$%02x", BITSn(word0,0x00ff));
1715      retString = m_opcode + " " + std::string(temp);
1688      retString = "jsr " + std::string(temp);
17161689   }
17171690   void evaluate(dsp56k_core* cpustate) {}
17181691   size_t size() const { return 1; }
r8846r8847
17341707   bool decode(const UINT16 word0, const UINT16 word1)
17351708   {
17361709      decode_RR_table(BITSn(word0,0x0003), m_destination);
1737
1738      m_opcode = "jsr";
17391710      return true;
17401711   }
17411712   void disassemble(std::string& retString) const
17421713   {
1743      retString = m_opcode + " " + regIdAsString(m_destination);
1714      retString = "jsr " + regIdAsString(m_destination);
17441715   }
17451716   void evaluate(dsp56k_core* cpustate) {}
17461717   size_t size() const { return 1; }
r8846r8847
17651736
17661737      INT8 rNum = BITSn(word0,0x0003);
17671738      assemble_ea_from_MM_table(BITSn(word0,0x000c), rNum, m_ea);
1768     
1769      m_opcode = "lea";
1739
17701740      return true;
17711741   }
17721742   void disassemble(std::string& retString) const
17731743   {
17741744        // HACK
1775      retString = m_opcode + " " + m_ea + "," + regIdAsString(m_destination);
1745      retString = "lea " + m_ea + "," + regIdAsString(m_destination);
17761746   }
17771747   void evaluate(dsp56k_core* cpustate) {}
17781748   size_t size() const { return 1; }
r8846r8847
17991769      INT8 rNum = BITSn(word0,0x0003);
18001770      assemble_ea_from_MM_table(BITSn(word0,0x000c), rNum, m_ea);
18011771
1802      m_opcode = "lea";
18031772      return true;
18041773   }
18051774   void disassemble(std::string& retString) const
18061775   {
18071776        // HACK
1808      retString = m_opcode + " " + m_ea + "," + regIdAsString(m_destination);
1777      retString = "lea " + m_ea + "," + regIdAsString(m_destination);
18091778   }
18101779   void evaluate(dsp56k_core* cpustate) {}
18111780   size_t size() const { return 1; }
r8846r8847
18261795   bool decode(const UINT16 word0, const UINT16 word1)
18271796   {
18281797      decode_F_table(BITSn(word0,0x08), m_destination);
1829      m_opcode = "lsl";
18301798      return true;
18311799   }
18321800   void disassemble(std::string& retString) const
18331801   {
1834      retString = m_opcode + " " + regIdAsString(m_destination);
1802      retString = "lsl " + regIdAsString(m_destination);
18351803   }
18361804   void evaluate(dsp56k_core* cpustate) {}
18371805   size_t size() const { return 1; }
r8846r8847
18491817   bool decode(const UINT16 word0, const UINT16 word1)
18501818   {
18511819      decode_F_table(BITSn(word0,0x08), m_destination);
1852      m_opcode = "lsr";
18531820      return true;
18541821   }
18551822   void disassemble(std::string& retString) const
18561823   {
1857      retString = m_opcode + " " + regIdAsString(m_destination);
1824      retString = "lsr " + regIdAsString(m_destination);
18581825   }
18591826   void evaluate(dsp56k_core* cpustate) {}
18601827   size_t size() const { return 1; }
r8846r8847
18771844                    m_source, m_source2, m_destination);
18781845
18791846      decode_kSign_table(BITSn(word0,0x40), m_sign);
1880
1881      m_opcode = "mac";
18821847      return true;
18831848   }
18841849   void disassemble(std::string& retString) const
18851850   {
18861851        std::string ts = m_sign;
18871852        if (ts != "-") ts = "";
1888      retString = m_opcode + " " +
1853      retString = "mac " +
18891854                   ts +
18901855               regIdAsString(m_source) + "," +
18911856               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
r8846r8847
19121877   {
19131878      decode_QQF_table(BITSn(word0,0x03), BITSn(word0,0x08),
19141879                   m_source, m_source2, m_destination);
1915
1916      m_opcode = "mac";
19171880      return true;
19181881   }
19191882   void disassemble(std::string& retString) const
19201883   {
1921      retString = m_opcode + " " +
1884      retString = "mac " +
19221885               regIdAsString(m_source) + "," +
19231886               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
19241887   }
r8846r8847
19431906   {
19441907      decode_QQQF_table(BITSn(word0,0x0007), BITSn(word0,0x0008),
19451908                    m_source, m_source2, m_destination);
1946      m_opcode = "mac";
19471909      return true;
19481910   }
19491911   void disassemble(std::string& retString) const
19501912   {
1951      retString = m_opcode + " " +
1913      retString = "mac " +
19521914               regIdAsString(m_source) + "," +
19531915               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
19541916   }
r8846r8847
19761938                    m_source, m_source2, m_destination);
19771939
19781940      decode_kSign_table(BITSn(word0,0x40), m_sign);
1979
1980      m_opcode = "macr";
19811941      return true;
19821942   }
19831943   void disassemble(std::string& retString) const
19841944   {
19851945        std::string ts = m_sign;
19861946        if (ts != "-") ts = "";
1987      retString = m_opcode + " " +
1947      retString = "macr " +
19881948                   ts +
19891949               regIdAsString(m_source) + "," +
19901950               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
r8846r8847
20111971   {
20121972      decode_QQF_table(BITSn(word0,0x03), BITSn(word0,0x08),
20131973                   m_source, m_source2, m_destination);
2014      m_opcode = "macr";
20151974      return true;
20161975   }
20171976   void disassemble(std::string& retString) const
20181977   {
2019      retString = m_opcode + " " +
1978      retString = "macr " +
20201979               regIdAsString(m_source) + "," +
20211980               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
20221981   }
r8846r8847
20341993public:
20351994   Macsuuu(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
20361995   {
1996        m_mnem = oINVALID;
20371997      m_source2 = iINVALID;
20381998      m_valid = decode(word0, word1);
20391999   }
r8846r8847
20432003      decode_QQF_special_table(BITSn(word0,0x0003), BITSn(word0,0x0008),
20442004                         m_source, m_source2, m_destination);
20452005
2046      std::string a;
2047      decode_s_table(BITSn(word0,0x0004), a);
2048      m_opcode = "mac" + a;
2049      // NEW // sprintf(opcode_str, "mac(%s)", A);
2006      decode_s_table(BITSn(word0,0x0004), m_mnem);
20502007      return true;
20512008   }
20522009   void disassemble(std::string& retString) const
20532010   {
2054      retString = m_opcode + " " +
2011        std::string opcode = "mac" + opMnemonicAsString(m_mnem);
2012       
2013      retString = opcode + " " +
20552014               regIdAsString(m_source) + "," +
20562015               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
2016      // NEW // sprintf(opcode_str, "mac(%s)", A);
20572017   }
20582018   void evaluate(dsp56k_core* cpustate) {}
20592019   size_t size() const { return 1; }
20602020   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
20612021
20622022private:
2023    op_mnem m_mnem;
20632024   reg_id m_source2;
20642025};
20652026
r8846r8847
20882049      if (BITSn == 0x4a || BITSn == 0x4b)
20892050         m_isNop = true;
20902051
2091      m_opcode = "move";
20922052      return true;
20932053   }
20942054   void disassemble(std::string& retString) const
r8846r8847
20962056      if (m_isNop)
20972057         retString = "nop";
20982058      else
2099         retString = m_opcode;
2059         retString = "move";
21002060   }
21012061   void evaluate(dsp56k_core* cpustate) {}
21022062   size_t size() const { return 1; }
r8846r8847
21232083      else
21242084         m_destination = iA;
21252085
2126      m_opcode = "move";
21272086      return true;
21282087   }
21292088   void disassemble(std::string& retString) const
21302089   {
2131      retString = m_opcode;
2090      retString = "move";
21322091   }
21332092   void evaluate(dsp56k_core* cpustate) {}
21342093   size_t size() const { return 1; }
r8846r8847
21512110      m_b = BITSn(word0,0x00ff);
21522111        m_W = BITSn(word1,0x0100);
21532112      decode_HHH_table(BITSn(word1,0x0e00), m_SD);
2154
2155      m_opcode = "move";
21562113      return true;
21572114   }
21582115   void disassemble(std::string& retString) const
r8846r8847
21602117        std::string source;
21612118        std::string destination;
21622119      assemble_reg_from_W_table(m_W, 'X', m_SD, m_b, source, destination);
2163      retString = m_opcode + " " + source + "," + destination;
2120      retString = "move " + source + "," + destination;
21642121   }
21652122   void evaluate(dsp56k_core* cpustate) {}
21662123   size_t size() const { return 2; }
r8846r8847
21912148        m_W = BITSn(word0,0x0400);
21922149      decode_DDDDD_table(BITSn(word0,0x03e0), m_SD);
21932150      if (m_SD == iINVALID) return false;
2194
2195      m_opcode = "move";
2196      // NEW // sprintf(opcode_str, "move(c)");
21972151      return true;
21982152   }
21992153   void disassemble(std::string& retString) const
r8846r8847
22012155        std::string source;
22022156        std::string destination;
22032157      assemble_arguments_from_W_table(m_W, 'X', m_SD, m_ea, source, destination);
2204      retString = m_opcode + " " + source + "," + destination;
2158      retString = "move " + source + "," + destination;
2159      // NEW // sprintf(opcode_str, "move(c)");
22052160   }
22062161   void evaluate(dsp56k_core* cpustate) {}
22072162   size_t size() const { return 1; }
r8846r8847
22322187      decode_DDDDD_table(BITSn(word0,0x03e0), m_SD);
22332188        m_W = BITSn(word0,0x0400);
22342189      if (m_SD == iINVALID) return false;
2235
2236      m_opcode = "move";
2237      // NEW // sprintf(opcode_str, "move(c)");
22382190      return true;
22392191   }
22402192   void disassemble(std::string& retString) const
r8846r8847
22422194        std::string source;
22432195        std::string destination;
22442196      assemble_arguments_from_W_table(m_W, 'X', m_SD, m_ea, source, destination);
2245      retString = m_opcode + " " + source + "," + destination;
2197      retString = "move " + source + "," + destination;
2198      // NEW // sprintf(opcode_str, "move(c)");
22462199   }
22472200   void evaluate(dsp56k_core* cpustate) {}
22482201   size_t size() const { return 1; }
r8846r8847
22722225      decode_DDDDD_table(BITSn(word0,0x03e0), m_SD);
22732226        m_W = BITSn(word0,0x0400);
22742227      if (m_SD == iINVALID) return false;
2275
2276      m_opcode = "move";
2277      // NEW // sprintf(opcode_str, "move(c)");
22782228      return true;
22792229   }
22802230   void disassemble(std::string& retString) const
r8846r8847
22822232        std::string source;
22832233        std::string destination;
22842234      assemble_arguments_from_W_table(m_W, 'X', m_SD, m_ea, source, destination);
2285      retString = m_opcode + " " + source + "," + destination;
2235      retString = "move " + source + "," + destination;
2236      // NEW // sprintf(opcode_str, "move(c)");
22862237   }
22872238   void evaluate(dsp56k_core* cpustate) {}
22882239   size_t size() const { return 1; }
r8846r8847
23182269      if ((word0 & 0x000c) == 0x000c && (word0 & 0x0400) == 0x0000)
23192270         return false;
23202271
2321      m_opcode = "move";
2322      // NEW // sprintf(opcode_str, "move(c)");
23232272      return true;
23242273   }
23252274   void disassemble(std::string& retString) const
r8846r8847
23272276        std::string ea;
23282277        assemble_ea_from_t_table(m_t, m_value, ea);
23292278
2330        retString = m_opcode + " ";
2279        retString = "move ";
23312280        if (m_W) retString += ea + "," + regIdAsString(m_sd);
23322281        else    retString += regIdAsString(m_sd) + "," + ea;
2282      // NEW // sprintf(opcode_str, "move(c)");
23332283   }
23342284   void evaluate(dsp56k_core* cpustate)
23352285    {
r8846r8847
23892339
23902340      if (m_source == iINVALID || m_destination == iINVALID) return false;
23912341      if (m_source == iSSH && m_destination == iSSH) return false;
2392
2393      m_opcode = "move";
2394      // NEW // sprintf(opcode_str, "move(c)");
23952342      return true;
23962343   }
23972344   void disassemble(std::string& retString) const
23982345   {
2399      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
2346      retString = "move " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
2347      // NEW // sprintf(opcode_str, "move(c)");
24002348   }
24012349   void evaluate(dsp56k_core* cpustate) {}
24022350   size_t size() const { return 1; }
r8846r8847
24122360        m_W = 0;
24132361      m_b = 0;
24142362        m_SD = iINVALID;
2363        m_mnem = oINVALID;
24152364      m_valid = decode(word0, word1);
24162365   }
24172366   bool decode(const UINT16 word0, const UINT16 word1)
r8846r8847
24192368      m_b = BITSn(word0,0x00ff);
24202369        m_W = BITSn(word1,0x0400);
24212370      decode_DDDDD_table(BITSn(word1,0x03e0), m_SD);
2422
2423      m_opcode = "move";
2424      // NEW // m_opcode = "move(c)";
24252371      return true;
24262372   }
24272373   void disassemble(std::string& retString) const
r8846r8847
24292375        std::string source;
24302376        std::string destination;
24312377      assemble_reg_from_W_table(m_W, 'X', m_SD, m_b, source, destination);
2432      retString = m_opcode + " " + source + "," + destination;
2378      retString = "move " + source + "," + destination;
2379      // NEW // opcode = "move(c)";
24332380   }
24342381   void evaluate(dsp56k_core* cpustate) {}
24352382   size_t size() const { return 2; }
r8846r8847
24392386   INT8 m_b;
24402387    UINT8 m_W;
24412388    reg_id m_SD;
2389    op_mnem m_mnem;
24422390};
24432391
24442392// MOVE(I) : 0010 00DD BBBB BBBB : A-150 ///////////////////////////////////////
r8846r8847
24532401   bool decode(const UINT16 word0, const UINT16 word1)
24542402   {
24552403      m_immediate = (INT8)BITSn(word0,0x00ff);
2456
24572404      decode_DD_table(BITSn(word0,0x0300), m_destination);
2458
2459      m_opcode = "move";
2460      // NEW // sprintf(opcode_str, "move(i)");
24612405      return true;
24622406   }
24632407   void disassemble(std::string& retString) const
r8846r8847
24672411      else                  sprintf(temp, "#<-$%x", 1 - m_immediate - 1);
24682412      // NEW // sprintf(temp, "#$%02x,%s", BITSn(word0,0x00ff), D1);
24692413
2470      retString = m_opcode + " " +
2414      retString = "move " +
24712415               std::string(temp) + "," + regIdAsString(m_destination);
2416      // NEW // sprintf(opcode_str, "move(i)");
24722417   }
24732418   void evaluate(dsp56k_core* cpustate) {}
24742419   size_t size() const { return 1; }
r8846r8847
24962441      decode_HHH_table(BITSn(word0,0x0007), m_SD);
24972442      assemble_ea_from_MM_table(BITSn(word0,0x0018), rNum, m_ea);
24982443        m_W = BITSn(word0,0x0100);
2499
2500      m_opcode = "move";
2501      // NEW // sprintf(opcode_str, "move(m)");
25022444      return true;
25032445   }
25042446   void disassemble(std::string& retString) const
r8846r8847
25062448        std::string source;
25072449        std::string destination;
25082450      assemble_arguments_from_W_table(m_W, 'P', m_SD, m_ea, source, destination);
2509      retString = m_opcode + " " + source + "," + destination;
2451      retString = "move " + source + "," + destination;
2452      // NEW // sprintf(opcode_str, "move(m)");
25102453   }
25112454   void evaluate(dsp56k_core* cpustate) {}
25122455   size_t size() const { return 1; }
r8846r8847
25332476   {
25342477        m_W = BITSn(word0,0x0100);
25352478      assemble_eas_from_mm_table(BITSn(word0,0x000c), BITSn(word0,0x00c0), BITSn(word0,0x0003), m_ea, m_ea2);
2536
2537      m_opcode = "move";
2538      // NEW // sprintf(opcode_str, "move(m)*");
25392479      return true;
25402480   }
25412481   void disassemble(std::string& retString) const
r8846r8847
25522492         source = "P:" + m_ea;
25532493         destination = "X:" + m_ea2;
25542494      }
2555      retString = m_opcode + " " + source + "," + destination;
2495      retString = "move " + source + "," + destination;
2496      // NEW // sprintf(opcode_str, "move(m)*");
25562497   }
25572498   void evaluate(dsp56k_core* cpustate) {}
25582499   size_t size() const { return 1; }
r8846r8847
25722513   {
25732514        m_b = 0;
25742515        m_SD = iINVALID;
2516        m_mnem = oINVALID;
25752517      m_valid = decode(word0, word1);
25762518   }
25772519   bool decode(const UINT16 word0, const UINT16 word1)
r8846r8847
25792521      m_b = BITSn(word0,0x00ff);
25802522        m_W = BITSn(word1,0x0100);
25812523      decode_HHH_table(BITSn(word1,0x0007), m_SD);
2582
2583      m_opcode = "move";
2584      // NEW // m_opcode = "move(m)";
25852524      return true;
25862525   }
25872526   void disassemble(std::string& retString) const
r8846r8847
25892528        std::string source;
25902529        std::string destination;
25912530      assemble_reg_from_W_table(m_W, 'P', m_SD, m_b, source, destination);
2592      retString = m_opcode + " " + source + "," + destination;
2531      retString = "move " + source + "," + destination;
2532      // NEW // opcode = "move(m)";
25932533   }
25942534   void evaluate(dsp56k_core* cpustate) {}
25952535   size_t size() const { return 2; }
r8846r8847
25992539    INT8 m_b;
26002540    UINT8 m_W;
26012541    reg_id m_SD;
2542    op_mnem m_mnem;
26022543};
26032544
26042545// MOVE(P) : 0001 100W HH1p pppp : A-156 ///////////////////////////////////////
r8846r8847
26202561      m_ea = "<<$" + m_ea;
26212562
26222563      m_W = BITSn(word0,0x0100);
2623
2624      m_opcode = "movep";
2625      // NEW // sprintf(opcode_str, "move(p)");
26262564      return true;
26272565   }
26282566   void disassemble(std::string& retString) const
r8846r8847
26302568        std::string source;
26312569        std::string destination;
26322570      assemble_arguments_from_W_table(m_W, 'X', m_SD, m_ea, source, destination);
2633      retString = m_opcode + " " + source + "," + destination;
2571      retString = "movep " + source + "," + destination;
2572      // NEW // sprintf(opcode_str, "move(p)");
26342573   }
26352574   void evaluate(dsp56k_core* cpustate) {}
26362575   size_t size() const { return 1; }
r8846r8847
26652604        m_W = BITSn(word0,0x0100);
26662605      m_SD = "X:<<$" + fullAddy;
26672606      // NEW // sprintf(SD, "X:$%s", fullAddy);
2668
2669      m_opcode = "movep";
2670      // NEW // sprintf(opcode_str, "move(p)*");
26712607      return true;
26722608   }
26732609   void disassemble(std::string& retString) const
r8846r8847
26752611        std::string source;
26762612        std::string destination;
26772613      assemble_arguments_from_W_table(m_W, 'X', m_SD, m_ea, source, destination);
2678      retString = m_opcode + " " + source + "," + destination;
2614      retString = "movep " + source + "," + destination;
2615      // NEW // sprintf(opcode_str, "move(p)*");
26792616   }
26802617   void evaluate(dsp56k_core* cpustate) {}
26812618   size_t size() const { return 1; }
r8846r8847
27072644      m_ea = temp;
27082645
27092646        m_W = BITSn(word0,0x0100);
2710     
2711      m_opcode = "moves";
2712      // NEW // sprintf(opcode_str, "move(s)");
27132647      return true;
27142648   }
27152649   void disassemble(std::string& retString) const
r8846r8847
27172651        std::string source;
27182652        std::string destination;
27192653      assemble_arguments_from_W_table(m_W, 'X', m_SD, m_ea, source, destination);
2720      retString = m_opcode + " " + source + "," + destination;
2654      retString = "moves " + source + "," + destination;
2655      // NEW // sprintf(opcode_str, "move(s)");
27212656   }
27222657   void evaluate(dsp56k_core* cpustate) {}
27232658   size_t size() const { return 1; }
r8846r8847
27472682                    m_source, m_source2, m_destination);
27482683
27492684      decode_kSign_table(BITSn(word0,0x40), m_sign);
2750
2751      m_opcode = "mpy";
27522685      return true;
27532686   }
27542687   void disassemble(std::string& retString) const
27552688   {
27562689        std::string ts = m_sign;
27572690        if (ts != "-") ts = "";
2758      retString = m_opcode + " " +
2691      retString = "mpy " +
27592692                   ts +
27602693               regIdAsString(m_source) + "," +
27612694               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
r8846r8847
27822715   {
27832716      decode_QQF_table(BITSn(word0,0x03), BITSn(word0,0x08),
27842717                   m_source, m_source2, m_destination);
2785
2786      m_opcode = "mpy";
27872718      return true;
27882719   }
27892720   void disassemble(std::string& retString) const
27902721   {
2791      retString = m_opcode + " " +
2722      retString = "mpy " +
27922723               regIdAsString(m_source) + "," +
27932724               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
27942725   }
r8846r8847
28132744   {
28142745      decode_QQQF_table(BITSn(word0,0x0007), BITSn(word0,0x0008),
28152746                    m_source, m_source2, m_destination);
2816     
2817      m_opcode = "mpy";
28182747      return true;
28192748   }
28202749   void disassemble(std::string& retString) const
28212750   {
2822      retString = m_opcode + " " +
2751      retString = "mpy " +
28232752               regIdAsString(m_source) + "," +
28242753               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
28252754   }
r8846r8847
28492778                    m_source, m_source2, m_destination);
28502779
28512780      decode_kSign_table(BITSn(word0,0x40), m_sign);
2852
2853      m_opcode = "mpyr";
28542781      return true;
28552782   }
28562783   void disassemble(std::string& retString) const
28572784   {
28582785        std::string ts = m_sign;
28592786        if (ts != "-") ts = "";
2860      retString = m_opcode + " " +
2787      retString = "mpyr " +
28612788               ts +
28622789                   regIdAsString(m_source) + "," +
28632790               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
r8846r8847
28842811   {
28852812      decode_QQF_table(BITSn(word0,0x03), BITSn(word0,0x08),
28862813                   m_source, m_source2, m_destination);
2887
2888      m_opcode = "mpyr";
28892814      return true;
28902815   }
28912816   void disassemble(std::string& retString) const
28922817   {
2893      retString = m_opcode + " " +
2818      retString = "mpyr " +
28942819               regIdAsString(m_source) + "," +
28952820               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
28962821   }
r8846r8847
29082833public:
29092834   Mpysuuu(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
29102835   {
2836        m_mnem = oINVALID;
29112837      m_source2 = iINVALID;
29122838      m_valid = decode(word0, word1);
29132839   }
r8846r8847
29162842      decode_QQF_special_table(BITSn(word0,0x0003), BITSn(word0,0x0008),
29172843                         m_source, m_source2, m_destination);
29182844
2919      std::string a;
2920      decode_s_table(BITSn(word0,0x0004), a);
2921      m_opcode = "mpy" + a;
2922      // NEW // sprintf(opcode_str, "mpy(%s)", A);
2845      decode_s_table(BITSn(word0,0x0004), m_mnem);
29232846      return true;
29242847   }
29252848   void disassemble(std::string& retString) const
29262849   {
2927      retString = m_opcode + " " +
2850        std::string opcode = "mpy" + opMnemonicAsString(m_mnem);
2851       
2852      retString = opcode + " " +
29282853               regIdAsString(m_source) + "," +
29292854               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
2855      // NEW // sprintf(opcode_str, "mpy(%s)", A);
29302856   }
29312857   void evaluate(dsp56k_core* cpustate) {}
29322858   size_t size() const { return 1; }
29332859   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
29342860   
29352861private:
2862    op_mnem m_mnem;
29362863   reg_id m_source2;
29372864};
29382865
r8846r8847
29472874   bool decode(const UINT16 word0, const UINT16 word1)
29482875   {
29492876      decode_F_table(BITSn(word0,0x08), m_destination);
2950
2951      m_opcode = "neg";
29522877      return true;
29532878   }
29542879   void disassemble(std::string& retString) const
29552880   {
2956      retString = m_opcode + " " + regIdAsString(m_destination);
2881      retString = "neg " + regIdAsString(m_destination);
29572882   }
29582883   void evaluate(dsp56k_core* cpustate) {}
29592884   size_t size() const { return 1; }
r8846r8847
29712896   bool decode(const UINT16 word0, const UINT16 word1)
29722897   {
29732898      decode_F_table(BITSn(word0,0x0008), m_destination);
2974      m_opcode = "negc";
29752899      return true;
29762900   }
29772901   void disassemble(std::string& retString) const
29782902   {
2979      retString = m_opcode + " " + regIdAsString(m_destination);
2903      retString = "negc " + regIdAsString(m_destination);
29802904   }
29812905   void evaluate(dsp56k_core* cpustate) {}
29822906   size_t size() const { return 1; }
r8846r8847
29932917   }
29942918   bool decode(const UINT16 word0, const UINT16 word1)
29952919   {
2996      m_opcode = "nop";
29972920      return true;
29982921   }
29992922   void disassemble(std::string& retString) const
30002923   {
3001      retString = m_opcode;
2924      retString = "nop";
30022925   }
30032926   void evaluate(dsp56k_core* cpustate) {}
30042927   size_t size() const { return 1; }
r8846r8847
30182941      decode_F_table(BITSn(word0,0x0008), m_destination);
30192942
30202943      decode_RR_table(BITSn(word0,0x0003), m_source);
3021
3022      m_opcode = "norm";
30232944      return true;
30242945   }
30252946   void disassemble(std::string& retString) const
30262947   {
3027      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
2948      retString = "norm " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
30282949   }
30292950   void evaluate(dsp56k_core* cpustate) {}
30302951   size_t size() const { return 1; }
r8846r8847
30422963   bool decode(const UINT16 word0, const UINT16 word1)
30432964   {
30442965      decode_F_table(BITSn(word0,0x08), m_destination);
3045
3046      m_opcode = "not";
30472966      return true;
30482967   }
30492968   void disassemble(std::string& retString) const
30502969   {
3051      retString = m_opcode + " " + regIdAsString(m_destination);
2970      retString = "not " + regIdAsString(m_destination);
30522971   }
30532972   void evaluate(dsp56k_core* cpustate) {}
30542973   size_t size() const { return 1; }
r8846r8847
30672986   {
30682987      decode_JJF_table(BITSn(word0,0x03),BITSn(word0,0x08),
30692988                   m_source, m_destination);
3070      m_opcode = "or";
30712989      return true;
30722990   }
30732991   void disassemble(std::string& retString) const
30742992   {
3075      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
2993      retString = "or " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
30762994   }
30772995   void evaluate(dsp56k_core* cpustate) {}
30782996   size_t size() const { return 1; }
r8846r8847
30913009   bool decode(const UINT16 word0, const UINT16 word1)
30923010   {
30933011      m_immediate = BITSn(word0,0x00ff);
3094     
30953012      decode_EE_table(BITSn(word0,0x0600), m_destination);
3096      m_opcode = "ori";
3097      // NEW // sprintf(opcode_str, "or(i)");
30983013      return true;
30993014   }
31003015   void disassemble(std::string& retString) const
r8846r8847
31023017      char temp[32];
31033018      sprintf(temp, "#$%x", m_immediate);
31043019      // NEW // sprintf(temp, "#$%02x", BITSn(word0,0x00ff));
3105      retString = m_opcode + " " + std::string(temp) + "," + regIdAsString(m_destination);
3020      retString = "ori " + std::string(temp) + "," + regIdAsString(m_destination);
3021      // NEW // sprintf(opcode_str, "or(i)");
31063022   }
31073023   void evaluate(dsp56k_core* cpustate) {}
31083024   size_t size() const { return 1; }
r8846r8847
31233039   bool decode(const UINT16 word0, const UINT16 word1)
31243040   {
31253041      decode_RR_table(BITSn(word0,0x0003), m_source);
3126
3127      m_opcode = "rep";
31283042      return true;
31293043   }
31303044   void disassemble(std::string& retString) const
31313045   {
31323046      char temp[32];
31333047      sprintf(temp, "X:(%s)", regIdAsString(m_source).c_str());
3134      retString = m_opcode + " " + std::string(temp);
3048      retString = "rep " + std::string(temp);
31353049   }
31363050   void evaluate(dsp56k_core* cpustate) {}
31373051   size_t size() const { return 1; }
r8846r8847
31503064   bool decode(const UINT16 word0, const UINT16 word1)
31513065   {
31523066      m_immediate = BITSn(word0,0x00ff);
3153      m_opcode = "rep";
31543067      return true;
31553068   }
31563069   void disassemble(std::string& retString) const
r8846r8847
31583071      char temp[32];
31593072      sprintf(temp, "#$%x", m_immediate);
31603073      // NEW // sprintf(temp, "#$%02x (%d)", BITSn(word0,0x00ff), BITSn(word0,0x00ff));
3161      retString = m_opcode + " " + std::string(temp);
3074      retString = "rep " + std::string(temp);
31623075   }
31633076   void evaluate(dsp56k_core* cpustate) {}
31643077   size_t size() const { return 1; }
r8846r8847
31803093   {
31813094      decode_DDDDD_table(BITSn(word0,0x001f), m_source);
31823095      if (m_source == iINVALID) return false;
3183     
3184      m_opcode = "rep";
31853096      return true;
31863097   }
31873098   void disassemble(std::string& retString) const
31883099   {
3189      retString = m_opcode + " " + regIdAsString(m_source);
3100      retString = "rep " + regIdAsString(m_source);
31903101   }
31913102   void evaluate(dsp56k_core* cpustate) {}
31923103   size_t size() const { return 1; }
r8846r8847
31993110public:
32003111   Repcc(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
32013112   {
3113        m_mnem = oINVALID;
32023114      m_valid = decode(word0, word1);
32033115   }
32043116   bool decode(const UINT16 word0, const UINT16 word1)
32053117   {
3206      std::string M;
3207      decode_cccc_table(BITSn(word0,0x000f), M);
3208      m_opcode = "rep" + M;
3209      // NEW // sprintf(opcode_str, "rep.%s", M);
3118      decode_cccc_table(BITSn(word0,0x000f), m_mnem);
32103119      return true;
32113120   }
32123121   void disassemble(std::string& retString) const
32133122   {
3214      retString = m_opcode;
3123        std::string opcode = "rep" + opMnemonicAsString(m_mnem);
3124      retString = opcode;
3125      // NEW // sprintf(opcode_str, "rep.%s", M);
32153126   }
32163127   void evaluate(dsp56k_core* cpustate) {}
32173128   size_t size() const { return 1; }
32183129   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
3130
3131private:
3132    op_mnem m_mnem;
32193133};
32203134
32213135// RESET : 0000 0000 0000 1000 : A-186 /////////////////////////////////////////
r8846r8847
32283142   }
32293143   bool decode(const UINT16 word0, const UINT16 word1)
32303144   {
3231      m_opcode = "reset";
32323145      return true;
32333146   }
32343147   void disassemble(std::string& retString) const
32353148   {
3236      retString = m_opcode;
3149      retString = "reset";
32373150   }
32383151   void evaluate(dsp56k_core* cpustate) {}
32393152   size_t size() const { return 1; }
r8846r8847
32513164   bool decode(const UINT16 word0, const UINT16 word1)
32523165   {
32533166      decode_F_table(BITSn(word0,0x08), m_destination);
3254
3255      m_opcode = "rnd";
32563167      return true;
32573168   }
32583169   void disassemble(std::string& retString) const
32593170   {
3260      retString = m_opcode + " " + regIdAsString(m_destination);
3171      retString = "rnd " + regIdAsString(m_destination);
32613172   }
32623173   void evaluate(dsp56k_core* cpustate) {}
32633174   size_t size() const { return 1; }
r8846r8847
32753186   bool decode(const UINT16 word0, const UINT16 word1)
32763187   {
32773188      decode_F_table(BITSn(word0,0x08), m_destination);
3278
3279      m_opcode = "rol";
32803189      return true;
32813190   }
32823191   void disassemble(std::string& retString) const
32833192   {
3284      retString = m_opcode + " " + regIdAsString(m_destination);
3193      retString = "rol " + regIdAsString(m_destination);
32853194   }
32863195   void evaluate(dsp56k_core* cpustate) {}
32873196   size_t size() const { return 1; }
r8846r8847
32993208   bool decode(const UINT16 word0, const UINT16 word1)
33003209   {
33013210      decode_F_table(BITSn(word0,0x08), m_destination);
3302
3303      m_opcode = "ror";
33043211      return true;
33053212   }
33063213   void disassemble(std::string& retString) const
33073214   {
3308      retString = m_opcode + " " + regIdAsString(m_destination);
3215      retString = "ror " + regIdAsString(m_destination);
33093216   }
33103217   void evaluate(dsp56k_core* cpustate) {}
33113218   size_t size() const { return 1; }
r8846r8847
33223229   }
33233230   bool decode(const UINT16 word0, const UINT16 word1)
33243231   {
3325      m_opcode = "rti";
33263232      return true;
33273233   }
33283234   void disassemble(std::string& retString) const
33293235   {
3330      retString = m_opcode;
3236      retString = "rti";
33313237   }
33323238   void evaluate(dsp56k_core* cpustate) {}
33333239   size_t size() const { return 1; }
r8846r8847
33453251   }
33463252   bool decode(const UINT16 word0, const UINT16 word1)
33473253   {
3348      m_opcode = "rts";
33493254      return true;
33503255   }
33513256   void disassemble(std::string& retString) const
33523257   {
3353      retString = m_opcode;
3258      retString = "rts";
33543259   }
33553260   void evaluate(dsp56k_core* cpustate) {}
33563261   size_t size() const { return 1; }
r8846r8847
33703275   {
33713276      decode_JF_table(BITSn(word0,0x01), BITSn(word0,0x08),
33723277                  m_source, m_destination);
3373
3374      m_opcode = "sbc";
33753278      return true;
33763279   }
33773280   void disassemble(std::string& retString) const
33783281   {
3379      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
3282      retString = "sbc " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
33803283   }
33813284   void evaluate(dsp56k_core* cpustate) {}
33823285   size_t size() const { return 1; }
r8846r8847
33933296   }
33943297   bool decode(const UINT16 word0, const UINT16 word1)
33953298   {
3396      m_opcode = "stop";
33973299      return true;
33983300   }
33993301   void disassemble(std::string& retString) const
34003302   {
3401      retString = m_opcode;
3303      retString = "stop";
34023304   }
34033305   void evaluate(dsp56k_core* cpustate) {}
34043306   size_t size() const { return 1; }
r8846r8847
34173319   {
34183320      decode_JJJF_table(BITSn(word0,0x07), BITSn(word0,0x08),
34193321                    m_source, m_destination);
3420      m_opcode = "sub";
34213322      return true;
34223323   }
34233324   void disassemble(std::string& retString) const
34243325   {
3425      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
3326      retString = "sub " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
34263327   }
34273328   void evaluate(dsp56k_core* cpustate) {}
34283329   size_t size() const { return 1; }
r8846r8847
34353336public:
34363337   Sub_2(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
34373338   {
3339        m_opcode = "";
34383340      m_valid = decode(word0, word1);
34393341   }
34403342   bool decode(const UINT16 word0, const UINT16 word1)
r8846r8847
34523354   void evaluate(dsp56k_core* cpustate) {}
34533355   size_t size() const { return 1; }
34543356   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
3357   
3358private:
3359    std::string m_opcode;
34553360};
34563361
34573362// SUBL : .... .... 0100 F001 : A-204 //////////////////////////////////////////
r8846r8847
34753380         m_source = iA;
34763381         m_destination = iB;
34773382      }
3478
3479      m_opcode = "subl";
34803383      return true;
34813384   }
34823385   void disassemble(std::string& retString) const
34833386   {
3484      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
3387      retString = "subl " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
34853388   }
34863389   void evaluate(dsp56k_core* cpustate) {}
34873390   size_t size() const { return 1; }
r8846r8847
34993402   bool decode(const UINT16 word0, const UINT16 word1)
35003403   {
35013404      decode_F_table(BITSn(word0,0x0008), m_destination);
3502
3503      m_opcode = "swap";
35043405      return true;
35053406   }
35063407   void disassemble(std::string& retString) const
35073408   {
3508      retString = m_opcode + " " + regIdAsString(m_destination);
3409      retString = "swap " + regIdAsString(m_destination);
35093410   }
35103411   void evaluate(dsp56k_core* cpustate) {}
35113412   size_t size() const { return 1; }
r8846r8847
35223423   }
35233424   bool decode(const UINT16 word0, const UINT16 word1)
35243425   {
3525      m_opcode = "swi";
35263426      return true;
35273427   }
35283428   void disassemble(std::string& retString) const
35293429   {
3530      retString = m_opcode;
3430      retString = "swi";
35313431   }
35323432   void evaluate(dsp56k_core* cpustate) {}
35333433   size_t size() const { return 1; }
r8846r8847
35403440public:
35413441   Tcc(const Opcode* oco, const UINT16 word0, const UINT16 word1) : Instruction(oco)
35423442   {
3443        m_mnem = oINVALID;
35433444      m_destination2 = iINVALID;
35443445      m_valid = decode(word0, word1);
35453446   }
r8846r8847
35503451     
35513452      decode_RR_table(BITSn(word0,0x0030), m_destination2);
35523453
3553      std::string M;
3554      decode_cccc_table(BITSn(word0,0x03c0), M);
3555      m_opcode = "t" + M;
3556      // NEW // sprintf(opcode_str, "t.%s", M);
3454      decode_cccc_table(BITSn(word0,0x03c0), m_mnem);
35573455      if (m_source != m_destination)
35583456         return true;
35593457      if (m_destination2 != iR0)
r8846r8847
35633461   }
35643462   void disassemble(std::string& retString) const
35653463   {
3566      retString = m_opcode;
3464        std::string opcode = "t" + opMnemonicAsString(m_mnem);
3465      // NEW // sprintf(opcode_str, "t.%s", M);
3466       
3467      retString = opcode;
35673468      if (m_source != m_destination)
35683469         retString += std::string(" ") + regIdAsString(m_source) + "," + regIdAsString(m_destination);
35693470     
r8846r8847
35753476   size_t accumulatorBitsModified() const { return BM_HIGH | BM_MIDDLE | BM_LOW; }
35763477   
35773478private:
3479    op_mnem m_mnem;
35783480   reg_id m_destination2;
35793481};
35803482
r8846r8847
35903492   {
35913493      decode_JJJF_table(BITSn(word0,0x07), BITSn(word0,0x08),
35923494                    m_source, m_destination);
3593
3594      m_opcode = "tfr";
35953495      return true;
35963496   }
35973497   void disassemble(std::string& retString) const
35983498   {
3599      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
3499      retString = "tfr " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
36003500   }
36013501   void evaluate(dsp56k_core* cpustate) {}
36023502   size_t size() const { return 1; }
r8846r8847
36153515   {
36163516      decode_DDF_table(BITSn(word0,0x03), BITSn(word0,0x08),
36173517                   m_source, m_destination);
3618
3619      m_opcode = "tfr";
36203518      return true;
36213519   }
36223520   void disassemble(std::string& retString) const
36233521   {
3624      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
3522      retString = "tfr " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
36253523   }
36263524   void evaluate(dsp56k_core* cpustate) {}
36273525   size_t size() const { return 1; }
r8846r8847
36403538   {
36413539      decode_JF_table(BITSn(word0,0x0001),BITSn(word0,0x0008),
36423540                  m_destination, m_source);
3643
3644      m_opcode = "tfr2";
36453541      return true;
36463542   }
36473543   void disassemble(std::string& retString) const
36483544   {
3649      retString = m_opcode + " " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
3545      retString = "tfr2 " + regIdAsString(m_source) + "," + regIdAsString(m_destination);
36503546   }
36513547   void evaluate(dsp56k_core* cpustate) {}
36523548   size_t size() const { return 1; }
r8846r8847
36793575      assemble_ea_from_m_table(BITSn(word0,0x0200), rNum, m_ea);
36803576
36813577        m_W = BITSn(word0,0x0100);
3682
3683      m_opcode = "tfr3";
36843578      return true;
36853579   }
36863580   void disassemble(std::string& retString) const
r8846r8847
36883582        std::string source2;
36893583        std::string destination2;
36903584      assemble_arguments_from_W_table(m_W, 'X', m_SD, m_ea, source2, destination2);
3691      retString = m_opcode + " " +
3585      retString = "tfr3 " +
36923586               regIdAsString(m_source) + "," + regIdAsString(m_destination) + " " +
36933587                    source2 + "," + destination2;
36943588   }
r8846r8847
37153609   bool decode(const UINT16 word0, const UINT16 word1)
37163610   {
37173611      decode_F_table(BITSn(word0,0x08), m_destination);
3718
3719      m_opcode = "tst";
37203612      return true;
37213613   }
37223614   void disassemble(std::string& retString) const
37233615   {
3724      retString = m_opcode + " " + regIdAsString(m_destination);
3616      retString = "tst " + regIdAsString(m_destination);
37253617   }
37263618   void evaluate(dsp56k_core* cpustate) {}
37273619   size_t size() const { return 1; }
r8846r8847
37393631   bool decode(const UINT16 word0, const UINT16 word1)
37403632   {
37413633      decode_DD_table(BITSn(word0,0x0003), m_source);
3742
3743      m_opcode = "tst2";
37443634      return true;
37453635   }
37463636   void disassemble(std::string& retString) const
37473637   {
3748      retString = m_opcode + " " + regIdAsString(m_source);
3638      retString = "tst2 " + regIdAsString(m_source);
37493639   }
37503640   void evaluate(dsp56k_core* cpustate) {}
37513641   size_t size() const { return 1; }
r8846r8847
37623652   }
37633653   bool decode(const UINT16 word0, const UINT16 word1)
37643654   {
3765      m_opcode = "wait";
37663655      return true;
37673656   }
37683657   void disassemble(std::string& retString) const
37693658   {
3770      retString = m_opcode;
3659      retString = "wait";
37713660   }
37723661   void evaluate(dsp56k_core* cpustate) {}
37733662   size_t size() const { return 1; }
r8846r8847
37853674   bool decode(const UINT16 word0, const UINT16 word1)
37863675   {
37873676      decode_F_table(BITSn(word0,0x0008), m_destination);
3788
3789      m_opcode = "zero";
37903677      return true;
37913678   }
37923679   void disassemble(std::string& retString) const
37933680   {
3794      retString = m_opcode + " " + regIdAsString(m_destination);
3681      retString = "zero " + regIdAsString(m_destination);
37953682   }
37963683   void evaluate(dsp56k_core* cpustate) {}
37973684   size_t size() const { return 1; }
r8846r8847
38263713         m_source  = iX1;
38273714         m_source2 = iY1;
38283715      }
3829     
3830      m_opcode = "shfl";
38313716      return true;
38323717   }
38333718   void disassemble(std::string& retString) const
38343719   {
3835      retString = m_opcode + " " +
3720      retString = "shfl " +
38363721               regIdAsString(m_source) + "," +
38373722               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
38383723   }
r8846r8847
38723757         m_source  = iX1;
38733758         m_source2 = iY1;
38743759      }
3875     
3876      m_opcode = "shfr";
38773760      return true;
38783761   }
38793762   void disassemble(std::string& retString) const
38803763   {
3881      retString = m_opcode + " " +
3764      retString = "shfr " +
38823765               regIdAsString(m_source) + "," +
38833766               regIdAsString(m_source2) + "," + regIdAsString(m_destination);
38843767   }
src/emu/cpu/rsp/rspdrc.c
r8846r8847
72077207   drcuml_block *block;
72087208   jmp_buf errorbuf;
72097209
7210   profiler_mark_start(PROFILER_DRC_COMPILE);
7210   g_profiler.start(PROFILER_DRC_COMPILE);
72117211
72127212   /* get a description of this sequence */
72137213   desclist = drcfe_describe_code(rsp->impstate->drcfe, pc);
r8846r8847
72887288
72897289   /* end the sequence */
72907290   drcuml_block_end(block);
7291   profiler_mark_end();
7291   g_profiler.stop();
72927292}
72937293
72947294/***************************************************************************
src/emu/cpu/powerpc/ppcdrc.c
r8846r8847
947947   drcuml_block *block;
948948   jmp_buf errorbuf;
949949
950   profiler_mark_start(PROFILER_DRC_COMPILE);
950   g_profiler.start(PROFILER_DRC_COMPILE);
951951
952952   /* get a description of this sequence */
953953   desclist = drcfe_describe_code(ppc->impstate->drcfe, pc);
r8846r8847
10301030
10311031   /* end the sequence */
10321032   drcuml_block_end(block);
1033   profiler_mark_end();
1033   g_profiler.stop();
10341034}
10351035
10361036
src/emu/cpu/sh2/sh2drc.c
r8846r8847
925925   drcuml_block *block;
926926   jmp_buf errorbuf;
927927
928   profiler_mark_start(PROFILER_DRC_COMPILE);
928   g_profiler.start(PROFILER_DRC_COMPILE);
929929
930930   /* get a description of this sequence */
931931   desclist = drcfe_describe_code(sh2->drcfe, pc);
r8846r8847
10161016
10171017   /* end the sequence */
10181018   drcuml_block_end(block);
1019   profiler_mark_end();
1019   g_profiler.stop();
10201020}
10211021
10221022/*-------------------------------------------------
src/emu/cpu/sh2/sh2comn.c
r8846r8847
773773   state_save_register_device_item(device, 0, sh2->frt_input);
774774   state_save_register_device_item(device, 0, sh2->internal_irq_level);
775775   state_save_register_device_item(device, 0, sh2->internal_irq_vector);
776   state_save_register_device_item(device, 0, sh2->icount);
777776   state_save_register_device_item_array(device, 0, sh2->dma_timer_active);
778777}
779778
src/emu/cpu/mips/mips3drc.c
r8846r8847
742742   drcuml_block *block;
743743   jmp_buf errorbuf;
744744
745   profiler_mark_start(PROFILER_DRC_COMPILE);
745   g_profiler.start(PROFILER_DRC_COMPILE);
746746
747747   /* get a description of this sequence */
748748   desclist = drcfe_describe_code(mips3->impstate->drcfe, pc);
r8846r8847
827827
828828   /* end the sequence */
829829   drcuml_block_end(block);
830   profiler_mark_end();
830   g_profiler.stop();
831831}
832832
833833
src/emu/video/vooddefs.h
r8846r8847
1/*************************************************************************
1/***************************************************************************
22
3    3dfx Voodoo Graphics SST-1/2 emulator
3    vooddefs.h
44
5    emulator by Aaron Giles
5    3dfx Voodoo Graphics SST-1/2 emulator.
66
7**************************************************************************/
7****************************************************************************
88
9    Copyright Aaron Giles
10    All rights reserved.
911
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
40
1041/*************************************
1142 *
1243 *  Misc. constants
src/emu/video/voodoo.c
r8846r8847
1/***************************************************************************
2
3    voodoo.c
4
5    3dfx Voodoo Graphics SST-1/2 emulator.
6
7****************************************************************************
8
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38****************************************************************************
39
140//fix me -- blitz2k dies when starting a game with heavy fog (in DRC)
241
3/*************************************************************************
42****************************************************************************
443
544    3dfx Voodoo Graphics SST-1/2 emulator
645
r8846r8847
34173456   voodoo_state *v = get_safe_token(device);
34183457   int stall = FALSE;
34193458
3420   profiler_mark_start(PROFILER_USER1);
3459   g_profiler.start(PROFILER_USER1);
34213460
34223461   /* should not be getting accesses while stalled */
34233462   if (v->pci.stall_state != NOT_STALLED)
r8846r8847
34453484               if (offset & 0x40000/4)
34463485                  data = FLIPENDIAN_INT32(data);
34473486               cmdfifo_w(v, &v->fbi.cmdfifo[0], offset & 0xffff, data);
3448               profiler_mark_end();
3487               g_profiler.stop();
34493488               return;
34503489            }
34513490
r8846r8847
34583497                  v->fbi.swaps_pending++;
34593498
34603499               logerror("Ignoring write to %s in CMDFIFO mode\n", v->regnames[offset & 0xff]);
3461               profiler_mark_end();
3500               g_profiler.stop();
34623501               return;
34633502            }
34643503         }
r8846r8847
34753514      /* ignore if writes aren't allowed */
34763515      if (!(access & REGISTER_WRITE))
34773516      {
3478         profiler_mark_end();
3517         g_profiler.stop();
34793518         return;
34803519      }
34813520
r8846r8847
35113550            timer_get_time(device->machine).seconds, (UINT32)(timer_get_time(device->machine).attoseconds >> 32), (UINT32)timer_get_time(device->machine).attoseconds,
35123551            v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.attoseconds >> 32), (UINT32)v->pci.op_end_time.attoseconds);
35133552      }
3514      profiler_mark_end();
3553      g_profiler.stop();
35153554      return;
35163555   }
35173556
r8846r8847
35773616      stall_cpu(v, STALLED_UNTIL_FIFO_EMPTY, timer_get_time(device->machine));
35783617   }
35793618
3580   profiler_mark_end();
3619   g_profiler.stop();
35813620}
35823621
35833622
r8846r8847
47884827   int destbuf;
47894828   int pixels;
47904829
4791   profiler_mark_start(PROFILER_USER2);
4830   g_profiler.start(PROFILER_USER2);
47924831
47934832   /* determine the number of TMUs involved */
47944833   texcount = 0;
r8846r8847
48594898   /* update stats */
48604899   v->stats.total_triangles++;
48614900
4862   profiler_mark_end();
4901   g_profiler.stop();
48634902
48644903   /* 1 pixel per clock, plus some setup time */
48654904   if (LOG_REGISTERS) logerror("cycles = %d\n", TRIANGLE_SETUP_CLOCKS + pixels);
src/emu/video/voodoo.h
r8846r8847
1/*************************************************************************
1/***************************************************************************
22
3    3dfx Voodoo Graphics SST-1 emulator
3    voodoo.h
44
5    driver by Aaron Giles
5    3dfx Voodoo Graphics SST-1/2 emulator.
66
7**************************************************************************/
7****************************************************************************
88
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38***************************************************************************/
39
940#ifndef __VOODOO_H__
1041#define __VOODOO_H__
1142
src/emu/tilemap.c
r8846r8847
824824   if (!tmap->enable)
825825      return;
826826
827profiler_mark_start(PROFILER_TILEMAP_DRAW);
827g_profiler.start(PROFILER_TILEMAP_DRAW);
828828   /* configure the blit parameters based on the input parameters */
829829   configure_blit_parameters(&blit, tmap, dest, cliprect, flags, priority, priority_mask);
830830
r8846r8847
927927         }
928928      }
929929   }
930profiler_mark_end();
930g_profiler.stop();
931931}
932932
933933
r8846r8847
962962      return;
963963   }
964964
965profiler_mark_start(PROFILER_TILEMAP_DRAW_ROZ);
965g_profiler.start(PROFILER_TILEMAP_DRAW_ROZ);
966966   /* configure the blit parameters */
967967   configure_blit_parameters(&blit, tmap, dest, cliprect, flags, priority, priority_mask);
968968
r8846r8847
971971
972972   /* then do the roz copy */
973973   tilemap_draw_roz_core(tmap, &blit, startx, starty, incxx, incxy, incyx, incyy, wraparound);
974profiler_mark_end();
974g_profiler.stop();
975975}
976976
977977
r8846r8847
12741274   if (tmap->all_tiles_clean)
12751275      return;
12761276
1277profiler_mark_start(PROFILER_TILEMAP_DRAW);
1277g_profiler.start(PROFILER_TILEMAP_DRAW);
12781278
12791279   /* compute which columns and rows to update */
12801280   if (cliprect != NULL)
r8846r8847
13141314   if (mincol == 0 && minrow == 0 && maxcol == tmap->cols - 1 && maxcol == tmap->rows - 1)
13151315      tmap->all_tiles_clean = TRUE;
13161316
1317profiler_mark_end();
1317g_profiler.stop();
13181318}
13191319
13201320
r8846r8847
13291329   tilemap_memory_index memindex;
13301330   UINT32 flags;
13311331
1332profiler_mark_start(PROFILER_TILEMAP_UPDATE);
1332g_profiler.start(PROFILER_TILEMAP_UPDATE);
13331333
13341334   /* call the get info callback for the associated memory index */
13351335   memindex = tmap->logical_to_memory[logindex];
r8846r8847
13531353      tmap->gfx_dirtyseq[tmap->tileinfo.gfxnum] = tmap->machine->gfx[tmap->tileinfo.gfxnum]->dirtyseq;
13541354   }
13551355
1356profiler_mark_end();
1356g_profiler.stop();
13571357}
13581358
13591359
src/emu/video.c
r8846r8847
297297      init_buffered_spriteram(machine);
298298
299299   /* call the PALETTE_INIT function */
300   if (machine->config->m_init_palette != NULL)
301      (*machine->config->m_init_palette)(machine, memory_region(machine, "proms"));
300   machine->driver_data<driver_data_t>()->palette_init(memory_region(machine, "proms"));
302301
303302   /* create a render target for snapshots */
304303   viewname = options_get_string(machine->options(), OPTION_SNAPVIEW);
r8846r8847
461460      update_throttle(machine, current_time);
462461
463462   /* ask the OSD to update */
464   profiler_mark_start(PROFILER_BLIT);
463   g_profiler.start(PROFILER_BLIT);
465464   osd_update(machine, !debug && skipped_it);
466   profiler_mark_end();
465   g_profiler.stop();
467466
468467   /* perform tasks for this frame */
469468   if (!debug)
r8846r8847
485484         machine->primary_screen->scanline0_callback();
486485
487486      /* otherwise, call the video EOF callback */
488      else if (machine->config->m_video_eof != NULL)
487      else
489488      {
490         profiler_mark_start(PROFILER_VIDEO);
491         (*machine->config->m_video_eof)(machine);
492         profiler_mark_end();
489         g_profiler.start(PROFILER_VIDEO);
490         machine->driver_data<driver_data_t>()->video_eof();
491         g_profiler.stop();
493492      }
494493   }
495494}
r8846r8847
882881       allowed_to_sleep = TRUE;
883882
884883   /* loop until we reach our target */
885   profiler_mark_start(PROFILER_IDLE);
884   g_profiler.start(PROFILER_IDLE);
886885   while (current_ticks < target_ticks)
887886   {
888887      osd_ticks_t delta;
r8846r8847
920919      }
921920      current_ticks = new_ticks;
922921   }
923   profiler_mark_end();
922   g_profiler.stop();
924923
925924   return current_ticks;
926925}
r8846r8847
13701369      png_info pnginfo = { 0 };
13711370      png_error error;
13721371
1373      profiler_mark_start(PROFILER_MOVIE_REC);
1372      g_profiler.start(PROFILER_MOVIE_REC);
13741373
13751374      /* create the bitmap */
13761375      create_snapshot_bitmap(NULL);
r8846r8847
14061405         global.movie_frame++;
14071406      }
14081407
1409      profiler_mark_end();
1408      g_profiler.stop();
14101409   }
14111410}
14121411
r8846r8847
15051504      attotime curtime = timer_get_time(machine);
15061505      avi_error avierr;
15071506
1508      profiler_mark_start(PROFILER_MOVIE_REC);
1507      g_profiler.start(PROFILER_MOVIE_REC);
15091508
15101509      /* create the bitmap */
15111510      create_snapshot_bitmap(NULL);
r8846r8847
15261525         global.movie_frame++;
15271526      }
15281527
1529      profiler_mark_end();
1528      g_profiler.stop();
15301529   }
15311530}
15321531
r8846r8847
15431542   {
15441543      avi_error avierr;
15451544
1546      profiler_mark_start(PROFILER_MOVIE_REC);
1545      g_profiler.start(PROFILER_MOVIE_REC);
15471546
15481547      /* write the next frame */
15491548      avierr = avi_append_sound_samples(global.avifile, 0, sound + 0, numsamples, 1);
r8846r8847
15521551      if (avierr != AVIERR_NONE)
15531552         video_avi_end_recording(machine);
15541553
1555      profiler_mark_end();
1554      g_profiler.stop();
15561555   }
15571556}
15581557
r8846r8847
21182117   {
21192118      UINT32 flags = UPDATE_HAS_NOT_CHANGED;
21202119
2121      profiler_mark_start(PROFILER_VIDEO);
2120      g_profiler.start(PROFILER_VIDEO);
21222121      LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.min_y, clip.max_y));
21232122
2124      if (machine->config->m_video_update != NULL)
2125         flags = (*machine->config->m_video_update)(this, m_bitmap[m_curbitmap], &clip);
2123      flags = machine->driver_data<driver_data_t>()->video_update(*this, *m_bitmap[m_curbitmap], clip);
21262124      global.partial_updates_this_frame++;
2127      profiler_mark_end();
2125      g_profiler.stop();
21282126
21292127      // if we modified the bitmap, we have to commit
21302128      m_changed |= ~flags & UPDATE_HAS_NOT_CHANGED;
src/emu/inptport.c
r8846r8847
24682468   INT32 mouse_target_y;
24692469   int mouse_button;
24702470
2471profiler_mark_start(PROFILER_INPUT);
2471g_profiler.start(PROFILER_INPUT);
24722472
24732473   /* record/playback information about the current frame */
24742474   playback_frame(machine, curtime);
r8846r8847
25462546         }
25472547   }
25482548
2549profiler_mark_end();
2549g_profiler.stop();
25502550}
25512551
25522552
src/emu/emu.h
r8846r8847
5252// core emulator headers -- must be first
5353#include "emucore.h"
5454#include "eminline.h"
55#include "profiler.h"
5556
5657// commonly-referenecd utilities imported from lib/util
5758#include "chd.h"
src/emu/machine.c
r8846r8847
203203   // allocate the driver data (after devices)
204204   if (m_config.m_driver_data_alloc != NULL)
205205      m_driver_data = (*m_config.m_driver_data_alloc)(*this);
206   else
207      m_driver_data = auto_alloc(this, driver_data_t(*this));
206208
207209   // find devices
208210   primary_screen = screen_first(*this);
r8846r8847
267269   output_init(this);
268270   state_init(this);
269271   state_save_allow_registration(this, true);
272   state_save_register_presave(this, pre_save_static, NULL);
273   state_save_register_postload(this, post_load_static, NULL);
270274   palette_init(this);
271275   render_init(this);
272276   ui_init(this);
r8846r8847
338342      debugger_init(this);
339343
340344   // call the driver's _START callbacks
341   if (m_config.m_machine_start != NULL)
342      (*m_config.m_machine_start)(this);
343   if (m_config.m_sound_start != NULL)
344      (*m_config.m_sound_start)(this);
345   if (m_config.m_video_start != NULL)
346      (*m_config.m_video_start)(this);
345   m_driver_data->machine_start();
346   m_driver_data->sound_start();
347   m_driver_data->video_start();
347348
348349   // if we're coming in with a savegame request, process it now
349350   const char *savegame = options_get_string(&m_options, OPTION_STATE);
r8846r8847
403404      m_hard_reset_pending = false;
404405      while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE)
405406      {
406         profiler_mark_start(PROFILER_EXTRA);
407         g_profiler.start(PROFILER_EXTRA);
407408
408409         // execute CPUs if not paused
409410         if (!m_paused)
r8846r8847
417418         if (m_saveload_schedule != SLS_NONE)
418419            handle_saveload();
419420
420         profiler_mark_end();
421         g_profiler.stop();
421422      }
422423
423424      // and out via the exit phase
r8846r8847
713714   // process only if there is a target
714715   if (m_logerror_list != NULL)
715716   {
716      profiler_mark_start(PROFILER_LOGERROR);
717      g_profiler.start(PROFILER_LOGERROR);
717718
718719      // dump to the buffer
719720      vsnprintf(giant_string_buffer, ARRAY_LENGTH(giant_string_buffer), format, args);
r8846r8847
722723      for (logerror_callback_item *cb = m_logerror_list; cb != NULL; cb = cb->m_next)
723724         (*cb->m_func)(*this, giant_string_buffer);
724725
725      profiler_mark_end();
726      g_profiler.stop();
726727   }
727728}
728729
r8846r8847
863864
864865
865866//-------------------------------------------------
867//  pre_save_static - callback to prepare for
868//  state saving
869//-------------------------------------------------
870
871STATE_PRESAVE( running_machine::pre_save_static )
872{
873   machine->m_driver_data->pre_save();
874}
875
876
877//-------------------------------------------------
878//  post_load_static - callback to update after
879//  static loading
880//-------------------------------------------------
881
882STATE_POSTLOAD( running_machine::post_load_static )
883{
884   machine->m_driver_data->post_load();
885}
886
887
888//-------------------------------------------------
866889//  soft_reset - actually perform a soft-reset
867890//  of the system
868891//-------------------------------------------------
r8846r8847
880903   call_notifiers(MACHINE_NOTIFY_RESET);
881904
882905   // run the driver's reset callbacks
883   if (m_config.m_machine_reset != NULL)
884      (*m_config.m_machine_reset)(this);
885   if (m_config.m_sound_reset != NULL)
886      (*m_config.m_sound_reset)(this);
887   if (m_config.m_video_reset != NULL)
888      (*m_config.m_video_reset)(this);
906   m_driver_data->machine_reset();
907   m_driver_data->sound_reset();
908   m_driver_data->video_reset();
889909
890910   // now we're running
891911   m_current_phase = MACHINE_PHASE_RUNNING;
r8846r8847
9881008}
9891009
9901010
1011//-------------------------------------------------
1012//  machine_start - default implementation which
1013//  calls to the legacy machine_start function
1014//-------------------------------------------------
9911015
1016void driver_data_t::machine_start()
1017{
1018   if (m_machine.m_config.m_machine_start != NULL)
1019      (*m_machine.m_config.m_machine_start)(&m_machine);
1020}
1021
1022
1023//-------------------------------------------------
1024//  machine_reset - default implementation which
1025//  calls to the legacy machine_reset function
1026//-------------------------------------------------
1027
1028void driver_data_t::machine_reset()
1029{
1030   if (m_machine.m_config.m_machine_reset != NULL)
1031      (*m_machine.m_config.m_machine_reset)(&m_machine);
1032}
1033
1034
1035//-------------------------------------------------
1036//  sound_start - default implementation which
1037//  calls to the legacy sound_start function
1038//-------------------------------------------------
1039
1040void driver_data_t::sound_start()
1041{
1042   if (m_machine.m_config.m_sound_start != NULL)
1043      (*m_machine.m_config.m_sound_start)(&m_machine);
1044}
1045
1046
1047//-------------------------------------------------
1048//  sound_reset - default implementation which
1049//  calls to the legacy sound_reset function
1050//-------------------------------------------------
1051
1052void driver_data_t::sound_reset()
1053{
1054   if (m_machine.m_config.m_sound_reset != NULL)
1055      (*m_machine.m_config.m_sound_reset)(&m_machine);
1056}
1057
1058
1059//-------------------------------------------------
1060//  palette_init - default implementation which
1061//  calls to the legacy palette_init function
1062//-------------------------------------------------
1063
1064void driver_data_t::palette_init(const UINT8 *color_prom)
1065{
1066   if (m_machine.m_config.m_init_palette != NULL)
1067      (*m_machine.m_config.m_init_palette)(&m_machine, color_prom);
1068}
1069
1070
1071//-------------------------------------------------
1072//  video_start - default implementation which
1073//  calls to the legacy video_start function
1074//-------------------------------------------------
1075
1076void driver_data_t::video_start()
1077{
1078   if (m_machine.m_config.m_video_start != NULL)
1079      (*m_machine.m_config.m_video_start)(&m_machine);
1080}
1081
1082
1083//-------------------------------------------------
1084//  video_reset - default implementation which
1085//  calls to the legacy video_reset function
1086//-------------------------------------------------
1087
1088void driver_data_t::video_reset()
1089{
1090   if (m_machine.m_config.m_video_reset != NULL)
1091      (*m_machine.m_config.m_video_reset)(&m_machine);
1092}
1093
1094
1095//-------------------------------------------------
1096//  video_update - default implementation which
1097//  calls to the legacy video_update function
1098//-------------------------------------------------
1099
1100bool driver_data_t::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
1101{
1102   if (m_machine.m_config.m_video_update != NULL)
1103      return (*m_machine.m_config.m_video_update)(&screen, &bitmap, &cliprect);
1104   return 0;
1105}
1106
1107
1108//-------------------------------------------------
1109//  video_eof - default implementation which
1110//  calls to the legacy video_eof function
1111//-------------------------------------------------
1112
1113void driver_data_t::video_eof()
1114{
1115   if (m_machine.m_config.m_video_eof != NULL)
1116      (*m_machine.m_config.m_video_eof)(&m_machine);
1117}
1118
1119
1120//-------------------------------------------------
1121//  pre_save - default implementation which
1122//  does nothing
1123//-------------------------------------------------
1124
1125void driver_data_t::pre_save()
1126{
1127}
1128
1129
1130//-------------------------------------------------
1131//  post_load - default implementation which
1132//  does nothing
1133//-------------------------------------------------
1134
1135void driver_data_t::post_load()
1136{
1137}
1138
1139
1140
9921141//**************************************************************************
9931142//  SYSTEM TIME
9941143//**************************************************************************
src/emu/machine.h
r8846r8847
160160// base class for all driver data structures
161161class driver_data_t : public bindable_object
162162{
163   friend class running_machine;
164   
163165public:
164166   driver_data_t(running_machine &machine);
165167   virtual ~driver_data_t();
166168
169   virtual void machine_start();
170   virtual void machine_reset();
171   
172   virtual void sound_start();
173   virtual void sound_reset();
174   
175   virtual void palette_init(const UINT8 *color_prom);
176   virtual void video_start();
177   virtual void video_reset();
178   virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
179   virtual void video_eof();
180
181   virtual void pre_save();
182   virtual void post_load();
183
167184   running_machine &   m_machine;
168185};
169186
r8846r8847
406423   void set_saveload_filename(const char *filename);
407424   void fill_systime(system_time &systime, time_t t);
408425   void handle_saveload();
426   static STATE_PRESAVE( pre_save_static );
427   static STATE_POSTLOAD( post_load_static );
409428
410429   static TIMER_CALLBACK( static_soft_reset );
411430   void soft_reset();
src/emu/ui.c
r8846r8847
822822
823823void ui_set_show_profiler(int show)
824824{
825   if (show)
826   {
827      show_profiler = TRUE;
828      profiler_start();
829   }
830   else
831   {
832      show_profiler = FALSE;
833      profiler_stop();
834   }
825   show_profiler = show;
826   g_profiler.enable(show);
835827}
836828
837829
r8846r8847
13021294   if (show_profiler)
13031295   {
13041296      astring profilertext;
1305      profiler_get_text(machine, profilertext);
1297      g_profiler.text(*machine, profilertext);
13061298      ui_draw_text_full(container, profilertext, 0.0f, 0.0f, 1.0f, JUSTIFY_LEFT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
13071299   }
13081300
src/emu/profiler.c
r8846r8847
44
55    Functions to manage profiling of MAME execution.
66
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
7****************************************************************************
98
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
38****************************************************************************
39
40   Profiling is scope-based. To start profiling, put a profiler_scope
41   object on the stack. To end profiling, just end the scope:
42
43   {
44       profiler_scope scope(PROFILER_VIDEO);
45       
46       your_work_here();
47   }
48
49    the profiler handles a FILO list so calls may be nested.
50
1051***************************************************************************/
1152
1253#include "emu.h"
r8846r8847
1455
1556
1657
17/***************************************************************************
18    TYPE DEFINITIONS
19***************************************************************************/
58//**************************************************************************
59//  TYPE DEFINITIONS
60//**************************************************************************
2061
21typedef struct _profile_string profile_string;
22struct _profile_string
62struct profile_string
2363{
2464   int       type;
2565   const char *string;
r8846r8847
2767
2868
2969
30/***************************************************************************
31    GLOBAL VARIABLES
32***************************************************************************/
70//**************************************************************************
71//  GLOBAL VARIABLES
72//**************************************************************************
3373
34profiler_state global_profiler;
74profiler_state g_profiler;
3575
3676
3777
38/***************************************************************************
39    CORE FUNCTIONS
40***************************************************************************/
78//**************************************************************************
79//  DUMMY PROFILER STATE
80//**************************************************************************
4181
42/*-------------------------------------------------
43    _profiler_mark_start - mark the beginning of a
44    profiler entry
45-------------------------------------------------*/
82//-------------------------------------------------
83//  dummy_profiler_state - constructor
84//-------------------------------------------------
4685
47void _profiler_mark_start(int type)
86dummy_profiler_state::dummy_profiler_state()
4887{
49   profiler_data *data = &global_profiler.data[global_profiler.dataindex];
88}
89
90
91
92//**************************************************************************
93//  REAL PROFILER STATE
94//**************************************************************************
95
96//-------------------------------------------------
97//  real_profiler_state - constructor
98//-------------------------------------------------
99
100real_profiler_state::real_profiler_state()
101   : m_enabled(false),
102     m_dataready(false),
103     m_filoindex(0),
104     m_dataindex(0)
105{
106   memset(m_filo, 0, sizeof(m_filo));
107   memset(m_data, 0, sizeof(m_data));
108}
109
110
111//-------------------------------------------------
112//  real_start - mark the beginning of a
113//  profiler entry
114//-------------------------------------------------
115
116void real_profiler_state::real_start(profile_type type)
117{
50118   osd_ticks_t curticks = get_profile_ticks();
51   profiler_filo_entry *entry;
52   int index;
53119
54   /* track context switches */
120   // track context switches
121   history_data &data = m_data[m_dataindex];
55122   if (type >= PROFILER_DEVICE_FIRST && type <= PROFILER_DEVICE_MAX)
56      data->context_switches++;
123      data.context_switches++;
57124
58   /* we're starting a new bucket, begin now */
59   index = global_profiler.filoindex++;
60   entry = &global_profiler.filo[index];
125   // we're starting a new bucket, begin now
126   int index = m_filoindex++;
127   filo_entry &entry = m_filo[index];
61128
62   /* fail if we overflow */
63   if (index > ARRAY_LENGTH(global_profiler.filo))
64      fatalerror("Profiler FILO overflow (type = %d)\n", type);
129   // fail if we overflow
130   if (index > ARRAY_LENGTH(m_filo))
131      throw emu_fatalerror("Profiler FILO overflow (type = %d)\n", type);
65132
66   /* if we're nested, stop the previous entry */
133   // if we're nested, stop the previous entry
67134   if (index > 0)
68135   {
69      profiler_filo_entry *preventry = entry - 1;
70      data->duration[preventry->type] += curticks - preventry->start;
136      filo_entry &preventry = m_filo[index - 1];
137      data.duration[preventry.type] += curticks - preventry.start;
71138   }
72139
73   /* fill in this entry */
74   entry->type = type;
75   entry->start = curticks;
140   // fill in this entry
141   entry.type = type;
142   entry.start = curticks;
76143}
77144
78145
79/*-------------------------------------------------
80    _profiler_mark_end - mark the end of a
81    profiler entry
82-------------------------------------------------*/
146//-------------------------------------------------
147//  real_stop - mark the end of a profiler entry
148//-------------------------------------------------
83149
84void _profiler_mark_end(void)
150void real_profiler_state::real_stop()
85151{
86   profiler_data *data = &global_profiler.data[global_profiler.dataindex];
87152   osd_ticks_t curticks = get_profile_ticks();
88153
89   /* we're ending an existing bucket, update the time */
90   if (global_profiler.filoindex > 0)
154   // we're ending an existing bucket, update the time
155   if (m_filoindex > 0)
91156   {
92      int index = --global_profiler.filoindex;
93      profiler_filo_entry *entry = &global_profiler.filo[index];
157      int index = --m_filoindex;
158      filo_entry &entry = m_filo[index];
94159
95      /* account for the time taken */
96      data->duration[entry->type] += curticks - entry->start;
160      // account for the time taken
161      history_data &data = m_data[m_dataindex];
162      data.duration[entry.type] += curticks - entry.start;
97163
98      /* if we have a previous entry, restart his time now */
164      // if we have a previous entry, restart his time now
99165      if (index != 0)
100166      {
101         profiler_filo_entry *preventry = entry - 1;
102         preventry->start = curticks;
167         filo_entry &preventry = m_filo[index - 1];
168         preventry.start = curticks;
103169      }
104170   }
105171}
106172
107173
108/*-------------------------------------------------
109    _profiler_get_text - return the current text
110    in an astring
111-------------------------------------------------*/
174//-------------------------------------------------
175//  text - return the current text in an astring
176//-------------------------------------------------
112177
113astring &_profiler_get_text(running_machine *machine, astring &string)
178const char *real_profiler_state::text(running_machine &machine, astring &string)
114179{
115180   static const profile_string names[] =
116181   {
117182      { PROFILER_DRC_COMPILE,      "DRC Compilation" },
183      { PROFILER_MEM_REMAP,        "Memory Remapping" },
118184      { PROFILER_MEMREAD,          "Memory Read" },
119185      { PROFILER_MEMWRITE,         "Memory Write" },
120186      { PROFILER_VIDEO,            "Video Update" },
r8846r8847
141207      { PROFILER_PROFILER,         "Profiler" },
142208      { PROFILER_IDLE,             "Idle" }
143209   };
144   UINT64 computed, normalize, total;
145   int curtype, curmem, switches;
146210
147   profiler_mark_start(PROFILER_PROFILER);
211   g_profiler.start(PROFILER_PROFILER);
148212
149   /* compute the total time for all bits, not including profiler or idle */
150   computed = 0;
151   for (curtype = 0; curtype < PROFILER_PROFILER; curtype++)
152      for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
153         computed += global_profiler.data[curmem].duration[curtype];
213   // compute the total time for all bits, not including profiler or idle
214   UINT64 computed = 0;
215   profile_type curtype;
216   for (curtype = PROFILER_DEVICE_FIRST; curtype < PROFILER_PROFILER; curtype++)
217      for (int curmem = 0; curmem < ARRAY_LENGTH(m_data); curmem++)
218         computed += m_data[curmem].duration[curtype];
154219
155   /* save that result in normalize, and continue adding the rest */
156   normalize = computed;
220   // save that result in normalize, and continue adding the rest
221   UINT64 normalize = computed;
157222   for ( ; curtype < PROFILER_TOTAL; curtype++)
158      for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
159         computed += global_profiler.data[curmem].duration[curtype];
223      for (int curmem = 0; curmem < ARRAY_LENGTH(m_data); curmem++)
224         computed += m_data[curmem].duration[curtype];
160225
161   /* this becomes the total; if we end up with 0 for anything, we were just started, so return empty */
162   total = computed;
226   // this becomes the total; if we end up with 0 for anything, we were just started, so return empty
227   UINT64 total = computed;
163228   string.reset();
164229   if (total == 0 || normalize == 0)
165      goto out;
230   {
231      g_profiler.stop();
232      return string;
233   }
166234
167   /* loop over all types and generate the string */
168   for (curtype = 0; curtype < PROFILER_TOTAL; curtype++)
235   // loop over all types and generate the string
236   for (curtype = PROFILER_DEVICE_FIRST; curtype < PROFILER_TOTAL; curtype++)
169237   {
170      /* determine the accumulated time for this type */
238      // determine the accumulated time for this type
171239      computed = 0;
172      for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
173         computed += global_profiler.data[curmem].duration[curtype];
240      for (int curmem = 0; curmem < ARRAY_LENGTH(m_data); curmem++)
241         computed += m_data[curmem].duration[curtype];
174242
175      /* if we have non-zero data and we're ready to display, do it */
176      if (global_profiler.dataready && computed != 0)
243      // if we have non-zero data and we're ready to display, do it
244      if (m_dataready && computed != 0)
177245      {
178         int nameindex;
179
180         /* start with the un-normalized percentage */
246         // start with the un-normalized percentage
181247         string.catprintf("%02d%% ", (int)((computed * 100 + total/2) / total));
182248
183         /* followed by the normalized percentage for everything but profiler and idle */
249         // followed by the normalized percentage for everything but profiler and idle
184250         if (curtype < PROFILER_PROFILER)
185251            string.catprintf("%02d%% ", (int)((computed * 100 + normalize/2) / normalize));
186252
187         /* and then the text */
253         // and then the text
188254         if (curtype >= PROFILER_DEVICE_FIRST && curtype <= PROFILER_DEVICE_MAX)
189            string.catprintf("'%s'", machine->m_devicelist.find(curtype - PROFILER_DEVICE_FIRST)->tag());
255            string.catprintf("'%s'", machine.m_devicelist.find(curtype - PROFILER_DEVICE_FIRST)->tag());
190256         else
191            for (nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++)
257            for (int nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++)
192258               if (names[nameindex].type == curtype)
193259               {
194260                  string.cat(names[nameindex].string);
195261                  break;
196262               }
197263
198         /* followed by a carriage return */
264         // followed by a carriage return
199265         string.cat("\n");
200266      }
201267   }
202268
203   /* followed by context switches */
204   if (global_profiler.dataready)
269   // followed by context switches
270   if (m_dataready)
205271   {
206      switches = 0;
207      for (curmem = 0; curmem < ARRAY_LENGTH(global_profiler.data); curmem++)
208         switches += global_profiler.data[curmem].context_switches;
209      string.catprintf("%d CPU switches\n", switches / (int) ARRAY_LENGTH(global_profiler.data));
272      int switches = 0;
273      for (int curmem = 0; curmem < ARRAY_LENGTH(m_data); curmem++)
274         switches += m_data[curmem].context_switches;
275      string.catprintf("%d CPU switches\n", switches / (int) ARRAY_LENGTH(m_data));
210276   }
211277
212   /* advance to the next dataset and reset it to 0 */
213   global_profiler.dataindex = (global_profiler.dataindex + 1) % ARRAY_LENGTH(global_profiler.data);
214   memset(&global_profiler.data[global_profiler.dataindex], 0, sizeof(global_profiler.data[global_profiler.dataindex]));
278   // advance to the next dataset and reset it to 0
279   m_dataindex = (m_dataindex + 1) % ARRAY_LENGTH(m_data);
280   memset(&m_data[m_dataindex], 0, sizeof(m_data[m_dataindex]));
215281
216   /* we are ready once we have wrapped around */
217   if (global_profiler.dataindex == 0)
218      global_profiler.dataready = TRUE;
219
220out:
221   profiler_mark_end();
222
282   // we are ready once we have wrapped around
283   if (m_dataindex == 0)
284      m_dataready = true;
285   
286   g_profiler.stop();
223287   return string;
224288}
src/emu/profiler.h
r8846r8847
44
55    Functions to manage profiling of MAME execution.
66
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
7****************************************************************************
98
9    Copyright Aaron Giles
10    All rights reserved.
11
12    Redistribution and use in source and binary forms, with or without
13    modification, are permitted provided that the following conditions are
14    met:
15
16        * Redistributions of source code must retain the above copyright
17          notice, this list of conditions and the following disclaimer.
18        * Redistributions in binary form must reproduce the above copyright
19          notice, this list of conditions and the following disclaimer in
20          the documentation and/or other materials provided with the
21          distribution.
22        * Neither the name 'MAME' nor the names of its contributors may be
23          used to endorse or promote products derived from this software
24          without specific prior written permission.
25
26    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
27    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
30    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
35    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36    POSSIBILITY OF SUCH DAMAGE.
37
1038****************************************************************************
1139
12    To start profiling a certain section, e.g. video:
13    profiler_mark_start(PROFILER_VIDEO);
40   Profiling is scope-based. To start profiling, put a profiler_scope
41   object on the stack. To end profiling, just end the scope:
1442
15    to end profiling the current section:
16    profiler_mark_end();
43   {
44       profiler_scope scope(PROFILER_VIDEO);
45       
46       your_work_here();
47   }
1748
1849    the profiler handles a FILO list so calls may be nested.
1950
r8846r8847
2657
2758
2859
29/***************************************************************************
30    CONSTANTS
31***************************************************************************/
60//**************************************************************************
61//  CONSTANTS
62//**************************************************************************
3263
33/* profiling */
34enum
64enum profile_type
3565{
3666   PROFILER_DEVICE_FIRST = 0,
3767   PROFILER_DEVICE_MAX = PROFILER_DEVICE_FIRST + 256,
3868   PROFILER_DRC_COMPILE,
69   PROFILER_MEM_REMAP,
3970   PROFILER_MEMREAD,
4071   PROFILER_MEMWRITE,
4172   PROFILER_VIDEO,
r8846r8847
4778   PROFILER_BLIT,
4879   PROFILER_SOUND,
4980   PROFILER_TIMER_CALLBACK,
50   PROFILER_INPUT,      /* input.c and inptport.c */
51   PROFILER_MOVIE_REC,   /* movie recording */
52   PROFILER_LOGERROR,   /* logerror */
53   PROFILER_EXTRA,      /* everything else */
81   PROFILER_INPUT,            // input.c and inptport.c
82   PROFILER_MOVIE_REC,         // movie recording
83   PROFILER_LOGERROR,         // logerror
84   PROFILER_EXTRA,            // everything else
5485
55   /* the USER types are available to driver writers to profile */
56   /* custom sections of the code */
86   // the USER types are available to driver writers to profile
87   // custom sections of the code
5788   PROFILER_USER1,
5889   PROFILER_USER2,
5990   PROFILER_USER3,
r8846r8847
6798   PROFILER_IDLE,
6899   PROFILER_TOTAL
69100};
101DECLARE_ENUM_OPERATORS(profile_type);
70102
71103
72104
73/***************************************************************************
74    TYPE DEFINITIONS
75***************************************************************************/
105//**************************************************************************
106//  TYPE DEFINITIONS
107//**************************************************************************
76108
77typedef struct _profiler_filo_entry profiler_filo_entry;
78struct _profiler_filo_entry
79{
80   int            type;            /* type of entry */
81   osd_ticks_t      start;            /* start time */
82};
83109
110// ======================> real_profiler_state
84111
85typedef struct _profiler_data profiler_data;
86struct _profiler_data
112class real_profiler_state
87113{
88   UINT32         context_switches;   /* number of context switches seen */
89   osd_ticks_t      duration[PROFILER_TOTAL]; /* duration spent in each entry */
90};
114   friend class profile_scope;
91115
116public:
117   // construction/destruction
118   real_profiler_state();
119   
120   // getters
121   bool enabled() const { return m_enabled; }
122   const char *text(running_machine &machine, astring &string);
92123
93typedef struct _profiler_state profiler_state;
94struct _profiler_state
95{
96   UINT8         enabled;         /* are we enabled? */
97   UINT8         filoindex;         /* current FILO index */
98   UINT8         dataindex;         /* current data index */
99   UINT8         dataready;         /* are we to display the data yet? */
100   profiler_filo_entry filo[16];      /* array of FILO entries */
101   profiler_data   data[16];         /* array of data */
102};
124   // enable/disable
125   void enable(bool state = true)
126   {
127      if (state != m_enabled)
128      {
129         m_enabled = state;
130         if (m_enabled)
131         {
132            m_dataready = false;
133            m_filoindex = m_dataindex = 0;
134         }
135      }
136   }
103137
138   // start/stop
139   void start(profile_type type) { if (m_enabled) real_start(type); }
140   void stop() { if (m_enabled) real_stop(); }
104141
142private:
143   void real_start(profile_type type);
144   void real_stop();
105145
106/***************************************************************************
107    GLOBAL VARIABLES
108***************************************************************************/
146   // an entry in the FILO
147   struct filo_entry
148   {
149      int            type;                  // type of entry
150      osd_ticks_t      start;                  // start time
151   };
109152
110extern profiler_state global_profiler;
153   // item in the array of recent states
154   struct history_data
155   {
156      UINT32         context_switches;         // number of context switches seen
157      osd_ticks_t      duration[PROFILER_TOTAL];   // duration spent in each entry
158   };
111159
160   // internal state
161   bool            m_enabled;               // are we enabled?
162   bool            m_dataready;            // are we to display the data yet?
163   UINT8            m_filoindex;            // current FILO index
164   UINT8            m_dataindex;            // current data index
165   filo_entry         m_filo[16];               // array of FILO entries
166   history_data      m_data[16];               // array of data
167};
112168
113169
114/***************************************************************************
115    MACROS
116***************************************************************************/
170// ======================> dummy_profiler_state
117171
118#ifdef MAME_PROFILER
172class dummy_profiler_state
173{
174public:
175   // construction/destruction
176   dummy_profiler_state();
119177
120#define profiler_mark_start(x)   do { if (global_profiler.enabled) _profiler_mark_start(x); } while (0)
121#define profiler_mark_end()      do { if (global_profiler.enabled) _profiler_mark_end(); } while (0)
122#define profiler_start()      do { global_profiler.enabled = TRUE; global_profiler.filoindex = global_profiler.dataindex = global_profiler.dataready = 0; } while (0)
123#define profiler_stop()         do { global_profiler.enabled = FALSE; } while (0)
124#define profiler_get_text(x,s)   _profiler_get_text(x, s)
178   // getters
179   bool enabled() const { return false; }
180   const char *text(running_machine &machine, astring &string) { return string.cpy(""); }
125181
126#else
182   // enable/disable
183   void enable(bool state = true) { }
127184
128#define profiler_mark_start(x)   do { } while (0)
129#define profiler_mark_end()      do { } while (0)
130#define profiler_start()      do { } while (0)
131#define profiler_stop()         do { } while (0)
132#define profiler_get_text(x,s)   (s).reset()
185   // start/stop
186   void start(profile_type type) { }
187   void stop() { }
188};
133189
134#endif
135190
191// ======================> profiler_state
136192
193#ifdef MAME_PROFILER
194typedef real_profiler_state profiler_state;
195#else
196typedef dummy_profiler_state profiler_state;
197#endif
137198
138/***************************************************************************
139    FUNCTION PROTOTYPES
140***************************************************************************/
141199
142200
143/* ----- core functions (do not call directly; use macros) ----- */
201//**************************************************************************
202//  GLOBAL VARIABLES
203//**************************************************************************
144204
145/* mark the beginning of a profiler entry */
146void _profiler_mark_start(int type);
205extern profiler_state g_profiler;
147206
148/* mark the end of a profiler entry */
149void _profiler_mark_end(void);
150207
151/* return the current text in an astring */
152astring &_profiler_get_text(running_machine *machine, astring &string);
153
154
155208#endif   /* __PROFILER_H__ */
src/emu/schedule.c
r8846r8847
180180               // if we're not suspended, actually execute
181181               if (exec->m_suspend == 0)
182182               {
183                  profiler_mark_start(exec->m_profiler);
183                  g_profiler.start(exec->m_profiler);
184184
185185                  // note that this global variable cycles_stolen can be modified
186186                  // via the call to cpu_execute
r8846r8847
202202                  ran -= *exec->m_icount;
203203                  assert(ran >= exec->m_cycles_stolen);
204204                  ran -= exec->m_cycles_stolen;
205                  profiler_mark_end();
205                  g_profiler.stop();
206206               }
207207else
208208if (TEMPLOG) printf("Skipping %s for %d cycles\n", exec->device().tag(), ran);
src/emu/streams.c
r8846r8847
508508   INT32 update_sampindex = time_to_sampindex(strdata, stream, timer_get_time(machine));
509509
510510   /* generate samples to get us up to the appropriate time */
511   profiler_mark_start(PROFILER_SOUND);
511   g_profiler.start(PROFILER_SOUND);
512512   assert(stream->output_sampindex - stream->output_base_sampindex >= 0);
513513   assert(update_sampindex - stream->output_base_sampindex <= stream->output_bufalloc);
514514   generate_samples(stream, update_sampindex - stream->output_sampindex);
515   profiler_mark_end();
515   g_profiler.stop();
516516
517517   /* remember this info for next time */
518518   stream->output_sampindex = update_sampindex;
src/emu/uiinput.c
r8846r8847
255255   ui_input_private *uidata = machine->ui_input_data;
256256   int pressed = FALSE;
257257
258profiler_mark_start(PROFILER_INPUT);
258g_profiler.start(PROFILER_INPUT);
259259
260260   /* get the status of this key (assumed to be only in the defaults) */
261261   assert(code >= IPT_UI_CONFIGURE && code <= IPT_OSD_16);
r8846r8847
283283   else
284284      uidata->next_repeat[code] = 0;
285285
286profiler_mark_end();
286g_profiler.stop();
287287
288288   return pressed;
289289}
src/emu/memory.c
r8846r8847
10711071   // native read
10721072   _NativeType read_native(offs_t offset, _NativeType mask)
10731073   {
1074      profiler_mark_start(PROFILER_MEMREAD);
1074      g_profiler.start(PROFILER_MEMREAD);
10751075
10761076      if (TEST_HANDLER) printf("[r%X,%s]", offset, core_i64_hex_format(mask, sizeof(_NativeType) * 2));
10771077
r8846r8847
10891089      else if (sizeof(_NativeType) == 4) result = handler.read32(*this, offset >> 2, mask);
10901090      else if (sizeof(_NativeType) == 8) result = handler.read64(*this, offset >> 3, mask);
10911091
1092      profiler_mark_end();
1092      g_profiler.stop();
10931093      return result;
10941094   }
10951095
10961096   // mask-less native read
10971097   _NativeType read_native(offs_t offset)
10981098   {
1099      profiler_mark_start(PROFILER_MEMREAD);
1099      g_profiler.start(PROFILER_MEMREAD);
11001100
11011101      if (TEST_HANDLER) printf("[r%X]", offset);
11021102
r8846r8847
11141114      else if (sizeof(_NativeType) == 4) result = handler.read32(*this, offset >> 2, 0xffffffff);
11151115      else if (sizeof(_NativeType) == 8) result = handler.read64(*this, offset >> 3, U64(0xffffffffffffffff));
11161116
1117      profiler_mark_end();
1117      g_profiler.stop();
11181118      return result;
11191119   }
11201120
11211121   // native write
11221122   void write_native(offs_t offset, _NativeType data, _NativeType mask)
11231123   {
1124      profiler_mark_start(PROFILER_MEMWRITE);
1124      g_profiler.start(PROFILER_MEMWRITE);
11251125
11261126      // look up the handler
11271127      offs_t byteaddress = offset & m_bytemask;
r8846r8847
11401140      else if (sizeof(_NativeType) == 4) handler.write32(*this, offset >> 2, data, mask);
11411141      else if (sizeof(_NativeType) == 8) handler.write64(*this, offset >> 3, data, mask);
11421142
1143      profiler_mark_end();
1143      g_profiler.stop();
11441144   }
11451145
11461146   // mask-less native write
11471147   void write_native(offs_t offset, _NativeType data)
11481148   {
1149      profiler_mark_start(PROFILER_MEMWRITE);
1149      g_profiler.start(PROFILER_MEMWRITE);
11501150
11511151      // look up the handler
11521152      offs_t byteaddress = offset & m_bytemask;
r8846r8847
11611161      else if (sizeof(_NativeType) == 4) handler.write32(*this, offset >> 2, data, 0xffffffff);
11621162      else if (sizeof(_NativeType) == 8) handler.write64(*this, offset >> 3, data, U64(0xffffffffffffffff));
11631163
1164      profiler_mark_end();
1164      g_profiler.stop();
11651165   }
11661166
11671167   // generic direct read
src/emu/diexec.c
r8846r8847
267267     m_timedint_timer(NULL),
268268     m_iloops(0),
269269     m_partial_frame_timer(NULL),
270     m_profiler(0),
270     m_profiler(PROFILER_IDLE),
271271     m_icount(NULL),
272272     m_cycles_running(0),
273273     m_cycles_stolen(0),
r8846r8847
538538   // fill in the initial states
539539   int index = m_machine.m_devicelist.index(&m_device);
540540   m_suspend = SUSPEND_REASON_RESET;
541   m_profiler = index + PROFILER_DEVICE_FIRST;
541   m_profiler = profile_type(index + PROFILER_DEVICE_FIRST);
542542   m_inttrigger = index + TRIGGER_INT;
543543
544544   // fill in the input states and IRQ callback information
src/emu/diexec.h
r8846r8847
322322   attotime            m_partial_frame_period;      // the length of one partial frame for interrupt purposes
323323
324324   // cycle counting and executing
325   int                  m_profiler;               // profiler tag
325   profile_type         m_profiler;               // profiler tag
326326   int *               m_icount;               // pointer to the icount
327327   int                m_cycles_running;         // number of cycles we are executing
328328   int                  m_cycles_stolen;         // number of cycles we artificially stole
src/emu/addrmap.h
r8846r8847
438438//  ADDRESS MAP MACROS
439439//**************************************************************************
440440
441//
442// There are two versions of the macros below
443//
444// By default, the legacy forms are enabled; however, if ADDRESS_MAP_MODERN is #defined
445// prior to including this file, the new format are enabled instead.
446//
447
441448// so that "0" can be used for unneeded address maps
442449#define construct_address_map_0 NULL
443450
444451
452#ifndef ADDRESS_MAP_MODERN
453
454//
455// Legacy ADDRESS_MAPs
456//
457
445458// start/end tags for the address map
446459#define ADDRESS_MAP_NAME(_name) construct_address_map_##_name
447460
r8846r8847
573586   curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \
574587
575588
589// special-case accesses
590#define AM_ROM \
591   curentry->set_read_type(AMH_ROM); \
592
593#define AM_RAM \
594   curentry->set_read_type(AMH_RAM); \
595   curentry->set_write_type(AMH_RAM); \
596
597#define AM_READONLY \
598   curentry->set_read_type(AMH_RAM); \
599
600#define AM_WRITEONLY \
601   curentry->set_write_type(AMH_RAM); \
602
603#define AM_UNMAP \
604   curentry->set_read_type(AMH_UNMAP); \
605   curentry->set_write_type(AMH_UNMAP); \
606
607#define AM_NOP \
608   curentry->set_read_type(AMH_NOP); \
609   curentry->set_write_type(AMH_NOP); \
610
611#define AM_READNOP \
612   curentry->set_read_type(AMH_NOP); \
613
614#define AM_WRITENOP \
615   curentry->set_write_type(AMH_NOP); \
616
617
618// port accesses
619#define AM_READ_PORT(_tag) \
620   curentry->set_read_port(devconfig, _tag); \
621
622#define AM_WRITE_PORT(_tag) \
623   curentry->set_write_port(devconfig, _tag); \
624
625#define AM_READWRITE_PORT(_tag) \
626   curentry->set_readwrite_port(devconfig, _tag); \
627
628
629// bank accesses
630#define AM_READ_BANK(_tag) \
631   curentry->set_read_bank(devconfig, _tag); \
632
633#define AM_WRITE_BANK(_tag) \
634   curentry->set_write_bank(devconfig, _tag); \
635
636#define AM_READWRITE_BANK(_tag) \
637   curentry->set_readwrite_bank(devconfig, _tag); \
638
639
640// attributes for accesses
641#define AM_REGION(_tag, _offs) \
642   curentry->set_region(_tag, _offs); \
643
644#define AM_SHARE(_tag) \
645   curentry->set_share(_tag); \
646
647#define AM_BASE(_base) \
648   curentry->set_baseptr(_base); \
649
650#define myoffsetof(_struct, _member)  ((FPTR)&((_struct *)0x1000)->_member - 0x1000)
651#define AM_BASE_MEMBER(_struct, _member) \
652   curentry->set_member_baseptr(myoffsetof(_struct, _member)); \
653
654#define AM_BASE_GENERIC(_member) \
655   curentry->set_generic_baseptr(myoffsetof(generic_pointers, _member)); \
656
657#define AM_SIZE(_size) \
658   curentry->set_sizeptr(_size); \
659
660#define AM_SIZE_MEMBER(_struct, _member) \
661   curentry->set_member_sizeptr(myoffsetof(_struct, _member)); \
662
663#define AM_SIZE_GENERIC(_member) \
664   curentry->set_generic_sizeptr(myoffsetof(generic_pointers, _member##_size)); \
665
666
667// common shortcuts
668#define AM_ROMBANK(_bank)               AM_READ_BANK(_bank)
669#define AM_RAMBANK(_bank)               AM_READWRITE_BANK(_bank)
670#define AM_RAM_READ(_read)               AM_READ(_read) AM_WRITEONLY
671#define AM_RAM_WRITE(_write)            AM_READONLY AM_WRITE(_write)
672#define AM_RAM_DEVREAD(_tag, _read)       AM_DEVREAD(_tag, _read) AM_WRITEONLY
673#define AM_RAM_DEVWRITE(_tag, _write)       AM_READONLY AM_DEVWRITE(_tag, _write)
674
675#define AM_BASE_SIZE_MEMBER(_struct, _base, _size)   AM_BASE_MEMBER(_struct, _base) AM_SIZE_MEMBER(_struct, _size)
676#define AM_BASE_SIZE_GENERIC(_member)      AM_BASE_GENERIC(_member) AM_SIZE_GENERIC(_member)
677
678
679#else
680
681//
682// Modern ADDRESS_MAPs
683//
684
685// start/end tags for the address map
686#define ADDRESS_MAP_NAME(_name) construct_address_map_##_name
687
688#define ADDRESS_MAP_START(_name, _space, _bits, _class) \
689void ADDRESS_MAP_NAME(_name)(address_map &map, const device_config &devconfig) \
690{ \
691   typedef read##_bits##_proto_delegate read_proto_delegate; \
692   typedef write##_bits##_proto_delegate write_proto_delegate; \
693   address_map_entry##_bits *curentry = NULL; \
694   (void)curentry; \
695   map.configure(_space, _bits); \
696   typedef _class drivdata_class; \
697
698#define ADDRESS_MAP_END \
699}
700
701// use this to declare external references to an address map
702#define ADDRESS_MAP_EXTERN(_name, _bits) \
703   extern void ADDRESS_MAP_NAME(_name)(address_map &map, const device_config &devconfig)
704
705
706// global controls
707#define ADDRESS_MAP_GLOBAL_MASK(_mask) \
708   map.set_global_mask(_mask); \
709
710#define ADDRESS_MAP_UNMAP_LOW \
711   map.set_unmap_value(0); \
712
713#define ADDRESS_MAP_UNMAP_HIGH \
714   map.set_unmap_value(~0); \
715
716
717// importing data from other address maps
718#define AM_IMPORT_FROM(_name) \
719   ADDRESS_MAP_NAME(_name)(map, devconfig); \
720
721
722// address ranges
723#define AM_RANGE(_start, _end) \
724   curentry = map.add(_start, _end, curentry); \
725
726#define AM_MASK(_mask) \
727   curentry->set_mask(_mask); \
728
729#define AM_MIRROR(_mirror) \
730   curentry->set_mirror(_mirror); \
731
732
733// legacy space reads
734#define AM_READ_LEGACY(_handler) \
735   curentry->set_handler(_handler, #_handler); \
736
737#define AM_READ8_LEGACY(_handler, _unitmask) \
738   curentry->set_handler(_handler, #_handler, _unitmask); \
739
740#define AM_READ16_LEGACY(_handler, _unitmask) \
741   curentry->set_handler(_handler, #_handler, _unitmask); \
742
743#define AM_READ32_LEGACY(_handler, _unitmask) \
744   curentry->set_handler(_handler, #_handler, _unitmask); \
745
746
747// legacy space writes
748#define AM_WRITE_LEGACY(_handler) \
749   curentry->set_handler(_handler, #_handler); \
750
751#define AM_WRITE8_LEGACY(_handler, _unitmask) \
752   curentry->set_handler(_handler, #_handler, _unitmask); \
753
754#define AM_WRITE16_LEGACY(_handler, _unitmask) \
755   curentry->set_handler(_handler, #_handler, _unitmask); \
756
757#define AM_WRITE32_LEGACY(_handler, _unitmask) \
758   curentry->set_handler(_handler, #_handler, _unitmask); \
759
760
761// legacy space reads/writes
762#define AM_READWRITE_LEGACY(_rhandler, _whandler) \
763   curentry->set_handler(_rhandler, #_rhandler, _whandler, #_whandler); \
764
765#define AM_READWRITE8_LEGACY(_rhandler, _whandler, _unitmask) \
766   curentry->set_handler(_rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \
767
768#define AM_READWRITE16_LEGACY(_rhandler, _whandler, _unitmask) \
769   curentry->set_handler(_rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \
770
771#define AM_READWRITE32_LEGACY(_rhandler, _whandler, _unitmask) \
772   curentry->set_handler(_rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \
773
774
775// legacy device reads
776#define AM_DEVREAD_LEGACY(_tag, _handler) \
777   curentry->set_handler(devconfig, _tag, _handler, #_handler); \
778
779#define AM_DEVREAD8_LEGACY(_tag, _handler, _unitmask) \
780   curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \
781
782#define AM_DEVREAD16_LEGACY(_tag, _handler, _unitmask) \
783   curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \
784
785#define AM_DEVREAD32_LEGACY(_tag, _handler, _unitmask) \
786   curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \
787
788
789// legacy device writes
790#define AM_DEVWRITE_LEGACY(_tag, _handler) \
791   curentry->set_handler(devconfig, _tag, _handler, #_handler); \
792
793#define AM_DEVWRITE8_LEGACY(_tag, _handler, _unitmask) \
794   curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \
795
796#define AM_DEVWRITE16_LEGACY(_tag, _handler, _unitmask) \
797   curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \
798
799#define AM_DEVWRITE32_LEGACY(_tag, _handler, _unitmask) \
800   curentry->set_handler(devconfig, _tag, _handler, #_handler, _unitmask); \
801
802
803// legacy device reads/writes
804#define AM_DEVREADWRITE_LEGACY(_tag, _rhandler, _whandler) \
805   curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler); \
806
807#define AM_DEVREADWRITE8_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
808   curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \
809
810#define AM_DEVREADWRITE16_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
811   curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \
812
813#define AM_DEVREADWRITE32_LEGACY(_tag, _rhandler, _whandler, _unitmask) \
814   curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \
815
816
576817// driver data reads
577#define AM_READ_MEMBER(_class, _handler) \
578   curentry->set_handler(devconfig, NULL, read_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler)); \
818#define AM_READ(_handler) \
819   curentry->set_handler(devconfig, NULL, read_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler)); \
579820
580#define AM_READ8_MEMBER(_class, _handler, _unitmask) \
581   curentry->set_handler(devconfig, NULL, read8_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
821#define AM_READ8(_handler, _unitmask) \
822   curentry->set_handler(devconfig, NULL, read8_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler), _unitmask); \
582823
583#define AM_READ16_MEMBER(_class, _handler, _unitmask) \
584   curentry->set_handler(devconfig, NULL, read16_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
824#define AM_READ16(_handler, _unitmask) \
825   curentry->set_handler(devconfig, NULL, read16_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler), _unitmask); \
585826
586#define AM_READ32_MEMBER(_class, _handler, _unitmask) \
587   curentry->set_handler(devconfig, NULL, read32_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
827#define AM_READ32(_handler, _unitmask) \
828   curentry->set_handler(devconfig, NULL, read32_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler), _unitmask); \
588829
589830
590831// driver data writes
591#define AM_WRITE_MEMBER(_class, _handler) \
592   curentry->set_handler(devconfig, NULL, write_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler)); \
832#define AM_WRITE(_handler) \
833   curentry->set_handler(devconfig, NULL, write_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler)); \
593834
594#define AM_WRITE8_MEMBER(_class, _handler, _unitmask) \
595   curentry->set_handler(devconfig, NULL, write8_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
835#define AM_WRITE8(_handler, _unitmask) \
836   curentry->set_handler(devconfig, NULL, write8_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler), _unitmask); \
596837
597#define AM_WRITE16_MEMBER(_class, _handler, _unitmask) \
598   curentry->set_handler(devconfig, NULL, write16_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
838#define AM_WRITE16(_handler, _unitmask) \
839   curentry->set_handler(devconfig, NULL, write16_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler), _unitmask); \
599840
600#define AM_WRITE32_MEMBER(_class, _handler, _unitmask) \
601   curentry->set_handler(devconfig, NULL, write32_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
841#define AM_WRITE32(_handler, _unitmask) \
842   curentry->set_handler(devconfig, NULL, write32_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler), _unitmask); \
602843
603844
604845// driver data reads/writes
605#define AM_READWRITE_MEMBER(_class, _rhandler, _whandler) \
606   curentry->set_handler(devconfig, NULL, read_proto_delegate::_create_member<_class, &_class::_rhandler>(#_class "::" #_rhandler), write_proto_delegate::_create_member<_class, &_class::_whandler>(#_class "::" #_whandler)); \
846#define AM_READWRITE(_rhandler, _whandler) \
847   curentry->set_handler(devconfig, NULL, read_proto_delegate::_create_member<drivdata_class, &drivdata_class::_rhandler>("driver_data::" #_rhandler), write_proto_delegate::_create_member<drivdata_class, &drivdata_class::_whandler>("driver_data::" #_whandler)); \
607848
608#define AM_READWRITE8_MEMBER(_class, _rhandler, _whandler, _unitmask) \
609   curentry->set_handler(devconfig, NULL, read8_proto_delegate::_create_member<_class, &_class::_rhandler>(#_class "::" #_rhandler), write8_proto_delegate::_create_member<_class, &_class::_whandler>(#_class "::" #_whandler), _unitmask); \
849#define AM_READWRITE8(_rhandler, _whandler, _unitmask) \
850   curentry->set_handler(devconfig, NULL, read8_proto_delegate::_create_member<drivdata_class, &drivdata_class::_rhandler>("driver_data::" #_rhandler), write8_proto_delegate::_create_member<drivdata_class, &drivdata_class::_whandler>("driver_data::" #_whandler), _unitmask); \
610851
611#define AM_READWRITE16_MEMBER(_class, _rhandler, _whandler, _unitmask) \
612   curentry->set_handler(devconfig, NULL, read16_proto_delegate::_create_member<_class, &_class::_rhandler>(#_class "::" #_rhandler), write16_proto_delegate::_create_member<_class, &_class::_whandler>(#_class "::" #_whandler), _unitmask); \
852#define AM_READWRITE16(_rhandler, _whandler, _unitmask) \
853   curentry->set_handler(devconfig, NULL, read16_proto_delegate::_create_member<drivdata_class, &drivdata_class::_rhandler>("driver_data::" #_rhandler), write16_proto_delegate::_create_member<drivdata_class, &drivdata_class::_whandler>("driver_data::" #_whandler), _unitmask); \
613854
614#define AM_READWRITE32_MEMBER(_class, _rhandler, _whandler, _unitmask) \
615   curentry->set_handler(devconfig, NULL, read32_proto_delegate::_create_member<_class, &_class::_rhandler>(#_class "::" #_rhandler), write32_proto_delegate::_create_member<_class, &_class::_whandler>(#_class "::" #_whandler), _unitmask); \
855#define AM_READWRITE32(_rhandler, _whandler, _unitmask) \
856   curentry->set_handler(devconfig, NULL, read32_proto_delegate::_create_member<drivdata_class, &drivdata_class::_rhandler>("driver_data::" #_rhandler), write32_proto_delegate::_create_member<drivdata_class, &drivdata_class::_whandler>("driver_data::" #_whandler), _unitmask); \
616857
617858
618859// device reads
619#define AM_DEVREAD_MEMBER(_tag, _class, _handler) \
860#define AM_DEVREAD(_tag, _class, _handler) \
620861   curentry->set_handler(devconfig, _tag, read_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler)); \
621862
622#define AM_DEVREAD8_MEMBER(_tag, _class, _handler, _unitmask) \
863#define AM_DEVREAD8(_tag, _class, _handler, _unitmask) \
623864   curentry->set_handler(devconfig, _tag, read8_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
624865
625#define AM_DEVREAD16_MEMBER(_tag, _class, _handler, _unitmask) \
866#define AM_DEVREAD16(_tag, _class, _handler, _unitmask) \
626867   curentry->set_handler(devconfig, _tag, read16_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
627868
628#define AM_DEVREAD32_MEMBER(_tag, _class, _handler, _unitmask) \
869#define AM_DEVREAD32(_tag, _class, _handler, _unitmask) \
629870   curentry->set_handler(devconfig, _tag, read32_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
630871
631872
632873// device writes
633#define AM_DEVWRITE_MEMBER(_tag, _class, _handler) \
874#define AM_DEVWRITE(_tag, _class, _handler) \
634875   curentry->set_handler(devconfig, _tag, write_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler)); \
635876
636#define AM_DEVWRITE8_MEMBER(_tag, _class, _handler, _unitmask) \
877#define AM_DEVWRITE8(_tag, _class, _handler, _unitmask) \
637878   curentry->set_handler(devconfig, _tag, write8_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
638879
639#define AM_DEVWRITE16_MEMBER(_tag, _class, _handler, _unitmask) \
880#define AM_DEVWRITE16(_tag, _class, _handler, _unitmask) \
640881   curentry->set_handler(devconfig, _tag, write16_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
641882
642#define AM_DEVWRITE32_MEMBER(_tag, _class, _handler, _unitmask) \
883#define AM_DEVWRITE32(_tag, _class, _handler, _unitmask) \
643884   curentry->set_handler(devconfig, _tag, write32_proto_delegate::_create_member<_class, &_class::_handler>(#_class "::" #_handler), _unitmask); \
644885
645886
646887// device reads/writes
647#define AM_DEVREADWRITE_MEMBER(_tag, _class, _rhandler, _whandler) \
888#define AM_DEVREADWRITE(_tag, _class, _rhandler, _whandler) \
648889   curentry->set_handler(devconfig, _tag, read_proto_delegate::_create_member<_class, &_class::_rhandler>(#_class "::" #_rhandler), write_proto_delegate::_create_member<_class, &_class::_whandler>(#_class "::" #_whandler)); \
649890
650#define AM_DEVREADWRITE8_MEMBER(_tag, _class, _rhandler, _whandler, _unitmask) \
891#define AM_DEVREADWRITE8(_tag, _class, _rhandler, _whandler, _unitmask) \
651892   curentry->set_handler(devconfig, _tag, read8_proto_delegate::_create_member<_class, &_class::_rhandler>(#_class "::" #_rhandler), write8_proto_delegate::_create_member<_class, &_class::_whandler>(#_class "::" #_whandler), _unitmask); \
652893
653#define AM_DEVREADWRITE16_MEMBER(_tag, _class, _rhandler, _whandler, _unitmask) \
894#define AM_DEVREADWRITE16(_tag, _class, _rhandler, _whandler, _unitmask) \
654895   curentry->set_handler(devconfig, _tag, read16_proto_delegate::_create_member<_class, &_class::_rhandler>(#_class "::" #_rhandler), write16_proto_delegate::_create_member<_class, &_class::_whandler>(#_class "::" #_whandler), _unitmask); \
655896
656#define AM_DEVREADWRITE32_MEMBER(_tag, _class, _rhandler, _whandler, _unitmask) \
897#define AM_DEVREADWRITE32(_tag, _class, _rhandler, _whandler, _unitmask) \
657898   curentry->set_handler(devconfig, _tag, read32_proto_delegate::_create_member<_class, &_class::_rhandler>(#_class "::" #_rhandler), write32_proto_delegate::_create_member<_class, &_class::_whandler>(#_class "::" #_whandler), _unitmask); \
658899
659900
r8846r8847
715956#define AM_SHARE(_tag) \
716957   curentry->set_share(_tag); \
717958
718#define AM_BASE(_base) \
959#define AM_BASE_LEGACY(_base) \
719960   curentry->set_baseptr(_base); \
720961
721962#define myoffsetof(_struct, _member)  ((FPTR)&((_struct *)0x1000)->_member - 0x1000)
722#define AM_BASE_MEMBER(_struct, _member) \
723   curentry->set_member_baseptr(myoffsetof(_struct, _member)); \
963#define AM_BASE(_member) \
964   curentry->set_member_baseptr(myoffsetof(drivdata_class, _member)); \
724965
725966#define AM_BASE_GENERIC(_member) \
726967   curentry->set_generic_baseptr(myoffsetof(generic_pointers, _member)); \
727968
728#define AM_SIZE(_size) \
969#define AM_SIZE_LEGACY(_size) \
729970   curentry->set_sizeptr(_size); \
730971
731#define AM_SIZE_MEMBER(_struct, _member) \
732   curentry->set_member_sizeptr(myoffsetof(_struct, _member)); \
972#define AM_SIZE(_struct, _member) \
973   curentry->set_member_sizeptr(myoffsetof(drivdata_class, _member)); \
733974
734975#define AM_SIZE_GENERIC(_member) \
735976   curentry->set_generic_sizeptr(myoffsetof(generic_pointers, _member##_size)); \
r8846r8847
739980#define AM_ROMBANK(_bank)               AM_READ_BANK(_bank)
740981#define AM_RAMBANK(_bank)               AM_READWRITE_BANK(_bank)
741982#define AM_RAM_READ(_read)               AM_READ(_read) AM_WRITEONLY
742#define AM_RAM_READ_MEMBER(_class, _read)   AM_READ_MEMBER(_class, _read) AM_WRITEONLY
743983#define AM_RAM_WRITE(_write)            AM_READONLY AM_WRITE(_write)
744#define AM_RAM_WRITE_MEMBER(_class, _write)   AM_READONLY AM_WRITE_MEMBER(_class, _write)
745#define AM_RAM_DEVREAD(_tag, _read)       AM_DEVREAD(_tag, _read) AM_WRITEONLY
746#define AM_RAM_DEVREAD_MEMBER(_tag, _class, _read) AM_DEVREAD_MEMBER(_tag, _class, _read) AM_WRITEONLY
747#define AM_RAM_DEVWRITE(_tag, _write)       AM_READONLY AM_DEVWRITE(_tag, _write)
748#define AM_RAM_DEVWRITE_MEMBER(_tag, _class, _write) AM_READONLY AM_DEVWRITE_MEMBER(_tag, _class, _write)
984#define AM_RAM_DEVREAD(_tag, _class, _read) AM_DEVREAD(_tag, _class, _read) AM_WRITEONLY
985#define AM_RAM_DEVWRITE(_tag, _class, _write) AM_READONLY AM_DEVWRITE(_tag, _class, _write)
749986
750#define AM_BASE_SIZE_MEMBER(_struct, _base, _size)   AM_BASE_MEMBER(_struct, _base) AM_SIZE_MEMBER(_struct, _size)
987#define AM_BASE_SIZE(_base, _size)         AM_BASE_MEMBER(_base) AM_SIZE_MEMBER(_size)
751988#define AM_BASE_SIZE_GENERIC(_member)      AM_BASE_GENERIC(_member) AM_SIZE_GENERIC(_member)
752989
990#endif
753991
754992
993
755994//**************************************************************************
756995//  GLOBAL VARIABLES
757996//**************************************************************************
src/emu/sound.c
r8846r8847
404404
405405   VPRINTF(("sound_update\n"));
406406
407   profiler_mark_start(PROFILER_SOUND);
407   g_profiler.start(PROFILER_SOUND);
408408
409409   leftmix = global->leftmix;
410410   rightmix = global->rightmix;
r8846r8847
452452   /* update the streamer */
453453   streams_update(machine);
454454
455   profiler_mark_end();
455   g_profiler.stop();
456456}
457457
458458
src/emu/input.c
r8846r8847
857857   INT32 result = 0;
858858   int curindex;
859859
860   profiler_mark_start(PROFILER_INPUT);
860   g_profiler.start(PROFILER_INPUT);
861861
862862   /* return 0 for any disabled or invalid device classes */
863863   if (devclass <= DEVICE_CLASS_INVALID || devclass >= DEVICE_CLASS_MAXIMUM || !device_list[devclass].enabled)
r8846r8847
908908   }
909909
910910exit:
911   profiler_mark_end();
911   g_profiler.stop();
912912   return result;
913913}
914914
src/emu/timer.c
r8846r8847
371371      if (was_enabled && timer->callback != NULL)
372372      {
373373         LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9)));
374         profiler_mark_start(PROFILER_TIMER_CALLBACK);
374         g_profiler.start(PROFILER_TIMER_CALLBACK);
375375         (*timer->callback)(machine, timer->ptr, timer->param);
376         profiler_mark_end();
376         g_profiler.stop();
377377      }
378378
379379      /* clear the callback timer global */
src/emu/drawgfxm.h
r8846r8847
370370
371371#define DRAWGFX_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE)                        \
372372do {                                                               \
373   profiler_mark_start(PROFILER_DRAWGFX);                                    \
373   g_profiler.start(PROFILER_DRAWGFX);                                    \
374374   do {                                                            \
375375      const UINT8 *srcdata;                                             \
376376      INT32 destendx, destendy;                                          \
r8846r8847
613613         }                                                         \
614614      }                                                            \
615615   } while (0);                                                      \
616   profiler_mark_end();                                          \
616   g_profiler.stop();                                          \
617617} while (0)
618618
619619
r8846r8847
642642
643643#define DRAWGFXZOOM_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE)                     \
644644do {                                                               \
645   profiler_mark_start(PROFILER_DRAWGFX);                                       \
645   g_profiler.start(PROFILER_DRAWGFX);                                       \
646646   do {                                                            \
647647      const UINT8 *srcdata;                                             \
648648      UINT32 dstwidth, dstheight;                                          \
r8846r8847
698698      destendy = desty + dstheight - 1;                                    \
699699      if (desty > cliprect->max_y || destendy < cliprect->min_y)                  \
700700      {                                                            \
701         profiler_mark_end();                                       \
701         g_profiler.stop();                                       \
702702         return;                                                      \
703703      }                                                            \
704704                                                                  \
r8846r8847
797797         }                                                         \
798798      }                                                            \
799799   } while (0);                                                      \
800   profiler_mark_end();                                          \
800   g_profiler.stop();                                          \
801801} while (0)
802802
803803
r8846r8847
821821
822822#define COPYBITMAP_CORE(PIXEL_TYPE, PIXEL_OP, PRIORITY_TYPE)                     \
823823do {                                                               \
824   profiler_mark_start(PROFILER_COPYBITMAP);                                       \
824   g_profiler.start(PROFILER_COPYBITMAP);                                       \
825825   do {                                                            \
826826      const PIXEL_TYPE *srcdata;                                          \
827827      UINT32 numblocks, leftovers;                                       \
r8846r8847
975975         }                                                         \
976976      }                                                            \
977977   } while (0);                                                      \
978   profiler_mark_end();                                          \
978   g_profiler.stop();                                          \
979979} while (0)
980980
981981
r8846r8847
10061006   UINT32 numblocks, leftovers;                                       \
10071007   INT32 curx, cury;                                                \
10081008                                                               \
1009   profiler_mark_start(PROFILER_COPYBITMAP);                              \
1009   g_profiler.start(PROFILER_COPYBITMAP);                              \
10101010                                                               \
10111011   assert(dest != NULL);                                             \
10121012   assert(src != NULL);                                             \
r8846r8847
12801280         }                                                      \
12811281      }                                                         \
12821282   }                                                            \
1283   profiler_mark_end();                                             \
1283   g_profiler.stop();                                             \
12841284} while (0)
12851285
12861286
src/mess/machine/apple2.c
r8846r8847
10631063   int irq_freq = 1;
10641064   int scanline;
10651065
1066   profiler_mark_start(PROFILER_A2INT);
1066   g_profiler.start(PROFILER_A2INT);
10671067
10681068   scanline = device->machine->primary_screen->vpos();
10691069
r8846r8847
10791079
10801080   device->machine->primary_screen->update_partial(scanline);
10811081
1082   profiler_mark_end();
1082   g_profiler.stop();
10831083}
10841084
10851085
r8846r8847
11281128   if(!space->debugger_access())
11291129   {
11301130      /* Read the keyboard data and strobe */
1131      profiler_mark_start(PROFILER_C00X);
1131      g_profiler.start(PROFILER_C00X);
11321132      result = AY3600_keydata_strobe_r();
1133      profiler_mark_end();
1133      g_profiler.stop();
11341134   }
11351135
11361136   return result;
r8846r8847
11781178
11791179   if(!space->debugger_access())
11801180   {
1181      profiler_mark_start(PROFILER_C01X);
1181      g_profiler.start(PROFILER_C01X);
11821182
11831183      LOG(("a2 softswitch_r: %04x\n", offset + 0xc010));
11841184      switch (offset)
r8846r8847
12011201         case 0x0F:         result |= (apple2_flags & VAR_80COL)      ? 0x80 : 0x00;   break;
12021202      }
12031203
1204      profiler_mark_end();
1204      g_profiler.stop();
12051205   }
12061206
12071207   return result;
r8846r8847
12161216WRITE8_HANDLER( apple2_c01x_w )
12171217{
12181218   /* Clear the keyboard strobe - ignore the returned results */
1219   profiler_mark_start(PROFILER_C01X);
1219   g_profiler.start(PROFILER_C01X);
12201220   AY3600_anykey_clearstrobe_r();
1221   profiler_mark_end();
1221   g_profiler.stop();
12221222}
12231223
12241224
src/mess/video/gb.c
r8846r8847
356356{
357357   bitmap_t *bitmap = machine->generic.tmpbitmap;
358358
359   profiler_mark_start(PROFILER_VIDEO);
359   g_profiler.start(PROFILER_VIDEO);
360360
361361   /* Make sure we're in mode 3 */
362362   if ( ( LCDSTAT & 0x03 ) == 0x03 )
r8846r8847
502502      }
503503   }
504504
505   profiler_mark_end();
505   g_profiler.stop();
506506}
507507
508508/* --- Super Game Boy Specific --- */
r8846r8847
679679{
680680   bitmap_t *bitmap = machine->generic.tmpbitmap;
681681
682   profiler_mark_start(PROFILER_VIDEO);
682   g_profiler.start(PROFILER_VIDEO);
683683
684684   if ( ( LCDSTAT & 0x03 ) == 0x03 )
685685   {
r8846r8847
864864      }
865865   }
866866
867   profiler_mark_end();
867   g_profiler.stop();
868868}
869869
870870/* --- Game Boy Color Specific --- */
r8846r8847
985985{
986986   bitmap_t *bitmap = machine->generic.tmpbitmap;
987987
988   profiler_mark_start(PROFILER_VIDEO);
988   g_profiler.start(PROFILER_VIDEO);
989989
990990   if ( ( LCDSTAT & 0x03 ) == 0x03 )
991991   {
r8846r8847
11711171      }
11721172   }
11731173
1174   profiler_mark_end();
1174   g_profiler.stop();
11751175}
11761176
11771177/* OAM contents on power up.

Previous 15994 Revisions Next


© 1998-2018 The MESS Team