News:

The forum will NOT disappear in April 2023 please check this topic!

Main Menu

Ants! (a WIP)

Started by Chris!, March 22, 2011, 06:48:37 AM

Previous topic - Next topic

Chris!

What is the timer, and how do I use it to get random numbers?
All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html

Chris!

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:

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...  :(
My code can be downloaded at http://www.atari2600land.com/ants


All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html

Rene_G7400

I haven't checked your code yet, but it looks like the "anl a,#020h" needs to be replaced by "xrl a,#020h".

Rene_G7400

Quote from: Chris! on September 06, 2011, 11:57:45 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.

Chris!

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:

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.
All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html

Chris!

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.
All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html

Rene_G7400

Quote from: Chris! on September 10, 2011, 01:59:51 AM
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:

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:

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


Chris!

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?
All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html

Rene_G7400

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.

Chris!

I thought they WERE initialized:

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?
All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html

Rene_G7400

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:

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.

Chris!

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.
All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html

gertk

Quote from: Chris! 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.

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 https://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.. ;:)

But anyway, great that you figured it out!
>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<

Chris!

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.
All my Odyssey2 projects, now in one place!
http://www.atari2600land.com/odyssey2.html

Rafael

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.