mads 2.1.6 build 66 (7 Jun 23)
Source: D:\!Delphi\mads\examples\demoscene\256B\kefrens\kefrens_final.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-012E> A0 00	init		ldy	#$00
     9 						;tay					; when calling from TBXL we have #0 in A reg.
    10
    11 				; move code to zero page
    12
    13 0102 A2 51				ldx	#zp_code_end-zp_code_str	; size of moved code to X reg.
    14 0104 8E 6F 02				stx	$26f				; switch GTIA to 16-shades mode
    15 0107 BD 2F 01		zp_mv		lda	zp_code_ldr,x			; copy from source...
    16 010A 95 AB				sta	zp_code_str,x			; ...to destination
    17 010C CA					dex					; decr. loop counter
    18 010D 10 F8				bpl	zp_mv				; all done?
    19
    20 010F 20 E9 00		make_dl		jsr	put_line
    21 0112 C8					iny
    22 0113 D0 FA				bne	make_dl
    23
    24 				; calculate sine table
    25
    26 0115 A2 FC		s0		ldx	#-4				; use negative index for loop counter opt.
    27 0117 B5 AD		s1		lda	val+4,x			; first add delta to val, then add xad to delta
    28 0119 75 AF				adc	val+6,x
    29 011B 95 AD				sta	val+4,x
    30 011D E8					inx					; inc. reg counter
    31 011E D0 F7				bne	s1				; done when X reg. is zero
    32
    33 0120 A5 AA				lda	val+1				; store calculated val (hi-byte) to sine LUT
    34 0122 99 00 06				sta	sine,y
    35 0125 49 1F				eor	#$1f				; negate
    36 0127 99 80 06				sta	sine+$80,y			; fill-up the 2nd half of fine table
    37 012A C8					iny				; next step
    38 012B 10 E8				bpl	s0				; all bytes done?
    39 012D 30 AD				bmi	go				; jump to main code ;)
    40
    41
    42 				; code located od zero page starts here...
    43
    44 = 00A9			val		equ	$a9				; used to caltulate sine LUT
    45
    46 012F			zp_code_ldr
    47 012F					org	r:$ab				; address of zero-page code location
    48 00AB			zp_code_str
    49
    50 012F-017F> 00 00		dlt		dta	a(0)
    51 00AD 01 00		xad		dta	a(1)				; sine LUT increment
    52
    53 00AF			loop		;ldy	#240				; # of lines to process
    54
    55 00AF A9 00		adc0		lda	#0				; starting val. of 1st component
    56 00B1 85 B8				sta	sm0+1				; store directly in code body
    57 00B3 A9 20		adc1		lda	#$20				; starting val. of 2st component
    58 00B5 85 BB				sta	sm1+1				; store directly in code body
    59
    60 00B7			kf_loop							; kefrens bars drawin loop
    61 00B7 AD 00 06		sm0		lda	sine				; get 1st sine value
    62 00BA 6D 00 06		sm1		adc	sine				; add 2nd sine value
    63 00BD 4A					lsr	@				; /2
    64 00BE AA					tax					; move to X reg. (line buffer index)
    65
    66 				; the "shaded-plot" routine
    67
    68 00BF 18					clc					; clear carry
    69 00C0 A9 11				lda	#$11				; value added to pixel/line buffer (add +1 to both nibbles)
    70 00C2 75 03				adc	line+3,x			; add current value in pixel/line buffer
    71 00C4 90 02				bcc	*+4				; check for overflow
    72 00C6 A9 FF				lda	#$ff				; when overflow then set max. luminance/saturation
    73
    74 00C8 95 03				sta	line+3,x			; store in pixel/line buffer
    75
    76 00CA E6 B8				inc	sm0+1				; inc. index of 1st sine component
    77 00CC E6 B8				inc	sm0+1
    78 00CE E6 BB				inc	sm1+1				; inc. index of 2nd sine component
    79
    80 00D0 FE 00 D5				inc	$d500,x
    81 				;		sta	$d40a				; halt CPU till end of scanline!
    82 00D3 88					dey					; decr. loop counter (lines to process)
    83 00D4 D0 E1				bne	kf_loop				; all done?
    84
    85 00D6 E6 B4				inc	adc1+1				; inc. 1st starting value
    86 00D8 C6 B0				dec	adc0+1				; dec. 2nd starting value
    87 00DA C6 B0				dec	adc0+1				; repeat for 2nd component (-2)
    88
    89 00DC AE 0B D4		go		ldx	$d40b				; wait for scanline #0
    90 00DF D0 FB				bne	*-3
    91
    92 00E1 8A					txa					; clear A reg.
    93 00E2 95 00		c0		sta	line,x			; clear pixel/line buffer
    94 00E4 E8					inx					; next byte in pixel/line buffer
    95 00E5 10 FB				bpl	c0				; repeat until X is <128 (of coz we can clear only 1st 40 bytes
    96 											; ...this loop construcion shortens the code
    97
    98 00E7 30 C6				bmi	loop				; always jump to main loop
    99
   100 00E9 A9 4F		put_line	lda	#$4f
   101 00EB 20 F3 00				jsr	put_dl
   102 00EE A9 00				lda	#$00
   103 00F0 20 F3 00				jsr	put_dl
   104 00F3 9D 21 BB		put_dl		sta	$bc20-$ff,x
   105 00F6 E8					inx
   106 00F7 D0 02				bne	*+4
   107 00F9 E6 F5				inc	put_dl+2
   108 00FB 60					rts
   109
   110 00FC			zp_code_end
