Results 1 to 7 of 7
  1. #1
    EmuTalk Member
    Join Date
    Dec 2018
    Posts
    4
    Mentioned
    0 Post(s)

    Need help drawing in space invaders 8080 emulator

    Hi all,

    I've recently finished my first emulator, chip 8, and decided to move onto space invaders. I've implemented all the instructions required to run space invaders (or, i guess i have, as it now enters into an infinite loop) but I can't work out how to draw. I was hoping it would be similar to how chip 8 draws, but it seems not. I've tried looking at other peoples source on github, but it seems no one comments their code for some reason, and I can't understand the description on the website i linked. Could anyone please explain to me, in clear english, how space invaders is drawn to the screen? Many thanks

  2. #2
    Texture Pack Invader NES_player4LIFE's Avatar
    Join Date
    Nov 2005
    Location
    Earth
    Posts
    2,203
    Mentioned
    21 Post(s)
    I think we have a thread around here somewhere.

    -NES
    We are in the process of archiving all qualifying texture packs!
    Contact me via PM to have your N64 texture pack hosted on Emulation64.com!
    Having a hard time loading Large packs? Be sure to patch your emulator.
    Can't load .DAT or .HTC archives? Look no further then this shiny Tutorial, Android users may use this Tutorial.

      Spoiler:

  3. #3
    EmuTalk Member
    Join Date
    Dec 2018
    Posts
    4
    Mentioned
    0 Post(s)
    I hoped something like this would work:

    Code:
    int offset = 0x2400;
            // i corresponds to each row
    	for (int i=0; i<224; i++) {
                    // there are 32 bytes per scanline
    		for (int j=0; j<32; j++) {
                            // offset + j becuase sprites stored at 0x2400
    			int pixel_group = memory[offset + j];
                            // shift amount for each byte
    			for (int b=0; b<8; b++) {
    				if ((pixel_group >> b) & 1) {
                                            //create pixels
    but it doesn't seem to find any set bits. I'm not sure what I'm doing wrong

  4. #4
    EmuTalk Member
    Join Date
    Dec 2018
    Posts
    4
    Mentioned
    0 Post(s)
    If I can't do this, is there any chance at all of managing to do nes or gameboy? I was so excited when I got the chip 8 up and running, now I'm hopelessly stuck again lol.

  5. #5
    Texture Pack Invader NES_player4LIFE's Avatar
    Join Date
    Nov 2005
    Location
    Earth
    Posts
    2,203
    Mentioned
    21 Post(s)
    Id look into the SpaceInvaders Thread. Im not a programmer myself.
    -NES
    We are in the process of archiving all qualifying texture packs!
    Contact me via PM to have your N64 texture pack hosted on Emulation64.com!
    Having a hard time loading Large packs? Be sure to patch your emulator.
    Can't load .DAT or .HTC archives? Look no further then this shiny Tutorial, Android users may use this Tutorial.

      Spoiler:

  6. #6
    Moderator Robbbert's Avatar
    Join Date
    Aug 2005
    Posts
    103
    Mentioned
    1 Post(s)
    When calculating the byte for memory[], you're not including i.

    Try int pixel_group = memory[offset + j + i*32]; , perhaps?

  7. #7
    EmuTalk Member
    Join Date
    Dec 2018
    Posts
    4
    Mentioned
    0 Post(s)
    Thanks for your replies guys. Yeah, I worked out where I'd gone wrong, this draws draws the writing to the screen
    Code:
    int offset = 0x2400;
    	
    	for (int y=0; y<224; y++) {
    		for (int x=0; x<32; x++) {
    			//printf("%d\n", (y * 32 + x));
    			int pix = memory[offset + (y * 32 + x)];
    			//printf("%d  ", pix);
    			for (int b=0; b<8; b++) {
    				if ((pix >> b) & 1) {
    					Pixel p;
    					p.rect.x = ((x * 8) + b) * PIXEL_SIZE;
    					p.rect.y = y * PIXEL_SIZE;
    					//printf("%d %d\n", p.rect.x, p.rect.y);
    					p.rect.h = PIXEL_SIZE;
    					p.rect.w = PIXEL_SIZE;
    					SDL_SetRenderDrawColor(app.renderer, 255,255,255,255);
    					SDL_RenderFillRect(app.renderer, &p.rect);
    I'm stuck in an infinite loop now lol

    edit: I (finally) got it running in attract mode!!!
    Last edited by dboxall123; December 8th, 2018 at 00:07.

Tags for this Thread

Posting Permissions

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