程序设计项目十一
动态画出一个棵七彩圣诞树。参看demo5.gif示例。
参考代码:
画树的代码感觉想到有两种,一种是向下面写的一样
另一种是把这个路线保存下来,然后循环添加的他的路线
1 assume cs:code 2 3 data segment 4 db 'ACEGIKMOQSUWY13579BD' 5 db 'BDFHJLNPRTVXZ2468ACE' 6 data ends 7 8 stack segment 9 dw 8 dup(0) 10 stack ends 11 12 code segment 13 start: 14 mov ax,data 15 mov ds,ax 16 mov ax,0b800h 17 mov es,ax 18 mov ax,stack 19 mov ss,ax 20 mov sp,10h 21 22 call clear_screen 23 call greenground 24 call draw_chrismastree 25 call over 26 27 draw_chrismastree: 28 mov di,80 29 mov ah,31 30 mov al,'*' 31 call draw 32 mov cx,7 33 dxt0: 34 add di,156 35 call draw 36 loop dxt0 37 mov cx,6 38 dxt1: 39 add di,4 40 call draw 41 loop dxt1 42 mov cx,10 43 dxt2: 44 add di,156 45 call draw 46 loop dxt2 47 mov cx,10 48 dxt3: 49 add di,4 50 call draw 51 loop dxt3 52 mov cx,7 53 dxt4: 54 add di,160 55 call draw 56 loop dxt4 57 mov cx,3 58 dxt5: 59 add di,4 60 call draw 61 loop dxt5 62 mov cx,7 63 dxt6: 64 sub di,160 65 call draw 66 loop dxt6 67 mov cx,10 68 dxt7: 69 add di,4 70 call draw 71 loop dxt7 72 mov cx,10 73 dxt8: 74 sub di,164 75 call draw 76 loop dxt8 77 mov cx,6 78 dxt9: 79 add di,4 80 call draw 81 loop dxt9 82 mov cx,8 83 dxt10: 84 sub di,164 85 call draw 86 loop dxt10 87 ret 88 89 draw: 90 add ah,12 91 mov es:[di],ax 92 call sleep_1s 93 ret 94 95 greenground: 96 mov di,0 97 mov bp,3844 98 mov cx,25 99 gg0:100 push cx101 mov ah,02h102 mov si,0103 mov bx,20104 mov cx,20105 gg1:106 mov al,ds:[si]107 mov es:[di],ax108 mov al,ds:[bx]109 mov es:[bp],ax110 add di,8111 add bp,8112 inc si113 inc bx114 loop gg1115 call sleep_1s116 sub bp,320117 pop cx118 loop gg0119 ret120 121 sleep_1s:122 push cx123 mov cx,8h124 sps0:125 push cx126 mov cx,0ffffh127 sps1:128 loop sps1129 pop cx130 loop sps0131 pop cx132 ret133 134 clear_screen:135 push cx136 push di137 mov di,0138 mov cx,25139 cses0:140 push cx141 mov cx,80142 cses1:143 mov word ptr es:[di],0144 add di,2145 loop cses1146 pop cx147 loop cses0148 pop di149 pop cx150 ret151 152 over:153 mov ax,4c00h154 int 21h155 code ends156 end start