|
1 | 1 | #pragma once |
2 | 2 |
|
| 3 | +// Copyright 2015 by Joseph Forgion |
| 4 | +// This file is part of VCC (Virtual Color Computer). |
3 | 5 | // |
4 | | -// access cc flags |
| 6 | +// VCC (Virtual Color Computer) is free software: you can redistribute it and/or |
| 7 | +// modify it under the terms of the GNU General Public License as published by |
| 8 | +// the Free Software Foundation, either version 3 of the License, or |
| 9 | +// (at your option) any later version. |
| 10 | +// |
| 11 | +// VCC (Virtual Color Computer) is distributed in the hope that it will be |
| 12 | +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +// GNU General Public License for more details. |
| 15 | +// |
| 16 | +// You should have received a copy of the GNU General Public License along |
| 17 | +// with VCC. If not, see <http://www.gnu.org/licenses/>. |
| 18 | +// |
| 19 | +// 2025/05/22 - Craig Allsop - Interrupt handling. |
| 20 | +// |
| 21 | + |
| 22 | +// no includes here, included by 6809.c, 6309.c |
| 23 | + |
| 24 | +// |
| 25 | +// Access cc flags as boolean |
5 | 26 | // |
6 | 27 | static inline bool CC(char flag) |
7 | 28 | { |
8 | 29 | return cc[flag] ? true : false; |
9 | 30 | } |
10 | 31 |
|
11 | 32 | // |
12 | | -// interrupt lines (active low) |
| 33 | +// Interrupt lines reading from output of the latch |
13 | 34 | // |
14 | | -static inline bool FIRQ() { return InterruptLatch & Bit(INT_FIRQ) ? true : false; } |
15 | | -static inline bool IRQ() { return InterruptLatch & Bit(INT_IRQ) ? true : false; } |
16 | | -static inline bool NMI() { return InterruptLatch & Bit(INT_NMI) ? true : false; } |
| 35 | +static inline bool FIRQ() { return InterruptLatch.Q & Bit(INT_FIRQ) ? true : false; } |
| 36 | +static inline bool IRQ() { return InterruptLatch.Q & Bit(INT_IRQ) ? true : false; } |
| 37 | +static inline bool NMI() { return InterruptLatch.Q & Bit(INT_NMI) ? true : false; } |
17 | 38 |
|
18 | 39 | // |
19 | | -// latch the interrupt lines, done per instruction top of state A (see figure 15, 6809 spec) |
| 40 | +// Latch the interrupt lines |
| 41 | +// This done per instruction top of state A (see figure 15, 6809 spec) and also waiting in SYNC |
20 | 42 | // |
21 | 43 | static inline void LatchInterrupts() |
22 | 44 | { |
23 | | - InterruptLatch = 0; |
| 45 | + uint8_t OR = 0; |
24 | 46 | for (int is = 0; is < IS_MAX; ++is) |
25 | | - InterruptLatch |= InterruptLine[is]; |
| 47 | + OR |= InterruptLine[is]; |
| 48 | + |
| 49 | + // clock next input |
| 50 | + InterruptLatch.Clock(OR); |
26 | 51 | } |
27 | 52 |
|
28 | 53 | // |
29 | | -// clear the nmi interrupt |
| 54 | +// Clear the nmi interrupt |
30 | 55 | // |
31 | 56 | static inline void ClearNMI() |
32 | 57 | { |
33 | 58 | InterruptLine[IS_NMI] &= BitMask(INT_NMI); |
| 59 | + LatchInterrupts(); |
34 | 60 | } |
35 | 61 |
|
36 | 62 | // |
37 | | -// clear state of all interrupt lines |
38 | | -// |
39 | | -static inline void ClearInterrupt(Interrupt interrupt) |
40 | | -{ |
41 | | - for (int is = 0; is < IS_MAX; ++is) |
42 | | - InterruptLine[is] &= BitMask(interrupt); |
43 | | -} |
44 | | - |
45 | | -// |
46 | | -// clear state of all interrupt lines |
| 63 | +// Clear state of all interrupt lines |
47 | 64 | // |
48 | 65 | static inline void ClearInterrupts() |
49 | 66 | { |
50 | | - InterruptLatch = 0; |
51 | 67 | for (int is = 0; is < IS_MAX; ++is) |
52 | 68 | InterruptLine[is] = 0; |
| 69 | + InterruptLatch.Reset(); |
53 | 70 | } |
54 | 71 |
|
0 commit comments