Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Original NES PlayState order, including ARE/lineclear states
- // 1 Core game logic. When we try to drop a piece, but it can't be dropped, set to state 2 and vramRow should be partially reset
- // 2 Waits for VRAM to be okay, locks the piece into playfield (Gameover on failure), and then partially resets the vramRow again
- // 3 Waits for VRAM to be okay, and then takes 4 Frames to check for lineclears, then sets vramRow=0 (Which immediately becomes 4 at end of frame)
- // 4 is only for lineclears. If a lineclear happens, we wait for "five" iterations, only iterating when frame_count is a multiple of 4
- // NOTE: The first progression may happen on the same frame as PlayState 3
- // On the fifth iteration, vramRow = 0, but the vram is not updated in that frame
- // oooooooooo
- // ooooxxoooo <- First progression
- // oooxxxxooo <- Second progression
- // ooxxxxxxoo <- Third progression
- // oxxxxxxxxo <- Fourth progression
- // xxxxxxxxxx <- Fifth progression (vramRow will be 0 when this frame finishes)
- // 5 happens once in parallel with vram, [Audio is played at this time, and scores are updated]
- // 6 happens once in parallel with vram, does nothing in particular
- // 7 happens once in parallel with vram, does nothing in particular
- // 8 waits for VRAM to be okay, and then takes 1Frame, after which the current piece is ready-to-render and it goes back to 1
- // Calculating VRAM Delay, based off of a partial reset of vramRow
- // Playstates 1/2 will partially update vramRow to be max(y-2, 0), where y is the tetromino location
- // VRAM will copy data over, 4 rows at a time, until vramRow >= 20
- // Some PlayStates will wait for VRAM to be copied, before acting
- // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 y
- // 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 max(y-2, 0)
- // ^---------^ ^-----^ ^---------^ ^---------^ ^---^
- // 4 3 2 1 0 <- Starts at 0, since it gets copied on that very frame
- //
- // Thus, partial_vram_delay(y) = 4 - Math.floor(max(y - 2, 0) / 4)
- // PlayState1: When a piece failed to drop, sets vramRow = max(y-2, 0), and iterates PlayState
- // ~ Waiting for partial_vram_delay(y) Dead Frames
- // PlayState2: 1 Frame, sets vramRow = max(y-2, 0)
- // ~ Waiting for partial_vram_delay(y) Dead Frames
- // PlayState3: 4 Frames, sets vramRow = 0
- // [vramRow += 4 at the end of this frame, 4 Frames left for vram copy]
- // if LineClearingAnimation:
- // PlayState4: 5 Frame animation, iteration only on %4 == 0-Frames, which can overlap with End of PlayState3
- // vramRow does not get iterated during LineClearingAnimation
- // [vramRow = 0 at the end of this frame, 5 Frames left for vram copy]
- //
- // else:
- // Skip this PlayState entirely
- // PlayState5: 1 [If LineClearingAnimation, Frame 1 of copy, else Frame 2 of copy]
- // PlayState6: 1 [If LineClearingAnimation, Frame 2 of copy, else Frame 3 of copy]
- // PlayState7: 1 [If LineClearingAnimation, Frame 3 of copy, else Frame 4 of copy]
- // ~ If LineClearingAnimation:
- // Waiting for Frame 4 / Frame 5 of copy
- // Else:
- // Waiting for Frame 5 of copy
- // PlayState8: 1 Frame, Now ready to render nextpiece on playfield, with a new nextpiece
- // Total Delay Math:
- // AREState 1 ~ Playing the game
- // AREState 2 ~ Do nothing for f_delay(x) Frames, on last Frame inc AREState and decide game-over
- // AREState 3 ~ Do Nothing for f_delay(x) + 4 Frames
- // AREState 4 ~ Lineclear State:
- // Go through 5 states of LineClearingAnimation, make progress only on %4==0 indices
- // Progress is allowed to be made, on the last frame of AREState 3
- // AREState 5 ~
- // If LineClearingAnimation:
- // Copy from board, to VRAM, starting at row=0, in groups of 4 [Will take 5 frames]
- // Else:
- // Do Nothing for 4 Frames
- // AREState 6 ~
- // On this Frame, make the spawn piece ready-to-render, and reset AREState to 1
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement