;******************************************************************************
;
;   Name:	rs1vwf.658
;
;   Group:	Translation
;
;   Revision:	1.04
;
;   Date:	28/12/4 
;
;   Author:	Frank Hughes [fh512 'at' yahoo 'dot' co 'dot' uk]
;
;******************************************************************************
;
;  Module Functional Description:
;
;       This module contains Variable Width Font routines for
;       the Romancing Sa.Ga Translation.
;       It is written to support RS1's complex window setup - which can 
;       either of two windows, and can have different numbers of bitplanes,
;       positions, sizes and fonts.  
;       It was also written with the highest optimisation I could achieve (and the
;       65816 does allow high optimisation - TnkU Mr Mensch! :D ) to squeeze
;       best performance out of the 2.68Mhz CPU speed, and avoid lags which can cause 
;       user delays and crashes (as in the BLagoon real snes crash).
;       It decides on one of four tile states, based on the position of the tile
;       to be placed, which results in a faster operation; and will utilise hardware
;       Multiplication Registers to perform shifts of bitrow data.
;		
;******************************************************************************

;
;  Changes:
;
;    DATE     REVISION				DESCRIPTION
;  --------   --------	-------------------------------------------------------
;  28/12/4      1.04    Now working in game. Added conditional inlining to code.
;                       More support for text events.
;  23/09/4      1.01    Major revamp to support window buffering.
;  20/03/4     	1.00	Original
;
;******************************************************************************

;
;  INCLUDE Files.
;

;
;  PUBLIC Declarations
;

;
;  EXTERN Declarations
;

; EQUATES
__VWF_INLINE	EQU	1				; Inline Enable = 1.


;******************************************************************************
;
;  Routine Functional Description
;	Map Adjustments
;       
;
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
Rs1eMap_nop	PROC	Near,MX:%10,D:RS1E_DPAGE
	rts
	ENDP	Rs1eMap_nop	

Rs1eMap_Add	PROC	Near,MX:%10,D:RS1E_DPAGE
; --- Map Number.
	php
	rep	#$31
	phy					; Preserve Y Index.
; --- Generate Index for Map.
	lda	Rs1e.VWF.mapBuffIndx				; 
	adc	Rs1e.VWF.mapBuffBase		; This contains the base screen address.
	tay					; Pass to Y.
; --- Generate Map Data.
	lda	RS1_MAPATTRIB-1
	and	#$fc00				; Mask to leave attib byte in AH.
	ora	Rs1e.VWF.currTil		; Merge with current tile.
; --- Tile Type
	ldx	Rs1e.VWF.tilDimType		; Load X with Tile Dimension Type.
; --- Process Map based on the tile dimension.
	jsr	(fnTab_VMapDim,x)		; Call to add data to Map.
; --- Adjust to next tile in the buffer.
	lda	Rs1e.VWF.tilBuffIndx
	adc	Rs1e.VWF.WtileSz
	sta	Rs1e.VWF.tilBuffIndx
	ply					; Restore Y Index.
; ------
	plp
	rts					; Return.
	ENDP	Rs1eMap_Add	

fnTab_MPlace
; Merge.
	DW	Rs1eMap_nop		& $ffff
	DW	Rs1eMap_Add		& $ffff
	DW	Rs1eMap_nop		& $ffff
; Store.
	DW	Rs1eMap_nop		& $ffff
	DW	Rs1eMap_Add		& $ffff
	DW	Rs1eMap_nop		& $ffff
; Whitespace.
	DW	Rs1eMap_nop		& $ffff
	DW	Rs1eMap_Add		& $ffff
	DW	Rs1eMap_nop		& $ffff

fnTab_VMapDim	PROC	Near
	DW	fnMapDim_8_16		& $ffff	; 8*16 Tile (2-bitplane).
	DW	fnMapDim_8_16		& $ffff	; 8*16 Tile (4-bitplane).
	ENDP	fnTab_VMapDim	



fnMapDim_8_8	PROC	Near,MX:%00,D:RS1E_DPAGE
; Not sure about this - check the include file.
; 8*8 Tile Horz adjust.
;00a54e b9 07 16      LDA $1607,Y     	; Adjust W1HorzCharCount by 2.
;00a551 1a            INC      		; ...
;00a552 99 07 16      STA $1607,Y     	; ...

;00a569 b9 0f 16      LDA $160f,Y     	; Load YCount
;00a56c d9 06 16      CMP $1606,Y     	; Compare to YMax
;00a56f b0 05         BCS $a576     	; Branch over adjustment if greater than?!
;00a571 1a            INC      		; Adjust by 2.
;00a572 1a            INC      
;00a573 99 0f 16      STA $160f,Y     	; Update 
;00a576 b9 07 16      LDA $1607,Y     	; Load W1HorzCharCount.
; --- Update Map Buffer.
	inc	Rs1e.VWF.mapBuffIndx
	inc	Rs1e.VWF.mapBuffIndx

	tyx
	inc	Rs1e.VWF.currTil		; Increment to next tile number.
	sta	>MAPBUFF_BASE+RS1_MAP_R2,x	; Store in the Map Buffer.
; ---
	sep	#$10
	ldx	RS1_WINACTV			; Load Active Window setting.
	lda	>ActvW2Rs1WinTab,x		; Active Win to Rs1 Win Index.
	tax
	lda	$1607,x
	bra	@fmd_join
	ENDP	fnMapDim_8_8	

fnMapDim_8_16	PROC	Near,MX:%00,D:RS1E_DPAGE
; 16*16 Tile Horz adjust.
;00a544 b9 07 16      LDA $1607,Y     
;00a547 1a            INC      
;00a548 1a            INC      
;00a549 99 07 16      STA $1607,Y     
;00a555 d9 05 16      CMP $1605,Y     	; Compare to W1HorzCharMax
;00a558 90 1c         BCC $a576     	; Branch if less than.
;00a55a a9 00         LDA #$00     
;00a55c 99 07 16      STA $1607,Y     	; Zero W1HorzCharCount.
;00a55f b9 08 16      LDA $1608,Y     	; Load W1VertRowCount.
;00a562 1a            INC      		; Adjust by 2.
;00a563 1a            INC      
;00a564 29 3f         AND #$3f     	; Mask within 64 range.
;00a566 99 08 16      STA $1608,Y     	; Update W1VertRowCount.
; Not sure about this - check the include file.
;00a569 b9 0f 16      LDA $160f,Y     	; Load YCount
;00a56c d9 06 16      CMP $1606,Y     	; Compare to YMax
;00a56f b0 05         BCS $a576     	; Branch over adjustment if greater than?!
;00a571 1a            INC      		; Adjust by 2.
;00a572 1a            INC      
;00a573 99 0f 16      STA $160f,Y     	; Update 
;00a576 b9 07 16      LDA $1607,Y     	; Load W1HorzCharCount.
;00a579 60            RTS      		; Return.

; --- Update Map Buffer.
	inc	Rs1e.VWF.mapBuffIndx
	inc	Rs1e.VWF.mapBuffIndx

	tyx
	inc	Rs1e.VWF.currTil		; Increment to next tile number.
	inc	Rs1e.VWF.currTil		; Increment to next tile number.

	sta	>MAPBUFF_BASE+RS1_MAP_R1,x	; Store in the Map Buffer.
	inc	a				; Increment Map Number.
	sta	>MAPBUFF_BASE+RS1_MAP_R2,x	; Store in the Map Buffer.
;---

	sep	#$30
	ldx	RS1_WINACTV			; Load Active Window setting.
	lda	>ActvW2Rs1WinTab,x		; Active Win to Rs1 Win Index.
	tax
	lda	$1607,x				; Load W1HorzCharCount.
@fmd_join					; Join for other Map handling routines.
	inc	a				; ...
	sta	$1607,x				; Update W1HorzCharCount..
	cmp	$1605,x				; Compare to W1HorzCharMax
	bcc	@fmd8_16_1
	stz	$1607,x				; Zero W1HorzCharCount.

	beq	@fmd8_16_1

	lda	$1608,x				; Load W1VertRowCount.
	inc	a				; Adjust by 2.
	inc	a				; ...
	and	#$3f				; Mask within 64 range.
	sta	$1608,x
	lda	$160f,x
	cmp	$1606,x
	bcs	@fmd8_16_1
	inc	a
	inc	a
	sta	$160f,x
@fmd8_16_1
	lda	$1607,x				; Update W1VertRowCount.
	rep	#$31
	stz	Rs1e.VWF.indxTilR		; Flag that tile has been updated.
	rts					; Return.
	ENDP	fnMapDim_8_16	



;00a569 b9 0f 16      LDA $160f,Y     	; Load YCount
;00a56c d9 06 16      CMP $1606,Y     	; Compare to YMax
;00a56f b0 05         BCS $a576     	; Branch over adjustment if greater than?!
;00a571 1a            INC      		; Adjust by 2.
;00a572 1a            INC      
;00a573 99 0f 16      STA $160f,Y     	; Update 
;00a576 b9 07 16      LDA $1607,Y     	; Load W1HorzCharCount.

;******************************************************************************
;
;  Routine Functional Description
;
;       TransVWFRowOffsetMake()
;		Make Row Offset.
;               
;               
;
;       Registers on Entry:
;		A8	: Character number.
;              
;
;       Registers on Exit:
;		Status.M	: 8-bit.
;		Status.X	: 8-bit.
;
;               
;	DW		; Shift+Merge
;	DW		; Shift+Store
;	DW		; 
;
;******************************************************************************
TransVWFRowOffsetMake	PROC	Near,MX:%10,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
; --- Make Index to Character Width.
	sep	#$20
	pha
	rep	#$21
	and	#$00ff				; Mask off extraneous data.
	adc	Rs1e.VWF.chrLenTabPtr
	tax
; --- Make Tile Buffer Indexes.
	lda	Rs1e.VWF.tilBuffIndx
	sta	Rs1e.VWF.indxTilL
	adc	Rs1e.VWF.WtileSz
	sta	Rs1e.VWF.indxTilR
; --- Fetch Character Width.
	lda	RS1E_CHRLENTAB_BASE,x
	sep	#$30				; MX to 8-bit. (leave it here!! :p )
	sta	Rs1e.VWF.chrWidth
	lda	Rs1e.VWF.pixPos			; Load accum with Current Pixel Position.
	plx
	cpx	#$BB				; <--- WILL HAVE TO CHECK THIS.
	clc
	beq	@rom_wSpace
	ldx	#MERGE8_BASE			; MERGE Dual Tile status
	and	#%00000111			; Mask 0~7 pixel position within a tile.
	bne	@pPosNotZero
; --- Tile Offset is on edge of tile.
	ldx	#STORE8_BASE			; STORE Dual Tile status.
@pPosNotZero
; --- Work out width over tile.			; |<--------- Pixel Length for 16*16 Tile ------->|
	adc	Rs1e.VWF.chrWidth		; Combine with current tile length.
	eor	#$ff				; 1's Complement.
	adc	#16+1				; (2's Complement)  16-chrWidth-pixOffset 'k? =D
	cmp	#8				; check if it's crossed a tile width.
	bcc	@tilCrssOvr			; Branch tile crossover
; --- Within 8-pixel.
	beq	@til8_noShift
; --- Til8ShiftStore
	inx					; SHIFT_8 (code with post increment this).
; --- Tile Crosses the pixel offset: adjust row address.
@tilCrssOvr
	inx					; SHIFT_16 status.
;--- Generate Shift Value.
@til8_noShift
	phx					; Preserve 'Place Tile Type'.
	tax					; 	
	lda	vwf.widthShiftTab-1,x		; Fetch mplier to shift bitrow.
	sta	Rs1e.VWF.WidthShiftValue	; Store here.
	pla					; Restore 'Place Tile Type' to accum.
	asl	a				; Adjust for word access.
	tax					; Transfer back to X index.
	rts					; Return.
@rom_wSpace
	ldx	#WSPACE_BASE
	and	#%00000111
	bra	@pPosNotZero

vwf.widthShiftTab
	DB	%00000010		; Shift by 1
	DB	%00000100		; Shift by 2
	DB	%00001000		; Shift by 3
	DB	%00010000		; Shift by 4
	DB	%00100000		; Shift by 5
	DB	%01000000		; Shift by 6
	DB	%10000000		; Shift by 7
	DB	%00000000		; Dummy Data.
; Duplicate Table to help optimisation (referred when width >8 pixels).
	DB	%00000010		; Shift by 1
	DB	%00000100		; Shift by 2
	DB	%00001000		; Shift by 3
	DB	%00010000		; Shift by 4
	DB	%00100000		; Shift by 5
	DB	%01000000		; Shift by 6
	DB	%10000000		; Shift by 7

	ENDP	TransVWFRowOffsetMake

;******************************************************************************
;
;  Routine Functional Description
;
;       VWFResetPositions()
;		Reset VWF variables and Line Buffer.
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;		Status.M	: 16-bit
;		Status.X	: 16-bit
;		A16		: #$ffff
;               X16		: Modified
;		Y16		: Modified
;
;******************************************************************************
VWFResetPositions	PROC	Near,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA

	LongA	OFF
	lda	#00				; Load Accum with 0.
        sta	>Rs1e.VWF.tilBuff		; Clear the base of out Tile Buffer.
	stz	Rs1e.VWF.pixPos			; Reset Pixel Position.
	rep	#$30				; Index and Accum to 16-bit.
	stz	Rs1e.VWF.tilBuffIndx		; Reset Tile Buffer Index.
; --- Purge Current Row Size.
        ldx	#Rs1e.VWF.tilBuff&$FFFF		; Load X with low word of Source Address.
        ldy	#(Rs1e.VWF.tilBuff+1)&$FFFF	; Load Y with low word of Destination Address.
        lda	Rs1e.VWF.currRowSz		; Load Current Size of Row Buffer.
	dec	a				; Adjust by 1 for block move count.
	dec	a				; Discard initial purge address.
        mvn  	Rs1e.VWF.tilBuff,Rs1e.VWF.tilBuff	; Block Move Neg (note: no need to preserve DB).
; ---
	rts					; Return.
;@rp_noPurge
	rep	#$30
	rts
	ENDP	VWFResetPositions

;******************************************************************************
;
;  Routine Functional Description
;
;       VWFDisable()
;		Disable the Variable Width Font environment.
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
VWFDisable	PROC	Far,MX:%10,D:$1200
	pha
	stz	Rs1e.VWF.enabFlg
	pla
	rtl
	ENDP	VWFDisable

;******************************************************************************
;
;  Routine Functional Description
;
;       VWFEnable()
;		Enable the Variable Width Font environment.
;			bit7 = 1		:  VWF Tile xfr.
;			bit6 = 1		:  VWF Enab
;			bit0 = 0		:  Purge VWF Buff
;                       bit7 = 1 && bit bit0 =1 : Swap window parms.
;               
;               
;
;       Registers on Entry:
;		Status_C	: Defines whether VWF is enabled.
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
Rs1eVWF_Setup	PROC	Near,MX:%10,D:$1200
	bcc	@vwfe_1
	pha
	lda	#%11111110				; bit7:(VWF Til xfr)bit6:1 (VWF Enab). bit1:0 (Purge VWF Buff)
	sta	Rs1e.VWF.enabFlg
	CALL	VWFInit
	pla
	rts
@vwfe_1	stz	Rs1e.VWF.enabFlg
	rts
	ENDP	VWFEnable

;******************************************************************************
;
;  Routine Functional Description
;
;       VWFInit()
;		Initialise the Variable Width Font environment.
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
VWFInit		PROC	Near,MX:%10
	PUSHA					; Preserve Assember Assumes.
	php					; Preserve Status Flags.
	rep	#$30				; Accum to 16-bit.
	pha					; Preserve A16.
	phx					; Preserve X16.
	phy					; Preserve Y16.
	phd					; Preserve Direct Page.
	phb					; Preserve Data Bank.
; ---
	pea	RS1E_DPAGE			; Push Trans' DPage onto stack.
	pld					; Pass to DP.
	ASSUME	D:RS1E_DPAGE
	pea	^RS1E_KERNELDATA<<8
	plb					; Discard.
	plb					; Pass to PB.
	ASSUME	DB:^RS1E_KERNELDATA
; ---
	stz	Rs1e.VWF.tilBuffIndx		; Reset Tile Buffer Index.
	sep	#$31				; Accum 8, and C:1 (no window swap).
	CALL	VWFBuildParms			; Build Window Parameters.
	CALL	Rs1eVWFInitActivWin		; Initialise
	CALL	VWFResetPositions		; Reset Variable Width Font Positions.
	plb					; Restore DB.
	pld					; Restore DP.
	ply					; Restore Y.
	plx					; Restore X.
	pla
	plp
	rts					; Return.
	POPA					; Restore Assembler Assumes.
	ENDP	VWFInit	


;-----------------------------------------------
bytesPerTile					; *** NUMBER OF BYTES IN A BITPLANE TILE ***
	DW	TILSZ_8_16_2BP
	DW	TILSZ_8_16_4BP
	DW	TILSZ_4BP			; 4-bitplane 8*8 tile.
;-----------------------------------------------
vTilAddrBase					; *** VRAM TILE BASE ADDRESSES FOR TYPES ***
	DW	RS1_VTIL_SPEECH_2BP_BASE	; 2-bitplane Tile Base.
	DW	RS1_VTIL_SPEECH_4BP_BASE	; 4-bitplane Tile Base.
;--------------------
vMapAddrBase					; *** VRAM MAP BASE ADDRESSES FOR TYPES ***
	DW	RS1_VMAP_SPEECH_2BP_BASE	; 2-bitplane Map Base.
	DW	RS1_VMAP_SPEECH_4BP_BASE	; 4-bitplane Map Base.
;-----------------------------------------------
; -- Use when rs1 window value wants to access rs1e window.
vwfWinIndxTab
	DB	0
	DB	RS1E_VWFWIN_STRUCTSZ

; -- Use when Window number wants to access rs1 window.
ActvW2Rs1WinTab
	DB	0
	DB	RS1_WIN_STRUCTSZ
;-----------------------------------------------
vwfBplaneIndxTab
	DB	0
	DB	2
;-----------------------------------------------

; -- Use when rs1e Index wants to access the same rs1 window.
WinIndxTab					; *** RS1 WINDOW STRUCTURE ACCESS ***
RS1E_VWFWIN_STRUCTSZ_OFFS = RS1E_VWFWIN_STRUCTSZ-2
	DW	0				; Window 1 index.
	DS	RS1E_VWFWIN_STRUCTSZ_OFFS	; **** Code optimsation fix to allow quick access.
	DW	RS1_WIN_STRUCTSZ		; Window 2 index.

; -- Use when rs1e Index wants to access rs1 alternative window.
WinAltIndxTab					; *** RS1 WINDOW ALTERNATIVE STRUCTURE ACCESS ***
	DW	RS1_WIN_STRUCTSZ		; Window 1 index.
	DS	RS1E_VWFWIN_STRUCTSZ_OFFS		; **** Code optimsation fix to allow quick access.
	DW	0				; Window 2 index.

; -- Use when rs1 Index wants to access rs1e alternative window.
Rs1WinIndx2AltRs1eWinIndx
	DW	RS1E_VWFWIN_STRUCTSZ		; Rs1e Window 2 index.
	DS	RS1_WIN_STRUCTSZ-2		; **** Code optimsation fix to allow quick access.
	DW	0				; Rs1e Window 1 index.

;-----------------------------------------------
VramMapBuffBase
	DW	$0B48
	DS	RS1E_VWFWIN_STRUCTSZ-2
	DW	$1B48
;-----------------------------------------------
vwfChrLenTab
	DW	(ChrLenTab_Dlog-$80) & $FFFF			; Dialogue Font.
	DW	(ChrLenTab_Mnu-$80) & $FFFF			; Menu Font
;-----------------------------------------------
FnTab_Rs1eVWFLineUpdate
	DW	Rs1eVWFLineUpdate_Dlogue & $ffff
	DW	Rs1eVWFLineUpdate_Menu	& $ffff
;-----------------------------------------------
tileBase
	DW	ChrSet_Dlog & $ffff	; Debug until I get a 8*8 2bitplane setting.
	DW	ChrSet_Mnu  & $ffff

Fn_TabRs1eVWFAlign
	DW	Fn_TabRs1eVWFAlign_Dlogue	& $ffff			; Dialogue
	DW	Fn_TabRs1eVWFAlign_Menu		& $ffff			; Menu

;-----------------------------------------------
ChrSet_Dlog
	INCBIN	"rs1vwf16.dat"
ChrSet_Mnu
	INCBIN	"rs1prch.set"
;-----------------------------------------------
ChrLenTab_Dlog				; *** DEBUG ***
	INCBIN	"widthout.bin"
ChrLenTab_Mnu				; *** DEBUG ***
	INCBIN	"rs1prch.wid"
;-----------------------------------------------

;******************************************************************************
;
;  Routine Functional Description
;
;       Tile Adjustments.
;
;               
;        There's four types of Tile Place: 
;        1: shift+merge+store - Tile is moved in position, merged with existing data, stored.
;        2: merge+store       - Tile is already in correct pos, merged with exist' dat, store.
;        3: shift+store.      - Tile is shifted to the start of a fresh block, stored.
;        4: store             - Tile is in 'Fixed-Width-Font' mode.
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
fnTab_TPlace	PROC	Near
;MERGE
;SHIFT_MERGE16
;SHIFT_MERGE8

;STORE
;SHIFT_STORE16
;SHIFT_STORE8
; Merge
	DW	TPlaceMerge8		& $ffff		; Tile is not left-aligned, but in 8-bit width.
	DW	TPlaceShiftMerge16	& $ffff		; Tile is not left-aligned, and lies between 2 tiles (16 pixels).
	DW	TPlaceShiftMerge8	& $ffff		; Tile is not left-aligned, but shifted within 8-bit width.
; Store
	DW	TPlaceStore8		& $ffff		; Tile is left-aligned and source tile is on the leftmost side.
	DW	TPlaceStore16		& $ffff		; (not used on 8*8 or 8*16 implementation).
	DW	TPlaceShiftStore8	& $ffff		; Tile is left-aligned and shifted within 8-bit width.
; Whitespace
	DW	TPlaceWSpace8		& $ffff		; Null routine.
	DW	TPlaceWSpace16		& $ffff		; Null routine.
	DW	TPlaceWSpaceShift8	& $ffff		; Null routine.

	ENDP	fnTab_TPlace


Rs1eAddChr2Map	PROC	Near,MX:%10,D:RS1_DPAGE
	PUSHA
; --- Preserve Y.
	phy
; --- Setup Data Bank.
	php
	phb					; Preserve Data Bank.
	pea	^RS1E_KERNELDATA<<8		; Push Bank of Trans' data onto stack.
	plb					; Discard.
	plb					; Pass to PB.
	ASSUME	DB:^RS1E_KERNELDATA
; --- Setup Direct Page.
	phd					; Preserve current Direct Page.
	pea	RS1E_DPAGE			; Push Translation DPage loc' onto stack.
	pld					; Pass it to DP.
	ASSUME	D:RS1E_DPAGE
	stx	Rs1e.VWF.mapBuffIndx		; Store the map Buffer Index.
	pha					; Preserve Character onto stack.
   	CALL	TransVWFRowOffsetMake		; Generate offsets into VWF Row Data.	
	LongI	ON
	pla
	sbc	#$80-1				; -1, because carry is clear.
	sta	WRMPYA				; Store it in multiplier.
	lda	Rs1e.VWF.WtileSz		; Fetch size of a single Tile for this window.
	sta	WRMPYB				; Store as multiplicand.
	sta	Rs1e.VWF.rowCount		; Store as bitrow counter.
	stz	Rs1e.VWF.rowCount+1		; Clear top byte of rowCount.
; --- Setup Shift value in multiplier (this will not corrupt the current Product).
	lda	Rs1e.VWF.widthShiftValue	; Load Shift Value.
	sta	WRMPYA				; Store in Multiplier.
	rep	#$31
	lda	Rs1e.VWF.tilSrcBase		; Base Address of Tile.
	adc	RDMPYL				; Add offset
	phx
	jsr	(fnTab_TPlace,x)		; Call Table subroutine for Tile Placing.
	plx
@ac_wspace
	jsr	(fnTab_MPlace,x)		; Call Table subroutine for Map Placing.
	CALL	Rs1eAdjustPixPos		
	pld					; Restore direct page.
	plb					; Restore Data Bank.
	plp
	ply					; Restore Y.
	rts					; Return.
	POPA
	ENDP	Rs1eAddChr2Map

;******************************************************************************
;
;  Routine Functional Description
;
;       Rs1eProcChar()
;
;          This subroutine decides which way to process the char, depending on the 
;          VWF enable state and the range of the character.
;
;               
;               
;
;       Registers on Entry:
;		A8		:character.
;		X16		: Map Buffer Index.
;              	Status_M	: 8-bit.
;		Status_X	: 16-bit.
;		DPage		: Unknown
;
;       Registers on Exit:
;		Status.M	; 16-bit
;		Status.X	; 16-bit.

;               
; Add 8*8 to Map.
;******************************************************************************
Rs1eProcChar	PROC	Far,MX:%00,D:RS1_DPAGE
	bit	Rs1e.VWF.enabFlg-1		; Check if the VWF is enabled.
	bvc	@pc_nvwfArea			; Branch if a non-vwf area.
	sep	#$20
	
	stx	Rs1e.VWF.mapBuffIndx		; Store Map Buffer Index.
	cmp	#RS1E_CHRRANGE_NONVWF		; Check if in our range of non-vwf chars.
	bcc	@pc_nvwfChar			; Branch if a non vwf character.
; --- VWF Char.
	plx					; Discard X from rs1 code.
	cmp	#$ff
	bne	@he_2
	lda	#$bb
@he_2

	CALL	Rs1eAddChr2Map			; VWF char: add
	rep	#$10
	sep	#$20
	jml	$00A579				; Hook back into rs1 code.
; --- Non-VWF Char.
@pc_nvwfChar					; Carry clear on branch.
; ****************** QUESTION:  HOW TO I UPDATE A PIXEL OFFSET FROM THIS??
; *** MAYBE ADD A DEFAULT 8 PIXELS TO PIXPOS HERE??
; *** ALSO, FOR REALIGNMAPNUM, IF SHIFTED - DO I INCREASE THE RS1'S MAP NUMBER?? (I guess at 'yes').

	pha
	phd
	pea	RS1E_DPAGE
	pld
	PUSHA
	ASSUME D:RS1E_DPAGE
	CALL	Rs1eAlignMapNum 
	pld
	pla
	POPA
	rep	#$20				; **** DEBUG ****
; --- Non-VWF Area.
@pc_nvwfArea
	LongA	ON
	and	#$00ff				; Overwritten Game code.
	asl	a				; ...
	jml	$00a4e0			; Return to Rs1's place char into Map code.
	ENDP	Rs1eProcChar

;******************************************************************************
;
;  Routine Functional Description
;
;       Pixel Position Adjustments
;
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
Rs1eAdjustPixPos	PROC	Near,D:RS1E_DPAGE
	sep	#$20
	clc
	lda	Rs1e.VWF.pixPos
	adc	Rs1e.VWF.chrWidth
; A 'charspace' addition operation can go in here.
	sta	Rs1e.VWF.pixPos
	rts
	ENDP	Rs1eAdjustPixPos

; ******************* I'VE GOTTA BE CAREFUL OF REGISTER PRESERVATION AND MX SIZINGS *********************
Rs1eAlignMapNum	PROC	Near,MX:%10,D:RS1E_DPAGE
	lda	Rs1e.VWF.pixPos		; Fetch pixel position.
	and	#$07			; Mask to leave 0~7 pixel area in tile.
	beq	@amn_NoAdj		; Branch if no adjustment needed.
; --- Realign pixel pos.
	eor	#$07
	sec				; '+1'
	adc	Rs1e.VWF.pixPos		; Add to pixel Position.
	sta	Rs1e.VWF.pixPos		; Update Pixel Position.
; --- Realign Current map number.
	CALL	Rs1eMap_Add		; Add Map data
@amn_NoAdj
	rts				; Return.
	ENDP	Rs1eAlignMapNum

Rs1eVWFUpdateTileLine	PROC	Far,MX:%10
	ldx	$16c9				; Game Code
	stx	$2116				; Game Code.
; --- Check if VWF Enabled.
	lda	Rs1e.VWF.enabFlg
	bit	Rs1e.VWF.enabFlg		; bit6 0: VWF on/off.  bit7=0:  VWF Line refresh (
	bvc	@noVWFEnab
; --- Check if Tile Xfer Flag enabled.
	bmi	@noTileXfr
; ****   WOAH, DEBUG THIS PART, AS I'VE CHANGED THE WHOLE WAY THIS WORKS! ****
	lda	Rs1e.VWF.enabFlg
	cmp	#$7f
	bne	@noTileXfr
	ldx	Rs1e.VWF.tilBuffIndx
	beq	@emptyBuffer
; ****************************************************************************
	lda	#$80
	sta	$420b
; --- Setup VRAM Tile Position.
	ldx	Rs1e.VWF.currVTilPos
	stx	VMADDL
; --- Setup B-Addr and Parameters.
	ldx	#$1800+DMAPRM_2A
	stx	$4370
; --- Setup A-Addr.
	ldx	#Rs1e.VWF.tilBuff & $FFFF
	stx	$4372
	lda	#Rs1e.VWF.tilBuff >>16
	sta	$4374
; --- Setup Byte Xfer Count.
	ldx	Rs1e.VWF.currRowSz
	stx	$4375
@emptyBuffer
	rol	Rs1e.VWF.enabFlg		; Restore enable flag. 
@noVWFEnab
@noTileXfr
	rtl
	ENDP	Rs1eVWFUpdateTileLine


;******************************************************************************
;
;  Routine Functional Description
;
;       End of Window Adjustments.
;
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************


Rs1eVWFEV2e_Refresh	PROC	Far,D:$1200,DB:$00,MX:%10
	pea	$c5b8-1
	bra	rs1e_ev3cJoin
	ENDP	Rs1eVWFEV2e_Refresh




Rs1eVWF_HookEv3c	PROC	Far,MX:%10,D:RS1_DPAGE,DB:$00
	plx				; ** Game Code **	
	pea	$b994-1			; Return address.
	bra	rs1e_ev3cJoin
	ENDP	Rs1eVWF_HookEv3c


; --- TxtCmd $12 (Oneshot).
;00c634 fa            PLX      
;00c635 da            PHX      
;00c636 5a            PHY      
;00c637 20 34 a3      JSR $a334     	; VRAM Map Update
;00c63a ad 0f 12      LDA $120f     	; 
;00c63d d0 0c         BNE $c64b     
;00c63f b9 00 16      LDA $1600,Y     
;00c642 c9 01         CMP #$01     
;00c644 d0 05         BNE $c64b     
;00c646 a9 ff         LDA #$ff     
;00c648 99 00 16      STA $1600,Y     
;00c64b 20 f1 dc      JSR $dcf1     	; 
;00c64e 7a            PLY      
;00c64f fa            PLX      
;00c650 b9 00 16      LDA $1600,Y     
;00c653 c9 ff         CMP #$ff     
;00c655 d0 0c         BNE $c663     
;00c657 a9 01         LDA #$01     
;00c659 99 00 16      STA $1600,Y     
;00c65c da            PHX      
;00c65d 5a            PHY      
;00c65e 20 40 9a      JSR $9a40     	; 
;00c661 7a            PLY      
;00c662 fa            PLX      
;00c663 4c d2 a0      JMP $a0d2     	; 
;	IF 0
Rs1eVWF_HookOneShot	PROC	Far,MX:%10,D:RS1_DPAGE,DB:$00
	phy					; Game Code.
	pea	$c63a-1				; Adjusted return address onto stack.
rs1e_ev3cJoin
	bit	Rs1e.VWF.enabFlg
	bpl	@os_1
	lda	Rs1e.VWF.pixPos
	beq	@os_1
	phd
	pea	RS1E_DPAGE
	pld
	phb
	pea	^RS1E_KERNELDATA<<8
	plb					; Discard.
	plb					; Pass to PB.
	ASSUME	DB:^RS1E_KERNELDATA
	phx
	ASSUME	D:RS1E_DPAGE
	LongA	OFF

	CALL	Rs1eMap_Add
	sep	#$20
	lsr	Rs1e.VWF.enabFlg		; Bit7:0 Denotes a tile Buffer send.
	stz	Rs1e.VWF.pixPos			; *** DEBUG ***
	plx
	plb
	pld
@os_1	jml	>$00a334			; Jump to game code.
	ENDP	Rs1eVWF_HookOneShot


;******************************************************************************
;
;  Routine Functional Description
;
;       End of Window Adjustments.
;
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
Rs1eVWF_HookEow	PROC	Far,MX:%10,D:RS1_DPAGE,DB:$00
	bit	Rs1e.VWF.enabFlg
	bpl	@he_1
	cpx	#$0000
	bne	@he_1
	lda	Rs1e.VWF.pixPos
	beq	@he_1
	phd
	pea	RS1E_DPAGE
	pld
	phb
	pea	^RS1E_KERNELDATA<<8
	plb					; Discard.
	plb					; Pass to PB.
	ASSUME	DB:^RS1E_KERNELDATA
	phx
	ASSUME	D:RS1E_DPAGE
	LongA	OFF

	ldx	Rs1e.VWF.tilDimType		; Load X with Tile Dimension Type.

	CALL	Rs1eMap_Add

	sep	#$20
	lsr	Rs1e.VWF.enabFlg		; Bit7:0 Denotes a tile Buffer send.
	plx
	plb
	pld
@he_1
	pea	$a0da-1				; Adjusted return address onto stack.
	jml	>$00a334			; Jump to game code.
	



;******************************************************************************
;
;  Routine Functional Description
;
;       Window Updates
;
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
Rs1eVWFEolUpdate	PROC	Far,D:$1200,MX:%10
	PUSHA
	phb					; Preserve current Data Bank.
	pea	^RS1E_KERNELDATA<<8		; Push Trans' bank onto stack.
	plb					; Discard.
	plb					; Pass to Data Bank.
	ASSUME	DB:^RS1E_KERNELDATA
	phd					; Preserve current Direct Page.
	pea	RS1E_DPAGE			; Push Trans' Direct Page onto stack.
	pld					; Pass to Direct Page.
	ASSUME D:RS1E_DPAGE
	phx					; Preserve X.
	phy					; Preserve Y.
	php
	ldx	Rs1e.VWF.tilBuffIndx		; Set ZFlag.
	sep	#$10
	bcs	@eu_1				; Branch if no window swap.

	CALL	VWFBuildParms
	CALL	Rs1eVWFInitActivWin
	sep	#$20
	CALL	VWFResetPositions		; Reset Variable Width Font Positions.
	bra	@eu_2

@eu_1
; --- Tile Type
	php
	ldx	Rs1e.VWF.tilDimType		; Load X with Tile Dimension Type.
	jsr	(FnTab_Rs1eVWFLineUpdate,x)
	plp
	beq	@eu_2
	CALL	VWFResetPositions		; Reset Variable Width Font Positions.
@eu_2
	plp
	ply
	plx
	pld
	plb
	rtl
	POPA
	ENDP	Rs1eVWFEolUpdate

Rs1eVWFLineUpdate_Dlogue	PROC Near,MX:%11,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
; --- Check for Window+Buffer wraparound.
; Tiles should be wrapped for full win length and y+1 size.
	ldx	Rs1e.VWF.winIndx
	inc	Rs1e.VWF.YBuffCounter			; <--- This may be moved outside of routine.
	lda	Rs1e.VWF.YBuffCounter
	cmp	Rs1e.VWF.Win.YRowTiles,x
	bcc	@lud_1
	tdc						; Speed hack for 'lda #$00'.
@lud_1	sta	Rs1e.VWF.YBuffCounter			; Reset YBuffer Counter.
; --- Generate VRAM Offset.
; ((TBuffSz/2)*(YBuffCounter)+VramBase.
	rep	#$20
	lda	Rs1e.VWF.Win.RowSz,x
	lsr	a
	sep	#$20
	sta	M7A
	xba
	sta	M7A
	lda	Rs1e.VWF.YBuffCounter
	sta	M7B

	rep	#$21
	lda	Rs1e.VWF.Win.VTilPos,x
	adc	MPYL
	sta	Rs1e.VWF.currVTilPos
; --- Generate Tile Offset.
; --- (XLen*YBuffCounter)+TNumBase
	sep	#$20
	lda	Rs1e.VWF.YBuffCounter
lud_align_hook1
; I need to keep this here with so many rep/seps, due to this hookup.
	sta	WRMPYA
	lda	Rs1e.VWF.Win.xTiles,x		; 
	asl	a
	sta	WRMPYB

	rep	#$20				; [3 cycs]
	lda	Rs1e.VWF.Win.TilNumBase,x	; [5 cycs]
	adc	RDMPYL				; [3 decode cycs]
	sta	Rs1e.VWF.currTil
	sep	#$20				; Accum back to 8-bit.
	rts

Fn_TabRs1eVWFAlign_Dlogue
	ldx	Rs1e.VWF.winIndx
	lda	$1608,y
	lsr	a
	jsr	lud_align_hook1
	lda	Rs1e.VWF.WtileSz
	sta	WRMPYA
	lda	$3,s
	sta	WRMPYB
;--
	rep	#$21
	and	#$00ff
	asl	a
	adc	Rs1e.VWF.currTil
	sta	Rs1e.VWF.currTil
	lda	RDMPYL
	sta	Rs1e.VWF.TilBuffIndx
	sep	#$20
	rts

Fn_TabRs1eVWFAlign_Menu
	rts
	ENDP	Rs1eVWFLineUpdate_2bp

Rs1eVWFLineUpdate_Menu	PROC Near,MX:%11,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
	rep	#$21
	lda	Rs1e.VWF.tilBuffIndx	; Load accumulator with Tile Buffer Index.
	beq	@lum_1			; Branch if no Tiles where added.
; --- Calculate new tile number.
	lsr	a			; Divide Tile Buffer Index by 2 for VRAM addressing. (2Cycs)
	adc	Rs1e.VWF.currVTilPos	; Add to current VRAM Tile Position. (4Cycs)
	sta	Rs1e.VWF.currVTilPos	; Update current VRAM Tile Position. (4Cycs)
@lum_1	sep	#$20
	rts
	ENDP	Rs1eVWFLineUpdate_Menu
	

Rs1eVRAMMapUpdate2
	sec
	bra	@rs1eVRAMMapUpdate2_link

Rs1eVRAMMapUpdate	PROC	Far,MX:%10,D:RS1_DPAGE
	pea	eh_3-1				; Return address in EOL Handler.
@rs1eVRAMMapUpdate2_link
	pha
	php
	bit	Rs1e.VWF.enabFlg		; Check bit6 (VWF Enab status).
	bpl	nlh_1				; Branch out if VWF is not enabled.
	rep	#$20				; darn.......
	lda	Rs1e.VWF.indxTilR		; Check if this has been zeroed by the tile placer.
	sep	#$20
	bne	nlh_e				; Branch if no (needs tile updating).
	lda	Rs1e.VWF.pixPos			; Check for possibility we have residual 16-bit tile.
	and	#$07				; check if it currently lies within a font.
	beq	nlh_1

nlh_e	phy					; Preserve Y.
	phd					; Preserve Direct Page.
	pea	RS1E_DPAGE			; Rs1e Direct Page.
	pld					; Pass to DP.
	phx					; Preserve X.
	ASSUME	D:RS1E_DPAGE			; Set Assembler assume for the direct page.
	CALL	Rs1eMap_Add			; Add character to map.
	sep	#$20				; Accum back to 8-bit.
	plx					; Restore X.
	pld					; Restore direct Page.
	ply
nlh_1	plp
	bcc	nlh_2				; branch if no window swap.
	pla
	jml	>$00c744			; Jump into Rs1 Subroutine.
nlh_2	pla
	sta	$2,s				; Heh! :P
	pla					; Discard return address.
	pla
	jml	>eh_4				; Return to game code.

	ENDP	Rs1eVRAMMapUpdate

;******************************************************************************
;
;  Routine Functional Description
;
;       Window Type Adjustments.
;
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
; TxtCmd $13 <
;00c666 fa            PLX      
;00c667 20 44 c7      JSR $c744     	; Window Manipulation.
;00c66a 20 34 a3      JSR $a334     	; VRAM Map UpdateUpdate VRAM map data.
;00c66d a9 01         LDA #$01     

;00c66f 85 8e         STA $8e     
;00c671 20 6b a1      JSR $a16b     	; Fetch Byte from Block Stream.
;00c674 85 82         STA $82     	; Store here.
;00c676 a5 8c         LDA $8c           ; Active Speech Window.
;00c678 da            PHX      
;00c679 20 6d 98      JSR $986d     	; Close Active Window
;00c67c fa            PLX      
;00c67d 4c d2 a0      JMP $a0d2     	; 
Rs1eVWF_WTypeHandler_Hook	PROC	Far,D:RS1_DPAGE,MX:%10
; --- Perform overwritten game code
	plx					; Game Code: Restore X.
; --- Check if VWF Enabled.
	bit	Rs1e.VWF.enabFlg		; Check if VWF Enabled.
	bvc	@wth_1				; Branch if no.
; --- Build Window Parameters.
	phb					; Preserve current Data Bank.
	pea	^RS1E_KERNELDATA<<8		; Push Trans' bank onto stack.
	plb					; Discard.
	plb					; Pass to Data Bank.
	phd					; Preserve current Direct Page.
	pea	RS1E_DPAGE			; Push Trans' Direct Page onto stack.
	pld					; Pass to Direct Page.
	phx					; Preserve X.
	phy					; Preserve Y.
	clc					; <--- see if this can be removed.
	ASSUME	D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
	CALL	VWFBuildParms			; Build Parameters for active window.
; --- Initialise Active Window.
	CALL	Rs1eVWFInitActivWin		; Refresh Active Window parameters.
	rep	#$10				; Index to 16-bit.
	ply					; Restore Y.
	plx					; Restore X.
	pld					; Restore Direct Page.
	plb					; Restore Data Bank.
; --- Return to game code
@wth_1	jml	>$00a0d2			; Jump back into Game Code.
	ENDP	Rs1eVWFWTypeHandler

;******************************************************************************
;
;  Routine Functional Description
;
;       VWFBuildParms()
;		Build Parameters for Variable Width Font.
;               
;               
;
;       Registers on Entry:
;	  Y:8		Window Select. (0=win1;1=win2) (assume 1 if there are 2
;                       active windows.
;         Status.C:     Window Select. (0=win1;1=win2)
;
;       Registers on Exit:
;	  Status.V:	Request for another window build (if matching types).
;	  Status.M:	8-bit.
;	  Status.X:	8-bit.
;               
;
;******************************************************************************
RS1E_MENU_TILNUM_BASE	EQU	64+1		; 64+1whitespace.
RS1E_SPEECH_TILNUM_BASE	EQU	1		; 1whitespace


VWFBuildParms	PROC	Near,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
	LongI	OFF
	phx					; Preserve X
	phy					; Preserve Y
	php					; Preserve Status Flags.
; --- Setup indexes to data.
	sep	#$30
	ldx	#0000				; Rs1e Win1 Structure access.
	lda	RS1_WINACTV
	beq	@bp_win1			; Branch if window 1.
	ldx	#RS1E_VWFWIN_STRUCTSZ		; Rs1e Win2 Structure access.
@bp_win1
	CALL	Rs1eVWFChkDualWinActv		; Check for dual window active.
	rep	#$10
	bne	@bp_dualWin			; Branch if dual window
	bmi	@bp_singleWin2Dlogue		; Branch if Window 2.
	bvc	@bp_singleWin1Dlogue		; Branch if not a menu.
; === Menu.
@bp_singleWinMenu
@bp_dualWinMenu
; ------ Set Tile Number Base.
	ldy	#RS1E_MENU_TILNUM_BASE
	sty	Rs1e.VWF.Win.TilNumBase,x
; ------ Set VRAMBase to $0400.
	ldy	#RS1_VTIL_SPEECH_4BP_BASE
; ------ Set TileType to 4-Bitplane.
	lda	#TILDIM_8_16_4BP
	bra	@bp_join

; === Dialogue
; ------ Single Win.
@bp_singleWin1Dlogue
@bp_singleWin2Dlogue
	ldy	#RS1E_SPEECH_TILNUM_BASE
	sty	Rs1e.VWF.Win.TilNumBase,x
; ------ Set VRAMBase.
	ldy	#RS1_VTIL_SPEECH_2BP_BASE
; ------ Set TileBase.
	bra	@bp_join_2bp	


; === Dual Window Active.
@bp_dualWin
	bvc	@bp_dualWinMenu			; Branch if a menu.
; --- Dual Win - 2Blane.
@bp_dualWinBPlane2
; ------ Calculate VRAMBase.
	CALL	Bp_CalcDualWinOffs		; Calculate Dual Window offsets.
; ------ Calculate TileBase.
@bp_join_2bp
; ------ Set TileType to 2-Bitplane.
	lda	#TILDIM_8_16_2BP
@bp_join
	sty	Rs1e.VWF.Win.VTilPos,x
	sta	Rs1e.VWF.Win.tilDimType,x
	stz	Rs1e.VWF.Win.tilDimType+1,x
	xba					; Temporarily preserve
	sep	#$10
	ldy	WinIndxTab,x			; Fetch RS1 Structure Index.
	lda	RS1.WIN.WIDTH,y			; Fetch the current window width.
; ------ Setup number of X Tiles.
	sta	Rs1e.VWF.Win.xTiles,x	; Store here.
; --- Generate Number of Tiles in Window.
	sta	WRMPYA
	lda	RS1.WIN.HEIGHT,y		; Fetch the current window height.
	lsr	a
	inc	a				; <<----- Buffer adjustment.
	sta	WRMPYB
; ------ Setup number of Y Tiles.
	sta	Rs1e.VWF.Win.YRowTiles,x	; 
;--- Placed here for Mult' latency.
	xba					; Restore BPlane access index back to accum.
	tay					; Transfer to Y.
;---
	lda	RDMPYL
; --- Setup Number of tiles in Active Window.
	sta	Rs1e.VWF.Win.NumTiles,x		; Store here.
	
; --- Generate the size of a Row of tiles in the Tile Buffer.
	lda	bytesPerTile,Y			; Fetch the number of bytes in a tile.
	sta	WRMPYA
	sta	Rs1e.VWF.Win.WtileSz,x		; Store here.
	stz	Rs1e.VWF.Win.WtileSz+1,x
	lda	Rs1e.VWF.Win.xTiles,x	; Store here.
	sta	WRMPYB
	rep	#$20				; Accum to 16-bit.
; --- Fetch Source Tile Base.
	lda	tileBase,y
	sta	Rs1e.VWF.Win.tilSrcBase,x
; --- Generate Bitplane Row Size.
	lda	RDMPYL				; Fetch 16-bit product (4/5cycles). (6cycs if long).
	sta	Rs1e.VWF.Win.RowSz,x		; Store in Window Row Size.
; --- Setup Current Row Size (also, so that we can initially purge to this size).
	sta	Rs1e.VWF.currRowSz		; Store here for initial RowBuff purge size.
; -- Setup Tile Base
	lda	Rs1e.VWF.Win.TilNumBase,x
	sta	Rs1e.VWF.currTil
; --- Character Width Pointer.
	lda	vwfChrLenTab,y
	sta	Rs1e.VWF.Win.chrLenTabPtr,x
; --- Exit.
	plp					; Restore Status Flags.
	ply					; Restore Y.
	plx					; Restore X.
	rts					; Return.
	ENDP	VWFBuildParms

Bp_CalcDualWinOffs	PROC	Near,MX:%10,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
; -- Generate VRAM Tile Offset.
	ldy	WinAltIndxTab,x
	lda	Rs1e.VWF.Win.RowSz,y
	sta	M7A
	lda	Rs1e.VWF.Win.RowSz+1,y
	sta	M7A
	lda	Rs1e.VWF.Win.YRowTiles,y
	sta	M7B
; -- Generate Map num offset.
	rep	#$21
	lda	Rs1e.VWF.Win.NumTiles,y
	and 	#$00ff
	asl	a
	adc	#$0001
	sta	Rs1e.VWF.Win.TilNumBase,x
; --- Fetch VRAM Tile Offset.
	lda	MPYL
	lsr	a

	adc	#RS1_VTIL_SPEECH_2BP_BASE
	tay
	sep	#$20
	rts
	ENDP	Bp_CalcDualWinOffs

Rs1eVWFChkDualWinActv	PROC	Near,MX:%11,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
	beq	@cdw_a
	lda	$1600
	bra	@cdw_a1
@cdw_a	lda	$120f
	bne	@cdw_singlWinMenu
@cdw_a1	lda	$1620
	beq	@cdw_singleWinDlogue
@cdw_Dual
	bcs	@cdw_dualWin2Dlogue
	cmp	#$10
	beq	@cdw_dualWinMenu
@cdw_dualWin2Dlogue				; Z already != 0.
	rep	#%00000011
	sep	#%01000000
	rts
@cdw_dualWinMenu
	rep	#%01000011
	rts
@cdw_singlWinMenu
	ror	a			; Carry Set N Flag (denotes Win1 or 2)
	sep	#%01000011		; Set Carry Z and overflow
	rts
@cdw_singleWinDlogue
	ror	a			; Carry Set N Flag (denotes Win1 or 2)
	bpl	@singleWin1Dlogue
	sep	#%10000011		; Set Carry Z and overflow
	rep	#%01000000
	rts
@singleWin1Dlogue
	sep	#%00000011
	rep	#%11000000
	rts
	ENDP	Rs1eVWFChkDualWinActv



; Dual Win Dlog		%0100 0000
; Dual Win Menu		%0000 0000
; Sing Win Menu		%0100 0011 
; Sing Win Dlog		%0000 0011 


;******************************************************************************
;
;  Routine Functional Description
;
;       Window Initialisations.
;
;               
;               
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
Rs1eVWFInitActivWin	PROC	Near,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA	
	php
	stz	Rs1e.VWF.YBuffCounter
; --- Setup Active Window.
	sep	#$10
	ldy	RS1_WINACTV			; Load Active Window setting.
	rep	#$20				; Accum 16-bit.
	stz	Rs1e.VWF.winIndx
	ldx	vwfWinIndxTab,y			; Active Win to Rs1e Win Index.
	stx	Rs1e.VWF.winIndx		; Store here.
; ** Character Length Table Pointer. **
	lda	Rs1e.VWF.Win.chrLenTabPtr,x	
	sta	Rs1e.VWF.chrLenTabPtr		; ...
; ** Tile Source Base **
	lda	Rs1e.VWF.Win.tilSrcBase,x	
	sta	Rs1e.VWF.tilSrcBase		; ...
; ** VRAM Tile Position. **
	lda	Rs1e.VWF.Win.VTilPos,x		; ...
	sta	Rs1e.VWF.currVTilPos
; ** Active Window Tiles Size **
	lda	Rs1e.VWF.Win.WtileSz,x		
	sta	Rs1e.VWF.WtileSz		; ...
; ** Map Buffer Base **
	lda	#$0b48
	sta	Rs1e.VWF.mapBuffBase		; ...
; ** Active Tile Dimension Type (16-bit width for optimisation) **
	lda	Rs1e.VWF.Win.tilDimType,x	
	sta	Rs1e.VWF.tilDimType		; ...

; --- Return.
	sep	#$20				; Accum 8-bit.
	plp
	rts					; Return.
	ENDP	Rs1e.VWF.InitActivWin


Rs1eVWFTileAlign_Hook	PROC	Far,MX:%10,D:RS1_DPAGE
	bit	Rs1e.VWF.enabFlg		; Check if variable width font
	bvc	@tah_1				; Branch if VWF is not enabled.
; --- Align font.
	phx					; Preserve X16.
	phy					; Preserve Y16.
	phd					; Preserve Direct Page.
	phb					; Preserve Data Bank.
; ---
	pea	RS1E_DPAGE			; Push Trans' DPage onto stack.
	pld					; Pass to DP.
	ASSUME	D:RS1E_DPAGE
	pea	^RS1E_KERNELDATA<<8
	plb					; Discard.
	plb					; Pass to PB.
	ASSUME	DB:^RS1E_KERNELDATA
	php
	pha					; Push tile offset on stack.
	CALL	Rs1eAlignMapNum
	sep	#$20
; --- Generate new Pixel Position.
	clc
	lda	$1,s				; Load tile offset into accum.	
	adc	$129a
	pha
	and	#$1f				; Mask to leave 0~31 range.
; ** Multiply by 8 to convert tile to pixel.
	asl	a				; Multiply by 8.
	asl	a				; ...
	asl	a				; ...
	pha					; Temporarily preserve on the stack.
; ** Extract Pixel bits into tile (bits 7~5).
	lda	$2,s				; Load tile offset back into accum.
	and	#$e0				; Mask to leave bits 7~5.
	lsr	a				; Shift to bit 0 position.
	lsr	a				; ...
	lsr	a				; ...
	lsr	a				; ...
	lsr	a				; ...
; ** Combine together.
	adc	$1,s				; Add to partial product.
	sta	Rs1e.VWF.pixPos			; Update Pixel Position.
	pla					; Discard Partial.
; --- Generate new Tile Number (this varies depending on the type of tile??).
; Menu: 	(no adjustment - it will sit directly on to next tile).
; Dlogue: 	(Align to base of line).
	ldx	Rs1e.VWF.tilDimType
	jsr	(Fn_TabRs1eVWFAlign,x)
; --- Restore Registers.
	pla					; Discard.
	pla
	plp
	plb
	pld
	ply
	plx
; -- Return game code.
	ASSUME	D:$1200
@tah_1	adc	$129a
	sta	$1607,y
	rtl
	ENDP	Rs1eVWFTileAlign_Hook


;------------------------------------
; TxtCmd $17
;00b9a9 fa            PLX      
;00b9aa 20 34 a3      JSR $a334     	; VRAM Map Update
;00b9ad a9 00         LDA #$00     
;00b9af 8d 72 16      STA $1672     	; 
;00b9b2 99 14 16      STA $1614,Y     
;00b9b5 20 7a ba      JSR $ba7a     	; Window manipulations.
;00b9b8 4c d2 a0      JMP $a0d2     	; 
Rs1eVWFTileVRfrsh_Hook	PROC	Far,MX:%10,D:RS1_DPAGE
	plx					; Perform Game Code.
	bit	Rs1e.VWF.enabFlg
	bpl	@vh_1
	lda	Rs1e.VWF.pixPos
	beq	@vh_1
	phd
	pea	RS1E_DPAGE
	pld
	phb
	pea	^RS1E_KERNELDATA<<8
	plb					; Discard.
	plb					; Pass to PB.
	ASSUME	DB:^RS1E_KERNELDATA
	phx
	ASSUME	D:RS1E_DPAGE
	LongA	OFF

	CALL	Rs1eMap_Add
	sep	#$20
	lsr	Rs1e.VWF.enabFlg		; Bit7:0 Denotes a tile Buffer send.
	plx
	plb
	pld
@vh_1
	pea	$b9ad-1				; Adjusted return address onto stack.
	jml	>$00a334			; Jump to game code.
	ENDP	Rs1eVWFTileVRfrsh_Hook


Rs1eVWFHlightChk	PROC	Far,MX:%10,D:$1200,DB:$00
	bit	Rs1e.VWF.enabFlg		; Check if Variable Width Font is enabled.
	bvc	@hlc_1				; Branch if 'no'.
; -- 8*8 VWF checks would go here if we have a 8*8 font.
	phy					; Preserve Y Index.
	ldy	Rs1e.VWF.tilDimType
	rep	#$21				; Accum to 16 bit and clear carry.
	txa					; Pass X to accum.
	adc	RS1E_VWF_MAPOFFSETTAB,y
	tax					; Update index.
	ply					; Restore Y Index.
	lda	$1,s
	adc	#$15-1				; Return offset for two identical routines.
	sta	$1,s				; Hee..  Elegant code! =D
	sep	#$20
@hlc_1	lda	>$7f0b48,x			; Load accum with top byte of Map Data.
	rtl					; Return.
	ENDP	Rs1eVWFHlightChk


Rs1eVWFHlightChk_2	PROC	Far,MX:%00,D:$1200,DB:$00
	bit	Rs1e.VWF.enabFlg-1		; Check if Variable Width Font is enabled.
	bvc	@hlc2_1				; Branch if 'no'.	
	phy					; Preserve Y Index.
	ldy	Rs1e.VWF.tilDimType
	lda	#$bde3-1
	sta	$3,s
	lda	>$7f0b48,x			; ** Game Code **
	and	#$03ff
	cmp	RS1E_VWF_NULLMAPVALTAB,y
	beq	@hlc2_2
	ply
	rep	#%00000010			; Set ZFlag = 0.
	rtl					; Return to game code.
@hlc2_2	ply
	sep	#%00000010			; Set ZFlag = 1.
	rtl					; Return to game code.
@hlc2_1	lda	>$7f0b48,x			; ** Game Code **
	rtl					; Return.
	ENDP	Rs1eVWFHlightChk_2



Rs1eVWFProcNullChar	PROC	Far,MX:%10,DB:$00,D:$1200
	lda	$1298
	sta	$1296
	pla					; Discard $ff from the stack.
	lda	$1607,y				; Load Current XTile.
	sbc	$129a
	inc	a				; Adjust to next tile.
	CALL	>Rs1eVWFTileAlign_Hook		; Call Tile alignment function.
	jml	$00a555				; Rejoin game code.
	ENDP	Rs1eVWFProcNullChar




;******************************************************************************
;
;  Routine Functional Description
;
;       Tile Adjustments.
;
;               
;        There's four types of Tile Place: 
;        1: shift+merge+store - Tile is moved in position, merged with existing data, stored.
;        2: merge+store       - Tile is already in correct pos, merged with exist' dat, store.
;        3: shift+store.      - Tile is shifted to the start of a fresh block, stored.
;        4: store             - Tile is in 'Fixed-Width-Font' mode.
;
;       Registers on Entry:
;
;              
;
;       Registers on Exit:
;
;               
;
;******************************************************************************
TPlaceStore16	PROC		Near,MX:%10,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
	rts
	ENDP	TPlaceStore16

TPlaceShiftMerge8	PROC	Near,MX:%10,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
   IF	__VWF_INLINE=0
	tay					; Pass Tile Source Address to Y
	sep	#$20				; Accum back to 8-bit.
	lsr	Rs1e.VWF.rowCount		; Divide rowcount by 2 (proc' two at a time).
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
@lp1
	lda	RS1E_TILSRC_BASE,y
	sta	WRMPYB
	inx
	lda	>Rs1e.VWF.tilBuff-1,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff-1,x		; Update Left-most Tile Data.
	lda	RS1E_TILSRC_BASE+1,y
	sta	WRMPYB
	inx
	lda	>Rs1e.VWF.tilBuff-1,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff-1,x		; Update Left-most Tile Data.	
	iny
	iny
	dec	Rs1e.VWF.rowCount		; Decrement out bitrow count.
	bne	@lp1				; Loop back if not done for all.
	rts					; Done for all: Return.
   ELSE
	
	PUSHA					; Push assume list.
	tax					; Pass Tile Source Addess to X.
	ldy	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	sep	#$20				; Accum to 8-bit.
	lda	Rs1e.VWF.tilDimType		; Load accum with tile dimension type.

	pea	$2070
	plb
	phd
	pea	$4200
	pld


	cmp	#$00
	bne	@sm8_4bp
	brl	@sm8_2bp
@sm8_4bp
; shift-merge8_4Bitplane:
	ASSUME	D:$4200,DB:$70
	lda	>RS1E_TILSRC_BASE+63,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+63,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+63,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+62,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+62,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+62,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+61,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+61,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+61,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+60,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+60,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+60,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+59,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+59,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+59,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+58,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+58,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+58,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+57,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+57,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+57,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+56,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+56,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+56,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+55,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+55,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+55,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+54,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+54,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+54,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+53,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+53,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+53,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+52,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+52,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+52,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+51,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+51,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+51,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+50,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+50,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+50,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+49,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+49,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+49,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+48,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+48,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+48,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+47,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+47,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+47,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+46,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+46,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+46,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+45,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+45,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+45,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+44,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+44,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+44,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+43,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+43,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+43,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+42,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+42,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+42,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+41,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+41,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+41,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+40,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+40,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+40,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+39,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+39,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+39,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+38,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+38,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+38,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+37,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+37,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+37,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+36,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+36,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+36,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+35,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+35,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+35,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+34,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+34,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+34,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+33,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+33,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+33,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+32,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+32,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+32,y		; Update Left-most Tile Data.
@sm8_2bp
	lda	>RS1E_TILSRC_BASE+31,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+31,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+31,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+30,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+30,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+30,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+29,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+29,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+29,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+28,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+28,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+28,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+27,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+27,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+27,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+26,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+26,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+26,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+25,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+25,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+25,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+24,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+24,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+24,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+23,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+23,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+23,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+22,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+22,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+22,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+21,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+21,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+21,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+20,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+20,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+20,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+19,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+19,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+19,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+18,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+18,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+18,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+17,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+17,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+17,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+16,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+16,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+16,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+15,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+15,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+15,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+14,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+14,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+14,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+13,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+13,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+13,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+12,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+12,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+12,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+11,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+11,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+11,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+10,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+10,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+10,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+9,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+9,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+9,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+8,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+8,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+8,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+7,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+7,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+7,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+6,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+6,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+6,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+5,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+5,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+5,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+4,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+4,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+4,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+3,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+3,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+3,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+2,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+2,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+2,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+1,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+1,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+1,y		; Update Left-most Tile Data.
	lda	>RS1E_TILSRC_BASE+0,x		; Load Accumulator with a bitrow of Source Tile.
	sta	<WRMPYB				; Store as Multiplicand.
	lda	|Rs1e.VWF.tilBuff+0,y Load Tile Buffer Data.
	ora	>RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	|Rs1e.VWF.tilBuff+0,y		; Update Left-most Tile Data.

	pld					; Restore RS1E Direct Page.
	plb					; Restore RS1E Kernel Bank.
	POPA					; Restore Assume List.
	rts					; Return.
	ENDIF
	ENDP	TPlaceShiftMerge8

; The following is the slowest and worst case scenario of the VWF Tile place!!!
TPlaceShiftMerge16	PROC	Near,MX:%10,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
   IF	__VWF_INLINE=0
	tay					; Pass Tile Source Address to Y
	lsr	Rs1e.VWF.rowCount		; Divide rowcount by 2 (proc' two at a time).
@loop
	lda	|RS1E_TILSRC_BASE,y		; Fetch 2 rows of Bitrow data.
	sep	#$20				; Pixels set in Bitplane: Accum to 8-bit.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff,x		; Update Left-most Tile Data.

	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff,x		; Update Right-most Tile Data.

	xba					; Reveal second bitrow.
	sta	WRMPYB				; Pixels set in Bitrow: Store in S-NES mult' Reg.

	lda	>Rs1e.VWF.tilBuff+1,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+1,x		; Update Right-most Tile Data.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+1,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+1,x		; Update Left-most Tile Data.
	rep	#$20				; Accum to 16-bit.
	inc	Rs1e.VWF.indxTilL		; Adjust Left-most Tile buffer Index by 2.
	inc	Rs1e.VWF.indxTilL		; ...
	inc	Rs1e.VWF.indxTilR		; Adjust Right-most Tile Buffer Index by 2.
	inc	Rs1e.VWF.indxTilR		; ...
	iny					; Adjust Tile Index by 2 bitrows.
	iny					; ...
	dec	Rs1e.VWF.rowCount		; Decrement out bitrow count.
	bne	@loop				; Loop back if not done for all.
	rts					; Done for all: Return.
   ELSE
	PUSHA					; Push assume list.
	tay					; Pass Tile Source Addess to Y.
	sep	#$20				; Accum to 8-bit.
	lda	Rs1e.VWF.tilDimType		; Load accum with tile dimension type.
	bne	@sm16_4bp
	brl	@sm16_2bp
@sm16_4bp
	lda	|RS1E_TILSRC_BASE+63,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+63,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+63,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+63,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+63,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+62,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+62,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+62,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+62,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+62,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+61,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+61,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+61,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+61,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+61,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+60,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+60,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+60,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+60,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+60,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+59,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+59,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+59,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+59,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+59,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+58,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+58,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+58,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+58,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+58,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+57,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+57,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+57,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+57,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+57,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+56,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+56,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+56,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+56,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+56,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+55,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+55,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+55,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+55,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+55,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+54,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+54,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+54,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+54,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+54,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+53,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+53,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+53,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+53,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+53,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+52,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+52,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+52,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+52,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+52,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+51,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+51,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+51,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+51,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+51,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+50,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+50,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+50,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+50,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+50,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+49,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+49,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+49,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+49,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+49,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+48,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+48,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+48,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+48,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+48,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+47,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+47,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+47,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+47,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+47,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+46,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+46,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+46,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+46,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+46,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+45,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+45,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+45,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+45,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+45,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+44,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+44,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+44,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+44,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+44,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+43,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+43,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+43,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+43,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+43,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+42,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+42,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+42,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+42,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+42,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+41,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+41,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+41,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+41,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+41,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+40,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+40,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+40,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+40,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+40,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+39,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+39,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+39,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+39,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+39,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+38,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+38,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+38,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+38,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+38,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+37,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+37,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+37,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+37,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+37,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+36,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+36,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+36,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+36,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+36,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+35,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+35,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+35,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+35,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+35,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+34,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+34,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+34,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+34,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+34,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+33,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+33,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+33,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+33,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+33,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+32,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+32,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+32,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+32,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+32,x		; Update Right-most Tile Data.
@sm16_2bp
	lda	|RS1E_TILSRC_BASE+31,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+31,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+31,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+31,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+31,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+30,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+30,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+30,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+30,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+30,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+29,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+29,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+29,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+29,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+29,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+28,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+28,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+28,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+28,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+28,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+27,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+27,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+27,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+27,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+27,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+26,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+26,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+26,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+26,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+26,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+25,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+25,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+25,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+25,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+25,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+24,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+24,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+24,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+24,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+24,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+23,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+23,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+23,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+23,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+23,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+22,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+22,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+22,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+22,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+22,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+21,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+21,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+21,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+21,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+21,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+20,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+20,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+20,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+20,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+20,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+19,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+19,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+19,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+19,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+19,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+18,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+18,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+18,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+18,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+18,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+17,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+17,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+17,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+17,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+17,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+16,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+16,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+16,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+16,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+16,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+15,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+15,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+15,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+15,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+15,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+14,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+14,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+14,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+14,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+14,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+13,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+13,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+13,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+13,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+13,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+12,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+12,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+12,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+12,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+12,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+11,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+11,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+11,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+11,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+11,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+10,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+10,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+10,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+10,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+10,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+9,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+9,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+9,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+9,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+9,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+8,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+8,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+8,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+8,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+8,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+7,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+7,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+7,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+7,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+7,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+6,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+6,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+6,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+6,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+6,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+5,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+5,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+5,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+5,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+5,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+4,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+4,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+4,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+4,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+4,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+3,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+3,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+3,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+3,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+3,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+2,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+2,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+2,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+2,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+2,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+1,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+1,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+1,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+1,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+1,x		; Update Right-most Tile Data.
	lda	|RS1E_TILSRC_BASE+0,y		; Load Accumulator with a bitrow of Source Tile.
	sta	WRMPYB				; Store bitplane data in S-NES multiplicand Register.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+0,x		; Load Tile Buffer Data.
	ora	RDMPYH				; Merge Left-most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+0,x		; Update Left-most Tile Data.
	ldx	Rs1e.VWF.indxTilR		; Load index to right-most Tile in the buffer.
	lda	>Rs1e.VWF.tilBuff+0,x		; Load Tile Buffer Data.
	ora	RDMPYL				; Merge Right most tile with shifted bitrow.
	sta	>Rs1e.VWF.tilBuff+0,x		; Update Right-most Tile Data.

	POPA					; Restore Assume List.
	rts					; Return.
	ENDIF

	ENDP	TPlaceShiftMerge16


; This following method will be for tiles exactly in position:
; to fix: see above.
; 'Merge'.
TPlaceMerge8	PROC	Near,MX:%10,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
   IF	__VWF_INLINE=0
	tay					; Pass Tile Source Address to Y
	sep	#$20				; Accum back to 8-bit.
	lsr	Rs1e.VWF.rowCount		; Divide rowcount by 2 (proc' two at a time).
	ldx	Rs1e.VWF.indxTilL		; Load X with Tile Buffer Index.
@tp_loop
	lda	|RS1E_TILSRC_BASE,y		; Fetch Source Tile bitrow.
	ora	>Rs1e.VWF.tilBuff,x		; Merge bitrow with Existing Tile Buffer.
	sta	>Rs1e.VWF.tilBuff,x		; Update Tile Buffer.
	lda	|RS1E_TILSRC_BASE+1,y		; Fetch Source Tile bitrow.
	ora	>Rs1e.VWF.tilBuff+1,x		; Merge bitrow with Existing Tile Buffer.
	sta	>Rs1e.VWF.tilBuff+1,x		; Update Tile Buffer.
	inx
	inx
	iny
	iny
	dec	Rs1e.VWF.rowCount		; Decrement Row Count.
	bne	@tp_loop			; Loop back if not done for all.
	lda	Rs1e.VWF.WidthShiftValue
	bne	@skip_1
	lda	#$02
	sta	$3,s
@skip_1
	rts					; Return.
   ELSE
	PUSHA					; Push assume list.
	tax					; Pass Tile Source Addess to X.
	pea	$2070
	plb
	ASSUME	DB:$70
	ldy	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	Rs1e.VWF.tilDimType		; Load accum with tile dimension type.
	bne	@m8_4bp
	brl	@m8_2bp
@m8_4bp
	lda	>RS1E_TILSRC_BASE+62,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+62,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+62,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+60,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+60,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+60,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+58,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+58,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+58,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+56,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+56,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+56,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+54,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+54,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+54,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+52,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+52,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+52,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+50,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+50,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+50,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+48,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+48,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+48,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+46,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+46,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+46,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+44,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+44,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+44,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+42,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+42,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+42,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+40,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+40,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+40,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+38,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+38,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+38,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+36,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+36,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+36,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+34,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+34,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+34,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+32,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+32,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+32,y		; Update Tile Buffer.
@m8_2bp
	lda	>RS1E_TILSRC_BASE+30,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+30,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+30,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+28,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+28,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+28,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+26,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+26,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+26,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+24,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+24,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+24,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+22,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+22,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+22,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+20,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+20,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+20,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+18,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+18,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+18,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+16,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+16,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+16,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+14,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+14,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+14,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+12,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+12,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+12,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+10,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+10,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+10,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+8,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+8,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+8,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+6,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+6,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+6,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+4,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+4,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+4,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+2,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+2,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+2,y		; Update Tile Buffer.
	lda	>RS1E_TILSRC_BASE+0,x		; Fetch Source Tile bitrow.
	ora	|Rs1e.VWF.tilBuff+0,y		; Merge bitrow with Existing Tile Buffer.
	sta	|Rs1e.VWF.tilBuff+0,y		; Update Tile Buffer.

	plb					; Restore RS1E Kernel Bank.
	POPA					; Restore Assume List.
	sep	#$20
	lda	Rs1e.VWF.WidthShiftValue
	bne	@skip_1
	lda	#$02
	sta	$3,s
@skip_1
	rts					; Return.
	ENDIF


	ENDP	TPlaceMerge8

; 'Shift+Store'
; This method is used for tiles when they are
; shifted to the 0pix position (8-bit shift
; range).
TPlaceShiftStore8	PROC	Near,MX:%00,D:RS1E_DPAGE,DB:^RS1E_KERNELDATA
   IF	__VWF_INLINE=0
	tay					; Pass Tile Source Address to Y
	sep	#$20				; Accum back to 8-bit.
	lsr	Rs1e.VWF.rowCount		; Divide rowcount by 2 (proc' two at a time).
	ldx	Rs1e.VWF.indxTilL		; Load X with Tile Buffer Index.
@tss_loop
	lda	|RS1E_TILSRC_BASE,y		; Load accum with a byte of tile data.
	sta	WRMPYB				; Store bitplane data in S-NES mult' Reg.
	iny
	inx					; Placed here to fill hware latency.
	lda	RDMPYL				; Fetch Shifted bitrow (8-bit range=4cyc latency).
	sta	>Rs1e.VWF.tilBuff-1,x		; Store in the buffer (note: pre-adjusted X indx!).
	lda	|RS1E_TILSRC_BASE,y		; Load accum with a byte of tile data.
	sta	WRMPYB				; Store bitplane data in S-NES mult' Reg.
	iny
	inx					; Placed here to fill hware latency.
	lda	RDMPYL				; Fetch Shifted bitrow (8-bit range=4cyc latency).
	sta	>Rs1e.VWF.tilBuff-1,x		; Store in the buffer (note: pre-adjusted X indx!).

	dec	Rs1e.VWF.rowCount		; Decrement our count.
	bne	@tss_loop			; Loop back if not done for all.
	rts					; Return.
   ELSE
	PUSHA					; Push assume list.
	tay					; Pass Tile Source Addess to X.
	phd
	pea	$4200
	pld
	ASSUME	D:$4200
	sep	#$20				; Accum to 8-bit.
	ldx	Rs1e.VWF.indxTilL		; Load index to left-most Tile in the buffer.
	lda	Rs1e.VWF.tilDimType		; Load accum with tile dimension type.
	bne	@ss8_4bp
	brl	@ss8_2bp
@ss8_4bp
	lda	|RS1E_TILSRC_BASE+63,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+63,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+62,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+62,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+61,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+61,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+60,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+60,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+59,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+59,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+58,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+58,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+57,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+57,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+56,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+56,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+55,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+55,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+54,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+54,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+53,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+53,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+52,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+52,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+51,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+51,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+50,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+50,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+49,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+49,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+48,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+48,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+47,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+47,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+46,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+46,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+45,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+45,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+44,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+44,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+43,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+43,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+42,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+42,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+41,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+41,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+40,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+40,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+39,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+39,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+38,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+38,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+37,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+37,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+36,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+36,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+35,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+35,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+34,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+34,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+33,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+33,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+32,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+32,x		; Store in the buffer .
@ss8_2bp
	lda	|RS1E_TILSRC_BASE+31,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+31,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+30,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+30,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+29,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+29,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+28,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+28,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+27,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+27,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+26,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+26,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+25,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+25,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+24,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+24,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+23,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+23,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+22,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+22,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+21,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+21,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+20,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+20,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+19,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+19,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+18,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+18,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+17,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+17,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+16,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+16,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+15,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+15,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+14,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+14,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+13,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+13,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+12,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+12,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+11,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+11,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+10,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+10,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+9,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+9,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+8,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+8,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+7,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+7,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+6,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+6,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+5,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+5,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+4,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+4,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+3,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+3,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+2,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+2,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+1,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES mult' Reg.
	nop
	lda	>RDMPYL				; Fetch Shifted bitrow .
	sta	>Rs1e.VWF.tilBuff+1,x		; Store in the buffer .
	lda	|RS1E_TILSRC_BASE+0,y		; Load accum with a byte of tile data.
	sta	<WRMPYB				; Store bitplane data in S-NES