Пример #1
0
DMA_STATUS dmaTransfer(DMA_ENGINE channel, unsigned int sourceAddr,
		       unsigned int destAddr, unsigned int numOfBytes,
		       unsigned int command,
		       DMA_RECORED * nextRecoredPointer)
{
	unsigned int tempData, checkBits, alignmentOffset = 0;
	DMA_RECORED *next = nextRecoredPointer;

	if (channel > LAST_DMA_ENGINE)
		return NO_SUCH_CHANNEL;
	if (numOfBytes > 0xffff)
		return GENERAL_ERROR;
	if (isDmaChannelActive(channel))
		return CHANNEL_BUSY;
	if (next != NULL) {	/* case of chain Mode */
		alignmentOffset = ((unsigned int) next % 16);
	}
	checkBits = command & 0x6000000;
	if (checkBits == 0) {
		while (next != NULL) {
			WRITE_WORD((unsigned int) next - alignmentOffset,
				   next->ByteCnt);
			tempData = (unsigned int) next->SrcAdd;
			WRITE_WORD((unsigned int) next + 4 -
				   alignmentOffset, tempData & 0x5fffffff);
			tempData = (unsigned int) next->DestAdd;
			WRITE_WORD((unsigned int) next + 8 -
				   alignmentOffset, tempData & 0x5fffffff);
			tempData = (unsigned int) next->NextRecPtr;
			WRITE_WORD((unsigned int) next + 12 -
				   alignmentOffset,
				   tempData & 0x5fffffff -
				   alignmentOffset);
			next = (DMA_RECORED *) tempData;
			if (next == nextRecoredPointer)
				next = NULL;
		}
	}
	GT_REG_WRITE(CHANNEL0_DMA_BYTE_COUNT + channel * 4, numOfBytes);
	tempData = sourceAddr;
	GT_REG_WRITE(CHANNEL0_DMA_SOURCE_ADDRESS + channel * 4,
		     tempData & 0x5fffffff);
	tempData = destAddr;
	GT_REG_WRITE(CHANNEL0_DMA_DESTINATION_ADDRESS + channel * 4,
		     tempData & 0x5fffffff);
	if (nextRecoredPointer != NULL) {
		tempData =
		    (unsigned int) nextRecoredPointer - alignmentOffset;
		GT_REG_WRITE(CHANNEL0NEXT_RECORD_POINTER + 4 * channel,
			     tempData & 0x5fffffff);
		command = command | CHANNEL_ENABLE;
	} else {
		command = command | CHANNEL_ENABLE | NON_CHAIN_MOD;
	}
	/* Activate DMA engine By writting to dmaControlRegister */
	GT_REG_WRITE(CHANNEL0CONTROL + channel * 4, command);

	return DMA_OK;
}
Пример #2
0
static void pow_spriteram_w(int offset, int data)
{
	/* DWORD aligned bytes should be $ff */
	if (offset & 0x02)
		WRITE_WORD(&spriteram[offset], data);
	else
		WRITE_WORD(&spriteram[offset], data | 0xff00);
}
Пример #3
0
ROM_END



static void init_aztarac(void)
{
	unsigned char *rom = memory_region(REGION_CPU1);

	/* patch IRQ vector 4 to autovector location */
	WRITE_WORD(&rom[0x70], 0);
	WRITE_WORD(&rom[0x72], 0x0c02);
}
Пример #4
0
void do_mem()
{
  enum md_fault_type _fault;
  mw.inst = em.inst;
  if(mw.inst.a == NOP){
  	return;
  }
  mw.PC = em.PC;
  mw.opcode = em.opcode;
  mw.oprand = em.oprand;
  mw.ALUResult = em.ALUResult;
  mw.WriteData = em.WriteData;
  mw.WriteTargetRegister = em.WriteTargetRegister;

  mw.RegWrite = em.RegWrite;
  mw.MemtoReg = em.MemtoReg;
  mw.MemRead = em.MemRead;
  mw.MemWrite = em.MemWrite;
  if(mw.MemRead){
  	mw.MemReadData = READ_WORD(em.ALUResult,_fault);
  }else if(mw.MemWrite){
    WRITE_WORD(mw.WriteData,mw.ALUResult,_fault);
  }

    
}                                                                                        
Пример #5
0
// add_padding: adds padding bytes to a KSSL message. Assumes that the buffer
// being written to is calloced.
kssl_error_code add_padding(WORD size,      // Length of padding
                            BYTE *bytes,    // Buffer into which item is
                            // serialized
                            int *offset) {  // (optional) offset into bytes
    // to write from
    int local_offset = 0;

    if (bytes == NULL) {
        return KSSL_ERROR_INTERNAL;
    }

    if (offset != NULL) {
        local_offset = *offset;
    }

    // Add the padding. This gets added even is padding_size == 0

    WRITE_BYTE(bytes, local_offset, KSSL_TAG_PADDING);
    WRITE_WORD(bytes, local_offset, size);

    if (offset != NULL) {
        *offset = local_offset;
    }

    return KSSL_ERROR_NONE;
}
Пример #6
0
// flatten_item: Serialize a single kssl_item. The offset is updated
// as bytes are written. If offset pointer is NULL this function
// starts at offset 0. Returns KSSL_ERROR_NONE if successful.
kssl_error_code flatten_item(BYTE tag,         // The kssl_item's tag (see
                             // kssl.h)
                             BYTE *payload,    // Buffer containing the item's
                             // payload
                             WORD payload_len, // Length of data from payload
                             // to copy
                             BYTE *bytes,      // Buffer into which item is
                             // serialized
                             int *offset) {    // (optional) offset into bytes
    // to write from
    int local_offset = 0;

    if (bytes == NULL) {
        return KSSL_ERROR_INTERNAL;
    }

    if (offset != NULL) {
        local_offset = *offset;
    }

    WRITE_BYTE(bytes, local_offset, tag);
    WRITE_WORD(bytes, local_offset, payload_len);
    if (payload_len > 0) {
        WRITE_BUFFER(bytes, local_offset, payload, payload_len);
    }

    if (offset != NULL) {
        *offset = local_offset;
    }

    return KSSL_ERROR_NONE;
}
Пример #7
0
// flatten_item_byte: serialize a kssl_item with a given tag and one
// byte payload at an offset. The offset is updated as bytes are written.
// If offset pointer is NULL this function starts at offset 0. Returns
// KSSL_ERROR_NONE if successful.
kssl_error_code flatten_item_byte(BYTE tag,      // The kssl_item's tag (see
                                  // kssl.h)
                                  BYTE payload , // A single byte for the
                                  // payload
                                  BYTE *bytes,   // Buffer into which
                                  // kssl_item is written (must
                                  // be pre-allocated and have
                                  // room)
                                  int *offset) { // (optional) offset into
    // bytes to start writing at
    int local_offset = 0;
    if (bytes == NULL) {
        return KSSL_ERROR_INTERNAL;
    }

    if (offset != NULL) {
        local_offset = *offset;
    }

    WRITE_BYTE(bytes, local_offset, tag);
    WRITE_WORD(bytes, local_offset, 1);
    WRITE_BYTE(bytes, local_offset, payload);

    if (offset != NULL) {
        *offset = local_offset;
    }

    return KSSL_ERROR_NONE;
}
Пример #8
0
// flatten_header: serialize a header into a pre-allocated byte array
// at a given offset. The offset is updated as bytes are written.  If
// offset pointer is NULL this function starts at offset 0.
kssl_error_code flatten_header(kssl_header *header, // Pointer to kssl_header
                               // to serialize
                               BYTE *bytes,         // Byte buffer to write
                               // into (must be allocated
                               // and have sufficient
                               // space for a
                               // kssl_header)
                               int *offset) {       // (optional) offset into
    // bytes to
    int local_offset = 0;
    // write to
    if (bytes == NULL || header == NULL) {
        return KSSL_ERROR_INTERNAL;
    }

    if (offset != NULL) {
        local_offset = *offset;
    }

    WRITE_BYTE(bytes, local_offset, header->version_maj);
    WRITE_BYTE(bytes, local_offset, header->version_min);
    WRITE_WORD(bytes, local_offset, header->length);
    WRITE_DWORD(bytes, local_offset, header->id);

    if (offset != NULL) {
        *offset = local_offset;
    }

    return KSSL_ERROR_NONE;
}
Пример #9
0
void atarisys2_paletteram_w (int offset, int data)
{
	static const int intensity_table[16] =
	{
		#define ZB 115
		#define Z3 78
		#define Z2 37
		#define Z1 17
		#define Z0 9
		0, ZB+Z0, ZB+Z1, ZB+Z1+Z0, ZB+Z2, ZB+Z2+Z0, ZB+Z2+Z1, ZB+Z2+Z1+Z0,
		ZB+Z3, ZB+Z3+Z0, ZB+Z3+Z1, ZB+Z3+Z1+Z0,ZB+ Z3+Z2, ZB+Z3+Z2+Z0, ZB+Z3+Z2+Z1, ZB+Z3+Z2+Z1+Z0
	};
	static const int color_table[16] =
		{ 0x0, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xe, 0xf, 0xf };

	int inten, red, green, blue;

	int oldword = READ_WORD (&paletteram[offset]);
	int newword = COMBINE_WORD (oldword, data);
	int indx = offset / 2;

	WRITE_WORD (&paletteram[offset], newword);

	inten = intensity_table[newword & 15];
	red = (color_table[(newword >> 12) & 15] * inten) >> 4;
	green = (color_table[(newword >> 8) & 15] * inten) >> 4;
	blue = (color_table[(newword >> 4) & 15] * inten) >> 4;
	palette_change_color (indx, red, green, blue);
}
Пример #10
0
void namcos2_68k_video_palette_w( int offset, int data )
{
	int oldword = READ_WORD(&namcos2_68k_palette_ram[offset&0xffff]);
	int newword = COMBINE_WORD(oldword, data);
	int pen,red,green,blue;

	if(oldword != newword)
	{
		WRITE_WORD(&namcos2_68k_palette_ram[offset&0xffff],newword);

        /* 0x3000 offset is control registers */
        if((offset&0x3000)!=0x3000)
        {
            pen=(((offset&0xc000)>>2) | (offset&0x0fff))>>1;

            red  =(READ_WORD(&namcos2_68k_palette_ram[offset&0xcfff]))&0x00ff;
            green=(READ_WORD(&namcos2_68k_palette_ram[(offset&0xcfff)+0x1000]))&0x00ff;
            blue =(READ_WORD(&namcos2_68k_palette_ram[(offset&0xcfff)+0x2000]))&0x00ff;

            /* Int color, uchar r/g/b */

            palette_change_color(pen,red,green,blue);

//          if (errorlog) fprintf(errorlog,"CPU#%d PC=$%06x Video Palette write Addr=%08x, Data=%04x\n",cpu_getactivecpu(),cpu_get_pc(),offset,data);
            if (errorlog) fprintf(errorlog,"CPU#%d PC=$%06x Video Palette PEN=%04x, R=%02x, G=%02x B=%02x\n",cpu_getactivecpu(),cpu_get_pc(),pen,red,green,blue);
        }
Пример #11
0
void gen_tmss_w(unsigned int offset, unsigned int data)
{
    /* write TMSS regisiter */
    WRITE_WORD(tmss, offset, data);

    /* VDP requires "SEGA" value to be written in TMSSS register */
    int i;
    if (strncmp((char *)tmss, "SEGA", 4) == 0)
    {
        for (i=0xc0; i<0xe0; i+=8)
        {
            m68k_memory_map[i].read8    = vdp_read_byte;
            m68k_memory_map[i].read16   = vdp_read_word;
            m68k_memory_map[i].write8   = vdp_write_byte;
            m68k_memory_map[i].write16  = vdp_write_word;
            zbank_memory_map[i].read    = zbank_read_vdp;
            zbank_memory_map[i].write   = zbank_write_vdp;
        }
    }
    else
    {
        for (i=0xc0; i<0xe0; i+=8)
        {
            m68k_memory_map[i].read8    = m68k_lockup_r_8;
            m68k_memory_map[i].read16   = m68k_lockup_r_16;
            m68k_memory_map[i].write8   = m68k_lockup_w_8;
            m68k_memory_map[i].write16  = m68k_lockup_w_16;
            zbank_memory_map[i].read    = zbank_lockup_r;
            zbank_memory_map[i].write   = zbank_lockup_w;
        }
    }
}
Пример #12
0
static WRITE_HANDLER( sync_w )
{
	int oldword = READ_WORD(&sync_data[offset]);
	int newword = COMBINE_WORD(oldword, data);
	WRITE_WORD(&sync_data[offset], newword);
	if ((oldword & 0xff00) != (newword & 0xff00))
		cpu_yield();
}
Пример #13
0
static void cabal_background_w( int offset, int data ){
	int oldword = READ_WORD(&videoram[offset]);
	int newword = COMBINE_WORD(oldword,data);
	if( oldword != newword ){
		WRITE_WORD(&videoram[offset],newword);
		dirtybuffer[offset/2] = 1;
	}
}
Пример #14
0
static void sync_w(int offset, int data)
{
	int oldword = READ_WORD(&sync_data[offset]);
	int newword = COMBINE_WORD(oldword, data);
	WRITE_WORD(&sync_data[offset], newword);
	if ((oldword & 0xff00) != (newword & 0xff00))
		cpu_yield();
}
Пример #15
0
void atarisys2_hscroll_w (int offset, int data)
{
	int oldword = READ_WORD (&atarigen_hscroll[offset]);
	int newword = COMBINE_WORD (oldword, data);
	WRITE_WORD (&atarigen_hscroll[offset], newword);

	/* if we changed the bank, we need to rerender the playfield */
	if (offset == 0 && (oldword & 15) != (newword & 15))
		fast_memset (playfielddirty, 1, playfieldram_size / 2);
}
Пример #16
0
void
printer_mem_setup(void)
{
  int i;
  for (i = 0; i < 3; i++) {
    /* set the port address for each printer in bios */
    WRITE_WORD(BIOS_ADDRESS_LPT1 + i * 2, lpt[i].base_port);
    WRITE_BYTE(BIOS_LPT1_TIMEOUT + i, 20);
  }
}
Пример #17
0
void
printer_mem_setup(void)
{
    int i;
    for (i = 0; i < NUM_LPTS; i++) {
        /* set the port address for each printer in bios */
        WRITE_WORD(BIOS_ADDRESS_LPT1 + i * 2, get_lpt_base(i));
        WRITE_BYTE(BIOS_LPT1_TIMEOUT + i, 20);
    }
}
Пример #18
0
void klax_playfieldram_w (int offset, int data)
{
	int oldword = READ_WORD (&atarigen_playfieldram[offset]);
	int newword = COMBINE_WORD (oldword, data);

	if (oldword != newword)
	{
		WRITE_WORD (&atarigen_playfieldram[offset], newword);
		playfielddirty[(offset & 0xfff) / 2] = 1;
	}
}
Пример #19
0
void eprom_playfieldpalram_w(int offset, int data)
{
	int oldword = READ_WORD(&eprom_playfieldpalram[offset]);
	int newword = COMBINE_WORD(oldword, data);

	if (oldword != newword)
	{
		WRITE_WORD(&eprom_playfieldpalram[offset], newword);
		atarigen_pf_dirty[offset / 2] = 1;
	}
}
Пример #20
0
void toobin_playfieldram_w (int offset, int data)
{
	int oldword = READ_WORD (&atarigen_playfieldram[offset]);
	int newword = COMBINE_WORD (oldword, data);

	if (oldword != newword)
	{
		WRITE_WORD (&atarigen_playfieldram[offset], newword);
		playfielddirty[offset / 4] = 1;
	}
}
Пример #21
0
void badlands_playfieldram_w(int offset, int data)
{
	int oldword = READ_WORD(&atarigen_playfieldram[offset]);
	int newword = COMBINE_WORD(oldword, data);

	if (oldword != newword)
	{
		WRITE_WORD(&atarigen_playfieldram[offset], newword);
		atarigen_pf_dirty[offset / 2] = 0xff;
	}
}
Пример #22
0
ROM_END



void init_ginganin(void)
{
	unsigned char *RAM;

/* main cpu patches */
	RAM = memory_region(REGION_CPU1);
	WRITE_WORD(&RAM[0x408],0x6000);	WRITE_WORD(&RAM[0x40a],0x001c);	// avoid writes to rom getting to the log


/* sound cpu patches */
	RAM = memory_region(REGION_CPU2);

	/* let's clear the RAM: ROM starts at 0x4000 */
	memset (&RAM[0],0,0x800);

}
Пример #23
0
/* This function is called on every reset */
void neogeo_init_machine(void)
{
	int src,res;
	time_t		ltime;
	struct tm		*today;


	/* Reset variables & RAM */
	memset (neogeo_ram, 0, 0x10000);

	/* Set up machine country */
    src = readinputport(5);
    res = src&0x3;

    /* Console/arcade mode */
	if (src & 0x04)	res |= 0x8000;

	/* write the ID in the system BIOS ROM */
	WRITE_WORD(&memory_region(REGION_USER1)[0x0400],res);

	if (memcard_manager==1)
	{
		memcard_manager=0;
		WRITE_WORD(&memory_region(REGION_USER1)[0x11b1a], 0x500a);
	}
	else
	{
		WRITE_WORD(&memory_region(REGION_USER1)[0x11b1a],0x1b6a);
	}

	time(&ltime);
	today = localtime(&ltime);

	seconds = ((today->tm_sec/10)<<4) + (today->tm_sec%10);
	minutes = ((today->tm_min/10)<<4) + (today->tm_min%10);
	hours = ((today->tm_hour/10)<<4) + (today->tm_hour%10);
	days = ((today->tm_mday/10)<<4) + (today->tm_mday%10);
	month = (today->tm_mon + 1);
	year = ((today->tm_year/10)<<4) + (today->tm_year%10);
	weekday = today->tm_wday;
}
Пример #24
0
void bionicc_fgvideoram_w(int offset,int data)
{
	int oldword = READ_WORD(&bionicc_fgvideoram[offset]);
	int newword = COMBINE_WORD(oldword,data);

	if (oldword != newword)
	{
		int tile_index = offset/4;
		WRITE_WORD(&bionicc_fgvideoram[offset],newword);
		tilemap_mark_tile_dirty(fg_tilemap,tile_index%64,tile_index/64);
	}
}
Пример #25
0
void bionicc_txvideoram_w(int offset,int data)
{
	int oldword = READ_WORD(&bionicc_txvideoram[offset]);
	int newword = COMBINE_WORD(oldword,data);

	if (oldword != newword)
	{
		int tile_index = (offset&0x7ff)/2;
		WRITE_WORD(&bionicc_txvideoram[offset],newword);
		tilemap_mark_tile_dirty(tx_tilemap,tile_index%32,tile_index/32);
	}
}
Пример #26
0
static WRITE_HANDLER( interrupt_scan_w )
{
	int oldword = READ_WORD(&interrupt_scan[offset]);
	int newword = COMBINE_WORD(oldword, data);

	/* if something changed, update the word in memory */
	if (oldword != newword)
	{
		WRITE_WORD(&interrupt_scan[offset], newword);
		atarigen_scanline_int_set(newword & 0x1ff);
	}
}
Пример #27
0
static READ_HANDLER( bakatono_cycle_r )
{
        int mem;
        if (cpu_get_pc()==0x197cc)
        {
                cpu_spinuntil_int();
                mem=READ_WORD(&neogeo_ram[0x00fa]);
                mem--;
                WRITE_WORD(&neogeo_ram[0x00fa],mem);
                return mem;
        }
        return READ_WORD(&neogeo_ram[0x00fa]);
}
Пример #28
0
static READ_HANDLER( minasan_cycle_r )
{
        int mem;
        if (cpu_get_pc()==0x17766)
        {
                cpu_spinuntil_int();
                mem=READ_WORD(&neogeo_ram[0x00ca]);
                mem--;
                WRITE_WORD(&neogeo_ram[0x00ca],mem);
                return mem;
        }
        return READ_WORD(&neogeo_ram[0x00ca]);
}
Пример #29
0
int create_sha(unsigned char * src, unsigned long length, unsigned long * addr)
{
	int i;
	WRITE_WORD(0xb802e098, ((READ_WORD(0xb802e098)&0xf0ffffff)|0x02000000));
	WRITE_WORD(SHA_STATUS, SHA_DMA_OK);
	WRITE_WORD(SHA_CTRL,SHA_HW_256_MODE|SHA_HW_FLASH_DMA);
	WRITE_WORD(SHA_DMA_ADDRESS,(unsigned long)src);
	WRITE_WORD(SHA_DMA_LENGTH,length);
	WRITE_WORD(SHA_CTRL,SHA_HW_256_MODE|SHA_HW_FLASH_DMA|SHA_HW_FLASH_STA|FLASH_DATA_BYTE_SWAP);
	i=READ_WORD(SHA_DMA_STATUS);
	while(READ_WORD(SHA_STATUS) ==0);
	WRITE_WORD(SHA_STATUS, SHA_DMA_OK);
	for(i=0;i<8;i++)
		{
			WRITE_WORD(SHA_DIGEST_SEL,i|SHA_DIGEST_SWP|SHA_DIGEST_LE);
			*(addr+i)=READ_WORD(SHA_DIGEST_PORT);
		}
	WRITE_WORD(SHA_CTRL,SHA_HW_256_MODE|SHA_HW_FLASH_DMA);
	return 1;
}
Пример #30
0
void zerowing_videoram3_w(int offset, int data)
{
	int oldword = READ_WORD (&zerowing_videoram3[(video_ofs3 & (VIDEORAM3_SIZE-1))*4 + offset]);
	int newword = COMBINE_WORD (oldword, data);

#ifdef DEBUG
if ((video_ofs3 & (VIDEORAM3_SIZE-1))*4 + offset >= VIDEORAM3_SIZE*4)
{
	return;
}
#endif

	WRITE_WORD (&zerowing_videoram3[(video_ofs3 & (VIDEORAM3_SIZE-1))*4 + offset],newword);
	if ( offset == 2 ) video_ofs3++;
}