; InfraRed Chat for the IR Link (http://unet.univie.ac.at/~a9501901/irlink) ; by Sami Khawam (sKhawam@bigfoot.com) ; http://unet.univie.ac.at/~a9501901 ; ; NOTE: The Keys indexes are had been fixed. ; ; This is for ASH. ; ; No WhiteBoard support! (Chat can be made with a TI85 or TI85, but ; no drawings ... :( ; ; Thanks for Randy Gluvna (gluvna@home.com) for his recieve routine. ; Thanks for Osma Suominen (ozone@clinet.fi) for his keys scaning ; codes for the TI85, and for his MChat. ; ; ; - Sami Khawam #INCLUDE "TI82.H" #INCLUDE "KEYS.INC" PORT = 000H .ORG START_ADDR .db "IR Chat v.12 ",0 BySK: .db "by Sami Khawam", 0 BufferLen = APD_BUF ; String length TextBuffer = APD_BUF+1 KeyFlags = GRAPH_MEM ; 0000xxxx ; bit 0 = Alpha ; bit 1 = Num ; bit 2 = Lock CursorX = KeyFlags + 1 ScreenX = CursorX + 1 ScreenY = ScreenX + 1 iCursor = ScreenY + 1 Init: ROM_CALL(CLEARLCD) ld a, 4 out (5), a ld de, $0102 ld (CURSOR_ROW), de ld hl, ProgName ROM_CALL(D_ZT_STR) ld de, $0103 ld (CURSOR_ROW), de ld hl, BySK ROM_CALL(D_ZT_STR) ld hl, $0004 ld (ScreenX), hl xor a ld (KeyFlags), a ld a, $DC ld (iCursor), a jp ClearInput MainLoop: ld a, $C0 ; Set W1 and R1 out (0), a in a, (0) and 3 cp 3 jp nz, ReceiveLine ; Only one line low. GetKey: call GET_KEY or a ; No key pressed jr z, MainLoop cp G_MODE ret z cp G_DEL jp z, BackSpace cp G_ENTER jp z, SendLine cp G_CLEAR jp z, ClearInput cp G_2nd jp z, SetNumber cp G_ALPHA jp z, SetAlpha cp $0a ; Ignore the arrows and 'Enter'. jp c, MainLoop sub $0a ld hl, Scan2Index ld d,0 ld e,a add hl,de ld a,(hl) ; a=ascii value of key or a jp z, MainLoop ; Invalid key - loop ld c, a ld a, (KeyFlags) and 1 jr nz, AlphaSet ld a, (KeyFlags) and 2 jr nz, NumSet ld a, c ld hl, Index2Ascii ld d,0 ld e,a add hl,de ld a,(hl) ; a=ascii value of key or a jp z, MainLoop ; Invalid key - loop jr Continue2 AlphaSet: ld a, c ld hl, Index2Shift ld d,0 ld e,a add hl,de ld a,(hl) ; a=ascii value of key or a jp z, MainLoop ; Invalid key - loop ld c, a jr Continue NumSet: ld a, c ld hl, Index2Num ld d,0 ld e,a add hl,de ld a,(hl) ; a=ascii value of key or a jp z, MainLoop ; Invalid key - loop ld c, a Continue: ld a, (KeyFlags) and 4 jr nz, IsLocked xor a ld (KeyFlags), a ld a, $DC ld (iCursor), a call PrintInput IsLocked: ld a, c Continue2: ld b, a ld hl, TextBuffer ld d, 0 ld a, (BufferLen) ld e, a add hl, de ld (hl), b ld a, (BufferLen) inc a ld (BufferLen), a ld a, (CursorX) cp 12 jr nz, NoDecal PrintInputLine: ld hl, $0000 ld (CURSOR_ROW), hl ld a, (BufferLen) sub 12 ld hl, TextBuffer ld d, 0 ld e, a add hl, de ld b, 12 ld a, $CE ROM_CALL(TX_CHARPUT) NextChar: ld a, (hl) ROM_CALL(TX_CHARPUT) inc hl djnz NextChar call PrintInput jp MainLoop NoDecal: inc a ld (CursorX), a ld a, b ROM_CALL(TX_CHARPUT) call PrintInput jp MainLoop BackSpace: ld a, (BufferLen) or a jp z, MainLoop dec a ld (BufferLen), a ld a, (CursorX) cp 12 jr nz, FirstCh ld a, (BufferLen) cp 11 ; !!!!!! jp nz, PrintInputLine FirstCh dec a ld (CursorX), a ld a, ' ' ROM_CALL(TX_CHARPUT) ld a, (CURSOR_COL) dec a dec a ld (CURSOR_COL), a call PrintInput jp MainLoop SetAlpha: ld a, (KeyFlags) and 1 jr z, ASet ld a, (KeyFlags) and 4 jr z, ALock xor a ld (KeyFlags), a ; Normal set ld a, $DC jr ANEnd ASet ld a, 1 ld (KeyFlags), a ; Alpha set ld a, $DF jr ANEnd ALock ld a, 5 ld (KeyFlags), a ; Alpha locked ld a, $DB ANEnd ld (iCursor), a call PrintInput jp MainLoop SetNumber: ld a, (KeyFlags) and 2 jr z, NSet ld a, (KeyFlags) and 4 jr z, NLock xor a ld (KeyFlags), a ; Normal set ld a, $DC jr SNEnd NSet ld a, 2 ld (KeyFlags), a ; Num set ld a, $DD jr SNEnd NLock ld a, 6 ld (KeyFlags), a ; Num locked ld a, $D9 SNEnd ld (iCursor), a call PrintInput jp MainLoop SendLine ld a, (BufferLen) or a jp z, MainLoop ld b, a call ScrollPage ld hl, TextBuffer NextByte ld a, (hl) ROM_CALL(TX_CHARPUT) call PutByte ; Now we send all bytes. inc hl djnz NextByte ld de, (CURSOR_ROW) inc de ld d, 0 ld (CURSOR_ROW), de ld (ScreenX), de ld a, $FE call PutByte ; Send 'Enter'. ClearInput: xor a ;ld a, 0 ld (BufferLen), a inc a ld (CursorX), a ld hl, $0200 ld (CURSOR_ROW), hl ld b, 12 ld a, ' ' NextBlank: ROM_CALL(TX_CHARPUT) djnz NextBlank ld hl, $0000 ld (CURSOR_ROW), hl ld a, '>' ROM_CALL(TX_CHARPUT) call PrintInput jp MainLoop PrintInput ld a, (iCursor) ROM_CALL(TX_CHARPUT) ld a, (CURSOR_COL) dec a ld (CURSOR_COL), a ret ScrollPage: ld hl, (ScreenX) ld (CURSOR_ROW), hl ld a, l cp 8 ret nz dec hl ld (CURSOR_ROW), hl ld a, 1 ld ($8C8F),a ;Starting row is 1 ld a, 8 ld ($8C90),a ;Last row to scroll is 7 res 1, (IY+0D) ; don't scroll the text memory!!!!!!!!!!!!! ROM_CALL(SCROLL_UP) ret ReceiveLine: call GetByte or a jp z, MainLoop ld c, a call ScrollPage ld a, c cp $FE jr z, NextLine ROM_CALL(TX_CHARPUT) jr NoNextLine NextLine: inc hl ld h, 0 ld (CURSOR_ROW), hl NoNextLine: ld hl, (CURSOR_ROW) ld (ScreenX), hl ld a, (CursorX) ld d, a ld e, 0 ld (CURSOR_ROW), de jp MainLoop ; Thanks for Randy Gluvna (gluvna@home.com) for this recieve routine. GetByte: LD B,008H R0: LD DE,0FFFFH JR R2 R1: IN A,(PORT) AND 003H RET Z CP 003H JR NZ,R3 IN A,(PORT) AND 003H RET Z CP 003H JR NZ,R3 R2: DEC DE LD A,D OR E JR NZ,R1 RET R3: SUB 002H JR NC,R8 LD A,0D4H OUT (PORT),A RR C LD DE,0FFFFH R4: IN A,(PORT) AND 003H CP 002H JR Z,R5 DEC DE LD A,D OR E JR NZ,R4 RET R5: LD A,0C0H OUT (PORT),A LD D,004H R6: DEC D JR Z,R7 IN A,(PORT) AND 003H CP 003H JR NZ,R6 R7: DJNZ R0 LD A,C RET R8: LD A,0E8H OUT (PORT),A RR C LD DE,0FFFFH R9: IN A,(PORT) AND 003H CP 001H JR Z,R5 DEC DE LD A,D OR E JR NZ,R9 RET PutByte: push bc LD C,A LD B,8 ; 8 Bits PB_Next_Bit: LD A, $C0 ; Set W1 and R1 OUT (0),A Cont: RR C JR NC, PB_SendZero PB_SendOne: LD A, $E8 JR PB_Output_val PB_SendZero: LD A, $D4 PB_Output_val: OUT (0),A LD DE, $FFFF ; For time-out PB_Wait_for_W0_and_R0: IN A,(0) AND 3 JR Z, PB_Continue IN A,(0) AND 3 JR Z, PB_Continue DEC DE LD A,D OR E JR NZ, PB_Wait_for_W0_and_R0 JR PB_End ; If error return. PB_Continue: LD A, $C0 ; Set W1 and R1 OUT (0),A LD DE, $FFFF ; Reload time-out PB_Wait_for_W1_and_R1: DEC DE LD A,D OR E JR Z, PB_End IN A,(0) AND 3 CP 3 JR NZ, PB_Wait_for_W1_and_R1 DJNZ PB_Next_Bit PB_End: POP BC RET Scan2Index: .db 1, 2, 3, 4, 5, 0, 0, 6, 7, 8, 9, 10, 11 .db 1, 2, 12, 13, 14, 15, 16, 17, 18 .db 0, 19, 20, 21, 22, 23, 24, 25, 0 .db 0, 26, 27, 28, 29, 30, 31 Index2Ascii: ; Plain .db 0,$22, "wrmh?", $c1, .db "vqlg:zupkfc yto" .db "jebxsnida" Index2Shift: .db 0,$22, "WRMH?", $c1, .db "VQLG:ZYPKFC YTO" .db "JEBXSNIDA" Index2Num: .db 0,"+-*/^-3" .db "69)", 34, ".258(", 196, "!0147" .db "E<>=e", $1D, $D3, 206, "?" ProgName: .db "InfraRed Chat", 0 .end