Skip to content

Commit 3d1cc39

Browse files
committed
fix nctools4.0 makebin and dir table
1 parent 9da7a89 commit 3d1cc39

File tree

1 file changed

+167
-4
lines changed

1 file changed

+167
-4
lines changed

cpu.cpp

Lines changed: 167 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,172 @@ void prepare_soft_reset(){
123123

124124

125125
int invalid_op_extra_skip(int op){
126-
if(op==0x3){
127-
//nctools has this illegal opcode, if not handled, "S h" will not work.
128-
return 1;
126+
static unsigned char mp[256];
127+
bool initialized = false;
128+
if(!initialized){
129+
memset(mp,0,sizeof(mp));
130+
initialized = true;
131+
132+
//03 fixes nctools (all version) "S h"
133+
//13 and 1f fixes nctools 4.0's "制作应用程序" and "系统信息->文件列表"
134+
135+
// below value from https://www.masswerk.at/6502/6502_instruction_set.html
136+
137+
//ALR(asr)
138+
mp[0x4b]=2;
139+
140+
//ANC
141+
mp[0x0b]=2;
142+
143+
//ANC(ANC2)
144+
mp[0x2b]=2;
145+
146+
//ANE(XAA)
147+
mp[0x8b]=2;
148+
149+
//ARR
150+
mp[0x6b]=2;
151+
152+
//DCP(DCM)
153+
mp[0xc7]=2;
154+
mp[0xd7]=2;
155+
mp[0xcf]=3;
156+
mp[0xdf]=3;
157+
mp[0xdb]=3;
158+
mp[0xc3]=2;
159+
mp[0xd3]=2;
160+
161+
//ISC(ISB,INS)
162+
mp[0xe7]=2;
163+
mp[0xf7]=2;
164+
mp[0xef]=3;
165+
mp[0xff]=3;
166+
mp[0xfb]=3;
167+
mp[0xe3]=2;
168+
mp[0xf3]=2;
169+
170+
//LAS (LAR)
171+
mp[0xbb]=3;
172+
173+
//LAX
174+
mp[0xa7]=2;
175+
mp[0xb7]=2;
176+
mp[0xaf]=3;
177+
mp[0xbf]=3;
178+
mp[0xa3]=2;
179+
mp[0xb3]=2;
180+
181+
//LXA(LAX immediate)
182+
mp[0xab]=2;
183+
184+
//RLA
185+
mp[0x27]=2;
186+
mp[0x37]=2;
187+
mp[0x2f]=3;
188+
mp[0x3f]=3;
189+
mp[0x3b]=3;
190+
mp[0x23]=2;
191+
mp[0x33]=2;
192+
193+
//RRA
194+
mp[0x67]=2;
195+
mp[0x77]=2;
196+
mp[0x6f]=3;
197+
mp[0x7f]=3;
198+
mp[0x7b]=3;
199+
mp[0x63]=2;
200+
mp[0x73]=2;
201+
202+
//SAX(AXS,AAX)
203+
mp[0x87]=2;
204+
mp[0x97]=2;
205+
mp[0x8f]=3;
206+
mp[0x83]=2;
207+
208+
//SBX(AXS,SAX)
209+
mp[0xcb]=2;
210+
211+
//SHA(AHX,AXA)
212+
mp[0x9f]=3;
213+
mp[0x93]=2;
214+
215+
//SHX(A11,SXA,XAS)
216+
mp[0x9e]=3;
217+
218+
//SHY(A11,SYA,SAY)
219+
mp[0x9c]=3;
220+
221+
//SLO(ASO)
222+
mp[0x07]=2;
223+
mp[0x17]=2;
224+
mp[0x0f]=3;
225+
mp[0x1f]=3;
226+
mp[0x1b]=3;
227+
mp[0x03]=2;
228+
mp[0x13]=2;
229+
230+
//SRE(LSE)
231+
mp[0x47]=2;
232+
mp[0x57]=2;
233+
mp[0x4f]=3;
234+
mp[0x5f]=3;
235+
mp[0x5b]=3;
236+
mp[0x43]=2;
237+
mp[0x53]=2;
238+
239+
//TAS(XAS,SHS)
240+
mp[0x9b]=3;
241+
242+
//USBC(SBC)
243+
mp[0xeb]=2;
244+
245+
//NOPS(including DOP, TOP)
246+
mp[0x1a]=1;
247+
mp[0x3a]=1;
248+
mp[0x5a]=1;
249+
mp[0x7a]=1;
250+
mp[0xda]=1;
251+
mp[0xfa]=1;
252+
mp[0x80]=2;
253+
mp[0x82]=2;
254+
mp[0x89]=2;
255+
mp[0xc2]=2;
256+
mp[0xe2]=2;
257+
mp[0x04]=2;
258+
mp[0x44]=2;
259+
mp[0x64]=2;
260+
mp[0x14]=2;
261+
mp[0x34]=2;
262+
mp[0x54]=2;
263+
mp[0x74]=2;
264+
mp[0xd4]=2;
265+
mp[0xf4]=2;
266+
mp[0x0c]=3;
267+
mp[0x1c]=3;
268+
mp[0x3c]=3;
269+
mp[0x5c]=3;
270+
mp[0x7c]=3;
271+
mp[0xdc]=3;
272+
mp[0xfc]=3;
273+
274+
//JAM (KIL,HLT)
275+
mp[0x02]=1;
276+
mp[0x12]=1;
277+
mp[0x22]=1;
278+
mp[0x32]=1;
279+
mp[0x42]=1;
280+
mp[0x52]=1;
281+
mp[0x62]=1;
282+
mp[0x72]=1;
283+
mp[0x92]=1;
284+
mp[0xb2]=1;
285+
mp[0xd2]=1;
286+
mp[0xf2]=1;
287+
}
288+
if(mp[op]==0){
289+
if(debug_level>=1) printf("invalid op %02x, but not know how to skip extra bytes\n",op);
290+
return 0;
129291
}
130-
return 0;
292+
if(debug_level>=1) printf("skipped extra %d bytes for invalid op %02x\n",mp[op]-1,op);
293+
return mp[op]-1;
131294
}

0 commit comments

Comments
 (0)