此代码效果很好,并按预期输出像素:
int main()
{
*(unsigned int *)0x04000000 = 0x0403;
unsigned short *Screen = (unsigned short *)0x06000000;
Screen[120 + 80 * 240] = 0x001F;
Screen[136 + 80 * 240] = 0x03E0;
Screen[120 + 96 * 240] = 0x7C00;
Screen[100] = 0x7C00;
while (1);
return 0;
}
但是每当我尝试添加 for 循环并从中更改 vram 值时,我在模拟器上得到白屏,它编译时没有错误甚至警告,但我在模拟器上得到白屏。
int main()
{
*(unsigned int *)0x04000000 = 0x0403;
unsigned short *Screen = (unsigned short *)0x06000000;
Screen[120 + 80 * 240] = 0x001F;
Screen[136 + 80 * 240] = 0x03E0;
Screen[120 + 96 * 240] = 0x7C00;
Screen[100] = 0x7C00;
int i;
for (i = 100; i < 110; i++)
{
Screen[i] = 0x7C00;
}
while (1);
return 0;
}