What's new

Space Invaders

Pixman

New member
Anybody found some new articles or updates on this?

I'm now trying to code a Space Invaders emulator by myself, looks very interesting to me and as a good start before I can approach on something else.

Have some of you already finished an 8080 emulation and can provde source codes? Would be very interesting to me and others I think.

Greets,
Pix
 

Pixman

New member
Yeppa :)
It's going forward.
Your emulator was a big help, by the way. But I'm doign mine completly in C++ / OOP.

The base-structure is finished, now I'm implementing the opcodes and this is why I write: I'm looking for a good opcode-table _with_ cycles.

I don't want to lookup emulator source code all the time.
I only find tables without cycles.

Thanks for your help. :)

I already see, that it was a very good idea to make an I8080 emulator in the first place instead of the gameboy emulator... way more simple.
Greets,
Pix

P.s. I can _really_ recommend the SIDE / PIE source code for understanding the principles of emulation. Helped a lot in my case.
 
OP
hap

hap

New member
I'm looking for a good opcode-table _with_ cycles.

I don't want to lookup emulator source code all the time.
I only find tables without cycles.

lut_cycles + lut_mnemonic in my emulator... source code (sorry :p )
 

smkdan

New member
I have a quick question: There's a couple of operations for the 8080 that aren't documented anywhere it seems. I don't think I missed them, and that pattern looks suspect. They're 0x08, 0x18, 0x28, 0x38. At the moment I'm putting these as NOP's but incase something uses it, how does it react really? Google isn't being the friend people make out to be.

Thanks,
 
OP
hap

hap

New member
how does it react really?
I don't know.

If you're just going for a Space Invaders emulator, substituting undocumented opcodes for NOPs is ok, since it never executes them.
 

smkdan

New member
Ok, thanks. One less thing to consider when problems arise. But now that they have...I want to make sure I got the right idea.

By interrupts CF and D7 you mean RST 1 and RST 2? I have 17066 cycles passing before 1, then another 17066 until the next as another doc here seems to say. With ram mirror on 0x4000+ does it apply to ram *only* or does rom become part of the mirror? I remember seeing in other doc it applies to the whole lot but I'd like to know where the problems may be for sure.

Also, does it actually rely on mirroring to function? I have 0x4000 bytes of memory set aside for rom and ram and I mask accesses with &0x3fff because the app kept crashing with accesses outside of the memory...If it doesn't, I know I have something to sort out.

Thanks again.
 
Last edited:
OP
hap

hap

New member
Interrupts work with the interrupting device putting an opcode on the databus, theoretically this could be any single-byte opcode, in this case indeed RST 1 and 2.

Space Invaders is not very sensitive to timing, so a 50/50 (17066/17066) ratio will probably work. I assumed the interrupts to happen at the start and end of vblank, with timing of 127.35369 cycles per scanline (2mhz/(60/1.001)/262)*, 224 lines active display (28527 cycles) and 38 lines vblank (4839 cycles).
*: assuming standard NTSC with 262 scanlines at ~59.94hz

As for mirroring, I didn't test further than just RAM mirroring (got that info from MAME btw). My emulator writes outside the 'legal' area, which could be caused by a bug in my quickly written only-tested-with-SpaceInvaders 8080 core.
 

smkdan

New member
Ok, I'm getting title screen (sort of) but it's not long before it crashes. It prints the introduction stuff like the score counts and high scores but when it tries to go into the attract gameplay it crashes. Also, everything that is printed is upside down, although they are placed on the right area of the screen...I figured I'd get all or nothing so this is really throwing me off...

sicrashnv4.png

sicrash2no6.png


Any ideas much appreciated because this is casuing an awful lot of head scratching.
 
OP
hap

hap

New member
If the crash is a Windows program crash, it's probably due to the program reading/writing outside of an array. If it's an 'internal' crash, it's most likely due to a bug in your CPU core.

As for the upside-down graphics, when updating the window, you'll have to read the 8 bits from the vram bytes in reversed order. I had the exact same problem.
 

smkdan

New member
I would have never thought of the reverse order video...

Well, I fixed up the rotate instructions so it goes in game and the attract play works great. Still more bugs to work out though, like those wierd bunker hits and the fact that the '0' in the score is deformed when hit (?!) and the alien that fixes up the inverted 'Y' is missing in the attract mode.

Anyway, atleast it'll a be a tad easier now that I get some actual game screen so I can immediately make changes and see them right away.

siattractre0.png
 

smkdan

New member
siworksob9.png


I've been staring at the CPU code for quite a bit when really the in game issues were caused by the shift register shifting left to make room for new data instead of shifting right...The bunker and shots look right and the aliens don't leave impressions of themselves as they advance. I thought all was well but the inverted Y at the second round of attract mode still doesn't have the alien coming out to fix it...This is the last niggling issue left until the game runs perfectly well (atleast to me and SI). I'm clueless as to what's causing it. I had a look at the MAME source but I'm still stuck. I was thinking of trying the NES out but having this irritating issue left...

Hap if you have any clues as to what's causing this it would be much appreciated. Unitl then, I'm going for a NES emulator. I got a good grasp on the 6502 and the PPU. Audio has to wait but I'll try my best to understand it.

sidoesntworkswj5.png
 
OP
hap

hap

New member
It's probably a bug hidden somewhere in your 8080 core. With only one game that can be used for testing (Space Invaders), I understand it's annoying and very hard to find it.
Actually, it might be easy to add support for games using similar hardware, that would make testing easier, but I haven't looked in to that myself. I suggest you just forget about :/ and move on to another fun project, like the NES. Space Invaders isn't worth the irritating hours it may take to find the bug :p
 

krypt100

New member
SI and Phoenix

Here's my progress on SI emulator and Phoenix (it's in JAVA), the i8080 assembly manual on the first page is really helpful for anyone who wants to write his own 8080 cpu core.

I had to copy the interrupt handling and IN/OUT routine from "it's a trap" since I was too lazy to do it myself (I hope you don't mind :))

As for Phoenix, I reused my cpu core (8080, phoenix uses 8085) and implemented the memory emulation.
I used the AEHOWTO.txt doc for the memory emulation and I had to use Jabawape 0.21 src for graphics emulation, since the doc that I found didn't elaborate much on it's video hardware and couldn't fully understand it.
 
Last edited:

Thesuperchang

New member
Hi guys, I've upgraded from Chip-8 to Space Invaders. The emulator is being coded in C (C99 standard) in a 32-bit Linux environment (Ubuntu 8.10). The emulator currently relies on the X Window system. I will re/upload my work as it evolves.

My current status on this project is below;
- i8080 Core 85%
date: 20/01/09
At the moment, it should be able to compile on any little-endian platform that has support for the standard C libraries. However, if your not using a platform that has support for the X Window System, you won't be able to compile with debug mode enabled.

- i8080 disassembler 100%
Date: 20/01/09
Disassembles Intel 8080 machine code. Should be able to compile and run on any platform that supports the standard C libraries. To disassemble machine code type;
Code:
./executable input output

- i8080 Assembler 100%
Date: 21/01/09
Will assemble anything that comes out of the disassembler found above. At the moment it does not contain a user manual containing the mnemonics, nor does it contain a manual of how the input should be structured. All I can recommend at the moment is to find some i8080 machine code and disassemble to get an idea of the programming structure. To assemble assembly code type;
Code:
./executable input output

- System Misc Hardware 10%

- System keypad/coins 0%

- System Graphics 10%

- System Audio 0%

I will not provide any protected i8080 machine code. Sorry.
 
Last edited:

Antígeno

New member
Screen Update Bug

Hi all, i need little from you guys to fix a bug in my space invaders emulator. I'm trying to understand how to update the screen. I'm doing something wrong , cause the player and the aliens are leaving impressions of themselves on screen. If you now how to fix it, let me know. I'm coding in C and Allegro.

thanks anyway
 
Last edited:

CodeSlinger

New member
Without seeing your code it is difficult to guess what you're doing wrong. It sounds to me like you're not clearing the screen after rendering a frame.
 

Antígeno

New member
I'm trying to upload a snapshot, but I'm getting an error message.
Anyway, my basic code.

void ramWrite( unsigned short int address, unsigned char byte ){

siRam[ address ] = byte ;
if( address > 0x2400 )
siVram(address,byte);

}

//
void siVram( unsigned short int address , unsigned char byte ){

int posx, posy, color;
posx = address>>5;
color = address&0x1f;
posy = ((address&0x1F)<<3);
_putpixel32(Buffer,posx,255-((posy) ), byte&1 ? Overlay[color] : black );
_putpixel32(Buffer,posx,255-((posy)+ 1), byte>>1&1 ? Overlay[color] : black );
_putpixel32(Buffer,posx,255-((posy)+ 2), byte>>2&1 ? Overlay[color] : black );
_putpixel32(Buffer,posx,255-((posy)+ 3), byte>>3&1 ? Overlay[color] : black );
_putpixel32(Buffer,posx,255-((posy)+ 4), byte>>4&1 ? Overlay[color] : black );
_putpixel32(Buffer,posx,255-((posy)+ 5), byte>>5&1 ? Overlay[color] : black );
_putpixel32(Buffer,posx,255-((posy)+ 6), byte>>6&1 ? Overlay[color] : black );
_putpixel32(Buffer,posx,255-((posy)+ 7), byte>>7&1 ? Overlay[color] : black );

}

void siIrq( unsigned short int address ){

if ( inte ){

inte=0;
pushpc( pc ) ;
pc = address ;
//no need to decrement cycles
}

}

main(){


//my main loop. Just for test

while(!key[KEY_ESC]){ //

cpuRun( 17000 );
siIrq( 0x0008 );
blit(buffer,screen,0,0,0,0,224,256);
clear_bitmap(buffer);
//wrong way to clean
cpuRun( 17000 );
siIrq( 0x0010 );
// audio/joystick update
}


}

Looks like everything(except timing and sound) that was emulated is ok. But look the picture.

3219176900_49d7d2baa8_o.png


using clear_bitmap(buffer):
3220246974_c91f50f7f8_o.png


I don't now how to fix this bug. I don't understand the right way to work with vram and how to update the screen. The clear_bitmap(buffer) was the last attempt.
 
Last edited:

swatgod

New member
hi, i have been working on space invaders for a while now and i am just about finished, all that remains is that where the alien is supposed to come out to switch the y, it crashes, i have done some debugging and found that at an area where it is adding 20 to the h register pair, that its already to high at this point and causes it to go outside the boundaries of the memory array, would anyone know possibly why this happens?

edit: i figured out the cause of the crash and fixed it. it would seem space invaders needs a minimum (at least mien did to work right) of 0x41B9 bytes of ram to function perfectly and have the alien fix the y without crashing. hope this helps anyone else working on space invaders.
 
Last edited:

Top