Jump to content
IGNORED

Writing More of My First Lines of Code in Batari Basic - Night Driver Arcade


Recommended Posts

Paddle or Joystick?

 

Spoiler

image.jpeg.e1cbac21001b2e3c5cb539c80aea8b9f.jpeg Night Driver arcade version (Atari, 1976)

0001paddles_400x301.jpg.f93a313475d5e4adc7be04ad393e8abb.jpg Paddle 

The road markers are all the same height - you lose the 3D perspective

 

0001joystick_400x300.jpg.67f8dc2e7d71aa39d31d65e1909a72c9.jpg Joystick + pfheights

The road markers vanish into the distance - strong 3D perspective

 

According to RT's Guide, you cannot have paddle controls and pfheights at the same time.  (kernel options chart)

I was really hoping to use paddles, but for this project I'll probably go with the joystick just because IMO it looks so much better.  

0001_paddles.bas 0001_paddles.bas.bin

0001_joystick.bas0001_joystick.bas.bin 

  • Like 1
Link to comment
Share on other sites

 Joystick Controls

 

Spoiler

The arcade version of Night Driver had a steering wheel, a gas pedal and an up/down gear shifter with four gears.  

 

Spoiler

image.thumb.jpeg.948cceb444c88823103de3bb09885eb9.jpeg

 

Proposed Joystick Controls for Atari 2600 Night Driver Arcade

 

JN = joystick neutral, JL = joystick left, JR = joystick right, JU = joystick up, JD = joystick down

BU = button up, BD = button down

 

On Game Reset, start in gear 1 at 0 mph

 

BU and JN first, then JU-and-release = shift up one gear

BU and JN first, then JD-and-release = shift down one gear

 

BU and JN first, then...

  • JU = gas and add BD for more gas
  • JD = brake and add BD for more brake
  • JL = turn left and add BD to turn left harder
  • JR = turn right and add BD to turn right harder

 

Kernel

 

Spoiler

Actually, if we're not using the paddle, then we can choose any kernel.  I'll probably choose the 8k Super Chip for more RAM and more options.  

 

Link to comment
Share on other sites

On 9/15/2010 at 8:35 PM, ComputerSpaceFan said:

I really like the original coin-op version of Night Driver and I always felt the 2600 cartridge was a bit disappointing. No offence to Rob Fullop, he did a heck of a lot with what the 2600 had to offer, but any similarity between the coin-op version and the cartridge version is pretty distant.

 

Two questions:

 

1) Would the 2600 be capable of displaying the white road markers as smoothly as the coin-op machine did? I mean, that arcade unit didn't show much in the way of graphics but what it did show was silky smooth for frame rate and such.

 

2) Would it be possible to make the game work with paddles in the Player 1 slot for steering and a joystick in Player 2 slot for switching gears?

 

Failing that, Enduro and Pole Position aren't playable with paddles are they? Or is there a hack out there to make them work with paddles?

Well, as a Batari Basic newbie, I'm not qualified to answer these questions.  I can only talk about my project.  

 

Spoiler

1) In my project here, so far, I'm still looking into that, but that is certainly what I would want if I could do it!  

 

2) That's an interesting idea using a paddle for steering and a joystick for shifting.  I'll keep it in mind!  

 

@ComputerSpaceFan Thank you for your comment.  And thanks for the encouragement and good luck!  

Link to comment
Share on other sites

Let's Try the Paddle Again

 

Spoiler

@ComputerSpaceFan's comment about getting the white road markers to move smoothly got me thinking.  

 

New Proposal

  • Use the basic kernel with no options (so as to retain use of Missile0 and Missile1)
  • Now you have the ball, 2 missiles and P1 sprites to use to draw white road markers.
  • Now you don't need a playfield.  Just a black background.
  • Now that you are using the basic kernel again, we can use paddle controllers again
  • The white road markers, being sprites, can now be moved smoothly.

Sprite Management

 

Situation A: The Road Is Straight

 

Then you will have 4 pairs of white road markers + 1 on the horizon.   

 image.jpeg.8fc7a86df919591af9c7339e04c1112b.jpeg

  • Your car sprite P0 (your car) will be used to draw the white road marker on the horizon using flicker.
  • The four white road markers on one side of the road with be drawn using missile0, missile1, the ball and P1 sprites.
  • On alternate frames, missile0, missile1, the ball and P1 sprites will be used to draw the white road markers on the opposite side of the road using flicker.  
  • Thus, all nine white road markers (and your car) will all be drawn every other frame using flicker.  

Situation B: The Road Is Curved

 

When the road curves enough so that either one of the two white road markers at the bottom disappear off the side of the screen, then

 

image.jpeg.b8e268062542e59674e1bf06cb6ffa2d.jpeg

  • The white road marker on the horizon is moved to the bottom row.  It is still drawn using P0 (your car) using flicker.  
  • The other four white road markers on one side of the road will again be drawn by missile0, missile1, the ball and P1.
  • Again, on alternating frames, missile0, missile1, the ball and P1 will be used to draw the white road markers on the opposite side of the road using flicker.  
  • Thus, again, all nine white road markers (and your car) will all be drawn every other frame using flicker.  

Summary 

 

Thus, whether the road is straight or curved, there will always be nine white road markers.  One is always drawn with flicker using your car's P0 sprite.  The other 8 are always drawn, using flicker, using the 2 missiles, ball and P1 sprites.  Thus, every white road marker is always drawn every other frame and your car is always drawn every other frame.  

 

Controls

 

Spoiler
  • Simple paddle control like in Atari 2600 Night Driver.  
  • The possibility of using Player 2's joystick for shifting.  
Link to comment
Share on other sites

I'm an ASM guy, but if I were doing this game, the static yellow block of a car would be drawn with PF using the mirroring feature, and you would have both players, both missiles, and the ball free....  You could do really nice overlapping markers and get VERY close to the original.

Edited by glurk
Misspelling
  • Thanks 1
Link to comment
Share on other sites

Sprite/Flicker Management - Rotations

 

Spoiler

As I think about it some more, a better way to manage sprites/flicker might be to set up a rotation for drawing the sprites.

 

Generally, I think it would work like this.  Make a list of all the objects that you want to draw on the screen.  Next, make a list of all the sprites available to use to draw them.  Finally, assign the objects to be drawn to the available sprites in a rotation, calling drawscreen after each rotation.  

 

Example.

Suppose there are 10 white road markers to be drawn on the screen.  

Further, we have 3.5 sprites available with which to draw them.  

They are missile1, the ball, the P1 sprite every frame and the P0 sprite every other frame.  

 

So, our rotations might look like this:

 

Frame 1: 

missile1 - draw white road marker 1

the ball - draw white road marker 2

P1 - draw white road marker 3.  

drawscreen

 

Frame2:

missile1 - draw white road marker 4

the ball - draw white road marker 5

P1 - draw white road marker 6  

P0 - draw white road marker 7

drawscreen

 

Frame 3: 

missile1 - draw white road marker 8 

the ball - draw white road marker 9 

P1 - draw white road marker 10 

Call the subroutine to update the list of 10 items to be drawn. 

drawscreen

 

Note: The P0 sprite is available every other frame to draw white road markers.  On the alternate frames it is used to draw the player's car.  

Link to comment
Share on other sites

Night Driver Arcade - Paddle & Flicker Version 

 

Spoiler

The Concept:

  • The white road markers are made from the missile1 and the ball sprites and will be drawn in a rotation using flicker.
  • There will be two digital displays at the top of the screen.  Current speed in mph in the top left corner and time remaining in seconds in the top right corner.  They, along with the player's car, will be drawn using the P0 and P1 sprites in a rotation using flicker.  
  • The total distance traveled (AKA your score) in miles will be displayed using the bB 6-digit score area at the bottom of the screen.  

image.jpeg.3b89cfd298a088bf15c6e98e7fa412f6.jpeg

 

Parallel Processes

 

In the Main Loop, there will be parallel processes going on separately, at the same time, but not in sync with each other.  (They each can begin and end separately.)

 

PP #1: White Road Markers

  • Do some calculations.  Make a list of all of the white road markers to be drawn on the screen w/ x-y coordinates for each.
  • Next, assign missile1 and the ball to the items in the list in a rotation until all of the items have been drawn over the course of a few frames.
  • Make an updated list and repeat.  

PP #2: Speed, Time Remaining and Your Car

  • Do some calculations.  Find the player's current speed in mph and the time remaining in seconds.  Speed can be 1, 2 or 3 digits.  Time remaining can be 1 or 2 digits (99 seconds max).  
  • Make a list of all of the objects that need to be drawn.  Ex.  In the picture, above, speed is 126 mph, time remaining is 99 seconds.  Therefore, the 6 objects on the list would be: 1, 2, 6, 9, 9 and the players orange car.  
  • Next, assign P0 and P1 to the objects on the list in a rotation until all of the items have been drawn over the course of a few frames.    
  • Update the calculations and make a new list.  Repeat.

PP #3: Total Distance Travelled

  • Calculate the player's total distance travelled and update its value in the 6-digit display.
  • Repeat.  

 

Rates of Flicker

  • White Road Markers: If 6 white road markers need to be drawn, we have 2 things with which to draw them (missile1 and the ball).  Then the ratio is 3:1.  If the game is running at 60 frames per second, then the white road markers would be flickering at 20 fps.  
  • Digital Score Display and Your Car: Max 6 objects to be drawn and 2 things with which to draw them (P0 and P1 sprites).  The ratio is 3:1 and the flicker rate would be 20 fps.  
Link to comment
Share on other sites

"Falling" White Road Markers - A Kaboom! Analogy

 

Spoiler

During game play, pairs of white road markers are continuously "falling down" until they "fall off" the bottom of the screen.  The road "turns" when the point of origin of the pairs of white road markers on the horizon shifts left or right.  

 

Think of the game Kaboom!  The Mad Bomber is always dropping bombs.  The bombs fall straight down from the locations where the Mad Bomber dropped them.  

 

When the Mad Bomber is stationary, the bombs form a straight line.  This is like a straight section in the road in Night Driver.  

Straightdown_400x268.jpg.dec171aaf2891142dd44958a898b355c.jpg The Mad Bomber is stationary.  This is like a straight road.  

 

But when the Mad Bomber is moving left or right, the bombs can form a curve.  Actually, nothing is "curved."  The path of each bomb is always straight down.  It's kind of an illusion that there is a "curve."  Anyway, this is like a bend in the road in Night Driver.  

 rightturn_400x267.jpg.881d43b6fd33dc760eb6acf0ccd030f7.jpg The Mad Bomber moves right.  This is like a road turning right.  

 leftturn_400x266.jpg.fb93c4ab3c1beb00884ec8942926acc8.jpg The Mad Bomber moves left.  This is like a road turning left.  

 

I used Darell Spice, Jr.'s Kaboom Deluxe to control the Mad Bomber to make these screenshots.  

Link to comment
Share on other sites

9 hours ago, Living Room Arcade said:

@glurk I think I understood what you said.  That is a good suggestion, I think.  Thanks!  Except, what did you mean by "overlapping markers?"

The most distant road markers overlap each other vertically during turns as part of the 3D depth effect.  You can see this in videos of the original game.

 

I was thinking in terms of a purpose-built assembly code kernel, which is how I would do the game.  This idea is probably not possible in Batari.

 

For the car, it just seems WASTEFUL to use 2 sprites to draw it.  Since it is static and unmoving, and you were using wide pixels, might as well draw it with PF and take advantage of the automatic mirroring.  This one is just a no-brainer to me.

 

But I am aware that Batari has certain limitations that must be accomodated...  I only do ASM coding....

 

EDIT TO ADD:

 

I think a very fine version of this game could be don in assembly, too.  But I am not volunteering, LOL.  I had never really thought about it until I saw these recent threads.....

Edited by glurk
  • Like 1
Link to comment
Share on other sites

@glurk  Thanks for the clarification about the overlapping markers.  About using the PF to draw the car.  Here are two issues.  One, the PF is only 11x32.  Those are some big pixels!  Two, the ball will be the same color as the PF.  So, if the car is yellow, we will end up with some yellow road markers that were drawn using the ball.     

 

@ComputerSpaceFan  Me too!  Thanks for the encouraging words!  

Link to comment
Share on other sites

White Road Markers - Flicker Tests

 

Spoiler

We lose missile0 when we choose the paddle kernel options.  

Using missile1 and the ball, we test the flicker with 6 and 8 white road markers.  

 

6 stationary white road markers - flicker test

0002_paddles_6_stationary.bas

0002_paddles_6_stationary.bas.bin

 

8 stationary white road markers - flicker test

0002_paddles_8_stationary.bas

0002_paddles_8_stationary.bas.bin

 

With phosphor turned on (hit Alt+p in Stella), it looks better.  

 

So far, it seems that a 1:3 ratio of sprites to objects results in acceptable flicker.  

Link to comment
Share on other sites

Design Update - Adjusting for the Loss of Missile0

 

Spoiler

I now realize that in order to use the paddle controllers, we will lose missile0.  Missile0 was going to be used to draw white road markers.  So to compensate for its loss, we will get rid of some things that we had planned and use the sprites we will save to draw white road markers.  

 

Here is the list of the changes.  

 

image.jpeg.cc4f368cdd2a4e9bb8ba40a420c251c3.jpeg

 

  • Get rid of the digital display on top of the screen.  
    • That frees up the P1 sprite, which was going to be used to draw the 3 digit MAX SPEED readout in the upper left corner.  Instead, P1 will draw white road markers.  
    • The P0 sprite, which draws your car, can be free 50% of the time to also help draw road markers.  Previously, the P0 sprite was going to draw the 2 digit TIME REMAINING digital display in the upper right corner using flicker.  
  • The result is that now we will have 3.5 sprites available to draw white road markers.
    • missile1
    • the ball
    • the P1 sprite
    • and 50% of the time, the P0 sprite (the other 50% of the time, it will be used to draw your car)
  • From early tests, it seems that a 1:3 ratio of sprites to objects results in acceptable flicker.  Therefore, with 3.5 sprites, we can plan on having 5 pairs of white road markers.  
  • The 3 digit total distance travelled (AKA your score) will be displayed using the 3 left-most digits of the 6 digit display.
  • The 2 digit time remaining in seconds will be displayed in the 2 right-most digits of the 6 digit display.
  • A blank space will be created in the 4th digit to separate the two numbers.  

Advantages of This Design

  • The game will still be played using the paddle controllers.  I think people will appreciate that.  
  • We keep the beautiful-looking yellow car drawn by the P0 sprite.
  • Five pairs of white road markers: I think that's not a bad number.  The road should be looking pretty good, I think.  
Link to comment
Share on other sites

White Road Markers - Calculations

 

Spoiler

Using the Center Point in the Road as the Reference for Calculations

 

We use the Mad Bomber analogy again.  Pretend that the Mad Bomber is dropping white road markers from Night Driver.  As the road markers fall, they become larger and spread farther apart.  

 

image.thumb.jpeg.4dde6724c1fd351982fa723431391ddd.jpeg

 

  • XM (x "middle") is the point in the center of the road.  
  • The width of the road is equal to 2xDELTA.
  • If we know XM and we know DELTA, then we know the x-coordinates of the two white road markers on either side.  

 

Approximating a Quadratic Equation with Linear Equations

 

Given: XM and a particular y value

Find: the x-coordinates of the left and right white road markers

 

Normally, a curved line such as the one, below, would be described by a quadratic equation (x = Ay^2 + By + C).

image.thumb.jpeg.ec0c2281e0c74849a75842a44748c598.jpeg

However, I have a feeling that such mathematical calculations would probably be too demanding of the 6502 processor and not be worth their high cost in processor cycles.  An alternate kind of computation that might use fewer processor cycles would be this.  Instead of using one quadratic equation to describe the whole curve, we can break up the curve into, say, three or four regions and approximate each region with a straight line (x = ym + B).  Then, for a given value of y, first, we can use a series of If...Then statements to determine the region.  Once we know the region, we plug y into that region's linear equation to find DELTA.  Finally, we can use DELTA to find the x-coordinates of the left and right white road markers of that particular pair.  Repeat the above calculations for all of the other pairs and you will have the (x,y) coordinates of all of the white road markers.  

 

Link to comment
Share on other sites

Collision Detection

 

Spoiler

Given: The x-coordinates of the left and right white road markers at the moment when they "fell off" the bottom of the screen.  

Given: The value of the paddle at that same moment.  

Find: Did either white road marker touch the player's car?

 

We can use If...Then statements.  In words: 

  • If the x-coordinate of the left road marker is equal to or greater than the x-coordinate of the left edge of the player's car plus the paddle then there was a collision on the left side of the road.  
  • If the x-coordinate of the right road marker is equal to or less than the x-coordinate of the right edge of the player's car plus the paddle then there was a collision on the right side of the road.  
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...