Emuforums.com

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


Reply
 
LinkBack Thread Tools Display Modes
Old February 27th, 2009   #1 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
my next emulation project

well i chose space invaders as my next emulation project and i have a lot of the information i need to get started but after i created my decompiler to check what opcodes are being used in the space invaders rom, i immediately came across an issue.

besides the mirror of the first 4000 bytes of memory, which even than goes up to what, 8000? the jump that i see immediately at the start makes no sense as it jumps clearly very far outside the memory range of the emulator and could not possibly work, so i was wondering if anyone could point me to a possible reason why it'd do this or maybe tell me what i may have done wrong? i know i decoded the op code right.

also here is the first little bit of my decompiled space invaders rom.

Code:
0000 : 00       NOP
0001 : 00       NOP
0002 : 00       NOP
0003 : C3 D4 C3 JMP C3D4
0006 : 00       NOP
0007 : 00       NOP
0008 : F5       PUSH PSW
0009 : C5       PUSH BC
000A : D5       PUSH DE
000B : E5       PUSH HL
i know i read in the rom the right way so not sure why it would get the first part of the decoding right and the rest of it would just not turn out right. also i have a lot of other jumps that also reference memory locations in the range of CXXX as well.

thanks in advance for any help.

EDIT: fixed this bug already but decided to update the post.

Space Invaders - EmuTalk.net this is where i found the documents i am using for my emulator and it has some other nice information for anyone interested.

i would just include the documents but the file size is to big to attach.

Last edited by Hatorijr; March 3rd, 2009 at 21:18..
Hatorijr is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old February 27th, 2009   #2 (permalink)
Dax
ライチュウ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,289
I don't see a reason to close it, this could be the next sticky perhaps. The Space Invaders Thread?
Dax is offline   Reply With Quote
Old February 27th, 2009   #3 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
well i got some opcodes coded already, i am doing my space invaders emulator in C# like i did my chip8, of course its not going to be as fast as some c/c++ versions but it will get the job done.

if anyone wants any help i can try to help unless its later on when i am finished than i will be sure to help as best i can.
Hatorijr is offline   Reply With Quote
Old February 27th, 2009   #4 (permalink)
Dax
ライチュウ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,289
Do you need docs? I could go Googling. Kinda bored at the moment.
Dax is offline   Reply With Quote
Old February 28th, 2009   #5 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
i already pulled a lot of documents i came across on emutalk which is what i had started reading to get a feel for how things should work, my main issue is effectively detecting when certain flags should be changed lol. i can do just about all of them but the auxiliary carry flag is looking to be a small issue in some cases.
Hatorijr is offline   Reply With Quote
Old February 28th, 2009   #6 (permalink)
Hackin 'n Slashin
 
SCHUMI_4EVER's Avatar
 
Join Date: Jan 2007
Location: Corrupt Rapist run South Africa
Posts: 11,327
you accidentaly inserted 1 instead of 1? what?
__________________
Intel Core2Quad Q9550 (2.83Ghz stock) | ASUS P5Q | 2x2GB Transcend JetRam DDR2-800 | ASUS ENGTX260\HDTP\896M | Windows Vista Home Premium 64bit SP1
The Champ has retired but may his Legacy live on FOREVER !!!!
Get it right fools! The glass is HALF-EMPTY, not half-full!!!
!!! WARNING: Emulation requires a brain !!! WARNING: Emulation =/= Piracy !!!
SCHUMI_4EVER is offline   Reply With Quote
Old February 28th, 2009   #7 (permalink)
Mobile Fanatic
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Santa Cruz, CA
Posts: 6,205
I think he meant 2 instead of 1, Schumi. ;p On some system, opcodes have parameters trailing behind their identifier, thus... length can vary depending on the opcode. The program counter needs to be incremented accordingly or otherwise, you'd start fetching weird stuffs.

Not that I know anything about Space Invaders at all... but I do know that that's almost the case with MIDI and Gameboy. Amen.

On another side note, Chip-8 opcodes have a fixed length of 2 bytes regardless... making it almost "too" easy to emulate... (why so conveniently 2 bytes? lol)
__________________
cChip interpreter WIP - current status: Release Candidate
LRx Filter RC - current performance rating: 9/10
runawayprisoner is offline   Reply With Quote
Old March 1st, 2009   #8 (permalink)
Banned
 
Join Date: Feb 2007
Location: Lost.
Posts: 1,767
Quote:
Chip-8 opcodes have a fixed length of 2 bytes regardless... making it almost "too" easy to emulate...
Yes, why not do a NES/GB emu? OR if you REALLY want a challenge, a SNES/GBA one? (they are both similar in complexity)
mudlord is offline   Reply With Quote
Old March 1st, 2009   #9 (permalink)
Dax
ライチュウ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,289
I believe RAP is already working on a GB emu in Flash/Actionscript.
Dax is offline   Reply With Quote
Old March 1st, 2009   #10 (permalink)
Mobile Fanatic
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Santa Cruz, CA
Posts: 6,205
Quote:
Originally Posted by mudlord View Post
Yes, why not do a NES/GB emu? OR if you REALLY want a challenge, a SNES/GBA one? (they are both similar in complexity)
Well, already worked on GB a bit. I also took a look at GBA and the ARM specifications.

But I decided to halt work due to... well... I just can't get over the fact that I'll need to "legally" own some stuffs to make things work right. Otherwise I'll just be walking down the road that I protest. That's not to say I don't own a GameBoy Advance SP or an old-school Gameboy... but the games... now that's a different story. Relying solely on tech demos may make me overlook something. And I don't like a job half-done. :/

But I'd be glad to document the Gameboy's Z80 CPU and the way opcodes are encoded for future reference, since I'm about done with that for now. GBA... hmm... exophase's gpsp is worth checking out. I think the ARM codes in there are among the fastest (if not the fastest) around.
__________________
cChip interpreter WIP - current status: Release Candidate
LRx Filter RC - current performance rating: 9/10
runawayprisoner is offline   Reply With Quote
Old March 1st, 2009   #11 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
what i did wrong was that see my decompiler just uses a variable i in a giant loop to go through and spit out what the opcodes are and on several that are multibyte, i replaced the i with a 1 and did not catch it(this happened while coding at around 4 am in the morning) and so i got all of those opcodes picking up a byte at the very start which was a c3 byte so all addresses had a c3 at the start of them which messed everything up even though it was still incrementing through memory correctly, it just was picking out the high order byte from the wrong location.

but progress report, i have a lot of opcodes coded so far, not worked on input/output yet so nothing shows but so far those i finished appear to work as they are documented to. after this i think i may take a stab at a gameboy emulator .
Hatorijr is offline   Reply With Quote
Old March 2nd, 2009   #12 (permalink)
Mobile Fanatic
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Santa Cruz, CA
Posts: 6,205
Holy ****...

Now I get it. Much worse than that. lol

That's why you should use something other than a generic i if possible. Something like pc would work... considering that thing is acting as a program counter as it is.
__________________
cChip interpreter WIP - current status: Release Candidate
LRx Filter RC - current performance rating: 9/10
runawayprisoner is offline   Reply With Quote
Old March 2nd, 2009   #13 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
in my actual cpu class i use pc, the i was just for the giant for statement being used in my decompiler. i have nearly half of the opcodes finished so far, though i know i will have a ton of fun once i get to handling timing and the input and output stuff lol.
Hatorijr is offline   Reply With Quote
Old March 2nd, 2009   #14 (permalink)
Dax
ライチュウ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,289
How difficult would you say the 8080[that's in Space Invaders, right?] is compared to CHIP8 so far?
Dax is offline   Reply With Quote
Old March 3rd, 2009   #15 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
not to difficult. i am a math wise and most opcodes i have been doing deals with math so its more of a challenge dealing with how to set the flags correctly than anything. but yes it is a big step going from chip 8 to an actual cpu core with a lot more to check for.
Hatorijr is offline   Reply With Quote
Old March 3rd, 2009   #16 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
can someone please explain to me what vblank is? i saw the term used in the gb documents that i have and also mention of it in some of the stuff i have for space invaders, and since this is the first real emulator i will be making, i have no real idea what this really means .
Hatorijr is offline   Reply With Quote
Old March 3rd, 2009   #17 (permalink)
Dax
ライチュウ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,289
Vertical blank interrupt - Wikipedia, the free encyclopedia
Dax is offline   Reply With Quote
Old March 3rd, 2009   #18 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
thank you that makes a lot more sense now, i am down to the last 3 opcodes before i start fixing bugs and working on getting stuff to show up on screen.
Hatorijr is offline   Reply With Quote
Old March 3rd, 2009   #19 (permalink)
Dax
ライチュウ
 
Dax's Avatar
 
Join Date: Nov 2006
Location: USA
Posts: 3,289
Nice man.

You should update the first post with docs and stuff. Then we could make this a comprehensive SI thread.
Dax is offline   Reply With Quote
Old March 3rd, 2009   #20 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 374
i updated the first post with a link on where i got my information. i would have just attached everything but one of the pdf files is huge so i figured since i could not attach them i would at least post the link to them .

i fixed some bugs earlier so now i can have the cpu running without crashing for several minutes(thats how long i ran it before i stopped it) now to work on getting correct timing and maybe output but than again i need to put in the last 3 opcodes still lol.

btw if anyone is interested, as of right now i have my cpu enclosed in its own class which means it can easily be taken out and ported to another emulator so if anyone would ever like to have a copy of it just ask . of course its not optimized any and needs a lot of condensing but eventually it will be very well optimized.
Hatorijr 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
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:59.

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


Powered by vBulletin® Version 3.7.6
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5