744865306 发表于 2021-7-4 08:40:57

在Github看到一个东西,不知道怎么用

static void WaitForVBlank(void)
{
    gMain.intrCheck &= ~INTR_FLAG_VBLANK;
-   while (!(gMain.intrCheck & INTR_FLAG_VBLANK))
-       ;
+   asm("swi 0x5");
}

这个东西怎么用?求大佬们解答

海のLUGIA 发表于 2021-7-4 10:01:50

贴链接吧先

744865306 发表于 2021-7-4 10:52:19

海のLUGIA 发表于 2021-7-4 10:01
贴链接吧先

https://github.com/pret/pokeemerald/wiki/Improving-the-WaitForVBlank-function

744865306 发表于 2021-7-4 15:26:45

唔……没人理我了

海のLUGIA 发表于 2021-7-4 22:13:24

744865306 发表于 2021-7-4 10:52
https://github.com/pret/pokeemerald/wiki/Improving-the-WaitForVBlank-function

- -|||你要知道现在GBA都被彻底扒掉了,你这问题可真是够底层的研究…重点在这:

In Emerald, Gamefreak used a while loop that kept on checking for VBlank over and over again. However, this approach is very wasteful. The while loop is not doing anything, so all it does is waste CPU cycles, and burning CPU cycles like this burns battery power.

你理解为绿宝石(应该还包含火叶)技术力堪忧,写了个函数但while循环没有做任何事情,所以它所做的只是浪费CPU周期,像这样燃烧CPU周期会消耗电池电量。

所以他叫你替换成红蓝宝石用的函数…

jiangzhengwenjz 发表于 2021-7-5 03:20:50

-就是去掉的行,+就是增加的行
具体原因楼上说的很明白了

jiangzhengwenjz 发表于 2021-7-5 03:28:42

本帖最后由 jiangzhengwenjz 于 2021-7-5 06:06 编辑

海のLUGIA 发表于 2021-7-4 22:13
- -|||你要知道现在GBA都被彻底扒掉了,你这问题可真是够底层的研究…重点在这:

In Emerald, Gamefre ...

感觉应该写asm("swi\t5":::"r0", "r1", "r2", "r3", "cc", "memory");
否则在某些编译条件下被inline可能会出问题
页: [1]
查看完整版本: 在Github看到一个东西,不知道怎么用