Because the school has not taught, I find a practice ...

xiaoxiao2021-03-06  47

Title Snake Game by Masm 5.0 Copyright (c) Detective QQ: 87036211

HLINE painting horizontal line function; VLINE paintings; REC painting no fill rectangle; BAR paint rectangle; setGB sets cursor position; MSG display string; delay delay; MsGHz Display a 64 * 64 Chinese characters; subspeed Reduce speed; PRTMSG display prompt; PRTSPD_PROC displays the initial state; hidspd_proc displays the state of movement; random generates a random number; the random number of the specified range size; GAMEINIT initializes the game interface and data; Selspeed Select the game speed; GameProc game process; INITSNAKEDATA initial four-section position; Foodinit produces a property location

; ------------------------------------------------- -------------------; Equal Table

Up EQU 48HDOWN EQU 50hleft EQU 4bhright EQU 4dhquit Equ 01henter EQU 1CH; -------------------------------------------------------------------------------------------------------------------------------- --------------------------------

. Modack 300 .data; ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sposx dw 107

The life of the snake life DB 1; the direction of the snake Direct DB 2; Speed ​​SPEED DB 3; Score Score DW 4 DUP (0); random seed SEED DW 200; -------------- -------------------------------------------------- ----

; ------------------------------------------------- -------------------; Displayed series of strings; score szscore db 'score'; speed selection SZList DB '1 2 3 4 5 6 7 8 9'; Author szname db 'Copyright (c) Detective QQ: 87036211'; ---------------------------------------------------------------------------------------------------------------------------------- --------------------------------

Hzsnake DB 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H DB DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 010H, 000H, 000H, 000H DB 000H, 000H DB 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 007H, 0F0H, 000H, 000H DB 000H, 000H, 000H, 003H, 0FCH, 000H, 000H DB 000H, 000H, 0F0H, 000H, 003H, 0FCH, 000H, 000H, 001H, 0FEH, 000H, 000H DB 000H, 000H, 0FCH, 000H, 000H, 0FEH, 000H DB 000H, 000H, 0BCH, 000H, 000H, 07EH, 000H, 000H DB 000H, 000H, 000H, 000H DB 000H, 01EH, 000H, 003H, 0FEH, 010H, 000H DB 000H, 01EH, 000H, 0FFH, 0FFH, 0F8H, 000H DB 000H, 000H, 01EH, 001H, 0C0H, 07FH, 01H, 001H, 0E3H, 01EH, 01EH, 000H DB 000H, 000H, 01EH, 001H, 0EFH, 0FCH, 03FH, 000H DB 000H, 000H, 01FH, 081H, 0FFH, 0F0H, 07FH, 000H DB 000H, 000H, 01FH, 0F1H, 0FFH, 0C1H, 01FH, 000H DB 000H, 01FH, 0FFH, 0FFH, 01FH, 0FFH, 000H DB 000H, 000H, 03FH, 0FFH, 0FCH, 03FH, 0FEH, 000H DB 000H, 000H, 070H, 000H, 000H DB 000H, 001H, 070H, 07FH, 0E0H, 070H, 000H, 000H DB 000H, 083H, 0FCH, 07FH, 0C0H, 03EH, 000H, 000H DB 000H, 03EH, 000H, 000H DB 000H, 0FFH, 0FCH, 0FFH, 080H, 03FH, 000H, 000H DB 000H, 07FH, 03DH, 080H, 080H, 07FH, 080H, 000H DB 000H, 07EH, 03FH, 0F7H, 000H, 0FH, 080H, 000H DB 000H, 03EH, 03FH, 0E3H, 003H, 0GFH, 080H, 000H DB 000H, 03EH, 03FH, 0C0H, 03FH, 0FH, 080H, 000H DB 000H, 03EH, 03FH, 0E0H, 0FFH, 010H, 000H DB 000H, 01EH, 07FH, 0E0H, 0FFH, 0E0H, 000H, 000H DB 000H, 01FH, 0FH, 0E0H, 07FH, 080H, 000H, 0E DB 000H, 01FH, 0FFH, 0E0H, 01FH, 000H, 000H, 000H DB 000H, 01FH, 0FCH, 000H, 01FH, 000H, 000H, 000H DB 000H, 01FH, 0FDH, 080H, 03FH, 000H, 000H, 0E0H, 03EH, 000H, 000H DB 000H, 007H, 0BFH, 0F0H, 03EH, 000H, 000H, 000H DB 000H, 000H, 03FH, 0F8H, 07CH, 000H, 000H, 000H DB 000H, 000H, 07FH, 0FCH,

07ch, 000H, 001H, 000H DB 000H, 000H, 07FH, 0FEH, 07CH, 000H, 001H, 080H, 078H, 000H, 003H, 080H DB 000H, 003H, 0FCH, 03EH, 0F8H, 000H, 003H, 080H DB 000H, 07FH, 0F8H, 03EH, 0F8H, 000H, 003H, 080H DB 000H, 07FH, 010H, 00CH, 0F0H, 000H, 007H, 080H DB 000H, 07FH, 0E0H, 000H, 0F0H, 000H, 007H, 0C0H DB 000H, 03FH, 0C0H, 000H, 0F0H, 000H, 00FH, 0C0H DB 000H, 03FH, 080H, 000H, 078H, 000H, 03FH, 0C0H DB 000H, 01FH, 000H, 000H, 07FH, 0FFH, 0FFH, 0C0H DB 000H, 00EH, 000H, 07FH, 0FFH, 0FFH, 0C0H DB 000H, 000H, 0FFH, 0C0H DB 000H, 000H, 000H, 000H, 00FH, 0FFH, 0FFH, 080H DB 000H, 000H, 0FeH, 000H DB 000H, 000H, 000H DB 000H, 000H, 000H, 000H, 000H, 000H DB 000H, 000H, 000H DB 000H, 000H, 000H DB 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 000H, 000H, 000H DB 000H, 000H, 000H DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 000H, 000H, 000H, 000H DB 000H, 000H, 000H, 000H, 000H, 000H, 0 00h, 000H.DATA?; ------------------------------------------- -------------------------; These four variables are used to use Hzcolor DB when showing Chinese characters ?; Chinese characters colors hzoldx dw?; Save Chinese character coordinates XHzx dw?; Chinese characters coordinate XHzy DW?; Chinese character coordinate Y; ---------------------------------------------------------------------------------------------------------------------- --------------------------------

; ------------------------------------------------- -------------------; the specific coordinates of the snake can put 200 positions POS DW 400 DUP (?); The length of the snake LEN DB?; -------------------------------------------------- ---------------

; ------------------------------------------------- -------------------; Foodx DW? Foody DW?; -------------------- ------------------------------------------------

; ------------------------------------------------- -------------------; Temporary variable EAX DW? EBX DW? ECX DW? EDX DW? ESI DB? EDI DB?; --------- -------------------------------------------------- --------. Codemain Proc Far Mov AX, @Data MoV DS, AX; Game Initiation Interface Call Gameinit; Game Selection Speed ​​Call Selspeed CMP AX, 1 Je Gameover; Game Process Call GameProc CMP AX, 1 JE GameOvergameover:; Settings text mode MOV AH, 00 MOV Al, 03 INT 10H; Exit Program MOV AH, 4CH INT 21HMAIN ENDP

******************************; function name: GameProc; function: game process; pass parameters: empty; function returns: AX; ************************************************* GAMEPROC PUSH BX PUSH CX Push DX Push Si Push Di Mov Cl, 0; Originally Screen Functions MOV SI, 125 MOV BX, 25 MOV DI, 195 MOV DX, 95 Call Bar Mov Cl, 0 MOV Si, 1 MOV BX, 125 MOV DI, 319 MOV DX, 129 Call Bar Mov Cl, 0 MOV Si 58 MOV BX, 139 MOV DI, 267 MOV DX, 156 Call Bar; game border; left and right (2-315); up and down (2-160) MOV CX, 8 MOV Si, 1 MOV DI, 316 MOV BX, 1 MOV DX, 161 CALL REC MOV DX, 1; Initial 4 Segment Callinit; Display 4 Position Call Foodinit; Initial Location M8_1: MOV AH, 01H INT 16H JZ M8_2; Continue to wait for button MOV AH if not button 0EH MOV AL, 7 INT 10H MOV AH, 00H; get the scanning code INT 16H CMP AH, LEFT; move to the left move JZ M8_4 CMP AH, Right; move the JZ M8_5 CMP AH, Up to the right, UP; move JZ M8_6 CMP AH, Down; Top Move JZ M8_7 CMP AH, Quit; End Game JZ M8_3 JMP M8_2M8_4: CMP Direct, 2 JE M8_2 MOV Direct, 4 JMP M8_2M8_5: CMP Direct, 4 JMP M8_2 MOV Direct, 2 JMP M8_2M8_6: C MP Direct, 3 JE M8_2 MOV DIRECT, 1 JMP M8_2M8_7: CMP Direct, 1 JE M8_2 MOV Direct, 3 JMP M8_2 M8_2: Call Hidspd_Proc CMP AX, 1; Judgment Whether the JNE M8_8 JMP M8_3M8_8: JMP M8_1 M8_3: MOV AX, 1 POP DI POP SI POP DX POP CX POP BX RETGAMEPROC ENDP

*******************************; function name: selspeed; function: select game speed; pass parameters: empty; function returns : Ax; ************************************************************** SELSPEED Proc Push BX Push CX Push DX Push Si Push Di Call PPRSPD_PROC; display four Position M10_1: MOV AH, 01H INT 16H JZ M10_2; Continue to wait for button MOV AH, 0EH MOV Al, 7 INT 10H MOV AH, 00H; obtain the scanning code INT 16H CMP AH, Left; judgment the scan code left , The game speed is reduced by 1 JZ M10_3 CMP AH, Right; judgment the scan code is right, the game speed plus 1 JZ M10_4 CMP AH, Quit; Judgment the scan code is ESC, end the game JZ M10_5 CMP AH, ENTER; judgment the scan code is a carriage return , confirmed to start the game jz M10_6 jmp M10_2M10_3:; reduce speed call SubSpeed ​​jmp M10_1M10_4:; increase the speed of call AddSpeed ​​jmp M10_1M10_2: call HidSpd_Proc jmp M10_1 M10_5:; the game is mov ax, 1 jmp M10_7M10_6: mov ax, 0M10_7: pop di pop si POP DX POP CX POP BX Retselspeed Endp

******************************; function name: Gameinit; function: initialization game interface and data; transfer parameters: empty; Function returns: empty; *********************************************************** GAMEINIT Proc Push AX Push BX Push CX Push DX Push Si Push Di MoV AH, 00; Setting Graphic Mode MOV Al, 13h INT 10h Call Random; Cerete Number of Seed MOV HZX, 125; Displaying Chinese Word "Snake" Word MOV HZY, 25 MOV HZCOLOR, 4 MOV BX, Offset Hzsnake Call Msghz Call Prtmsg [Display prompt; use quadrangular as the selection button to select the speed of the game, increase the -24 pixel position each time; the coordinates of the speed 1 are (59, 140, 74, 155); the coordinates of the speed 9 (251, 140, 266, 155) MOV CL, 50 MOV SI, SPOSX MOV BX, 140 Add SPOSX, 15 MOV DI, SPOSX SUB SPOSX, 15 MOV DX, 155 Call Rec Mov DX, 0; Initial 4th Position Call Intesnakedata Mov Foodx, 22 MOV Foody, 22 Pop Di Pop Si Pop DX POP CX Pop Bx Pop Ax Retgameinit Endp

******************************; function name: INITSNAKEDATA; function: initial four-section location; transfer parameters:; DX status Sign; function returns: empty; ******************************************************** INITSNAKEDATA Proc Push AX Push BX Push CX Push DX Push Si Push Di Mov Al, 4 MOV LEN, Al Mov BX, Offset POS MOV CX, 4 MOV AX, 17; Left Coordinate Assignment CMP DX, 1; Upside Coordinate Assignment JE M9_2; Judgment is the speed test period or formal game initial period MOV DX, 125 JMP M9_1M9_2: MOV DX, 2 m9_1: MOV [BX], AX; Specific Assignment SUB AX, 5 Add BX, 2; Spaces Interval between 1 MOV [BX], DX Add BX, 2 LOOP M9_1 POP DI POP SI POP DX POP CX POP BX Pop Ax RetinitsnakeData Endp; ******************** ********; function name: prTspd_proc; function : Show the initial state of the snake; transfer parameters: empty; function returns: empty; **************************** PPRSPD_PROC PUSH AX Push Bx Push CX Push DX Push Si Push Di Mov BX, Offset Pos; Show initial snake MOV CX, 4M6_1: Push CX MOV CL, 80; get left and right coordinate MOV Si, [BX] MOV DI, SI Add Di, 4 Add BX, 2 Push BX; get up and down coordinates Push Si Mov Si, [BX] MOV BX, Si Pop Si Mov DX, BX Add DX, 4 Call Bar Pop BX Add BX, 2 Pop Cx Loop M6_1 Pop Di Pop Si Pop DX Pop CX POP BX POP A x retpprspd_proc endp

******************************; function name: hidspd_proc; function: Show the specific location of the moving snake; transfer parameters: Empty; function returning: ax; ************************************** HIDSPD_PROC PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI MOV CL, SPEED; Delayed Call Delay MOV BX, OFFSET POS MOV CL, LEN; Move to the Latest Position Deccl XOR AX, AX MOV Al, Cl, AX Push Bx MoV DX, [ BX]; Save the last section MOV EAX, DX ADD BX, 2 MOV DX, [BX] MOV EBX, DX POP BX Push BX; Erase the last MOV CL, 0 MOV Si, [BX] MOV Di, Si Add di, 4 Add BX, 2 Push Bx Push Si Mov Si, [BX] MOV BX, Si Pop Si MoV DX, BX Add DX, 4 Call Bar Pop BX Pop BX MOV CL, LEN DEC CXM7_1: Conclusion Start loop picking the coordinate Push Bx Sub BX, 4 MOV DX, [BX] Add BX, 2 MOV Si, [BX] POP ​​BX MOV [BX], DX Add BX, 2 MOV [BX], Si Sub BX , 6 LOOP M7_1 MOV BX, OFFSET POS; redefine the first section and display the first CMP Direct, 1; Top Judge JE M7_2_1 JMP M7_NEXT_2M7_2_1: Add BX, 2 MOV AX, [BX] SUB AX, 5 JNC M7_2_1_1 MOV AX, 157M7_2_1_1: MOV [BX], AX SUB BX, 2 JMP M7_3M7_NEXT_2:; Right Judgment CMP Direct, 2 JE M7_2_2 JMP M7_NEXT_3 M7_2_2: MOV AX, [BX] Add AX, 5 CMP AX, 315 JB M7_2_2_1 MOV AX, 2M7_2_2_1: MOV [BX], AX JMP M7_3M7_NEXT_3:; Decision CMP Direct, 3 JE M7_2_3 JMP M7_NEXT_4M7_2_3: Add BX, 2 MOV AX, [BX] Add AX, 5 CMP AX, 161 JB M7_2_3_1 MOV AX, 2M7_2_3_1: MOV [BX], AX SUB BX, 2 JMP M7_3M7_Next_4:; Decision to the left CMP Direct, 4 JE M7_2_4 M7_2_4: MOV AX, [BX] SUB AX, 5 JNC M7_2_4_1 MOV AX, 312M7_2_4_1: MOV [BX], AX JMP M7_3

M7_3: MOV CL, 80 MOV Si, [BX] MOV DI, SI Add Di, 4 Add BX, 2 Push Bx Push Si Mov Si, [BX] MOV BX, Si Pop Si Mov DX, BX Add DX, 4 Call Bar POP BX MOV BX, OFFSET POS; Judgment Whether to add MOV AX, [BX] Add BX, 2 MOV DX, [BX] MOV CX, 0 CMP AX, FOODX JNE M7_4 INC CXM7_4: CMP DX, Foody JNE M7_5 Inc CXM7_5 : CMP CX, 2 JE M7_6 JMP M7_7M7_6: Inc Len; increasing a section MOV BX, OFFSET POS MOV CL, LEN; Move to the last position DEC CL XOR AX, AX MOV Al, Cl Mov CL, 4 MUL CL Add BX , AX MOV DX, EAX MOV [BX], DX ADD BX, 2 MOV DX, EBX MOV [BX], DX MOV SI, EAX MOV DI, SI Add Di, 4 MOV BX, EBX MOV DX, BX Add DX, 4 MOV CL, 80 CALL BAR CALL FOODINIT; generated a new food M7_7: MOV AX, 1; return logo, 0 represents no abnormal MOV BX, OFFSET POS; Judging whether to encounter your own body MOV Si, [bx] add bx 2 MOV DI, [BX] Add BX, 2

MOV CL, LEN DEC CXM7_8: PUSH CX XOR CX, CX MOV EAX, CX; Counter, accumulated to 2 indicates failure MOV DX, [BX] Add BX, 2 MOV CX, [BX] Add BX, 2 CMP Si, DX JNE M7_10 inc eaxM7_10: cmp di, cx jne M7_11 inc eaxM7_11: mov cx, eax cmp cx, 2 je M7_9; failure pop cx loop M7_8 mov ax, 0 jmp M7_12M7_9: pop cxM7_12: pop di pop si pop dx pop cx pop bx retHidSpd_Proc ENDP

******************************; function name: addspeed; function: increase game speed; pass parameters: empty; function returns : Air; ************************************************************************************************************* AddSpeed ​​Proc Push AX Push Bx Push CX Push DX Push Si Push Di Mov Cl, 0 MOV SI, SPOSX MOV BX, 140 Add SPOSX, 15 MOV DI, SPOSX SUB SPOSX, 15 MOV DX, 155 Call Rec CMP Speed, 9; Mobile to 1 JNZ M11_1 MOV Speed, 1 MOV SPOSX, 59 JMP M11_2 M11_1 : Add Speed, 1 Add SPOSX, 24M11_2: MOV CL, 50 MOV SI, SPOSX MOV BX, 140 Add SPOP, 15 MOV DI, Sposx Sub Sposx, 15 MOV DX, 155 CALL REC POP DI POP Si Pop DX Pop CX Pop BX POP AX Retdspeed Endp

********************* **********; function name: prMsg; function: display prompt; pass parameters: empty; function returns: Empty; ********************************************************** PRTMSG Proc Push Ax Push Bx Push CX Push DX Push Si Push Di MoV DX, 1208H Show 1-9 Speed ​​Select 9 Digital Call Setgb Lea BP, SZList MoV CX, 27 Call MSG MoV DX, 1803H; Show Author Call Setgb Lea BP, SZNAME MOV CX, 34 Call MSG Pop Di Pop Si Pop DX Pop CX Pop BX pop ax RetPRTMSG ENDP; ******************************; function name: Foodinit; function: generating things; transfer parameters : Empty; function return: empty; *********************************************** FOODINIT Proc Push AX Push BX Push CX Push DX Push Si PUSH DIM13_1: XOR CX, CX MOV SI, 63; Random Foodx Coordinate Call Rand MoV BX, 5 MUL BX Add Ax, 2 MOV BX, AX CMP AX, FOODX JE M13_2 JMP M13_3M13_2: Inc CXM13_3:; Random Foody Coordinate MOV Si, 32 Call Rand Mov DX, 5 MUL DX Add Ax, 2 MOV DX, AX CMP AX, Foody JE M13_4 JMP M13_5M13_4: Inc CXM13_5: CMP CX, 2; Judgment Do I need to re-generate the random value JE M13_1

MOV CL, LEN; Judgment whether to coordinate DEC CL Mov Si, Offset Pos Mov Eax, BX in a certain festival with the snake; save the new location to the temporary variable MOV FOODX, BX MOV EBX, DX MOV Foody, DXM13_6: XOR AX, AX MOV BX, [Si] Add Si, 2 MOV DX, [Si] Add Si, 2 CMP BX, Foodx JNE M13_7 Inc AXM13_7: CMP DX, Foody JNE M13_8 INC AXM13_8: CMP AX, 2 JE M13_1; Repeat resume Random value loop m13_6m13_9: MOV BX, EAX MOV DX, EBX MOV Foodx, BX Mov Foody, DX MOV SI, BX; Show Food MOV DI, SI Add Di, 4 MOV BX, DX MOV DX, BX Add DX, 4 MOV CL , 4 Call Bar Pop Di Pop Si Pop DX POP CX POP BX Pop Ax Retfoodinit ENDP

******************************; function name: subspeed; function: reduce game speed; pass parameters: empty; function returns : Air; ******************************************************** Subspeed Proc Push AX Push BX Push CX Push DX Push Si Push Di Mov Cl, 0 MOV SI, SPOSX MOV BX, 140 Add SPOSX, 15 MOV DI, SPOSX SUB SPOSX, 15 MOV DX, 155 Call Rec CMP Speed, 1; From 1 Move to 9 JNZ M12_1 MOV Speed, 9 MOV SPOSX, 251 JMP M12_2 M12_1 : Sub Speed, 1 SUB Sposx, 24M12_2: MOV CL, 50 MOV SI, SPOSX MOV BX, 140 Add Sposx, 15 MOV DI, Sposx Sub Sposx, 15 MOV DX, 155 Call Rec Pop Di Pop Si Pop DX Pop CX Pop BX POP AX RETSUBSPEED ENDP; ****************************** *********; function name: hline; function: painting horizontal line; transfer parameters: AH 0CH; Si starting point; DI end point; Al color number; DX line number; function returns: empty; ********************************************** *** Hline Proc Near Push AX Push BX Push CX Push DX Push Si Push Di MoV BX, 1; Default End Point is greater than the starting point PUSH Si CLC SUB Si, Di JNC M1_1; negative number JMP M1_2; positive number M1_1: NEG BXM1_2: POP SIM1_3 :; Cycling line MOV CX, Si INT 10h Add Si, BX CMP Si, Di JE M1_4 JMP M1_3M1_4: POP Di Pop Si Pop DX Pop CX Pop BX Pop AX Rethline ENDP

*******************************; function name: VLINE; function: painting, passing parameters:; AH 0CH; Si starting point; di end point; Al color number; CX column number; function returns: empty; ***************** VLINE Proc Near Push AX Push Bx Push CX Push DX Push Si Push Di MoV BX, 1; Default End Point is greater than the starting point PUSH Si CLC SUB Si, Di JNC M2_1; negative number JMP M2_2; positive M2_1: NEG BXM2_2: POP SIM2_3:; Cycling Line MOV DX, SI INT 10h Add Si, BX CMP Si, Di JE M2_4 JMP M2_3M2_4: POP DI POP SI POP DX POP CX POP BX POP AX Retvline ENDP

*******************************; function name: Rec; function: draw quadrilateral; transfer parameters:; CL color; Si Left; BX on the side; DI right side; DX lower; function return: empty; ************************************** REC PROC NEAR PUSH AX Push Bx Push CX Push DX Push Si Push Di Mov AH, 0CH MOV Al, Cl, CL Push DX MOV DX, BX Call Hline; Painting Side Pop Dx Call Hline; Painting Side Mov CX, Si Mov Si, BX Push Di Mov Di, DX CALL VLINE; painting left line POP CX Inc Di; replenishing the lower right corner CALL VLINE; painted right line POP DI POP Si Pop DX POP CX Pop BX Pop AX RetRec ENDP; ********** ********** *********; function name: bar; function: draw a rectangle; pass parameters:; cl color; Si left; BX on the side; DX; DX; Function return: empty; ************************************************ BAR Proc Near Push AX Push BX Push CX Push DX Push Si Push Di MOV AH, 0CH MOV Al, Cl M4_1: Push DX MOV DX, BX Call Hline Pop DX Inc BX CMP BX, DX JZ M4_2 JMP M4_1M4_2: POP DI POP SI POP DX POP CX POP BX Pop AX RET BAR ENDP

*******************************; function name: msg; function: output string; pass parameters:; bp string Offset address; CX string length; DH / DI row / column; function returns: empty; ************************************ * MSG Proc Near Push AX Push Bx Push CX Push DX Push Si Push Di

PUSH ES PUSH DS POP ES; send data DS to ES, equivalent to ES: BP MOV Al, 0 MOV AH, 13H MOV BX, 2 INT 10H POP ES

POP DI POP SI POP DX POP CX POP BX POP AX RET MSG ENDP

******************************; function name: setgb; function: set cursor position; transfer parameters:; DH / DL Row / column; function returns: empty; ************************************************ SETGB Proc Near Push AX Push BX Push CX Push DX Push Si Push di MoV Bh, 0 MOV AH, 02H INT 10H

POP DI POP SI POP DX POP CX POP BX POP AX RetsetGB ENDP

*******************************; function name: delay; function: delay; pass parameters:; CX delay speed (Theoretically 1 is 0.5 seconds; function returns: empty; ******************************************************* DELAY Proc Push AX PUSH CX MOV AX, 0AH SUB AX, CX MOV CX, AXM3_1: PUSH CX; Outer Loop Controls Delay Speed ​​MOV CX, 3500; Standard Half Seconds should be 33144 Size M3_2: in Al, 61h And Al, 10H CMP Al, AH JE M3_1 MOV AH, Al LOOP M3_2 POP CX LOOP M3_1 POP CX POP AX Retdelay Endp; ***************************** Function Name: Msghz; Function: Display a 64 * 64 Chinese character; pass parameters:; hzx x position; hzcolor color; bx Chinese offset address; function return: empty; ********** ******************** MSGHZ Proc Push AX Push Bx Push CX Push DX Push Si Push Di MoV CX, 512 MOV DX, HZX MOV Hzoldx, DX MOV DX, 0 The number of statistical characters, to a certain number of wraps M5_1: MOV Al, [BX]; take out a character PUSH CX MOV CX, 8M5_2: RCL Al, 1 JNC M5_3; no carry push ax push dx push cx mov AH, 0CH; Write Pixels MOV Al, Hzcolor Mov DX, HZY MOV CX, HZX INT 10H POP CX Pop DX POP AX M5_3: Inc HZX LOOP M5_2 POP CX Inc BX; Remove a Character Inc DX CMP DX, 8 JNE M5_4 MOV DX, 0 ; Wrap Inc HZY PUSH DX MOV DX, HZOLDX MOV HZX, DX; Restore original X coordinate POP DXM5_4: Loop M5_1 POP DI POP Si Pop DX Pop CX Pop BX Pop AX RETMSGHZ ENDP

*******************************; function name: random; function: random seed; pass parameters: empty; function returns : Empty; ************************************************ Random Proc Push AX Push Bx Push CX Push Dx Push Si Push Di Mov AH , 0; Read Clock Counter Value INT 1AH Add DX, SEED AND DX, 8FFFH MOV SEED, DX POP DI POP SI POP DX POP CX Pop BX Pop Ax Retrandom ENDP

转载请注明原文地址:https://www.9cbs.com/read-78945.html

New Post(0)