gameboy

gbz80 - IF statements

不打扰是莪最后的温柔 提交于 2019-12-13 07:29:34
问题 I'm doing some coding in Z80 on VisualboyAdvance and I have no idea how to do an IF statement of any kind. I made a script to increment the value of each tile on screen starting at 0xC3A0. The screen data ends at 0xC507. My code is as follows: d322|21A0C3|LD HL,C3A0h d325|34 |INC (HL) d326|23 |INC HL d327|00 |NOP . . . d340|00 |NOP d341|C325D3|JP D325h 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

table of functions vs switch in golang

ぐ巨炮叔叔 提交于 2019-12-06 00:51:30
问题 im am writing a simple emulator in go (should i? or should i go back to c?). anyway, i am fetching the instruction and decoding it. at this point i have a byte like 0x81, and i have to execute the right function. should i have something like this func (sys *cpu) eval() { switch opcode { case 0x80: sys.add(sys.b) case 0x81: sys.add(sys.c) etc } } or something like this var fnTable = []func(*cpu) { 0x80: func(sys *cpu) { sys.add(sys.b) }, 0x81: func(sys *cpu) { sys.add(sys.c) } } func (sys *cpu

table of functions vs switch in golang

陌路散爱 提交于 2019-12-04 06:29:28
im am writing a simple emulator in go (should i? or should i go back to c?). anyway, i am fetching the instruction and decoding it. at this point i have a byte like 0x81, and i have to execute the right function. should i have something like this func (sys *cpu) eval() { switch opcode { case 0x80: sys.add(sys.b) case 0x81: sys.add(sys.c) etc } } or something like this var fnTable = []func(*cpu) { 0x80: func(sys *cpu) { sys.add(sys.b) }, 0x81: func(sys *cpu) { sys.add(sys.c) } } func (sys *cpu) eval() { return fnTable[opcode](sys) } 1.which one is better? 2.which one is faster? also 3.can i

hdu 1176 免费馅饼

匿名 (未验证) 提交于 2019-12-02 23:49:02
。。免费馅饼 65536/32768 K (Java/Others) Problem Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉 下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉 ,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所 以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他 只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是 个身手敏捷的高手,但在现实中运动神经特别迟钝,每秒种只有在移动不超 过一米的范围内接住坠落的馅饼。现在给这条小径如图标上坐标: 为了使问题简化,假设在接下来的一段时间里,馅饼都掉落在0-10这11个位 置。开始时gameboy站在5这个位置,因此在第一秒,他只能接到4,5,6这三 个位置中其中一个位置上的馅饼。问gameboy最多可能接到多少个馅饼?( 假设他的背包可以容纳无穷多个馅饼) Input 输入数据有多组。每组数据的第一行为以正整数n(0<n<100000),表示有n个 馅饼掉在这条小径上。在结下来的n行中,每行有两个整数x,T (0<T<100000),表示在第T秒有一个馅饼掉在x点上。同一秒钟在同一点上可 能掉下多个馅饼。n=0时输入结束。 Output 每一组输入数据对应一行输出。输出一个整数m

Game Boy emulator with a full debugger?

試著忘記壹切 提交于 2019-12-01 04:29:05
As part of the work I've been doing to answer this question about the technical workings of a glitch in Pokémon Red , I've been looking for a way to use a standard debugger to debug a Game Boy ROM. Although many of the emulators I've found have some support for debugging, nothing I've found so far has been helpful. As a background, as of now I have tried to use the Visual Boy Advance built-in features to do debugging, but they aren't particularly useful for what I'm trying to do. VBA lacks the ability to set breakpoints, and since it steps forward at the level of frames rather than

GBZ80: How does LD HL,(SP+e) affect H and C flags?

放肆的年华 提交于 2019-11-30 05:34:07
问题 On Gameboy Z80, exactly how does the LD HL,(SP+e) operation affect H and C flags? (Half-carry + carry) Reference: http://www.devrs.com/gb/files/opcodes.html 回答1: I realise this is an old question but I had a similar problem a while ago and would just like to add my solution as there is absolutely no documentation or open-source emulator that does it correctly to my knowledge. Took me some actual debugging on a real gameboy to find the solution. For both 16bit SP + s8 (signed immediate)

GBZ80: What constitutes a “half-carry”?

馋奶兔 提交于 2019-11-30 00:26:31
The Game Boy Z80 CPU has a half-carry flag, and I can't seem to find much information about when to set/clear it. What I understand so far is that any 8-bit add, subtract, shift, or rotate operation (and maybe others?) set it to bit 4 of the result(?), and the DAA instruction sets/uses this somehow. What I'm not sure is how 16-bit instructions affect it and whether it's affected or not by the use of certain registers. It's the carry from bit 3 to bit 4, just like the normal carry flag records carry from bit 7. So, e.g. to get the half carry bit in an add: ((a&0xf) + (value&0xf))&0x10 Which

What's the purpose of instructions for loading a register to itself?

Deadly 提交于 2019-11-29 13:33:44
While looking through the Gameboy's instruction set, I came across instructions such as: LD A, A LD B, B LD C, C LD D, D ... Each of these instructions has it's own opcode in this table , which makes me think they are of some importance due to the restrictions on the number of possible opcodes. I first thought that it might be dereferencing a pointer in that register and storing the value at that pointer ( like in this question ), but in an emulator , LD A, A is implemented as: Z80._r.a = Z80._r.a They seem to have no effect on the state of the processor (just set registers to their own value)

A - 猜数字

你离开我真会死。 提交于 2019-11-29 02:43:30
http://acm.hdu.edu.cn/showproblem.php?pid=1172 猜数字 猜数字游戏是gameboy最喜欢的游戏之一。游戏的规则是这样的:计算机随机产生一个四位数,然后玩家猜这个四位数是什么。每猜一个数,计算机都会告诉玩家猜对几个数字,其中有几个数字在正确的位置上。 比如计算机随机产生的数字为1122。如果玩家猜1234,因为1,2这两个数字同时存在于这两个数中,而且1在这两个数中的位置是相同的,所以计算机会告诉玩家猜对了2个数字,其中一个在正确的位置。如果玩家猜1111,那么计算机会告诉他猜对2个数字,有2个在正确的位置。 现在给你一段gameboy与计算机的对话过程,你的任务是根据这段对话确定这个四位数是什么。 Input 输入数据有多组。每组的第一行为一个正整数N(1<=N<=100),表示在这段对话中共有N次问答。在接下来的N行中,每行三个整数A,B,C。gameboy猜这个四位数为A,然后计算机回答猜对了B个数字,其中C个在正确的位置上。当N=0时,输入数据结束。 Output 每组输入数据对应一行输出。如果根据这段对话能确定这个四位数,则输出这个四位数,若不能,则输出"Not sure"。 Sample Input 6 4815 2 1 5716 1 0 7842 1 0 4901 0 0 8585 3 3 8555 3 2 2 4815 0

GBZ80: What constitutes a “half-carry”?

我们两清 提交于 2019-11-27 11:42:37
问题 The Game Boy Z80 CPU has a half-carry flag, and I can't seem to find much information about when to set/clear it. What I understand so far is that any 8-bit add, subtract, shift, or rotate operation (and maybe others?) set it to bit 4 of the result(?), and the DAA instruction sets/uses this somehow. What I'm not sure is how 16-bit instructions affect it and whether it's affected or not by the use of certain registers. 回答1: It's the carry from bit 3 to bit 4, just like the normal carry flag