refraction said:doin a good job guysi wish i was as far as some of you! but my emulator ive not even started doing cpu ops yet! but i did give zenogais a bit of a hand the other night, most of it was pretty easy to understand but some are quite baffling!
isnt it fun doing opcodes from 0x40ish to about 0x60?![]()
refraction said:doin a good job guysi wish i was as far as some of you! but my emulator ive not even started doing cpu ops yet! but i did give zenogais a bit of a hand the other night, most of it was pretty easy to understand but some are quite baffling!
isnt it fun doing opcodes from 0x40ish to about 0x60?![]()
bcrew1375 said:Man, you're really kicking my arse.
Edit: Dooooooooooooooooooooooooooooohhhhhhhhhhhhhhhhhhhhhhhhhhh!!!!!!!!!!!!!!!!!!!! I figured out my sprite problem. After trying everything else, I noticed I hadn't implemented the DMA register -_-.
bcrew1375 said:I used to be able to go out of the house and walk around the town with distorted graphics, but now that I've repaired some opcodes, I can't get past name registration. I have a feeling that's it's not the MBC, but some minor bugs in the CPU core.
Edit: Well, Tetris now works flawlessly, except I still haven't implemented the DAA instruction. Would you be so kind as to to tell me the formula you used, aprentice :blush:?
Edit 2: Another thing. Is there any purpose at all to the H and N flags? I haven't seen a single thing that makes use of them.
aprentice said:H and N are used when the AF register is used in opcodes
This is what i used for DAA, but I dont know if its correct, its probably wrong
int hi=(regA>>4)&0x0F;
int lo=(regA)&0x0F;
regA=(hi*10)+lo;
Do you emulate the HALT instruction? I dont have it emulated and I'm not exactly sure how to "correctly" approach it.
bcrew1375 said:I've basically got two variables called 'halted' and 'stopped', which I turn on when either command is executed. I then stop executing opcodes until a interrupt occurs for halted, or a button is pressed for stopped.
void GBProcessorZ80::INC_R()
{
byte value = 0;
switch( opcode )
{
case 0x34:
{
value = readMemory8( registers[0].wds.HL ) + 1;
writeMemory8(registers[0].wds.HL, value);
}
break;
default:
{
opcode >>= 3;
*(registers8[opcode])++;
value = *registers8[opcode];
}
break;
}
if((value&0xF) == 0)
SET_FLAG ( GAMEBOY_FLAG_H );
CLR_FLAG ( GAMEBOY_FLAG_N );
CHECK_ZERO_FLAG( value );
}
void GBProcessorZ80::DEC_R()
{
byte value = 0;
switch( opcode )
{
case 0x35:
{
value = readMemory8( registers[0].wds.HL ) - 1;
writeMemory8(registers[0].wds.HL, value);
}
break;
default:
{
opcode >>= 3;
*(registers8[opcode])--;
value = *registers8[opcode];
}
break;
}
if((value&0x0F) == 0x07)
SET_FLAG ( GAMEBOY_FLAG_H );
CLR_FLAG ( GAMEBOY_FLAG_N );
CHECK_ZERO_FLAG( value );
}
sethmcdoogle said:Check gnuboy's source? It's an open-source GB emulator. Maybe look how they handle it? http://gnuboy.unix-fu.org/
bcrew1375 said:I've been generating interrupts based on the number of cycles executed. I have a counter for the H-Blank and the Timer that holds the number of cycles it takes for a H-Blank or Timer update to occur. Everytime an instruction is executed, I subtract the number of cycles it used from the counter. When the counter hits <= 0, I call a function that updates the I/O registers. Then I reset the counters. When LY hits 144, I generate a V-Blank interrupt. I can't be sure, but I don't seem to be having any trouble with mine.