NE Corner Reloading Glitch Fix - RetroKoH/S1Fixed GitHub Wiki

(Original guide by SpirituInsanum)
Source: SSRG Thread
Commit: b1b7f80

There is a bug w/ the top left corner of the screen updating, most of the time when going right and up or down, and it will get worse if you remove the speed cap. To summarize MarkeyJester's explanation on the matter, the 68k is too slow to transfer all the blocks soon enough if that transfer happens too long after the v-blank interruption. Among the possible fixes proposed, rewriting the routine to make the block/tiles loading faster or making the transfer happen sooner seemed too technical and time-consuming. So rather than doing that, I decided to give the map plane redrawing some advance, one column should be enough after all.

This fix is far from being complicated: we only have 5 lines to change, all of which are in sonic.asm. Find loc_6938 and change the following lines:

loc_6938:
	bclr	#3,(a2)
	beq.s	locret_6952
	; Draw new tiles on the right
	moveq	#-16,d4
!	move.w	#336,d5		; Was 320
	bsr.w	Calc_VRAM_Pos
	moveq	#-16,d4
!	move.w	#336,d5		; Was 320
	bsr.w	DrawBlocks_TB

Next, go to locj_6D56 and change the following lines (This section of code is in Revision 01):

locj_6D56:
	bclr	#3,(a2)
	beq.s	locj_6D70
	; Draw new tiles on the right
	moveq	#-16,d4
!	move.w	#336,d5		; Was 320
	bsr.w	Calc_VRAM_Pos
	moveq	#-16,d4
!	move.w	#336,d5		; Was 320
	bsr.w	DrawBlocks_TB

If you do only this, there will be holes in the planes when going up or down, one block per line. In order to fix this, we have to load one more block per line. Go to DrawBlocks_LR (this routine is used to redraw a line of blocks) and replace:

moveq	#((320+16+16)/16)-1,d6	; Draw the entire width of the screen + two extra columns

with:

moveq	#((320+16+16)/16),d6	; Draw the entire width of the screen + two extra columns

That's it, the problem should be gone.

NOTE: In S3K, a brand new screen manager also fixes this bug. If that gets imported, I'll need to look at how that affects this fix.