Videopac / Odyssey2 forum
December 08, 2022, 05:56:16 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: The forum will disappear in April 2023 please check this topic!
 
   Home   Help Login Register links videopac.nl  
Pages: 1 [2] 3 4   Go Down
  Print  
Author Topic: Ants! (a WIP)  (Read 20139 times)
Chris!
Give this man a Jopac!
******
Posts: 1310



WWW
« Reply #15 on: September 06, 2011, 11:57:45 PM »

What is the timer, and how do I use it to get random numbers?
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Chris!
Give this man a Jopac!
******
Posts: 1310



WWW
« Reply #16 on: September 08, 2011, 05:59:38 AM »

OK, let's forget that for now. Let's say I have an internal variable named iram_y. iram_y is set to begin at #068h. So, at the start, iram_y is at #068h, which is approximately the middle of the screen. So, with that in mind, how would I check to see if iram_y is at, well, let's just for now say, for the sake of example, #020h, and if it is, nudge it down a notch because it's at the top of the screen? I tried the following, which doesn't work:

Code:
check_up_point

mov r1,#iram_y ; y position
mov a,@r1 ; get it
anl a,#020h
jnz check_down_point

inc r3


check_down_point

I have figured out that increasing or decreasing r3 makes the player go up or down accordingly. I thought that if I moved #iram_y to a analyzable point that I could analyze it and then either increase or decrease r3 accordingly, but nooooo, that would be too easy...  Sad
My code can be downloaded at http://www.atari2600land.com/ants


Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #17 on: September 09, 2011, 04:24:51 PM »

I haven't checked your code yet, but it looks like the "anl a,#020h" needs to be replaced by "xrl a,#020h".
Logged
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #18 on: September 09, 2011, 04:46:30 PM »

What is the timer, and how do I use it to get random numbers?

The timer is a feature of the 8048 microcontroller. It's a countdown timer. It's clock frequency is the instruction cycle clock divided by 32. You start it with STRT T. Before starting it you can initialize it with MOV T,A , but for the random function you won't need that. You can read the value of the timer with MOV A,T . Some extra calculations will probably be required to get a good random value, but it would be best to first try which values you get.
Logged
Chris!
Give this man a Jopac!
******
Posts: 1310



WWW
« Reply #19 on: September 10, 2011, 01:59:51 AM »

Thanks for your help so far, I really appreciate it. Now, I have the ant moving to different spots on the screen when I touch it. How would I make it stay within the confines of the border? I moved the ant calling spot subroutine to its own thingy. It's called "ant_new_spot." And this is it:
Code:
ant_new_spot
; set sprite position for ant
mov r0,#vdc_spr1_ctrl
mov a,t ; y position
movx @r0,a
inc r0
mov a,t ; x position
movx @r0,a
inc r0
mov a,#col_spr_black
movx @r0,a
ret
I really enjoyed the samples on soeren.informationstheater.de I learn best when I tweak samples. I then can understand this means such-and-such and that means something else, etc. Link to my code and ROM is in my signature.
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Chris!
Give this man a Jopac!
******
Posts: 1310



WWW
« Reply #20 on: September 10, 2011, 04:56:19 AM »

By the way, I changed the border. I was having trouble activating the right wall since it was too far to the right, so I just said "To heck with it, I'll just make the area smaller." So I did.
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #21 on: September 10, 2011, 04:25:07 PM »

How would I make it stay within the confines of the border? I moved the ant calling spot subroutine to its own thingy. It's called "ant_new_spot." And this is it:
Code:
ant_new_spot
; set sprite position for ant
mov r0,#vdc_spr1_ctrl
mov a,t ; y position
movx @r0,a
inc r0
mov a,t ; x position
movx @r0,a
inc r0
mov a,#col_spr_black
movx @r0,a
ret

The easiest way would be to limit the range to 080h and add an offset, but it won't match your current playfield exactly:
Code:
mov a,t
anl a,#07fh  ; you will only get values from 00 to 7F
add a,#025h ; add offset (use 00dh for X offset)
movx @r0,a
Logged
Chris!
Give this man a Jopac!
******
Posts: 1310



WWW
« Reply #22 on: September 10, 2011, 06:09:49 PM »

Thanks. Now, what is causing the blue things next to the score that I call "half-zeroes," because they look like it, and how would I get rid of them?
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #23 on: September 10, 2011, 10:09:50 PM »

You have use two quads for the score. A quad is a row of 4 characters. The space between these characters is fixed in a quad, therefore usually two quads are interleaved (like in your game). You have used the last two characters of each quad for the score, but you haven't initialized the first two characters of these quads. You should put spaces in them.
Logged
Chris!
Give this man a Jopac!
******
Posts: 1310



WWW
« Reply #24 on: September 11, 2011, 01:50:58 AM »

I thought they WERE initialized:
Code:
init_score:
; preset x positions (they are fixed in my program)
mov r3,#50 ; quad 0 xposition
mov r4,#202 ; quad 0 and 1 yposition

mov r0,#quad0 ; pointer to quad0 vdc
call store_r3r4 ; I made this a subroutine as it is used so often here

mov r0,#quad0+004h ; next character in quad
call store_r3r4

mov r0,#quad0+008h ; and the next
call store_r3r4

mov r0,#quad0+00ch ; and another
call store_r3r4

mov r3,#58 ; quad 1 xposition (8 pixels further to interleave)

mov r0,#quad1 ; pointer to quad1 in vdc
call store_r3r4

mov r0,#quad1+004h ; next character in quad
call store_r3r4

mov r0,#quad1+008h ; and the next
call store_r3r4

mov r0,#quad1+00ch ; and another one
call store_r3r4

ret

store_r3r4:
mov a,r4
movx @r0,a ; store it
inc r0
mov a,r3
movx @r0,a
ret
If this doesn't do it, then how do I initialize them?
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #25 on: September 12, 2011, 12:17:08 AM »

For each quad, X and Y only need to be initialized once, so you can remove 3 of the 4 store_r3r4 calls.
But it's important that all unused characters of a quad contain spaces. This requires some calculation, so it's best to use a BIOS routine for that. Register R4 should contain the Ypos of the quad. In your program you could do:
Code:
mov r0,#quad0+002h  ; pointer to first character byte of quad0
mov r5,#00ch ; code for character "space"
call 0261h ; convert character code and store in VDC
mov r0,#quad0+006h ; pointer to second character byte of quad0
mov r5,#00ch
call 0261h
This should be repeated for quad1.
Normally register R6 should contain the color, but for a space it won't matter.
Logged
Chris!
Give this man a Jopac!
******
Posts: 1310



WWW
« Reply #26 on: September 12, 2011, 01:09:46 AM »

Success! I got those stupid half-zeroes off the screen. Now, I'd like some suggestions for what to do next to the game. As it stands right now, it's pretty boring going around chasing ants with no way to die. Should I put in an enemy that chases you, or a timer, or what? By the way, I wonder why the guy providing the original sample code decided to initialize all eight characters.
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
gertk
Post Axe Pete!
*****
Posts: 868



gertk64
WWW
« Reply #27 on: September 12, 2011, 07:38:17 AM »

Success! I got those stupid half-zeroes off the screen. Now, I'd like some suggestions for what to do next to the game. As it stands right now, it's pretty boring going around chasing ants with no way to die. Should I put in an enemy that chases you, or a timer, or what? By the way, I wonder why the guy providing the original sample code decided to initialize all eight characters.

The quad characters are spaced apart a character so with just one quad it would look like:

A B C D

Which is not so nice for a score counter (it would look just like 4 single numbers)

With the two quads interleaved the gaps are filled with the other quad
(ABCD are in the first quad and EFGH in the second)


AEBFCGDH

But then you have to do some more work to get the score into CGDH  (and use AEBF for something else or just blanks) but the end result looks better.

In my Omega Race startup http://videopac.nl/forum/index.php?topic=1598.0 in the center box I used 4 quads for displaying the number of ships left (4 positions), the current score (3 positions) and the hi-score (2 + 5 positions) so that is quite a bit of interleaving.. Roll Eyes

But anyway, great that you figured it out!
 
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Chris!
Give this man a Jopac!
******
Posts: 1310



WWW
« Reply #28 on: September 12, 2011, 09:43:08 AM »

Well, I need help again. I decided the route to go is to have an ant bounce around inside the borders of the screen. This ant is called the "tan ant" both in the game and in the code. ("tan" is an anagram of "ant". Also, I renamed the little green guy Stan, which is an anagram of "ants".) I tried to move it around by myself but I just couldn't do it. It just kept flashing on different parts of the screen, so I just deleted the code that made it do that. I think even getting a third sprite on the screen is a success for me, but darned if I know how to make it bounce around the screen. Code is attached.
Logged

All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html
Rafael
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2838



« Reply #29 on: September 16, 2011, 03:19:57 AM »

The new ants looks better. Maybe you can think about some strategy game, like ants armys defending their anthill, or something like take the ants safely to its nest.
Logged

Pages: 1 [2] 3 4   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!