castleraider
changeset 284:7091d0eab594
Removed redundant comparison operations.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sat Mar 22 01:44:43 2014 +0100 |
| parents | 144f5f3bbd16 |
| children | 2f0e1ac0c9d0 |
| files | code.oph loader.oph monsters.oph plotting.oph scrolling.oph |
| diffstat | 5 files changed, 38 insertions(+), 95 deletions(-) [+] |
line diff
1.1 --- a/code.oph Sat Mar 22 00:02:17 2014 +0100 1.2 +++ b/code.oph Sat Mar 22 01:44:43 2014 +0100 1.3 @@ -139,11 +139,9 @@ 1.4 main_loop_check_lost: 1.5 1.6 lda player_lost 1.7 - cmp #0 1.8 beq main_loop_check_jump 1.9 1.10 lda player_lives 1.11 - cmp #0 1.12 beq main_loop_endloop 1.13 1.14 jsr clear_banks ; Clear both banks and show the first. 1.15 @@ -162,15 +160,13 @@ 1.16 main_loop_check_jump: 1.17 1.18 lda player_jumping ; Is the character jumping? 1.19 - cmp #0 ; If so then check for input, which might. 1.20 - bne main_loop_allow_movement ; be ignored. 1.21 - 1.22 + bne main_loop_allow_movement ; If so then check for input, which might 1.23 + ; be ignored. 1.24 jsr check_beneath ; If not, then check below the character. 1.25 1.26 main_loop_check_fall: 1.27 1.28 lda player_falling ; Is the character falling? 1.29 - cmp #0 1.30 beq main_loop_allow_movement ; No, so allow movement. 1.31 1.32 jsr player_fall ; Yes, so move them downwards. 1.33 @@ -188,7 +184,6 @@ 1.34 main_loop_next: 1.35 1.36 lda scrolled 1.37 - cmp #0 1.38 bne main_loop_after_monsters 1.39 1.40 jsr vsync 1.41 @@ -211,7 +206,6 @@ 1.42 player_move: 1.43 1.44 lda player_jumping 1.45 - cmp #0 1.46 beq player_move_check_fall 1.47 1.48 ; Whether moving or not, the player needs to be replotted before any 1.49 @@ -238,7 +232,6 @@ 1.50 player_move_check_fall: 1.51 1.52 lda player_falling 1.53 - cmp #0 1.54 beq player_move_check_input 1.55 1.56 player_move_exit: 1.57 @@ -250,7 +243,6 @@ 1.58 sta player_moving 1.59 1.60 lda using_joystick 1.61 - cmp #0 1.62 beq player_move_check_keys 1.63 1.64 ldx #1 1.65 @@ -300,11 +292,9 @@ 1.66 player_move_check_jump: 1.67 1.68 lda player_jumping 1.69 - cmp #0 1.70 bne player_move_not_jump 1.71 1.72 lda using_joystick 1.73 - cmp #0 1.74 beq player_move_check_jump_key 1.75 1.76 jsr read_joystick_fire 1.77 @@ -348,7 +338,6 @@ 1.78 check_beneath: ; Checks beneath the character for solid tiles. 1.79 ; Sets player_falling if none exist. 1.80 lda player_ys 1.81 - cmp #0 1.82 bne check_beneath_fall 1.83 1.84 lda player_y 1.85 @@ -368,9 +357,8 @@ 1.86 bcs check_beneath_solid 1.87 1.88 lda bank_number ; When half way across a cell, check another cell 1.89 - cmp #1 ; beneath the player since they could be standing 1.90 - bne check_beneath_fall ; on one or more of three tiles. 1.91 - 1.92 + beq check_beneath_fall ; beneath the player since they could be standing 1.93 + ; on one or more of three tiles. 1.94 clc 1.95 inc $80 1.96 jsr check_tile 1.97 @@ -379,8 +367,7 @@ 1.98 check_beneath_fall: 1.99 1.100 lda player_falling 1.101 - cmp #0 1.102 - bne check_beneath_fall_exit 1.103 + bne check_beneath_fall_exit 1.104 1.105 lda #1 ; (Clears the Z flag.) 1.106 bne check_beneath_fall_exit 1.107 @@ -600,7 +587,6 @@ 1.108 eor #$01 ; check the corresponding collectable tile 1.109 tay ; (00DtnnnN) 1.110 lda ($82),y 1.111 - cmp #0 1.112 bne check_tile_visible_exit ; if visible (i.e. not collected) then exit 1.113 1.114 ldy $8c ; restore the special tile number (00Dtnnnn) 1.115 @@ -700,7 +686,6 @@ 1.116 sta $7d ; the player's top row, the order of bits is 0000tmb[f] for 1.117 ; top, middle, bottom and an optional falling bit. 1.118 lda player_falling 1.119 - cmp #0 1.120 beq check_move_loop 1.121 1.122 inc $7c ; If the player is falling then we need to check an 1.123 @@ -725,15 +710,12 @@ 1.124 bpl check_move_loop 1.125 1.126 lda $7d ; If all tiles are empty then allow the move. 1.127 - cmp #0 1.128 beq player_move_common_exit 1.129 1.130 lda player_falling ; If some tiles are not empty while falling then 1.131 - cmp #0 ; stop moving. 1.132 bne check_move_exit_not_ok 1.133 1.134 lda player_jumping ; If some tiles are not empty while jumping then 1.135 - cmp #0 ; stop moving. 1.136 bne check_move_exit_not_ok 1.137 1.138 lda $7d ; If more than the lowest tile is blocked then 1.139 @@ -775,8 +757,8 @@ 1.140 ldx player_jumping ; Load the number of rows to move. 1.141 lda jump_steps_y,x 1.142 1.143 - cmp #0 ; If there are no rows to move then stop jumping. 1.144 - beq player_jump_check_after 1.145 + beq player_jump_check_after ; If there are no rows to move then stop 1.146 + ; jumping. 1.147 1.148 jsr player_can_jump 1.149 bcs player_jump_stop_jumping 1.150 @@ -826,9 +808,8 @@ 1.151 bcs player_can_jump_stop_jumping 1.152 1.153 lda bank_number ; When half way across a cell, check another 1.154 - cmp #1 ; cell above the player since they could be 1.155 - bne player_can_jump_exit ; under one or more of three tiles. 1.156 - 1.157 + beq player_can_jump_exit ; cell above the player since they could be 1.158 + ; under one or more of three tiles. 1.159 inc $80 1.160 1.161 jmp check_tile ; Branch and exit. 1.162 @@ -976,7 +957,6 @@ 1.163 ; replotted because redrawing because scrolling does not occur. 1.164 1.165 lda scrolled 1.166 - cmp #0 1.167 bne player_fall_plot 1.168 1.169 jsr vsync 1.170 @@ -1010,8 +990,7 @@ 1.171 player_demise: 1.172 1.173 lda player_lost ; Don't allow the routine to be entered if it has 1.174 - cmp #0 ; just been called. 1.175 - bne player_demise_exit 1.176 + bne player_demise_exit ; just been called. 1.177 1.178 jsr plot_char ; Unplot the character. 1.179
2.1 --- a/loader.oph Sat Mar 22 00:02:17 2014 +0100 2.2 +++ b/loader.oph Sat Mar 22 01:44:43 2014 +0100 2.3 @@ -502,8 +502,7 @@ 2.4 clc 2.5 2.6 lda $83 ; if we encounter a 0xff padding byte 2.7 - cmp #0 ; then increment X to skip past it 2.8 - beq draw_title_loop_no_increment 2.9 + beq draw_title_loop_no_increment; then increment X to skip past it 2.10 2.11 inx 2.12 2.13 @@ -672,8 +671,7 @@ 2.14 sta ($72),y 2.15 2.16 lda $8f ; if not running as an interrupt, jump straight 2.17 - cmp #0 ; into the column loop 2.18 - beq update_column_loop 2.19 + beq update_column_loop ; into the column loop 2.20 2.21 lda #<update_column_loop 2.22 sta $7a 2.23 @@ -740,7 +738,6 @@ 2.24 sta $81 2.25 2.26 lda $8f 2.27 - cmp #0 2.28 beq update_column_loop 2.29 2.30 rts ; keep $7a,$7b the same (loop) 2.31 @@ -769,8 +766,7 @@ 2.32 sta ($76),y 2.33 2.34 lda $8f ; if not running as an interrupt, jump straight 2.35 - cmp #0 ; into the next part of the routine 2.36 - beq update_title3 2.37 + beq update_title3 ; into the next part of the routine 2.38 2.39 lda #<update_title3 2.40 sta $7a 2.41 @@ -791,9 +787,8 @@ 2.42 sta $73 2.43 clc 2.44 2.45 - lda $83 ; if we encounter a 0xff padding byte 2.46 - cmp #0 ; then increment X to skip past it 2.47 - beq update_title_loop_no_increment 2.48 + lda $83 ; if we encounter a 0xff padding byte 2.49 + beq update_title_loop_no_increment ; then increment X to skip past it 2.50 2.51 inc $75 2.52 2.53 @@ -814,7 +809,6 @@ 2.54 inc $84 2.55 2.56 lda $8f 2.57 - cmp #0 2.58 bne update_title3_break 2.59 2.60 jmp update_title2
3.1 --- a/monsters.oph Sat Mar 22 00:02:17 2014 +0100 3.2 +++ b/monsters.oph Sat Mar 22 01:44:43 2014 +0100 3.3 @@ -127,7 +127,6 @@ 3.4 plot_monsters: 3.5 3.6 lda bank_number 3.7 - cmp #0 3.8 bne plot_monsters_bank2 3.9 beq plot_monsters_bank1 3.10 3.11 @@ -167,7 +166,6 @@ 3.12 3.13 tay 3.14 lda ($86),y ; type, animation and dx 3.15 - cmp #0 3.16 beq plot_monsters_loop_next 3.17 3.18 jsr plot_monster 3.19 @@ -326,8 +324,8 @@ 3.20 jsr read_monster_row_address 3.21 ldy #0 3.22 lda ($76),y ; Read the monster type. 3.23 - cmp #0 ; If no monster is defined then exit; 3.24 - beq create_monster_no_monster ; otherwise create the monster. 3.25 + beq create_monster_no_monster ; If no monster is defined then exit; 3.26 + ; otherwise create the monster. 3.27 3.28 tay ; Temporarily store the type. 3.29 3.30 @@ -338,7 +336,6 @@ 3.31 create_monster_index_loop: 3.32 3.33 lda monster_positions_address,x ; Look for an empty slot. 3.34 - cmp #0 3.35 bne create_monster_index_loop_not_empty 3.36 3.37 stx $7c ; Temporarily store any unused slots. 3.38 @@ -391,7 +388,6 @@ 3.39 3.40 tya ; Recover the type. 3.41 and #monster_data_axis_bit 3.42 - cmp #0 3.43 beq create_monster_store_type 3.44 3.45 lda #$40 ; Set the axis bit (vertical motion). 3.46 @@ -429,8 +425,8 @@ 3.47 ldy monster_movement_offset 3.48 3.49 lda ($86),y ; Load the type, animation flag and dx. 3.50 - cmp #0 ; If the slot is empty then this is zero, 3.51 - beq move_monsters_next ; so we move to the next monster and exit. 3.52 + beq move_monsters_next ; If the slot is empty then this is zero, 3.53 + ; so we move to the next monster and exit. 3.54 3.55 eor #monster_animation_bit ; Flip the animation bit. 3.56 sta $8b ; Temporarily store the type/dx byte. 3.57 @@ -477,16 +473,14 @@ 3.58 3.59 lda $8b ; Recover the type. 3.60 and #monster_direction_bit 3.61 - cmp #$00 3.62 - bne move_monster_down_check 3.63 + bne move_monster_down_check ; If not zero then the monster is moving down. 3.64 3.65 ; Upward motion 3.66 3.67 iny ; Select the dy value. 3.68 lda ($86),y 3.69 - cmp #0 ; If we are aligned with a cell then 3.70 - beq move_monster_up ; check that we can move. 3.71 - 3.72 + beq move_monster_up ; If we are aligned with a cell then 3.73 + ; check that we can move. 3.74 lda #0 ; Otherwise, set dy = 0 and exit. 3.75 sta ($86),y 3.76 clc 3.77 @@ -495,7 +489,6 @@ 3.78 move_monster_up: 3.79 3.80 lda $89 ; Recover the y offset. 3.81 - cmp #0 3.82 beq move_monsters_change_direction 3.83 3.84 sec 3.85 @@ -519,8 +512,7 @@ 3.86 ; Downward motion 3.87 3.88 iny ; Select the dy value. 3.89 - lda ($86),y 3.90 - cmp #0 ; If we are aligned with a cell then 3.91 + lda ($86),y ; If we are aligned with a cell then 3.92 beq move_monster_down ; check that we can move. 3.93 3.94 lda #0 ; Otherwise, set dy = 0. 3.95 @@ -581,7 +573,6 @@ 3.96 beq move_monsters_change_direction ; range then move right next time. 3.97 3.98 lda bank_number 3.99 - cmp #0 3.100 bne move_monster_horizontally_check_left 3.101 3.102 clc 3.103 @@ -599,7 +590,6 @@ 3.104 sta $8b 3.105 3.106 and #monster_dx_bit 3.107 - cmp #0 3.108 beq move_monster_horizontally_exit 3.109 3.110 lda ($86),y 3.111 @@ -640,7 +630,6 @@ 3.112 sta $8b 3.113 3.114 and #monster_dx_bit 3.115 - cmp #0 3.116 bne move_monster_horizontally_exit 3.117 3.118 clc 3.119 @@ -731,8 +720,7 @@ 3.120 bcs check_monster_common_exit 3.121 3.122 check_monster_player_bank2: 3.123 - lda bank_number 3.124 - cmp #0 ; x = 17,20 is only a potential hit if 3.125 + lda bank_number ; x = 17,20 is only a potential hit if 3.126 beq check_monster_common_exit ; bank 2 is showing. 3.127 3.128 check_monster_player_vertical: 3.129 @@ -761,7 +749,6 @@ 3.130 3.131 sty $88 3.132 lda ($86),y 3.133 - cmp #0 3.134 beq check_player_monsters_next 3.135 3.136 jsr check_monster_player
4.1 --- a/plotting.oph Sat Mar 22 00:02:17 2014 +0100 4.2 +++ b/plotting.oph Sat Mar 22 01:44:43 2014 +0100 4.3 @@ -463,7 +463,6 @@ 4.4 sta $78 4.5 4.6 lda $74 4.7 - cmp #0 4.8 beq plot_bank2r_row_loop_skip_leading 4.9 cmp #41 4.10 bcc plot_bank2r_row_loop_plot_leading 4.11 @@ -522,9 +521,9 @@ 4.12 ldy #1 4.13 lda ($76),y ; Load the number of tiles minus 1, n - 1. 4.14 sta $79 ; temp (n - 1) 4.15 - cmp #0 ; If there is only one tile in the 4.16 - beq plot_bank2r_offset_next ; span, move to the next span, 4.17 - ; otherwise plot a continuation tile. 4.18 + beq plot_bank2r_offset_next ; If there is only one tile in the span, 4.19 + ; move to the next span, otherwise plot a 4.20 + ; continuation tile. 4.21 4.22 lda $78 4.23 jsr read_rotated_sprite_address 4.24 @@ -744,8 +743,8 @@ 4.25 ldy #1 4.26 lda ($76),y ; Load the number of tiles minus 1, n - 1. 4.27 sta $79 ; temp (n - 1) 4.28 - cmp #0 ; If there is only one tile in the 4.29 - beq plot_bank2l_offset_next ; span, move to the next span, 4.30 + beq plot_bank2l_offset_next ; If there is only one tile in the 4.31 + ; span, move to the next span, 4.32 ; otherwise plot a trailing tile. 4.33 clc 4.34 lda $74 4.35 @@ -868,7 +867,6 @@ 4.36 sta $74 4.37 4.38 lda initial_row_offsets,x 4.39 - cmp #0 4.40 beq initial_plot_bank1_span_loop 4.41 sta $78 4.42 dec $78 4.43 @@ -937,8 +935,7 @@ 4.44 sta $74 4.45 sta $79 4.46 4.47 - lda initial_row_offsets,x 4.48 - cmp #0 ; If at the start of a span, just 4.49 + lda initial_row_offsets,x ; If at the start of a span, just 4.50 beq initial_plot_bank2_span_loop ; go straight into the loop. 4.51 sta $78 ; Otherwise, store a decremented 4.52 dec $78 ; span length. 4.53 @@ -1021,7 +1018,6 @@ 4.54 cmp #40 4.55 beq initial_plot_bank2_span_endloop 4.56 lda $78 4.57 - cmp #0 4.58 beq initial_plot_bank_tile_endloop 4.59 ; fall through 4.60 4.61 @@ -1050,7 +1046,6 @@ 4.62 cmp #40 4.63 beq initial_plot_bank_tile_loop_span_endloop1 4.64 lda $78 4.65 - cmp #0 4.66 beq initial_plot_bank_tile_endloop 4.67 4.68 dec $78 ; one tile less to plot 4.69 @@ -1076,7 +1071,6 @@ 4.70 plot_player: 4.71 4.72 lda bank_number 4.73 - cmp #0 4.74 beq plot_char_bank1 4.75 bne plot_char_bank2 4.76 4.77 @@ -1115,7 +1109,6 @@ 4.78 plot_char_bank: 4.79 4.80 lda player_lost 4.81 - cmp #0 4.82 beq plot_char_bank_plot 4.83 rts 4.84 4.85 @@ -1173,7 +1166,6 @@ 4.86 4.87 iny 4.88 lda ($86),y ; dy offset 4.89 - cmp #0 4.90 bne plot8x8_x0_y1 4.91 ; fall through 4.92
5.1 --- a/scrolling.oph Sat Mar 22 00:02:17 2014 +0100 5.2 +++ b/scrolling.oph Sat Mar 22 01:44:43 2014 +0100 5.3 @@ -95,9 +95,8 @@ 5.4 5.5 scroll_right_update: 5.6 5.7 - lda bank_number 5.8 - cmp #1 ; showing the second bank? 5.9 - beq scroll_right_update_show_bank1 5.10 + lda bank_number ; showing the second bank? 5.11 + bne scroll_right_update_show_bank1 5.12 5.13 lda scroll_offset_low 5.14 cmp #level_extent_low 5.15 @@ -165,15 +164,12 @@ 5.16 5.17 scroll_left_update: 5.18 5.19 - lda bank_number 5.20 - cmp #1 ; showing the second bank? 5.21 - beq scroll_left_update_show_bank1 5.22 + lda bank_number ; showing the second bank? 5.23 + bne scroll_left_update_show_bank1 5.24 5.25 lda scroll_offset_low 5.26 - cmp #0 5.27 bne scroll_left_update_ok_to_scroll 5.28 lda scroll_offset_high 5.29 - cmp #0 5.30 beq scroll_left_update_common_exit 5.31 5.32 scroll_left_update_ok_to_scroll: 5.33 @@ -236,7 +232,6 @@ 5.34 jsr plot_monsters_bank2 ; unplot the monsters, too 5.35 5.36 lda player_falling 5.37 - cmp #0 5.38 beq scroll_update_plot_bank1 5.39 5.40 jsr player_drop 5.41 @@ -245,7 +240,6 @@ 5.42 scroll_update_plot_bank1: 5.43 5.44 lda player_jumping 5.45 - cmp #0 5.46 bne scroll_update_common_exit 5.47 5.48 lda player_animation 5.49 @@ -262,7 +256,6 @@ 5.50 jsr plot_monsters_bank1 ; unplot the monsters, too 5.51 5.52 lda player_falling 5.53 - cmp #0 5.54 beq scroll_update_common_exit 5.55 5.56 jmp player_drop 5.57 @@ -276,8 +269,8 @@ 5.58 scroll_right_loop: 5.59 5.60 lda initial_row_offsets,x 5.61 - cmp #0 ; Is the current offset zero? 5.62 - beq scroll_right_loop_next_offset ; If so, update the current span. 5.63 + beq scroll_right_loop_next_offset ; Is the current offset zero? 5.64 + ; If so, update the current span. 5.65 5.66 dec initial_row_offsets,x ; Otherwise, decrease the offset. 5.67 dex 5.68 @@ -456,8 +449,8 @@ 5.69 beq scroll_left_reset_left_offset ; then reset it. 5.70 5.71 inc monster_left_offset ; Otherwise, increase the offset. 5.72 - cmp #0 ; If it was 0, we create a monster. 5.73 - bne scroll_left_update_monsters_exit 5.74 + cmp #0 5.75 + bne scroll_left_update_monsters_exit; If it was 0, we create a monster. 5.76 jmp create_monster_left ; Branch and exit. 5.77 5.78 scroll_left_reset_left_offset: 5.79 @@ -494,7 +487,6 @@ 5.80 5.81 tay 5.82 lda ($86),y ; type, animation flag and dx 5.83 - cmp #0 5.84 beq scroll_monsters_left_loop_next 5.85 5.86 ; Move the monster right on screen. 5.87 @@ -547,7 +539,6 @@ 5.88 5.89 tay 5.90 lda ($86),y ; type, animation flag and dx 5.91 - cmp #0 5.92 beq scroll_monsters_right_loop_next 5.93 5.94 ; Move the monster left on screen.
