peasant: try to keep peasant Y at a multiple of 4

also initial bg priority support
This commit is contained in:
Vince Weaver 2021-08-24 21:31:07 -04:00
parent da4412f3f2
commit 8e3b60e1bb
6 changed files with 108 additions and 6 deletions

View File

@ -15,6 +15,9 @@
hgr_draw_sprite_7x28:
lda #0
sta MASK_COUNTDOWN
; set up pointers
lda INL
sta h728_smc1+1
@ -31,6 +34,30 @@ hgr_draw_sprite_7x28:
ldx #0 ; X is row counter
hgr_7x28_sprite_yloop:
lda MASK_COUNTDOWN
and #$3 ; only update every 4th
bne mask_good
txa
pha ; save X
; recalculate mask
txa
clc
adc CURSOR_Y
tax
ldy CURSOR_X
jsr update_bg_mask
pla ; restore X
tax
mask_good:
lda MASK
bne draw_sprite_skip
txa ; X is current row
clc
@ -53,6 +80,11 @@ h728_smc1:
ora $d000,X ; or in sprite
sta (GBASL),Y ; store out
draw_sprite_skip:
inc MASK_COUNTDOWN
inx
cpx #28
bne hgr_7x28_sprite_yloop
@ -129,6 +161,73 @@ restore_yloop:
rts
;===================
; update_bg_mask
;===================
; newx/7 in Y
; newy in X
; updates MASK
update_bg_mask:
; rrrr rtii top 5 bits row, bit 2 top/bottom
txa
and #$04 ; see if odd/even
beq bg_mask_even
bg_mask_odd:
lda #$f0
bne bg_mask_mask ; bra
bg_mask_even:
lda #$0f
bg_mask_mask:
sta MASK
txa
lsr
lsr ; need to divide by 8 then * 2
lsr ; can't just div by 4 as we need to mask bottom bit
asl
tax
lda gr_offsets,X
sta BASL
lda gr_offsets+1,X
sta BASH
lda (BASL),Y
and MASK
cmp #$30
beq mask_false ; true if color 3
cmp #$03
beq mask_false
;bne mask_false
mask_true:
lda #$ff
sta MASK
rts
mask_false:
lda #$00
sta MASK
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rts
;====================
; save area
;====================

View File

@ -106,11 +106,11 @@ escape_handler:
;=========================
; init peasant position
; draw at 18,107
; draw at 18,108
lda #18
sta PEASANT_X
lda #107
lda #108
sta PEASANT_Y
lda #PEASANT_DIR_RIGHT

View File

@ -165,7 +165,7 @@ score_text:
.include "hgr_font.s"
.include "draw_box.s"
.include "hgr_rectangle.s"
.include "hgr_7x28_sprite.s"
.include "hgr_7x28_sprite_mask.s"
.include "hgr_1x5_sprite.s"
;.include "hgr_save_restore.s"
.include "hgr_partial_save.s"

View File

@ -166,7 +166,7 @@ score_text:
.include "hgr_font.s"
.include "draw_box.s"
.include "hgr_rectangle.s"
.include "hgr_7x28_sprite.s"
.include "hgr_7x28_sprite_mask.s"
.include "hgr_1x5_sprite.s"
;.include "hgr_save_restore.s"
.include "hgr_partial_save.s"

View File

@ -85,7 +85,7 @@ done_movex:
cmp #45 ; if <45 then off screen
bcc peasant_y_negative ; blt
cmp #150 ; if >=150 then off screen
cmp #160 ; if >=150 then off screen
bcs peasant_y_toobig ; bge
; check collide
@ -126,7 +126,7 @@ peasant_y_negative:
jsr new_map_location
lda #150 ; new X location
lda #160 ; new X location
jmp done_movey

View File

@ -11,7 +11,10 @@ HGR_BITS = $1C
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
MASK = $2E
MASK_COUNTDOWN = $2F
PEASANT_X = $60
PEASANT_Y = $61