Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;    PONG for MENUET v1.0
  3. ;    2001 by Mario Birkner, Germany
  4. ;    cyflexx@digitalrice.com
  5. ;
  6. ;    PONG for MENUET is
  7. ;    a small PONG-clone for MenuetOS
  8. ;
  9. ; HINT: If the Paddle moves too slow,increase the
  10. ;       typematic Rate in your BIOS
  11. ;
  12.  
  13. include '..\..\..\macros.inc'
  14.  
  15. CK_UP1 equ 113
  16. CK_DOWN1 equ 97
  17. CK_UP2 equ 130+48
  18. CK_DOWN2 equ 129+48
  19.  
  20. use32
  21.  
  22.                 org     0x0
  23.  
  24.                 db      'MENUET00'              ; 8 byte id
  25.                 dd      38                      ; required os
  26.                 dd      START                   ; program start
  27.                 dd      I_END                   ; program image size
  28.                 dd      0x2000                  ; required amount of memory
  29.                 dd      0x2000                  ; esp = 0x7FFF0
  30.                 dd      0x00000000              ; reserved=no extended header
  31.  
  32.  
  33.  
  34. START:
  35.  
  36.     call draw_window
  37.  
  38.  
  39. still:
  40.  
  41.     mov  eax,10
  42.     add  eax,[control]
  43.     mcall
  44.     cmp  eax,1
  45.     je   red
  46.     cmp  eax,2
  47.     je   key
  48.     cmp  eax,3
  49.     je   button
  50.     cmp  [control],1
  51.     jne  still
  52.  
  53.     mov  eax,5
  54.     mov  ebx,[delay]
  55.     mcall
  56.  
  57.     jmp  move
  58.  
  59.  red:
  60.     call draw_window
  61.     cmp  [control],1
  62.     jne  still
  63.     call clall
  64.     call drawpad
  65.     jmp  still
  66.  key:
  67.     mov  eax,2
  68.     mcall
  69.     cmp  [control],1
  70.     jne  still
  71.  
  72.    up1:
  73.     cmp  ah,CK_UP1
  74.     jne  dn1
  75.     cmp  [posya],52*65536+64
  76.     je   still
  77.     sub  [posya],4*65536
  78.     call cl0
  79.     call drawpad
  80.     jmp  still
  81.    dn1:
  82.     cmp  ah,CK_DOWN1
  83.     jne  up2
  84.     cmp  [posya],140*65536+64
  85.     je   still
  86.     add  [posya],4*65536
  87.     call cl0
  88.     call drawpad
  89.     jmp  still
  90.    up2:
  91.     cmp  ah,CK_UP2
  92.     jne  dn2
  93.     cmp  [posyb],52*65536+64
  94.     je   still
  95.     sub  [posyb],4*65536
  96.     call cl1
  97.     call drawpad
  98.     jmp  still
  99.    dn2:
  100.     cmp  ah,CK_DOWN2
  101.     jne  still
  102.     cmp  [posyb],140*65536+64
  103.     je   still
  104.     add  [posyb],4*65536
  105.     call cl1
  106.     call drawpad
  107.     jmp  still
  108.  
  109.   button:
  110.     mov  eax,17
  111.     mcall
  112.  
  113.     cmp  ah,1
  114.     jne  button2
  115.     mov  eax,-1
  116.     mcall
  117.  
  118.     jmp  still
  119.  
  120.   button2:
  121.     cmp  ah,2
  122.     jne  still
  123.     mov  [control],1
  124.     mov  [scp1],0
  125.     mov  [scp2],0
  126.     jmp  res
  127.  move:
  128.     mov  eax,[mposx]
  129.     mov  ebx,[mposy]
  130.     add  [bposx],eax
  131.     add  [bposy],ebx
  132.     cmp  [bposx],16*65536+16
  133.      je  pf1
  134.     cmp  [bposx],272*65536+16
  135.      je  pf2
  136.     cmp  [bposy],191*65536+16
  137.      je  bot
  138.     cmp  [bposy],48*65536+16
  139.      je  top
  140.     cmp  [bposx],247*65536+16
  141.      je  rig
  142.      jg  padr
  143.     cmp  [bposx],55*65536+16
  144.      je  lef
  145.      jl  padl
  146.     jmp  draw
  147.  
  148.  padr:
  149.     mov  ecx,[posyb]
  150.     jmp  pad
  151.  padl:
  152.     mov  ecx,[posya]
  153.  pad:
  154.     mov  eax,[bposy]
  155.     sub  eax,16
  156.     mov  ebx,eax
  157.     add  ebx,17*65536
  158.     sub  ecx,64
  159.     mov  edx,ecx
  160.     add  edx,65*65536
  161.     cmp  eax,edx
  162.     je   top
  163.     cmp  ebx,ecx
  164.     je   bot
  165.     jmp  draw
  166.  
  167.   bot:
  168.     mov  [mposy],-65536
  169.     jmp  draw
  170.   top:
  171.     mov  [mposy],65536
  172.     jmp  draw
  173.   rig:
  174.     mov  eax,[posyb]
  175.     sub  eax,1*65536-64 ;verhindert das der ball ins paddle eindringt
  176.     mov  ebx,[posyb]
  177.     add  ebx,64*65536-64
  178.     mov  ecx,[bposy]
  179.     add  ecx,16*65536-16
  180.     mov  edx,[bposy]
  181.     sub  edx,16
  182.     cmp  ecx,eax
  183.      je  blr
  184.      jl  draw
  185.     cmp  edx,ebx
  186.      je  blr
  187.      jl  blr
  188.      jg  draw
  189.    blr:
  190.     mov  [mposx],-65536
  191.     jmp  draw
  192.  
  193.   lef:
  194.     mov  eax,[posya]
  195.     sub  eax,1*65536+64
  196.     mov  ebx,[posya]
  197.     add  ebx,64*65536-64
  198.     mov  ecx,[bposy]
  199.     add  ecx,16*65536-16
  200.     mov  edx,[bposy]
  201.     add  edx,16
  202.     cmp  ecx,eax
  203.      je  bll
  204.      jl  draw
  205.     cmp  edx,ebx
  206.      je  bll
  207.      jl  bll
  208.      jg  draw
  209.    bll:
  210.     mov  [mposx],65536
  211.     jmp  draw
  212.  
  213. drawpad:
  214. ; draw paddle
  215.     mov  edx,[posya]
  216.     shr  edx,16
  217.     add  edx,32*65536
  218.     mov  ecx,24*65536+64
  219.     mov  ebx,paddle
  220.     mov  eax,7
  221.     mcall
  222.     mov  edx,[posyb]
  223.     shr  edx,16
  224.     add  edx,264*65536
  225.     mov  eax,7
  226.     mov  ebx,paddle
  227.     mov  ecx,24*65536+64
  228.     mcall
  229.     ret
  230.  
  231. draw:
  232. ; draw ball
  233.     mov  eax,13
  234.     mov  ebx,-65536+2
  235.     mov  ecx,-65536+2
  236.     add  ebx,[bposx]
  237.     add  ecx,[bposy]
  238.     xor  edx,edx
  239.     mcall
  240.     add  ebx,65536-2
  241.     add  ecx,65536-2
  242.     mov  edx,ebx
  243.     and  edx,0xffff0000
  244.     mov  esi,ecx
  245.     shr  esi,16
  246.     add  edx,esi
  247.     mov  esi,ebx
  248.     shl  esi,16
  249.     mov  edi,ecx
  250.     and  edi,0x0000ffff
  251.     add  esi,edi
  252.     mov  ecx,esi
  253.     mov  ebx,ball
  254.     mov  eax,7
  255.     mcall
  256.     jmp  still
  257. cls:
  258.     mov  eax,13
  259.     mov  edx,0x00000000
  260.     mcall
  261.     ret
  262. cl0:
  263.     mov  ebx,32*65536+24
  264.     mov  ecx,[posya]
  265.     sub  ecx,4*65536+60
  266.     call cls
  267.     mov  ecx,[posya]
  268.     add  ecx,64*65536-60
  269.     call cls
  270.     ret
  271. cl1:
  272.     mov  ebx,264*65536+24
  273.     mov  ecx,[posyb]
  274.     sub  ecx,4*65536+60
  275.     call cls
  276.     mov  ecx,[posyb]
  277.     add  ecx,64*65536-60
  278.     call cls
  279.     ret
  280. clall:
  281.     mov  ebx,16*65536+288
  282.     mov  ecx,47*65536+161
  283.     call cls
  284.     ret
  285. pf1:
  286.     inc  [scp2]
  287.     jmp  res
  288. pf2:
  289.      inc  [scp1]
  290.  res:
  291.     cmp  [scp2],20
  292.      je  over
  293.     cmp  [scp1],20
  294.      je  over
  295.     mov  [bposx],152*65536+16 ;default position ball
  296.     mov  [bposy],119*65536+16
  297.     call draw_window
  298.     call clall
  299.     call drawpad
  300.     jmp  draw
  301. over:
  302.     mov  [control],0
  303.     call draw_window
  304.     mov  eax,4
  305.     mov  ebx,120*65536+100
  306.     mov  ecx,0x00ffdd00
  307.     mov  esi,14
  308.     cmp  [scp1],20
  309.     jne  win
  310.     mov  edx,w1
  311.     mcall
  312.     jmp  still
  313.  win:
  314.     mov  edx,w2
  315.     mcall
  316.     jmp  still
  317.  
  318. ;   *********************************************
  319. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  320. ;   *********************************************
  321.  
  322.  
  323. draw_window:
  324.  
  325.     mov  eax,12
  326.     mov  ebx,1
  327.     mcall
  328.  
  329.  
  330.     mov  eax,0
  331.     mov  ebx,100*65536+320
  332.     mov  ecx,100*65536+250
  333.     mov  edx,0x134873a0    ;70d0
  334.     mov  edi,labelt
  335.     mcall
  336.  
  337.     mov  eax,8
  338.     mov  ebx,20*65536+80
  339.     mov  ecx,220*65536+20
  340.     mov  edx,2
  341.     mov  esi,0x900000
  342.     mcall
  343.  
  344.     mov  eax,4
  345.     mov  ebx,38*65536+227
  346.     mov  ecx,0x00FFFFFF
  347.     mov  edx,b0lab
  348.     mov  esi,8
  349.     mcall
  350.  
  351.     mov  eax,4
  352.     mov  ebx,25*65536+30
  353.     mov  ecx,0x00ffdd00
  354.     mov  edx,welcome
  355.     mov  esi,40
  356.     mcall
  357.  
  358.     mov  eax,4
  359.     mov  ebx,220*65536+228
  360.     mov  ecx,0x00ffdd00
  361.     mov  edx,scotext
  362.     mov  esi,11
  363.     mcall
  364.  
  365.     mov  eax,47
  366.     mov  ebx,0x00020000
  367.     mov  ecx,[scp1]
  368.     mov  edx,268 shl 16+228
  369.     mov  esi,0x0000ddff
  370.     mcall
  371.  
  372.     mov  eax,47
  373.     mov  ebx,0x00020000
  374.     mov  ecx,[scp2]
  375.     mov  edx,285 shl 16+228
  376.     mov  esi,0x0000ddff
  377.     mcall
  378.  
  379.     mov  eax,12
  380.     mov  ebx,2
  381.     mcall
  382.  
  383.     ret
  384.  
  385.  
  386. ; DATA AREA
  387. posya   dd 96*65536+64  ;default position paddle
  388. posyb   dd 96*65536+64
  389. bposx   dd 152*65536+16 ;default position ball
  390. bposy   dd 119*65536+16
  391. mposx   dd 65536        ;richtung ball
  392. mposy   dd 65536
  393. control dd 0x0
  394. delay   dd 0x1          ;delay betw. frames
  395. scp1    dd 0x0
  396. scp2    dd 0x0
  397.  
  398.  
  399. scotext:
  400.      db  'SCORE:    :'
  401. welcome:
  402.      db  'PLAYER1: Q , A            PLAYER2:  , '
  403. b0lab:
  404.      db  'NEW GAME'
  405. labelt:
  406.      db  'PONG FOR MENUET v1.0',0
  407. w1:
  408.      db  'Player 1 wins!'
  409. w2:
  410.      db  'Player 2 wins!'
  411. clsign:
  412.      db   'x'
  413.  
  414. ball:
  415. file "ball.raw"
  416.  
  417. paddle:
  418. file "paddle.raw"
  419.  
  420. I_END:
  421.