⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mos3de01.asm

📁 Application sources:A084.ZIP
💻 ASM
📖 第 1 页 / 共 4 页
字号:
     add ebx,[tempdiv]
     mov eax,ebx
    ;or eax,1
    cdq
    mov ecx,6553
    idiv ecx
    mov [zl2],eax
   
   
;-----------------------------------------------------------------------
;;  xl3#=(yl2*Sin(alpha)+xl2*Cos(alpha))
    mov ebx,[yl2]
    mov eax,[alphacopy]
    call get_sinus
    imul ebx,[eax]
    mov [tempdiv],ebx ; is yl2*sin(alpha)
   
    mov ebx,[xl2]  ; xl2
    mov eax,[alphacopy]
    call get_cosinus
    imul ebx,[eax]  ; is xl2*cos(alpha
   
    add ebx,[tempdiv]
    mov eax,ebx
    ;or eax,1
    cdq
    mov ecx,6553
    idiv ecx
    mov [xl3],eax
   
   
;;  yl3#=(yl2*Cos(alpha)-xl2*Sin(alpha))
    mov ebx,[yl2]
    mov eax,[alphacopy]
    call get_cosinus
    imul ebx,[eax]
    mov [tempdiv],ebx ; is yl2*cos(alpha)
   
    mov ebx,[xl2]  ; xl2
    mov eax,[alphacopy]
    call get_sinus
    imul ebx,[eax]  ; is xl2*sin(alpha
   
    sub [tempdiv],ebx
    mov eax,[tempdiv]
    ;or eax,1
    cdq
    mov ecx,6553
    idiv ecx
    mov [yl3],eax
   
   
;;  zl3#=(zl2)
    mov eax,[zl2]
    mov [zl3],eax
   
;-----------------------------------------------------------------------
   
; *********************
;  PROJECTING 3D to 2D
   
;  If yloc# - Zoom <> 0 Then yloc = Int(yl3 ) * 200 / (zl3 - Zoom)
   ;-------
   mov ecx,[zl3]
   sub ecx,[zoom]
   mov eax,[yl3]
   imul eax,200
   or eax,1
   cdq
   idiv ecx
   ;mov eax,[yl3] ; no perpective
   mov [yloc],eax
   ;------
   
 ; If xloc# - Zoom <> 0 Then xloc = Int(xl3 ) * 200 / (zl3 - Zoom)
   
   ;------
   mov ecx,[zl3]
   sub ecx,[zoom]
   mov eax,[xl3]
   imul eax,200
   or eax,1
   cdq
   idiv ecx
   ;mov eax,[xl3] ; no perspective
   mov [xloc],eax
   ;------
   
;  xw(i)=((mausy#)*xloc) +160
;  yw(i)=((mausy#)*yloc) +120
;  zw(i)=(zl3+256)
   
   mov eax,[mousey] ; define scaling
   mov [factor],eax
   cmp eax,32000
   jl positivemousey
   mov [factor],dword 10
   jmp less220
   positivemousey:
   cmp eax,10
   jg more20
   mov [factor],dword 10
   jmp less220
   more20:
   cmp eax,220
   jl less220
   mov [factor],dword 220
   less220:
   
   mov eax,esi ; i...
   imul eax,4
   
   mov ecx,[xloc]
   mov eax,esi
   imul eax,4
   mov ebx,a_xw
   add ebx,eax
   imul ecx,[factor]
   sar ecx,5
   mov [ebx],ecx
   add [ebx],dword 160
   
   mov ecx,[yloc]
;   mov eax,esi
;   imul eax,4
   mov ebx,a_yw
   add ebx,eax
   imul ecx,[factor]
   sar ecx,5
   mov [ebx],ecx
   add [ebx],dword 120
   
   mov ecx,[zl3] ; used for z sorting
   mov ebx,a_zw
   add ebx,eax
   mov [ebx],ecx
   add [ebx],dword 256
   
; Next
  inc esi
  cmp esi,[anz]
  jle for_i
;---------------
   
   
  mov [sorted_quads],dword 0
   
   
; ; z-sorting...
; For i=0 To 10000 ; clear old info
;  zbuffer(i)=-1
; Next
  mov eax,zbuffer
  mov ebx,eax
  add ebx,40000
  clear_zbuffer:
  mov [eax],dword 1000000
  add eax,4
  cmp eax,ebx
  jle clear_zbuffer
   
   
   
; For i=0 To anz-3 Step 4
  mov eax,0
  mov ebx,[anz]
  for_i_0_to_anz:
   
;  If zw(i)>=0 ; clip Quads behind Camera
   mov ecx,eax
   imul ecx,4
   add ecx,a_zw
   mov edx,[ecx]
   cmp edx,0
   jle behindcamera
   
;   zwmax=zw(i)
    mov esi,edx
   
;   ;find quads internal most far point
;   If zwmax<zw(i+1) Then zwmax=zw(i+1)
;   If zwmax<zw(i+2) Then zwmax=zw(i+2)
;   If zwmax<zw(i+3) Then zwmax=zw(i+3)
    ; skip this for debugging
    ; jmp no_internal_sorting
    cmp esi,[ecx+4]
    jge checkmore1
    mov esi,[ecx+4]
    checkmore1:
   
    cmp esi,[ecx+8]
    jge checkmore2
    mov esi,[ecx+8]
    checkmore2:
   
    cmp esi,[ecx+12]
    jge checkmore3
    mov esi,[ecx+12]
    checkmore3:
   
    no_internal_sorting:
   
    mov [i],eax ; anz-ID in [i] (not times 4)
    push eax
    push ebx
   
;   While zbuffer(zwmax)<>-1 And zwmax<10000
;    zwmax=zwmax+1
;   Wend
    mov eax,esi  ; is actual z/poititon of point (used for z-order)
    imul eax,4
   
    findslot:
    mov ebx,eax
    add ebx,zbuffer
    cmp [ebx],dword 1000000
    je found_empty_slot
    add eax,4
    cmp eax,40000
    jl findslot
    found_empty_slot:
   
;   zbuffer(zwmax)=i
    inc dword[sorted_quads]  ; check slot writing
   
    mov ecx,[i]
    mov [ebx],ecx
   
    pop ebx
    pop eax
   
;  EndIf
   behindcamera:
; Next
  add eax,4
  cmp eax,[anz]  ;ebx
  jl for_i_0_to_anz
  ;----------------
   
  ;mov [rendered_quads],dword 0 ; debugging...
   
; For i2=10000 To 0 Step -1 ; reading quads in z-order from far to near
  mov eax,40000
  mov ebx,0
  for_i_0_to_10000:
   
   
;  i=zbuffer(i2)
   mov edx,eax
   add edx,zbuffer
   mov ecx,[edx] ; i...
   
;  If i>-1 And i< anz-2 ; if it isn't -1 then it's a Quad Point 1 ID
   cmp ecx,1000000
   je is_empty_slot
   
    ;inc dword[rendered_quads] ; used for debugging
   
;   ;***Mapping***
   
;   ;GetPolygonPoints(i)
;   ;FindSmallLargeY()
   
    mov [ilocal],ecx
    call get_polygon_points
    call find_small_large_y
   
;   X1% = Polypoints%(0, 0)
    mov edi,[polypoints]
    mov [x1],edi
;   Y1% = Polypoints%(0, 1)
    mov edi,[polypoints+4]
    mov [y1],edi
;   X2% = Polypoints%(1, 0)
    mov edi,[polypoints+8]
    mov [x2],edi
;   Y2% = Polypoints%(1, 1)
    mov edi,[polypoints+12]
    mov [y2],edi
   
;   ScanConvert(X1%, Y1%, X2%, Y2%, 1)     ;scan top of picture
    mov [pside],dword 1
    call scan_convert
   
;   X1% = Polypoints%(1, 0)
    mov edi,[polypoints+8]
    mov [x1],edi
;   Y1% = Polypoints%(1, 1)
    mov edi,[polypoints+12]
    mov [y1],edi
;   X2% = Polypoints%(2, 0)
    mov edi,[polypoints+16]
    mov [x2],edi
;   Y2% = Polypoints%(2, 1)
    mov edi,[polypoints+20]
    mov [y2],edi
   
;   ScanConvert(X1%, Y1%, X2%, Y2%, 2)   ;scan Right of picture
    mov [pside],dword 2
    call scan_convert
   
;   X1% = Polypoints%(2, 0)
    mov edi,[polypoints+16]
    mov [x1],edi
;   Y1% = Polypoints%(2, 1)
    mov edi,[polypoints+20]
    mov [y1],edi
;   X2% = Polypoints%(3, 0)
    mov edi,[polypoints+24]
    mov [x2],edi
;   Y2% = Polypoints%(3, 1)
    mov edi,[polypoints+28]
    mov [y2],edi
   
;   ScanConvert(X1%, Y1%, X2%, Y2%, 3)  ;scan bottom of picture
    mov [pside],dword 3
    call scan_convert
   
;   X1% = Polypoints%(3, 0)
    mov edi,[polypoints+24]
    mov [x1],edi
;   Y1% = Polypoints%(3, 1)
    mov edi,[polypoints+28]
    mov [y1],edi
;   X2% = Polypoints%(0, 0)
    mov edi,[polypoints]
    mov [x2],edi
;   Y2% = Polypoints%(0, 1)
    mov edi,[polypoints+4]
    mov [y2],edi
   
;   ScanConvert(X1%, Y1%, X2%, Y2%, 4)    ;scan Left of picture
    mov [pside],dword 4
    call scan_convert
   
;   TextureMap()
     call texture_map
   
;  EndIf
   is_empty_slot:
   
; Next
  sub eax,4
  cmp eax,0  ;ebx
  jge for_i_0_to_10000
   
;Wend
ret
   
;End
   
   
   
   
; ---------------------------------------------------------------------
   
get_sinus:
 imul eax,4 ; expects degree*10
 add eax,sinus
ret
   
get_cosinus:
 imul eax,4 ; expects degree*10
 add eax,sinus
 add eax,10804
 cmp eax,eosinus
 jl ok3600sub
 sub eax,14400
 ok3600sub:
ret
   
   
   
   
   
   
;; ------------------ texture mapping functions-----------------------------
   
;Function GetPolygonPoints(ilocal%) ; initially read in a rectangle
get_polygon_points:
pusha
; For Count% = 0 To 3
;  Polypoints%(Count%, 0) = xw(ilocal%+Count%)
;  Polypoints%(Count%, 1) = yw(ilocal%+Count%)
; Next
  mov eax,0
; ---
  count_0_3:
   
  mov ebx,eax
  imul ebx,8         ; count
  add ebx,polypoints  ; desti adr
  mov ecx,eax
  add ecx,[ilocal]
  imul ecx,4
  add ecx,a_xw      ; src adr
  mov edx,[ecx]
  mov [ebx],edx
  ; ----
  add ebx,4          ; desti 2
  mov ecx,eax
  add ecx,[ilocal]
  imul ecx,4
  add ecx,a_yw       ; src 2
  mov edx,[ecx]
  mov [ebx],edx
  ; ----
  inc eax
  cmp eax,4
  jl count_0_3
   
;End Function
 popa
ret
   
; -------------------------------------------------------------------------
   
;Function FindSmallLargeY()
find_small_large_y:
 pusha
; For Count% = 0 To 3
  mov eax,0
  for03b:
   
;  Ycoord% = Polypoints%(Count%, 1)
   mov ebx,eax
   imul ebx,8
   add ebx,4
   add ebx,polypoints
   mov ecx,[ebx]
   
;  If Ycoord% < Miny% Then       ; is this the New lowest y co-ord?
;   Miny% = Ycoord%             ; Yes...
;  End If
   cmp ecx,[miny]
   jge isge0
   mov [miny],ecx
   isge0:
   
;  If Ycoord% > Maxy% Then       ; is this the New highest y co-ord?
;   Maxy% = Ycoord%             ; Yes...
;  End If
   cmp ecx,[maxy]
   jle isge1
   mov [maxy],ecx
   isge1:
   
; Next
  inc eax
  cmp eax,4
  jl for03b
   
;End Function
 popa
ret
   
; -------------------------------------------------------------------------
   
   
;Function ScanConvert (X1%, Y1%, X2%, Y2%, Pside)
scan_convert:
 pusha
; If Y2% < Y1% Then
  mov eax,[y1]
  mov ebx,[y2]
  cmp eax,ebx
  jl l_else0
   
;  temp%=X1% : X1%=X2% : X2%=temp%
;  temp%=Y1% : Y1%=Y2% : Y2%=temp%
;  Lineheight% = (Y2% - Y1%)
;  ScanLeftSide(X1%, X2%, Y1%, Lineheight%, Pside)
   mov [y1],ebx ; swap y,x
   mov [y2],eax
    mov eax,[x1]
    mov ebx,[x2]
   mov [x1],ebx
   mov [x2],eax
   mov eax,[y1]
    mov ebx,[y2]
    ; eo swap
   sub ebx,eax
    mov [lineheight],ebx
    call scan_left_side
   jmp l_endif0
   
; Else
  l_else0:
   
;  Lineheight% = (Y2% - Y1%)
;  ScanRightSide(X1%, X2%, Y1%, Lineheight%, Pside)
   sub ebx,eax
   mov [lineheight],ebx
   call scan_right_side
   
; End If
  l_endif0:
;End Function
 popa
ret
; -------------------------------------------------------------------------
   
   
;Function ScanLeftSide (X1%, X2%, Ytop%, Lineheight%, Pside)
 scan_left_side:
  pusha
   
  mov eax,[y1]
  mov [ytop],eax
   
; Lineheight% = Lineheight% + 1       ; prevent divide by zero
  inc dword[lineheight]
; Xadd = (X2% - X1%) Shl 16
  mov edi,[x2]
  sub edi,[x1]
  sal edi,16
   
; Xadd = Xadd / Lineheight%
  mov eax,edi ; whole
  cdq
  mov ebx,[lineheight] ; divisor
; or ebx,1
  idiv ebx ; result now in eax
  mov [v_xadd],eax
   
; ------------
; If Pside = 1 Then
  cmp [pside],dword 1
  jne psidenot10
   
;  Px = Pwidth% - 1
;  Py = 0
   mov edi,[pwidth]
   mov esi,edi
   sub esi,1
   mov [px],esi
   mov [py],dword 0
;  Pxadd = -Pwidth%  / Lineheight%
;  Pyadd = 0
   mov eax,0
   sub eax,[pwidth]
   cdq
   mov ebx,[lineheight] ; divisor
   ;or ebx,1
   idiv ebx ; result now in eax

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -