Would you like to make this site your homepage? It's fast and easy...
Yes, Please make this my home page!
Best viewed in 1024x768
LCD Screen
The LCD, or Liquid Crystal Display, screen is the area on the TI-86 where graphics and text are displayed. This screen is 128x64 pixels wide. For more information, please click on the picture. This is not intended to be a programming tutorial, rather then a summary. Any tutorials will be posted below under the section, "More Information". Here is a overview (in programmers terms) on the display:
- General Description:
- Dark black pixels "dots" overlayed on a light gray display area.
- 128 pixels in width, 64 pixels in height
- Accessing the display (LCD) in memory:
- Memory mapped region begins at $FC00
- ...and ends at $FFFF
- WIDTH (1 row) is 16 ($10 in hex) bytes long
- HEIGHT (1 column) is 8 ($8 in hex) bytes long
- 128x64 = 8198. 8 PIXELS/BYTE, 8198/8 = 1024 bytes
- 1024 bytes (or $400 in hex) is the length of the memory mapped region
- 8 Pixels in a Byte, changing one byte may change all 8-pixels.
To draw a pixel to the screen, we use a findpixel routine developed by Dan Eble and James Yopp. I explained this routine in much detail on Tutorial #4 located on my tutorials page.
Examples:
; Sets a Pixel at 64, 32
ld e, 64
ld d, 32
call FindPixel ; Returns a bitmask, in this case %10000000 or $80
or (hl) ; A = A or (HL), which OR's the bitmask, A, with the address in the display, (HL)
ld (hl), a ; (HL) = A, Apply's the changes
; XOR's (inverts) a Pixel at 64, 32
ld e, 64
ld d, 32
call FindPixel ; Returns a bitmask, in this case %10000000 or $80
xor (hl) ; A = A xor (HL), which XOR's the bitmask, A, with the address in the display, (HL)
; Any bits set in the bitmask (only 1) will cause the cooresponding bit in (HL) to be inverted.
ld (hl), a ; (HL) = A, Apply's the changes
; Clears a pixel at 64, 32
ld e, 64
ld d, 32
call FindPixel ; Returns a bitmask, in this case A = %10000000 or $80
cpl ; Same as XOR 255, Inverts bitmask (changes all 1's to 0's and 0's to 1's), in this case A = %01111111
and (hl) ; A = A and (HL), which AND's the inverted bitmask, A, with the address in the display, (HL)
ld (hl), a ; (HL) = A, Apply's the changes
Here is the routine:
;--------------------------------------------------------------------
; The Eble-Yopp-Yopp-Eble-Eble-Eble-Yopp Fast FindPixel Routine :)
; 36 bytes / 121 t-states not counting ret or possible push/pop of BC
;--------------------------------------------------------------------
; Input: D = y
; E = x
; Output: HL= address of byte in video memory
; A = bitmask (bit corresponding to pixel is set)
; C is modified
;
; +-----------+
; |(0,0) | <- Screen layout
; | |
; | (127,63)|
; +-----------+
;
;--------------------------------------------------------------------
FindPixel:
ld hl,FP_Bits
ld a,e
and $07 ; a = bit offset
add a,l
ld l,a
adc a,h
sub l
ld h,a
ld c,(hl) ; c = bitmask for (hl)
;48 t-states up to this point
ld hl,FP_RLD
ld (hl),d
ld a,e ; a = x/8 (byte offset within row)
rrca
rrca
rrca
rld
or $FC
ld l,(hl)
ld h,a ; hl -> byte in vid mem
ld a,c ; now a = bitmask for (hl)
;121 t-states up to this point
ret
FP_RLD: .db $00
FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01
.end
More Information:
TI-86 Offical Asm Documentation - Display
Matt Johnson's Simple Display Tutorial
Trent Lillehaugen's Asm86 Tutorial - Video Examples