cliff: sort of have bg mask sprite more or less working

This commit is contained in:
Vince Weaver 2024-09-01 00:51:31 -04:00
parent d4add23de1
commit 7d6ecf97f2

View File

@ -3,8 +3,11 @@
;=============================================== ;===============================================
; used primarily to draw Rather Dashing ; used primarily to draw Rather Dashing
;=============================================== ;===============================================
; *cannot* handle sprites bigger than 256 bytes
;
; attempts to shift for odd/even column ; attempts to shift for odd/even column
; cannot handle sprites bigger than 256 bytes ; ideally sprite palette has precedence over background
; if completely transparent then let bg keep palette
; Location at CURSOR_X CURSOR_Y ; Location at CURSOR_X CURSOR_Y
@ -53,8 +56,7 @@ hgr_draw_sprite_bg_mask:
; based on head location ; based on head location
; see chart later ; see chart later
lda PEASANT_Y ; this should be CURSOR_Y???? lda CURSOR_Y
; they should in theory be same
sec sec
sbc #48 ; Y=48 sbc #48 ; Y=48
lsr ; div by 8 lsr ; div by 8
@ -67,14 +69,18 @@ hgr_draw_sprite_bg_mask:
; set up sprite pointers ; set up sprite pointers
lda walk_sprites_data_l,X lda walk_sprites_data_l,X
sta h728_smc1+1 sta h728_smc1+1
sta h728_smc2+1
lda walk_sprites_data_h,X lda walk_sprites_data_h,X
sta h728_smc1+2 sta h728_smc1+2
sta h728_smc2+2
; set up mask pointers ; set up mask pointers
lda walk_mask_data_l,X lda walk_mask_data_l,X
sta h728_smc3+1 sta h728_smc3+1
sta h728_smc4+1
lda walk_mask_data_h,X lda walk_mask_data_h,X
sta h728_smc3+2 sta h728_smc3+2
sta h728_smc4+2
;=============================== ;===============================
; main loop ; main loop
@ -85,7 +91,8 @@ hgr_draw_sprite_bg_mask:
stx CURRENT_ROW ; zero row counter stx CURRENT_ROW ; zero row counter
hgr_sprite_bm_yloop: hgr_sprite_bm_yloop:
lda MASK_COUNTDOWN lda MASK_COUNTDOWN ; FIXME is this same as CURRENT_ROW
and #$3 ; only update every 4th and #$3 ; only update every 4th
bne mask_good bne mask_good
@ -121,7 +128,7 @@ mask_good:
lda hposn_low,Y lda hposn_low,Y
sta GBASL sta GBASL
lda hposn_high,Y lda hposn_high,Y
sta GBASH sta GBASH ; always page2
;============================ ;============================
@ -135,28 +142,79 @@ mask_good:
hsbm_inner_loop: hsbm_inner_loop:
lda MASK lda MASK
bne draw_sprite_skip bne draw_sprite_skip
;============================ ;============================
; not masked so actually draw ; not masked so actually draw
;=========================
; pick if even or odd
lda CURSOR_X
ror
bcs hsbm_draw_sprite_odd
;============================
hsbm_draw_sprite_even:
h728_smc1: h728_smc1:
lda $d000,X ; load sprite value lda $d000,X ; load sprite value
sta TEMP_SPRITE sta TEMP_SPRITE
h728_smc3: h728_smc3:
lda $d000,X ; load mask value lda $d000,X ; load mask value
sta TEMP_MASK
jmp hsbm_draw_sprite_both
hsbm_draw_sprite_odd:
h728_smc2:
lda $f000,X ; load sprite data
; PSSS SSSS
; rol C=P, SSSS SSST
; want to set bit7 to C?
rol SPRITE_TEMP
rol
sta SPRITE_TEMP
bcc hsbm_pal0
hsbm_pal1:
ora #$80 ; set pal bit
bne hsbm_pal_done
hsbm_pal0:
and #$7f ; clear pal bit
hsbm_pal_done:
sta TEMP_SPRITE
h728_smc4:
lda $f000,X ; load sprite data
rol MASK_TEMP
rol
sta MASK_TEMP
hsbm_draw_sprite_both: hsbm_draw_sprite_both:
lda (GBASL),Y ; load background eor #$FF
eor TEMP_SPRITE and #$7F
and TEMP_MASK sta TEMP_MASK
; if mask is $7f then skip drawing
cmp #$7f
beq draw_sprite_skip
; do actual sprite-ing
lda (GBASL),Y ; load background
and TEMP_MASK
ora TEMP_SPRITE
eor (GBASL),Y ; store out
sta (GBASL),Y ; store out sta (GBASL),Y ; store out
draw_sprite_skip: draw_sprite_skip: