From 847087affbcf2fb5c18b47ae1ee7b5471fc32378 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 31 May 2021 23:30:54 -0400 Subject: Semi-random ship damage --- draw_lorcha.s | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'draw_lorcha.s') diff --git a/draw_lorcha.s b/draw_lorcha.s index 07c4afe..b08fa50 100644 --- a/draw_lorcha.s +++ b/draw_lorcha.s @@ -44,6 +44,10 @@ lorcha_data: damaged_data: .incbin "DAMAGED.DAT" +; fully-damaged version of the lorcha, damaged_shipshape2[] in convfont.c +damaged_data2: + .incbin "DAMAGED2.DAT" + .ifdef CART_TARGET .segment "HIGHCODE" .else @@ -176,7 +180,7 @@ _damage_lorcha: xrand: ; get random number 0-48 in X: - lda 53770 ; RANDOM + lda RANDOM lsr lsr cmp #49 @@ -184,7 +188,15 @@ xrand: tax getpiece: + bit RANDOM + bpl @used2 lda damaged_data,x + jmp @can_dmg + +@used2: + lda damaged_data2,x + +@can_dmg: cmp lorcha_data,x beq xrand ; if it's a piece that can't show damage, ; ditch it and start over @@ -204,10 +216,16 @@ calcrow: bcc calcrow rowdone: - lda temp ; the piece ldy temp+1 + + lda (destptr),y + cmp lorcha_data,x ; if it's already damaged, + bne @ret ; leave it alone. + + lda temp ; the piece sta (destptr),y +@ret: rts ; end of _damage_lorcha ; a couple of utility functions for dealing with destptr: -- cgit v1.2.3