root / unification.html

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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>The TI-82/83(+) Unification FAQ</title>
  <meta name="author" content="GuillaumeH">
</head>

<body link="Lime" vlink="Green" style="color: white; background-color: black;">

<div style="text-align: center;"><big style="color: Lime;"><big>
-= THE TI-82/83(+) UNIFICATION FAQ =-</big></big><br />
<br />
by Guillaume Hoffmann<br />
revision 10: 21/12/2005<br />
</div>

<p>
<big> I Introduction<br />
II The actual FAQ<br />
</big>
</p>

<div style="margin-left: 40px;">
<a href="#part01">1. Which shell should I program for on
each calc?</a><br />
<a href="#part02">2. Are there already existant headers to do so, or will I have to
do it all by myself ?</a><br />
<a href="#part03">3. Do all these calculators have the same saferams ?</a><br />
<a href="#part04">4. How do I manage ROM Calls on these different calcs ?</a><br />
<a href="#part05">5. How can I use the free RAM ?</a><br />
<a href="#part06">6. What about other z80-based devices ?</a><br />
</div>
<p><big> III To do / Questions without answser<br />
IV Contact/thanks<br />
V History<br />
</big></p>

<p><big><big><span style="text-decoration: underline;">I Introduction:</span></big></big></p>
<p>
The purpose of this FAQ is to help programmers who program only for
TI-82, TI-83 or TI-83+ to program for these 3 calcs at the same time.</p>
<p>
When ION was released, making easy the development on both TI-83 and
TI-83+, it was the first time people could almost transparently program
for two (quite) different calculator models. But unfortunately nothing has evolved since then.</p>
<p>You may be wondering why I don't include the TI-85 and TI-86 in this
FAQ. The answer is : it's only a matter of time. If you really want the
clues to do it, just get "Phoenix" by Patrick Davidson at <a
 href="http://pad.calc.org">http://pad.calc.org</a>, and see how
the author manages to build a program for every TI-z80 calc with
almost the same source code.</p>
<p>
Last, you may have already noticed that English is not
my mother language, so you can e-mail me to report spell and grammar
errors :)
</p>

<p><span style="text-decoration: underline;"><br /><big><big> II The actual FAQ:</big></big></span>

<a name="part01"></a>
<p><big><span style="text-decoration: underline;">1. Which shell should I program for on each calc?</span></big></p>

<p>Remarks :<br />
* the way I use the word "shell" is sometimes abusive (in example, Venus is rather a plug-in than a shell)<br />
* I don't always use the right names for each built-in functions, I prefer to use names that give you an immediate idea of what it does. And sometimes functions to which I give the same name are a little different :)<br />
* I don't mention outdated shells<br />
</p>

<p>The choice of the shell depends on several points:</p>

<p>
1) amount of RAM it leaves once loaded (FBLOI: free bytes left once
installed)<br />
2) built-in functions<br />
3) stability<br />
4) compatibility with other shells</p>

<p>Explanation:</p>

<p>1) very important because the user will be more comfortable when
ey can put more (or bigger) programs on eir calc. It may be
important also if the programmer wants to make a full use of the calc's
memory.</p>

<p>
2) it can be good and bad at the same time, because if a program uses a
lot of shell functions, it will certainly be bigger once ported to
another calc, because the shell will be different and may not have all
the functions used; on the other hand, if a there are many shell
functions that aren't used by a majority of programs, there functions
are useless and still take your calc's precious memory. The best
compromise is a shell that has only <strong>really</strong>
useful functions.</p>


<p>3) Most of the shells are stable, but some of them are no
longer maintained or still under development. It is seldom a
real issue.</p>

<p>4) It can be useful if you don't want to force the user to forsake
eir beloved programs that work with an older shell. But, obviously,
this can interfere with the 1st point, beware!</p>

<p>So the most important points you should look at are the first two
ones. I'm going to make my own research on this topic :
</p>

<p><span style="text-decoration: underline;">On TI-82 :</span></p>

<p>The choice is hard, because, to me, there isn&#039;t really a &quot;best ti-82 shell&quot;, they all have drawbacks.</p>

<table cellpadding="2" cellspacing="0" border="1"
 style="text-align: left; width: 100%;">
  <tbody>
    <tr>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);"> <br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);">CrASH<br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);">CrASH19006</td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);">ACE<br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);">SNG<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">FBLOI<br />
      </td>
      <td style="vertical-align: top;" rowspan="1" colspan="2">27700</td>
      <td style="vertical-align: top;">25700</td>
      <td style="vertical-align: top;">26930</td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Built-in routines<br />
      </td>
      <td style="vertical-align: top;" rowspan="1" colspan="2">FastCopy,
Random, Exit2TIOS, CP_HL_BC<br />
      </td>
      <td style="vertical-align: top;">CrASH ones + Pause,&nbsp;Fill
(hl) with a, HL_DECI, DirectKey...<br />
      </td>
      <td style="vertical-align: top;">ACE ones + Greyscale, Beep,
Mul_HL_BC, HL_HEX...<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">For which ROMs ?</td>
      <td style="vertical-align: top;">all but 19.006<br />
      </td>
      <td style="vertical-align: top;">19.006<br />
      </td>
      <td style="vertical-align: top; text-align: center;" rowspan="1"
 colspan="2">All known ROMs<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Comment</td>
      <td style="vertical-align: top;" rowspan="1" colspan="2">You have
to compile two different versions, one for CrASH, another one for
CrASH19006.<br />
      </td>
      <td style="vertical-align: top;">Beta, no longer maintained.<br />
Uses TEXT_MEM2. Has an inner 2 kB buffer.<br />
      </td>
      <td style="vertical-align: top;">
            Has &quot;emulators&quot; to run CRASH, ASH, ACE and ION programs.
            <br />
      </td>
    </tr>
  </tbody>
</table>
<p>
<span style="color: Lime;">My choice : CrASH/CrASH19006</span></p>

<a name="onemorereason"></a>Remark : if you don't use any ROM call and no link routine, you can compile a single program for any TI-82 ROM versions, than can be run with CrASH and CrASH19006. For the link issue, you can find more info <a href="http://julien.lasson.free.fr/Doc-link19006.htm">here</a> (in French).


<p><span style="text-decoration: underline;">On TI-83 :</span></p>

<table cellpadding="2" cellspacing="0" border="1"
 style="text-align: left; width: 100%;">
  <tbody>
    <tr>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);"><br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);">ION<br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);">Venus<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">FBLOI</td>
      <td style="vertical-align: top;">25800<br />
      </td>
      <td style="vertical-align: top;">26900<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Built-in routines<br />
      </td>
      <td style="vertical-align: top;">FastCopy, Random, Putsprite,
Putlargesprite, Getpixel, Detectprogram, Unpackdata<br />
      </td>
      <td style="vertical-align: top;">FastCopy, Random<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Comments</td>
      <td style="vertical-align: top;"><br />
      </td>
      <td style="vertical-align: top;">Allows to lauch program directly
from the TI-OS. It is just a single program that you can sent and
delete
at wish. Can run ION and SOS programs with an external module.<br />
      </td>
    </tr>
  </tbody>
</table>

<p><span style="color: Lime;">My choice : Venus</span></p>

<p><span style="text-decoration: underline;">On TI-83+ :</span>
</p>
<table cellpadding="2" cellspacing="0" border="1"
 style="text-align: left; width: 100%;">
  <tbody>
    <tr>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);"><br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);">ION<br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102);">MirageOS<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">FBLOI</td>
      <td style="vertical-align: top;">22800<br />
      </td>
      <td style="vertical-align: top;">24300<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Built-in routines<br />
      </td>
      <td style="vertical-align: top;">FastCopy, Random, Putsprite,
Putlargesprite, Getpixel, Detectprogram, Unpackdata<br />
      </td>
      <td style="vertical-align: top;">ION ones + lots</td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Comments<br />
      </td>
      <td style="vertical-align: top;"><br />
      </td>
      <td style="vertical-align: top;">It's a Flash APP, so it leaves
all RAM free.<br />
Handles ION programs.<br />
      </td>
    </tr>
  </tbody>
</table>

<p><span style="color: Lime;">My choice : I make ION programs and I use MirageOS</span></p>

<p>I've chosen ION because it has fewer features, so I prevent myself
from using extra features of MirageOS that will be hard to let down on
other calcs. Plus, a ION program can be run with MirageOS, while the
contrary is impossible.</p>

<p>There is also the possibility to make flash APPs, but you won't be
able to use self-modifying code, and you'll have to create APP
vars&nbsp; to store things like highscore, saves, etc. Plus, your
programs must fit in one or several 16 kB Flash APPS, that means that a
5 kB program will use a whole 16 kB Flash APP, and that a 24 kB program
will use two 16 kB Flash Apps (that you will have to link together...).</p>

<p><a name="part02"></a><p><big><span style="text-decoration: underline;">2. Are there already
headers to do so, or will I have to do it all by myself?</span></big></p>

<p>It depends on which compiler you use.</p>

<p>
The most widespread one is <strong>TASM</strong>.
It works under DOS (thus Windows). You can also launch TASM under Linux
with DOSEMU or WINE. But you have to know that it is a shareware, it is not free,
though propably noone and nothing will prevent you from using it for
years, like almost the whole ti-community does :)</p>

<p>
The less known one is <strong>TPASM</strong>.
It works under Unix (and Linux). It's under the GNU/GPL. TPASM
requires a source code syntax that is a little different from TASM's,
i.e. the MACROs are defined differently, you must use "db", "dw", "ds",
"org", etc. instead of ".db", ".dw", ".ds", .org"... Another important
thing is that TPASM is case sensitive, including for the labels, while
TASM isn't.</p>

<p>
In case you use <strong>TASM</strong>,
the header you may use is "dwedit.inc", by Dan "Dwedit" Weiss. You can
find it at <a href="http://home.comcast.net/%7Ealanweiss3/dwedit/ti/">http://home.comcast.net/~alanweiss3/dwedit/ti/</a>.
With this header, you will be able to program for TI-82, TI-83(+) and
even TI-73 ! You will also be able to make Flash Apps for ti-83+. It's
really a huge header, and it handles almost all known shells.</p>

<p> If you use <strong>TPASM</strong>,
I've made a header called "vion.inc". You can find it at <a
 href="http://gh.paxl.org/">http://gh.paxl.org/</a>. This
header handles CrASH and CrASH19006 for the TI-82, Venus for the Ti-83
and ION for the Ti-83+. That's all! It is just my own little header,
but then you can add what you want for yourself.</p>

<p>
<a name="part03"></a><big><span style="text-decoration: underline;">3. Do all these
calculators have the same saferams ?</span></big></p>


<p>Saferams are really useful, but sometimes you can't do what you want with them.</p>

<p>The most useful one is the <strong>APD
Buffer</strong>, which is 768 bytes big. On TI-83(+) there's no
problem, they are only used if the calc shuts down after a few minutes
of inactivity (Auto Power Down) so it won't happen in your programs
(unless you use the rom call _getkey, that is NOT recommended !)</p>

<p>But on TI-82 it's a little more difficult; actually it depends on
the shell you are using. I don't really know how it works for ACE and
SNG... CrASH(19006) has a disturbing feature ; it allows to
install an interrupt routine in the APD_BUF, that stays even when
another program is launched... So, as I don't care about what the
others' interrupt routines will do, I merely disable them as I
start my program, like this (replace the # by a space for TPASM) :</p>

<pre>
#IFDEF TI82
&nbsp;&nbsp;&nbsp; im 1 ; tells to the z80 processor to stop executing
"custom interrupt", and to execute the "normal interrupt" instead
&nbsp;&nbsp;&nbsp; xor a
&nbsp;&nbsp;&nbsp; ld (INT_STATE),a ; tells CrASH that there is no more
interrupt routine installed (not really useful I think)
#ENDIF
</pre>

<p>Now you have the whole APD_BUF for you alone.</p>

<p>
There is another useful saferam: <strong>TXT_BUF</strong> (128 bytes big).
This one is usable on TI-82,83(+) without problem, just remember to
reset it before leaving your program, if you don't want remaining
weird characters on the TI-OS screen.</p>

<p>And last, the <strong>OPs</strong> (the area where are stored the Floating Points values) that is 66 bytes
big. You can use it as long as you don't use any rom call concerning
FP operations (that is a wise decision because they are <strong>sluggish</strong>, unless you really need to do FP maths).</p>

<p>We also have the <strong>PlotsScreen</strong> area (768 bytes)
on every calc model. It is almost always used as a buffer for the display, but you can use it as a saferam.</p>
<p>There are other saferams, but for compatibility's sake, we can't use
them :</p>
<p>* <strong>StatRam</strong> (531 bytes)
is on TI-83(+) but not on TI-82. Moreover, on TI-83+, MirageOS
has its own interrupt that uses the first bytes of StatRam, as says the
doc :</p>
<p>( By default, there will be an interrupt running during your program. This interrupt is located in the StatRam location. If you wish to use StatRam for variable storage, you must disable interrupts or set IM 1 before doing
so.</span></p>

<p>So, for the TI-83+ version of your program, if you really want to use
StatRam, put im 1 at the beginning of your program, to be sure it's wot mess everything up.</p>

<p>* On TI-83+ there are <strong>appBackupScreen</strong>
(768 bytes) and <strong>tempSwapArea</strong>
(323 bytes), but they aren't on TI-82/83 as they are related to Flash
RAM.</p>

<p>
* On TI-83(+) we have <strong>imathptrs</strong>
(10 bytes), I don't know what it's for, but as it isn't on TI-82 we
won't use it.</p>

<p>
* The TI-83(+) have a ram place called <strong>cmdShadow</strong>, that is 128 bytes
big. It is not free when you use ION or MirageOS, but with Venus
there's
no problem. This area is called <strong>TEXT_MEM2</strong>
on TI-82, and gets reseted each time you call the CR_HAND routine under
CrASH (but you shouldn't use CR_HAND = _getkey).</p>

<p>Summary table :</p>

<table cellpadding="2" cellspacing="0" border="1"
 style="text-align: left; width: 100%;">
  <tbody>
    <tr>
      <td style="vertical-align: top;">Saferam name<br />
      </td>
      <td style="vertical-align: top;">APD_BUF (savesscreen)<br />
      </td>
      <td style="vertical-align: top;">TEXT_MEM (textshadow)<br />
      </td>
      <td style="vertical-align: top;">OPs<br />
      </td>
      <td style="vertical-align: top;">cmdShadow / TEXT_MEM2<br />
      </td>
      <td style="vertical-align: top;">StatRam</td>
      <td style="vertical-align: top;">imathptrs<br />
      </td>
      <td style="vertical-align: top;">appBackupScreen<br />
      </td>
      <td style="vertical-align: top;">tempSwapArea<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Size</td>
      <td style="vertical-align: top;">768<br />
      </td>
      <td style="vertical-align: top;">128<br />
      </td>
      <td style="vertical-align: top;">66<br />
      </td>
      <td style="vertical-align: top;">128<br />
      </td>
      <td style="vertical-align: top;">531</td>
      <td style="vertical-align: top;">10<br />
      </td>
      <td style="vertical-align: top;">768<br />
      </td>
      <td style="vertical-align: top;">323<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">TI-82 status, address<br />
      </td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available </span>(with CrASH, after
disabling interrupts)<br />
      <span style="color: Lime;">$8228</span><br />
      </td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$808F</span><br />
      </span> </td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$8028</span><br />
      </span></td>
      <td
 style="vertical-align: top; background-color: rgb(51, 51, 51);"><span
 style="color: rgb(255, 0, 0);"></span><span
 style="color: rgb(51, 255, 255);">Available<span
 style="color: rgb(255, 255, 255);"> (reseted when you call CR_HAND;
Non
Available with ACE)<br />
      <span style="color: Lime;">$8BDF</span><br />
      </span></span></td>
      <td style="vertical-align: top; text-align: center;" rowspan="1"
 colspan="4"><span style="color: rgb(255, 0, 0);">Non Available</span>
(doesn't exist)<span style="color: rgb(255, 0, 0);"></span></td>
    </tr>
    <tr>
      <td style="vertical-align: top;">TI-83 status, address<br />
      </td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$8265</span><br />
      </span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$80C9</span><br />
      </span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$8039</span><br />
      </span></td>
      <td
 style="vertical-align: top; background-color: rgb(51, 51, 51);"><span
 style="color: rgb(51, 255, 255);">Available</span> (with Venus only)<br />
      <span style="color: Lime;">$9157</span><br />
      </td>
      <td style="vertical-align: top; background-color: rgb(0, 0, 0);"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$858F</span></span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$8094</span><br />
      </span></td>
      <td style="vertical-align: top; text-align: center;" rowspan="1"
 colspan="2"><span style="color: rgb(255, 0, 0);">Non Available </span>(doesn't
exist)<span style="color: rgb(255, 0, 0);"></span></td>
    </tr>
    <tr>
      <td style="vertical-align: top;">TI-83+ status, address<br />
      </td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$86EC</span><br />
      </span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$8508</span><br />
      </span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$8478</span><br />
      </span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(255, 0, 0);">Non Available <span
 style="color: rgb(255, 255, 255);">(used by shells)<br />
      <span style="color: Lime;">$966E</span><br />
      </span></span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available</span><span
 style="color: rgb(255, 0, 0);"> <span
 style="color: rgb(255, 255, 255);">(disable interrupts)<br />
      <span style="color: Lime;">$8A3A</span><br />
      </span></span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$84D3</span><br />
      </span></td>
      <td
 style="vertical-align: top; background-color: rgb(51, 51, 51);"><span
 style="color: rgb(51, 255, 255);">Available<br />
      <span style="color: Lime;">$9872</span><br />
      </span></td>
      <td style="vertical-align: top;"><span
 style="color: rgb(51, 255, 255);">Available</span> (unless during
Flash
ROM loading)<br />
      <span style="color: Lime;">$82A5</span><br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Use it ?<br />
      </td>
      <td style="vertical-align: top;">Yes<br />
      </td>
      <td style="vertical-align: top;">Yes<br />
      </td>
      <td style="vertical-align: top;">Yes<br />
      </td>
      <td style="vertical-align: top;">No<br />
      </td>
      <td style="vertical-align: top;">No</td>
      <td style="vertical-align: top;">No<br />
      </td>
      <td style="vertical-align: top;">No<br />
      </td>
      <td style="vertical-align: top;">No<br />
      </td>
    </tr>
  </tbody>
</table>

<p>We can use <strong>3 saferams</strong>,
but look at the grey cells : the smallest among them is TEXT_MEM2 on
TI-82 (and cmdShadow on TI-83), so in the source code of your programs
you can refer to these 3 different saferam as a single one that is 128
bytes big like this :</p>

<pre>
#IFDEF TI82
&nbsp;mysaferam=$8BDF
#ENDIF

#IFDEF TI83
&nbsp;mysaferam=$9157
#ENDIF

#IFDEF TI83P
&nbsp;mysaferam=$9872
#ENDIF
</pre>

<p>Thus, later in your program, you will be able to use these 128 bytes
to store temporary data :</p>

<pre>
ship_x = mysaferam
ship_y = ship_x+1
life = ship_y+1
...
</pre>

<p>Now we can say that we have <strong>4 common saferams</strong> on TI-82, TI-83 and TI-83+ ! THIS is useful !</p>

<a name="part04"></a>
<p><big><span style="text-decoration: underline;">4. How do I manage
ROM Calls on these different calcs ?</span></big></p>

<p>First of all, read carefully the following sentence, and copy it a hundred times on a sheet of paper :</p>

<p align="center"><FONT color="Red">I SHALL NOT USE ROM CALLS</FONT></p>

<p>
You're certainly wondering why. "They're handy and they make my programs smaller!", I hear you say. Sure. It is also true that, since we program in ASM, we are used to heavily depend on the hardware our programs will run on, so for certain things very hardware-related (i.e. for all that concerns the VAT) we just can't avoid using ROM calls.<br />
But from an "unification" point of view, you must remind that the more your program is machine-independent, the better it is.</p>
<p>
One thing for sure is that you won't always find the same ROM Calls on different calc models (and I'm not yet considering the possibility to port your program to other z80-based systems). It will not really kill the porting process, but I'm sure that the amount of time you want to give for TI-programming is not so big. So, take the good way since the beginning, and use ROM call as less as possible.</p>
<p>Plus, you will see further in this part that dealing with bcall, icall, bjp and ijp are a pain...</p>
<p>
      Moreover, ROM calls on the TI-8X+ series are slow, this is because the bcall thingy looks for the right ROM page before calling the routine. So it is also a speed issue.
    </p>
<p>Oh, I was about to forget mention <a href="#onemorereason">this</a> reason ! :)</p>
<p>
Now, here are some explanations if you really want or have to use ROM calls :</p>

<p>If you already program for TI-83 and TI-83+, you are already used to
"bcall" instead of "call" for calling ROM Calls. This is a command that is equated by the compiler, differently in function of the calc :<br />
* for the TI-83 is is replaced by a mere "call"<br />
* for the TI-83+ it is replaced by a slow code that handles different
rom pages to find the ROM Call (don't ask me how the TI-83+ memory
works...)
</p>

<p>But when you program also for the TI-82 you have to take in account
2 categories of TI-82 ROM Calls : those that you can directly call with
a mere "call", and those you can't (that's where the shell is useful).</p>

<p>Here is a table to visualise how it works (the ????
address is the address of the routine used by CrASH(19006) to
handle ROM Calls) :<br />
</p>
<table cellpadding="2" cellspacing="0" border="1"
 style="text-align: left; width: 100%;">
  <tbody>
    <tr>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102); color: rgb(255, 255, 255);">Command<br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102); color: rgb(255, 255, 255);"><span
 style="color: rgb(255, 255, 255);">bcall</span> xxxx<br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102); color: rgb(255, 255, 255);">icall
xxxx<br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102); color: rgb(255, 255, 255);">bjp
xxxx<br />
      </td>
      <td
 style="vertical-align: top; background-color: rgb(102, 102, 102); color: rgb(255, 255, 255);">ijp
xxxx<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">TI-82 transcription<br />
      </td>
      <td style="vertical-align: top;">call ????<br />
dw xxxx<br />
      </td>
      <td style="vertical-align: top;">call xxxx<br />
      </td>
      <td style="vertical-align: top;">bcall xxxx<br />
ret<br />
      </td>
      <td style="vertical-align: top;">jp xxxx<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">TI-83 transcription</td>
      <td style="vertical-align: top;">call xxxx<br />
      </td>
      <td style="vertical-align: top;">call xxxx<br />
      </td>
      <td style="vertical-align: top;">jp xxxx<br />
      </td>
      <td style="vertical-align: top;">jp xxxx<br />
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;">TI-83+ transcription</td>
      <td style="vertical-align: top;">rst 28h<br />
dw xxxx<br />
      </td>
      <td style="vertical-align: top;">bcall xxxx<br />
      </td>
      <td style="vertical-align: top;">bcall xxxx<br />
ret<br />
      </td>
      <td style="vertical-align: top;">bjp xxxx<br />
      </td>
    </tr>
  </tbody>
</table>
<p>Hopefully, the ROM Calls that require icall aren't too numerous.
(reminder : this is for CrASH(19006) programming) :</p>

<p>_ldhlind ( LD_HL_MHL )<br />
_cphlde (CP_HL_DE )<br />
_divhlby10 ( UNPACK_HL )<br />
_divhlbya ( DIV_HL_A )<br />
_getcsc ( GET_KEY )<br />
_lcdbusy ( DISP_DELAY )</p>

<p>The faster you&#039;ll memorize them, the fewer bugs you&#039;ll experience in your developpements, because confusing an icall/ijp with a bcall/bjp always leads to a crash on TI-82.</p>

<p><big><u>Replacing ROM calls</u></big></p>

<p>Here is an explanation of how I do to avoid using ROM calls.</p>

<p>For the following rom calls, I merely paste their code into my programs (it's small) :</p>

<p>_ldhlind<br />
_cphlde<br />
_divhlby10<br />
_divhlbya<br />
_lcdbusy
</p>

<p>For _clrlcdf, I first clear the graph buffer and then I update the screen with a FastCopy routine. Quite dirty, but for now I realize that I don't need speed when I use _clrlcdf.<br />
When I need speed for a _clrlcdf routine, I'll make one based on the FastCopy.</p>

<p>Now the most controversial part :</p>

<p>_puts (and its derivates) : I use only small fonts, so I don't need these :)</p>

<p>_vputs (and its derivates) : here comes the one that can make your programs noticeably bigger... I think the best replacement for this routine is the one made by Dan "Dwedit" Weiss for <a href="http://home.comcast.net/~alanweiss3/dwedit/bubblebobble/index.html">Bubble Bobble 85</a>. This routine draws the most useful characters jsut like the _vputs routine and it's 334 bytes big. I've also made a <a href="http://paxl.org:2080/~gh/ti83/bub4font.z80">4x4 version</a> or this routine that is 220 bytes big. There are also (not as good) routines like it at <a href="http://void.ticalc.org">http://void.ticalc.org</a>, just look at the file font.h or into the program TxtView.</p>

<p>Using a replacement for _vputs also allows to develop TI-85 versions of your programs, because on this calc you can't write in the graph buffer in small fonts. It also allows to have a personnalised font, and some extra characters you may want to insert that are not in TI's &quot;ASCII&quot;.</p>

<p>_getcsc : I find this rom call useful because of its simplicity and because it provides non-repeating keys for a small amount of time. A good pure asm re-implementation of it can be found in the source code of Acelgoyobis by CoBB.

<pre>
ReadKeyboard:		; Fills 7 bytes at KeyPressed; if a key is pressed, the corresponding
 ld hl,KeyPressed	; bit is set to ZERO. Works with disabled interrupts as well.
 ld b,7
 ld c,$fe
RK_Loop:
 ld a,$ff
 out (1),a
 ld a,c
 out (1),a
 in a,(1)
 ld (hl),a
 inc hl
 rlc c
 djnz RK_Loop
 ret

ValidateKeys:		; Fills the ValidKey array; if a key was just pressed, the corresponding
 ld hl,KeyPressed	; bit is reset (zeroed). Must be called after ReadKeyboard.
 ld de,KeyState
 ld ix,ValidKey
 ld b,7
VK_Loop:
 ld a,(de)
 or (hl)
 ld (ix),a
 ld a,(hl)
 cpl
 ld (de),a
 inc hl
 inc de
 inc ix
 djnz VK_Loop
 ret
</pre>

And its variables :

<pre>
KeyPressed:		; bit:	7	6	5	4	3	2	1	0
 .byte 255		;					up	right	left	down
 .byte 255		;		clear	^	/	*	-	+	enter
 .byte 255		;		vars	tan	)	9	6	3	(-)
 .byte 255		;	stat	prgm	cos	(	8	5	2	.
 .byte 255		;	X	matrx	sin	,	7	4	1	0
 .byte 255		;	alpha	math	x^-1	x^2	log	ln	sto
 .byte 255		;	del	mode	2nd	y=	window	zoom	trace	graph

KeyState:		; Auxiliary array to validate keys
 .byte 0,0,0,0,0,0,0

ValidKey:		; Valid keys: keys pressed since the last check
 .byte 255,255,255,255,255,255,255
</pre>

Here is how to use these two routines : to test if a key has been pressed :

<pre>
DHS_WaitKey:				; Waiting for 2nd
 call ReadKeyboard
 call ValidateKeys
 ld a,(ValidKey+6)			; 2nd
 and %00100000
 jr nz,DHS_WaitKey
 ret
</pre>

The z flag is set when there is a rising edge on the 2nd key, i.e. only if when the 2nd key is pressed after it is not pressed.
</p>


<a name="part05"></a><p><big><span style="text-decoration: underline;">5. How do I use the
free RAM ?</span></big></p>

<p>
Sometime, you need a BIG temporary buffer for your games. You can&nbsp;
put it inside your program, but it would be a waste because it will
take space even if your program isn't running. So the best solution is
to use the free RAM of your calc.</p>

<p><strong>On TI-83 and TI-83+</strong>, it's easy to do so. Put these equates in the
header you're using (if they aren't already there) :</p>

<pre>
#IFDEF TI83
FREE_MEM_START = $930D
FREE_MEM_END = $9311
_enoughmem = 443Ah
#ENDIF

#IFDEF TI83P
FREE_MEM_START = $9824
FREE_MEM_END = $9828
_enoughmem = 42FDh
#ENDIF
</pre>
<br />
<br />
_enoughmem is a rom call that compares the value given in HL with the
amount of free RAM. After calling it, the carry flag is set if there is
not enough free RAM. I think it is not available on TI-82.<br />
Let's say you need 4000 bytes. At the beginning of your program, put :<br />

<pre>
ld hl,4000
bcall _enoughmem
ret c
</pre>

Thus, the program won't start if there is not enough free mem (you may
want to display a "not enough free mem" message in this case).<br />
Later, to access this "buffer", you'll have to do :

<pre>
ld hl,(FREE_MEM_START) ; now HL has the address of the buffer
</pre>

<p><strong>On TI-82 :</strong></p>

<p>Marc Plouhinec, the author of the TI-82 shell SNG v 1.0, has included these macros in the file SNG.inc :</p>

<p>
<pre>
;Creates a buffer if there is enough memory, leaves if not (ret)

#Define CREATEBUFFERANDTESTMEM1(Size,BufferAddress)
ROM_CALL(DEL_TMP)
LD HL,Size
ROM_CALL(MEM_FREE)
JR NC,EnoughMem
ROM_CALL(CREATE_TMP)
RET
EnoughMem:
LD HL,Sizee
LD DE,BufferAddress
ROM_CALL(INSERT_MEM)
ROM_CALL(CREATE_TMP)
</pre>

</p>

<p>
<pre>
;Creates a buffer if there is enough memory, jumps at the label NotEnoughMem else.

#Define CREATEBUFFERANDTESTMEM2(Size,BufferAddress,NotEnoughMem)
ROM_CALL(DEL_TMP)
LD HL,Size
ROM_CALL(MEM_FREE)
JR NC,EnoughMem
ROM_CALL(CREATE_TMP)
JR NotEnoughMem
EnoughMem:
LD HL,Size
LD DE,BufferAddress
ROM_CALL(INSERT_MEM)
ROM_CALL(CREATE_TMP)
</pre>
</p>

<p>
<p>
<pre>
;Destroys the buffer

#Define DELBUFFER(Size, BufferAddress)
ROM_CALL(DEL_TMP)
LD DE,Size
LD HL,BufferAddress
ROM_CALL(DEL_MEM)
ROM_CALL(CREATE_TMP)
</pre>
</p>


<p>When you "call a macro" to create a temporary buffer, you have to specify the address of the buffer. A solution that works well is simply to choose the adress of the byte right after the end of the current program. You merely need to define a label at the very end of your program, and use this label as the address of the temporary buffer. The romcalls INSERT_MEM and CREATE_TMP take care of moving the other programs, so in theory you can choose any adress, but choosing the previous solution works fine.</p>

<p>CoBB says : "These macros work only with those shells that leave the VAT consistent with the memory. That means no CrASH." So for the moment you'd better stick to SNG 1.0 if you want to use free ram on TI-82.</p>

<p>CoBB also has an easy way to make this "83(+) compatible", by introducing the 2 FREE_MEM_START and FREE_MEM_END variables :</p>



<pre>
; These equates are in the OPs, but they could be anywhere (only 4 bytes needed)
FREE_MEM_START = $8028
FREE_MEM_END = $802A

ROM_CALL(DEL_TMP)
LD HL,Size
ROM_CALL(MEM_FREE)
JR NC,EnoughMem
ROM_CALL(CREATE_TMP)
JR NotEnoughMem
EnoughMem:
LD HL,Size
LD DE,BufferAddress
LD (FREE_MEM_START),DE
ROM_CALL(INSERT_MEM)
ROM_CALL(CREATE_TMP)
LD HL,BufferAddress+Size; These are constant anyway
LD (FREE_MEM_END),HL
</pre>
</p>


<a name="part06"></a><p><big><u>6. What about other z80-based devices ?</u></big></p>


<p><big><u>Sinclair Computers</u></big></p>

(not_yet_implemented)


<p><big><u>Game Boy</u></big></p>

Learning that the GameBoy has a z80 processor is quite mouthwatering, but the bad news is that it is a modified version. The GB processor has :<br /><br />

* No IX, IY and shadow registers.<br />
* No input/output operations (so no in/out opcodes).<br />
* HALT is interrupted even when interrupts are disabled.<br /><br />

And several opcodes are changed, including the following :<br /><br />

DJNZ offset<br />
LD (word),HL<br />
LD HL,(word)<br />
LD (word),A<br />
LD A,(word)<br />
EX HL,(SP)<br />
EX DE,HL<br />
<br />

<p><a href="http://www.semis.demon.co.uk/Gameboy/Gbspec.txt">This text file</a> explains more deeply the differences between the GB's processor and a regular z80 processor.</p>

<p>So, you get the idea, it is almost impossible to have similar source codes that run on both GB and TI z80.</p>


<p><big><big><span style="text-decoration: underline;">III To do/Questions
without answer</span></big></big></p>

<p>
How do I replace the rom call _getcsc ?<br />
How do I handle external programs ?<br />
Is a TI-z80 program easily portable on z80-based Sinclair computers ?</p>

<p><big><big><span style="text-decoration: underline;">IV Contact/thanks</span></big></big></p>

<p>
If you have any suggestion, comment or question about this FAQ, contact
me!</p>

<p>E-mail : guillaume.h (a) ifrance dot com</p>
<p>Webpages: <a href="http://gh.paxl.org/">http://gh.paxl.org/</a>, <a href="http://tift.paxl.org/">TIFT</a></p>

<p><big>Thanks to (in no particular order):</big><br /><br />
CoBB<br />
Kozak<br />
Pat Fagan (who made the GB's z80 comparsion)<br />
pacHa<br />
<br />
and anyone acting for the ti-community :)</p>


<p><big><big><span style="text-decoration: underline;">V History</span></big></big></p>

<p><big>revision 10 : 21/12/2005</big><br />
Added a replacement for _getcsc (thanks CoBB!)</p>

<p><big>revision 9 : 05/05/2005</big><br />
Some minor corrections.</p>

<p><big>revision 8 : 28/10/2004</big><br />
Added the info about using the free RAM on TI82 with SNG. BIG thanks to Marc Plouhinec, pacHa and CoBB for this.</p>

<p><big>revision 7 : 01/07/2004</big><br />
Complete the "don't use rom calls" stuff with _vputs replacement.<br />
Used <a href="http://www.aetherlumina.com/gnp/">neutral pronouns</a> ;)</p>

<p><big>revision 6 : 06/06/2004</big><br />
Added the "don't use rom calls" and Game Boy stuff.</p>

<p><big>revision 5 : 01/03/2004</big><br />
Added the incomplete "free RAM" part.</p>

<p><big>revision 4 : 28/10/2003</big><br />
Added several precisions</p>

<p><big>revision 3 : 07/10/2003</big><br />
Added the saferam addresses.</p>

<p><big>revision 2 : 06/10/2003</big><br />
Added the icall/bcall/ijp/bjp part.</p>

<p><big>revision 1 : 05/10/2003</big><br />
I realised that cmdShadow and TEXT_MEM2 were the same thing...<br />
Mentionned the PlotsScreen in the saferam part.<br />
Corrected several things</p>

<p><big>revision 0 : 04/10/2003</big></p>
</body>
</html>