![]() ![]() The result is that memory locations which are up to 512 bytes past the start of the fruit table, which are used for some other totally different part of the program, are drawn on the screen at increasing locations in video memory. It is decremented at the end of the loop, which makes it roll back down to 255, causing the loop to run a total of 256 times, which is why the split screen gets drawn on this level. If it is not zero then the loop runs again, if it is zero then the subroutine ends. At the end of the loop, B is decreased by one and checked for zero. The program starts drawing fruit with the counter in register B set to zero, instead of the expected number from 1 to 7. So with the counter at zero, this causes the subroutine which draws fruit to think that it is a level less than 7 with only 1 to 7 fruit to draw, in addition to some possible blank spaces. No check is done to see if the Carry flag is set, which would have been one way for the programmers to realize the game has reached this point. The subroutine is called to draw the fruit and the value for the level wraps around to zero when it is incremented. When level 256 is reached, it is counted by the game as level 255 (this number is #FF in hexadecimal). Then it figures out how many and which fruit to draw. The programmers know this and so when the subroutine is called to draw the fruit, it loads the level counter and then increases it by one. The second level (strawberry) is counted as level 1 by the game, and so on. In other words, the first level that we play (cherry) is treated as level zero by the game. Levels in Pac-Man are stored with a starting value of zero. If so, then draw the proper number of blank spaces and color them all black. Check to see if any blank spaces are needed.Loop back up to 7 times to draw the rest of the fruit.Increase the pointers to the next fruit in the table and the next location on screen.One is for drawing fruit, the other is for possibly drawing blank spaces in cases where there are less than 7 fruit to draw. If the level is 19 or above, set the fruit pointer to the 1st key.If the level is 8 or more, set the fruit pointer to the starting fruit for the current level.If the level is 7 or less, set the pointer to the starting fruit to the cherry.Load level number and increase its count by 1.Here are the main points of fruit drawing: ![]() The table below details the fruit descriptions, their colors, and their position in memory: 2BF0 3A134E LD A,(#4E13) Load A with level numberĢBF4 FE08 CP #08 Is this level #13 (19 decimal, 7th key) ?ĢC30 3802 JR C,#2C34 If not, skip next stepĢC32 3E13 LD A,#13 If yes, treat all levels 19 and up as if they are level 19.ĢC34 D607 SUB #07 Subtract 7 to point to first value to be drawnĢC39 21083B LD HL,#3B08 Load HL with pointer to start of fruit tableĢC3D 09 ADD HL,BC Adjust fruit table pointer, based on current levelĢC3E EB EX DE,HL Load DE to point to fruit in tableĢC3F 0607 LD B,#07 Load B counter to draw 7 fruitĢC41 C3FD2B JP #2BFD Jump back up to fruit drawing section ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |