Re: A85: Pixel Off Routine?


[Prev][Next][Index][Thread]

Re: A85: Pixel Off Routine?



On Sat, 26 Jul 1997, Andrew Ferrara wrote:

> Is there a routine that turns pixels off?

Yup. Just write zeroes to whatever part of the display you want to turn
off. According to ti-85.h, the video memory starts at $FC00, so that's the
base address I've used in the instructions.

Example 1: We want to turn off eight pixels, starting in the upper-left
corner of the LCD and working to the right. The instruction would be:

ld a,$00      ; use zeroes to turn pixels off
ld hl,$FC00   ; the location to turn off
ld (hl),a     ; do the actual turning off

Example 2: We want the pixel pattern (. . . . . ) to be displayed starting
with the ninth pixel from the left on the top row:

ld a,%10101010  ; this is the binary representation of the pattern
ld hl,$FC01     ; this shows where on screen to do it
ld (hl),a       ; now it gets done

Example 3: You have something drawn on the screen. You want to have a 12x6
pixel space turned off (don't care about everything else) with the upper
left corner 15 pixels from the left and 5 rows down.

ld b,6               ; We want to clear a space six lines tall.
ld de,$0010          ; A constant. The screen is sixteen bits wide:
                     ; 128 pixels divided by 8 pixels per byte = 16
                     ; this makes the routine below wrap directly down
                     ; to the next line. A different number would
                     ; different effects such as zig-zag or skipping lines.

ld c,$00             ; First, we'll clear a space 8 bits by six lines.
                     ; since we want to clear all 8 bits, we use $00
ld hl,$FC26          ; this is the starting address of the space
                     ; to be cleared, minus the offset of $10. We do it
                     ; this way because the routine below will add $10
                     ; before it does anything else. It's easier that way.
CALL_(BlockBlanker)  ; call the routine that does the work

ld c,%00001111       ; this time we'll clear only the first four bits
ld hl,$FC27          ; and we want to start one byte (8 pixels) to the
                     ; right of where we were last time.
CALL_(BlockBlanker)  ; call the routine that does the work

CALL_(whatever)      ; be sure to put in some mechanism to prevent the
                     ; program from accidentally running the routine
                     ; without setting it up first.. it could screw up
                     ; anything on the screen or in RAM.

BlockBlanker:        ; the routine that does the work
 add hl,de           ; adds the offset to the starting address
 ld a,(hl)           ; gets what is onscreen into a register
 xor c               ; turns off the selected bits
 ld (hl),a           ; puts the new data back where it came from
 djnz BlockBlanker   ; and repeats until b=0 (six lines, in this case)
 ret                 ; when it's done, go back to where we were called

Hopefully that all works properly. It's been a while since I did any ASM
on the 85, so I'm not certain about the starting address of the video
(screen) memory. Almost everything else was snipped from a program I
wrote.

-- 
Greg Hill
      Email: greg-hill@bigfoot.com
Link cables: www.comports.com/link


Follow-Ups: References: