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

📄 mario.asm

📁 超级马力``大家喜欢的游戏```有原代码
💻 ASM
📖 第 1 页 / 共 2 页
字号:
  .if Sprite.bOnLine 
     invoke CanFrameMovie
     .if eax    
        mov eax,Sprite.Frame
        inc eax
        .if (eax >8) || (eax <4)
             mov eax,5
        .endif  
        mov Sprite.Frame,eax
      .endif
  .else
     push 9
     pop  Sprite.Frame
  .endif
  ret

SpriteMoveLeft endp

SpriteMoveRight proc

  .if Sprite.x < 44 ; Not the Last screen 
     mov eax,Sprite.x_Detail
     add eax,Sprite.Speed
     mov Sprite.x_Detail,eax
     .if eax > 31
         inc Sprite.x
         sub Sprite.x_Detail ,32
     .endif
     .else
         push 0
         pop  Sprite.x_Detail
     .endif
      
     mov eax,Sprite.x
     sub eax,x_Index
     .if eax > 10 ; 17 -7
         mov eax , GateInfo.DataLen
         sub eax ,12*17
        .if x_nPos < eax ; Right Scroll Background
           mov eax , x_Detail
           add eax , Sprite.Speed
           mov x_Detail ,eax
           .if eax > 31 
              add x_nPos ,12
              inc x_Index
              mov eax ,x_Detail
              sub eax,32
              mov x_Detail,eax
           .endif
      .endif  
      
  .endif  
  
  .if Sprite.bOnLine
      invoke CanFrameMovie
      .if eax
          mov eax,Sprite.Frame
          inc eax
         .if eax >3
               mov eax,0
         .endif  
          mov Sprite.Frame,eax
      .endif
  .else
      push 4
      pop  Sprite.Frame
  .endif
  ret

SpriteMoveRight endp

CanMoveLeft proc
; check Sprite can move left    
LOCAL x1:DWORD
LOCAL y1:DWORD
LOCAL n1:DWORD
LOCAL n2:DWORD
  .if Sprite.x_Detail != 0 
      mov eax ,TRUE 
  .else 
     ; Sprite.x_Detail == 0
     .if Sprite.x == 0 
         mov eax ,FALSE 
     .else
        ; Sprite.x != 0
        mov eax,Sprite.x
        dec eax
        mov x1,eax
        mov eax,Sprite.y
        mov y1,eax
        invoke ReadMapXY,x1,y1
        mov n1,eax
        inc y1
        invoke ReadMapXY,x1,y1
        mov n2,eax
        .if (n1!=MAP_BRICK)&& (n1!= MAP_BRICK1)
            .if Sprite.y_Detail == 0
                mov eax ,TRUE 
            .else
                .if (n2!=MAP_BRICK)&&(n2!=MAP_BRICK1)
                    mov eax ,TRUE 
                .else
                    mov eax,FALSE 
                .endif
            .endif
        .else
           mov eax ,FALSE 
        .endif
   
     .endif
  .endif
  
  ret

CanMoveLeft endp

CanMoveRight proc
; check Sprite can move right
LOCAL x1:DWORD
LOCAL y1:DWORD
LOCAL n1:DWORD
LOCAL n2:DWORD

  .if Sprite.x_Detail != 0 
      mov eax ,TRUE ; can MoveRight
  .else
     mov eax,Sprite.x
     inc eax
     mov x1,eax
     push Sprite.y
     pop y1
     invoke ReadMapXY,x1,y1
     mov n1,eax
     inc y1
     invoke ReadMapXY,x1,y1
     mov n2,eax
     .if Sprite.y_Detail != 0 
         .if (n1!=MAP_BRICK)&& (n1!= MAP_BRICK1)
             .if (n2!= MAP_BRICK)&&(n2!= MAP_BRICK1)
                 mov eax,TRUE 
             .else
                 mov eax,FALSE 
             .endif
         .else
             mov eax,FALSE 
         .endif
     .else
        ;-- Sprite.y_Detail == 0
        .if (n1!= MAP_BRICK)&&(n1!=MAP_BRICK1)
            mov eax ,TRUE 
        .else
            mov eax, FALSE 
        .endif
     .endif
  .endif
  ret

CanMoveRight endp


JumpProc proc
LOCAL dwTime:DWORD
  invoke GetTickCount
  mov dwTime,eax
  sub eax,Sprite.JumpTimeLamp
  .if eax < JUMP_MAX_TIME
  sub Sprite.y_Detail ,ACTOR_JUMP_SPEED
  cmp Sprite.y_Detail,0
  jg @@1
  dec Sprite.y
  add Sprite.y_Detail,32
@@1:
  .endif

;  mov eax,Sprite.y
;  sub eax,Sprite.JumpBaseY
;  .if eax< MAX_JUMP_HEIGHT 
;  .endif  
  
  
  ret

JumpProc endp


InitApp proc
    
  invoke SendDlgItemMessage,hWnd,IDC_SBR1,SB_SETPARTS,STBAR_GRIDS,Addr Stbar_Parts
  invoke SendDlgItemMessage,hWnd,IDC_SBR1,SB_SETTEXT,0,Addr AppName

  ret

InitApp endp

UpdateWnd proc
LOCAL x:DWORD
LOCAL y:DWORD
;LOCAL dwTime:DWORD
LOCAL x1:DWORD
  
  push esi
  ; Draw Map
  mov esi ,GateInfo.BaseAddress
  add esi,x_nPos
  mov eax,0
  sub eax,x_Detail
  mov x,eax  ; x = - x_Detail
  
@@1:
  mov y,0
@@2:
  xor eax,eax
  mov al,[esi]
  inc esi
  shl eax,5
  mov x1,eax
  invoke BitBlt,hBackDc,x,y,32,32,hImagesDc,x1,0,SRCCOPY
  add y,32
  cmp y,12*32
  jb @@2
  
  add x,32
  cmp x,17*32
  jb @@1
    

  ; Draw Man 
  ; Screen x = (Sprite.x - x_Index )*32 - x_Detail + Sprite.x_Detail
  mov eax,Sprite.x
  sub eax,x_Index
  shl eax ,5  ; eax = eax *32
  sub eax,x_Detail
  add eax,Sprite.x_Detail ; Screen x
  mov x,eax
  ; Screen y = Sprite.y *32 + Sprite.y_Detail
  mov eax,Sprite.y
  shl eax,5
  add eax,Sprite.y_Detail
  mov y,eax
  
  mov eax,Sprite.Frame
  shl eax,5
  mov x1,eax
  
  ;invoke BitBlt,hBackDc,x,y,32,32,hActorDc,x1,0,SRCINVERT
  invoke BitBlt,hBackDc,x,y,32,32,hActorMaskDc,x1,0,SRCAND
  invoke BitBlt,hBackDc,x,y,32,32,hActorDc,x1,0,SRCPAINT
  
  ;invoke BitBlt,hBackDc,x,y,32,32,hImagesMaskDc,7*32,0,SRCAND
  ;invoke BitBlt,hBackDc,x,y,32,32,hImagesDc,7*32,0,SRCPAINT
  
  invoke TextOut,hBackDc,10,10,Addr AppName,5
  pop esi
  
  ret

UpdateWnd endp


Flip proc
    
  invoke BitBlt,hDc,LEFT_MARGIN,TOP_MARGIN,17*32,12*32,hBackDc,0,0,SRCCOPY  
  ret

Flip endp

SelectGate proc iGate:DWORD
LOCAL nPos :DWORD
  ; Load Gate information
  mov eax,offset Gates
  mov GateInfo.BaseAddress,eax
  push 45  ; width 45
  pop  GateInfo.dwWidth
  push 12*45
  pop  GateInfo.DataLen
  push iGate
  pop  GateInfo.Num
  ; refresh Gate information
  push esi
  mov esi,GateInfo.BaseAddress
  mov nPos ,-1
@@1:
  mov al,[esi]
  inc esi
  inc nPos  
  cmp al,MAP_MAN
  jnz @@1
@@2:  
  dec esi
  mov Byte ptr [esi],MAP_EMPTY

  xor edx,edx
  mov eax,nPos
  mov ebx ,12
  div ebx
  mov Sprite.x,eax
  mov Sprite.y,edx
  
  ;invoke wsprintf,Addr szFpsBuffer,Addr FpsFmtStr,Sprite.y
  ;invoke MessageBox,hWnd,Addr szFpsBuffer,Addr FpsFmtStr,MB_OK
  
  push GS_STARTGAME
  pop  GameState
  
  mov eax ,0
  mov Sprite.x_Detail,eax
  mov Sprite.y_Detail,eax
  
  mov x_Detail,eax
  mov x_Index,eax
  
  push ACTOR_LOW_SPEED
  pop  Sprite.Speed
  
  invoke RtlZeroMemory,Addr KeyState ,SizeOf(CKeyState)
  pop esi
  ret

SelectGate endp

ReadMapXY proc x:DWORD,y:DWORD
; return the (x,y) MapData
  push esi
  mov eax ,y
  cmp eax,0
  jl @@1
    ; eax > 0
    mov esi, GateInfo.BaseAddress  
    xor edx,edx
    mov eax,x
    mov ebx,12
    mul ebx 
    add eax,y ; x*12+ y
    add esi,eax 
    xor eax,eax
    mov al,byte ptr [esi] 
    jmp @@2
@@1:
    ; -- eax <0
    mov eax,0FFh
@@2:  
  pop  esi
  ret

ReadMapXY endp

CheckDrop proc
LOCAL y1:DWORD
LOCAL x1:DWORD

   push FALSE 
   pop  Sprite.bOnLine    
   
  .if Sprite.y_Detail != 0
      add Sprite.y_Detail,ACTOR_DROP_SPEED
  .else ; Sprite.y_Detail == 0
      mov eax ,Sprite.y
      inc eax
      mov y1,eax
      invoke ReadMapXY,Sprite.x,y1
      .if (al!= MAP_BRICK)&& (al!= MAP_BRICK1)
         ; Drop
         .if Sprite.x_Detail != 0 
             mov eax ,Sprite.x
             inc eax
             mov x1,eax
             invoke ReadMapXY,x1,y1
             .if (al!= MAP_BRICK)&&(al!= MAP_BRICK1)
                 add Sprite.y_Detail ,ACTOR_DROP_SPEED
             .endif
         .else
             add Sprite.y_Detail,ACTOR_DROP_SPEED
         .endif
      .else ;-- al = MAP_BRICK
          push TRUE 
          pop  Sprite.bOnLine
      .endif
  .endif

  .if Sprite.y_Detail >= 32
      inc Sprite.y
      sub Sprite.y_Detail,32
  .endif
           
  ret

CheckDrop endp

CheckGameOver proc
; Set the Game State    
   cmp Sprite.y,0
   jl @Exit
   ;  Sprite.y > 0
   .if Sprite.y >11
       push  GS_GAMEOVER
       pop   GameState 
   .endif    
@Exit:  
   ret

CheckGameOver endp

CalcFps proc
LOCAL dwDetal :DWORD
LOCAL dwTime :DWORD

  add FrameCount ,1
  invoke GetTickCount
  mov dwTime,eax
  sub eax,TimeLamp1
  mov dwDetal,eax
  .if eax > 1000
      xor edx,edx
      mov eax,FrameCount
      div dwDetal
      invoke wsprintf,Addr szFpsBuffer,Addr FpsFmtStr,edx
      invoke SendDlgItemMessage,hWnd,IDC_SBR1,SB_SETTEXT,0,addr szFpsBuffer
      push 0 
      pop  FrameCount
      push dwTime
      pop  TimeLamp1
  .endif
  
  ret

CalcFps endp

CanFrameMovie proc 
LOCAL dwTime:DWORD
  invoke GetTickCount
  mov dwTime,eax
  sub eax, Sprite.FrameTimeLamp
  .if eax > FRAME_MOVIE_INTERVAL ; if dwTime - FrameTimeLamp > FRAME_MOVIE_INTERVAL
      mov eax,dwTime
      mov Sprite.FrameTimeLamp,eax
      mov eax,TRUE 
  .else
      mov eax,FALSE 
  .endif
  
  ret

CanFrameMovie endp

end start

⌨️ 快捷键说明

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