📄 mode7ext.asm
字号:
jg near .nextval3w
cmp dword[.mode7yadder],-7F0h
jl near .nextval3w
test byte[mode7set],80h
jnz near .norep2w
mov eax,[.mode7xpos]
and eax,7FFh
mov [.mode7xrpos],eax
mov eax,[.mode7ypos]
and eax,7FFh
mov [.mode7yrpos],eax
; get tile data offset into edi
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
shl ebx,5
shr eax,3
and ebx,07FF8h
shl al,1
mov bl,al
mov edi,[vram]
xor ch,ch
mov [.mode7ptr],ebx
mov cl,[edi+ebx]
shl ecx,7
add edi,ecx
jmp .nextvalw
ALIGN16
.nextvalw
test byte[.mode7xrpos+1],08h
jnz .rposoffxw
.nextposxw
test byte[.mode7yrpos+1],08h
jnz near .rposoffyw
.nextposyw
mov cl,[.mode7yrpos+1]
mov eax,[.mode7xadder]
mov ch,[.mode7xrpos+1]
add [.mode7xrpos],eax
mov dl,[mode7tab+ecx]
mov eax,[.mode7yadder]
mov cl,[edi+edx]
sub [.mode7yrpos],eax
mov byte[esi+288],cl
test cl,80h
jnz .nodrawbw
or cl,cl
jz .nodrawbw
test byte[ebp],0FFh
jnz .nodrawbw
mov byte[esi],cl
.nodrawbw
inc esi
inc ebp
dec byte[.temp]
jnz .nextvalw
jmp .finishmode7w
.rposoffxw
mov al,[.mode7xinc]
mov edi,[vram]
add [.mode7ptr],al
mov ebx,[.mode7ptr]
xor ecx,ecx
mov cl,[edi+ebx]
mov eax,[.mode7xadd2]
shl ecx,7
sub [.mode7xrpos],eax
add edi,ecx
jmp .nextposxw
.rposoffyw
mov al,[.mode7yinc]
mov edi,[vram]
sub [.mode7ptr+1],al
and byte[.mode7ptr+1],7Fh
mov ebx,[.mode7ptr]
xor ecx,ecx
mov cl,[edi+ebx]
mov eax,[.mode7yadd2]
shl ecx,7
add [.mode7yrpos],eax
add edi,ecx
jmp .nextposyw
.finishmode7w
xor eax,eax
ret
;**********************************************************
; Mode 7, no repetition mode
;**********************************************************
.norep2w
test byte[mode7set],40h
jnz .tilerep2w
.nextvalb2w
cmp byte[.mode7ypos+2],3
ja .offscr2w
cmp byte[.mode7xpos+2],3
jbe near .offscr3w
.offscr2w
mov eax,[.mode7xadder]
mov ebx,[.mode7yadder]
add [.mode7xpos],eax
sub [.mode7ypos],ebx
inc esi
inc ebp
dec byte[.temp]
jnz near .nextvalb2w
jmp .finishmode7w
.tilerep2w
.nextvalb3w
cmp byte[.mode7ypos+2],3
ja .offscr2bw
cmp byte[.mode7xpos+2],3
jbe .offscr3w
.offscr2bw
mov ch,[.mode7xpos+1]
mov eax,[.mode7xadder]
mov cl,[.mode7ypos+1]
mov ebx,[.mode7yadder]
mov dl,[mode7tab+ecx]
add [.mode7xpos],eax
mov cl,[vrama+edx]
sub [.mode7ypos],ebx
mov byte[esi+288],cl
test cl,80h
jnz .nodraw2trb2w
or cl,cl
jz .nodraw2trb2w
test byte[ebp],0FFh
jnz .nodraw2trb2w
mov byte[esi],cl
.nodraw2trb2w
inc esi
inc ebp
dec byte[.temp]
jnz .nextvalb3w
jmp .finishmode7w
.offscr3w
mov eax,[.mode7xpos]
and eax,7FFh
mov [.mode7xrpos],eax
mov eax,[.mode7ypos]
and eax,7FFh
mov [.mode7yrpos],eax
; get tile data offset into edi
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
shl ebx,5
shr eax,3
and ebx,07FF8h
shl al,1
mov bl,al
mov edi,[vram]
xor ch,ch
mov [.mode7ptr],ebx
mov cl,[edi+ebx]
shl ecx,7
add edi,ecx
.nextvalrw
test byte[.mode7xrpos+1],08h
jnz .rposoffxrw
.nextposxrw
test byte[.mode7yrpos+1],08h
jnz near .rposoffyrw
.nextposyrw
mov cl,[.mode7yrpos+1]
mov eax,[.mode7xadder]
mov ch,[.mode7xrpos+1]
add [.mode7xrpos],eax
mov dl,[mode7tab+ecx]
mov eax,[.mode7yadder]
mov cl,[edi+edx]
sub [.mode7yrpos],eax
mov byte[esi+288],cl
test cl,80h
jnz .nodrawbrw
or cl,cl
jz .nodrawbrw
test byte[ebp],0FFh
jnz .nodrawbrw
mov byte[esi],cl
.nodrawbrw
inc esi
inc ebp
dec byte[.temp]
jnz .nextvalrw
jmp .finishmode7w
.rposoffxrw
mov al,[.mode7xinc]
mov edi,[vram]
add [.mode7ptr],al
mov cl,byte[.mode7xincc]
cmp byte[.mode7ptr],cl
je .roffw
.roffxretbw
mov ebx,[.mode7ptr]
xor ecx,ecx
mov cl,[edi+ebx]
mov eax,[.mode7xadd2]
shl ecx,7
sub [.mode7xrpos],eax
add edi,ecx
jmp .nextposxrw
.rposoffyrw
mov al,[.mode7yinc]
mov edi,[vram]
sub [.mode7ptr+1],al
js .roffw
.roffyretbw
mov ebx,[.mode7ptr]
xor ecx,ecx
mov cl,[edi+ebx]
mov eax,[.mode7yadd2]
shl ecx,7
add [.mode7yrpos],eax
add edi,ecx
jmp .nextposyrw
.roffw
test byte[mode7set],40h
jnz .tilerep3w
jmp .finishmode7w
.tilerep3w
and byte[.mode7yrpos+1],07h
and byte[.mode7xrpos+1],07h
mov cl,[.mode7yrpos+1]
mov eax,[.mode7xadder]
mov ch,[.mode7xrpos+1]
add [.mode7xrpos],eax
mov dl,[mode7tab+ecx]
mov eax,[.mode7yadder]
mov cl,[vrama+edx]
sub [.mode7yrpos],eax
mov byte[esi+288],cl
test cl,80h
jnz .nodrawbr2w
or cl,cl
jz .nodrawbr2w
test byte[ebp],0FFh
jnz .nodrawbr2w
mov byte[esi],cl
.nodrawbr2w
inc esi
inc ebp
dec byte[.temp]
jnz .tilerep3w
jmp .finishmode7w
;**********************************************************
; Mode 7, old routines
;**********************************************************
.nextval3w
test byte[mode7set],80h
jnz near .norepw
.nextval2w
; get tile # @ ([.mode7xpos],[.mode7ypos])
; get tile location in vram (tileloc=x*2+y*256)
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
mov cl,bl
mov ch,al
shl ebx,5
shr eax,3
mov dl,[mode7tab+ecx]
and ebx,07FF8h
shl al,1
mov bl,al
xor ch,ch
mov cl,[edi+ebx]
mov eax,[.mode7xadder]
shl ecx,7
add [.mode7xpos],eax
add ecx,edx
mov eax,[.mode7yadder]
mov cl,[edi+ecx]
sub [.mode7ypos],eax
mov byte[esi+288],cl
test cl,80h
jnz .nodraww
or cl,cl
jz .nodraww
test byte[ebp],0FFh
jnz .nodraww
mov byte[esi],cl
.nodraww
inc esi
inc ebp
dec byte[.temp]
jnz .nextval2w
xor eax,eax
ret
; Color repetition
.norepw
test byte[mode7set],40h
jnz near .tilerepw
.nextvalbw
; get tile # @ ([.mode7xpos],[.mode7ypos])
; get tile location in vram (tileloc=x*2+y*256)
cmp byte[.mode7ypos+2],3
ja near .offscrw
cmp byte[.mode7xpos+2],3
ja near .offscrw
.offscrwb
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
mov cl,bl
mov ch,al
shl ebx,5
shr eax,3
mov dl,[mode7tab+ecx]
and ebx,07FF8h
shl al,1
mov bl,al
xor ch,ch
mov cl,[edi+ebx]
mov eax,[.mode7xadder]
shl ecx,7
add [.mode7xpos],eax
add ecx,edx
mov eax,[.mode7yadder]
mov cl,[edi+ecx]
sub [.mode7ypos],eax
mov byte[esi+288],cl
test cl,80h
jnz .nodraw2w
or cl,cl
jz .nodraw2w
test byte[ebp],0FFh
jnz .nodraw2w
mov byte[esi],cl
.nodraw2w
inc esi
inc ebp
dec byte[.temp]
jnz near .nextvalbw
jmp .goonw
.offscrwc
cmp byte[.mode7ypos+2],3
ja .offscrw
cmp byte[.mode7xpos+2],3
jbe near .offscrwb
.offscrw
mov eax,[.mode7xadder]
mov ebx,[.mode7yadder]
add [.mode7xpos],eax
sub [.mode7ypos],ebx
inc esi
inc ebp
dec byte[.temp]
jnz .offscrwc
.goonw
xor eax,eax
ret
.tilerepw
.nextvalbtrw
; get tile # @ ([.mode7xpos],[.mode7ypos])
; get tile location in vram (tileloc=x*2+y*256)
cmp byte[.mode7ypos+2],3
ja near .offscrtrw
cmp byte[.mode7xpos+2],3
ja near .offscrtrw
.notoffscrtrw
mov ebx,[.mode7ypos+1]
mov eax,[.mode7xpos+1]
mov cl,bl
mov ch,al
shl ebx,5
shr eax,3
mov dl,[mode7tab+ecx]
and ebx,07FF8h
shl al,1
mov bl,al
xor ch,ch
mov cl,[edi+ebx]
mov eax,[.mode7xadder]
shl ecx,7
add [.mode7xpos],eax
add ecx,edx
mov eax,[.mode7yadder]
mov cl,[edi+ecx]
sub [.mode7ypos],eax
mov byte[esi+288],cl
test cl,80h
jnz .nodraw2trw
or cl,cl
jz .nodraw2trw
test byte[ebp],0FFh
jnz .nodraw2trw
mov byte[esi],cl
.nodraw2trw
inc esi
inc ebp
dec byte[.temp]
jnz near .nextvalbtrw
jmp .goonw
.offscrtrwb
cmp byte[.mode7ypos+2],3
ja .offscrtrw
cmp byte[.mode7xpos+2],3
jbe near .notoffscrtrw
.offscrtrw
mov ch,[.mode7xpos+1]
mov eax,[.mode7xadder]
mov cl,[.mode7ypos+1]
mov ebx,[.mode7yadder]
mov dl,[mode7tab+ecx]
add [.mode7xpos],eax
mov cl,[vrama+edx]
sub [.mode7ypos],ebx
mov byte[esi+288],cl
test cl,80h
jnz .nodraw2trbw
or cl,cl
jz .nodraw2trbw
test byte[ebp],0FFh
jnz .nodraw2trbw
mov byte[esi],cl
.nodraw2trbw
inc esi
inc ebp
dec byte[.temp]
jnz near .offscrtrwb
jmp .goonw
NEWSYM drawmode7extbg2
mov esi,[cwinptr]
mov [winptrref],esi
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+16
mov ecx,64
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+16
.nomosaic
cmp byte[curmosaicsz],1
jne .domosaic
cmp byte[winon],0
jne near .drawwin
.domosaic
mov ecx,256
.loop
mov al,[esi+288]
test al,80h
jz .nopr2
and al,7Fh
mov [esi],al
.nopr2
inc esi
loop .loop
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic
ret
.drawwin
mov ebp,[cwinptr]
mov byte[esi],cl
.nodrawbw
mov ecx,256
.loop2
mov al,[esi+288]
test byte[ebp],0FFh
jnz .nopr2b
test al,80h
jz .nopr2b
and al,7Fh
mov [esi],al
.nopr2b
inc esi
inc ebp
loop .loop2
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic
ret
%macro Mode7Normalng 0
mov byte[esi+75036],dl
test dl,80h
jnz %%nodrawb
or dl,dl
jz %%nodrawb
mov byte[esi],dl
%%nodrawb
inc esi
%endmacro
%macro Mode7Windowng 0
mov byte[esi+75036],dl
test dl,80h
jnz %%nodrawbw
or dl,dl
jz %%nodrawbw
test byte[ebp],0FFh
jnz %%nodrawbw
mov byte[esi],dl
%%nodrawbw
inc esi
inc ebp
%endmacro
NEWSYM drawmode7ngextbg
ProcessBuildWindow 0
mov esi,[cwinptr]
mov [winptrref],esi
Mode7Calculate
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+16
mov ecx,64
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+16
.nomosaic
; esi = pointer to video buffer
; edi = pointer to vram
; [.mode7xadder] = dword value to add to x value (decimal between 7 & 8bit)
; [.mode7yadder] = dword value to add to y value (decimal between 7 & 8bit)
; [.mode7xpos] = dword value of x position, decimal between 7 & 8bit
; [.mode7xpos+1] = word value of x position
; [.mode7ypos] = dword value of y position, decimal between 7 & 8bit
; [.mode7ypos+1] = word value of y position
xor ebx,ebx
xor edx,edx
xor ecx,ecx
mov dword[.mode7xadd2],800h
mov byte[.mode7xinc],2
mov byte[.mode7xincc],0
test dword[.mode7xadder],80000000h
jz .noneg
mov dword[.mode7xadd2],-800h
mov byte[.mode7xinc],-2
mov byte[.mode7xincc],0FEh
.noneg
mov dword[.mode7yadd2],800h
mov byte[.mode7yinc],1
test dword[.mode7yadder],80000000h
jz .noneg2
mov dword[.mode7yadd2],-800h
mov byte[.mode7yinc],-1
.noneg2
cmp byte[ngwinen],1
je near .drawmode7win
mov edi,[vram]
cmp dword[.mode7xadder],7F0h
jg near .nextval3
cmp dword[.mode7xadder],-7F0h
jl near .nextval3
cmp dword[.mode7yadder],7F0h
jg near .nextval3
cmp dword[.mode7yadder],-7F0h
jl near .nextval3
Mode7Process Mode7Normalng, domosaic, 1
.nextval3
Mode7ProcessB Mode7Normalng, domosaic, 1
ret
ALIGN32
.temp dd 0 ; for byte move left
.mode7xpos dd 0 ; x position
.tempa2 dd 0 ; keep this blank!
.mode7xrpos dd 0 ; x position
.tempa dd 0 ; keep this blank!
.mode7ypos dd 0 ; y position
.tempb2 dd 0 ; keep this blank!
.mode7yrpos dd 0 ; y position
.tempb dd 0 ; keep this blank!
.mode7xadder dd 0 ; number to add for x
.tempc2 dd 0 ; keep this blank!
.mode7xadd2 dd 0 ; number to add for x
.tempc dd 0 ; keep this blank!
.mode7yadder dd 0 ; number to add for y
.tempd2 dd 0 ; keep this blank!
.mode7yadd2 dd 0 ; number to add for y
.tempd dd 0 ; keep this blank!
.mode7ptr dd 0 ; pointer value
.mode7xinc dd 0 ; number to add for x
.mode7xincc dd 0 ; range check for x
.mode7yinc dd 0 ; number to add for y
.mode7xsloc dd 0 ; which screen x
.mode7ysloc dd 0 ; which screen y
.mode7xsrl dd 0 ; which relative screen x
.mode7ysrl dd 0 ; which relative screen y
.cxloc dw 0 ; cx location
.cyloc dw 0 ; cy location
.m7xaddofa dd 0
.m7xaddof2a dd 0
.m7yaddofa dd 0
.m7yaddof2a dd 0
.drawmode7win
.domosaicw
mov ebx,[.mode7xrpos]
mov [mode7xrpos],ebx
mov ebx,[.mode7yrpos]
mov [mode7yrpos],ebx
mov ebx,[.mode7xadder]
mov [mode7xadder],ebx
mov ebx,[.mode7yadder]
mov [mode7yadder],ebx
mov edi,[vram]
Mode7Processngw Mode7Normalng, domosaic, 1
NEWSYM drawmode7ngextbg2
; esi = pointer to video buffer
mov esi,[curvidoffset] ; esi = [vidbuffer] + curypos * 288 + 16
cmp byte[curmosaicsz],1
je .nomosaic
mov esi,xtravbuf+16
mov ecx,64
.clearnext
mov dword[esi],0
add esi,4
dec ecx
jnz .clearnext
mov esi,xtravbuf+16
.nomosaic
mov ecx,256
.loop
mov al,[esi+75036]
test al,80h
jz .nopr2
and al,7Fh
mov [esi],al
.nopr2
inc esi
loop .loop
xor eax,eax
mov dh,byte[curmosaicsz]
cmp dh,1
jne near domosaic
ret
NEWSYM Mode7ExtAsmEnd
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -