CPU-Z80-Disassembler
view release on metacpan or search on metacpan
t/data/zx48.asm view on Meta::CPAN
DEFB $31 ;;duplicate sx, sy, sy.
DEFB $E0 ;;get-mem-0 sx, sy, sy, sx.
DEFB $01 ;;exchange sx, sy, sx, sy.
DEFB $31 ;;duplicate sx, sy, sx, sy, sy.
DEFB $E0 ;;get-mem-0 sx, sy, sx, sy, sy, sx.
; Locations mem-1 and mem-2 are the relative x and y values which are updated
; after each line is drawn. Since we are drawing a vertical line then the rx
; value in mem-1 is zero and the ry value in mem-2 is the full chord.
DEFB $A0 ;;stk-zero sx, sy, sx, sy, sy, sx, 0.
DEFB $C1 ;;st-mem-1 sx, sy, sx, sy, sy, sx, 0.
DEFB $02 ;;delete sx, sy, sx, sy, sy, sx.
; Although the three pairs of x/y values are the same for a circle, they
; will be labelled terminating, absolute and start coordinates.
DEFB $38 ;;end-calc tx, ty, ax, ay, sy, sx.
; Use the exponent manipulating trick again to double the value of mem-2.
INC (IY+$62) ; Increment MEM-2-1st doubling half chord.
; Note. this first vertical chord is drawn at the radius so circles are
; slightly displaced to the right.
; It is only necessary to place the values (sx) and (sy) in the system
; variable COORDS to ensure that drawing commences at the correct pixel.
; Note. a couple of LD (COORDS),A instructions would have been quicker, and
; simpler, than using LD (COORDS),HL.
CALL L1E94 ; routine FIND-INT1 fetches sx from stack to A.
LD L,A ; place X value in L.
PUSH HL ; save the holding register.
CALL L1E94 ; routine FIND-INT1 fetches sy to A
POP HL ; restore the holding register.
LD H,A ; and place y value in high byte.
LD ($5C7D),HL ; Update the COORDS system variable.
;
; tx, ty, ax, ay.
POP BC ; restore the chord count
; values 4,8,12,16,20,24,28 or 32.
JP L2420 ; forward to DRW-STEPS
; tx, ty, ax, ay.
; Note. the jump to DRW-STEPS is just to decrement B and jump into the
; middle of the arc-drawing loop. The arc count which includes the first
; vertical arc draws one less than the perceived number of arcs.
; The final arc offsets are obtained by subtracting the final COORDS value
; from the initial sx and sy values which are kept at the base of the
; calculator stack throughout the arc loop.
; This ensures that the final line finishes exactly at the starting pixel
; removing the possibility of any inaccuracy.
; Since the initial sx and sy values are not required until the final arc
; is drawn, they are not shown until then.
; As the calculator stack is quite busy, only the active parts are shown in
; each section.
; ------------------
; THE 'DRAW' COMMAND
; ------------------
; The Spectrum's DRAW command is overloaded and can take two parameters sets.
;
; With two parameters, it simply draws an approximation to a straight line
; at offset x,y using the LINE-DRAW routine.
;
; With three parameters, an arc is drawn to the point at offset x,y turning
; through an angle, in radians, supplied by the third parameter.
; The arc will consist of 4 to 252 straight lines each one of which is drawn
; by calls to the DRAW-LINE routine.
;; DRAW
L2382: RST 18H ; GET-CHAR
CP $2C ; is it the comma character ?
JR Z,L238D ; forward, if so, to DR-3-PRMS
; There are two parameters e.g. DRAW 255,175
CALL L1BEE ; routine CHECK-END
JP L2477 ; jump forward to LINE-DRAW
; ---
; There are three parameters e.g. DRAW 255, 175, .5
; The first two are relative coordinates and the third is the angle of
; rotation in radians (A).
;; DR-3-PRMS
L238D: RST 20H ; NEXT-CHAR skips over the 'comma'.
CALL L1C82 ; routine EXPT-1NUM stacks the rotation angle.
CALL L1BEE ; routine CHECK-END
; Now enter the calculator and store the complete rotation angle in mem-5
RST 28H ;; FP-CALC x, y, A.
DEFB $C5 ;;st-mem-5 x, y, A.
; Test the angle for the special case of 360 degrees.
DEFB $A2 ;;stk-half x, y, A, 1/2.
DEFB $04 ;;multiply x, y, A/2.
DEFB $1F ;;sin x, y, sin(A/2).
DEFB $31 ;;duplicate x, y, sin(A/2),sin(A/2)
DEFB $30 ;;not x, y, sin(A/2), (0/1).
DEFB $30 ;;not x, y, sin(A/2), (1/0).
DEFB $00 ;;jump-true x, y, sin(A/2).
DEFB $06 ;;forward to L23A3, DR-SIN-NZ
; if sin(r/2) is not zero.
; The third parameter is 2*PI (or a multiple of 2*PI) so a 360 degrees turn
; would just be a straight line. Eliminating this case here prevents
( run in 1.274 second using v1.01-cache-2.11-cpan-39bf76dae61 )