home *** CD-ROM | disk | FTP | other *** search
- ; \|/
- ; O O
- ; --------------------------------oOO--U--OOo--------------------------------
- ; - -
- ; - - zOArcnOId - -
- ; - © Alain BROBECKER (baah/Arm'sTeack) -
- ; - 29th Sept 96 -
- ; ---------------------------------------------------------------------------
- ;
- ; This game is decicated to MJJ-Prods, a cool crew (Atari ST) which has
- ; developped the concept of zOgAIms... Hi BigFoot, Biro... (Though I' ve not
- ; preserved the original spirit, I hope you' ll like this one =)
- ;
- ; This source is given for free and is widely commented, so I hope some
- ; people will look at it and (maybe) improve their own code. Re-use of my
- ; routines is allowed (though not recommended, cos you' ll understand more
- ; if you write your owns...) as long as it is not for commercial purposes,
- ; as long as you credit me and send me a free copy of your proggy. Oh, btw
- ; the assembler I used is ExtASM 0.50b. You' ll have to make changes in
- ; macros if you use a newer version of ExtASM.
- ;
- ; Hey, that' s no difficult game (except maybe for TRizOiDS=zO) and some
- ; will say it' s no game at all. I quite agree, but coding it was so fun! =)
- ; Don' t hesitate to contact me if you write another zOgAIm, I like them
- ; so much. (zOspAcEInvAdErs would be welcome =)
- ;
- ; Alain BROBECKER Dracula / Positivity (STe)
- ; rte de Dardagny baah / Arm's Tech (Archie)
- ; 01630 CHALLEX baah (PC)
- ; FRANCE
-
- #name zOArcnOId ; zOgAIm forever...
-
- ;------ zOcOnstAnts ---------------------------------------------------------
- #set boxmax_w = 28 ; Max width for box routine.
- #set bat_w = 27 ; bat_width-1.
- #set bat_h = 4 ; bat_height-1.
- #set bat_color = &ff ; Color for bat.
- #set ball_s = 7 ; ball_size-1.
- #set ball_color = &d0 ; Ball color.
- #set nb_lines = 10 ; Nb of lines of blocks.
-
- ;------ zOcOdE --------------------------------------------------------------
- .proggy_start
- swi 256+22 ; Vdu 22, set screenmode.
- swi 256+13 ; Switch to mode 13.
- swi OS_RemoveCursors ; Who needs them?
- adr r0,vram_adress ; Get videoram adress.
- mov r1,r0
- swi OS_ReadVduVariables
- ; At first we draw the blocks on screen, with the good color.
- ldr r0,vram_adress
- mov r6,#320-16 ; r6=blockx.
- mov r7,#16*(nb_lines-1) ; r7=blocky.
- adr r8,blocks ; Contain blocks' colors. (0=no block)
- .init_one_block
- ldrB r1,[r8],#1 ; Load block color.
- add r2,r6,#1 ; r2=x1.
- add r3,r7,#1 ; r3=y1.
- add r4,r2,#14 ; r4=x2.
- add r5,r3,#14 ; r5=y2.
- bl SlowBox256 ; Draw block.
- subS r7,r7,#16 ; Next blocky.
- addMI r7,r7,#16*nb_lines ; If negative, then reinit blocky,
- subMIS r6,r6,#16 ; and next blockx.
- bPL init_one_block ; Finished if blocky<0 and blockx<0.
- ; Some other inits, called each time the player dies. We' ll have...
- ; r8=scotch_flag, r9=batx, r10=ballx, r11=bally, r12=incx, r13=incy.
- mov r9,#0 ; batx=0.
- .triso_player
- mov r8,#0 ; Ball scotched.
- add r10,r9,#2 ; Initial position for scotched ball.
- mov r11,#254-bat_h-ball_s-3
- mov r12,#-1 ; incx=-1.
- mov r13,#-1 ; incy=-1.
- .playing_aRCNoiD
- mov r0,#&13 ; Wait for Vsync.
- swi OS_Byte
- ; Clear the bat and ball we have drawn previous VBl.
- ldr r0,vram_adress
- mov r1,#0
- mov r2,r9 ; r2=old_batx1.
- mov r3,#254-bat_h ; r3=old_baty1.
- add r4,r2,#bat_w ; r4=old_batx2.
- add r5,r3,#bat_h ; r5=old_baty2.
- bl SlowBox256 ; Clear bat.
- mov r2,r10 ; r2=old_ballx1.
- mov r3,r11 ; r3=old_bally1.
- add r4,r2,#ball_s ; r4=old_ballx2.
- add r5,r3,#ball_s ; r5=old_bally2.
- bl SlowBox256 ; Clear the ball.
- ; Check bat' s movements from mouse and draw it.
- swi OS_Mouse ; r0=mousex | r2=mousek.
- orr r8,r8,r2 ; scotch_flag<>0 if mousek<>0.
- mov r9,r0,lsr #2 ; r9=new bat position.
- cmp r9,#319-bat_w ; Right edge bounding.
- movGE r9,#319-bat_w
- ldr r0,vram_adress ; Draw the bat.
- mov r1,#bat_color ; r1=bat color.
- mov r2,r9 ; r2=batx1.
- mov r3,#254-bat_h ; r3=baty1.
- add r4,r2,#bat_w ; r4=batx2.
- add r5,r3,#bat_h ; r5=baty2.
- bl SlowBox256 ; Draw it.
- ; Compute ball mvts, test collisions with the bat and draw it.
- cmp r8,#0 ; scotch_flag=0?
- addEQ r10,r9,#2 ; Yup, ball is scotched to the bat,
- bEQ draw_ball ; and so we have no other mvts.
- addS r10,r10,r12 ; ballx+=incx.
- cmpNE r10,#319-ball_s ; Flags=x-(319-ball_s).
- rsbEQ r12,r12,#0 ; If x=0 or x=(319-ball_s), then incx-=incx.
- addS r11,r11,r13 ; bally+=incy.
- rsbEQ r13,r13,#0 ; If y=0, then incy-=incy.
- cmp r11,#254-bat_h-ball_s ; Possible collision with bat?
- bLT draw_ball ; No, then no more tests...
- cmp r11,#254-ball_s ; We have reached bottom of screen?
- bEQ triso_player ; Lost, what a trisoid! =)
- add r1,r10,#ball_s ; r1=ball_xright.
- add r2,r9,#bat_w ; r2=bat_xright.
- cmp r1,r9 ; Flags=ball_xright-bat_xleft.
- cmpGE r2,r10 ; If >=0, flags=bat_xright-ball_xleft.
- movGE r13,#-1 ; If >=0, we have a collision.
- addGE r11,r11,r13 ; bally+=incy.
- .draw_ball
- mov r1,#ball_color ; r1=ball color.
- mov r2,r10 ; r2=ballx1.
- mov r3,r11 ; r3=bally1.
- add r4,r2,#ball_s ; r4=ballx2.
- add r5,r3,#ball_s ; r5=bally2.
- bl SlowBox256 ; Draw ball.
- ; Perform the collisions between ball and blocks.
- mov r5,#320-16 ; r5=blockx.
- mov r6,#16*(nb_lines-1) ; r6=blocky.
- adr r7,blocks ; Contains block colors. (0=no blocks)
- .test_one_collision
- ldrB r14,[r7],#1 ; Load block color.
- cmp r14,#0 ; Is it null?
- bEQ next_collision ; Then we have no block here.
- add r0,r10,r12 ; r0=ballx+incx.
- add r1,r11,r13 ; r1=bally+incy.
- add r2,r0,#ball_s-1 ; r2=ballx+incx+ball_s-1.
- add r3,r1,#ball_s-1 ; r3=bally+incy+ball_s-1.
- add r4,r5,#15 ; r4=blockx+15.
- add r14,r6,#15 ; r14=blocky+15.
- cmp r0,r4 ; Flags=ballx+incx-(blockx+15).
- cmpLE r1,r14 ; Flags=bally+incy-(blocky+15).
- cmpLE r5,r2 ; Flags=blockx-(ballx+incx+ball_s-1).
- cmpLE r6,r3 ; Flags=blocky-(bally+incy+ball_s-1).
- bGT next_collision ; If one result>0, no collision.
- cmp r0,r4 ; Flags=ballx+incx-(blockx+15).
- cmpNE r5,r2 ; Flags=blockx-(ballx+incx+ball_s-1).
- rsbEQ r12,r12,#0 ; If one result=0, then change incx.
- cmp r1,r14 ; Flags=bally+incy-(blocky+15).
- cmpNE r6,r3 ; Flags=blocky-(bally+incy+ball_s-1).
- rsbEQ r13,r13,#0 ; If one result=0, then change incy.
- str r5,vram_adress+4 ; Save blockx.
- ldr r0,vram_adress
- mov r1,#0
- strB r1,[r7,#-1] ; Block does no exist anymore.
- add r2,r5,#1 ; r2=blockx1.
- add r3,r6,#1 ; r3=blocky1.
- add r4,r2,#14 ; r4=blockx2.
- add r5,r3,#14 ; r5=blocky2.
- bl SlowBox256 ; Clear block.
- ldr r5,vram_adress+4 ; Restore blockx.
- .next_collision
- subS r6,r6,#16 ; Next blocky.
- addMI r6,r6,#16*nb_lines ; If negative, then reinit blocky,
- subMIS r5,r5,#16 ; and next blockx.
- bPL test_one_collision ; Finished if blocky<0 and blockx<0.
- ; Finished, it was short and good.
- swi OS_ReadEscapeState ; Escape key pressed?
- bCC playing_aRCNoiD ; No, then loop.
- swi OS_Exit ; What, game not good enough for you?
-
- ;------ zOdAtAs -------------------------------------------------------------
- ; vram_adress+4 is used as temporary storage.
- .vram_adress dcd 148,-1 ; Values for the swi.
- .blocks ; Colors for each blocks. (zO!)
- dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
- dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
- dcb &2a,&d3,&c4,&d1,&d0,&2f,&2e,&2d,&2c,&fb
- dcb &2a,&d3,&c4,&d1,&d0,&2f,&2e,&2d,&2c,&fb
- dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
- dcb &2a,&2b,&d2,&d1,&d0,&2f,&2e,&2d,&fa,&fb
- dcb &2a,&d3,&d2,&d1,&d0,&2f,&2e,&2d,&2c,&fb
- dcb &2a,&d3,&c4,&c5,&c6,&c7,&f8,&f9,&2c,&fb
- dcb &2a,&d3,&c4,&c5,&c6,&c7,&f8,&f9,&2c,&fb
- dcb &2a,&d3,&d2,&d1,&d0,&2f,&2e,&2d,&2c,&fb
- dcb &2a,&2b,&d2,&d1,&d0,&2f,&2e,&2d,&fa,&fb
- dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
- dcb &2a,&d3,&c4,&c5,&c6,&2f,&f8,&f9,&fa,&fb
- dcb &2a,&d3,&c4,&c5,&d0,&2f,&f8,&f9,&fa,&fb
- dcb &2a,&d3,&c4,&d1,&d0,&2f,&f8,&f9,&fa,&fb
- dcb &2a,&d3,&d2,&d1,&c6,&2f,&f8,&f9,&fa,&fb
- dcb &2a,&d3,&d2,&c5,&c6,&2f,&f8,&f9,&fa,&fb
- dcb &2a,&d3,&c4,&c5,&c6,&2f,&f8,&f9,&fa,&fb
- dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
- dcb &2a,&2b,&c4,&c5,&c6,&c7,&f8,&f9,&fa,&fb
-
- ;------ zOrOUtInEs ----------------------------------------------------------
- ; Draws (slowly) a 256 color box. It uses strB, is not clipped and dx shall
- ; not exceed boxmax_w. But it is tiny and StrongARM compatible.
- ; Parameters are...
- ; r0 = screen adress.
- ; r1 = filling pattern.
- ; r2 = x1. 1------+
- ; r3 = y1. | |
- ; r4 = x2. | |
- ; r5 = y2. +------2
- .SlowBox256
- sub r4,r4,r2 ; r4=dx=x2-x1.
- sub r5,r5,r3 ; r5=dy=y2-y1.
- add r2,r0,r2 ; r2=screen+x1.
- add r3,r3,r3,lsl #2 ; r3=y1*5.
- add r2,r2,r3,lsl #6 ; r2=screen+x1+y1*320.
- rsb r3,r4,#320 ; r3=Nb of bytes to pass each line.
- rsb r4,r4,#boxmax_w-1 ; r4=nb of instructions to pass.
- add r4,pc,r4,lsl #2 ; r4=adress of first instruction.
- mov pc,r4 ; And jump to it.
- #rept boxmax_w-1
- strB r1,[r2],#1 ; Draw one byte.
- #endr
- strB r1,[r2],r3 ; Draw one byte and next line.
- subS r5,r5,#1 ; One line drawn.
- movGE pc,r4 ; Loop if there are lines left.
- mov pc,r14 ; Done.
-