glVertex3f said:I downloaded and installed the MinGW studio again. And I am really enjoying the IDE. A few problems though.
Code:..\..\Emul8\Chip8.cpp:81: error: invalid conversion from `unsigned char*' to ` char*'
That happens here..
Code:bool CPU::LoadRom(char *sFileName) { ifstream Rom(sFileName); if(!Rom.is_open()) return FALSE; Rom.seekg(0, ios::end); long size = Rom.tellg(); Rom.seekg(0, ios::beg); Rom.read(Memory + 0x200, size); <---- HERE Rom.close(); return TRUE; }
Why is this happening and how can I fix it?
edit: Also I had functions named and() or() and xor()
These names seemed to be keywords in this IDE.. why is that.
EDIT2: I did this
Is this acceptable?Code:Rom.read((char*)Memory + 0x200, size);
refraction said:you want unsigned char as its gonna be a hex value from 0x0 to 0xFF in each memory space, signed only does -0x7F to 0x80.
look for mine or zenogais's source in the chip8 thread and have a look at our load rom code to see how we load ours in.
Rom.read(RomBuffer, size);
memcpy(Memory + 0x200, RomBuffer, size);
sethmcdoogle said:This is why I use C I/O, fread uses a void pointer, it just doesn't care what it is so long as it has a place to go.![]()
Rom.read(&RomBuffer, romFileSize);
Rom.seekg(ios::cur, ios::beg);
long size1 = Rom.tellg();
Rom.seekg(ios::cur, ios::end);
long size2 = Rom.tellg();
Rom.seekg(ios::cur, ios::beg);
long romFileSize = (size2 - size1);
Rom.seekg(ios::cur, ios::beg);
long size1 = Rom.tellg();
Rom.seekg(ios::cur, ios::end);
long size2 = Rom.tellg();
Rom.seekg(ios::cur, ios::beg);
long romFileSize = (size2 - size1);
Rom.seekg(ios::cur, ios::end);
long romFileSize = Rom.tellg();
Rom.seekg(ios::cur, ios::beg);
unsigned char stack[16];
refraction said:i woulda thought ud guess that if you had a stack, seen as the opcode comprises of a 16bit hex number
didnt you get any "short to char conversion: data may be lost"
errors when compiling?![]()
sethmcdoogle said:Zenogais:
// C I/O ... it is using void *
int fread( void *buffer, size_t size, size_t num, FILE *stream );
// C++ I/O ... it is using char *
istream &read( char *buffer, streamsize num );
A side note, given that it is an array, you don't have to put the ampersand in the read(&
Ummm bad IDE! BAD!glVertex3f said:Actually the char instead of short was a simplr typo I made in the midst of declaring stuff. And would you believe I didnt get that error/warning at all!
I new it was supposed to be a short but I never thought I woulda made it a char.aperbag:
EDIT:
Yay, Space Invaders runs without crashing!!! Woo...
lol
Question: If a 2d array is not a good idea, how else could I do the graphics?
glVertex3f said:Doomulation, thats how I found the problem, was using the debugger.
refraction, the x y and height being shorts was just something I was trying.
And using Memory[0x200], wouldnt that try to load it into "Memory[0x200]" and not "Memory"?
in.read((char*)memory->get_pointer(0x200), size);
u8* ChipMemory::get_pointer(u16 location) {
return (&memory[location]);
}
glVertex3f said:memcpy(&Memory[0x200], RomBuffer, size);
thanks refraction. It seems to work about the same but this way seems more "correct".