N8080 Screenshot Day

· Read in about 1 min · (202 Words)

Today was the big day. Attaching a display to the section of memory the Space Invaders 8080 binary uses to display images. (0x2400 - 0x7FFF). I moved Interrupt handling from main.go and put it into the Display device. I did this because that is how Space Invaders was actually wired. This also means that the display is synced to the interrupts firing, about every 8ms for the vsync and ½ vsync interrupts the machine expected.

Each ½ vsync frame the code here creates a new go «image» and decodes the bytes into bits of color.White or color.Black.

img := image.NewRGBA(image.Rect(0, 0, 256, 224))
x := 0
y := 0
for i := range dsp.memory {
    pixels := dsp.memory[i]

    for j := uint(0); j < 8; j++ {
        if pixels>>j&0x01 == 0x01 {
            img.Set(x, y, color.White)
        } else {
            img.Set(x, y, color.Black)
        }
        x += 1
    }

    if x > 255 {
        x = 0
        y += 1
    }
}

if counter%500 == 0 {
    f, _ := os.Create("draw" + strconv.FormatInt(int64(counter), 10) + ".png")
    png.Encode(f, img)
    f.Close()
}

The result is the following image at from 2000. It is super exciting to finally see an image out of the emulator!

8080 Invaders Screenshot

8080 Invaders Screenshot