Advertisement
Levii_Valenok

Untitled

May 28th, 2022
3,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. .model small
  3. .stack 100h
  4. .data
  5.     platform db 0FFh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h,0FEh,44h
  6.     platformRight   dw ?
  7.     platformLeft    dw ?
  8.     line_title      db 0FEh,66h
  9.     line            dw 0x0005
  10.     ball            db 0Fh, 0Ah  
  11.     size_platform   dw 0x001A                
  12.     size_line       dw 0x00A0                    
  13.     platformLoc     dw 0x0F50              
  14.     ballLoc         dw 0x0F00
  15.     repeat          dw 0x8F00
  16.     endLine         dw 0x0FF0
  17.     byteDivider     db 0x0002
  18.     curX            dw 0x0050h
  19.     curY            dw 0x0017h
  20.     vectorX         dw -2h
  21.     vectorY         dw -1h
  22.     points          dw 0x0000                                
  23.     max_coints      dw 0x0250                      
  24.     points_str      db 10 dup(?)            
  25.     LEN             dw 0                          
  26.     score           db ' ',0Fh
  27.                     db 's',0Fh,'c',0Fh,'o',0Fh,'r',0fh,'e',0Fh,':',0Fh,' ',0Fh ,' ',0h,' ',07h  ,' ',07h
  28.     size_score      dw 0x0015h
  29.    
  30.     rules  db '<',0Fh,'-',0Fh,' ',0Fh,'-',0fh,' ',0Fh,'w',0Fh,'r',0Fh ,'u',0Fh ,'m',0Fh ,' ',0Fh ,'v',0Fh ,'l',0Fh ,'e',0Fh ,'v',0Fh ,'o',0Fh
  31.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  32.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  33.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  34.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  35.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  36.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  37.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  38.            
  39.            db '-',0Fh,'>',0Fh,' ',0Fh,'-',0fh,' ',0Fh,'w',0Fh,'r',0Fh ,'u',0Fh ,'m',0Fh ,' ',0Fh ,'v',0Fh ,'p',0Fh ,'r',0Fh ,'a',0Fh ,'v',0Fh,'o',0Fh
  40.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  41.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  42.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  43.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  44.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  45.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  46.            db ' ',0Fh,' ',0Fh,' ',0Fh,' ',0Fh
  47.            db 'A',0Fh,'n',0Fh,'y',0Fh,' ',0Fh,'k',0Fh,'e',0Fh,'y',0Fh,' ',0Fh,'t',0Fh,'o',0Fh,' ',0Fh,'s',0Fh,'t',0Fh,'a',0Fh,'r',0Fh,'t',0Fh,'!',0Fh
  48.     size_rules dw 0x0162h
  49.    
  50.     game_over   db 'G',0Fh,'a',0Fh,'m',0Fh,'e',0Fh,' ',0h,'o',0Fh,'v',0Fh,'e',0Fh,'r',0Fh
  51.     winner      db 'W',0Fh,'i',0Fh,'n',0Fh
  52.     flag        db 0
  53.     curSpeed    dw 0x8f00          
  54.    
  55.     SPA     equ 20h                    
  56.     PL      equ 0FEh                  
  57.    
  58.     LEFT    equ 0x4B00  ;"<-"
  59.     RIGHT   equ 0x4D00  ; "->"  
  60.     ENTER   equ 0x1C0D  ; "Enter"
  61. .code
  62.  start:
  63.     main1:
  64.     call begin
  65.     call cursorHide
  66.     call clearScreen
  67.     call drawRules
  68.     call drawTitle
  69.     call drawScore
  70.     call points_show
  71.     call drawPlatform
  72.     call drawBall
  73.     call drawBreaks
  74.     call go
  75.  main:
  76.     mov cx,[repeat]          
  77.   cycle:  
  78.     call movePlatform
  79.     dec cx
  80.     cmp cx, 0
  81.     jne cycle                  
  82.     call moveBall            
  83.     call drawBall
  84.     jmp main
  85. logics:
  86.     begin:
  87.         mov ax,@data
  88.         mov ds, ax
  89.         mov ah,00                        
  90.         mov al,03
  91.         int 10h  
  92.        
  93.         push 0B800h
  94.         pop es
  95.         mov ax, [platformLoc]                
  96.         mov [platformLeft], ax            
  97.         mov [platformRight], ax
  98.         mov ax, [size_platform]          
  99.         add [platformRight],ax            
  100.         ret
  101.      go:
  102.         mov ah, 00h              
  103.         int 16h    
  104.      cursorHide:                  
  105.         mov ah,1              
  106.         mov cx, 0x2000          
  107.         int 10h
  108.         ret
  109.      drawScore:
  110.         mov di, 00h
  111.         lea si, score
  112.         mov cx, [size_score]
  113.         rep movsb
  114.         ret
  115.      drawTitle:                
  116.         xor ax, ax
  117.         mov ax, 0x0001h
  118.         mul [size_line]          
  119.         mov di, ax
  120.         add ax, size_line
  121.      cycle_:                
  122.         cmp di, ax          
  123.         je return            
  124.         mov si, offset line_title  
  125.         mov cx, 2
  126.         rep movsb
  127.         jmp cycle_      
  128.      clearScreen:              
  129.         mov ah, 0x06
  130.         mov al, 0x00              
  131.         mov bh, 0x07h              
  132.         xor cx,cx                
  133.         mov dl, 0x80              
  134.         mov dh, 0x25
  135.         int 0x10
  136.         ret
  137.      drawBreaks:              
  138.         mov ax, [line]        
  139.         mul [size_line]        
  140.         mov bx, ax
  141.         add ax, [size_line]    
  142.         mov cx, 0x0032          
  143.      loopl:        
  144.         call drawBlock        
  145.         call drawSpace          
  146.         dec cx                
  147.         cmp cx, 0
  148.         je return                
  149.         cmp bx, ax            
  150.         jge new_line
  151.         jmp loopl
  152.      new_line:                  
  153.         add ax, [size_line]    
  154.         add [line],1            
  155.         push ax
  156.         mov ax, [line]
  157.         div [byteDivider]
  158.         cmp ah, 1            
  159.         je step                
  160.         add bx, 8              
  161.         pop ax
  162.         jmp loopl              
  163.      step:
  164.         pop ax
  165.         mov bx, ax
  166.         sub bx, [size_line]        
  167.         jmp loopl    
  168.      drawBlock:         ;block of 1 element  
  169.         push cx
  170.         mov cx, 0x0004            
  171.      drawBlock2:                      
  172.         mov es:[bx], PL    
  173.         mov es:[bx+1], 040h      
  174.         add bx, 2                
  175.         dec cx
  176.         cmp cx, 0                
  177.         jne drawBlock2
  178.         pop cx                    
  179.         ret
  180.      drawSpace:          ;space of 1 element        
  181.         push cx
  182.         mov cx, 0x0004
  183.      drawSpace2:
  184.         mov es:[bx], SPA        
  185.         mov es:[bx+1], 0h
  186.         add bx, 2
  187.         dec cx
  188.         cmp cx, 0
  189.         jne drawSpace2
  190.         pop cx    
  191.         ret  
  192.      drawPlatform:                  
  193.         mov di, [platformLoc]      ;location
  194.         mov cx, [size_platform]             ;size
  195.         mov si, offset platform                  ;draw
  196.         cld
  197.         rep movsb
  198.         ret  
  199.      movePlatform:            
  200.         mov ah, 01h          
  201.         int 16h
  202.         jnz checkKey
  203.         ret
  204.      checkKey:                    ;comparing with codes of right and left
  205.         mov ah, 00h          
  206.         int 16h
  207.         cmp ax, RIGHT
  208.         je  go_right
  209.         cmp ax, LEFT
  210.         je  go_left
  211.         ret
  212.      go_right:                ;wrum-wrum pravo      
  213.         mov bx, [platformLoc]      
  214.         add bx, [size_platform]      
  215.         cmp bx, [endLine]            
  216.         jge movePlatform            
  217.         mov es:[bx],PL        
  218.         mov es:[bx+1], 044h
  219.         mov bx, [platformLoc]
  220.         mov es:[bx],SPA            
  221.         mov es:[bx+1],0h
  222.         add [platformLoc],2
  223.         add [platformRight], 2
  224.         add [platformLeft], 2        
  225.         jmp movePlatform
  226.      go_left:                      ;wrum-wrum levo    
  227.         cmp [platformLoc], 0F00h      
  228.         jle movePlatform
  229.         sub [platformLoc], 2
  230.         sub [platformRight], 2
  231.         sub [platformLeft], 2          
  232.         mov bx, [platformLoc]
  233.         add bx, [size_platform]        
  234.         mov es:[bx],SPA
  235.         mov es:[bx+1],0h
  236.         mov bx, [platformLoc]          
  237.         mov es:[bx],PL
  238.         mov es:[bx+1], 044h
  239.         jmp movePlatform
  240.      moveNull:
  241.         jmp movePlatform      
  242.      drawBall:
  243.         xor bx, bx
  244.         mov bx, [ballLoc]    
  245.         xor ax, ax
  246.         mov ax, [curY]      
  247.         mul [size_line]      
  248.         add ax, [curX]      
  249.         mov [ballLoc], ax    
  250.         cmp ax, bx
  251.         je return            
  252.         mov di, ax          
  253.         mov si, offset ball
  254.         mov cx, 2
  255.         cld
  256.         rep movsb
  257.         mov es:[bx], SPA  
  258.         mov es:[bx+1], 0h
  259.         ret
  260.      changeVectorY:          
  261.         neg [vectorY]
  262.         jmp checkBorderX
  263.      changeVectorX:
  264.         neg [vectorX]
  265.         jmp next  
  266.      
  267.      moveBall:                  
  268.      checkBorderY:              
  269.         cmp [curY], 2          
  270.         je changeVectorY
  271.      checkBorderX:              
  272.         xor dx, dx              
  273.         mov dx, [size_line]
  274.         sub dx, [vectorX]        
  275.         cmp [curX], dx          
  276.         jge  changeVectorX      
  277.         cmp [curX], 0          
  278.         jle  changeVectorX  
  279.      next:                      
  280.         xor ax, ax  
  281.         mov ax, [curY]          
  282.         add ax, [vectorY]      
  283.         mov [curY], ax          
  284.         xor bx, bx
  285.         mov bx, [curX]          
  286.         add bx, [vectorX]      
  287.         cmp bx, 0              
  288.         jl back1
  289.       next1:  
  290.         mov [curX], bx          
  291.         mul [size_line]          
  292.         add ax, bx              
  293.         mov di, ax
  294.         push di
  295.         mov ax, es:[di]
  296.      next2:  
  297.         pop di
  298.         mov ax, es:[di]
  299.         cmp al, PL      
  300.         je back_move
  301.         cmp [curY], 0x0019      
  302.         je gameOver
  303.         cmp al, 0FEh
  304.         jne check_go_awake      
  305.         ret  
  306.      back1:                  
  307.         neg [vectorX]
  308.         add bx, [vectorX]      
  309.         add bx, [vectorX]      
  310.         jmp next1  
  311.      back_move:
  312.         call checkBrick      
  313.         neg [vectorY]        
  314.         neg [vectorX]
  315.         mov ax, [curY]
  316.         add ax, [vectorY]      
  317.         mov [curY], ax        
  318.         mov ax, [curX]
  319.         add ax, [vectorX]
  320.         mov [curX], ax          
  321.         neg [vectorX]
  322.         call checkChangeVector  
  323.         ret
  324.      checkChangeVector:          
  325.         mov dx, [platformLeft]
  326.         sub dx, [size_line]
  327.         cmp dx, [ballLoc]      
  328.         je decVectorX          
  329.         add dx, 2              
  330.         cmp dx, [ballLoc]
  331.         je decVectorX          
  332.         add dx, 2
  333.         cmp dx, [ballLoc]      
  334.         je decVectorX
  335.         mov dx, [platformRight]
  336.         sub dx, [size_line]    
  337.         cmp dx, [ballLoc]
  338.         je incVectorY          
  339.         sub dx, 2
  340.         cmp dx, [ballLoc]
  341.         je incVectorY
  342.         sub dx, 2
  343.         cmp dx, [ballLoc]
  344.         je incVectorY
  345.         ret
  346.      decVectorX:
  347.         sub [vectorX], 2
  348.         ret
  349.      incVectorY:
  350.         add [vectorX], 2
  351.         ret                                                      
  352.      checkBrick:                
  353.         cmp [curY],0x0018      
  354.         je return
  355.         cmp [curY], 0x0001    
  356.         je return
  357.         mov ax, [curY]        
  358.         mul [size_line]
  359.         mov bx, ax
  360.         add bx, [curX]
  361.      loop1:                      
  362.         sub bx, 2              
  363.         cmp bx, ax
  364.         jl go1
  365.         cmp es:[bx], SPA
  366.         jne loop1
  367.      go1:                      
  368.         add bx, 2              
  369.         call drawSpace
  370.         add [points],10        
  371.         call points_show
  372.      return:
  373.         ret      
  374.      gameOver:
  375.         call clearScreen          
  376.         mov ax,0x000A
  377.         mul [size_line]
  378.         add ax,0x0048
  379.         mov di, ax
  380.         mov si, offset game_over
  381.         mov cx, 0x0012
  382.         rep movsb
  383.         push ax
  384.        
  385.         call sleep                
  386.         jmp reload                
  387.      sleep:
  388.         mov cx,20
  389.         mov dx,0          
  390.         mov ah,86h              
  391.         int 15h                
  392.        
  393.      cycle_read:
  394.         mov ah,1              
  395.         int 16h
  396.         jnz read
  397.         ret  
  398.      read:
  399.         xor ah,ah              
  400.         int 16h
  401.         jmp cycle_read  
  402.      check_go_awake:
  403.         mov bx, [ballLoc]          
  404.         add bx, [vectorX]        
  405.         mov ax, es:[bx]        
  406.         cmp al, 0FEh
  407.         jne return
  408.         mov ax, [curY]          
  409.         mul [size_line]
  410.         mov dx, ax
  411.         add ax, [curX]          
  412.         sub ax, [vectorX]
  413.         mov bx, ax
  414.         mov ax, es:[bx]        
  415.         cmp al, 0FEh
  416.         jne return
  417.      loop3:                  
  418.         sub bx, 2
  419.         cmp bx, dx
  420.         je go2
  421.         cmp es:[bx],0FEh
  422.         je loop3
  423.         add bx, 2
  424.      go2:                        
  425.         call drawSpace
  426.         mov bx, [ballLoc]          
  427.         add bx, [vectorX]        
  428.      loop4:                        
  429.         sub bx,2                  
  430.         cmp es:[bx],0FEh
  431.         je loop4
  432.      next3:
  433.         add bx,2                    
  434.         call drawSpace
  435.         neg [vectorY]            
  436.         neg [vectorX]
  437.         mov ax, [curY]
  438.         add ax, [vectorY]
  439.         mov [curY], ax
  440.         mov ax, [curX]
  441.         add ax, [vectorX]
  442.         mov [curX], ax              
  443.         add [points],20
  444.         call points_show
  445.            
  446. points_show:                        
  447.     push bx
  448.     mov ax, [max_coints]
  449.     cmp [points], ax
  450.     jge win
  451.     lea bx, points
  452.     lea di, points_str
  453.     call pointsTOstr                      
  454.    
  455.     mov cx, LEN
  456.     mov di, 10h
  457.     lea si, points_str
  458.     cld
  459.     rep movsb                        
  460.     pop bx
  461.     ret          
  462. pointsTOstr PROC                          
  463.     push ax
  464.     push bx
  465.     push cx
  466.     push di    
  467.  
  468.     mov ax, [bx]
  469.     mov bx, 10
  470.     xor cx, cx      
  471. division:
  472.     xor dx, dx
  473.     div bx      
  474.     push dx
  475.     inc cx
  476.     cmp ax, 0
  477.     jne division
  478.    
  479.     mov LEN, cx
  480.     add LEN, cx  
  481. save_in_str:
  482.     pop dx
  483.     add dl, '0'
  484.     mov [di], dl
  485.     inc di  
  486.     mov [di], 0Fh
  487.     inc di
  488.     loop save_in_str    
  489.    
  490.     pop di
  491.     pop cx
  492.     pop bx
  493.     pop ax
  494.     ret
  495. endp
  496.  
  497. drawRules proc
  498.     mov di, 00h
  499.     lea si, rules
  500.     mov cx, [size_rules]
  501.     rep movsb
  502.    
  503.     mov ah, 1
  504.     int 21h
  505.     call clearScreen    
  506. ret
  507. endp
  508.  
  509. reload:
  510.     mov ah, 00h
  511.     int 16h
  512.     mov bx, ENTER
  513.     cmp ax, bx
  514.     jne endProgram
  515.     mov [points], 0
  516.     mov [platformLoc],0x0F50
  517.     mov [ballLoc],0x0FA0
  518.     mov [curX],0x005Ah
  519.     mov [curY],0x0017h
  520.     mov [vectorX],-2h
  521.     mov [vectorY],-1h  
  522.     mov [line], 5
  523.     mov [repeat], 0x8F00
  524.     mov [flag], 0
  525.     call begin
  526.     call clearScreen
  527.     call drawTitle
  528.     call drawScore
  529.     call points_show
  530.     call drawPlatform
  531.     call drawBall
  532.     call drawBreaks
  533.     call go
  534.     jmp main
  535. endProgram:
  536.     call clearScreen
  537.     mov ax, 4C00h
  538.     int 21h
  539. win:
  540.         call clearScreen
  541.         mov ax,0x000A
  542.         mul [size_line]
  543.         add ax,0x0048
  544.         mov di, ax
  545.         mov si, offset winner
  546.         mov cx, 0x000E
  547.         rep movsb
  548.         push ax
  549.         call sleep
  550.         jmp reload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement