xmas2018: make sprites non-transparent

and vapor lock again
This commit is contained in:
Vince Weaver 2018-12-18 14:48:58 -05:00
parent 5a0a148666
commit c82b4c8bdb
5 changed files with 106 additions and 86 deletions

View File

@ -24,7 +24,7 @@ XMAS2018: xmas2018.o
xmas2018.o: xmas2018.s \ xmas2018.o: xmas2018.s \
zp.inc hardware.inc \ zp.inc hardware.inc \
vapor_lock.s delay_a.s wait_keypress.s \ vapor_lock.s delay_a.s wait_keypress.s gr_putsprite.s \
play_music.s mockingboard.s rts.s \ play_music.s mockingboard.s rts.s \
wreath.s wreath.img.lz4 sprites.inc \ wreath.s wreath.img.lz4 sprites.inc \
ball.s ball.img.lz4 greets.raw.lz4 gr_scroll.s \ ball.s ball.img.lz4 greets.raw.lz4 gr_scroll.s \

View File

@ -16,3 +16,5 @@ Memory Map:
SIZE: SIZE:
3903 -- 12/18 3903 -- 12/18
3647 -- use LZ4 encryption on scroll text 3647 -- use LZ4 encryption on scroll text
3903 -- add in support for all 5 candles
3647 -- make sprites non-transparent

View File

@ -1,31 +1,15 @@
;============================================= ;=============================================
; put_sprite ; put_sprite_no_transparency
;============================================= ;=============================================
; Sprite to display in INH,INL ; Sprite to display in INH,INL
; Location is XPOS,YPOS ; Location is XPOS,YPOS
; Note, only works if YPOS is multiple of two ; Note, only works if YPOS is multiple of two
; time= 28 setup ; time= 28 + Y* (34+ X*31 + 17) + 5
; Y*outerloop ; = 33 + Y*(51+31*X)
; outerloop = 34 setup
; X*innerloop
; innerloop = 30 if $00 17+13(done)
; 64 if $0X 16+7+8+20(put_sprite_mask)+13(done)
; 69 if $X0 16+8+7+5+20(put_sprite_mask)+13(done)
; 54 if if $XX 16+8+8+9(put_all)+13(done)
put_sprite_no_transparency:
; -1 for last iteration
; 18 (-1 for last)
; 6 return
; so cost = 28 + Y*(34+18)+ (INNER-Y) -1 + 6
; = 33 + Y*(52)+(INNER-Y)
; = 33 + Y*(52)+ [30A + 64B + 69C + 54D]-Y
put_sprite:
ldy #0 ; byte 0 is xsize ; 2 ldy #0 ; byte 0 is xsize ; 2
lda (INL),Y ; 5 lda (INL),Y ; 5
@ -34,7 +18,7 @@ put_sprite:
lda (INL),Y ; byte 1 is ysize ; 5 lda (INL),Y ; byte 1 is ysize ; 5
sta CV ; ysize is in CV ; 3 sta CV ; ysize is in CV ; 3
iny ; 2 iny ; Y now points to begin of sprite data ; 2
lda YPOS ; make a copy of ypos ; 3 lda YPOS ; make a copy of ypos ; 3
sta TEMPY ; as we modify it ; 3 sta TEMPY ; as we modify it ; 3
@ -42,7 +26,7 @@ put_sprite:
; 28 ; 28
put_sprite_loop: put_sprite_loop:
sty TEMP ; save sprite pointer ; 3 sty TEMP ; save sprite pointer ; 3
ldy TEMPY ; 3 ldy TEMPY ; get YPOS ; 3
lda gr_offsets,Y ; lookup low-res memory address ; 4 lda gr_offsets,Y ; lookup low-res memory address ; 4
clc ; 2 clc ; 2
adc XPOS ; add in xpos ; 3 adc XPOS ; add in xpos ; 3
@ -60,78 +44,29 @@ put_sprite_loop:
put_sprite_pixel: put_sprite_pixel:
lda (INL),Y ; get sprite colors ; 5 lda (INL),Y ; get sprite colors ; 5
iny ; increment sprite pointer ; 2 iny ; increment sprite pointer ; 2
sty TEMP ; save sprite pointer ; 3 sty TEMP ; save sprite pointer ; 3
ldy #$0 ; 2 ldy #0 ; set out pointer ; 2
; check if completely transparent
; if so, skip
cmp #$0 ; if all zero, transparent ; 2
beq put_sprite_done_draw ; don't draw it ; 2nt/3
;==============
; 16/17
sta COLOR ; save color for later ; 3
; check if top pixel transparent
and #$f0 ; check if top nibble zero ; 2
bne put_sprite_bottom ; if not skip ahead ; 2nt/3
;==============
; 7/8
lda #$f0 ; setup mask ; 2
sta MASK ; 3
bmi put_sprite_mask ; always? ; 3
;=============
; 8
put_sprite_bottom:
lda COLOR ; re-load color ; 3
and #$0f ; check if bottom nibble zero ; 2
bne put_sprite_all ; if not, skip ahead ; 2nt/3
;=============
; 7/8
lda #$0f ; 2
sta MASK ; setup mask ; 3
;===========
; 5
put_sprite_mask:
lda (OUTL),Y ; get color at output ; 5
and MASK ; mask off unneeded part ; 3
ora COLOR ; or the color in ; 3
sta (OUTL),Y ; store it back ; 6
jmp put_sprite_done_draw ; we are done ; 3
;===========
; 20
put_sprite_all:
lda COLOR ; load color ; 3
sta (OUTL),Y ; and write it out ; 6 sta (OUTL),Y ; and write it out ; 6
;============ ;============
; 9 ; 18
put_sprite_done_draw:
ldy TEMP ; restore sprite pointer ; 3 ldy TEMP ; restore sprite pointer ; 3
inc OUTL ; increment output pointer ; 5 inc OUTL ; increment output pointer ; 5
dex ; decrement x counter ; 2 dex ; decrement x counter ; 2
bne put_sprite_pixel ; if not done, keep looping ; 2nt/3 bne put_sprite_pixel ; if not done, keep looping ; 3
;============== ;==============
; 12/13 ; 13
; -1
inc TEMPY ; each line has two y vars ; 5 inc TEMPY ; each line has two y vars ; 5
inc TEMPY ; 5 inc TEMPY ; 5
dec CV ; decemenet total y count ; 5 dec CV ; decemenet total y count ; 5
bne put_sprite_loop ; loop if not done ; 2nt/3 bne put_sprite_loop ; loop if not done ; 3
;============== ;==============
; 17/18 ; 17
; -1
rts ; return ; 6 rts ; return ; 6

View File

@ -1,3 +1,10 @@
wide_empty:
.byte $2,$3
.byte $00,$00
.byte $00,$00
.byte $00,$00
wide_flame0: wide_flame0:
.byte $2,$3 .byte $2,$3
.byte $dd,$dd .byte $dd,$dd
@ -7,6 +14,7 @@ wide_flame0:
; = 33 + Y*(52)+ [30A + 64B + 69C + 54D]-Y ; = 33 + Y*(52)+ [30A + 64B + 69C + 54D]-Y
; = 33 + 3*52 + 30*0 + 64*0 + 69*0 + 54*6 - 3 ; = 33 + 3*52 + 30*0 + 64*0 + 69*0 + 54*6 - 3
; = 510 ; = 510
; = 33 + Y*(51+31*X) = 33 + 3*(51+62) = 372
wide_flame1: wide_flame1:
.byte $2,$3 .byte $2,$3
@ -39,6 +47,12 @@ wide_flame3:
; = 510 ; = 510
empty:
.byte $1,$3
.byte $00
.byte $00
.byte $00
flame0: flame0:
.byte $1,$3 .byte $1,$3
.byte $dd .byte $dd
@ -79,4 +93,8 @@ flame3:
; = 33 + 3*52 + 30*0 + 64*0 + 69*0 + 54*3 - 3 ; = 33 + 3*52 + 30*0 + 64*0 + 69*0 + 54*3 - 3
; = 348 ; = 348
wide_lookup:
.byte >wide_flame0,>wide_flame1,>wide_flame2,>wide_flame3
flame_lookup:
.byte >flame0,>flame1,>flame2,>flame3

View File

@ -120,12 +120,13 @@ wrloopF:dex ; 2
; do_nothing should be 4550 ; do_nothing should be 4550
; play music 1023 ; play music 1023
; sprite 536 ; sprites (536*3+374*2) = ;2356
; 398
; -18 frame adjust ; -18 frame adjust
; -7 end detect ; -7 end detect
; -10 keypress ; -10 keypress
; =========== ; ===========
; 2956 ; 1136
@ -159,6 +160,8 @@ done_wframing:
; draw sprites ; draw sprites
;======================== ;========================
; Candle 1 (Hope)
lda #>wide_flame0 ; 2 lda #>wide_flame0 ; 2
sta INH ; 3 sta INH ; 3
lda #<wide_flame0 ; 2 lda #<wide_flame0 ; 2
@ -168,14 +171,76 @@ done_wframing:
sta XPOS ; 3 sta XPOS ; 3
lda #4 ; 2 lda #4 ; 2
sta YPOS ; 3 sta YPOS ; 3
jsr put_sprite ; 6+510 jsr put_sprite_no_transparency ; 6+372
;===============
; 398
.if 0
; Candle 2 (Peace)
lda #>flame0 ; 2
sta INH ; 3
lda #<flame0 ; 2
sta INL ; 3
lda #14 ; 2
sta XPOS ; 3
lda #4 ; 2
sta YPOS ; 3
jsr put_sprite_no_transparency ; 6+348
;===============
; 374
; Candle 3 (Joy)
lda #>flame0 ; 2
sta INH ; 3
lda #<flame0 ; 2
sta INL ; 3
lda #31 ; 2
sta XPOS ; 3
lda #4 ; 2
sta YPOS ; 3
jsr put_sprite_no_transparency ; 6+348
;===============
; 374
; Candle 4 (Love)
lda #>wide_flame1 ; 2
sta INH ; 3
lda #<wide_flame0 ; 2
sta INL ; 3
lda #26 ; 2
sta XPOS ; 3
lda #4 ; 2
sta YPOS ; 3
jsr put_sprite_no_transparency ; 6+510
;=============== ;===============
; 536 ; 536
; Try X=117 Y=5 cycles=2956 ; Candle 5 (Christmas)
ldy #5 ; 2 lda #>wide_flame0 ; 2
wrloop1:ldx #117 ; 2 sta INH ; 3
lda #<wide_flame0 ; 2
sta INL ; 3
lda #20 ; 2
sta XPOS ; 3
lda #4 ; 2
sta YPOS ; 3
jsr put_sprite_no_transparency ; 6+510
;===============
; 536
.endif
; Try X=225 Y=1 cycles=1132 R4
; Try X=205 Y=3 cycles=3094
ldy #3 ; 2
wrloop1:ldx #205 ; 2
wrloop2:dex ; 2 wrloop2:dex ; 2
bne wrloop2 ; 2nt/3 bne wrloop2 ; 2nt/3
dey ; 2 dey ; 2