// Input files inputPicture = arguments[1]; cgaROM = "5788005.u33"; // Resample the input picture to this size before matching. Measured in hdots // horizontally and scanlines vertically. activeSize.x = inputPicture.size.x; activeSize.y = floor(inputPicture.size.y/2); // CGA mode configuration // CGA mode register values: // Basic modes: // 0x08 = low-resolution text (e.g. 40 columns standard width) // 0x09 = high-resolution text (e.g. 80 columns standard width) // 0x0a = 2bpp graphics // 0x1a = 1bpp graphics // Improper modes // 0x0b = high-res 2bpp graphics // 0x18 = low-resolution text with 1bpp graphics // 0x19 = high-resolution text with 1bpp graphics // 0x1b = high-res 1bpp graphics, odd bits ignored // Add 4 to any of these for to disable colour burst and carrier and use // red/cyan palette for 2bpp modes. // Add 0x20 in text modes to enable blinking and disable bright backgrounds. // Matcher will not use the blink bit - this just prevents it from using // bright backgrounds. // The improper modes latch bytes at incorrect times, so have strange bit // patterns and require multiple passes to get optimal results. // Use 0x80 for auto -HRES and 0x81 for auto +HRES (tries all combinations). mode = 0x1a; // Low 4 bits of palette register are // overscan in text mode and 2bpp graphics mode // colour 1 in 1bpp graphics mode // colour 0 in 2bpp graphics mode // Bits 4 and 5 are significant in 2bpp graphics mode: // 0x00..0x0f = background/green/red/brown // 0x10..0x1f = background/light green/light red/yellow // 0x20..0x2f = background/cyan/magenta/light grey // 0x30..0x3f = background/light cyan/light magenta/white // Use 0xff for auto palette (tries all combinations appropriate for mode). palette = 0x0f; // In graphics modes, only the lowest bit of the scanline counter (CRTC "row // address") is used. It is used to select between the two 8kB regions of VRAM, // so for cgaart purposes 1 and 2 are equivalent for graphics modes (except for // the way that data is laid out in RAM), and 3+ give repeated scanlines. In // text modes, the lowest 3 bits of the scanline counter give the scanline // within the character to look up in ROM, so 1 to 8 are useful (9+ give // repeated scanlines). scanlinesPerRow = 2; // Number of times to display each scanline. There are various hacks for // repeating scanlines, but not all repeat counts are possible in every // combination of mode and CRTC variant. cgaart allows you to repeat each // scanline any number of times even though that may not be possible on a // real CGA card. scanlinesRepeat = 1; // Interlace mode: // 0 = None (non-interlaced, like standard CGA modes) // 1 = Even odd (480i equivalent in combination with interlace sync) // 2 = Odd even (same but with fields swapped) // 3 = Even even (only show even scanlines) // 4 = Odd odd (only show odd scanlines) interlaceMode = 0; // Set to true to offset scanlines by half a line (to double vertical // resolution at the expense of halving the field rate): interlaceSync = false; // Set to true to alternate phase each field: interlacePhase = false; // Set to true to use different VRAM regions for even and odd fields: flicker = false; // Phase is relevant for improper +HRES modes (0x0b, 0x19 and 0x1b). // Phase 0 starts is 8 hdots further left and has different bit patterns. phase = 1; // Matching options // Character set to use for matching in text modes: // 0 = 0xdd 160x100x16 // 1 = 0x13/0x55 80x100x512 composite // 2 = 0x13/0x55/0xb0/0xb1 80x100x1024 composite // 3 = all // 4 = 0xb1 80x100x256 // 5 = 0xb0/0xb1 80x100x512 // 6 = 0x06/0x13/0x19/0x22/0x27/0x55/0x57/0x60/0xb6/0xdd // 7 = 0x0c/0x0d/0x21/0x35/0x55/0x6a/0xdd // Set 6 is all the characters with the same data on scanlines 0 and 1, // allowing us to do 200 1-scanline rows with no CPU time, or 100 // duplicated-scanline rows with no CPU time // Set 7 has all possible combinations of double-wide pixels on scanline 0. characterSet = 3; // Quality for matching in text modes. 0 = fastest, 1 = best quality quality = 0.5; // Parameters for error diffusion in match mode. This corresponds to diffusing // the error at a 45 degree angle with the default aspect ratio, since // 0.647565^12 ~= (1-0.647565)^5. horizontalDiffusion = 0.647565; verticalDiffusion = 1 - horizontalDiffusion; temporalDiffusion = 0; // If set to true, errors will only be diffused within a character cell and // not to adjacent (rightward, downward) cells. This may eliminate a "blotchy" // effect in RGBI text modes without sacrificing the ability of the matcher to // use dither characters. diffuseInternallyHorizontal = false; diffuseInternallyVertical = false; // Gamma correction. 0 for sRGB standard, 1 for no gamma correction. // Other values (e.g. 2.2) use power approximation. gamma = 0; // Target colour clipping mode: // 0 = no colour clipping // 1 = clip colour components separately to [0,1] // 2 = project towards center of colour cube // 3 = clip colour components separately to [-1,2] clipping = 1; // Fitness metric: // 0 = sRGB // 1 = linear RGB // 2 = Fast colour distance metric from http://www.compuphase.com/cmetric.htm // 3 = Luv // 4 = CIE76 // 5 = CIE94 // 6 = CIEDE2000 metric = 2; // Number of hdots to look ahead. The matcher tries all possible combinations // within the look ahead region, so the matching time increases by a factor of // 2 (4 for +HRES 2bpp mode) each time this is increased. Higher numbers // eliminate artifacts in some cases. lookAhead = 3; // Number of hdots to move right after each matching block. Higher numbers may // be faster but may also introduce artifacts in some cases. // 0 = 1 hdot // 1 = 2 hdots // 2 = 4 hdots // 3 = 8 hdots // 4 = 16 hdots advance = 2; // For graphics modes with more than 2 scanlines per row: // set to true to process all scanlines within row at once // set to false to process scanlines individually // Combining gives better results but is slower and limits the amount of // horizontal lookahead that can be used. combineScanlines = true; // CGA composite encoding options // Connector used to connect CGA card to monitor: // 0 = RGBI // 1 = Composite (old) // 2 = Composite (new) // New CGA cards have a lower chroma amplitude and the text mode colours show // up as more different shades of grey on a monochrome monitor. Boolean isRGBI = bitmapIsRGBI(inputPicture); connector = isRGBI ? 0 : 1; // NTSC decoding options contrast = 100; brightness = 0; saturation = 100; hue = 0; chromaBandwidth = 1; // units of colour carrier frequency /8 lumaBandwidth = 1; // units of colour carrier frequency rollOff = 0; // units of colour carrier frequency showClipping = false; // Comb filter settings: // 0 = none // 1 = 1 line // 2 = 2 line combFilter = 0; lobes = 1.5; // Scaling and scanline options aspectRatio = 5/6; // Pixel aspect ratio of one ldot scanlineWidth = 1; // Width of a scanline in units of "zoom" pixels overscan = 0.1; // Overscan to add on each edge, as fraction of active size // Scaler profiles // 0 = rectangle // 1 = triangle // 2 = circle // 3 = gaussian // 4 = sinc // 5 = box (nearest neighbour) scanlineProfile = 0; horizontalProfile = 0; prescalerProfile = isRGBI ? 5 : 4; // Scanline bleeding settings // 0 = none (clipping only, inaccurate colour) // 1 = down (fast) // 2 = symmetrical (good) scanlineBleeding = 2; horizontalBleeding = 2; zoom = 2; // Output pixels per scanline vertically horizontalRollOff = 0; verticalRollOff = 0; horizontalLobes = 4; verticalLobes = 4; subPixelSeparation = 1; // Positive for RGB, negative for BGR // Phosphor colour settings // 0 = colour // 1 = green // 2 = amber // 3 = white // 4 = blue phosphor = 0; // Mask settings // 0 = shadow mask // 1 = aperture grille mask = 0; maskSize = 0; // size of mask in scanlines // Set to false to convert and immediately exit without showing UI, for batch // processing. interactive = true; // Location of wisdom file for FFTW. This caches data which is used to speed up // subsequent runs of the program. The data it contains may be sub-optimal for // machines other than the machine it was created on, so it should not be // copied to other machines. fftWisdom = "wisdom";