def test_dots_to_pixels(self): self.assertEqual((HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.DARK_BLUE, HGRColours.MED_BLUE, HGRColours.AQUA, HGRColours.AQUA, HGRColours.GREEN, HGRColours.BROWN, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK), colours.dots_to_nominal_colour_pixels( 31, 0b00000000000000000000111000000000, HGRColours, init_phase=0)) self.assertEqual( (HGRColours.BLACK, HGRColours.MAGENTA, HGRColours.VIOLET, HGRColours.LIGHT_BLUE, HGRColours.WHITE, HGRColours.AQUA, HGRColours.GREEN, HGRColours.BROWN, HGRColours.BLACK, HGRColours.MAGENTA, HGRColours.VIOLET, HGRColours.LIGHT_BLUE, HGRColours.WHITE, HGRColours.AQUA, HGRColours.GREEN, HGRColours.BROWN, HGRColours.BLACK, HGRColours.MAGENTA, HGRColours.VIOLET, HGRColours.LIGHT_BLUE, HGRColours.WHITE, HGRColours.AQUA, HGRColours.GREEN, HGRColours.BROWN, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK, HGRColours.BLACK), colours.dots_to_nominal_colour_pixels( 31, 0b0000111100001111000011110000, HGRColours, init_phase=0))
def test_nominal_colours_sather_odd_5(self): """Cut off blue-black with violet to produce bright violet. "Bright" here is because the sequence of pixels has high intensity Blue-Blue-Light Blue-Light Blue-Violet-Violet. """ # PDCCBBAA self.main.page_offset[0, 1] = 0b10100000 # PGGFFEED self.main.page_offset[0, 2] = 0b00000001 self.hgr = screen.HGRBitmap(main_memory=self.main, palette=Palette.NTSC) masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=1)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=1) self.assertEqual( ( colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.DARK_BLUE, colours.HGRColours.MED_BLUE, colours.HGRColours.MED_BLUE, colours.HGRColours.LIGHT_BLUE, colours.HGRColours.LIGHT_BLUE, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[1]) )
def test_nominal_colours_sather_even_5(self): """Cut off orange-black with green to produce bright green. "Bright" here is because the sequence of pixels has high intensity Orange-Orange-Yellow-Yellow-Green-Green.""" # PDCCBBAA self.main.page_offset[0, 0] = 0b10100000 # PGGFFEED self.main.page_offset[0, 1] = 0b00000001 self.hgr = screen.HGRBitmap(main_memory=self.main, palette=Palette.NTSC) masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=0)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=0) self.assertEqual( ( colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BROWN, # 0001 colours.HGRColours.ORANGE, # 1001 colours.HGRColours.ORANGE, # 1001 colours.HGRColours.YELLOW, # 1011 colours.HGRColours.YELLOW, # 1011 colours.HGRColours.GREEN, # 0011 colours.HGRColours.GREEN, # 0011 ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[0]) )
def test_nominal_colours_sather_even_1(self): """Extend violet into light blue.""" # PDCCBBAA self.main.page_offset[0, 0] = 0b01000000 # PGGFFEED self.main.page_offset[0, 1] = 0b10000000 self.hgr = screen.HGRBitmap(main_memory=self.main, palette=Palette.NTSC) masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=0)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=0) self.assertEqual( ( colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.MAGENTA, # 1000 colours.HGRColours.VIOLET, # 1100 colours.HGRColours.LIGHT_BLUE, # 1110 colours.HGRColours.LIGHT_BLUE, # 1110 colours.HGRColours.MED_BLUE, # 0110 # last repeated bit from byte 0 colours.HGRColours.DARK_GREEN, # 0010 ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[0]) )
def test_nominal_colours_sather_odd_2(self): """Cut off orange with black to produce dark brown.""" # PDCCBBAA self.main.page_offset[0, 1] = 0b11000000 # PGGFFEED self.main.page_offset[0, 2] = 0b00000000 self.hgr = screen.HGRBitmap(main_memory=self.main, palette=Palette.NTSC) masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=1)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=1) self.assertEqual( ( colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BROWN, colours.HGRColours.BROWN, colours.HGRColours.BROWN, colours.HGRColours.BROWN, colours.HGRColours.BLACK, ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[1]) )
def test_nominal_colours_sather_odd_1(self): """Extend green into light brown.""" # PDCCBBAA self.main.page_offset[0, 1] = 0b01000000 # PGGFFEED self.main.page_offset[0, 2] = 0b10000000 self.hgr = screen.HGRBitmap(main_memory=self.main, palette=Palette.NTSC) masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=1)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=1) self.assertEqual( ( colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.DARK_GREEN, colours.HGRColours.GREEN, colours.HGRColours.YELLOW, colours.HGRColours.YELLOW, colours.HGRColours.ORANGE, colours.HGRColours.MAGENTA, ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[1]) )
def test_nominal_colours_sather_even_4(self): """Cut off white with black to produce pink.""" # PDCCBBAA self.main.page_offset[0, 0] = 0b11100000 # PGGFFEED self.main.page_offset[0, 1] = 0b00000000 self.hgr = screen.HGRBitmap(main_memory=self.main, palette=Palette.NTSC) masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=0)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=0) self.assertEqual( ( colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BROWN, colours.HGRColours.ORANGE, colours.HGRColours.PINK, colours.HGRColours.PINK, colours.HGRColours.VIOLET, colours.HGRColours.DARK_BLUE, colours.HGRColours.BLACK, ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[0]) )
def test_nominal_colours_sather_even_3(self): """Cut off blue with green to produce aqua.""" # PDCCBBAA self.main.page_offset[0, 0] = 0b11000000 # PGGFFEED self.main.page_offset[0, 1] = 0b00000001 self.hgr = screen.HGRBitmap(main_memory=self.main, palette=Palette.NTSC) masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=0)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=0) self.assertEqual( ( colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.BLACK, colours.HGRColours.DARK_BLUE, colours.HGRColours.MED_BLUE, colours.HGRColours.AQUA, colours.HGRColours.AQUA, colours.HGRColours.GREEN, ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[0]) )
def test_nominal_colours(self): # PDCCBBAA self.main.page_offset[0, 0] = 0b01010101 # PGGFFEED self.main.page_offset[0, 1] = 0b00101010 # PDCCBBAA self.main.page_offset[0, 2] = 0b01010101 self.hgr = screen.HGRBitmap(main_memory=self.main, palette=Palette.NTSC) want = 0b0100101010001010101000 got = self.hgr.packed[0, 0] self.assertEqual( want, got, "\n%s\n%s" % (binary(want), binary(got)) ) masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=0)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=0) self.assertEqual( ( colours.HGRColours.MAGENTA, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[0]) ) # Now check byte offset 1 masked = int(screen.HGRBitmap.mask_and_shift_data( self.hgr.packed[0, 0], byte_offset=1)) dots = screen.HGRBitmap.to_dots(masked, byte_offset=1) self.assertEqual( ( colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, colours.HGRColours.VIOLET, ), colours.dots_to_nominal_colour_pixels( 18, dots, colours.HGRColours, init_phase=screen.HGRBitmap.PHASES[1]) )