comparison blastem.c @ 115:11d72e471104

Fix Z80 busreq logic
author Mike Pavone <pavone@retrodev.com>
date Fri, 28 Dec 2012 20:46:29 -0800
parents a71544cd01ea
children 0bdbffa9fe90
comparison
equal deleted inserted replaced
114:e821b6fde0e4 115:11d72e471104
282 } 282 }
283 if (value & 1) { 283 if (value & 1) {
284 busreq = 1; 284 busreq = 1;
285 if(!reset) { 285 if(!reset) {
286 busack_cycle = context->current_cycle + Z80_ACK_DELAY; 286 busack_cycle = context->current_cycle + Z80_ACK_DELAY;
287 new_busack = 1; 287 new_busack = 0;
288 } 288 }
289 } else { 289 } else {
290 busreq = 0; 290 busreq = 0;
291 busack_cycle = CYCLE_NEVER; 291 busack_cycle = CYCLE_NEVER;
292 busack = 0; 292 busack = 1;
293 } 293 }
294 } else if (location == 0x1200) { 294 } else if (location == 0x1200) {
295 if (value & 1) { 295 if (value & 1) {
296 if (reset && busreq) { 296 if (reset && busreq) {
297 new_busack = 1; 297 new_busack = 0;
298 busack_cycle = context->current_cycle + Z80_ACK_DELAY; 298 busack_cycle = context->current_cycle + Z80_ACK_DELAY;
299 } 299 }
300 reset = 0; 300 reset = 0;
301 } else { 301 } else {
302 busack = 0;
303 reset = 1; 302 reset = 1;
304 } 303 }
305 } 304 }
306 } 305 }
307 return context; 306 return context;
326 case 0x5: 325 case 0x5:
327 gamepad_2.control = value; 326 gamepad_2.control = value;
328 break; 327 break;
329 } 328 }
330 } else { 329 } else {
331 //printf("IO Write of %X to %X\n", value, location); 330 printf("IO Write of %X to %X @ %d\n", value, location, context->current_cycle);
332 if (location == 0x1100) { 331 if (location == 0x1100) {
333 if (busack_cycle > context->current_cycle) { 332 if (busack_cycle > context->current_cycle) {
334 busack = new_busack; 333 busack = new_busack;
335 busack_cycle = CYCLE_NEVER; 334 busack_cycle = CYCLE_NEVER;
336 } 335 }
337 if (value & 0x100) { 336 if (value & 0x100) {
338 busreq = 1; 337 busreq = 1;
339 if(!reset) { 338 if(!reset) {
340 busack_cycle = context->current_cycle + Z80_ACK_DELAY; 339 busack_cycle = context->current_cycle + Z80_ACK_DELAY;
341 new_busack = 1; 340 new_busack = 0;
342 } 341 }
343 } else { 342 } else {
344 busreq = 0; 343 busreq = 0;
345 busack_cycle = CYCLE_NEVER; 344 busack_cycle = CYCLE_NEVER;
346 busack = 0; 345 busack = 1;
347 } 346 }
348 } else if (location == 0x1200) { 347 } else if (location == 0x1200) {
349 if (value & 0x100) { 348 if (value & 0x100) {
350 if (reset && busreq) { 349 if (reset && busreq) {
351 new_busack = 1; 350 new_busack = 0;
352 busack_cycle = context->current_cycle + Z80_ACK_DELAY; 351 busack_cycle = context->current_cycle + Z80_ACK_DELAY;
353 } 352 }
354 reset = 0; 353 reset = 0;
355 } else { 354 } else {
356 busack = 0;
357 reset = 1; 355 reset = 1;
358 } 356 }
359 } 357 }
360 } 358 }
361 return context; 359 return context;
390 if (location == 0x1100) { 388 if (location == 0x1100) {
391 if (busack_cycle > context->current_cycle) { 389 if (busack_cycle > context->current_cycle) {
392 busack = new_busack; 390 busack = new_busack;
393 busack_cycle = CYCLE_NEVER; 391 busack_cycle = CYCLE_NEVER;
394 } 392 }
395 context->value = (!reset) && busack; 393 context->value = reset || busack;
396 //printf("Byte read of BUSREQ returned %d\n", context->value); 394 printf("Byte read of BUSREQ returned %d @ %d (reset: %d, busack: %d)\n", context->value, context->current_cycle, reset, busack);
397 } else if (location == 0x1200) { 395 } else if (location == 0x1200) {
398 context->value = !reset; 396 context->value = !reset;
399 } else { 397 } else {
400 printf("Byte read of unknown IO location: %X\n", location); 398 printf("Byte read of unknown IO location: %X\n", location);
401 } 399 }
438 if (location == 0x1100) { 436 if (location == 0x1100) {
439 if (busack_cycle > context->current_cycle) { 437 if (busack_cycle > context->current_cycle) {
440 busack = new_busack; 438 busack = new_busack;
441 busack_cycle = CYCLE_NEVER; 439 busack_cycle = CYCLE_NEVER;
442 } 440 }
443 context->value = ((!reset) && busack) << 8; 441 context->value = (reset || busack) << 8;
444 //printf("Word read of BUSREQ returned %d\n", context->value); 442 printf("Word read of BUSREQ returned %d\n", context->value);
445 } else if (location == 0x1200) { 443 } else if (location == 0x1200) {
446 context->value = (!reset) << 8; 444 context->value = (!reset) << 8;
447 } else { 445 } else {
448 printf("Word read of unknown IO location: %X\n", location); 446 printf("Word read of unknown IO location: %X\n", location);
449 } 447 }