?? robot1.txt
字號:
robot.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;宏
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include MACRO.ASM
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;結構
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include struc.ASM
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;數據段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
data segment
mess1 db '*****Play With Our Cute Robot*****',13,10,'$'
mess1len dw $-mess1-3
mess2 db 'HINT :',13,10,'$'
mess2len dw $-mess2-3
mess3 db ' 1.Key J for jumping! ',13,10,'$'
mess3len dw $-mess3-3
mess4 db ' 2.Key L for swinging left arm and leg.',13,10,'$'
mess4len dw $-mess4-3
mess5 db ' 3.Key R for swinging right arm and leg.',13,10,'$'
mess5len dw $-mess5-3
mess6 db ' 4.Key G for moving aroud.',13,10,'$'
mess6len dw $-mess6-3
mess7 db ' Keystrock ENTER ','$'
mess7len dw $-mess7-1
mess8 db 'ROBOT','$'
mess8len dw $-mess8-1
mess9 db 'Please make your choice: ','$'
mess9len dw $-mess9-1
data ends
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
data segment
ante ANTENNA <>
ante_jmp ANTENNA <0000000000230022h,00003D4Fh,00000A0Ah, 000000002B002Eh,00003D4Fh,00000A0Ah>
ante_mvr ANTENNA <0000024201410040h,,,0000024701480049h,,>
ante_mvl ANTENNA <0000020C010B000Bh,,,0000021201130014h,,>
**ce FACIAL <>
**ce_jmp FACIAL <0225h,,,022bh,,,0328h,,,0427h,,>
**ce_mvr FACIAL <0443h,,,0449h,,,0546h,,,0645h,,>
**ce_mvl FACIAL <040dh,,,0413h,,,0510h,,,060fh,,>
nec NECK <>
nec_jmp NECK <0526h,052ah,>
nec_mvr NECK <0744h,0748h,>
nec_mvl NECK <070eh,0712h,>
body_s BODY <>
body_jmp BODY <061fh,0c31h,30h,0822h,0c22h,00h,082eh,0c2eh,00h,0c23h,'*',3dh,0926h,34h>
body_mvr BODY <083dh,0e4fh,30h,0a40h,0e40h,00h,0a4ch,0e4ch,00h,0e41h,'*',3dh,0b44h,34h>
body_mvl BODY <0807h,0e19h,30h,0a0ah,0e0ah,00h,0a16h,0e16h,00h,0e0bh,'*',3dh,0b0eh,34h>
head_s HEAD <>
head_jmp HEAD <0123h,042dh,70h,0221h,0322h,70h,0223h,032fh,70h>
head_mvr HEAD <0341h,064bh,70h,043fh,0540h,70h,044ch,054dh,70h>
head_mvl HEAD <030bh,0615h,70h,0409h,050ah,70h,0416h,0517h,70h>
leg_s LEG <>
leg_jmp LEG <0d24h,132ch,60h,0d28h,1328h,00h>
leg_mvr LEG <0f42h,154ah,60h,0f46h,1546h,00h>
leg_mvl LEG <0f0ch,1514h,60h,0f10h,1510h,00h>
swing_l MOTION <>
swing_r MOTION <0a2eh,0e32h,00h,082eh,093ah,30h,1328h,152ch,00h,112ch,1232h,60h>
data ends
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;代碼段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
code segment
assume cs:code,ds:data,es:data
begin: mov ax,data
mov ds,ax
call Login_ini
call Robot_ini
call Fat
mov ah,07 ;直接鍵盤輸入
int 21h
mov ah,00 ;設置顯示模式
mov al,02 ;模式代號AL
int 10h
mov ah,4ch
int 21h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Login_ini proc
mov ah,00
mov al,03
int 10h
PUTSTR mess1,0513h,0fh,mess1len
PUTSTR mess2,0a06h,0eh,mess2len
PUTSTR mess3,0c06h,0eh,mess3len
PUTSTR mess4,0e06h,0eh,mess4len
PUTSTR mess5,1006h,0eh,mess5len
PUTSTR mess6,1206h,0eh,mess6len
call showStrokey
L0: mov ah,01h ;帶回顯鍵盤輸入
int 21h
cmp al,0dh ;是否為ESCAPE鍵?
jne L0
ret
Login_ini endp
Robot_ini proc
call Bcolor
call Robot_body
call Robot_neck
call Robot_head
call Robot_leg
call Robot_line
call Robot_**ce
call showHint
ret
Robot_ini endp
Bcolor proc
DRAW_BLK 0000h, 184fh, 00h
ret
Bcolor endp
showHint proc
PUTSTR mess9,1703h,0eh,mess9len
call showStrokey
ret
showHint endp
showStrokey proc
PUTSTR mess7,173ch, 8eh,mess7len
ret
showStrokey endp
Fat proc
L100: mov ah,01
int 21h
or al,20h ;轉小寫
cmp al,'l'
jne L7
call Robot_larmleg
jmp L100
L7: cmp al,'r'
jne L8
call Robot_rarmleg
jmp L100
L8: cmp al,'g'
jne L9
call Robot_rmove
jmp L100
L9: cmp al,'j'
jne L10
call Robot_jmp
jmp L100
L10: cmp al,0dh+20h ;判斷是否為回車鍵
jne L100
ret
Fat endp
Timer proc
mov ax,0000
L14: mov bx,0000
L13: inc bx
cmp bx,0ffffh
jne L13
inc ax
cmp ax,0fffh
jne L14
ret
Timer endp
Robot_rmove proc
call Bcolor
call Robot_body_mr
call Robot_neck_mr
call Robot_head_mr
call Robot_leg_mr
call Robot_line_mr
call Robot_**ce_mr
call showHint
call Timer
call Robot_lmove
call Timer
call Robot_ini
ret
Robot_rmove endp
Robot_jmp proc
call Bcolor
call Robot_body_j
call Robot_neck_j
call Robot_head_j
call Robot_leg_j
call Robot_line_j
call Robot_**ce_j
call showHint
call Timer
call Robot_ini
ret
Robot_jmp endp
Robot_lmove proc
call Bcolor
call Robot_body_ml
call Robot_neck_ml
call Robot_head_ml
call Robot_leg_ml
call Robot_line_ml
call Robot_**ce_ml
call showHint
ret
Robot_lmove endp
;================================
;關于天線
;---------------------
MVNXT MACRO
inc si
inc si
inc di
inc bp
ENDM
;---------------------
DRAW_ANTE MACRO pos, shape,attrib
push si
push di
push bp
push ax
;
LEA di, shape
LEA si, pos
LEA bp, attrib
;
mov ax, word ptr [si]
PUTCH [di], ax, [bp], 2
MVNXT
;
mov ax, word ptr [si]
PUTCH [di], ax, [bp], 2
MVNXT
;
mov ax, word ptr [si]
PUTCH [di], ax, [bp], 2
pop ax
pop bp
pop di
pop si
ENDM
;---------------------
DRAW_ANTE_j MACRO pos, shape,attrib
push si
push di
push bp
push ax
;
LEA si, pos
LEA di, shape
LEA bp, attrib
;
mov ax, word ptr [si]
PUTCH [di], ax, [bp], 1
MVNXT
mov ax, word ptr [si]
PUTCH [di], ax, [bp], 3
pop ax
pop bp
pop di
pop si
ENDM
;---------------------
Robot_line proc
DRAW_ANTE ante.L_POS, ante.L_SHP, ante.L_ATTR
DRAW_ANTE ante.R_POS, ante.R_SHP, ante.R_ATTR
ret
Robot_line endp
Robot_line_j proc
DRAW_ANTE_j ante_jmp.L_POS, ante_jmp.L_SHP, ante_jmp.L_ATTR
DRAW_ANTE_j ante_jmp.R_POS, ante_jmp.R_SHP, ante_jmp.R_ATTR
ret
Robot_line_j endp
Robot_line_mr proc
DRAW_ANTE ante_mvr.L_POS, ante_mvr.L_SHP, ante_mvr.L_ATTR
DRAW_ANTE ante_mvr.R_POS, ante_mvr.R_SHP, ante_mvr.R_ATTR
ret
Robot_line_mr endp
Robot_line_ml proc
DRAW_ANTE ante_mvl.L_POS, ante_mvl.L_SHP, ante_mvl.L_ATTR
DRAW_ANTE ante_mvl.R_POS, ante_mvl.R_SHP, ante_mvl.R_ATTR
ret
Robot_line_ml endp
;================================
;FACE:Eye,Nose & Mouth
;宏 DRAW_ORG
;
DRAW_ORG MACRO pos,shp,attr,cnt
PUTCH shp, pos, attr, cnt
ENDM
;---------------------
;宏 DRAW_FACE
;
DRAW_FACE MACRO **ce
DRAW_ORG **ce.LEYE_POS,**ce.LEYE_SHP, **ce.LEYE_ATTR,1
DRAW_ORG **ce.REYE_POS,**ce.REYE_SHP, **ce.REYE_ATTR,1
DRAW_ORG **ce.NOSE_POS,**ce.NOSE_SHP, **ce.NOSE_ATTR,1
DRAW_ORG **ce.MOUTH_POS,**ce.MOUTH_SHP, **ce.MOUTH_ATTR,3
ENDM
Robot_**ce proc
DRAW_FACE **ce
ret
Robot_**ce endp
Robot_**ce_mr proc
DRAW_FACE **ce_mvr
ret
Robot_**ce_mr endp
Robot_**ce_j proc
DRAW_FACE **ce_jmp
ret
Robot_**ce_j endp
Robot_**ce_ml proc
DRAW_FACE **ce_mvl
ret
Robot_**ce_ml endp
;================================
;Neck
; 宏 DRAW_NECK
DRAW_NECK MACRO nec
DRAW_BLK nec.NEC_TL, nec.NEC_BR, nec.NEC_ATTR
ENDM
; ----------------------
Robot_neck proc
DRAW_NECK nec
ret
Robot_neck endp
Robot_neck_mr proc
DRAW_NECK nec_mvr
ret
Robot_neck_mr endp
Robot_neck_ml proc
DRAW_NECK nec_mvl
ret
Robot_neck_ml endp
Robot_neck_j proc
DRAW_NECK nec_jmp
ret
Robot_neck_j endp
;================================
;Body
; 宏:DRAW_BODY
DRAW_BODY MACRO body
DRAW_BLK body.BODY_TL1, body.BODY_BR1, body.BODY_ATT1
PUTCH body.BODY_DEC_SHP, body.BODY_DEC_POS, body.BODY_DEC_ATT, 12
DRAW_BLK body.BODY_TL2, body.BODY_BR2, body.BODY_ATT2
DRAW_BLK body.BODY_TL3, body.BODY_BR3, body.BODY_ATT3
PUTSTR mess8,body.BODY_STR_POS,body.BODY_STR_ATT,mess8len
ENDM
; --------------
Robot_body proc
DRAW_BODY body_s
ret
Robot_body endp
Robot_body_mr proc
DRAW_BODY body_mvr
ret
Robot_body_mr endp
Robot_body_j proc
DRAW_BODY body_jmp
ret
Robot_body_j endp
Robot_body_ml proc
DRAW_BODY body_mvl
ret
Robot_body_ml endp
;================================
;Head
; 宏:DRAW_HEAD
DRAW_HEAD MACRO head
DRAW_BLK head.HEAD_TL1, head.HEAD_BR1, head.HEAD_ATT1
DRAW_BLK head.HEAD_TL2, head.HEAD_BR2, head.HEAD_ATT2
DRAW_BLK head.HEAD_TL3, head.HEAD_BR3, head.HEAD_ATT3
ENDM
; --------------
Robot_head proc
DRAW_HEAD head_s
ret
Robot_head endp
Robot_head_j proc
DRAW_HEAD head_jmp
ret
Robot_head_j endp
Robot_head_mr proc
DRAW_HEAD head_mvr
ret
Robot_head_mr endp
Robot_head_ml proc
DRAW_HEAD head_mvl
ret
Robot_head_ml endp
;================================
;Leg
; 宏:DRAW_LEG
DRAW_LEG MACRO leg
DRAW_BLK leg.LEG_TL1, leg.LEG_BR1, leg.LEG_ATT1
DRAW_BLK leg.LEG_TL2, leg.LEG_BR2, leg.LEG_ATT2
ENDM
; --------------
Robot_leg proc
DRAW_LEG leg_s
ret
Robot_leg endp
Robot_leg_j proc
DRAW_LEG leg_jmp
ret
Robot_leg_j endp
Robot_leg_mr proc
DRAW_LEG leg_mvr
ret
Robot_leg_mr endp
Robot_leg_ml proc
DRAW_LEG leg_mvl
ret
Robot_leg_ml endp
;================================
;MOTION
; 宏:DRAW_MTN
DRAW_MTN MACRO swing
DRAW_BLK swing.MV_ARM_TL1, swing.MV_ARM_BR1, swing.MV_ARM_ATT1
DRAW_BLK swing.MV_ARM_TL2, swing.MV_ARM_BR2, swing.MV_ARM_ATT2
DRAW_BLK swing.MV_LEG_TL1, swing.MV_LEG_BR1, swing.MV_LEG_ATT1
DRAW_BLK swing.MV_LEG_TL2, swing.MV_LEG_BR2, swing.MV_LEG_ATT2
ENDM
; --------------
Robot_larmleg proc
DRAW_MTN swing_l
call Timer
call Robot_ini
ret
Robot_larmleg endp
Robot_rarmleg proc
DRAW_MTN swing_r
call Timer
call Robot_ini
ret
Robot_rarmleg endp
code ends
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end begin
MACRO.ASM
;;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;宏
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;--------------------
;宏: SETCUR
;功能:置光標位置
;入口:coor:行列號
;--------------------
SETCUR MACRO coor
push dx
push ax
mov dx, coor ;DH=行號,DL=列號
mov ah,02h
int 10h
pop ax
pop dx
ENDM
;--------------------
;宏: ECHO
;功能:顯示字符
;入口:char: 字符
; attr:屬性
; dup: 重復次數
;--------------------
ECHO MACRO char,attr,dup
push ax
push bx
push cx
mov ah,09h
mov al,char
mov bl,attr
mov cx,dup
int 10h
pop cx
pop bx
pop ax
ENDM
;--------------------
;宏: PUTCH
;功能:顯示字符串
;入口: char:字符變量
; coor:行列號
; attr:屬性
; len: 重復次數
;--------------------
PUTCH MACRO char, coor, attr, len
push ax
push bx
push cx
SETCUR coor
mov ah,09h
mov al,char
mov bl,attr
mov cx,len
int 10h
pop cx
pop bx
pop ax
ENDM
;--------------------
;宏: PUTSTR
;功能:顯示字符串
;入口: str:字符串變量
; coor:行列號
; attr:屬性
; len: 字符串長度
;--------------------
PUTSTR MACRO str, coor, attr, len
LOCAL L_1
push si
push di
push ax
push dx
;
lea si,str
mov dx,coor
mov bl,attr
mov di,len
;
L_1: SETCUR dx
mov al,[si]
mov cx,1
mov ah,09h
int 10h
inc si
inc dl
dec di
cmp di,0
jnz L_1
;
pop dx
pop ax
pop di
pop si
ENDM
;--------------------
;宏: DRAW_BLK
;功 能:填充屏幕塊
;入口參數:ATTR=填充空白的屬性
; TL =空白區左上角的行列號
; BR =空白區右下角的行列號
;--------------------
DRAW_BLK MACRO TL, BR, ATTR
push ax
mov ax, 0600h
mov bh, ATTR
mov cx, TL
mov dx, BR
int 10h
pop ax
ENDM
struc.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;結構
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;ANTENNA
;FACIAL
;NECK
;HEAD
;BODY
;LEG
;MOTION
ANTENNA STRUC
;L_POS DQ 0000260225012400h ;從右至左,左天線坐標(橫,縱)
L_POS DQ 0000022601250024h ;從右至左,左天線坐標(行,列)
L_SHP DD 005C5C4Fh
L_ATTR DD 00020202h
;
; R_POS DQ 00002A022B012C00h ;從右至左,右天線坐標
R_POS DQ 0000022A012B002Ch ;從右至左,右天線坐標
R_SHP DD 002F2F4Fh
R_ATTR DD 00020202h
ANTENNA ENDS
FACIAL STRUC
LEYE_POS DW 0425h
LEYE_SHP DB 02h
LEYE_ATTR DB 0f2h
REYE_POS DW 042bh
REYE_SHP DB 02h
REYE_ATTR DB 0f2h
NOSE_POS DW 0528h
NOSE_SHP DB 'V'
NOSE_ATTR DB 71h
MOUTH_POS DW 0627h
MOUTH_SHP DB '-'
MOUTH_ATTR DB 74h
FACIAL ENDS
NECK STRUC
NEC_TL DW 0726h ;左上角坐標
NEC_BR DW 072ah ;右下角坐標
NEC_ATTR DB 20h ;顏色
NECK ENDS
HEAD STRUC
HEAD_TL1 DW 0323h
HEAD_BR1 DW 062dh
HEAD_ATT1 DB 70h
HEAD_TL2 DW 0421h
HEAD_BR2 DW 0522h
HEAD_ATT2 DB 70h
HEAD_TL3 DW 042eh
HEAD_BR3 DW 052fh
HEAD_ATT3 DB 70h
HEAD ENDS
BODY STRUC
BODY_TL1 DW 081fh
BODY_BR1 DW 0e31h
BODY_ATT1 DB 30h
BODY_TL2 DW 0a22h
BODY_BR2 DW 0e22h
BODY_ATT2 DB 00h
BODY_TL3 DW 0a2eh
BODY_BR3 DW 0e2eh
BODY_ATT3 DB 00h
BODY_DEC_POS DW 0e23h
BODY_DEC_SHP DB '*'
BODY_DEC_ATT DB 3dh
BODY_STR_POS DW 0b26h
BODY_STR_ATT DB 34h
BODY ENDS
LEG STRUC
LEG_TL1 DW 0f24h
LEG_BR1 DW 152ch
LEG_ATT1 DB 60h
LEG_TL2 DW 0f28h
LEG_BR2 DW 1528h
LEG_ATT2 DB 00h
LEG ENDS
MOTION STRUC
MV_ARM_TL1 DW 081fh
MV_ARM_BR1 DW 0e22h
MV_ARM_ATT1 DB 00h
MV_ARM_TL2 DW 0816h
MV_ARM_BR2 DW 0922h
MV_ARM_ATT2 DB 30h
;
mv_lEG_TL1 DW 1324h
MV_LEG_BR1 DW 1527h
MV_LEG_ATT1 DB 00h
MV_LEG_TL2 DW 111dh
MV_LEG_BR2 DW 1223h
MV_LEG_ATT2 DB 60h
MOTION ENDS
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -