summaryrefslogtreecommitdiffstats
path: root/3ball/3ball.asm
diff options
context:
space:
mode:
Diffstat (limited to '3ball/3ball.asm')
-rw-r--r--3ball/3ball.asm148
1 files changed, 148 insertions, 0 deletions
diff --git a/3ball/3ball.asm b/3ball/3ball.asm
new file mode 100644
index 0000000..ad92603
--- /dev/null
+++ b/3ball/3ball.asm
@@ -0,0 +1,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,TIM_2_16TIC,0 ; Initial state
+ db EVT_RESUME,TIM_ONCE,0 ; Resume from a nested app
+ db EVT_DNNEXT,TIM_2_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