home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / demos / baah / TinyDemos / zOArcnOId / zO_src next >
Encoding:
Text File  |  1996-09-29  |  11.4 KB  |  228 lines

  1. ;                                     \|/
  2. ;                                     O O
  3. ; --------------------------------oOO--U--OOo--------------------------------
  4. ; -                                                                         -
  5. ; -                              - zOArcnOId -                              -
  6. ; -                   © Alain BROBECKER (baah/Arm'sTeack)                   -
  7. ; -                                                            29th Sept 96 -
  8. ; ---------------------------------------------------------------------------
  9. ;
  10. ;   This game is decicated to MJJ-Prods, a cool crew (Atari ST) which has
  11. ; developped the concept of zOgAIms... Hi BigFoot, Biro... (Though I' ve not
  12. ; preserved the original spirit, I hope you' ll like this one =)
  13. ;
  14. ;   This source is given for free and is widely commented, so I hope some
  15. ; people will look at it and (maybe) improve their own code. Re-use of my
  16. ; routines is allowed (though not recommended, cos you' ll understand more
  17. ; if you write your owns...) as long as it is not for commercial purposes,
  18. ; as long as you credit me and send me a free copy of your proggy. Oh, btw
  19. ; the assembler I used is ExtASM 0.50b. You' ll have to make changes in
  20. ; macros if you use a newer version of ExtASM.
  21. ;
  22. ;   Hey, that' s no difficult game (except maybe for TRizOiDS=zO) and some
  23. ; will say it' s no game at all. I quite agree, but coding it was so fun! =)
  24. ; Don' t hesitate to contact me if you write another zOgAIm, I like them
  25. ; so much. (zOspAcEInvAdErs would be welcome =)
  26. ;
  27. ;           Alain BROBECKER         Dracula / Positivity (STe)
  28. ;           rte de Dardagny         baah / Arm's Tech (Archie)
  29. ;            01630 CHALLEX                           baah (PC)
  30. ;               FRANCE
  31.  
  32. #name       zOArcnOId               ; zOgAIm forever...
  33.  
  34. ;------ zOcOnstAnts ---------------------------------------------------------
  35. #set        boxmax_w = 28           ; Max width for box routine.
  36. #set        bat_w = 27              ; bat_width-1.
  37. #set        bat_h = 4               ; bat_height-1.
  38. #set        bat_color = &ff         ; Color for bat.
  39. #set        ball_s = 7              ; ball_size-1.
  40. #set        ball_color = &d0        ; Ball color.
  41. #set        nb_lines = 10           ; Nb of lines of blocks.
  42.  
  43. ;------ zOcOdE --------------------------------------------------------------
  44. .proggy_start
  45.   swi       256+22                  ; Vdu 22, set screenmode.
  46.   swi       256+13                  ; Switch to mode 13.
  47.   swi       OS_RemoveCursors        ; Who needs them?
  48.   adr       r0,vram_adress          ; Get videoram adress.
  49.   mov       r1,r0
  50.   swi       OS_ReadVduVariables
  51. ; At first we draw the blocks on screen, with the good color.
  52.   ldr       r0,vram_adress
  53.   mov       r6,#320-16              ; r6=blockx.
  54.   mov       r7,#16*(nb_lines-1)     ; r7=blocky.
  55.   adr       r8,blocks               ; Contain blocks' colors. (0=no block)
  56. .init_one_block
  57.   ldrB      r1,[r8],#1              ; Load block color.
  58.   add       r2,r6,#1                ; r2=x1.
  59.   add       r3,r7,#1                ; r3=y1.
  60.   add       r4,r2,#14               ; r4=x2.
  61.   add       r5,r3,#14               ; r5=y2.
  62.   bl        SlowBox256              ; Draw block.
  63.   subS      r7,r7,#16               ; Next blocky.
  64.   addMI     r7,r7,#16*nb_lines      ; If negative, then reinit blocky,
  65.   subMIS    r6,r6,#16               ;   and next blockx.
  66.   bPL       init_one_block          ; Finished if blocky<0 and blockx<0.
  67. ; Some other inits, called each time the player dies. We' ll have...
  68. ; r8=scotch_flag, r9=batx, r10=ballx, r11=bally, r12=incx, r13=incy.
  69.   mov       r9,#0                   ; batx=0.
  70. .triso_player
  71.   mov       r8,#0                   ; Ball scotched.
  72.   add       r10,r9,#2               ; Initial position for scotched ball.
  73.   mov       r11,#254-bat_h-ball_s-3
  74.   mov       r12,#-1                 ; incx=-1.
  75.   mov       r13,#-1                 ; incy=-1.
  76. .playing_aRCNoiD
  77.   mov       r0,#&13                 ; Wait for Vsync.
  78.   swi       OS_Byte
  79. ; Clear the bat and ball we have drawn previous VBl.
  80.   ldr       r0,vram_adress
  81.   mov       r1,#0
  82.   mov       r2,r9                   ; r2=old_batx1.
  83.   mov       r3,#254-bat_h           ; r3=old_baty1.
  84.   add       r4,r2,#bat_w            ; r4=old_batx2.
  85.   add       r5,r3,#bat_h            ; r5=old_baty2.
  86.   bl        SlowBox256              ; Clear bat.
  87.   mov       r2,r10                  ; r2=old_ballx1.
  88.   mov       r3,r11                  ; r3=old_bally1.
  89.   add       r4,r2,#ball_s           ; r4=old_ballx2.
  90.   add       r5,r3,#ball_s           ; r5=old_bally2.
  91.   bl        SlowBox256              ; Clear the ball.
  92. ; Check bat' s movements from mouse and draw it.
  93.   swi       OS_Mouse                ; r0=mousex | r2=mousek.
  94.   orr       r8,r8,r2                ; scotch_flag<>0 if mousek<>0.
  95.   mov       r9,r0,lsr #2            ; r9=new bat position.
  96.   cmp       r9,#319-bat_w           ; Right edge bounding.
  97.   movGE     r9,#319-bat_w
  98.   ldr       r0,vram_adress          ; Draw the bat.
  99.   mov       r1,#bat_color           ; r1=bat color.
  100.   mov       r2,r9                   ; r2=batx1.
  101.   mov       r3,#254-bat_h           ; r3=baty1.
  102.   add       r4,r2,#bat_w            ; r4=batx2.
  103.   add       r5,r3,#bat_h            ; r5=baty2.
  104.   bl        SlowBox256              ; Draw it.
  105. ; Compute ball mvts, test collisions with the bat and draw it.
  106.   cmp       r8,#0                   ; scotch_flag=0?
  107.   addEQ     r10,r9,#2               ; Yup, ball is scotched to the bat,
  108.   bEQ       draw_ball               ;   and so we have no other mvts.
  109.   addS      r10,r10,r12             ; ballx+=incx.
  110.   cmpNE     r10,#319-ball_s         ; Flags=x-(319-ball_s).
  111.   rsbEQ     r12,r12,#0              ; If x=0 or x=(319-ball_s), then incx-=incx.
  112.   addS      r11,r11,r13             ; bally+=incy.
  113.   rsbEQ     r13,r13,#0              ; If y=0, then incy-=incy.
  114.   cmp       r11,#254-bat_h-ball_s   ; Possible collision with bat?
  115.   bLT       draw_ball               ; No, then no more tests...
  116.   cmp       r11,#254-ball_s         ; We have reached bottom of screen?
  117.   bEQ       triso_player            ; Lost, what a trisoid! =)
  118.   add       r1,r10,#ball_s          ; r1=ball_xright.
  119.   add       r2,r9,#bat_w            ; r2=bat_xright.
  120.   cmp       r1,r9                   ; Flags=ball_xright-bat_xleft.
  121.   cmpGE     r2,r10                  ; If >=0, flags=bat_xright-ball_xleft.
  122.   movGE     r13,#-1                 ; If >=0, we have a collision.
  123.   addGE     r11,r11,r13             ; bally+=incy.
  124. .draw_ball
  125.   mov       r1,#ball_color          ; r1=ball color.
  126.   mov       r2,r10                  ; r2=ballx1.
  127.   mov       r3,r11                  ; r3=bally1.
  128.   add       r4,r2,#ball_s           ; r4=ballx2.
  129.   add       r5,r3,#ball_s           ; r5=bally2.
  130.   bl        SlowBox256              ; Draw ball.
  131. ; Perform the collisions between ball and blocks.
  132.   mov       r5,#320-16              ; r5=blockx.
  133.   mov       r6,#16*(nb_lines-1)     ; r6=blocky.
  134.   adr       r7,blocks               ; Contains block colors. (0=no blocks)
  135. .test_one_collision
  136.   ldrB      r14,[r7],#1             ; Load block color.
  137.   cmp       r14,#0                  ; Is it null?
  138.   bEQ       next_collision          ; Then we have no block here.
  139.   add       r0,r10,r12              ; r0=ballx+incx.
  140.   add       r1,r11,r13              ; r1=bally+incy.
  141.   add       r2,r0,#ball_s-1         ; r2=ballx+incx+ball_s-1.
  142.   add       r3,r1,#ball_s-1         ; r3=bally+incy+ball_s-1.
  143.   add       r4,r5,#15               ; r4=blockx+15.
  144.   add       r14,r6,#15              ; r14=blocky+15.
  145.   cmp       r0,r4                   ; Flags=ballx+incx-(blockx+15).
  146.   cmpLE     r1,r14                  ; Flags=bally+incy-(blocky+15).
  147.   cmpLE     r5,r2                   ; Flags=blockx-(ballx+incx+ball_s-1).
  148.   cmpLE     r6,r3                   ; Flags=blocky-(bally+incy+ball_s-1).
  149.   bGT       next_collision          ; If one result>0, no collision.
  150.   cmp       r0,r4                   ; Flags=ballx+incx-(blockx+15).
  151.   cmpNE     r5,r2                   ; Flags=blockx-(ballx+incx+ball_s-1).
  152.   rsbEQ     r12,r12,#0              ; If one result=0, then change incx.
  153.   cmp       r1,r14                  ; Flags=bally+incy-(blocky+15).
  154.   cmpNE     r6,r3                   ; Flags=blocky-(bally+incy+ball_s-1).
  155.   rsbEQ     r13,r13,#0              ; If one result=0, then change incy.
  156.   str       r5,vram_adress+4        ; Save blockx.
  157.   ldr       r0,vram_adress
  158.   mov       r1,#0
  159.   strB      r1,[r7,#-1]             ; Block does no exist anymore.
  160.   add       r2,r5,#1                ; r2=blockx1.
  161.   add       r3,r6,#1                ; r3=blocky1.
  162.   add       r4,r2,#14               ; r4=blockx2.
  163.   add       r5,r3,#14               ; r5=blocky2.
  164.   bl        SlowBox256              ; Clear block.
  165.   ldr       r5,vram_adress+4        ; Restore blockx.
  166. .next_collision
  167.   subS      r6,r6,#16               ; Next blocky.
  168.   addMI     r6,r6,#16*nb_lines      ; If negative, then reinit blocky,
  169.   subMIS    r5,r5,#16               ;   and next blockx.
  170.   bPL       test_one_collision      ; Finished if blocky<0 and blockx<0.
  171. ; Finished, it was short and good.
  172.   swi       OS_ReadEscapeState      ; Escape key pressed?
  173.   bCC       playing_aRCNoiD         ; No, then loop.
  174.   swi       OS_Exit                 ; What, game not good enough for you?
  175.  
  176. ;------ zOdAtAs -------------------------------------------------------------
  177. ; vram_adress+4 is used as temporary storage.
  178. .vram_adress dcd 148,-1             ; Values for the swi.
  179. .blocks                             ; Colors for each blocks. (zO!)
  180.   dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
  181.   dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
  182.   dcb &2a,&d3,&c4,&d1,&d0,&2f,&2e,&2d,&2c,&fb
  183.   dcb &2a,&d3,&c4,&d1,&d0,&2f,&2e,&2d,&2c,&fb
  184.   dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
  185.   dcb &2a,&2b,&d2,&d1,&d0,&2f,&2e,&2d,&fa,&fb
  186.   dcb &2a,&d3,&d2,&d1,&d0,&2f,&2e,&2d,&2c,&fb
  187.   dcb &2a,&d3,&c4,&c5,&c6,&c7,&f8,&f9,&2c,&fb
  188.   dcb &2a,&d3,&c4,&c5,&c6,&c7,&f8,&f9,&2c,&fb
  189.   dcb &2a,&d3,&d2,&d1,&d0,&2f,&2e,&2d,&2c,&fb
  190.   dcb &2a,&2b,&d2,&d1,&d0,&2f,&2e,&2d,&fa,&fb
  191.   dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
  192.   dcb &2a,&d3,&c4,&c5,&c6,&2f,&f8,&f9,&fa,&fb
  193.   dcb &2a,&d3,&c4,&c5,&d0,&2f,&f8,&f9,&fa,&fb
  194.   dcb &2a,&d3,&c4,&d1,&d0,&2f,&f8,&f9,&fa,&fb
  195.   dcb &2a,&d3,&d2,&d1,&c6,&2f,&f8,&f9,&fa,&fb
  196.   dcb &2a,&d3,&d2,&c5,&c6,&2f,&f8,&f9,&fa,&fb
  197.   dcb &2a,&d3,&c4,&c5,&c6,&2f,&f8,&f9,&fa,&fb
  198.   dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
  199.   dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
  200.  
  201. ;------ zOrOUtInEs ----------------------------------------------------------
  202. ; Draws (slowly) a 256 color box. It uses strB, is not clipped and dx shall
  203. ; not exceed boxmax_w. But it is tiny and StrongARM compatible.
  204. ; Parameters are...
  205. ;     r0 = screen adress.
  206. ;     r1 = filling pattern.
  207. ;     r2 = x1.    1------+
  208. ;     r3 = y1.    |      |
  209. ;     r4 = x2.    |      |
  210. ;     r5 = y2.    +------2
  211. .SlowBox256
  212.   sub       r4,r4,r2                ; r4=dx=x2-x1.
  213.   sub       r5,r5,r3                ; r5=dy=y2-y1.
  214.   add       r2,r0,r2                ; r2=screen+x1.
  215.   add       r3,r3,r3,lsl #2         ; r3=y1*5.
  216.   add       r2,r2,r3,lsl #6         ; r2=screen+x1+y1*320.
  217.   rsb       r3,r4,#320              ; r3=Nb of bytes to pass each line.
  218.   rsb       r4,r4,#boxmax_w-1       ; r4=nb of instructions to pass.
  219.   add       r4,pc,r4,lsl #2         ; r4=adress of first instruction.
  220.   mov       pc,r4                   ; And jump to it.
  221. #rept boxmax_w-1
  222.   strB      r1,[r2],#1              ; Draw one byte.
  223. #endr
  224.   strB      r1,[r2],r3              ; Draw one byte and next line.
  225.   subS      r5,r5,#1                ; One line drawn.
  226.   movGE     pc,r4                   ; Loop if there are lines left.
  227.   mov       pc,r14                  ; Done.
  228.