Fixed: Calibration errors with half height frame buffers (#40)

Change-Id: I6792399e5a1a234c3b1b66226c5ee0447e759f0b
pull/44/head
David Banks 2019-03-10 11:02:05 +00:00
rodzic da87c53fb1
commit 5eb987a25b
3 zmienionych plików z 16 dodań i 13 usunięć

Wyświetl plik

@ -147,8 +147,8 @@ typedef struct {
unsigned char *fb; // framebuffer base address
int pitch; // framebuffer pitch (in bytes per line)
int width; // framebuffer width (in pixels)
int height; // framebuffer height (in pixels)
int heightx2; // framebuffer height (in pixels)
int height; // framebuffer height (in pixels, after any doubling is applied)
int heightx2; // if 1 then double frame buffer height
int bpp; // framebuffer bits per pixel (4 or 8)
int chars_per_line; // active 8-pixel characters per line (83 in Modes 0..6, but 63 in Mode 7)
int nlines; // number of active lines to capture each field

Wyświetl plik

@ -34,8 +34,8 @@ typedef struct {
int h_width; // active horizontal width (in 8-bit characters)
int v_height; // active vertical height (in lines)
int fb_width; // framebuffer width in pixels
int fb_height; // framebuffer height in pixels
int fb_heightx2; // framebuffer height in pixels
int fb_height; // framebuffer height (in pixels, before and doubling is applied)
int fb_heightx2; // if 1 then double frame buffer height
int fb_bpp; // framebuffer bits per pixel
int clock; // cpld clock (in Hz)
int line_len; // number of clocks per horizontal line

Wyświetl plik

@ -840,37 +840,40 @@ int *diff_N_frames_by_sample(capture_info_t *capinfo, int n, int mode7, int elk)
uint32_t *lastp = (uint32_t *)last;
for (int y = 0; y < capinfo->height; y++) {
int skip = 0;
// As v_offset increases, e.g. by one, the screen image moves up one scan line, which is two frame buffer lines
// So line N in the framebuffer corresponds to line N + 2 in the image
int line = y + (capinfo->v_offset - 20) * 2;
// Calculate the capture scan line number (allowing for a double hight framebuffer)
// (capinfo->height is the framebuffer height after any doubling)
int line = capinfo->heightx2 ? (y >> 1) : y;
// As v_offset increases, e.g. by one, the screen image moves up one capture line
// (the hardcoded constant of 20 relates to the BBC video format)
line += (capinfo->v_offset - 20);
// Skip lines that might contain flashing cursor
// (the cursor rows were determined empirically)
if (line >= 0) {
if (elk) {
// Eliminate cursor lines in 32 row modes (0,1,2,4,5)
if (!mode7 && ((line >> 1) % 8) == 5) {
if (!mode7 && (line % 8) == 5) {
skip = 1;
}
// Eliminate cursor lines in 25 row modes (3, 6)
if (!mode7 && ((line >> 1) % 10) == 3) {
if (!mode7 && (line % 10) == 3) {
skip = 1;
}
// Eliminate cursor lines in mode 7
// (this case is untested as I don't have a Jafa board)
if (mode7 && ((line % 20) == 14 || (line % 20) == 15)) {
if (mode7 && (line % 10) == 7) {
skip = 1;
}
} else {
// Eliminate cursor lines in 32 row modes (0,1,2,4,5)
if (!mode7 && ((line >> 1) % 8) == 7) {
if (!mode7 && (line % 8) == 7) {
skip = 1;
}
// Eliminate cursor lines in 25 row modes (3, 6)
if (!mode7 && ((line >> 1) % 10) >= 5 && ((line >> 1) % 10) <= 7) {
if (!mode7 && (line % 10) >= 5 && (line % 10) <= 7) {
skip = 1;
}
// Eliminate cursor lines in mode 7
if (mode7 && ((line % 20) == 14 || (line % 20) == 15)) {
if (mode7 && (line % 10) == 7) {
skip = 1;
}
}