A CHIP-8 display is a 64-by-32 black-and-white grid. Represent its pixels as a two-dimensional array of single-bit values, wrapped in a struct with a method to clear the screen. section 6.3.2
Listing 6.4 Structuring input and output
pub const Display = struct {
pixels: [32][64]u1, #1
pub fn clear(display: *Display) void {
@memset(&display.pixels, [1]u1{0} ** 64); #2
}
};
pub const Keypad = struct {
keys: [16]bool, #3
};
The Display struct stores 32 rows of 64 pixels and clears them by filling the array with zeroes. section 6.3.2
Display instructions change this stored state: 00E0 clears it, while DXYN draws a sprite by XORing its bits with pixels starting at coordinates in registers X and Y. Out-of-bounds pixels are ignored. section 6.5.7
