Jump to content
IGNORED

Tetris


atari2600land

Recommended Posts

I've ran into a major problem. Suppose you've got a long 1x4 line to fit into the following hole:

post-9475-1245636719_thumb.png

The result is quite messed up. I need someone to go through my code and figure out why this is happening and how to fix it. The trouble code begins at line #389. The code that begins the process of erasing rows begins at line #449, and the code that moves the blocks down accordingly begins at line #465. I think you can avoid most of the code that is before line 389, so it shouldn't take that long to read all my code. I think the problem is that the game can't handle one line being full, then one not full, then one (or two lines) full again.

tetris15.bas

tetris15.bas.bin

Link to comment
Share on other sites

I've tinkered with the code a little bit, and while i have trimmed it a lot, i still can't get to the root of the problem i'm having. Maybe a visual aid will better convey the problem i'm having:

post-9475-1245889265_thumb.png

Note that this only works with triples that have a line between them. If you get three lines in a row, it works perfectly. Please help!

tetris16.bas.bin

tetris16.bas

  • Like 1
Link to comment
Share on other sites

I've tinkered with the code a little bit, and while i have trimmed it a lot, i still can't get to the root of the problem i'm having. Maybe a visual aid will better convey the problem i'm having:

post-9475-1245889265_thumb.png

Note that this only works with triples that have a line between them. If you get three lines in a row, it works perfectly. Please help!

I'll look at this when I get home later.

 

Michael

  • Like 1
Link to comment
Share on other sites

I used 'set debug cyclescore' and if I'm reading it right (meaning 000064 means there's 64 left), it kinda looks like i'm barely getting by the maximum allowed. It goes down to 64 when the shape is moving down, most of the time it's near 2000. So, to answer your question, probably not. This is the first time i've used 'set debug cyclescore,' so I don't really know what the number *means* in terms of how I'm programming this.

Link to comment
Share on other sites

If you're looking for some cycles, either tune the worst offending routines or throw them in the vblank. (Provided they're less than 1000 cycles)

 

The latter is the easiest, the former takes some art.

 

In a worst case scenario in which you could do neither, you could probably make a 2 player version by doing the work for player1 during odd frames and handle player2 during even ones.

Link to comment
Share on other sites

I am able to get 2-player tetris at a full 60fps. This is just a visual aid to see how it works, but it is still VERY VERY buggy, kind of unplayable right now (actually, if you move player 2 to the right at all, it goes back to the title screen) You can move player0's pieces normally, though, but like i said, still very very buggy right now. I also still need help with the problem above. Once i get that fixed, I can double the code to use for player 1's line clearing.

tetris2player.bas.bin

tetris2player.bas

post-9475-1245950900_thumb.png

Link to comment
Share on other sites

Here's a way better version using 'set debug cyclescore'. Sometimes the score is red, but the number is 000000. What does that mean? This is still kind of buggy, though, and may start over again. To have 2player mode, set the right difficulty switch to A. Even though the name of the file is the same, it is a different build.

tetris2player.bas.bin

tetris2player.bas

  • Like 1
Link to comment
Share on other sites

Forgot to add a few lines of code. Here's the corrected file. Also, fire now works more smoothly for player 2. And, if anyone can tell me why it goes back to the title screen when you get player 2's shape to the right side of the well, please tell me.

tetris2player2.bas.bin

tetris2player2.bas

  • Like 1
Link to comment
Share on other sites

If you can be a little more patient (okay-- maybe a *lot* more patient!), I have an idea or two up my sleeve that might help, but I doubt I could get anything to you before next week.

 

Okay, you twisted my arm. (Well, I twisted my own arm; so sue me.) I noticed that you aren't using any of the players, missiles, or the ball in your kernel (aside from the score)-- at least, you weren't in the earlier versions I looked at. So I'm going to create a custom kernel for you that will let you draw one or two standard-size Tetris playing fields-- 10 blocks across, and 20 rows tall-- without needing to use the Superchip. And I'm going to have the kernel check each row as it's drawn to see if it's all filled, and set a bit flag for that row if it is-- so that all you have to do to see whether or not a given row is filled is check its bit flag after executing the drawscreen command. :cool:

 

By the way, I suggest that you use the "score color mode" for the two-player game, so the left side of the screen can be drawn in one color, and the right side of the screen can be drawn in another color-- e.g., blue for the left player and green for the right player, or yellow and red, or red and blue, or whatever two colors the players want to pick.

 

Michael

Link to comment
Share on other sites

Cool! Although in this latest version, I'm using player0 in the title screen, but it isn't very important and i could get rid of it if need be.

I'll check out how you're using player0 in the title screen; I don't think it should be much trouble to include the players, especially on a title screen as opposed to the actual game screen.

 

For the two-player game, how high do you want the score to go? I should be able to split the standard 6-digit score into two 4-digit scores, or I could split it and draw 2 digits with each sprite to get two 8-digit scores.

 

Also, I was thinking it might make more sense to draw the next piece directly over the board, as if it's in position and just waiting for its turn to drop down. That way in the two-player game the two preview pieces won't be so close to each other in the middle of the screen, but will be clearly separated on each player's side of the screen.

 

Michael

Link to comment
Share on other sites

For the two-player game, how high do you want the score to go? I should be able to split the standard 6-digit score into two 4-digit scores, or I could split it and draw 2 digits with each sprite to get two 8-digit scores.

Two four-digit scores would be fine.

 

Also, I was thinking it might make more sense to draw the next piece directly over the board, as if it's in position and just waiting for its turn to drop down. That way in the two-player game the two preview pieces won't be so close to each other in the middle of the screen, but will be clearly separated on each player's side of the screen.

This sounds good.

Link to comment
Share on other sites

I stayed up until 3:30am thinking about how to do this, and one bright idea led to another, and i woke up and came back to it, and i finally solved the problem! Note that this only works on player0 (left hand) because i still haven't added line clearing logic to the right hand player yet. The solution is to go through the line dropping down process twice. While this does take longer, it does work (i think, so if you see anything not working, please let me know.)

tetris2player3.bas.bin

tetris2player3.bas

Link to comment
Share on other sites

I have figured out why the game resets. It is because the game goes to -1600 cycles left. So, to get rid of this problem, I have added a change to the controls. If you hold the left or right button down, it will only move to the left or right once. To move two times to the left, you need to press left twice. I had to do this, unless someone else can think of another solution.

tetris2player4.bas.bin

tetris2player4.bas

Link to comment
Share on other sites

I added a score counter for each player. There seems to be a little bug with the playerscores kernel. Every time it goes past 09, it goes to 0A instead of 10. I've tried using $, but to no avail. Weird. By the way, there is no game over because I deleted it and haven't put it back in yet.

 

@ SeaGtGruff - Would it be possible to use your line checking kernel with the SuperChip? I need the SuperChip because I need the extra variables.

tetris2player5.bas.bin

tetris2player5.bas

Link to comment
Share on other sites

I added a score counter for each player. There seems to be a little bug with the playerscores kernel. Every time it goes past 09, it goes to 0A instead of 10. I've tried using $, but to no avail. Weird.

 

Don't you need to follow inline playerscores.asm with inline bcd_math.asm? Or is that irrelevant now?

(but that would explain it...the addition to the score was handled as hex instead of bcd).

Link to comment
Share on other sites

I added a score counter for each player. There seems to be a little bug with the playerscores kernel. Every time it goes past 09, it goes to 0A instead of 10. I've tried using $, but to no avail. Weird.

 

Don't you need to follow inline playerscores.asm with inline bcd_math.asm? Or is that irrelevant now?

(but that would explain it...the addition to the score was handled as hex instead of bcd).

I tried putting inline bcd_math.asm in and "player0score = addbcd(player0score, l)" but it didn't like it. It went back to the title screen whenever I got a line.

Link to comment
Share on other sites

@ Nukey Shay - I know, I'm just leaving it out for now.

 

I've changed the background color in-game from red to blue so I can see where the score goes red in set debug cyclescore more clearly. This allowed me to clear up a few places where the cyclescore was -1000 or more and I've also made it possible to hold left or right and have the block move more left and right. This is the result. I hope it doesn't flicker too much for you. As always, I'd enjoy some feedback on how I'm doing.

tetris2player6.bin

tetris2player6.bas

Link to comment
Share on other sites

This is really great, this is looking like the best tetris yet for the 2600. I mostly finished my 2 player SC tetris - it looks pretty much the same, but I used a regular 6 digit score and just have it display the player scores in different colors, and it displays the score of the last player who finished lines. I also masked the dropping pieces and previews with player0 and player1 so they can be different colors; you might try that if you aren't using them for anything else. You can also do different patterns in the background for each level.

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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...