| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | /*====================================================================
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    filename:     opcodes.h | 
					
						
							|  |  |  |    project:      GameCube DSP Tool (gcdsp) | 
					
						
							|  |  |  |    created:      2005.03.04 | 
					
						
							|  |  |  |    mail:		  duddie@walla.com | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Copyright (c) 2005 Duddie | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |    modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |    as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |    of the License, or (at your option) any later version. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |    GNU General Public License for more details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |    along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    ====================================================================*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-28 10:00:25 +00:00
										 |  |  | #include "DSPIntUtil.h"
 | 
					
						
							|  |  |  | #include "DSPMemoryMap.h"
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | // Extended opcodes do not exist on their own. These opcodes can only be
 | 
					
						
							|  |  |  | // attached to opcodes that allow extending (8 lower bits of opcode not used by
 | 
					
						
							|  |  |  | // opcode). Extended opcodes do not modify program counter $pc register.
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-01 19:07:29 +00:00
										 |  |  | // Most of the suffixes increment or decrement one or more addressing registers
 | 
					
						
							|  |  |  | // (the first four, ARx). The increment/decrement is either 1, or the corresponding 
 | 
					
						
							|  |  |  | // "index" register (the second four, IXx). The addressing registers will wrap
 | 
					
						
							|  |  |  | // in odd ways, dictated by the corresponding wrapping register, WP0-3.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-07 11:06:40 +00:00
										 |  |  | // The following should be applied as a decrement (and is applied by dsp_decrement_addr_reg):
 | 
					
						
							| 
									
										
										
										
											2009-05-01 19:07:29 +00:00
										 |  |  | // ar[i] = (ar[i] & wp[i]) == 0 ? ar[i] | wp[i] : ar[i] - 1;
 | 
					
						
							|  |  |  | // I have not found the corresponding algorithms for increments yet.
 | 
					
						
							|  |  |  | // It's gotta be fairly simple though. See R3123, R3125 in Google Code.
 | 
					
						
							| 
									
										
										
										
											2009-06-07 11:06:40 +00:00
										 |  |  | // (May have something to do with (ar[i] ^ wp[i]) == 0)
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-21 13:11:47 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | namespace DSPInterpreter | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-01 20:06:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | namespace Ext  | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | // DR $arR
 | 
					
						
							|  |  |  | // xxxx xxxx 0000 01rr
 | 
					
						
							|  |  |  | // Decrement addressing register $arR.
 | 
					
						
							|  |  |  | void dr(const UDSPInstruction& opc) { | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 	dsp_decrement_addr_reg(opc.hex & 0x3); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // IR $arR
 | 
					
						
							|  |  |  | // xxxx xxxx 0000 10rr
 | 
					
						
							|  |  |  | // Increment addressing register $arR.
 | 
					
						
							|  |  |  | void ir(const UDSPInstruction& opc) { | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 	dsp_increment_addr_reg(opc.hex & 0x3); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | // NR $arR
 | 
					
						
							|  |  |  | // xxxx xxxx 0000 11rr
 | 
					
						
							|  |  |  | // Add corresponding indexing register $ixR to addressing register $arR.
 | 
					
						
							|  |  |  | void nr(const UDSPInstruction& opc) { | 
					
						
							|  |  |  | 	u8 reg = opc.hex & 0x3;	 | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 	//	g_dsp.r[reg] += g_dsp.r[reg + DSP_REG_IX0];
 | 
					
						
							|  |  |  | 	dsp_increase_addr_reg(reg, (s16)g_dsp.r[DSP_REG_IX0 + reg]); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // MV $axD, $acS.l
 | 
					
						
							|  |  |  | // xxxx xxxx 0001 ddss
 | 
					
						
							|  |  |  | // Move value of $acS.l to the $axD.l.
 | 
					
						
							|  |  |  | void mv(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	u8 dreg = ((opc.hex >> 2) & 0x3); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	g_dsp.r[dreg + DSP_REG_AXL0] = g_dsp.r[sreg + DSP_REG_ACC0]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // S @$D, $acD.l
 | 
					
						
							|  |  |  | // xxxx xxxx 001s s0dd
 | 
					
						
							|  |  |  | // Store value of $(acS.l) in the memory pointed by register $D.
 | 
					
						
							|  |  |  | // Post increment register $D.
 | 
					
						
							|  |  |  | void s(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 dreg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	u8 sreg = ((opc.hex >> 3) & 0x3) + DSP_REG_ACC0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dsp_dmem_write(g_dsp.r[dreg], g_dsp.r[sreg]); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 	dsp_increment_addr_reg(dreg); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // SN @$D, $acD.l
 | 
					
						
							|  |  |  | // xxxx xxxx 001s s1dd
 | 
					
						
							|  |  |  | // Store value of register $acS in the memory pointed by register $D.
 | 
					
						
							|  |  |  | // Add indexing register $ixD to register $D.
 | 
					
						
							|  |  |  | void sn(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 dreg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	u8 sreg = ((opc.hex >> 3) & 0x3) + DSP_REG_ACC0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dsp_dmem_write(g_dsp.r[dreg], g_dsp.r[sreg]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 	//	g_dsp.r[dreg] += g_dsp.r[dreg + DSP_REG_IX0];
 | 
					
						
							|  |  |  | 	dsp_increase_addr_reg(dreg, (s16)g_dsp.r[DSP_REG_IX0 + dreg]); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // L axD.l, @$S
 | 
					
						
							|  |  |  | // xxxx xxxx 01dd d0ss
 | 
					
						
							|  |  |  | // Load $axD with value from memory pointed by register $S. 
 | 
					
						
							|  |  |  | // Post increment register $S.
 | 
					
						
							|  |  |  | void l(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	u8 dreg = ((opc.hex >> 3) & 0x7) + DSP_REG_AXL0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	u16 val = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							|  |  |  | 	g_dsp.r[dreg] = val; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 	dsp_increment_addr_reg(sreg); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // LN axD.l, @$S
 | 
					
						
							|  |  |  | // xxxx xxxx 01dd d0ss
 | 
					
						
							|  |  |  | // Load $axD with value from memory pointed by register $S. 
 | 
					
						
							|  |  |  | // Add indexing register register $ixS to register $S.
 | 
					
						
							|  |  |  | void ln(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	u8 dreg = ((opc.hex >> 3) & 0x7) + DSP_REG_AXL0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	u16 val = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							|  |  |  | 	g_dsp.r[dreg] = val; | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 	//	g_dsp.r[sreg] += g_dsp.r[sreg + DSP_REG_IX0];
 | 
					
						
							|  |  |  | 	dsp_increase_addr_reg(sreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg]); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Not in duddie's doc
 | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | // LD $ax0.d $ax1.r @$arS
 | 
					
						
							|  |  |  | // xxxx xxxx 11dr 00ss
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | void ld(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | 	u8 dreg = (((opc.hex >> 5) & 0x1) << 1) + DSP_REG_AXL0; | 
					
						
							|  |  |  | 	u8 rreg = (((opc.hex >> 4) & 0x1) << 1) + DSP_REG_AXL1; | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | 	g_dsp.r[dreg] = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							|  |  |  | 	g_dsp.r[rreg] = dsp_dmem_read(g_dsp.r[DSP_REG_AR3]); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 	dsp_increment_addr_reg(sreg); | 
					
						
							|  |  |  | 	dsp_increment_addr_reg(DSP_REG_AR3); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Not in duddie's doc
 | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | // LDN $ax0.d $ax1.r @$arS
 | 
					
						
							|  |  |  | // xxxx xxxx 11dr 01ss
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | void ldn(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | 	u8 dreg = (((opc.hex >> 5) & 0x1) << 1) + DSP_REG_AXL0; | 
					
						
							|  |  |  | 	u8 rreg = (((opc.hex >> 4) & 0x1) << 1) + DSP_REG_AXL1; | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | 	g_dsp.r[dreg] = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							|  |  |  | 	g_dsp.r[rreg] = dsp_dmem_read(g_dsp.r[DSP_REG_AR3]); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	g_dsp.r[sreg] += g_dsp.r[sreg + DSP_REG_IX0]; | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 	dsp_increment_addr_reg(DSP_REG_AR3); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Not in duddie's doc
 | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | // LDM $ax0.d $ax1.r @$arS
 | 
					
						
							|  |  |  | // xxxx xxxx 11dr 10ss
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | void ldm(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | 	u8 dreg = (((opc.hex >> 5) & 0x1) << 1) + DSP_REG_AXL0; | 
					
						
							|  |  |  | 	u8 rreg = (((opc.hex >> 4) & 0x1) << 1) + DSP_REG_AXL1; | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | 	g_dsp.r[dreg] = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							|  |  |  | 	g_dsp.r[rreg] = dsp_dmem_read(g_dsp.r[DSP_REG_AR3]); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 	dsp_increment_addr_reg(sreg); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	g_dsp.r[DSP_REG_AR3] += g_dsp.r[DSP_REG_IX3]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Not in duddie's doc
 | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | // LDNM $ax0.d $ax1.r @$arS
 | 
					
						
							|  |  |  | // xxxx xxxx 11dr 11ss
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | void ldnm(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | 	u8 dreg = (((opc.hex >> 5) & 0x1) << 1) + DSP_REG_AXL0; | 
					
						
							|  |  |  | 	u8 rreg = (((opc.hex >> 4) & 0x1) << 1) + DSP_REG_AXL1; | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							| 
									
										
										
										
											2009-04-14 11:43:44 +00:00
										 |  |  | 	g_dsp.r[dreg] = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							|  |  |  | 	g_dsp.r[rreg] = dsp_dmem_read(g_dsp.r[DSP_REG_AR3]); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	g_dsp.r[sreg] += g_dsp.r[sreg + DSP_REG_IX0]; | 
					
						
							|  |  |  | 	g_dsp.r[DSP_REG_AR3] += g_dsp.r[DSP_REG_IX3]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // end namespace ext
 | 
					
						
							|  |  |  | } // end namespace DSPInterpeter
 | 
					
						
							| 
									
										
										
										
											2009-06-21 13:11:47 +00:00
										 |  |  | */  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_r_epi(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 op  = (opc.hex >> 2) & 0x3; | 
					
						
							|  |  |  | 	u8 reg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	switch (op) { | 
					
						
							|  |  |  | 	case 0x00: // 
 | 
					
						
							| 
									
										
										
										
											2009-04-14 13:13:12 +00:00
										 |  |  | 		g_dsp.r[reg] = 0; | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 	case 0x01: // DR
 | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 		dsp_decrement_addr_reg(reg); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 		break; | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 	case 0x02: // IR
 | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 		dsp_increment_addr_reg(reg); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2009-05-03 11:57:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	case 0x03: // NR
 | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		//		g_dsp.r[reg] += g_dsp.r[reg + 4];
 | 
					
						
							|  |  |  | 		dsp_increase_addr_reg(reg, (s16)g_dsp.r[DSP_REG_IX0 + reg]); | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_mv(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	u8 dreg = ((opc.hex >> 2) & 0x3); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	g_dsp.r[dreg + 0x18] = g_dsp.r[sreg + 0x1c]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_s(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 dreg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	u8 sreg = ((opc.hex >> 3) & 0x3) + 0x1c; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dsp_dmem_write(g_dsp.r[dreg], g_dsp.r[sreg]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	if (opc.hex & 0x04) // SN
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		//		g_dsp.r[dreg] += g_dsp.r[dreg + 4];
 | 
					
						
							|  |  |  | 		dsp_increase_addr_reg(dreg, (s16)g_dsp.r[DSP_REG_IX0 + dreg]); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 		dsp_increment_addr_reg(dreg); // S
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_l(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							| 
									
										
										
										
											2009-05-02 16:15:52 +00:00
										 |  |  | 	u8 dreg = ((opc.hex >> 3) & 0x7) + DSP_REG_AXL0; | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	u16 val = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							|  |  |  | 	g_dsp.r[dreg] = val; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	if (opc.hex & 0x04) // LN/LSMN
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		dsp_increase_addr_reg(sreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg]); | 
					
						
							|  |  |  | 		//		g_dsp.r[sreg] += g_dsp.r[sreg + 4];
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 		dsp_increment_addr_reg(sreg); // LS
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_ls_pro(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 areg = (opc.hex & 0x1) + 0x1e; | 
					
						
							|  |  |  | 	dsp_dmem_write(g_dsp.r[0x03], g_dsp.r[areg]); | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 	u8 sreg = 0x03; | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	if (opc.hex & 0x8) // LSM/LSMN
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		dsp_increase_addr_reg(sreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg]); | 
					
						
							|  |  |  | 		//		g_dsp.r[0x03] += g_dsp.r[0x07];
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	}  | 
					
						
							|  |  |  | 	else // LS
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		dsp_increment_addr_reg(sreg); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_ls_epi(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-02 16:15:52 +00:00
										 |  |  | 	u8 dreg = ((opc.hex >> 4) & 0x3) + DSP_REG_AXL0; | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	u16 val = dsp_dmem_read(g_dsp.r[0x00]); | 
					
						
							|  |  |  | 	dsp_op_write_reg(dreg, val); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	if (opc.hex & 0x4) // LSN/LSMN
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		//g_dsp.r[0x00] += g_dsp.r[0x04];
 | 
					
						
							|  |  |  | 		dsp_increase_addr_reg(0x00, (s16)g_dsp.r[DSP_REG_IX0]); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	else // LS
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 		dsp_increment_addr_reg(0x00);  | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_sl_pro(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 areg = (opc.hex & 0x1) + 0x1e; | 
					
						
							|  |  |  | 	dsp_dmem_write(g_dsp.r[0x00], g_dsp.r[areg]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	if (opc.hex & 0x4) // SLN/SLNM
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		dsp_increase_addr_reg(0x00, (s16)g_dsp.r[DSP_REG_IX0]); | 
					
						
							|  |  |  | 		//		g_dsp.r[0x00] += g_dsp.r[0x04];
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	else // SL 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 		dsp_increment_addr_reg(0x00); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_sl_epi(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 dreg = ((opc.hex >> 4) & 0x3) + 0x18; | 
					
						
							| 
									
										
										
										
											2009-07-11 10:18:25 +00:00
										 |  |  | 	const u8 sreg = 0x03; | 
					
						
							|  |  |  | 	u16 val = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	dsp_op_write_reg(dreg, val); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	if (opc.hex & 0x8) // SLM/SLMN
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		dsp_increase_addr_reg(sreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg]); | 
					
						
							|  |  |  | 		//		g_dsp.r[0x03] += g_dsp.r[0x07];
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	else // SL
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		dsp_increment_addr_reg(sreg); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_ld(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u8 dreg1 = (((opc.hex >> 5) & 0x1) << 1) + 0x18; | 
					
						
							|  |  |  | 	u8 dreg2 = (((opc.hex >> 4) & 0x1) << 1) + 0x19; | 
					
						
							|  |  |  | 	u8 sreg = opc.hex & 0x3; | 
					
						
							|  |  |  | 	g_dsp.r[dreg1] = dsp_dmem_read(g_dsp.r[sreg]); | 
					
						
							|  |  |  | 	g_dsp.r[dreg2] = dsp_dmem_read(g_dsp.r[0x03]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  |    	if (opc.hex & 0x04) // N
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		dsp_increase_addr_reg(sreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg]); | 
					
						
							|  |  |  | 		//g_dsp.r[sreg] += g_dsp.r[sreg + 0x04];
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 		dsp_increment_addr_reg(sreg); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	if (opc.hex & 0x08) // M
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-06-21 09:56:39 +00:00
										 |  |  | 		dsp_increase_addr_reg(0x03, (s16)g_dsp.r[DSP_REG_IX0 + 0x03]); | 
					
						
							|  |  |  | 		//		g_dsp.r[0x03] += g_dsp.r[0x07];
 | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-07-11 10:18:25 +00:00
										 |  |  | 		// Hmm
 | 
					
						
							|  |  |  | 		// if (sreg != 0x3)
 | 
					
						
							| 
									
										
										
										
											2009-05-01 22:17:22 +00:00
										 |  |  | 		dsp_increment_addr_reg(0x03); | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ================================================================================
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // ================================================================================
 | 
					
						
							|  |  |  | void dsp_op_ext_ops_pro(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if ((opc.hex & 0xFF) == 0){return;} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch ((opc.hex >> 4) & 0xf) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-05-03 11:57:53 +00:00
										 |  |  | 	case 0x00: | 
					
						
							|  |  |  | 		dsp_op_ext_r_epi(opc.hex); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case 0x01: | 
					
						
							|  |  |  | 		dsp_op_ext_mv(opc.hex); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case 0x02: | 
					
						
							|  |  |  | 	case 0x03: | 
					
						
							|  |  |  | 		dsp_op_ext_s(opc.hex); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case 0x04: | 
					
						
							|  |  |  | 	case 0x05: | 
					
						
							|  |  |  | 	case 0x06: | 
					
						
							|  |  |  | 	case 0x07: | 
					
						
							|  |  |  | 		dsp_op_ext_l(opc.hex); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case 0x08: | 
					
						
							|  |  |  | 	case 0x09: | 
					
						
							|  |  |  | 	case 0x0a: | 
					
						
							|  |  |  | 	case 0x0b: | 
					
						
							|  |  |  | 		if (opc.hex & 0x2) | 
					
						
							|  |  |  | 			dsp_op_ext_sl_pro(opc.hex); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			dsp_op_ext_ls_pro(opc.hex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case 0x0c: | 
					
						
							|  |  |  | 	case 0x0d: | 
					
						
							|  |  |  | 	case 0x0e: | 
					
						
							|  |  |  | 	case 0x0f: | 
					
						
							|  |  |  | 		dsp_op_ext_ld(opc.hex); | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void dsp_op_ext_ops_epi(const UDSPInstruction& opc) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-01 19:07:29 +00:00
										 |  |  | 	if ((opc.hex & 0xFF) == 0) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	switch ((opc.hex >> 4) & 0xf) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-05-02 16:15:52 +00:00
										 |  |  | 	case 0x08: | 
					
						
							|  |  |  | 	case 0x09: | 
					
						
							|  |  |  | 	case 0x0a: | 
					
						
							|  |  |  | 	case 0x0b: | 
					
						
							|  |  |  | 		if (opc.hex & 0x2) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			dsp_op_ext_sl_epi(opc.hex); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			dsp_op_ext_ls_epi(opc.hex); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2009-04-12 19:56:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-02 16:15:52 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-04-12 10:21:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } |