base:8x8_charset_pixel-blend-in
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:8x8_charset_pixel-blend-in [2015-04-17 04:30] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Blend charsets ====== | ||
+ | By Monte Carlos | ||
+ | |||
+ | This little routine blends in a charset at $2000 into $2800 (only the first 64 chars, $0200 bytes), pixel by pixel | ||
+ | with random values. | ||
+ | |||
+ | < | ||
+ | |||
+ | ;done with Turbo-Assembler in VICE | ||
+ | |||
+ | |||
+ | |||
+ | *= $1000 | ||
+ | |||
+ | sei | ||
+ | lda #51 | ||
+ | sta $01 | ||
+ | ldy #$00 | ||
+ | a1 lda $d000, | ||
+ | sta $2000, | ||
+ | lda $d100,y | ||
+ | sta $2100,y | ||
+ | lda #$00 | ||
+ | sta $2800, | ||
+ | sta $2900,y | ||
+ | iny | ||
+ | bne a1 | ||
+ | lda #55 | ||
+ | sta $01 | ||
+ | cli | ||
+ | |||
+ | jmp a2 | ||
+ | |||
+ | ; | ||
+ | |||
+ | rand inc val | ||
+ | ldy val | ||
+ | lda $dc04 ;generate random | ||
+ | eor $fedc, | ||
+ | eor $d012 | ||
+ | sta $57 ;save it in $57 | ||
+ | rts | ||
+ | |||
+ | val .byte 0 | ||
+ | |||
+ | ; | ||
+ | |||
+ | a2 jsr $e518 ; | ||
+ | lda #$01 ; | ||
+ | sta $0286 ; | ||
+ | lda #$93 ;color white | ||
+ | jsr $ffd2 ; | ||
+ | ldy #$00 | ||
+ | a3 tya | ||
+ | sta $0400,y ;show chars 0-63 | ||
+ | | ||
+ | cpy #$40 | ||
+ | bne a3 | ||
+ | lda #26 ; | ||
+ | sta $d018 ;on ($2800) | ||
+ | |||
+ | lda #$00 | ||
+ | sta $58 ; | ||
+ | |||
+ | ; | ||
+ | ;create random list of values from 0-63 | ||
+ | ;for each bit of a char and save it | ||
+ | ;to $03c0-$03ff | ||
+ | |||
+ | a4 jsr rand ;filter out | ||
+ | and #$c0 ;values 64-255 | ||
+ | bne a4 ;and get new random | ||
+ | |||
+ | lda $58 | ||
+ | bne a5 | ||
+ | a7 ldx $58 ; | ||
+ | lda $57 ;accept first/ | ||
+ | sta $03c0, | ||
+ | inc $58 ;for the list | ||
+ | lda $58 ; | ||
+ | cmp #64 ;64 values? | ||
+ | beq a8 ;list finished! | ||
+ | jmp a4 | ||
+ | |||
+ | a5 ldy #$00 ; | ||
+ | a6 lda $03c0, | ||
+ | cmp $57 ;test if value in | ||
+ | beq a4 ;$57 is unique | ||
+ | | ||
+ | cpy $58 ; | ||
+ | bne a6 ; | ||
+ | |||
+ | jmp a7 ; | ||
+ | |||
+ | ; | ||
+ | |||
+ | a8 ldy #$20 | ||
+ | ldx #$00 | ||
+ | lda #$28 ;$fa/$fb points at | ||
+ | stx $fa ; | ||
+ | sty $fb | ||
+ | stx $fc ; | ||
+ | sta $fd ; | ||
+ | |||
+ | stx $f9 ; | ||
+ | |||
+ | |||
+ | ldx #$00 | ||
+ | |||
+ | a12 stx $02 | ||
+ | |||
+ | lda $03c0,x ; | ||
+ | | ||
+ | adc $03c0,x ;duplicate content | ||
+ | ;of $03c0,x | ||
+ | | ||
+ | ; | ||
+ | lda bitpnt, | ||
+ | sta $5a ;the byte | ||
+ | | ||
+ | lda bitpnt, | ||
+ | sta $5b ;at the bit on the | ||
+ | ; | ||
+ | ; | ||
+ | |||
+ | |||
+ | ldy $5a ; | ||
+ | ldx $5b ; | ||
+ | lda ($fa), | ||
+ | and bits, | ||
+ | beq a9 ; | ||
+ | lda bits, | ||
+ | | ||
+ | adc ($fc), | ||
+ | sta ($fc), | ||
+ | |||
+ | a9 lda #$08 | ||
+ | clc | ||
+ | adc $fa | ||
+ | sta $fa ;next char (source) | ||
+ | bcc a10 | ||
+ | inc $fb | ||
+ | |||
+ | a10 lda #$08 | ||
+ | clc | ||
+ | adc $fc | ||
+ | sta $fc ;next char (target) | ||
+ | bcc a11 | ||
+ | inc $fd | ||
+ | |||
+ | a11 ldx $02 | ||
+ | |||
+ | inc $f9 | ||
+ | lda $f9 | ||
+ | cmp #64 | ||
+ | bne a12 | ||
+ | |||
+ | lda #$00 | ||
+ | sta $f9 | ||
+ | |||
+ | ldy #$20 ; | ||
+ | ldx #$00 ;and start with the | ||
+ | lda #$28 ;next pixel | ||
+ | stx $fa | ||
+ | sty $fb | ||
+ | stx $fc | ||
+ | sta $fd | ||
+ | |||
+ | ldy #$00 | ||
+ | w2 dey | ||
+ | ldx #$00 | ||
+ | w1 | ||
+ | cpx #$80 | ||
+ | bne w1 | ||
+ | cpy #$e0 | ||
+ | bne w2 | ||
+ | |||
+ | ldx $02 | ||
+ | |||
+ | inx | ||
+ | cpx #64 | ||
+ | bne a12 | ||
+ | |||
+ | rts | ||
+ | |||
+ | |||
+ | ; | ||
+ | |||
+ | bitpnt | ||
+ | .byte 0,6,0,7 | ||
+ | .byte 1, | ||
+ | .byte 1,6,1,7 | ||
+ | .byte 2, | ||
+ | .byte 2,6,2,7 | ||
+ | .byte 3, | ||
+ | .byte 3,6,3,7 | ||
+ | .byte 4, | ||
+ | .byte 4,6,4,7 | ||
+ | .byte 5, | ||
+ | .byte 5,6,5,7 | ||
+ | .byte 6, | ||
+ | .byte 6,6,6,7 | ||
+ | .byte 7, | ||
+ | .byte 7,6,7,7 | ||
+ | |||
+ | bits .byte 128, | ||
+ | |||
+ | </ | ||
+ | |||
+ | download: [[http:// |
base/8x8_charset_pixel-blend-in.txt · Last modified: 2015-04-17 04:30 by 127.0.0.1