1
/*====================================================================
4
project: GameCube DSP Tool (gcdsp)
8
Copyright (c) 2005 Duddie
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
====================================================================*/
27
// At the moment just ls and sl are using the prolog
28
// perhaps all actions on r03 must be in the prolog
32
#include "OutBuffer.h"
37
void dsp_op_ext_r_epi(uint16 _Opcode)
39
uint8 op = (_Opcode >> 2) & 0x3;
40
uint8 reg = _Opcode & 0x3;
45
OutBuffer::AddCode("Error: dsp_op_ext_r_epi");
49
OutBuffer::AddCode("%s--", OutBuffer::GetRegName(reg));
54
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(reg));
59
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(reg), OutBuffer::GetRegName(reg+4));
60
// g_dsp.r[reg] += g_dsp.r[reg + 4];
66
void dsp_op_ext_mv(uint16 _Opcode)
68
uint8 sreg = _Opcode & 0x3;
69
uint8 dreg = ((_Opcode >> 2) & 0x3);
71
OutBuffer::AddCode("%s = %s", OutBuffer::GetRegName(dreg + 0x18), OutBuffer::GetRegName(sreg + 0x1c));
73
// g_dsp.r[dreg + 0x18] = g_dsp.r[sreg + 0x1c];
77
void dsp_op_ext_s(uint16 _Opcode)
79
uint8 dreg = _Opcode & 0x3;
80
uint8 sreg = ((_Opcode >> 3) & 0x3) + 0x1c;
82
OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
83
// dsp_dmem_write(g_dsp.r[dreg], g_dsp.r[sreg]);
87
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(dreg+4));
88
// g_dsp.r[dreg] += g_dsp.r[dreg + 4];
92
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(dreg));
98
void dsp_op_ext_l(uint16 _Opcode)
100
uint8 sreg = _Opcode & 0x3;
101
uint8 dreg = ((_Opcode >> 3) & 0x7) + 0x18;
103
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
104
// uint16 val = dsp_dmem_read(g_dsp.r[sreg]);
105
// g_dsp.r[dreg] = val;
109
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(sreg), OutBuffer::GetRegName(sreg+4));
110
// g_dsp.r[sreg] += g_dsp.r[sreg + 4];
114
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(sreg));
120
void dsp_op_ext_ls_pro(uint16 _Opcode)
122
uint8 areg = (_Opcode & 0x1) + 0x1e;
124
OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(areg));
125
// dsp_dmem_write(g_dsp.r[0x03], g_dsp.r[areg]);
129
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(0x07));
130
// g_dsp.r[0x03] += g_dsp.r[0x07];
134
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x03));
140
void dsp_op_ext_ls_epi(uint16 _Opcode)
142
uint8 dreg = ((_Opcode >> 4) & 0x3) + 0x18;
144
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(0x00));
145
// uint16 val = dsp_dmem_read(g_dsp.r[0x00]);
146
// dsp_op_write_reg(dreg, val);
150
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x00), OutBuffer::GetRegName(0x04));
151
// g_dsp.r[0x00] += g_dsp.r[0x04];
155
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x00));
161
void dsp_op_ext_sl_pro(uint16 _Opcode)
163
uint8 areg = (_Opcode & 0x1) + 0x1e;
165
OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(0x00), OutBuffer::GetRegName(areg));
166
// dsp_dmem_write(g_dsp.r[0x00], g_dsp.r[areg]);
170
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x00), OutBuffer::GetRegName(0x04));
171
// g_dsp.r[0x00] += g_dsp.r[0x04];
175
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x00));
181
void dsp_op_ext_sl_epi(uint16 _Opcode)
183
uint8 dreg = ((_Opcode >> 4) & 0x3) + 0x18;
185
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(0x03));
186
// uint16 val = dsp_dmem_read(g_dsp.r[0x03]);
187
// dsp_op_write_reg(dreg, val);
191
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(0x07));
192
// g_dsp.r[0x03] += g_dsp.r[0x07];
196
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x03));
202
void dsp_op_ext_ld(uint16 _Opcode)
204
uint8 dreg1 = (((_Opcode >> 5) & 0x1) << 1) + 0x18;
205
uint8 dreg2 = (((_Opcode >> 4) & 0x1) << 1) + 0x19;
206
uint8 sreg = _Opcode & 0x3;
208
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg1), OutBuffer::GetRegName(sreg));
209
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg2), OutBuffer::GetRegName(0x03));
211
// g_dsp.r[dreg1] = dsp_dmem_read(g_dsp.r[sreg]);
212
// g_dsp.r[dreg2] = dsp_dmem_read(g_dsp.r[0x03]);
216
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(sreg), OutBuffer::GetRegName(sreg + 0x04));
217
// g_dsp.r[sreg] += g_dsp.r[sreg + 0x04];
221
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(sreg));
227
OutBuffer::AddCode("%s += %s", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(sreg + 0x07));
228
// g_dsp.r[0x03] += g_dsp.r[0x07];
232
OutBuffer::AddCode("%s++", OutBuffer::GetRegName(0x03));
238
// ================================================================================
242
// ================================================================================
244
void dsp_op_ext_ops_pro(uint16 _Opcode)
246
if ((_Opcode & 0xFF) == 0){return;}
248
switch ((_Opcode >> 4) & 0xf)
251
dsp_op_ext_r_epi(_Opcode);
255
dsp_op_ext_mv(_Opcode);
260
dsp_op_ext_s(_Opcode);
267
dsp_op_ext_l(_Opcode);
277
dsp_op_ext_sl_pro(_Opcode);
281
dsp_op_ext_ls_pro(_Opcode);
290
dsp_op_ext_ld(_Opcode);
296
void dsp_op_ext_ops_epi(uint16 _Opcode)
298
if ((_Opcode & 0xFF) == 0){return;}
300
switch ((_Opcode >> 4) & 0xf)
309
dsp_op_ext_sl_epi(_Opcode);
313
dsp_op_ext_ls_epi(_Opcode);