home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / ctenari / Veber / src / Sputnik.asm < prev    next >
Assembly Source File  |  2002-07-21  |  19KB  |  743 lines

  1. ;
  2. ; Game Sputnik
  3. ; Copyright (C) 2001 Jaromφr Veber
  4. ;
  5. ; This program is free software; you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation; either version 2 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program; if not, write to the Free Software
  17. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ;
  19.  
  20. ;Jaromir Veber
  21. ;5.11.2001  - changed game kernel
  22.  
  23. ;Jaromir Veber
  24. ;6.11.2001  - small change
  25.  
  26. ;Jaromir Veber
  27. ;10.11.2001  - ver 2.0 changes
  28.  
  29. ;Jaromφr Veber
  30. ;18.11.2001 - brutal changes
  31.  
  32. ;Jaromφr Veber
  33. ;1.06.2002 - reported one bug in detection of fences so I found it 
  34. ;            and removed it...
  35.  
  36. ;Jaromφr Veber
  37. ;8.06.2002 - Totaly rebuilded and optimised, applied jump optimisation...
  38.  
  39. ;Jaromφr Veber
  40. ;21.07.2002 - Small bug in keyboard detected and repaired...
  41.  
  42. %define MODE 0x13
  43. %define  P80386
  44.  
  45.          org 100H
  46. %include "Macros.asm"
  47. ;STACICS - WITCH - CAN BE CHNAGED
  48. ;#######################################################################
  49. ;menu
  50. MAX_MENU_POS        equ 1       ;maximal position in menu (it is number of menu texts -1)
  51. START_GAME_POS      equ 0       ;position of START_GAME in menu
  52. MENU_RECT_SIZE_X    equ 84      ;size of rectangle in menu X
  53. MENU_RECT_SIZE_Y    equ 11      ;size of rectangle in menu Y
  54. MENU_RECT_COLOR     equ 130     ;color of menu
  55. MENU_BACKGR_COLOR   equ 0       ;color of menu background
  56. MENU_RECT_START_X   equ 109     ;start position of restangle X
  57. MENU_RECT_START_Y   equ 69      ;start position of restangle Y
  58. ;land under sputnik
  59. LAND_POS_Y            equ 180        ;positon of land on start
  60. LAND_COLOR            equ 3    ;land color
  61. SPUT_SHIMMER_TIME   equ 10
  62. MAX_LAND_POS        equ    198
  63. MIN_LAND_POS        equ    100
  64. ;sputnik
  65.  
  66. SPUT_SIZE_X            equ    25            ;size of sputnik X    
  67. SPUT_SIZE_Y         equ    9       ;size of sputnik Y
  68. SPUT_START_POS_X    equ    100            ;X start position
  69. SPUT_START_POS_Y    equ    100     ;Y start position
  70. SPUT_BODY_COLOR        equ    12     ;color of sputnik
  71. SPUT_BACKGROUND        equ    0          ;sputnik background color
  72. ;2.0
  73. SPUT_FROM_LAND      equ 1 ;sput from land 
  74.  
  75.  
  76. ;game data
  77. SPUT_FLY_POINTS        equ   1        ;rate of change up down
  78. SPUT_STEP_RATE        equ   2   ;rate of change left right
  79.  
  80.  
  81. START_GAME_SPEED    equ      9    ;start delay
  82.  
  83. LIFES                equ        3     ;number of lifes
  84. SPUT_MAX_FLY_POS    equ       50    ;height of sputnik jump
  85. COMMAND_JUMP        equ        1
  86.  
  87. FENCE_FROM_LAND        equ   0
  88.  
  89. FENCE_SIZE_X         equ        10    ;size of fence X
  90. FENCE_SIZE_Y        equ        10  ;         Y
  91. FENCE_COLOR            equ        34
  92. FENCE_SPEED            equ        5   ;speed of fence
  93.  
  94. ;FENCES
  95. LAND_UP                equ   1
  96. LAND_DOWN            equ   2
  97. FENCE_UP_TAPE1        equ   3
  98.  
  99. SCORE_TO_SPEED_UP    equ   10  ;how many fences to speed up
  100.  
  101. ;#######################################################################
  102. ;STACICS - WITCH - SHOULD NOT BE CHANGED (DO NOT CHANGE THEM)!
  103. ;LAND
  104. LAND_FLUMMOX_POINTS equ 2    ;this is is needent to compute real positon of Y
  105.                                                     ;for units moving on the land            
  106. ;SPUTNIK
  107. SPUT_FLY_POINT            equ LAND_FLUMMOX_POINTS    + SPUT_FROM_LAND    
  108. SPUT_START_MIN_Y        equ LAND_POS_Y - (SPUT_FLY_POINT + SPUT_SIZE_Y)
  109. SPUT_START_MAX_Y        equ SPUT_START_MIN_Y - SPUT_MAX_FLY_POS
  110. START_SIZE_DOWN            equ        (LAND_POS_Y - SPUT_START_POS_Y - SPUT_SIZE_Y - SPUT_FLY_POINT) / SPUT_FLY_POINTS
  111. SPUT_FROM_LAND_OK        equ   FENCE_FROM_LAND + LAND_FLUMMOX_POINTS
  112. SPUT_SHRIM                equ SPUT_SHIMMER_TIME*16
  113. SPUT_MAX_POS_X            equ        318 - SPUT_SIZE_X - SPUT_STEP_RATE
  114. SPUT_MIN_POS_X            equ        SPUT_STEP_RATE
  115.  
  116.  
  117. ;FENCE
  118. FENCE_EXIST                    equ        1
  119. FENCE_START_X       equ        319
  120. FENCE_START_Y       equ   (LAND_POS_Y - 2) - FENCE_SIZE_Y
  121. LAND_WIDTH            equ   2
  122. ;#######################################################################
  123.  
  124. ;=======================================================================
  125. ;GAME CODE
  126. ;=======================================================================
  127.  
  128. start:
  129.         mov AX,0A000H
  130.         mov FS,AX
  131.         ;ok
  132. ;=======================================================================
  133. ;MENU
  134. ;=======================================================================
  135. Draw_menu:
  136. ;;set vide mode
  137.         mov ax,MODE
  138.         int 10h
  139. ;;write menu texts
  140.         xor BX,BX
  141.         mov AH,02H
  142.         mov DX,030FH
  143.         int 10H
  144.         writestr text3
  145.         mov AH,02H
  146.         mov DX,090EH
  147.         int 10H
  148.         writestr text1
  149.         mov AH,02H
  150.         mov DX,0B0EH
  151.         int 10H
  152.         writestr text2
  153.         ;ok
  154.         
  155.         mov byte [menu_rect_position],0
  156.         ;initialize positoion of rectangle
  157.         
  158.         
  159. ;111111111111111111111111        
  160.   ;wait key looper
  161. ;111111111111111111111111
  162.         push word MENU_RECT_START_X
  163.         push word MENU_RECT_START_Y
  164.         push word MENU_RECT_SIZE_X
  165.         push word MENU_RECT_SIZE_Y
  166.         push word MENU_RECT_COLOR        
  167.         
  168. Exit_arrow:                ;draw graphical rectangle        
  169.         call New_Rectangle
  170.         
  171. waitme:        
  172.         Wait_char
  173.         cmp AL,0DH    ;was it key with extended scan code
  174.         jz do
  175.         mov AL,AH
  176.         cmp AL,48H  ;up 
  177.         mov BL,0
  178.         mov CX,MENU_RECT_START_Y
  179.         jz .do
  180.         mov BL,1
  181.         add CX,16
  182.         cmp AL,50H  ;down        
  183.         jnz waitme
  184. .do
  185.         mov [menu_rect_position],BL
  186.         mov bp,sp
  187.         mov [var],CX ;save CX
  188.         mov word [BP],0
  189.         call New_Rectangle
  190.         mov BP,SP
  191.         mov AX,[var]
  192.         mov word [BP],MENU_RECT_COLOR
  193.         mov [BP+6],AX
  194.         jmp Exit_arrow
  195. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  196. ;end of looper
  197. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  198.  
  199. do:     
  200.         mov AL,[menu_rect_position]
  201.         cmp AL,START_GAME_POS ;was rectangle on SATRT GAME
  202.         jnz near EXIT                                    ;position
  203. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  204.                                     ;GAME STARTING
  205. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  206.         
  207.         mov byte [lifes],LIFES
  208.         mov word [Land_pos_Y],LAND_POS_Y
  209.         XOR ax,ax
  210.         MOV BYTE [score],al
  211.         
  212.         mov word [game_speed],START_GAME_SPEED
  213. GAME:           
  214.         clear_display
  215.         xor BX,BX
  216.         mov AH,02H
  217.         mov DX,0102H
  218.         int 10H
  219.         writestr text5
  220.         mov AL,byte [lifes]
  221.         writeAL
  222.         mov AH,02H
  223.         mov DX,0202H
  224.         int 10H
  225.         writestr text6
  226.         mov AL,[score]
  227.         writeAL       
  228.         linex 1,[Land_pos_Y],318,LAND_COLOR
  229.         xor AX,AX
  230.         mov word [Sput_pos_X_cahnge],AX
  231.         mov byte [LandUP_exist],AL
  232.         mov word [LandUP_pos_X],AX
  233.         mov AX,[Land_pos_Y]
  234.         mov [Land_new_pos_Y],AX        
  235.         mov word [Sput_pos_X],SPUT_START_POS_X
  236.         mov word [Fence_pos_X],200
  237.         mov word [Fence_pos_Y],200
  238.         mov word [Fence_sizeX],2
  239.         mov word [Fence_sizeY],2
  240.         
  241. START_GAME:        
  242.         mov AX,[Land_pos_Y]
  243.         sub AX,SPUT_MAX_FLY_POS
  244.         
  245.         mov word [Sput_pos_Y],AX        
  246.         mov AX,0        
  247.         mov word [Sput_fly],AX
  248.         
  249. ;changing position X        
  250.  
  251. ;shrimming        
  252.         mov word [Sput_shimmer],0
  253. ;land        
  254.         
  255.  
  256.         align 16
  257. GAME_CYKLUS:
  258.         inc word [citac]
  259.            mov AX,[Sput_pos_Y]
  260.            mov BX,[Sput_shimmer]           
  261.            cmp BX,SPUT_SHRIM
  262.            
  263.            ja .dal
  264.            inc word  [Sput_shimmer]
  265.            shr BX,4           
  266.            mov word [Sput_act_color],SPUT_BODY_COLOR
  267.            jnc .dal
  268.            mov word [Sput_act_color],SPUT_BACKGROUND           
  269. .dal
  270.         mov BX,[Sput_pos_X]                
  271.         mov [Sput_old_pos_Y],AX    ;save old Sputnik position
  272.         mov [Sput_old_pos_X],BX ;
  273.  
  274.         invoke delay,word [game_speed] ;game dalay (game speed)        
  275.         
  276.         
  277.            mov AH,1                ;check for keyboard
  278.         int 16H                 ;pressed?
  279.         jz    NEXT
  280.         Wait_char
  281.         cmp AL,1BH
  282.         jz Draw_menu
  283.         shr AX,8        
  284.         sub ax,48H
  285.         jc NEXT
  286.         mov SI,AX
  287.         shl SI,1
  288.         jb NEXT
  289.         mov AX,[SI+keyboard]
  290.         jmp AX
  291. NEXT:
  292.         mov AX,[Sput_pos_X]
  293.         mov BX,[Sput_pos_X_cahnge]
  294.         mov CX,SPUT_MAX_POS_X
  295.         add AX,BX         
  296.         cmp CX,AX
  297.         sbb BX,0
  298.         cmp CX,AX
  299.         sbb AX,0        
  300.         cmp AX,SPUT_MIN_POS_X
  301.         adc BX,0
  302.         cmp AX,SPUT_MIN_POS_X
  303.         mov [Sput_pos_X_cahnge],BX
  304.         adc AX,0
  305.         mov [Sput_pos_X],AX
  306.         
  307.         ;Is sputnik falling or is on land or fly up?
  308.         mov AX,[Sput_pos_Y]        
  309.         mov BX,[Land_pos_Y]
  310.         mov CX,AX
  311.         add AX,SPUT_SIZE_Y+LAND_WIDTH+SPUT_FROM_LAND
  312.         cmp AX,BX
  313.         jz .sputnik_on_land
  314.         
  315. ;Sputnik is flying        
  316. ;this can seems confused it's cause I use jum elimination and i need 
  317. ;some temporary instructions I thig that this solution is very good,
  318. ;because it is realy fast
  319. ;But I thing, that I'll inprove it in leter versions, becouse it can be inproved 
  320.         mov AX,SPUT_FLY_POINTS
  321.         ;in ax is number of points to fly        
  322.         mov DI,[Sput_fly] ;;optimised number for compute the fly direction        
  323. ;  it can be a bit frustrating for ALU, a lot of alu instructions, but
  324. ; a lot of processors have more than one ALU..
  325.         xor AX,DI ;temporary computation to get change for 
  326.         mov DX,CX
  327.         add DX,AX
  328.         sub BX,DX
  329.         mov AX,SPUT_MAX_FLY_POS
  330.         sub AX,BX
  331.         adc DI,0
  332.         ;ok [Sput_fly] is changed...
  333.         ;the right compution starts there
  334.         mov AX,SPUT_FLY_POINTS
  335.         xor AX,DI 
  336.         mov [Sput_fly],DI
  337.         add CX,AX        
  338.         mov [Sput_pos_Y],CX        
  339.         ;it is pretty short..!
  340. .sputnik_on_land
  341. LAND:   
  342.         cmp word [LandUP_pos_X],0
  343.         ja near .land_existing
  344.  
  345.         ;try to generate land
  346.         mov AX,[citac]
  347.         and  AX,[Sput_pos_X]        
  348.         push AX
  349.         push word 10    ;possibility to do new land is 1:20
  350.         call Random 
  351.         add SP,4
  352.         test AX,AX        
  353.         jnz near .no_land_generated        
  354. ;.land_generated
  355. ;optimazation, only to try it...
  356. ;PPro, PII, PIII instruction sheduling
  357. ;ok jump elimination applied..
  358. ;ok instructin sheduling enabled for PPro
  359.         
  360.         mov word [LandUP_pos_X],318 ;set existence of land..      ;2UOPS                                                                
  361.         mov AX,[Sput_pos_X]                                        ;1UOP
  362.         MOV CX,[citac]                                            ;1UOP        
  363.         
  364.         sbb AX,[Sput_pos_Y]                                        ;2UOPs
  365.         xor AX,CX                                               ;1UOP
  366.         
  367.         push AX                                                    ;3UOPs
  368.         push word 2                                                ;3UOPs
  369.         
  370.         call Random                                             ;4UOPs
  371.         ;;;
  372.         
  373.         dec AX                                                    ;1UOP
  374.         mov bp,sp                                               ;1UOP
  375.         
  376.         mov word [LandUP_code],AX                                ;2UOPs        
  377.         mov AX,[Sput_pos_X]                                     ;1UOP
  378.         
  379.         xor [bp+2],AX                                            ;4UOPs
  380.         
  381.         mov word [bp],20                                        ;2UOPs
  382.         
  383.         call Random                                                ;4UOPs
  384.         ;;;;
  385.         
  386.         add SP,4                                                ;1Uop
  387.         inc AX                                                    ;1Uop
  388.         mov CX,AX                                                ;1Uop
  389. ;OK AX and BX is for computing, so I'll use it for this 
  390. ;CX,DX,SI is used to store smome values that are often used
  391.  
  392.         mov BX,AX                                                ;1Uop
  393.         add BX,LAND_FLUMMOX_POINTS+1                            ;1Uop
  394.         mov DX,[LandUP_code]                                    ;1Uop    
  395.         
  396. ;;CX - [LandUP_size]        
  397.         mov word [LandUP_size],BX                                ;2Uops
  398.         mov BX,[Land_pos_Y]                                        ;1UOP        
  399.         xor AX,DX                                                ;1Uop
  400. ;DX = [LandUP_code]
  401. ;BX = [Land_pos_Y]
  402.          
  403.  
  404.         
  405.         ;hmm, but throught RAT can go only 3 uops per cycle so no problem...
  406.         
  407.         add AX,BX                                                ;1Uop
  408.         cmp AX,MIN_LAND_POS                                        ;1Uop
  409.         
  410.         
  411.         adc DX,0                                                ;2Uops
  412.         mov SI,MAX_LAND_POS                                        ;1Uop        
  413.         cmp SI,AX                                                ;1Uop
  414.  
  415.         
  416.         sbb DX,0                                                ;2Uops
  417.         mov AX,CX                                                ;1UOP        
  418.         and AX,DX                                                ;1Uop        
  419. ;BX = [Land_pos_Y]                
  420.         
  421.         mov [LandUP_code],DX                                    ;2Uops
  422.         mov SI,BX                                                ;1Uop
  423.         sub BX,AX                                               ;1Uop
  424. ;SI = [Land_pos_Y]                
  425.  
  426.         
  427.         mov [LandUP_pos_Y],BX                                   ;2Uops
  428.         xor DX,CX                                                ;1Uop        
  429.         add SI,DX                                               ;1Uop
  430.         
  431.         mov [Land_new_pos_Y],SI                                 ;2uops        
  432.         
  433.         
  434. .land_existing
  435.         liney   [LandUP_pos_X],[LandUP_pos_Y],[LandUP_size],0
  436.         dec word [LandUP_pos_X]
  437.         liney   [LandUP_pos_X],[LandUP_pos_Y],[LandUP_size],LAND_COLOR
  438.         linex    [LandUP_pos_X],[Land_new_pos_Y],2,LAND_COLOR
  439.         
  440.         mov AX,[Sput_pos_X]
  441.         mov BX,SPUT_SIZE_X
  442.         mov DX,[LandUP_code]
  443.         
  444.         and BX,DX
  445.         add AX,BX
  446.         mov CX,AX
  447.         
  448.         cmp AX,[LandUP_pos_X]
  449.         jb .dal        
  450.         mov BX,[Land_new_pos_Y]
  451.         mov AX,[Sput_pos_Y]
  452.         add AX,SPUT_SIZE_Y
  453.         cmp BX,AX
  454.         jb near LIFE_LOST        
  455.         mov [Land_pos_Y],BX        
  456.     .dal    
  457. .no_land_generated
  458.  
  459.  
  460.  
  461. FENCES:
  462.         mov AX,[Fence_pos_X]
  463.         cmp AX,0
  464.         ja near .fence_exist
  465.         
  466.         rectangle  [Fence_pos_X],[Fence_pos_Y],[Fence_sizeX],[Fence_sizeY],SPUT_BACKGROUND
  467.         
  468.         xor BX,BX
  469.           mov ah,2
  470.           mov DX,0208H
  471.           int 10H
  472.   
  473.         mov AL,[score]
  474.         inc AL
  475.         writeAL 
  476.         mov [score],AL
  477.         
  478.         mov CL,SCORE_TO_SPEED_UP
  479.         div CL         
  480.         mov AL,AH
  481.         test AL,AL
  482.         jnz .dal
  483.         dec word [game_speed]
  484.         jz near GAME_WIN
  485. .dal
  486.         
  487.         mov AX,word [citac]
  488.         mov BX,[LandUP_pos_X]
  489.         mov CX,[Sput_pos_X]
  490.         
  491.         mov DX,[Sput_pos_Y]        
  492.         and AX,DX
  493.         or  DX,CX
  494.  
  495.         
  496.         sbb BX,DX
  497.         xor AX,DX
  498.         and CX,BX
  499.         
  500.         adc AX,CX
  501.         sub AX,BX
  502.         xor AX,CX
  503.         
  504.         push AX
  505.         push 16
  506.         call Random
  507.         
  508.         add AX,2
  509.         mov BX,[LandUP_pos_X]
  510.         mov word [Fence_sizeX],AX
  511.         
  512.         shr AX,5
  513.         and AX,BX
  514.           xor BX,AX
  515.           
  516.           add AX,[Sput_pos_X]
  517.           or  AX,BX
  518.           mov bp,sp
  519.           
  520.           mov [bp+2],AX
  521.           
  522.           call Random
  523.           
  524.           add SP,4
  525.           
  526.           add AX,2
  527.           mov BX,[Fence_sizeX]
  528.           mov CX,318
  529.           
  530.           mov word [Fence_sizeY],AX
  531.           mov DX,[Land_new_pos_Y]
  532.           sub cx,bx
  533.           
  534.           mov word [Fence_pos_X],CX
  535.           sub DX,AX
  536.           sub DX,LAND_FLUMMOX_POINTS 
  537.           mov word [Fence_pos_Y],DX       
  538.         
  539. .fence_exist
  540.         rectangle  [Fence_pos_X],[Fence_pos_Y],[Fence_sizeX],[Fence_sizeY],SPUT_BACKGROUND
  541.         dec word [Fence_pos_X]
  542.         rectangle  [Fence_pos_X],[Fence_pos_Y],[Fence_sizeX],[Fence_sizeY],FENCE_COLOR
  543.         
  544.         .check_sputnik
  545.         mov AX,[Sput_pos_X]
  546.         mov BX,[Fence_pos_X]        
  547.         add AX,SPUT_SIZE_X        
  548.         cmp AX,BX        
  549.         jb .sput_before_fence        
  550.         mov DX,[Fence_sizeX]
  551.         add BX,DX
  552.         cmp [Sput_pos_X],BX        
  553.         ja .sput_after_fence        
  554.         mov AX,[Sput_pos_Y]
  555.         add AX,SPUT_SIZE_Y+2
  556.         
  557.         cmp AX,[Fence_pos_Y]
  558.         jb  .sput_over_fence
  559.         jmp LIFE_LOST
  560. .sput_before_fence
  561. .sput_after_fence
  562. .sput_over_fence
  563.  
  564.  
  565. liney   0,MIN_LAND_POS,MAX_LAND_POS-MIN_LAND_POS+LAND_FLUMMOX_POINTS+1,0
  566. DRAW_SPUTNIK:
  567. ;clear old sputnik.... 
  568.         push word [Sput_old_pos_X]
  569.         push word [Sput_old_pos_Y]
  570.         push word SPUT_SIZE_X
  571.         push word SPUT_SIZE_Y
  572.         push word SPUT_BACKGROUND
  573.         call New_Rectangle
  574.         mov bp,sp
  575.         mov AX,[Sput_pos_Y]
  576.         mov BX,[Sput_pos_X]        
  577.         mov [bp+6],AX
  578.         mov CX,[Sput_act_color]        
  579.         mov [bp+8],BX
  580.         mov word [bp],CX
  581.         call New_Rectangle
  582.         add sp,10
  583. ;ok                
  584.         jmp GAME_CYKLUS       
  585. GAME_WIN:        
  586.            clear_display
  587.            xor BX,BX
  588.         mov AH,02H
  589.         mov DX,0608H
  590.         int 10H        
  591.         writestr text9
  592.         Wait_char
  593.         Wait_char
  594. ;;exit to DOS 
  595. EXIT:
  596.         mov ax,03H
  597.         int 10h        
  598.         writestr ver
  599. EXIT_E:        
  600.         int 20H
  601.         ;ok
  602.         
  603. LIFE_LOST:
  604.         mov AL,[lifes]
  605.         dec AL
  606.         test AL,AL
  607.         jz GAME_OVER        
  608.         xor BX,BX
  609.         mov AH,02H
  610.         mov DX,0108H
  611.         int 10H
  612.         writeAL
  613.         mov [lifes],AL
  614.         
  615.         
  616.         push word [Sput_old_pos_X]
  617.         push word [Sput_old_pos_Y]
  618.         push word SPUT_SIZE_X
  619.         push word SPUT_SIZE_Y
  620.         push word SPUT_BACKGROUND
  621.         call New_Rectangle
  622.         add SP,8        
  623.         
  624.         jmp START_GAME        
  625. GAME_OVER:
  626.         clear_display
  627.         xor BX,BX
  628.         mov AH,02H
  629.         mov DX,060DH
  630.         int 10H       
  631.         writestr text10
  632.         mov AH,02H
  633.         mov DX,080DH
  634.         int 10H        
  635.         writestr text6
  636.         mov AH,02H
  637.         mov DX,0814H
  638.         int 10H        
  639.         mov AL,[score]
  640.         writeAL
  641.         Wait_char
  642.         Wait_char
  643.         jmp Draw_menu         
  644. arrow_up:        
  645.         mov AX,[Sput_pos_Y]        ;is Sputnik on the land..
  646.         mov BX,[Land_pos_Y]
  647.         sub BX,SPUT_SIZE_Y+LAND_WIDTH+SPUT_FROM_LAND
  648.         cmp AX,BX
  649.         jnz NEXT
  650.         dec AX
  651.         mov BX,-1
  652.         mov [Sput_pos_Y],AX
  653.         mov [Sput_fly],BX
  654.         jmp NEXT
  655. arrow_down:
  656.         mov word [Sput_fly],0
  657.         jmp NEXT
  658. arrow_right:
  659.         mov word [Sput_pos_X_cahnge],1
  660.         jmp NEXT
  661. arrow_left:
  662.         mov word [Sput_pos_X_cahnge],-1        
  663.         jmp NEXT
  664. num_five:
  665.         mov word [Sput_pos_X_cahnge],0
  666.         jmp NEXT
  667. num_End:        
  668. num_minus:
  669.  
  670. num_plus:
  671. numPgDown:
  672. numPgUp:
  673. num_Ins:
  674.      jmp NEXT
  675. num_del:
  676.      jmp EXIT_E
  677.  
  678. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  679. ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  680. %include "PROCS.ASM"
  681. ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  682. segment .data
  683. text1:    db "START GAME",0
  684. text2:    db "EXIT  GAME",0
  685. text3:    db "SPUTNIK",0
  686.  
  687. text5:        db "lifes:",0
  688. text6:        db "score:",0
  689.  
  690. text9:        db "YOU WIN",0
  691. text10:        db "GAME OVER",0
  692.  
  693. ver: db "SPUTNIK ver. 2.2",0 
  694.  
  695. keyboard: dw arrow_up,
  696.           dw numPgUp,
  697.           dw num_minus,
  698.           dw arrow_left,
  699.           dw num_five,
  700.           dw arrow_right,
  701.           dw num_plus,
  702.           dw num_End,
  703.           dw arrow_down,
  704.           dw numPgDown,
  705.           dw num_Ins,
  706.           dw num_del
  707.  
  708. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  709. segment .bss
  710.     ;MENU variables
  711.  
  712. menu_rect_position  resb 1    ;position of rectangle in menu
  713.  
  714. lifes                        resb    1
  715. score                        resb    1
  716. citac                        resw    1
  717. Sput_fly                    resw    1
  718. game_speed                    resw    1
  719. var                            resw    1
  720.  
  721.  
  722. Sput_pos_X                    resw    1
  723. Sput_pos_Y                    resw    1
  724. Sput_old_pos_X                resw    1
  725. Sput_old_pos_Y                resw    1
  726. Sput_pos_X_cahnge            resw    1
  727. Sput_shimmer                resw    1
  728. Sput_act_color                resw    1
  729.  
  730. Land_pos_Y                    resw    1
  731. LandUP_pos_Y                resw    1
  732. LandUP_exist                resw    1
  733. LandUP_code                    resw    1
  734. LandUP_size                    resw    1
  735. LandUP_pos_X                resw    1
  736. Land_new_pos_Y                resw    1 
  737.  
  738. Fence_sizeX                    resw    1
  739. Fence_sizeY                    resw    1
  740. Fence_pos_X                    resw    1
  741. Fence_pos_Y                    resw    1
  742.  
  743. end