high speed hplot a line from assembly
make the table:
https://rich12345.tripod.com/prog/lookupgen.html
the hplot routine:
https://rich12345.tripod.com/prog/hplotassy.html
this basic program calls the assembly:
0 HGR
1 HOME : VTAB 21
10 A$ = "BRESLINES"
15 X1POK = 32768
80 Y = 50
90 PRINT CHR$ (4);"BLOAD ";A$
91 FOR X = 1 TO 250
95 POKE X1,X: POKE X1 + 1,Y: POKE X1 + 2,100: POKE X1 + 3,100
310 CALL 32787
320 NEXT X
;FILENAME = BRESLINES
;REMEMBER TO PUT
;HPLOT AND
;LOOKUPY TABBLE
;SHI EQU $06
;SLO EQU $07
;DRAW A LINE WITH BRESENHAM ALGO
;
;FROM X1,Y1
;
;TO X2,Y2
X1 DFB #00
Y1 DFB #00
X2 DFB #00
Y2 DFB #00
DELTAX DFB #00
DELTAY DFB #00
NUMPXELS DFB #00
XINC1 DFB #00
XINC2 DFB #00
YINC1 DFB #00
YINC2 DFB #00
D DFB #00
D1 DFB #00
D2 DFB #00
X3 DFB #00
Y3 DFB #00
XP DFB #00
YP DFB #00
;
;deltax = abs(X2-X1)
;
LINESTART
SEC
LDA X2 ;X2 - X1
SBC X1 ;
STA DELTAX
BPL NOABSX1
ABSX1
CLC
EOR #$FF ;A HAS RESULT
ADC #1
STA DELTAX
NOABSX1
;
;DELTAY = Y2-Y1
;
SEC
LDA Y2 ;Y2 - Y1
SBC Y1 ;
STA DELTAY
BPL NOABSY1
ABSY1
CLC
EOR #$FF ;A HAS RESULT
ADC #1
STA DELTAY
NOABSY1
;ABS COULD BE A SUBROUTINE TO SAVE RAM
LDA DELTAX ;IF DELTAX OR = DELTAY
DX>DY
CLC
LDA DELTAX ;NUMPIXELS = deltax+1
ADC #1 ;
STA NUMPXELS
;D=(2*DELTAY)-DELTAX
CLC
LDA DELTAY ;2*DELTAY
ROL ;
SEC
SBC DELTAX ;-DELTAX
STA D
;D1=DELTAy *2
LDA DELTAY ;2*DELTAy
CLC
ROL ;
STA D1
;D2=(DELTAY-DELTAX)*2
LDA DELTAY
SEC
SBC DELTAX
CLC
ROL
STA D2
LDA #1
STA XINC1 ;XINC1=1
STA XINC2 ;XINC2=1
STA YINC2 ;YINC2=1
LDA #00
STA YINC1 ;YINC1=0
JMP END ;GOTO 36300: REM DNE
;
;NOT>=0
;
DX X2 THEN X5 = - X5:X6X - = 6
CMP X2
BEQ X1NOT>X2
BCC X1NOT>X2 ;C=0 WHEN A(X1) < MEM (X2)
;X1IS>X2
LDA XINC1 ;x5=-x5
EOR #$FF
STA XINC1
INC XINC1
LDA XINC2 ;x6=-x6
EOR #$FF
STA XINC2
INC XINC2
X1NOT>X2
;IF Y1 > Y2 THEN Y5 = - Y5:Y6Y - = 6
LDA Y1
CMP Y2
BEQ Y1NOT>Y2
BCC Y1NOT>Y2 ;C=0 IF A(Y1) < MEM(Y2)
;Y1IS>X2
LDA YINC1 ;y5=-y5
EOR #$FF
STA YINC1
INC YINC1
LDA YINC2 ;y6=-y6
EOR #$FF
STA YINC2
INC YINC2
Y1NOT>Y2
***************************************
LDA X1 ;X = X1
STA X3 ;
LDA Y1 ;Y = Y1
STA Y3 ;
LDX NUMPXELS ;FOR I = 1 TO NUMPIXELS
STX XTEMP2
ILOOP
LDA X3 ;XP = X
STA XLOC ;
LDA Y3 ;YP = Y
STA YLOC ;
JSR HPLOT ;GOSUB 34000: REM PLOT PIXEL
LDA D ;IF D < 0 THEN D = D + D1 ;X = X + XINC1:Y = Y + YIN:1C
BPL DNOT<0
CLC ;D = D + D1
LDA D ;
ADC D1 ;
STA D ;
CLC ;X = X + XINC1
LDA X3 ;
ADC XINC1 ;
STA X3 ;
CLC ;Y = Y + YINC1
LDA Y3 ;
ADC YINC1 ;
STA Y3 ;
JMP D<0
DNOT<0
;D = D + D2:X = X + XINC2: Y 2
;
CLC ;D = D + D2:
LDA D ;
ADC D2 ;
STA D ;
CLC ;X = X + XINC2
LDA X3 ;
ADC XINC2 ;
STA X3 ;
CLC ;Y = Y + YINC2
LDA Y3 ;
ADC YINC2 ;
STA Y3 ;
D<0
LDX XTEMP2
DEX
STX XTEMP2
BEQ ENDLINE ;NEXT I
JMP ILOOP
ENDLINE RTS
XTEMP2 DFB #00