📄 bg16.asm
字号:
push esi
js %%xflip
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,edx
and esi,0xFFFF * 4 / 8 ; Clip to VRAM
Plot_8_Paletted_Lines_Clip_noflip (%3),C_LABEL(TileCache2)+esi*8,0,TileClip1
pop esi
%if %3
dec byte [esp+4]
%else
dec cl
%endif
jle %%early_out
%%leftedge_noflip:
add esi,byte 8
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF * 4 / 8 ; Clip to VRAM
%if %3
mov ebx,[BGLineCount]
%endif
Plot_8_Paletted_Lines_Clip_noflip (%3),C_LABEL(TileCache2)+esi*8,8,TileClip2
%if %3
pop ebx
pop ecx
%endif
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],cl
%endif
add edi,byte 16
dec cl
jg %%next_tile
ret
%%early_out:
%if %3
pop ebx
pop ecx
%endif
ret
ALIGNC
%%xflip:
add esi,byte 8
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,edx
and esi,0xFFFF * 4 / 8 ; Clip to VRAM
Plot_8_Paletted_Lines_Clip_Xflip (%3),C_LABEL(TileCache2)+esi*8,0,TileClip1
pop esi
%if %3
dec byte [esp+4]
%else
dec cl
%endif
jle %%early_out
%%leftedge_xflip:
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF * 4 / 8 ; Clip to VRAM
%if %3
mov ebx,[BGLineCount]
%endif
Plot_8_Paletted_Lines_Clip_Xflip (%3),C_LABEL(TileCache2)+esi*8,8,TileClip2
%if %3
pop ebx
pop ecx
%endif
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],cl
%endif
add edi,byte 16
dec cl
jg %%next_tile
ret
.LeftEdge:
mov al,[ebx+1]
Check_Tile_Priority %2, %1_check
dec cl
mov ebp,[LineAddressY]
test al,al ; Check Y flip
mov si,[ebx] ; Get tile #
%if %3
push ecx
mov ecx,-1
%endif
js %%leftedge_flip_y
mov ebp,[LineAddress]
%if %3
add ecx,byte (1 * 2)
%endif
%%leftedge_flip_y:
shl esi,3
mov edx,eax
add esi,ebp
and edx,byte 7*4 ; Get palette
add ebx,byte 2 ; Update screen pointer
mov ebp,[Palette_Base]
mov edx,[palette_2bpl+edx]
or ebp,edx ; Adjust palette for mode 0
mov edx,[TilesetAddress]
add al,al ; Get X flip (now in MSB)
%if %3
push ebx
mov ebx,[BGLineCount]
%endif
jns %%leftedge_noflip
jmp %%leftedge_xflip
%endmacro
;%1 = label, %2 = priority - 0 = none, 1 = low, 2 = high, %3 = multi-line
%macro Plot_Lines_16x16_C4 2-3 1
%if %2 > 0
%%return:
ret
ALIGNC
%1_check:
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Unused],cl
%endif
add ebx,byte 2 ; Update screen pointer
add edi,byte 16
sub cl,2
jle %%return
%else
ALIGNC
%endif
EXPORT_C %1 ; Define label, entry point
%%next_tile:
mov al,[ebx+1]
Check_Tile_Priority %2, %1_check
%if %3
push ecx
mov ecx,-1
%endif
mov ebp,[LineAddressY]
test al,al ; Check Y flip
mov si,[ebx] ; Get tile #
js %%flip_y
mov ebp,[LineAddress]
%if %3
add ecx,byte (1 * 2)
%endif
%%flip_y:
shl esi,3
mov edx,eax
add esi,ebp
add ebx,byte 2 ; Update screen pointer
and edx,byte 7*4 ; Get palette
mov ebp,[palette_4bpl+edx]
add al,al ; Get X flip (now in MSB)
mov edx,[TilesetAddress]
%if %3
push ebx
mov ebx,[BGLineCount]
%endif
push esi
js %%xflip
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,edx
and esi,0xFFFF * 2 / 8 ; Clip to VRAM
Plot_8_Paletted_Lines_Clip_noflip (%3),C_LABEL(TileCache4)+esi*8,0,TileClip1
pop esi
%if %3
dec byte [esp+4]
%else
dec cl
%endif
jle %%early_out
%%leftedge_noflip:
add esi,byte 8
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF * 2 / 8 ; Clip to VRAM
%if %3
mov ebx,[BGLineCount]
%endif
Plot_8_Paletted_Lines_Clip_noflip (%3),C_LABEL(TileCache4)+esi*8,8,TileClip2
%if %3
pop ebx
pop ecx
%endif
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],cl
%endif
add edi,byte 16
dec cl
jg %%next_tile
ret
%%early_out:
%if %3
pop ebx
pop ecx
%endif
ret
ALIGNC
%%xflip:
add esi,byte 8
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,edx
and esi,0xFFFF * 2 / 8 ; Clip to VRAM
Plot_8_Paletted_Lines_Clip_Xflip (%3),C_LABEL(TileCache4)+esi*8,0,TileClip1
pop esi
%if %3
dec byte [esp+4]
%else
dec cl
%endif
jle %%early_out
%%leftedge_xflip:
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF * 2 / 8 ; Clip to VRAM
%if %3
mov ebx,[BGLineCount]
%endif
Plot_8_Paletted_Lines_Clip_Xflip (%3),C_LABEL(TileCache4)+esi*8,8,TileClip2
%if %3
pop ebx
pop ecx
%endif
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],cl
%endif
add edi,byte 16
dec cl
jg %%next_tile
ret
.LeftEdge:
mov al,[ebx+1]
Check_Tile_Priority %2, %1_check
dec cl
mov ebp,[LineAddressY]
test al,al ; Check Y flip
mov si,[ebx] ; Get tile #
%if %3
push ecx
mov ecx,-1
%endif
js %%leftedge_flip_y
mov ebp,[LineAddress]
%if %3
add ecx,byte (1 * 2)
%endif
%%leftedge_flip_y:
shl esi,3
mov edx,eax
add esi,ebp
add ebx,byte 2 ; Update screen pointer
and edx,byte 7*4 ; Get palette
mov ebp,[palette_4bpl+edx]
add al,al ; Get X flip (now in MSB)
mov edx,[TilesetAddress]
%if %3
push ebx
mov ebx,[BGLineCount]
%endif
jns %%leftedge_noflip
jmp %%leftedge_xflip
%endmacro
;%1 = label, %2 = priority - 0 = none, 1 = low, 2 = high, %3 = multi-line
%macro Plot_Lines_16x16_C8 2-3 1
%if %2 > 0
%%return:
ret
ALIGNC
%1_check:
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Unused],cl
%endif
add ebx,byte 2 ; Update screen pointer
add edi,byte 16
sub cl,2
jle %%return
%else
ALIGNC
%endif
EXPORT_C %1 ; Define label, entry point
%%next_tile:
mov al,[ebx+1]
Check_Tile_Priority %2, %1_check
mov si,[ebx] ; Get tile #
add ebx,byte 2 ; Update screen pointer
shl esi,3
%if %3
push ecx
mov ecx,-1
%endif
test al,al ; Check Y flip
mov ebp,[LineAddressY]
js %%flip_y
mov ebp,[LineAddress]
%if %3
add ecx,byte (1 * 2)
%endif
%%flip_y:
add esi,ebp
mov ebp,[TilesetAddress]
add al,al ; Get X flip (now in MSB)
%if %3
push ebx
mov ebx,[BGLineCount]
%endif
push esi
js %%xflip
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,ebp
and esi,0xFFFF / 8 ; Clip to VRAM
Plot_8_Lines_Clip_noflip (%3),C_LABEL(TileCache8)+esi*8,0,TileClip1
pop esi
%if %3
dec byte [esp+4]
%else
dec cl
%endif
jle %%early_out
%%leftedge_noflip:
add esi,byte 8
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF / 8 ; Clip to VRAM
%if %3
mov ebx,[BGLineCount]
%endif
Plot_8_Lines_Clip_noflip (%3),C_LABEL(TileCache8)+esi*8,8,TileClip2
%if %3
pop ebx
pop ecx
%endif
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],cl
%endif
add edi,byte 16
dec cl
jg %%next_tile
ret
%%early_out:
%if %3
pop ebx
pop ecx
%endif
ret
ALIGNC
%%xflip:
add esi,byte 8
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,ebp
and esi,0xFFFF / 8 ; Clip to VRAM
Plot_8_Lines_Clip_Xflip (%3),C_LABEL(TileCache8)+esi*8,0,TileClip1
pop esi
%if %3
dec byte [esp+4]
%else
dec cl
%endif
jle %%early_out
%%leftedge_xflip:
and esi,0x3FF * 8 + 7 ; Clip to tileset
add esi,[TilesetAddress]
and esi,0xFFFF / 8 ; Clip to VRAM
%if %3
mov ebx,[BGLineCount]
%endif
Plot_8_Lines_Clip_Xflip (%3),C_LABEL(TileCache8)+esi*8,8,TileClip2
%if %3
pop ebx
pop ecx
%endif
%if %2 == 1 || %2 == 3
mov [Tile_Priority_Used],cl
%endif
add edi,byte 16
dec cl
jg %%next_tile
ret
.LeftEdge:
mov al,[ebx+1]
Check_Tile_Priority %2, %1_check
dec cl
mov si,[ebx] ; Get tile #
add ebx,byte 2 ; Update screen pointer
shl esi,3
%if %3
push ecx
mov ecx,-1
%endif
test al,al ; Check Y flip
mov ebp,[LineAddressY]
js %%leftedge_flip_y
mov ebp,[LineAddress]
%if %3
add ecx,byte (1 * 2)
%endif
%%leftedge_flip_y:
add esi,ebp
add al,al ; Get X flip (now in MSB)
mov edx,[TilesetAddress]
%if %3
push ebx
mov ebx,[BGLineCount]
%endif
jns %%leftedge_noflip
jmp %%leftedge_xflip
%endmacro
;%1 = depth, %2 = count
%macro Generate_Line_Plotters_16x16 2
%ifndef NO_NP_RENDER
Plot_Lines_16x16_C%1 Plot_Lines_%2_NP_16x16_C%1,0,%2
%endif
Plot_Lines_16x16_C%1 Plot_Lines_%2_V_16x16_C%1,3,%2
%endmacro
%macro Generate_Line_Plotters_16x16_Depth 1
Generate_Line_Plotters_16x16 %1,0
Generate_Line_Plotters_16x16 %1,1
%endmacro
Generate_Line_Plotters_16x16_Depth 2
Generate_Line_Plotters_16x16_Depth 4
Generate_Line_Plotters_16x16_Depth 8
section .data
ALIGND
;%1 = type, %2 = depth
%macro Generate_Line_Plotter_Table_16x16 2
EXPORT_C Plot_Lines_%1_16x16_Table_C%2
dd C_LABEL(Plot_Lines_0_%1_16x16_C%2)
dd C_LABEL(Plot_Lines_1_%1_16x16_C%2)
dd C_LABEL(Plot_Lines_0_%1_16x16_C%2).LeftEdge
dd C_LABEL(Plot_Lines_1_%1_16x16_C%2).LeftEdge
%endmacro
%ifndef NO_NP_RENDER
Generate_Line_Plotter_Table_16x16 NP,2
Generate_Line_Plotter_Table_16x16 NP,4
Generate_Line_Plotter_Table_16x16 NP,8
%endif
Generate_Line_Plotter_Table_16x16 V,2
Generate_Line_Plotter_Table_16x16 V,4
Generate_Line_Plotter_Table_16x16 V,8
section .text
ALIGNC
section .data
ALIGND
section .bss
ALIGNB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -