1 /*
2 * KCemu -- The emulator for the KC85 homecomputer series and much more.
3 * Copyright (C) 1997-2010 Torsten Paul
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "kc/system.h"
21
22 #include "kc/daisy.h"
23
24 #include "libdbg/dbg.h"
25
DaisyChain(void)26 DaisyChain::DaisyChain(void)
27 {
28 }
29
~DaisyChain(void)30 DaisyChain::~DaisyChain(void)
31 {
32 }
33
34 void
add_last(InterfaceCircuit * ic)35 DaisyChain::add_last(InterfaceCircuit *ic)
36 {
37 if (_daisy_chain_list.empty())
38 {
39 ic->iei(1);
40 }
41 else
42 {
43 InterfaceCircuit *last = _daisy_chain_list.back();
44 last->next(ic);
45 }
46
47 ic->next(0);
48 _daisy_chain_list.push_back(ic);
49
50 //printf("------- DaisyChain::add_last(): '%s'\n", ic->get_ic_name());
51 //_daisy_chain_list.front()->debug();
52 }
53
54 void
remove(InterfaceCircuit * ic)55 DaisyChain::remove(InterfaceCircuit *ic)
56 {
57 _daisy_chain_list.remove(ic);
58
59 InterfaceCircuit *prev = ic->get_prev();
60 InterfaceCircuit *next = ic->get_next();
61
62 if (prev != NULL)
63 prev->next(ic->get_next());
64 else if (next != NULL)
65 next->prev(0);
66
67 //printf("------- DaisyChain::remove(): '%s'\n", ic->get_ic_name());
68 //_daisy_chain_list.front()->debug();
69 }
70
71 word_t
irq_ack(void)72 DaisyChain::irq_ack(void)
73 {
74 if (_daisy_chain_list.empty())
75 return IRQ_NOT_ACK;
76
77 //_daisy_chain_first->debug();
78 word_t val = _daisy_chain_list.back()->ack();
79 //_daisy_chain_first->debug();
80 //sleep(1);
81 return val;
82 }
83
84 void
reti(void)85 DaisyChain::reti(void)
86 {
87 if (_daisy_chain_list.empty())
88 return;
89
90 _daisy_chain_list.back()->reti_ED();
91 _daisy_chain_list.back()->reti_4D();
92 }
93
94