Jump to content
IGNORED

My first homebrew: 2048_4vcs


Sohl

Recommended Posts

Hello. I'm a new forum member, Mike "Lockmoore" Losh. I'll post a longer intro in the introductions sub-forum in the next few days. I've had a lot of fun in the last several weeks while recovering from some minor surgery by getting back to my 2600 gaming roots and writing my first homebrew 2600 game: yet another implementation of the sliding-tile game 2048.

 

As I was playing my new Atari Flashback 5, I started thinking that it should be possible to play my favorite smartphone timewaster, 2048 on the 2600 console. I found these Atari Age forums, tutorials, and references. I can thank Andrew Davie, Kirk Israel, Darrell Spice, Jr. for some really great tutorials and sample code, SvOlli, randomterrain.com, and the many folks who have put together the DASM assembler, the z26 and stella emulators and who have posted may interesting bits of code and advice in these forums.

 

Of course, not long after I started looking at how I might implement 2048 for the VCS 2600, I came across chesterbr's very nice implementation of it here: http://atariage.com/forums/topic/223570-2048-2600/?hl=+2048. It has a clever stacking the digits in higher-value tiles so they all fit with the limited space of 2600's sprites, and a neat rolling animation of the tile numbers when the tiles merge. While an impressive version, it uses some very different colors than Gabriele Cirulli's smash-hit online version. I wanted to see if I could get a lot closer to Gabriele's aesthetic while being still fun to play. While far from perfect, I think I'm getting close to my goal.

 

Right now it has a title/attract screen, main play screen, and a best-score screen. It has some very basic sound effects. (Thanks again to Darrell Spice for the sfx code. I used a direct copy of the functions and custom-edited the sound sequences for my 2048 game.) There are some extra visual effects, such as flashing the grid background color gold when you create a 2048 or higher tile, or blue when the current game is over.

 

I will probably post my source code and some specific questions someday soon. Right now, the code is littered with abandoned ideas and little extra testing bits, so I need to do some cleaning before I subject any of you to that.

 

Game controls are pretty simple, Reset Switch will start the game play with a fresh board at any time. Move the left joystick in the direction you want to slide/merge tiles (left, right, up, or down). If the game is over, the best score screen will alternate with the screen showing the final arrangement of the tile grid. While in best-score mode, if you press and hold the left fire button, you will see a yellow underline bar grow under the words "TRY AGAIN?" If the bar fills the entire screen width, the game is reset just as if you used the console game reset switch.

 

There are a few issues with the current version, which I will call "Beta 1". The scores shown in the main play screen and the best score screen are not well centered. At times when you move tiles, there is a noticeable shudder in the emulator, which I am certain is caused by not completing some code fast enough to start the next video frame at the proper time. I may need to do some deferred action to keep the screen drawing happen on-time.

 

I have some ideas for enhancements, but I thought I get some feedback here before I go much further. Please note, this has only been tested on z26 and stella emulators. I don't currently have a real 2600, just the Flashback 5. If someone can put my .bin on a Harmony cart and give it a test on a real 2600, I'd really appreciate it. I'd especially get a kick out of seeing a photo of it running on a real VCS 2600!

 

I'll also post some of the development process, such as ideas for things I could not get to work, at least in the self-impsed constraints of a normal 4K cart.

 

OK, enough blabbering. Have fun and let me know how it works for you!

--

Mike

2048_4vcs_beta1.bin

post-42328-0-01336800-1430538632_thumb.png

post-42328-0-93622900-1430538642_thumb.png

post-42328-0-59758600-1430538650_thumb.png

  • Like 7
Link to comment
Share on other sites

@accousticguitar: Thanks for trying it out. It works! (sorta) Just to be clear, is it jittering all the time in that play screen (when you don't touch the joystick), or just when you make a slide movement?

Link to comment
Share on other sites

@Arenafoot: Yes, when I run Stella, I often see that kind of garbled appearance at the start too, but other runs I don't. I have no idea why. On z26, I never see that. I wonder if anyone else has some idea why that happens. Is that on Windows? I'm running z26 and Stella on Xubuntu Linux.

 

@accousticguitar: Hmmm. I was hoping that if I make sure to output 262 lines and have it stable on both Stella and z26, it would work on a real console. I suppose I could try to generate a few fewer or more lines and see if that helps. Or is the jitter only in one part of the screen, such as the score, or the tile numbers, or the tile positions? I just might have to get a real 2600 console again. :)

  • Like 1
Link to comment
Share on other sites

@Arenafoot: Yes, when I run Stella, I often see that kind of garbled appearance at the start too, but other runs I don't. I have no idea why. On z26, I never see that. I wonder if anyone else has some idea why that happens. Is that on Windows? I'm running z26 and Stella on Xubuntu Linux.

It's because you didn't clear decimal mode. You need to add a CLD at startup to fix this.

 

Stella randomizes the state of decimal mode because on real hardware it can be in either state at power on. You might not notice it if you are trying this on a Harmony cart (when selecting the rom through the menu) as the rom running on the Harmony clears decimal mode. However, the bug will show up if you make a run of carts, so it's good Stella does this. :)

  • Like 1
Link to comment
Share on other sites

Here is an updated binary (Beta 2), that should at least fix the garbled title screen issue with Omegamatrix's suggestion. It also defers updating the score display right after a move, which could help the bad jitter after some moves. I don' think it will help the main jitter issue reported by accousticguitar. I have a request for debugging advice in the main programming subforum (http://atariage.com/forums/topic/237892-advice-to-debug-jitter/) to help me sort that out.

2048_4vcs_beta2.bin

  • Like 2
Link to comment
Share on other sites

I really like the graphics on your version - they go closer to Thomas Jentzsch's Three.s than to my 2600 (thanks for the kind words on the other post, btw). They are an eye-opener on how my stubborness (on keeping the playfield "grid" the way it was originally designe) made the colored tiles harder to implement and less detailed than they could have been.

 

Jittering is likely caused by non-standard frames, as you suggest. Best way to debug is to configure Stella to break into the monitor whenever you reach a scanline number that is past the maximum frame size. E.g., for NTSC, something in the lines of:

 

> breakif _scan==#263

 

This is useful to keep on your configs, since it's something that is so easy to break. Such default breakpoitns are as close to a test suite that you'll get on 2600, I guess :)

 

Anyway, this is great stuff, keep on going. Also, don't be *too* shy with the source code - of course, you want to tidy it up a bit before going public, but that job is never over, so don't over-stress on it! (I got lots of good advice and patches once I went public, if you need more incentive).

 

 

  • Like 1
Link to comment
Share on other sites

@Chesterbr: That sounds like a really useful tip. I can already see where I'm violating that scanline limit. :-o

 

In my version, I wanted tiles relatively big and square to look close to Gabriele's web/mobile app version. I was mostly done developing the main playscreen kernel before I looked in detail at Thomas Jentzsch's Three.s kernel, but it seems like I arrived at a similar method. SvOlli's youtube presentation on the 48-bit sprite and some associated posts here at AtaruAge on that topic provided a real breakthrough for me.

 

I've tried to make the color of the numbers on each tile vary in the same way as Gabriele;s web/mobile app (2 and 4 are black on a light background, all higher number tiles white on a more colorful background), but have not managed to figure out a way to update the player graphics, player colors, and playfield (tile) colors every scan line... maybe its possible alternating "window blind" style or something, or using special cart accelerator features, but I wanted to see what I could do with an ordinary 4K cart. In the end I just made the 2 and 4 tile number bitmap "thicker" to look darker, and to my eyes seems to give a similar visual appearance to the "real" version.

 

Yes, I'll get my source cleaned up a bit and posted soon, hopefully within a week or so. ;)

Link to comment
Share on other sites

@Arenafoot: Yes, when I run Stella, I often see that kind of garbled appearance at the start too, but other runs I don't. I have no idea why. On z26, I never see that. I wonder if anyone else has some idea why that happens. Is that on Windows? I'm running z26 and Stella on Xubuntu Linux.

I run Stella 4.0 on Win7 - it did the same thing to me, first run messed up second, third runs perfect, fourth messed up and so on............

Link to comment
Share on other sites

Here is an updated binary (Beta 2), that should at least fix the garbled title screen issue with Omegamatrix's suggestion. It also defers updating the score display right after a move, which could help the bad jitter after some moves. I don' think it will help the main jitter issue reported by accousticguitar. I have a request for debugging advice in the main programming subforum (http://atariage.com/forums/topic/237892-advice-to-debug-jitter/) to help me sort that out.

 

main screen fixed - the first time I ran it, it started me off with THREE "2" tiles?!?!?!? (instead of two) - I tried to replicate it but couldn't.

Link to comment
Share on other sites

@Arenafoot: I think I have seen the tripple starting tiles happen at least once too. Perhaps a timing issue reading the switches. Thanks for reporting. I will see if I can prevent in a future release.

  • Like 1
Link to comment
Share on other sites

Thanks to Omegamatrix's help in my programming question thread, I have updated the VSYNC/VBLANK code to hopefully provide a more stable VSYNC signal. It can still sometimes miss the VSYNC timing when it gets too busy and generate an extra scan line or two, but until I can figure out a way to prevent that, you can work with this copy, "Beta 3". (Hmm, maybe I should not have started "Beta 1" as a beta release...)

 

2048_4vcs_beta3.bin

  • Like 2
Link to comment
Share on other sites

Thanks to Omegamatrix's help in my programming question thread, I have updated the VSYNC/VBLANK code to hopefully provide a more stable VSYNC signal. It can still sometimes miss the VSYNC timing when it gets too busy and generate an extra scan line or two, but until I can figure out a way to prevent that, you can work with this copy, "Beta 3". (Hmm, maybe I should not have started "Beta 1" as a beta release...)

 

works great from what i see!!!!

Link to comment
Share on other sites

I have cleaned up the assembler source code, and maybe fixed a small issue during the "win" effect when you get a 2048 or higher tile. Here are the assembler and binary files.

 

The wording for the best score screen is formed with playfield graphics I compile with a special tool I wrote in C, and the file extension I use (.pfg - "play field graphics") for the input file is not allowed here, so I will just post the output .inc file. I will probably post the source code for the play field assembler in another thread someday. The input .pfg file looks like this:

# Playfield Graphics source file for 2048 game bestscore screen

; Label for best score
revplayfield BestLabelGraphics           ; label above the best score seen so far
    ; graphical content goes here
    ; pfad = playfield asysmetric, duplicated order 
    # Guideline
    #    "-123456789-123456789-123456789-123456789"
    pfad "         XXX   XXXX   XXX XXXXX         "    ;
    pfad "         X  X  x     X      X           "    ;
    pfad "         X  X  x     X      X           "    ;
    pfad "         XXX   XXX    XX    X           "    ;
    pfad "         X  X  X        X   X           "    ;
    pfad "         X  X  X        X   X           "    ;
    pfad "         XXX   XXXX  XXX    X           "    ;
    pfad "                                        "    ;
playfield-end

revplayfield LastLabelGraphics           ; label above the last game's score
    # graphical content goes here
    # Guideline
    #    "-123456789-123456789-123456789-123456789"
    pfad "         X      XX    XXX XXXXX         "    ;
    pfad "         X     X  X  X      X           "    ;
    pfad "         X     X  X  X      X           "    ;
    pfad "         X     XXXX   XX    X           "    ;
    pfad "         X     X  X     X   X           "    ;
    pfad "         X     X  X     X   X           "    ;
    pfad "         XXXX  X  X  XXX    X           "    ;
    pfad "                                        "    ;

playfield-end

revplayfield AgainLabelGraphics           ; A bit of encouragement!
    # graphical content goes here
    # Guideline
    #    "-123456789-123456789-123456789-123456789"
    pfad "XXX XXX  X X   XX   XX   XX  X X  X  XX "    ;
    pfad " X  X  X X X  X  X X  X X  X X XX X X  X"    ;
    pfad " X  X  X X X  X  X X    X  X X XX X    X"    ;
    pfad " X  XXX   X   XXXX X XX XXXX X X XX   X "    ;
    pfad " X  XX    X   X  X X  X X  X X X XX   X "    ;
    pfad " X  X X   X   X  X X  X X  X X X  X     "    ;
    pfad " X  X  X  X   X  X  XX  X  X X X  X   X "    ;
    pfad "                                        "    ;

playfield-end

playfield RestartBar
    ; pfm = playfield, mirrored
    #    "-123456789-123456789-123456789-123456789"
    pfm  "                    " ; 0
    pfm  "                  XX" ; 1
    pfm  "                XXXX" ; 2
    pfm  "              XXXXXX" ; 3
    pfm  "            XXXXXXXX" ; 4
    pfm  "          XXXXXXXXXX" ; 5
    pfm  "         XXXXXXXXXXX" ; 6
    pfm  "        XXXXXXXXXXXX" ; 7
    pfm  "       XXXXXXXXXXXXX" ; 8
    pfm  "      XXXXXXXXXXXXXX" ; 9
    pfm  "     XXXXXXXXXXXXXXX" ; 10
    pfm  "    XXXXXXXXXXXXXXXX" ; 11
    pfm  "   XXXXXXXXXXXXXXXXX" ; 12
    pfm  "  XXXXXXXXXXXXXXXXXX" ; 13
    pfm  " XXXXXXXXXXXXXXXXXXX" ; 14
    pfm  "XXXXXXXXXXXXXXXXXXXX" ; 15
playfield-end

I'm releasing 2048_4vcs for non-commercial private/educational rights usage. I hope you enjoy it and can perhaps learn something useful from it, as I have learned from the many examples posted here in AtariAge. In the unlikely event someone wants to package and sell this as a cartridge or something, please contact me to work something out. ;)

 

In the event you have code suggesions, please reply here and I can try to learn from you!

--

Mike

2048_4vcs_beta4.asm

2048_4vcs_beta4.bin

2048_bestscore.inc

Edited by MLockmoore
  • Like 3
Link to comment
Share on other sites

I have cleaned up the assembler source code, and maybe fixed a small issue during the "win" effect when you get a 2048 or higher tile. Here are the assembler and binary files.

 

The wording for the best score screen is formed with playfield graphics I compile with a special tool I wrote in C, and the file extension I use (.pfg - "play field graphics") for the input file is not allowed here, so I will just post the output .inc file. I will probably post the source code for the play field assembler in another thread someday. The input .pfg file looks like this:

# Playfield Graphics source file for 2048 game bestscore screen

; Label for best score
revplayfield BestLabelGraphics           ; label above the best score seen so far
    ; graphical content goes here
    ; pfad = playfield asysmetric, duplicated order 
    # Guideline
    #    "-123456789-123456789-123456789-123456789"
    pfad "         XXX   XXXX   XXX XXXXX         "    ;
    pfad "         X  X  x     X      X           "    ;
    pfad "         X  X  x     X      X           "    ;
    pfad "         XXX   XXX    XX    X           "    ;
    pfad "         X  X  X        X   X           "    ;
    pfad "         X  X  X        X   X           "    ;
    pfad "         XXX   XXXX  XXX    X           "    ;
    pfad "                                        "    ;
playfield-end

revplayfield LastLabelGraphics           ; label above the last game's score
    # graphical content goes here
    # Guideline
    #    "-123456789-123456789-123456789-123456789"
    pfad "         X      XX    XXX XXXXX         "    ;
    pfad "         X     X  X  X      X           "    ;
    pfad "         X     X  X  X      X           "    ;
    pfad "         X     XXXX   XX    X           "    ;
    pfad "         X     X  X     X   X           "    ;
    pfad "         X     X  X     X   X           "    ;
    pfad "         XXXX  X  X  XXX    X           "    ;
    pfad "                                        "    ;

playfield-end

revplayfield AgainLabelGraphics           ; A bit of encouragement!
    # graphical content goes here
    # Guideline
    #    "-123456789-123456789-123456789-123456789"
    pfad "XXX XXX  X X   XX   XX   XX  X X  X  XX "    ;
    pfad " X  X  X X X  X  X X  X X  X X XX X X  X"    ;
    pfad " X  X  X X X  X  X X    X  X X XX X    X"    ;
    pfad " X  XXX   X   XXXX X XX XXXX X X XX   X "    ;
    pfad " X  XX    X   X  X X  X X  X X X XX   X "    ;
    pfad " X  X X   X   X  X X  X X  X X X  X     "    ;
    pfad " X  X  X  X   X  X  XX  X  X X X  X   X "    ;
    pfad "                                        "    ;

playfield-end

playfield RestartBar
    ; pfm = playfield, mirrored
    #    "-123456789-123456789-123456789-123456789"
    pfm  "                    " ; 0
    pfm  "                  XX" ; 1
    pfm  "                XXXX" ; 2
    pfm  "              XXXXXX" ; 3
    pfm  "            XXXXXXXX" ; 4
    pfm  "          XXXXXXXXXX" ; 5
    pfm  "         XXXXXXXXXXX" ; 6
    pfm  "        XXXXXXXXXXXX" ; 7
    pfm  "       XXXXXXXXXXXXX" ; 8
    pfm  "      XXXXXXXXXXXXXX" ; 9
    pfm  "     XXXXXXXXXXXXXXX" ; 10
    pfm  "    XXXXXXXXXXXXXXXX" ; 11
    pfm  "   XXXXXXXXXXXXXXXXX" ; 12
    pfm  "  XXXXXXXXXXXXXXXXXX" ; 13
    pfm  " XXXXXXXXXXXXXXXXXXX" ; 14
    pfm  "XXXXXXXXXXXXXXXXXXXX" ; 15
playfield-end

I'm releasing 2048_4vcs for non-commercial private/educational rights usage. I hope you enjoy it and can perhaps learn something useful from it, as I have learned from the many examples posted here in AtariAge. In the unlikely event someone wants to package and sell this as a cartridge or something, please contact me to work something out. ;)

 

In the event you have code suggesions, please reply here and I can try to learn from you!

--

Mike

 

Excellent work Mike!

Link to comment
Share on other sites

I just ran version 4 and got this to start with........

Oh, I belived you before, but I'm not sure how that happened yet! It's really hard to reproduce. Could be a subtle timing bug in my game reset code. Or if you are running on an emulator, perhaps you bumped the mouse/touchpad at the same time you hit reset? If that is the reason, I suppose I could ignore the joystick input for the first second after a reset or something.

Link to comment
Share on other sites

Oh, I belived you before, but I'm not sure how that happened yet! It's really hard to reproduce. Could be a subtle timing bug in my game reset code. Or if you are running on an emulator, perhaps you bumped the mouse/touchpad at the same time you hit reset? If that is the reason, I suppose I could ignore the joystick input for the first second after a reset or something.

Yeah I'm running it on Stella 4.0 on my PC.

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...