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
145
146
147
148
|
;Name: 3BALL
;Version: 3BALL
;Description: An executive decision maker that will give a yes/no/maybe answer. Pressing Next will generate another answer and beep (since it will be the same answer sometimes).
;
;(c) 1997 Wayne Buttles (timex@fdisk.com). Compiled using tools and knowledge published by John A. Toebes, VIII and Michael Polymenakos (mpoly@panix.com).
; Some enhancements by John Toebes...
;
;HelpFile: watchapp.hlp
;HelpTopic: 100
;
; <A NAME="3ball_1">(1) Program specific constants</A>
;
INCLUDE "wristapp.i"
;
; Program specific constants
;
CURRENT_TIC EQU $27 ; Current system clock tic (Timer)
LAST_ANS EQU $61
RAND_SEED EQU $60
MARQ_POS EQU $62
START EQU *
;
; <A NAME="3ball_2">(2) System entry point vectors</A>
;
L0110: jmp MAIN ; The main entry point - <A HREF="wristappformat.html#WRIST_MAIN">WRIST_MAIN</A>
L0113: bclr 1,BTNFLAGS ; Called when we are suspended for any reason - <A HREF="wristappformat.html#WRIST_SUSPEND">WRIST_SUSPEND</A>
rts
L0116: jmp FLASH ; Called to handle any timers or time events - <A HREF="wristappformat.html#WRIST_DOTIC">WRIST_DOTIC</A>
L0119: bclr 1,BTNFLAGS ; Called when the COMM app starts and we have timers pending - <A HREF="wristappformat.html#WRIST_INCOMM">WRIST_INCOMM</A>
rts
L011c: rts ; Called when the COMM app loads new data - <A HREF="wristappformat.html#WRIST_NEWDATA">WRIST_NEWDATA</A>
nop
nop
L011f: lda STATETAB,X ; The state table get routine - <A HREF="wristappformat.html#WRIST_GETSTATE">WRIST_GETSTATE</A>
rts
L0123: jmp HANDLE_STATE0
db STATETAB-STATETAB
;
; <A NAME="3ball_3">(3) Program strings</A>
;
S6_MSG timex6 "3 BALL"
S6_MAYBE timex6 "MAYBE"
S6_YES timex6 " YES"
S6_NO timex6 " NO"
S6_MARQ timex6 " +O+ "
MARQ_SEL
DB S6_MARQ+2-START
DB S6_MARQ+3-START
DB S6_MARQ+2-START
DB S6_MARQ+1-START
DB S6_MARQ-START
DB S6_MARQ+1-START
MSG_SEL DB S6_YES-START
DB S6_NO-START
DB S6_MAYBE-START
DB S6_YES-START
;
; <A NAME="3ball_4">(4) State Table</A>
;
STATETAB:
db 0
db EVT_ENTER,TIM2_16TIC,0 ; Initial state
db EVT_RESUME,TIM_ONCE,0 ; Resume from a nested app
db EVT_DNNEXT,TIM2_16TIC,0 ; Next button
db EVT_TIMER2,TIM_ONCE,0 ; Timer
db EVT_MODE,TIM_ONCE,$FF ; Mode button
db EVT_END
;
; <A NAME="3ball_5">(5) State Table 0 Handler</A>
; This is called to process the state events.
; We see ENTER, RESUME, TIMER2 and NEXT events
;
HANDLE_STATE0:
bset 1,APP_FLAGS ; Indicate that we can be suspended
bclr 1,BTNFLAGS
lda BTNSTATE
cmp #EVT_DNNEXT ; Did they press the next button?
beq DOITAGAIN
cmp #EVT_ENTER ; Or did we start out
beq DOITAGAIN
cmp #EVT_RESUME
beq REFRESH
;
; <A NAME="3ball_6">(6) Select a random answer</A>
;
SHOWIT
bsr RAND
and #3 ; go to a 1 in 4 chance
sta LAST_ANS
;
; <A NAME="3ball_7">(7) Display the currently selected random number</A>
;
REFRESH
ldx LAST_ANS ; Get the last answer we had, and use it as an index
lda MSG_SEL,X ; And get the message to display
jsr PUT6TOP ; Put that on the top
BANNER
lda #S6_MSG-START
jsr PUT6MID
lda #SYS8_MODE ; And show the mode on the bottom
jmp PUTMSGBOT
;
; <A NAME="3ball_8">(8) This flashes the text on the screen</A>
;
FLASH
lda CURRENT_APP ; See which app is currently running
cmp #APP_WRIST ; Is it us?
bne L0113 ; No, so just turn off the tic timer since we don't need it
ldx #5
lda MARQ_POS
jsr INCA_WRAPX
sta MARQ_POS
tax
lda MARQ_SEL,X
jmp PUT6TOP
;
; <A NAME="3ball_9">(9) They want us to do it again</A>
;
DOITAGAIN ; Tell them we are going to do it again
clr MARQ_POS
bset 1,BTNFLAGS
bra BANNER
;
; <A NAME="3ball_10">(10) Here is a simple random number generator</A>
;
RAND
lda RAND_SEED
ldx #85
mul
add #25
sta RAND_SEED
rola
rola
rola
rts
;
; <A NAME="3ball_11">(11) This is the main initialization routine which is called when we first get the app into memory</A>
;
MAIN:
lda #$c0 ; We want button beeps and to indicate that we have been loaded
sta WRISTAPP_FLAGS
lda CURRENT_TIC
sta RAND_SEED
rts
|