Skip to content

Commit 2d1d51d

Browse files
author
aquanull
committed
Fixed many text-missing problems in GBC games such as Tonic Trouble,
Hunter X Hunter - Hunter no Keifu and Monster Rancher Explorer.
1 parent d03844b commit 2d1d51d

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

src/gb/V7/gbGfx.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,16 @@ void gbRenderLine()
4848
u8 *bank1;
4949
if (gbCgbMode)
5050
{
51-
bank0 = &gbVram[0x0000];
52-
bank1 = &gbVram[0x2000];
51+
if (register_VBK & 1)
52+
{
53+
bank0 = &gbVram[0x0000];
54+
bank1 = &gbVram[0x2000];
55+
}
56+
else
57+
{
58+
bank0 = &gbVram[0x0000];
59+
bank1 = &gbVram[0x2000];
60+
}
5361
}
5462
else
5563
{

src/gb/V8/GB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,7 @@ u8 gbReadOpcode(register u16 address)
17601760
return register_SCX;
17611761
case 0x44:
17621762
if (((gbHardware & 7) && ((gbLcdMode == 1) && (gbLcdTicks == 0x71))) ||
1763-
(!(register_LCDC && 0x80)))
1763+
(!(register_LCDC & 0x80)))
17641764
return 0;
17651765
else
17661766
return register_LY;
@@ -2058,7 +2058,7 @@ u8 gbReadMemoryWrapped(register u16 address)
20582058
return register_SCX;
20592059
case 0x44:
20602060
if (((gbHardware & 7) && ((gbLcdMode == 1) && (gbLcdTicks == 0x71))) ||
2061-
(!(register_LCDC && 0x80)))
2061+
(!(register_LCDC & 0x80)))
20622062
return (0);
20632063
else
20642064
return register_LY;

src/gb/V8/gbGfx.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "gbGlobals.h"
55
#include "gbSGB.h"
66

7+
using namespace std;
8+
79
extern int32 layerSettings;
810
extern int32 inUseRegister_WY;
911
extern int32 inUseRegister_WX;
@@ -53,8 +55,16 @@ void gbRenderLine()
5355
u8 *bank1;
5456
if (gbCgbMode)
5557
{
56-
bank0 = &gbVram[0x0000];
57-
bank1 = &gbVram[0x2000];
58+
if (register_VBK & 1)
59+
{
60+
bank0 = &gbVram[0x0000];
61+
bank1 = &gbVram[0x2000];
62+
}
63+
else
64+
{
65+
bank0 = &gbVram[0x0000];
66+
bank1 = &gbVram[0x2000];
67+
}
5868
}
5969
else
6070
{
@@ -192,8 +202,8 @@ void gbRenderLine()
192202
by = sy & 7;
193203

194204
tile_pattern_address = tile_pattern + tile * 16 + by * 2;
195-
tile_map_line_y = tile_map + ty * 32;
196-
tile_map_address = tile_map_line_y + tx;
205+
tile_map_line_y = tile_map + ty * 32;
206+
tile_map_address = tile_map_line_y + tx;
197207

198208
if (bank1)
199209
attrs = bank1[tile_map_line_y + tx];
@@ -215,8 +225,9 @@ void gbRenderLine()
215225
{
216226
u16 color = gbColorOption ? gbColorFilter[0x7FFF] : 0x7FFF;
217227
if (!gbCgbMode)
218-
color = gbColorOption ? gbColorFilter[gbPalette[gbBgpLine[i + (gbSpeed ? 5 : 11) + gbSpritesTicks[i] * (gbSpeed ? 2 : 4)] & 3] & 0x7FFF] :
219-
gbPalette[gbBgpLine[i + (gbSpeed ? 5 : 11) + gbSpritesTicks[i] * (gbSpeed ? 2 : 4)] & 3] & 0x7FFF;
228+
color = gbColorOption ?
229+
gbColorFilter[gbPalette[gbBgpLine[i + (gbSpeed ? 5 : 11) + gbSpritesTicks[i] * (gbSpeed ? 2 : 4)] & 3] & 0x7FFF] :
230+
gbPalette[gbBgpLine[i + (gbSpeed ? 5 : 11) + gbSpritesTicks[i] * (gbSpeed ? 2 : 4)] & 3] & 0x7FFF;
220231
gbLineMix[i] = color;
221232
gbLineBuffer[i] = 0;
222233
}
@@ -230,14 +241,12 @@ void gbRenderLine()
230241
{
231242
if (y >= inUseRegister_WY)
232243
{
233-
// layer settings shall not affect timings
234-
if (layerSettings & 0x2000)
244+
int wx = inUseRegister_WX - 7;
245+
int wy = inUseRegister_WY;
246+
if (wx <= 159 && gbWindowLine <= 143 && gbWindowLine >= 0)
235247
{
236-
int wx = inUseRegister_WX - 7;
237-
int wy = inUseRegister_WY;
238-
int swx = 0;
239-
240-
if (wx <= 159 && gbWindowLine <= 143 && gbWindowLine >= 0)
248+
// layer settings shall not affect timings
249+
if (layerSettings & 0x2000)
241250
{
242251
tile_map = 0x1800;
243252

@@ -252,6 +261,7 @@ void gbRenderLine()
252261

253262
// Tries to emulate the 'window scrolling bug' when wx == 0 (ie. wx-7 == -7).
254263
// Nothing close to perfect, but good enought for now...
264+
int swx = 0;
255265
if (wx == -7)
256266
{
257267
swx = 7 - ((gbSCXLine[0] - 1) & 7);
@@ -275,7 +285,7 @@ void gbRenderLine()
275285
wx = 0;
276286
}
277287

278-
tile_map_line_y = tile_map + ty * 32;
288+
tile_map_line_y = tile_map + ty * 32;
279289
tile_map_address = tile_map_line_y + tx;
280290

281291
tile = bank0[tile_map_address];
@@ -382,10 +392,9 @@ void gbRenderLine()
382392

383393
//for (int i = swx; i<160; i++)
384394
// gbLineMix[i] = gbWindowColor[i];
395+
gbWindowLine++;
385396
}
386397
}
387-
388-
gbWindowLine++;
389398
}
390399
}
391400
}

0 commit comments

Comments
 (0)