mads 2.1.6 build 66 (7 Jun 23)
Source: D:\!Delphi\mads\examples\demoscene\256B\kefrens\kefrens_interlaced.xsm
     1 						opt	h+
     2
     3 = 0600			sine		equ	$600				; sine table location
     4 = 0000			line		equ	$00				; line buffer location
     5
     6 						org	$100				; start of code (placed at stack area)
     7
     8 FFFF> 0100-012B> EE 0E + init		inc	$d40e				; disable NMI
     9
    10 0103 A0 00				ldy	#$00
    11 				;		tay					; when calling from TBXL we have #0 in A reg.
    12
    13 				; move code to zero page
    14
    15 0105 A2 54				ldx	#zp_code_end-zp_code_str	; size of moved code to X reg.
    16 0107 8E 1B D0				stx	$d01b				; switch GTIA to 16-shades mode
    17 010A BD 2C 01		zp_mv		lda	zp_code_ldr,x			; copy from source...
    18 010D 95 A0				sta	zp_code_str,x			; ...to destination
    19 010F CA					dex					; decr. loop counter
    20 0110 10 F8				bpl	zp_mv				; all done?
    21
    22 				; calculate sine table
    23
    24 0112 A2 FC		s0		ldx	#-4				; use negative index for loop counter opt.
    25 0114 B5 A4		s1		lda	val+4,x				; first add delta to val, then add xad to delta
    26 0116 75 A6				adc	val+6,x
    27 0118 95 A4				sta	val+4,x
    28 011A E8					inx					; inc. reg counter
    29 011B D0 F7				bne	s1				; done when X reg. is zero
    30
    31 011D A5 A1				lda	val+1				; store calculated val (hi-byte) to sine LUT
    32 011F 99 00 06				sta	sine,y
    33 0122 49 1F				eor	#$1f				; negate
    34 0124 99 80 06				sta	sine+$80,y			; fill-up the 2nd half of fine table
    35 0127 C8					iny					; next step
    36 0128 10 E8				bpl	s0				; all bytes done?
    37 012A 30 AF				bmi	go				; jump to main code ;)
    38
    39 				; code located od zero page starts here...
    40
    41 012C			zp_code_ldr
    42 012C					org	r:$a0				; address of zero-page code location
    43 00A0			zp_code_str
    44
    45 012C-017F> 00 00		val		dta	a(0)				; used to caltulate sine LUT
    46 00A2 00 00		dlt		dta	a(0)				; sine LUT delata
    47 00A4 01 00		xad		dta	a(1)				; sine LUT increment
    48
    49 00A6 4F 00 00 01 A6 00	dl		dta	$4f,a(line+0),$01,a(dl)		; display list
    50
    51 00AC A0 F0		loop		ldy	#240				; # of lines to process
    52
    53 00AE A9 00		adc0		lda	#0				; starting val. of 1st component
    54 00B0 85 B7				sta	sm0+1				; store directly in code body
    55 00B2 A9 00		adc1		lda	#0				; starting val. of 2st component
    56 00B4 85 BA				sta	sm1+1				; store directly in code body
    57
    58 00B6			kf_loop							; kefrens bars drawin loop
    59 00B6 AD 00 06		sm0		lda	sine				; get 1st sine value
    60 00B9 6D 80 06		sm1		adc	sine+$80			; add 2nd sine value
    61 00BC 4A					lsr	@				; /2
    62 00BD AA					tax					; move to X reg. (line buffer index)
    63
    64 				; the "shaded-plot" routine
    65
    66 00BE 18					clc					; clear carry
    67 00BF A9 11				lda	#$11				; value added to pixel/line buffer (add +1 to both nibbles)
    68 00C1 75 03				adc	line+3,x			; add current value in pixel/line buffer
    69 00C3 90 02				bcc	*+4				; check for overflow
    70 00C5 A9 FF				lda	#$ff				; when overflow then set max. luminance/saturation
    71
    72 00C7 95 03				sta	line+3,x			; store in pixel/line buffer
    73
    74 00C9 E6 B7				inc	sm0+1				; inc. index of 1st sine component
    75 00CB E6 B7				inc	sm0+1
    76 00CD E6 BA				inc	sm1+1				; inc. index of 2nd sine component
    77
    78 00CF 8D 0A D4				sta	$d40a				; halt CPU till end of scanline!
    79 00D2 88					dey					; decr. loop counter (lines to process)
    80 00D3 D0 E1				bne	kf_loop				; all done?
    81
    82 00D5 E6 B3				inc	adc1+1				; inc. 1st starting value
    83 00D7 C6 AF				dec	adc0+1				; dec. 2nd starting value
    84 00D9 C6 AF				dec	adc0+1				; repeat for 2nd component (-2)
    85
    86 00DB AE 0B D4		go		ldx	$d40b				; wait for scanline #0
    87 00DE D0 FB				bne	*-3
    88 00E0 8E 03 D4				stx	$d403				; set Hi-byte of DLIST pointer
    89 00E3 A9 A6		xor		lda	#<dl
    90 00E5 8D 02 D4				sta	$d402				; set Lo-byte od DLIST pointer
    91 00E8 49 03				eor	#$03				; emulate interlac mode (even/odd lines switch)
    92 00EA 85 E4				sta	xor+1				; store modif. value
    93
    94 00EC 8A					txa					; clear A reg.
    95 00ED 95 00		c0		sta	line,x				; clear pixel/line buffer
    96 00EF E8					inx					; next byte in pixel/line buffer
    97 00F0 10 FB				bpl	c0				; repeat until X is <128 (of coz we can clear only 1st 40 bytes
    98 											; ...this loop construcion shortens the code
    99
   100 00F2 30 B8				bmi	loop				; always jump to main loop
   101 00F4			zp_code_end
