YuChen Lee
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 最終成果 [連結](https://drive.google.com/file/d/1bNwdHSQBdKQTQZ1v8bziRWLL1Msduuh6/view?usp=sharing) ![Screenshot 2025-01-20 212550](https://hackmd.io/_uploads/Bkiaw6Lcyg.png) # 我的code op2_selecting PROC cmp load2opY, 1 je dh2 jg dhB2 dhB2: cmp load2opY, 17 js mid je bottom bottom: mov load2opY, 19 cmp load2opX, 108 jg setX js L1 setX: mov load2opX, 107 L1: INVOKE DrawPic,OFFSET clearOP,LENGTHOF clearOP,85,5 INVOKE PrintNPixel, lightblue, load2opX, load2opY, 3 INVOKE DrawPic,OFFSET lookLeftMonster,LENGTHOF lookLeftMonster, 75,5 mov eax, 10 call Delay INVOKE PrintNPixel, black, load2opX, load2opY, 3 cmp load2opX, 65 je u jg l u: sub load2opY, 2 jmp up l: jmp toleft mid: cmp load2opX, 85 jg rig js lef rig: INVOKE DrawPic,OFFSET clearOP,LENGTHOF clearOP,95,5 INVOKE DrawPic,OFFSET lookLeftMonster,LENGTHOF lookLeftMonster, 85,5 INVOKE PrintNPixel, lightblue, load2opX, load2opY, 2 mov eax, 10 call Delay INVOKE PrintNPixel, black, load2opX, load2opY, 2 jmp down lef: INVOKE DrawPic,OFFSET clearOP,LENGTHOF clearOP,75,5 INVOKE DrawPic,OFFSET lookLeftMonster,LENGTHOF lookLeftMonster, 65,5 INVOKE PrintNPixel, lightblue, load2opX, load2opY, 2 mov eax, 10 call Delay INVOKE PrintNPixel, black, load2opX, load2opY, 2 jmp up dh2: INVOKE DrawPic,OFFSET clearOP,LENGTHOF clearOP,65,5 INVOKE DrawPic,OFFSET lookLeftMonster,LENGTHOF lookLeftMonster, 95,5 mov load2opY, 1 INVOKE PrintNPixel, lightblue, load2opX, load2opY, 3 mov eax, 10 call Delay INVOKE PrintNPixel, black, load2opX, load2opY, 3 cmp load2opX, 107 js toright je down down: add load2opY, 1 mov load2opX, 112 call ResetColor ret toright: add load2opX, 3 call ResetColor ret up: sub load2opY, 1 mov load2opX, 61 ret toleft: sub load2opX, 3 call ResetColor ret op2_selecting ENDP # code link https://drive.google.com/file/d/1bNwdHSQBdKQTQZ1v8bziRWLL1Msduuh6/view?usp=drive_link # display.asm ## 在主程式碼宣告 ```as= ;make text color white, background color black ResetColor PROTO PrintPixel PROTO, backgroundColor: WORD, x:BYTE, y:BYTE DrawNum PROTO, number:DWORD, xP:BYTE, yP:BYTE DrawPic PROTO, picture: ptr byte, totalLength: WORD, xP:BYTE, yP:BYTE ``` ## 在另一個asm檔 ```as= INCLUDE Irvine32.inc ;draw one pixel at x y PrintPixel PROTO, backgroundColor: WORD, x:BYTE, y:BYTE ;draw a picture from x,y DrawPic PROTO, picture: ptr byte, totalLength: WORD, xP:BYTE, yP:BYTE ;private function DrawDigit PROTO, number: BYTE, xP:BYTE, yP:BYTE ;draw a num at x y DrawNum PROTO, number:DWORD, xP:BYTE, yP:BYTE .data num_0 BYTE "NWWWZ", "WNWZ", "WNWZ", "WNWZ", "WWWZ",0 num_1 BYTE "NNWNZ", "NWNZ", "NWNZ", "NWNZ", "NWNZ",0 num_2 BYTE "NWWWZ", "NNWZ", "WWWZ", "WNNZ", "WWWZ",0 num_3 BYTE "NWWWZ", "NNWZ", "WWWZ", "NNWZ", "WWWZ",0 num_4 BYTE "NWNWZ", "WNWZ", "WWWZ", "NNWZ", "NNWZ",0 num_5 BYTE "NWWWZ", "WNNZ", "WWWZ", "NNWZ", "WWWZ",0 num_6 BYTE "NWWWZ", "WNNZ", "WWWZ", "WNWZ", "WWWZ",0 num_7 BYTE "NWWWZ", "NNWZ", "NNWZ", "NNWZ", "NNWZ",0 num_8 BYTE "NWWWZ", "WNWZ", "WWWZ", "WNWZ", "WWWZ",0 num_9 BYTE "NWWWZ", "WNWZ", "WWWZ", "NNWZ", "WWWZ",0 buffer BYTE 11 DUP(?) .code PrintPixel PROC USES eax edx ebx, backgroundColor: WORD, x:BYTE, y:BYTE mov dl,x mov dh,y call Gotoxy movsx eax, backgroundColor mov ebx, eax shl eax,4 add eax, ebx call setTextColor mov eax,'.' call WriteChar call WriteChar mov eax,0 call delay ret PrintPixel ENDP DrawDigit PROC USES eax ebx ecx edx, number: BYTE, xP: BYTE, yP: BYTE .IF (number==0) INVOKE drawPic,OFFSET num_0,LENGTHOF num_0,xP,yP .ENDIF .IF (number==1) INVOKE drawPic,OFFSET num_1,LENGTHOF num_0,xP,yP .ENDIF .IF (number==2) INVOKE drawPic,OFFSET num_2,LENGTHOF num_0,xP,yP .ENDIF .IF (number==3) INVOKE drawPic,OFFSET num_3,LENGTHOF num_0,xP,yP .ENDIF .IF (number==4) INVOKE drawPic,OFFSET num_4,LENGTHOF num_0,xP,yP .ENDIF .IF (number==5) INVOKE drawPic,OFFSET num_5,LENGTHOF num_0,xP,yP .ENDIF .IF (number==6) INVOKE drawPic,OFFSET num_6,LENGTHOF num_0,xP,yP .ENDIF .IF (number==7) INVOKE drawPic,OFFSET num_7,LENGTHOF num_0,xP,yP .ENDIF .IF (number==8) INVOKE drawPic,OFFSET num_8,LENGTHOF num_0,xP,yP .ENDIF .IF (number==9) INVOKE drawPic,OFFSET num_9,LENGTHOF num_0,xP,yP .ENDIF ret DrawDigit ENDP DrawPic PROC USES eax ebx ecx edx, picture: ptr byte, totalLength : WORD, xP:BYTE , yP:BYTE , movzx ecx, totalLength mov ebx,0 movzx dx, xP L1: mov esi,picture add esi,ebx mov al,[esi] cmp al , 'S' je nextChar cmp al, 'Z' jne Zcontinute nextLine: inc yP mov xP, dl jp nextChar Zcontinute: cmp al,'G' jne Gcontinute GreenLabel: INVOKE PrintPixel,green,xP,yP jp nextChar Gcontinute: cmp al,'J' jne Jcontinute GrayLabel: INVOKE PrintPixel,lightGray,xP,yP jp nextChar Jcontinute: cmp al,'F' jne Fcontinute lightGreenLabel: INVOKE PrintPixel,lightGreen,xP,yP jp nextChar Fcontinute: cmp al,'N' jne Ncontinute BlackLabel: INVOKE PrintPixel,black,xP,yP jp nextChar Ncontinute: cmp al,'R' jne Rcontinute RedLabel: INVOKE PrintPixel,red,xP,yP jp nextChar Rcontinute: cmp al,'M' jne Mcontinute purpleLabel: INVOKE PrintPixel,magenta,xP,yP jp nextChar Mcontinute: cmp al,'O' jne Ocontinute brownLabel: INVOKE PrintPixel,brown,xP,yP jp nextChar Ocontinute: cmp al,'D' jne Dcontinute lightCyanLabel: INVOKE PrintPixel,lightCyan,xP,yP jp nextChar Dcontinute: cmp al,'H' jne Hcontinute lightRedLabel: INVOKE PrintPixel,lightRed,xP,yP jp nextChar Hcontinute: cmp al,'B' jne Bcontinute blueLabel: INVOKE PrintPixel,blue,xP,yP jp nextChar Bcontinute: cmp al,'Y' jne Ycontinute yellowLabel: INVOKE PrintPixel,yellow,xP,yP jp nextChar Ycontinute: cmp al,'I' jne Icontinute lightMagentaLabel: INVOKE PrintPixel,lightMagenta,xP,yP jp nextChar Icontinute: cmp al,'W' jne Wcontinute whiteLabel: INVOKE PrintPixel,white,xP,yP jp nextChar Wcontinute: nextChar: inc ebx add xP,2 dec ecx jne L1 call ResetColor ret DrawPic ENDP ResetColor PROC USES eax mov eax,white(black) call setTextColor ret ResetColor ENDP DrawNum PROC USES eax ebx ecx edx, number:DWORD, xP:BYTE, yP:BYTE ;get point mov eax,number mov ebx,10 mov ecx,0 ;make point into buffer .IF (eax==0) mov buffer[0],0 inc ecx .ENDIF L1: .IF (eax==0) jmp endLabel .ENDIF xor edx,edx div bx mov buffer[ecx],dl inc ecx jmp L1 ;print point endLabel: mov bl,xP L2: INVOKE DrawDigit,buffer[ecx-1],bl,yP add bl,8 Loop L2 ret DrawNum ENDP END ``` # functions ## random ```as= GetRandom PROC, number: DWORD mov eax,number call Randomize call RandomRange ret GetRandom ENDP ``` ## zombie animation ```as= .data purpleZombie BYTE "SSSSMSMSSSZ", "MSMMMMMSMZ", "SMMNMNMMSZ", "SSMMMMMSSZ", "SSSMSMSSSZ", "SSJJSJJSSZ",0 greenZombie BYTE "SSSSGSGSSSZ", "GSGGGGGSGZ", "SGGNGNGGSZ", "SSGGGGGSSZ", "SSSGSGSSSZ", "SSJJSJJSSZ",0 brownZombie BYTE "SSSSOSOSSSZ", "OSOOOOOSOZ", "SOONONOOSZ", "SSOOOOOSSZ", "SSSOSOSSSZ", "SSJJSJJSSZ",0 redZombie BYTE "SSSSRSRSSSZ", "RSRRRRRSRZ", "SRRNRNRRSZ", "SSRRRRRSSZ", "SSSRSRSSSZ", "SSJJSJJSSZ",0 blueZombie BYTE "SSSSBSBSSSZ", "BSBBBBBSBZ", "SBBNBNBBSZ", "SSBBBBBSSZ", "SSSBSBSSSZ", "SSJJSJJSSZ",0 .code ZombieAnimation PROC uses eax INVOKE DrawPic,OFFSET purpleZombie,LENGTHOF purpleZombie,0,0 mov eax,100 call Delay INVOKE DrawPic,OFFSET greenZombie,LENGTHOF greenZombie,0,0 mov eax,100 call Delay INVOKE DrawPic,OFFSET brownZombie,LENGTHOF brownZombie,0,0 mov eax,100 call Delay INVOKE DrawPic,OFFSET redZombie,LENGTHOF redZombie,0,0 mov eax,100 call Delay INVOKE DrawPic,OFFSET blueZombie,LENGTHOF blueZombie,0,0 mov eax,100 call Delay ret ZombieAnimation ENDP ``` ## Delay millisecond ```as= DelayMillisec PROTO, sec: DWORD DelayMillisec PROC USES eax, sec: DWORD, mov eax,sec call Delay ret DelayMillisec ENDP ``` ## 讓Cursor消失 ```as= HideCursor PROC USES eax INVOKE GetStdHandle, STD_OUTPUT_HANDLE mov outputHandle, eax INVOKE GetConsoleCursorInfo,outputHandle,OFFSET cursorInfo mov cursorInfo.bVisible,0 INVOKE SetConsoleCursorInfo,outputHandle,OFFSET cursorInfo ret HideCursor ENDP ``` ## 60秒倒數 ```as= INCLUDE Irvine32.inc .data startTime SYSTEMTIME <> currentTime SYSTEMTIME <> sTime DWORD ? nTime DWORD ? main EQU start@0 .code main PROC call Init L2: call GetCurrentTime mov eax,nTime sub eax,sTime ;call WriteDec .IF (eax>60) jmp endLabel .ENDIF call PrintTime Loop L2 endLabel: ret main ENDP Init PROC USES eax ebx INVOKE GetSystemTime,OFFSET startTime movzx eax,WORD PTR [startTime.wHour] imul eax,eax,60 movzx ebx,WORD PTR [startTime.wMinute] add eax,ebx imul eax,eax,60 movzx ebx,WORD PTR [startTime.wSecond] add eax,ebx mov sTime,eax mov eax,10 call Delay ret Init ENDP GetCurrentTime PROC USES eax ebx INVOKE GetSystemTime,OFFSET currentTime movzx eax,WORD PTR [currentTime.wHour] imul eax,eax,60 movzx ebx,WORD PTR [currentTime.wMinute] add eax,ebx imul eax,eax,60 movzx ebx,WORD PTR [currentTime.wSecond] add eax,ebx mov nTime,eax mov eax,10 call Delay ret GetCurrentTime ENDP PrintTime PROC USES eax edx mov eax,sTime sub eax,nTime add eax,60 mov dl,10 mov dh,10 call Gotoxy call WriteDec mov eax,100 call Delay ret PrintTime ENDP END main ``` ## 顏色 ```as= include Irvine32.inc PrintPixel PROTO, backgroundColor: WORD, x:BYTE, y:BYTE PrintString PROTO, stringLoc: PTR BYTE, xPos: BYTE, yPos: BYTE, .data shape db '.',0ah,0dh .code main PROC mov eax, green(green * 16) call setTextColor call ResetColor INVOKE PrintPixel,lightBlue,20,20 call ResetColor; ret main ENDP PrintPixel PROC USES eax edx ebx, backgroundColor: WORD, x:BYTE, y:BYTE mov dl,x mov dh,y call Gotoxy movsx eax, backgroundColor mov ebx, eax shl eax,4 add eax, ebx call setTextColor mov eax,'B' call WriteChar call WriteChar ret PrintPixel ENDP ResetColor PROC USES eax mov eax,white(black) call setTextColor ret ResetColor ENDP PrintString PROC USES edx, stringLoc: PTR BYTE, xPos: BYTE, yPos: BYTE, mov dl,xPos mov dh,yPos call Gotoxy mov edx,stringLoc call WriteString ret PrintString ENDP END main ``` ## Readkey(讀完存KEY,ascii code會存在 al) ```as= call Readkey INVOKE DelayMillisec,200 cmp al,"a" ``` ## WriteString ```as= .data prompt BYTE "Enter your name: ",0 .code mov edx,OFFSET prompt call WriteString ``` ## setTextColor ```as= SetColor PROTO, color: BYTE SetColor PROC USES eax, color: BYTE movzx eax,color call SetTextColor ret SetColor ENDP ``` # 顏色 ## 色碼 * black : 0 "N" * blue : 1 深藍 "B" * green : 2 "G" * cyan : 3 青藍 "C" * red : 4 深紅 "R" * magenta : 5 紫 "M" * brown : 6 黃棕 "O" * lightGray : 7 亮灰(偏白)"J" * gray : 8 灰 "T" * lightBlue : 9 亮正藍 "E" * lightGreen : a 亮綠 "F" * lightCyan : b 亮青(淺)藍 "D" * lightRed : c 淺紅 "H" * lightMagenta : d 亮(紅)紫 "I" * yellow : e 淺黃 "Y" * white : f "W" ... ```as= mov al,GREEN ``` ## 搭配使用 ```as= main PROC invoke DrawPic , offset num_6, lengthof num_0 , 18, 10,10 mov eax,0 call setTextColor ret main ENDP PrintPixel PROC USES eax edx ebx, backgroundColor: WORD, x:BYTE, y:BYTE mov dl,x mov dh,y call Gotoxy movsx eax, backgroundColor mov ebx, eax shl eax,4 add eax, ebx call setTextColor mov eax,'B' call WriteChar call WriteChar ret PrintPixel ENDP DrawPic PROC USES eax ebx ecx edx, picture: ptr byte, totalLength : WORD, xP:BYTE , yP:BYTE movzx ecx, totalLength mov ebx,0 movzx dx, xP L1: mov esi,picture add esi,ebx mov al,[esi] cmp al , 'S' je nextChar cmp al, 'Z' jne Zcontinute nextLine: inc yP mov xP, dl jp nextChar Zcontinute: cmp al,'G' jne Gcontinute GreenLabel: INVOKE PrintPixel,green,xP,yP jp nextChar Gcontinute: cmp al,'J' jne Jcontinute GrayLabel: INVOKE PrintPixel,lightGray,xP,yP jp nextChar Jcontinute: cmp al,'F' jne Fcontinute lightGreenLabel: INVOKE PrintPixel,lightGreen,xP,yP jp nextChar Fcontinute: cmp al,'N' jne Ncontinute BlackLabel: INVOKE PrintPixel,black,xP,yP jp nextChar Ncontinute: cmp al,'R' jne Rcontinute RedLabel: INVOKE PrintPixel,red,xP,yP jp nextChar Rcontinute: cmp al,'M' jne Mcontinute purpleLabel: INVOKE PrintPixel,magenta,xP,yP jp nextChar Mcontinute: cmp al,'O' jne Ocontinute brownLabel: INVOKE PrintPixel,brown,xP,yP jp nextChar Ocontinute: cmp al,'D' jne Dcontinute lightCyanLabel: INVOKE PrintPixel,lightCyan,xP,yP jp nextChar Dcontinute: cmp al,'H' jne Hcontinute lightRedLabel: INVOKE PrintPixel,lightRed,xP,yP jp nextChar Hcontinute: cmp al,'B' jne Bcontinute blueLabel: INVOKE PrintPixel,blue,xP,yP jp nextChar Bcontinute: cmp al,'Y' jne Ycontinute yellowLabel: INVOKE PrintPixel,yellow,xP,yP jp nextChar Ycontinute: cmp al,'I' jne Icontinute lightMagentaLabel: INVOKE PrintPixel,lightMagenta,xP,yP jp nextChar Icontinute: cmp al,'W' jne Wcontinute whiteLabel: INVOKE PrintPixel,white,xP,yP jp nextChar Wcontinute: nextChar: inc ebx add xP,2 dec ecx jne L1 ret DrawPic ENDP ResetColor PROC USES eax mov eax,white(black) call setTextColor ret ResetColor ENDP ``` # 生成圖 ## 打殭屍(? dinosaur BYTE "SSFFFFFFGZ", "SFFFFFFFGZ", "SOYFOYFFGZ", "GFGFFFFFGZ", "FFFFFFFFGZ", "RRRRRFFFGZ", "RRRRRFFGGZ", "SSFFFFGGZS",0 zombie BYTE "SSSFFFFRRSZ", "SFFFFFFFRRZ", "SFFFFFFFFGZ", "FOOFOOFFFGZ", "FYOFYORFFGZ", "FFFFFFRFFGZ", "FGGGGRFFGGZ", "SJGJGFFGGSZ", "SRFRRGFGSSZ",0 monster BYTE "SSSSMSMSSSZ", "MSMMMMMSMZ", "SMMNMNMMSZ", "SSMMMMMSSZ", "SSSMSMSSSZ", "SSJJSJJSSZ",0 num_0 BYTE "NWWWZ", "WNWZ", "WNWZ", "WNWZ", "WWWZ",0 num_1 BYTE "NNWNZ", "NWNZ", "NWNZ", "NWNZ", "NWNZ",0 num_2 BYTE "NWWWZ", "NNWZ", "WWWZ", "WNNZ", "WWWZ",0 num_3 BYTE "NWWWZ", "NNWZ", "WWWZ", "NNWZ", "WWWZ",0 num_4 BYTE "NWNWZ", "WNWZ", "WWWZ", "NNWZ", "NNWZ",0 num_5 BYTE "NWWWZ", "WNNZ", "WWWZ", "NNWZ", "WWWZ",0 num_6 BYTE "NWWWZ", "WNNZ", "WWWZ", "WNWZ", "WWWZ",0 num_7 BYTE "NWWWZ", "NNWZ", "NNWZ", "NNWZ", "NNWZ",0 num_8 BYTE "NWWWZ", "WNWZ", "WWWZ", "WNWZ", "WWWZ",0 num_9 BYTE "NWWWZ", "WNWZ", "WWWZ", "NNWZ", "WWWZ",0 TimePixel byte "NDDDDD DDD DNNND DDDDZ", "NNDNN NDN DDNDD DNNNZ", "NNDNN NDN DNDND DDDDZ", "NNDNN NDN DNNND DNNNZ", "NNDNN DDD DNNND DDDDZ",0 PointPixel byte "NDDDD DDDD DDD DNND DDDDDZ", "DNND DNND NDN DDND NNDNNZ", "DDDD DNND NDN DNDD NNDNNZ", "DNNN DNND NDN DNND NNDNNZ", "DNNN DDDD DDD DNND NNDNNZ",0 YourScorePixel byte "NONNNO OOOO ONNO OOONZ", "ONNNO ONNO ONNO ONNOZ", "NOOON ONNO ONNO OOOOZ", "NNONN ONNO ONNO ONONZ", "NNONN OOOO OOOO ONNOZ" monster2 BYTE "SSSSMSMSSSZ", "NSMMMMMSMZ", "NMMNMNMMNZ", "MSMMMMMSNZ", "SSSMSMSSSZ", "SSJJSJJSSZ",0 monster3 BYTE "SSSSMSMSSSZ", "MSMMMMMSNZ", "NMMNMNMMNZ", "NSMMMMMNMZ", "SSSMSMSSSZ", "SSJJSJJSSZ",0 bigNum_3 BYTE "NWWWWWWZ", "WWWWWWZ", "NNNNWWZ", "NNNNWWZ", "WWWWWWZ", "WWWWWWZ", "NNNNWWZ", "NNNNWWZ", "WWWWWWZ", "WWWWWWZ",0 bigNum_2 BYTE "NWWWWWWZ", "WWWWWWZ", "NNNNWWZ", "NNNNWWZ", "WWWWWWZ", "WWWWWWZ", "WWNNNNZ", "WWNNNNZ", "WWWWWWZ", "WWWWWWZ",0 bigNum_1 BYTE "NNNWWNNZ", "NNWWNNZ", "NNWWNNZ", "NNWWNNZ", "NNWWNNZ", "NNWWNNZ", "NNWWNNZ", "NNWWNNZ", "NNWWNNZ", "NNWWNNZ",0 接下來所有字體都將改成該顏色 吃eax 的第一BYTE為字,第二BYTE為背景 例: eax = 0x00000012 --> 藍底綠字 ![image](https://hackmd.io/_uploads/HyoE6gd8a.png) ```as= mov eax,Blue(blue*16) call setTextColor ``` ## 煙火生成圖 SmallFireworkCircle BYTE "SNYNZ", "YNYZ", "NYNZ", BigFireworkCircle BYTE "SNNYNNZ", "NYNYNZ", "YNNNYZ", "NYNYNZ", "NNYNNZ",0 ClearFireworkCircle BYTE "SNNNNNZ", "NNNNNZ", "NNNNNZ", "NNNNNZ", "NNNNNZ",0 FireworkCracks BYTE "SNNYNNNNZ", "NNNNNYNZ", "YNNNYNNZ", "NYNNNNYZ", "NNYNYNNZ",0 FireworkCracks2 BYTE "SNNNNNNNNNNNNNZ", "NNNNNNNNNNNNNZ", "NNNYNNNNNNNNNZ", "NNNNNNNNNYNNNZ", "YNNNNNNNNNNNYZ", "NNYNNNNNNYNNNZ", "NNNNNNNNNNNNNZ", "NNNNYNNNNNNNNZ", "NNNNNNNNNNYNNZ", "NNNNNNNNNNNNNZ",0 ## 天天過馬路生成圖 ### 小精靈 lookRightMonster BYTE "SNRRRNZ", "RWBWBZ", "RRRRRZ", "RRRRRZ", "RNRNRZ",0 lookLeftMonster BYTE "SNDDDNZ", "BWBWDZ", "DDDDDZ", "DDDDDZ", "DNDNDZ",0 ### SUS(player) redCarbiPixel BYTE "SNHHHNZ", "HWHWHZ", "HBHBHZ", "HHHHRZ", "RHHRRZ",0 susPixel BYTE "SNRRRRZ", "RRWWWZ", "RRRRRZ", "RRRRRZ", "NRNNRZ",0 # functions # firework ```as= FireworkAnime PROC USES eax ebx edx, x :Byte, y :Byte, mov bh,x mov bl,y invoke GetRandom,60 add eax,20 mov bh,al StraightUp: invoke PrintPixel, yellow, bh, bl mov eax,70 call delay invoke PrintPixel, black, bh, bl sub bl,1 cmp bl,10 jae Straightup StraightUpEnd: Explore: sub bh,4 sub bl,2 invoke DrawPic, offset SmallFireworkCircle , lengthof SmallFireworkCircle, bh, bl mov eax,150 call delay sub bh,2 sub bl,1 invoke DrawPic, offset BigFireworkCircle , lengthof BigFireworkCircle, bh, bl mov eax,150 call delay invoke DrawPic, offset ClearFireworkCircle , lengthof BigFireworkCircle, bh, bl mov eax,180 call delay sub bh,2 invoke DrawPic, offset FireworkCracks , lengthof FireworkCracks, bh, bl mov eax,200 call delay sub bh,4 invoke DrawPic, offset FireworkCracks2 , lengthof FireworkCracks2, bh, bl mov eax,250 call delay call clrscr ret FireworkAnime ENDP ``` ## DANCE ```AS= mov ecx,20 dance: invoke drawPic, offset monster3, lengthof monster, 10, 10 mov eax,200 call delay invoke drawPic, offset monster2, lengthof monster2, 10, 10 mov eax,200 call delay loop dance ``` ## string 宣告 ```as= testStr BYTE "-------------",0dh,0ah BYTE "hello world",0dh,0ah BYTE "-------------",0 GAME_START_STR db 'line1',0ah,0dh db 'line2',0ah,0dh ``` 執行結果: ![image](https://hackmd.io/_uploads/Byzwex5H6.png) ## printstring at x,y(不換行的string) ```as= PrintString PROTO, stringLoc: PTR BYTE, xPos: BYTE, yPos: BYTE, PrintString PROC USES edx, stringLoc: PTR BYTE, xPos: BYTE, yPos: BYTE, mov dl,xPos mov dh,yPos call Gotoxy mov edx,stringLoc call WriteString ret PrintString ENDP ``` # bios 中斷 [wiki](https://zh.wikipedia.org/zh-tw/BIOS%E4%B8%AD%E6%96%B7%E5%91%BC%E5%8F%AB) # reference [fired or tired](https://github.com/AbdallahHemdan/FIRED-OR-TIRED) [dosbox](https://www.dosbox.com/) # 去年分數 [成績](https://docs.google.com/spreadsheets/d/15l7B0ogqwGK_VoQtLXtb-sqPC9tg0_FX/edit#gid=423603609) # zombie [網站](https://emojicombos.com/zombie-ascii-art) # 羊羽李在做天天過馬路 但他快死了 ```as= INCLUDE Irvine32.inc ;make text color white, background color black ResetColor PROTO PrintPixel PROTO, backgroundColor: WORD, x:BYTE, y:BYTE DrawNum PROTO, number:DWORD, xP:BYTE, yP:BYTE DrawPic PROTO, picture: ptr byte, totalLength: WORD, xP:BYTE, yP:BYTE .data player db '^', 0 playerX db 5 playerY db 12 startLine db 4 mapSizeX db 6 ;0-5 mapSizeY db 22 ;0-23 line struct e1 db ? e2 db ? line ends enemy db '@', 0 enemies line 6 DUP(<0,0>) copyEnemies line 5 DUP(<0,0>) enemyDirect db 6 DUP(0) copyEnemyDirect db 5 DUP(0) enemyNum db 2 enemyRound db 0 score db 0 gameover db 0 susPixel BYTE "SNRRRRZ", "RRWWWZ", "RRRRRZ", "RRRRRZ", "NRNNRZ",0 lookRightMonster BYTE "SNRRRNZ", "RWBWBZ", "RRRRRZ", "RRRRRZ", "RNRNRZ",0 lookLeftMonster BYTE "SNDDDNZ", "BWBWDZ", "DDDDDZ", "DDDDDZ", "DNDNDZ",0 redCarbiPixel BYTE "SNHHHNZ", "HWHWHZ", "HBHBHZ", "HHHHRZ", "RHHRRZ",0 main EQU start@0 .code ;================================================ DrawCross PROTO, character: byte, xP:BYTE, yP:BYTE, DrawCross PROC USES eax ebx ecx edx esi, character: BYTE, x:BYTE , y:BYTE, mov bl, 5 mov al, x mul bl mov dh, al mov al, y mul bl mov dl, al mov al, character cmp al, 0 jne DrawEnemy INVOKE DrawPic, OFFSET redCarbiPixel, LENGTHOF redCarbiPixel, dh, dl jmp EndDraw DrawEnemy: cmp al, 1 jne DrawRight INVOKE DrawPic, OFFSET lookLeftMonster, LENGTHOF lookLeftMonster, dh, dl jmp EndDraw DrawRight: INVOKE DrawPic, OFFSET lookRightMonster, LENGTHOF lookRightMonster, dh, dl EndDraw: ret DrawCross ENDP ;================================================ IsGameover PROC uses eax mov al, 1 mov gameover, al ret IsGameover ENDP ;================================================ PrintPlayer PROC uses eax ebx ecx edx mov dh, playerX mov dl, playerY INVOKE DrawCross, 0, dl,dh ret PrintPlayer ENDP ;================================================ Hit PROC uses eax ebx ecx esi mov al, playerX mov bl, startLine cmp al, bl jne NoHit mov esi, OFFSET enemies add esi, 8 mov ecx, 2 mov al, playerY IsHit: mov bl, [esi] inc esi sub bl, al cmp bl, 0 je Die cmp bl, 1 je Die cmp bl, -1 jne Safe Die: call IsGameover Safe: loop IsHit NoHit: ret Hit ENDP ;================================================ SpawnEnemy PROTO, lineNum: PTR BYTE, directNum: PTR BYTE, SpawnEnemy PROC uses eax ebx ecx esi, lineNum: PTR BYTE, directNum: PTR BYTE, setDirect: mov eax, 2 call RandomRange inc eax mov esi, directNum mov [esi], al mov ecx, 2 mov esi, lineNum setLine: mov eax, 9 call RandomRange add al, 2 mov ebx,2 mul ebx mov [esi], al inc esi loop setLine ret SpawnEnemy ENDP ;================================================ EnemyMove PROC uses eax ebx ecx edx esi movzx ecx, MapSizeX mov esi, OFFSET enemies movzx eax, enemyRound mov ebx, 0 cmp eax, 2 je MoveRows inc eax mov enemyRound, al jmp DontMove MoveRows: mov eax, 0 mov enemyRound, al push ecx movzx ecx, enemyNum MoveColumns: mov al, enemyDirect[ebx] cmp al, 0 je NoEnemyMove cmp al, 1 jne NoLeft GoLeft: mov al, [esi] cmp al, 2 jne JustLeft mov dl, mapSizeY sub dl, 2 mov al,dl inc al mov [esi], al jmp EndMove JustLeft: dec al mov [esi], al jmp EndMove NoLeft: cmp al, 2 jne Road GoRight: mov al, [esi] mov dl, mapSizeY dec dl cmp al, dl jne JustRight mov al, 1 mov [esi], al jmp EndMove JustRight: inc al mov [esi], al jmp EndMove Road: EndMove: inc esi loop MoveColumns NoEnemyMove: inc ebx pop ecx loop MoveRows call Hit DontMove: ret EnemyMove ENDP ;================================================ EnemyDown PROC uses eax ecx esi edi mov ecx, 5 mov esi, OFFSET enemyDirect mov edi, OFFSET copyEnemyDirect cld CopyDirect: lodsb stosb loop CopyDirect mov ecx, 5 mov esi, OFFSET copyEnemyDirect mov edi, OFFSET enemyDirect inc edi CopyDirectBack: lodsb stosb loop CopyDirectBack mov ecx, 10 mov esi, OFFSET enemies mov edi, OFFSET copyEnemies cld Copy: lodsb stosb loop Copy INVOKE SpawnEnemy, OFFSET enemies, OFFSET enemyDirect mov ecx, 10 mov esi, OFFSET copyEnemies mov edi, OFFSET enemies add edi, 2 cld CopyBack: lodsb stosb loop CopyBack ret EnemyDown ENDP ;================================================ PrintEnemy PROC uses eax ebx ecx edx esi movzx ecx, MapSizeX mov esi, OFFSET enemies mov ebx, 0 PrintRows: push ecx movzx ecx, enemyNum PrintColumns: mov al, [esi] inc esi mov dh, bl mov dl, al mov al, enemyDirect[ebx] cmp al, 0 je NoEnemy cmp al, 1 jne RightEnemy LeftEnemy: INVOKE DrawCross, 1, dl, dh jmp EndPrintEnemy RightEnemy: INVOKE DrawCross, 2, dl, dh EndPrintEnemy: NoEnemy: loop PrintColumns pop ecx inc ebx loop PrintRows ret PrintEnemy ENDP ;================================================ PlayerForward PROC uses eax ebx esi movzx eax, playerX cmp al, startLine je move2 move1: movzx eax, playerX sub eax, 1 mov playerX, al jmp endMove move2: call EnemyDown mov al, score inc al mov score, al endMove: ret PlayerForward ENDP ;================================================ PlayerLeft PROC uses eax ebx esi movzx eax, playerY cmp eax, 2 je InLeftest sub eax, 1 mov playerY, al InLeftest: ret PlayerLeft ENDP ;================================================ PlayerRight PROC uses eax ebx esi movzx eax, playerY mov bl, mapSizeY dec bl inc al cmp al, bl je InRightest mov playerY, al InRightest: ret PlayerRight ENDP ;================================================ CrossRoadInput PROC uses eax ebx edx call Readkey jz EndInput cmp eax, 1177h jne NotForward call PlayerForward NotForward: cmp eax, 1e61h jne NotLeft call PlayerLeft NotLeft: cmp eax, 2064h jne NotRight call PlayerRight NotRight: cmp eax, 011bh jne EndInput call Hit EndInput: ret CrossRoadInput ENDP ;================================================ CrossRoadInit PROC uses eax ecx esi mov playerX, 5 mov playerY, 12 mov enemyRound, 0 mov score, 0 mov gameover, 0 mov ecx, 12 mov esi, OFFSET enemies mov eax, 0 InitEnemy: mov [esi], al loop InitEnemy mov ecx, 6 mov esi, OFFSET enemyDirect InitDirect: mov [esi], al loop InitDirect call Randomize mov esi, OFFSET enemies mov edi, OFFSET enemyDirect movzx ecx, startLine SetEnemies: INVOKE spawnEnemy, esi, edi add esi, 2 inc edi loop SetEnemies ret CrossRoadInit ENDP ;================================================ CrossRoadLoop PROC uses eax Init: call CrossRoadInit GameLoop: call CrossRoadInput call EnemyMove call PrintEnemy call PrintPlayer ;call PrintScore mov eax, 50 call delay call Clrscr mov al, gameover cmp al, 1 je EndGame jmp GameLoop EndGame: ret CrossRoadLoop ENDP ;================================================ main PROC call CrossRoadLoop main ENDP END main ``` ### DEBUG\ ```as= include Irvine32.inc PrintPixel PROTO, backgroundColor: WORD, x:BYTE, y:BYTE PrintString PROTO, stringLoc: PTR BYTE, xPos: BYTE, yPos: BYTE DrawPic PROTO, picture: ptr BYTE, totalLength : WORD, lineLength : WORD, xP : BYTE , yP : BYTE .data shape db '.',0ah,0dh dinosaur BYTE "SSFFFFFFGZ", "SFFFFFFFGZ", "SOYFOYFFGZ", "GFGFFFFFGZ", "FFFFFFFFGZ", "RRRRRFFFGZ", "RRRRRFFGGZ", "SSFFFFGGZS",0 zombie BYTE "SSSFFFFRRSZ", "SFFFFFFFRRZ", "SFFFFFFFFGZ", "FOOFOOFFFGZ", "FYOFYORFFGZ", "FFFFFFRFFGZ", "FGGGGRFFGGZ", "SJGJGFFGGSZ", "SRFRRGFGSSZ",0 FFSIZE WINDOW_BUFFER_SIZE_RECORD <> .code main PROC ;mov eax, 'A' ;call WriteChar ;invoke DrawPic , offset zombie,lengthof zombie, 20 , 10,10 ;mov eax,0 ;call setTextColor mov ax,00h mov ds,ax mov ah, 00h mov al,13h INT 10h ;ret main ENDP PrintPixel PROC USES eax edx ebx, backgroundColor: WORD, x:BYTE, y:BYTE mov dl,x mov dh,y call Gotoxy movsx eax, backgroundColor mov ebx, eax shl eax,4 add eax, ebx call setTextColor mov eax,'B' call WriteChar call WriteChar ret PrintPixel ENDP DrawPic PROC USES eax ebx ecx edx, picture: ptr byte, totalLength : WORD, lineLength : WORD, xP:BYTE , yP:BYTE movzx ecx, totalLength mov ebx,0 mov xP,0 mov yP,10 movzx dx, xP L1: mov esi,picture add esi,ebx mov al,[esi] cmp al , 'S' je nextChar cmp al, 'Z' jne Zcontinute nextLine: inc yP mov xP, dl jp nextChar Zcontinute: cmp al,'G' jne Gcontinute GreenLabel: INVOKE PrintPixel,green,xP,yP jp nextChar Gcontinute: cmp al,'J' jne Jcontinute GrayLabel: INVOKE PrintPixel,lightGray,xP,yP jp nextChar Jcontinute: cmp al,'F' jne Fcontinute lightGreenLabel: INVOKE PrintPixel,lightGreen,xP,yP jp nextChar Fcontinute: cmp al,'R' jne Rcontinute RedLabel: INVOKE PrintPixel,red,xP,yP jp nextChar Rcontinute: cmp al,'O' jne Ocontinute brownLabel: INVOKE PrintPixel,brown,xP,yP jp nextChar Ocontinute: cmp al,'Y' jne Ycontinute yellowLabel: INVOKE PrintPixel,yellow,xP,yP jp nextChar Ycontinute: cmp al,'W' jne Wcontinute whiteLabel: INVOKE PrintPixel,white,xP,yP jp nextChar Wcontinute: nextChar: inc ebx add xP,2 dec ecx jne L1 ret DrawPic ENDP ResetColor PROC USES eax mov eax,white(black) call setTextColor ret ResetColor ENDP PrintString PROC USES edx, stringLoc: PTR BYTE, xPos: BYTE, yPos: BYTE, mov dl,xPos mov dh,yPos call Gotoxy mov edx,stringLoc call WriteString ret PrintString ENDP END main ``` # SHOT ZOMBIE code ```as= INCLUDE Irvine32.inc PrintPixel PROTO, backgroundColor: WORD, x:BYTE, y:BYTE PrintString PROTO, stringLoc: PTR BYTE, xPos: BYTE, yPos: BYTE GetRandom PROTO, number: DWORD DrawPic PROTO, picture: ptr byte, totalLength: WORD, xP:BYTE, yP:BYTE, delayMilli: DWORD DrawNum PROTO, number: BYTE, xP:BYTE, yP:BYTE ChangeZombie PROTO, targetZombie: PTR BYTE .data outputHandle DWORD ? cursorInfo CONSOLE_CURSOR_INFO <> startTime SYSTEMTIME <> currentTime SYSTEMTIME <> sTime DWORD ? nTime DWORD ? timeLimit DWORD 10 timeString BYTE "Time",0 scoreString BYTE "Score",0 resultString BYTE "You scores ",0 resultEnd BYTE "!!!!!",0 refreshStr db ' ',0 lineValue BYTE 0,0,0,0,0,0 point DWORD 0 zombieCount DWORD ? instruction BYTE 55 buffer BYTE 11 DUP(?) YourPixel byte "NONNNO OOOO ONNO OOONZ", "ONNNO ONNO ONNO ONNOZ", "NOOON ONNO ONNO OOOOZ", "NNONN ONNO ONNO ONONZ", "NNONN OOOO OOOO ONNOZ" TimePixel byte "NOOOOO OOO ONNNO OOOOZ", "NNONN NON OONOO ONNNZ", "NNONN NON ONONO OOOOZ", "NNONN NON ONNNO ONNNZ", "NNONN OOO ONNNO OOOOZ",0 PointPixel byte "NOOOO OOOO OOO ONNO OOOOOZ", "ONNO ONNO NON OONO NNONNZ", "OOOO ONNO NON ONOO NNONNZ", "ONNN ONNO NON ONNO NNONNZ", "ONNN OOOO OOO ONNO NNONNZ",0 purpleZombie BYTE "SSSSMSMSSSZ", "MSMMMMMSMZ", "SMMNMNMMSZ", "SSMMMMMSSZ", "SSSMSMSSSZ", "SSJJSJJSSZ",0 greenZombie BYTE "SSSSGSGSSSZ", "GSGGGGGSGZ", "SGGNGNGGSZ", "SSGGGGGSSZ", "SSSGSGSSSZ", "SSJJSJJSSZ",0 brownZombie BYTE "SSSSOSOSSSZ", "OSOOOOOSOZ", "SOONONOOSZ", "SSOOOOOSSZ", "SSSOSOSSSZ", "SSJJSJJSSZ",0 redZombie BYTE "SSSSRSRSSSZ", "RSRRRRRSRZ", "SRRNRNRRSZ", "SSRRRRRSSZ", "SSSRSRSSSZ", "SSJJSJJSSZ",0 blueZombie BYTE "SSSSBSBSSSZ", "BSBBBBBSBZ", "SBBNBNBBSZ", "SSBBBBBSSZ", "SSSBSBSSSZ", "SSJJSJJSSZ",0 currentZombie BYTE 66 DUP(?) num_0 BYTE "NWWWZ", "WNWZ", "WNWZ", "WNWZ", "WWWZ",0 num_1 BYTE "NNWNZ", "NWNZ", "NWNZ", "NWNZ", "NWNZ",0 num_2 BYTE "NWWWZ", "NNWZ", "WWWZ", "WNNZ", "WWWZ",0 num_3 BYTE "NWWWZ", "NNWZ", "WWWZ", "NNWZ", "WWWZ",0 num_4 BYTE "NWNWZ", "WNWZ", "WWWZ", "NNWZ", "NNWZ",0 num_5 BYTE "NWWWZ", "WNNZ", "WWWZ", "NNWZ", "WWWZ",0 num_6 BYTE "NWWWZ", "WNNZ", "WWWZ", "WNWZ", "WWWZ",0 num_7 BYTE "NWWWZ", "NNWZ", "NNWZ", "NNWZ", "NNWZ",0 num_8 BYTE "NWWWZ", "WNWZ", "WWWZ", "WNWZ", "WWWZ",0 num_9 BYTE "NWWWZ", "WNWZ", "WWWZ", "NNWZ", "WWWZ",0 main EQU start@0 .code main PROC call HideCursor call Init L2: ;check time call GetCurrentTime mov eax,nTime sub eax,sTime .IF (eax>timeLimit) jmp endLabel .ENDIF call PrintTime call GetInputKey mov al,instruction .IF lineValue[4] == al call RefreshScreen add point,100 call PrintScore .IF(point==2900) INVOKE ChangeZombie,OFFSET greenZombie .ENDIF .IF(point==5900) INVOKE ChangeZombie,OFFSET brownZombie .ENDIF .IF(point==8900) INVOKE ChangeZombie,OFFSET redZombie .ENDIF .IF(point==11900) INVOKE ChangeZombie,OFFSET blueZombie .ENDIF .ENDIF mov instruction,55 jmp L2 endLabel: call clrscr call showResult ret main ENDP ZombieAnimation PROC uses eax INVOKE DrawPic,OFFSET purpleZombie,LENGTHOF purpleZombie,0,0,0 mov eax,100 call Delay INVOKE DrawPic,OFFSET greenZombie,LENGTHOF greenZombie,0,0,0 mov eax,100 call Delay INVOKE DrawPic,OFFSET brownZombie,LENGTHOF brownZombie,0,0,0 mov eax,100 call Delay INVOKE DrawPic,OFFSET redZombie,LENGTHOF redZombie,0,0,0 mov eax,100 call Delay INVOKE DrawPic,OFFSET blueZombie,LENGTHOF blueZombie,0,0,0 mov eax,100 call Delay ret ZombieAnimation ENDP ChangeZombie PROC uses eax ecx esi edi, targetZombie: PTR BYTE cld mov esi, targetZombie mov edi, OFFSET currentZombie mov ecx, 66 GoDown: lodsb stosb loop GoDown ret ChangeZombie ENDP Init PROC USES eax ebx ecx edx ;print zombie INVOKE ChangeZombie,OFFSET purpleZombie mov ecx,5 L1: INVOKE GetRandom,3 mov lineValue[ecx-1],al movzx ebx,al imul ebx,ebx,20 movzx edx,cl dec edx imul edx,edx,5 INVOKE DrawPic,OFFSET currentZombie,LENGTHOF currentZombie,bl,dl,0 call ResetColor mov eax,100 call Delay Loop L1 ;get gameStartTime INVOKE GetSystemTime,OFFSET startTime movzx eax,WORD PTR [startTime.wHour] imul eax,eax,60 movzx ebx,WORD PTR [startTime.wMinute] add eax,ebx imul eax,eax,60 movzx ebx,WORD PTR [startTime.wSecond] add eax,ebx mov sTime,eax ;reset point mov point,0 ;print "0" call PrintScore ret Init ENDP RefreshScreen PROC USES eax ecx edx call clrscr call RefreshLineValue ;move the zombies position downward, and make a random zombie position on the top call PrintTime mov ecx,5 L2: ;print all zombies again .IF (lineValue[ecx-1] == 0) mov ebx,0 .ENDIF .IF (lineValue[ecx-1] == 1) mov ebx,1 .ENDIF .IF (lineValue[ecx-1] == 2) mov ebx,2 .ENDIF imul ebx,ebx,20 movzx edx,cl dec edx imul edx,edx,5 INVOKE DrawPic,OFFSET currentZombie,LENGTHOF currentZombie,bl,dl,0 call ResetColor Loop L2 ret RefreshScreen ENDP RefreshLineValue PROC USES eax ebx ecx mov ecx,4 L1: mov al,LineValue[ecx-1] mov LineValue[ecx],al Loop L1 INVOKE GetRandom,3 mov LineValue[0],al ret RefreshLineValue ENDP DrawNum PROC USES eax ebx ecx edx, number: BYTE, xP: BYTE, yP: BYTE .IF (number==0) INVOKE drawPic,OFFSET num_0,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==1) INVOKE drawPic,OFFSET num_1,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==2) INVOKE drawPic,OFFSET num_2,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==3) INVOKE drawPic,OFFSET num_3,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==4) INVOKE drawPic,OFFSET num_4,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==5) INVOKE drawPic,OFFSET num_5,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==6) INVOKE drawPic,OFFSET num_6,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==7) INVOKE drawPic,OFFSET num_7,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==8) INVOKE drawPic,OFFSET num_8,LENGTHOF num_0,xP,yP,0 .ENDIF .IF (number==9) INVOKE drawPic,OFFSET num_9,LENGTHOF num_0,xP,yP,0 .ENDIF call ResetColor ret DrawNum ENDP DrawPic PROC USES eax ebx ecx edx, picture: ptr byte, totalLength : WORD, xP:BYTE , yP:BYTE , delayMilli: DWORD movzx ecx, totalLength mov ebx,0 movzx dx, xP L1: mov eax,delayMilli call Delay mov esi,picture add esi,ebx mov al,[esi] cmp al , 'S' je nextChar cmp al, 'Z' jne Zcontinute nextLine: inc yP mov xP, dl jp nextChar Zcontinute: cmp al,'G' jne Gcontinute GreenLabel: INVOKE PrintPixel,green,xP,yP jp nextChar Gcontinute: cmp al,'J' jne Jcontinute GrayLabel: INVOKE PrintPixel,lightGray,xP,yP jp nextChar Jcontinute: cmp al,'F' jne Fcontinute lightGreenLabel: INVOKE PrintPixel,lightGreen,xP,yP jp nextChar Fcontinute: cmp al,'N' jne Ncontinute BlackLabel: INVOKE PrintPixel,black,xP,yP jp nextChar Ncontinute: cmp al,'R' jne Rcontinute RedLabel: INVOKE PrintPixel,red,xP,yP jp nextChar Rcontinute: cmp al,'M' jne Mcontinute purpleLabel: INVOKE PrintPixel,magenta,xP,yP jp nextChar Mcontinute: cmp al,'O' jne Ocontinute brownLabel: INVOKE PrintPixel,brown,xP,yP jp nextChar Ocontinute: cmp al,'D' jne Dcontinute lightCyanLabel: INVOKE PrintPixel,lightCyan,xP,yP jp nextChar Dcontinute: cmp al,'H' jne Hcontinute lightRedLabel: INVOKE PrintPixel,lightRed,xP,yP jp nextChar Hcontinute: cmp al,'B' jne Bcontinute blueLabel: INVOKE PrintPixel,blue,xP,yP jp nextChar Bcontinute: cmp al,'Y' jne Ycontinute yellowLabel: INVOKE PrintPixel,yellow,xP,yP jp nextChar Ycontinute: cmp al,'I' jne Icontinute lightMagentaLabel: INVOKE PrintPixel,lightMagenta,xP,yP jp nextChar Icontinute: cmp al,'W' jne Wcontinute whiteLabel: INVOKE PrintPixel,white,xP,yP jp nextChar Wcontinute: nextChar: inc ebx add xP,2 dec ecx jne L1 call ResetColor ret DrawPic ENDP ResetColor PROC USES eax mov eax,white(black) call setTextColor ret ResetColor ENDP showResult PROC USES eax INVOKE DrawPic,OFFSET YourPixel,LENGTHOF YourPixel,0,0,1 INVOKE DrawPic,OFFSET PointPixel,LENGTHOF PointPixel,60,20,1 mov eax,point mov ebx,10 mov ecx,0 ;make point into buffer .IF (eax==0) mov buffer[0],0 inc ecx .ENDIF L1: .IF (eax==0) jmp endLabel .ENDIF xor edx,edx div bx mov buffer[ecx],dl inc ecx jmp L1 ;print point endLabel: mov bl,36 L2: INVOKE DrawNum,buffer[ecx-1],bl,10 dec esi add bl,8 Loop L2 mov eax,0 call setTextColor ret showResult ENDP HideCursor PROC USES eax edx INVOKE GetStdHandle, STD_OUTPUT_HANDLE mov outputHandle, eax INVOKE GetConsoleCursorInfo,outputHandle,OFFSET cursorInfo mov cursorInfo.bVisible,0 INVOKE SetConsoleCursorInfo,outputHandle,OFFSET cursorInfo ret HideCursor ENDP GetInputKey PROC USES eax mov eax,10 call Delay call ReadKey cmp al,'a' je L1 cmp al,'s' je L2 cmp al,'d' je L3 ret L1: mov instruction,0 ret L2: mov instruction,1 ret L3: mov instruction,2 ret GetInputKey ENDP GetCurrentTime PROC USES eax ebx ;get currenttime and convert the time INVOKE GetSystemTime,OFFSET currentTime movzx eax,WORD PTR [currentTime.wHour] imul eax,eax,60 movzx ebx,WORD PTR [currentTime.wMinute] add eax,ebx imul eax,eax,60 movzx ebx,WORD PTR [currentTime.wSecond] add eax,ebx mov nTime,eax mov eax,10 call Delay ret GetCurrentTime ENDP PrintString PROC USES eax edx, stringLoc: PTR BYTE, xPos: BYTE, yPos: BYTE, mov dl,xPos mov dh,yPos call Gotoxy mov edx,stringLoc call WriteString ret PrintString ENDP PrintPixel PROC USES eax edx ebx, backgroundColor: WORD, x:BYTE, y:BYTE mov dl,x mov dh,y call Gotoxy movsx eax, backgroundColor mov ebx, eax shl eax,4 add eax, ebx call setTextColor mov eax,'.' call WriteChar call WriteChar mov eax,0 call delay ret PrintPixel ENDP PrintTime PROC USES eax ecx edx ;getCurrentTime and convert mov eax,sTime sub eax,nTime add eax,timeLimit xor dx,dx INVOKE DrawPic,OFFSET TimePixel,LENGTHOF TimePixel,64,0,0 mov ecx,10 div cx INVOKE DrawNum,al,64,6 INVOKE DrawNum,dl,72,6 ret PrintTime ENDP PrintScore PROC USES eax ebx ecx edx, ;print "score" INVOKE DrawPic,OFFSET PointPixel,LENGTHOF PointPixel,64,13,0 ;get point mov eax,point mov ebx,10 mov ecx,0 ;make point into buffer .IF (eax==0) mov buffer[0],0 inc ecx .ENDIF L1: .IF (eax==0) jmp endLabel .ENDIF xor edx,edx div bx mov buffer[ecx],dl inc ecx jmp L1 ;print point endLabel: mov bl,64 L2: INVOKE DrawNum,buffer[ecx-1],bl,20 dec esi add bl,8 Loop L2 ret PrintScore ENDP GetRandom PROC, number: DWORD mov eax,number call Randomize call RandomRange ret GetRandom ENDP END main ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully