Emuforums.com

Go Back   Emuforums.com > General Discussion > Web development / Programming
Home Register Downloads FAQ Members List Calendar Arcade Mark Forums Read

WON'T YOU JOIN US?
You are not a registered member and
are viewing this site as a guest.
Registration is simple and FREE.
Join this CrowdGather community today.
Registration offers the following perks:

» Less advertising throughout
» Post and participate in discussions
» Network with other forum members
» Free private messaging

join

Reply
 
Thread Tools Display Modes
Old May 2nd, 2012, 16:54   #361
tykel
Sober coder
 
tykel's Avatar
 
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!
__________________
tchip16 (chip16 assembler) Js16 (browser chip16 emulator)
mash16 (chip16 emulator) img16 (chip16 sprite converter)
______________________________________

Desktop: i5 750 @ 3.6 Ghz, 4GB ram, GTX 570 OC | Windows 7 Pro 64
Laptop: (Thinkpad) i5 430M, 4GB ram, Intel IGP | Arch Linux, Windows 7 Pro 64
tykel is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old May 2nd, 2012, 21:35   #362
paul_nicholls
Registered User
 
Join Date: Sep 2011
Location: Australia, Tasmania
Posts: 180
Thanks tykel! No worries, back to business now LOL
paul_nicholls is offline   Reply With Quote
Old May 17th, 2012, 08:36   #363
sbeng
Registered User
 
Join Date: Feb 2009
Location: Italy
Posts: 27
Hi,
i have a question: every opcode is of 16 bit size?
sbeng is offline   Reply With Quote
Old May 17th, 2012, 09:13   #364
refraction
PCSX2 Coder
 
refraction's Avatar
 
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/
refraction is offline   Reply With Quote
Old May 17th, 2012, 11:15   #365
tronix286
Registered User
 
tronix286's Avatar
 
Join Date: Aug 2010
Location: Russia, Moscow
Posts: 48
Quote:
Originally Posted by sbeng View Post
Hi,
i have a question: every opcode is of 16 bit size?
Nope. Every opcode have 32-bit size (4 bytes).
tronix286 is offline   Reply With Quote
Old May 17th, 2012, 11:55   #366
refraction
PCSX2 Coder
 
refraction's Avatar
 
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/
refraction is offline   Reply With Quote
Old May 17th, 2012, 13:22   #367
sbeng
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
Then did write a function for reading a ch16 file:

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;
        }
Then i did a start function:

Code:
private void start()
{
            byte[] rom = null;
            
            try
            {
                rom = readRom("C:/download/BC_TestRom.c16");
            }
            catch (Exception e)
            {

            }
            finally
            {
                rom = null;
            }


}
My question is:
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
sbeng is offline   Reply With Quote
Old May 17th, 2012, 17:30   #368
refraction
PCSX2 Coder
 
refraction's Avatar
 
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/
refraction is offline   Reply With Quote
Old May 17th, 2012, 18:31   #369
sbeng
Registered User
 
Join Date: Feb 2009
Location: Italy
Posts: 27
Quote:
Originally Posted by refraction View Post
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.
if it is?
sbeng is offline   Reply With Quote
Old May 17th, 2012, 19:04   #370
refraction
PCSX2 Coder
 
refraction's Avatar
 
Join Date: Jan 2004
Location: Plymouth, UK
Posts: 10,037
Quote:
Originally Posted by sbeng View Post
if it is?
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/
refraction is offline   Reply With Quote
Old May 18th, 2012, 00:46   #371
tykel
Sober coder
 
tykel's Avatar
 
Join Date: Aug 2010
Location: London, UK
Posts: 433
Quote:
Originally Posted by sbeng View Post
if it is?
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.
__________________
tchip16 (chip16 assembler) Js16 (browser chip16 emulator)
mash16 (chip16 emulator) img16 (chip16 sprite converter)
______________________________________

Desktop: i5 750 @ 3.6 Ghz, 4GB ram, GTX 570 OC | Windows 7 Pro 64
Laptop: (Thinkpad) i5 430M, 4GB ram, Intel IGP | Arch Linux, Windows 7 Pro 64
tykel is offline   Reply With Quote
Old May 18th, 2012, 07:13   #372
sbeng
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
sbeng is offline   Reply With Quote
Old May 18th, 2012, 08:56   #373
refraction
PCSX2 Coder
 
refraction's Avatar
 
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 xD

Either 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/
refraction is offline   Reply With Quote
Old May 18th, 2012, 09:31   #374
sbeng
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?
sbeng is offline   Reply With Quote
Old May 18th, 2012, 10:27   #375
refraction
PCSX2 Coder
 
refraction's Avatar
 
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/
refraction is offline   Reply With Quote
Old May 18th, 2012, 18:32   #376
sbeng
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
sbeng is offline   Reply With Quote
Old May 18th, 2012, 19:25   #377
refraction
PCSX2 Coder
 
refraction's Avatar
 
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/
refraction is offline   Reply With Quote
Old May 19th, 2012, 13:19   #378
tykel
Sober coder
 
tykel's Avatar
 
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!
__________________
tchip16 (chip16 assembler) Js16 (browser chip16 emulator)
mash16 (chip16 emulator) img16 (chip16 sprite converter)
______________________________________

Desktop: i5 750 @ 3.6 Ghz, 4GB ram, GTX 570 OC | Windows 7 Pro 64
Laptop: (Thinkpad) i5 430M, 4GB ram, Intel IGP | Arch Linux, Windows 7 Pro 64
tykel is offline   Reply With Quote
Old May 29th, 2012, 09:10   #379
sbeng
Registered User
 
Join Date: Feb 2009
Location: Italy
Posts: 27
Hi,
about Chip opcode documentation of page 1 there is written:

Quote:
B3 YX 00 00 SHL RX, RY Logical Shift value in register X left by the value in (RY & 0xf). Affects [z,n]
B3 YX 00 00 SAL RX, RY Arithmetic Shift value in register X left by the value in (RY & 0xf). Affects [z,n] (same as SHL)
My question is:
how can i know which type of B3 opcode (logical or arithmetic) i need to decode?
Best regards.
sbeng is offline   Reply With Quote
Old May 29th, 2012, 09:21   #380
refraction
PCSX2 Coder
 
refraction's Avatar
 
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/
refraction is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 15:42.

© 2006 - 2012 Emu Forums | About Emu Forums | Advertisers | Investors | Legal | A member of the Crowdgather Forum Community


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.