JSFiddle - React, Tailwind, and code Playground
by electronoob
HTML
<canvas id="lcd" width=160px height=140px></canvas>
<div id="memory"></div>
CSS
div {
white-space: pre-wrap;
word-wrap: break-word;
}
div#memory {
width: 800px;
font-size: 8px;
}
canvas#lcd {
width: 640px;
height: 576px;
image-rendering: optimizeSpeed;
image-rendering: -moz-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
image-rendering: pixelated;
background-color: #004400;
border: 1px solid #000;
}
JavaScript
var buffer_vram = new ArrayBuffer(0x1fff);
var vram = new DataView(buffer_vram);
var buffer_oam = new ArrayBuffer(40*4);
var oam = new DataView(buffermem_vram);
function gbhw () {
this._HW = 0xFF00;
this._VRAM = 0x8000;
this._SCRN0 = 0x9800;
this._SCRN1 = 0x9C00;
this._RAM = 0xC000;
this._HRAM = 0xF800;
this._OAMRAM = 0xFE00;
this._AUD3WAVERAM = 0xFF30;
this.OAMF_PRI = 0b10000000;
this.OAMF_YFLIP = 0b01000000;
this.OAMF_XFLIP = 0b00100000;
this.OAMF_PAL0 = 0b00000000;
this.OAMF_PAL1 = 0b00010000;
this.rP1 = 0xFF00;
this.P1F_5 = 0b00100000;
this.P1F_4 = 0b00010000;
this.P1F_3 = 0b00001000;
this.P1F_2 = 0b00000100;
this.P1F_1 = 0b00000010;
this.P1F_0 = 0b00000001;
this.rLCDC = 0xFF40;
this.LCDCF_OFF = 0b00000000;
this.LCDCF_ON = 0b10000000;
this.LCDCF_WIN9800 = 0b00000000;
this.LCDCF_WIN9C00 = 0b01000000;
this.LCDCF_WINOFF = 0b00000000;
this.LCDCF_WINON = 0b00100000;
this.LCDCF_BG8800 = 0b00000000;
this.LCDCF_BG8000 = 0b00010000;
this.LCDCF_BG9800 = 0b00000000;
this.LCDCF_BG9C00 = 0b00001000;
this.LCDCF_OBJ8 = 0b00000000;
this.LCDCF_OBJ16 = 0b00000100;
this.LCDCF_OBJOFF = 0b00000000;
this.LCDCF_OBJON = 0b00000010;
this.LCDCF_BGOFF = 0b00000000;
this.LCDCF_BGON = 0b00000001;
this.rSTAT = 0xFF41;
this.STATF_LYC = 0b01000000;
this.STATF_MODE10 = 0b00100000;
this.STATF_MODE01 = 0b00010000;
this.STATF_MODE00 = 0b00001000;
this.STATF_LYCF = 0b00000100;
this.STATF_HB = 0b00000000;
this.STATF_VB = 0b00000001;
this.STATF_OAM = 0b00000010;
this.STATF_LCD = 0b00000011;
this.STATF_BUSY = 0b00000010;
this.rSCY = 0xFF42;
this.rSCX = 0xFF43;
this.rLY = 0xFF44;
this.rLYC = 0xFF45;
this.rDMA = 0xFF46;
this.rBGP = 0xFF47;
this.rOBP0 = 0xFF48;
this.rOBP1 = 0xFF49;
this.rSB = 0xFF01;
this.rSC = 0xFF02;
this.rDIV = 0xFF04;
this.rTIMA = 0xFF05;
this.rTMA = 0xFF06;
this.rTAC = 0xFF07;
this.TACF_START = 0b00000100;
this.TACF_STOP = 0b00000000;
this.TACF_4KHZ =...