Created
October 20, 2020 12:20
-
-
Save sasq64/5177c7b0ff752cbcb459f63d9dbfede5 to your computer and use it in GitHub Desktop.
Revisions
-
sasq64 created this gist
Oct 20, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,307 @@ XPOS = $07 PATTERN = $0800; 48 columns * 48 rows * 8 bytes + 48 columns = $4830 bytes SCALEDBMP = $8c00; 25 columns * 25 rows * 8 bytes = $1388 bytes pointer = $7a pointer2 = $33 pointer3 = $35 pointer4 = $22 linecount = pointer3 xfraction = $02 yfraction = $03 yshrinked = $04 srccount = $05 srcpattern = $06 destpattern = $07 ybuffer = $08 destpos = $09 character = $02 currchar = $03 charpattern = $04 ADDYTOPTR = $a8fb ADDTOPTR = $a8fc ADDTOPTR2 = $b6cb ADDTOPTR3 = $b699 ADDTOPTR4 = $b5f8 ;* = $032c; CLALL vector !section "main", $032c !byte <code, >code code sei ; music to my ears ldy #$19 - lda ringmoddata - 1,y sta $d400 - 1,y dey bne - ; generate pattern on a linear bitmap (384*385 pixels) ; x = 0, carry = 1 lda #>PATTERN sta pointer + 1 tya - sta (pointer),y iny bne - ldx #>$4830 genpattern ldy #$00 lda (pointer),y ror eor (pointer),y ldy #48; next line (48 * 8 = 384) sta (pointer),y inc pointer; next column bne genpattern inc pointer + 1 dex bne genpattern genanimation ; scale and convert all animation frames lda #$a0 progress = * + 1 sta end + 1 inc progress ; scale linear bitmap ; x = 0 lda #<(PATTERN + $30); first line is at $0832 sta pointer lda #>(PATTERN + $30) sta pointer + 1 stx pointer2 lda #>SCALEDBMP sta pointer2 + 1 stx yfraction stx yshrinked lda #200; scaled bitmap lines sta linecount framecount = * + 1 ldx #NUMFRAMES - 1 scalebmp lda #$00 tay $ sta (pointer2),y iny bpl - yshrink lda linecount lsr; 1..100 pha and #$07 tay sec lda #$00 $ rol dey bpl - sta destpattern; center triangles... pla lsr lsr lsr sta destpos; ... for symmetry tya; a = $ff iny; y = $00 sty xfraction beq firstpixel scaleline lda scale,x adc xfraction sta xfraction bcc + asl srcpattern dec srccount $ asl srcpattern dec srccount bpl shiftpixel iny lda srccount firstpixel and #$07 sta srccount cmp #$07 lda (pointer),y bcs + asl $ asl sta srcpattern shiftpixel rol destpattern bcc scaleline sty ybuffer ldy destpos lda destpattern ora (pointer2),y sta (pointer2),y lda #$01 sta destpattern inc destpos cpy #25 - 1; destination columns ldy ybuffer bcc scaleline lda #48; columns per source line jsr ADDTOPTR asl yshrinked bcs noyshrink lda scale,x adc yfraction sta yfraction ror yshrinked bmi yshrink noyshrink lda #25; columns per destination line jsr ADDTOPTR2 dec linecount bne scalebmp ; convert linear bitmap to screen + charset lda screens,x sta pointer + 1 lda charsets,x sta pointer2 + 1 ldy #$00; char $00 is empty sty character sty pointer sty pointer2 tya inc $01; RAM under IO $ sta (pointer),y; clear top left of screen sta (pointer2),y; clear char $00 iny cpy #$08 bne - dec $01 tax lda #XPOS sta pointer lda #>SCALEDBMP sta pointer3 + 1 convrow ldx #25; convert 25 char columns convcolumn txs ldx #$07 ldy #8 * 25 $ tya sec sbc #25 tay lda (pointer3),y sta charpattern,x dex bpl - tsx checkchar iny cpy #$08 ora charpattern,y bcc checkchar beq emptychar ; encountered non-empty character tya; next character in charset jsr ADDTOPTR2 inc $01; RAM under IO copychar lda charpattern,y sta (pointer2),y dey bpl copychar dec $01 inc character lda character emptychar ldy #$00 inc $01; RAM under IO sta (pointer),y dec $01 iny jsr ADDYTOPTR; next screen column tya jsr ADDTOPTR3 dex bne convcolumn txa tay inc $01; RAM under IO $ sta (pointer),y; clear border chars iny cpy #40 - 25 bne - dec $01 lda #7 * 25 jsr ADDTOPTR3 jsr ADDYTOPTR; next screen row cmp #<((40 * 25) + XPOS) bne convrow ; generate ALL THE animation frames o/ dec framecount bmi copyanimdata jmp genanimation ; loop animation copyanimdata ; copy animation data over pattern stx pointer3 lda #>$0c00 sta pointer3 + 1 ldy #>$6c00 stx pointer4 sty pointer4 + 1 $ lda #$80 jsr $b68c; copy from ($22) to ($35), a = $35 lda #$80 jsr ADDTOPTR4 dec charsets + 2; $38 bne - lsr $d016 loopanim ldx #NUMFRAMES - 1 nextframe ldy #$02 waitvbl bit $d011 bpl waitvbl $ bit $d011 bmi - dey bne waitvbl lda d018,x sta $d018 lda charsets,x asl rol rol eor #$03 sta $dd00 dex bpl nextframe bmi loopanim ringmoddata !byte $69, $02, $00, $00, $25, $00, $f0, $6a !byte $02, $00, $00, $25, $00, $f0, $6b, $02 !byte $00, $00, $25, $00, $f0, $00, $27, $f7 !byte $1f NUMFRAMES = 16 !define scalevalue(frame) { 256 * (exp(frame / NUMFRAMES * log(2)) - 1) } scale !fill 16 { scalevalue(i) } d018 !byte $3a, $8c, $9e !byte $04, $16, $28, $3c, $ae !byte $2a, $8c, $9e !byte $16, $28, $3a, $4c, $5e screens !byte >$6c00, >$8000, >$8400; these are copied to $0c00 !byte >$4000, >$4400, >$4800, >$4c00, >$6800; gap at $6c00-$7000 and $8000-$8800 -> $0c00-$1000 and $2000-$2800 ; scaled bitmap at $8c00..$a000 approx. !byte >$8800, >$a000, >$a400 !byte >$c400, >$c800, >$cc00, >$d000, >$d400 charsets !byte >$2800, >$3000, >$3800 !byte >$5000, >$5800, >$6000, >$7000, >$7800 !byte >$a800, >$b000, >$b800 !byte >$d800, >$e000, >$e800, >$f000, >$f800 !byte $20,$b,$12,$c end