zoukankan      html  css  js  c++  java
  • 基于汇编语言的电子琴设计(2)

    六、程序清单:

    主要程序代码如下:

    ;宏定义

    DRAW MACRO START_X,START_Y,END_X,END_Y,COLOR

            LOCAL DRAW_NEXT

    local :避免宏重复调用时,标号的重复

    ;功能:画填充的矩形

    ;使用条件:START_X < END_X ,START_Y < END_Y

           PUSH AX

           PUSH BX

           PUSH CX

           PUSH DX

          

           MOV AH,0CH                                         ;写像素点

           MOV AL,COLOR                                    ;设置颜色

           MOV BH,0                                              ;选用页号0

           MOV CX,START_X                                 ;列起始点

           MOV DX,START_Y                                 ;行起始点

    DRAW_NEXT:

           INT 10H                                                  ;画点

           INC CX                                                   ;画横线

           CMP CX,END_X                                      ;比较行是否画完

           JNE DRAW_NEXT                                   ;画另一行

        MOV CX, START_X                                ;另一行的起始点

        INC DX

        CMP DX,END_Y                                      ;比较列是否画完

        JNE DRAW_NEXT                                   ;未完继续画

          

           POP DX

           POP CX

           POP BX

           POP AX

           ENDM

    DRAWSQRE MACRO START_X,START_Y,END_X,END_Y,COLOR

           LOCAL ROW_UP,ROW_DOWN,RANK_LEFT,RANK_RIGHT

    ;功能:画不填充的矩形

           PUSH AX

           PUSH BX

           PUSH CX

           PUSH DX

           PUSH SI

     

          MOV AH,0CH

           MOV AL,COLOR

           MOV BH,0

           MOV CX,START_X

           MOV DX,START_Y

    ROW_UP:                                        ;画上边

           INT 10H

           INC CX

           CMP CX,END_X

           JNE ROW_UP

     

    RANK_RIGHT:                                 ;画右边

           INT 10H

        INC DX

        CMP DX,END_Y

        JNE RANK_RIGHT

     

           MOV CX, START_X                  ;下边起始点

           MOV SI,END_X

           INC SI

    ROW_DOWN:                                 ;画下边

           INT 10H

           INC CX

           CMP CX,SI

           JNE ROW_DOWN

          

           MOV DX,START_Y                   ;右边起始点

           MOV CX,START_X

    RANK_LEFT:                                   ;画右边

           INT 10H

           INC DX

           CMP DX, END_Y

           JNE RANK_LEFT

          

           POP SI

           POP DX

           POP CX

           POP BX

           POP AX

           ENDM

     

    ;数据段

    DATA SEGMENT

           ;定义在屏幕绘制字

           START_COL DB ?                     ;存储起始行

           TEXT DB 16                                                                 ;起始行

                    DB 2                                                             ;起始列

                 DB 06H                                                         ;字体颜色

                 DB 'Piano XP',0FFH,'Copyright(c)Auto-5-5th',0FFH,0FFH        ;显示字

                 DB 10 DUP(2 DUP(0DBH),2 DUP(20H)),0FFH                     ;颜色交叉矩形

                 DB 10 DUP(2 DUP(20H),2 DUP(0DBH)),0FFH

                 DB 10 DUP(2 DUP(0DBH),2 DUP(20H)),0FFH

                 DB 10 DUP(2 DUP(20H),2 DUP(0DBH)),0FFH

                 DB 10 DUP(2 DUP(0DBH),2 DUP(20H)),0FFH

                 DB 10 DUP(2 DUP(20H),2 DUP(0DBH)),0FFH

                 DB 00

           ;白色琴键坐标

        ST_LX DW  50,61,72,83,94,105,116

        ST_MX DW  127,138,149,160,171,182,193

        ST_HX DW  204,215,226,237,248,259,270

        ST_Y   DW  50

        ED_LX DW  60,71,82,93,104,115,126

        ED_MX DW  137,148,159,170,181,192,203

        ED_HX DW  214,225,236,247,258,269,280

        ED_Y   DW  90

           ;黑色琴键坐标

        BT_X  DW 57,68,90,101,112

               DW 134,145,167,178,189

               DW 211,222,244,254,265

        BT_Y  DW  50

        BD_X DW  64,75,97,108,119

              DW  141,152,174,185,196

              DW  218,229,251,262,273

        BD_Y  DW  70

    ;音乐频率值

           LOWD  DW 131

           LOWDD DW 147,165,175,196,220,247

           MID  DW 262

           MIDD DW 294,330,349,392,440,494

           HGH  DW 523

           HGHD DW 587,659,797,783,879,987,1046

     

        KEYFLAG DB 1                                       ;标记低(0)、中(1)、高(2)音键

           KEYNUM DW 1                                       ;存储1~7

        DELAY_TIME DW 7000                          ;延时

           SONG DW 100                                         ;保存所选的自动演奏的曲目

           TUNE DW 1                                             ;标记c调或d

           AUDIO DW 1                                          ;标记低(1)、中(2)、高音(3

    ;自动演奏的歌曲频率和延时

    MUS_FREQ1 DW 440,392,330,392,523,440,392,440

             DW 330,392,440,392,330,262,220,392

             DW 330,2 DUP(294),330,2 DUP(392),440,330

             DW 294,262,392,330,294,262,220,262,196

             DW -1

    MUS_TIME1 DW 37,12,3 DUP(25),2 DUP(12),50

             DW 25,2 DUP(12 ),2 DUP(25),4 DUP(12 ),50

             DW 37 ,12 ,25,2 DUP(12 ),2 DUP(25),50

             DW 37 ,5 DUP(12 ),100

    MUS_FREQ2 DW 392,523,392,330,2 DUP(262,330,392),2 DUP(523)

             DW 349,3 DUP(440),330,3 DUP(392),294,349,330,294,262

             DW 392,523,392,330,2 DUP(262,330,392),2 DUP(523)

             DW 349,3 DUP(440),330,3 DUP(392),294,349,330,294,262

             DW 392,3 DUP(523),494,587,392,392,3 DUP(587),523,659,392

             DW 3 DUP(523),330,3 DUP(392),294,349,330,294,262

             DW -1

    MUS_TIME2 DW 12 ,3 DUP(25,2 DUP(12 )),2 DUP(25)

             DW 2 DUP(19,6,2 DUP(12 )),4 DUP(12 )

             DW 25,12 ,3 DUP(25,2 DUP(12 )),2 DUP(25)

             DW 2 DUP(19,6,2 DUP(12 )),5 DUP(12 )

             DW 2 DUP(19,6,4 DUP(12 ),25)

             DW 25,2 DUP(12 ),19,6,6 DUP(12 ),25

    MUS_FREQ3 DW 262,262,294,330,330,349,392,440,392,330

             DW 392,349,330,294,349,330,294,262

             DW 262,262,294,330,330,349,392,440,392,330

             DW 392,349,330,294,330,294,262,196

             DW 392,349,330,294,196,196,349,330,294,262

             DW 392,349,330,294,196,196,349,330,294,262

             DW 262,262,294,330,330,349,392,440,392,330

             DW 392,349,330,294,330,294,262

             DW -1

    MUS_TIME3 DW 3 DUP(25,2 DUP(12)),50

             DW 2 DUP(25,2 DUP(12),50)

             DW 3 DUP(25,2 DUP(12)),50

             DW 2 DUP(25,2 DUP(12)),2 DUP (50)

             DW 3 DUP(25,2 DUP(12)),50

             DW 3 DUP(25,2 DUP(12)),50 

             DW 3 DUP(25,2 DUP(12)),50

             DW 2 DUP(25,2 DUP(12)),50

    MUS_FREQ4 DW 262,262,294,330,330,294,262,262,220,196

            DW 262,294,330,294,262,294

            DW 262,294,330,330,294,294,262,220,220,294,262,262,220,196

            DW 196,220,220,262,262,294,294,262,220

            DW 294,330,294,262,262,294,262,220,196,220

            DW 196,220,262,294,330,392,294,330,262,294,262,220

            DW 220,294,247,220,196,196

            DW 4 DUP(392),330,392,440,440,392,330

            DW 5 DUP(440),392,392,330,294

            DW 440,392,440,392,330,294,330,294,262,220

            DW 4 DUP(294),262,220,196

            DW 2 DUP(440,392),2 DUP(330,294),262,220

            DW 3 DUP(294),262,220,392

            DW -1

    MUS_TIME4 DW 3 DUP(20,10,10),50

           DW 20,10,20,10,10,80

           DW 20,10,20,10,10,3 DUP(20,10),20,20,80

           DW 20,10,10,20,20,20,10,10,40

           DW 20,10,20,20,10,5,5,10,10,40

          DW 20,10,2 DUP(20,10,10),10,5,5,20

           DW 20,20,20,10,10,80

           DW 10,20,10,20,10,10,40,10,10,20

           DW 8 DUP(10),80

           DW 20,10,10,20,20,4 DUP(10),40

           DW 15,5,10,10,20,20,80

           DW 20,10,10,20,20,4 DUP(10),40

           DW 40,20,20,40,40,100

     

    MUS_FREQ5 DW 330,392,440,330,392,294   

           DW 330,392,440,523,440,392,220,262,330,294

           DW 294,330,392,294,330,294,220,220        

           DW 220,262,294,330,294,247,220,262,196    

           DW 294,330,294,247,220,196,262               

           DW  523,523,440,523,440,523,440,392

           DW  392,330,440,392,262,294,262,292,330

           DW  330,330,294,330

           DW  523,523,494,440

           DW 330,330,294,330,523,494,440,330,392

           DW -1

    MUS_TIME5 DW 2 DUP(12,12,75),3 DUP(12),25,12,25,6,6,12,75 #1,2

           DW 12,12,75,4 DUP(12),75,12,12,37,5 DUP(12),75

           DW 37,12,12,12,12,12,50

           DW 12,12,12,50,12,12,12,75

           DW 12,12,37,12,25,6,6,12,50,12,12,12,50,12,12,12,75

           DW 12,12,37,12,12,12,12,12,75

    DATA ENDS

    〈未完〉

  • 相关阅读:
    Android控件之圆形Button
    MotionEvent常见值
    Android通过URL加载网络图片
    Android音频播放实例
    Android沉浸式任务栏的实现
    Android学习之路书籍推荐
    Linux端BaiduPCS-Go使用方法
    Remove Duplicates from Sorted ListII
    RemoveDuplicatesfromSortedList
    Partition List 划分链表
  • 原文地址:https://www.cnblogs.com/aiwz/p/6333314.html
Copyright © 2011-2022 走看看