Previous 15994 Revisions Next

r3232 Thursday 11th September, 2008 at 21:18:03 UTC by Roberto Zandonà
[C64] simplified sprites and fixed collision
[src/mess/video]vic6567.c vic6567.h

src/mess/video/vic6567.c
r3231r3232
455455   case 0x11:
456456      if (vic2.reg[offset] != data)
457457      {
458//         vic2.reg_buffer[offset] = data;
459
458460         vic2.reg[offset] = data;
459461         if (LINES25)
460462         {
r3231r3232
466468            vic2.y_begin = 4;
467469            vic2.y_end = vic2.y_begin + 192;
468470         }
471
469472      }
470473      break;
471474   case 0x12:
r3231r3232
477480   case 0x16:
478481      if (vic2.reg[offset] != data)
479482      {
483//         vic2.reg_buffer[offset] = data;
484
480485         vic2.reg[offset] = data;
481486         if (COLUMNS40)
482487         {
r3231r3232
488493            vic2.x_begin = HORIZONTALPOS;
489494            vic2.x_end = vic2.x_begin + 320;
490495         }
496
491497      }
492498      break;
493499   case 0x18:
r3231r3232
11701176   int attr, ch, ecm;
11711177   int syend;
11721178   int offs, yoff, xoff, ybegin, yend, xbegin, xend;
1173   int i, j;
1179   int i;
11741180
11751181   if (vic2.vic3 && VIC3_BITPLANES) return ;
1182
11761183   /* temporary allowing vic3 displaying 80 columns */
1177   if (vic2.vic3&&(vic2.reg[0x31]&0x80)) {
1178      vic3_drawlines(first , last, start_x, end_x);
1184   if (vic2.vic3 && (vic2.reg[0x31] & 0x80))
1185   {
1186      vic3_drawlines(first, first + 1, start_x, end_x);
11791187      return;
11801188   }
11811189
1182   if (first == last)
1183      return;
1184   vic2.lastline = last;
11851190   if (video_skip_this_frame ())
11861191      return;
11871192
11881193   /* top part of display not rastered */
11891194   first -= VIC2_YPOS - YPOS;
1190   last -= VIC2_YPOS - YPOS;
11911195
1192/*
1193   if ((first >= last) || (last <= 0))
1194   {
1195      for (i = 0; i < 8; i++)
1196         vic2.sprites[i].repeat = vic2.sprites[i].line = 0;
1197      return;
1198   }
1199   if (first < 0)
1200      first = 0;
1201*/
12021196   if (!SCREENON)
12031197   {
1204      for (line = first; (line < last) && (line < vic2.bitmap->height); line++)
1205         memset16 (BITMAP_ADDR16(vic2.bitmap, line + FIRSTLINE, 0), FRAMECOLOR, vic2.bitmap->width);
1198//      if (first < vic2.bitmap->height)
1199      memset16 (BITMAP_ADDR16(vic2.bitmap, first + FIRSTLINE, 0), FRAMECOLOR, vic2.bitmap->width);
12061200      return;
12071201   }
12081202
r3231r3232
12111205   else
12121206      xbegin = XPOS + 7, xend = xbegin + 304;
12131207
1214   if (last < vic2.y_begin)
1215      end = last;
1208   if (first + 1 < vic2.y_begin)
1209      end = first + 1;
12161210   else
12171211      end = vic2.y_begin + YPOS;
12181212
12191213   line = first;
1220   if (line < end) {
1214   if (line < end)
1215   {
12211216      plot_box(vic2.bitmap, start_x, line + FIRSTLINE, end_x - start_x, 1, FRAMECOLOR);
1222      line=end;
1217      line = end;
12231218   }
12241219
12251220   if (LINES25)
r3231r3232
12301225   {
12311226      vline = line - vic2.y_begin - YPOS + 8 - VERTICALPOS;
12321227   }
1233   if (last < vic2.y_end + YPOS)
1234      end = last;
1228   if (first + 1 < vic2.y_end + YPOS)
1229      end = first + 1;
12351230   else
12361231      end = vic2.y_end + YPOS;
12371232
1238   for (; line < end; vline = (vline + 8) & ~7, line = line + 1 + yend - ybegin)
1233   if (line < end)
12391234   {
12401235      offs = (vline >> 3) * 40;
12411236      ybegin = vline & 7;
12421237      yoff = line - ybegin;
12431238      yend = (yoff + 7 < end) ? 7 : (end - yoff - 1);
1239
12441240      /* rendering 39 characters */
12451241      /* left and right borders are overwritten later */
1242
12461243      vic2.shift[line] = HORIZONTALPOS;
12471244      for (xoff = vic2.x_begin + XPOS; xoff < vic2.x_end + XPOS; xoff += 8, offs++)
12481245      {
r3231r3232
12851282            vic2_draw_character (ybegin, yend, ch, yoff, xoff, vic2.mono, start_x, end_x);
12861283         }
12871284      }
1288   }
12891285
1290   line = first;
1291   if (LINES25)
1292   {
1293      vline = line - vic2.y_begin - YPOS;
1294   }
1295   else
1296   {
1297      vline = line - vic2.y_begin - YPOS + 8 - VERTICALPOS;
1298   }
1299   if (last < vic2.y_end + YPOS)
1300      end = last;
1301   else
1302      end = vic2.y_end + YPOS;
1303
1304   for (; line < end; vline = (vline + 8) & ~7, line = line + 1 + yend - ybegin)
1305   {
1306      offs = (vline >> 3) * 40;
1307      ybegin = vline & 7;
1308      yoff = line - ybegin;
1309      yend = (yoff + 7 < end) ? 7 : (end - yoff - 1);
13101286      /* sprite priority, sprite overwrites lowerprior pixels */
13111287      for (i = 7; i >= 0; i--)
13121288      {
1313      if (vic2.sprites[i].line || vic2.sprites[i].repeat) // FIX ME: sprite warp is wrong
1314         {
1315            syend = yend;
1316            if (SPRITE_Y_EXPAND (i))
1317            {
1318               if ((21 - vic2.sprites[i].line) * 2 - vic2.sprites[i].repeat < yend - ybegin + 1)
1319               syend = ybegin + (21 - vic2.sprites[i].line) * 2 - vic2.sprites[i].repeat - 1;
1320            }
1321            else
1322            {
1323               if (vic2.sprites[i].line + yend - ybegin + 1 > 20)
1324               syend = ybegin + 20 - vic2.sprites[i].line;
1325            }
1326            if (yoff + syend > YPOS + 200)
1327               syend = YPOS + 200 - yoff - 1;
1328            if (yoff + ybegin < 0)
1329            {
1330               ybegin = -yoff;
1331               yend = - yoff;
1332            }
1333
1334            if (SPRITE_MULTICOLOR (i))
1335               vic2_draw_sprite_multi (i, yoff, ybegin, syend, start_x, end_x);
1336            else
1337               vic2_draw_sprite (i, yoff, ybegin, syend,  start_x, end_x);
1338            if ((syend != yend) || (vic2.sprites[i].line > 20))
1339            {
1340               vic2.sprites[i].line = vic2.sprites[i].repeat = 0;
1341               for (j = syend; j <= yend; j++)
1342                  vic2.sprites[i].paintedline[j] = 0;
1343            }
1344         }
1345         else if (SPRITEON (i) &&
1289         if (SPRITEON (i) &&
13461290               (yoff + ybegin >= SPRITE_Y_POS (i)) &&
13471291               (yoff + ybegin - SPRITE_Y_POS (i) < (SPRITE_Y_EXPAND (i)? 21 * 2 : 21 )) &&
13481292               (SPRITE_Y_POS (i) < 0))
r3231r3232
13701314               vic2_draw_sprite_multi (i, 0, 0 , syend, start_x, end_x);
13711315            else
13721316               vic2_draw_sprite (i, 0, 0 , syend, start_x, end_x);
1373
1374            if ((syend != yend) || (vic2.sprites[i].line > 20))
1375            {
1376               for (j = syend; j <= yend; j++)
1377                  vic2.sprites[i].paintedline[j] = 0;
1378               vic2.sprites[i].line = vic2.sprites[i].repeat = 0;
1379            }
13801317         }
13811318         else if    (SPRITEON (i) &&
13821319               (yoff + ybegin >= SPRITE_Y_POS (i)) &&
r3231r3232
14021339
14031340            vic2.sprites[i].line = wrapped;
14041341
1405            for (j = 0; j < SPRITE_Y_POS (i) - yoff; j++)
1406               vic2.sprites[i].paintedline[j] = 0;
1407
14081342            if (SPRITE_MULTICOLOR (i))
14091343               vic2_draw_sprite_multi (i, yoff + ybegin, 0, 0, start_x, end_x);
14101344            else
14111345               vic2_draw_sprite (i, yoff + ybegin, 0, 0, start_x, end_x);
1412
1413            if ((syend != yend) || (vic2.sprites[i].line > 20))
1414            {
1415               for (j = syend; j <= yend; j++)
1416                  vic2.sprites[i].paintedline[j] = 0;
1417               vic2.sprites[i].line = vic2.sprites[i].repeat = 0;
1418            }
14191346         }
14201347         else
14211348         {
14221349            memset (vic2.sprites[i].paintedline, 0, sizeof (vic2.sprites[i].paintedline));
14231350         }
14241351      }
1352      line += 1 + yend - ybegin;
14251353   }
14261354   // TO DO: to implement start_x and end_x
14271355   plot_box(vic2.bitmap, 0, first + FIRSTLINE, xbegin, 1, FRAMECOLOR);
14281356   plot_box(vic2.bitmap, xend, first + FIRSTLINE, vic2.bitmap->width - xend, 1, FRAMECOLOR);
14291357
1430   if (last < vic2.bitmap->height)
1431      end = last;
1358   if (first + 1 < vic2.bitmap->height)
1359      end = first + 1;
14321360   else
14331361      end = vic2.bitmap->height;
14341362
r3231r3232
14431371// TIMER_CALLBACK( vic2_scanline_interrupt )
14441372INTERRUPT_GEN( vic2_raster_irq )
14451373{
1446   int i;
1374   int i,j;
14471375//   int scanline = param;
14481376
14491377   vic2.rasterline++;
r3231r3232
14631391   }
14641392   for (i=0; i < 5; i++)
14651393      vic2.spritemulti[i] = vic2.spritemulti_buffer[i];
1466   // if (input_code_pressed(KEYCODE_Q)) { cpunum_set_clock(machine, 0, 0x93203); }
1467   // if (input_code_pressed(KEYCODE_W)) { cpunum_set_clock(machine, 0, 0xf08a0); }
1468   // if (input_code_pressed(KEYCODE_E)) printf("%04x    ",cpunum_get_clock(0));
1469   // if (input_code_pressed(KEYCODE_R)) printf("%04x    ", (int)(cpunum_get_clock(0)*63/103));
1394/*
1395   i=0;
1396   if (input_code_pressed(KEYCODE_Q)) i = 1;
1397   if (input_code_pressed(KEYCODE_W)) i = 2;
1398   if (input_code_pressed(KEYCODE_E)) i = 3;
1399   if (input_code_pressed(KEYCODE_R)) i = 4;
1400   if (input_code_pressed(KEYCODE_T)) i = 5;
1401   if (input_code_pressed(KEYCODE_Y)) i = 6;
1402   if (input_code_pressed(KEYCODE_U)) i = 7;
1403
1404   if ((vic2.rasterline % 8) == 0x02)
1405   {
1406      vic2.reg[0x11] = vic2.reg_buffer[0x11];
1407      if (LINES25)
1408      {
1409         vic2.y_begin = 0;
1410         vic2.y_end = vic2.y_begin + 200;
1411      }
1412      else
1413      {
1414         vic2.y_begin = 4;
1415         vic2.y_end = vic2.y_begin + 192;
1416      }
1417
1418      vic2.reg[0x16] = vic2.reg_buffer[0x16];
1419      if (COLUMNS40)
1420      {
1421         vic2.x_begin = 0;
1422         vic2.x_end = vic2.x_begin + 320;
1423      }
1424      else
1425      {
1426         vic2.x_begin = HORIZONTALPOS;
1427         vic2.x_end = vic2.x_begin + 320;
1428      }
1429   }
1430*/
1431/*
1432   if (input_code_pressed(KEYCODE_Q)) { cpunum_set_clock(machine, 0, 0x93203); }
1433   if (input_code_pressed(KEYCODE_W)) { cpunum_set_clock(machine, 0, 0xf08a0); }
1434   if (input_code_pressed(KEYCODE_E)) printf("%04x    ",cpunum_get_clock(0));
1435   if (input_code_pressed(KEYCODE_R)) printf("%04x    ", (int)(cpunum_get_clock(0)*63/103));
14701436   vic2.raster_mod += 63 - (activecpu_gettotalcycles() - vic2.rasterline_start_cpu_cycles);
1471   // if (input_code_pressed(KEYCODE_Q)) printf("%04x-%04x ",vic2.raster_mod, (int)(activecpu_gettotalcycles() - vic2.rasterline_start_cpu_cycles));
1437   if (input_code_pressed(KEYCODE_Q)) printf("%04x-%04x ",vic2.raster_mod, (int)(activecpu_gettotalcycles() - vic2.rasterline_start_cpu_cycles));
14721438   vic2.rasterline_start_cpu_cycles = activecpu_gettotalcycles();
14731439   if (vic2.raster_mod > 63)
14741440   {
r3231r3232
14801446      vic2.raster_mod += 63;
14811447      vic2.rasterline++;
14821448   }
1483
1449*/
14841450   if (vic2.rasterline == vic2.lines)
14851451   {
14861452      vic2.rasterline = 0;
14871453
1454
1455
14881456      for (i = 0; i < 8; i++)
1457      {
14891458         vic2.sprites[i].repeat = vic2.sprites[i].line = 0;
1490      vic2.lastline = 0;
1459         for (j = 0; j < 256; j++)
1460            vic2.sprites[i].paintedline[j] = 0;
1461      }
1462
14911463      if (LIGHTPEN_BUTTON)
14921464      {
14931465         /* lightpen timer starten */
14941466         timer_set (attotime_make(0, 0), NULL, 1, vic2_timer_timeout);
14951467      }
14961468   }
1497   // activecpu_eat_cycles(1000);
14981469
14991470   if (vic2.rasterline == C64_2_RASTERLINE(RASTERLINE))
15001471   {
src/mess/video/vic6567.h
r3231r3232
4444#define VIC2_CLOCK ((vic2.pal?VIC6569_CLOCK:VIC6567_CLOCK))
4545
4646#define VIC6567_HRETRACERATE (VIC6567_CLOCK / 65)
47#define VIC6569_HRETRACERATE (VIC6569_CLOCK / VIC6569_CLOCK )
47#define VIC6569_HRETRACERATE (VIC6569_CLOCK / 63)
4848
4949#define VIC2_HRETRACERATE (vic2.pal?VIC6569_HRETRACERATE:VIC6567_HRETRACERATE)
5050

Previous 15994 Revisions Next


© 1998-2018 The MESS Team