AMS:
*** _get_jump_table.s:
.xdef __get_jump_table
.section _st20
__get_jump_table:
| Get the address of the jump table (needed a few times).
| Note that calling a function will destroy %a0; be sure to check whether
| this is still valid for screen-saving support whenever you make a change in
| between.
move.l 0xC8,%a0
*** _detect_ams.s:
.xdef __MIN_AMS_required_AND_NOT___kernel_library_header
.section _st41
bcc.s __ams_version_is_OK__
bra.s __ams_version_not_OK__
.section _st10012, "d"
.asciz " or higher needed"
*** _compare_ams_1_01.s:
.xdef __MIN_AMS_1_01_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x3CC,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "1.01"
*** _compare_ams_1_05.s:
.xdef __MIN_AMS_1_05_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x3CC,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "1.05"
*** _compare_ams_2_00.s:
.xdef __MIN_AMS_2_00_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #1000,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.00"
*** _compare_ams_2_01.s:
.xdef __MIN_AMS_2_01_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x508,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.01"
*** _compare_ams_2_02.s:
.xdef __MIN_AMS_2_02_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x5B7,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.02"
*** _compare_ams_2_03.s:
.xdef __MIN_AMS_2_03_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x5B7,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.03"
*** _compare_ams_2_04.s:
.xdef __MIN_AMS_2_04_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x5E2,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.04"
*** _compare_ams_2_05.s:
.xdef __MIN_AMS_2_05_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x5EF,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.05"
*** _compare_ams_2_07.s:
.xdef __MIN_AMS_2_07_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x607,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.07"
*** _compare_ams_2_08.s:
.xdef __MIN_AMS_2_08_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x607,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.08"
*** _compare_ams_2_09.s:
.xdef __MIN_AMS_2_09_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x607,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "2.09"
*** _compare_ams_3_00.s:
.xdef __MIN_AMS_3_00_AND_NOT___kernel_library_header
.section _st40
| Check the number of ROM calls available.
cmp.l #0x608,(%a0,-4) /* TIOS_entries */
.section _st10011, "d"
.ascii "3.00"
*** _detect_ams_1_05.s:
.xdef __MIN_AMS_1_05_AND_NOT___kernel_library_header
.section _st61
bne.s __ams_version_1_05_OK__ /* AMS >1.05 */
cmpa.l #0x278eac,%a0 /* TI-89 AMS 1.05 */
beq.s __ams_version_1_05_OK__
cmpa.l #0x478280,%a0 /* TI-92+ AMS 1.05 */
bne.s __ams_version_not_OK__
__ams_version_1_05_OK__:
*** _detect_ams_2_03.s:
.xdef __MIN_AMS_2_03_AND_NOT___kernel_library_header
.section _st61
bne.s __ams_version_2_03_OK__ /* AMS >2.03 */
movea.l (%a0,0x440*4),%a1 /* ReleaseVersion (AMS 2 only ROM_CALL) */
cmpi.b #'2',3(%a1) /* AMS 2.02 */
beq.s __ams_version_not_OK__
__ams_version_2_03_OK__:
*** _detect_ams_2_08.s:
.xdef __MIN_AMS_2_08_AND_NOT___kernel_library_header
.section _st61
bne.s __ams_version_2_08_OK__ /* AMS >2.09 */
movea.l (%a0,0x440*4),%a1 /* ReleaseVersion (AMS 2 only ROM_CALL) */
cmpi.b #'7',3(%a1) /* AMS 2.07 */
beq.s __ams_version_not_OK__
__ams_version_2_08_OK__:
*** _detect_ams_2_09.s:
.xdef __MIN_AMS_2_09_AND_NOT___kernel_library_header
.section _st61
bne.s __ams_version_2_09_OK__ /* AMS >2.09 */
movea.l (%a0,0x440*4),%a1 /* ReleaseVersion (AMS 2 only ROM_CALL) */
cmpi.b #'9',3(%a1) /* AMS 2.09 */
bne.s __ams_version_not_OK__
__ams_version_2_09_OK__:
HW:
| Hardware version detection, adapted from gray.s
| Copyright (C) 2002 Thomas Nussbaumer.
| Copyright (C) 2003 Kevin Kofler.
| See License.txt for licensing conditions.
.xdef __get_hw_version
__get_hw_version:
|--------------------------------------------------------------------------
| get the HW parm block using the algorithm suggested by Julien Muchembled
|--------------------------------------------------------------------------
move.l 0xc8:w,%d0
andi.l #0xE00000,%d0 | get the ROM base
movea.l %d0,%a0
movea.l 260(%a0),%a1 | get pointer to the hardware param block
adda.l #0x10000,%a0
cmpa.l %a0,%a1 | check if the HW parameter block is near enough
bcc.s L.is_hw1 | if it is too far, it is HW1
cmpi.w #22,(%a1) | check if the parameter block contains HW ver
bls.s L.is_hw1 | if it is too small, it is HW1
|--------------------------------------------------------------------------
| check for VTI (trick suggested by Julien Muchembled)
|--------------------------------------------------------------------------
trap #12 | enter supervisor mode. returns old (%sr) in %d0.w
move.w #0x3000,%sr | set a non-existing flag in %sr (but keep s-flag)
move.w %sr,%d1 | get %sr content and check for non-existing flag
move.w %d0,%sr | restore old %sr content
btst.l #12,%d1 | this non-existing flag can only be set on the VTI
beq.s L.not_vti | flag not set -> no VTI
|--------------------------------------------------------------------------
| VTI detected -> treat as HW1
|--------------------------------------------------------------------------
| Fall through...
L.is_hw1:
|--------------------------------------------------------------------------
| HW1 detected
|--------------------------------------------------------------------------
moveq.l #1,%d0 | set %d0 to 1 (HW1)
rts | return 1
L.not_vti:
|--------------------------------------------------------------------------
| Real calculator detected, so read the HW version from the HW parm block
|--------------------------------------------------------------------------
move.l 22(%a1),%d0 | get the hardware version
rts | return it
Calculette:
*** _get_jump_table.s:
.xdef __get_jump_table
.section _st20
__get_jump_table:
| Get the address of the jump table (needed a few times).
| Note that calling a function will destroy %a0; be sure to check whether
| this is still valid for screen-saving support whenever you make a change in
| between.
move.l 0xC8,%a0
*** _detect_calc.s:
.xdef __detect_calc
| This object file needs the jump table in %a0.
.xdef __ref_all___get_jump_table
.section _st30
__detect_calc:
| At first, assume TI-92 Plus.
| It takes less space to write the values into %d0 first and then check whether they are correct.
moveq #1,%d0
| Move the address of the jump table to %d1.
move.l %a0,%d1
and.l #0x400000,%d1
| Now %d1 is 0 on a TI-89, TI-89 Titanium or V200, or 0x400000 on a TI-92+.
jbne __calc_in_d0__
| Otherwise, assume TI-89 / TI-89 Titanium.
clr.w %d0
| Get the address of the ScrRect variable into a1.
move.l (%a0,0x2F*4),%a1 /* ScrRect */
| If ScrRect+2 (x2) is less than 200, it is a TI-89 or TI-89 Titanium.
cmp.b #200,2(%a1)
jbcs __calc_in_d0__
| Otherwise, it is a V200.
moveq #3,%d0
__calc_in_d0__: