| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| Setup |
|
| 0.0;0 |
| 1 | /* |
|
| 2 | * Setup.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 | * Global system settings. |
|
| 25 | * |
|
| 26 | * @author Copyright (C) 2002 Chris White |
|
| 27 | * @version 17th March 2002 |
|
| 28 | * @see "JavaGear Final Project Report" |
|
| 29 | */ |
|
| 30 | public final class Setup { |
|
| 31 | ||
| 32 | /** |
|
| 33 | * The different kinds of systems for which ROMs can be read. |
|
| 34 | */ |
|
| 35 | 0 | public enum System { |
| 36 | ||
| 37 | /** |
|
| 38 | * SEGA Master System. |
|
| 39 | */ |
|
| 40 | 0 | SMS("SEGA Master System", "sms"), |
| 41 | ||
| 42 | /** |
|
| 43 | * SEGA Game Gear. |
|
| 44 | */ |
|
| 45 | 0 | GG("SEGA Game Gear", "gg"); |
| 46 | ||
| 47 | /** |
|
| 48 | * The <code>System</code>'s full name. |
|
| 49 | */ |
|
| 50 | private final String name; |
|
| 51 | ||
| 52 | /** |
|
| 53 | * The <code>System</code>'s ROM file extension. |
|
| 54 | */ |
|
| 55 | private final String romFileExtension; |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Constructor used for each of the elements of the enumeration. |
|
| 59 | * |
|
| 60 | * @param name the system's full name. |
|
| 61 | * @param romFileExtension the extension of the files containing ROM |
|
| 62 | * data for the system. |
|
| 63 | */ |
|
| 64 | 0 | System(String name, String romFileExtension) { |
| 65 | 0 | this.name = name; |
| 66 | 0 | this.romFileExtension = romFileExtension; |
| 67 | 0 | } |
| 68 | ||
| 69 | /** |
|
| 70 | * Returns the <code>System</code>'s full name. |
|
| 71 | * |
|
| 72 | * @return the <code>System</code>'s full name. |
|
| 73 | */ |
|
| 74 | public String getName() { |
|
| 75 | 0 | return name; |
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * Returns the <code>System</code>'s ROM file extension. |
|
| 80 | * |
|
| 81 | * @return the <code>System</code>'s ROM file extension. |
|
| 82 | */ |
|
| 83 | public String getRomFileExtension() { |
|
| 84 | 0 | return romFileExtension; |
| 85 | } |
|
| 86 | }; |
|
| 87 | ||
| 88 | /** |
|
| 89 | * The extension Zip files containing SMS or GG ROMs should have. |
|
| 90 | */ |
|
| 91 | public static final String ZIP_FILE_EXTENSION = "zip"; |
|
| 92 | ||
| 93 | /** |
|
| 94 | * SMS Screen Width. |
|
| 95 | */ |
|
| 96 | public static final int SMS_WIDTH = 256; |
|
| 97 | ||
| 98 | /** |
|
| 99 | * SMS Screen Height. |
|
| 100 | */ |
|
| 101 | public static final int SMS_HEIGHT = 192; |
|
| 102 | ||
| 103 | /** |
|
| 104 | * GG Screen Width. |
|
| 105 | */ |
|
| 106 | public static final int GG_WIDTH = 160; |
|
| 107 | ||
| 108 | /** |
|
| 109 | * GG Screen Height. |
|
| 110 | */ |
|
| 111 | public static final int GG_HEIGHT = 144; |
|
| 112 | ||
| 113 | /** |
|
| 114 | * GG Window Starts Here (x). |
|
| 115 | */ |
|
| 116 | public static final int GG_X_OFFSET = 48; |
|
| 117 | ||
| 118 | /** |
|
| 119 | * GG Window Starts Here (y). |
|
| 120 | */ |
|
| 121 | public static final int GG_Y_OFFSET = 24; |
|
| 122 | ||
| 123 | /** |
|
| 124 | * The system being emulated. |
|
| 125 | */ |
|
| 126 | 0 | private Setup.System system = Setup.System.SMS; |
| 127 | ||
| 128 | /** |
|
| 129 | * SMS Mode. |
|
| 130 | */ |
|
| 131 | 0 | private boolean smsModeActive = true; |
| 132 | ||
| 133 | /** |
|
| 134 | * GG Mode. |
|
| 135 | */ |
|
| 136 | 0 | private boolean ggModeActive = false; |
| 137 | ||
| 138 | /** |
|
| 139 | * Horizontal Viewport Start. |
|
| 140 | */ |
|
| 141 | 0 | private int hStart = 0; |
| 142 | ||
| 143 | /** |
|
| 144 | * Horizontal Viewport End. |
|
| 145 | */ |
|
| 146 | 0 | private int hEnd = SMS_WIDTH; |
| 147 | ||
| 148 | /** |
|
| 149 | * Vertical Viewport Start. |
|
| 150 | */ |
|
| 151 | 0 | private int vStart = 0; |
| 152 | ||
| 153 | /** |
|
| 154 | * Vertical Viewport End. |
|
| 155 | */ |
|
| 156 | 0 | private int vEnd = SMS_HEIGHT; |
| 157 | ||
| 158 | /** |
|
| 159 | * Horizontal Viewport Start (Scaled Mode). |
|
| 160 | */ |
|
| 161 | 0 | private int hStartScaled = 0; |
| 162 | ||
| 163 | /** |
|
| 164 | * Vertical Viewport Start (Scaled Mode). |
|
| 165 | */ |
|
| 166 | 0 | private int vStartScaled = 0; |
| 167 | ||
| 168 | /** |
|
| 169 | * Horizontal Viewport End (Scaled Mode). |
|
| 170 | */ |
|
| 171 | 0 | private int hEndScaled = SMS_WIDTH; |
| 172 | ||
| 173 | /** |
|
| 174 | * Vertical Viewport End (Scaled Mode). |
|
| 175 | */ |
|
| 176 | 0 | private int vEndScaled = SMS_HEIGHT; |
| 177 | ||
| 178 | /** |
|
| 179 | * Horizontal Viewport End (Scaled Game Gear Mode). |
|
| 180 | */ |
|
| 181 | 0 | private int hEndScaledGG = 0; |
| 182 | ||
| 183 | /** |
|
| 184 | * Vertical Viewport End (Scaled Game Gear Mode). |
|
| 185 | */ |
|
| 186 | 0 | private int vEndScaledGG = 0; |
| 187 | ||
| 188 | /** |
|
| 189 | * The viewport's scale. |
|
| 190 | */ |
|
| 191 | private int scale; |
|
| 192 | ||
| 193 | /** |
|
| 194 | * SMS Pause Button. |
|
| 195 | */ |
|
| 196 | private boolean pauseButton; |
|
| 197 | ||
| 198 | ||
| 199 | /** |
|
| 200 | * Setup. Constructor. |
|
| 201 | * |
|
| 202 | * Default to Screen Size 1. |
|
| 203 | */ |
|
| 204 | 0 | public Setup() { |
| 205 | 0 | scale = 1; |
| 206 | 0 | setScreenSize(scale); |
| 207 | 0 | } |
| 208 | ||
| 209 | /** |
|
| 210 | * Getter for property system. Returns the kind of system being emulated. |
|
| 211 | * |
|
| 212 | * @return value of property system. The kind of system being emulated. |
|
| 213 | */ |
|
| 214 | public Setup.System getSystem() { |
|
| 215 | 0 | return this.system; |
| 216 | } |
|
| 217 | ||
| 218 | /** |
|
| 219 | * Setter for property system. Sets the kind of system to emulate. |
|
| 220 | * |
|
| 221 | * @param system New value of property system. |
|
| 222 | * @throws IllegalArgumentException if system is neither System.SMS nor System.GG |
|
| 223 | */ |
|
| 224 | public void setSystem(Setup.System system) throws IllegalArgumentException { |
|
| 225 | 0 | switch (system) { |
| 226 | case SMS: |
|
| 227 | // SMS uses 256x192 window (32x28) |
|
| 228 | 0 | hStart = 0; |
| 229 | 0 | hEnd = SMS_WIDTH; |
| 230 | 0 | vStart = 0; |
| 231 | 0 | vEnd = SMS_HEIGHT; |
| 232 | 0 | break; |
| 233 | case GG: |
|
| 234 | //h_start = 40; // should be 48 ie 6, but due to wierd hscroll code has to be 8 less |
|
| 235 | 0 | hStart = 40; |
| 236 | 0 | hEnd = GG_WIDTH + GG_X_OFFSET; |
| 237 | ||
| 238 | 0 | vStart = GG_Y_OFFSET; |
| 239 | 0 | vEnd = GG_HEIGHT + GG_Y_OFFSET; |
| 240 | 0 | break; |
| 241 | default: |
|
| 242 | 0 | throw new IllegalArgumentException("Invalid system: " + system); |
| 243 | } |
|
| 244 | 0 | this.system = system; |
| 245 | 0 | } |
| 246 | ||
| 247 | /** |
|
| 248 | * Return the horizontal viewport start. |
|
| 249 | * |
|
| 250 | * @return the horizontal viewport start. |
|
| 251 | */ |
|
| 252 | public int getHStart() { |
|
| 253 | 0 | return hStart; |
| 254 | } |
|
| 255 | ||
| 256 | /** |
|
| 257 | * Return the horizontal viewport end. |
|
| 258 | * |
|
| 259 | * @return the horizontal viewport end. |
|
| 260 | */ |
|
| 261 | public int getHEnd() { |
|
| 262 | 0 | return hEnd; |
| 263 | } |
|
| 264 | ||
| 265 | /** |
|
| 266 | * Return the vertical viewport start. |
|
| 267 | * |
|
| 268 | * @return the vertical viewport start. |
|
| 269 | */ |
|
| 270 | public int getVStart() { |
|
| 271 | 0 | return vStart; |
| 272 | } |
|
| 273 | ||
| 274 | /** |
|
| 275 | * Return the vertical viewport end. |
|
| 276 | * |
|
| 277 | * @return the vertical viewport end. |
|
| 278 | */ |
|
| 279 | public int getVEnd() { |
|
| 280 | 0 | return vEnd; |
| 281 | } |
|
| 282 | ||
| 283 | /** |
|
| 284 | * Return the horizontal viewport start (scaled mode). |
|
| 285 | * |
|
| 286 | * @return the horizontal viewport start (scaled mode). |
|
| 287 | */ |
|
| 288 | public int getHStartScaled() { |
|
| 289 | 0 | return hStartScaled; |
| 290 | } |
|
| 291 | ||
| 292 | /** |
|
| 293 | * Return the vertical viewport start (scaled mode). |
|
| 294 | * |
|
| 295 | * @return the vertical viewport start (scaled mode). |
|
| 296 | */ |
|
| 297 | public int getVStartScaled() { |
|
| 298 | 0 | return vStartScaled; |
| 299 | } |
|
| 300 | ||
| 301 | /** |
|
| 302 | * Return the horizontal viewport end (scaled mode). |
|
| 303 | * |
|
| 304 | * @return the horizontal viewport end (scaled mode). |
|
| 305 | */ |
|
| 306 | public int getHEndScaled() { |
|
| 307 | 0 | return hEndScaled; |
| 308 | } |
|
| 309 | ||
| 310 | /** |
|
| 311 | * Return the vertical viewport end (scaled mode). |
|
| 312 | * |
|
| 313 | * @return the vertical viewport end (scaled mode). |
|
| 314 | */ |
|
| 315 | public int getVEndScaled() { |
|
| 316 | 0 | return vEndScaled; |
| 317 | } |
|
| 318 | ||
| 319 | /** |
|
| 320 | * Return the horizontal viewport end (scaled Game Gear mode). |
|
| 321 | * |
|
| 322 | * @return the horozontal viewport end (scaled Game Gear mode). |
|
| 323 | */ |
|
| 324 | public int getHEndScaledGG() { |
|
| 325 | 0 | return hEndScaledGG; |
| 326 | } |
|
| 327 | ||
| 328 | /** |
|
| 329 | * Return the vertical viewport end (scaled Game Gear mode). |
|
| 330 | * |
|
| 331 | * @return the vertical viewport end (scaled Game Gear mode). |
|
| 332 | */ |
|
| 333 | public int getVEndScaledGG() { |
|
| 334 | 0 | return vEndScaledGG; |
| 335 | } |
|
| 336 | ||
| 337 | /** |
|
| 338 | * Return the viewport's scale. |
|
| 339 | * |
|
| 340 | * @return the viewport's scale. |
|
| 341 | */ |
|
| 342 | public int getScale() { |
|
| 343 | 0 | return scale; |
| 344 | } |
|
| 345 | ||
| 346 | /** |
|
| 347 | * Returns <code>true</code> if the SMS is paused and <code>false</code> otherwise. |
|
| 348 | * |
|
| 349 | * @return <code>true</code> if the SMS is paused and <code>false</code> otherwise. |
|
| 350 | */ |
|
| 351 | public boolean isPauseButton() { |
|
| 352 | 0 | return pauseButton; |
| 353 | } |
|
| 354 | ||
| 355 | /** |
|
| 356 | * Set if the SMS is paused. |
|
| 357 | * |
|
| 358 | * @param pause <code>true</code> to pause the SMS, <code>false</code> otherwise. |
|
| 359 | */ |
|
| 360 | public void setPauseButton(boolean pause) { |
|
| 361 | 0 | this.pauseButton = pause; |
| 362 | 0 | } |
| 363 | ||
| 364 | /** |
|
| 365 | * Set Screen Size. |
|
| 366 | * |
|
| 367 | * @param s Screen Size will be (normal * s) |
|
| 368 | */ |
|
| 369 | public void setScreenSize(int s) { |
|
| 370 | 0 | scale = s; |
| 371 | 0 | hEndScaled = SMS_WIDTH * scale; |
| 372 | 0 | vEndScaled = SMS_HEIGHT * scale; |
| 373 | ||
| 374 | 0 | hStartScaled = GG_X_OFFSET * scale; |
| 375 | 0 | vStartScaled = GG_Y_OFFSET * scale; |
| 376 | ||
| 377 | 0 | hEndScaledGG = (GG_WIDTH + GG_X_OFFSET) * scale; |
| 378 | 0 | vEndScaledGG = (GG_HEIGHT + GG_Y_OFFSET) * scale; |
| 379 | 0 | } |
| 380 | ||
| 381 | } |