summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/bsmt2000.h
blob: 7cf963cb90c524124cbeb359b3af8b5ee2a2b77e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**********************************************************************************************
 *
 *   BSMT2000 driver
 *   by Aaron Giles
 *
 **********************************************************************************************/

#pragma once

#ifndef __BSMT2000_H__
#define __BSMT2000_H__

WRITE16_HANDLER( bsmt2000_data_0_w );

SND_GET_INFO( bsmt2000 );

#endif /* __BSMT2000_H__ */
#n225'>225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
/*********************************************************************

    debugvw.c

    Debugger view engine.

****************************************************************************

    Copyright Aaron Giles
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are
    met:

        * Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above copyright
          notice, this list of conditions and the following disclaimer in
          the documentation and/or other materials provided with the
          distribution.
        * Neither the name 'MAME' nor the names of its contributors may be
          used to endorse or promote products derived from this software
          without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
    INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGE.

***************************************************************************/

#include "emu.h"
#include "express.h"
#include "debugvw.h"
#include "dvtext.h"
#include "dvstate.h"
#include "dvdisasm.h"
#include "dvmemory.h"
#include "debugcmd.h"
#include "debugcpu.h"
#include "debugcon.h"
#include <ctype.h>



//**************************************************************************
//  DEBUG VIEW SOURCE
//**************************************************************************

//-------------------------------------------------
//  debug_view_source - constructor
//-------------------------------------------------

debug_view_source::debug_view_source(const char *name, device_t *device)
	: m_next(NULL),
		m_name(name),
		m_device(device),
		m_is_octal(false)
{
	device_execute_interface *intf;
	if (device && device->interface(intf))
		m_is_octal = intf->is_octal();

}


//-------------------------------------------------
//  ~debug_view_source - destructor
//-------------------------------------------------

debug_view_source::~debug_view_source()
{
}



//**************************************************************************
//  DEBUG VIEW SOURCE LIST
//**************************************************************************

//-------------------------------------------------
//  debug_view_source_list - constructor
//-------------------------------------------------

debug_view_source_list::debug_view_source_list(running_machine &machine)
	: m_machine(machine),
		m_head(NULL),
		m_tail(NULL),
		m_count(0)
{
}


//-------------------------------------------------
//  ~debug_view_source_list - destructor
//-------------------------------------------------

debug_view_source_list::~debug_view_source_list()
{
	reset();
}


//-------------------------------------------------
//  index - return the index of a source
//-------------------------------------------------

int debug_view_source_list::index(const debug_view_source &source) const
{
	int result = 0;
	for (debug_view_source *cursource = m_head; cursource != NULL; cursource = cursource->m_next)
	{
		if (cursource == &source)
			break;
		result++;
	}
	return result;
}


//-------------------------------------------------
//  by_index - return a source given an index
//-------------------------------------------------

const debug_view_source *debug_view_source_list::by_index(int index) const
{
	if (m_head == NULL)
		return NULL;
	const debug_view_source *result;
	for (result = m_head; index > 0 && result->m_next != NULL; result = result->m_next)
		index--;
	return result;
}


//-------------------------------------------------
//  reset - free all the view_sources
//-------------------------------------------------

void debug_view_source_list::reset()
{
	// free from the head
	while (m_head != NULL)
	{
		debug_view_source *source = m_head;
		m_head = source->m_next;
		auto_free(machine(), source);
	}

	// reset the tail pointer and index
	m_tail = NULL;
	m_count = 0;
}


//-------------------------------------------------
//  append - add a view_source to the end of the
//  list
//-------------------------------------------------

void debug_view_source_list::append(debug_view_source &source)
{
	// set the next and index values
	source.m_next = NULL;

	// append to the end
	if (m_tail == NULL)
		m_head = m_tail = &source;
	else
		m_tail->m_next = &source;
	m_tail = &source;
	m_count++;
}


//-------------------------------------------------
//  match_device - find the first view that
//  matches the given device
//-------------------------------------------------

const debug_view_source *debug_view_source_list::match_device(device_t *device) const
{
	for (debug_view_source *source = m_head; source != NULL; source = source->m_next)
		if (device == source->m_device)
			return source;
	return m_head;
}



//**************************************************************************
//  DEBUG VIEW
//**************************************************************************

//-------------------------------------------------
//  debug_view - constructor
//-------------------------------------------------

debug_view::debug_view(running_machine &machine, debug_view_type type, debug_view_osd_update_func osdupdate, void *osdprivate)
	: m_next(NULL),
		m_type(type),
		m_source(NULL),
		m_source_list(machine),
		m_osdupdate(osdupdate),
		m_osdprivate(osdprivate),
		m_visible(10,10),
		m_total(10,10),
		m_topleft(0,0),
		m_cursor(0,0),
		m_supports_cursor(false),
		m_cursor_visible(false),
		m_recompute(true),
		m_update_level(0),
		m_update_pending(true),
		m_osd_update_pending(true),
		m_viewdata(NULL),
		m_viewdata_size(0),
		m_machine(machine)
{
	// allocate memory for the buffer
	m_viewdata_size = m_visible.y * m_visible.x;
	m_viewdata = auto_alloc_array(machine, debug_view_char, m_viewdata_size);
}


//-------------------------------------------------
//  ~debug_view - destructor
//-------------------------------------------------

debug_view::~debug_view()
{
}


//-------------------------------------------------
//  end_update - bracket a sequence of changes so
//  that only one update occurs
//-------------------------------------------------

void debug_view::end_update()
{
	/* if we hit zero, call the update function */
	if (m_update_level == 1)
	{
		while (m_update_pending)
		{
			// no longer pending, but flag for the OSD
			m_update_pending = false;
			m_osd_update_pending = true;

			// resize the viewdata if needed
			int size = m_visible.x * m_visible.y;
			if (size > m_viewdata_size)
			{
				m_viewdata_size = size;
				auto_free(machine(), m_viewdata);
				m_viewdata = auto_alloc_array(machine(), debug_view_char, m_viewdata_size);
			}

			// update the view
			view_update();
		}
	}

	// decrement the level
	m_update_level--;
}


//-------------------------------------------------
//  flush_osd_updates - notify the OSD of any
//  pending updates
//-------------------------------------------------

void debug_view::flush_osd_updates()
{
	if (m_osd_update_pending && m_osdupdate != NULL)
		(*m_osdupdate)(*this, m_osdprivate);
	m_osd_update_pending = false;
}


//-------------------------------------------------
//  set_visible_size - set the visible size in
//  rows and columns
//-------------------------------------------------*/

void debug_view::set_visible_size(debug_view_xy size)
{
	if (size.x != m_visible.x || size.y != m_visible.y)
	{
		begin_update();
		m_visible = size;
		m_update_pending = true;
		view_notify(VIEW_NOTIFY_VISIBLE_CHANGED);
		end_update();
	}
}


//-------------------------------------------------
//  set_visible_position - set the top left
//  position of the visible area in rows and
//  columns
//-------------------------------------------------

void debug_view::set_visible_position(debug_view_xy pos)
{
	if (pos.x != m_topleft.x || pos.y != m_topleft.y)
	{
		begin_update();
		m_topleft = pos;
		m_update_pending = true;
		view_notify(VIEW_NOTIFY_VISIBLE_CHANGED);
		end_update();
	}
}


//-------------------------------------------------
//  set_cursor_position - set the current cursor
//  position as a row and column
//-------------------------------------------------

void debug_view::set_cursor_position(debug_view_xy pos)
{
	if (pos.x != m_cursor.x || pos.y != m_cursor.y)
	{
		begin_update();
		m_cursor = pos;
		m_update_pending = true;
		view_notify(VIEW_NOTIFY_CURSOR_CHANGED);
		end_update();
	}
}


//-------------------------------------------------
//  set_cursor_visible - set the visible state of
//  the cursor
//-------------------------------------------------

void debug_view::set_cursor_visible(bool visible)
{
	if (visible != m_cursor_visible)
	{
		begin_update();
		m_cursor_visible = visible;
		m_update_pending = true;
		view_notify(VIEW_NOTIFY_CURSOR_CHANGED);
		end_update();
	}
}


//-------------------------------------------------
//  set_subview - set the current subview
//-------------------------------------------------

void debug_view::set_source(const debug_view_source &source)
{
	if (&source != m_source)
	{
		begin_update();
		m_source = &source;
		m_update_pending = true;
		view_notify(VIEW_NOTIFY_SOURCE_CHANGED);
		end_update();
	}
}


//-------------------------------------------------
//  adjust_visible_x_for_cursor - adjust a view's
//  visible X position to ensure the cursor is
//  visible
//-------------------------------------------------

void debug_view::adjust_visible_x_for_cursor()
{
	if (m_cursor.x < m_topleft.x)
		m_topleft.x = m_cursor.x;
	else if (m_cursor.x >= m_topleft.x + m_visible.x - 1)
		m_topleft.x = m_cursor.x - m_visible.x + 2;
}


//-------------------------------------------------
//  adjust_visible_y_for_cursor - adjust a view's
//  visible Y position to ensure the cursor is
//  visible
//-------------------------------------------------

void debug_view::adjust_visible_y_for_cursor()
{
	if (m_cursor.y < m_topleft.y)
		m_topleft.y = m_cursor.y;
	else if (m_cursor.y >= m_topleft.y + m_visible.y - 1)
		m_topleft.y = m_cursor.y - m_visible.y + 2;
}


//-------------------------------------------------
//  view_notify - handle notification of updates
//-------------------------------------------------

void debug_view::view_notify(debug_view_notification type)
{
	// default does nothing
}


//-------------------------------------------------
//  view_char - handle a character typed within
//  the current view
//-------------------------------------------------

void debug_view::view_char(int chval)
{
	// default does nothing
}


//-------------------------------------------------
//  view_click - handle a mouse click within the
//  current view
//-------------------------------------------------

void debug_view::view_click(const int button, const debug_view_xy& pos)
{
	// default does nothing
}



//**************************************************************************
//  DEBUG VIEW MANAGER
//**************************************************************************

//-------------------------------------------------
//  debug_view_manager - constructor
//-------------------------------------------------

debug_view_manager::debug_view_manager(running_machine &machine)
	: m_machine(machine),
		m_viewlist(NULL)
{
}


//-------------------------------------------------
//  ~debug_view_manager - destructor
//-------------------------------------------------

debug_view_manager::~debug_view_manager()
{
	while (m_viewlist != NULL)
	{
		debug_view *oldhead = m_viewlist;
		m_viewlist = oldhead->m_next;
		auto_free(machine(), oldhead);
	}
}


//-------------------------------------------------
//  alloc_view - create a new view
//-------------------------------------------------

debug_view *debug_view_manager::alloc_view(debug_view_type type, debug_view_osd_update_func osdupdate, void *osdprivate)
{
	switch (type)
	{
		case DVT_CONSOLE:
			return append(auto_alloc(machine(), debug_view_console(machine(), osdupdate, osdprivate)));

		case DVT_STATE:
			return append(auto_alloc(machine(), debug_view_state(machine(), osdupdate, osdprivate)));

		case DVT_DISASSEMBLY:
			return append(auto_alloc(machine(), debug_view_disasm(machine(), osdupdate, osdprivate)));

		case DVT_MEMORY:
			return append(auto_alloc(machine(), debug_view_memory(machine(), osdupdate, osdprivate)));

		case DVT_LOG:
			return append(auto_alloc(machine(), debug_view_log(machine(), osdupdate, osdprivate)));

		case DVT_TIMERS:
//          return append(auto_alloc(machine(), debug_view_timers(machine(), osdupdate, osdprivate)));

		case DVT_ALLOCS:
//          return append(auto_alloc(machine(), debug_view_allocs(machine(), osdupdate, osdprivate)));

		default:
			fatalerror("Attempt to create invalid debug view type %d\n", type);
	}
	return NULL;
}


//-------------------------------------------------
//  free_view - free a view
//-------------------------------------------------

void debug_view_manager::free_view(debug_view &view)
{
	// free us but only if we're in the list
	for (debug_view **viewptr = &m_viewlist; *viewptr != NULL; viewptr = &(*viewptr)->m_next)
		if (*viewptr == &view)
		{
			*viewptr = view.m_next;
			auto_free(machine(), &view);
			break;
		}
}


//-------------------------------------------------
//  update_all - force all views to refresh
//-------------------------------------------------

void debug_view_manager::update_all(debug_view_type type)
{
	// loop over each view and force an update
	for (debug_view *view = m_viewlist; view != NULL; view = view->next())
		if (type == DVT_NONE || type == view->type())
			view->force_update();
}


//-------------------------------------------------
//  flush_osd_updates - flush all pending OSD
//  updates
//-------------------------------------------------

void debug_view_manager::flush_osd_updates()
{
	for (debug_view *view = m_viewlist; view != NULL; view = view->m_next)
		view->flush_osd_updates();
}


//-------------------------------------------------
//  append - append a view to the end of our list
//-------------------------------------------------

debug_view *debug_view_manager::append(debug_view *view)
{
	debug_view **viewptr;
	for (viewptr = &m_viewlist; *viewptr != NULL; viewptr = &(*viewptr)->m_next) ;
	*viewptr = view;
	return view;
}



//**************************************************************************
//  DEBUG VIEW EXPRESSION
//**************************************************************************

//-------------------------------------------------
//  debug_view_expression - constructor
//-------------------------------------------------

debug_view_expression::debug_view_expression(running_machine &machine)
	: m_machine(machine),
		m_dirty(true),
		m_result(0),
		m_parsed(debug_cpu_get_global_symtable(machine)),
		m_string("0")
{
}


//-------------------------------------------------
//  ~debug_view_expression - destructor
//-------------------------------------------------

debug_view_expression::~debug_view_expression()
{
}


//-------------------------------------------------
//  set_context - set the context for the
//  expression
//-------------------------------------------------

void debug_view_expression::set_context(symbol_table *context)
{
	m_parsed.set_symbols((context != NULL) ? context : debug_cpu_get_global_symtable(machine()));
	m_dirty = true;
}


//-------------------------------------------------
//  recompute - recompute the value of an
//  expression
//-------------------------------------------------

bool debug_view_expression::recompute()
{
	bool changed = m_dirty;

	// if dirty, re-evaluate
	if (m_dirty)
	{
		astring oldstring(m_parsed.original_string());
		try
		{
			m_parsed.parse(m_string);
		}
		catch (expression_error &)
		{
			m_parsed.parse(oldstring);
		}
	}

	// if we have a parsed expression, evalute it
	if (!m_parsed.is_empty())
	{
		// recompute the value of the expression
		try
		{
			UINT64 newresult = m_parsed.execute();
			if (newresult != m_result)
			{
				m_result = newresult;
				changed = true;
			}
		}
		catch (expression_error &)
		{
		}
	}

	// expression no longer dirty by definition
	m_dirty = false;
	return changed;
}