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 November 21st, 2008, 18:17   #1
Dax
ライチュウ|タオ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,864
[Super/MEGA]CHIPX thread

Let's keep a CHIPX discussion thread.

CHIP8 Specs:
16 8bit general purpose registers(really, 15 registers, as Register F(16) is typically used as a flag for subtraction/addition/sprite collision)
16bit Program Counter(Ranges from 0-0xFFF)
16bit Memory addressing register(referred to as I)
8bit Stack Pointer(can be any size you want, it doesn't matter, but I use 8bit; it simply points to a 16bit elementn the stack)
256 byte stack(16 16bit spaces(something like u16 Stack[16])
4KBytes RAM(512 bytes reserved for chip8 font at location 0x000-0x050(80 bytes), and interpreter(which on emulators, will be zeroes since the interpreter would be useless))
64 x 32 screen resolution
2 colour screen(black and white)
Hex keypad for input(16 keys, labeled 1-0, A-F)


Note: Super/Mega are both backward compatible with CHIP8, and inherit its base specs[except for MEGAChip, which gains colour]. They simply add on to CHIP8.
SuperChip 48 Specs:
128 x 64 screen resolution
Adds 7 8bit registers(HP48 flags?)

SuperChip 48 adds new opcodes:
00CN* Scroll display N lines down
00FB* Scroll display 4 pixels right
00FC* Scroll display 4 pixels left
00FD* Exit CHIP interpreter
00FE* Disable extended screen mode
00FF* Enable extended screen mode for full-screen graphics
DXYN* Show N-byte sprite from M(I) at coords (VX,VY), VF :=
collision. If N=0 and extended mode, show 16x16 sprite.

FX30* Point I to 10-byte font sprite for digit VX (0..9)
FX75* Store V0..VX in RPL user flags (X <= 7)
FX85* Read V0..VX from RPL user flags (X <= 7)

MEGAChip Specs:
- 256x192 resolution
- Indexed coloring (255 colors max + transparency)
- Fixed high-speed speed in megachip mode
- Custom sprite sizes
- Update timing at ClearScreen
- Extended I-register range (24 bit addessing, 32MB max)
- Digitised sound (mono 8bit)
- Downward compability (you can run your old CHIP/S-CHIP games)
- Spritecolor 0 = transparent.
- Spritecollision will occur if (backgroundcolor>0) when plotting spritepixel.

MEGAChip adds new opcodes:
0010+ Disable Megachip mode (MEGAoFF)
0011+ Enable Megachip mode (MEGAON)
01nn+ I=(nn<<16)+nnnn , PC+=2; (LDHI I,nnnnnn , always follow LDHI with a NOP)
02nn+ Load nn-colors palette at I (LDPAL nn)
03nn+ Set Sprite-width to nn (SPRW nn)
04nn+ Set Sprite-height to nn (SPRH nn)
05nn+ Set Screenalpha to nn (ALPHA nn, will become FADE nn)
060n+ Play digitised sound at I (DIGISND), will add n for loop/noloop
0700+ Stop digitised sound (STOPSND)
080n+ Set sprite blendmode (BMODE n) (0=normal,1=25%,2=50%,3=75%,4=addative,5=multiply)
00BN+ Scroll display N lines up (SCRU n)

Documents:
1. Chip8 thread on Emutalk: Chip 8 - EmuTalk.net
3. Cowgod's documentation: Cowgod's Chip-8 Technical Reference
4. Wikipedia: CHIP-8 - Wikipedia, the free encyclopedia
5. David Winter's docs: CHIP8
6. CHIP8 tutorial by Codeslinger(Try to avoid using this unless you really need help since it has full source!): codeslinger.co.uk
7. MEGAChip document from the development kit: chip8.com - Dedicated to Chip-8 , SuperChip and MegaChip Emulation / Development
8. RCA 1802(required for hybrid CHIP8 games) CPU documents:
COSMAC ELF and the TinyELF Emulator - The 1802 in Microcomputer History
RCA 1802 - Wikipedia, the free encyclopedia
The 1802 Instruction Set
http://mess.redump.net/sysinfo:vip
RCA Cosmac VIP - Instruction manual for VP-111
RCA COS/MAC Microprocessor Trainers
RCA 1802
http://www.hobbylabs.org/files/1802/...Manual1976.pdf


Test ROM(s)/Public Domain ROM(s):
Snafu by Shendo
Source to above rom by Shendo
0xFX0A test rom by Shendo
Test rom by tronix286
Test rom by BestCoder

Cool stuff/toys:
Chip8 pascal compiler by tronix286


Update (July 8, 2011): Updated first post with new documentation(thanks, Omegadox!), and a new test rom from BestCoder.

Last edited by Dax; July 8th, 2011 at 18:35.. Reason: Cleaning up post, adding new stuff
Dax is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old November 21st, 2008, 18:19   #2
ShendoXT
Moderator
 
ShendoXT's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 4,372
Cool. I highly recommend that you make a debugger also which can really help you to iron bugs.
__________________
Shendo's software blog

Core i5 2400 3.1 Ghz | ASRock H67M | HD4850 512MB | 8GB DDR3 1333 | 500 GB + 1500 GB HDD
Grundig VLC 7121 C (1080p) 32" | Razer DeathAdder | Logitech G110 | Windows 7 x64
ShendoXT is offline   Reply With Quote
Old November 21st, 2008, 18:19   #3
Squall-Leonhart
Banned
 
Squall-Leonhart's Avatar
 
Join Date: Feb 2006
Location: Sydney, Australia
Posts: 23,270
OpenGL or gtfo!
Squall-Leonhart is offline   Reply With Quote
Old November 21st, 2008, 18:22   #4
Dax
ライチュウ|タオ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,864
Quote:
Originally Posted by Shendo View Post
Cool. I highly recommend that you make a debugger also which can really help you to iron bugs.
Not totally sure how to do that, but I'll read up on it. ;
Dax is offline   Reply With Quote
Old November 21st, 2008, 18:27   #5
P_RePTiLe
PReP - Lizard of Reason
 
P_RePTiLe's Avatar
 
Join Date: Sep 2006
Location: Sweden
Posts: 865
Quote:
Originally Posted by Squall-Leonhart View Post
OpenGL or gtfo!
You DO know what SDL is, right?!
__________________

#1 Main: Intel Core i5 2500k (Sandy Bridge) @ 3.9 Ghz, 8 GB DDR2-XMP RAM @ 1600 Mhz, Geforce GTX 570 (Gainward Phantom), Arch Linux 64-Bit, Win7 64-Bit.

#2 Server:
C2D E8400 @ 3.6 Ghz, 4 GB DDR2-RAM @ 802mhz, XFX GF GTX260 XT -ArchLinux 64-bit.

<- Server Homepage: http://prep.mine.nu ->
P_RePTiLe is offline   Reply With Quote
Old November 21st, 2008, 18:34   #6
Squall-Leonhart
Banned
 
Squall-Leonhart's Avatar
 
Join Date: Feb 2006
Location: Sydney, Australia
Posts: 23,270
Simple Directmedia Layer, can connect with any available API in the system, most commonly video implementation connects to OpenGL.
Squall-Leonhart is offline   Reply With Quote
Old November 21st, 2008, 18:50   #7
cottonvibes
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Planet Vegeta
Posts: 5,235
Quote:
Originally Posted by daxtsu View Post
Not totally sure how to do that, but I'll read up on it. ;
its basically a way to show you what instructions are being run and at what address; it also can show registers, and what they have in them.

you can also make it so that the debugger goes by 1 instruction at a time, so you can find bugs easier.

shendo has a pic of his debugger in his chip8 thread:


anyways, its not really needed, but it helps 'debugging' for problems.
pcsx2's debugger for example, doesn't even work.
__________________

"It was, of course, a lie what you read about my religious convictions, a lie which is being systematically repeated. I do not believe in a personal God and I have never denied this but have expressed it clearly. If something is in me which can be called religious then it is the unbounded admiration for the structure of the world so far as our science can reveal it." - Albert Einstein
check out my blog
cottonvibes is offline   Reply With Quote
Old November 21st, 2008, 18:51   #8
ShendoXT
Moderator
 
ShendoXT's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 4,372
Quote:
Originally Posted by daxtsu View Post
Not totally sure how to do that, but I'll read up on it. ;
Well it doesn't have to be anything special.
If you take a look at my thread you will see that my debugger is simply 2 listboxes, one showing values of registers and other disassembled code.
When you have that you are able to check if each opcode you execute gives desired result.

Edit: I see cottonvibes beat me to it
__________________
Shendo's software blog

Core i5 2400 3.1 Ghz | ASRock H67M | HD4850 512MB | 8GB DDR3 1333 | 500 GB + 1500 GB HDD
Grundig VLC 7121 C (1080p) 32" | Razer DeathAdder | Logitech G110 | Windows 7 x64
ShendoXT is offline   Reply With Quote
Old November 21st, 2008, 18:55   #9
Chrono Archangel
 
Chrono Archangel's Avatar
 
Join Date: Dec 2001
Location: Montreal, Canada
Posts: 8,062
ITs always nice to see new people making emulators. Even if its just a small step, its sometimes enough to get them hooked

Hmmm I should redo mine in a standard programming language eventually
Chrono Archangel is offline   Reply With Quote
Old November 21st, 2008, 19:00   #10
Dax
ライチュウ|タオ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,864
I have a question. I'm looking at Cowgod's documentation(http://devernay.free.fr/hacks/chip8/C8TECH10.HTM#3.0) and he says the following about the character data/sprites:

Quote:
The data should be stored in the interpreter area of Chip-8 memory (0x000 to 0x1FF).
He doesn't specify where though. Can I just put the 16 characters[0-F] in the first 80 bytes with no issue?

Also, thanks for all the positive feedback. It's encouraging.
Dax is offline   Reply With Quote
Old November 21st, 2008, 19:16   #11
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 8,267
Yep, put the characters anywhere. Later on, when you run across an opcode that asks for the address, point it there.

P.S.: You may also put your own custom Chip8/SChip instructions there just for lols and giggles when something tries to call a system instruction in those addresses. But that's just for fun. It may mess what you are running up badly... so that's not very recommended.
runawayprisoner is offline   Reply With Quote
Old November 21st, 2008, 19:19   #12
Dax
ライチュウ|タオ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,864
Well, the characters are in the first bytes[0x0-0x5d], the ROM gets loaded at 0x200, and the rest of the RAM is zeroed. Now I'm ready to start fetching opcodes, right? Or did I miss any steps?
Dax is offline   Reply With Quote
Old November 21st, 2008, 19:56   #13
ShendoXT
Moderator
 
ShendoXT's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 4,372
That's basically it.
Don't forget that almost all opcodes increase program counter by 2.
__________________
Shendo's software blog

Core i5 2400 3.1 Ghz | ASRock H67M | HD4850 512MB | 8GB DDR3 1333 | 500 GB + 1500 GB HDD
Grundig VLC 7121 C (1080p) 32" | Razer DeathAdder | Logitech G110 | Windows 7 x64
ShendoXT is offline   Reply With Quote
Old November 21st, 2008, 20:17   #14
Zack
Emu author
 
Zack's Avatar
 
Join Date: Sep 2007
Location: idk
Posts: 266
On the subject.... kind of a silly question but.. how does one decode the opcodes from that list?

I understand 1nnn is an address but what address? One that I specify?
__________________
My iPhone / iPod Touch Games :


Last edited by Zack; November 21st, 2008 at 20:27..
Zack is offline   Reply With Quote
Old November 21st, 2008, 20:18   #15
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 8,267
Actually, I think program counter should be increased by 2 after every opcode regardless. Then if it's an opcode that skips the next instruction, increase the program counter by 2, if it's an opcode that delays the instruction, decrease program counter by 2.
runawayprisoner is offline   Reply With Quote
Old November 21st, 2008, 20:27   #16
Dax
ライチュウ|タオ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,864
Well I think I'm sort of getting it. I have it printing whatever opcodes it finds out to the screen[and it's wildly printing info like zeroes, FF98, etc], but I'm not sure if I'm reading the opcodes correctly.
I set regs.PC equal to 0x200 and have it going from there.

Code:
opcode = RAM[regs.PC] + RAM[regs.PC++];
cout << hex << opcode << endl;
Isn't this where bit shifting is supposed to come in?
Dax is offline   Reply With Quote
Old November 21st, 2008, 20:30   #17
ShendoXT
Moderator
 
ShendoXT's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 4,372
opcode = (RAM[regs.PC]<<8) | RAM[regs.PC+1];

Quote:
Originally Posted by Zack View Post
I understand 1nnn is an address but what address? One that I specify?
If for example you have 1342 opcode which is a jump opcode,
by ANDing that opcode with 0xFFF you will get 0x342 which is the address you have to jump to.
__________________
Shendo's software blog

Core i5 2400 3.1 Ghz | ASRock H67M | HD4850 512MB | 8GB DDR3 1333 | 500 GB + 1500 GB HDD
Grundig VLC 7121 C (1080p) 32" | Razer DeathAdder | Logitech G110 | Windows 7 x64

Last edited by ShendoXT; November 21st, 2008 at 20:38..
ShendoXT is offline   Reply With Quote
Old November 21st, 2008, 20:51   #18
Dax
ライチュウ|タオ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,864
Should I AND the opcodes with 0xFFF or 0xFF? I've been reading Emutalk a bit and I think they said 0xFF. :o
Dax is offline   Reply With Quote
Old November 21st, 2008, 21:14   #19
ShendoXT
Moderator
 
ShendoXT's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 4,372
If you are asking how to know what instruction should be executed when you fetch an opcode you should AND it with 0xF000 and shift it to the right by 12.

You can also use higher part of the opcode (RAM[PC]) to get the same result:
Code:
switch ((RAM[PC] & 0xF0)>>4)
            {
                case 0x00:
                    break;

                case 0x01:
                    break;

                case 0x02:
                    break;

                ...
            }
Some people split opcodes into nibbles so you may also take that approach.
__________________
Shendo's software blog

Core i5 2400 3.1 Ghz | ASRock H67M | HD4850 512MB | 8GB DDR3 1333 | 500 GB + 1500 GB HDD
Grundig VLC 7121 C (1080p) 32" | Razer DeathAdder | Logitech G110 | Windows 7 x64
ShendoXT is offline   Reply With Quote
Old November 21st, 2008, 21:18   #20
Dax
ライチュウ|タオ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,864
Thanks, I'm going to take a break for now. I'll update later. Sorry for all the annoying questions!
Dax 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. The time now is 04:55.

© 2006 - 2008 Emu Forums | About Emu Forums | Advertising Opportunities | Legal | A member of the Crowdgather Forum Community


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