⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cave.c

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 C
📖 第 1 页 / 共 5 页
字号:
   layer_id_data[0] = add_layer_info(layer_id_name[0]);   layer_id_data[1] = 0;   layer_id_data[2] = 0;   layer_id_data[3] = add_layer_info(layer_id_name[3]);/* *  StarScream Stuff follows */   ByteSwap(ROM,0x100000);   ByteSwap(RAM,0x048000);   AddMemFetch(0x000000, 0x0FFFFF, ROM+0x000000-0x000000);      // 68000 ROM   AddReadByte(0x000000, 0x0FFFFF, NULL, ROM+0x000000);         // 68000 ROM   AddReadByte(0x100000, 0x10FFFF, NULL, RAM+0x000000);         // 68000 RAM   AddReadBW(0x300002,0x300003,cave_sound_r,NULL);   AddWriteBW(0x300000, 0x300003, cave_sound_w,NULL);   AddReadByte(0x400000, 0x40FFFF, NULL, RAM+0x010000);         // OBJECT RAM   AddReadByte(0x500000, 0x507FFF, NULL, RAM+0x020000);         // BG0 RAM   AddReadWord(0x600000, 0x60007F, cave_irq_cause_r, NULL);      // ?   AddReadByte(0x800000, 0x80FFFF, NULL, RAM+0x038000);         // COLOR RAM   AddReadByte(0x900000, 0x900003, esp_input_rb, NULL);         // INPUT   AddReadWord(0x000000, 0x0FFFFF, NULL, ROM+0x000000);         // 68000 ROM   AddReadWord(0x100000, 0x10FFFF, NULL, RAM+0x000000);         // 68000 RAM   AddReadWord(0x400000, 0x40FFFF, NULL, RAM+0x010000);         // OBJECT RAM   AddReadWord(0x500000, 0x507FFF, NULL, RAM+0x020000);         // BG0 RAM   AddReadWord(0x800000, 0x80FFFF, NULL, RAM+0x038000);         // COLOR RAM   AddReadWord(0x900000, 0x900003, esp_input_rw, NULL);         // INPUT   AddWriteByte(0x100000, 0x10FFFF, NULL, RAM+0x000000);      // 68000 RAM   AddWriteByte(0x400000, 0x40FFFF, NULL, RAM+0x010000);      // OBJECT RAM   AddWriteByte(0x500000, 0x507FFF, NULL, RAM+0x020000);      // BG0 RAM   //AddWriteByte(0x600000, 0x60007F, esp_800000_wb, NULL);      // ?   AddWriteByte(0x800000, 0x80FFFF, NULL, RAM+0x038000);      // COLOR RAM   AddWriteByte(0x900000, 0x900003, esp_input_wb, NULL);      // INPUT   AddWriteByte(0xAA0000, 0xAA0001, Stop68000, NULL);         // Trap Idle 68000   AddWriteWord(0x100000, 0x10FFFF, NULL, RAM+0x000000);      // 68000 RAM   AddWriteWord(0x400000, 0x40FFFF, NULL, RAM+0x010000);      // OBJECT RAM   AddWriteWord(0x500000, 0x507FFF, NULL, RAM+0x020000);      // BG0 RAM   //AddWriteWord(0x600000, 0x60007F, esp_800000_ww, NULL);      // ?   AddWriteBW(0x600000, 0x60007F, NULL, RAM_CTRL+0);      AddWriteWord(0x800000, 0x80FFFF, NULL, RAM+0x038000);      // COLOR RAM   AddWriteWord(0x900000, 0x900003, esp_input_ww, NULL);      // INPUT   AddWriteWord(0xA00000, 0xA00001, cave_eeprom_w, NULL);      // EEPROM   AddWriteWord(0x700000, 0x700007, NULL, RAM+0x048080);      // BG0 CTRL RAM   setup_cave_game();}void execute_hotdogst_frame(void){   cpu_execute_cycles(CPU_68K_0, CPU_FRAME_MHz(28,60));   // M68000 28MHz (60fps)#ifdef RAINE_DEBUG      print_debug("PC:%06x SR:%04x\n",s68000context.pc,s68000context.sr);      debug_cave_vcu();#endif   cpu_execute_cycles(CPU_Z80_0, CPU_FRAME_MHz(4,60));        // Sound Z80         vblank_irq = 1;   irq_counter = 0;   update_irq_state();}struct GAME_MAIN game_hotdogst ={   hotdogst_dirs,   hotdogst_roms,   cave_68k_inputs,   NULL,   NULL,   load_hotdogst,   clear_cave_68k,   &hotdogst_video_r270,   execute_hotdogst_frame,   "hotdogst",   "Hotdog Storm",   "?",   COMPANY_ID_MARBLE,   NULL,   1996,   hotdogst_sound,   GAME_SHOOT,};void clear_cave_68k(void){   save_eeprom();#ifdef RAINE_DEBUG      save_debug("RAM.bin",RAM,RAMSize,1);      save_debug("ROM.bin",ROM,get_region_size(REGION_ROM1),1);#endif}#ifdef RAINE_DEBUGvoid debug_cave_vcu(void){   clear_ingame_message_list();   if(RAM_BG0_CTRL)      print_ingame(60,"BG0: (%04x,%04x) %04x", ReadWord(RAM_BG0_CTRL+0), ReadWord(RAM_BG0_CTRL+2), ReadWord(RAM_BG0_CTRL+4));   if(RAM_BG1_CTRL)      print_ingame(60,"BG1: (%04x,%04x) %04x", ReadWord(RAM_BG1_CTRL+0), ReadWord(RAM_BG1_CTRL+2), ReadWord(RAM_BG1_CTRL+4));   if(RAM_BG2_CTRL)      print_ingame(60,"BG2: (%04x,%04x) %04x", ReadWord(RAM_BG2_CTRL+0), ReadWord(RAM_BG2_CTRL+2), ReadWord(RAM_BG2_CTRL+4));   print_ingame(60,"CTRL: %04x %04x %04x %04x %04x %04x %04x %04x", ReadWord(RAM_CTRL+0x00), ReadWord(RAM_CTRL+0x02), ReadWord(RAM_CTRL+0x04), ReadWord(RAM_CTRL+0x06), ReadWord(RAM_CTRL+0x08), ReadWord(RAM_CTRL+0x0A), ReadWord(RAM_CTRL+0x0C), ReadWord(RAM_CTRL+0x0E));}#endifvoid execute_cave_68k_frame(void){   cpu_execute_cycles(CPU_68K_0, CPU_FRAME_MHz(28,60));   // M68000 28MHz (60fps)#ifdef RAINE_DEBUG      print_debug("PC:%06x SR:%04x\n",s68000context.pc,s68000context.sr);      debug_cave_vcu();#endif   vblank_irq = 1;   irq_counter = 0;   update_irq_state();}static void ClearTileQueue(void){   int ta;   last_tile = TileQueue;   last_tile_scroll = TileQueue_scroll;   for(ta=0; ta<MAX_PRI; ta++){      first_tile[ta] = last_tile;      next_tile[ta]  = last_tile;      last_tile      = last_tile+1;      if (raster_bg) {	first_tile_scroll[ta] = last_tile_scroll;	next_tile_scroll[ta]  = last_tile_scroll;	last_tile_scroll      = last_tile_scroll+1;      }   }}static void TerminateTileQueue(void){   int ta;   struct TILE_Q *curr_tile;   struct TILE_QS *curr_tile_scroll;   for(ta=0; ta<MAX_PRI; ta++){      curr_tile = next_tile[ta];      curr_tile->next = NULL;      if (raster_bg) {	curr_tile_scroll = next_tile_scroll[ta];		curr_tile_scroll->next = NULL;      }   }}static DEF_INLINE void QueueTile(UINT32 tile, int x, int y, UINT8 *map, UINT8 flip, UINT32 pri,UINT16 ww,UINT16 hh){   struct TILE_Q *curr_tile;   curr_tile = next_tile[pri];   curr_tile->tile = tile;   curr_tile->x    = x;   curr_tile->y    = y;   curr_tile->map  = map;   curr_tile->flip = flip;   curr_tile->next = last_tile;   curr_tile->ww   = ww;   curr_tile->hh   = hh;      next_tile[pri]  = last_tile;   last_tile       = last_tile+1;}static DEF_INLINE void QueueTileZoom(UINT32 tile, int x, int y, UINT8 *map, UINT8 flip, UINT32 pri,UINT16 ww,UINT16 hh,UINT16 zoomx, UINT16 zoomy){   struct TILE_Q *curr_tile;   curr_tile = next_tile[pri];   curr_tile->tile = tile;   curr_tile->x    = x;   curr_tile->y    = y;   curr_tile->map  = map;   curr_tile->flip = flip;   curr_tile->next = last_tile;   curr_tile->ww   = ww;   curr_tile->hh   = hh;   curr_tile->zoomx= zoomx;   curr_tile->zoomy= zoomy;      next_tile[pri]  = last_tile;   last_tile       = last_tile+1;}static DEF_INLINE void QueueTileScroll(UINT32 tile, int x, int y, UINT8 *map, UINT8 flip, UINT32 pri,UINT8 *dy){   struct TILE_QS *curr_tile;   curr_tile = next_tile_scroll[pri];   curr_tile->tile = tile;   curr_tile->x    = x;   curr_tile->y    = y;   curr_tile->map  = map;   curr_tile->flip = flip;   curr_tile->next = last_tile_scroll;   curr_tile->dy   = dy;      next_tile_scroll[pri]  = last_tile_scroll;   last_tile_scroll       = last_tile_scroll+1;}static DEF_INLINE void make_tile_new(UINT32 num, UINT32 width){   UINT32 x,y;   UINT8 *src,*dst;      src = GFX_OBJ_A + (num << 8);   dst = GFX_OBJ_B + (num << 8);      for(y = 0; y < (0x010 * 0x010); y += 0x010){   for(x = 0; x < (width * 0x100); x += 0x100){      dst[x + tile_16x16_map[y +  0]] = src[ 0];      dst[x + tile_16x16_map[y +  1]] = src[ 1];      dst[x + tile_16x16_map[y +  2]] = src[ 2];      dst[x + tile_16x16_map[y +  3]] = src[ 3];      dst[x + tile_16x16_map[y +  4]] = src[ 4];      dst[x + tile_16x16_map[y +  5]] = src[ 5];      dst[x + tile_16x16_map[y +  6]] = src[ 6];      dst[x + tile_16x16_map[y +  7]] = src[ 7];      dst[x + tile_16x16_map[y +  8]] = src[ 8];      dst[x + tile_16x16_map[y +  9]] = src[ 9];      dst[x + tile_16x16_map[y + 10]] = src[10];      dst[x + tile_16x16_map[y + 11]] = src[11];      dst[x + tile_16x16_map[y + 12]] = src[12];      dst[x + tile_16x16_map[y + 13]] = src[13];      dst[x + tile_16x16_map[y + 14]] = src[14];      dst[x + tile_16x16_map[y + 15]] = src[15];      src += 16;   }   }   for(x = 0; x < width; x ++){      GFX_OBJ_SIZE[num + x] = width;      GFX_OBJ_SOLID[num + x] = check_tile_solid(GFX_OBJ_B + ((num + x) << 8), 0x100);   }}static void DrawTileQueue(void){  struct TILE_Q *tile_ptr;  struct TILE_QS *tile_ptr_scroll;  UINT32 ta,pri;  UINT8 *GFX_BG = 0;  UINT8 *GFX_BG_SOLID = 0;  UINT8 which,*map,flip;  UINT16 x,y,w,xx,ww,hh,zoomx,zoomy;  TerminateTileQueue();  for(pri=0;pri<MAX_PRI;pri++){    tile_ptr = first_tile[pri];    tile_ptr_scroll = first_tile_scroll[pri];    which = pri & 3;          switch(which){    case 0:  // sprites      GFX_BG = GFX_OBJ_B;      GFX_BG_SOLID = GFX_OBJ_SOLID;      break;    case 1: // bg0      GFX_BG = GFX_BG0;      GFX_BG_SOLID = GFX_BG0_SOLID;      break;    case 2: // bg1      GFX_BG = GFX_BG1;      GFX_BG_SOLID = GFX_BG1_SOLID;      break;    case 3: // bg2      GFX_BG = GFX_BG2;      GFX_BG_SOLID = GFX_BG2_SOLID;      break;	default:	  return;	  break;    }          switch(which){          case 3:      if (romset==1) { // ddonpach has a 8x8 bg2	while(tile_ptr->next){	  ta = tile_ptr->tile;	  if(GFX_BG_SOLID[ta]==1)                     // Some pixels; trans	    Draw8x8_Trans_Mapped_Rot(&GFX_BG[ta<<6], tile_ptr->x, tile_ptr->y, tile_ptr->map);	  else                                        // all pixels; solid	    Draw8x8_Mapped_Rot(&GFX_BG[ta<<6], tile_ptr->x, tile_ptr->y, tile_ptr->map);	  tile_ptr = tile_ptr->next;	}	break;      }    case 1:        // BG0 BG1 [no flipping] and bg2 (except ddonpach)    case 2:      while(tile_ptr->next){	ta = tile_ptr->tile;	if(GFX_BG_SOLID[ta]==1)                     // Some pixels; trans	  Draw16x16_Trans_Mapped_Rot(&GFX_BG[ta<<8], tile_ptr->x, tile_ptr->y, tile_ptr->map);	else                                        // all pixels; solid	  Draw16x16_Mapped_Rot(&GFX_BG[ta<<8], tile_ptr->x, tile_ptr->y, tile_ptr->map);	tile_ptr = tile_ptr->next;      }      // This is the only place where it makes sense : uopoko for now !      if (raster_bg) {	while(tile_ptr_scroll->next){	  ta = tile_ptr_scroll->tile;	  if(GFX_BG_SOLID[ta]==1)                     // Some pixels; trans	    ldraw16x16_Trans_Mapped_Rot(&GFX_BG[ta<<8], tile_ptr_scroll->x, tile_ptr_scroll->y, tile_ptr_scroll->map,tile_ptr_scroll->dy);	  else                                        // all pixels; solid	    ldraw16x16_Mapped_Rot(&GFX_BG[ta<<8], tile_ptr_scroll->x, tile_ptr_scroll->y, tile_ptr_scroll->map,tile_ptr_scroll->dy);	  tile_ptr_scroll = tile_ptr_scroll->next;	}      }      break;    case 0:        // OBJECT [flipping]      while(tile_ptr->next){	ta = tile_ptr->tile;	x   = tile_ptr->x;	y   = tile_ptr->y;	ww  = tile_ptr->ww;	flip= tile_ptr->flip;	hh  = tile_ptr->hh;	if (*dsw_buffer & 1){	  zoomx = zoomy = 16;	} else {	  zoomx= tile_ptr->zoomx;	  zoomy= tile_ptr->zoomy;	}	map = tile_ptr->map;		switch(flip){	case 0:	  do{	    if(GFX_OBJ_SIZE[ta] != ww)	      make_tile_new(ta, ww);	    xx = x;	    w = ww;	    	    do{	      if((xx > zoomx) && (xx < limitx-zoomx) && (y > zoomy) && (y < 240+32-zoomy+16)){		  		if(GFX_OBJ_SOLID[ta]){		  if(GFX_BG_SOLID[ta]==1)      // Some pixels; trans		    Draw16x16_64_Trans_Mapped_ZoomXY_flip_Rot(&GFX_BG[ta<<8], xx, y, map, zoomx, zoomy, 0);		  else                         // all pixels; solid		    Draw16x16_64_Mapped_ZoomXY_flip_Rot(&GFX_BG[ta<<8], xx, y, map, zoomx, zoomy, 0);		}	      }	      xx = (xx + zoomx) & 0x3FF;	      ta++; //ta = (ta + 1) & 0xFFFF;			    }while(--w);	    y = (y + zoomy) & 0x3FF;	  }while(--hh);	  break;	case 1:	  x = (x + ((ww - 1) * 16)) & 0x3FF;	  do{	     	    if(GFX_OBJ_SIZE[ta] != ww)	      make_tile_new(ta, ww);	    xx = x;	    w = ww;	     	    do{	       	      if(GFX_OBJ_SOLID[ta]){		if((xx > zoomx) && (xx < limitx-zoomx) && (y > zoomy) && (y < 240+32-zoomy+16)){		  		  if(GFX_BG_SOLID[ta]==1)      // Some pixels; trans		    Draw16x16_64_Trans_Mapped_ZoomXY_flip_Rot(&GFX_BG[ta<<8], xx, y, map, zoomx, zoomy, 1);		  else                         // all pixels; solid		    Draw16x16_64_Mapped_ZoomXY_flip_Rot(&GFX_BG[ta<<8], xx, y, map, zoomx, zoomy, 1);		}	      }	       	      xx = (xx - zoomx) & 0x3FF;	      ta++; //(code + 1) & 0xFFFF;	    }while(--w);	    	    y = (y + zoomy) & 0x3FF;	     	  }while(--hh);	  break;	case 2:	  y = (y + ((hh - 1) * 16)) & 0x3FF;	  do{	     	     	    if(GFX_OBJ_SIZE[ta] != ww)	      make_tile_new(ta, ww);	    xx = x;	    w = ww;	     	    do{	       	      if(GFX_OBJ_SOLID[ta]){		if((xx > zoomx) && (xx < limitx-zoomx) && (y > zoo

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -