-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfurby.asm
More file actions
6788 lines (5680 loc) · 189 KB
/
furby.asm
File metadata and controls
6788 lines (5680 loc) · 189 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; XXX Missing labels
;;; XXX
;;; XXX TI_reset
;;; XXX Name_table
;;; XXX Word_group0
;;; XXX Word_group1
;;; XXX Word_group2
;;; XXX Clr_word_end
;;; XXX Set_end
;;; XXX Spch_more
;;; XXX GBYTE
;;; XXX
;;; XXX cac I am not sure how Furby 27 gets included. XXX
;;; XXX Included at end XXX
;;; XXX Include Furby27.inc
;;; XXX
;;; XXX
;;; XXX
;;; XXX Table of contents
;;; XXX
;;; XXX pg 3-4 Voice EQUs
;;; XXX pg 4 Motor EQUs
;;; XXX pg 5-7 I/O port EQUs
;;; XXX pg 7-9 Timer EQUs
;;; XXX pg 9-10 DAC EQUs
;;; XXX pg 10 Sensor EQUs
;;; XXX pg 10-14 Run EQUs
;;; XXX pg 14-19 Variables, stack
;;; XXX pg 19-25 RESET handler
;;; XXX pg 26- Idle handler
;;; XXX
;;; XXX pg 98-99 EEPROM write
;;; XXX pg 99 Sleep code
;;; XXX pg 99-105 Interupt handlers
;;; XXX
;;; XXX pg 105-108 TI sound chip communication
;;; XXX
;;; XXX
;;; page 001 start complete
;;;<;+-----------------------------------------------------------------------------+
;;;<;| |
;;;<;| SPC81A Source Code (Version 25) |
;;;<;| |
;;;<;| |
;;;<;| Written by: Dave Hampton / Wayne Schulz |
;;;<;| |
;;;<;| Date: July 30, 1998 |
;;;<;| |
;;;<;| Copyright (C) 1996,1997,1998 by Sounds Amazing! |
;;;<;| |
;;;<;| All rights reserved |
;;;<;| |
;;;<;+-----------------------------------------------------------------------------+
;;;>;EIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
;;;>IIII>
;;;>;*
;;;>*
;;;>;* SPC81A Source Code (Version 25)
;;;>*
;;;>;*
;;;>*
;;;>;* Written by: Dave Hampton / Wayne Schulz
;;;>*
;;;>;* Date: July 30, 1998
;;;>*
;;;>;*
;;;>*
;;;>;* Copyright (C) 1996,1997,1998 by Sounds Amazing!
;;;>*
;;;>;* All rights reserved.
;;;>*
;;;>;EIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
;;;>IIII#
;
;
;**********************************************************************
; remember SBC if there is a borrow carry is CLEARED
;;;<; also SBC if the two numbers are equal you still get a negative result
;;;>; also SBC if the two numbers are equal you still get a negative
;;;>result
;
;
;;;<;+-----------------------------------------------------------------------------+
;;;<;| MODIFICATION LIST
;;;<;|
;;;>;EIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
;;;>IIII>
;;;>;* MODIFICATION LIST :
;;;>*
;
; Furby29/30/31/32
; Final testing for shipment of code on 8/2/98.
; Tables updated, motor speed updated, wake up/name fix
; sequential tables never getting first entry,fixed.
;;;<; New diag5.asm, Light3.asm (if light osc stalls it wont hang system).
;;;>; New diag5.asm, Light3.asm (if light osc stalls it wont hang
;;;>system).
;
; Furby33
; In motor brake routine, turn motors off before turning reverse
; braking pulse on to save transistors.
;
; Furby34
; Cleanup start code and wake routines
; Light sensor goes max dark and stays there to reff time, then
; call sleep macro and shut down.
;
; Furby35
; Adds four new easter eggs,BURP ATTACK, SAY NAME, TWINkLE SONG,
; and ROOSTER LOVES YOU. Also add new names.
;
;
;
;;;<;-------------------------------------------------------------------------------
;;;>;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;;; page 001 end
;;; page 002 start complete
; Release 3
;; File "testR3a"
;;;<; 1. Light sensor has a hysteresis point of continually triggering sensor.
;;;>; 1. Light sensor has a hysteresis point of continually triggering
;;;>sensor.
; 2. Light sensor decrements two instead of one on hungry counter
; 3. Diagnostic mode for light sensor wont trigger very easily.
;;;<; 4. When a furby receives the I.R. sleep command he sends the same command
;;;>; 4. When a furby receives the I.R. sleep command he sends the same
;;;>command
; out before going to sleep.
;
; 5. When hungry is low enough to trigger sick counter, each sensor
; deducts two instead of one for each hit.
;
; 6. When diagnostics complete clear memory, reset hungry & sick to FF
; randomly choose new name and voice, then write EEPROM before
; going to sleep. Also extend EEPROM diagnostic to test all locations
; for pass/fail of device.
;
; 7. Add new light routine
; 8. Change hide and seek egg to light, light, light, tummy.
; 9. Change sick/hungry counter so that it can only get so sick and
; not continue down to zero. (MAX_SICK)
;;;<;10. In diagnostics, motor position test ,,,, first goes forward continuously
;;;>;10. In diagnostics, motor position test ,,,, first goes forward
;;;>continuously
; until the front switch is pressed, then goes reverse continuously
;;;<; until the front switch is pressed again, and then does normal position
;;;>; until the front switch is pressed again, and then does normal
;;;>position
; calibration stopping at the calibration switch.
;11. On power up we still use tilt and invert to generate startup random
; numbers, but if feed switch is pressed for cold boot, we use it to
; generate random numbers, because it is controlled by the user where
; the tilt and invert are more flaky.
;12. No matter what age, 25% of time he randomly pulls speech from age
; to generate more Furbish at older ages.
;13. Twinkle song egg
; When song is complete, if both front and back switches are pressed
; we goto deep sleep. That means only the invert can wake us up, not
; the tilt switch.
;;;<;| |
;;;<;-------------------------------------------------------------------------------
;;;>;°
;;;>°
;;;>;EÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
;;;>ÍÍÍÍÍÍÍ
;**************************************************************************
;**************************************************************************
;**************************************************************************
;**************************************************************************
;**************************************************************************
;;; page 002 end
;;; page 003 start complete
; Actual numeric value for TI pitch control
; bit 7 set = subtract value from current course value
; clr = add value to current course value
; bit 6 set = select music pitch table
; clr = select normal speech pitch table
; bit 0-5 value to change course value (no change = 0)
; A math routine in 'say_0' converts the value for + or -
; if <80 then subtracts from 80 to get the minus version of 00
; ie, if number is 70 then TI gets sent 10 (which is -10)
; If number is 80 or > 80 then get sent literal as positive.
; NOTE: MAX POSITIVE IS 8F (+16 from normal voice of 00)
; MAX NEGATIVE is 2F (-47 from normal voice of 00)
;This is a difference of 80h - 2Fh or 51h
; 8Fh is hi voice (8f is very squeeeeeke)
; 2Fh lo voice ( very low)
;;;<; The math routine in 'Say_0' allows a +-decimal number in the speech table.
;;;>; The math routine in 'Say_0' allows a +-decimal number in the speech
;;;>table.
; A value of 80 = no change or 00 sent to TI
; 81 = +1
; 8f = +16
;
; A value of 7F = -1 from normal voice
; 70 = -16
; The voice selection should take into consideration that the hi voice
; selection plus an aditional offset is never greater than 8f
; Or a low voice minus offset never less than 2f.
Voice1 EQU 83h ;(+3) hi voice
Voice2 EQU 7Ah ;(-6) mid voice
Voice3 EQU 71h ;(-15) low voice
;;;<;;;; we converted to a random selection table, but since all voice tables
;;;>;;;; we converted to a random selection table, but since all voice
;;;>tables
; use the equates plus some offset, we made the change in the SAY_0
; routine. We always assign voice 3 which is the lowest, and based on
;;;<; the random power up pitch selection, the ram location 'Rvoice' holds
;;;>; the random power up pitch selection, the ram location 'Rvoice'
;;;>holds
;;;<; the number to add to the voice+offset received from the macro table.
;;;>; the number to add to the voice+offset received from the macro
;;;>table.
;;;<Voice EQU Voice3 ;pitch (choose Voice1, Voice2, Voice3) (voice2=norm)
;;;>Voice EQU Voice3 ;pitch (choose Voice1, Voice2,
;;;>Voice3) (voice2=norm)
;;;<; Select Voice3 since it is the lowest and then add the difference to get
;;;>; Select Voice3 since it is the lowest and then add the difference to
;;;>get
; Voice2 or Voice3. Here we assign that difference to an equate to be
; used in the voice table that is randomly selected on power up.
S_voice1 EQU 18 ;Voice3 + 18d = Voice1
S_voice2 EQU 09 ;Voice3 + 09d = Voice2
;;; page 003 end
;;; page 004 start complete
S_voice3 EQU 0 ;Voice3 + 00d = Voice3
;********************************************************************
; Motor speed pulse width :
; Motor_on = power to motor, Motor_off is none.
Mpulse_on EQU 16 ;
Mpulse_off EQU 16 ;
;;;
Cal_pos_fwd EQU 134 ;calibration switch forward direction
Cal_pos_rev EQU 134 ;calibration switch forward direction
;********************************************************************
;********************************************************************
;********************************************************************
;********************************************************************
;********************************************************************
;
;+------------------------------------------------------------------+
;| PORTS |
;| SPC40A has : 16 I/O pins |
;| PORT_A 4 I/O pins 0-3 |
;| PORT_C 4 I/O pins 0-3 |
;| PORT_D 8 I/O pins 0-7 |
;| |
;| RAM |
;| |
;| SPC40A has : 128 bytes of RAM |
;| from $80 - $FF |
;| |
;| ROM |
;| SPC40A has : |
;| BANK0 user ROM from $0600 - $7FFF |
;| BANK1 user ROM from $8000 - $FFF9 |
;| |
;| |
;| VECTORS |
;| NMI vector $7FFA / $7FFB |
;| RESET vector $7FFC / $7FFD |
;| IRQ vector $7FFE / $7FFF |
;+------------------------------------------------------------------+
;+------------------------------------------------------------------+
;| PORTS |
;| SPC120A has : 17 I/O pins |
;| PORT_A 4 I/O pins 0-3 |
;| PORT_B 4 I/O pins 0,1,2,4,5 |
;| PORT_C 4 I/O pins 0-3 input only |
;| PORT_D 8 I/O pins 0-7 |
;| |
;| RAM |
;| SPC120A has : 128 bytes of RAM |
;| from $80 - $FF |
;| |
;| ROM |
;| SPC120A has : |
;;; page 004 end
;;; page 005 start complete
;| BANK0 user ROM from $0600 - $7FFA |
;| BANK1 user ROM from $8000 - $FFFF |
;| BANK2 user ROM from $10000 - $17FFF |
;| BANK3 user ROM from $1A000 - $1FFFF |
;| |
;| |
;| VECTORS |
;| NMI vector $7FFA / $7FFB |
;| RESET vector $7FFC / $7FFD |
;| IRQ vector $7FFE / $7FFF |
;+------------------------------------------------------------------+
; unuseable areas in rom
;SPC40A: 8000H -- DFFFH should be skiped (Dummy area)
; bank 0 = 600-7FFA
; bank 1 = 8000 - DFFF reserved , start @ E000 - FFFA
;SPC80A: 10000H -- 13FFFH should be skiped (Dummy area)
; bank 0 = 600 - 7FFA
; bank 1 = 8000 - FFFA
; bank 2 = 10000-13FFF reserved , start at 14000 - 17FFF
;SPC120A: ;SPC120A: 18000H -- 19FFFH should be skiped (Dummy area)
; bank 0 = 600-7FFA
; bank 1 = 8000 - FFFA
; bank 2 = 10000-17FFF
; bank 3 = 18000-19FFF reserved , start at 1A000 - 1FFFA
;SPC256A: ;SPC256A: Non dummy area
;SPC512A: ;SPC512A: Non dummy area
;*************************************************************************************
.CODE
;;;<.6502
;;;>.SYNTAX 6502
.LINKLIST
.SYMBOLS
;----------------- PORT DIRECTION CONTROL REGISTER -----------------------------
Ports_dir EQU 00 ; (write only)
;
; (4 I/O pins) controlled with each bit of this register
; you can't control each pin separately, only as a nibble
; 0 = input / 1 = output
;
;;;<; 7 6 5 4 3 2 1 0 (REGISTER BITS)
;;;>; 7 6 5 4 3 2 1 0 (REGISTER
;;;>BITS)
; D D C C B B A A (PORT)
; 7654 3210 7654 3210 7654 3210 7654 3210 (PORT BITS)
;-------------------------------------------------------------------------------
;----------------- PORT CONFIGURATION CONTROL REGISTER -------------------------
;;; page 005 end
;;; page 006 start complete
; based on if the port pin is input or output
;
Ports_con EQU 01 ; (write only)
;
; (4 I/O pins) controlled with each bit of this register
;;;<; 7 6 5 4 3 2 1 0 (REGISTER BITS)
;;;>; 7 6 5 4 3 2 1 0 (REGISTER
;;;>BITS)
; D D C C B B A A (PORT)
; 7654 3210 7654 3210 7654 3210 7654 3210 (PORT BITS)
; port_a INPUTS can be either:
; 0 = float 1 = pulled high
; port_a OUTPUTS can be either:
; 0 = buffer 1 = upper (4) bits Open drain Pmos (source)
; lower (4) bits Open drain Nmos (sink)
;
; port_b INPUTS can be either:
; 0 = float 1 = pulled low
; port_b OUTPUTS can be either:
; 0 = buffer 1 = upper (4) bits Open drain Nmos (sink)
; lower (4) bits Open drain Nmos (sink)
;
; port_c INPUTS can be either:
; 0 = float 1 = pulled high
; port_c OUTPUTS can be either:
; 0 = buffer 1 = upper (4) bits Open drain Pmos (source)
; lower (4) bits Open drain Nmos (sink)
;
; port_d INPUTS can be either:
; 0 = float 1 = pulled low
; port_d OUTPUTS can be either:
; 0 = buffer 1 = Open drain Pmos (source)
;-------------------------------------------------------------------------------
;----------------- I/O PORTS ---------------------------------------------------
;;;<Port_A EQU 02H ; (read/write) for TI & speech recgn CPU's
;;;>Port_A EQU 02H ; (read/write) for TI & speech recgn
;;;>CPU's
Data_D0 EQU 01H ; bit 0 data nible port
Data_D1 EQU 02H ;
Data_D2 EQU 04H ;
Data_D3 EQU 08H ;
Port_B EQU 03H ;b0/b1 = I/O b4/b5 = inp only
TI_init EQU 01H ;B0 - TI reset control
TI_CTS EQU 02H ;B1 - hand shake to TI
IR_IN EQU 10H ;B4 - I.R. Recv data
TI_RTS EQU 20H ;B5 - TI wants data
Port_C EQU 04H ;(read/write)
Motor_cal EQU 01H ;C0 - lo when motor crosses switch
Pos_sen EQU 02H ;C1 - motor optiical sensor (intt C1)
Touch_bck EQU 04H ;C2 - back touch
Touch_frnt EQU 08H ;C3 - front touch
;;; page 006 end
;;; page 007 start complete
Port_D EQU 05H ;(read/write)
Ball_side EQU 01H ;D0 - hi when on any side (TILT)
Ball_invert EQU 02H ;D1 - hi when inverted
Light_in EQU 04H ;D2 - hi when bright light hits sensor
Mic_in EQU 08H ;D3 - hi pulse microphone input
Power_on EQU 10H ;D4 - power to rest of circuit
Motor_led EQU 20H ;D5 - motor I.R. led driver
Motor_lt EQU 40H ;D6 - motor drive left (forward)
Motor_rt EQU 80H ;D7 - motor drive right (reverse)
;-------------------------------------------------------------------------------
;----------------- DATA LATCH PORT_D -------------------------------------------
Latch_D EQU 06H ; (read)
; read to latch data from port_d, used for wake-up on pin change
;-------------------------------------------------------------------------------
;----------------- BANK SELECTION REGISTER -------------------------------------
Bank EQU 07H ; (read/write) x x x x x x x b
; 0 = bank 0, 1 = bank 1 ; 7 6 5 4 3 2 1 0
; only two banks in SPC40a
;-------------------------------------------------------------------------------
;----------------- WAKE UP -----------------------------------------------------
Wake_up EQU 08H ; (read/write) x x x x x x x w
; 7 6 5 4 3 2 1 0
; w=(0=disable, 1=enable wake-upon port_d change)
; read to see if wake-up, or normal reset
; this is the only source for a wake-up
; Always reset stack on wake up.
;-------------------------------------------------------------------------------
;----------------- SLEEP -------------------------------------------------------
Sleep EQU 09H ; (write) x x x x x x x s
; ; 7 6 5 4 3 2 1 0
; s =(0=don't care, 1=sleep)
; writting 1 to bit0, forces sleep
;-------------------------------------------------------------------------------
;----------------- TIMER A CONTROL REGISTER ------------------------------------
; this needs more work to understand DMH
TMA_CON EQU 0BH ; (write)
;
;
; 7 6 5 4 3 2 1 0
; m x x x
;
; m= Timer one mode (0=Timer,1=Counter)
;;; page 007 end
;;; page 008 start complete
; Bit3: IE1 | IE1= 0: Counter clock= external clock from IOC2
; Bit2: T1 | = 1, T1= 0: counter clock= CPUCLK/8192
; Bit1: IE0 | T1= 1: counter clock= CPUCLK/65536
; Bit0: T0 | IE0= 0: Counter clocks external clock from IOC2
; = 1, T0= 0: counter clock= CPUCLK/4
; T0= 1: counter clock= CPUCLK/64
;
;-------------------------------------------------------------------------------
;----------------- INTERRUPTS --------------------------------------------------
Interrupts EQU 0DH ; (read/write)
;
; 7 6 5 4 3 2 1 0
; w m a b 3 2 1 e
;
; w = (0=watch dog ON, power-on default) (1=watch dog OFF)
; m = (0=Timer A generates NMI INT, 1=Timer A generates IRQ INT)
; a = (0=Timer A interrupt off, 1=Timer A interrupt on)
; b = (0=Timer B interrupt off, 1=Timer B interrupt on)
;;;<; 3 = (0=CPU CLK/1024 interrupt off, 1=CPU CLK/1024 interrupt on)
;;;<; 2 = (0=CPU CLK/8192 interrupt off, 1=CPU CLK/8192 interrupt on)
;;;<; 1 = (0=CPU CLK/65536 interrupt off, 1=CPU CLK/65536 interrupt on)
;;;>; 3 = (0=CPU CLK/1024 interrupt off, 1=CPU CLK/1024 interrupt
;;;>on)
;;;>; 2 = (0=CPU CLK/8192 interrupt off, 1=CPU CLK/8192 interrupt
;;;>on)
;;;>; 1 = (0=CPU CLK/65536 interrupt off, 1=CPU CLK/65536 interrupt
;;;>on)
; e = (0=external interrupt off, 1=external interrupt on)
; rising edge, from port_c bit 1
;-------------------------------------------------------------------------------
;----------------- TIMERS ------------------------------------------------------
; There are two 12bits timers.
; Timer A can be either a timer or a counter. (as set by TIMER_CON)
; Timer B can only be used as a timer.
; *
; Timers count-up and on overflow from 0FFF to 0000, this carry bit will
;;;<; create an interrupt if the corresponding bit is set in INTERRUPTS register.
;;;>; create an interrupt if the corresponding bit is set in INTERRUPTS
;;;>register.
;;;<; The timer will be auto reloaded with the user setup value, and start,,,
;;;>; The timer will be auto reloaded with the user setup value, and
;;;>start,,,
; count-up again.
;
;;;<; Counter will reset by user loading #00 into register TMA_LSB and TMA_MSB.
;;;>; Counter will reset by user loading #00 into register TMA_LSB and
;;;>TMA_MSB.
;;;<; Counter registers can be read on-the-fly, this will not affect register,,,
;;;>; Counter registers can be read on-the-fly, this will not affect
;;;>register,,,
; values, or reset them.
;
;-------------------------------------------------------------------------------
;----------------- TIMER A (low byte) ------------------------------------------
;;;<TMA_LSB EQU 10H ;(read/write)
;;;>TMA_LSB EQU 10H (read/write)
;
; all 8bits valid (lower 8bits of 12bit timer)
;;; page 008 end
;;; page 009 start complete
;-------------------------------------------------------------------------------
;----------------- TIMER A (high byte) -----------------------------------------
;;;<TMA_MSB EQU 11H ;(read/write)
;;;>TMA_MSB EQU 11H (read/write)
; read x x x x 11 10 9 8 timer upper 4bits
; 7 6 5 4 3 2 1 0
;
; write x x t c 11 10 9 8 timer upper 4bits
; 7 6 5 4 3 2 1 0 register bit
;
; t=(0=speech mode, 1=Tone mode)
; this connects the AUDA pin to either
; the DAC1, or Timer generated square wave
;
; c=(0=CPU clock, 1=CPU clock/4)
;-------------------------------------------------------------------------------
;----------------- TIMER B (low byte) ------------------------------------------
TMB_LSB EQU 12H
;
; all 8 bits valid (lower 8 bits of 12bit timer)
;-------------------------------------------------------------------------------
;----------------- TIMER B (high byte) -----------------------------------------
TMB_MSB EQU 13H
; read x x x x 11 10 9 8 timer upper 4 bits
; 7 6 5 4 3 2 1 0
;
; write x x t c 11 10 9 8 timer upper 4 bits
; 7 6 5 4 3 2 1 0 register bit
; t=(0=speech mode, 1=Tone mode)
; this connects the AUDB pin to either
; the DAC2, or Timer generated square wave
;
; c=(0=CPU clock, 1=CPU clock/4)
;-------------------------------------------------------------------------------
;----------------- D/A CONVERTERS ----------------------------------------------
DAC1 EQU 14H ; (write)
DAC2 EQU 15H ; (write)
;-------------------------------------------------------------------------------
;----------------- D/A CONVERTERS ----------------------------------------------
; this needs more work to understand DMH
; 16H ADCoutputPort16H:
DAC_ctrl EQU 16H
;
;;; page 009 end
;;; page 010 start complete
; Bit7: I/O 0: Diable ADC; 1: Enable ADC
; Bit6: I/O
; Bit5: I/O
; Bit4: I/O
; Bit3: I/O
; Bit2: I/O
; Bit1: I/O
; Bit0: I/O
;-------------------------------------------------------------------------------
;-----------------------------------------------------
; Operating equate definition
;-----------------------------------------------------
;EQdef
;to calculate sample rates
; CPU clk/sample rate divisor
; Hi & Lo timer reg command = FFF
; FFF - divisor = values to load hi & lo reg.
;ex: 6mHZ clk = 166nSEC
;********* start Tracker
;/* here is some definition chnge of time interrupt constant */Tracker
;;;<;SystemClock: EQU 6000000 ;Select 6000000Hz it will be the same
;;;>;SystemClock: EQU 6000000 ;Select 6000000Hz it will be the
;;;>same
;as before
;;;<SystemClock: EQU 3579545 ;Select 3579545Hz while we are use that
;;;>SystemClock: EQU 3579545 ;Select 3579545Hz while we are
;;;>use that
;crystal
;;;<TimeA_low: EQU <(4096-(SystemClock/5859)) ;put constant definition
;;;>TimeA_low: EQU <(4096-(SystemClock/5859)) ;put constant
;;;>definition
TimeA_hi: EQU >(4096-(SystemClock/5859))
TimeB_low: EQU <(4096-(SystemClock/1465))
TimeB_hi: EQU >(4096-(SystemClock/1465))
;********* end Tracker
Port_def EQU A7h ;D hi=out,D lo=inp / C hi=out,C lo=inp
;B hi=inp,B lo=out / A hi=out,A lo=out
Con_def EQU 50H ;D hi=out buffer, D lo=in pull lo
; ;C hi=out buffer, C lo=in pull hi
; ;B hi=in hi-Z , B lo=out buffer
; ;A hi=out buffer, A lo=out buffer
Intt_dflt EQU D0H ;sets interrupt reg = no watchdog,irq
; timer B , and EXt port C bit 1 = off
;***** run EQU's
;*******************************************************************************
;;; page 010 end
;;; page 011 start complete
;;;<; Send a braking pulse to stop motor drift, and this EQU is a decimal number
;;;>; Send a braking pulse to stop motor drift, and this EQU is a decimal
;;;>number
;;;<; that determines how many time through the 2.9 mSec loop (how many loops)
;;;>; that determines how many time through the 2.9 mSec loop (how many
;;;>loops)
; the brake pulse is on. If attempting to make single count jumps, the
;;;<; brake pulse needs to be between 26 and 30. For any jump greater than 10
;;;>; brake pulse needs to be between 26 and 30. For any jump greater than
;;;>10
; braking between 22 and 80 is acceptable. ( Long jumps are not critical
; but short jump will begin to oscillate if braking is too great.)
; 60 long & 20 short work at 3.6v and no pulse width
Drift_long EQU 60 ;number times thru intt before clearing pulse
Drift_short EQU 25 ;
;*******************************************************************************
;;;<; set this with a number from 0 - 255 to determine timeout of all sensors
;;;>; set this with a number from 0 - 255 to determine timeout of all
;;;>sensors
; for the sequential increments. If it times out the table pointer
;;;<; goes back to the start, else each trigger increments through the table.
;;;>; goes back to the start, else each trigger increments through the
;;;>table.
; NOTE: this time includes the motor/speech execution time !!!
Global_time EQU 16 ; 1= 742 mSEC ;; 255 = 189.3 seconds
;*******************************************************************************
; This determines how long Firby waits with no sensor activity, then
; calls the Bored_table for a random speech selection.
; Use a number between 1 & 255. Should probably not be less than 10.
; SHOULD BE > 10 SEC TO ALLOW TIME FOR TRAINING OF SENSORS
Bored_reld EQU 40 ; 1= 742 mSEC ;; 255 = 189.3 seconds
;*******************************************************************************
;
; Each sensor has a sequential random split which must equal 16.
; Each sensor has a different assignment.
; The tables are formatted with the first X assignments random
; and the remaining as sequential.
Seq_front EQU 8
Ran_front EQU 8
Seq_back EQU 9
Ran_back EQU 7
Seq_tilt EQU 10
Ran_tilt EQU 6
Seq_invert EQU 8
Ran_invert EQU 8
Seq_sound EQU 0
Ran_sound EQU 16
;;; page 011 end
;;; page 012 start complete
Seq_light EQU 0
Ran_light EQU 16
Seq_feed EQU 8
Ran_feed EQU 8
Seq_wake EQU 0
Ran_wake EQU 16
Seq_bored EQU 7
Ran_bored EQU 9
Seq_hunger EQU 5
Ran_hunger EQU 11
Seq_sick EQU 4
Ran_sick EQU 12
; rev furb11ja
; Each sensor also determines how often it is random or sequential
; as in 50/50 or 60/40 etc.
; These entries are subtracted from the random number generated
;;;<; and determine the split. (the larger here, the more likely sequential pick)
;;;>; and determine the split. (the larger here, the more likely sequential
;;;>pick)
Tilt_split EQU 80h ;
Invert_split EQU 80h ;
Front_split EQU 80h ;
Back_split EQU 80h ;
Feed_split EQU 80h ;
Sound_split EQU 80h ;
Light_split EQU 80h ;
Bored_split EQU 80h ;
Hunger_split EQU 80h ;
Sick_split EQU 80h ;
;***************************************************************************
Random_age EQU 30h ;at any age, below this number when a
; random number is picked will cause him
; to pull from the age 1 table. More Furbish.
;****************************************************************************
Learn_chg EQU 31 ;amount to inc or dec training of words
;------------------------------------
Food EQU 20h ;amount to increase 'Hungry' for each feeding
Need_food EQU 80h ;below this starts complaining about hunger
Sick_reff EQU 60h ;below this starts complaining about sickness
Really_sick EQU C0h ;below this only complains about sickness
Max_sick EQU 80h ;cant go below this when really sick
Hungry_dec EQU 01 ;subtract X amount for each sensor trigger
Sick_dec EQU 01 ;subtract X amount for each sensor trigger
;------------------------------------
Nt_word EQU FEH ;turn speech word active off
Nt_last EQU FBH ;bit 2 off - last word sent to TI
;;; page 012 end
;;; page 013 start complete
Nt_term EQU F7h ;bit 3 off -terminator to speech TI
Clr_spch EQU FCH ;clears spch_activ & word_activ
CTS_lo EQU FDH ;makes TI_CTS go lo
;--------
Motor_rev EQU FDH ;clears motor fwd bit
Motor_inactv EQU FEh ;kill motor activ bit
Motor_ntseek EQU FBh ;kill motor seek bit
Motor_off EQU C0h ;turns both motor lines off (hi)
Motor_revs EQU 7FH ;bit 7 lo
Motor_fwds EQU BFh ;bit 6 lo
Ntmot_on EQU DFh ;clears motor pulse on req
Nt_IRQdn EQU F7h ;clear IRQ stat
Nt_Motor_led EQU DFh ;motor opto led off
Motor_led_rst EQU 100 ;X * 2.9 millSec for shut off time
Nt_Init_motor EQU FBh ;cks motor speed only on wake up
NT_Init_Mspeed EQU F7h ;clears 2nd part of motor speed test
Opto_spd_reld EQU 80 ;number of IRQ to count opto pulse speed
Speed_reff EQU 30 ;value to adjust speed to
Nt_macro_actv EQU 7Fh ;clears request
;--------
Not_bside EQU F7h ;clear ball side done flag
Not_binvrt EQU EFh ;clear ball invert done flag
Not_tch_bk EQU BFh ;clear touch back sense done flag
Not_tch_ft EQU DFh ;clear touch back sense done flag
Not_feed EQU FDh ;clear feed sense done flag
Sound_reload EQU 05 ;X * 742 milisec time between trigger
Snd_cycle_rled EQU 02 ;sound sense referrence cycle timer
;--------
Light_reload EQU 07 ;X * 742 milisec until new reff level set
;--------
Nt_Slot_dn EQU FEh ;clr IR slot low detected
Nt_lt_reff EQU EFh ;turns reff off
Nt_lght_stat EQU FEh ;clears light bright status to dim status
;;; Bright & Dim equates have been moved to the light include file.
;;;Bright EQU 05 ;light sensor trigger > reff level
;;;Dim EQU 05 ;Light sensor trigger < reff level
;--------
;Qik_snd_reload EQU 01 ;
;Nt_end_reff EQU DFh ;kill sound reff level bit
Nt_do_snd EQU FEh ;clears sound state change req
Nt_snd_stat EQU FBh ;clears Sound_stat
;--------
Nt_fortune EQU FEh ;kills fortune teller mode
Nt_Rap EQU FDh ;kills Rap mode
Nt_hideseek EQU FBh ;kills Hide & seek game mode
Nt_simon EQU F7h ;kills simon say game mode
;--------
Nt_do_tummy EQU F7h ;clears sensor change req
Nt_do_back EQU EFh ;clears sensor change req
Nt_do_feed EQU DFh ;clears sensor change req
Nt_do_tilt EQU BFh ;clears sensor change req
Nt_do_invert EQU 7Fh ;clears sensor change req
Nt_do_lt_brt EQU FDh ;clears sensor change req
;;; page 013 end
;;; page 014 start complete
Nt_do_lt_dim EQU FBh ;clears sensor change req
;--------
Nt_temp_gam1 EQU FEh ;clears game mode bits
Nt_half_age EQU BFh ;clears req for 2 table instead of 4
Nt_randm EQU 7Fh ;clears random/sequential status
GameT_reload EQU 24 ; 1= 742 mSEC ;; 255 = 189.3 seconds
;+-------------------------------------------------+
;| Variable definition (Ram = $80 to $FF)
;+-------------------------------------------------+
;Rdef
;***** DO NOT CHANGE RAM ASSIGNMENTS (X pointer used as offsett)
;************* The next group of RAM locations can be used by any
; sensor routine but cannot be used to save data.
; TEMP ONLY!
;***************** koball
TEMP0 equ 80h
TEMP1 equ 81h
TEMP2 equ 82h
TEMP3 equ 83h
TEMP4 equ 84h
IN_DAT equ 85h
;****************** end koball
;* END TEMP RAM ************
Task_ptr EQU 86h ;what function is in process
Port_A_image EQU 87h ;
Port_B_Image EQU 88H ;output port image
Port_D_Image EQU 89H ;output port image
;-------
Word_lo EQU 8Ah ;speech word lo adrs
Word_hi EQU 8Bh ; " " hi "
Saysent_lo EQU 8CH ;saysent word pointer
Saysent_hi EQU 8DH ; " " "
Bank_ptr EQU 8EH ;which bank words are in
Which_word EQU 8FH ;which word or saysent to call
Sgroup EQU 90H ;which saysent group table
Tx_data EQU 91H ;
;-------
Which_motor EQU 92h ;holds table number of motor positon
Mgroup EQU 93H ;which motor group table
Motor_lo EQU 94H ;
Motptr_lo EQU 95h ;table pointer to get motor position
Motptr_hi EQU 96H ;
Which_delay EQU 97H ;how much time between motor calls
Intt_Temp EQU 98H ;
Drift_fwd EQU 99h ;time motor reverses to stop drift
Drift_rev EQU 9Ah ;
Pot_timeL EQU 9Bh ;motor uses to compare against current positon
; moved to hi ram that is not cleared on power up
;Pot_timeL2
Moff_len EQU 9Ch ;holds motor power off pulse time
Mon_len EQU 9Dh ;holds motor power on pulse time
Motor_pulse1 EQU 9Eh ;motor pulse timer
Slot_vote EQU 9Fh ;need majority cnt to declare a valid slot
;;; page 014 end
;;; page 015 start complete; more low ram A0-C7
Motor_led_timer EQU A0h ;how long after motion done led on for IR
Mot_speed_cnt EQU A1h ;motor speed test
Mot_opto_cnt EQU A2h ; "
Cal_switch_cnt EQU A3h ;used to eliminate noisy reads
motorstoped EQU A4h ;times wheel count when stopping
Drift_counter EQU A5h ;decides how much braking pulse to apply
;-------
Mili_sec EQU A6h ;used in calc pot position by timer
Cycle_timer EQU A7h ;bypasses intt port c updates to motor
Sensor_timer EQU A8h ;times between sensor trigger
Bored_timer EQU A9h ;time with no activity to random speech
;-------
Invrt_count EQU AAh ;which speech/motor call is next
Tilt_count EQU ABh ;which speech/motor call is next
Tchfrnt_count EQU ACh ;which speech/motor call is next
Tchbck_count EQU ADh ;which speech/motor call is next
Feed_count EQU AEh ;which speech/motor call is next
;-------
Last_IR EQU AFh ;last IR sample data to compare to next
Wait_time EQU B0h ;used in IRQ to create 2.8mSec timers
;-------
Light_timer EQU B1h ;Light sensor routines
Lght_count EQU B2h ;which speech/motor call is next
Light_reff EQU B3h ;holds previous sample
;---------------
Sound_timer EQU B4h ;time to set new reff level
Sound_count EQU B5h ;which speech/motor call is next
;---------------
Milisec_flag EQU B6h ;set every 742 miliseconds
Macro_Lo EQU B7h ;table pointer
Macro_Hi EQU B8h ; " "
Egg_cnt EQU B9h ;easter egg table count pointer
;******************** Koball code rev B
HCEL_LO EQU BAh ;
HCEL_HI EQU BBh ;
BIT_CT EQU BCh ;
;******************** end koball
Light_shift EQU BDh ;(was TMA_INT ) used for threshold change
;***************************
Prev_random EQU BEh ;prevents random number twice in a row
Bored_count EQU BFh ;sequential selection for bored table
TEMP5 EQU C0h ;general use also used for wake up
Temp_ID2 EQU C1h ;use in sensor training routines
Temp_ID EQU C2h ;use in sensor training routines
Learn_temp EQU C3h ;use in sensor training routines
Req_macro_lo EQU C4h ;holds last call to see if sleep or IR req
Req_macro_hi EQU C5h ;
Sickr_count EQU C6h ;sequential counter for sick speech table
Hungr_count EQU C7h ;sequential counter for hunger speech table
;;; page 015 end
;;; page 016 start complete; more low ram C8-CD
Motor_pulse2 EQU C8h ;motor pulse timer
;***** DO NOT CHANGE BIT ORDER ******
Stat_0 Equ C9h ;System status
Want_name EQU 01H ;bit 0 =set forces system to say Furby's name
Lt_prev_dn EQU 02H ;bit 0 = done flag for quick light changes
Init_motor EQU 04H ;bit 1 = on wakeup do motor speed/batt test
Init_Mspeed EQU 08H ;bit 3 = 2nd part of motor speed test
Train_Bk_prev EQU 10H ;bit 4 = set when 2 back sw hit in a row
Say_new_name EQU 20H ;bit 5 = only happens on cold boot
REQ_dark_sleep EQU 40H ;bit 6 = set -dark level sends to sleep
;;;<Dark_sleep_prev EQU 80H ;bit 7 = if set on wake up thendont gotosleep