diff --git a/doc/specifications/86box-unit-tester.md b/doc/specifications/86box-unit-tester.md index fe0203b46..c58b15960 100644 --- a/doc/specifications/86box-unit-tester.md +++ b/doc/specifications/86box-unit-tester.md @@ -101,8 +101,6 @@ This is an easy way to reset the status to 0x04 (no command in flight, not waiti ### 0x01: Capture Screen Snapshot -**TODO: IMPLEMENT ME!** - Captures a snapshot of the current screen state and stores it in the current snapshot buffer. The initial state of the screen snapshot buffer has an image area of 0x0, an overscanned area of 0x0, and an image start offset of (0,0). diff --git a/src/device/unittester.c b/src/device/unittester.c index 78086fd90..c020a81ee 100644 --- a/src/device/unittester.c +++ b/src/device/unittester.c @@ -248,7 +248,7 @@ unittester_write(uint16_t port, uint8_t val, UNUSED(void *priv)) /* Monitor disabled - clear snapshot */ unittester.snap_monitor = 0x00; } else { - /* Capture snapshot from monitor */ + /* Compute bounds for snapshot */ const monitor_t *m = &monitors[unittester.snap_monitor - 1]; unittester.snap_img_width = m->mon_xsize; unittester.snap_img_height = m->mon_ysize; @@ -256,7 +256,12 @@ unittester_write(uint16_t port, uint8_t val, UNUSED(void *priv)) unittester.snap_overscan_height = m->mon_ysize + m->mon_overscan_y; unittester.snap_img_xoffs = (m->mon_overscan_x >> 1); unittester.snap_img_yoffs = (m->mon_overscan_y >> 1); - /* TODO: Actually take snapshot! --GM */ + /* Take snapshot */ + for (size_t y = 0; y < unittester.snap_img_height; y++) { + for (size_t x = 0; x < unittester.snap_img_width; x++) { + unittester_screen_buffer->line[y][x] = m->target_buffer->line[y][x]; + } + } } /* We have 12 bytes to read. */