]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/dsp.cpp
Virtual Jaguar GCC/SDL v1.0.3 import.
[virtualjaguar] / src / dsp.cpp
index 99cc887c7ffd02de4c5fb44db457d3d723bbd586..294b73e8ee73ed376a5bab4fa66728a58f291cf9 100644 (file)
@@ -1,15 +1,12 @@
-//////////////////////////////////////////////////////////////////////////////
 //
-//////////////////////////////////////////////////////////////////////////////
+// DSP core
 //
+// by cal2
+// GCC/SDL port by Niels Wagenaar (Linux/WIN32) and Caz (BeOS)
+// Cleanups by James L. Hammons
 //
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
 
-#include "include/dsp.h"
+#include "dsp.h"
 
 #define CINT0FLAG                      0x00200
 #define CINT1FLAG                      0x00400
@@ -155,7 +152,6 @@ char *dsp_opcode_str[64]=
 static uint16  *mirror_table;
 static uint8   *dsp_ram_8;
 
-
 static uint32  dsp_pc;
 static uint32  dsp_acc;
 static uint32  dsp_remain;
@@ -200,52 +196,23 @@ uint32 dsp_convert_zero[32] = { 32,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
 uint8 *dsp_branch_condition_table=0;
 #define branch_condition(x)    dsp_branch_condition_table[(x) + ((jaguar_flags & 7) << 5)]
 
-static uint32 dsp_in_exec=0;
-static uint32 dsp_releaseTimeSlice_flag=0;
+static uint32 dsp_in_exec = 0;
+static uint32 dsp_releaseTimeSlice_flag = 0;
+
+FILE * dsp_fp;
 
-FILE *dsp_fp;
 
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
 void dsp_reset_stats(void)
 {
-       for (uint32 i=0;i<64;i++)
-               dsp_opcode_use[i]=0;
+       for (uint32 i=0; i<64; i++)
+               dsp_opcode_use[i] = 0;
 }
 
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
 void dsp_releaseTimeslice(void)
 {
-       dsp_releaseTimeSlice_flag=1;
+       dsp_releaseTimeSlice_flag = 1;
 }
 
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
 void dsp_build_branch_condition_table(void)
 {
        int i,j;
@@ -291,16 +258,7 @@ void dsp_build_branch_condition_table(void)
                                }
        }
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 unsigned dsp_byte_read(unsigned int offset)
 {
 // battlemorph
@@ -333,16 +291,7 @@ unsigned dsp_byte_read(unsigned int offset)
        }
        return(jaguar_byte_read(offset));
 } 
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 unsigned dsp_word_read(unsigned int offset)
 {
        offset&=0xFFFFFFFE;
@@ -408,16 +357,7 @@ unsigned dsp_word_read(unsigned int offset)
        }
        return(jaguar_word_read(offset));
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 unsigned dsp_long_read(unsigned int offset)
 {
        offset&=0xFFFFFFFC;
@@ -459,16 +399,7 @@ unsigned dsp_long_read(unsigned int offset)
        data|=jaguar_word_read(offset+2);
        return(data);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_byte_write(unsigned offset, unsigned data)
 {
        if ((offset >= dsp_work_ram_base) && (offset < dsp_work_ram_base+0x2000))
@@ -502,16 +433,7 @@ void dsp_byte_write(unsigned offset, unsigned data)
 //     fprintf(log_get(),"dsp: writing %.2x at 0x%.8x\n",data,offset);
        jaguar_byte_write(offset, data);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_word_write(unsigned offset, unsigned data)
 {
        offset &= 0xFFFFFFFE;
@@ -552,16 +474,7 @@ void dsp_word_write(unsigned offset, unsigned data)
        }
        jaguar_word_write(offset, data);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_long_write(unsigned offset, unsigned data)
 {
        offset &= 0xFFFFFFFC;
@@ -663,16 +576,7 @@ void dsp_long_write(unsigned offset, unsigned data)
        jaguar_word_write(offset, (data>>16) & 0xFFFF);
        jaguar_word_write(offset+2, data & 0xFFFF);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 uint8 * jaguar_rom_load(char * path, uint32 * romSize);
 void dsp_load_bin_at(char * path, uint32 offset)
 {
@@ -683,16 +587,7 @@ void dsp_load_bin_at(char * path, uint32 offset)
        for(uint32 i=0; i<romSize; i++)
                jaguar_byte_write(offset+i, rom[i]);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static int go = 0;
 void dsp_update_register_banks(void)
 {
@@ -737,16 +632,7 @@ void dsp_update_register_banks(void)
                }
        }
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_check_if_i2s_interrupt_needed(void)
 {
        static uint32 count=8;
@@ -770,16 +656,7 @@ void dsp_check_if_i2s_interrupt_needed(void)
                dsp_set_irq_line(1,1);
        }
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_check_irqs(void)
 {
        int bits, mask, which = 0;
@@ -829,16 +706,7 @@ void dsp_check_irqs(void)
        dsp_pc += which * 0x10;
        dsp_reg[30]=dsp_pc;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_set_irq_line(int irqline, int state)
 {
        int mask = 0x40 << irqline;
@@ -849,36 +717,17 @@ void dsp_set_irq_line(int irqline, int state)
                dsp_check_irqs();
        }
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_init(void)
 {
-       memory_malloc_secure((void**)&dsp_ram_8,0x2000,"dsp work ram");
-       memory_malloc_secure((void**)&dsp_reg,32*sizeof(int32),"dsp bank 0 regs");
-       memory_malloc_secure((void**)&dsp_alternate_reg,32*sizeof(int32),"dsp bank 1 regs");
+       memory_malloc_secure((void **)&dsp_ram_8, 0x2000, "dsp work ram");
+       memory_malloc_secure((void **)&dsp_reg, 32*sizeof(int32), "dsp bank 0 regs");
+       memory_malloc_secure((void **)&dsp_alternate_reg, 32*sizeof(int32), "dsp bank 1 regs");
        
        dsp_build_branch_condition_table();
-
        dsp_reset();
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_reset(void)
 {
        dsp_pc                            = 0x00f1b000;
@@ -893,7 +742,7 @@ void dsp_reset(void)
        dsp_div_control           = 0x00000000;
        dsp_in_exec                       = 0;
 
-       for (int i=0;i<32;i++)
+       for(int i=0; i<32; i++)
        {
                dsp_reg[i]           = 0x00000000;
                dsp_alternate_reg[i] = 0x00000000;
@@ -908,24 +757,14 @@ void dsp_reset(void)
        reset_flag_n();
        reset_flag_c();
 
-       dsp_alternate_flag_z=0;
-       dsp_alternate_flag_n=0;
-       dsp_alternate_flag_c=0;
+       dsp_alternate_flag_z = 0;
+       dsp_alternate_flag_n = 0;
+       dsp_alternate_flag_c = 0;
 
        dsp_reset_stats();
-
-       memset(dsp_ram_8,                 0xff, 0x2000);
+       memset(dsp_ram_8, 0xFF, 0x2000);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//     
-//////////////////////////////////////////////////////////////////////////////
+
 void dsp_done(void)
 {
        int i, j;
@@ -982,16 +821,6 @@ void dsp_done(void)
        memory_free(dsp_ram_8);
 }
 
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
 void dsp_exec(int32 cycles)
 {
        if ((cycles!=1)&&(jaguar_mainRom_crc32==0xba74c3ed))
@@ -1048,16 +877,7 @@ void dsp_exec(int32 cycles)
        }
        dsp_in_exec--;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_jump(void)
 {
        uint32 delayed_pc = Rm;
@@ -1076,16 +896,7 @@ static void dsp_opcode_jump(void)
                dsp_pc=delayed_pc;
        }
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_jr(void)
 {
        int32 offset=(imm_1&0x10) ? (0xFFFFFFF0|imm_1) : imm_1;
@@ -1106,16 +917,7 @@ static void dsp_opcode_jr(void)
                dsp_pc=delayed_pc;
        }
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_add(void)
 {
        uint32 _Rm=Rm;
@@ -1166,16 +968,7 @@ static void dsp_opcode_add(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_addc(void)
 {
        uint32 _Rm=Rm;
@@ -1247,16 +1040,7 @@ dsp_opcode_addc_no_carry:
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_addq(void)
 {
        uint32 _Rn=Rn;
@@ -1312,16 +1096,7 @@ static void dsp_opcode_addq(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_sub(void)
 {
        uint32 _Rm=Rm;
@@ -1376,16 +1151,7 @@ static void dsp_opcode_sub(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_subc(void)
 {
        uint32 _Rm=Rm;
@@ -1457,16 +1223,7 @@ dsp_opcode_subc_no_carry:
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_subq(void)
 {
        uint32 _Rm=dsp_convert_zero[imm_1];
@@ -1520,16 +1277,7 @@ static void dsp_opcode_subq(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_cmp(void)
 {
        uint32 _Rm=Rm;
@@ -1579,16 +1327,7 @@ static void dsp_opcode_cmp(void)
        };
 #endif
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_cmpq(void)
 {
        static int32 sqtable[32] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1};
@@ -1639,16 +1378,7 @@ static void dsp_opcode_cmpq(void)
        };
 #endif
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_and(void)
 {
        uint32 _Rm=Rm;
@@ -1700,16 +1430,7 @@ static void dsp_opcode_and(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_or(void)
 {
        uint32 _Rm=Rm;
@@ -1761,16 +1482,7 @@ static void dsp_opcode_or(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_xor(void)
 {
        uint32 _Rm=Rm;
@@ -1822,16 +1534,7 @@ static void dsp_opcode_xor(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_not(void)
 {
        uint32 _Rn=Rn;
@@ -1881,30 +1584,12 @@ static void dsp_opcode_not(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_move_pc(void)
 {
        Rn = dsp_pc-2; 
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_sat8(void)
 {
        int32 _Rn=(int32)Rn;
@@ -1913,16 +1598,7 @@ static void dsp_opcode_sat8(void)
        set_flag_z(res);
        reset_flag_n();
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_sat16(void)
 {
        uint32 _Rn=Rn;
@@ -1930,16 +1606,7 @@ static void dsp_opcode_sat16(void)
        set_flag_z(res);
        reset_flag_n();
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_sat24(void)
 {
        uint32 _Rn=Rn;
@@ -1948,113 +1615,41 @@ static void dsp_opcode_sat24(void)
        set_flag_z(res);
        reset_flag_n();
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_store_r14_indexed(void)
 {
        dsp_long_write( dsp_reg[14] + (dsp_convert_zero[imm_1] << 2),Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_store_r15_indexed(void)
 {
        dsp_long_write( dsp_reg[15] + (dsp_convert_zero[imm_1] << 2),Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_load_r14_ri(void)
 {
        Rn=dsp_long_read(dsp_reg[14] + Rm);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_load_r15_ri(void)
 {
        Rn=dsp_long_read(dsp_reg[15] + Rm);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_store_r14_ri(void)
 {
        dsp_long_write(dsp_reg[14] + Rm,Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_store_r15_ri(void)
 {
        dsp_long_write(dsp_reg[15] + Rm,Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_nop(void)
 {
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_pack(void)
 {
        uint32 _Rn=Rn;
@@ -2076,16 +1671,7 @@ static void dsp_opcode_pack(void)
        set_flag_z(Rn);
        set_flag_n(Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_storeb(void)
 {
        if ((Rm >= dsp_work_ram_base) && (Rm < (dsp_work_ram_base+0x2000)))
@@ -2093,16 +1679,7 @@ static void dsp_opcode_storeb(void)
        else
                jaguar_byte_write(Rm,Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_storew(void)
 {
        if ((Rm >= dsp_work_ram_base) && (Rm < (dsp_work_ram_base+0x2000)))
@@ -2110,30 +1687,12 @@ static void dsp_opcode_storew(void)
        else
                jaguar_word_write(Rm,Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_store(void)
 {
        dsp_long_write(Rm,Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_loadb(void)
 {
        if ((Rm >= dsp_work_ram_base) && (Rm < (dsp_work_ram_base+0x2000)))
@@ -2141,16 +1700,7 @@ static void dsp_opcode_loadb(void)
        else
                Rn=jaguar_byte_read(Rm);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_loadw(void)
 {
        if ((Rm >= dsp_work_ram_base) && (Rm < (dsp_work_ram_base+0x2000)))
@@ -2158,175 +1708,67 @@ static void dsp_opcode_loadw(void)
        else
                Rn=jaguar_word_read(Rm);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_load(void)
 {
        Rn = dsp_long_read(Rm);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_load_r14_indexed(void)
 {
        Rn = dsp_long_read( dsp_reg[14] + (dsp_convert_zero[imm_1] << 2));
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_load_r15_indexed(void)
 {
        Rn = dsp_long_read( dsp_reg[15] + (dsp_convert_zero[imm_1] << 2));
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_movei(void)
 {
        Rn = ((uint32)dsp_word_read(dsp_pc)) + (((uint32)dsp_word_read(dsp_pc+2))<<16);
        dsp_pc+=4;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_moveta(void)
 {
        alternate_Rn = Rm;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_movefa(void)
 {
        Rn = alternate_Rm;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_move(void)
 {
        Rn = Rm;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_moveq(void)
 {
        Rn = imm_1;    
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_resmac(void)
 {
        Rn = dsp_acc;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_imult(void)
 {
        uint32 res=Rn=((int16)Rn)*((int16)Rm);
        set_flag_z(res);
        set_flag_n(res);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_mult(void)
 {
        uint32 res=Rn =  ((uint16)Rm) * ((uint16)Rn);
        set_flag_z(res);
        set_flag_n(res);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_bclr(void)
 {
        uint32 _Rm=imm_1;
@@ -2382,16 +1824,7 @@ static void dsp_opcode_bclr(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_btst(void)
 {
        uint32 _Rm=imm_1;
@@ -2435,16 +1868,7 @@ static void dsp_opcode_btst(void)
        };
 #endif
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_bset(void)
 {
        uint32 _Rm=imm_1;
@@ -2499,59 +1923,23 @@ static void dsp_opcode_bset(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_subqt(void)
 {
        Rn -= dsp_convert_zero[imm_1];
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_addqt(void)
 {
        Rn += dsp_convert_zero[imm_1];
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_imacn(void)
 {
        uint32 res=((int16)Rm) * ((int16)(Rn));
        dsp_acc += res;
 } 
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_mtoi(void)
 {
        uint32 _Rm=Rm;
@@ -2559,16 +1947,7 @@ static void dsp_opcode_mtoi(void)
        set_flag_z(res);
        set_flag_n(res);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_normi(void)
 {
        uint32 _Rm = Rm;
@@ -2591,16 +1970,7 @@ static void dsp_opcode_normi(void)
        set_flag_z(res);
        set_flag_n(res);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_mmult(void)
 {
        int count       = dsp_matrix_control&0x0f;
@@ -2641,16 +2011,7 @@ static void dsp_opcode_mmult(void)
        set_flag_z(res);
        set_flag_n(res);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_abs(void)
 {
        uint32 _Rn=Rn;
@@ -2668,16 +2029,7 @@ static void dsp_opcode_abs(void)
                set_flag_z(res);
        }
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_div(void)
 {
        uint32 _Rm=Rm;
@@ -2703,16 +2055,7 @@ static void dsp_opcode_div(void)
        else
                Rn=0xffffffff;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_imultn(void)
 {
        uint32 res=(int32)(((int16)Rn)*((int16)Rm));
@@ -2720,16 +2063,7 @@ static void dsp_opcode_imultn(void)
        set_flag_z(res);
        set_flag_n(res);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_neg(void)
 {
        uint32 _Rn=Rn;
@@ -2785,16 +2119,7 @@ static void dsp_opcode_neg(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_shlq(void)
 {
        uint32 shift=(32-dsp_convert_zero[imm_1]);
@@ -2855,16 +2180,7 @@ static void dsp_opcode_shlq(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_shrq(void)
 {
        uint32 shift=dsp_convert_zero[imm_1];
@@ -2926,16 +2242,7 @@ static void dsp_opcode_shrq(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_ror(void)
 {
        uint32 shift=Rm;
@@ -2996,16 +2303,7 @@ static void dsp_opcode_ror(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_rorq(void)
 {
        uint32 shift=dsp_convert_zero[imm_1&0x1f];
@@ -3066,16 +2364,7 @@ static void dsp_opcode_rorq(void)
 #endif
        Rn=res;
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_sha(void)
 {
        int32 sRm=(int32)Rm;
@@ -3107,16 +2396,7 @@ static void dsp_opcode_sha(void)
        set_flag_z(_Rn);
        set_flag_n(_Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_sharq(void)
 {
        uint32 shift=dsp_convert_zero[imm_1];
@@ -3132,16 +2412,7 @@ static void dsp_opcode_sharq(void)
        set_flag_z(_Rn);
        set_flag_n(_Rn);
 }
-//////////////////////////////////////////////////////////////////////////////
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-//
-//
-//
-//
-//
-//////////////////////////////////////////////////////////////////////////////
+
 static void dsp_opcode_sh(void)
 {
        int32 sRm=(int32)Rm;