#define BUFFSIZE 96 ;number of samples #define PLOTSIZE 10 ;height of plot on screen #define RECEIVE_TIME 5 ;resolution of samples .nolist #include "ti83plus.inc" .list .org $9D93 .db t2ByteTok, tAsmCmp buffer .EQU TextShadow cursorx: .db 0 ;these store drawing cursor coordinates cursory: .db 0 start: b_call(_runindicoff) ;run indicator off for more screen area call fastcopyerase ;erase the screen call fastcopyerase ld hl, 0 ld (CurRow), hl ld hl, msg_startup b_call(_PutS) ;display the text key_loop: b_call(_GetCSC) cp sk1 ;pressing one will exit ret Z cp skClear ;pressing clear will reset program call Z, start cp skEnter ;pressing enter will start trigger loop jr Z, trigger_loop jr key_loop trigger_loop: call fastcopyerase ;erase the screen call fastcopyerase ld b, BUFFSIZE ld hl, buffer trigger_loop0: in a, (0) ;loop until data start detected bit 0, a ;check red wire jr NZ, trigger_loop0 tripped: call test_port ld (hl), c ;store sample to buffer inc hl ;increment buffer pointer call uart_delay djnz tripped ;repeat for all samples call draw_buffer ;draw to screen jr key_loop ;go back to checking for keys ;************************************************************** ;* draw_buffer-Draws a line representing the recorded signal ;************************************************************** draw_buffer: ld hl, buffer ld a, 0 ld b, BUFFSIZE draw_buffer0: ;go through whole sample buffer and draw it to graph buffer ld d, a ld e, (hl) call plot inc a inc hl djnz draw_buffer0 call fastcopyerase ;draw buffer to screen ret ;************************************************************** ;* test_port-Outputs a specified value if red high/low ;************************************************************** test_port: in a, (0) bit 0, a jr NZ, test_port1 test_port0: ld c, 31+PLOTSIZE ret test_port1: ld c, 31-PLOTSIZE ret ;************************************************************** ;* uart_delay-One half bit delay ;************************************************************** uart_delay: ;(time-1)*14+39 ld a, RECEIVE_TIME ;7 uart_delay0: dec a ;4 jr NZ, uart_delay0 ;10 or 1 ret ;10 ;---------------------------------------------------------------- ; Draw Pixel ;---------------------------------------------------------------- ;Author Again copy pasted from Sean McLaughlin's tutorial BUT the Bug has been fixed! =D ;Input d x-coord ; e y-coord ;Destroys de plot: push hl push bc push af ld a, d ld l, e ld h, 0 ld d, h ld e, l add hl, hl add hl, de add hl, hl add hl, hl ld e, a srl e srl e srl e add hl, de ld de, plotsscreen add hl, de and 7 ld b, a ; In the original routine this code is executed after "JR Z, _finalize", it's easy to see that this isn't correct ld a, 080h jr z, _finalize _loop: rrca djnz _loop _finalize: or (HL) LD (HL), A pop af pop bc pop hl ret ;------------------------------------------------------------ ; Copies the buffer to the display ;------------------------------------------------------------ ; And this is the GREATEST routine EVER! It copies the buffer very fast to the screen, and erases it at the same time! ;-----> Copy the gbuf to the screen and clear graph buffer (fast) ;Input: nothing ;Output:graph buffer is copied to the screen and subsequently cleared fastcopyerase: di ld a,$80 out ($10),a ld hl,plotsscreen-12-(-(12*64)+1) ld a,$20 ld c,a inc hl dec hl fastCopyAgain: ld b,64 inc c ld de,-(12*64)+1 out ($10),a add hl,de ld de,11 fastCopyLoop: add hl,de inc hl inc de ld a,(hl) patch ld (hl),000h ; clears the graph buffer at the same time out ($11),a dec de djnz fastCopyLoop ld a,c cp $2B+1 jr nz,fastCopyAgain ret msg_startup: .db "Serdebug", 0 .end .end