wip 160px height
This commit is contained in:
parent
3826fe8205
commit
7d7a5bd064
2 changed files with 15 additions and 29 deletions
|
@ -529,8 +529,15 @@ function decimate(input, palette, n, inputError) {
|
|||
*/
|
||||
async function loadImage(src) {
|
||||
let image = await Jimp.read(src);
|
||||
|
||||
let width = image.bitmap.width;
|
||||
let height = image.bitmap.height;
|
||||
if (width != 160 || height != 160) {
|
||||
width = 160;
|
||||
height = 160;
|
||||
image = image.resize(width, height);
|
||||
}
|
||||
|
||||
let rgba = image.bitmap.data.slice();
|
||||
return {
|
||||
width,
|
||||
|
@ -539,23 +546,6 @@ async function loadImage(src) {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Halve the horizontal resolution, interpolating input.
|
||||
* @param {Uint8Array} rgba
|
||||
* @returns {Uint8Array}
|
||||
**/
|
||||
function halveImage(rgba) {
|
||||
let out = new Uint8Array(rgba.length >> 1);
|
||||
for (let i = 0; i < rgba.length; i += 8) {
|
||||
let j = i >> 1;
|
||||
out[j + 0] = (rgba[i + 0] + rgba[i + 4] + 1) >> 1;
|
||||
out[j + 1] = (rgba[i + 1] + rgba[i + 5] + 1) >> 1;
|
||||
out[j + 2] = (rgba[i + 2] + rgba[i + 6] + 1) >> 1;
|
||||
out[j + 3] = (rgba[i + 3] + rgba[i + 7] + 1) >> 1;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function imageToLinearRGB(rgba) {
|
||||
let input = [];
|
||||
for (let i = 0; i < rgba.length; i += 4) {
|
||||
|
@ -583,18 +573,13 @@ async function convert(source, nbits) {
|
|||
rgba
|
||||
} = await loadImage(source);
|
||||
|
||||
if (width == 320) {
|
||||
width = 160;
|
||||
rgba = halveImage(rgba);
|
||||
}
|
||||
|
||||
if (width !== 160) {
|
||||
throw new Error(`expected 160px-compatible width, got ${width} pixels`);
|
||||
}
|
||||
|
||||
if (height !== 192) {
|
||||
if (height !== 160) {
|
||||
// @fixme support up to 240px
|
||||
throw new Error(`expected 192px height, got ${height} pixels`);
|
||||
throw new Error(`expected 160px height, got ${height} pixels`);
|
||||
}
|
||||
|
||||
if (rgba.length != width * 4 * height) {
|
||||
|
|
11
dither4.s
11
dither4.s
|
@ -27,11 +27,12 @@ sample_ptrh = $85
|
|||
sample_ptr = sample_ptrl
|
||||
scanline = $86
|
||||
|
||||
height = 192
|
||||
height = 160
|
||||
bytes_per_line = 40
|
||||
pages_per_frame = 32
|
||||
lines_per_frame = 262
|
||||
scanline_offset = 31
|
||||
;scanline_offset = 31 + (40 - 24) / 2
|
||||
scanline_offset = 47
|
||||
scanline_max = (lines_per_frame - scanline_offset) / 2
|
||||
|
||||
.data
|
||||
|
@ -44,12 +45,12 @@ scanline_max = (lines_per_frame - scanline_offset) / 2
|
|||
.import audio_samples_end
|
||||
|
||||
displaylist:
|
||||
; 24 lines overscan
|
||||
.repeat 3
|
||||
; 40 lines overscan
|
||||
.repeat 5
|
||||
.byte $70 ; 8 blank lines
|
||||
.endrep
|
||||
|
||||
; 192 lines graphics
|
||||
; 160 lines graphics
|
||||
; ANTIC mode e (160px 2bpp, 1 scan line per line)
|
||||
.byte $4e
|
||||
.addr framebuffer
|
||||
|
|
Loading…
Reference in a new issue