*TEST CASE FOR MODIFYING DLIST 8 WAY SCROLLING
	ORG	$4000
SCREEN	EQU	$5000
NDLIST	EQU	$4900
DLIST	DB	$70,$70,$70,$47,$00,$50,$47,$80,$50
	DB	$47,$00,$51,$47,$80,$51,$47,$00,$52
	DB	$47,$80,$52,$47,$00,$53,$47,$80,$53
	DB	$47,$00,$54,$47,$80,$54,$47,$00,$48
	DB	$47,$80,$48,$41,$00,$49
*VARIABLES
XS	DS	1
YS	DS	1
SCLO	DS	1
SCHI	DS	1
TEMPH	DS	1
*MAIN PROGRAM
START	LDA	#$05		;TEST VALUES - INPUT YOUR OWN XS,YS
	STA	XS
	LDA	#$03
	STA	YS
*MOVE DLIST
	LDX	#$00
DLOOP	LDA	DLIST,X
	STA	NDLIST,X
	INX
	CPX	#$2A		;44 ELEMENTS
	BNE	DLOOP
	JSR	MODLIST		;MODIFY DISPLAY LIST
FOREVER	JMP	FOREVER		;ENDLESS LOOP
*
*SUBROUTINE TO MODIFY DISPLAY LIST FOR 8 WAY SCROLLING
* - 128 (#$80) BYTES WIDE
*INPUT ROUGH SCROLL COORDINATES XS,YS
MODLIST	LDA	#>SCREEN
	STA	SCLO
	LDA	#<SCREEN
	STA	SCHI
	LDA	YS
	LSR			;DIVIDE/2
	STA 	TEMPH
	BCC	AA1		;SKIP IF EVEN
	LDA	#$80		;ODD THEN LO BYTE ADDRESS BEGINS WITH #$80
	STA	SCLO
AA1	CLC
	LDA	SCHI
	ADC	TEMPH
	STA	SCHI		;NEW HI BYTE
	STA	NDLIST+5
	CLC
	LDA	SCLO
	ADC	XS
	STA	SCLO		;NEW LO BYTE
	STA	NDLIST+4
	LDY	#$00
AA2	CLC
	LDA	SCLO		;ADD #$80 TO EACH MODE LINE ADDRESS
	ADC	#$80		;STARTING WITH SECOND LINE
	STA	SCLO
	STA	NDLIST+7,Y
	LDA	SCHI
	ADC	#$00
	STA	SCHI
	STA	NDLIST+8,Y
	INY			;INCREMENT BY 3 TO REACH NEXT ADDRESS PAIR
	INY
	INY
	CPY	#$21		;(12ROWS*3)-3
	BL	AA2		;DONE?
	RTS
