;TREND2 program 12/05/03 (c) RHPigford ;T200 program is called from BASIC with ; SP in H, PV in L ; PLOTS both PV and SP at each X val ;1-plot the stack from x=156 ;2-plot same stack again from x=155 ;3-erase the stack at x=156 BUT DO NOT ; ERASE IF CONSECUTIVE DOTS ;4-plot the new dot at X=156 ;5-RIFFL the stack up 1 byte, RETURN ;to BASIC ; PLOT: EQU 36214 ;on, all regs destroy ; upon entry D=x coord ; E=y coord UNPLOT: EQU 36215 ;off, same ; ORG 59500 ;room for 423 bytes ;SAVEM"SWP2J1",59500, ;end-317,0 ;No need to consume ;file RAM with buffer START: MOV A,H STA YSP MOV A,L STA YPV MVI B,156 ;print from X=156 CALL PRINT MVI B,155 ;print from X=155 CALL PRINT MVI B, 156 CALL ERASE ;erase first plot, ;skip duplicates ; LDA YPV ;get newest PV dot MOV E,A ;put it in E MVI D,156 ;put first X val in D CALL PLOT ;registers destroyed LDA YSP ; repeat for the SP dot MOV E,A MVI D,156 CALL PLOT CALL RIFFL ;ready for next time RET ;back to BASIC ; ;PRINT Enter B = x pos ; then decrement X as incr thru ; CALL PLOT ( D = x , E = y) ; do both values at each x PRINT: LXI H,OLDSP PRINT1: MVI C,2 PRINT2: MOV E,M ;get the Y val MOV D,B ;get the current x INX H PUSH H PUSH B PUSH PSW MOV A,E ANA A JZ PRINT3 ;don't print Y=0's CALL PLOT ;print dot @ X,Y PRINT3: POP PSW POP B POP H DCR C JNZ PRINT2 DCR B RZ JMP PRINT1 ; ;ERASE A holds first X val to start ; erasing, don't erase if ; Y is repeated from Y @ prev X ERASE: LXI H,OLDSP ;start addr of Y ;vals in data stack ERASE1: MVI C,2 ERASE2: MOV E,M ;get y, put in E MOV D,B ;the x val, 156 -> 1 PUSH H PUSH B PUSH PSW MOV A,E ANA A JZ ERASE3 DCX H ;point back 2 mem adrs DCX H ;check for duplicate val ; A should still hold the ; current Y val CMP M ;sub val @ mem from Accum ;if = previous, bypass JZ ERASE3 CALL UNPLOT ERASE3: POP PSW POP B POP H ;restore Y pointer INX H DCR C JNZ ERASE2 DCR B RZ JMP ERASE1 ; ;RIFFL is to move the 2 Y values down ; the 312 byte row, starting at the old ; first Y byte, move up 2 adresses, ; move the second Y byte up 2 addresses ; until all are done RIFFL: LXI H,LASTPV ;start @ 312th val MVI B,157 ;work back to 1st RIFFL1: MOV A,M ; get the Y val INX H INX H ; go up 2 addrs MOV M,A ; put the Y val DCX H DCX H DCX H ; back 3 addresses MOV A,M ;get next val INX H INX H ;move up 2 addrs MOV M,A ; put the Y val DCR B ;done all 156 yet? RZ DCX H DCX H DCX H JMP RIFFL1 ; YSP: DS 1 ;new dot's y val YPV: DS 1 OLDSP: DS 310 ;stack of Y vals LASTSP: DS 1 LASTPV: DS 1 LOST: DS 2 END: END