;=================================================================
;
; Copyright (c) Microsoft Corporation 1999 - All Rights Reserved.
;
;=================================================================

	.486
	.model	flat, stdcall
;	OPTION	PROC:PRIVATE		; only public procs explicitly
	OPTION	CASEMAP:NONE		; mixed case allowed for C compatibility
	OPTION	SCOPED			; labels are local inside PROCs
	OPTION	EXPR32			; 32-bit expression word size

include grf.inc
include chunk.inc

IF USE_C EQ 0

.DATA

; these should be done by h2inc, but require a "C" which h2inc can't handle.
extrn g_grdChunkData:ChunkData
extrn rgpspanfnTrivialZAndBackend:PSPANFN

.CODE

SAVE_REGS_CHKSTK    macro
; NOTE this avoids problems with stack checking when called from C code
if DEBUG
    push ebx
    push esi
    push edi
    push ebp
endif
endm

RESTORE_REGS_CHKSTK    macro
; NOTE this avoids problems with stack checking when called from C code
if DEBUG
    pop ebp
    pop edi
    pop esi
    pop ebx
endif
endm

;------------------------------------------------------------------------------------------
; Chunk processor: draws 16-bpp texels (any format) into working buffer, checking for wrap.
;------------------------------------------------------------------------------------------
SpanTexture_Wrap    proc

    SAVE_REGS_CHKSTK

    mov ecx,[g_grdChunkData.cyTextureShift]
    mov edx,[g_grdChunkData.fix16u_Chunk]
    mov ebp,[g_grdChunkData.fix16v_Chunk]
    mov esi,[g_grdChunkData.pwTexture]
    mov ebx,[g_grdChunkData.cPixels_Chunk]
	cmp	ecx,8
    jz  do256x256
    mov [g_grdChunkData.SaveESP],esp
	xor	edi,edi
mloop:
    mov esp,edx
    mov eax,ebp
    shr esp,16
    shr eax,cl
    and esp,[g_grdChunkData.cxTextureMask]
    and eax,[g_grdChunkData.cyTextureMask]
    add eax,esp
    mov esp,[g_grdChunkData.fix16du_Chunk]
    add edx,esp
    mov esp,[g_grdChunkData.fix16dv_Chunk]
    mov di,[esi+eax*2]
    add ebp,esp
    mov [g_grdChunkData.rgm3WorkingBuffer+ebx*4+16*4],edi
    inc ebx
    jnz mloop

    mov esp,[g_grdChunkData.SaveESP]
    RESTORE_REGS_CHKSTK

    jmp dword ptr [g_grdChunkData.pspanfnWorking+PSPANFN_AFTER_TEXTURING*4]

do256x256:
    xor ecx,ecx
mloop256x256:
    mov edi,edx
    mov eax,ebp
    shr edi,16
    shr eax,8
    and edi,0000FFh
    and eax,00FF00h
    add eax,edi
    mov edi,[g_grdChunkData.fix16du_Chunk]
    add edx,edi
    mov edi,[g_grdChunkData.fix16dv_Chunk]
    mov cx,[esi+eax*2]
    add ebp,edi
    mov [g_grdChunkData.rgm3WorkingBuffer+ebx*4+16*4],ecx
    inc ebx
    jnz mloop256x256

    RESTORE_REGS_CHKSTK

    jmp dword ptr [g_grdChunkData.pspanfnWorking+PSPANFN_AFTER_TEXTURING*4]

SpanTexture_Wrap      endp


;------------------------------------------------------------------------------------------
; Chunk processor: draws Gouraud color into working buffer.
;------------------------------------------------------------------------------------------
SpanShade_GouraudRGB    proc

    SAVE_REGS_CHKSTK

    mov ecx,[g_grdChunkData.cPixels_Chunk]
    mov ebx,[g_grdChunkData.grb_Chunk]
    mov edx,[g_grdChunkData.gag_Chunk]
    mov esi,[g_grdChunkData.grbIncrement_Chunk]
    mov eax,ebx
    mov edi,[g_grdChunkData.gagIncrement_Chunk]
    cmp ecx,-16
    jz  Do16
mloop:
    or  eax,edx
    add ebx,esi
    shr eax,5
    add edx,edi
    and eax,01F07C1Fh
    mov [g_grdChunkData.rgm3WorkingBuffer+ecx*4+16*4],eax
    mov eax,ebx
    inc ecx
    jnz mloop

    RESTORE_REGS_CHKSTK

    jmp dword ptr [g_grdChunkData.pspanfnWorking+PSPANFN_AFTER_SHADING*4]

SPAN_SHADE_GOURAUD_RGB  macro   OFFSET
    add ebx,esi
    add edx,edi
    shr ebp,5
    mov eax,ebx
    and ebp,01F07C1Fh
    or  eax,edx
    mov [g_grdChunkData.rgm3WorkingBuffer+OFFSET*4],ebp

    add ebx,esi
    add edx,edi
    shr eax,5
    mov ebp,ebx
    and eax,01F07C1Fh
    or  ebp,edx
    mov [g_grdChunkData.rgm3WorkingBuffer+(OFFSET+1)*4],eax
    endm

Do16:
    add ebx,esi
    or  eax,edx
    add edx,edi
    shr eax,5
    mov ebp,ebx
    and eax,01F07C1Fh
    or  ebp,edx
    mov [g_grdChunkData.rgm3WorkingBuffer+0*4],eax

    SPAN_SHADE_GOURAUD_RGB  1
    SPAN_SHADE_GOURAUD_RGB  3
    SPAN_SHADE_GOURAUD_RGB  5
    SPAN_SHADE_GOURAUD_RGB  7
    SPAN_SHADE_GOURAUD_RGB  9
    SPAN_SHADE_GOURAUD_RGB  11
    SPAN_SHADE_GOURAUD_RGB  13

    shr ebp,5
    and ebp,01F07C1Fh
    mov [g_grdChunkData.rgm3WorkingBuffer+15*4],ebp

    RESTORE_REGS_CHKSTK

    jmp dword ptr [g_grdChunkData.pspanfnWorking+PSPANFN_AFTER_SHADING*4]

SpanShade_GouraudRGB    endp


;------------------------------------------------------------------------------------------
; chunk processor: writes z unconditionally.
;------------------------------------------------------------------------------------------
SpanTrivialZ_W  proc

    SAVE_REGS_CHKSTK

    ; set pointer to next chunk processor
    mov edx,[g_grdChunkData.pspanfnWorking+PSPANFN_AFTER_TRIVIALZ*4]
    jmp short near ptr SpanTrivialZ_W_Entry

SpanTrivialZ_W  endp

SpanTrivialZ_W_Native  proc

    SAVE_REGS_CHKSTK

    ; set pointer to next chunk processor
    mov edx,[rgpspanfnTrivialZAndBackend]

SpanTrivialZ_W_Entry    label   dword
    mov ecx,[g_grdChunkData.cPixels_Chunk]
    mov esi,[g_grdChunkData.pZ_Chunk]
    cmp ecx,-16
    jz  Do16
    mov ebx,[g_grdChunkData.dwZ_Chunk]
    ror ebx,16
    mov eax,[g_grdChunkData.ZIncr_Chunk]
    ror eax,16
mloopz:
    mov [esi+ecx*2],bx
    add ebx,eax
    adc ebx,0
    inc ecx
    jnz mloopz

    RESTORE_REGS_CHKSTK

    jmp edx

SPAN_TRIVIALZ_W_1   macro   OFFSET
    add ebx,eax
    shr edi,16
    and ecx,0FFFF0000h
    mov ebp,ebx
    add ebx,eax
    or  edi,ecx
    mov ecx,ebx
    mov [esi-8*4+OFFSET],edi
    endm

SPAN_TRIVIALZ_W_2   macro   OFFSET
    add ebx,eax
    shr ebp,16
    and ecx,0FFFF0000h
    mov edi,ebx
    add ebx,eax
    or  ebp,ecx
    mov ecx,ebx
    mov [esi-8*4+OFFSET],ebp
    endm

Do16:
    mov ebx,[g_grdChunkData.dwZ_Chunk]
    mov eax,[g_grdChunkData.ZIncr_Chunk]
    test esi,2
    jnz Do16OddStart

; even-pixel start address
    mov ebp,ebx
    add ebx,eax
    mov ecx,ebx
    add ebx,eax
    shr ebp,16
    and ecx,0FFFF0000h
    mov edi,ebx
    add ebx,eax
    or  ebp,ecx
    mov ecx,ebx
    mov [esi-8*4+0*4],ebp

    SPAN_TRIVIALZ_W_1   1*4
    SPAN_TRIVIALZ_W_2   2*4
    SPAN_TRIVIALZ_W_1   3*4
    SPAN_TRIVIALZ_W_2   4*4
    SPAN_TRIVIALZ_W_1   5*4
    SPAN_TRIVIALZ_W_2   6*4

    shr edi,16
    and ecx,0FFFF0000h
    or  edi,ecx
    mov [esi-8*4+7*4],edi

    RESTORE_REGS_CHKSTK

    jmp edx

; odd-pixel start address
Do16OddStart:
    mov ebp,ebx
    add ebx,eax
    shr ebp,16
    mov edi,ebx
    mov [esi-8*4+0*4],bp    ; leading odd pixel

    add ebx,eax
    mov ecx,ebx
    add ebx,eax
    shr edi,16
    and ecx,0FFFF0000h
    mov ebp,ebx
    add ebx,eax
    or  edi,ecx
    mov ecx,ebx
    mov [esi+2-8*4+0*4],edi

    SPAN_TRIVIALZ_W_2   2+1*4
    SPAN_TRIVIALZ_W_1   2+2*4
    SPAN_TRIVIALZ_W_2   2+3*4
    SPAN_TRIVIALZ_W_1   2+4*4
    SPAN_TRIVIALZ_W_2   2+5*4

    add ebx,eax
    shr edi,16
    and ecx,0FFFF0000h
    shr ebx,16
    or  edi,ecx
    mov [esi-8*4+2+6*4],edi

    mov [esi-8*4+2+7*4],bx    ; trailing odd pixel

    RESTORE_REGS_CHKSTK

    jmp edx                   ; jump to next chunk processor

SpanTrivialZ_W_Native   endp

;------------------------------------------------------------------------------------------
; chunk processor: munges 555 texels into working buffer.
;------------------------------------------------------------------------------------------
SpanMunge_555   proc

    SAVE_REGS_CHKSTK

    mov ecx,[g_grdChunkData.cPixels_Chunk]
    mov esi,001F00000h
mloop:
    mov eax,[g_grdChunkData.rgm3WorkingBuffer+ecx*4+16*4]
    mov ebx,eax
    shl eax,10
    mov edx,ebx
    shl ebx,5
    and eax,esi
    and edx,00000001Fh
    and ebx,000007C00h
    or  eax,edx
    or  eax,ebx
    mov [g_grdChunkData.rgm3WorkingBuffer+ecx*4+16*4],eax
    inc ecx
    jnz mloop

    RESTORE_REGS_CHKSTK

    jmp dword ptr [g_grdChunkData.pspanfnWorking+PSPANFN_AFTER_MUNGING*4]

SpanMunge_555   endp


;------------------------------------------------------------------------------------------
; chunk processor: munges 565 texels into working buffer.
;------------------------------------------------------------------------------------------
SpanMunge_565   proc

    SAVE_REGS_CHKSTK

    mov ecx,[g_grdChunkData.cPixels_Chunk]
    mov esi,001F00000h
    cmp ecx,-16
    jz  do16
mloop:
    mov eax,[g_grdChunkData.rgm3WorkingBuffer+ecx*4+16*4]
    mov ebx,eax
    shl eax,9
    mov edx,ebx
    shl ebx,4
    and eax,esi
    and edx,00000001Fh
    and ebx,000007C00h
    or  eax,edx
    or  eax,ebx
    mov [g_grdChunkData.rgm3WorkingBuffer+ecx*4+16*4],eax
    inc ecx
    jnz mloop

    RESTORE_REGS_CHKSTK

    jmp dword ptr [g_grdChunkData.pspanfnWorking+PSPANFN_AFTER_MUNGING*4]

SPAN_MUNGE_565_1    macro   OFFSET
    mov eax,[g_grdChunkData.rgm3WorkingBuffer+(OFFSET+1)*4]
    shl ebp,4
    mov ebx,eax
    and edi,esi
    and edx,00000001Fh
    and ebp,000007C00h
    or  edi,edx
    shl eax,9
    or  edi,ebp
    mov edx,ebx
    mov [g_grdChunkData.rgm3WorkingBuffer+OFFSET*4],edi
    endm

SPAN_MUNGE_565_2    macro   OFFSET
    shl ebx,4
    mov edi,[g_grdChunkData.rgm3WorkingBuffer+(OFFSET+1)*4]
    and eax,esi
    mov ebp,edi
    and edx,00000001Fh
    and ebx,000007C00h
    shl edi,9
    or  eax,edx
    mov edx,ebp
    or  eax,ebx
    mov [g_grdChunkData.rgm3WorkingBuffer+OFFSET*4],eax
    endm

do16:
    mov eax,[g_grdChunkData.rgm3WorkingBuffer+0*4]
    mov edi,[g_grdChunkData.rgm3WorkingBuffer+1*4]
    mov ebx,eax
    mov ebp,edi
    shl eax,9
    mov edx,ebx
    shl ebx,4
    and eax,esi
    and edx,00000001Fh
    and ebx,000007C00h
    shl edi,9
    or  eax,edx
    or  eax,ebx
    mov edx,ebp
    mov [g_grdChunkData.rgm3WorkingBuffer+0*4],eax

    SPAN_MUNGE_565_1    1
    SPAN_MUNGE_565_2    2
    SPAN_MUNGE_565_1    3
    SPAN_MUNGE_565_2    4
    SPAN_MUNGE_565_1    5
    SPAN_MUNGE_565_2    6
    SPAN_MUNGE_565_1    7
    SPAN_MUNGE_565_2    8
    SPAN_MUNGE_565_1    9
    SPAN_MUNGE_565_2    10
    SPAN_MUNGE_565_1    11
    SPAN_MUNGE_565_2    12
    SPAN_MUNGE_565_1    13
    SPAN_MUNGE_565_2    14

    shl ebp,4
    and edi,esi
    and edx,00000001Fh
    and ebp,000007C00h
    or  edi,edx
    or  edi,ebp
    mov [g_grdChunkData.rgm3WorkingBuffer+15*4],edi

    RESTORE_REGS_CHKSTK

    jmp dword ptr [g_grdChunkData.pspanfnWorking+PSPANFN_AFTER_MUNGING*4]

SpanMunge_565   endp


;------------------------------------------------------------------------------------------
; chunk processor: draws 16-bpp texels (any format) directly to 16-bpp destination
; without any conversion, checking for wrap.
;------------------------------------------------------------------------------------------
SpanTextureBackend_Wrap_Native_NoZ_10_NoAlphaTest   proc

    SAVE_REGS_CHKSTK

IF DEBUG
    cmp [g_grdChunkData.cyTextureShift],8
    jnb @F
    int 3
@@:
    cmp [g_grdChunkData.cyTextureShift],16
    jna @F
    int 3
@@:
    cmp [g_grdChunkData.cPixels_Chunk],-1
    jng @F
    int 3
@@:
    cmp [g_grdChunkData.cPixels_Chunk],-16
    jnl @F
    int 3
@@:
ENDIF

    mov [g_grdChunkData.SaveESP],esp
    mov ecx,[g_grdChunkData.cyTextureShift]

    mov esp,[g_grdChunkData.fix16u_Chunk]
    mov edx,[g_grdChunkData.pPix_Chunk]

    shl esp,cl
    mov ebx,[g_grdChunkData.fix16du_Chunk]

    shl ebx,cl
    mov edi,esp

    shl ecx,4
    mov eax,[g_grdChunkData.cPixels_Chunk]

    add eax,ecx
    mov ecx,ebx

    mov ebp,[g_grdChunkData.fix16v_Chunk]
    mov esi,[g_grdChunkData.pwTexture]

    mov ebx,[g_grdChunkData.fix16dv_Chunk]
    jmp dword ptr [TexmapBySizeTable+16*4-8*16*4+eax*4]


TEXMAP_PIXEL    macro   USHIFT, VSHIFT, VMASK, OFFSET
    mov eax,ebp
    shr edi,USHIFT
    and eax,VMASK
    shr eax,VSHIFT
    add esp,ecx
    add eax,edi
    add ebp,ebx
    mov ax,[esi+eax*2]
    mov edi,esp
    mov [edx-OFFSET*2],ax
endm

TEXMAP_LAST_PIXEL   macro   USHIFT, VSHIFT, VMASK
    mov eax,ebp
    shr edi,USHIFT
    and eax,VMASK
    shr eax,VSHIFT
    add eax,edi
    mov ax,[esi+eax*2]
    mov [edx-1*2],ax

    mov esp,[g_grdChunkData.SaveESP]
    RESTORE_REGS_CHKSTK
    ret
endm

TEXMAP_PIXEL_1x1    macro   OFFSET
    mov ax,[esi]
    mov [edx-OFFSET*2],ax
endm

TEXMAP_LAST_PIXEL_1x1   macro
    mov ax,[esi]
    mov [edx-1*2],ax

    mov esp,[g_grdChunkData.SaveESP]
    RESTORE_REGS_CHKSTK
    ret
endm

Texmap256x256_16:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 16
Texmap256x256_15:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 15
Texmap256x256_14:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 14
Texmap256x256_13:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 13
Texmap256x256_12:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 12
Texmap256x256_11:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 11
Texmap256x256_10:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 10
Texmap256x256_9:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 9
Texmap256x256_8:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 8
Texmap256x256_7:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 7
Texmap256x256_6:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 6
Texmap256x256_5:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 5
Texmap256x256_4:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 4
Texmap256x256_3:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 3
Texmap256x256_2:
    TEXMAP_PIXEL    24, 8, 000FF0000h, 2
Texmap256x256_1:
    TEXMAP_LAST_PIXEL   24, 8, 000FF0000h

Texmap128x128_16:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 16
Texmap128x128_15:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 15
Texmap128x128_14:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 14
Texmap128x128_13:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 13
Texmap128x128_12:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 12
Texmap128x128_11:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 11
Texmap128x128_10:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 10
Texmap128x128_9:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 9
Texmap128x128_8:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 8
Texmap128x128_7:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 7
Texmap128x128_6:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 6
Texmap128x128_5:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 5
Texmap128x128_4:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 4
Texmap128x128_3:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 3
Texmap128x128_2:
    TEXMAP_PIXEL    25, 9, 0007F0000h, 2
Texmap128x128_1:
    TEXMAP_LAST_PIXEL   25, 9, 0007F0000h

Texmap64x64_16:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 16
Texmap64x64_15:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 15
Texmap64x64_14:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 14
Texmap64x64_13:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 13
Texmap64x64_12:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 12
Texmap64x64_11:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 11
Texmap64x64_10:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 10
Texmap64x64_9:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 9
Texmap64x64_8:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 8
Texmap64x64_7:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 7
Texmap64x64_6:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 6
Texmap64x64_5:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 5
Texmap64x64_4:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 4
Texmap64x64_3:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 3
Texmap64x64_2:
    TEXMAP_PIXEL    26, 10, 0003F0000h, 2
Texmap64x64_1:
    TEXMAP_LAST_PIXEL   26, 10, 0003F0000h

Texmap32x32_16:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 16
Texmap32x32_15:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 15
Texmap32x32_14:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 14
Texmap32x32_13:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 13
Texmap32x32_12:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 12
Texmap32x32_11:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 11
Texmap32x32_10:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 10
Texmap32x32_9:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 9
Texmap32x32_8:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 8
Texmap32x32_7:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 7
Texmap32x32_6:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 6
Texmap32x32_5:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 5
Texmap32x32_4:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 4
Texmap32x32_3:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 3
Texmap32x32_2:
    TEXMAP_PIXEL    27, 11, 0001F0000h, 2
Texmap32x32_1:
    TEXMAP_LAST_PIXEL   27, 11, 0001F0000h

Texmap16x16_16:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 16
Texmap16x16_15:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 15
Texmap16x16_14:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 14
Texmap16x16_13:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 13
Texmap16x16_12:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 12
Texmap16x16_11:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 11
Texmap16x16_10:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 10
Texmap16x16_9:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 9
Texmap16x16_8:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 8
Texmap16x16_7:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 7
Texmap16x16_6:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 6
Texmap16x16_5:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 5
Texmap16x16_4:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 4
Texmap16x16_3:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 3
Texmap16x16_2:
    TEXMAP_PIXEL    28, 12, 0000F0000h, 2
Texmap16x16_1:
    TEXMAP_LAST_PIXEL   28, 12, 0000F0000h

Texmap8x8_16:
    TEXMAP_PIXEL    29, 13, 000070000h, 16
Texmap8x8_15:
    TEXMAP_PIXEL    29, 13, 000070000h, 15
Texmap8x8_14:
    TEXMAP_PIXEL    29, 13, 000070000h, 14
Texmap8x8_13:
    TEXMAP_PIXEL    29, 13, 000070000h, 13
Texmap8x8_12:
    TEXMAP_PIXEL    29, 13, 000070000h, 12
Texmap8x8_11:
    TEXMAP_PIXEL    29, 13, 000070000h, 11
Texmap8x8_10:
    TEXMAP_PIXEL    29, 13, 000070000h, 10
Texmap8x8_9:
    TEXMAP_PIXEL    29, 13, 000070000h, 9
Texmap8x8_8:
    TEXMAP_PIXEL    29, 13, 000070000h, 8
Texmap8x8_7:
    TEXMAP_PIXEL    29, 13, 000070000h, 7
Texmap8x8_6:
    TEXMAP_PIXEL    29, 13, 000070000h, 6
Texmap8x8_5:
    TEXMAP_PIXEL    29, 13, 000070000h, 5
Texmap8x8_4:
    TEXMAP_PIXEL    29, 13, 000070000h, 4
Texmap8x8_3:
    TEXMAP_PIXEL    29, 13, 000070000h, 3
Texmap8x8_2:
    TEXMAP_PIXEL    29, 13, 000070000h, 2
Texmap8x8_1:
    TEXMAP_LAST_PIXEL   29, 13, 000070000h

Texmap4x4_16:
    TEXMAP_PIXEL    30, 14, 000030000h, 16
Texmap4x4_15:
    TEXMAP_PIXEL    30, 14, 000030000h, 15
Texmap4x4_14:
    TEXMAP_PIXEL    30, 14, 000030000h, 14
Texmap4x4_13:
    TEXMAP_PIXEL    30, 14, 000030000h, 13
Texmap4x4_12:
    TEXMAP_PIXEL    30, 14, 000030000h, 12
Texmap4x4_11:
    TEXMAP_PIXEL    30, 14, 000030000h, 11
Texmap4x4_10:
    TEXMAP_PIXEL    30, 14, 000030000h, 10
Texmap4x4_9:
    TEXMAP_PIXEL    30, 14, 000030000h, 9
Texmap4x4_8:
    TEXMAP_PIXEL    30, 14, 000030000h, 8
Texmap4x4_7:
    TEXMAP_PIXEL    30, 14, 000030000h, 7
Texmap4x4_6:
    TEXMAP_PIXEL    30, 14, 000030000h, 6
Texmap4x4_5:
    TEXMAP_PIXEL    30, 14, 000030000h, 5
Texmap4x4_4:
    TEXMAP_PIXEL    30, 14, 000030000h, 4
Texmap4x4_3:
    TEXMAP_PIXEL    30, 14, 000030000h, 3
Texmap4x4_2:
    TEXMAP_PIXEL    30, 14, 000030000h, 2
Texmap4x4_1:
    TEXMAP_LAST_PIXEL   30, 14, 000030000h

Texmap2x2_16:
    TEXMAP_PIXEL    31, 15, 000010000h, 16
Texmap2x2_15:
    TEXMAP_PIXEL    31, 15, 000010000h, 15
Texmap2x2_14:
    TEXMAP_PIXEL    31, 15, 000010000h, 14
Texmap2x2_13:
    TEXMAP_PIXEL    31, 15, 000010000h, 13
Texmap2x2_12:
    TEXMAP_PIXEL    31, 15, 000010000h, 12
Texmap2x2_11:
    TEXMAP_PIXEL    31, 15, 000010000h, 11
Texmap2x2_10:
    TEXMAP_PIXEL    31, 15, 000010000h, 10
Texmap2x2_9:
    TEXMAP_PIXEL    31, 15, 000010000h, 9
Texmap2x2_8:
    TEXMAP_PIXEL    31, 15, 000010000h, 8
Texmap2x2_7:
    TEXMAP_PIXEL    31, 15, 000010000h, 7
Texmap2x2_6:
    TEXMAP_PIXEL    31, 15, 000010000h, 6
Texmap2x2_5:
    TEXMAP_PIXEL    31, 15, 000010000h, 5
Texmap2x2_4:
    TEXMAP_PIXEL    31, 15, 000010000h, 4
Texmap2x2_3:
    TEXMAP_PIXEL    31, 15, 000010000h, 3
Texmap2x2_2:
    TEXMAP_PIXEL    31, 15, 000010000h, 2
Texmap2x2_1:
    TEXMAP_LAST_PIXEL   31, 15, 000010000h

Texmap1x1_16:
    TEXMAP_PIXEL_1x1    16
Texmap1x1_15:
    TEXMAP_PIXEL_1x1    15
Texmap1x1_14:
    TEXMAP_PIXEL_1x1    14
Texmap1x1_13:
    TEXMAP_PIXEL_1x1    13
Texmap1x1_12:
    TEXMAP_PIXEL_1x1    12
Texmap1x1_11:
    TEXMAP_PIXEL_1x1    11
Texmap1x1_10:
    TEXMAP_PIXEL_1x1    10
Texmap1x1_9:
    TEXMAP_PIXEL_1x1    9
Texmap1x1_8:
    TEXMAP_PIXEL_1x1    8
Texmap1x1_7:
    TEXMAP_PIXEL_1x1    7
Texmap1x1_6:
    TEXMAP_PIXEL_1x1    6
Texmap1x1_5:
    TEXMAP_PIXEL_1x1    5
Texmap1x1_4:
    TEXMAP_PIXEL_1x1    4
Texmap1x1_3:
    TEXMAP_PIXEL_1x1    3
Texmap1x1_2:
    TEXMAP_PIXEL_1x1    2
Texmap1x1_1:
    TEXMAP_LAST_PIXEL_1x1


    .data

    align   4
TexmapBySizeTable   label   dword
    dd  Texmap256x256_16, Texmap256x256_15, Texmap256x256_14, Texmap256x256_13
    dd  Texmap256x256_12, Texmap256x256_11, Texmap256x256_10, Texmap256x256_9
    dd  Texmap256x256_8,  Texmap256x256_7,  Texmap256x256_6,  Texmap256x256_5
    dd  Texmap256x256_4,  Texmap256x256_3,  Texmap256x256_2,  Texmap256x256_1

    dd  Texmap128x128_16, Texmap128x128_15, Texmap128x128_14, Texmap128x128_13
    dd  Texmap128x128_12, Texmap128x128_11, Texmap128x128_10, Texmap128x128_9
    dd  Texmap128x128_8,  Texmap128x128_7,  Texmap128x128_6,  Texmap128x128_5
    dd  Texmap128x128_4,  Texmap128x128_3,  Texmap128x128_2,  Texmap128x128_1

    dd  Texmap64x64_16, Texmap64x64_15, Texmap64x64_14, Texmap64x64_13
    dd  Texmap64x64_12, Texmap64x64_11, Texmap64x64_10, Texmap64x64_9
    dd  Texmap64x64_8,  Texmap64x64_7,  Texmap64x64_6,  Texmap64x64_5
    dd  Texmap64x64_4,  Texmap64x64_3,  Texmap64x64_2,  Texmap64x64_1

    dd  Texmap32x32_16, Texmap32x32_15, Texmap32x32_14, Texmap32x32_13
    dd  Texmap32x32_12, Texmap32x32_11, Texmap32x32_10, Texmap32x32_9
    dd  Texmap32x32_8,  Texmap32x32_7,  Texmap32x32_6,  Texmap32x32_5
    dd  Texmap32x32_4,  Texmap32x32_3,  Texmap32x32_2,  Texmap32x32_1

    dd  Texmap16x16_16, Texmap16x16_15, Texmap16x16_14, Texmap16x16_13
    dd  Texmap16x16_12, Texmap16x16_11, Texmap16x16_10, Texmap16x16_9
    dd  Texmap16x16_8,  Texmap16x16_7,  Texmap16x16_6,  Texmap16x16_5
    dd  Texmap16x16_4,  Texmap16x16_3,  Texmap16x16_2,  Texmap16x16_1

    dd  Texmap8x8_16, Texmap8x8_15, Texmap8x8_14, Texmap8x8_13
    dd  Texmap8x8_12, Texmap8x8_11, Texmap8x8_10, Texmap8x8_9
    dd  Texmap8x8_8,  Texmap8x8_7,  Texmap8x8_6,  Texmap8x8_5
    dd  Texmap8x8_4,  Texmap8x8_3,  Texmap8x8_2,  Texmap8x8_1

    dd  Texmap4x4_16, Texmap4x4_15, Texmap4x4_14, Texmap4x4_13
    dd  Texmap4x4_12, Texmap4x4_11, Texmap4x4_10, Texmap4x4_9
    dd  Texmap4x4_8,  Texmap4x4_7,  Texmap4x4_6,  Texmap4x4_5
    dd  Texmap4x4_4,  Texmap4x4_3,  Texmap4x4_2,  Texmap4x4_1

    dd  Texmap2x2_16, Texmap2x2_15, Texmap2x2_14, Texmap2x2_13
    dd  Texmap2x2_12, Texmap2x2_11, Texmap2x2_10, Texmap2x2_9
    dd  Texmap2x2_8,  Texmap2x2_7,  Texmap2x2_6,  Texmap2x2_5
    dd  Texmap2x2_4,  Texmap2x2_3,  Texmap2x2_2,  Texmap2x2_1

    dd  Texmap1x1_16, Texmap1x1_15, Texmap1x1_14, Texmap1x1_13
    dd  Texmap1x1_12, Texmap1x1_11, Texmap1x1_10, Texmap1x1_9
    dd  Texmap1x1_8,  Texmap1x1_7,  Texmap1x1_6,  Texmap1x1_5
    dd  Texmap1x1_4,  Texmap1x1_3,  Texmap1x1_2,  Texmap1x1_1

    .code
SpanTextureBackend_Wrap_Native_NoZ_10_NoAlphaTest   endp


;------------------------------------------------------------------------------------------
; chunk processor: draws 16-bpp texels (any format) directly to pixel-doubled
; 16-bpp destination without any conversion, checking for wrap.
;------------------------------------------------------------------------------------------
SpanTextureBackend2X_Wrap_Native_NoZ_10_NoAlphaTest   proc

    SAVE_REGS_CHKSTK

IF DEBUG
    cmp [g_grdChunkData.cyTextureShift],8
    jnb @F
    int 3
@@:
    cmp [g_grdChunkData.cyTextureShift],16
    jna @F
    int 3
@@:
    cmp [g_grdChunkData.cPixels_Chunk],-1
    jng @F
    int 3
@@:
    cmp [g_grdChunkData.cPixels_Chunk],-16
    jnl @F
    int 3
@@:
ENDIF

    mov [g_grdChunkData.SaveESP],esp
    mov ecx,2

    mov edx,[g_grdChunkData.pPix_Chunk]
    mov esi,[g_grdChunkData.pwTexture]
dloop:
    mov [g_grdChunkData.cDouble],ecx
    mov ecx,[g_grdChunkData.cyTextureShift]

    mov esp,[g_grdChunkData.fix16u_Chunk]

    shl esp,cl
    mov ebx,[g_grdChunkData.fix16du_Chunk]

    shl ebx,cl
    mov edi,esp

    shl ecx,4
    mov eax,[g_grdChunkData.cPixels_Chunk]

    add eax,ecx
    mov ecx,ebx

    mov ebp,[g_grdChunkData.fix16v_Chunk]

    xor ebx,ebx
    jmp dword ptr [Texmap2XBySizeTable+16*4-8*16*4+eax*4]


TEXMAP2X_PIXEL    macro   USHIFT, VSHIFT, VMASK, OFFSET
    mov eax,ebp
    shr edi,USHIFT
    and eax,VMASK
    shr eax,VSHIFT
    add esp,ecx
    add eax,edi
    add ebp,[g_grdChunkData.fix16dv_Chunk]
    mov bx,[esi+eax*2]
    mov edi,esp
    mov eax,ebx
    shl eax,16
    or  eax,ebx
    mov [edx-OFFSET*4],eax
endm

TEXMAP2X_LAST_PIXEL   macro   USHIFT, VSHIFT, VMASK
    mov eax,ebp
    shr edi,USHIFT
    and eax,VMASK
    shr eax,VSHIFT
    add eax,edi
    mov bx,[esi+eax*2]
    mov eax,ebx
    shl eax,16
    or  eax,ebx
    mov [edx-1*4],eax

    mov ebx,[g_grdChunkData.cbScanDoubleOffset]
    mov ecx,[g_grdChunkData.cDouble]
    add edx,ebx
    dec ecx
    jnz dloop

    mov esp,[g_grdChunkData.SaveESP]
    RESTORE_REGS_CHKSTK
    ret
endm

TEXMAP2X_PIXEL_1x1    macro   OFFSET
    mov bx,[esi]
    mov eax,ebx
    shl eax,16
    or  eax,ebx
    mov [edx-OFFSET*4],eax
endm

TEXMAP2X_LAST_PIXEL_1x1   macro
    mov bx,[esi]
    mov eax,ebx
    shl eax,16
    or  eax,ebx
    mov [edx-1*4],eax

    mov ebx,[g_grdChunkData.cbScanDoubleOffset]
    mov ecx,[g_grdChunkData.cDouble]
    add edx,ebx
    dec ecx
    jnz dloop

    mov esp,[g_grdChunkData.SaveESP]
    RESTORE_REGS_CHKSTK
    ret
endm

Texmap2X256x256_16:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 16
Texmap2X256x256_15:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 15
Texmap2X256x256_14:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 14
Texmap2X256x256_13:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 13
Texmap2X256x256_12:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 12
Texmap2X256x256_11:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 11
Texmap2X256x256_10:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 10
Texmap2X256x256_9:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 9
Texmap2X256x256_8:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 8
Texmap2X256x256_7:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 7
Texmap2X256x256_6:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 6
Texmap2X256x256_5:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 5
Texmap2X256x256_4:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 4
Texmap2X256x256_3:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 3
Texmap2X256x256_2:
    TEXMAP2X_PIXEL    24, 8, 000FF0000h, 2
Texmap2X256x256_1:
    TEXMAP2X_LAST_PIXEL   24, 8, 000FF0000h

Texmap2X128x128_16:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 16
Texmap2X128x128_15:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 15
Texmap2X128x128_14:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 14
Texmap2X128x128_13:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 13
Texmap2X128x128_12:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 12
Texmap2X128x128_11:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 11
Texmap2X128x128_10:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 10
Texmap2X128x128_9:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 9
Texmap2X128x128_8:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 8
Texmap2X128x128_7:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 7
Texmap2X128x128_6:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 6
Texmap2X128x128_5:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 5
Texmap2X128x128_4:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 4
Texmap2X128x128_3:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 3
Texmap2X128x128_2:
    TEXMAP2X_PIXEL    25, 9, 0007F0000h, 2
Texmap2X128x128_1:
    TEXMAP2X_LAST_PIXEL   25, 9, 0007F0000h

Texmap2X64x64_16:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 16
Texmap2X64x64_15:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 15
Texmap2X64x64_14:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 14
Texmap2X64x64_13:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 13
Texmap2X64x64_12:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 12
Texmap2X64x64_11:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 11
Texmap2X64x64_10:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 10
Texmap2X64x64_9:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 9
Texmap2X64x64_8:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 8
Texmap2X64x64_7:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 7
Texmap2X64x64_6:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 6
Texmap2X64x64_5:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 5
Texmap2X64x64_4:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 4
Texmap2X64x64_3:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 3
Texmap2X64x64_2:
    TEXMAP2X_PIXEL    26, 10, 0003F0000h, 2
Texmap2X64x64_1:
    TEXMAP2X_LAST_PIXEL   26, 10, 0003F0000h

Texmap2X32x32_16:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 16
Texmap2X32x32_15:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 15
Texmap2X32x32_14:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 14
Texmap2X32x32_13:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 13
Texmap2X32x32_12:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 12
Texmap2X32x32_11:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 11
Texmap2X32x32_10:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 10
Texmap2X32x32_9:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 9
Texmap2X32x32_8:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 8
Texmap2X32x32_7:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 7
Texmap2X32x32_6:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 6
Texmap2X32x32_5:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 5
Texmap2X32x32_4:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 4
Texmap2X32x32_3:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 3
Texmap2X32x32_2:
    TEXMAP2X_PIXEL    27, 11, 0001F0000h, 2
Texmap2X32x32_1:
    TEXMAP2X_LAST_PIXEL   27, 11, 0001F0000h

Texmap2X16x16_16:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 16
Texmap2X16x16_15:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 15
Texmap2X16x16_14:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 14
Texmap2X16x16_13:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 13
Texmap2X16x16_12:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 12
Texmap2X16x16_11:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 11
Texmap2X16x16_10:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 10
Texmap2X16x16_9:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 9
Texmap2X16x16_8:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 8
Texmap2X16x16_7:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 7
Texmap2X16x16_6:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 6
Texmap2X16x16_5:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 5
Texmap2X16x16_4:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 4
Texmap2X16x16_3:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 3
Texmap2X16x16_2:
    TEXMAP2X_PIXEL    28, 12, 0000F0000h, 2
Texmap2X16x16_1:
    TEXMAP2X_LAST_PIXEL   28, 12, 0000F0000h

Texmap2X8x8_16:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 16
Texmap2X8x8_15:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 15
Texmap2X8x8_14:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 14
Texmap2X8x8_13:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 13
Texmap2X8x8_12:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 12
Texmap2X8x8_11:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 11
Texmap2X8x8_10:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 10
Texmap2X8x8_9:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 9
Texmap2X8x8_8:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 8
Texmap2X8x8_7:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 7
Texmap2X8x8_6:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 6
Texmap2X8x8_5:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 5
Texmap2X8x8_4:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 4
Texmap2X8x8_3:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 3
Texmap2X8x8_2:
    TEXMAP2X_PIXEL    29, 13, 000070000h, 2
Texmap2X8x8_1:
    TEXMAP2X_LAST_PIXEL   29, 13, 000070000h

Texmap2X4x4_16:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 16
Texmap2X4x4_15:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 15
Texmap2X4x4_14:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 14
Texmap2X4x4_13:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 13
Texmap2X4x4_12:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 12
Texmap2X4x4_11:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 11
Texmap2X4x4_10:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 10
Texmap2X4x4_9:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 9
Texmap2X4x4_8:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 8
Texmap2X4x4_7:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 7
Texmap2X4x4_6:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 6
Texmap2X4x4_5:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 5
Texmap2X4x4_4:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 4
Texmap2X4x4_3:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 3
Texmap2X4x4_2:
    TEXMAP2X_PIXEL    30, 14, 000030000h, 2
Texmap2X4x4_1:
    TEXMAP2X_LAST_PIXEL   30, 14, 000030000h

Texmap2X2x2_16:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 16
Texmap2X2x2_15:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 15
Texmap2X2x2_14:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 14
Texmap2X2x2_13:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 13
Texmap2X2x2_12:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 12
Texmap2X2x2_11:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 11
Texmap2X2x2_10:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 10
Texmap2X2x2_9:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 9
Texmap2X2x2_8:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 8
Texmap2X2x2_7:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 7
Texmap2X2x2_6:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 6
Texmap2X2x2_5:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 5
Texmap2X2x2_4:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 4
Texmap2X2x2_3:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 3
Texmap2X2x2_2:
    TEXMAP2X_PIXEL    31, 15, 000010000h, 2
Texmap2X2x2_1:
    TEXMAP2X_LAST_PIXEL   31, 15, 000010000h

Texmap2X1x1_16:
    TEXMAP2X_PIXEL_1x1    16
Texmap2X1x1_15:
    TEXMAP2X_PIXEL_1x1    15
Texmap2X1x1_14:
    TEXMAP2X_PIXEL_1x1    14
Texmap2X1x1_13:
    TEXMAP2X_PIXEL_1x1    13
Texmap2X1x1_12:
    TEXMAP2X_PIXEL_1x1    12
Texmap2X1x1_11:
    TEXMAP2X_PIXEL_1x1    11
Texmap2X1x1_10:
    TEXMAP2X_PIXEL_1x1    10
Texmap2X1x1_9:
    TEXMAP2X_PIXEL_1x1    9
Texmap2X1x1_8:
    TEXMAP2X_PIXEL_1x1    8
Texmap2X1x1_7:
    TEXMAP2X_PIXEL_1x1    7
Texmap2X1x1_6:
    TEXMAP2X_PIXEL_1x1    6
Texmap2X1x1_5:
    TEXMAP2X_PIXEL_1x1    5
Texmap2X1x1_4:
    TEXMAP2X_PIXEL_1x1    4
Texmap2X1x1_3:
    TEXMAP2X_PIXEL_1x1    3
Texmap2X1x1_2:
    TEXMAP2X_PIXEL_1x1    2
Texmap2X1x1_1:
    TEXMAP2X_LAST_PIXEL_1x1


    .data

    align   4
Texmap2XBySizeTable   label   dword
    dd  Texmap2X256x256_16, Texmap2X256x256_15, Texmap2X256x256_14, Texmap2X256x256_13
    dd  Texmap2X256x256_12, Texmap2X256x256_11, Texmap2X256x256_10, Texmap2X256x256_9
    dd  Texmap2X256x256_8,  Texmap2X256x256_7,  Texmap2X256x256_6,  Texmap2X256x256_5
    dd  Texmap2X256x256_4,  Texmap2X256x256_3,  Texmap2X256x256_2,  Texmap2X256x256_1

    dd  Texmap2X128x128_16, Texmap2X128x128_15, Texmap2X128x128_14, Texmap2X128x128_13
    dd  Texmap2X128x128_12, Texmap2X128x128_11, Texmap2X128x128_10, Texmap2X128x128_9
    dd  Texmap2X128x128_8,  Texmap2X128x128_7,  Texmap2X128x128_6,  Texmap2X128x128_5
    dd  Texmap2X128x128_4,  Texmap2X128x128_3,  Texmap2X128x128_2,  Texmap2X128x128_1

    dd  Texmap2X64x64_16, Texmap2X64x64_15, Texmap2X64x64_14, Texmap2X64x64_13
    dd  Texmap2X64x64_12, Texmap2X64x64_11, Texmap2X64x64_10, Texmap2X64x64_9
    dd  Texmap2X64x64_8,  Texmap2X64x64_7,  Texmap2X64x64_6,  Texmap2X64x64_5
    dd  Texmap2X64x64_4,  Texmap2X64x64_3,  Texmap2X64x64_2,  Texmap2X64x64_1

    dd  Texmap2X32x32_16, Texmap2X32x32_15, Texmap2X32x32_14, Texmap2X32x32_13
    dd  Texmap2X32x32_12, Texmap2X32x32_11, Texmap2X32x32_10, Texmap2X32x32_9
    dd  Texmap2X32x32_8,  Texmap2X32x32_7,  Texmap2X32x32_6,  Texmap2X32x32_5
    dd  Texmap2X32x32_4,  Texmap2X32x32_3,  Texmap2X32x32_2,  Texmap2X32x32_1

    dd  Texmap2X16x16_16, Texmap2X16x16_15, Texmap2X16x16_14, Texmap2X16x16_13
    dd  Texmap2X16x16_12, Texmap2X16x16_11, Texmap2X16x16_10, Texmap2X16x16_9
    dd  Texmap2X16x16_8,  Texmap2X16x16_7,  Texmap2X16x16_6,  Texmap2X16x16_5
    dd  Texmap2X16x16_4,  Texmap2X16x16_3,  Texmap2X16x16_2,  Texmap2X16x16_1

    dd  Texmap2X8x8_16, Texmap2X8x8_15, Texmap2X8x8_14, Texmap2X8x8_13
    dd  Texmap2X8x8_12, Texmap2X8x8_11, Texmap2X8x8_10, Texmap2X8x8_9
    dd  Texmap2X8x8_8,  Texmap2X8x8_7,  Texmap2X8x8_6,  Texmap2X8x8_5
    dd  Texmap2X8x8_4,  Texmap2X8x8_3,  Texmap2X8x8_2,  Texmap2X8x8_1

    dd  Texmap2X4x4_16, Texmap2X4x4_15, Texmap2X4x4_14, Texmap2X4x4_13
    dd  Texmap2X4x4_12, Texmap2X4x4_11, Texmap2X4x4_10, Texmap2X4x4_9
    dd  Texmap2X4x4_8,  Texmap2X4x4_7,  Texmap2X4x4_6,  Texmap2X4x4_5
    dd  Texmap2X4x4_4,  Texmap2X4x4_3,  Texmap2X4x4_2,  Texmap2X4x4_1

    dd  Texmap2X2x2_16, Texmap2X2x2_15, Texmap2X2x2_14, Texmap2X2x2_13
    dd  Texmap2X2x2_12, Texmap2X2x2_11, Texmap2X2x2_10, Texmap2X2x2_9
    dd  Texmap2X2x2_8,  Texmap2X2x2_7,  Texmap2X2x2_6,  Texmap2X2x2_5
    dd  Texmap2X2x2_4,  Texmap2X2x2_3,  Texmap2X2x2_2,  Texmap2X2x2_1

    dd  Texmap2X1x1_16, Texmap2X1x1_15, Texmap2X1x1_14, Texmap2X1x1_13
    dd  Texmap2X1x1_12, Texmap2X1x1_11, Texmap2X1x1_10, Texmap2X1x1_9
    dd  Texmap2X1x1_8,  Texmap2X1x1_7,  Texmap2X1x1_6,  Texmap2X1x1_5
    dd  Texmap2X1x1_4,  Texmap2X1x1_3,  Texmap2X1x1_2,  Texmap2X1x1_1

    .code
SpanTextureBackend2X_Wrap_Native_NoZ_10_NoAlphaTest   endp

OPTION PROLOGUE:    PrologueDef
OPTION EPILOGUE:    EpilogueDef

ENDIF ; USE_C EQ 0

END

