汇编音乐程序.docx

上传人:b****5 文档编号:5693500 上传时间:2022-12-31 格式:DOCX 页数:14 大小:16.76KB
下载 相关 举报
汇编音乐程序.docx_第1页
第1页 / 共14页
汇编音乐程序.docx_第2页
第2页 / 共14页
汇编音乐程序.docx_第3页
第3页 / 共14页
汇编音乐程序.docx_第4页
第4页 / 共14页
汇编音乐程序.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

汇编音乐程序.docx

《汇编音乐程序.docx》由会员分享,可在线阅读,更多相关《汇编音乐程序.docx(14页珍藏版)》请在冰豆网上搜索。

汇编音乐程序.docx

汇编音乐程序

;-----------------------------------------

;画横线

;-------------------------------------------

DRAWLINE0MACROSTART_X,START_Y,END_X,COLOR

LOCALPAINT

PUSHAX

PUSHBX

PUSHCX

PUSHDX

MOVAH,0CH

MOVAL,COLOR

MOVBX,0

MOVCX,START_X

MOVDX,START_Y

PAINT:

INT10H

INCCX

CMPCX,END_X

JCPAINT

POPDX

POPCX

POPBX

POPAX

ENDM

;------------------------------------------------

;画竖线

;-----------------------------------------------

DRAWLINE1MACROSTART_X,START_Y,END_Y,COLOR

LOCALPAINT

PUSHAX

PUSHBX

PUSHCX

PUSHDX

MOVAH,0CH

MOVAL,COLOR

MOVBX,0

MOVCX,START_X

MOVDX,START_Y

PAINT:

INT10H

INCDX

CMPDX,END_Y

JCPAINT

POPDX

POPCX

POPBX

POPAX

ENDM

;----------------------------------------------

;画斜线向右倾斜

;----------------------------------------------

DRAWOBILQUEMACROSTART_X,START_Y,END_X,COLOR

LOCALPAINT2

PUSHAX

PUSHBX

PUSHCX

PUSHDX

MOVAH,0CH

MOVAL,COLOR

MOVBX,0

MOVDX,START_Y

MOVCX,START_X

PAINT2:

INT10H

DECCX

INCDX

CMPCX,END_X

JAPAINT2

POPDX

POPCX

POPBX

POPAX

ENDM

;-------------------------------------------

;画填充矩形

;-------------------------------------------

DRAWMACROSTART_X,START_Y,END_X,END_Y,COLOR

LOCALDRAW_NEXT

      PUSHAX

      PUSHBX

      PUSHCX

      PUSHDX

      

      MOVAH,0CH                                        ;写像素点

      MOVAL,COLOR                                   ;设置颜色

      MOVBH,0                                             ;选用页号0

      MOVCX,START_X                                ;列起始点

      MOVDX,START_Y                                ;行起始点

DRAW_NEXT:

      INT10H                                                 ;画点

      INCCX                                                  ;画横线

      CMPCX,END_X                                     ;比较行是否画完

      JNEDRAW_NEXT                                  ;画另一行

      MOVCX,START_X                               ;另一行的起始点

      INCDX

      CMPDX,END_Y                                     ;比较列是否画完

      JNEDRAW_NEXT                                  ;未完继续画

    

      POPDX

      POPCX

      POPBX

      POPAX

      ENDM

;--------------------------------------------       

DATASSEGMENT

WHITEDB0FFH

BLACKDB0

YELLOWDB0EEH

GRAYDB8

CHOSEDB'Chosethetone:

C,F',0AH,0DH,'$'

ANSWERDB0AH,0DH,'Youhavechosedthetone,Nowenjoythegame!

$'

;TABFADW441,495,556,589,661,742,833

;TABFBDW495,556,624,661,742,833,935

TABFCDW192,294,330,350,393,441,495

;TABFDDW294,330,371,393,441,495,556

;TABFEDW330,371,416,441,495,556,624

TABFFDW350,393,441,467,525,589,661

;TABFGDW393,441,495,525,589,661,742

;ZERODW-1

BUFFERDW0

DTIMEDW10

TONEFDW0

TABOLINEDW240,290,340,390,440,490

BLACKLDW225,275,375,425,475

BLACKRDW  255,305,405,455,505

BBLDW180,230,330,380,430

BBRDW211,261,361,411,461

WLDW101,151,201,251,301,351,401

WRDW150,200,250,300,350,400,451

DATASENDS

CODESSEGMENT

   ASSUMECS:

CODES,DS:

DATAS

START:

   MOVAX,DATAS

   MOVDS,AX

   

   CALLINIT

   CALLOPEN

;---------------------------------------

;主界面

;----------------------------------------

;画白键盘,平行四边形

;----------------------------------------      

   MOVSI,190  ;SI=START_X

   MOVDI,140  ;DI=START_Y

   MOVBP,540  ;BP=END_X

DRAWW:

  DRAWLINE0SI,DI,BP,WHITE

  DECSI

  DECBP

  INCDI

  CMPDI,230

  JCDRAWW

;------------------------------------------

;DRAW190,120,540,140,YELLOW

;-------------------------------------

;画阴影

;-------------------------------------

  DRAW100,230,450,250,GRAY

  

;--------------------------------------

;侧面阴影

;-------------------------------------

MOVSI,140

PAINTSIDE:

DRAWOBILQUE540,SI,450,GRAY

INCSI

CMPSI,160

JCPAINTSIDE

;----------------------------------------

;黑键阴影

;--------------------------------------

MOVSI,140

PAINTSIDE0:

DRAWOBILQUE255,SI,210,WHITE

INCSI

CMPSI,150

JCPAINTSIDE0

MOVSI,140

PAINTSIDE1:

DRAWOBILQUE305,SI,260,WHITE

INCSI

CMPSI,150

JCPAINTSIDE1

MOVSI,140

PAINTSIDE2:

DRAWOBILQUE405,SI,360,WHITE

INCSI

CMPSI,150

JCPAINTSIDE2

MOVSI,140

PAINTSIDE3:

DRAWOBILQUE455,SI,410,WHITE

INCSI

CMPSI,150

JCPAINTSIDE3

MOVSI,140

PAINTSIDE4:

DRAWOBILQUE505,SI,460,WHITE

INCSI

CMPSI,150

JCPAINTSIDE4

;---------------------------------------

;画分割线

;---------------------------------------

  MOVSI,240

REDRAW0:

  MOVDI,SI

  SUBDI,90

  DRAWOBILQUESI,140,DI,BLACK

  ADDSI,50

  CMPSI,540

  JCREDRAW0

   

  MOVSI,150

REDRAW1:

  DRAWLINE1SI,230,250,BLACK

  ADDSI,50

  CMPSI,440

  JCREDRAW1

;------------------------------------------

;画黑键盘

;------------------------------------------

MOVBX,0

PAINTB:

MOVSI,OFFSETBLACKL

MOVDI,OFFSETBLACKR

MOVSI,[SI+BX]

MOVBP,[DI+BX]

;DRAWSI,185,BP,195,BLACK

   MOVDI,140  ;DI=START_Y

DRAWB:

  DRAWLINE0SI,DI,BP,BLACK

  DECSI

  DECBP

  INCDI

  CMPDI,185

  JCDRAWB

  ADDBX,2

  CMPBX,9

  JCPAINTB

;-----------------------------------------

;黑键底下阴影

;-----------------------------------------

MOVBX,0

PAINTBB:

MOVSI,OFFSETBBL

MOVDI,OFFSETBBR

MOVSI,[SI+BX]

MOVBP,[DI+BX]

DRAWSI,185,BP,195,BLACK

ADDBX,2

   ;MOVDI,140  ;DI=START_Y

;DRAWB:

;DRAWLINE0SI,DI,BP,BLACK

;DECSI

;DECBP

;INCDI

;CMPDI,185

;JCDRAWB

;ADDBX,2

  CMPBX,9

  JCPAINTBB

;-----------------------------------------

;提示选择信息

;-------------------------------

  MOVAH,09H

  MOVDX,OFFSETCHOSE

  INT21H

;---------------------------------

INPUT:

  MOVAH,01H

  INT21H

  CMPAL,'C'

  JZCTONE

  CMPAL,'c'

  JZCTONE

  CMPAL,'F'

  JZFTONE

  CMPAL,'f'

  JZFTONE

  JMPINPUT

;-------------------------------

;C调,F调

;--------------------------------  

CTONE:

MOVDI,OFFSETTABFC

JMPANS

FTONE:

  MOVDI,OFFSETTABFF

;------------------------

ANS:

MOVTONEF,DI;把选择的音调标号存储在TONEF中

MOVDX,OFFSETANSWER;显示提示信息

MOVAH,09H

INT21H

;-------------------------------------

;获取弹奏的音符

;-------------------------------------

SCAN:

MOVAH,00H

INT16H

   CMPAL,37H  ;ASCII>37H,退出

   JAERROR

   CMPAL,31H  ;ASCII<31H,退出

   JCERROR

   ANDAX,000FH;将ASCII码转换成数字

   MOVBUFFER,AX;将数字存储在内存空间BUFFER中

   JMPPLAY

ERROR:

CMPAL,1BH

JZEXIT

JMPSCAN

PLAY:

MOVDI,TONEF

DECAX

ADDAX,AX  ;TABFx为双字表,需要将获得的ASCII符*2

ADDDI,AX

MOVBX,[DI];根据按键获取的ASCII码得到相应的频率值

;--------------------------------------------------------

MOVDX,12H

MOVAX,34DEH  ;1.193182MHZ/BX

DIVBX

OUT42H,AL

MOVAL,AH

OUT42H,AL

;---------------------------------------------------

;画阴影抖动模拟动态效果

PAINTKEY:

MOVAX,BUFFER   

MOVSI,OFFSETWL

MOVDI,OFFSETWR

DECAX

ADDAX,AX

ADDSI,AX

ADDDI,AX

MOVSI,WORDPTR[SI]

MOVDI,WORDPTR[DI]

;-------------------------------------

DRAWSI,230,DI,250,WHITE  

DRAWSI,230,DI,250,WHITE

;------------------------------------

CALLDELAY  ;扬声器延时

MOVAX,12H  ;往扬声器送高频,模拟关闭

OUT42H,AL

MOVAL,AH

OUT42H,AL

JMPSCAN

EXIT:

CALLCLOSE

MOVAH,1

   INT21H

   MOVAH,4CH

   INT21H

;--------------------------------------------------------

DELAYPROC

MOVAH,2DH

MOVCX,0

MOVDX,0

INT21H;设置系统时间

READ:

MOVAH,2CH

INT21H

MOVAL,100

MULDH

   MOVDH,0

ADDAX,DX

CMPAX,DTIME

JCREAD

RET

DELAYENDP

;---------------------------------------

OPENPROC

PUSHAX

INAL,61H

ORAL,03H

OUT61H,AL

POPAX

RET

OPENENDP

;-----------------------------------------

CLOSEPROC

PUSHAX

INAL,61H

ANDAL,0FCH

OUT61H,AL

POPAX

RET

CLOSEENDP

;------------------------------------------

INITPROC

MOVAH,00H

   MOVAL,12H;640*480彩色图形

   INT10H

   

MOVAL,80H;对8255进行初始化工作,A口、B口均为输出状态工作与方式0

OUT63H,AL

MOVAL,0B7H;对计数器8254进行初始化工作,选2号计数器,且先读写低8位后高8位,工作与模式3

OUT43H,AL

RET

INITENDP

   

CODESENDS

   ENDSTART

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 学科竞赛

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1