Page 5 of 9 FirstFirst ... 34567 ... LastLast
Results 41 to 50 of 84

Thread: Space Invaders

  1. #41
    EmuTalk Member
    Join Date
    Aug 2008
    Posts
    3
    Mentioned
    0 Post(s)
    well I started space invaders.

    Got to the point where it was supposed to be showing stuff on the screen but it wasn't working properly and the design was incredibly painful to debug.



    So I restarted and planned it out a bit better.



    It is quite slow right now, I have a bunch of code that I'm just using to debug it that I think might be part fo the problem. Still have quite a few opcodes to implement as well.

  2. #42
    EmuTalk Member
    Join Date
    Sep 2009
    Posts
    4
    Mentioned
    0 Post(s)
    I'm trying to write a Space Invaders emulator to teach myself about writing emulators. I'm a professional programmer in the games industry and I've always been interested in emulators and fancied giving it a go.

    I picked the Space Invaders cabinet because it seems extremely simple. I can theoretically just take existing 8080 or Z80 emulator code and just wire in the required functions to handle memory and whatnot.

    Obviously, in future I'd like to do everything from scratch but as a start I thought I could knock up something like this in a couple of hours easily enough.

    I'm using Marat Fayzullin's Z80 emulator code from http://fms.komkon.org. I've got a 64k memory buffer of which only the first 32k should be being used (16k for the cab and then the mirrored 16k). I'm loading the roms (invaders.h, invaders.g, invaders.f and invaders.e in that order) into the first 8k of my buffer.

    I'm not sure how to do the mirror exactly but at the minute I'm literally just mirroring the first 16k into the second 16k (i.e. 0xab, 0x12, 0xd4 ... 0xd4, 0x12, 0xab).

    The problem I'm having immediately is that only the read memory function from the Z80 emulator code is being accessed. The write memory, read port and write port functions don't get called at all from the Z80 code.

    I'm presuming that the Z80 code starts picking up instructions at address 0x00 (the first element in my memory buffer and the first byte read in from the roms) and just runs from there. The first address it tries to read from is 0x00, followed by 0x01, 0x02, 0x03, 0x04 and 0x05. This would result in the following byte values being accessed 0x00, 0x00, 0x00, 0xc3, 0xd4, 0x18. Now I'm not sure how the Z80 works which is why I'm posting on here but the seventh address it tries to read is 0xd418 which seems strange to me for two reasons. 1) because it's greater than the 32k of memory that the cabinet is supposed to have (16k and 16k mirrored) but the main reason I find it strange is because 0xd418 is the combined value of the last two returned values (from accessing addresses 0x04 and 0x05).

    I'm not sure whether it's a bug in the Z80 code or, more likely, something I'm doing wrong or not understanding.

    My foray into the world of emulation is only a couple of hours long so far but I'm already enjoying it and am hoping someone can point me in the right direction.
    Last edited by redneon; September 25th, 2009 at 23:00.

  3. #43
    EmuTalk Member
    Join Date
    Feb 2005
    Posts
    8
    Mentioned
    0 Post(s)
    space invaders uses a i8080a cpu, which would explain the trouble you are having. z80 wont be able to run the space invaders code at all to my knowledge as they are 2 completely different cpu cores.

  4. #44
    EmuTalk Member
    Join Date
    Aug 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Actually, the Z80 is backwards-compatible with the 8080/5, though there may be a few very differences when it comes to some flags. (for example, the P/V flag seems to be calculated differently)

    For something as simple as booting Space Invaders - this shouldn't be a problem. (though fully running may prove problematic. Or may not.

    Anyway, the program should jump to the valid address 0x18d4, so it seems that your emulator doesn't handle 16-bit words correctly? Maybe your machine's endianess is different from the machine endianess that the CPU emulator expects?


    EDIT:
    Oh and you misunderstood mirroring.
    if, for example, a document says that "0x4000 - 0xffff" is a mirror of "0x2000 - 0x3fff", that means that:
    mem[0x4000] = mem[0x2000]
    mem[0x4001] = mem[0x2001]
    ...
    mem[0x5fff] = mem[0x3fff]
    mem[0x6000] = mem[0x2000]
    ...
    mem[0xffff] = mem[0x3fff]
    Last edited by nameuser; September 26th, 2009 at 01:12.

  5. #45
    EmuTalk Member
    Join Date
    Aug 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Sorry for double posting, but I was wondering what the differences between the Z80 and the 8080 are? (aside from things like timing and the addition of many instructions and features in the Z80)

    Going by the 8080 doc I read, it seems that the 8080 sets the P flag to the result's parity even in arithmetic instructions, while the Z80 sets the P flag to the overflow. Is this true?
    Additionally, there seems to be no trace of the "N" flag in the 8080 doc I've looked through, suggesting that the 8080's DAA instruction always operates as if after addition. Is this true?
    Anything else?

    Are there any "the undocumented documented"-style docs for the 8080/5?
    Thanks.
    Last edited by nameuser; September 26th, 2009 at 03:15.

  6. #46
    EmuTalk Member
    Join Date
    Sep 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Quote Originally Posted by nameuser View Post
    Oh and you misunderstood mirroring.
    So it literally just duplicates the memory byte for byte from a specified address?

    I know it's possible to emulate Space Invaders with a Z80 as a friend from work did it a few years ago. It was he who pointed me to Marat Fayzullin's website. I believe he used Marat Fayzullin's Z80 emulator too but it was a long time ago. 12 years, apparently

    I see what you mean with the endianness but I believe the 8080 and Z80 are both little endian and the platform I'm developing on (x86, surprise surprise) is also little endian, so this shouldn't be an issue.

  7. #47
    EmuTalk Member
    Join Date
    Sep 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Just thought I'd reply and add that I've figured out what the problem was. There's a define in the Z80 code (LSB_FIRST) which enables little endianness (I wrongly assumed this would be done by default).

    I'm on the right track now, at any rate.

  8. #48
    EmuTalk Member
    Join Date
    Sep 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Quick question. I've got it all working now but I don't understand why I need the mirrored memory? The game works exactly the same without it and with a 16k memory buffer.

  9. #49
    I know nothing... Facon's Avatar
    Join Date
    Sep 2009
    Location
    Search in the north of Spain
    Posts
    5
    Mentioned
    0 Post(s)

    Unhappy

    I've problems coding interruptions in 8080, how it should work?, I try to check hap's code, but it's unclear to me, I also check the documentation of the post but it says nothing (apparently) about it.

    Can anybody explains it?
    PD: Sorry for my bad English :S .

  10. #50
    EmuTalk Member
    Join Date
    Aug 2008
    Posts
    3
    Mentioned
    0 Post(s)
    I was just wondering, is it actually necessary to emulate the 8088 auxilary carry flag?

    edit: Okay, based on what I'm seeing it's not needed, but scoring and credits will be messed up if you don't.
    Last edited by serge2k; April 22nd, 2010 at 06:57.

Page 5 of 9 FirstFirst ... 34567 ... LastLast

Similar Threads

  1. help with space channel 5
    By Tails Prower in forum Chankast
    Replies: 2
    Last Post: October 30th, 2004, 12:41
  2. how to manage for the memory space?
    By swings in forum Chankast
    Replies: 4
    Last Post: July 8th, 2004, 13:49
  3. Bug found in Space Station Silicon Valley [E]
    By -Shadow- in forum General Nintendo 64 Emulation Discussion
    Replies: 0
    Last Post: May 22nd, 2004, 14:14
  4. Backfacing culling in ****geneous space?
    By Orkin in forum Emulator Programming
    Replies: 6
    Last Post: January 12th, 2004, 10:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •