yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::test::gfx Namespace Reference

Namespaces

namespace  anonymous_namespace{compression_test.cc}
 
namespace  anonymous_namespace{snes_palette_test.cc}
 

Functions

 TEST (LC_LZ2_CompressionTest, TrivialRepeatedBytes)
 
 TEST (LC_LZ2_CompressionTest, RepeatedBytesBetweenUncompressable)
 
 TEST (LC_LZ2_CompressionTest, RepeatedBytesBeforeUncompressable)
 
 TEST (LC_LZ2_CompressionTest, RepeatedBytesAfterUncompressable)
 
 TEST (LC_LZ2_CompressionTest, RepeatedBytesAfterUncompressableRepeated)
 
 TEST (LC_LZ2_CompressionTest, RepeatedBytesBeforeUncompressableRepeated)
 
 TEST (LC_LZ2_CompressionTest, NewDecompressionPieceOk)
 
 TEST (LC_LZ2_CompressionTest, CompressionSingleSet)
 
 TEST (LC_LZ2_CompressionTest, CompressionSingleWord)
 
 TEST (LC_LZ2_CompressionTest, CompressionSingleIncrement)
 
 TEST (LC_LZ2_CompressionTest, CompressionSingleCopy)
 
 TEST (LC_LZ2_CompressionTest, CompressionSingleOverflowIncrement)
 
 TEST (HandleDirectCopyTest, NotDirectCopyWithAccumulatedBytes)
 
 TEST (HandleDirectCopyTest, NotDirectCopyWithoutAccumulatedBytes)
 
 TEST (HandleDirectCopyTest, AccumulateBytesWithoutMax)
 
 TEST (CheckIncByteV3Test, IncreasingSequence)
 
 TEST (CheckIncByteV3Test, IncreasingSequenceSurroundedByIdenticalBytes)
 
 TEST (CheckIncByteV3Test, NotAnIncreasingSequence)
 
 TEST (LC_LZ2_CompressionTest, DecompressionValidCommand)
 
 TEST (LC_LZ2_CompressionTest, DecompressionMixingCommand)
 
 TEST (SNESPaletteTest, AddColor)
 
 TEST (SNESColorTest, ConvertRGBtoSNES)
 
 TEST (SNESColorTest, ConvertSNEStoRGB)
 
 TEST (SNESColorTest, ConvertSNESToRGB_Binary)
 
 TEST (SNESColorTest, Extraction)
 
 TEST (SNESColorTest, Convert)
 

Function Documentation

◆ TEST() [1/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
TrivialRepeatedBytes  )

Definition at line 103 of file compression_test.cc.

◆ TEST() [2/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
RepeatedBytesBetweenUncompressable  )

Definition at line 107 of file compression_test.cc.

◆ TEST() [3/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
RepeatedBytesBeforeUncompressable  )

Definition at line 112 of file compression_test.cc.

◆ TEST() [4/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
RepeatedBytesAfterUncompressable  )

Definition at line 117 of file compression_test.cc.

◆ TEST() [5/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
RepeatedBytesAfterUncompressableRepeated  )

Definition at line 122 of file compression_test.cc.

◆ TEST() [6/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
RepeatedBytesBeforeUncompressableRepeated  )

Definition at line 128 of file compression_test.cc.

◆ TEST() [7/26]

◆ TEST() [8/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
CompressionSingleSet  )
Todo
Check why header built is off by one

Definition at line 158 of file compression_test.cc.

References BUILD_HEADER.

◆ TEST() [9/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
CompressionSingleWord  )

Definition at line 167 of file compression_test.cc.

References BUILD_HEADER.

◆ TEST() [10/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
CompressionSingleIncrement  )

Definition at line 176 of file compression_test.cc.

References BUILD_HEADER.

◆ TEST() [11/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
CompressionSingleCopy  )

Definition at line 184 of file compression_test.cc.

References BUILD_HEADER.

◆ TEST() [12/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
CompressionSingleOverflowIncrement  )

Definition at line 193 of file compression_test.cc.

References BUILD_HEADER.

◆ TEST() [13/26]

yaze::test::gfx::TEST ( HandleDirectCopyTest ,
NotDirectCopyWithAccumulatedBytes  )

TEST(LC_LZ2_CompressionTest, CompressionSingleCopyRepeat) { std::vector<uint8_t> single_copy_expected = {0x03, 0x0A, 0x07, 0x14, 0x03, 0x0A, 0x07, 0x14};

auto comp_result = ExpectCompressV3Ok( single_copy_expected, {BUILD_HEADER(0x00, 0x04), 0x03, 0x0A, 0x07, 0x14, BUILD_HEADER(0x04, 0x04), 0x00, 0x00, 0xFF}); EXPECT_THAT(single_copy_expected, ElementsAreArray(comp_result.data(), 6)); }

TEST(LC_LZ2_CompressionTest, CompressionMixedRepeatIncrement) { AssertCompressionQuality( {0x05, 0x05, 0x05, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x0A, 0x0B, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x08, 0x0A, 0x00, 0x05}, {BUILD_HEADER(0x01, 0x04), 0x05, BUILD_HEADER(0x03, 0x06), 0x06, BUILD_HEADER(0x00, 0x01), 0x05, 0xFF}); }

TEST(LC_LZ2_CompressionTest, CompressionMixedIncrementIntraCopyOffset) { "Mixing, inc, alternate, intra copy" compress start: 3, length: 21 compressed length: 9 AssertCompressionQuality( {0x05, 0x05, 0x05, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x0A, 0x0B, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x08, 0x0A, 0x00, 0x05}, {BUILD_HEADER(0x03, 0x07), 0x05, BUILD_HEADER(0x02, 0x06), 0x05, 0x02, BUILD_HEADER(0x04, 0x08), 0x05, 0x00, 0xFF}); }

TEST(LC_LZ2_CompressionTest, CompressionMixedIncrementIntraCopySource) { "Mixing, inc, alternate, intra copy" 0, 28 16 AssertCompressionQuality( {0x05, 0x05, 0x05, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x0A, 0x0B, 0x05, 0x02, 0x05, 0x02, 0x05, 0x02, 0x08, 0x0A, 0x00, 0x05}, {BUILD_HEADER(0x01, 0x04), 0x05, BUILD_HEADER(0x03, 0x06), 0x06, BUILD_HEADER(0x02, 0x06), 0x05, 0x02, BUILD_HEADER(0x04, 0x08), 0x08, 0x00, BUILD_HEADER(0x00, 0x04), 0x08, 0x0A, 0x00, 0x05, 0xFF}); }

Extended Header 111CCCLL LLLLLLLL CCC: Real command LLLLLLLLLL: Length

Normally you have 5 bits for the length, so the maximum value you can represent is 31 (which outputs 32 bytes). With the long length, you get 5 more bits for the length, so the maximum value you can represent becomes 1023, outputting 1024 bytes at a time.

void build_extended_header(uint8_t command, uint8_t length, uint8_t& byte1, uint8_t& byte2) { byte1 = command << 3; byte1 += (length - 1); byte1 += 0b11100000; byte2 = length >> 3; }

std::vector<uint8_t> CreateRepeatedBetweenUncompressable( int leftUncompressedSize, int repeatedByteSize, int rightUncompressedSize) { std::vector<uint8_t> result( leftUncompressedSize + repeatedByteSize + rightUncompressedSize, 0); std::fill_n(result.begin() + leftUncompressedSize, repeatedByteSize, 0x00); return result; }

TEST(LC_LZ2_CompressionTest, LengthBorderCompression) { "Length border compression" std::vector<uint8_t> result(42, 0); std::fill_n(result.begin(), 42, 0x05); AssertCompressionQuality(result, {BUILD_HEADER(0x04, 42), 0x05, 0x05, 0xFF});

"Extended length, 400 repeat of 5" std::vector<uint8_t> result2(400, 0); std::fill_n(result2.begin(), 400, 0x05); uint8_t byte1; uint8_t byte2; build_extended_header(0x01, 42, byte1, byte2); AssertCompressionQuality(result2, {byte1, byte2, 0x05, 0x05, 0xFF});

"Extended length, 1050 repeat of 5" std::vector<uint8_t> result3(1050, 0); std::fill_n(result3.begin(), 1050, 0x05); uint8_t byte3; uint8_t byte4; build_extended_header(0x04, 1050, byte3, byte4); AssertCompressionQuality(result3, {byte3, byte4, 0x05, 0x05, 0xFF});

// "Extended length, 2050 repeat of 5" std::vector<uint8_t> result4(2050, 0); std::fill_n(result4.begin(), 2050, 0x05); uint8_t byte5; uint8_t byte6; build_extended_header(0x04, 2050, byte5, byte6); AssertCompressionQuality(result4, {byte5, byte6, 0x05, 0x05, 0xFF}); }

TEST(LC_LZ2_CompressionTest, CompressionExtendedWordCopy) { ROM rom; uchar buffer[3000]; for (unsigned int i = 0; i < 3000; i += 2) { buffer[i] = 0x05; buffer[i + 1] = 0x06; } uchar hightlength_word_1050[] = { 0b11101011, 0xFF, 0x05, 0x06, BUILD_HEADER(0x02, 0x1A), 0x05, 0x06, 0xFF};

// "Extended word copy" auto comp_result = ExpectCompressOk(rom, buffer, 1050); EXPECT_THAT(hightlength_word_1050, ElementsAreArray(comp_result.data(), 8));

std::vector<uint8_t> buffer(3000, 0); std::fill_n(buffer.begin(), 3000, 0x05); for (unsigned int i = 0; i < 3000; i += 2) { buffer[i] = 0x05; buffer[i + 1] = 0x06; }

uint8_t byte1; uint8_t byte2; build_extended_header(0x02, 0x1A, byte1, byte2); AssertCompressionQuality( buffer, {0b11101011, 0xFF, 0x05, 0x06, byte1, byte2, 0x05, 0x06, 0xFF}); }

TEST(LC_LZ2_CompressionTest, CompressionMixedPatterns) { AssertCompressionQuality( {0x05, 0x05, 0x05, 0x06, 0x07, 0x06, 0x07, 0x08, 0x09, 0x0A}, {BUILD_HEADER(0x01, 0x03), 0x05, BUILD_HEADER(0x02, 0x04), 0x06, 0x07, BUILD_HEADER(0x03, 0x03), 0x08, 0xFF}); }

TEST(LC_LZ2_CompressionTest, CompressionLongIntraCopy) { ROM rom; uchar long_data[15] = {0x05, 0x06, 0x07, 0x08, 0x05, 0x06, 0x07, 0x08, 0x05, 0x06, 0x07, 0x08, 0x05, 0x06, 0x07}; uchar long_expected[] = {BUILD_HEADER(0x00, 0x04), 0x05, 0x06, 0x07, 0x08, BUILD_HEADER(0x04, 0x0C), 0x00, 0x00, 0xFF};

auto comp_result = ExpectCompressOk(rom, long_data, 15); EXPECT_THAT(long_expected, ElementsAreArray(comp_result.data(), sizeof(long_expected))); }

Definition at line 352 of file compression_test.cc.

References yaze::app::gfx::lc_lz2::CompressionContext::cmd_with_max.

◆ TEST() [14/26]

yaze::test::gfx::TEST ( HandleDirectCopyTest ,
NotDirectCopyWithoutAccumulatedBytes  )

◆ TEST() [15/26]

yaze::test::gfx::TEST ( HandleDirectCopyTest ,
AccumulateBytesWithoutMax  )

◆ TEST() [16/26]

yaze::test::gfx::TEST ( CheckIncByteV3Test ,
IncreasingSequence  )

Definition at line 377 of file compression_test.cc.

◆ TEST() [17/26]

yaze::test::gfx::TEST ( CheckIncByteV3Test ,
IncreasingSequenceSurroundedByIdenticalBytes  )

Definition at line 383 of file compression_test.cc.

◆ TEST() [18/26]

yaze::test::gfx::TEST ( CheckIncByteV3Test ,
NotAnIncreasingSequence  )

Definition at line 391 of file compression_test.cc.

◆ TEST() [19/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
DecompressionValidCommand  )

Definition at line 398 of file compression_test.cc.

References BUILD_HEADER.

◆ TEST() [20/26]

yaze::test::gfx::TEST ( LC_LZ2_CompressionTest ,
DecompressionMixingCommand  )

Definition at line 406 of file compression_test.cc.

References BUILD_HEADER.

◆ TEST() [21/26]

yaze::test::gfx::TEST ( SNESPaletteTest ,
AddColor  )

Definition at line 28 of file snes_palette_test.cc.

References yaze::app::gfx::SnesPalette::AddColor(), and yaze::app::gfx::SnesPalette::size().

Here is the call graph for this function:

◆ TEST() [22/26]

yaze::test::gfx::TEST ( SNESColorTest ,
ConvertRGBtoSNES  )

Definition at line 35 of file snes_palette_test.cc.

◆ TEST() [23/26]

yaze::test::gfx::TEST ( SNESColorTest ,
ConvertSNEStoRGB  )

Definition at line 41 of file snes_palette_test.cc.

References snes_color::blue, snes_color::green, and snes_color::red.

◆ TEST() [24/26]

yaze::test::gfx::TEST ( SNESColorTest ,
ConvertSNESToRGB_Binary  )

Definition at line 49 of file snes_palette_test.cc.

◆ TEST() [25/26]

yaze::test::gfx::TEST ( SNESColorTest ,
Extraction  )

Definition at line 66 of file snes_palette_test.cc.

◆ TEST() [26/26]

yaze::test::gfx::TEST ( SNESColorTest ,
Convert  )

Definition at line 78 of file snes_palette_test.cc.

References yaze::app::gfx::Convert().

Here is the call graph for this function: