trunk/src/emu/debug/dvbpoints.c
| r243727 | r243728 | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | |
| 16 | | // Sorting functors for the qsort function |
| 17 | | static int cIndexAscending(const void* a, const void* b) |
| 18 | | { |
| 19 | | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 20 | | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 21 | | return left->index() - right->index(); |
| 22 | | } |
| 23 | | |
| 24 | | static int cIndexDescending(const void* a, const void* b) |
| 25 | | { |
| 26 | | return cIndexAscending(b, a); |
| 27 | | } |
| 28 | | |
| 29 | | static int cEnabledAscending(const void* a, const void* b) |
| 30 | | { |
| 31 | | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 32 | | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 33 | | return (left->enabled() ? 1 : 0) - (right->enabled() ? 1 : 0); |
| 34 | | } |
| 35 | | |
| 36 | | static int cEnabledDescending(const void* a, const void* b) |
| 37 | | { |
| 38 | | return cEnabledAscending(b, a); |
| 39 | | } |
| 40 | | |
| 41 | | static int cCpuAscending(const void* a, const void* b) |
| 42 | | { |
| 43 | | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 44 | | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 45 | | return strcmp(left->debugInterface()->device().tag(), right->debugInterface()->device().tag()); |
| 46 | | } |
| 47 | | |
| 48 | | static int cCpuDescending(const void* a, const void* b) |
| 49 | | { |
| 50 | | return cCpuAscending(b, a); |
| 51 | | } |
| 52 | | |
| 53 | | static int cAddressAscending(const void* a, const void* b) |
| 54 | | { |
| 55 | | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 56 | | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 57 | | return (left->address() > right->address()) ? 1 : (left->address() < right->address()) ? -1 : 0; |
| 58 | | } |
| 59 | | |
| 60 | | static int cAddressDescending(const void* a, const void* b) |
| 61 | | { |
| 62 | | return cAddressAscending(b, a); |
| 63 | | } |
| 64 | | |
| 65 | | static int cConditionAscending(const void* a, const void* b) |
| 66 | | { |
| 67 | | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 68 | | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 69 | | return strcmp(left->condition(), right->condition()); |
| 70 | | } |
| 71 | | |
| 72 | | static int cConditionDescending(const void* a, const void* b) |
| 73 | | { |
| 74 | | return cConditionAscending(b, a); |
| 75 | | } |
| 76 | | |
| 77 | | static int cActionAscending(const void* a, const void* b) |
| 78 | | { |
| 79 | | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 80 | | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 81 | | return strcmp(left->action(), right->action()); |
| 82 | | } |
| 83 | | |
| 84 | | static int cActionDescending(const void* a, const void* b) |
| 85 | | { |
| 86 | | return cActionAscending(b, a); |
| 87 | | } |
| 88 | | |
| 89 | | |
| 90 | 16 | //************************************************************************** |
| 91 | 17 | // DEBUG VIEW BREAK POINTS |
| 92 | 18 | //************************************************************************** |
| r243727 | r243728 | |
| 100 | 26 | |
| 101 | 27 | debug_view_breakpoints::debug_view_breakpoints(running_machine &machine, debug_view_osd_update_func osdupdate, void *osdprivate) |
| 102 | 28 | : debug_view(machine, DVT_BREAK_POINTS, osdupdate, osdprivate), |
| 103 | | m_sortType(cIndexAscending) |
| 29 | m_sortType(SORT_INDEX_ASCENDING) |
| 104 | 30 | { |
| 105 | 31 | // fail if no available sources |
| 106 | 32 | enumerate_sources(); |
| 107 | 33 | if (m_source_list.count() == 0) |
| 108 | 34 | throw std::bad_alloc(); |
| 35 | |
| 36 | // configure the view |
| 37 | m_total.y = 10; |
| 38 | m_supports_cursor = false; |
| 109 | 39 | } |
| 110 | 40 | |
| 111 | 41 | |
| r243727 | r243728 | |
| 153 | 83 | |
| 154 | 84 | if (clickedTopRow) |
| 155 | 85 | { |
| 156 | | if (pos.x < tableBreaks[0]) |
| 157 | | m_sortType = (m_sortType == &cIndexAscending) ? &cIndexDescending : &cIndexAscending; |
| 86 | if (pos.x < tableBreaks[0] && m_sortType == SORT_INDEX_ASCENDING) |
| 87 | m_sortType = SORT_INDEX_DESCENDING; |
| 88 | else if (pos.x < tableBreaks[0]) |
| 89 | m_sortType = SORT_INDEX_ASCENDING; |
| 90 | else if (pos.x < tableBreaks[1] && m_sortType == SORT_ENABLED_ASCENDING) |
| 91 | m_sortType = SORT_ENABLED_DESCENDING; |
| 158 | 92 | else if (pos.x < tableBreaks[1]) |
| 159 | | m_sortType = (m_sortType == &cEnabledAscending) ? &cEnabledDescending : &cEnabledAscending; |
| 93 | m_sortType = SORT_ENABLED_ASCENDING; |
| 94 | else if (pos.x < tableBreaks[2] && m_sortType == SORT_CPU_ASCENDING) |
| 95 | m_sortType = SORT_CPU_DESCENDING; |
| 160 | 96 | else if (pos.x < tableBreaks[2]) |
| 161 | | m_sortType = (m_sortType == &cCpuAscending) ? &cCpuDescending : &cCpuAscending; |
| 97 | m_sortType = SORT_CPU_ASCENDING; |
| 98 | else if (pos.x < tableBreaks[3] && m_sortType == SORT_ADDRESS_ASCENDING) |
| 99 | m_sortType = SORT_ADDRESS_DESCENDING; |
| 162 | 100 | else if (pos.x < tableBreaks[3]) |
| 163 | | m_sortType = (m_sortType == &cAddressAscending) ? &cAddressDescending : &cAddressAscending; |
| 101 | m_sortType = SORT_ADDRESS_ASCENDING; |
| 102 | else if (pos.x < tableBreaks[4] && m_sortType == SORT_CONDITION_ASCENDING) |
| 103 | m_sortType = SORT_CONDITION_DESCENDING; |
| 164 | 104 | else if (pos.x < tableBreaks[4]) |
| 165 | | m_sortType = (m_sortType == &cConditionAscending) ? &cConditionDescending : &cConditionAscending; |
| 105 | m_sortType = SORT_CONDITION_ASCENDING; |
| 106 | else if (pos.x < tableBreaks[5] && m_sortType == SORT_ACTION_ASCENDING) |
| 107 | m_sortType = SORT_ACTION_DESCENDING; |
| 166 | 108 | else if (pos.x < tableBreaks[5]) |
| 167 | | m_sortType = (m_sortType == &cActionAscending) ? &cActionDescending : &cActionAscending; |
| 109 | m_sortType = SORT_ACTION_ASCENDING; |
| 168 | 110 | } |
| 169 | 111 | else |
| 170 | 112 | { |
| 171 | 113 | // Gather a sorted list of all the breakpoints for all the CPUs |
| 172 | | gather_breakpoints(); |
| 114 | device_debug::breakpoint** bpList = NULL; |
| 115 | const int numBPs = breakpoints(SORT_NONE, bpList); |
| 173 | 116 | |
| 174 | | int const bpIndex = pos.y - 1; |
| 175 | | if ((bpIndex >= m_buffer.count()) || (bpIndex < 0)) |
| 117 | const int bpIndex = pos.y - 1; |
| 118 | if (bpIndex > numBPs || bpIndex < 0) |
| 176 | 119 | return; |
| 177 | 120 | |
| 178 | 121 | // Enable / disable |
| 179 | | m_buffer[bpIndex]->setEnabled(!m_buffer[bpIndex]->enabled()); |
| 122 | if (bpList[bpIndex]->enabled()) |
| 123 | bpList[bpIndex]->setEnabled(false); |
| 124 | else |
| 125 | bpList[bpIndex]->setEnabled(true); |
| 180 | 126 | |
| 127 | delete[] bpList; |
| 128 | |
| 181 | 129 | machine().debug_view().update_all(DVT_DISASSEMBLY); |
| 182 | 130 | } |
| 183 | 131 | |
| r243727 | r243728 | |
| 201 | 149 | } |
| 202 | 150 | |
| 203 | 151 | |
| 204 | | void debug_view_breakpoints::gather_breakpoints() |
| 152 | // Sorting functors for the qsort function |
| 153 | static int cIndexAscending(const void* a, const void* b) |
| 205 | 154 | { |
| 206 | | m_buffer.resize(0); |
| 155 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 156 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 157 | return left->index() > right->index(); |
| 158 | } |
| 159 | |
| 160 | static int cIndexDescending(const void* a, const void* b) |
| 161 | { |
| 162 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 163 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 164 | return left->index() < right->index(); |
| 165 | } |
| 166 | |
| 167 | static int cEnabledAscending(const void* a, const void* b) |
| 168 | { |
| 169 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 170 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 171 | return left->enabled() < right->enabled(); |
| 172 | } |
| 173 | |
| 174 | static int cEnabledDescending(const void* a, const void* b) |
| 175 | { |
| 176 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 177 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 178 | return left->enabled() > right->enabled(); |
| 179 | } |
| 180 | |
| 181 | static int cCpuAscending(const void* a, const void* b) |
| 182 | { |
| 183 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 184 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 185 | const int result = strcmp(left->debugInterface()->device().tag(), right->debugInterface()->device().tag()); |
| 186 | return result >= 0; |
| 187 | } |
| 188 | |
| 189 | static int cCpuDescending(const void* a, const void* b) |
| 190 | { |
| 191 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 192 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 193 | const int result = strcmp(left->debugInterface()->device().tag(), right->debugInterface()->device().tag()); |
| 194 | return result < 0; |
| 195 | } |
| 196 | |
| 197 | static int cAddressAscending(const void* a, const void* b) |
| 198 | { |
| 199 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 200 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 201 | return left->address() > right->address(); |
| 202 | } |
| 203 | |
| 204 | static int cAddressDescending(const void* a, const void* b) |
| 205 | { |
| 206 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 207 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 208 | return left->address() < right->address(); |
| 209 | } |
| 210 | |
| 211 | static int cConditionAscending(const void* a, const void* b) |
| 212 | { |
| 213 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 214 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 215 | const int result = strcmp(left->condition(), right->condition()); |
| 216 | return result >= 0; |
| 217 | } |
| 218 | |
| 219 | static int cConditionDescending(const void* a, const void* b) |
| 220 | { |
| 221 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 222 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 223 | const int result = strcmp(left->condition(), right->condition()); |
| 224 | return result < 0; |
| 225 | } |
| 226 | |
| 227 | static int cActionAscending(const void* a, const void* b) |
| 228 | { |
| 229 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 230 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 231 | const int result = strcmp(left->action(), right->action()); |
| 232 | return result >= 0; |
| 233 | } |
| 234 | |
| 235 | static int cActionDescending(const void* a, const void* b) |
| 236 | { |
| 237 | const device_debug::breakpoint* left = *(device_debug::breakpoint**)a; |
| 238 | const device_debug::breakpoint* right = *(device_debug::breakpoint**)b; |
| 239 | const int result = strcmp(left->action(), right->action()); |
| 240 | return result < 0; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | int debug_view_breakpoints::breakpoints(SortMode sort, device_debug::breakpoint**& bpList) |
| 245 | { |
| 246 | // Alloc |
| 247 | int numBPs = 0; |
| 248 | bpList = NULL; |
| 207 | 249 | for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next()) |
| 208 | 250 | { |
| 251 | const device_debug& debugInterface = *source->device()->debug(); |
| 252 | for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != NULL; bp = bp->next()) |
| 253 | numBPs++; |
| 254 | } |
| 255 | bpList = new device_debug::breakpoint*[numBPs]; |
| 256 | |
| 257 | int bpAddIndex = 0; |
| 258 | for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next()) |
| 259 | { |
| 209 | 260 | // Collect |
| 210 | | device_debug &debugInterface = *source->device()->debug(); |
| 261 | device_debug& debugInterface = *source->device()->debug(); |
| 211 | 262 | for (device_debug::breakpoint *bp = debugInterface.breakpoint_first(); bp != NULL; bp = bp->next()) |
| 212 | | m_buffer.append() = bp; |
| 263 | { |
| 264 | bpList[bpAddIndex] = bp; |
| 265 | bpAddIndex++; |
| 266 | } |
| 213 | 267 | } |
| 214 | 268 | |
| 215 | 269 | // And now for the sort |
| 216 | | qsort(&m_buffer[0], m_buffer.count(), sizeof(device_debug::breakpoint *), m_sortType); |
| 270 | switch (m_sortType) |
| 271 | { |
| 272 | case SORT_NONE: |
| 273 | break; |
| 274 | case SORT_INDEX_ASCENDING: |
| 275 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cIndexAscending); |
| 276 | break; |
| 277 | case SORT_INDEX_DESCENDING: |
| 278 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cIndexDescending); |
| 279 | break; |
| 280 | case SORT_ENABLED_ASCENDING: |
| 281 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cEnabledAscending); |
| 282 | break; |
| 283 | case SORT_ENABLED_DESCENDING: |
| 284 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cEnabledDescending); |
| 285 | break; |
| 286 | case SORT_CPU_ASCENDING: |
| 287 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cCpuAscending); |
| 288 | break; |
| 289 | case SORT_CPU_DESCENDING: |
| 290 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cCpuDescending); |
| 291 | break; |
| 292 | case SORT_ADDRESS_ASCENDING: |
| 293 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cAddressAscending); |
| 294 | break; |
| 295 | case SORT_ADDRESS_DESCENDING: |
| 296 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cAddressDescending); |
| 297 | break; |
| 298 | case SORT_CONDITION_ASCENDING: |
| 299 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cConditionAscending); |
| 300 | break; |
| 301 | case SORT_CONDITION_DESCENDING: |
| 302 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cConditionDescending); |
| 303 | break; |
| 304 | case SORT_ACTION_ASCENDING: |
| 305 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cActionAscending); |
| 306 | break; |
| 307 | case SORT_ACTION_DESCENDING: |
| 308 | qsort(bpList, numBPs, sizeof(device_debug::breakpoint*), cActionDescending); |
| 309 | break; |
| 310 | } |
| 311 | |
| 312 | return numBPs; |
| 217 | 313 | } |
| 218 | 314 | |
| 219 | 315 | |
| r243727 | r243728 | |
| 225 | 321 | void debug_view_breakpoints::view_update() |
| 226 | 322 | { |
| 227 | 323 | // Gather a list of all the breakpoints for all the CPUs |
| 228 | | gather_breakpoints(); |
| 324 | device_debug::breakpoint** bpList = NULL; |
| 325 | const int numBPs = breakpoints(SORT_NONE, bpList); |
| 229 | 326 | |
| 230 | 327 | // Set the view region so the scroll bars update |
| 231 | | m_total.x = tableBreaks[ARRAY_LENGTH(tableBreaks) - 1]; |
| 232 | | m_total.y = m_buffer.count() + 1; |
| 233 | | if (m_total.y < 10) |
| 234 | | m_total.y = 10; |
| 328 | m_total.y = numBPs+1; |
| 235 | 329 | |
| 236 | 330 | // Draw |
| 237 | | debug_view_char *dest = m_viewdata; |
| 238 | | astring linebuf; |
| 239 | | |
| 240 | | // Header |
| 241 | | if (m_visible.y > 0) |
| 331 | debug_view_char *dest = m_viewdata; |
| 332 | for (int row = 0; row < m_visible.y; row++) |
| 242 | 333 | { |
| 243 | | linebuf.reset(); |
| 244 | | linebuf.cat("ID"); |
| 245 | | if (m_sortType == &cIndexAscending) linebuf.cat('\\'); |
| 246 | | else if (m_sortType == &cIndexDescending) linebuf.cat('/'); |
| 247 | | pad_astring_to_length(linebuf, tableBreaks[0]); |
| 248 | | linebuf.cat("En"); |
| 249 | | if (m_sortType == &cEnabledAscending) linebuf.cat('\\'); |
| 250 | | else if (m_sortType == &cEnabledDescending) linebuf.cat('/'); |
| 251 | | pad_astring_to_length(linebuf, tableBreaks[1]); |
| 252 | | linebuf.cat("CPU"); |
| 253 | | if (m_sortType == &cCpuAscending) linebuf.cat('\\'); |
| 254 | | else if (m_sortType == &cCpuDescending) linebuf.cat('/'); |
| 255 | | pad_astring_to_length(linebuf, tableBreaks[2]); |
| 256 | | linebuf.cat("Address"); |
| 257 | | if (m_sortType == &cAddressAscending) linebuf.cat('\\'); |
| 258 | | else if (m_sortType == &cAddressDescending) linebuf.cat('/'); |
| 259 | | pad_astring_to_length(linebuf, tableBreaks[3]); |
| 260 | | linebuf.cat("Condition"); |
| 261 | | if (m_sortType == &cConditionAscending) linebuf.cat('\\'); |
| 262 | | else if (m_sortType == &cConditionDescending) linebuf.cat('/'); |
| 263 | | pad_astring_to_length(linebuf, tableBreaks[4]); |
| 264 | | linebuf.cat("Action"); |
| 265 | | if (m_sortType == &cActionAscending) linebuf.cat('\\'); |
| 266 | | else if (m_sortType == &cActionDescending) linebuf.cat('/'); |
| 267 | | pad_astring_to_length(linebuf, tableBreaks[5]); |
| 334 | UINT32 effrow = m_topleft.y + row; |
| 268 | 335 | |
| 269 | | for (UINT32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) |
| 336 | // Header |
| 337 | if (row == 0) |
| 270 | 338 | { |
| 271 | | dest->byte = (i < linebuf.len()) ? linebuf[i] : ' '; |
| 272 | | dest->attrib = DCA_ANCILLARY; |
| 339 | astring header; |
| 340 | header.printf("ID"); |
| 341 | if (m_sortType == SORT_INDEX_ASCENDING) header.catprintf("\\"); |
| 342 | else if (m_sortType == SORT_INDEX_DESCENDING) header.catprintf("/"); |
| 343 | pad_astring_to_length(header, tableBreaks[0]); |
| 344 | header.catprintf("En"); |
| 345 | if (m_sortType == SORT_ENABLED_ASCENDING) header.catprintf("\\"); |
| 346 | else if (m_sortType == SORT_ENABLED_DESCENDING) header.catprintf("/"); |
| 347 | pad_astring_to_length(header, tableBreaks[1]); |
| 348 | header.catprintf("CPU"); |
| 349 | if (m_sortType == SORT_CPU_ASCENDING) header.catprintf("\\"); |
| 350 | else if (m_sortType == SORT_CPU_DESCENDING) header.catprintf("/"); |
| 351 | pad_astring_to_length(header, tableBreaks[2]); |
| 352 | header.catprintf("Address"); |
| 353 | if (m_sortType == SORT_ADDRESS_ASCENDING) header.catprintf("\\"); |
| 354 | else if (m_sortType == SORT_ADDRESS_DESCENDING) header.catprintf("/"); |
| 355 | pad_astring_to_length(header, tableBreaks[3]); |
| 356 | header.catprintf("Condition"); |
| 357 | if (m_sortType == SORT_CONDITION_ASCENDING) header.catprintf("\\"); |
| 358 | else if (m_sortType == SORT_CONDITION_DESCENDING) header.catprintf("/"); |
| 359 | pad_astring_to_length(header, tableBreaks[4]); |
| 360 | header.catprintf("Action"); |
| 361 | if (m_sortType == SORT_ACTION_ASCENDING) header.catprintf("\\"); |
| 362 | else if (m_sortType == SORT_ACTION_DESCENDING) header.catprintf("/"); |
| 363 | pad_astring_to_length(header, tableBreaks[5]); |
| 364 | |
| 365 | for (int i = 0; i < m_visible.x; i++) |
| 366 | { |
| 367 | dest->byte = (i < header.len()) ? header[i] : ' '; |
| 368 | dest->attrib = DCA_ANCILLARY; |
| 369 | dest++; |
| 370 | } |
| 371 | continue; |
| 273 | 372 | } |
| 274 | | } |
| 275 | 373 | |
| 276 | | for (int row = 1; row < m_visible.y; row++) |
| 277 | | { |
| 278 | 374 | // Breakpoints |
| 279 | | int bpi = row + m_topleft.y - 1; |
| 280 | | if ((bpi < m_buffer.count()) && (bpi >= 0)) |
| 375 | int bpi = effrow-1; |
| 376 | if (bpi < numBPs && bpi >= 0) |
| 281 | 377 | { |
| 282 | | device_debug::breakpoint *const bp = m_buffer[bpi]; |
| 378 | device_debug::breakpoint* bp = bpList[bpi]; |
| 283 | 379 | |
| 284 | | linebuf.reset(); |
| 285 | | linebuf.catprintf("%2X", bp->index()); |
| 286 | | pad_astring_to_length(linebuf, tableBreaks[0]); |
| 287 | | linebuf.cat(bp->enabled() ? 'X' : 'O'); |
| 288 | | pad_astring_to_length(linebuf, tableBreaks[1]); |
| 289 | | linebuf.cat(bp->debugInterface()->device().tag()); |
| 290 | | pad_astring_to_length(linebuf, tableBreaks[2]); |
| 291 | | linebuf.cat(core_i64_hex_format(bp->address(), bp->debugInterface()->logaddrchars())); |
| 292 | | pad_astring_to_length(linebuf, tableBreaks[3]); |
| 293 | | if (strcmp(bp->condition(), "1")) |
| 294 | | linebuf.cat(bp->condition()); |
| 295 | | pad_astring_to_length(linebuf, tableBreaks[4]); |
| 296 | | linebuf.cat(bp->action()); |
| 297 | | pad_astring_to_length(linebuf, tableBreaks[5]); |
| 380 | astring buffer; |
| 381 | buffer.printf("%X", bp->index()); |
| 382 | pad_astring_to_length(buffer, tableBreaks[0]); |
| 383 | buffer.catprintf("%c", bp->enabled() ? 'X' : 'O'); |
| 384 | pad_astring_to_length(buffer, tableBreaks[1]); |
| 385 | buffer.catprintf("%s", bp->debugInterface()->device().tag()); |
| 386 | pad_astring_to_length(buffer, tableBreaks[2]); |
| 387 | buffer.catprintf("%s", core_i64_hex_format(bp->address(), bp->debugInterface()->logaddrchars())); |
| 388 | pad_astring_to_length(buffer, tableBreaks[3]); |
| 389 | if (astring(bp->condition()) != astring("1")) |
| 390 | { |
| 391 | buffer.catprintf("%s", bp->condition()); |
| 392 | pad_astring_to_length(buffer, tableBreaks[4]); |
| 393 | } |
| 394 | if (astring(bp->action()) != astring("")) |
| 395 | { |
| 396 | buffer.catprintf("%s", bp->action()); |
| 397 | pad_astring_to_length(buffer, tableBreaks[5]); |
| 398 | } |
| 298 | 399 | |
| 299 | | for (UINT32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) |
| 400 | for (int i = 0; i < m_visible.x; i++) |
| 300 | 401 | { |
| 301 | | dest->byte = (i < linebuf.len()) ? linebuf[i] : ' '; |
| 402 | dest->byte = (i < buffer.len()) ? buffer[i] : ' '; |
| 302 | 403 | dest->attrib = DCA_NORMAL; |
| 303 | 404 | |
| 304 | 405 | // Color disabled breakpoints red |
| 305 | | if ((i >= tableBreaks[0]) && (i < tableBreaks[1]) && !bp->enabled()) |
| 306 | | dest->attrib |= DCA_CHANGED; |
| 406 | if (i == 5 && dest->byte == 'O') |
| 407 | dest->attrib = DCA_CHANGED; |
| 408 | |
| 409 | dest++; |
| 307 | 410 | } |
| 411 | continue; |
| 308 | 412 | } |
| 309 | | else |
| 413 | |
| 414 | // Fill the remaining vertical space |
| 415 | for (int i = 0; i < m_visible.x; i++) |
| 310 | 416 | { |
| 311 | | // Fill the remaining vertical space |
| 312 | | for (UINT32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) |
| 313 | | { |
| 314 | | dest->byte = ' '; |
| 315 | | dest->attrib = DCA_NORMAL; |
| 316 | | } |
| 417 | dest->byte = ' '; |
| 418 | dest->attrib = DCA_NORMAL; |
| 419 | dest++; |
| 317 | 420 | } |
| 318 | 421 | } |
| 422 | |
| 423 | delete[] bpList; |
| 319 | 424 | } |
trunk/src/emu/debug/dvwpoints.c
| r243727 | r243728 | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | |
| 16 | | static int cIndexAscending(const void* a, const void* b) |
| 17 | | { |
| 18 | | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 19 | | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 20 | | return left->index() - right->index(); |
| 21 | | } |
| 22 | | |
| 23 | | static int cIndexDescending(const void* a, const void* b) |
| 24 | | { |
| 25 | | return cIndexAscending(b, a); |
| 26 | | } |
| 27 | | |
| 28 | | static int cEnabledAscending(const void* a, const void* b) |
| 29 | | { |
| 30 | | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 31 | | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 32 | | return (left->enabled() ? 1 : 0) - (right->enabled() ? 1 : 0); |
| 33 | | } |
| 34 | | |
| 35 | | static int cEnabledDescending(const void* a, const void* b) |
| 36 | | { |
| 37 | | return cEnabledAscending(b, a); |
| 38 | | } |
| 39 | | |
| 40 | | static int cCpuAscending(const void* a, const void* b) |
| 41 | | { |
| 42 | | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 43 | | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 44 | | return strcmp(left->debugInterface()->device().tag(), right->debugInterface()->device().tag()); |
| 45 | | } |
| 46 | | |
| 47 | | static int cCpuDescending(const void* a, const void* b) |
| 48 | | { |
| 49 | | return cCpuAscending(b, a); |
| 50 | | } |
| 51 | | |
| 52 | | static int cSpaceAscending(const void* a, const void* b) |
| 53 | | { |
| 54 | | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 55 | | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 56 | | return strcmp(left->space().name(), right->space().name()); |
| 57 | | } |
| 58 | | |
| 59 | | static int cSpaceDescending(const void* a, const void* b) |
| 60 | | { |
| 61 | | return cSpaceAscending(b, a); |
| 62 | | } |
| 63 | | |
| 64 | | static int cAddressAscending(const void* a, const void* b) |
| 65 | | { |
| 66 | | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 67 | | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 68 | | return (left->address() > right->address()) ? 1 : (left->address() < right->address()) ? -1 : 0; |
| 69 | | } |
| 70 | | |
| 71 | | static int cAddressDescending(const void* a, const void* b) |
| 72 | | { |
| 73 | | return cAddressAscending(b, a); |
| 74 | | } |
| 75 | | |
| 76 | | static int cTypeAscending(const void* a, const void* b) |
| 77 | | { |
| 78 | | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 79 | | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 80 | | return left->type() - right->type(); |
| 81 | | } |
| 82 | | |
| 83 | | static int cTypeDescending(const void* a, const void* b) |
| 84 | | { |
| 85 | | return cTypeAscending(b, a); |
| 86 | | } |
| 87 | | |
| 88 | | static int cConditionAscending(const void* a, const void* b) |
| 89 | | { |
| 90 | | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 91 | | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 92 | | return strcmp(left->condition(), right->condition()); |
| 93 | | } |
| 94 | | |
| 95 | | static int cConditionDescending(const void* a, const void* b) |
| 96 | | { |
| 97 | | return cConditionAscending(b, a); |
| 98 | | } |
| 99 | | |
| 100 | | static int cActionAscending(const void* a, const void* b) |
| 101 | | { |
| 102 | | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 103 | | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 104 | | return strcmp(left->action(), right->action()); |
| 105 | | } |
| 106 | | |
| 107 | | static int cActionDescending(const void* a, const void* b) |
| 108 | | { |
| 109 | | return cActionAscending(b, a); |
| 110 | | } |
| 111 | | |
| 112 | | |
| 113 | 16 | //************************************************************************** |
| 114 | 17 | // DEBUG VIEW WATCH POINTS |
| 115 | 18 | //************************************************************************** |
| r243727 | r243728 | |
| 122 | 25 | |
| 123 | 26 | debug_view_watchpoints::debug_view_watchpoints(running_machine &machine, debug_view_osd_update_func osdupdate, void *osdprivate) |
| 124 | 27 | : debug_view(machine, DVT_WATCH_POINTS, osdupdate, osdprivate), |
| 125 | | m_sortType(&cIndexAscending) |
| 28 | m_sortType(SORT_INDEX_ASCENDING) |
| 126 | 29 | { |
| 127 | 30 | // fail if no available sources |
| 128 | 31 | enumerate_sources(); |
| 129 | 32 | if (m_source_list.count() == 0) |
| 130 | 33 | throw std::bad_alloc(); |
| 34 | |
| 35 | // configure the view |
| 36 | m_total.y = 10; |
| 37 | m_supports_cursor = false; |
| 131 | 38 | } |
| 132 | 39 | |
| 133 | 40 | |
| r243727 | r243728 | |
| 171 | 78 | |
| 172 | 79 | void debug_view_watchpoints::view_click(const int button, const debug_view_xy& pos) |
| 173 | 80 | { |
| 174 | | bool const clickedTopRow = (m_topleft.y == pos.y); |
| 81 | bool clickedTopRow = (m_topleft.y == pos.y); |
| 175 | 82 | |
| 176 | 83 | if (clickedTopRow) |
| 177 | 84 | { |
| 178 | | if (pos.x < tableBreaks[0]) |
| 179 | | m_sortType = (m_sortType == &cIndexAscending) ? &cIndexDescending : &cIndexAscending; |
| 85 | if (pos.x < tableBreaks[0] && m_sortType == SORT_INDEX_ASCENDING) |
| 86 | m_sortType = SORT_INDEX_DESCENDING; |
| 87 | else if (pos.x < tableBreaks[0]) |
| 88 | m_sortType = SORT_INDEX_ASCENDING; |
| 89 | else if (pos.x < tableBreaks[1] && m_sortType == SORT_ENABLED_ASCENDING) |
| 90 | m_sortType = SORT_ENABLED_DESCENDING; |
| 180 | 91 | else if (pos.x < tableBreaks[1]) |
| 181 | | m_sortType = (m_sortType == &cEnabledAscending) ? &cEnabledDescending : &cEnabledAscending; |
| 92 | m_sortType = SORT_ENABLED_ASCENDING; |
| 93 | else if (pos.x < tableBreaks[2] && m_sortType == SORT_CPU_ASCENDING) |
| 94 | m_sortType = SORT_CPU_DESCENDING; |
| 182 | 95 | else if (pos.x < tableBreaks[2]) |
| 183 | | m_sortType = (m_sortType == &cCpuAscending) ? &cCpuDescending : &cCpuAscending; |
| 96 | m_sortType = SORT_CPU_ASCENDING; |
| 97 | else if (pos.x < tableBreaks[3] && m_sortType == SORT_SPACE_ASCENDING) |
| 98 | m_sortType = SORT_SPACE_DESCENDING; |
| 184 | 99 | else if (pos.x < tableBreaks[3]) |
| 185 | | m_sortType = (m_sortType == &cSpaceAscending) ? &cSpaceDescending : &cSpaceAscending; |
| 100 | m_sortType = SORT_SPACE_ASCENDING; |
| 101 | else if (pos.x < tableBreaks[4] && m_sortType == SORT_ADDRESS_ASCENDING) |
| 102 | m_sortType = SORT_ADDRESS_DESCENDING; |
| 186 | 103 | else if (pos.x < tableBreaks[4]) |
| 187 | | m_sortType = (m_sortType == &cAddressAscending) ? &cAddressDescending : &cAddressAscending; |
| 104 | m_sortType = SORT_ADDRESS_ASCENDING; |
| 105 | else if (pos.x < tableBreaks[5] && m_sortType == SORT_TYPE_ASCENDING) |
| 106 | m_sortType = SORT_TYPE_DESCENDING; |
| 188 | 107 | else if (pos.x < tableBreaks[5]) |
| 189 | | m_sortType = (m_sortType == &cTypeAscending) ? &cTypeDescending : &cTypeAscending; |
| 108 | m_sortType = SORT_TYPE_ASCENDING; |
| 109 | else if (pos.x < tableBreaks[6] && m_sortType == SORT_CONDITION_ASCENDING) |
| 110 | m_sortType = SORT_CONDITION_DESCENDING; |
| 190 | 111 | else if (pos.x < tableBreaks[6]) |
| 191 | | m_sortType = (m_sortType == &cConditionAscending) ? &cConditionDescending : &cConditionAscending; |
| 112 | m_sortType = SORT_CONDITION_ASCENDING; |
| 113 | else if (pos.x < tableBreaks[7] && m_sortType == SORT_ACTION_ASCENDING) |
| 114 | m_sortType = SORT_ACTION_DESCENDING; |
| 192 | 115 | else if (pos.x < tableBreaks[7]) |
| 193 | | m_sortType = (m_sortType == &cActionAscending) ? &cActionDescending : &cActionAscending; |
| 116 | m_sortType = SORT_ACTION_ASCENDING; |
| 194 | 117 | } |
| 195 | 118 | else |
| 196 | 119 | { |
| 197 | 120 | // Gather a sorted list of all the watchpoints for all the CPUs |
| 198 | | gather_watchpoints(); |
| 121 | device_debug::watchpoint** wpList = NULL; |
| 122 | const int numWPs = watchpoints(SORT_NONE, wpList); |
| 199 | 123 | |
| 200 | | int const wpIndex = pos.y - 1; |
| 201 | | if ((wpIndex >= m_buffer.count()) || (wpIndex < 0)) |
| 124 | const int wpIndex = pos.y - 1; |
| 125 | if (wpIndex > numWPs || wpIndex < 0) |
| 202 | 126 | return; |
| 203 | 127 | |
| 204 | 128 | // Enable / disable |
| 205 | | m_buffer[wpIndex]->setEnabled(!m_buffer[wpIndex]->enabled()); |
| 129 | if (wpList[wpIndex]->enabled()) |
| 130 | wpList[wpIndex]->setEnabled(false); |
| 131 | else |
| 132 | wpList[wpIndex]->setEnabled(true); |
| 133 | |
| 134 | delete[] wpList; |
| 206 | 135 | } |
| 207 | 136 | |
| 208 | 137 | begin_update(); |
| r243727 | r243728 | |
| 225 | 154 | } |
| 226 | 155 | |
| 227 | 156 | |
| 228 | | void debug_view_watchpoints::gather_watchpoints() |
| 157 | // Sorting functors for the qsort function |
| 158 | static int cIndexAscending(const void* a, const void* b) |
| 229 | 159 | { |
| 230 | | m_buffer.resize(0); |
| 160 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 161 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 162 | return left->index() > right->index(); |
| 163 | } |
| 164 | |
| 165 | static int cIndexDescending(const void* a, const void* b) |
| 166 | { |
| 167 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 168 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 169 | return left->index() < right->index(); |
| 170 | } |
| 171 | |
| 172 | static int cEnabledAscending(const void* a, const void* b) |
| 173 | { |
| 174 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 175 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 176 | return left->enabled() < right->enabled(); |
| 177 | } |
| 178 | |
| 179 | static int cEnabledDescending(const void* a, const void* b) |
| 180 | { |
| 181 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 182 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 183 | return left->enabled() > right->enabled(); |
| 184 | } |
| 185 | |
| 186 | static int cCpuAscending(const void* a, const void* b) |
| 187 | { |
| 188 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 189 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 190 | const int result = strcmp(left->debugInterface()->device().tag(), right->debugInterface()->device().tag()); |
| 191 | return result >= 0; |
| 192 | } |
| 193 | |
| 194 | static int cCpuDescending(const void* a, const void* b) |
| 195 | { |
| 196 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 197 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 198 | const int result = strcmp(left->debugInterface()->device().tag(), right->debugInterface()->device().tag()); |
| 199 | return result < 0; |
| 200 | } |
| 201 | |
| 202 | static int cSpaceAscending(const void* a, const void* b) |
| 203 | { |
| 204 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 205 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 206 | const int result = strcmp(left->space().name(), right->space().name()); |
| 207 | return result >= 0; |
| 208 | } |
| 209 | |
| 210 | static int cSpaceDescending(const void* a, const void* b) |
| 211 | { |
| 212 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 213 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 214 | const int result = strcmp(left->space().name(), right->space().name()); |
| 215 | return result < 0; |
| 216 | } |
| 217 | |
| 218 | static int cAddressAscending(const void* a, const void* b) |
| 219 | { |
| 220 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 221 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 222 | return left->address() > right->address(); |
| 223 | } |
| 224 | |
| 225 | static int cAddressDescending(const void* a, const void* b) |
| 226 | { |
| 227 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 228 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 229 | return left->address() < right->address(); |
| 230 | } |
| 231 | |
| 232 | static int cTypeAscending(const void* a, const void* b) |
| 233 | { |
| 234 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 235 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 236 | return left->type() > right->type(); |
| 237 | } |
| 238 | |
| 239 | static int cTypeDescending(const void* a, const void* b) |
| 240 | { |
| 241 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 242 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 243 | return left->type() < right->type(); |
| 244 | } |
| 245 | |
| 246 | static int cConditionAscending(const void* a, const void* b) |
| 247 | { |
| 248 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 249 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 250 | const int result = strcmp(left->condition(), right->condition()); |
| 251 | return result >= 0; |
| 252 | } |
| 253 | |
| 254 | static int cConditionDescending(const void* a, const void* b) |
| 255 | { |
| 256 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 257 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 258 | const int result = strcmp(left->condition(), right->condition()); |
| 259 | return result < 0; |
| 260 | } |
| 261 | |
| 262 | static int cActionAscending(const void* a, const void* b) |
| 263 | { |
| 264 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 265 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 266 | const int result = strcmp(left->action(), right->action()); |
| 267 | return result >= 0; |
| 268 | } |
| 269 | |
| 270 | static int cActionDescending(const void* a, const void* b) |
| 271 | { |
| 272 | const device_debug::watchpoint* left = *(device_debug::watchpoint**)a; |
| 273 | const device_debug::watchpoint* right = *(device_debug::watchpoint**)b; |
| 274 | const int result = strcmp(left->action(), right->action()); |
| 275 | return result < 0; |
| 276 | } |
| 277 | |
| 278 | |
| 279 | int debug_view_watchpoints::watchpoints(SortMode sort, device_debug::watchpoint**& wpList) |
| 280 | { |
| 281 | // Alloc |
| 282 | int numWPs = 0; |
| 283 | wpList = NULL; |
| 231 | 284 | for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next()) |
| 232 | 285 | { |
| 286 | for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; spacenum++) |
| 287 | { |
| 288 | /* loop over the watchpoints */ |
| 289 | const device_debug& debugInterface = *source->device()->debug(); |
| 290 | for (device_debug::watchpoint *wp = debugInterface.watchpoint_first(spacenum); wp != NULL; wp = wp->next()) |
| 291 | numWPs++; |
| 292 | } |
| 293 | } |
| 294 | wpList = new device_debug::watchpoint*[numWPs]; |
| 295 | |
| 296 | int wpAddIndex = 0; |
| 297 | for (const debug_view_source *source = m_source_list.first(); source != NULL; source = source->next()) |
| 298 | { |
| 233 | 299 | // Collect |
| 234 | | device_debug &debugInterface = *source->device()->debug(); |
| 235 | 300 | for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; spacenum++) |
| 236 | 301 | { |
| 302 | device_debug& debugInterface = *source->device()->debug(); |
| 237 | 303 | for (device_debug::watchpoint *wp = debugInterface.watchpoint_first(spacenum); wp != NULL; wp = wp->next()) |
| 238 | | m_buffer.append() = wp; |
| 304 | { |
| 305 | wpList[wpAddIndex] = wp; |
| 306 | wpAddIndex++; |
| 307 | } |
| 239 | 308 | } |
| 240 | 309 | } |
| 241 | 310 | |
| 242 | 311 | // And now for the sort |
| 243 | | qsort(&m_buffer[0], m_buffer.count(), sizeof(device_debug::watchpoint *), m_sortType); |
| 312 | switch (m_sortType) |
| 313 | { |
| 314 | case SORT_NONE: |
| 315 | break; |
| 316 | case SORT_INDEX_ASCENDING: |
| 317 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cIndexAscending); |
| 318 | break; |
| 319 | case SORT_INDEX_DESCENDING: |
| 320 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cIndexDescending); |
| 321 | break; |
| 322 | case SORT_ENABLED_ASCENDING: |
| 323 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cEnabledAscending); |
| 324 | break; |
| 325 | case SORT_ENABLED_DESCENDING: |
| 326 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cEnabledDescending); |
| 327 | break; |
| 328 | case SORT_CPU_ASCENDING: |
| 329 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cCpuAscending); |
| 330 | break; |
| 331 | case SORT_CPU_DESCENDING: |
| 332 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cCpuDescending); |
| 333 | break; |
| 334 | case SORT_SPACE_ASCENDING: |
| 335 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cSpaceAscending); |
| 336 | break; |
| 337 | case SORT_SPACE_DESCENDING: |
| 338 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cSpaceDescending); |
| 339 | break; |
| 340 | case SORT_ADDRESS_ASCENDING: |
| 341 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cAddressAscending); |
| 342 | break; |
| 343 | case SORT_ADDRESS_DESCENDING: |
| 344 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cAddressDescending); |
| 345 | break; |
| 346 | case SORT_TYPE_ASCENDING: |
| 347 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cTypeAscending); |
| 348 | break; |
| 349 | case SORT_TYPE_DESCENDING: |
| 350 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cTypeDescending); |
| 351 | break; |
| 352 | case SORT_CONDITION_ASCENDING: |
| 353 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cConditionAscending); |
| 354 | break; |
| 355 | case SORT_CONDITION_DESCENDING: |
| 356 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cConditionDescending); |
| 357 | break; |
| 358 | case SORT_ACTION_ASCENDING: |
| 359 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cActionAscending); |
| 360 | break; |
| 361 | case SORT_ACTION_DESCENDING: |
| 362 | qsort(wpList, numWPs, sizeof(device_debug::watchpoint*), cActionDescending); |
| 363 | break; |
| 364 | } |
| 365 | |
| 366 | return numWPs; |
| 244 | 367 | } |
| 245 | 368 | |
| 246 | 369 | |
| r243727 | r243728 | |
| 252 | 375 | void debug_view_watchpoints::view_update() |
| 253 | 376 | { |
| 254 | 377 | // Gather a list of all the watchpoints for all the CPUs |
| 255 | | gather_watchpoints(); |
| 378 | device_debug::watchpoint** wpList = NULL; |
| 379 | const int numWPs = watchpoints(SORT_NONE, wpList); |
| 256 | 380 | |
| 257 | 381 | // Set the view region so the scroll bars update |
| 258 | | m_total.x = tableBreaks[ARRAY_LENGTH(tableBreaks) - 1]; |
| 259 | | m_total.y = m_buffer.count() + 1; |
| 260 | | if (m_total.y < 10) |
| 261 | | m_total.y = 10; |
| 382 | m_total.y = numWPs+1; |
| 262 | 383 | |
| 263 | 384 | // Draw |
| 264 | | debug_view_char *dest = m_viewdata; |
| 265 | | astring linebuf; |
| 266 | | |
| 267 | | // Header |
| 268 | | if (m_visible.y > 0) |
| 385 | debug_view_char *dest = m_viewdata; |
| 386 | for (int row = 0; row < m_visible.y; row++) |
| 269 | 387 | { |
| 270 | | linebuf.reset(); |
| 271 | | linebuf.cat("ID"); |
| 272 | | if (m_sortType == &cIndexAscending) linebuf.cat('\\'); |
| 273 | | else if (m_sortType == &cIndexDescending) linebuf.cat('/'); |
| 274 | | pad_astring_to_length(linebuf, tableBreaks[0]); |
| 275 | | linebuf.cat("En"); |
| 276 | | if (m_sortType == &cEnabledAscending) linebuf.cat('\\'); |
| 277 | | else if (m_sortType == &cEnabledDescending) linebuf.cat('/'); |
| 278 | | pad_astring_to_length(linebuf, tableBreaks[1]); |
| 279 | | linebuf.cat("CPU"); |
| 280 | | if (m_sortType == &cCpuAscending) linebuf.cat('\\'); |
| 281 | | else if (m_sortType == &cCpuDescending) linebuf.cat('/'); |
| 282 | | pad_astring_to_length(linebuf, tableBreaks[2]); |
| 283 | | linebuf.cat("Space"); |
| 284 | | if (m_sortType == &cSpaceAscending) linebuf.cat('\\'); |
| 285 | | else if (m_sortType == &cSpaceDescending) linebuf.cat('/'); |
| 286 | | pad_astring_to_length(linebuf, tableBreaks[3]); |
| 287 | | linebuf.cat("Addresses"); |
| 288 | | if (m_sortType == &cAddressAscending) linebuf.cat('\\'); |
| 289 | | else if (m_sortType == &cAddressDescending) linebuf.cat('/'); |
| 290 | | pad_astring_to_length(linebuf, tableBreaks[4]); |
| 291 | | linebuf.cat("Type"); |
| 292 | | if (m_sortType == &cTypeAscending) linebuf.cat('\\'); |
| 293 | | else if (m_sortType == &cTypeDescending) linebuf.cat('/'); |
| 294 | | pad_astring_to_length(linebuf, tableBreaks[5]); |
| 295 | | linebuf.cat("Condition"); |
| 296 | | if (m_sortType == &cConditionAscending) linebuf.cat('\\'); |
| 297 | | else if (m_sortType == &cConditionDescending) linebuf.cat('/'); |
| 298 | | pad_astring_to_length(linebuf, tableBreaks[6]); |
| 299 | | linebuf.cat("Action"); |
| 300 | | if (m_sortType == &cActionAscending) linebuf.cat('\\'); |
| 301 | | else if (m_sortType == &cActionDescending) linebuf.cat('/'); |
| 302 | | pad_astring_to_length(linebuf, tableBreaks[7]); |
| 388 | UINT32 effrow = m_topleft.y + row; |
| 303 | 389 | |
| 304 | | for (UINT32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) |
| 390 | // Header |
| 391 | if (row == 0) |
| 305 | 392 | { |
| 306 | | dest->byte = (i < linebuf.len()) ? linebuf[i] : ' '; |
| 307 | | dest->attrib = DCA_ANCILLARY; |
| 393 | astring header; |
| 394 | header.printf("ID"); |
| 395 | if (m_sortType == SORT_INDEX_ASCENDING) header.catprintf("\\"); |
| 396 | else if (m_sortType == SORT_INDEX_DESCENDING) header.catprintf("/"); |
| 397 | pad_astring_to_length(header, tableBreaks[0]); |
| 398 | header.catprintf("En"); |
| 399 | if (m_sortType == SORT_ENABLED_ASCENDING) header.catprintf("\\"); |
| 400 | else if (m_sortType == SORT_ENABLED_DESCENDING) header.catprintf("/"); |
| 401 | pad_astring_to_length(header, tableBreaks[1]); |
| 402 | header.catprintf("CPU"); |
| 403 | if (m_sortType == SORT_CPU_ASCENDING) header.catprintf("\\"); |
| 404 | else if (m_sortType == SORT_CPU_DESCENDING) header.catprintf("/"); |
| 405 | pad_astring_to_length(header, tableBreaks[2]); |
| 406 | header.catprintf("Space"); |
| 407 | if (m_sortType == SORT_SPACE_ASCENDING) header.catprintf("\\"); |
| 408 | else if (m_sortType == SORT_SPACE_DESCENDING) header.catprintf("/"); |
| 409 | pad_astring_to_length(header, tableBreaks[3]); |
| 410 | header.catprintf("Addresses"); |
| 411 | if (m_sortType == SORT_ADDRESS_ASCENDING) header.catprintf("\\"); |
| 412 | else if (m_sortType == SORT_ADDRESS_DESCENDING) header.catprintf("/"); |
| 413 | pad_astring_to_length(header, tableBreaks[4]); |
| 414 | header.catprintf("Type"); |
| 415 | if (m_sortType == SORT_TYPE_ASCENDING) header.catprintf("\\"); |
| 416 | else if (m_sortType == SORT_TYPE_DESCENDING) header.catprintf("/"); |
| 417 | pad_astring_to_length(header, tableBreaks[5]); |
| 418 | header.catprintf("Condition"); |
| 419 | if (m_sortType == SORT_CONDITION_ASCENDING) header.catprintf("\\"); |
| 420 | else if (m_sortType == SORT_CONDITION_DESCENDING) header.catprintf("/"); |
| 421 | pad_astring_to_length(header, tableBreaks[6]); |
| 422 | header.catprintf("Action"); |
| 423 | if (m_sortType == SORT_ACTION_ASCENDING) header.catprintf("\\"); |
| 424 | else if (m_sortType == SORT_ACTION_DESCENDING) header.catprintf("/"); |
| 425 | pad_astring_to_length(header, tableBreaks[7]); |
| 426 | |
| 427 | for (int i = 0; i < m_visible.x; i++) |
| 428 | { |
| 429 | dest->byte = (i < header.len()) ? header[i] : ' '; |
| 430 | dest->attrib = DCA_ANCILLARY; |
| 431 | dest++; |
| 432 | } |
| 433 | continue; |
| 308 | 434 | } |
| 309 | | } |
| 310 | 435 | |
| 311 | | for (int row = 1; row < m_visible.y; row++) |
| 312 | | { |
| 313 | 436 | // watchpoints |
| 314 | | int const wpi = row + m_topleft.y - 1; |
| 315 | | if ((wpi < m_buffer.count()) && wpi >= 0) |
| 437 | int wpi = effrow-1; |
| 438 | if (wpi < numWPs && wpi >= 0) |
| 316 | 439 | { |
| 317 | | static char const *const types[] = { "unkn ", "read ", "write", "r/w " }; |
| 318 | | device_debug::watchpoint *const wp = m_buffer[wpi]; |
| 440 | static const char *const types[] = { "unkn ", "read ", "write", "r/w " }; |
| 441 | device_debug::watchpoint* wp = wpList[wpi]; |
| 319 | 442 | |
| 320 | | linebuf.reset(); |
| 321 | | linebuf.catprintf("%2X", wp->index()); |
| 322 | | pad_astring_to_length(linebuf, tableBreaks[0]); |
| 323 | | linebuf.cat(wp->enabled() ? 'X' : 'O'); |
| 324 | | pad_astring_to_length(linebuf, tableBreaks[1]); |
| 325 | | linebuf.cat(wp->debugInterface()->device().tag()); |
| 326 | | pad_astring_to_length(linebuf, tableBreaks[2]); |
| 327 | | linebuf.cat(wp->space().name()); |
| 328 | | pad_astring_to_length(linebuf, tableBreaks[3]); |
| 329 | | linebuf.cat(core_i64_hex_format(wp->space().byte_to_address(wp->address()), wp->space().addrchars())); |
| 330 | | linebuf.cat('-'); |
| 331 | | linebuf.cat(core_i64_hex_format(wp->space().byte_to_address_end(wp->address() + wp->length()) - 1, wp->space().addrchars())); |
| 332 | | pad_astring_to_length(linebuf, tableBreaks[4]); |
| 333 | | linebuf.cat(types[wp->type() & 3]); |
| 334 | | pad_astring_to_length(linebuf, tableBreaks[5]); |
| 335 | | if (strcmp(wp->condition(), "1")) |
| 336 | | linebuf.cat(wp->condition()); |
| 337 | | pad_astring_to_length(linebuf, tableBreaks[6]); |
| 338 | | linebuf.cat(wp->action()); |
| 339 | | pad_astring_to_length(linebuf, tableBreaks[7]); |
| 443 | astring buffer; |
| 444 | buffer.printf("%X", wp->index()); |
| 445 | pad_astring_to_length(buffer, tableBreaks[0]); |
| 446 | buffer.catprintf("%c", wp->enabled() ? 'X' : 'O'); |
| 447 | pad_astring_to_length(buffer, tableBreaks[1]); |
| 448 | buffer.catprintf("%s", wp->debugInterface()->device().tag()); |
| 449 | pad_astring_to_length(buffer, tableBreaks[2]); |
| 450 | buffer.catprintf("%s", wp->space().name()); |
| 451 | pad_astring_to_length(buffer, tableBreaks[3]); |
| 452 | buffer.catprintf("%s-%s", |
| 453 | core_i64_hex_format(wp->space().byte_to_address(wp->address()), wp->space().addrchars()), |
| 454 | core_i64_hex_format(wp->space().byte_to_address_end(wp->address() + wp->length()) - 1, wp->space().addrchars())); |
| 455 | pad_astring_to_length(buffer, tableBreaks[4]); |
| 456 | buffer.catprintf("%s", types[wp->type() & 3]); |
| 457 | pad_astring_to_length(buffer, tableBreaks[5]); |
| 458 | if (astring(wp->condition()) != astring("1")) |
| 459 | { |
| 460 | buffer.catprintf("%s", wp->condition()); |
| 461 | pad_astring_to_length(buffer, tableBreaks[6]); |
| 462 | } |
| 463 | if (astring(wp->action()) != astring("")) |
| 464 | { |
| 465 | buffer.catprintf("%s", wp->action()); |
| 466 | pad_astring_to_length(buffer, tableBreaks[7]); |
| 467 | } |
| 340 | 468 | |
| 341 | | for (UINT32 i = m_topleft.x; i < (m_topleft.x + m_visible.x); i++, dest++) |
| 469 | for (int i = 0; i < m_visible.x; i++) |
| 342 | 470 | { |
| 343 | | dest->byte = (i < linebuf.len()) ? linebuf[i] : ' '; |
| 471 | dest->byte = (i < buffer.len()) ? buffer[i] : ' '; |
| 344 | 472 | dest->attrib = DCA_NORMAL; |
| 345 | 473 | |
| 346 | 474 | // Color disabled watchpoints red |
| 347 | | if ((i >= tableBreaks[0]) && (i < tableBreaks[1]) && !wp->enabled()) |
| 348 | | dest->attrib |= DCA_CHANGED; |
| 475 | if (i == 5 && dest->byte == 'O') |
| 476 | dest->attrib = DCA_CHANGED; |
| 477 | |
| 478 | dest++; |
| 349 | 479 | } |
| 480 | continue; |
| 350 | 481 | } |
| 351 | | else |
| 482 | |
| 483 | // Fill the remaining vertical space |
| 484 | for (int i = 0; i < m_visible.x; i++) |
| 352 | 485 | { |
| 353 | | // Fill the remaining vertical space |
| 354 | | for (int i = 0; i < m_visible.x; i++, dest++) |
| 355 | | { |
| 356 | | dest->byte = ' '; |
| 357 | | dest->attrib = DCA_NORMAL; |
| 358 | | } |
| 486 | dest->byte = ' '; |
| 487 | dest->attrib = DCA_NORMAL; |
| 488 | dest++; |
| 359 | 489 | } |
| 360 | 490 | } |
| 491 | |
| 492 | delete[] wpList; |
| 361 | 493 | } |
trunk/src/mame/drivers/wms.c
| r243727 | r243728 | |
| 376 | 376 | { |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | | GAME( 200?, wms, 0, wms, wms, wms_state, wms, ROT0, "WMS", "WMS SetUp/Clear Chips (set 1)", GAME_IS_SKELETON_MECHANICAL ) |
| 380 | | GAME( 200?, wmsa, wms, wms, wms, wms_state, wms, ROT0, "WMS", "WMS SetUp/Clear Chips (set 2)", GAME_IS_SKELETON_MECHANICAL ) |
| 381 | | GAME( 200?, wmsb, wms, wms, wms, wms_state, wms, ROT0, "WMS", "WMS SetUp/Clear Chips (set 3)", GAME_IS_SKELETON_MECHANICAL ) |
| 379 | GAME( 200?, wms, 0, wms, wms, wms_state, wms, ROT0, "WMS", "WMS SetUp/Clear Chips (set 1)", GAME_IS_SKELETON ) |
| 380 | GAME( 200?, wmsa, wms, wms, wms, wms_state, wms, ROT0, "WMS", "WMS SetUp/Clear Chips (set 2)", GAME_IS_SKELETON ) |
| 381 | GAME( 200?, wmsb, wms, wms, wms, wms_state, wms, ROT0, "WMS", "WMS SetUp/Clear Chips (set 3)", GAME_IS_SKELETON ) |
| 382 | 382 | |
| 383 | | GAME( 200?, btippers, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Big Tippers (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 384 | | GAME( 200?, wmsboom, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Boom (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 385 | | GAME( 200?, cashcrop, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Cash Crop (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 386 | | GAME( 200?, filthyr, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Filthy Rich (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 387 | | GAME( 200?, hottop, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Hot Toppings (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 388 | | GAME( 200?, inwinner, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Instant Winner (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 389 | | GAME( 200?, jptparty, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Jackpot Party (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 390 | | GAME( 200?, leprgld, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Leprechaun's Gold (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 391 | | GAME( 200?, lol, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Life of Luxury (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 392 | | GAME( 200?, lovewin, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Love To Win (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 393 | | GAME( 200?, mtburn, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Money To Burn (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 394 | | GAME( 200?, otchart, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Off The Charts (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 395 | | GAME( 200?, perfect, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Perfect Game (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 396 | | GAME( 200?, reelemin, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Reel 'Em In (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 397 | | GAME( 200?, sonoth, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Something For Nothing (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 398 | | GAME( 200?, swingin, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Swingin In The Green (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 399 | | GAME( 200?, wmstopb, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Top Banana (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 400 | | GAME( 200?, wdun, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Who Dunnit (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 401 | | GAME( 200?, winbid, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Winning Bid (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 402 | | GAME( 200?, wldstrek, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Wild Streak (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 403 | | GAME( 200?, yukongld, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Yukon Gold (Russia)", GAME_IS_SKELETON_MECHANICAL ) |
| 383 | GAME( 200?, btippers, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Big Tippers (Russia)", GAME_IS_SKELETON ) |
| 384 | GAME( 200?, wmsboom, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Boom (Russia)", GAME_IS_SKELETON ) |
| 385 | GAME( 200?, cashcrop, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Cash Crop (Russia)", GAME_IS_SKELETON ) |
| 386 | GAME( 200?, filthyr, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Filthy Rich (Russia)", GAME_IS_SKELETON ) |
| 387 | GAME( 200?, hottop, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Hot Toppings (Russia)", GAME_IS_SKELETON ) |
| 388 | GAME( 200?, inwinner, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Instant Winner (Russia)", GAME_IS_SKELETON ) |
| 389 | GAME( 200?, jptparty, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Jackpot Party (Russia)", GAME_IS_SKELETON ) |
| 390 | GAME( 200?, leprgld, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Leprechaun's Gold (Russia)", GAME_IS_SKELETON ) |
| 391 | GAME( 200?, lol, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Life of Luxury (Russia)", GAME_IS_SKELETON ) |
| 392 | GAME( 200?, lovewin, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Love To Win (Russia)", GAME_IS_SKELETON ) |
| 393 | GAME( 200?, mtburn, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Money To Burn (Russia)", GAME_IS_SKELETON ) |
| 394 | GAME( 200?, otchart, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Off The Charts (Russia)", GAME_IS_SKELETON ) |
| 395 | GAME( 200?, perfect, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Perfect Game (Russia)", GAME_IS_SKELETON ) |
| 396 | GAME( 200?, reelemin, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Reel 'Em In (Russia)", GAME_IS_SKELETON ) |
| 397 | GAME( 200?, sonoth, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Something For Nothing (Russia)", GAME_IS_SKELETON ) |
| 398 | GAME( 200?, swingin, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Swingin In The Green (Russia)", GAME_IS_SKELETON ) |
| 399 | GAME( 200?, wmstopb, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Top Banana (Russia)", GAME_IS_SKELETON ) |
| 400 | GAME( 200?, wdun, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Who Dunnit (Russia)", GAME_IS_SKELETON ) |
| 401 | GAME( 200?, winbid, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Winning Bid (Russia)", GAME_IS_SKELETON ) |
| 402 | GAME( 200?, wldstrek, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Wild Streak (Russia)", GAME_IS_SKELETON ) |
| 403 | GAME( 200?, yukongld, 0, wms, wms, wms_state, wms, ROT0, "WMS", "Yukon Gold (Russia)", GAME_IS_SKELETON ) |