|
| 1 | +#pragma once |
| 2 | + |
| 3 | +// Copyright 2015 by Joseph Forgion |
| 4 | +// This file is part of VCC (Virtual Color Computer). |
| 5 | +// |
| 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 |
| 26 | +// |
| 27 | +static inline bool CC(char flag) |
| 28 | +{ |
| 29 | + return cc[flag] ? true : false; |
| 30 | +} |
| 31 | + |
| 32 | +// |
| 33 | +// Interrupt lines reading from output of the latch |
| 34 | +// |
| 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; } |
| 38 | + |
| 39 | +// |
| 40 | +// Latch the interrupt lines |
| 41 | +// This done per instruction top of state A (see figure 15, 6809 spec) and also waiting in SYNC |
| 42 | +// |
| 43 | +static inline void LatchInterrupts() |
| 44 | +{ |
| 45 | + uint8_t OR = 0; |
| 46 | + for (int is = 0; is < IS_MAX; ++is) |
| 47 | + OR |= InterruptLine[is]; |
| 48 | + |
| 49 | + // clock next input |
| 50 | + InterruptLatch.Clock(OR); |
| 51 | +} |
| 52 | + |
| 53 | +// |
| 54 | +// Clear the nmi interrupt |
| 55 | +// |
| 56 | +static inline void ClearNMI() |
| 57 | +{ |
| 58 | + InterruptLine[IS_NMI] &= BitMask(INT_NMI); |
| 59 | + LatchInterrupts(); |
| 60 | +} |
| 61 | + |
| 62 | +// |
| 63 | +// Clear state of all interrupt lines |
| 64 | +// |
| 65 | +static inline void ClearInterrupts() |
| 66 | +{ |
| 67 | + for (int is = 0; is < IS_MAX; ++is) |
| 68 | + InterruptLine[is] = 0; |
| 69 | + InterruptLatch.Reset(); |
| 70 | +} |
| 71 | + |
0 commit comments