blob: 155c6a45e0b7533fafd0d1bc1f69afe67071da17 (
plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
(ql:quickload "cl-charms")
(ql:quickload "trivial-left-pad")
(defvar *splits* '(("Chozo" 0 0 0)("Kraid" 0 0 0)("Wave Beam" 0 0 0)("Phantoon" 0 0 0)("Botwoon" 0 0 0)("Draygon" 0 0 0)("Lower Norfair" 0 0 0)("Ridley" 0 0 0)("Mother Brain" 0 0 0)))
(defvar *current-split-index* 0)
(defvar *interval* internal-time-units-per-second)
(defvar *start-time* 0)
(defun get-value (list index)
(cond
((null list) nil)
((zerop index) (car list))
(t (get-value (cdr list) (1- index)))))
(defun change-value (list index value)
(cond
((null list) '())
((zerop index) (setq list (cons value (cdr list))))
(t (setq list (cons (car list) (change-value (cdr list) (1- index) value))))))
(defun get-minimum (splits index current_minimum)
(cond
((null splits) '())
(t
(let ((val (get-value (car splits) index)))
(cond ((< val current_minimum)
(defun read-list-splits (filename)
(with-open-file (in filename)
(with-standard-io-syntax
(setf *splits* (read in)))))
(defun save-split-file (filename)
(with-open-file (out filename
:direction :output
:if-exists :append)
(with-standard-io-syntax
(print *splits* out))))
(defun current-time ()
(let ((time (get-internal-real-time)))
(cond ((zerop *start-time*) (setf *start-time* time))
(t (- time *start-time*)))))
(defun time-to-millis (time)
(* (/ time *interval*) 1000))
(defun add-to-string-if-not-empty (string suffix)
(cond ((not (zerop (length string))) (concatenate 'string string suffix))))
(defun number->two-wide (num)
(cond ((not (zerop num)) (format nil "~2,'0D" num)) (t "")))
(defun millis->strings (millis)
(let*
((hours (/ millis (* 1000 60 60)))
(minutes (mod (/ millis (* 1000 60)) 60))
(seconds (mod (/ millis 1000) 60))
(centis (mod millis 100)))
(list
(number->two-wide (floor hours))
(number->two-wide (floor minutes))
(format nil "~2,'0d" (floor seconds))
(format nil "~2,'0d" (floor centis)))))
(defun time->string (time_strs)
(concatenate 'string
(add-to-string-if-not-empty (car time_strs) ":")
(add-to-string-if-not-empty (cadr time_strs) ":")
(add-to-string-if-not-empty (caddr time_strs) ".")
(cadddr time_strs)))
(defun format-split (split)
(cond
((null split) "")
(t
(concatenate
'string
(trivial-left-pad:left-pad
(cond
((numberp (car split))
(time->string (millis->strings (car split))))
(t (car split)))
15)
(format-split (cdr split))))))
(defun start-split (split)
(setq split (change-value split 1 (time-to-millis (current-time))))
(setq split (change-value split 2 (time-to-millis (current-time)))))
(defun update-split (split)
(cond
((zerop (caddr split)) (setq split (start-split split)))
)
(setq split (change-value split 2 (time-to-millis (current-time))))
(setq split (change-value split 3 (- (caddr split) (cadr split)))))
(defun format-splits (current_list)
(cond
((null current_list) "")
(t
(concatenate
'string
(format nil "|~a|~%" (format-split (car current_list)))
(format-splits (cdr current_list)))))
)
(defun do-on-current-split (f)
(setq
*splits*
(change-value
*splits*
*current-split-index*
(funcall f
(get-value
*splits*
*current-split-index*)))))
(defun hello-world (filename)
(charms:with-curses ()
(charms:disable-echoing)
(charms:enable-raw-input :interpret-control-characters t)
(charms:enable-non-blocking-mode charms:*standard-window*)
(setq *start-time* (get-internal-real-time))
(loop :named driver-loop
:for c := (charms:get-char charms:*standard-window*
:ignore-error t)
:do (progn
(charms:clear-window charms:*standard-window*)
(cond ((null (get-value *splits* *current-split-index*)) (return-from driver-loop)))
(do-on-current-split (lambda (x) (update-split x)))
(charms:write-string-at-point charms:*standard-window*(format-splits *splits*) 0 0)
(charms:refresh-window charms:*standard-window*)
(case c
((nil) nil)
((#\Space) (incf *current-split-index* 1))
((#\q) (return-from driver-loop)))
(sleep 0.01)
)))
(save-split-file filename)
(get-value *splits* (1- *current-split-index*))
)
|