📄 screen.asm
字号:
%macro Check_Present_OBJ 1
test byte %1,0x10
%endmacro
%macro Jump_Present_OBJ 2
Check_Present_OBJ %1
jnz (%2)
%endmacro
%macro Jump_Not_Present_OBJ 2
Check_Present_OBJ %1
jz (%2)
%endmacro
%macro Jump_BG3_Highest 1
cmp byte [C_LABEL(Base_BGMODE)],1
jne %%not_highest
test byte [C_LABEL(BGMODE)],8
jnz (%1)
%%not_highest:
%endmacro
%macro Jump_Not_BG3_Highest 1
cmp byte [C_LABEL(Base_BGMODE)],1
jne (%1)
test byte [C_LABEL(BGMODE)],8
jz (%1)
%endmacro
;requires current line in ebx, uses cl
%macro Check_Present_OBJ_Priority 1
mov cl,[OAM_Count_Priority+ebx*4-4+(%1)]
test cl,cl
%endmacro
%macro Jump_Present_OBJ_Priority 2
Check_Present_OBJ_Priority (%1)
jnz (%2)
%endmacro
%macro Jump_Not_Present_OBJ_Priority 2
Check_Present_OBJ_Priority (%1)
jz (%2)
%endmacro
%macro Get_Clip_Window 1
mov esi,[Window_Offset_First+(%1)*4]
%endmacro
%macro Render_SM01 2
Jump_Not_Present_Layer 4,[SM01_Layers+%1],%%bg4_lo_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
%ifndef NO_EARLY_PRIORITY_ELIMINATION
Jump_Present_Layer 3,[SM01_Layers+%1],%%bg4_lo_priority
Jump_Not_Present_OBJ [SM01_Layers+%1],%%bg4_no_priority
Jump_Present_OBJ_Priority 0,%%bg4_lo_priority
%%bg4_no_priority:
RENDER_LINE_NP 4
and byte [SM01_Layers+%1],~8
jmp %%bg3_done
%%bg4_lo_priority:
%endif
RENDER_LINE 4,0
%%bg4_lo_done:
Jump_Not_Present_Layer 3,[SM01_Layers+%1],%%bg3_lo_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
%ifndef NO_EARLY_PRIORITY_ELIMINATION
Jump_BG3_Highest %%bg3_lo_priority
Jump_Present_Layer 4,[SM01_Layers+%1],%%bg3_lo_priority
Jump_Not_Present_OBJ [SM01_Layers+%1],%%bg3_no_priority
Jump_Present_OBJ_Priority 0,%%bg3_lo_priority
%%bg3_no_priority:
RENDER_LINE_NP 3
and byte [SM01_Layers+%1],~4
jmp %%bg3_done
%%bg3_lo_priority:
%endif
RENDER_LINE 3,0
%%bg3_lo_done:
Jump_Not_Present_OBJ [SM01_Layers+%1],%%no_sprites_0
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
;inc ebx
mov dl,0x00
call Plot_Sprites
%%no_sprites_0:
Jump_Not_Present_Layer 4,[SM01_Layers+%1],%%bg4_hi_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
RENDER_LINE 4,1
%%bg4_hi_done:
Jump_Not_Present_Layer 3,[SM01_Layers+%1],%%bg3_hi_done
Jump_BG3_Highest %%bg3_hi_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
RENDER_LINE 3,1
%%bg3_hi_done:
%%bg3_done:
Jump_Not_Present_OBJ [SM01_Layers+%1],%%no_sprites_1
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
;inc ebx
mov dl,0x10
call Plot_Sprites
%%no_sprites_1:
Jump_Not_Present_Layer 2,[SM01_Layers+%1],%%bg2_lo_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
%ifndef NO_EARLY_PRIORITY_ELIMINATION
Jump_Present_Layer 1,[SM01_Layers+%1],%%bg2_lo_priority
Jump_Not_Present_OBJ [SM01_Layers+%1],%%bg2_no_priority
Jump_Present_OBJ_Priority 2,%%bg2_lo_priority
%%bg2_no_priority:
RENDER_LINE_NP 2
and byte [SM01_Layers+%1],~2
jmp %%bg1_done
%%bg2_lo_priority:
%endif
RENDER_LINE 2,0
%%bg2_lo_done:
Jump_Not_Present_Layer 1,[SM01_Layers+%1],%%bg1_lo_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
%ifndef NO_EARLY_PRIORITY_ELIMINATION
Jump_Present_Layer 2,[SM01_Layers+%1],%%bg1_lo_priority
Jump_Not_Present_OBJ [SM01_Layers+%1],%%bg1_no_priority
Jump_Present_OBJ_Priority 2,%%bg1_lo_priority
%%bg1_no_priority:
RENDER_LINE_NP 1
and byte [SM01_Layers+%1],~1
jmp %%bg1_done
%%bg1_lo_priority:
%endif
RENDER_LINE 1,0
%%bg1_lo_done:
Jump_Not_Present_OBJ [SM01_Layers+%1],%%no_sprites_2
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
;inc ebx
mov dl,0x20
call Plot_Sprites
%%no_sprites_2:
Jump_Not_Present_Layer 2,[SM01_Layers+%1],%%bg2_hi_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
RENDER_LINE 2,1
%%bg2_hi_done:
Jump_Not_Present_Layer 1,[SM01_Layers+%1],%%bg1_hi_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
RENDER_LINE 1,1
%%bg1_hi_done:
%%bg1_done:
Jump_Not_Present_OBJ [SM01_Layers+%1],%%no_sprites_3
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
;inc ebx
mov dl,0x30
call Plot_Sprites
%%no_sprites_3:
Jump_Not_BG3_Highest %%bg3_max_done
Jump_Not_Present_Layer 3,[SM01_Layers+%1],%%bg3_max_done
mov ebx,[SM01_Current_Line]
mov edi,[SM01_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
RENDER_LINE 3,1
%%bg3_max_done:
%endmacro
ALIGNC
EXPORT_C SCREEN_MODE_0
EXPORT_C SCREEN_MODE_1
push eax
push ebx
push edi
push ebp
push eax
.next_line:
mov edi,[C_LABEL(SNES_Screen8)] ; (256+16)*(239+1) framebuffer
; Clear the framebuffer
mov ebx,[SM01_BaseDestPtr]
%ifdef LAYERS_PER_LINE
mov ebp,1
%else
mov ebp,[SM01_Lines]
%endif
add edi,ebx
; Clear the framebuffer
call C_LABEL(Clear_Scanlines)
%ifndef LAYERS_PER_LINE
Render_SM01 0,[SM01_Lines]
Render_SM01 1,[SM01_Lines]
%else
Render_SM01 0,1
Render_SM01 1,1
mov eax,[SM01_Layers_Copy]
mov [SM01_Layers],eax
mov edi,[SM01_BaseDestPtr]
inc dword [SM01_Current_Line]
add edi,GfxBufferLinePitch
dec dword [SM01_Lines]
mov [SM01_BaseDestPtr],edi
jnz .next_line
%endif
add esp,byte SM01_Local_Bytes
ret
%if 0
Mode 2 - 2 background layers, 8x8 and 16x16 tile sizes
4bpl tile depth in layers 1 and 2
special: offset change data (h and v) stored in layer 3
Mode 3 - 2 background layers, 8x8 and 16x16 tile sizes
8bpl tile depth in layer 1, 4bpl tile depth in layer 2
special: direct color mode
Mode 4 - 2 background layers, 8x8 and 16x16 tile sizes
8bpl tile depth in layer 1, 2bpl tile depth in layer 2
special: direct color mode
offset change data (h or v?) stored in layer 3
Mode 5 - 2 background layers, 16x8 and 16x16 tile sizes
4bpl tile depth in layer 1, 2bpl tile depth in layer 2
special: 512 mode
Mode 6 - 1 background layer, 16x8 and 16x16 tile sizes
4bpl tile depth in layer 1
special: 512 mode
offset change data (h and v?) stored in layer 3 (?)
%endif
%define SM26_Local_Bytes 20
%define SM26_Layers_Copy esp+16
%define SM26_Current_Line esp+12
%define SM26_BaseDestPtr esp+8
%define SM26_Lines esp+4
%define SM26_Layers esp
%macro Render_SM26 2
Jump_Not_Present_Layer 2,[SM26_Layers+%1],%%bg2_lo_done
mov ebx,[SM26_Current_Line]
mov edi,[SM26_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
%ifndef NO_EARLY_PRIORITY_ELIMINATION
Jump_Present_Layer 1,[SM26_Layers+%1],%%bg2_lo_priority
Jump_Not_Present_OBJ [SM26_Layers+%1],%%bg2_no_priority
Jump_Present_OBJ_Priority 0,%%bg2_lo_priority
Jump_Present_OBJ_Priority 1,%%bg2_lo_priority
%%bg2_no_priority:
RENDER_LINE_NP 2
and byte [SM26_Layers+%1],~2
jmp %%bg2_done
%%bg2_lo_priority:
%endif
RENDER_LINE 2,0
%%bg2_lo_done:
Jump_Not_Present_OBJ [SM26_Layers+%1],%%no_sprites_0
mov ebx,[SM26_Current_Line]
mov edi,[SM26_BaseDestPtr]
mov ebp,%2
;inc ebx
mov dl,0x00
call Plot_Sprites
%%no_sprites_0:
Jump_Not_Present_Layer 1,[SM26_Layers+%1],%%bg1_lo_done
mov ebx,[SM26_Current_Line]
mov edi,[SM26_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
%ifndef NO_EARLY_PRIORITY_ELIMINATION
Jump_Present_Layer 2,[SM26_Layers+%1],%%bg1_lo_priority
Jump_Not_Present_OBJ [SM26_Layers+%1],%%bg1_no_priority
Jump_Present_OBJ_Priority 1,%%bg1_lo_priority
Jump_Present_OBJ_Priority 2,%%bg1_lo_priority
%%bg1_no_priority:
RENDER_LINE_NP 1
and byte [SM26_Layers+%1],~1
jmp %%bg1_done
%%bg1_lo_priority:
%endif
RENDER_LINE 1,0
%%bg1_lo_done:
Jump_Not_Present_OBJ [SM26_Layers+%1],%%no_sprites_1
mov ebx,[SM26_Current_Line]
mov edi,[SM26_BaseDestPtr]
mov ebp,%2
;inc ebx
mov dl,0x10
call Plot_Sprites
%%no_sprites_1:
Jump_Not_Present_Layer 2,[SM26_Layers+%1],%%bg2_hi_done
mov ebx,[SM26_Current_Line]
mov edi,[SM26_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
RENDER_LINE 2,1
%%bg2_hi_done:
%%bg2_done:
Jump_Not_Present_OBJ [SM26_Layers+%1],%%no_sprites_2
mov ebx,[SM26_Current_Line]
mov edi,[SM26_BaseDestPtr]
mov ebp,%2
;inc ebx
mov dl,0x20
call Plot_Sprites
%%no_sprites_2:
Jump_Not_Present_Layer 1,[SM26_Layers+%1],%%bg1_hi_done
mov ebx,[SM26_Current_Line]
mov edi,[SM26_BaseDestPtr]
mov ebp,%2
Get_Clip_Window %1
RENDER_LINE 1,1
%%bg1_hi_done:
%%bg1_done:
Jump_Not_Present_OBJ [SM26_Layers+%1],%%no_sprites_3
mov ebx,[SM26_Current_Line]
mov edi,[SM26_BaseDestPtr]
mov ebp,%2
;inc ebx
mov dl,0x30
call Plot_Sprites
%%no_sprites_3:
%endmacro
EXPORT_C SCREEN_MODE_2
EXPORT_C SCREEN_MODE_3
EXPORT_C SCREEN_MODE_4
EXPORT_C SCREEN_MODE_5
EXPORT_C SCREEN_MODE_6
push eax
push ebx
push edi
push ebp
push eax
.next_line:
mov edi,[C_LABEL(SNES_Screen8)] ; (256+16)*(239+1) framebuffer
; Clear the framebuffer
mov ebx,[SM26_BaseDestPtr]
%ifdef LAYERS_PER_LINE
mov ebp,1
%else
mov ebp,[SM26_Lines]
%endif
add edi,ebx
; Clear the framebuffer
call C_LABEL(Clear_Scanlines)
%ifndef LAYERS_PER_LINE
Render_SM26 0,[SM26_Lines]
Render_SM26 1,[SM26_Lines]
%else
Render_SM26 0,1
Render_SM26 1,1
mov eax,[SM26_Layers_Copy]
mov [SM26_Layers],eax
mov edi,[SM26_BaseDestPtr]
inc dword [SM26_Current_Line]
add edi,GfxBufferLinePitch
dec dword [SM26_Lines]
mov [SM26_BaseDestPtr],edi
jnz .next_line
%endif
add esp,byte SM26_Local_Bytes
ret
section .text
ALIGNC
section .data
ALIGND
section .bss
ALIGNB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -