Difference between revisions of "Programming cross z80 calculators"
(completing the info, a more neutral view) |
(main reestructure of topic, added more info) |
||
Line 11: | Line 11: | ||
There are in less number TI-82 and TI-83 (Regular) users. They will rejoice with a build for them. | There are in less number TI-82 and TI-83 (Regular) users. They will rejoice with a build for them. | ||
− | TI-85 and TI-86 are no longer produced, there is few visible development and interest on them | + | TI-85 and TI-86 are no longer produced, long discontinued, there is few visible development and very few interest on them. TI-86 has TI-85 compatibility. (in asm???) |
By any means feel unmotivated or constricted by the current interest, there are still old calculator enthusiasts who enjoy new stuff for their legacy calculator. And assembling for more models can be an important feature. | By any means feel unmotivated or constricted by the current interest, there are still old calculator enthusiasts who enjoy new stuff for their legacy calculator. And assembling for more models can be an important feature. | ||
− | == General Advices == | + | == Porting Help == |
+ | |||
+ | === General Advices === | ||
* avoid b_calls (when possible, of course) | * avoid b_calls (when possible, of course) | ||
* use a assembler that supports #if #else #endif directives (give a example on how to use) | * use a assembler that supports #if #else #endif directives (give a example on how to use) | ||
Line 21: | Line 23: | ||
* See in Z80 Routines a set of graphic routines to all calculators (not right now...) | * See in Z80 Routines a set of graphic routines to all calculators (not right now...) | ||
* If you need memory in assembly programs in RAM, place variables in the program | * If you need memory in assembly programs in RAM, place variables in the program | ||
− | |||
− | |||
=== Safe Rams === | === Safe Rams === | ||
Line 43: | Line 43: | ||
| APD_BUF (savesscreen) | | APD_BUF (savesscreen) | ||
| 768 | | 768 | ||
− | | Available (with CrASH, after disabling interrupts) $8228 | + | | Available (with CrASH, after disabling interrupts) ($8228) |
− | | Available $8265 | + | | Available ($8265) |
− | | Available $86EC | + | | Available ($86EC) |
| ??? | | ??? | ||
| ??? | | ??? | ||
Line 53: | Line 53: | ||
| | | | ||
| | | | ||
− | | | + | | |
− | | | + | | |
− | | | + | | |
+ | | | ||
+ | | | ||
|- | |- | ||
| OPs | | OPs | ||
| | | | ||
| | | | ||
− | | | + | | |
− | | | + | | |
− | | | + | | |
+ | | | ||
+ | | | ||
|- | |- | ||
| cmdShadow / TEXT_MEM2 | | cmdShadow / TEXT_MEM2 | ||
| | | | ||
| | | | ||
− | | | + | | |
− | | | + | | |
− | | | + | | |
+ | | | ||
+ | | | ||
|- | |- | ||
| StatRam | | StatRam | ||
| | | | ||
| | | | ||
− | | | + | | |
− | | | + | | |
− | | | + | | |
+ | | | ||
+ | | | ||
|- | |- | ||
| imathptrs | | imathptrs | ||
| | | | ||
| | | | ||
− | | | + | | |
− | | | + | | |
− | | | + | | |
+ | | | ||
+ | | | ||
|- | |- | ||
| appBackupScreen | | appBackupScreen | ||
| | | | ||
| | | | ||
− | | | + | | |
− | | | + | | |
− | | | + | | |
+ | | | ||
+ | | | ||
|- | |- | ||
| tempSwapArea | | tempSwapArea | ||
| | | | ||
| | | | ||
− | | | + | | |
− | | | + | | |
− | | | + | | |
+ | | | ||
+ | | | ||
|} | |} | ||
Line 104: | Line 118: | ||
=== bcalls, icalls (system calls) === | === bcalls, icalls (system calls) === | ||
− | There are two | + | There are two suggested ways here to solve the bcalls across calculators: |
− | - do not use bcalls (or just a few) | + | - first, simply do not use bcalls (or just a few) |
− | - use complete include files | + | - use complete include files with bcall macros for each calculator model and #ifdef directives when bcall names differs. |
− | The system calls definition changes in | + | The system calls definition changes in different calculator models series: |
* TI-82 - icall(xxxx) = call xxxx | * TI-82 - icall(xxxx) = call xxxx | ||
* TI-83 - call xxxx | * TI-83 - call xxxx | ||
* TI-83+ - bcall(xxxx) = rst 28h \ .dw xxxx | * TI-83+ - bcall(xxxx) = rst 28h \ .dw xxxx | ||
− | * TI-85/86 | + | * TI-85/86 - ??? |
=== Shells === | === Shells === | ||
While TI-83+ series run assembly programs without shells (called no-stub) all others require some shell or exploit to run assembly code. So knowing the shells is important for testing on emulator and release to public. | While TI-83+ series run assembly programs without shells (called no-stub) all others require some shell or exploit to run assembly code. So knowing the shells is important for testing on emulator and release to public. | ||
− | TI-82 | + | TI-82, there is AShell and CRASH |
− | TI-83 and TI-83+ | + | TI-83, has Ion and Venus |
− | TI-85 | + | TI-83+/84+/SE - Ion and Ion compatible shells (MirageOS, DoorCS, CrunchyOS) |
− | TI-86 | + | TI-85 ??? |
+ | TI-86 ??? | ||
− | + | I suggest Ion for 83 and 83+ series because is popular and has a nice set of routines (mainly for games). | |
− | Here you have important aspects of calculators, mostly hardware | + | |
+ | === Assemblers and Linkers === | ||
+ | |||
+ | I strongly suggest SPASM because it outputs all program file types. | ||
+ | For TI-83+ linker there is DEVPAC8X. | ||
+ | |||
+ | Use the assembler #ifdef, #ifndef and #endif directives. For example if you want specific code for TI-83: | ||
+ | <nowiki> | ||
+ | #ifdef TI83 | ||
+ | ;this code will only be assembled when TI83 define is defined. | ||
+ | ;so define TI83 to assemble for TI83 and the code inside the #ifdef only gets assembled for TI83 | ||
+ | xor a | ||
+ | #endif | ||
+ | </nowiki> | ||
+ | |||
+ | Also writing your shell scripts (batch or bash) or using an IDE can help assembling program files for all calculator models. | ||
+ | A example of a batch for SPASM: | ||
+ | <nowiki> | ||
+ | spasm -DTI83 source.asm output.83p | ||
+ | spasm -DTI83P source.asm output.8xp | ||
+ | |||
+ | </nowiki> | ||
+ | Just copy the text and save in a name.bat file, this for Windows users. Now to assemble for TI-83 and TI-83+ just double click the batch file and see it assembling. If you want to see assemble errors, edit the name.bat and put "pause" in the last line. | ||
+ | |||
+ | If you do not use SPASM, see your assembler manual for information. | ||
+ | |||
+ | |||
+ | == Calculator Differences Resume/Reference == | ||
+ | |||
+ | Here you have the important aspects of z80 calculators, mostly hardware and OS differences. | ||
+ | |||
+ | All calculators have a 96x64 pixels screen except TI-85 and TI-86 which have 128x64 pixels. | ||
Line 131: | Line 177: | ||
=== TI-81 === | === TI-81 === | ||
− | * | + | * unfriendly calculator to code (no emulator, code must be typed on the calculator, hard to hack) |
* note again that few people own one and very few use it | * note again that few people own one and very few use it | ||
Line 145: | Line 191: | ||
=== TI-83 === | === TI-83 === | ||
* Link port is different from TI-83+ | * Link port is different from TI-83+ | ||
− | * there is no | + | * there is no bcalls, just normal calls |
=== TI-83+ === | === TI-83+ === | ||
− | * | + | * Most usual z80 platform, compatible with TI-83+SE and TI-84+ calculators |
* APPS programming | * APPS programming | ||
Line 159: | Line 205: | ||
* CPU is around 3x faster (16 MHz) (good but not always) | * CPU is around 3x faster (16 MHz) (good but not always) | ||
* time crystals | * time crystals | ||
− | |||
* APPS programming | * APPS programming | ||
+ | * Some bad LCD can screw your beautiful graphics, use a [[safefastcopy]] routine | ||
− | == Program in RAM template == | + | == Useful Tools and Utilities == |
+ | |||
+ | === Various === | ||
+ | |||
+ | * SPASM | ||
+ | * Dwedit's large include file | ||
+ | * this set of most complete include files | ||
+ | * this routines | ||
+ | |||
+ | === Source Code Template Program in RAM template === | ||
<nowiki> | <nowiki> | ||
Line 218: | Line 273: | ||
</nowiki> | </nowiki> | ||
− | == APPS template == | + | === Source Code Template APPS template === |
<nowiki> | <nowiki> | ||
+ | .org $4000 | ||
+ | |||
;Free APPS header | ;Free APPS header | ||
+ | Start: | ||
+ | |||
+ | |||
+ | |||
+ | exit: | ||
+ | bjump(_JForceCmdNoChar) | ||
</nowiki> | </nowiki> | ||
== Related Topics and sources of info == | == Related Topics and sources of info == | ||
* THE TI-82/83(+) UNIFICATION FAQ by Guillaume Hoffmann | * THE TI-82/83(+) UNIFICATION FAQ by Guillaume Hoffmann |
Revision as of 11:32, 19 April 2010
Contents
Introduction
It is a nice feature to do in your games and other programs to be able to use them across all the z80 calculators. Or this topic will help you in porting some programs to your calculator.
The difficulty to port depends on every case. In some games, it is enough changes in some graphics routines, safe ram locations and to bcalls to make it work. Some cases might be a nightmare (in practical too difficult) or simply impossible.
Calculators Series Current Interest
Note that the TI-83+ series (TI-83+, TI-83+SE, TI-84+, TI-84+SE) are the most common worldwide. Most development is done to this series. Historically, most times ports were done to this series.
There are in less number TI-82 and TI-83 (Regular) users. They will rejoice with a build for them.
TI-85 and TI-86 are no longer produced, long discontinued, there is few visible development and very few interest on them. TI-86 has TI-85 compatibility. (in asm???)
By any means feel unmotivated or constricted by the current interest, there are still old calculator enthusiasts who enjoy new stuff for their legacy calculator. And assembling for more models can be an important feature.
Porting Help
General Advices
- avoid b_calls (when possible, of course)
- use a assembler that supports #if #else #endif directives (give a example on how to use)
- use a linker capable to output all z80 calculators format (notably SPASM)
- See in Z80 Routines a set of graphic routines to all calculators (not right now...)
- If you need memory in assembly programs in RAM, place variables in the program
Safe Rams
Safe ram is simply some portions of fixed ram (re)usable to programmers without any conflict to the TI-OS. But their location and existence depend from calculator to calculator model. Because of this may be preferable to keep variables inside your program. The obvious disadvantage is your program will take more space.
This table illustrates what safe ram locations are available in the various calculator models.
Safe Ram Name | Size | TI-82 | TI-83 | TI-83+/84+/SE | TI-85 | TI-86 | Use it? |
---|---|---|---|---|---|---|---|
APD_BUF (savesscreen) | 768 | Available (with CrASH, after disabling interrupts) ($8228) | Available ($8265) | Available ($86EC) | ??? | ??? | ??? |
TEXT_MEM (textshadow) | |||||||
OPs | |||||||
cmdShadow / TEXT_MEM2 | |||||||
StatRam | |||||||
imathptrs | |||||||
appBackupScreen | |||||||
tempSwapArea |
The conclusion is using APD_BUF (savesscreen) because it has a good size, is present in all calculators and doesn't need to be restored after use.
bcalls, icalls (system calls)
There are two suggested ways here to solve the bcalls across calculators: - first, simply do not use bcalls (or just a few) - use complete include files with bcall macros for each calculator model and #ifdef directives when bcall names differs.
The system calls definition changes in different calculator models series:
- TI-82 - icall(xxxx) = call xxxx
- TI-83 - call xxxx
- TI-83+ - bcall(xxxx) = rst 28h \ .dw xxxx
- TI-85/86 - ???
Shells
While TI-83+ series run assembly programs without shells (called no-stub) all others require some shell or exploit to run assembly code. So knowing the shells is important for testing on emulator and release to public.
TI-82, there is AShell and CRASH TI-83, has Ion and Venus TI-83+/84+/SE - Ion and Ion compatible shells (MirageOS, DoorCS, CrunchyOS) TI-85 ??? TI-86 ???
I suggest Ion for 83 and 83+ series because is popular and has a nice set of routines (mainly for games).
Assemblers and Linkers
I strongly suggest SPASM because it outputs all program file types. For TI-83+ linker there is DEVPAC8X.
Use the assembler #ifdef, #ifndef and #endif directives. For example if you want specific code for TI-83:
#ifdef TI83 ;this code will only be assembled when TI83 define is defined. ;so define TI83 to assemble for TI83 and the code inside the #ifdef only gets assembled for TI83 xor a #endif
Also writing your shell scripts (batch or bash) or using an IDE can help assembling program files for all calculator models. A example of a batch for SPASM:
spasm -DTI83 source.asm output.83p spasm -DTI83P source.asm output.8xp
Just copy the text and save in a name.bat file, this for Windows users. Now to assemble for TI-83 and TI-83+ just double click the batch file and see it assembling. If you want to see assemble errors, edit the name.bat and put "pause" in the last line.
If you do not use SPASM, see your assembler manual for information.
Calculator Differences Resume/Reference
Here you have the important aspects of z80 calculators, mostly hardware and OS differences.
All calculators have a 96x64 pixels screen except TI-85 and TI-86 which have 128x64 pixels.
TI-73
- just APPS programming (?)
TI-81
- unfriendly calculator to code (no emulator, code must be typed on the calculator, hard to hack)
- note again that few people own one and very few use it
TI-82
- No Hooks
TI-85
- memory mapped LCD (great but others don't)
TI-86
- memory mapped LCD (great but others don't)
TI-83
- Link port is different from TI-83+
- there is no bcalls, just normal calls
TI-83+
- Most usual z80 platform, compatible with TI-83+SE and TI-84+ calculators
- APPS programming
TI-83+SE
- CPU is around 3x faster (16 MHz) (good but not always)
- time crystals
- APPS programming
TI-84+/84+SE
- CPU is around 3x faster (16 MHz) (good but not always)
- time crystals
- APPS programming
- Some bad LCD can screw your beautiful graphics, use a safefastcopy routine
Useful Tools and Utilities
Various
- SPASM
- Dwedit's large include file
- this set of most complete include files
- this routines
Source Code Template Program in RAM template
#ifdef TI73 #include ti73.inc ;TI73 asm execution normally is on a APPS #endif #ifdef TI82 ;#include ti82.inc ;depends on shell (?) #endif #ifdef TI83 #include ti83.inc .org userMem #endif #ifdef TI83P #include ti83plus.inc .org userMem-2 .db t2ByteTok,tAsmCmp ; .db $BB,$6D tokens for ASM program #endif #ifdef TI85 ;#include ti85.inc .org asm_exec_ram-2 .db $8E,$28 nop jp lblStart .dw 0 .dw tTitle ;no idea of what this is #endif #ifdef TI86 ;#include ti86.inc .org asm_exec_ram-2 .db $8E,$28 ;no idea of what this is nop jp lblStart .dw 0 .dw tTitle #endif Start: #ifdef TI83P b_call(_RunIndicOff) b_call(_GrBufClr) #endif ret End:
Source Code Template APPS template
.org $4000 ;Free APPS header Start: exit: bjump(_JForceCmdNoChar)
Related Topics and sources of info
- THE TI-82/83(+) UNIFICATION FAQ by Guillaume Hoffmann