From 9200e82a1519919437e8379ba36e67b609fd8a24 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 7 Dec 2022 17:11:22 -0800 Subject: [PATCH] not working --- Makefile | 2 +- dither-image.js | 105 +++++++++++++++++++++++++++++++++++------------- dither4.s | 33 +++++++++++++-- 3 files changed, 107 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index f895d81..9a00152 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ chickens.s : chickens.wav pack-wav.js ca65 -v -t atari -o $@ $< %.xex : %.o dither4.o chickens.o - ld65 -v -C atari-asm-xex.cfg -o $@ $< dither4.o chickens.o + ld65 -v -C ./atari-asm-xex.cfg -o $@ dither4.o chickens.o $< clean : rm -f dither4.o diff --git a/dither-image.js b/dither-image.js index 685d2c2..1a441c8 100644 --- a/dither-image.js +++ b/dither-image.js @@ -654,41 +654,90 @@ function byte2byte(arr) { return lines.join('\n'); } -function genAssembly(width, height, nbits, lines) { +function genAssembly(width, height, nbits, lines, reps) { + let linesEach = height / reps; let stride = width * nbits / 8; - let palette1 = new Uint8Array(height); - let palette2 = new Uint8Array(height); - let palette3 = new Uint8Array(height); - let bitmap = new Uint8Array(stride * height); - for (let y = 0; y < lines.length; y++) { - palette1[y] = lines[y].palette[1]; - palette2[y] = lines[y].palette[2]; - palette3[y] = lines[y].palette[3]; - indexedToBitmap( - width, - nbits, - lines[y].output, - bitmap.subarray(y * stride, (y + 1) * stride) - ); + let half = stride * linesEach / 2; + let frames = []; + + for (let i = 0; i < reps; i ++) { + let frame = frames[i] = { + palette1: new Uint8Array(linesEach), + palette2: new Uint8Array(linesEach), + palette3: new Uint8Array(linesEach), + bitmap: new Uint8Array(stride * linesEach), + }; + for (let y = 0; y < lines.length; y++) { + let base = linesEach * i; + console.log(i, y, base); + frame.palette1[y] = lines[y + base].palette[1]; + frame.palette2[y] = lines[y + base].palette[2]; + frame.palette3[y] = lines[y + base].palette[3]; + indexedToBitmap( + width, + nbits, + lines[y + base].output, + frame.bitmap.subarray(y * stride, y + 1 * stride) + ); + } } return `.data -.export palette1 -.export palette2 -.export palette3 -.export bitmap +.export frame1_top +.export frame1_bottom +.export frame1_palette1 +.export frame1_palette2 +.export frame1_palette3 +.export frame2_top +.export frame2_bottom +.export frame2_palette1 +.export frame2_palette2 +.export frame2_palette3 -palette1: -${byte2byte(palette1)} +.segment buffers -palette2: -${byte2byte(palette2)} +.align 4096 +frame1_top +${byte2byte(frame[0].bitmap.slice(0, half))} -palette3: -${byte2byte(palette3)} +.align 256 +frame1_palette1: +${byte2byte(frame[0].palette1)} + +.align 256 +frame1_palette2: +${byte2byte(frame[0].palette2)} + +.align 256 +frame1_palette3: +${byte2byte(frame[0].palette3)} + +.align 4096 +frame1_bottom: +${byte2byte(frame[0].bitmap.slice(half))} + + + +.align 4096 +frame2_top +${byte2byte(frame[1].bitmap.slice(0, half))} + +.align 256 +frame2_palette1: +${byte2byte(frame[1].palette1)} + +.align 256 +frame2_palette2: +${byte2byte(frame[1].palette2)} + +.align 256 +frame2_palette3: +${byte2byte(frame[1].palette3)} + +.align 4096 +frame2_bottom: +${byte2byte(frame[1].bitmap.slice(half))} -bitmap: -${byte2byte(bitmap)} `; } @@ -744,7 +793,7 @@ async function main() { let {width, height, lines} = await convert(process.argv[2], nbits, reps); - let asm = genAssembly(width, height, nbits, lines); + let asm = genAssembly(width, height, nbits, lines, reps); writeFileSync(process.argv[3], asm, "utf-8"); let heightPerFrame = height / reps; diff --git a/dither4.s b/dither4.s index 5682f87..b75a029 100644 --- a/dither4.s +++ b/dither4.s @@ -15,6 +15,8 @@ NMIEN = $D40E framebuffer = $a000 framebuffer2 = $b000 +framebuffer3 = $8000 +framebuffer4 = $9000 temp1l = $80 temp1h = $81 @@ -64,9 +66,32 @@ displaylist: .byte $0e .endrep + .byte $41 ; jump and blank + .addr displaylist_part2 + +displaylist_part2: + ; 40 lines overscan + .repeat 5 + .byte $70 ; 8 blank lines + .endrep + + ; 160 lines graphics + ; ANTIC mode e (160px 2bpp, 1 scan line per line) + .byte $4e + .addr framebuffer3 + .repeat height / 2 - 1 + .byte $0e + .endrep + .byte $4e + .addr framebuffer4 + .repeat height / 2 - 1 + .byte $0e + .endrep + .byte $41 ; jump and blank .addr displaylist + audio_high_byte: .scope .macro byteseq val @@ -185,8 +210,8 @@ each_scanline: .macro audio_play_lo ; 11 cycles lda audiotemp ; 3 cyc - and #$0f ; 2 cyc - ora #$10 ; 2 cyc + ;and #$0f ; 2 cyc + ;ora #$10 ; 2 cyc sta AUDC1 ; 4 cyc .endmacro @@ -221,9 +246,9 @@ each_scanline: audio_cont: .endmacro - audio_prep + ;audio_prep inner_scanline - audio_play_lo + ;audio_play_lo inner_scanline ;audio_play_hi