castleraider
changeset 282:a2e9b4a405cd
Fixed level corruption that could occur when monsters overshot
the bottom of the playing area.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Fri Mar 21 22:51:54 2014 +0100 |
| parents | 0c23ccf1253d |
| children | 144f5f3bbd16 |
| files | build.py code.oph monsters.oph |
| diffstat | 3 files changed, 24 insertions(+), 4 deletions(-) [+] |
line diff
1.1 --- a/build.py Fri Mar 21 22:14:42 2014 +0100 1.2 +++ b/build.py Fri Mar 21 22:51:54 2014 +0100 1.3 @@ -515,6 +515,12 @@ 1.4 monster_right_offset, 1.5 monster_right_max_offset) 1.6 1.7 + scenery_rows = 16 1.8 + extra_rows = 7 1.9 + top_char_row, top_monster_row, top_row = 0, 0, 0 1.10 + bottom_char_row = scenery_rows + extra_rows - 3 1.11 + bottom_monster_row = bottom_row = scenery_rows + extra_rows - 1 1.12 + 1.13 char_rows = range(6, 13) 1.14 rows = range(13, 29) 1.15 banks_char_rows_low = map(lambda x: (0x3000 + (x * 0x140)) & 0xff, char_rows) 1.16 @@ -538,6 +544,20 @@ 1.17 ",".join(map(lambda x: "$%02x" % x, bank2_char_rows_high)), 1.18 ",".join(map(lambda x: "$%02x" % x, bank2_rows_high))) 1.19 1.20 + screen_oph += ( 1.21 + "; Define the vertical extent of the player area in terms of rows.\n" 1.22 + ".alias scenery_rows %i\n" 1.23 + ".alias extra_rows %i\n" 1.24 + ".alias top_char_row %i\n" 1.25 + ".alias top_monster_row %i\n" 1.26 + ".alias top_row %i\n" 1.27 + ".alias bottom_char_row %i\n" 1.28 + ".alias bottom_monster_row %i\n" 1.29 + ".alias bottom_row %i\n\n" 1.30 + ) % (scenery_rows, extra_rows, 1.31 + top_char_row, top_monster_row, top_row, 1.32 + bottom_char_row, bottom_monster_row, bottom_row) 1.33 + 1.34 # Assemble the main game code and loader code. 1.35 1.36 open("constants.oph", "w").write(constants_oph)
2.1 --- a/code.oph Fri Mar 21 22:14:42 2014 +0100 2.2 +++ b/code.oph Fri Mar 21 22:51:54 2014 +0100 2.3 @@ -339,7 +339,7 @@ 2.4 bne check_beneath_fall 2.5 2.6 lda player_y 2.7 - cmp #20 ; The last visible row is 22 and the top of 2.8 + cmp #bottom_char_row ; The last visible row is 22 and the top of 2.9 bcs check_beneath_demise_exit ; the character is two rows above that. 2.10 2.11 adc #3 2.12 @@ -411,10 +411,10 @@ 2.13 ; returns C set if tile found or C clear if not 2.14 2.15 lda $81 ; For y positions less than 7 do not check the corresponding 2.16 - cmp #7 ; row since there are no level spans in these rows. 2.17 + cmp #extra_rows ; row since there are no level spans in these rows. 2.18 bcc check_tile_exit 2.19 2.20 - sbc #7 2.21 + sbc #extra_rows 2.22 clc 2.23 2.24 tax ; Transfer the y coordinate to the X register.
3.1 --- a/monsters.oph Fri Mar 21 22:14:42 2014 +0100 3.2 +++ b/monsters.oph Fri Mar 21 22:51:54 2014 +0100 3.3 @@ -537,7 +537,7 @@ 3.4 move_monster_down: 3.5 3.6 lda $89 ; Recover the y offset. 3.7 - cmp #23 3.8 + cmp #bottom_monster_row 3.9 beq move_monsters_change_direction 3.10 3.11 dey ; Select the y offset.
