-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathtice.h
1611 lines (1490 loc) · 48.8 KB
/
tice.h
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
/* Derived from Matt "MateoConLechuga" Waltz and Jacob "jacobly" Young, in addtion to
* contributors of http://wikiti.brandonw.net/index.php?title=84PCE:OS:Include_File
* Latest as of October 2016
*/
#ifndef TICE_H
#define TICE_H
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
/************* HARDWARE AND CUSTOM ROUTINE DEFINITIONS *************/
/* Creates a random integer value */
#define randInt(min, max) ((unsigned)rand() % ((max) - (min) + 1) + (min))
/* RTC define -- useful for srand() */
#define rtc_Time() (*(volatile uint32_t*)0xF30044)
/* RTC definitions */
#define RTC_UNFREEZE (1<<7)
#define RTC_FREEZE (0<<7)
#define RTC_LOAD (1<<6)
#define RTC_ENABLE ((1<<0)|(RTC_UNFREEZE))
#define RTC_DISABLE (0<<0)
/* RTC registers */
#define rtc_Seconds (*(volatile uint8_t*)0xF30000)
#define rtc_Minutes (*(volatile uint8_t*)0xF30004)
#define rtc_Hours (*(volatile uint8_t*)0xF30008)
#define rtc_Days (*(volatile uint16_t*)0xF3000C)
#define rtc_AlarmSeconds (*(uint8_t*)0xF30010)
#define rtc_AlarmMinutes (*(uint8_t*)0xF30014)
#define rtc_AlarmHours (*(uint8_t*)0xF30018)
#define rtc_Control (*(uint8_t*)0xF30020)
#define rtc_LoadSeconds (*(uint8_t*)0xF30024)
#define rtc_LoadMinutes (*(uint8_t*)0xF30028)
#define rtc_LoadHours (*(uint8_t*)0xF3002C)
#define rtc_LoadDays (*(uint16_t*)0xF30030)
#define rtc_IntStatus (*(volatile uint8_t*)0xF30034)
#define rtc_IntAcknowledge (*(volatile uint8_t*)0xF30034)
#define rtc_IsBusy() (rtc_Control & RTC_LOAD)
/* RTC interrupt masks */
#define RTC_ALARM_INT_SOURCE (1<<5)
#define RTC_DAY_INT_SOURCE (1<<4)
#define RTC_HR_INT_SOURCE (1<<3)
#define RTC_MIN_INT_SOURCE (1<<2)
#define RTC_SEC_INT_SOURCE (1<<1)
/* RTC interrupt statuses */
#define RTC_LOAD_INT (1<<5)
#define RTC_ALARM_INT (1<<4)
#define RTC_DAY_INT (1<<3)
#define RTC_HR_INT (1<<2)
#define RTC_MIN_INT (1<<1)
#define RTC_SEC_INT (1<<0)
#define RTC_INT_MASK (RTC_SEC_INT | RTC_MIN_INT | RTC_HR_INT | RTC_DAY_INT | RTC_ALARM_INT | RTC_LOAD_INT)
/* Whole bunch of useful timer functions */
#define TIMER1_ENABLE (1<<0) /* Enables Timer 1 */
#define TIMER1_DISABLE (0<<0) /* Disables Timer 1 */
#define TIMER1_32K (1<<1) /* Use the 32K clock for timer 1 */
#define TIMER1_CPU (0<<1) /* Use the CPU clock rate for timer 1 */
#define TIMER1_0INT (1<<2) /* Enable an interrupt when 0 is reached for the timer 1 */
#define TIMER1_NOINT (0<<2) /* Disable interrupts for the timer 1 */
#define TIMER1_UP (1<<9) /* Timer 1 counts up */
#define TIMER1_DOWN (0<<9) /* Timer 1 counts down */
#define TIMER2_ENABLE (1<<3) /* Enables Timer 2 */
#define TIMER2_DISABLE (0<<3) /* Disables Timer 2 */
#define TIMER2_32K (1<<4) /* Use the 32K clock for timer 2 */
#define TIMER2_CPU (0<<4) /* Use the CPU clock rate for timer 2 */
#define TIMER2_0INT (1<<5) /* Enable an interrupt when 0 is reached for the timer 2 */
#define TIMER2_NOINT (0<<5) /* Disable interrupts for the timer 2 */
#define TIMER2_UP (1<<10) /* Timer 2 counts up */
#define TIMER2_DOWN (0<<10) /* Timer 2 counts down */
/* These defines can be used to check the status of the timer */
#define TIMER1_MATCH1 (1<<0) /* Timer 1 hit the first match value */
#define TIMER1_MATCH2 (1<<1) /* Timer 1 hit the second match value */
#define TIMER1_RELOADED (1<<2) /* Timer 1 was reloaded (Needs TIMER1_0INT enabled) */
#define TIMER2_MATCH1 (1<<3) /* Timer 2 hit the first match value */
#define TIMER2_MATCH2 (1<<4) /* Timer 2 hit the second match value */
#define TIMER2_RELOADED (1<<5) /* Timer 2 was reloaded (Needs TIMER2_0INT enabled) */
/* Timer registers */
#define timer_1_Counter (*(volatile uint32_t*)0xF20000)
#define timer_2_Counter (*(volatile uint32_t*)0xF20010)
#define timer_1_ReloadValue (*(uint32_t*)0xF20004)
#define timer_2_ReloadValue (*(uint32_t*)0xF20014)
#define timer_1_MatchValue_1 (*(uint32_t*)0xF20008)
#define timer_1_MatchValue_2 (*(uint32_t*)0xF2000C)
#define timer_2_MatchValue_1 (*(uint32_t*)0xF20018)
#define timer_2_MatchValue_2 (*(uint32_t*)0xF2001C)
#define timer_Control (*(uint32_t*)0xF20030)
#define timer_EnableInt (*(uint16_t*)0xF20038)
#define timer_IntStatus (*(volatile uint16_t*)0xF20034)
#define timer_IntAcknowledge (*(volatile uint16_t*)0xF20034)
/* LCD defines */
#define lcd_BacklightLevel (*(uint8_t*)0xF60024)
#define lcd_Timing0 (*(uint32_t*)0xE30000)
#define lcd_Timing1 (*(uint32_t*)0xE30004)
#define lcd_Timing2 (*(uint32_t*)0xE30008)
#define lcd_Timing3 (*(uint32_t*)0xE3000C)
#define lcd_UpBase (*(uint32_t*)0xE30010)
#define lcd_LpBase (*(uint32_t*)0xE30014)
#define lcd_Control (*(uint32_t*)0xE30018)
#define lcd_EnableInt (*(uint32_t*)0xE3001C)
#define lcd_IntStatus (*(uint32_t*)0xE30020)
#define lcd_IntStatusMasked (*(uint32_t*)0xE30024)
#define lcd_IntAcknowledge (*(uint32_t*)0xE30028)
#define lcd_UpBaseCurr (*(uint32_t*)0xE3002C)
#define lcd_LpBaseCurr (*(uint32_t*)0xE30030)
#define lcd_Palette ((uint16_t*)0xE30200)
#define LCD_WIDTH (320)
#define LCD_HEIGHT (240)
/* OS varaible type definitions */
typedef struct { int8_t sign, exp; uint8_t mant[7]; } real_t;
typedef struct { real_t real, imag; } cplx_t;
typedef struct { uint16_t dim; real_t items[1]; } list_t;
typedef struct { uint16_t dim; cplx_t items[1]; } cplx_list_t;
typedef struct { uint8_t cols, rows; real_t items[1]; } matrix_t;
typedef struct { uint16_t len; char data[1]; } string_t;
typedef struct { uint16_t len; char data[1]; } equ_t;
typedef struct { uint16_t size; uint8_t data[1]; } var_t;
#define matrix_element(matrix, row, col) ((matrix)->items[(row)+(col)*(matrix)->rows])
/* Cleans up everything and gets ready to enter back to the OS when you are ready to exit your program */
void prgm_CleanUp(void);
/* A faster implementation of memset */
void *memset_fast(void *ptr, int c, size_t num);
/************* TI OS SPECIFIC ROUTINES AND IMPLEMENTATIONS *************/
/**
* Resets the RTC back to its original values
* If enable is true, the RTC will be enabled during this function
*/
void boot_RTCInitialize(bool enable);
/**
* Returns the Bootcode version major
*/
uint8_t boot_GetBootVerMajor(void);
/**
* Returns the Bootcode version minor
*/
uint8_t boot_GetBootVerMinor(void);
/**
* Returns the Harware version
*/
uint8_t boot_GetHardwareVers(void);
/**
* Turns all of VRAM into 0xFF (white)
*/
void boot_ClearVRAM(void);
/**
* Checks if the [on] key was pressed
*/
bool boot_CheckOnPressed(void);
/**
* Basically a reimplemented form of printf that prints to some debugging device
*/
void boot_DebugPrintf(const char *string);
/**
* Turns off the calculator (probably not a good idea to use)
*/
void boot_TurnOff(void);
/**
* Inserts a new line at the current cursor posistion on the homescreen
*/
void boot_NewLine(void);
/**
* Prints the boot version at a really silly place on the homescreen
*/
void boot_PrintBootVersion(void);
/**
* Returns the current battery status
*/
uint8_t boot_GetBatteryStatus(void);
/**
* Waits for 10 ms
*/
void boot_WaitShort(void);
/**
* Set the time of the calculator
*/
void boot_SetTime(uint8_t seconds, uint8_t minutes, uint8_t hours);
/**
* Disables the OS cursor
*/
void os_DisableCursor(void);
/**
* Enables the OS cursor
*/
void os_EnableCursor(void);
/**
* Set/Get the foreground color used to draw text on the graphscreen
*/
void os_SetDrawFGColor(uint24_t color);
uint24_t os_GetDrawFGColor(void);
/**
* Set/Get the backgroundground color used to draw text on the graphscreen
* os_GetDrawBGColor is only useable in OS 5.2 and above; use at your own risk
*/
void os_SetDrawBGColor(uint24_t color);
uint24_t os_GetDrawBGColor(void);
/**
* Set/Get the cursor posistion used on the homescreen
*/
void os_SetCursorPos(uint8_t curRow, uint8_t curCol);
void os_GetCursorPos(unsigned int *curRow, unsigned int *curCol);
/**
* Selects/Gets the font to use when drawing on the graphscreen
* 0: small font
* 1: large monospace font
*/
void os_FontSelect(char id);
uint24_t os_FontGetID(void);
/**
* Returns the width of a string in the varaible-width format
* Second function is used to get the height of the characters
*/
uint24_t os_FontGetWidth(const char *string);
uint24_t os_FontGetHeight(void);
/**
* Draws a text using the small font to the screen
* Returns the end column
*/
uint24_t os_FontDrawText(const char *string, uint16_t col, uint8_t row);
uint24_t os_FontDrawTransText(const char *string, uint16_t col, uint8_t row);
/**
* Puts some text at the current homescreen cursor location
* Returns 1 if string fits on screen, 0 otherwise
*/
uint24_t os_PutStrFull(const char *string);
/**
* Puts some text at the current homescreen cursor location
* Returns 1 if string fits on line, 0 otherwise
*/
uint24_t os_PutStrLine(const char *string);
/**
* Set/Get a particular flag variable
*/
void os_SetFlagByte(int offset, uint8_t set);
uint8_t os_GetFlagByte(int offset);
/**
* Returns amount of free ram, free set to start of free ram
*/
size_t os_MemChk(void **free);
/**
* Throws an OS error
*/
void os_ThrowError(uint8_t error);
/**
* Returns a pointer to the system stats
*/
void *os_GetSystemStats(void);
/**
* Sets up the defualt error handlers if an OS routine encounters an error when running
*/
void os_PushErrorHandler(void *routine);
void os_PopErrorHandler(void);
/**
* Returns a pointer to symtable of the OS
*/
void *os_GetSymTablePtr(void);
/**
* Creates an appvar; and returns a pointer to the structure
* Returns NULL if creation failed for some reason, otherwise a pointer to the size bytes
*/
var_t *os_CreateAppVar(const char *name, uint16_t size);
/**
* Returns next entry or NULL if no more entries, pass os_GetSymTablePtr() as first entry
*/
void *os_NextSymEntry(void *entry, uint24_t *type, uint24_t *nameLength, const char *name, void **data);
/**
* If file exists, returns 1 and sets entry and data, otherwise returns 0.
* entry and/or data can be NULL if you don't care
*/
int os_ChkFindSym(uint8_t type, const char *name, void **entry, void **data);
/**
* type is set to the current varaible type in ANS, and a pointer to the data is returned
* Returns NULL if Ans doesn't exist or type is NULL
*/
void *os_RclAns(uint8_t *type);
/**
* Copies a real_t
*/
real_t os_RealCopy(const real_t *src);
/**
* Unary operations used to interact with the OS math functions
*/
real_t os_RealAcosRad(const real_t *arg);
real_t os_RealAsinRad(const real_t *arg);
real_t os_RealAtanRad(const real_t *arg);
real_t os_RealCosRad(const real_t *arg);
real_t os_RealRadToDeg(const real_t *arg);
real_t os_RealExp(const real_t *arg);
real_t os_RealFloor(const real_t *arg);
real_t os_RealFrac(const real_t *arg);
real_t os_RealRoundInt(const real_t *arg);
real_t os_RealLog(const real_t *arg);
real_t os_RealNeg(const real_t *arg);
real_t os_RealDegToRad(const real_t *arg);
real_t os_RealInv(const real_t *arg);
real_t os_RealSinRad(const real_t *arg);
real_t os_RealSqrt(const real_t *arg);
real_t os_RealTanRad(const real_t *arg);
real_t os_RealInt(const real_t *arg);
cplx_t os_CplxSquare(const cplx_t *arg);
/**
* Binary operations used to interact with the OS math functions
*/
real_t os_RealAdd(const real_t *arg1, const real_t *arg2);
real_t os_RealDiv(const real_t *arg1, const real_t *arg2);
real_t os_RealGcd(const real_t *arg1, const real_t *arg2);
real_t os_RealLcm(const real_t *arg1, const real_t *arg2);
real_t os_RealMax(const real_t *arg1, const real_t *arg2);
real_t os_RealMin(const real_t *arg1, const real_t *arg2);
real_t os_RealMul(const real_t *arg1, const real_t *arg2);
real_t os_RealNcr(const real_t *total, const real_t *num);
real_t os_RealNpr(const real_t *total, const real_t *num);
real_t os_RealPow(const real_t *base, const real_t *exp);
real_t os_RealRandInt(const real_t *min, const real_t *max);
real_t os_RealMod(const real_t *arg1, const real_t *arg2);
real_t os_RealSub(const real_t *arg1, const real_t *arg2);
/**
* digits must be in the range 0 - 9
*/
real_t os_RealRound(const real_t *arg, char digits);
/**
* Returns -1, 0, or 1 depending on the comparison
*/
int os_RealCompare(const real_t *arg1, const real_t *arg2);
/**
* Conversion routines for ti-floats.
* All saturate on overflow.
*/
int24_t os_RealToInt24(const real_t *arg);
real_t os_Int24ToReal(int24_t arg);
float os_RealToFloat(const real_t *arg);
real_t os_FloatToReal(float arg);
/** os_RealToStr:
* This converts a ti-float to a ti-ascii string.
* result: zero terminated string copied to this address
* arg: real to convert
* maxLength:
* <=0: use default max length (14)
* >0: max length of result, minimum of 6
* mode:
* 0: Use current mode for everything (digits ignored)
* 1: Normal mode
* 2: Sci mode
* 3: Eng mode
* >4: Use current Normal/Sci/Eng mode (digits still used)
* digits:
* -1: Float mode
* 0-9: Fix # mode
* returns length of result
*/
int os_RealToStr(char *result, const real_t *arg, char maxLength, char mode, char digits);
/** os_StrToReal:
* This converts a ti-ascii string to a ti-float.
* String format regexp: / *[-\032+]?[0-9]*(\.[0-9]*)?([eE\033][-\032+]?[0-9]*)?/
* result: resulting ti-float stored here, on exponent overflow this is +-9.9999999999999e99
* string: ti-ascii string to convert
* end: if non-null, pointer to end of parsed number is stored here
* returns result
*/
real_t os_StrToReal(const char *string, char **end);
/**
* High 8 is unsigned offset, low 8 is bits to test
* os_TestFlagBits will return a 0 or 1
*/
int os_TestFlagBits(uint16_t offset_pattern);
void os_SetFlagBits(int16_t offset_pattern);
void os_ResetFlagBits(int16_t offset_pattern);
/**
* Returns extended key in high byte
*/
uint16_t os_GetKey(void);
/**
* Performs an OS call to get the keypad scan code
* Technically return type is uint24_t, but that is not useful as the high byte is 0
* Values returned are listed below
*/
uint8_t os_GetCSC(void);
typedef uint8_t sk_key_t;
/**
* Things you shouldn't use unless you know what you are doing
*/
void boot_Set6MHzMode(void);
void boot_Set48MHzMode(void);
void boot_Set6MHzModeI(void);
void boot_Set48MHzModeI(void);
void os_ForceCmdNoChar(void);
/**
* Use this function to call assembly functions in the OS and Bootcode
* i.e. _OS( asm_ArcChk );
*/
void _OS(void *function);
/**
* Assembly functions ( Don't forget to call from _OS() )
*/
void asm_MoveUp(void);
void asm_MoveDown(void);
void asm_HomeUp(void);
void asm_RunIndicOn(void);
void asm_RunIndicOff(void);
void asm_DisableAPD(void);
void asm_EnableAPD(void);
void asm_ArcChk(void);
/**
* OS RAM Location defines for direct modification
*/
#define OS_COLOR_BLUE 10
#define OS_COLOR_RED 11
#define OS_COLOR_BLACK 12
#define OS_COLOR_MAGENTA 13
#define OS_COLOR_GREEN 14
#define OS_COLOR_ORANGE 15
#define OS_COLOR_BROWN 16
#define OS_COLOR_NAVY 17
#define OS_COLOR_LTBLUE 18
#define OS_COLOR_YELLOW 19
#define OS_COLOR_WHITE 20
#define OS_COLOR_LTGRAY 21
#define OS_COLOR_MEDGRAY 22
#define OS_COLOR_GRAY 23
#define OS_COLOR_DARKGRAY 24
#define os_ramStart ((uint8_t*)0xD00000)
#define os_flags ((uint8_t*)0xD00080)
#define os_textFlags (*(uint8_t*)0xD00080)
#define os_apdFlags (*(uint8_t*)0xD00088)
#define os_rclFlags (*(uint8_t*)0xD0008E)
#define os_kbdScanCode (*(uint8_t*)0xD00587)
#define os_kbdLGSC (*(uint8_t*)0xD00588)
#define os_kbdPSC (*(uint8_t*)0xD00589)
#define os_kbdWUR (*(uint8_t*)0xD0058A)
#define os_kbdDebncCnt (*(uint8_t*)0xD0058B)
#define os_kbdKey (*(uint8_t*)0xD0058C)
#define os_kbdGetKy (*(uint8_t*)0xD0058D)
#define os_keyExtend (*(uint8_t*)0xD0058E)
#define os_brightness (*(uint8_t*)0xD0058F)
#define os_apdSubTimer (*(uint8_t*)0xD00590)
#define os_apdTimer (*(uint8_t*)0xD00591)
#define os_curRow (*(uint8_t*)0xD00595)
#define os_curCol (*(uint8_t*)0xD00596)
#define os_OP1 ((uint8_t*)0xD005F8)
#define os_OP2 ((uint8_t*)0xD00603)
#define os_OP3 ((uint8_t*)0xD0060E)
#define os_OP4 ((uint8_t*)0xD00619)
#define os_OP5 ((uint8_t*)0xD00624)
#define os_OP6 ((uint8_t*)0xD0062F)
#define os_progToEdit ((char*)0xD0065B)
#define os_nameBuff ((char*)0xD00663)
#define os_promptRow (*(uint8_t*)0xD00800)
#define os_promptCol (*(uint8_t*)0xD00801)
#define os_promptIns (*(uint8_t*)0xD00802)
#define os_promptShift (*(uint8_t*)0xD00803)
#define os_promptRet (*(uint8_t*)0xD00804)
#define os_promptValid (*(uint8_t*)0xD00807)
#define os_penCol (*(uint24_t*)0xD008D2)
#define os_penRow (*(uint8_t*)0xD008D5)
#define os_asmPrgmSize (*(uint16_t*)0xD0118C)
#define os_uXMin (*(real_t*)0xD01D61)
#define os_uXMax (*(real_t*)0xD01D6A)
#define os_uXScl (*(real_t*)0xD01D73)
#define os_uYMin (*(real_t*)0xD01D7C)
#define os_uYMax (*(real_t*)0xD01D85)
#define os_uYScl (*(real_t*)0xD01D8E)
#define os_uThetaMin (*(real_t*)0xD01D97)
#define os_uThetaMax (*(real_t*)0xD01DA0)
#define os_uThetaStep (*(real_t*)0xD01DA9)
#define os_uTmin (*(real_t*)0xD01DB2)
#define os_uTmax (*(real_t*)0xD01DBB)
#define os_uTStep (*(real_t*)0xD01DC4)
#define os_uPlotStart (*(real_t*)0xD01DCD)
#define os_unMax (*(real_t*)0xD01DD6)
#define os_uu0 (*(real_t*)0xD01DDF)
#define os_uv0 (*(real_t*)0xD01DE8)
#define os_unMin (*(real_t*)0xD01DF1)
#define os_uu02 (*(real_t*)0xD01DFA)
#define os_uv02 (*(real_t*)0xD01E03)
#define os_uw0 (*(real_t*)0xD01E0C)
#define os_uPlotStep (*(real_t*)0xD01E15)
#define os_uXres (*(real_t*)0xD01E1E)
#define os_uw02 (*(real_t*)0xD01E27)
#define os_XMin (*(real_t*)0xD01E33)
#define os_XMax (*(real_t*)0xD01E3C)
#define os_XScl (*(real_t*)0xD01E45)
#define os_YMin (*(real_t*)0xD01E4E)
#define os_YMax (*(real_t*)0xD01E57)
#define os_YScl (*(real_t*)0xD01E60)
#define os_ThetaMin (*(real_t*)0xD01E69)
#define os_ThetaMax (*(real_t*)0xD01E72)
#define os_ThetaStep (*(real_t*)0xD01E7B)
#define os_tMinPar (*(real_t*)0xD01E84)
#define os_tMaxPar (*(real_t*)0xD01E8D)
#define os_tStep (*(real_t*)0xD01E96)
#define os_plotStart (*(real_t*)0xD01E9F)
#define os_nMax (*(real_t*)0xD01EA8)
#define os_u0 (*(real_t*)0xD01EB1)
#define os_v0 (*(real_t*)0xD01EBA)
#define os_nMin (*(real_t*)0xD01EC3)
#define os_u02 (*(real_t*)0xD01ECC)
#define os_v02 (*(real_t*)0xD01ED5)
#define os_w0 (*(real_t*)0xD01EDE)
#define os_plotStep (*(real_t*)0xD01EE7)
#define os_xResO (*(real_t*)0xD01EF0)
#define os_w02 (*(real_t*)0xD01EF9)
#define os_un1 (*(real_t*)0xD01F02)
#define os_un2 (*(real_t*)0xD01F0B)
#define os_vn1 (*(real_t*)0xD01F14)
#define os_vn2 (*(real_t*)0xD01F1D)
#define os_wn1 (*(real_t*)0xD01F26)
#define os_wn2 (*(real_t*)0xD01F2F)
#define os_fin_N (*(real_t*)0xD01F38)
#define os_fin_I (*(real_t*)0xD01F41)
#define os_fin_PV (*(real_t*)0xD01F4A)
#define os_fin_PMT (*(real_t*)0xD01F53)
#define os_fin_FV (*(real_t*)0xD01F5C)
#define os_fin_PY (*(real_t*)0xD01F65)
#define os_fin_CY (*(real_t*)0xD01F6E)
#define os_cal_N (*(real_t*)0xD01F77)
#define os_cal_I (*(real_t*)0xD01F80)
#define os_cal_PV (*(real_t*)0xD01F89)
#define os_cal_PMT (*(real_t*)0xD01F92)
#define os_cal_FV (*(real_t*)0xD01F9B)
#define os_cal_PY (*(real_t*)0xD01FA4)
#define os_y1LineType (*(uint8_t*)0xD024BF)
#define os_y2LineType (*(uint8_t*)0xD024C0)
#define os_y3LineType (*(uint8_t*)0xD024C1)
#define os_y4LineType (*(uint8_t*)0xD024C2)
#define os_y5LineType (*(uint8_t*)0xD024C3)
#define os_y6LineType (*(uint8_t*)0xD024C4)
#define os_y7LineType (*(uint8_t*)0xD024C5)
#define os_y8LineType (*(uint8_t*)0xD024C6)
#define os_y9LineType (*(uint8_t*)0xD024C7)
#define os_y0LineType (*(uint8_t*)0xD024C8)
#define os_para1LineType (*(uint8_t*)0xD024C9)
#define os_para2LineType (*(uint8_t*)0xD024CA)
#define os_para3LineType (*(uint8_t*)0xD024CB)
#define os_para4LineType (*(uint8_t*)0xD024CC)
#define os_para5LineType (*(uint8_t*)0xD024CD)
#define os_para6LineType (*(uint8_t*)0xD024CE)
#define os_polar1LineType (*(uint8_t*)0xD024CF)
#define os_polar2LineType (*(uint8_t*)0xD024D0)
#define os_polar3LineType (*(uint8_t*)0xD024D1)
#define os_polar4LineType (*(uint8_t*)0xD024D2)
#define os_polar5LineType (*(uint8_t*)0xD024D3)
#define os_polar6LineType (*(uint8_t*)0xD024D4)
#define os_secULineType (*(uint8_t*)0xD024D5)
#define os_secVLineType (*(uint8_t*)0xD024D6)
#define os_secWLineType (*(uint8_t*)0xD024D7)
#define os_y1LineColor (*(uint8_t*)0xD024D8)
#define os_y2LineColor (*(uint8_t*)0xD024D9)
#define os_y3LineColor (*(uint8_t*)0xD024DA)
#define os_y4LineColor (*(uint8_t*)0xD024DB)
#define os_y5LineColor (*(uint8_t*)0xD024DC)
#define os_y6LineColor (*(uint8_t*)0xD024DD)
#define os_y7LineColor (*(uint8_t*)0xD024DE)
#define os_y8LineColor (*(uint8_t*)0xD024DF)
#define os_y9LineColor (*(uint8_t*)0xD024E0)
#define os_y0LineColor (*(uint8_t*)0xD024E1)
#define os_para1LineColor (*(uint8_t*)0xD024E2)
#define os_para2LineColor (*(uint8_t*)0xD024E3)
#define os_para3LineColor (*(uint8_t*)0xD024E4)
#define os_para4LineColor (*(uint8_t*)0xD024E5)
#define os_para5LineColor (*(uint8_t*)0xD024E6)
#define os_para6LineColor (*(uint8_t*)0xD024E7)
#define os_polar1LineColor (*(uint8_t*)0xD024E8)
#define os_polar2LineColor (*(uint8_t*)0xD024E9)
#define os_polar3LineColor (*(uint8_t*)0xD024EA)
#define os_polar4LineColor (*(uint8_t*)0xD024EB)
#define os_polar5LineColor (*(uint8_t*)0xD024EC)
#define os_polar6LineColor (*(uint8_t*)0xD024ED)
#define os_secULineColor (*(uint8_t*)0xD024EE)
#define os_secVLineColor (*(uint8_t*)0xD024EF)
#define os_secWLineColor (*(uint8_t*)0xD024F0)
#define os_appErr1 ((char*)0xD025A9)
#define os_appErr2 ((char*)0xD025B6)
#define os_cursorHookPtr (*(uint24_t*)0xD025D5)
#define os_libraryHookPtr (*(uint24_t*)0xD025D8)
#define os_rawKeyHookPtr (*(uint24_t*)0xD025DB)
#define os_getKeyHookPtr (*(uint24_t*)0xD025DE)
#define os_homescreenHookPtr (*(uint24_t*)0xD025E1)
#define os_windowHookPtr (*(uint24_t*)0xD025E4)
#define os_graphHookPtr (*(uint24_t*)0xD025E7)
#define os_yEqualsHookPtr (*(uint24_t*)0xD025EA)
#define os_fontHookPtr (*(uint24_t*)0xD025ED)
#define os_regraphHookPtr (*(uint24_t*)0xD025F0)
#define os_graphicsHookPtr (*(uint24_t*)0xD025F3)
#define os_traceHookPtr (*(uint24_t*)0xD025F6)
#define os_parserHookPtr (*(uint24_t*)0xD025F9)
#define os_appChangeHookPtr (*(uint24_t*)0xD025FC)
#define os_catalog1HookPtr (*(uint24_t*)0xD025FF)
#define os_helpHookPtr (*(uint24_t*)0xD02602)
#define os_cxRedispHookPtr (*(uint24_t*)0xD02605)
#define os_menuHookPtr (*(uint24_t*)0xD02608)
#define os_catalog2HookPtr (*(uint24_t*)0xD0260B)
#define os_tokenHookPtr (*(uint24_t*)0xD0260E)
#define os_localizeHookPtr (*(uint24_t*)0xD02611)
#define os_silentLinkHookPtr (*(uint24_t*)0xD02614)
#define os_activeUSBHookPtr (*(uint24_t*)0xD0261A)
#define os_tempFreeArc (*(uint24_t*)0xD02655) /* Set after asm_ArcChk call */
#define os_textBGcolor (*(uint16_t*)0xD02688)
#define os_textFGcolor (*(uint16_t*)0xD0268A)
#define os_drawBGColor (*(uint16_t*)0xD026AA)
#define os_drawFGColor (*(uint16_t*)0xD026AC)
#define os_drawColorCode (*(uint8_t*)0xD026AE)
#define os_batteryStatus (*(uint8_t*)0xD02A86)
#define os_graphBGColor (*(uint16_t*)0xD02A98)
#define os_fillRectColor (*(uint16_t*)0xD02AC0)
#define os_statusBarBGColor (*(uint16_t*)0xD02ACC)
/**
* ---- TI-OS Token definitions ----
*/
#define tToDMS 0x01
#define tToDEC 0x02
#define tToAbc 0x03
#define tStore 0x04 // ->
#define tBoxPlot 0x05
#define tLBrack 0x06 // '['
#define tRBrack 0x07 // ']'
#define tLBrace 0x08 // '{'
#define tRBrace 0x09 // '}'
#define tFromRad 0x0A
#define tFromDeg 0x0B
#define tRecip 0x0C
#define tSqr 0x0D
#define tTrnspos 0x0E
#define tCube 0x0F // '^3'
#define tLParen 0x10 // '('
#define tRParen 0x11 // ')'
#define tRound 0x12 // 'round'
#define tPxTst 0x13 // 'PXL-TEST'
#define tAug 0x14 // 'aug'
#define tRowSwap 0x15 // 'rSwap'
#define tRowPlu 0x16 // 'rAdd'
#define tmRow 0x17 // 'multR'
#define tmRowPlus 0x18 // 'mRAdd'
#define tMax 0x19 // 'max'
#define tMin 0x1A // 'min'
#define tRToPr 0x1B // 'R>Pr'
#define tRToPo 0x1C // 'R>Po'
#define tPToRx 0x1D // 'P>Rx'
#define tPToRy 0x1E // 'P>Ry'
#define tMedian 0x1F // 'MEDIAN'
#define tRandM 0x20 // 'randM'
#define tMean 0x21 // 'MEAN'
#define tRoot 0x22 // 'ROOT'
#define tSeries 0x23 // 'seq'
#define tFnInt 0x24 // 'fnInt'
#define tNDeriv 0x25 // 'fnIr'
#define tEvalF 0x26
#define tFmin 0x27
#define tFmax 0x28
#define tSpace 0x29 // ' '
#define tString 0x2A // '"'
#define tComma 0x2B // ','
#define tii 0x2C // 'i'
#define tFact 0x2D // '!'
#define tCubicR 0x2E
#define tQuartR 0x2F
#define t0 0x30
#define t1 0x31
#define t2 0x32
#define t3 0x33
#define t4 0x34
#define t5 0x35
#define t6 0x36
#define t7 0x37
#define t8 0x38
#define t9 0x39
#define tDecPt 0x3A // '.'
#define tee 0x3B // 'e'
#define tOr 0x3C // '_or_'
#define tXor 0x3D
#define tColon 0x3E // ':'
#define tEnter 0x3F
#define tAnd 0x40 // '_and_'
#define tA 0x41
#define tB 0x42
#define tC 0x43
#define tD 0x44
#define tE 0x45
#define tF 0x46
#define tG 0x47
#define tH 0x48
#define tI 0x49
#define tJ 0x4A
#define tK 0x4B
#define tL 0x4C
#define tM 0x4D
#define tN 0x4E
#define tO 0x4F
#define tP 0x50
#define tQ 0x51
#define tR 0x52
#define tS 0x53
#define tT 0x54
#define tU 0x55
#define tV 0x56
#define tW 0x57
#define tX 0x58
#define tY 0x59
#define tZ 0x5A
#define tTheta 0x5B
/**
* Extended Tokens
*/
#define tExtTok 0xEF
#define tSetDate 0x00
#define tSetTime 0x01
#define tCheckTmr 0x02
#define tSetDtFmt 0x03
#define tSetTmFmt 0x04
#define tTimeCnv 0x05
#define tDayOfWk 0x06
#define tGetDtStr 0x07
#define tGetTmStr 0x08
#define tGetDate 0x09
#define tGetTime 0x0A
#define tStartTmr 0x0B
#define tGtDtFmt 0x0C
#define tGetTmFmt 0x0D
#define tIsClockOn 0x0E
#define tClockOff 0x0F
#define tClockOn 0x10
#define tOpenLib 0x11
#define tExecLib 0x12
#define tInvT 0x13
#define tChiSquaredTest 0x14
#define tLinRegTInt 0x15
#define tManualFit 0x16
#define tZQuadrant 0x17
#define tZFracHalf 0x18
#define tZFracThird 0x19
#define tZFracFourth 0x1A
#define tZFracFifth 0x1B
#define tZFracEighth 0x1C
#define tZFracTenth 0x1D
#define tFracSlash 0x2E
#define tFracMixedNum 0x2F
#define tSwapImProper 0x30
#define tSwapFracDec 0x31
#define tRemainder 0x32
#define tSummationSigma 0x33
#define tLogBase 0x34
#define tRandIntNoRep 0x35
#define tMathPrint 0x36
#define tClassic 0x38
#define tAutoAnswer 0x3B
#define tDecAnswer 0x3C
#define tFracAnswer 0x3D
#define tBlue 0x41
#define tRed 0x42
#define tBlack 0x43
#define tMagenta 0x44
#define tGreen 0x45
#define tOrange 0x46
#define tBrown 0x47
#define tNavy 0x48
#define tLtBlue 0x49
#define tYellow 0x4A
#define tWhite 0x4B
#define tLtGray 0x4C
#define tMedGray 0x4D
#define tGray 0x4E
#define tDarkGray 0x4F
#define tGraphColor 0x65
#define tTextColor 0x67
#define tBackgroundOn 0x5B
#define tBackgroundOff 0x64
#define tThin 0x74
#define tBorderColor 0x6C
#define tAsm84CPrgm 0x68
#define tAsm84CCmp 0x69
#define tAsm84CeCmp 0x7B
#define tAsm84CePrgm 0x7A
#define tVarMat 0x5C
#define tVarLst 0x5D
#define tVarEqu 0x5E
#define tProg 0x5F
#define tVarPict 0x60
#define tVarGDB 0x61
#define tVarOut 0x62
#define tVarSys 0x63
/**
* Mode settings tokens
*/
#define tRad 0x64 // 'Radian'
#define tDeg 0x65 // 'Degree'
#define tNormF 0x66 // 'Normal'
#define tSci 0x67 // 'Sci'
#define tEng 0x68 // 'Eng'
#define tFloat 0x69 // 'Float'
#define tFix 0x73 // 'Fix_'
#define tSplitOn 0x74
#define tFullScreen 0x75
#define tStndrd 0x76 // 'Func'
#define tParam 0x77 // 'Param'
#define tPolar 0x78 // 'Pol'
#define tSeqG 0x79 // ;79h
#define tAFillOn 0x7A // 'AUTO FILL ON'
#define tAFillOff 0x7B // 'AutoFill OFF'
#define tACalcOn 0x7C
#define tACalcOff 0x7D
#define tEQ 0x6A // '=='
#define tLT 0x6B // '<'
#define tGT 0x6C // '>'
#define tLE 0x6D // LLE
#define tGE 0x6E // LGE
#define tNE 0x6F // LNE
#define tAdd 0x70 // '+'
#define tSub 0x71 // '-'
#define tMul 0x82 // '*'
#define tDiv 0x83 // '/'
#define tAns 0x72
#define tBoxIcon 0x7F
#define tCrossIcon 0x80
#define tDotIcon 0x81
#define tTrace 0x84 // 'Trace'
#define tClDrw 0x85 // 'ClDraw'
#define tZoomStd 0x86 // 'ZStd'
#define tZoomtrg 0x87 // 'Ztrg'
#define tZoomBox 0x88 // 'ZBOX'
#define tZoomIn 0x89 // 'ZIn'
#define tZoomOut 0x8A // 'ZOut'
#define tZoomSqr 0x8B // 'ZSqr'
#define tZoomInt 0x8C // 'ZInt'
#define tZoomPrev 0x8D // 'ZPrev'
#define tZoomDec 0x8E // 'ZDecm'
#define tZoomStat 0x8F // 'ZStat
#define tUsrZm 0x90 // 'ZRcl'
#define tPrtScrn 0x91 // 'PrtScrn'
#define tZoomSto 0x92 // 'ZSto'
#define tText 0x93
#define tnPr 0x94 // '_nPr_'
#define tnCr 0x95 // '_nCr_'
// Graph Commands
#define tYOn 0x96 // 'FnOn_'
#define tYOff 0x97 // 'FnOff_'
#define tStPic 0x98 // 'StPic_'
#define tRcPic 0x99 // 'RcPic_'
#define tStoDB 0x9A // 'StGDB_'
#define tRclDB 0x9B // 'RcGDB_'
#define tLine 0x9C // 'Line'
#define tVert 0x9D // 'Vert_'
#define tPtOn 0x9E // 'PtOn'
#define tPtOff 0x9F // 'PtOff'
#define tPtChg 0xA0 // 'PtChg'
#define tPXOn 0xA1
#define tPXOff 0xA2
#define tPXChg 0xA3
#define tShade 0xA4 // 'Shade'
#define tCircle 0xA5 // 'Circle'
#define tHorz 0xA6 // 'HORIZONTAL'
#define tTanLn 0xA7 // 'TanLn'
#define tDrInv 0xA8 // 'DrInv_'
#define tDrawF 0xA9 // 'DrawF_'
#define tVarStrng 0xAA
// Functions with No Argument
#define tRand 0xAB // 'rand'
#define tPi 0xAC // Lpi
#define tGetKey 0xAD // 'getKy'
#define tAPost 0xAE // '''
#define tQuest 0xAF // '?'
#define tChs 0xB0
#define tInt 0xB1
#define tAbs 0xB2
#define tDet 0xB3
#define tIdent 0xB4
#define tDim 0xB5
#define tSum 0xB6
#define tProd 0xB7
#define tNot 0xB8
#define tIPart 0xB9
#define tFPart 0xBA
// New 2 Byte Tokens
#define t2ByteTok 0xBB
#define tSqrt 0xBC
#define tCubRt 0xBD
#define tLn 0xBE
#define tExp 0xBF
#define tLog 0xC0
#define tALog 0xC1
#define tSin 0xC2
#define tASin 0xC3
#define tCos 0xC4
#define tACos 0xC5
#define tTan 0xC6
#define tATan 0xC7
#define tSinH 0xC8
#define tASinH 0xC9
#define tCoshH 0xCA
#define tACosH 0xCB
#define tTanH 0xCC
#define tATanH 0xCD
// Some Programming Commands
#define tIf 0xCE // 'If_'
#define tThen 0xCF // 'Then_'
#define tElse 0xD0 // 'Else_'
#define tWhile 0xD1 // 'While_'
#define tRepeat 0xD2 // 'Repeat_'
#define tFor 0xD3 // 'For_'
#define tEnd 0xD4 // 'End'
#define tReturn 0xD5 // 'Return'
#define tLbl 0xD6 // 'Lbl_'
#define tGoto 0xD7 // 'Goto_'
#define tPause 0xD8 // 'Pause_'
#define tStop 0xD9 // 'Stop'