From 76ebed5871c20411a6aa0605eeda4aadb0c2afc9 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 7 Dec 2022 18:20:24 -0800 Subject: [PATCH] wip 2frame --- dither-image.js | 28 +++++++++++----------- dither4.s | 62 ++++++++++++++++++------------------------------- 2 files changed, 37 insertions(+), 53 deletions(-) diff --git a/dither-image.js b/dither-image.js index 1a441c8..b448098 100644 --- a/dither-image.js +++ b/dither-image.js @@ -667,7 +667,7 @@ function genAssembly(width, height, nbits, lines, reps) { palette3: new Uint8Array(linesEach), bitmap: new Uint8Array(stride * linesEach), }; - for (let y = 0; y < lines.length; y++) { + for (let y = 0; y < linesEach; y++) { let base = linesEach * i; console.log(i, y, base); frame.palette1[y] = lines[y + base].palette[1]; @@ -694,49 +694,49 @@ function genAssembly(width, height, nbits, lines, reps) { .export frame2_palette2 .export frame2_palette3 -.segment buffers +.segment "BUFFERS" .align 4096 -frame1_top -${byte2byte(frame[0].bitmap.slice(0, half))} +frame1_top: +${byte2byte(frames[0].bitmap.slice(0, half))} .align 256 frame1_palette1: -${byte2byte(frame[0].palette1)} +${byte2byte(frames[0].palette1)} .align 256 frame1_palette2: -${byte2byte(frame[0].palette2)} +${byte2byte(frames[0].palette2)} .align 256 frame1_palette3: -${byte2byte(frame[0].palette3)} +${byte2byte(frames[0].palette3)} .align 4096 frame1_bottom: -${byte2byte(frame[0].bitmap.slice(half))} +${byte2byte(frames[0].bitmap.slice(half))} .align 4096 -frame2_top -${byte2byte(frame[1].bitmap.slice(0, half))} +frame2_top: +${byte2byte(frames[1].bitmap.slice(0, half))} .align 256 frame2_palette1: -${byte2byte(frame[1].palette1)} +${byte2byte(frames[1].palette1)} .align 256 frame2_palette2: -${byte2byte(frame[1].palette2)} +${byte2byte(frames[1].palette2)} .align 256 frame2_palette3: -${byte2byte(frame[1].palette3)} +${byte2byte(frames[1].palette3)} .align 4096 frame2_bottom: -${byte2byte(frame[1].bitmap.slice(half))} +${byte2byte(frames[1].bitmap.slice(half))} `; } diff --git a/dither4.s b/dither4.s index b75a029..d5acd40 100644 --- a/dither4.s +++ b/dither4.s @@ -13,11 +13,6 @@ WSYNC = $D40A VCOUNT = $D40B NMIEN = $D40E -framebuffer = $a000 -framebuffer2 = $b000 -framebuffer3 = $8000 -framebuffer4 = $9000 - temp1l = $80 temp1h = $81 temp1 = temp1l @@ -40,13 +35,20 @@ scanline_max = (lines_per_frame - scanline_offset) / 2 .data -.import palette1 -.import palette2 -.import palette3 -.import bitmap .import audio_samples .import audio_samples_end +.import frame1_top +.import frame1_bottom +.import frame1_palette1 +.import frame1_palette2 +.import frame1_palette3 +.import frame2_top +.import frame2_bottom +.import frame2_palette1 +.import frame2_palette2 +.import frame2_palette3 + displaylist: ; 40 lines overscan .repeat 5 @@ -56,12 +58,12 @@ displaylist: ; 160 lines graphics ; ANTIC mode e (160px 2bpp, 1 scan line per line) .byte $4e - .addr framebuffer + .addr frame1_top .repeat height / 2 - 1 .byte $0e .endrep .byte $4e - .addr framebuffer2 + .addr frame1_bottom .repeat height / 2 - 1 .byte $0e .endrep @@ -78,12 +80,12 @@ displaylist_part2: ; 160 lines graphics ; ANTIC mode e (160px 2bpp, 1 scan line per line) .byte $4e - .addr framebuffer3 + .addr frame2_top .repeat height / 2 - 1 .byte $0e .endrep .byte $4e - .addr framebuffer4 + .addr frame2_bottom .repeat height / 2 - 1 .byte $0e .endrep @@ -121,24 +123,6 @@ audio_high_byte: .export start .proc start - ; Copy the bitmap into our framebuffer - lda #.lobyte(bitmap) - sta temp1l - lda #.hibyte(bitmap) - sta temp1h - lda #.lobyte(framebuffer) - sta temp2l - lda #.hibyte(framebuffer) - sta temp2h - jsr copy_half_frame - - ; Second half of bitmap has to be separately aligned - lda #.lobyte(framebuffer2) - sta temp2l - lda #.hibyte(framebuffer2) - sta temp2h - jsr copy_half_frame - ; Set up the audio sample buffer lda #.lobyte(audio_samples) sta sample_ptrl @@ -150,7 +134,7 @@ audio_high_byte: sta DMACTL ; Disable VBI and DLI but allow Reset - lda #32 + lda #$20 sta NMIEN ; Set up the display list @@ -186,16 +170,16 @@ each_scanline: sta audiotemp ; 3 cyc .endmacro - .macro inner_scanline + .macro inner_scanline frame_base ; it'll fire on unused lines, but harmlessly ldy scanline ; 3 cyc inc scanline ; 5 cyc ; Leisurely memory fetches - lda palette1,y ; 5 - pha ; ...3? - ldx palette2,y ; 5 - lda palette3,y ; 5 + lda frame1_palette1,y ; 5 @FIXME alternate + pha ; ...3? + ldx frame1_palette2,y ; 5 + lda frame1_palette3,y ; 5 tay pla @@ -210,8 +194,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