Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 63
  1. #21
    EmuTalk Member albertwesker's Avatar
    Join Date
    Sep 2005
    Posts
    15
    Mentioned
    0 Post(s)
    things are moving along, but i was wondering if someone could explain how to determine if the half-carry flag is to be set or cleared. the P/V flag is a little confusing too, but i haven't come accross an opcode where that flag is affected yet.

    i've read that most emulation problems with the z80 occur because of incorrect flag register implementation...


  2. #22
    Emulator Developer ShizZy's Avatar
    Join Date
    Feb 2005
    Location
    RI, USA
    Posts
    758
    Mentioned
    0 Post(s)
    A carry occurs if the value of a bit carries over to the next bit to the left after an operation occurs. So say if it says to set Flag H if there is a carry from bit3, you check if bit4 (the next bit) is set after the operation. Simple as if(answer&0x10). A half carry is the same as a carry, except that it only occurs in the lower nibble of the byte.

    Just so you know the H and N flags are BCD flags, and thus only used by the DAA function for scores and what not. So H/N flag errors for the most part won't cause a game to break. You should be more concerned about the Carry and Zero flags, which are used for jumps and things.
    ~****Zy

    6Bit.net Emulation & Gaming | Forums
    Gekko GameCube Emulator

  3. #23
    A lowdown dirty shame blueshogun96's Avatar
    Join Date
    Aug 2005
    Location
    Puyallup, WA
    Posts
    194
    Mentioned
    0 Post(s)
    Glad to see that this thread is thiving
    This is me and my PC everyday

    Need a good tutorial on emu programming? Click here. (Link Updated)
    Dynarec article
    Misc emu programming tidbits

  4. #24
    EmuTalk Member albertwesker's Avatar
    Join Date
    Sep 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Quote Originally Posted by ****Zie
    A carry occurs if the value of a bit carries over to the next bit to the left after an operation occurs. So say if it says to set Flag H if there is a carry from bit3, you check if bit4 (the next bit) is set after the operation. Simple as if(answer&0x10). A half carry is the same as a carry, except that it only occurs in the lower nibble of the byte.

    Just so you know the H and N flags are BCD flags, and thus only used by the DAA function for scores and what not. So H/N flag errors for the most part won't cause a game to break. You should be more concerned about the Carry and Zero flags, which are used for jumps and things.
    ****zie, wouldn't it be (answer&0x8) to check the fourth bit? and also, in a carry operation in binary arithmetic, if the fourth bit was already a 1, then a carry from the addition of the third bits would cause the fourth bit to be 0 and cause it to carry to the fifth bit, etc.

    here is an example of this scenario:

    in this case the fourth bit for each operand was already 0, so the carry to the fourth bit made the fourth bit 1 for a binary result of 1000 or 0x8.

    0000 0100
    0000 0100
    ----------
    0000 1000

    here, the fourth bit is already set in one of the operands (in this case, the first), so a carry from the addition of the third bit causes another carry in the addition of the fourth over in to the fifth, resulting in the binary value 10000 or 0x10.

    0000 1100
    0000 0100
    ----------
    0001 0000

    taking this into consideration, i think to figure out if a half carry occurs at the third bit during and INC r instruction, where the register is simply incremented by '1', i would simply do this:

    //run this before the increment operation
    if(reg.B&0x7){
    // then the result is a carry
    }

    in other words if
    reg.B = 0111
    and 0111 + 0001 = 1000 then
    we have a half-carry situation and need to set the appropriate flag.

    perhaps i'm missing something?
    Last edited by albertwesker; December 7th, 2005 at 17:59.

  5. #25
    Emulator Developer ShizZy's Avatar
    Join Date
    Feb 2005
    Location
    RI, USA
    Posts
    758
    Mentioned
    0 Post(s)
    Yeah... it isn't the 4th bit, it's bit 4. There's bits 0-7, so actually it'd be the 5th bit - 0x10. And by bit three they mean the 4th bit. That's how the docs refer to them
    ~****Zy

    6Bit.net Emulation & Gaming | Forums
    Gekko GameCube Emulator

  6. #26
    A lowdown dirty shame blueshogun96's Avatar
    Join Date
    Aug 2005
    Location
    Puyallup, WA
    Posts
    194
    Mentioned
    0 Post(s)
    Ok, I have officially started my SMS emulator a few days ago. Right now, I'm just trying to get my z80 core out of the way. Heh, the jump from the 1802 to the z80 is a bit more difficult than I anticipated, lol.

    I have a quick question about the z80 state flags. This is how I calculate my flags so far.

    // Bit 3 of status thingy
    #define RegX(p) ( ( p >> 3 ) & 0x1 )

    Is there a better way of calculating flags? I'm getting lost quite easily here on the z80 emulation part. My strengths ly in the GPU not CPU :\
    This is me and my PC everyday

    Need a good tutorial on emu programming? Click here. (Link Updated)
    Dynarec article
    Misc emu programming tidbits

  7. #27
    Emulator Developer ShizZy's Avatar
    Join Date
    Feb 2005
    Location
    RI, USA
    Posts
    758
    Mentioned
    0 Post(s)
    You're trying to see if there's a carry from bit 3, right?
    This would be better:

    #define RegX(p) (p&0x10)

    Check bit 4 to see if it'd be carried into the bit 3. Easy as that.
    Last edited by ShizZy; December 20th, 2005 at 21:35.
    ~****Zy

    6Bit.net Emulation & Gaming | Forums
    Gekko GameCube Emulator

  8. #28
    A lowdown dirty shame blueshogun96's Avatar
    Join Date
    Aug 2005
    Location
    Puyallup, WA
    Posts
    194
    Mentioned
    0 Post(s)
    Sorry, it took me so long to reply, thanks for the info Been tied up with other stuff >_>
    This is me and my PC everyday

    Need a good tutorial on emu programming? Click here. (Link Updated)
    Dynarec article
    Misc emu programming tidbits

  9. #29
    EmuTalk Member albertwesker's Avatar
    Join Date
    Sep 2005
    Posts
    15
    Mentioned
    0 Post(s)
    here's an update of where i am. the cpu core is complete and the vdp is nearing completion. rom paging is next, then sound. so far this is easier than i had anticipated. thanks to finally sitting down and pouring through some documentation, things starting coming together. here's an early screenshot of Hang On on the Mega Master System:



    and obviously, there's still quite a bit of work left.

  10. #30
    Emulator Developer ShizZy's Avatar
    Join Date
    Feb 2005
    Location
    RI, USA
    Posts
    758
    Mentioned
    0 Post(s)
    Looking good, keep it up!
    ~****Zy

    6Bit.net Emulation & Gaming | Forums
    Gekko GameCube Emulator

Page 3 of 7 FirstFirst 12345 ... LastLast

Similar Threads

  1. Chanka Compatability List
    By Stezo2k in forum Chankast
    Replies: 923
    Last Post: March 4th, 2009, 21:17
  2. Sega Console Influence in Todays world!
    By SegaBOI in forum Chankast
    Replies: 9
    Last Post: October 15th, 2004, 21:21
  3. Sega Master System screenshots on nsx2 !
    By ShadowPrince in forum nSX2
    Replies: 11
    Last Post: February 10th, 2003, 00:08
  4. Interesting debate on existance of god, worth a read
    By sk8bloke22 in forum Talk of the Town
    Replies: 352
    Last Post: January 14th, 2002, 00:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •