📄 galaxian.c
字号:
galaxian_attributesram[offset] = data;}void galaxian_stars_w(int offset,int data){ stars_on = (data & 1); stars_scroll = 0;}void pisces_gfxbank_w(int offset,int data){ gfx_bank = data & 1;}void mooncrgx_gfxextend_w(int offset,int data){ /* for the Moon Cresta bootleg on Galaxian H/W the gfx_extend is located at 0x6000-0x6002. Also, 0x6000 and 0x6001 are reversed. */ if(offset == 1) offset = 0; else if(offset == 0) offset = 1; /* switch 0x6000 and 0x6001 */ if (data) gfx_extend |= (1 << offset); else gfx_extend &= ~(1 << offset);}void mooncrst_gfxextend_w(int offset,int data){ if (data) gfx_extend |= (1 << offset); else gfx_extend &= ~(1 << offset);}/*************************************************************************** Draw the game screen in the given osd_bitmap. Do NOT call osd_update_display() from this function, it will be called by the main emulation engine.***************************************************************************/void galaxian_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh){ int i,offs; /* for every character in the Video RAM, check if it has been modified */ /* since last time and update it accordingly. */ for (offs = videoram_size - 1;offs >= 0;offs--) { if (dirtybuffer[offs]) { int sx,sy,charcode; dirtybuffer[offs] = 0; sx = offs % 32; sy = offs / 32; if (flipscreen[0]) sx = 31 - sx; if (flipscreen[1]) sy = 31 - sy; charcode = videoram[offs]; /* bit 5 of [2*(offs%32)+1] is used only by Moon Quasar */ if (char_bank) { if (galaxian_attributesram[2 * (offs % 32) + 1] & 0x20) charcode += 256; } /* gfx_bank is used by Pisces and japirem/Uniwars only */ if (gfx_bank) charcode += 256; /* gfx_extend is used by Moon Cresta only */ if ((gfx_extend & 4) && (charcode & 0xc0) == 0x80) charcode = (charcode & 0x3f) | (gfx_extend << 6); if (BackGround) { /* Fill with Background colours */ int startx,starty,backline,j; if (Machine->orientation & ORIENTATION_SWAP_XY) { starty = backline = sx * 8; startx = sy * 8; if (Machine->orientation & ORIENTATION_FLIP_X) startx = (255 - startx)-7; if (Machine->orientation & ORIENTATION_FLIP_Y) { starty = (255 - starty); for (i=0;i<8;i++) { for(j=0;j<8;j++) { tmpbitmap->line[starty-i][startx+j] = backcolour[backline+i]; } } } else { for (i=0;i<8;i++) { for(j=0;j<8;j++) { tmpbitmap->line[starty+i][startx+j] = backcolour[backline+i]; } } } } else { starty = sy * 8; startx = backline = sx * 8; if (Machine->orientation & ORIENTATION_FLIP_Y) starty = (255 - starty) - 7; if (Machine->orientation & ORIENTATION_FLIP_X) { startx = (255 - startx); for (i=0;i<8;i++) { for(j=0;j<8;j++) { tmpbitmap->line[starty+i][startx-j] = backcolour[backline+j]; } } } else { for (i=0;i<8;i++) { for(j=0;j<8;j++) { tmpbitmap->line[starty][startx+j] = backcolour[backline+j]; } starty++; } } } /* Overlay foreground */ drawgfx(tmpbitmap,Machine->gfx[0], charcode, galaxian_attributesram[2 * (offs % 32) + 1] & 0x07, flipscreen[0],flipscreen[1], 8*sx,8*sy, 0,TRANSPARENCY_COLOR,0); } else { drawgfx(tmpbitmap,Machine->gfx[0], charcode, galaxian_attributesram[2 * (offs % 32) + 1] & 0x07, flipscreen[0],flipscreen[1], 8*sx,8*sy, 0,TRANSPARENCY_NONE,0); }; } } /* copy the temporary bitmap to the screen */ { int scroll[32]; if (flipscreen[0]) { for (i = 0;i < 32;i++) { scroll[31-i] = -galaxian_attributesram[2 * i]; if (flipscreen[1]) scroll[31-i] = -scroll[31-i]; } } else { for (i = 0;i < 32;i++) { scroll[i] = -galaxian_attributesram[2 * i]; if (flipscreen[1]) scroll[i] = -scroll[i]; } } copyscrollbitmap(bitmap,tmpbitmap,0,0,32,scroll,&Machine->drv->visible_area,TRANSPARENCY_NONE,0); } /* Draw the bullets */ for (offs = 0;offs < galaxian_bulletsram_size;offs += 4) { int x,y; int color; if (offs == 7*4) color = 0; /* yellow */ else color = 1; /* white */ x = 255 - galaxian_bulletsram[offs + 3] - Machine->drv->gfxdecodeinfo[2].gfxlayout->width; y = 255 - galaxian_bulletsram[offs + 1]; if (flipscreen[1]) y = 255 - y; drawgfx(bitmap,Machine->gfx[2], 0, /* this is just a line, generated by the hardware */ color, 0,0, x,y, &Machine->drv->visible_area,TRANSPARENCY_PEN,0); } /* Draw the sprites */ for (offs = spriteram_size - 4;offs >= 0;offs -= 4) { int flipx,flipy,sx,sy,spritecode; sx = (spriteram[offs + 3] + 1) & 0xff; /* ??? */ sy = 240 - spriteram[offs]; if (!sprite_bank) { flipx = spriteram[offs + 1] & 0x40; flipy = spriteram[offs + 1] & 0x80; } else { flipx = flipy = 0; } if (flipscreen[0]) { sx = 241 - sx; /* note: 241, not 240 (this is correct in Amidar, at least) */ flipx = !flipx; } if (flipscreen[1]) { sy = 240 - sy; flipy = !flipy; } /* In Amidar, */ /* Sprites #0, #1 and #2 need to be offset one pixel to be correctly */ /* centered on the ladders in Turtles (we move them down, but since this */ /* is a rotated game, we actually move them left). */ /* Note that the adjustment must be done AFTER handling flipscreen, thus */ /* proving that this is a hardware related "feature" */ /* This is not Amidar, it is Galaxian/Scramble/hundreds of clones, and I'm */ /* not sure it should be the same. A good game to test alignment is Armored Car *//* if (offs <= 2*4) sy++;*/ spritecode = spriteram[offs + 1]; if (!sprite_bank) spritecode &= 0x3f; /* Moon Quasar and Crazy Kong have different bank selection bits*/ if (spriteram[offs + 2] & bank_mask) spritecode += 64; /* gfx_bank is used by Pisces and japirem/Uniwars only */ if (gfx_bank) spritecode += 64; /* gfx_extend is used by Moon Cresta only */ if ((gfx_extend & 4) && (spritecode & 0x30) == 0x20) spritecode = (spritecode & 0x0f) | (gfx_extend << 4); drawgfx(bitmap,Machine->gfx[1], spritecode, spriteram[offs + 2] & 0x07, flipx,flipy, sx,sy, flipscreen[0] ? &spritevisibleareaflipx : &spritevisiblearea,TRANSPARENCY_PEN,0); } /* draw the stars */ if (stars_on) { switch (stars_type) { case 0: /* Galaxian stars */ for (offs = 0;offs < total_stars;offs++) { int x,y; x = (stars[offs].x + stars_scroll/2) % 256; y = stars[offs].y; if ((y & 1) ^ ((x >> 4) & 1)) { if (Machine->orientation & ORIENTATION_SWAP_XY) { int temp; temp = x; x = y; y = temp; } if (Machine->orientation & ORIENTATION_FLIP_X) x = 255 - x; if (Machine->orientation & ORIENTATION_FLIP_Y) y = 255 - y; if (bitmap->line[y][x] == Machine->pens[0] || bitmap->line[y][x] == backcolour[x]) bitmap->line[y][x] = stars[offs].col; } } break; case 1: /* Scramble stars */ case 2: /* Rescue stars */ for (offs = 0;offs < total_stars;offs++) { int x,y; x = stars[offs].x / 2; y = stars[offs].y; if ((stars_type != 2 || x < 128) && /* draw only half screen in Rescue */ ((y & 1) ^ ((x >> 4) & 1))) { if (Machine->orientation & ORIENTATION_SWAP_XY) { int temp; temp = x; x = y; y = temp; } if (Machine->orientation & ORIENTATION_FLIP_X) x = 255 - x; if (Machine->orientation & ORIENTATION_FLIP_Y) y = 255 - y; if (bitmap->line[y][x] == Machine->pens[0] || bitmap->line[y][x] == backcolour[x]) { switch (stars_blink) { case 0: if (stars[offs].code & 1) bitmap->line[y][x] = stars[offs].col; break; case 1: if (stars[offs].code & 4) bitmap->line[y][x] = stars[offs].col; break; case 2: if (stars[offs].x & 4) bitmap->line[y][x] = stars[offs].col; break; case 3: bitmap->line[y][x] = stars[offs].col; break; } } } } break; } }}int galaxian_vh_interrupt(void){ stars_scroll++; return nmi_interrupt();}int scramble_vh_interrupt(void){ static int blink_count; blink_count++; if (blink_count >= 45) { blink_count = 0; stars_blink = (stars_blink + 1) % 4; } return nmi_interrupt();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -