示例#1
0
文件: Memory.java 项目: Osmose/sno
  protected int readHWReg(Size size, int addr) {
    int reg = addr - 0x2000;
    if (mmap[reg] == null) {
      // Log.err(String.format("Read Memory Mapped register 0x%04x not implemented.", addr));
      if (Settings.get(Settings.MEM_THROW_INVALID_ADDR).equals("true"))
        throw new RuntimeException(
            String.format("Read Memory Mapped register 0x%04x not implemented.", addr));
      return 0;
    }
    if (size == Size.SHORT) {
      if (mmap[reg + 1] == null) {
        // mmap[addr-0x2000] = new UnimplementedHardwareRegister();
        // Log.err(String.format("Read Memory Mapped register 0x%04x not implemented.", addr+1));
        if (Settings.get(Settings.MEM_THROW_INVALID_ADDR).equals("true"))
          throw new RuntimeException(
              String.format("Read Memory Mapped register 0x%04x not implemented.", addr + 1));
        return 0;
      }

      // LOW ALWAYS GOES FIRST
      int val = mmap[reg].getValue();
      val |= mmap[reg + 1].getValue() << 8;
      return val;
    } else {
      return mmap[reg].getValue();
    }
  }
示例#2
0
文件: Memory.java 项目: Osmose/sno
  protected void writeHWReg(Size size, int addr, int value) {
    int reg = addr - 0x2000;

    if (mmap[reg] == null) {
      mmap[reg] = new UnimplementedHardwareRegister();
      Log.err(String.format("Write Memory Mapped register 0x%04x not implemented.", addr));
      if (Settings.get(Settings.MEM_THROW_INVALID_ADDR).equals("true"))
        throw new RuntimeException(
            String.format("Write Memory Mapped register 0x%04x not implemented.", addr));
    }

    if (size == Size.SHORT) {
      if (mmap[reg + 1] == null) {
        mmap[reg + 1] = new UnimplementedHardwareRegister();
        Log.err(String.format("Write Memory Mapped register 0x%04x not implemented.", addr + 1));
        if (Settings.get(Settings.MEM_THROW_INVALID_ADDR).equals("true"))
          throw new RuntimeException(
              String.format("Write Memory Mapped register 0x%04x not implemented.", addr + 1));
      }

      /*
       * Low goes first unless you want games to look like they're being
       * played through Kanye's shutter shades.
       */
      mmap[reg].setValue(value & 0x00FF);
      mmap[reg + 1].setValue((value & 0xFF00) >> 8);
    } else {
      mmap[reg].setValue(value);
    }
  }
示例#3
0
文件: Memory.java 项目: Osmose/sno
 public void dumpWRAM() {
   if (Settings.get(Settings.DEBUG_DIR) != null) {
     try {
       String fname = Settings.get(Settings.DEBUG_DIR) + "/wram.bin";
       FileOutputStream fos = new FileOutputStream(fname);
       for (int i = 0; i < wram.length; i++) fos.write(wram[i]);
       fos.close();
     } catch (IOException e) {
       System.out.println("Unable to dump wram");
       e.printStackTrace();
     }
   }
 }
示例#4
0
文件: Core.java 项目: Osmose/sno
  public static void run(InputStream is, boolean isZip) throws Exception {
    init(is, isZip);
    instCount = 0;
    maxInstructions = Long.parseLong(Settings.get(Settings.CORE_MAX_INSTRUCTIONS));

    // Load save file if found
    if (Settings.isSet(Settings.SAVE_PATH)) {
      InputStream saveStream = Util.getStreamFromUrl(Settings.get(Settings.SAVE_PATH));
      if (saveStream != null) {
        mem.loadSram(saveStream);
      }
    }

    // Execute and time game
    if (Log.instruction.enabled() && Settings.get(Settings.CPU_ALT_DEBUG) == "false") {
      Log.instruction("====CPU Execution====");
      Log.instruction(
          "romAdr pbr:pc   op   CPU Status                      args              Instruction");
      Log.instruction(
          "------ -------  --   ------------------------------- ---------------   -----------");
    }
    timeBegin = new Date().getTime();
    cycle(maxInstructions);
    timeEnd = new Date().getTime();
    running = false;

    // Print run stats
    System.out.println("Total time: " + ((timeEnd - timeBegin) / 1000) + " seconds");
    System.out.println("Instructions performed: " + instCount);
    System.out.println("Cycles performed: " + Timing.getCycles());
    System.out.println(
        "Average speed: "
            + (((Timing.getCycles() + 0f) / ((timeEnd - timeBegin + 0f) / 1000f)) / (1024f * 1024f))
            + " MHz");
    System.out.println(
        "Average speed: "
            + (((Timing.getCycles() + 0f) / ((timeEnd - timeBegin + 0f) / 1000f)))
            + " Hz");
    printMMaps();

    PPU.dumpVRAM();
    mem.dumpWRAM();
    APUMemory.dump();
    renderScreen();
  }
示例#5
0
文件: SNOApplet.java 项目: Osmose/sno
  /**
   * Checks if a ROM url has been specified by an applet tag or in the properties file. If so, loads
   * and starts the rom
   */
  private void checkForGame() {
    String loc = Settings.get(Settings.ROM_URL);
    if (loc != null) {
      System.out.println("Loading from url: " + loc);

      // Attempt to load from url
      InputStream is = Util.getStreamFromUrl(loc);
      boolean isZip = loc.endsWith(".zip");

      if (is != null) {
        runGame(is, isZip);
      }
    }
  }