www.pudn.com > sn068s.zip > BG16E.NI
;%1 = label, %2 = priority - 0 = none, 1 = low, 2 = high %macro Plot_Lines_Unclipped_16_Even_C2 2 %if %2 > 0 %%return: ret ALIGNC %1_check: %if %2 == 1 || %2 == 3 mov [Tile_Priority_Unused],ch %endif add ebx,byte 2 ; Update screen pointer add edi,byte 8 dec ch jz %%return %endif EXPORT_C %1 ; Define label, entry point %%next_tile: mov al,[ebx+1] Check_Tile_Priority %2, %1_check 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 dl,al add esi,ebp and edx,byte 7*4 ; Get palette add ebx,byte 2 ; Update screen pointer mov edx,[palette_2bpl+edx] mov ebp,[TilesetAddress] add al,al ; Get X flip (now in MSB) push esi js near %%xflip and esi,0x3FF * 8 + 7 ; Clip to tileset add esi,ebp and esi,0xFFFF * 4 / 8 ; Clip to VRAM lea esi,[_TileCache2+esi*8] Plot_2_Paletted 0,4,0,2 Plot_2_Paletted 2,6,1,3 pop esi add esi,byte 8 and esi,0x3FF * 8 + 7 ; Clip to tileset add esi,[TilesetAddress] and esi,0xFFFF * 4 / 8 ; Clip to VRAM lea esi,[_TileCache2+esi*8] Plot_2_Paletted 0,4,4,6 Plot_2_Paletted 2,6,5,7 %if %2 == 1 || %2 == 3 mov [Tile_Priority_Used],ch %endif add edi,byte 8 dec ch jnz near %%next_tile ret ALIGNC %%xflip: add esi,byte 8 and esi,0x3FF * 8 + 7 ; Clip to tileset add esi,ebp and esi,0xFFFF * 4 / 8 ; Clip to VRAM lea esi,[_TileCache2+esi*8] Plot_2_Paletted 6,2,0,2 Plot_2_Paletted 4,0,1,3 pop esi and esi,0x3FF * 8 + 7 ; Clip to tileset add esi,[TilesetAddress] and esi,0xFFFF * 4 / 8 ; Clip to VRAM lea esi,[_TileCache2+esi*8] Plot_2_Paletted 6,2,4,6 Plot_2_Paletted 4,0,5,7 %if %2 == 1 || %2 == 3 mov [Tile_Priority_Used],ch %endif add edi,byte 8 dec ch jnz near %%next_tile ret %endmacro ;%1 = label, %2 = priority - 0 = none, 1 = low, 2 = high %macro Plot_Lines_Unclipped_16_Even_C4 2 %if %2 > 0 %%return: ret ALIGNC %1_check: %if %2 == 1 || %2 == 3 mov [Tile_Priority_Unused],ch %endif add ebx,byte 2 ; Update screen pointer add edi,byte 8 dec ch jz %%return %endif EXPORT_C %1 ; Define label, entry point %%next_tile: mov al,[ebx+1] Check_Tile_Priority %2, %1_check 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 dl,al add esi,ebp and edx,byte 7*4 ; Get palette add ebx,byte 2 ; Update screen pointer mov edx,[palette_4bpl+edx] mov ebp,[TilesetAddress] add al,al ; Get X flip (now in MSB) push esi js near %%xflip and esi,0x3FF * 8 + 7 ; Clip to tileset add esi,ebp and esi,0xFFFF * 2 / 8 ; Clip to VRAM lea esi,[_TileCache4+esi*8] Plot_2_Paletted 0,4,0,2 Plot_2_Paletted 2,6,1,3 pop esi add esi,byte 8 and esi,0x3FF * 8 + 7 ; Clip to tileset add esi,[TilesetAddress] and esi,0xFFFF * 2 / 8 ; Clip to VRAM lea esi,[_TileCache4+esi*8] Plot_2_Paletted 0,4,4,6 Plot_2_Paletted 2,6,5,7 %if %2 == 1 || %2 == 3 mov [Tile_Priority_Used],ch %endif add edi,byte 8 dec ch jnz near %%next_tile ret ALIGNC %%xflip: add esi,byte 8 and esi,0x3FF * 8 + 7 ; Clip to tileset add esi,ebp and esi,0xFFFF * 2 / 8 ; Clip to VRAM lea esi,[_TileCache4+esi*8] Plot_2_Paletted 6,2,0,2 Plot_2_Paletted 4,0,1,3 pop esi and esi,0x3FF * 8 + 7 ; Clip to tileset add esi,[TilesetAddress] and esi,0xFFFF * 2 / 8 ; Clip to VRAM lea esi,[_TileCache4+esi*8] Plot_2_Paletted 6,2,4,6 Plot_2_Paletted 4,0,5,7 %if %2 == 1 || %2 == 3 mov [Tile_Priority_Used],ch %endif add edi,byte 8 dec ch jnz near %%next_tile ret %endmacro %ifndef NO_NP_RENDER Plot_Lines_Unclipped_16_Even_C2 Plot_Lines_Unclipped_NP_16_Even_C2,0 %endif %ifndef NO_PLOTTER_PER_PRIORITY Plot_Lines_Unclipped_16_Even_C2 Plot_Lines_Unclipped_L_16_Even_C2,1 Plot_Lines_Unclipped_16_Even_C2 Plot_Lines_Unclipped_H_16_Even_C2,2 %else Plot_Lines_Unclipped_16_Even_C2 Plot_Lines_Unclipped_V_16_Even_C2,3 %endif %ifndef NO_NP_RENDER Plot_Lines_Unclipped_16_Even_C4 Plot_Lines_Unclipped_NP_16_Even_C4,0 %endif %ifndef NO_PLOTTER_PER_PRIORITY Plot_Lines_Unclipped_16_Even_C4 Plot_Lines_Unclipped_L_16_Even_C4,1 Plot_Lines_Unclipped_16_Even_C4 Plot_Lines_Unclipped_H_16_Even_C4,2 %else Plot_Lines_Unclipped_16_Even_C4 Plot_Lines_Unclipped_V_16_Even_C4,3 %endif %define R16E_Local_Bytes 20 %define R16E_Plotter esp+16 %define R16E_BG_Table esp+12 %define R16E_Current_Line esp+8 %define R16E_BaseDestPtr esp+4 %define R16E_Lines esp %macro Render_16_Even 1 mov edi,[R16E_BaseDestPtr] mov eax,[SetAddress+edx] add edi,[_SNES_Screen8] mov [TilesetAddress],eax push ebx mov ah,[TileCount2+edx] push edx push eax mov ecx,[VLMapAddress+edx] mov eax,[FirstPixel+edx] add ebx,ecx sub edi,eax mov ch,[TileCount1+edx] call dword [R16E_Plotter+12] pop ecx pop edx pop ebx test ch,ch jz .no_second_set add ebx,[VRMapAddress+edx] call dword [R16E_Plotter] .no_second_set: %ifndef LAYERS_PER_LINE mov edi,[R16E_BaseDestPtr] inc dword [R16E_Current_Line] add edi,GfxBufferLinePitch dec dword [R16E_Lines] mov [R16E_BaseDestPtr],edi ; Point screen to next line jnz near .next_line %endif mov edx,[R16E_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 R16E_Local_Bytes ret %endmacro %macro Render_16Ex8 1 %ifndef NO_NP_RENDER mov ecx,_Plot_Lines_Unclipped_NP_16_Even_C%1 test al,al jnz .have_plotter %endif %ifndef NO_PLOTTER_PER_PRIORITY ;cmp byte [Tile_priority_bit],0 cmp [Tile_priority_bit],al mov ecx,_Plot_Lines_Unclipped_H_16_Even_C%1 jz .have_plotter mov ecx,_Plot_Lines_Unclipped_L_16_Even_C%1 %else mov ecx,_Plot_Lines_Unclipped_V_16_Even_C%1 %endif .have_plotter: push ecx push edx push ebx push edi push ebp ;mov al,[Tile_priority_opcode] ;mov [_Plot_Lines_Unclipped_16_Even_C%1.priority],al .next_line: mov edx,[R16E_BG_Table] mov eax,[R16E_Current_Line] call Sort_Screen_Height_Mosaic mov eax,[R16E_Current_Line] Get_Current_Line SORT_TILES_8_TALL ; This sets up the screen vert 2! Render_16_Even %1 %endmacro %macro Render_16Ex16 1 %ifndef NO_NP_RENDER mov ecx,_Plot_Lines_Unclipped_NP_16_Even_C%1 test al,al jnz .have_plotter %endif %ifndef NO_PLOTTER_PER_PRIORITY ;cmp byte [Tile_priority_bit],0 cmp [Tile_priority_bit],al mov ecx,_Plot_Lines_Unclipped_H_16_Even_C%1 jz .have_plotter mov ecx,_Plot_Lines_Unclipped_L_16_Even_C%1 %else mov ecx,_Plot_Lines_Unclipped_V_16_Even_C%1 %endif .have_plotter: push ecx push edx push ebx push edi push ebp ;mov al,[Tile_priority_opcode] ;mov [_Plot_Lines_Unclipped_16_Even_C%1.priority],al .next_line: mov edx,[R16E_BG_Table] mov eax,[R16E_Current_Line] call Sort_Screen_Height_Mosaic mov eax,[R16E_Current_Line] Get_Current_Line SORT_TILES_16_TALL ; This sets up the screen vert 2! Render_16_Even %1 %endmacro ALIGNC EXPORT_C Render_16x8_Even_C2 Render_16Ex8 2 ALIGNC EXPORT_C Render_16x16_Even_C2 Render_16Ex16 2 ALIGNC EXPORT_C Render_16x8_Even_C4 Render_16Ex8 4 ALIGNC EXPORT_C Render_16x16_Even_C4 Render_16Ex16 4