Previous 199869 Revisions Next

r25339 Sunday 15th September, 2013 at 23:49:35 UTC by Angelo Salese
Fixed fb out-of-bounds writes
[src/mame/video]powervr2.c
[src/mess/drivers]dccons.c

trunk/src/mame/video/powervr2.c
r25338r25339
29962996   UINT32 *fbaddr;
29972997   UINT32 c;
29982998   UINT32 r,g,b;
2999   //INT32 vo_horz_start_pos = vo_startx & 0x3ff;
30002999   UINT8 interlace_on = ((spg_control & 0x10) >> 4);
30013000   INT32 ystart_f1 = (vo_starty & 0x3ff) << interlace_on;
30023001   //INT32 ystart_f2 = (vo_starty >> 16) & 0x3ff;
30033002   INT32 hstart = (vo_startx & 0x3ff);
3003   int res_x,res_y;
3004//   rectangle fbclip;
30043005
30053006   UINT8 unpackmode = (fb_r_ctrl & 0x0000000c) >>2;  // aka fb_depth
30063007   UINT8 enable = (fb_r_ctrl & 0x00000001);
r25338r25339
30173018
30183019//   popmessage("%d %d %d %d %d",ystart_f1,ystart_f2,interlace_on,spg_vblank & 0x3ff,(spg_vblank >> 16) & 0x3ff);
30193020
3021#if 0
3022   fbclip.min_x = hstart;
3023   fbclip.min_y = ystart_f1;
3024   fbclip.max_x = hstart + (xi << ((vo_control & 0x100) >> 8));
3025   fbclip.max_y = ystart_f1 + dy;
3026
3027   popmessage("%d %d %d %d",fbclip.min_x,fbclip.min_y,fbclip.max_x,fbclip.max_y);
3028#endif
3029
30203030   switch (unpackmode)
30213031   {
30223032      case 0x00: // 0555 RGB 16-bit, Cleo Fortune Plus
r25338r25339
30283038            {
30293039               for (x=0;x < xi;x++)
30303040               {
3031                  fbaddr=&bitmap.pix32(y + ystart_f1, x*2+0 + hstart);
3041                  res_x = x*2+0 + hstart;
3042                  res_y = y + ystart_f1;
3043
3044                  fbaddr=&bitmap.pix32(res_y, res_x);
30323045                  c=*((reinterpret_cast<UINT16 *>(dc_framebuffer_ram)) + (WORD2_XOR_LE(addrp) >> 1));
30333046
30343047                  b = (c & 0x001f) << 3;
30353048                  g = (c & 0x03e0) >> 2;
30363049                  r = (c & 0x7c00) >> 7;
30373050
3038                  if (y<=cliprect.max_y)
3051                  if (cliprect.contains(res_x, res_y))
30393052                     *fbaddr = b | (g<<8) | (r<<16);
30403053
3041                  fbaddr=&bitmap.pix32(y + ystart_f1, x*2+1 + hstart);
3042                  if (y<=cliprect.max_y)
3054                  res_x = x*2+1 + hstart;
3055
3056                  fbaddr=&bitmap.pix32(res_y, res_x);
3057                  if (cliprect.contains(res_x, res_y))
30433058                     *fbaddr = b | (g<<8) | (r<<16);
30443059                  addrp+=2;
30453060               }
r25338r25339
30483063            {
30493064               for (x=0;x < xi;x++)
30503065               {
3051                  fbaddr=&bitmap.pix32(y + ystart_f1, x + hstart);
3066                  res_x = x + hstart;
3067                  res_y = y + ystart_f1;
3068
3069                  fbaddr=&bitmap.pix32(res_y, res_x);
30523070                  c=*((reinterpret_cast<UINT16 *>(dc_framebuffer_ram)) + (WORD2_XOR_LE(addrp) >> 1));
30533071
30543072                  b = (c & 0x001f) << 3;
30553073                  g = (c & 0x03e0) >> 2;
30563074                  r = (c & 0x7c00) >> 7;
30573075
3058                  if (y<=cliprect.max_y)
3076                  if (cliprect.contains(res_x, res_y))
30593077                     *fbaddr = b | (g<<8) | (r<<16);
30603078                  addrp+=2;
30613079               }
r25338r25339
30723090            {
30733091               for (x=0;x < xi;x++)
30743092               {
3075                  fbaddr=&bitmap.pix32(y + ystart_f1, x*2+0 + hstart);
3093                  res_x = x*2+0 + hstart;
3094                  res_y = y + ystart_f1;
3095                  fbaddr=&bitmap.pix32(res_y, res_x);
30763096                  c=*((reinterpret_cast<UINT16 *>(dc_framebuffer_ram)) + (WORD2_XOR_LE(addrp) >> 1));
30773097
30783098                  b = (c & 0x001f) << 3;
30793099                  g = (c & 0x07e0) >> 3;
30803100                  r = (c & 0xf800) >> 8;
30813101
3082                  if (y<=cliprect.max_y)
3102                  if (cliprect.contains(res_x, res_y))
30833103                     *fbaddr = b | (g<<8) | (r<<16);
30843104
3085                  fbaddr=&bitmap.pix32(y + ystart_f1, x*2+1 + hstart);
3105                  res_x = x*2+1 + hstart;
3106                  //res_y = y + ystart_f1;
3107                  fbaddr=&bitmap.pix32(res_y, res_x);
30863108
3087                  if (y<=cliprect.max_y)
3109                  if (cliprect.contains(res_x, res_y))
30883110                     *fbaddr = b | (g<<8) | (r<<16);
30893111
30903112                  addrp+=2;
r25338r25339
30943116            {
30953117               for (x=0;x < xi;x++)
30963118               {
3097                  fbaddr=&bitmap.pix32(y + ystart_f1, x + hstart);
3119                  res_x = x + hstart;
3120                  res_y = y + ystart_f1;
3121                  fbaddr=&bitmap.pix32(res_y, res_x);
30983122                  c=*((reinterpret_cast<UINT16 *>(dc_framebuffer_ram)) + (WORD2_XOR_LE(addrp) >> 1));
30993123
31003124                  b = (c & 0x001f) << 3;
31013125                  g = (c & 0x07e0) >> 3;
31023126                  r = (c & 0xf800) >> 8;
31033127
3104                  if (y<=cliprect.max_y)
3128                  if (cliprect.contains(res_x, res_y))
31053129                     *fbaddr = b | (g<<8) | (r<<16);
31063130                  addrp+=2;
31073131               }
r25338r25339
31183142            {
31193143               for (x=0;x < xi;x++)
31203144               {
3121                  fbaddr=&bitmap.pix32(y + ystart_f1, x*2+0 + hstart);
3145                  res_x = x*2+0 + hstart;
3146                  res_y = y + ystart_f1;
31223147
3148                  fbaddr=&bitmap.pix32(res_y, res_x);
3149
31233150                  c =*(UINT8 *)((reinterpret_cast<UINT8 *>(dc_framebuffer_ram)) + BYTE8_XOR_LE(addrp));
31243151                  b = c;
31253152
r25338r25339
31293156                  c =*(UINT8 *)((reinterpret_cast<UINT8 *>(dc_framebuffer_ram)) + BYTE8_XOR_LE(addrp+2));
31303157                  r = c;
31313158
3132                  if (y<=cliprect.max_y)
3159                  if (cliprect.contains(res_x, res_y))
31333160                     *fbaddr = b | (g<<8) | (r<<16);
31343161
3135                  fbaddr=&bitmap.pix32(y + ystart_f1, x*2+1 + hstart);
3136                  if (y<=cliprect.max_y)
3162                  res_x = x*2+1 + hstart;
3163
3164                  fbaddr=&bitmap.pix32(res_y, res_x);
3165                  if (cliprect.contains(res_x, res_y))
31373166                     *fbaddr = b | (g<<8) | (r<<16);
31383167
31393168                  addrp+=3;
r25338r25339
31433172            {
31443173               for (x=0;x < xi;x++)
31453174               {
3146                  fbaddr=&bitmap.pix32(y + ystart_f1, x + hstart);
3175                  res_x = x + hstart;
3176                  res_y = y + ystart_f1;
3177                  fbaddr=&bitmap.pix32(res_y, res_x);
31473178
31483179                  c =*(UINT8 *)((reinterpret_cast<UINT8 *>(dc_framebuffer_ram)) + BYTE8_XOR_LE(addrp));
31493180                  b = c;
r25338r25339
31543185                  c =*(UINT8 *)((reinterpret_cast<UINT8 *>(dc_framebuffer_ram)) + BYTE8_XOR_LE(addrp+2));
31553186                  r = c;
31563187
3157                  if (y<=cliprect.max_y)
3188                  if (cliprect.contains(res_x, res_y))
31583189                     *fbaddr = b | (g<<8) | (r<<16);
31593190
31603191                  addrp+=3;
r25338r25339
31723203            {
31733204               for (x=0;x < xi;x++)
31743205               {
3175                  fbaddr=&bitmap.pix32(y + ystart_f1, x*2+0 + hstart);
3206                  res_x = x*2+0 + hstart;
3207                  res_y = y + ystart_f1;
3208
3209                  fbaddr=&bitmap.pix32(res_y, res_x);
31763210                  c =*((reinterpret_cast<UINT32 *>(dc_framebuffer_ram)) + (WORD2_XOR_LE(addrp) >> 2));
31773211
31783212                  b = (c & 0x0000ff) >> 0;
31793213                  g = (c & 0x00ff00) >> 8;
31803214                  r = (c & 0xff0000) >> 16;
31813215
3182                  if (y<=cliprect.max_y)
3216                  if (cliprect.contains(res_x, res_y))
31833217                     *fbaddr = b | (g<<8) | (r<<16);
31843218
3185                  fbaddr=&bitmap.pix32(y + ystart_f1, x*2+1 + hstart);
3186                  if (y<=cliprect.max_y)
3219                  res_x = x*2+1 + hstart;
3220
3221                  fbaddr=&bitmap.pix32(res_y, res_x);
3222                  if (cliprect.contains(res_x, res_y))
31873223                     *fbaddr = b | (g<<8) | (r<<16);
31883224
31893225                  addrp+=4;
r25338r25339
31933229            {
31943230               for (x=0;x < xi;x++)
31953231               {
3196                  fbaddr=&bitmap.pix32(y + ystart_f1, x + hstart);
3232                  res_x = x + hstart;
3233                  res_y = y + ystart_f1;
3234                  fbaddr=&bitmap.pix32(res_y, res_x);
31973235                  c =*((reinterpret_cast<UINT32 *>(dc_framebuffer_ram)) + (WORD2_XOR_LE(addrp) >> 2));
31983236
31993237                  b = (c & 0x0000ff) >> 0;
32003238                  g = (c & 0x00ff00) >> 8;
32013239                  r = (c & 0xff0000) >> 16;
32023240
3203                  if (y<=cliprect.max_y)
3241                  if (cliprect.contains(res_x, res_y))
32043242                     *fbaddr = b | (g<<8) | (r<<16);
32053243
32063244                  addrp+=4;
r25338r25339
37343772   UINT8 interlace_on = ((spg_control & 0x10) >> 4);
37353773   dc_state *state = machine().driver_data<dc_state>();
37363774
3737   if(interlace_on)
3738   {
3739      vbin_line <<= 1;
3740      vbout_line <<= 1;
3741   }
3775   vbin_line <<= interlace_on;
3776   vbout_line <<= interlace_on;
37423777
37433778   if(vbin_line-(1+interlace_on) == vpos)
37443779      state->m_maple->maple_hw_trigger();
trunk/src/mess/drivers/dccons.c
r25338r25339
2020    TODO:
2121    - RTC error always pops up at start-up, no flash plus bug with ticks (needs rewrite)
2222    - Inputs doesn't work most of the time;
23    - Candy Stripe: fills the log with "ATAPI_FEATURES_FLAG_OVL not supported", black screen
24    - Carrier: Jaleco logo uses YUV, but y size is halved?
2325    - F355 Challenge: black screen after Sega logo;
2426   - Idol Janshi wo Tsukucchaou: pixel aspect is way wrong (stretched and offsetted horizontally)
2527   - Power Stone: hangs at Capcom logo;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team