mirror of https://github.com/bsnes-emu/bsnes.git
speling is veri difikult
This commit is contained in:
parent
89713521d4
commit
95af00a752
|
@ -819,7 +819,7 @@ static bool registers(GB_gameboy_t *gb, char *arguments, char *modifiers, const
|
||||||
GB_log(gb, "AF = $%04x (%c%c%c%c)\n", gb->registers[GB_REGISTER_AF], /* AF can't really be an address */
|
GB_log(gb, "AF = $%04x (%c%c%c%c)\n", gb->registers[GB_REGISTER_AF], /* AF can't really be an address */
|
||||||
(gb->f & GB_CARRY_FLAG)? 'C' : '-',
|
(gb->f & GB_CARRY_FLAG)? 'C' : '-',
|
||||||
(gb->f & GB_HALF_CARRY_FLAG)? 'H' : '-',
|
(gb->f & GB_HALF_CARRY_FLAG)? 'H' : '-',
|
||||||
(gb->f & GB_SUBSTRACT_FLAG)? 'N' : '-',
|
(gb->f & GB_SUBTRACT_FLAG)? 'N' : '-',
|
||||||
(gb->f & GB_ZERO_FLAG)? 'Z' : '-');
|
(gb->f & GB_ZERO_FLAG)? 'Z' : '-');
|
||||||
GB_log(gb, "BC = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_BC], false));
|
GB_log(gb, "BC = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_BC], false));
|
||||||
GB_log(gb, "DE = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_DE], false));
|
GB_log(gb, "DE = %s\n", value_to_string(gb, gb->registers[GB_REGISTER_DE], false));
|
||||||
|
|
|
@ -98,7 +98,7 @@ enum {
|
||||||
enum {
|
enum {
|
||||||
GB_CARRY_FLAG = 16,
|
GB_CARRY_FLAG = 16,
|
||||||
GB_HALF_CARRY_FLAG = 32,
|
GB_HALF_CARRY_FLAG = 32,
|
||||||
GB_SUBSTRACT_FLAG = 64,
|
GB_SUBTRACT_FLAG = 64,
|
||||||
GB_ZERO_FLAG = 128,
|
GB_ZERO_FLAG = 128,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -318,7 +318,7 @@ static void inc_hr(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
uint8_t register_id;
|
uint8_t register_id;
|
||||||
register_id = ((opcode >> 4) + 1) & 0x03;
|
register_id = ((opcode >> 4) + 1) & 0x03;
|
||||||
gb->registers[register_id] += 0x100;
|
gb->registers[register_id] += 0x100;
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(GB_SUBSTRACT_FLAG | GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(GB_SUBTRACT_FLAG | GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
||||||
|
|
||||||
if ((gb->registers[register_id] & 0x0F00) == 0) {
|
if ((gb->registers[register_id] & 0x0F00) == 0) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
||||||
|
@ -334,7 +334,7 @@ static void dec_hr(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
register_id = ((opcode >> 4) + 1) & 0x03;
|
register_id = ((opcode >> 4) + 1) & 0x03;
|
||||||
gb->registers[register_id] -= 0x100;
|
gb->registers[register_id] -= 0x100;
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_SUBTRACT_FLAG;
|
||||||
|
|
||||||
if ((gb->registers[register_id] & 0x0F00) == 0xF00) {
|
if ((gb->registers[register_id] & 0x0F00) == 0xF00) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
||||||
|
@ -396,7 +396,7 @@ static void add_hl_rr(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
register_id = (opcode >> 4) + 1;
|
register_id = (opcode >> 4) + 1;
|
||||||
rr = gb->registers[register_id];
|
rr = gb->registers[register_id];
|
||||||
gb->registers[GB_REGISTER_HL] = hl + rr;
|
gb->registers[GB_REGISTER_HL] = hl + rr;
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(GB_SUBSTRACT_FLAG | GB_CARRY_FLAG | GB_HALF_CARRY_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(GB_SUBTRACT_FLAG | GB_CARRY_FLAG | GB_HALF_CARRY_FLAG);
|
||||||
|
|
||||||
/* The meaning of the Half Carry flag is really hard to track -_- */
|
/* The meaning of the Half Carry flag is really hard to track -_- */
|
||||||
if (((hl & 0xFFF) + (rr & 0xFFF)) & 0x1000) {
|
if (((hl & 0xFFF) + (rr & 0xFFF)) & 0x1000) {
|
||||||
|
@ -432,7 +432,7 @@ static void inc_lr(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
value = (gb->registers[register_id] & 0xFF) + 1;
|
value = (gb->registers[register_id] & 0xFF) + 1;
|
||||||
gb->registers[register_id] = (gb->registers[register_id] & 0xFF00) | value;
|
gb->registers[register_id] = (gb->registers[register_id] & 0xFF00) | value;
|
||||||
|
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(GB_SUBSTRACT_FLAG | GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(GB_SUBTRACT_FLAG | GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
||||||
|
|
||||||
if ((gb->registers[register_id] & 0x0F) == 0) {
|
if ((gb->registers[register_id] & 0x0F) == 0) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
||||||
|
@ -452,7 +452,7 @@ static void dec_lr(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
gb->registers[register_id] = (gb->registers[register_id] & 0xFF00) | value;
|
gb->registers[register_id] = (gb->registers[register_id] & 0xFF00) | value;
|
||||||
|
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_SUBTRACT_FLAG;
|
||||||
|
|
||||||
if ((gb->registers[register_id] & 0x0F) == 0xF) {
|
if ((gb->registers[register_id] & 0x0F) == 0xF) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
||||||
|
@ -533,7 +533,7 @@ static void daa(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
|
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(0xFF00 | GB_ZERO_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(0xFF00 | GB_ZERO_FLAG);
|
||||||
|
|
||||||
if (gb->registers[GB_REGISTER_AF] & GB_SUBSTRACT_FLAG) {
|
if (gb->registers[GB_REGISTER_AF] & GB_SUBTRACT_FLAG) {
|
||||||
if (gb->registers[GB_REGISTER_AF] & GB_HALF_CARRY_FLAG) {
|
if (gb->registers[GB_REGISTER_AF] & GB_HALF_CARRY_FLAG) {
|
||||||
result = (result - 0x06) & 0xFF;
|
result = (result - 0x06) & 0xFF;
|
||||||
}
|
}
|
||||||
|
@ -567,19 +567,19 @@ static void daa(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
static void cpl(GB_gameboy_t *gb, uint8_t opcode)
|
static void cpl(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
{
|
{
|
||||||
gb->registers[GB_REGISTER_AF] ^= 0xFF00;
|
gb->registers[GB_REGISTER_AF] ^= 0xFF00;
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG | GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG | GB_SUBTRACT_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scf(GB_gameboy_t *gb, uint8_t opcode)
|
static void scf(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
{
|
{
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(GB_HALF_CARRY_FLAG | GB_SUBSTRACT_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(GB_HALF_CARRY_FLAG | GB_SUBTRACT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ccf(GB_gameboy_t *gb, uint8_t opcode)
|
static void ccf(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
{
|
{
|
||||||
gb->registers[GB_REGISTER_AF] ^= GB_CARRY_FLAG;
|
gb->registers[GB_REGISTER_AF] ^= GB_CARRY_FLAG;
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(GB_HALF_CARRY_FLAG | GB_SUBSTRACT_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(GB_HALF_CARRY_FLAG | GB_SUBTRACT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ld_dhli_a(GB_gameboy_t *gb, uint8_t opcode)
|
static void ld_dhli_a(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
|
@ -610,7 +610,7 @@ static void inc_dhl(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
value = cycle_read(gb, gb->registers[GB_REGISTER_HL]) + 1;
|
value = cycle_read(gb, gb->registers[GB_REGISTER_HL]) + 1;
|
||||||
cycle_write(gb, gb->registers[GB_REGISTER_HL], value);
|
cycle_write(gb, gb->registers[GB_REGISTER_HL], value);
|
||||||
|
|
||||||
gb->registers[GB_REGISTER_AF] &= ~(GB_SUBSTRACT_FLAG | GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~(GB_SUBTRACT_FLAG | GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
||||||
if ((value & 0x0F) == 0) {
|
if ((value & 0x0F) == 0) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
||||||
}
|
}
|
||||||
|
@ -627,7 +627,7 @@ static void dec_dhl(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
cycle_write(gb, gb->registers[GB_REGISTER_HL], value);
|
cycle_write(gb, gb->registers[GB_REGISTER_HL], value);
|
||||||
|
|
||||||
gb->registers[GB_REGISTER_AF] &= ~( GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
gb->registers[GB_REGISTER_AF] &= ~( GB_ZERO_FLAG | GB_HALF_CARRY_FLAG);
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_SUBTRACT_FLAG;
|
||||||
if ((value & 0x0F) == 0x0F) {
|
if ((value & 0x0F) == 0x0F) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
|
||||||
}
|
}
|
||||||
|
@ -763,7 +763,7 @@ static void sub_a_r(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
uint8_t value, a;
|
uint8_t value, a;
|
||||||
value = get_src_value(gb, opcode);
|
value = get_src_value(gb, opcode);
|
||||||
a = gb->registers[GB_REGISTER_AF] >> 8;
|
a = gb->registers[GB_REGISTER_AF] >> 8;
|
||||||
gb->registers[GB_REGISTER_AF] = ((a - value) << 8) | GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] = ((a - value) << 8) | GB_SUBTRACT_FLAG;
|
||||||
if (a == value) {
|
if (a == value) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
||||||
}
|
}
|
||||||
|
@ -781,7 +781,7 @@ static void sbc_a_r(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
value = get_src_value(gb, opcode);
|
value = get_src_value(gb, opcode);
|
||||||
a = gb->registers[GB_REGISTER_AF] >> 8;
|
a = gb->registers[GB_REGISTER_AF] >> 8;
|
||||||
carry = (gb->registers[GB_REGISTER_AF] & GB_CARRY_FLAG) != 0;
|
carry = (gb->registers[GB_REGISTER_AF] & GB_CARRY_FLAG) != 0;
|
||||||
gb->registers[GB_REGISTER_AF] = ((a - value - carry) << 8) | GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] = ((a - value - carry) << 8) | GB_SUBTRACT_FLAG;
|
||||||
|
|
||||||
if ((uint8_t) (a - value - carry) == 0) {
|
if ((uint8_t) (a - value - carry) == 0) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
||||||
|
@ -833,7 +833,7 @@ static void cp_a_r(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
value = get_src_value(gb, opcode);
|
value = get_src_value(gb, opcode);
|
||||||
a = gb->registers[GB_REGISTER_AF] >> 8;
|
a = gb->registers[GB_REGISTER_AF] >> 8;
|
||||||
gb->registers[GB_REGISTER_AF] &= 0xFF00;
|
gb->registers[GB_REGISTER_AF] &= 0xFF00;
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_SUBTRACT_FLAG;
|
||||||
if (a == value) {
|
if (a == value) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
||||||
}
|
}
|
||||||
|
@ -962,7 +962,7 @@ static void sub_a_d8(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
uint8_t value, a;
|
uint8_t value, a;
|
||||||
value = cycle_read_inc_oam_bug(gb, gb->pc++);
|
value = cycle_read_inc_oam_bug(gb, gb->pc++);
|
||||||
a = gb->registers[GB_REGISTER_AF] >> 8;
|
a = gb->registers[GB_REGISTER_AF] >> 8;
|
||||||
gb->registers[GB_REGISTER_AF] = ((a - value) << 8) | GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] = ((a - value) << 8) | GB_SUBTRACT_FLAG;
|
||||||
if (a == value) {
|
if (a == value) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +980,7 @@ static void sbc_a_d8(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
value = cycle_read_inc_oam_bug(gb, gb->pc++);
|
value = cycle_read_inc_oam_bug(gb, gb->pc++);
|
||||||
a = gb->registers[GB_REGISTER_AF] >> 8;
|
a = gb->registers[GB_REGISTER_AF] >> 8;
|
||||||
carry = (gb->registers[GB_REGISTER_AF] & GB_CARRY_FLAG) != 0;
|
carry = (gb->registers[GB_REGISTER_AF] & GB_CARRY_FLAG) != 0;
|
||||||
gb->registers[GB_REGISTER_AF] = ((a - value - carry) << 8) | GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] = ((a - value - carry) << 8) | GB_SUBTRACT_FLAG;
|
||||||
|
|
||||||
if ((uint8_t) (a - value - carry) == 0) {
|
if ((uint8_t) (a - value - carry) == 0) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
||||||
|
@ -1032,7 +1032,7 @@ static void cp_a_d8(GB_gameboy_t *gb, uint8_t opcode)
|
||||||
value = cycle_read_inc_oam_bug(gb, gb->pc++);
|
value = cycle_read_inc_oam_bug(gb, gb->pc++);
|
||||||
a = gb->registers[GB_REGISTER_AF] >> 8;
|
a = gb->registers[GB_REGISTER_AF] >> 8;
|
||||||
gb->registers[GB_REGISTER_AF] &= 0xFF00;
|
gb->registers[GB_REGISTER_AF] &= 0xFF00;
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_SUBSTRACT_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_SUBTRACT_FLAG;
|
||||||
if (a == value) {
|
if (a == value) {
|
||||||
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
gb->registers[GB_REGISTER_AF] |= GB_ZERO_FLAG;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue