📄 bg16ome.asm
字号:
xor ecx,ecx
mov cl,[edx+1]
mov edx,[RO16ME_BG_Table]
sub cl,bl
setz ch
mov [RO16MER_Next_Pixel],ebx
mov [RO16MER_Pixel_Count],ecx
dec al
je .last_run
.not_last_run:
mov [RO16ME_Runs_Left],al
call Render_Offset_16M_Even_Run
mov edx,[RO16ME_RunListPtr]
mov edi,[RO16ME_Output]
xor ebx,ebx
xor ecx,ecx
mov bl,[edx+2]
mov cl,[edx+3]
add edx,byte 2
sub cl,bl
mov [RO16ME_RunListPtr],edx
mov edx,[RO16ME_BG_Table]
mov [RO16MER_Next_Pixel],ebx
mov [RO16MER_Pixel_Count],ecx
mov al,[RO16ME_Runs_Left]
dec al
jne .not_last_run
.last_run:
call Render_Offset_16M_Even_Run
.done:
mov ebp,[RO16MER_LineCount]
mov eax,[RO16ME_Current_Line]
mov ecx,[RO16ME_Lines]
mov edx,[RO16ME_Countdown]
add eax,ebp
sub edx,ebp
jne .no_update_linecounter
mov [RO16ME_Current_Line_Mosaic],eax
.no_update_linecounter:
mov edi,[RO16ME_BaseDestPtr]
mov [RO16ME_Current_Line],eax
mov eax,ebp
mov [RO16ME_Countdown],edx
shl eax,8
lea edx,[edi+ebp*GfxBufferLineSlack]
add eax,edx
sub ecx,ebp
mov [RO16ME_BaseDestPtr],eax
mov [RO16ME_Lines],ecx
%ifndef LAYERS_PER_LINE
;cmp dword [RO16ME_Lines],0
jnz .next_line
%endif
mov edx,[RO16ME_BG_Table]
mov al,[Tile_Priority_Used]
mov [Priority_Used+edx],al
mov ah,[Tile_Priority_Unused]
mov [Priority_Unused+edx],ah
add esp,byte RO16ME_Local_Bytes
ret
%endmacro
Render_Offset_16M_Even 4,8
Render_Offset_16M_Even 4,16
;%1 = label, %2 = priority - 0 = none, 1 = low, 2 = high, %3 = lines,
;%4 = tile height
%macro Plot_Lines_Offset_16M_Even_C4 4
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:
pop ebp
pop ebx
pop esi
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
lea esi,[esi+eax-2]
EXPORT_C %1 ; Define label, entry point
lea eax,[esi+2]
mov dh,[1+esi] ; Offset change map
push eax
push ebx
push ebp
mov ebp,[RO16ME_FirstTile+RO16ME_Inner+12]
mov eax,[OffsetChangeVMap_VOffset]
test dh,[RO16ME_OC_Flag+RO16ME_Inner+12] ; H-offset enabled?
jz .have_h_offset
mov dl,[esi]
mov ebp,edx
shr ebp,3
add ebp,ebp
.have_h_offset:
mov dh,[1+esi+eax] ; Vertical offset change map
test dh,[RO16ME_OC_Flag+RO16ME_Inner+12] ; V-offset enabled?
jz .No_VChange
mov dl,[esi+eax]
mov eax,[RO16ME_Current_Line_Offset+RO16ME_Inner+12]
add eax,edx
.calc_v_offset:
and ah,(%4) / 8
mov esi,[RO16ME_TMapAddress+RO16ME_Inner+12]
jz .line_in_screen_map_top
mov esi,[RO16ME_BMapAddress+RO16ME_Inner+12]
.line_in_screen_map_top:
; al contains real Y offset for next tile
push ecx
%if %4 == 8
mov ecx,0xF8
mov edx,7
and ecx,eax
and eax,byte 7
sub edx,eax
lea esi,[esi+ecx*8] ; Get screen offset
%else
shl eax,2 ; Get screen offset
mov ecx,0x1F0*4 ; Current line + V scroll * 32words
and ecx,eax
and eax,byte 0x0F*4 ; Offset into table of line offsets
mov edx,16*8+7
mov eax,[Tile_Offset_Table_16_8+eax]
sub edx,eax
add esi,ecx
%endif
pop ecx
jmp .have_v_offset
.LeftEdge:
push esi
push ebx
push ebp
mov ebp,[RO16ME_FirstTile+RO16ME_Inner+12]
.No_VChange:
mov eax,[LineAddress]
mov esi,[RO16ME_MapAddress_Current+RO16ME_Inner+12]
mov edx,[LineAddressY]
.have_v_offset:
add ebp,ebx
mov [RO16ME_LineAddressOffset+RO16ME_Inner+12],eax
mov ebx,ebp
and ebp,byte 31*2 ; X offset wrap
mov [RO16ME_LineAddressOffsetY+RO16ME_Inner+12],edx
add esi,ebp ; Combine X and Y offsets into tile map
and ebx,byte 32*2
mov ebx,[RO16ME_RMapDifference+RO16ME_Inner+12]
jz .tile_in_screen_map_left
add esi,ebx
.tile_in_screen_map_left:
mov al,[esi+1]
Check_Tile_Priority %2, %1_check
mov ebp,[RO16ME_LineAddressOffsetY+RO16ME_Inner+12]
test al,al ; Check Y flip
mov si,[esi] ; Get tile #
js .flip_y
mov ebp,[RO16ME_LineAddressOffset+RO16ME_Inner+12]
.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
pop esi
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
pop esi
jmp %%next_tile
%%flip_none_return:
pop ebx
pop esi
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
pop esi
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
pop esi
xor ebp,byte -1
jmp %%next_tile
%%flip_x_return:
pop ebx
pop esi
ret
%endmacro
;%1 = depth, %2 = count, %3 = tile height
%macro Generate_Line_Plotters_Offset_16M_Even 3
%ifndef NO_NP_RENDER
Plot_Lines_Offset_16M_Even_C%1 Plot_Lines_%2_NP_Offset_16x%3M_Even_C%1,0,%2,%3
%endif
Plot_Lines_Offset_16M_Even_C%1 Plot_Lines_%2_V_Offset_16x%3M_Even_C%1,3,%2,%3
%endmacro
%macro Generate_Line_Plotters_Offset_16M_Even_Depth 2
%assign GLPO_16ME_Count 1
%rep RO16ME_MAX_LINE_COUNT
Generate_Line_Plotters_Offset_16M_Even %1,GLPO_16ME_Count,%2
%assign GLPO_16ME_Count GLPO_16ME_Count+1
%endrep
%undef GLPO_16ME_Count
%endmacro
Generate_Line_Plotters_Offset_16M_Even_Depth 4,8
Generate_Line_Plotters_Offset_16M_Even_Depth 4,16
section .data
%macro Generate_Line_Plotter_Offsets_16M_Even 4
dd C_LABEL(Plot_Lines_%3_%1_Offset_16x%4M_Even_C%2).LeftEdge
dd C_LABEL(Plot_Lines_%3_%1_Offset_16x%4M_Even_C%2)
%endmacro
;%1 = type, %2 = depth, %3 = tile height
%macro Generate_Line_Plotter_Table_Offset_16M_Even 3
ALIGND
EXPORT_C Plot_Lines_%1_Offset_16x%3M_Even_Table_C%2
%assign GLPTO_16ME_Count 1
%rep RO16ME_MAX_LINE_COUNT
Generate_Line_Plotter_Offsets_16M_Even %1,%2,GLPTO_16ME_Count,%3
%assign GLPTO_16ME_Count GLPTO_16ME_Count+1
%endrep
%undef GLPTO_16ME_Count
%endmacro
%ifndef NO_NP_RENDER
Generate_Line_Plotter_Table_Offset_16M_Even NP,4,8
Generate_Line_Plotter_Table_Offset_16M_Even NP,4,16
%endif
Generate_Line_Plotter_Table_Offset_16M_Even V,4,8
Generate_Line_Plotter_Table_Offset_16M_Even V,4,16
section .text
ALIGNC
section .data
ALIGND
section .bss
ALIGNB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -