home *** CD-ROM | disk | FTP | other *** search
-
-
- ;InfraRed Chat v0.1 for TI89
- ; by Sami Khawam
- ; sKhawam@bigfoot.com
- ;--------------------
- ;
- ;This is a port from the TI85 version.
- ;I wrote this little chat program in order to use it with my
- ;IR Link (see my page at: http://unet.univie.ac.at/~a9501901 ).
- ;
- ;Features and known bugs:
- ;-----------------------
- ;
- ;-In this version ther is NO WhiteBoard support, since I
- ; hadn't the time to convert it.
- ;
- ;-You can communicate with a TI82, TI83, TI85, TI86 and TI92.
- ; This program is compatible with IR_Term by Antoine Mercier.
- ;
- ;-I am including the source code with it.
- ;
- ;
- ;When using the program with the IR Link, the mode of the link
- ;should be set to the 'TI protocol without Ack' mode.
- ;
- ;If you don't have (yet) built an IR Link and you want to test
- ;this program you can connnect 2 calcs with the cable and test
- ;it; you cannot connect more that 2 calcs if you use the cable,
- ;but if you use the IR Link, you can communicate with as many
- ;calcs as you want.
- ;
- ;
- ; -Sami Khawam
- ; sKhawam@bigfoot.com
- ;
-
-
- include "doorsos.h"
- include "graphlib.h"
- include "userlib.h"
- include "hexlib.h"
- include "irlib.h"
-
- xdef _ti89
- xdef _main
- xdef _comment
-
-
- INBUF_SIZE equ 128
- MAX_COL equ 24 ; 24 for the TI89
- MAX_LINES equ 11 ; 11 for the TI89
- MAX_X equ 155 ; 155 for the TI89
- MAX_Y equ 88 ; 100 for the TI89
- SPACE_X equ 6 ; 6 for normal font;
- SPACE_Y equ 8 ; 8 for normal font;
- KEEP_SIZE equ 300 ; 10*30
- ; The 10 is for the 10 lines of the
- ; command line.
- SCROLL_SIZE equ 540 ; SPACE_Y*30 + KEEP_SIZE
- SIZE_SBUF equ 2250 ; 100*30-540-7*30 (7*30 for status line)
-
- SetFont macro
- move.w \1,-(a7)
- jsr doorsos::FontSetSys
- lea 2(a7),a7
- endm
- WriteStr macro
- move.w \3,-(a7)
- pea \4(pc)
- move.w \2,-(a7)
- move.w \1,-(a7)
- jsr doorsos::DrawStrXY
- lea 10(a7),a7
- endm
-
-
- _main:
-
- clr.b $60000C
- bset.b #6,$60000C
- bclr.b #0,$60000E ; Set R1
- bclr.b #1,$60000E ; Set W1
-
-
- move.l #SIZE_SBUF,-(a7) ; Allocate memory for a temp buffer.
- jsr doorsos::HeapAlloc
- lea 4(a7),a7
- tst.w d0
- beq error1
- move.w d0,hTmpBuf
- doorsos::DEREF d0,a0
- move.l a0,TmpBuf
-
- move.l #INBUF_SIZE,-(a7) ; Allocate memory for input buffer.
- jsr doorsos::HeapAlloc
- lea 4(a7),a7
- tst.w d0
- beq error2
- move.w d0,hInBuf
- doorsos::DEREF d0,a0
- move.l a0,InBuf
-
-
- ClearScreen:
- jsr graphlib::clr_scr2
-
- SetFont #2
- WriteStr #8,#14,#1,Text1
- WriteStr #62,#26,#1,Text2
- WriteStr #34,#38,#1,Text3
-
- move.l #30,-(a7) ; Draw a horizontal line
- move.w #$FFFF,-(a7)
- move.l #LCD_MEM+270,-(a7)
- jsr doorsos::memset
- lea 10(a7),a7
-
- clr.w d4 ; d4 : Input len
- clr.w iX
- move.w #51,iY
- SetFont #1
-
-
- MainLoop:
-
- move.l InBuf,a0
-
- PrintCmd
- jsr PrintCmdLine
-
- WaitKey:
- tst.w (doorsos::kb_vars+$1C)
- beq CheckLines
- move.w (doorsos::MaxHandles+$1E),d0
- clr.w (doorsos::kb_vars+$1C)
- cmp.w #264,d0
- beq Exit
- cmp.w #257,d0 ; Backspace ?
- beq BackSp
- cmp.w #263,d0 ; Clear ?
- beq ClearCmd
- cmp #13,d0 ; Enter ?
- beq SendCmdLine
-
- cmp.w #255,d0 ;Valid character ?
- bhi WaitKey ;no => loop
- cmp.w #INBUF_SIZE,d4 ;Maxchar ?
- beq WaitKey
-
- addq.w #1,d4 ; Add charachter to buf.
- move.b d0,(a0)+
- bra PrintCmd
-
- BackSp
- tst.w d4
- beq WaitKey
- subq.w #1,d4
- tst.b -(a0)
- bra PrintCmd
-
-
- CheckLines:
- btst.b #2,$60000E
- bne ReceiveData
- btst.b #3,$60000E
- bne ReceiveData
- bra WaitKey
- ReceiveData
- movem.l d3-d4/a0,-(a7)
- jsr irlib::GetByte
- jsr PrintChar
- jsr PrintCmdLine
- movem.l (a7)+,d3-d4/a0
- bra WaitKey
-
-
- SendCmdLine
- tst.w d4
- beq WaitKey
- move.b #$FE,(a0) ;the New Line code
- move.l InBuf,a0
- SNextByte
- move.b (a0)+,d3
- movem.l d3-d4/a0,-(a7)
- jsr irlib::PutByte
- movem.l (a7)+,d3-d4/a0
- movem.l d3-d4/a0,-(a7)
- jsr PrintChar
- movem.l (a7)+,d3-d4/a0
- dbra.b d4,SNextByte
-
- ClearCmd
- tst.w d4 ; If 2 consecutive [Clear]'s then clear
- beq ClearScreen ; the whole screen
- clr.w d4 ; If not, clear command line only.
- move.l InBuf,a0
- bra PrintCmd
-
-
-
- Exit:
- move.w hInBuf(PC),-(a7)
- jsr doorsos::HeapFree
- lea 2(a7),a7
- error2
- move.w hTmpBuf(PC),-(a7)
- jsr doorsos::HeapFree
- lea 2(a7),a7
- error1
- jsr doorsos::reset_link
- rts
-
- ;*********************************************************************
-
- PrintChar:
- cmp.b #$FE,d3
- bne NoNewLine
- addi.w #SPACE_Y,iY
- clr.w iX
- bra RDCont
-
- NoNewLine
- movem.l d0-d4/a0,-(a7)
- move.w #1,-(a7)
- move.w iY,-(a7)
- move.w iX,-(a7)
- move.w d3,-(a7)
- jsr userlib::DrawCharXY
- lea 8(a7),a7
- movem.l (a7)+,d0-d4/a0
-
- addi.w #SPACE_X,iX
-
- cmp.w #MAX_X,iX
- ble RDCont
- addi.w #SPACE_Y,iY
- clr.w iX
-
- RDCont
- cmp.w #MAX_Y,iY
- ble RDNoScroll
-
- movem.l d0-d4/a0,-(a7)
-
- move.l TmpBuf,a0
-
- move.l #SIZE_SBUF,-(a7)
- move.l #LCD_MEM+SCROLL_SIZE,-(a7)
- move.l a0,-(a7)
- jsr doorsos::memcpy
- lea 12(a7),a7
-
- jsr graphlib::clr_scr2 ; Won't erase status line.
-
- move.l TmpBuf,a0
-
- move.l #SIZE_SBUF,-(a7)
- move.l a0,-(a7)
- move.l #LCD_MEM+KEEP_SIZE,-(a7)
- jsr doorsos::memcpy
- lea 12(a7),a7
-
- move.l #30,-(a7) ; Redraw the horizontal line
- move.w #$FFFF,-(a7)
- move.l #LCD_MEM+270,-(a7)
- jsr doorsos::memset
- lea 10(a7),a7
-
- movem.l (a7)+,d0-d4/a0
-
- subi.w #SPACE_Y,iY
- RDNoScroll
- rts
-
-
- ;*********************************************************************
-
- PrintCmdLine:
- move.b #95,(a0) ;the '_' char
- clr.b 1(a0)
-
- movem.l d0-d7/a0-a6,-(a7)
- clr.w d0
- clr.w d1
- move.w #160,d2
- moveq.w #7,d3
- moveq.w #1,d4
- jsr graphlib::fill
- movem.l (a7)+,d0-d7/a0-a6
-
- movem.l d0-d7/a0-a6,-(a7)
- cmp.w #MAX_COL,d4
- ble NoCut
- subi.w #MAX_COL,d4
- move.l InBuf,a0
- add.l d4,a0
- move.w #160,d2 ; The '...' Char
- bra DrawStr
- NoCut
- move.l InBuf,a0
- move.w #62,d2 ; The '>' Char
- DrawStr
- movem.l d0-d4/a0,-(a7)
- move.w #1,-(a7)
- clr.l -(a7) ; x and y are 0
- move.w d2,-(a7)
- jsr userlib::DrawCharXY
- lea 8(a7),a7
- movem.l (a7)+,d0-d4/a0
-
- move.w #1,-(a7)
- move.l a0,-(a7)
- clr.w -(a7)
- move.w #7,-(a7)
- jsr doorsos::DrawStrXY
- lea 10(a7),a7
-
- movem.l (a7)+,d0-d7/a0-a6
- rts
-
-
-
- hInBuf dc.w 0
- InBuf dc.l 0
- hTmpBuf dc.w 0
- TmpBuf dc.l 0
- iX dc.w 0
- iY dc.w 0
-
-
- Text1: dc.b "InfraRed Chat v0.1",0
- Text2: dc.b "by",0
- Text3: dc.b "Sami Khawam",0
- _comment dc.b "IR Chat v0.1",0
- end
-
-