Previous 15994 Revisions Next

r8746 Sunday 8th August, 2010 at 18:05:38 UTC by Roberto Zandonà
[C64] modified rdy hack; now Turrican is playable
[src/mess/video]vic6567.c

src/mess/video/vic6567.c
r8745r8746
7474#include "emu.h"
7575#include "video/vic6567.h"
7676
77static UINT8 rdy_cycles = 0;
78
7779typedef struct _vic2_state  vic2_state;
7880struct _vic2_state
7981{
r8745r8746
375377   {
376378      vic2->first_ba_cycle = vic2->cycles_counter;
377379      if ((vic2->rdy_workaround_cb != NULL) && (vic2->rdy_workaround_cb(machine) != 7 ))
378         cpu_suspend(machine->firstcpu, SUSPEND_REASON_SPIN, 0);
380      {
381//         cpu_suspend(machine->firstcpu, SUSPEND_REASON_SPIN, 0);
382      }
379383      vic2->cpu_suspended = 1;
380384   }
381385}
r8745r8746
386390   if (vic2->cpu_suspended == 1)
387391   {
388392      if ((vic2->rdy_workaround_cb != NULL))
389         cpu_resume(machine->firstcpu, SUSPEND_REASON_SPIN);
393      {
394//   cpu_resume(machine->firstcpu, SUSPEND_REASON_SPIN);
395      }
390396      vic2->cpu_suspended = 0;
391397   }
392398}
r8745r8746
993999   vic2_state *vic2 = (vic2_state *)ptr;
9941000   int i;
9951001   UINT8 mask;
1002   static int adjust[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
1003
1004   UINT8 cpu_cycles = machine->device<cpu_device>("maincpu")->total_cycles() & 0xff;
1005   UINT8 vic_cycles = (vic2->cycles_counter + 1) & 0xff;
9961006   vic2->cycles_counter++;
9971007
1008//   printf("%02x %02x %02x\n",cpu_cycles,vic_cycles,rdy_cycles);
1009/*
1010if (input_code_pressed(machine, KEYCODE_X))
1011{
1012if (input_code_pressed_once(machine, KEYCODE_Q)) adjust[1]++;
1013if (input_code_pressed_once(machine, KEYCODE_W)) adjust[2]++;
1014if (input_code_pressed_once(machine, KEYCODE_E)) adjust[3]++;
1015if (input_code_pressed_once(machine, KEYCODE_R)) adjust[4]++;
1016if (input_code_pressed_once(machine, KEYCODE_T)) adjust[5]++;
1017if (input_code_pressed_once(machine, KEYCODE_Y)) adjust[6]++;
1018if (input_code_pressed_once(machine, KEYCODE_U)) adjust[7]++;
1019if (input_code_pressed_once(machine, KEYCODE_I)) adjust[8]++;
1020if (input_code_pressed_once(machine, KEYCODE_A)) adjust[1]--;
1021if (input_code_pressed_once(machine, KEYCODE_S)) adjust[2]--;
1022if (input_code_pressed_once(machine, KEYCODE_D)) adjust[3]--;
1023if (input_code_pressed_once(machine, KEYCODE_F)) adjust[4]--;
1024if (input_code_pressed_once(machine, KEYCODE_G)) adjust[5]--;
1025if (input_code_pressed_once(machine, KEYCODE_H)) adjust[6]--;
1026if (input_code_pressed_once(machine, KEYCODE_J)) adjust[7]--;
1027if (input_code_pressed_once(machine, KEYCODE_K)) adjust[8]--;
1028if (input_code_pressed_once(machine, KEYCODE_C)) adjust[0]++;
1029if (input_code_pressed_once(machine, KEYCODE_V)) adjust[0]--;
1030if (input_code_pressed_once(machine, KEYCODE_Z)) printf("b:%02x 1:%02x 2:%02x 3:%02x 4:%02x 5:%02x 6:%02x 7:%02x 8:%02x\n",
1031                        adjust[0],adjust[1],adjust[2],adjust[3],adjust[4],adjust[5],adjust[6],adjust[7],adjust[8]);
1032}
1033*/
1034
9981035   switch(vic2->cycle)
9991036   {
10001037
r8745r8746
10341071      else
10351072         vic2_resume_cpu(machine, vic2);
10361073
1074      if (vic2->spr_dma_on & 0x08) rdy_cycles += (2 + adjust[1]);
1075
10371076      vic2->cycle++;
10381077      break;
10391078
r8745r8746
10781117      else
10791118         vic2_resume_cpu(machine, vic2);
10801119
1120      if (vic2->spr_dma_on & 0x10) rdy_cycles += (2 + adjust[2]);
1121
10811122      vic2->cycle++;
10821123      break;
10831124
r8745r8746
11011142      else
11021143         vic2_resume_cpu(machine, vic2);
11031144
1145      if (vic2->spr_dma_on & 0x20) rdy_cycles += (2 + adjust[3]);
1146
11041147      vic2->cycle++;
11051148      break;
11061149
r8745r8746
11241167      else
11251168         vic2_resume_cpu(machine, vic2);
11261169
1170      if (vic2->spr_dma_on & 0x40) rdy_cycles += (2 + adjust[4]);
1171
11271172      vic2->cycle++;
11281173      break;
11291174
r8745r8746
11471192      else
11481193         vic2_resume_cpu(machine, vic2);
11491194
1195      if (vic2->spr_dma_on & 0x80) rdy_cycles += (2 + adjust[5]);
1196
11501197      vic2->cycle++;
11511198      break;
11521199
r8745r8746
11871234      vic2->raster_x = 0xfffc;
11881235
11891236      if ((vic2->rdy_workaround_cb(machine) == 0 ) && (vic2->is_bad_line))
1190         vic2_suspend_cpu(machine, vic2);
1237         rdy_cycles += (43+adjust[0]);
11911238
11921239      vic2->cycle++;
11931240      break;
r8745r8746
12021249      vic2->vc = vic2->vc_base;
12031250
12041251      if ((vic2->rdy_workaround_cb(machine) == 1 ) && (vic2->is_bad_line))
1205         vic2_suspend_cpu(machine, vic2);
1252         rdy_cycles += (42+adjust[0]);
12061253
12071254      vic2->cycle++;
12081255      break;
r8745r8746
12221269      vic2_matrix_access(machine, vic2);
12231270
12241271      if ((vic2->rdy_workaround_cb(machine) == 2 ) && (vic2->is_bad_line))
1225         vic2_suspend_cpu(machine, vic2);
1272         rdy_cycles += (41+adjust[0]);
12261273
12271274      vic2->cycle++;
12281275      break;
r8745r8746
12461293      vic2_matrix_access(machine, vic2);
12471294
12481295      if ((vic2->rdy_workaround_cb(machine) == 3 ) && (vic2->is_bad_line))
1249         vic2_suspend_cpu(machine, vic2);
1296         rdy_cycles += (40+adjust[0]);
12501297
12511298      vic2->cycle++;
12521299      break;
r8745r8746
12831330      vic2_matrix_access(machine, vic2);
12841331
12851332      if ((vic2->rdy_workaround_cb(machine) == 4 ) && (vic2->is_bad_line))
1286         vic2_suspend_cpu(machine, vic2);
1333         rdy_cycles += (40+adjust[0]);
12871334
12881335      vic2->cycle++;
12891336      break;
r8745r8746
14561503      else
14571504         vic2_resume_cpu(machine, vic2);
14581505
1506      if (vic2->spr_dma_on & 0x01) rdy_cycles += (2 + adjust[6]);
1507
14591508      vic2->cycle++;
14601509      break;
14611510
r8745r8746
15111560      else
15121561         vic2_resume_cpu(machine, vic2);
15131562
1563      if (vic2->spr_dma_on & 0x02) rdy_cycles += (2 + adjust[7]);
1564
15141565      vic2->cycle++;
15151566      break;
15161567
r8745r8746
15341585      else
15351586         vic2_resume_cpu(machine, vic2);
15361587
1588      if (vic2->spr_dma_on & 0x04) rdy_cycles += (2 + adjust[8]);
1589
15371590      vic2->cycle++;
15381591      break;
15391592
r8745r8746
15531606      vic2->cycle = 1;
15541607   }
15551608
1609   if ((cpu_cycles == vic_cycles) && (rdy_cycles > 0))
1610   {
1611      device_spin_until_time (machine->firstcpu, machine->device<cpu_device>("maincpu")->cycles_to_attotime(rdy_cycles));
1612      rdy_cycles = 0;
1613   }
1614
15561615   vic2->raster_x += 8;
15571616   timer_set(machine, machine->device<cpu_device>("maincpu")->cycles_to_attotime(1), vic2, 0, pal_timer_callback);
15581617}
r8745r8746
26852744   // from 0 to 311 (0 first, PAL) or from 0 to 261 (? first, NTSC 6567R56A) or from 0 to 262 (? first, NTSC 6567R8)
26862745   vic2->rasterline = 0; // VIC2_LINES - 1;
26872746
2688   vic2->cycles_counter = 0;
2747   vic2->cycles_counter = -1;
26892748   vic2->cycle = 63;
26902749
26912750   vic2->on = 1;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team