Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ZEROPAGE
- nmi_num: .res 1
- temp_16bit_1: .res 2
- temp_16bit_2: .res 2
- loop_addy: .res 2
- p_floor: .res 1
- p_x_pos: .res 1
- p_y_pos: .res 1
- ; CONSTANTS
- enemy_amount_on_floors = $500
- floors_lo:
- .byte <floor0_big, <floor1_big, <floor2_big, <floor3_big
- floors_hi:
- .byte >floor0_big, >floor1_big, >floor2_big, >floor3_big
- enemy_y_coords_lo:
- .byte <floor0_enemy_y, <floor1_enemy_y, <floor2_enemy_y, <floor3_enemy_y
- enemy_y_coords_hi:
- .byte >floor0_enemy_y, >floor1_enemy_y, >floor2_enemy_y, >floor3_enemy_y
- enemy_x_coords_lo:
- .byte <floor0_enemy_x, <floor1_enemy_x, <floor2_enemy_x, <floor3_enemy_x
- enemy_x_coords_hi:
- .byte >floor0_enemy_x, >floor1_enemy_x, >floor2_enemy_x, >floor3_enemy_x
- ; Number of enemy encounters per floor +1. Plus one so
- ; the routine will run entirely through all and exit
- enemy_amount_on_floors:
- .byte 21,26,31,36
- ; Dummy data for testing
- floor0_enemy_y:
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- floor1_enemy_y:
- .byte 46,44,$00,$00,$00,$00,$00,$00,$00,$00
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- floor2_enemy_y:
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- floor3_enemy_y:
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- floor0_enemy_x:
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- floor1_enemy_x:
- .byte 04,04,$00,$00,$00,$00,$00,$00,$00,$00
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- floor2_enemy_x:
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- floor3_enemy_x:
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- .byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- ; Run this AFTER the screen is done loading to find out
- ; if there is an enemy on the coordinate the player has
- ; landed on
- enemy_test_coordinate:
- ldx p_floor ; Get floor player is on
- lda enemy_y_coords_lo, x ; Get correct table of enemy Y pos
- sta temp_16bit_1+0 ;
- lda enemy_y_coords_hi, x ;
- sta temp_16bit_1+1 ;
- lda enemy_x_coords_lo, x ; Get correct table of enemy X pos
- sta temp_16bit_2+0 ;
- lda enemy_x_coords_hi, x ;
- sta temp_16bit_2+1 ;
- ldy #00 ; Set up Y register
- @test_y: ;
- lda (temp_16bit_1), y ; Test if enemy Y pos == player Y pos
- cmp p_y_pos ; and if so...
- bne :+ ;
- lda (temp_16bit_2), y ; Test if enemy X pos == player X pos
- cmp p_x_pos ; and if so...
- bne :+ ;
- lda enemy_present, y ; Test if enemy at that coord has been
- beq :+ ; defeated yet or not through RAM table
- lda #<loop_nothing ; Do stuff if enemies are present
- sta loop_addy+0 ;
- lda #>loop_nothing ;
- sta loop_addy+1 ;
- rts ;
- : iny ; Increment the Y register and stick it
- tya ; in A to compare the amount of enemies
- cmp enemy_amount_on_floors, x ; on the floor in order to escape the
- bne @test_y ; routine
- rts ;
- loop_nothing:
- jmp end_loop
- loop:
- jmp (loop_addy)
- end_loop:
- jsr nmi_wait
- jmp loop
- nmi_wait:
- lda nmi_num
- : cmp nmi_num
- beq :-
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement