Previous 15994 Revisions Next

r3913 Saturday 20th December, 2008 at 15:42:05 UTC by R. Belmont
Backport of upcoming MAME fix to memory view windows.
[src/emu/debug]debugvw.c

src/emu/debug/debugvw.c
r3912r3913
268268static int memory_view_needs_recompute(debug_view *view);
269269static void memory_view_get_cursor_pos(debug_view *view, offs_t *address, UINT8 *shift);
270270static void memory_view_set_cursor_pos(debug_view *view, offs_t address, UINT8 shift);
271static UINT64 memory_view_read(debug_view_memory *memdata, UINT8 size, offs_t offs);
271static int memory_view_read(debug_view_memory *memdata, UINT8 size, offs_t offs, UINT64 *data);
272272static void memory_view_write(debug_view_memory *memdata, UINT8 size, offs_t offs, UINT64 data);
273273
274274static const debug_view_callbacks callback_table[] =
r3912r3913
24432443   /* then add all the memory regions */
24442444   for (rgntag = memory_region_next(machine, NULL); rgntag != NULL; rgntag = memory_region_next(machine, rgntag))
24452445   {
2446      UINT32 length = memory_region_length(machine, rgntag);
24462447      UINT32 flags = memory_region_flags(machine, rgntag);
2447      UINT8 little_endian = ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE);
2448      UINT8 width = 1 << ((flags & ROMREGION_WIDTHMASK) >> 8);
2449      memory_subview_item *subview;
24502448
2451      /* determine the string and allocate a subview large enough */
2452      astring_printf(tempstring, "Region '%s'", rgntag);
2453      subview = auto_malloc(sizeof(*subview) + astring_len(tempstring));
2454      memset(subview, 0, sizeof(*subview));
2449      if (length > 0 && (flags & ROMREGION_DATATYPEMASK) == ROMREGION_DATATYPEROM)
2450      {
2451              UINT8 little_endian = ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE);
2452              UINT8 width = 1 << ((flags & ROMREGION_WIDTHMASK) >> 8);
2453              memory_subview_item *subview;
24552454
2456      /* populate the subview */
2457      subview->next = NULL;
2458      subview->index = curindex++;
2459      subview->base = memory_region(machine, rgntag);
2460      subview->length = memory_region_length(machine, rgntag);
2455         /* determine the string and allocate a subview large enough */
2456         astring_printf(tempstring, "Region '%s'", rgntag);
2457         subview = auto_malloc(sizeof(*subview) + astring_len(tempstring));
2458         memset(subview, 0, sizeof(*subview));
2459
2460         /* populate the subview */
2461         subview->next = NULL;
2462         subview->index = curindex++;
2463         subview->base = memory_region(machine, rgntag);
2464         subview->length = memory_region_length(machine, rgntag);
24612465#ifdef LSB_FIRST
2462      subview->offsetxor = width - 1;
2466         subview->offsetxor = width - 1;
24632467#else
2464      subview->offsetxor = 0;
2468         subview->offsetxor = 0;
24652469#endif
2466      subview->endianness = little_endian ? ENDIANNESS_LITTLE : ENDIANNESS_BIG;
2467      subview->prefsize = MIN(width, 8);
2468      strcpy(subview->name, astring_c(tempstring));
2470         subview->endianness = little_endian ? ENDIANNESS_LITTLE : ENDIANNESS_BIG;
2471         subview->prefsize = MIN(width, 8);
2472         strcpy(subview->name, astring_c(tempstring));
24692473
2470      /* add to the list */
2471      *tailptr = subview;
2472      tailptr = &subview->next;
2474         /* add to the list */
2475         *tailptr = subview;
2476         tailptr = &subview->next;
2477      }
24732478   }
24742479
24752480   /* finally add all global array symbols */
r3912r3913
26602665         /* generate the data */
26612666         for (chunknum = 0; chunknum < memdata->chunks_per_row; chunknum++)
26622667         {
2663            UINT64 chunkdata = memory_view_read(memdata, memdata->bytes_per_chunk, addrbyte + chunknum * memdata->bytes_per_chunk);
26642668            int chunkindex = memdata->reverse_view ? (memdata->chunks_per_row - 1 - chunknum) : chunknum;
2669                      UINT64 chunkdata;
2670                      int ismapped;
26652671
2672                      ismapped = memory_view_read(memdata, memdata->bytes_per_chunk, addrbyte + chunknum * memdata->bytes_per_chunk, &chunkdata);
26662673            dest = destrow + memdata->section[1].pos + 1 + chunkindex * posdata->spacing;
26672674            for (ch = 0; ch < posdata->spacing; ch++, dest++)
26682675               if (dest >= destmin && dest < destmax)
26692676               {
26702677                  UINT8 shift = posdata->shift[ch];
26712678                  if (shift < 64)
2672                     dest->byte = "0123456789ABCDEF"[(chunkdata >> shift) & 0x0f];
2679                     dest->byte = ismapped ? "0123456789ABCDEF"[(chunkdata >> shift) & 0x0f] : '*';             
26732680               }
26742681         }
26752682
r3912r3913
26802687            for (ch = 0; ch < memdata->bytes_per_row; ch++, dest++)
26812688               if (dest >= destmin && dest < destmax)
26822689               {
2683                  UINT8 chval = memory_view_read(memdata, 1, addrbyte + ch);
2684                  dest->byte = isprint(chval) ? chval : '.';
2690                  int ismapped;
2691                  UINT64 chval;
2692
2693                  ismapped = memory_view_read(memdata, 1, addrbyte + ch, &chval);
2694                  dest->byte = (ismapped && isprint(chval)) ? chval : '.';
26852695               }
26862696         }
26872697      }
r3912r3913
27002710   debug_view_memory *memdata = view->extra_data;
27012711   offs_t address;
27022712   char *hexchar;
2713   int ismapped;
27032714   UINT64 data;
27042715   UINT32 delta;
27052716   UINT8 shift;
r3912r3913
27722783         hexchar = strchr(hexvals, tolower(chval));
27732784         if (hexchar == NULL)
27742785            break;
2775         data = memory_view_read(memdata, memdata->bytes_per_chunk, address);
2786
2787         ismapped = memory_view_read(memdata, memdata->bytes_per_chunk, address, &data);
2788         if (!ismapped)
2789            break;
27762790         data &= ~((UINT64)0x0f << shift);
27772791         data |= (UINT64)(hexchar - hexvals) << shift;
27782792         memory_view_write(memdata, memdata->bytes_per_chunk, address, data);
r3912r3913
28792893   }
28802894
28812895   /* derive total sizes from that */
2882   view->total.y = (memdata->maxaddr - memdata->byte_offset + memdata->bytes_per_row - 1) / memdata->bytes_per_row;
2896   view->total.y = ((UINT64)memdata->maxaddr - (UINT64)memdata->byte_offset + (UINT64)memdata->bytes_per_row - 1) / memdata->bytes_per_row;
28832897
28842898   /* reset the current cursor position */
28852899   memory_view_set_cursor_pos(view, cursoraddr, cursorshift);
r3912r3913
29973011    reader
29983012-------------------------------------------------*/
29993013
3000static UINT64 memory_view_read(debug_view_memory *memdata, UINT8 size, offs_t offs)
3014static int memory_view_read(debug_view_memory *memdata, UINT8 size, offs_t offs, UINT64 *data)
30013015{
30023016   /* if no raw data, just use the standard debug routines */
30033017   if (memdata->desc->space != NULL)
30043018   {
30053019      const address_space *space = memdata->desc->space;
3006      UINT64 result = ~(UINT64)0;
3020      offs_t dummyaddr = offs;
3021      int ismapped;
30073022
3008      switch (size)
3023      ismapped = memdata->no_translation ? TRUE : memory_address_physical(space, TRANSLATE_READ_DEBUG, &dummyaddr);
3024      if (ismapped)
30093025      {
3010         case 1:   result = debug_read_byte(space, offs, !memdata->no_translation); break;
3011         case 2:   result = debug_read_word(space, offs, !memdata->no_translation); break;
3012         case 4:   result = debug_read_dword(space, offs, !memdata->no_translation); break;
3013         case 8:   result = debug_read_qword(space, offs, !memdata->no_translation); break;
3026         switch (size)
3027         {
3028            case 1:   *data = debug_read_byte(space, offs, !memdata->no_translation); break;
3029            case 2:   *data = debug_read_word(space, offs, !memdata->no_translation); break;
3030            case 4:   *data = debug_read_dword(space, offs, !memdata->no_translation); break;
3031            case 8:   *data = debug_read_qword(space, offs, !memdata->no_translation); break;
3032         }
30143033      }
3015      return result;
3034
3035      return ismapped;
30163036   }
30173037
30183038   /* if larger than a byte, reduce by half and recurse */
30193039   if (size > 1)
30203040   {
3041      UINT64 data0, data1;
3042      int ismapped;
3043
30213044      size /= 2;
3045      ismapped  = memory_view_read(memdata, size, offs + 0 * size, &data0);
3046      ismapped |= memory_view_read(memdata, size, offs + 1 * size, &data1);
3047
30223048      if (memdata->desc->endianness == ENDIANNESS_LITTLE)
3023         return memory_view_read(memdata, size, offs + 0 * size) | ((UINT64)memory_view_read(memdata, size, offs + 1 * size) << (size * 8));
3049         *data = data0 | (data1 << (size * 8));
30243050      else
3025         return memory_view_read(memdata, size, offs + 1 * size) | ((UINT64)memory_view_read(memdata, size, offs + 0 * size) << (size * 8));
3051         *data = data1 | (data0 << (size * 8));
3052
3053      return ismapped;
30263054   }
30273055
30283056   /* all 0xff if out of bounds */
30293057   offs ^= memdata->desc->offsetxor;
30303058   if (offs >= memdata->desc->length)
3031      return 0xff;
3032   return *((UINT8 *)memdata->desc->base + offs);
3059           return FALSE;
3060
3061    *data = *((UINT8 *)memdata->desc->base + offs);
3062    return TRUE;
30333063}
30343064
30353065

Previous 15994 Revisions Next


© 1998-2018 The MESS Team