📄 bg16me.asm
字号:
and ebp,byte 7
shr eax,3
add eax,eax
add ebx,eax ; Update screen pointer
EXPORT_C %1 ; Define label, entry point
mov al,[ebx+1]
Check_Tile_Priority %2, %1_check
push ebx
push ebp
mov ebp,[LineAddressY]
test al,al ; Check Y flip
mov si,[ebx] ; Get tile #
js %%flip_y
mov ebp,[LineAddress]
%%flip_y:
shl esi,3
mov edx,eax
add esi,ebp
and edx,byte 7*4 ; Get palette
mov ebp,[Palette_Base]
mov edx,[palette_2bpl+edx]
or edx,ebp ; Adjust palette for mode 0
pop ebp
add al,al ; Get X flip (now in MSB)
mov eax,[Mosaic_Size]
js %%xflip
%%flip_none_same_tile:
push esi
push ebp
and ebp,byte 4
add ebp,ebp
add esi,ebp
xor ebp,byte -1
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF * 4 / 8 ; Clip to VRAM
lea esi,[C_LABEL(TileCache2)+esi*8+ebp+1]
pop ebp
cmp ecx,eax
ja %%flip_none_partial
mov eax,ecx
%%flip_none_partial:
mov bl,[esi+ebp*2]
pop esi
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],al
%endif
and bl,dl
jz %%flip_none_empty_run
;eax = count, esi = source base, ebp = offset, edi = dest, ecx = # left
;edx = palette, bl = pixel
add ebp,eax
sub ecx,eax
%%flip_none_next_pixel:
%assign PLM16E_Dest_Offset 0
%rep %3
mov [edi+PLM16E_Dest_Offset],bl
%assign PLM16E_Dest_Offset (PLM16E_Dest_Offset + GfxBufferLinePitch)
%endrep
inc edi
dec eax
jnz %%flip_none_next_pixel
mov eax,[Mosaic_Size]
test ecx,ecx
jz %%flip_none_return
cmp ebp,byte 8
jb %%flip_none_same_tile
pop ebx
jmp %%next_tile
ALIGNC
%%flip_none_empty_run:
add edi,eax
add ebp,eax
sub ecx,eax
jz %%flip_none_return
cmp ebp,byte 8
jb %%flip_none_same_tile
pop ebx
jmp %%next_tile
%%flip_none_return:
pop ebx
ret
ALIGNC
%%xflip:
xor ebp,byte -1
%%flip_x_same_tile:
push esi
push ebp
and ebp,byte 4
add ebp,ebp
add esi,ebp
xor ebp,byte 8
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF * 4 / 8 ; Clip to VRAM
lea esi,[C_LABEL(TileCache2)+esi*8+ebp+8]
pop ebp
cmp ecx,eax
ja %%flip_x_partial
mov eax,ecx
%%flip_x_partial:
mov bl,[esi+ebp*2]
pop esi
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],al
%endif
and bl,dl
jz %%flip_x_empty_run
;eax = count, esi = source base, ebp = offset, edi = dest, ecx = # left
;edx = palette, bl = pixel
sub ebp,eax
sub ecx,eax
%%flip_x_next_pixel:
%assign PLM16E_Dest_Offset 0
%rep %3
mov [edi+PLM16E_Dest_Offset],bl
%assign PLM16E_Dest_Offset (PLM16E_Dest_Offset + GfxBufferLinePitch)
%endrep
inc edi
dec eax
jnz %%flip_x_next_pixel
mov eax,[Mosaic_Size]
test ecx,ecx
jz %%flip_x_return
cmp ebp,byte ~8
ja %%flip_x_same_tile
pop ebx
xor ebp,byte -1
jmp %%next_tile
%%flip_x_empty_run:
add edi,eax
sub ebp,eax
sub ecx,eax
jz %%flip_x_return
cmp ebp,byte ~8
ja %%flip_x_same_tile
pop ebx
xor ebp,byte -1
jmp %%next_tile
%%flip_x_return:
pop ebx
ret
%endmacro
;%1 = label, %2 = priority - 0 = none, 1 = low, 2 = high, %3 = lines
%macro Plot_Lines_16M_Even_C4 3
ALIGNC
%if %2 > 0
%%wrong_priority_last:
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Unused],cl
%endif
add edi,ecx
add ebp,ecx
%%return:
ret
ALIGNC
%1_check:
mov eax,[Mosaic_Size]
%%wrong_priority_same_tile:
cmp ecx,eax
jbe %%wrong_priority_last
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Unused],al
%endif
add edi,eax
add ebp,eax
sub ecx,eax
cmp ebp,byte 8
jb %%wrong_priority_same_tile
%endif
%%next_tile:
mov eax,ebp
and ebp,byte 7
shr eax,3
add eax,eax
add ebx,eax ; Update screen pointer
EXPORT_C %1 ; Define label, entry point
mov al,[ebx+1]
Check_Tile_Priority %2, %1_check
push ebx
push ebp
mov ebp,[LineAddressY]
test al,al ; Check Y flip
mov si,[ebx] ; Get tile #
js %%flip_y
mov ebp,[LineAddress]
%%flip_y:
shl esi,3
mov edx,eax
add esi,ebp
and edx,byte 7*4 ; Get palette
mov edx,[palette_4bpl+edx]
pop ebp
add al,al ; Get X flip (now in MSB)
mov eax,[Mosaic_Size]
js %%xflip
%%flip_none_same_tile:
push esi
push ebp
and ebp,byte 4
add ebp,ebp
add esi,ebp
xor ebp,byte -1
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF * 2 / 8 ; Clip to VRAM
lea esi,[C_LABEL(TileCache4)+esi*8+ebp+1]
pop ebp
cmp ecx,eax
ja %%flip_none_partial
mov eax,ecx
%%flip_none_partial:
mov bl,[esi+ebp*2]
pop esi
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],al
%endif
and bl,dl
jz %%flip_none_empty_run
;eax = count, esi = source base, ebp = offset, edi = dest, ecx = # left
;edx = palette, bl = pixel
add ebp,eax
sub ecx,eax
%%flip_none_next_pixel:
%assign PLM16E_Dest_Offset 0
%rep %3
mov [edi+PLM16E_Dest_Offset],bl
%assign PLM16E_Dest_Offset (PLM16E_Dest_Offset + GfxBufferLinePitch)
%endrep
%undef PLM16E_Dest_Offset
inc edi
dec eax
jnz %%flip_none_next_pixel
mov eax,[Mosaic_Size]
test ecx,ecx
jz %%flip_none_return
cmp ebp,byte 8
jb %%flip_none_same_tile
pop ebx
jmp %%next_tile
%%flip_none_empty_run:
add edi,eax
add ebp,eax
sub ecx,eax
jz %%flip_none_return
cmp ebp,byte 8
jb %%flip_none_same_tile
pop ebx
jmp %%next_tile
%%flip_none_return:
pop ebx
ret
ALIGNC
%%xflip:
xor ebp,byte -1
%%flip_x_same_tile:
push esi
push ebp
and ebp,byte 4
add ebp,ebp
add esi,ebp
xor ebp,byte 8
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF * 2 / 8 ; Clip to VRAM
lea esi,[C_LABEL(TileCache4)+esi*8+ebp+8]
pop ebp
cmp ecx,eax
ja %%flip_x_partial
mov eax,ecx
%%flip_x_partial:
mov bl,[esi+ebp*2]
pop esi
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],al
%endif
and bl,dl
jz %%flip_x_empty_run
;eax = count, esi = source base, ebp = offset, edi = dest, ecx = # left
;edx = palette, bl = pixel
sub ebp,eax
sub ecx,eax
%%flip_x_next_pixel:
%assign PLM16E_Dest_Offset 0
%rep %3
mov [edi+PLM16E_Dest_Offset],bl
%assign PLM16E_Dest_Offset (PLM16E_Dest_Offset + GfxBufferLinePitch)
%endrep
%undef PLM16E_Dest_Offset
inc edi
dec eax
jnz %%flip_x_next_pixel
mov eax,[Mosaic_Size]
test ecx,ecx
jz %%flip_x_return
cmp ebp,byte ~8
ja %%flip_x_same_tile
pop ebx
xor ebp,byte -1
jmp %%next_tile
%%flip_x_empty_run:
add edi,eax
sub ebp,eax
sub ecx,eax
jz %%flip_x_return
cmp ebp,byte ~8
ja %%flip_x_same_tile
pop ebx
xor ebp,byte -1
jmp %%next_tile
%%flip_x_return:
pop ebx
ret
%endmacro
;%1 = depth, %2 = count
%macro Generate_Line_Plotters_16M_Even 2
%ifndef NO_NP_RENDER
Plot_Lines_16M_Even_C%1 Plot_Lines_%2_NP_16M_Even_C%1,0,%2
%endif
Plot_Lines_16M_Even_C%1 Plot_Lines_%2_V_16M_Even_C%1,3,%2
%endmacro
%macro Generate_Line_Plotters_16M_Even_Depth 1
Generate_Line_Plotters_16M_Even %1,1
Generate_Line_Plotters_16M_Even %1,2
Generate_Line_Plotters_16M_Even %1,3
Generate_Line_Plotters_16M_Even %1,4
Generate_Line_Plotters_16M_Even %1,5
Generate_Line_Plotters_16M_Even %1,6
Generate_Line_Plotters_16M_Even %1,7
Generate_Line_Plotters_16M_Even %1,8
%endmacro
Generate_Line_Plotters_16M_Even_Depth 2
Generate_Line_Plotters_16M_Even_Depth 4
section .data
;%1 = type, %2 = depth
%macro Generate_Line_Plotter_Table_16M_Even 2
ALIGND
EXPORT_C Plot_Lines_%1_16M_Even_Table_C%2
dd C_LABEL(Plot_Lines_1_%1_16M_Even_C%2)
dd C_LABEL(Plot_Lines_2_%1_16M_Even_C%2)
dd C_LABEL(Plot_Lines_3_%1_16M_Even_C%2)
dd C_LABEL(Plot_Lines_4_%1_16M_Even_C%2)
dd C_LABEL(Plot_Lines_5_%1_16M_Even_C%2)
dd C_LABEL(Plot_Lines_6_%1_16M_Even_C%2)
dd C_LABEL(Plot_Lines_7_%1_16M_Even_C%2)
dd C_LABEL(Plot_Lines_8_%1_16M_Even_C%2)
%endmacro
%ifndef NO_NP_RENDER
Generate_Line_Plotter_Table_16M_Even NP,2
Generate_Line_Plotter_Table_16M_Even NP,4
%endif
Generate_Line_Plotter_Table_16M_Even V,2
Generate_Line_Plotter_Table_16M_Even V,4
section .text
ALIGNC
section .data
ALIGND
section .bss
ALIGNB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -