gbz80 - IF语句 [英] gbz80 - IF statements

查看:145
本文介绍了gbz80 - IF语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VisualboyAdvance在Z80上进行编码,我不知道如何进行任何类型的IF语句。

I'm doing some coding in Z80 on VisualboyAdvance and I have no idea how to do an IF statement of any kind.

我制作了一个脚本来增加屏幕上每个图块的值从0xC3A0开始。屏幕数据以0xC507结束。

I made a script to increment the value of each tile on screen starting at 0xC3A0. The screen data ends at 0xC507.

我的代码如下:

    d322|21A0C3|LD HL,C3A0h
    d325|34    |INC (HL)
    d326|23    |INC HL
    d327|00    |NOP
    .
    .
    .
    d340|00    |NOP
    d341|C325D3|JP D325h



你可以看到,它不断循环并最终通过增加核心功能来崩溃游戏。我希望有一种方法可以让它在HL达到0xC507时使用0xC9(Ret)。

As you can see, it loops constantly and eventually crashes the game by incrementing core functions. I'd like a way to have it so it uses 0xC9 (Ret) upon HL reaching 0xC507.

任何帮助都会非常感激。

Any help would be much appreciated.

如果你能向我解释你提供的陈述是如何运作的,那就太好了。机器代码对我来说很陌生。

And if you could explain to me how the statements you provide work, that'd be great. Machine code is foreign to me.

推荐答案

不要使用Visual Boy Advance。

Do NOT use Visual Boy Advance.

它的Game Boy仿真精度非常糟糕,尤其是内存访问时序,这对许多商业ROM来说都是个大问题: http://gbdev.gg8.se/wiki/articles/Test_ROMs#Emulators_running_on_desktop_computers

Its Game Boy emulation accuracy is very bad, especially the memory access timing which is a big problem for many commercial ROMs: http://gbdev.gg8.se/wiki/articles/Test_ROMs#Emulators_running_on_desktop_computers

它还有许多安全漏洞。堆栈缓冲区溢出,让攻击者控制您的计算机。以下是其中之一: https://youtu.be/L-L8qWpd_74

It has also many security vulnerabilities. Stack buffer overflows that let the attacker take control of your machine. Here's one of these: https://youtu.be/L-L8qWpd_74

使用BGB满足您的调试需求,它具有出色的调试器,并且其准确性非常好。

Use BGB for your debugging needs, it features an excellent debugger and its accuracy is very good.

退出循环的条件必须可以在跳转指令上完成,如下所示:

The condition to exit the loop must be done on the jump instruction, like this:

01 67 01         ld   bc,0167            ;0xC507 - 0xC3A0
21 A0 C3         ld   hl,C3A0            ;start of the area we wish to increment
:loop_start
34               inc (hl)                ;(hl) ++
23               inc hl                  ;hl ++
0B               dec  bc                 ;bc --
78               ld   a,b
B1               or   c
20 F9            jr   nz,[loop_start]    ;if(bc ≠ 0), loop to :loop_start
...

这篇关于gbz80 - IF语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆