Commit Graph

6 Commits

Author SHA1 Message Date
KrisKennaway f55e878b8e
Mark nogil functions as noexcept to avoid warning from newer cython (#15) 2023-10-29 14:43:55 +00:00
KrisKennaway f8fbd768a5
Optimize dither_dhr.dither_image performance by about 2x (#12)
- avoid passing around a float[::1] memoryview across function barriers, this seems to require reference counting which has a large overhead
- inline some functions
- C division
- float instead of double
2023-02-25 21:21:43 +00:00
KrisKennaway 3aa29f2d2c
Add support for hi-res conversions (#11)
Hi-Res is essentially a more constrained version of Double Hi-Res, in which only about half of the 560 horizontal screen pixels can be independently addressed.

In particular an 8 bit byte in screen memory controls 14 or 15 screen pixels.  Bits 0-7 are doubled, and bit 8 shifts these 14 dots to the right if enabled.  In this case bit 7 of the previous byte is repeated a third time.

This means that we have to optimize all 8 bits at once and move forward in increments of 14 screen pixels.

There's also a timing difference that results in a phase shift of the NTSC colour signal, which means the mappings from dot patterns to effective colours are rotated.

Error diffusion seems to give best results if we only distribute about 2/3 of the quantization error according to the dither pattern.
2023-02-03 00:40:32 +00:00
kris ae89682dab Split out common utility functions into a shared module 2021-11-26 12:26:46 +00:00
kris 0dc2c0a7a0 Disable bounds checking and wraparound by default 2021-11-26 12:12:55 +00:00
kris 4221c00701 Split dither into dither_dhr and dither_shr 2021-11-26 12:08:48 +00:00