Jump to content

Photo

Batari Basic Question


11 replies to this topic

#1 TidusRenegade OFFLINE  

TidusRenegade

    Space Invader

  • 30 posts

Posted Fri Apr 6, 2018 3:33 PM

Hi all

 

I've been having a go with Batari Basic and I've found a strange bug with my game that I don't know whether it is a limitation of the engine or something I'm doing stupid!

 

I'm trying to scroll the enemy player from right to left and when it reaches the left-hand side of the screen, restart from the right at a random y position.

 

It works - but sometimes, when the enemy sprite is scrolling right to left, it goes all the way to the side of the screen and sometimes it only gets 2/3s of the way there and then restarts.

 

I used the code:

 if l=1 || player1x=0 then player1x=150: player1y=(rand&76)+9: goto jump2
 player1x=player1x-1
 
Note l is just the loop iteration so starts the enemy sprite moving on first iteration
 
player1 coordinates are not in the code anywhere else other than the initial locations which are outside of the game loop and defined up with the variables.
 
Any idea why this is happening?
 
Thanks for any help
TR
 


#2 TidusRenegade OFFLINE  

TidusRenegade

    Space Invader

  • Topic Starter
  • 30 posts

Posted Fri Apr 6, 2018 4:00 PM

Attached some example code

 

I've cut it down to the bear-minimum and its still occuring

 

 

Attached Files



#3 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Fri Apr 6, 2018 5:25 PM

When l gets (up) to 1 player1x gets reset



#4 TidusRenegade OFFLINE  

TidusRenegade

    Space Invader

  • Topic Starter
  • 30 posts

Posted Sat Apr 7, 2018 2:39 AM

But l only ever equals 1 once in the example code - doesn’t it?
Is there a maximum value for variables at which point they loop back to zero? That would explain it

Thanks for the response btw

#5 TidusRenegade OFFLINE  

TidusRenegade

    Space Invader

  • Topic Starter
  • 30 posts

Posted Sat Apr 7, 2018 3:13 AM

Yep that was it, l was looping. So simple d'oh!

Thanks



#6 TidusRenegade OFFLINE  

TidusRenegade

    Space Invader

  • Topic Starter
  • 30 posts

Posted Sun Apr 8, 2018 3:00 AM

Actually can somebody please help again - I'm tearing my hair out with this!
 
So using the example above, I added a title screen - and that worked fine, but now I need to add more enemy sprites to make the game that I want to so I need to use either the multisprite kernel or DPC+
 
I got DPC+ working but the screen area shrunk dramatically and the missile for player0 did not work all of the time - and when it did work it was extremely flickery. I tried to change the screensize using DFxFRACINC but that seems to be more related to playfields than the screen size itself (not sure if I've got that right?). Is there any way to change the screensize to what it was pre-DPC+?
 
So I tried multisprite kernel and came to conclusion that it won't work with title screens created with the title screen editor (?). So after ripping out my title screen, I'm still failing to compile my code and I'm now getting the error:
2600 Basic compilation failed!
LINE -->  set kernel multisprite
--VERBOSE ERROR MESSAGE --
batari Basic v1.01dreveng40 ©2005-2017
Cannot open multisprite.inc for reading

 

I'm using BB.1.1d.reveng40.zip which had worked fine up until this point. I did try using 1.0 instead but that didn't work either.

 

I'm sure I'm doing something stupid but I'm not sure what!! Could anyone please help?

 

Thanks in advance for any help



#7 Mountain King OFFLINE  

Mountain King

    Dragonstomper

  • 679 posts
  • Location:Philadelphia, PA

Posted Sun Apr 8, 2018 8:36 AM

Can you post your code?



#8 TidusRenegade OFFLINE  

TidusRenegade

    Space Invader

  • Topic Starter
  • 30 posts

Posted Sun Apr 8, 2018 9:14 AM

This is my latest - might be a little bit of a mess as I was trying a lot of things to get it working 

Attached Files


Edited by TidusRenegade, Sun Apr 8, 2018 9:15 AM.


#9 Mountain King OFFLINE  

Mountain King

    Dragonstomper

  • 679 posts
  • Location:Philadelphia, PA

Posted Sun Apr 8, 2018 11:08 AM

I didn't see anything in this code that referred to the DPC+ code. You did have some typos I fixed and Your ship controls seem to be reversed. Do you have the DPC+ code?

Attached Files



#10 TidusRenegade OFFLINE  

TidusRenegade

    Space Invader

  • Topic Starter
  • 30 posts

Posted Sun Apr 8, 2018 12:01 PM

Thank you Mountain King - that seems to compile now and has the multisprite kernel so hopefully that means I can this idea of a game working.

However for some reason I seem to have lost the asteroid on screen in your fixed version, not sure why - I'll have a good look through the code.

 

As for the DPC+ version, I was supposed to attach that as well. I did get that working but the screen size became very small I couldn't find a way to push it back to the standard 88 rows resolution.

It should be attached now.

 

Thanks again for your help on this.

Attached Files



#11 bogax OFFLINE  

bogax

    Dragonstomper

  • 761 posts

Posted Sun Apr 8, 2018 2:00 PM

 
  Mountain King's version of mutisprite
 
  Added rand16
  _COLUP1 instead of COLUP1
  player1x<9
  player1y = (rand&63)+16 
  moved JUMP2
 
 
  bytes are 8 bits
 
  bits 0..7 (right to left) are powers of 2
  2^0 = 1
  2^1 = 2
  2^2 = 4
  2^3 = 8
  etc
 
  AND is (bits) 
 
  0 AND 0 = 0
  0 AND 1 = 0
  1 AND 0 = 0
  1 AND 1 = 1
 
  & is a bitwise AND (bytes a & b = c, bits a0 AND b0 = c0, a1 AND b1 = c1, etc) 
 
  63 = 00111111 = 32 + 16 + 8 + 4 + 2 + 1
  76 = 01001100 = 64 + 8 + 4
 
  you'll only get a bit where you've got two ones
  so ANDing something with 76 will only give you numbers
  that are the sum of three of 64, 8, 4, 0, 0, 0 (the corresponding power of 2 or 0, for each bit)
  that's 8 different possibilities (3 bits set, 2^3 = 8 possibilities)
 
 
 

Attached Files



#12 TidusRenegade OFFLINE  

TidusRenegade

    Space Invader

  • Topic Starter
  • 30 posts

Posted Mon Apr 9, 2018 11:13 AM

Thank you so much Bogax, thats exactly what I was looking for

Really appreciate the help

 

Hopefully I can start making something decent now






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users