-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_loop_input.asm
executable file
·61 lines (40 loc) · 1.31 KB
/
4_loop_input.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
; /////////////////////////////////////////////////////////////////////////////
; Znake (ZX Spectrum 48K)
; -----------------------------------------------------------------------------
; 4_loop_input.asm
; -----------------------------------------------------------------------------
; Copyright (C) 2016, Chris Wyatt
; All rights reserved
; Distributed under the Apache 2 license (see LICENSE)
; /////////////////////////////////////////////////////////////////////////////
next_input_loop:
call check_input
; If the current frame count is less than the previous frame count plus
; frame_wait, then continue input loop
ld hl,previous_frame_count
ld a,(23672)
sub (hl)
; Snake speed (higher = slower)
ld hl,no_of_frames_per_update
sub (hl)
jr c,next_input_loop
; Otherwise, move snake
; Store the new frame count
ld a,(23672)
ld (previous_frame_count),a
; Get highest priority direction
ld a,(snake_direction_queue)
ld b,a
and 0x0f
; If no direction queued, continue moving snake in same direction
jr z,update_head_history
; Otherwise, change snake direction
ld (snake_direction_current),a
; Pop the new direction from the direction queue
ld a,b
rrca
rrca
rrca
rrca
and 0x0f
ld (snake_direction_queue),a