summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/alto2/a2dwt.cpp
blob: 6876dbc193d95f2ead7407cfb0e97c5ea9acb39b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// license:BSD-3-Clause
// copyright-holders:Juergen Buchmueller
/*****************************************************************************
 *
 *   Xerox AltoII display word task
 *
 *****************************************************************************/
#include "emu.h"
#include "alto2cpu.h"

/*
 * Copied from ALTOCODE24.MU
 *
 *  ;Display Word Task
 *
 *  DWT:    T← DWA;
 *      T←-3+T+1;
 *      L← AECL+T,BUS=0,TASK;   AECL CONTAINS NWRDS AT THIS TIME
 *      AECL←L, :DWTZ;
 *
 *  DWTY:   BLOCK;
 *      TASK, :DWTF;
 *
 *  DWTZ:   L←HTAB-1, BUS=0,TASK;
 *      HTAB←L, :DOTAB;
 *
 *  DOTAB:  DDR←0, :DWTZ;
 *  NOTAB:  MAR←T←DWA;
 *      L←AECL-T-1;
 *      ALUCY, L←2+T;
 *      DWA←L, :XNOMORE;
 *
 *  DOMORE: DDR←MD, TASK;
 *      DDR←MD, :NOTAB;
 *
 *  XNOMORE:DDR← MD, BLOCK;
 *      DDR← MD, TASK;
 *
 *  DWTF:   :DWT;
 */

//! PROM a38 bit O1 is STOPWAKE' (stop DWT if bit is zero)
#define FIFO_STOPWAKE(a38) (0 == (a38 & disp_a38_STOPWAKE) ? true : false)

/**
 * @brief Block the display word task.
 */
void alto2_cpu_device::f1_early_dwt_block()
{
	m_dsp.dwt_blocks = true;

	// Clear the wakeup for the display word task
	m_task_wakeup &= ~(1 << m_task);
	LOG((this,LOG_DWT,2,"    BLOCK %s\n", task_name(m_task)));

	// Wakeup the display horizontal task, if it didn't block itself
	if (!m_dsp.dht_blocks)
		m_task_wakeup |= 1 << task_dht;
}

/**
 * @brief Load the display data register
 * Pushes the word on the bus to the display FIFO.
 * If the FIFO becomes full, the wakeup flag for task_dwt is reset.
 */
void alto2_cpu_device::f2_late_load_ddr()
{
	LOG((this,LOG_DWT,2,"    DDR<- BUS (%#o)\n", m_bus));
	m_dsp.fifo[m_dsp.wa] = m_bus;
	m_dsp.wa = (m_dsp.wa + 1) % A2_DISP_FIFO;
	uint8_t a38 = m_disp_a38[m_dsp.ra * 16 + m_dsp.wa];
	if (FIFO_STOPWAKE(a38))
		m_task_wakeup &= ~(1 << task_dwt);
	LOG((this,LOG_DWT,2, "   DWT push %04x into FIFO[%02o]%s\n",
		m_bus, (m_dsp.wa - 1) & (A2_DISP_FIFO - 1),
		FIFO_STOPWAKE(a38) ? " STOPWAKE" : ""));
}

void alto2_cpu_device::init_dwt(int task)
{
}

void alto2_cpu_device::exit_dwt()
{
	// nothing to do yet
}

void alto2_cpu_device::reset_dwt()
{
	m_dsp.dwt_blocks = false;
	memset(m_dsp.fifo, 0, sizeof(m_dsp.fifo));
	m_dsp.wa = 0;
	m_dsp.ra = 0;
}