Пример #1
0
 public PPU(final Mapper mapper) {
   this.mapper = mapper;
   fill(OAM, 0xff);
   if (PPUDEBUG) {
     nametableView = new BufferedImage(512, 480, TYPE_INT_BGR);
     debuggui = new DebugUI(512, 480);
     debuggui.run();
   }
   setParameters();
 }
Пример #2
0
  /** draw all 4 nametables/tileset/pallette to debug window. (for the nametable viewer) */
  private void debugDraw() {
    for (int i = 0; i < 32; ++i) {
      for (int j = 0; j < 30; ++j) {
        nametableView.setRGB(
            i * 8,
            j * 8,
            8,
            8,
            debugGetTile(mapper.ppuRead(0x2000 + i + 32 * j) * 16 + (bgpattern ? 0x1000 : 0)),
            0,
            8);
      }
    }
    for (int i = 0; i < 32; ++i) {
      for (int j = 0; j < 30; ++j) {
        nametableView.setRGB(
            i * 8 + 255,
            j * 8,
            8,
            8,
            debugGetTile(mapper.ppuRead(0x2400 + i + 32 * j) * 16 + (bgpattern ? 0x1000 : 0)),
            0,
            8);
      }
    }
    for (int i = 0; i < 32; ++i) {
      for (int j = 0; j < 30; ++j) {
        nametableView.setRGB(
            i * 8,
            j * 8 + 239,
            8,
            8,
            debugGetTile(mapper.ppuRead(0x2800 + i + 32 * j) * 16 + (bgpattern ? 0x1000 : 0)),
            0,
            8);
      }
    }
    for (int i = 0; i < 32; ++i) {
      for (int j = 0; j < 30; ++j) {
        nametableView.setRGB(
            i * 8 + 255,
            j * 8 + 239,
            8,
            8,
            debugGetTile(mapper.ppuRead(0x2C00 + i + 32 * j) * 16 + (bgpattern ? 0x1000 : 0)),
            0,
            8);
      }
    }

    // draw the tileset
    //        for (int i = 0; i < 16; ++i) {
    //            for (int j = 0; j < 32; ++j) {
    //                nametableView.setRGB(i * 8, j * 8, 8, 8,
    //                        debugGetTile((i + 16 * j) * 16), 0, 8);
    //            }
    //        }
    // draw the palettes on the bottom.
    //        for (int i = 0; i < 32; ++i) {
    //            for (int j = 0; j < 16; ++j) {
    //                for (int k = 0; k < 16; ++k) {
    //                    nametableView.setRGB(j + i * 16, k + 256, nescolor[0][pal[i]]);
    //                }
    //            }
    //        }
    debuggui.setFrame(nametableView);
    // debugbuff.clear();
  }