Pokemon Center | 口袋中心 以口袋妖怪为主题并带有其他动漫游戏的讨论

标题: 在Github看到一个东西,不知道怎么用 [打印本页]

作者: 744865306    时间: 2021-7-4 08:40
标题: 在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
贴链接吧先
作者: 744865306    时间: 2021-7-4 10:52
海のLUGIA 发表于 2021-7-4 10:01
贴链接吧先

https://github.com/pret/pokeemerald/wiki/Improving-the-WaitForVBlank-function
作者: 744865306    时间: 2021-7-4 15:26
唔……没人理我了
作者: 海のLUGIA    时间: 2021-7-4 22:13
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
-就是去掉的行,+就是增加的行
具体原因楼上说的很明白了
作者: jiangzhengwenjz    时间: 2021-7-5 03:28
本帖最后由 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可能会出问题




欢迎光临 Pokemon Center | 口袋中心 以口袋妖怪为主题并带有其他动漫游戏的讨论 (http://162.218.49.243/) Powered by Discuz! X3