dos33fsprogs/mist/draw_pointer.s

248 lines
3.9 KiB
ArmAsm
Raw Normal View History

2020-03-08 04:11:08 +00:00
;====================================
; draw pointer
;====================================
draw_pointer:
really_draw_pointer:
2020-03-08 04:11:08 +00:00
; point sprite to right location
2020-03-08 04:11:08 +00:00
lda CURSOR_X
sta XPOS
lda CURSOR_Y
sta YPOS
; see if inside special region
ldy #LOCATION_SPECIAL_EXIT
lda (LOCATION_STRUCT_L),Y
cmp #$ff
beq finger_not_special ; if $ff not special
2020-03-14 15:57:09 +00:00
lda DIRECTION
and #$f
cmp (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
bne finger_not_special ; only special if facing right way
; see if X1 < X < X2
lda CURSOR_X
ldy #LOCATION_SPECIAL_X1
cmp (LOCATION_STRUCT_L),Y
bcc finger_not_special ; blt
ldy #LOCATION_SPECIAL_X2
cmp (LOCATION_STRUCT_L),Y
bcs finger_not_special ; bge
; see if Y1 < Y < Y2
lda CURSOR_Y
ldy #LOCATION_SPECIAL_Y1
cmp (LOCATION_STRUCT_L),Y
bcc finger_not_special ; blt
ldy #LOCATION_SPECIAL_Y2
cmp (LOCATION_STRUCT_L),Y
bcs finger_not_special ; bge
; we made it this far, we are special
finger_grab:
lda #1
sta IN_SPECIAL
lda CURSOR_VISIBLE ; if not visible skip
bne really_draw_grab
rts
really_draw_grab:
lda DIRECTION
and #DIRECTION_ONLY_POINT
bne special_but_point
2020-03-08 04:11:08 +00:00
lda #<finger_grab_sprite
sta INL
lda #>finger_grab_sprite
jmp finger_draw
special_but_point:
jmp finger_point
2020-03-08 04:11:08 +00:00
finger_not_special:
lda CURSOR_VISIBLE ; if not visible skip
bne really_not_special
rts
really_not_special:
2020-03-08 04:11:08 +00:00
; check for left/right
lda CURSOR_X
cmp #7
bcc check_cursor_left ; blt
cmp #33
bcs check_cursor_right ; bge
; otherwise, finger_point
finger_point:
lda HOLDING_PAGE
beq real_finger_point
cmp #HOLDING_BLUE_PAGE
beq blue_finger
cmp #HOLDING_WHITE_PAGE
beq white_finger
red_finger:
lda #<finger_red_page_sprite
sta INL
lda #>finger_red_page_sprite
jmp finger_draw
blue_finger:
lda #<finger_blue_page_sprite
sta INL
lda #>finger_blue_page_sprite
jmp finger_draw
white_finger:
lda #<finger_white_page_sprite
sta INL
lda #>finger_white_page_sprite
jmp finger_draw
real_finger_point:
2020-03-08 04:11:08 +00:00
lda #<finger_point_sprite
sta INL
lda #>finger_point_sprite
jmp finger_draw
check_cursor_left:
ldy #LOCATION_BGS
check_left_north:
lda DIRECTION
and #$f
cmp #DIRECTION_N
2020-03-08 04:11:08 +00:00
bne check_left_south
handle_left_north:
; check if west exists
lda (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
and #BG_WEST
beq finger_point
bne finger_left
check_left_south:
cmp #DIRECTION_S
2020-03-08 04:11:08 +00:00
bne check_left_east
handle_left_south:
; check if east exists
lda (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
and #BG_EAST
beq finger_point
bne finger_left
check_left_east:
cmp #DIRECTION_E
2020-03-08 04:11:08 +00:00
bne check_left_west
handle_left_east:
; check if north exists
lda (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
and #BG_NORTH
beq finger_point
bne finger_left
check_left_west:
; we should be only option left
handle_left_west:
; check if south exists
lda (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
and #BG_SOUTH
beq finger_point
bne finger_left
check_cursor_right:
ldy #LOCATION_BGS
check_right_north:
lda DIRECTION
and #$f
cmp #DIRECTION_N
2020-03-08 04:11:08 +00:00
bne check_right_south
handle_right_north:
; check if east exists
lda (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
and #BG_EAST
beq finger_point
bne finger_right
check_right_south:
cmp #DIRECTION_S
2020-03-08 04:11:08 +00:00
bne check_right_east
handle_right_south:
; check if west exists
lda (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
and #BG_WEST
beq finger_point
bne finger_right
check_right_east:
cmp #DIRECTION_E
2020-03-08 04:11:08 +00:00
bne check_right_west
handle_right_east:
; check if south exists
lda (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
and #BG_SOUTH
bne finger_right
; beq finger_point
jmp finger_point
2020-03-08 04:11:08 +00:00
check_right_west:
; we should be only option left
handle_right_west:
; check if north exists
lda (LOCATION_STRUCT_L),Y
2020-03-08 04:11:08 +00:00
and #BG_NORTH
bne finger_right
; beq finger_point
jmp finger_point
2020-03-08 04:11:08 +00:00
finger_left:
lda #1
sta IN_LEFT
lda #<finger_left_sprite
sta INL
lda #>finger_left_sprite
jmp finger_draw
finger_right:
lda #1
sta IN_RIGHT
lda #<finger_right_sprite
sta INL
lda #>finger_right_sprite
jmp finger_draw
finger_draw:
sta INH
jsr put_sprite_crop
no_draw_pointer:
rts