mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-11 01:30:53 +00:00
cliff: work on tracking down bugs / commenting code
This commit is contained in:
parent
55955b22e6
commit
543382afb0
@ -6,11 +6,12 @@
|
|||||||
; attempts to shift for odd/even column
|
; attempts to shift for odd/even column
|
||||||
; cannot handle sprites bigger than 256 bytes
|
; cannot handle sprites bigger than 256 bytes
|
||||||
|
|
||||||
;
|
|
||||||
; Location at CURSOR_X CURSOR_Y
|
; Location at CURSOR_X CURSOR_Y
|
||||||
|
|
||||||
; for now, BG mask is only all or nothing
|
; for now, BG mask is only all or nothing (from LORES)
|
||||||
; so we just skip drawing if behind
|
; so we just skip drawing if behind
|
||||||
|
; this version handles arbitrary width sprites, which complicates
|
||||||
|
; things
|
||||||
|
|
||||||
; X is sprite to draw
|
; X is sprite to draw
|
||||||
|
|
||||||
@ -18,31 +19,42 @@
|
|||||||
|
|
||||||
hgr_draw_sprite_bg_mask:
|
hgr_draw_sprite_bg_mask:
|
||||||
|
|
||||||
ldy #4 ; FIXME
|
ldy #4 ; FIXME, should be proper save slot
|
||||||
|
|
||||||
|
; save info on background to restore
|
||||||
|
|
||||||
lda CURSOR_X
|
lda CURSOR_X
|
||||||
sta save_xstart,Y
|
sta save_xstart,Y
|
||||||
lda CURSOR_Y
|
lda CURSOR_Y
|
||||||
sta save_ystart,Y
|
sta save_ystart,Y
|
||||||
|
|
||||||
|
; calculate end of sprite on screen for Xpos loop
|
||||||
|
; also save for background restore
|
||||||
|
|
||||||
lda walk_sprites_xsize,X
|
lda walk_sprites_xsize,X
|
||||||
clc
|
clc
|
||||||
adc CURSOR_X
|
adc CURSOR_X
|
||||||
sta hdsb_width_smc+1
|
sta hdsb_width_smc+1
|
||||||
sta save_xend,Y
|
sta save_xend,Y
|
||||||
|
|
||||||
|
; calculate bottom of sprite for Ypos loop
|
||||||
|
; also save for background restore
|
||||||
|
|
||||||
lda walk_sprites_ysize,X
|
lda walk_sprites_ysize,X
|
||||||
sta hdsb_ysize_smc+1
|
sta hdsb_ysize_smc+1
|
||||||
sta save_yend,Y
|
sta save_yend,Y
|
||||||
|
|
||||||
|
; set up mask countdown value
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
sta MASK_COUNTDOWN
|
sta MASK_COUNTDOWN
|
||||||
|
|
||||||
; calculate peasant priority
|
; calculate peasant priority
|
||||||
; based on head
|
; based on head location
|
||||||
|
; see chart later
|
||||||
|
|
||||||
lda PEASANT_Y
|
lda PEASANT_Y ; this should be 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
|
||||||
@ -64,6 +76,11 @@ hgr_draw_sprite_bg_mask:
|
|||||||
lda walk_mask_data_h,X
|
lda walk_mask_data_h,X
|
||||||
sta h728_smc3+2
|
sta h728_smc3+2
|
||||||
|
|
||||||
|
;===============================
|
||||||
|
; main loop
|
||||||
|
; X = row counter at times (CURRENT_ROW is real one)
|
||||||
|
; Y = col counter
|
||||||
|
|
||||||
ldx #0 ; X is row counter
|
ldx #0 ; X is row counter
|
||||||
stx CURRENT_ROW
|
stx CURRENT_ROW
|
||||||
hgr_sprite_bm_yloop:
|
hgr_sprite_bm_yloop:
|
||||||
@ -128,12 +145,15 @@ hsbm_draw_sprite_both:
|
|||||||
eor (GBASL),Y ; store out
|
eor (GBASL),Y ; store out
|
||||||
sta (GBASL),Y ; store out
|
sta (GBASL),Y ; store out
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
iny
|
||||||
|
|
||||||
|
|
||||||
draw_sprite_skip:
|
draw_sprite_skip:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inx
|
inx
|
||||||
iny
|
|
||||||
|
|
||||||
hdsb_width_smc:
|
hdsb_width_smc:
|
||||||
cpy #6
|
cpy #6
|
||||||
@ -151,60 +171,15 @@ hdsb_ysize_smc:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;======================
|
|
||||||
; restore bg 1x28
|
|
||||||
;======================
|
|
||||||
|
|
||||||
restore_bg_1x28:
|
|
||||||
|
|
||||||
; restore bg behind peasant
|
|
||||||
|
|
||||||
; is this actually faster than using the generic version?
|
|
||||||
|
|
||||||
ldy CURSOR_Y ; y start point
|
|
||||||
|
|
||||||
ldx #27 ; height
|
|
||||||
|
|
||||||
restore_yloop:
|
|
||||||
; calc GBASL/GBASH using lookup table
|
|
||||||
|
|
||||||
clc
|
|
||||||
lda hposn_low,Y
|
|
||||||
adc PEASANT_X
|
|
||||||
sta restore_page1_smc+1
|
|
||||||
sta restore_page2_smc+1
|
|
||||||
|
|
||||||
; $40 -> $20 0100 0000 -> 0010 0000
|
|
||||||
; $41 -> $21 0100 0001 -> 0010 0001
|
|
||||||
; $51 -> $31 0101 0011 -> 0101 0001
|
|
||||||
|
|
||||||
lda hposn_high,Y
|
|
||||||
sta restore_page2_smc+2
|
|
||||||
eor #$60
|
|
||||||
sta restore_page1_smc+2
|
|
||||||
|
|
||||||
restore_page1_smc:
|
|
||||||
lda $DDDD
|
|
||||||
restore_page2_smc:
|
|
||||||
sta $DDDD
|
|
||||||
|
|
||||||
iny
|
|
||||||
|
|
||||||
dex
|
|
||||||
bpl restore_yloop
|
|
||||||
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
|
||||||
;===================
|
;===================
|
||||||
; update_bg_mask
|
; update_bg_mask
|
||||||
;===================
|
;===================
|
||||||
; newx/7 in Y
|
; Column (xpos/7) in Y
|
||||||
; newy in X
|
; Row in X
|
||||||
; updates MASK
|
; updates MASK
|
||||||
update_bg_mask:
|
update_bg_mask:
|
||||||
|
|
||||||
|
; ?????????
|
||||||
; rrrr rtii top 5 bits row, bit 2 top/bottom
|
; rrrr rtii top 5 bits row, bit 2 top/bottom
|
||||||
|
|
||||||
sty xsave
|
sty xsave
|
||||||
@ -212,9 +187,11 @@ mask_try_again:
|
|||||||
stx ysave
|
stx ysave
|
||||||
|
|
||||||
txa
|
txa
|
||||||
and #$04 ; see if odd/even
|
and #$04 ; see if odd/even in the lo-res lookup
|
||||||
beq bg_mask_even
|
beq bg_mask_even
|
||||||
|
|
||||||
|
; setup mask based on odd/even
|
||||||
|
|
||||||
bg_mask_odd:
|
bg_mask_odd:
|
||||||
lda #$f0
|
lda #$f0
|
||||||
bne bg_mask_mask ; bra
|
bne bg_mask_mask ; bra
|
||||||
@ -222,23 +199,37 @@ bg_mask_odd:
|
|||||||
bg_mask_even:
|
bg_mask_even:
|
||||||
lda #$0f
|
lda #$0f
|
||||||
bg_mask_mask:
|
bg_mask_mask:
|
||||||
|
|
||||||
sta MASK
|
sta MASK
|
||||||
|
|
||||||
|
; X is current row here
|
||||||
|
|
||||||
|
; converting to which row in lores
|
||||||
|
; 0 -> 0 low
|
||||||
|
; 4 -> 0 high
|
||||||
|
; 8 -> 1 low
|
||||||
|
; ....
|
||||||
|
; 191 -> 23 high
|
||||||
|
|
||||||
txa
|
txa
|
||||||
lsr
|
lsr
|
||||||
lsr ; need to divide by 8 then * 2
|
lsr ; need to divide by 8 then * 2
|
||||||
lsr ; can't just div by 4 as we need to mask bottom bit
|
lsr ; can't just div by 4 as we need to mask bottom bit
|
||||||
asl
|
asl ; because our lookup is multiple of two
|
||||||
tax
|
tax
|
||||||
|
|
||||||
|
; set up row for mask lookup
|
||||||
|
|
||||||
lda gr_offsets,X
|
lda gr_offsets,X
|
||||||
sta BASL
|
sta BASL
|
||||||
lda gr_offsets+1,X
|
lda gr_offsets+1,X
|
||||||
sta BASH
|
sta BASH
|
||||||
|
|
||||||
|
; read out current mask color
|
||||||
|
|
||||||
lda (BASL),Y
|
lda (BASL),Y
|
||||||
|
|
||||||
|
; get high/low properly
|
||||||
|
|
||||||
ldy MASK
|
ldy MASK
|
||||||
cpy #$f0
|
cpy #$f0
|
||||||
bne mask_bottom
|
bne mask_bottom
|
||||||
@ -250,13 +241,25 @@ mask_top:
|
|||||||
jmp mask_mask_mask
|
jmp mask_mask_mask
|
||||||
mask_bottom:
|
mask_bottom:
|
||||||
and #$0f
|
and #$0f
|
||||||
|
|
||||||
|
|
||||||
mask_mask_mask:
|
mask_mask_mask:
|
||||||
sta MASK
|
sta MASK
|
||||||
|
|
||||||
|
; special cases?
|
||||||
|
|
||||||
cmp #$0 ; 0 means collision, find mask
|
cmp #$0 ; 0 means collision, find mask
|
||||||
bne mask_not_zero ; by iteratively going down till
|
bne mask_not_zero ; by iteratively going down till
|
||||||
ldx ysave ; non-zero
|
|
||||||
|
; mask 0 here, which means can't walk there but doesn't give
|
||||||
|
; prioirty. This can happen if there's a don't walk spot
|
||||||
|
; above you even if not on it. In this case, find the actual
|
||||||
|
; mask by looking down the screen until we find an actual
|
||||||
|
; proper mask value
|
||||||
|
|
||||||
ldy xsave
|
ldy xsave
|
||||||
|
|
||||||
|
ldx ysave ; move to next lower lookup value
|
||||||
inx
|
inx
|
||||||
inx
|
inx
|
||||||
inx
|
inx
|
||||||
@ -307,10 +310,6 @@ mask_false:
|
|||||||
; save area
|
; save area
|
||||||
;====================
|
;====================
|
||||||
|
|
||||||
;save_sprite_1x28:
|
|
||||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
|
||||||
;.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
|
||||||
|
|
||||||
ysave:
|
ysave:
|
||||||
.byte $00
|
.byte $00
|
||||||
xsave:
|
xsave:
|
||||||
|
@ -168,7 +168,7 @@ erase_peasant:
|
|||||||
|
|
||||||
jmp hgr_partial_restore ; tail call
|
jmp hgr_partial_restore ; tail call
|
||||||
.endif
|
.endif
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
; when peasants collide
|
; when peasants collide
|
||||||
|
Loading…
x
Reference in New Issue
Block a user