;---------------------- SHIFTING
DISTORT
	LD	A,#FF
FZA	EQU $-1
	INC	A
	AND	15
	LD	(FZA),A
	JP	NZ,NOSHIFT
	LD	A,12
	LD	(FZSHIFT),A
NOSHIFT
	LD	A,0
FZSHIFT EQU $-1
	SUB	1
	ADC	A,0
	LD	(FZSHIFT),A
	ADD	A,A
	LD	C,A
	LD	A,128
	SUB	C
	LD	(MTBL_STEP_1),A
	ADD	A,C
	ADD	A,C
	LD	(MTBL_STEP_2),A
	LD	HL,MAPTBL
	LD	A,C
	RRA
	AND	%00111110
	LD	C,A
	LD	B,0
	ADD	HL,BC
	LD	(SWAPMAPTBL),HL
	RET
	
	
DISTORT
	LD	A,1
FZA	EQU $-1
	INC	A
	AND	31
	LD	(FZA),A
	JP	NZ,NOSHIFT
	LD	A,18
	LD	(FZSHIFT),A
NOSHIFT
	LD	A,18
FZSHIFT EQU $-1
	SUB	1
	ADC	A,0
	LD	(FZSHIFT),A
	;--
	ADD	A,A
	LD	C,A
	LD	B,0
	LD	HL,DISTBL_UD
	ADD	HL,BC
	LD	C,(HL)
	INC	HL
	LD	B,(HL)
	LD	HL,MAPTBL
	ADD	HL,BC
	LD	(SWAPMAPTBL),HL
	RET
DISTBL_UD
	DW	0
	DW	-128*1
	DW	128*1
	DW	-128*1
	DW	128*1
	DW	-128*1

	DW	128*2
	DW	-128*2	
	DW	128*2
	DW	-128*2
	DW	128*2
	DW	-128*2
	DW	128*2
	DW	-128*2	
	
	DW	128*3
	DW	-128*3
	DW	128*3
	DW	-128*3	
	
	
	
	
shift v 4
DISTORT
	LD	A,2
FZA	EQU $-1
	INC	A
	AND	15
	LD	(FZA),A
	JP	NZ,NOSHIFT
	LD	A,8
	LD	(FZSHIFT),A
NOSHIFT
	LD	A,8
FZSHIFT EQU $-1
	SUB	1
	ADC	A,0
	LD	(FZSHIFT),A
	ADD	A,A
	LD	C,A
	LD	B,0
	LD	HL,MAPTBL
	ADD	HL,BC
	LD	(SWAPMAPTBL),HL
	ADD	A,A
	LD	C,A
	
	
	
	LD	A,128
	SUB	C
	LD	(MTBL_STEP_1),A
	ADD	A,C
	ADD	A,C
	LD	(MTBL_STEP_2),A

	RET
	
	
shift v3
DISTORT
	LD	A,2
FZA	EQU $-1
	INC	A
	AND	15
	LD	(FZA),A
	JP	NZ,NOSHIFT
	LD	A,6
	LD	(FZSHIFT),A
NOSHIFT
	LD	A,6
FZSHIFT EQU $-1
	SUB	1
	ADC	A,0
	LD	(FZSHIFT),A
	ADD	A,A
	LD	C,A
	LD	A,128
	SUB	C
	LD	(MTBL_STEP_1),A
	ADD	A,C
	ADD	A,C
	LD	(MTBL_STEP_2),A
	LD	HL,MAPTBL
	LD	A,C
	RRA
	AND	%00111110
	LD	C,A
	LD	B,0
	ADD	HL,BC
	LD	(SWAPMAPTBL),HL
	RET
	
	
//======================================================== FX_INCLUDE_DATA
DISTORT
	LD	A,0
BORDER_NEXT EQU $-1
	LD	(BORDER),A


	LD	A,1
FZA	EQU $-1
	INC	A
	AND	31
	LD	(FZA),A
	JP	NZ,NOSHIFT
	LD	A,2
	LD	(AAA),A
NOSHIFT ;--
	LD	A,0
AAA	EQU	$-1
	SUB	1
	ADC	A,0
	LD	(AAA),A
	;--
	LD	BC,PALETTE + 0
	JR	Z,NOS
	LD	BC,PALETTE2 + 1
NOS	LD	A,B
	LD	(PALADR),A
	LD	A,C
	LD	(BORDER_NEXT),A
	RET