work in progress

This commit is contained in:
Brooke Vibber 2022-11-25 11:51:27 -08:00
parent dcf5cd2edd
commit f5f2c5dbbf
3 changed files with 97 additions and 17 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.DS_Store
*.o
*.xex
*.pxd
canvas*.png

View file

@ -530,9 +530,12 @@ function decimate(input, palette, n) {
let least = Infinity; let least = Infinity;
let pick = -1; let pick = -1;
for (let i = 1; i < decimated.length; i++) { for (let i = 1; i < decimated.length; i++) {
if (i == 0) { if (decimated[i] === palette256[0]) {
continue; // keep black always continue; // keep black always
} }
if (decimated[i] === palette256[0x0f]) {
continue; // keep white always
}
//let coolFactor = popularity[i]; //let coolFactor = popularity[i];
@ -552,11 +555,15 @@ function decimate(input, palette, n) {
} }
} }
let old = decimated.length; let old = decimated.length;
//decimated.splice(pick, 1);
decimated = decimated.filter((rgb, i) => { decimated = decimated.filter((rgb, i) => {
if (i == pick) { if (i == pick) {
return false; return false;
} }
if (i > 0 && popularity[i] == 0) { if (rgb !== palette256[0] && popularity[i] == 0) {
return false;
}
if (rgb !== palette256[0x0f] && popularity[i] == 0) {
return false; return false;
} }
return true; return true;

View file

@ -1,23 +1,91 @@
SAVMSC = $58 SAVMSC = $58
SDMCTL = $22F
SDLSTL = $230
SDLSTH = $231
COLPF0 = $D016
COLPF1 = $D017
COLPF2 = $D018
COLPF3 = $D019
COLBK = $D01A
WSYNC = $D40A
VCOUNT = $D40B
NMIEN = $D40E
.data
.import palette1
.import palette2
.import palette3
.import framebuffer
displaylist:
.repeat 3
.byte $70 ; 8 blank lines
.endrep
.byte $4e ; ANTIC mode e (160px 2bpp, 1 scan line per line)
.addr framebuffer
.repeat 191
.byte $0e
.endrep
.byte $41 ; jump and blank
.addr displaylist
.code .code
.export start .export start
.proc start ; Loop through scan lines updating the palette
; Get the framebuffer address and just write new fun values into it .proc update_palette
; x: byte to write in lda palette1,y
; y: index into the first 256 bytes of buffer pha
ldx palette2,y
lda palette3,y
tay
pla
; Wait for horizontal blank
sta WSYNC
; Update color registers as fast as possible
sta COLPF0
stx COLPF1
sty COLPF2
rst
.endproc
.proc start
; Disable display DMA
lda #$00
sta SDMCTL
; Set up the display list
lda .low displaylist
sta SDLSTL
lda .high displaylist
sta SDLSTH
; Turn off interrupts except reset button
lda #$20
sta NMIEN
; Manually wait for first scan line
wait_vblank:
lda VCOUNT
bnz wait_vblank
; Re-enable display DMA
lda #$22
sta SDMCTL
even_scanline:
ldy VCOUNT
jsr update_palette
odd_scanline:
ldy VCOUNT
iny
jsr update_palette
jmp even_scanline
ldx #00
outer_loop:
txa
ldy #00
inner_loop:
sta (SAVMSC),y
iny
bne inner_loop
inx
jmp outer_loop
; infinite loop
.endproc .endproc