1;;; -*- TI-Asm -*-
2
3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4;;;
5;;; TI-73/82/83/83+/84+/85/86 ROM Dumper
6;;;
7;;; Copyright (c) 2012 Benjamin Moody
8;;;
9;;; This program is free software; you can redistribute it and/or modify
10;;; it under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 2 of the License, or
12;;; (at your option) any later version.
13;;;
14;;; This program is distributed in the hope that it will be useful,
15;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
21;;;
22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23
24;; ClearLCD:
25;;
26;; Clear the LCD.
27;;
28;; Destroys:
29;; - AF, BC, DE, HL
30
31ClearLCD:
32	ld hl, 0FC00h
33	ld (hl), l
34	ld de, 0FC01h
35	ld bc, 03FFh
36	ldir
37	ret
38
39;; PutC:
40;;
41;; Display an ASCII character.
42;;
43;; Input:
44;; - A = character
45;; - (curRow) = cursor row
46;; - (curCol) = cursor column
47;;
48;; Output:
49;; - (curRow), (curCol) = updated
50;;
51;; Destroys:
52;; - AF
53
54PutC:
55	push hl
56	 push de
57	  push bc
58fontTable equ $ + 1
59	   ld hl, 0
60	   ld bc, 8
61PutC_FindBitmapLoop:
62	   cp (hl)
63	   jr z, PutC_FoundBitmap
64	   add hl, bc
65	   jr nc, PutC_FindBitmapLoop
66PutC_FoundBitmap:
67	   inc hl
68
69	   ld bc, curRow
70	   ld a, (bc)
71	   rrca
72	   ld e, a
73	   or 0FCh
74	   ld d, a
75
76	   inc bc
77	   ld a, (bc)
78	   inc a
79	   ld (bc), a
80	   dec a
81	   ld b, a
82	   add a, a
83	   add a, b
84	   rrca
85	   rrca
86	   xor e
87	   and 1Fh
88	   xor e
89	   ld e, a
90
91	   ld b, 7
92PutC_Loop:
93	   ld a, (curCol)
94	   and 3
95	   jr z, PutC_0
96	   dec a
97	   jr z, PutC_1
98	   dec a
99	   ld a, (hl)
100	   rrca
101	   rrca
102	   jr z, PutC_2
103
104	   ld c, a
105	   inc e
106	   ld a, (de)
107	   xor c
108	   and 03Fh
109	   xor c
110	   ld (de), a
111	   dec e
112	   ld a, (de)
113	   xor c
114	   and 0F0h
115	   xor c
116	   jr PutC_Next
117
118PutC_0:
119	   ld a, (de)
120	   and 0C0h
121	   or (hl)
122	   jr PutC_Next
123
124PutC_1:
125	   ld a, (hl)
126	   rlca
127	   rlca
128	   ld c, a
129	   ld a, (de)
130	   and 3
131	   or c
132	   jr PutC_Next
133
134PutC_2:
135	   rrca
136	   rrca
137	   ld c, a
138	   inc e
139	   ld a, (de)
140	   xor c
141	   and 0Fh
142	   xor c
143	   ld (de), a
144	   dec e
145	   ld a, (de)
146	   xor c
147	   and 0FCh
148	   xor c
149PutC_Next:
150	   ld (de), a
151	   inc hl
152	   ld a, e
153	   add a, 16
154	   ld e, a
155	   djnz PutC_Loop
156	   pop bc
157	  pop de
158	 pop hl
159	ret
160