TAP Hiscore (Game Over Code) source code

Thread in 'Research & Development' started by LOst, 31 Jan 2015.

  1. So you have all seen that code that appears at the Game Over screen in TAP (Tetris The Absolute The Grand Master 2 PLUS)?
    According to our wiki, TAP is an upgrade that was given away free to owners of TGM2. But why did it require an upgrade in the first place? Well, there were bad stuff in TGM2 that just had to be fixed, and one of them was the hiscore list. An example of a failure in the hiscore would be to beat the game as S7 at about 10 minutes, fail the fade roll to get the Green Line. The Green Line tells us that its hiscore entry holds the time at game completion (that is hitting level 999). Then play another game, but this time die after getting S7 at about 9 minutes. That new entry will rank above the Green Line one because TGM2 thought 9 minutes were faster than 10 minutes. But those times cannot be compared the same way. One time is the time at level 999, and the other time is the time when S7 was obtained. These issues and other were fixed in TAP, as well as some new game modes were added, Death Mode being the famous one.
    But TAP doesn't have hiscore for those new game modes. The hiscore was fixed, and Death Mode got medallions to keep track of, but no way to remember your games by...
    That's why the Game Over code exists. You get this code by pressing and holding A+B+C just before the Game Over screen, or in case of Normal Mode or Master Mode, before the name entry or at the end of it. This code remembers anything important about your game so that it can be reconstructed later. But was it ever used officially? I don't think so. Still, some of us have clearly hold A+B+C in our videos in hope that someday someone will crack the code. That day has come, ladies and gentlemen, let me introduce to you my TAP External Hiscore list:

    This is a Win32 console program that outputs, in order, all of your hiscore entries, and others as well. It can display hiscore entries in any order you want, and from all supported game modes. And with an easy double click with the mouse over an entry, can take you directly to the video of the play, if it is online.
    It has been tested in Windows NT 3.51 from 1994.

    It has been tested in Windows 98 SE from 1999.

    How it works:
    The Game Over code together with the name entry are required to decode the information about the game. Place your name entry (use quotation marks if your name includes whitespaces), the Game Over code , and an additional/optional comment in the file SCORE.TXT.
    Now run TAPExternalHiscore.exe and your hiscore entry will be shown.
    The SCORE.TXT can handle both capital and lower case letters, whitespaces and/or tabs, use line comments with the # character. If the format was incorrect, TAPExternalHiscore.exe will complain about it at startup with a line number, and eventually skip the entry.
    The optional comment can include a web address, which will be opened if the user double clicks the entry with the mouse.
    The mouse can also, and should be used to scroll the awesome textmode scrollbar provided at the right hand side of the screen. I spend a great time to program the scrollbar since it has been a deam of mine for a long long time, so use it!

    The ORDER.TXT keeps a list from left to right of the order to display and rank your hiscore entries. It is possible to rank Level before Grade, or Level before Time. Anything is possible. Also by default, the medallions are ranked as well (which is not the default behaviour in TGM2 of TAP!), which you can see and decide the order of. To turn off ranking of medallions, remove the text line with the medallions names from ORDER.TXT!

    If you want to decode the Game Over Code youself, or want to just understand it, the source code for it is included in the file ScoreValidateDec.c where all the secret stuff is kept. It took me one full day to program that whole file, using data and resources from my 2008 secret project LTAP. I had to figure out this code format and usage all by myself.
    The source code also includes the awesome scrollbar, and some crazy scrolling calculations for redrawing only the parts needed redrawing, so less tearing and flickering while browsing your hiscores!
    Because the hiscore entries are kept in a linked list, there is basically no limit to how many entries can be loaded, as can be seen in the Account.cpp source code file!
    Here is the source:
    If you use any of this code in your own projects, please give me credits: LOst

    Because SCORE.TXT is independent of the program, its entries (name, code, comment) can easily be shared online. Feel free to post your entries in this thread for others to pick up!
  2. Amazing work !
  3. Thanks.

    You don't need to have the best hiscore to post them here. TAPExternalHiscore can deal with unlimited number of hiscore entries, and the more added, the more interesting the result becomes
  4. [​IMG]
  5. K


    Amazing work lost ! :)
  6. Zaphod77

    Zaphod77 Resident Misinformer

    So where's the online form to post these scores to a web leaderboard? :)
    Last edited by a moderator: 1 Feb 2015
  7. Last edited: 4 Feb 2015
  8. SPL GD97J764RTEMG7R3 finally a good performance on TAP muhahaha

    This program you made just rocks, major props *o*
  9. Great tool, LOst!
    Here's a Death Gm from today.
    Edit: Faster Death Gm:
    STD 99HF3WWM9DPYG644
    Last edited: 14 Mar 2015
  10. Thanks a lot for taking the time to make this and reverse engineering "the code". I wouldn't even know where to start if I tried to figure it out myself.

    While reading the source I found a small bug in ScoreValidateDec.c, line 329:
    if (pbMedallionAllClear != NULL) // FIXME: should be pbMedallionSectionTime != NULL
        // Decode [ST] medallion
        *pbMedallionSectionTime = (unsigned char)((strComputeValidation[10] >> 1) & 0x3);
    Luckily it does not cause any problems in the current build because pbMedallionAllClear and pbMedallionSectionTime will always be non-null anyway.
  11. @LOst:
    If I have the time I would like to rewrite your code in php and put that whole functionality in a website. I hope you are okay with that!
  12. I need some help, because I am not good enough at T.A. Death, so I cannot generate enough test data. To add a meaningful sorting to the highscore table, I need codes of the following games:
    - two T.A. Death Games, dying at 499 (with different times)
    - two T.A. Death Games, reaching 500 slower than 3:25 with different times
    - one T.A. Death Games, dying somewhere between 501-998
    - two T.A. Death Games, reaching GM with different times

    If you want to help me, please either post your code here or just add it on my web page:
  13. Oooh... Sounds like a challenge to me! I'll see if I can get something this weekend

    Edit : do you need a tag at the end in particular?
  14. It should work with any tag, but you need to remember which one you used. You need a matching 3 letter name and the 16 letters/numbers code to extract the information of the run (grade, level, time and medals in case of Death).
  15. TGGC: Feel free to port to PHP. I have a feeling it would be more popular that way :p

    WakiMiko: Yea, that is a typical copy-paste bug. Thanks for finding it. I updated the source file and credited you.
    Last edited: 11 Apr 2015
    TGGC likes this.
  16. Name/initials are RED for all games.

    500 @ 3:27:71, gold ST, bronze RE

    500 @ 3:25:56, gold ST

    504 @ 3:19:26, gold ST, silver SK

    499 @ 3:24:88, silver ST

    499 @ 3:29:26, silver ST, bronze SK

    Not in an alert-enough state to get two GM games, that is left as an exercise for the rest of ya... get cracking!
    TGGC likes this.
  17. @rednefed: Thanks a lot!

    I did a small update:

    I kind of finished the Normal Mode Ranking: http://www.games-net.de/hosted/tggc/tetris/index.php?action=4&mode=0
    It sorts by score like it does in TAP. I never managed to get any medals in Normal, so I might remove them. But i found out that you get a grade in Nomal too. The game never displays it, but its stored in the code. So I added a second sorting, where the one with the highest grade goes to the top and the score is the tiebreaker if 2 people got the same grade. You can activate this alternate sorting by clicking on the "grade"

    Master and TGM+ should work fine, because they are fundamentally the same.

    And I think Death now works the way one would expect. It first looks for your grade, but there are only 2 different grades given. So everyone without a grade goes to the bottom, M goes above them and GM hopefully to the top (still have to verify this with some Death GM codes). Now within each rank, the level gets the tiebreaker instead of time, because the code does not store the mastering time of the last grade (like in Master mode) but the time of the full run. Only if the level aquired is the same, the time matters. So the 500 @ 3:25:56 of RED gets the top spot (so far...) among the games without a rank, because its the fastest game someone died at level 500 and the 499 @ 3:24:88 ranks below the level 500 games, despite beeing faster.

    Medal Ranking System
    As a little bonus I added a ranking for your Medals in Master, TGM+ and Death. Once again you can click on the "Medal" at the top of the table. So how does it work? You are awarded diffenrent points for each your medals:
    • Bronze : 4 points
    • Silver: 10 points
    • Gold: 25 points
    So you rank somewhere between 0-150 points. If two people got the some points, the spot within the original ranking decides who goes first. If someone manages to get a medal in a Normal game, I am going to add it there, too!

    Everyone feel free to add your codes over here:
    clincher, Linepiece778 and Jayce like this.
  18. Normal mode is a score attack (as ranked in the game's high score lists), so you should sort by the score. No medals are given in Normal, not even for bravos.
  19. Isn't that just sorting by level and then time? I don't think the grade matters since it is based on level and time anyway.

    LOst: Cool, thanks for crediting me
  20. @rednefed:
    Yes, sorting by score is the default. I know that in normal the game never displays a grade or a medal. But in the game over code, it stores your grade. So you have an invisble grade. But I have not found any code yet, where you have an invisible medal.

    Is there never a case where you get to level 999 and die before getting GM? I changed it for now and wait for this edge case to occur.

    I also found that a Death game to level 500 awards you a green line!?

Share This Page