;+------------------------------------------------------+ ;| Pixel v1.0 | ;| by Joe Wingbermuehle | ;| 12-23-1997 | ;+------------------------------------------------------+ ; This is a useful routine to turn off, turn on, change ; the state of, or just test the state of an individual ; pixel on the screen. To use it, just load xc,yc with ; the location of the pixel and load register a with the ; operation: ; 0-turn off ; 1-turn on ; 2-change state ; 3 or anything else-test ; the routine will return flag z=0 if the pixel is off ; or z=1 if the pixel is on (this will always happen ; no matter what a equals on entry). Note: the pixel ; is tested AFTER any operations the routine make. ; Therefore if a=0 on enty, z will be 0. ; ; Send bugs/comments to: joewing@usmo.com ; Visit my homepage at: http://www.usmo.com/~joewing ; ; This demo program randomly changes the state of a pixel ; on the screen until the user presses clear. ;---------- Constants ---------- #define copyg 5164h #define convop1 4EFCh #define random 50B6h #define fpmult 40AAh #define setxxop2 4A78h #define clrbuf 515Bh .org $9327 ; start for all TI-83 asm programs ;---------- Demo program for Pixel ---------- call clrbuf ; clear the graph buffer main: call random ; get a random number in op1 (0-1) ld a,96 call setxxop2 ; 96->op2 call fpmult ; op1*op2->op1 call convop1 ; op1->de ld a,e ; e->a (d will ALWAYS be =0) ld (xc),a ; a->xc call random ; you get the idea! ld a,64 call setxxop2 call fpmult call convop1 ld a,e ld (yc),a ld a,$02 ; 2->a (change pixel) call pixel ; do it! call copyg ; copy graph buffer to screen ld a,$FF ; 255->a (get the keyboard ready) out ($01),a ; do it ld a,$FD ; 254->a (enable a section of the keyboard) out ($01),a ; do it in a,($01) ; get the value back from the keyboard, store in a cp 191 ; a=191? (clear key) jr nz,main ; if not, plot another pixel, else... ret ; exit the program ;---------- Pixel ---------- ; input: xc,yc; a=action (0=off, 1=on, 2=change, 3=test) ; output: flag z=state (0=off, 1=on) pixel: push af ld a,(yc) ld e,a ld l,a ld h,$00 ld d,h add hl,de add hl,de add hl,hl add hl,hl ld bc,$8E29 add hl,bc ld a,(xc) ld e,a and $07 ld c,a srl e srl e srl e add hl,de pop af or a jr nz,px1 call pxt jr z,pxx ld a,(hl) xor e ld (hl),a jr pxx px1: cp $01 jr nz,px2 call pxt jr nz,pxx ld a,(hl) xor e ld (hl),a jr pxx px2: cp $02 jr nz,px3 call pxt ld a,(hl) xor e ld (hl),a pxx: call pxt ld a,(hl) and e ret pxt: ld d,a ld a,c ld e,%10000000 or a jr z,px4 ld b,c px3: rr e djnz px3 px4: ld a,d ret ;---------- Coordinate data for Pixel ---------- xc: .db $00 yc: .db $00 .end END