Exemple #1
0
// clear buffer <c>
void OsdClear(void)
{
	unsigned short n;

	// select OSD SPI device
	EnableOsd();

	// select buffer to write to
	SPI(OSDCMDWRITE|0x18);

	// clear buffer
	for(n=0; n < (OSD_LINE_BYTES * OSD_NO_LINES); n++)
	{	SPI(0x00);	}

	// deselect OSD SPI device
	DisableOsd();
}
Exemple #2
0
// SendFileV2 (for minimig_v2)
void SendFileV2(RAFile* file, unsigned char* key, int keysize, int address, int size)
{
  int i,j;
  unsigned int keyidx=0;
  iprintf("File size: %dkB\r", size>>1);
  iprintf("[");
  if (keysize) {
    // read header
    RARead(file, sector_buffer, 0xb);
  }
  for (i=0; i<size; i++) {
    if (!(i&31)) iprintf("*");
    RARead(file, sector_buffer, 512);
    if (keysize) {
      // decrypt ROM
      for (j=0; j<512; j++) {
        sector_buffer[j] ^= key[keyidx++];
        if(keyidx >= keysize) keyidx -= keysize;
      }
    }
    EnableOsd();
    unsigned int adr = address + i*512;
    SPI(OSD_CMD_WR);
    SPIN(); SPIN(); SPIN(); SPIN();
    SPI(adr&0xff); adr = adr>>8;
    SPI(adr&0xff); adr = adr>>8;
    SPIN(); SPIN(); SPIN(); SPIN();
    SPI(adr&0xff); adr = adr>>8;
    SPI(adr&0xff); adr = adr>>8;
    SPIN(); SPIN(); SPIN(); SPIN();
    for (j=0; j<512; j=j+4) {
      SPI(sector_buffer[j+0]);
      SPI(sector_buffer[j+1]);
      SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
      SPI(sector_buffer[j+2]);
      SPI(sector_buffer[j+3]);
      SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
    }
    DisableOsd();
  }
  iprintf("]\r");
}
//// UploadKickstart() ////
char UploadKickstart(char *name)
{
  int keysize=0;
  char filename[12];

  strncpy(filename, name, 8); // copy base name
  strcpy(&filename[8], "ROM"); // add extension

  BootPrint("Checking for Amiga Forever key file:");
  if(FileOpen(&file,"ROM     KEY")) {
    keysize=file.size;
    if(file.size<sizeof(romkey)) {
      int c=0;
      while(c<keysize) {
        FileRead(&file, &romkey[c]);
        c+=512;
        FileNextSector(&file);
      }
      BootPrint("Loaded Amiga Forever key file");
    } else {
      BootPrint("Amiga Forever keyfile is too large!");
    }
  }
  BootPrint("Loading file: ");
  BootPrint(filename);

  if(minimig_v1()) {
    if (RAOpen(&romfile, filename)) {
      if (romfile.size == 0x80000) {
        // 512KB Kickstart ROM
        BootPrint("Uploading 512 KB Kickstart...");
        PrepareBootUpload(0xF8, 0x08);
        SendFile(&romfile);
        return(1);
      } else if ((romfile.size == 0x8000b) && keysize) {
        // 512KB Kickstart ROM
        BootPrint("Uploading 512 KB Kickstart (Probably Amiga Forever encrypted...)");
        PrepareBootUpload(0xF8, 0x08);
        SendFileEncrypted(&romfile,romkey,keysize);
        return(1);
      } else if (romfile.size == 0x40000) {
        // 256KB Kickstart ROM
        BootPrint("Uploading 256 KB Kickstart...");
        PrepareBootUpload(0xF8, 0x04);
        SendFile(&romfile);
        return(1);
      } else if ((romfile.size == 0x4000b) && keysize) {
        // 256KB Kickstart ROM
        BootPrint("Uploading 256 KB Kickstart (Probably Amiga Forever encrypted...");
        PrepareBootUpload(0xF8, 0x04);
        SendFileEncrypted(&romfile,romkey,keysize);
        return(1);
      } else {
        BootPrint("Unsupported ROM file size!");
      }
    } else {
      siprintf(s, "No \"%s\" file!", filename);
      BootPrint(s);
    }
  } else {
    if (RAOpen(&romfile, filename)) {
      int i,j;
      unsigned int adr, size, base=0x180000, offset=0xc00000, data;
      puts("Uploading 512KB Kickstart ...");
      size = ((romfile.file.size)+511)>>9;
      iprintf("File size: %d.%01dkB\r", romfile.file.size>>10, romfile.file.size&0x3ff);
      iprintf("[");
      for (i=0; i<size; i++) {
        if (!(i&31)) iprintf("*");
        RARead(&romfile,sector_buffer,512);
        EnableOsd();
        adr = 0xf80000 + i*512;
        SPI(OSD_CMD_WR);
        SPIN(); SPIN(); SPIN(); SPIN();
        SPI(adr&0xff); adr = adr>>8;
        SPI(adr&0xff); adr = adr>>8;
        SPIN(); SPIN(); SPIN(); SPIN();
        SPI(adr&0xff); adr = adr>>8;
        SPI(adr&0xff); adr = adr>>8;
        SPIN(); SPIN(); SPIN(); SPIN();
        for (j=0; j<512; j=j+4) {
          SPI(sector_buffer[j+0]);
          SPI(sector_buffer[j+1]);
          SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
          SPI(sector_buffer[j+2]);
          SPI(sector_buffer[j+3]);
          SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
        }
        DisableOsd();
      }
      iprintf("]\r");
      return(1);
    }
  }
Exemple #4
0
void OsdWriteDoubleSize(unsigned char n, char *s, unsigned char pass)
{
    unsigned short i;
    unsigned char b;
    const unsigned char *p;
	int linelimit=OSDLINELEN;

    // select OSD SPI device
    EnableOsd();

    // select buffer and line to write to
    SPI(OSDCMDWRITE | n);

    i = 0;
    // send all characters in string to OSD
    while (1)
    {
		if(i==0)	// Render sidestripe
		{
	        p = &titlebuffer[(7-n)*8];
			SPI(0xff);
			SPI(0xff);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
			SPI(0xff);
			SPI(0xff);
			SPI(0x00);
			SPI(0x00);
	        i += 22;
		}
		else
		{
		    b = *s++;

		    if (b == 0) // end of string
		        break;

			else if(i<(linelimit-16)) // normal character
		    {
				int c;
		        p = &charfont[b][0];
				if(pass)	// Draw the bottom half..
				{
					int j;
					for(j=0;j<8;++j)
					{
						c=*p++;
						c=(c&0xf0)>>4;
						c=(c&0x08)<<1 | c;	// ....ABCD => ...AABCD
						c=(c&0x1c)<<1 | (c & 0x07);	// ...AABCD => ..AABBCD
						c=(c&0x3e)<<1 | (c & 0x03); // ..AABBCD => .AABBCCD
						c=c<<1 | (c&0x01); // .AABBCCD => AABBCCDD
						SPI(c); SPI(c);
					}
				}
				else	// Draw the top half...
				{
					int j;
					for(j=0;j<8;++j)
					{
						c=*p++;
						c=c&0xf;
						c=(c&0x08)<<1 | c;	// ....ABCD => ...AABCD
						c=(c&0x1c)<<1 | (c & 0x07);	// ...AABCD => ..AABBCD
						c=(c&0x3e)<<1 | (c & 0x03); // ..AABBCD => .AABBCCD
						c=c<<1 | (c&0x01); // .AABBCCD => AABBCCDD
						SPI(c); SPI(c);
					}
				}				
		        i += 16;
		    }
		}
Exemple #5
0
void OsdDrawLogo(unsigned char n, char row,char superimpose)
{
    unsigned short i;
    const unsigned char *p;
	int linelimit=OSDLINELEN;

    // select OSD SPI device
    EnableOsd();

    // select buffer and line to write to
    SPI(OSDCMDWRITE | n);

	const unsigned char *lp=logodata[row];
	int bytes=sizeof(logodata[0]);
	if(row>=(sizeof(logodata)/bytes))
		lp=0;
    i = 0;
    // send all characters in string to OSD

	if(superimpose)
	{
	  char *bg=framebuffer[n];
		while (bytes)
		{
			if(i==0)	// Render sidestripe
			{
			    p = &titlebuffer[(7-n)*8];
				SPI(0xff);
				SPI(0xff);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
				SPI(0xff);
				SPI(0xff);
				SPI(0x00);
				SPI(0x00);
			    i += 22;
			}
			if(i>=linelimit)
				break;
			if(lp)
				SPI(*lp++ | *bg++);
			else
			  SPI(*bg++);
			--bytes;
			++i;
		}
	    for (; i < linelimit; i++) // clear end of line
	      SPI(*bg++);
    }
	else
	{
		while (bytes)
		{
			if(i==0)	// Render sidestripe
			{
			    p = &titlebuffer[(7-n)*8];
				SPI(0xff);
				SPI(0xff);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
			    SPI(255^*p); SPI(255^*p++);
				SPI(0xff);
				SPI(0xff);
				SPI(0x00);
				SPI(0x00);
			    i += 22;
			}
			if(i>=linelimit)
				break;
			if(lp)
				SPI(*lp++);
			else
				SPI(0);
			--bytes;
			++i;
		}
	    for (; i < linelimit; i++) // clear end of line
	       SPI(0);
	}
    // deselect OSD SPI device
    DisableOsd();
}
Exemple #6
0
// write a null-terminated string <s> to the OSD buffer starting at line <n>
void OsdWriteOffset(unsigned char n, char *s, unsigned char invert, unsigned char stipple,char offset)
{
    unsigned short i;
    unsigned char b;
    const unsigned char *p;
	unsigned char stipplemask=0xff;
	int linelimit=OSDLINELEN;
	int arrowmask=arrow;
	if(n==7 && (arrow & OSD_ARROW_RIGHT))
		linelimit-=22;

	if(stipple)
	{
		stipplemask=0x55;
		stipple=0xff;
	}
	else
		stipple=0;

    // select OSD SPI device
    EnableOsd();

    // select buffer and line to write to
//    if (invert)
//        SPI(OSDCMDWRITE | 0x10 | n);
//    else
        SPI(OSDCMDWRITE | n);

	if(invert)
		invert=255;

    i = 0;
    // send all characters in string to OSD
    while (1)
    {
		if(i==0)	// Render sidestripe
		{
	        p = &titlebuffer[(7-n)*8];
			SPI(0xff);
			SPI(0xff);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
	        SPI(255^*p); SPI(255^*p++);
			SPI(0xff);
			SPI(0xff);
			SPI(0x00);
			SPI(0x00);
	        i += 22;
		}
		else if(n==7 && (arrowmask & OSD_ARROW_LEFT))	// Draw initial arrow
		{
			SPI(0);
			SPI(0);
			SPI(0);
		    p = &charfont[0x10][0];
	        SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset);
	        SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset);
		    p = &charfont[0x14][0];
	        SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset);
	        SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset);
			SPI(0);
			SPI(0);
			SPI(0);
			SPI(invert);
			SPI(invert);
			i+=24;
			arrowmask&=~OSD_ARROW_LEFT;
			if(*s++ == 0) break;	// Skip 3 characters, to keep alignent the same.
			if(*s++ == 0) break;
			if(*s++ == 0) break;
		}
		else
		{
		    b = *s++;

		    if (b == 0) // end of string
		        break;

		    else if (b == 0x0d || b == 0x0a) // cariage return / linefeed, go to next line
		    {
		        // increment line counter
		        if (++n >= linelimit)
		            n = 0;
		        // send new line number to OSD
		        DisableOsd();
		        EnableOsd();
		        SPI(OSDCMDWRITE | n);
		    }
			else if(i<(linelimit-8)) // normal character
		    {
		        p = &charfont[b][0];
		        SPI(((*p++<<offset)&stipplemask)^invert);	stipplemask^=stipple;
		        SPI(((*p++<<offset)&stipplemask)^invert);	stipplemask^=stipple;
		        SPI(((*p++<<offset)&stipplemask)^invert);	stipplemask^=stipple;
		        SPI(((*p++<<offset)&stipplemask)^invert);	stipplemask^=stipple;
		        SPI(((*p++<<offset)&stipplemask)^invert);	stipplemask^=stipple;
		        SPI(((*p++<<offset)&stipplemask)^invert);	stipplemask^=stipple;
		        SPI(((*p++<<offset)&stipplemask)^invert);	stipplemask^=stipple;
		        SPI(((*p++<<offset)&stipplemask)^invert);	stipplemask^=stipple;
		        i += 8;
		    }
		}
    }
    for (; i < linelimit; i++) // clear end of line
       SPI(invert);
	if(n==7 && (arrowmask & OSD_ARROW_RIGHT))	// Draw final arrow if needed
	{
		SPI(0);
		SPI(0);
		SPI(0);
        p = &charfont[0x15][0];
        SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset);
        SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset);
        p = &charfont[0x11][0];
        SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset);
        SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset); SPI(*p++<<offset);
		SPI(0);
		SPI(0);
		SPI(0);
		i+=22;
	}

    // deselect OSD SPI device
    DisableOsd();
}
Exemple #7
0
// write a null-terminated string <s> to the OSD buffer starting at line <n>
void OsdWrite(unsigned char n, const unsigned char *s, char invert)
{
	unsigned short byte_cnt;
	unsigned char b;
	const unsigned char *p;

	// select OSD SPI device
	EnableOsd();

	// select buffer and line to write to
	if (invert)
	{	SPI(OSDCMDWRITE|0x10|n);	}
	else
	{	SPI(OSDCMDWRITE|n);	}

	// Start Counting bytes
	byte_cnt = 0;
	
	// send all characters in string to OSD
	while(1)
	{
		b=*(s++);

		// end of string
		if (0 == b)
		{	break;	}
		else if (0x0d == b || 0x0a == b)	//cariage return / linefeed, go to next line
		{
			// Clear rest of line
			for(; byte_cnt < OSD_LINE_BYTES; byte_cnt++)
			{	SPI(0x00);	}

			// Start Counting bytes
			byte_cnt = 0;
			
			// increment line counter
			if(++n >= OSD_NO_LINES)
			{	n=0;	}

			// send new line number to OSD
			DisableOsd();
			EnableOsd();
			SPI(OSDCMDWRITE|n);
		}
		else
		{
			#if	defined(PGL090421) || defined(PGL090911) || defined(PGL100818)
				// Send Space
				SPI(0x00);
	
				// Send Character each byte
				p=&charfont[b][0];
				SPI(*(p++));
				SPI(*(p++));
				SPI(*(p++));
				SPI(*(p++));
				SPI(*(p++));
				
				byte_cnt += 6;
	
			#elif	defined(PGL091224) 
				// Send Space
				SPI(0x00);
				SPI(0x00);
	
				// Send Character each byte
				p=&charfont[b][0];
				SPI(*(p));
				SPI(*(p++));
	
				SPI(*(p));
				SPI(*(p++));
				
				SPI(*(p));
				SPI(*(p++));
				
				SPI(*(p));
				SPI(*(p++));
				
				SPI(*(p));
				SPI(*(p++));
				
				byte_cnt += 12;
			#endif
		}
	}
	
	// Clear rest of line
	for(; byte_cnt < OSD_LINE_BYTES; byte_cnt++)
	{	SPI(0x00);	}
	
	// deselect OSD SPI device
	DisableOsd();
}
Exemple #8
0
// mon_decodecmd()
static void mon_decodecmd()
{
  char* s;
  int adr;
  int len;
  int val;
  char fname[32];

  switch (rxbuf[0]) {
    case 'h':
      // help
      if (rxbuf[1]==0 || rxbuf[1]=='\n' || rxbuf[1]=='\r') {
        mon_usage();
      } else mon_illcmd();
      break;
    case 'r':
      // reboot
      if (rxbuf[1]==0 || rxbuf[1]=='\n' || rxbuf[1]=='\r') {
        RST_system();
      } else mon_illcmd();
      break;
    case 'e':
      // exit mon
      if (rxbuf[1]==0 || rxbuf[1]=='\n' || rxbuf[1]=='\r') {
        rxwp = rxrp = txwp = txrp = txln = 0;
        mon_step = 0;
        mon_en = 0;
      } else mon_illcmd();
      break;
    case 'c':
      // ctrl read/write
      if (rxbuf[1] == 'w') {
        // write
        if ((s = next_word(rxbuf)) == NULL) { mon_illcmd(); break;}
        scani(s, &adr);
        adr = adr&0xfffffffc;
        if ( (s = next_word(s)) == NULL ) { mon_illcmd(); break;}
        scani(s, &val);
        write32(adr, val);
        rxwp = 0;
      } else if (rxbuf[1] == 'r') {
        // read
        if ((s = next_word(rxbuf)) == NULL) { mon_illcmd(); break;}
        scani(s, &adr);
        adr = adr&0xfffffffc;
        val = read32(adr);
        sprintf(stbuf, "0x%8x = 0x%8x (b%32b)\r\n", adr, val, val);
        txbuf_puts(stbuf);
        rxwp = 0;
      } else mon_illcmd();
      break;
    case 'a':
      // amiga read/write
      if (rxbuf[1] == 'w') {
        // write
        if ((s = next_word(rxbuf)) == NULL) { mon_illcmd(); break;}
        scani(s, &adr);
        adr = adr&0xfffffffc;
        if ( (s = next_word(s)) == NULL ) { mon_illcmd(); break;}
        scani(s, &val);
        EnableOsd();
        rstval = rstval | SPI_CPU_HLT;
        SPI(rstval);
        DisableOsd();
        MEM_UPLOAD_INIT(adr);
        MEM_WRITE16(val);
        MEM_UPLOAD_FINI();
        EnableOsd();
        rstval = rstval & ~SPI_CPU_HLT;
        SPI(rstval);
        DisableOsd();
        rxwp = 0;
      } else if (rxbuf[1] == 'r') {
        // read
        printf("Amiga mem read currently unimplemented.\r");
        rxwp = 0;
      } else mon_illcmd();
      break;
    case 'u':
      // file upload
      if ((s = next_word(rxbuf)) == NULL) { mon_illcmd(); break;}
      //scani(s, fname);
      printf("File upload currently unimplemented.\r");
      rxwp = 0;
      break;
  }
}