xeij/Malfunction.java
//========================================================================================
//  Malfunction.java
//    en:Malfunction reproduction
//    ja:故障再現
//  Copyright (C) 2003-2026 Makoto Kamada
//
//  This file is part of the XEiJ (X68000 Emulator in Java).
//  You can use, modify and redistribute the XEiJ if the conditions are met.
//  Read the XEiJ License for more details.
//  https://stdkmd.net/xeij/
//========================================================================================

package xeij;

class Malfunction {

  public static final boolean MLF_ON = false;

  //mlfRaster (dataY)
  //  TVRAMのプレーン0のbit15-12を担当するマルチポートRAM(XVIで言うとIC56)のデータを暴れさせる
  //  drawRaster (dataY, screenY, false)の直前に呼び出す
  public static void mlfRaster (int dataY) {
    int my = (CRTC.crtR11TxYZero + dataY) & 1023;  //メモリY座標
    final int ba = 0x00e00000 + (0 << 17);  //ベースアドレス。プレーン0
    int sa = ba + 128 * my;  //開始アドレス
    int ea = sa + 128;  //終了アドレス
    for (int a = sa; a < ea; a += 2) {
      MainMemory.mmrM8[a] = (byte) (((random () >>> 24) & 0xf0) |  //bit15-12をノイズに
                                    (MainMemory.mmrM8[a] & 0x0f));  //bit11-8はそのまま
    }
  }  //mlfRaster

  private static int x = 123456789;
  private static int y = 362436069;
  private static int z = 521288629;
  private static int w = 88675123;
  private static int random () {
    int t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    return w = (w ^ (w >>> 19)) ^ (t ^ (t >>> 8));
  }  //random

}  //class Malfunction