| Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
| Refresh |
|
| 1.0;1 |
| 1 | /* |
|
| 2 | * Refresh.java |
|
| 3 | * |
|
| 4 | * This file is part of JavaGear. |
|
| 5 | * |
|
| 6 | * JavaGear is free software; you can redistribute it and/or modify |
|
| 7 | * it under the terms of the GNU General Public License as published by |
|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|
| 9 | * (at your option) any later version. |
|
| 10 | * |
|
| 11 | * JavaGear is distributed in the hope that it will be useful, |
|
| 12 | * 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 |
|
| 17 | * along with JavaGear; if not, write to the Free Software |
|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 19 | */ |
|
| 20 | ||
| 21 | package uk.co.javagear; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * Zilog Z80 CPU refresh register emulation. |
|
| 25 | * |
|
| 26 | * @author Copyright (C) 2002-2003 Chris White |
|
| 27 | * @version 18th January 2003 |
|
| 28 | * @see "JavaGear Final Project Report" |
|
| 29 | */ |
|
| 30 | public final class Refresh { |
|
| 31 | ||
| 32 | private int reg; |
|
| 33 | ||
| 34 | private int temp; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Refresh Register Constructor. |
|
| 38 | */ |
|
| 39 | 0 | public Refresh() { |
| 40 | 0 | reg = 0; |
| 41 | 0 | } |
| 42 | ||
| 43 | /** |
|
| 44 | * Clear register. |
|
| 45 | */ |
|
| 46 | public void clear() { |
|
| 47 | 0 | reg = 0; |
| 48 | 0 | } |
| 49 | ||
| 50 | /** |
|
| 51 | * Get value of refresh register. |
|
| 52 | * |
|
| 53 | * @return value stored in flag register. |
|
| 54 | */ |
|
| 55 | public int get() { |
|
| 56 | 0 | return reg; |
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Set refresh register. |
|
| 61 | * |
|
| 62 | * @param r value to set register (0 - 0xFF). |
|
| 63 | */ |
|
| 64 | public void set(int r) { |
|
| 65 | 0 | reg = r & 0xFF; |
| 66 | 0 | } |
| 67 | ||
| 68 | ||
| 69 | /** |
|
| 70 | * Increment refresh register. |
|
| 71 | */ |
|
| 72 | public void inc() { |
|
| 73 | // Increment lower 6 bits |
|
| 74 | // Preserve original 'bit 7' |
|
| 75 | 0 | reg = (reg & 0x80) | ((reg + 1) & 0x7F); |
| 76 | 0 | } |
| 77 | ||
| 78 | } |