|
|
|||||||
| Home | Register | Downloads | FAQ | Members List | Calendar | Arcade | Mark Forums Read |
» Less advertising throughout
» Post and participate in discussions
» Network with other forum members
» Free private messaging
![]() |
|
|
Thread Tools | Display Modes |
|
|
#361 |
|
Sober coder
![]() ![]() ![]() Join Date: Aug 2010
Location: London, UK
Posts: 433
|
Great work on your game paul, good job. That said, let's keep discussion on this thread related to Chip16. Don't hesitate to open a new thread in this subforum!
__________________
|
|
|
|
| Advertisement | [Remove Advertisement] | ||
|
|
|
#362 |
|
Registered User
![]() ![]() Join Date: Sep 2011
Location: Australia, Tasmania
Posts: 180
|
Thanks tykel! No worries, back to business now LOL
|
|
|
|
|
|
#363 |
|
Registered User
Join Date: Feb 2009
Location: Italy
Posts: 27
|
Hi, i have a question: every opcode is of 16 bit size? |
|
|
|
|
|
#364 |
|
PCSX2 Coder
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
|
correct
__________________
http://www.pcsx2.net Intel i7 920 @ 3.4Ghz, POV GTX 570 1.3Gb, 1.8Tb HD space, 6Gb OCZ Reaper PC3-14400 Triple Channel Dont PM me for help, use the forums, thats what its for! My Chip16 Emulator RefChip16 http://code.google.com/p/refchip16/
|
|
|
|
|
|
#365 |
|
Registered User
Join Date: Aug 2010
Location: Russia, Moscow
Posts: 48
|
|
|
|
|
|
|
#366 |
|
PCSX2 Coder
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
|
That'll teach me to post without thinking lol. It is 32, had 16 on the brain >.<
__________________
http://www.pcsx2.net Intel i7 920 @ 3.4Ghz, POV GTX 570 1.3Gb, 1.8Tb HD space, 6Gb OCZ Reaper PC3-14400 Triple Channel Dont PM me for help, use the forums, thats what its for! My Chip16 Emulator RefChip16 http://code.google.com/p/refchip16/
|
|
|
|
|
|
#367 |
|
Registered User
Join Date: Feb 2009
Location: Italy
Posts: 27
|
Hi, thank you for your reply ![]() I'm coding a simple CHIP16 emulator in C#. First i did declare some variables: Code:
private static short PC;
private static short SP;
private static short[] REG = new short[16];
private static BitArray flag_reg = new BitArray(8);
private static byte[] memory = new byte[65536];
private static int[] color = new int[16]
{0x000000,0x000000, //(Black)
0x888888, //(Gray)
0xBF3932, //(Red)
0xDE7AAE, //(Pink)
0x4C3D21, //(Dark brown)
0x905F25, //(Brown)
0xE49452, //(Orange)
0xEAD979, // (Yellow)
0x537A3B, // (Green)
0xABD54A, // (Light green)
0x252E38, // (Dark blue)
0x00467F, // (Blue)
0x68ABCC, // (Light blue)
0xBCDEE4, // (Sky blue)
0xFFFFFF
};
private static int[] opcode = new int[40]; //40 is temp number
Code:
private static byte[] readRom(String path)
{
FileStream fs = null;
byte[] raw = null;
byte[] arrTemp = new byte[1];
int pos = 0;
try
{
fs = new FileStream(path, FileMode.Open,FileAccess.Read);
raw = new byte[fs.Length];
//header
fs.Read(raw, 0, 16);
PC = raw[10]; //initial value of PC
//lettura contenuto del file
pos = 16;
while (true)
{
int read = fs.Read(arrTemp, 0, 1);
if (read < 0) break;
raw[pos] = arrTemp[0];
}
}
catch (Exception e)
{
Console.Write(e.ToString());
throw e;
}
finally
{
if (fs != null) fs.Close();
fs = null;
arrTemp = null;
}
return raw;
}
Code:
private void start()
{
byte[] rom = null;
try
{
rom = readRom("C:/download/BC_TestRom.c16");
}
catch (Exception e)
{
}
finally
{
rom = null;
}
}
after i have called readRom function, i need "copy" variable rom content in memory variable? If i'll read rom array (after 16th element) i'll can read opcodes? Best regards, sbeng |
|
|
|
|
|
#368 |
|
PCSX2 Coder
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
|
ignore the first 16 bytes of the rom and copy the rest in to the memory array starting at 0, worry about the header stuff later ;p or you can do what i do and check the first 4 bytes to see if its "CH16", if it isnt, copy the lot starting at 0, if it isnt, skip the first 16 bytes then copy from there in to memory starting at 0.
__________________
http://www.pcsx2.net Intel i7 920 @ 3.4Ghz, POV GTX 570 1.3Gb, 1.8Tb HD space, 6Gb OCZ Reaper PC3-14400 Triple Channel Dont PM me for help, use the forums, thats what its for! My Chip16 Emulator RefChip16 http://code.google.com/p/refchip16/
|
|
|
|
|
|
#369 | |
|
Registered User
Join Date: Feb 2009
Location: Italy
Posts: 27
|
Quote:
|
|
|
|
|
|
|
#370 |
|
PCSX2 Coder
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
|
if there is no "CH16" at the beginning there is no header, so just copy from the start of the file
__________________
http://www.pcsx2.net Intel i7 920 @ 3.4Ghz, POV GTX 570 1.3Gb, 1.8Tb HD space, 6Gb OCZ Reaper PC3-14400 Triple Channel Dont PM me for help, use the forums, thats what its for! My Chip16 Emulator RefChip16 http://code.google.com/p/refchip16/
|
|
|
|
|
|
#371 |
|
Sober coder
![]() ![]() ![]() Join Date: Aug 2010
Location: London, UK
Posts: 433
|
Yeah, there's a typo there. He just means only read from offset 0 if the first 4 bytes are 'CH16', otherwise read from offset 16 into your memory buffer.
__________________
|
|
|
|
|
|
#372 |
|
Registered User
Join Date: Feb 2009
Location: Italy
Posts: 27
|
I would to parse 2 ch16 types of file, one with CH16 header and one without. Which files can i parse into Chip16 program pack 08.04.2011 (ie: BC_TestRom.c16 file seem to not contain header)? Best regards. sbeng |
|
|
|
|
|
#373 |
|
PCSX2 Coder
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
|
pretty much yes The newest pack from this year should have headers on everything, but its good to check just in case xDEither that or just throw an error if the first 4 bytes arent "CH16"
__________________
http://www.pcsx2.net Intel i7 920 @ 3.4Ghz, POV GTX 570 1.3Gb, 1.8Tb HD space, 6Gb OCZ Reaper PC3-14400 Triple Channel Dont PM me for help, use the forums, thats what its for! My Chip16 Emulator RefChip16 http://code.google.com/p/refchip16/
|
|
|
|
|
|
#374 |
|
Registered User
Join Date: Feb 2009
Location: Italy
Posts: 27
|
Do you have ch16 files with header yet so i can download them and test my project?
|
|
|
|
|
|
#375 |
|
PCSX2 Coder
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
|
There are lots, just grab this http://forums.ngemu.com/attachment.p...5&d=1331761600
__________________
http://www.pcsx2.net Intel i7 920 @ 3.4Ghz, POV GTX 570 1.3Gb, 1.8Tb HD space, 6Gb OCZ Reaper PC3-14400 Triple Channel Dont PM me for help, use the forums, thats what its for! My Chip16 Emulator RefChip16 http://code.google.com/p/refchip16/
|
|
|
|
|
|
#376 |
|
Registered User
Join Date: Feb 2009
Location: Italy
Posts: 27
|
Hi all, in Chip16 documentation there is written: Memory: -------- 64 KB (65536 bytes). 0x0000 - Start of ROM. 0xFDF0 - Start of stack (512 bytes). 0xFFF0 - IO ports. I could to create a byte array of 65536 bytes then i write rom content in this array. So i'll obtain follow schema: memory array ---> contains ---->rom data + remains n zero values (in this 00000000000 section there is stack bytes and IO ports bytes). Does the stack contain 256 items of 2 byte for each ones? Is my schema ok? Best regards, sbeng |
|
|
|
|
|
#377 |
|
PCSX2 Coder
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
|
Yes, the stack stores the PC one on top of the other when they are added so a Max of 256 entries. Yes the memory is just one huge chunk. just zero the entire thing on reset/startup, then load the rom in to the beginning of it, that's the easiest way to do it. then just keep a pointer for your stack and monitor it doesnt go above 0xFFED or below 0xFDF0
__________________
http://www.pcsx2.net Intel i7 920 @ 3.4Ghz, POV GTX 570 1.3Gb, 1.8Tb HD space, 6Gb OCZ Reaper PC3-14400 Triple Channel Dont PM me for help, use the forums, thats what its for! My Chip16 Emulator RefChip16 http://code.google.com/p/refchip16/
|
|
|
|
|
|
#378 |
|
Sober coder
![]() ![]() ![]() Join Date: Aug 2010
Location: London, UK
Posts: 433
|
Just a quick shout to say exam period is over, so I have free time again. Yay! ![]() So I'm currently working on my emulator again, which I'm rewriting from scratch. (The previous version was going nowhere and was getting hacky, so binned it) I also want to write some more little games in due course... Something I want to try is compression, we'll see where that takes me!
__________________
|
|
|
|
|
|
#379 | |
|
Registered User
Join Date: Feb 2009
Location: Italy
Posts: 27
|
Hi, about Chip opcode documentation of page 1 there is written: Quote:
how can i know which type of B3 opcode (logical or arithmetic) i need to decode? Best regards. |
|
|
|
|
|
|
#380 |
|
PCSX2 Coder
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
|
Its the same thing when shifting left as you're pushing out the sign so just use the same opcode
__________________
http://www.pcsx2.net Intel i7 920 @ 3.4Ghz, POV GTX 570 1.3Gb, 1.8Tb HD space, 6Gb OCZ Reaper PC3-14400 Triple Channel Dont PM me for help, use the forums, thats what its for! My Chip16 Emulator RefChip16 http://code.google.com/p/refchip16/
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|