dos33fsprogs/ootw/laser.s

215 lines
2.4 KiB
ArmAsm
Raw Normal View History

2019-08-10 01:46:04 +00:00
; Handle laser
2019-08-10 02:25:10 +00:00
; should handle multiple at once?
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
; when pressed, find empty slot?
; initially 10 wide, from gun to right or left
; expand to 20 wide
; stop when encounter door, enemy, or edge of screen
; should bounds check carefully
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
; should handle shooting while crouching
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
laser0_out: .byte $0
laser0_start: .byte $0
laser0_end: .byte $0
2019-08-10 02:25:10 +00:00
laser0_y: .byte $0
laser0_direction: .byte $0
2019-08-10 03:01:15 +00:00
laser0_count: .byte $0
2019-08-10 02:25:10 +00:00
;=========================
; fire laser
;=========================
fire_laser:
lda laser0_out
bne done_fire_laser
2019-08-10 03:01:15 +00:00
; activate laser slot
2019-08-10 02:25:10 +00:00
inc laser0_out
2019-08-10 03:01:15 +00:00
; reset count
lda #0
sta laser0_count
2019-08-10 02:25:10 +00:00
; set y
2019-08-10 01:46:04 +00:00
lda PHYSICIST_Y
clc
adc #4
2019-08-10 02:25:10 +00:00
sta laser0_y
2019-08-10 01:46:04 +00:00
2019-08-10 03:01:15 +00:00
; set direction
2019-08-10 01:46:04 +00:00
lda DIRECTION
2019-08-10 02:25:10 +00:00
sta laser0_direction
2019-08-10 01:46:04 +00:00
beq laser_left
bne laser_right
2019-08-10 02:25:10 +00:00
; set x
2019-08-10 01:46:04 +00:00
laser_left:
ldx PHYSICIST_X
dex
stx laser0_end
txa
2019-08-10 03:01:15 +00:00
sec
sbc #10
2019-08-10 02:25:10 +00:00
sta laser0_start
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
jmp done_fire_laser
2019-08-10 01:46:04 +00:00
laser_right:
lda PHYSICIST_X
clc
adc #5
2019-08-10 02:25:10 +00:00
sta laser0_start
2019-08-10 01:46:04 +00:00
clc
adc #10
sta laser0_end
2019-08-10 02:25:10 +00:00
done_fire_laser:
rts
;====================
; draw laser
;====================
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
draw_laser:
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
lda laser0_out
beq done_draw_laser
lda #$10
sta hlin_color_smc+1
lda #$0f
sta hlin_mask_smc+1
ldy laser0_y
sec
lda laser0_end
sbc laser0_start
tax
2019-08-10 02:25:10 +00:00
lda laser0_start
2019-08-10 01:46:04 +00:00
jsr hlin
2019-08-10 02:25:10 +00:00
done_draw_laser:
2019-08-10 01:46:04 +00:00
rts
2019-08-10 02:25:10 +00:00
;===================
; move laser
;===================
move_laser:
lda laser0_out
beq done_move_laser
2019-08-10 03:01:15 +00:00
; slow down laser
lda laser0_count
and #$3
bne no_move_laser
lda laser0_direction
bne move_laser_right
move_laser_left:
lda laser0_count
cmp #4
bcc still_starting_left
cmp #8
bcc still_shooting_left
2019-08-10 03:01:15 +00:00
continue_shooting_left:
still_shooting_left:
lda laser0_end
sec
sbc #10
sta laser0_end
still_starting_left:
2019-08-10 03:01:15 +00:00
lda laser0_start
sec
sbc #10
2019-08-10 03:01:15 +00:00
sta laser0_start
laser_edge_detect_left:
lda laser0_end
2019-08-10 03:01:15 +00:00
bmi disable_laser
lda laser0_start
bpl no_move_laser
lda #0
sta laser0_start
2019-08-10 03:01:15 +00:00
jmp no_move_laser
move_laser_right:
lda laser0_count
cmp #4
bcc still_starting_right
cmp #8
bcc still_shooting_right
continue_shooting_right:
2019-08-10 02:25:10 +00:00
lda laser0_start
clc
adc #10
sta laser0_start
2019-08-10 03:01:15 +00:00
still_shooting_right:
lda laser0_end
clc
adc #10
sta laser0_end
2019-08-10 03:01:15 +00:00
still_starting_right:
laser_edge_detect_right:
; detect if totally off screen
2019-08-10 02:25:10 +00:00
lda laser0_start
2019-08-10 03:01:15 +00:00
cmp #40
bcs disable_laser
lda laser0_end
2019-08-10 02:25:10 +00:00
cmp #40
2019-08-10 03:01:15 +00:00
bcc no_move_laser
2019-08-10 02:25:10 +00:00
lda #39
sta laser0_end
2019-08-10 02:25:10 +00:00
2019-08-10 03:01:15 +00:00
no_move_laser:
inc laser0_count
2019-08-10 02:25:10 +00:00
done_move_laser:
rts
disable_laser:
lda #0
sta laser0_out
rts