func (g *Graphics) Clear() {
	g.EachPixel(func(_, _ uint16, addr int) {
		g.Pixels[addr] = 0
	})
}
Clear clears the display.
package chip8
import (
	termbox "github.com/nsf/termbox-go"
)
const (
	GraphicsWidth  = 64  
	GraphicsHeight = 32  
)
type Display interface {
	Render(*Graphics) error
}
type DisplayFunc func(*Graphics) error
func (f DisplayFunc) Render(g *Graphics) error {
	return f(g)
}
var NullDisplay = DisplayFunc(func(*Graphics) error {
	return nil
})
type Graphics struct {
	Pixels [GraphicsWidth * GraphicsHeight]byte
	Display
}
func (g *Graphics) WriteSprite(sprite []byte, x, y byte) (collision bool) {
	n := len(sprite)
	for yl := 0; yl < n; yl++ {
		r := sprite[yl]
		for xl := 0; xl < 8; xl++ {
			i := 0x80 >> byte(xl)
			on := (r & byte(i)) == byte(i)
			xp := uint16(x) + uint16(xl)
			for xp >= GraphicsWidth {
				xp = xp - GraphicsWidth
			}
			yp := uint16(y) + uint16(yl)
			for yp >= GraphicsHeight {
				yp = yp - GraphicsHeight
			}
			if g.Set(xp, yp, on) {
				collision = true
			}
		}
	}
	return
}