;---------------------; ;asaptrig.asm ; ;by Stephen Hicks ; ;shicks@mindspring.com; ;---------------------; #include "asm86.h" #include "ti86asm.inc" #include "ti86math.inc" #include "ti86ops.inc" #define ProgTitle "asaptrig v1.50B",0 _DisplayOP1 .equ $515B _flushallmenus .equ $49DC _custom5 .equ $D1CD _mMath_asap3 .equ $D65E _eostbl_asap3 .equ $D716 _numtok_asap3 .equ $D710 _tokspell_asap3 .equ $D70A _asap_nl3 .equ $D6EA _homeUp .equ $4A95 tokspell_start .equ $f3f8 asaptrig_flags .equ $2A asaptrig_installed .equ 0 asaptrig_mode .equ 1 asaptrig_mode2 .equ 2 .org _asm_exec_ram Start: call _clrLCD call _flushallmenus call _homeUp ld hl,message1 call WriteS ld hl,message2 call WriteS ld hl,message3 call WriteS ld hl,message4 call WriteS ld hl,message5 call WriteS ld hl,message6 call WriteS ld hl,cont_exit_msg call WriteS getkeyloop: call _getkey or a jr z,getkeyloop cp kF5 jr nz,noexit call _newline ret noexit: cp kF1 jr nz,getkeyloop ld a,(_numtok_asap3) or a jr z,install call _clrLCD call _homeUp ld hl,w_message1 call WriteS ld hl,w_message2 call WriteS ld hl,w_message3 call WriteS ld hl,$0A02 ld (_curRow),hl ld hl,_asap_nl3 call _putps ld hl,w_message4 call WriteS ld hl,w_message5 call WriteS ld hl,w_message6 call WriteS ld hl,cont_exit_msg call WriteS w_getkeyloop: call _getkey or a jr z,w_getkeyloop cp kF5 jr nz,w_noexit call _newline ret w_noexit: cp kF1 jr nz,w_getkeyloop install: t_menu: call _clrLCD call _homeUp ld hl,t_message1 call WriteS ld hl,t_message2 call WriteS ld hl,t_message3 call WriteS ld hl,t_message4 call WriteS ld hl,t_message5 call WriteS ld hl,t_message6 call WriteS ld hl,t_choice call WriteS t_getkeyloop: call _getkey or a jr z,t_getkeyloop cp kF5 jr z,t_Swap cp kF1 jr z,t_NoSwap jr c_getkeyloop t_Swap: ld hl,newArcsec ld de,tok_arcsec ld bc,6 ldir ld hl,newSec ld de,tok_sec ld bc,3 ldir ld hl,newArcsec ld de,menu_arcsec inc de ld bc,6 ldir ld hl,newSec ld de,menu_sec inc de ld bc,3 ldir t_NoSwap: c_menu: call _clrLCD call _homeUp ld hl,c_message1 call WriteS ld hl,c_message2 call WriteS ld hl,c_message3 call WriteS ld hl,c_message4 call WriteS ld hl,c_message5 call WriteS ld hl,c_message6 call WriteS ld hl,c_choice call WriteS c_getkeyloop: call _getkey or a jr z,c_getkeyloop cp kF5 jr z,c_Swap cp kF1 jr z,c_NoSwap jr c_getkeyloop c_Swap: ld hl,c_swapped ld de,c_swapper call _MOV10B c_NoSwap: ld a,7 ld (_numtok_asap3),a ld de,tokspell_start ld (_tokspell_asap3),de ld hl,tokspell ld bc,tokspell_end-tokspell ldir ld de,eostbl_start ld (_eostbl_asap3),de ld hl,eostbl ld bc,eostbl_end-eostbl ldir ld de,_asap_nl3 ld hl,asapname call _MOV10B ld de,custom_start ld (_custom5),de ld (_mMath_asap3),de ld hl,custom ld bc,custom_end-custom ldir res asaptrig_mode,(iy+asaptrig_flags) res asaptrig_mode2,(iy+asaptrig_flags) set asaptrig_installed,(iy+asaptrig_flags) call _newline call _newline ld hl,donemsg1 call WriteS call _newline ld hl,donemsg2 call WriteS call _newline ret asapname: .db 8,"asaptrig",0 tokspell: .dw tok_arccot-tokspell+tokspell_start .dw tok_arccsc-tokspell+tokspell_start .dw tok_arcsec-tokspell+tokspell_start .dw tok_cot-tokspell+tokspell_start .dw tok_csc-tokspell+tokspell_start .dw tok_sec-tokspell+tokspell_start .dw tok_trigmode-tokspell+tokspell_start tok_arccot: .db "Arccot",0 .db $06,$30 tok_arccsc: .db "Arccsc",0 .db $05,$30 tok_arcsec: .db "Arcsct",0 .db $04,$30 tok_cot: .db "cot",0 .db $03,$30 tok_csc: .db "csc",0 .db $02,$30 tok_sec: .db "sct",0 .db $01,$30 tok_trigmode: .db "SetRange",0 .db $07,$30 tokspell_end: eostbl: .dw code_sec .db $02,$00 .dw code_csc .db $02,$00 .dw code_cot .db $02,$00 .dw code_arcsec .db $02,$00 .dw code_arccsc .db $02,$00 .dw code_arccot .db $02,$00 .dw code_trigmode .db $02,$00 eostbl_end: custom: .db $05 ;open a menu .dw custom_sub-custom+custom_start ;at custom_sub .db "TRIG",0 ;called TRIG custom_sub: .db $09,7 ;new menu w/ 7 positions c_swapper: .dw menu_sec-custom+custom_start .dw menu_csc-custom+custom_start .dw menu_cot-custom+custom_start .dw menu_arcsec-custom+custom_start .dw menu_arccsc-custom+custom_start .dw menu_arccot-custom+custom_start .dw menu_trigmode-custom+custom_start menu_sec: .db $20,"sct",0 ;paste with space menu_csc: .db $20,"csc",0 ;paste with space menu_cot: .db $20,"cot",0 ;paste with space menu_arcsec: .db $20,"Arcsct",0 ;paste with space menu_arccsc: .db $20,"Arccsc",0 ;paste with space menu_arccot: .db $20,"Arccot",0 ;paste with space menu_trigmode: .db $20,"SetRange",0 ;paste with space custom_end: newArcsec: .db "Arcsec" newSec: .db "sec" c_swapped: .dw menu_csc-custom+custom_start .dw menu_sec-custom+custom_start .dw menu_cot-custom+custom_start .dw menu_arccsc-custom+custom_start .dw menu_arcsec-custom+custom_start code_sec: call _COS jp _FPRECIP code_csc: call _SIN jp _FPRECIP code_cot: call _TAN jp _FPRECIP code_arcsec: ld hl,_OP1 bit 7,(hl) jr nz,code_arcsec_neg call _FPRECIP jp _ACOS code_arcsec_neg: call _FPRECIP call _ACOS bit asaptrig_mode,(iy+asaptrig_flags) ret z call _OP1TOOP2 ld hl,TwoPi call _MOV10TOOP1 call _FPSUB bit asaptrig_mode2,(iy+asaptrig_flags) ret nz ld hl,TwoPi ld de,_OP2 call _MOV10B jp _FPSUB code_arccsc: call _FPRECIP call _ASIN bit asaptrig_mode,(iy+asaptrig_flags) ret z ld hl,_OP1 bit 7,(hl) ret z bit 0,(hl) ret nz call _OP1TOOP2 ld hl,Pi call _MOV10TOOP1 call _FPSUB bit asaptrig_mode2,(iy+asaptrig_flags) ret nz ld hl,TwoPi ld de,_OP2 call _MOV10B jp _FPSUB code_arccot: call _FPRECIP call _ATAN ld hl,_OP1 bit 7,(hl) ret z ld hl,Pi call _MOV10TOOP2 jp _FPADD code_trigmode: ld hl,_OP1 ld a,(hl) or a jr nz,trigmode_error inc hl ld a,(hl) or a jr nz,trigmode_error inc hl ld a,(hl) cp $FC jr nz,trigmode_error inc hl ld b,6 loopish: inc hl ld a,(hl) or a jr nz,trigmode_error djnz loopish ld hl,_OP1M ld a,(hl) cp $10 jr z,trigmode_set1 cp $20 jr z,trigmode_set2 cp $30 jr z,trigmode_set3 trigmode_error: call _OP1SET0 jp _LNX trigmode_set1: res asaptrig_mode,(iy+asaptrig_flags) res asaptrig_mode2,(iy+asaptrig_flags) ld hl,trigmode_msg call _puts ld hl,trigmode_msg1 call _puts jr trigmode_end trigmode_set2: set asaptrig_mode,(iy+asaptrig_flags) res asaptrig_mode2,(iy+asaptrig_flags) ld hl,trigmode_msg call _puts ld hl,trigmode_msg2 call _puts jr trigmode_end trigmode_set3: set asaptrig_mode,(iy+asaptrig_flags) set asaptrig_mode2,(iy+asaptrig_flags) ld hl,trigmode_msg call _puts ld hl,trigmode_msg3 call _puts trigmode_end: ld hl,_OP1 ld (hl),$12 call _DisplayOP1 jp $409C trigmode_msg: .db " Arccsc range set to",0 trigmode_msg1: .db " [",Lneg,Lpi,"/2,0) U (0,",Lpi,"/2]",0 trigmode_msg2: .db " (",Lneg,Lpi,",",Lneg,Lpi,"/2] U (0,",Lpi,"/2]",0 trigmode_msg3: .db " (0,",Lpi,"/2] U (",Lpi,",3",Lpi,"/2]",0 Pi: .db $00,$00,$FC,$31,$41,$59,$26,$53,$58,$98 TwoPi: .db $00,$00,$FC,$62,$83,$18,$53,$07,$17,$96 WriteS: ld e,(hl) inc hl ld d,(hl) inc hl ld (_curRow),de call _puts ret message1: .db 0,1,"Caution",0 message2: .db 1,0,"Any item in the 5th",0 message3: .db 2,0,"CUSTOM menu slot or",0 message4: .db 3,0,"the 9th MATH menu",0 message5: .db 4,0,"slot will be",0 message6: .db 5,0,"overwritten.",0 donemsg1: .db 7,0,ProgTitle,0 donemsg2: .db 7,0,"by Stephen Hicks",0 w_message1: .db 0,1,"WARNING",0 w_message2: .db 1,0,"Tokens already exist",0 w_message3: .db 2,0,"from prgm",0 w_message4: .db 3,0,"Installation WILL",0 w_message5: .db 4,0,"erase the previously",0 w_message6: .db 5,0,"installed tokens.",0 cont_exit_msg: .db 7,0,"Continue Exit",0 c_message1: .db 0,1,"Mode Select II",0 c_message2: .db 1,0,"Do you want to have",0 c_message3: .db 2,0,"secant or cosecant",0 c_message4: .db 3,0,"first in the custom",0 c_message5: .db 4,0,"menu? If not sure,",0 c_message6: .db 5,0,"choose F1.",0 c_choice: .db 7,0,"Secant Cosecant",0 t_message1: .db 0,1,"Mode Select I",0 t_message2: .db 1,0,"Do you want sec or",0 t_message3: .db 2,0,"sct? Warning: sec",0 t_message4: .db 3,0,"will mess up the",0 t_message5: .db 4,0,"seconds conversion",0 t_message6: .db 5,0,"If not sure, use F1.",0 t_choice: .db 7,0,"sct sec",0 eostbl_start .equ tokspell_start+tokspell_end-tokspell custom_start .equ tokspell_start+eostbl_end-tokspell .end