Checkpoint WIP for easier comparison to dhgr branch:

- naive version of NTSC artifacting, it uses a sliding 4-bit window to
  assign a nominal (D)HGR colour to each dot position.  A more
  sophisticated/correct implementation would model the YIQ signal
  directly.

- Switch DHGRBitmap implementation to use a 34-bit representation of
  the 4-byte tuple, comprised of a 3-bit header and footer, plus
  4*7=28-bit body.  The headers/footers account for the influence on
  neighbouring tuples from the 4-bit NTSC window.

- With this model each screen byte influences 13 pixels, so we need to
  precompute 2^26 edit distances for all possible (source, target)
  13-bit sequences.

- Checkpointing not-yet-working HGR implementation.

- Add new unit tests but not yet all passing due to refactoring
This commit is contained in:
kris
2019-07-02 22:40:50 +01:00
parent e2a8bd9b4d
commit 666272a8fc
9 changed files with 1268 additions and 367 deletions

View File

@@ -3,7 +3,7 @@ from typing import Dict, Type
import colormath.color_objects
from colours import DHGRColours
from colours import HGRColours
# Type annotation
RGB = colormath.color_objects.sRGBColor
@@ -24,7 +24,7 @@ class BasePalette:
ID = Palette.UNKNOWN # type: Palette
# Palette RGB map
RGB = {} # type: Dict[DHGRColours: RGB]
RGB = {} # type: Dict[HGRColours: RGB]
class NTSCPalette(BasePalette):
@@ -32,22 +32,22 @@ class NTSCPalette(BasePalette):
# Palette RGB values taken from BMP2DHGR's default NTSC palette
RGB = {
DHGRColours.BLACK: rgb(0, 0, 0),
DHGRColours.MAGENTA: rgb(148, 12, 125),
DHGRColours.BROWN: rgb(99, 77, 0),
DHGRColours.ORANGE: rgb(249, 86, 29),
DHGRColours.DARK_GREEN: rgb(51, 111, 0),
DHGRColours.GREY1: rgb(126, 126, 126),
DHGRColours.GREEN: rgb(67, 200, 0),
DHGRColours.YELLOW: rgb(221, 206, 23),
DHGRColours.DARK_BLUE: rgb(32, 54, 212),
DHGRColours.VIOLET: rgb(188, 55, 255),
DHGRColours.GREY2: rgb(126, 126, 126),
DHGRColours.PINK: rgb(255, 129, 236),
DHGRColours.MED_BLUE: rgb(7, 168, 225),
DHGRColours.LIGHT_BLUE: rgb(158, 172, 255),
DHGRColours.AQUA: rgb(93, 248, 133),
DHGRColours.WHITE: rgb(255, 255, 255)
HGRColours.BLACK: rgb(0, 0, 0),
HGRColours.MAGENTA: rgb(148, 12, 125),
HGRColours.BROWN: rgb(99, 77, 0),
HGRColours.ORANGE: rgb(249, 86, 29),
HGRColours.DARK_GREEN: rgb(51, 111, 0),
HGRColours.GREY1: rgb(126, 126, 126),
HGRColours.GREEN: rgb(67, 200, 0),
HGRColours.YELLOW: rgb(221, 206, 23),
HGRColours.DARK_BLUE: rgb(32, 54, 212),
HGRColours.VIOLET: rgb(188, 55, 255),
HGRColours.GREY2: rgb(126, 126, 126),
HGRColours.PINK: rgb(255, 129, 236),
HGRColours.MED_BLUE: rgb(7, 168, 225),
HGRColours.LIGHT_BLUE: rgb(158, 172, 255),
HGRColours.AQUA: rgb(93, 248, 133),
HGRColours.WHITE: rgb(255, 255, 255)
}
@@ -56,22 +56,22 @@ class IIGSPalette(BasePalette):
# Palette RGB values taken from BMP2DHGR's KEGS32 palette
RGB = {
DHGRColours.BLACK: rgb(0, 0, 0),
DHGRColours.MAGENTA: rgb(221, 0, 51),
DHGRColours.BROWN: rgb(136, 85, 34),
DHGRColours.ORANGE: rgb(255, 102, 0),
DHGRColours.DARK_GREEN: rgb(0, 119, 0),
DHGRColours.GREY1: rgb(85, 85, 85),
DHGRColours.GREEN: rgb(0, 221, 0),
DHGRColours.YELLOW: rgb(255, 255, 0),
DHGRColours.DARK_BLUE: rgb(0, 0, 153),
DHGRColours.VIOLET: rgb(221, 0, 221),
DHGRColours.GREY2: rgb(170, 170, 170),
DHGRColours.PINK: rgb(255, 153, 136),
DHGRColours.MED_BLUE: rgb(34, 34, 255),
DHGRColours.LIGHT_BLUE: rgb(102, 170, 255),
DHGRColours.AQUA: rgb(0, 255, 153),
DHGRColours.WHITE: rgb(255, 255, 255)
HGRColours.BLACK: rgb(0, 0, 0),
HGRColours.MAGENTA: rgb(221, 0, 51),
HGRColours.BROWN: rgb(136, 85, 34),
HGRColours.ORANGE: rgb(255, 102, 0),
HGRColours.DARK_GREEN: rgb(0, 119, 0),
HGRColours.GREY1: rgb(85, 85, 85),
HGRColours.GREEN: rgb(0, 221, 0),
HGRColours.YELLOW: rgb(255, 255, 0),
HGRColours.DARK_BLUE: rgb(0, 0, 153),
HGRColours.VIOLET: rgb(221, 0, 221),
HGRColours.GREY2: rgb(170, 170, 170),
HGRColours.PINK: rgb(255, 153, 136),
HGRColours.MED_BLUE: rgb(34, 34, 255),
HGRColours.LIGHT_BLUE: rgb(102, 170, 255),
HGRColours.AQUA: rgb(0, 255, 153),
HGRColours.WHITE: rgb(255, 255, 255)
}