Mercurial > repos > blastem
comparison blastem.c @ 89:9757b4c6c33f
Minor joypad fix and commeount out some debug printfs
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 26 Dec 2012 22:07:44 -0800 |
parents | c339559f1d4f |
children | dd3c680c618c |
comparison
equal
deleted
inserted
replaced
88:c339559f1d4f | 89:9757b4c6c33f |
---|---|
188 uint32_t busack_cycle = CYCLE_NEVER; | 188 uint32_t busack_cycle = CYCLE_NEVER; |
189 uint8_t new_busack = 0; | 189 uint8_t new_busack = 0; |
190 | 190 |
191 void io_adjust_cycles(io_port * pad, uint32_t current_cycle, uint32_t deduction) | 191 void io_adjust_cycles(io_port * pad, uint32_t current_cycle, uint32_t deduction) |
192 { | 192 { |
193 uint8_t control = pad->control | 0x80; | 193 /*uint8_t control = pad->control | 0x80; |
194 uint8_t th = control & pad->output; | 194 uint8_t th = control & pad->output; |
195 if (pad->input[GAMEPAD_TH0] || pad->input[GAMEPAD_TH1]) { | 195 if (pad->input[GAMEPAD_TH0] || pad->input[GAMEPAD_TH1]) { |
196 printf("adjust_cycles | control: %X, TH: %X, GAMEPAD_TH0: %X, GAMEPAD_TH1: %X, TH Counter: %d, Timeout: %d, Cycle: %d\n", control, th, pad->input[GAMEPAD_TH0], pad->input[GAMEPAD_TH1], pad->th_counter,pad->timeout_cycle, current_cycle); | 196 printf("adjust_cycles | control: %X, TH: %X, GAMEPAD_TH0: %X, GAMEPAD_TH1: %X, TH Counter: %d, Timeout: %d, Cycle: %d\n", control, th, pad->input[GAMEPAD_TH0], pad->input[GAMEPAD_TH1], pad->th_counter,pad->timeout_cycle, current_cycle); |
197 } | 197 }*/ |
198 if (current_cycle >= pad->timeout_cycle) { | 198 if (current_cycle >= pad->timeout_cycle) { |
199 pad->th_counter = 0; | 199 pad->th_counter = 0; |
200 } else { | 200 } else { |
201 pad->timeout_cycle -= deduction; | 201 pad->timeout_cycle -= deduction; |
202 } | 202 } |
228 uint8_t th = control & pad->output; | 228 uint8_t th = control & pad->output; |
229 uint8_t input; | 229 uint8_t input; |
230 if (context->current_cycle >= pad->timeout_cycle) { | 230 if (context->current_cycle >= pad->timeout_cycle) { |
231 pad->th_counter = 0; | 231 pad->th_counter = 0; |
232 } | 232 } |
233 if (pad->input[GAMEPAD_TH0] || pad->input[GAMEPAD_TH1]) { | 233 /*if (pad->input[GAMEPAD_TH0] || pad->input[GAMEPAD_TH1]) { |
234 printf("io_data_read | control: %X, TH: %X, GAMEPAD_TH0: %X, GAMEPAD_TH1: %X, TH Counter: %d, Timeout: %d, Cycle: %d\n", control, th, pad->input[GAMEPAD_TH0], pad->input[GAMEPAD_TH1], pad->th_counter,pad->timeout_cycle, context->current_cycle); | 234 printf("io_data_read | control: %X, TH: %X, GAMEPAD_TH0: %X, GAMEPAD_TH1: %X, TH Counter: %d, Timeout: %d, Cycle: %d\n", control, th, pad->input[GAMEPAD_TH0], pad->input[GAMEPAD_TH1], pad->th_counter,pad->timeout_cycle, context->current_cycle); |
235 } | 235 }*/ |
236 if (th) { | 236 if (th) { |
237 if (pad->th_counter == 2) { | 237 if (pad->th_counter == 2) { |
238 input = pad->input[GAMEPAD_EXTRA]; | 238 input = pad->input[GAMEPAD_EXTRA]; |
239 } else { | 239 } else { |
240 input = pad->input[GAMEPAD_TH1]; | 240 input = pad->input[GAMEPAD_TH1]; |
243 if (pad->th_counter == 2) { | 243 if (pad->th_counter == 2) { |
244 input = pad->input[GAMEPAD_TH0] | 0xF; | 244 input = pad->input[GAMEPAD_TH0] | 0xF; |
245 } else if(pad->th_counter == 3) { | 245 } else if(pad->th_counter == 3) { |
246 input = pad->input[GAMEPAD_TH0] & 0x30; | 246 input = pad->input[GAMEPAD_TH0] & 0x30; |
247 } else { | 247 } else { |
248 input = pad->input[GAMEPAD_TH0]; | 248 input = pad->input[GAMEPAD_TH0] | 0xC; |
249 } | 249 } |
250 } | 250 } |
251 context->value = ((~input) & (~control)) | (pad->output & control); | 251 context->value = ((~input) & (~control)) | (pad->output & control); |
252 /*if (pad->input[GAMEPAD_TH0] || pad->input[GAMEPAD_TH1]) { | 252 /*if (pad->input[GAMEPAD_TH0] || pad->input[GAMEPAD_TH1]) { |
253 printf ("value: %X\n", context->value); | 253 printf ("value: %X\n", context->value); |
326 case 0x5: | 326 case 0x5: |
327 gamepad_2.control = value; | 327 gamepad_2.control = value; |
328 break; | 328 break; |
329 } | 329 } |
330 } else { | 330 } else { |
331 printf("IO Write of %X to %X\n", value, location); | 331 //printf("IO Write of %X to %X\n", value, location); |
332 if (location == 0x1100) { | 332 if (location == 0x1100) { |
333 if (busack_cycle > context->current_cycle) { | 333 if (busack_cycle > context->current_cycle) { |
334 busack = new_busack; | 334 busack = new_busack; |
335 busack_cycle = CYCLE_NEVER; | 335 busack_cycle = CYCLE_NEVER; |
336 } | 336 } |
391 if (busack_cycle > context->current_cycle) { | 391 if (busack_cycle > context->current_cycle) { |
392 busack = new_busack; | 392 busack = new_busack; |
393 busack_cycle = CYCLE_NEVER; | 393 busack_cycle = CYCLE_NEVER; |
394 } | 394 } |
395 context->value = (!reset) && busack; | 395 context->value = (!reset) && busack; |
396 printf("Byte read of BUSREQ returned %d\n", context->value); | 396 //printf("Byte read of BUSREQ returned %d\n", context->value); |
397 } else if (location == 0x1200) { | 397 } else if (location == 0x1200) { |
398 context->value = !reset; | 398 context->value = !reset; |
399 } else { | 399 } else { |
400 printf("Byte read of unknown IO location: %X\n", location); | 400 printf("Byte read of unknown IO location: %X\n", location); |
401 } | 401 } |
431 //PORT C Control | 431 //PORT C Control |
432 context->value = 0; | 432 context->value = 0; |
433 break; | 433 break; |
434 } | 434 } |
435 context->value = context->value | (context->value << 8); | 435 context->value = context->value | (context->value << 8); |
436 printf("Word read to %X returned %d\n", location, context->value); | 436 //printf("Word read to %X returned %d\n", location, context->value); |
437 } else { | 437 } else { |
438 if (location == 0x1100) { | 438 if (location == 0x1100) { |
439 if (busack_cycle > context->current_cycle) { | 439 if (busack_cycle > context->current_cycle) { |
440 busack = new_busack; | 440 busack = new_busack; |
441 busack_cycle = CYCLE_NEVER; | 441 busack_cycle = CYCLE_NEVER; |
442 } | 442 } |
443 context->value = ((!reset) && busack) << 8; | 443 context->value = ((!reset) && busack) << 8; |
444 printf("Word read of BUSREQ returned %d\n", context->value); | 444 //printf("Word read of BUSREQ returned %d\n", context->value); |
445 } else if (location == 0x1200) { | 445 } else if (location == 0x1200) { |
446 context->value = (!reset) << 8; | 446 context->value = (!reset) << 8; |
447 } else { | 447 } else { |
448 printf("Word read of unknown IO location: %X\n", location); | 448 printf("Word read of unknown IO location: %X\n", location); |
449 } | 449 } |