Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;   Arcanoid Gaem 4Ver Mini Sample by Pavlushin Evgeni for ASCL
  3. ;   www.waptap@mail.ru   www.cyberdeck.fatal.ru www.deck4.narod.ru
  4. ;   Play again and exit button added
  5. ;
  6. ;   3Ver Play again, Exit button.
  7. ;   4Ver Next level function.
  8. ;
  9. ;******************************************************************************
  10.     use32
  11.     org    0x0
  12.     db     'MENUET01'              ; 8 byte id
  13.     dd     0x01                    ; header version
  14.     dd     START                   ; start of code
  15.     dd     IM_END                  ; size of image
  16.     dd     0x300000                ; memory for app
  17.     dd     0x300000                ; esp
  18.     dd     0x0 , 0x0         ; I_Param , I_Icon
  19.  
  20. ;******************************************************************************
  21.  
  22. include 'lang.inc'
  23. include '..\..\..\macros.inc'
  24. include 'ascl.inc'
  25. include 'ascgl.inc'
  26. include 'ascgml.inc'
  27.  
  28.  
  29. START:                          ; start of execution
  30.     bmptoimg arc_file,pong
  31.     getimg pong,0,0,80,4,img
  32.     getimg pong,0,4,80,4,img2
  33.     getimg pong,5,38,15,15,img3
  34.     getimg pong,0,8,80,20,img5
  35.     fullimg img4 , 80 ,20 ,0x00000000   ;black for rocket
  36.     fullimg img6 , 15 ,15 ,0x00000000   ;black for ball
  37.     fullimg img7a , 60,20,0x0000cf00
  38.     fullimg img7b , 60,20,0x00af0000
  39.     fullimg img7c , 60,20,0x000000cf
  40.     fullimg img8 , 60,20,0x00000000
  41.  
  42.     call draw_window
  43.  
  44. still:
  45.  
  46.     scevent red,key,button
  47.  
  48.     cmp [againbut],1
  49.     je  stl2
  50.  
  51.     outcount dword [scoreb],256,8,cl_Blue,5*65536
  52.     outcount dword [scorea],332,8,cl_Red,5*65536
  53.     outcount dword [level],368,8,cl_White,2*65536
  54.  
  55. del_images:
  56.     setimg dword [ply1x],dword [ply1y],img4
  57.     setimg dword [ballx],dword [bally],img6
  58.     setimg dword [gravx],dword [gravy],img4
  59.  
  60. del_blocks:
  61.     mov ecx,0
  62. xxx:
  63.     pushad
  64.     mov esi,dword [mass+ecx]
  65.     mov edi,dword [mass+ecx+4]
  66.     mov ebp,dword [mass+ecx+8]
  67.     cmp ebp,0
  68.     jne notptx
  69.     setimg esi,edi,img8
  70. notptx:
  71.     popad
  72.     add ecx,12
  73.     cmp ecx,[blocks_max]
  74.     jne xxx
  75.  
  76.  
  77.  
  78. move_ply1:
  79.  
  80.     correct [ply1x],[ply1rx],2
  81.     correct [ply1y],[ply1ry],2
  82.  
  83. ;automove ball
  84.     mov eax,dword [ballxv]
  85.     add dword [ballx],eax
  86.     mov eax,dword [ballyv]
  87.     add dword [bally],eax
  88.  
  89. ;autoslow ball for rocket gravitation (Space key)
  90.     cmp dword [ballxv],0
  91.     jl ballb
  92. balla:
  93.     cmp dword [ballxv],2
  94.     jng balln
  95.     dec dword [ballxv]
  96.     jmp balln
  97. ballb:
  98.     cmp dword [ballxv],-2
  99.     jnl balln
  100.     inc dword [ballxv]
  101.     jmp balln
  102. balln:
  103.     cmp dword [ballyv],2
  104.     jng by_n
  105.     dec dword [ballyv]
  106. by_n:
  107.  
  108. ;ball collusion of screen
  109.     cmp dword [ballx],400-12
  110.     jna xa_ok
  111.     neg dword [ballxv]
  112. xa_ok:
  113.     cmp dword [ballx],6
  114.     jnb xb_ok
  115.     neg dword [ballxv]
  116. xb_ok:
  117.  
  118.     cmp dword [bally],30
  119.     jnb yb_ok
  120.     neg dword [ballyv]
  121. yb_ok:
  122.  
  123.  
  124. ;if ball far out of screen come back
  125.     cmp dword [bally],466
  126.     jng yax_ok
  127.     call draw_window
  128.     dec dword [scoreb]
  129.     mov eax,[ply1ry]
  130.     sub eax,6
  131.     mov dword [bally],eax ;240
  132.     mov eax,[ply1rx]
  133.     add eax,30
  134.     mov dword [ballx],eax ;200
  135.     mov dword [ballyv],2
  136.     random 3,dword [ballxv]
  137.     sub dword [ballxv],1
  138. yax_ok:
  139.  
  140. xorx:
  141.     cmp dword [ballxv],0
  142.     jne norx
  143.     random 3,dword [ballxv]
  144.     sub dword [ballxv],1
  145.     cmp dword [ballxv],0
  146.     je  xorx
  147. norx:
  148.  
  149. ;test on collusion ply1 of ball
  150. collusion_test:
  151.     collimg img,[ply1x],[ply1y],img3,[ballx],[bally],eax
  152.     cmp eax,1
  153.     jne not_coll
  154.     neg dword [ballyv]
  155.     sub dword [bally],4
  156. ;    neg dword [ballxv]
  157. not_coll:
  158.  
  159. ;test on collusion gravity of ball
  160. collusion_grav:
  161.     collimg img,[gravx],[gravy],img3,[ballx],[bally],eax
  162.     cmp eax,1
  163.     jne not_collg
  164.     sub dword [bally],30
  165.     neg dword [ballyv]
  166.     cmp dword [ballyv],0
  167.     jl  ab
  168.     jg  bf
  169.     jmp not_collgx
  170. ab:
  171.     sub dword [ballyv],10
  172.     jmp not_collgx
  173. bf:
  174.     add dword [ballyv],10
  175. not_collgx:
  176.     cmp dword [ballxv],0
  177.     jl  abx
  178.     jg  bfx
  179.     jmp not_collg
  180. abx:
  181.     sub dword [ballxv],0 ;8 ;15
  182.     jmp not_collg
  183. bfx:
  184.     add dword [ballxv],0 ;8
  185.  
  186.  
  187. ;    mov dword [ballyv],20
  188. not_collg:
  189.  
  190. ;ply contorl
  191.     control 12,316,[ply1rx]
  192.     control 380,470,[ply1ry]
  193.  
  194. ;garvity
  195. gravity:
  196.     cmp dword [gravtime],0
  197.     je no_dg
  198.     dec dword [gravtime]
  199. no_dg:
  200.  
  201. draw_gravity:
  202.     cmp dword [gravtime],0
  203.     je  nograv
  204.     mov eax,dword [ply1x]
  205.     mov ebx,dword [ply1y]
  206.     sub ebx,30
  207.     mov dword [gravx],eax
  208.     mov dword [gravy],ebx
  209.     jmp endgrav
  210. nograv:
  211.     mov dword [gravx],1000
  212.     mov dword [gravy],1000
  213. endgrav:
  214.  
  215. redraw_images:
  216.     setimg dword [ply1x],dword [ply1y],img2
  217.     setimg dword [ballx],dword [bally],img3
  218.     setimg dword [gravx],dword [gravy],img5
  219.  
  220. draw_blocks:
  221.     mov ecx,0
  222. xxx2:
  223.     pushad
  224.     mov esi,dword [mass+ecx]
  225.     mov edi,dword [mass+ecx+4]
  226.     mov ebp,dword [mass+ecx+8]
  227.     cmp ebp,0
  228.     je  notpt
  229.     cmp ebp,1
  230.     jne no_a
  231.     setimg esi,edi,img7a
  232.     jmp notpt
  233. no_a:
  234.     cmp ebp,2
  235.     jne no_b
  236.     setimg esi,edi,img7b
  237.     jmp notpt
  238. no_b:
  239.     cmp ebp,3
  240.     jne no_c
  241.     setimg esi,edi,img7c
  242.     jmp notpt
  243. no_c:
  244.  
  245. notpt:
  246.     popad
  247.     add ecx,12
  248.     cmp ecx,[blocks_max]
  249.     jne xxx2
  250.  
  251. ;collusion ball of blocks
  252. coll_blocks:
  253.     mov [temp3],0
  254.     mov ecx,0
  255. testloop:
  256.     pushad
  257.     mov ebp,dword [mass+ecx+8]
  258.     cmp ebp,0
  259.     jne testcol
  260.     jmp notest
  261. testcol:
  262.     mov [temp3],1
  263.     mov esi,dword [mass+ecx]
  264.     mov edi,dword [mass+ecx+4]
  265.     mov [temp1],esi
  266.     mov [temp2],edi
  267.     push ecx
  268.     collimg img8,[temp1],[temp2],img3,[ballx],[bally],eax
  269.     pop ecx
  270.     cmp eax,1
  271.     jne notest
  272.     mov dword [mass+ecx+8],0
  273. ;    neg [ballxv]
  274.     neg [ballyv]
  275.     add [scorea],30
  276.     call draw_window
  277.     jmp end_col
  278. notest:
  279.     popad
  280.     add ecx,12
  281.     cmp ecx,[blocks_max]
  282.     jne testloop
  283. end_col:
  284.  
  285.     cmp [delay_cnt],0
  286.     jne no_delay
  287.     mov [delay_cnt],1
  288.     delay 1             ;don't generate delay for fast speed programm
  289. no_delay:
  290.     dec [delay_cnt]
  291.  
  292. win_test:
  293.     cmp [temp3],1
  294.     je stl
  295. ;    inc [level]
  296.     mov [nextlev],1
  297.     mov [againbut],1
  298.     call draw_window
  299. ;    label 160,200,'You Win!',cl_Green+font_Big
  300. ;    label 130,220,'Youre Score:',cl_Green+font_Big
  301. ;    outcount dword [scorea],230,220,cl_Green,5*65536
  302. ;    label 130,234,'Youre Lives:',cl_Green+font_Big
  303. ;    outcount dword [scoreb],230,234,cl_Green,5*65536
  304. ;    delay 600  ;wait 2sec
  305. ;    close      ;exit from program
  306. stl:
  307.  
  308. lose_test:
  309.     cmp [scoreb],0
  310.     jne stl2
  311. ;    call draw_window
  312. ;    label 160,200,'You Lose!',cl_Red+font_Big
  313. ;    label 130,220,'Youre Score:',cl_Red+font_Big
  314. ;    outcount dword [scorea],230,220,cl_Red,5*65536
  315. ;    delay 300  ;wait 2sec
  316. ;    close      ;exit from program
  317. ;    mov ebx,10*65536+40
  318. ;    mov ebx,10*65536+20
  319. ;    mov edx,2
  320. ;    mov esi,0x0000ff00
  321. ;    mov eax,8
  322. ;    mcall
  323.     mov [level],0
  324.     mov [nextlev],0
  325.     mov [againbut],1
  326.     call draw_window
  327.  
  328. stl2:
  329.  
  330.     jmp  still
  331.  
  332.   red:
  333.     call draw_window
  334.     jmp  still
  335.  
  336.   key:                          ; key
  337.     mov eax,2
  338.     mcall
  339.     cmp ah,key_Left
  340.     jne no_l
  341.     sub dword [ply1rx],50 ;24 ;16
  342. no_l:
  343.     cmp ah,key_Right
  344.     jne no_r
  345.     add dword [ply1rx],50 ;24 ;16
  346. no_r:
  347.     cmp ah,key_Up
  348.     jne no_u
  349.     sub dword [ply1ry],20
  350. no_u:
  351.     cmp ah,key_Down
  352.     jne no_d
  353.     add dword [ply1ry],20
  354. no_d:
  355.     cmp ah,key_Space
  356.     jne no_sp
  357.     mov dword [gravtime],100
  358. no_sp:
  359.     jmp  still
  360.  
  361.   button:                       ; button
  362.     mov  eax,17                 ; get id
  363.     mcall
  364.     cmp  ah,1                   ; button id=1 ?
  365.     jne  noclose
  366.     mov  eax,-1                 ; close this program
  367.     mcall
  368. noclose:
  369.     cmp ah,2
  370.     jne  noplayagain
  371.     mov [xt],100
  372.     mov [yt],100
  373.     mov [gravtime],10
  374.     mov [gravx],1000
  375.     mov [gravy],1000
  376.     mov [ply1rx],160
  377.     mov [ply1ry],460
  378.     mov [ply1x],160
  379.     mov [ply1y],400
  380.     mov [ballx],200
  381.     mov [bally],300
  382.     mov [ballyv],2
  383.     mov [ballxv],1
  384.  
  385.     cmp [nextlev],1
  386.     je  noch
  387.     mov [scorex],0
  388.     mov [scorea],0
  389.     mov [scoreb],3
  390.     jmp noch2
  391. noch:
  392.     inc [scoreb]
  393.     inc [level]
  394.     mov eax,[maxlev]
  395.     cmp [level],eax
  396.     jna noch2
  397.     mov [level],eax
  398. noch2:
  399.  
  400.     mov eax,18*4*5
  401.     mul [level]
  402.     mov ebp,eax
  403.     add ebp,levels
  404.     mov ecx,18*4*5   ;bytes
  405. loo:
  406.     mov eax,dword [ebp+ecx]
  407.     mov dword [mass+ecx],eax
  408.     sub ecx,4
  409.     jnz loo
  410.  
  411.     mov [againbut],0
  412.  
  413.     call draw_window
  414. noplayagain:
  415.     jmp  still
  416.  
  417.  
  418. draw_window:
  419.     startwd
  420.     window 0,0,400+8,480+24,window_Skinned
  421.     label 12,8,'ARCANOID: USE ARROW KEYS    LIVES      SCORE',cl_White+font_Big
  422.  
  423.     cmp [againbut],0
  424.     je  no_againbut
  425.  
  426.     cmp [nextlev],1
  427.     je  nlev
  428.     label 160,200,'You Lose!',cl_Red+font_Big
  429.     label 130,220,'Youre Score:',cl_Red+font_Big
  430.     outcount dword [scorea],230,220,cl_Red,5*65536
  431.     mov ebx,150*65536+80
  432.     mov ecx,240*65536+12
  433.     mov edx,2
  434.     mov esi,0x0000aa00
  435.     mov eax,8
  436.     mcall
  437.     mov ecx,260*65536+12
  438.     mov edx,1
  439.     mcall
  440.     label 152,244,'Play again?',cl_Red+font_Big
  441.     jmp elev
  442. nlev:
  443.     label 160,200,'You Win!',cl_Green+font_Big
  444.     label 130,220,'Youre Score:',cl_Green+font_Big
  445.     outcount dword [scorea],230,220,cl_Green,5*65536
  446.     mov ebx,150*65536+80
  447.     mov ecx,240*65536+12
  448.     mov edx,2
  449.     mov esi,0x0000aa00
  450.     mov eax,8
  451.     mcall
  452.     mov ecx,260*65536+12
  453.     mov edx,1
  454.     mcall
  455.     label 152,244,'Next level?',cl_Red+font_Big
  456. elev:
  457.  
  458.     label 178,264,'Exit?',cl_Red+font_Big
  459. no_againbut:
  460.  
  461.     endwd
  462.     ret
  463.  
  464.  
  465. ; DATA AREA
  466. againbut dd 0
  467.  
  468. xt dd 100
  469. yt dd 100
  470.  
  471. gravtime dd 10
  472. gravx dd 1000
  473. gravy dd 1000
  474.  
  475. ply1rx dd 160
  476. ply1ry dd 460
  477.  
  478. ply1x dd 160
  479. ply1y dd 400
  480.  
  481. ballx dd 200
  482. bally dd 300
  483.  
  484. ballyv dd 2
  485. ballxv dd 1
  486.  
  487. temp1 dd 0
  488. temp2 dd 0
  489. temp3 dd 0
  490.  
  491. scorex dd 0
  492. scorea dd 0
  493. scoreb dd 3
  494.  
  495. level dd 0
  496. nextlev dd 0
  497. maxlev dd 2
  498.  
  499. counter dd 0
  500. tsoi dd 0
  501.  
  502. delay_cnt dd 0
  503.  
  504. blocks_max dd 6*5*12 ;size in bytes 5*3 dd
  505.  
  506. mass:
  507.      dd  30,200,0 ,90,200,0 ,150,200,0 ,210,200,0 ,270,200,0 ,330,200,0
  508.      dd  30,180,0 ,90,180,0 ,150,180,0 ,210,180,0 ,270,180,0 ,330,180,0
  509.      dd  30,160,0 ,90,160,0 ,150,160,0 ,210,160,0 ,270,160,0 ,330,160,0
  510.      dd  30,140,0 ,90,140,1 ,150,140,1 ,210,140,1 ,270,140,0 ,330,140,0
  511.      dd  30,120,0 ,90,120,0 ,150,120,0 ,210,120,0 ,270,120,0 ,330,120,0
  512.  
  513. levels:
  514.      dd  30,200,0 ,90,200,0 ,150,200,0 ,210,200,2 ,270,200,0 ,330,200,0
  515.      dd  30,180,2 ,90,180,1 ,150,180,1 ,210,180,2 ,270,180,2 ,330,180,0
  516.      dd  30,160,1 ,90,160,3 ,150,160,1 ,210,160,2 ,270,160,2 ,330,160,2
  517.      dd  30,140,2 ,90,140,1 ,150,140,1 ,210,140,2 ,270,140,2 ,330,140,0
  518.      dd  30,120,0 ,90,120,0 ,150,120,0 ,210,120,2 ,270,120,0 ,330,120,0
  519. ;level2
  520.      dd  30,200,0 ,90,200,3 ,150,200,0 ,210,200,2 ,270,200,2 ,330,200,2
  521.      dd  30,180,0 ,90,180,1 ,150,180,0 ,210,180,2 ,270,180,2 ,330,180,2
  522.      dd  30,160,0 ,90,160,3 ,150,160,0 ,210,160,2 ,270,160,2 ,330,160,2
  523.      dd  30,140,0 ,90,140,1 ,150,140,0 ,210,140,2 ,270,140,2 ,330,140,2
  524.      dd  30,120,0 ,90,120,3 ,150,120,0 ,210,120,2 ,270,120,2 ,330,120,2
  525. ;level3
  526.      dd  30,200,1 ,90,200,3 ,150,200,1 ,210,200,2 ,270,200,2 ,330,200,2
  527.      dd  30,180,2 ,90,180,1 ,150,180,1 ,210,180,2 ,270,180,2 ,330,180,2
  528.      dd  30,160,1 ,90,160,3 ,150,160,1 ,210,160,2 ,270,160,2 ,330,160,2
  529.      dd  30,140,2 ,90,140,1 ,150,140,1 ,210,140,2 ,270,140,2 ,330,140,2
  530.      dd  30,120,1 ,90,120,3 ,150,120,1 ,210,120,2 ,270,120,2 ,330,120,2
  531.  
  532. arc_file:
  533. file 'arc.bmp'
  534.  
  535. rb 20000
  536.  
  537. IM_END:
  538.  
  539. pong:
  540. rb 80*60*3+8
  541. img:
  542. rb 32*32*3+8
  543. img2:
  544. rb 32*32*3+8
  545. img3:
  546. rb 32*32*3+8
  547. img4:
  548. rb 80*20*3+8
  549. img5:
  550. rb 80*20*3+8
  551. img6:
  552. rb 15*15*3+8
  553. img7a:
  554. rb 60*20*3+8
  555. img7b:
  556. rb 60*20*3+8
  557. img7c:
  558. rb 60*20*3+8
  559. img8:
  560. rb 60*40*3+8
  561.  
  562. I_END:
  563.