Из-за периодической блокировки нашего сайта РКН сервисами, просим воспользоваться резервным адресом:
Загрузить через ClipSave.ruУ нас вы можете посмотреть бесплатно why you get stuck on the same level for 800 lines или скачать в максимальном доступном качестве, которое было загружено на ютуб. Для скачивания выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса savevideohd.ru
Transcript (I wrote this in notepad sorry about the incessant linebreaks) NES tetris levels up when it shouldn't and doesn't level up when it should. Leveling up doesn't sound hard to get right, but let me walk through the relevant code and show you what happened. The code to check for level ups is pretty simple. First, it checks if the lines cleared is a multiple of 10. It adds lines one at a time so it never misses one - no bugs here. Next, it checks if the line count is more than 10 times the level. This is where everything falls apart. Here's what the code does. It divides the current line count by 10, and then compares it to the current level. Sounds fine until I show you the actual numbers it's manipulating; there's a conflict in the data format. I'm going to write out the numbers in hexadecimal as they appear in memory, and the reason you level up at 100 lines should be quite apparent. The line count truncated to its upper 2 digits is a larger number than the level. The level, as you can see, is directly stored as its binary representation, but the line count is stored such that when it is read as hexadecimal, it appears to be in base 10. This is handy for on-screen processing, and they could have easily avoided this error with a bit of extra code, but they did not. Essentially to see if a level-up should happen, write the current level in hexadecimal, and see if it's smaller than the upper 2 digits of the line count. If it is, then it will level up. So for example, on a 29 start, we transition at 200 lines, because level 29 written in hex is 1D, which is greater than 19 but less than 20. Now let me tell you why sometimes there's no level up when there should be one. From an 18 start, level 235 will last for an incredible 800 lines. Let me show you what that looks like in the calculations. Firstly, the line you would transition to level 236 is 2300. Something I haven't mentioned yet is that the top digit of the line count is actual normal binary, so in memory that looks like 1700, truncate to 70. The level is stored in memory as EB. Well, EB is greater than 70 so clearly a levelup is supposed to happen, right? Nope. The way the numbers are compared is by saying, if I were to subtract one number from the other, would the result be positive or negative? Now because we're working in bytes, positive/negative is distinguished by 00-7F being positive and 80-FF being negative. So let's do the math. If we rewind to 2290 lines, we get EA-69. This comes out to 81, a negative num. EB-70 is not negative. It's 7B, a very high positive number. The game won't level up. And this will go on, because if we look at the next time it should level, we get EB-71. We're subtracting a bigger number, so it's not going to be negative either, it's moving down to 7A. We have to go all the way out to 3100 lines. In memory, that's going to be EB-F0. That's negative 5. Finally, we move forward to level 236. You might be wondering why it desyncs in the first place, which just comes back to the mixed formats. When you clear 10 lines, your level and truncated lines both increase by 1. But when you cross any 100 line barrier, the truncated lines increases by 7, because it goes from 9 to 0. That's skipping over A,B,C,D,E, and F in hexadecimal. The level doesn't do that, so you essentially desync by 6 for every 100 lines. If you do 128 divided by 6 you'll see the result rounds up to 22, corresponding to the 2200 lines it takes to hit the superlevel from 0. Now because different start levels result in different line counts corresponding to each level, that means that the exact point you hit the superlevel depends on when you started; a 0 start hits 200 lines and is comparing 20 to 14, whereas an 18 start hits 200 lines and is comparing 20 to 1A. Starting at higher and higher levels pushes it further and further away, but you should note that the delay before first transition is actually the same thing as the superlevel, you just start midway through it instead of at the beginning, unless you start on level 127 where you really do experience the full 800 before moving to 128.