// boot.c // bootscreen functions // 2014, rok.krajnc@gmail.com #include "string.h" #include "stdio.h" #include "boot.h" #include "hardware.h" #include "osd.h" #include "spi.h" #include "fat_compat.h" #include "font.h" // TODO! #define SPIN() asm volatile ( "mov r0, r0\n\t" \ "mov r0, r0\n\t" \ "mov r0, r0\n\t" \ "mov r0, r0"); static void mem_upload_init(unsigned long addr) { spi_osd_cmd32le_cont(OSD_CMD_WR, addr); } static void mem_upload_fini() { DisableOsd(); // do we really still need these if it's within a function? SPIN(); SPIN(); SPIN(); SPIN(); } static void mem_write16(unsigned short x) { SPI((((x)>>8)&0xff)); SPI(((x)&0xff)); // do we really still need these if it's within a function? SPIN(); SPIN(); SPIN(); SPIN(); } //// boot cursor positions //// unsigned short bcurx=0; unsigned short bcury=96; static int bootscreen_adr = 0x80000 + /*120*/104*640/8; void BootHome() { bootscreen_adr = 0x80000 + /*120*/104*640/8; } //// BootEnableMem() //// static void BootEnableMem() { // TEMP enable 1MB memory spi_osd_cmd8(OSD_CMD_MEM, 0x5); SPIN(); SPIN(); SPIN(); SPIN(); //EnableOsd(); //SPI(OSD_CMD_RST); //rstval = (SPI_CPU_HLT | SPI_RST_CPU); //SPI(rstval); //DisableOsd(); //SPIN(); SPIN(); SPIN(); SPIN(); //while ((read32(REG_SYS_STAT_ADR) & 0x2)); } //// BootClearScreen() //// static void BootClearScreen(int adr, int size) { int i; mem_upload_init(adr); for (i=0; i>16)&$ffff,$dff0e0 ; BPL1PTH //move.w #bpl1&$ffff,$dff0e2 ; BPL1PTL //move.w #(bpl2>>16)&$ffff,$dff0e4 ; BPL2PTH //move.w #bpl2&$ffff,$dff0e6 ; BPL2PTL mem_upload_init(0xdff0e0); mem_write16(0x0008); mem_write16(0x0000); mem_write16(0x0008); mem_write16(0x5000); mem_upload_fini(); //move.w #$a200,$dff100 ; BPLCON0, two bitplanes & colorburst enabled //move.w #$0000,$dff102 ; BPLCON1, bitplane control scroll value //move.w #$0000,$dff104 ; BPLCON2, misc bitplane bits //move.w #$0000,$dff106 ; BPLCON3, TODO //move.w #$0000,$dff108 ; BPL1MOD, bitplane modulo for odd planes //move.w #$0000,$dff10a ; BPL2MOD, bitplane modulo for even planes mem_upload_init(0xdff100); mem_write16(0xa200); mem_write16(0x0000); mem_write16(0x0000); mem_write16(0x0000); mem_write16(0x0000); mem_write16(0x0000); mem_upload_fini(); //move.w #$09f0,$dff040 ; BLTCON0 //move.w #$0000,$dff042 ; BLTCON1 //move.w #$ffff,$dff044 ; BLTAFWM, blitter first word mask for srcA //move.w #$ffff,$dff046 ; BLTALWM, blitter last word mask for srcA mem_upload_init(0xdff040); mem_write16(0x09f0); mem_write16(0x0000); mem_write16(0xffff); mem_write16(0xffff); mem_upload_fini(); //move.w #$0000,$dff064 ; BLTAMOD //move.w #BLITS,$dff066 ; BLTDMOD mem_upload_init(0xdff064); mem_write16(0x0000); mem_write16(BLITS); mem_upload_fini(); //move.w #$0000,$dff180 ; COLOR00 //move.w #$0aaa,$dff182 ; COLOR01 //move.w #$0a00,$dff184 ; COLOR02 //move.w #$0000,$dff186 ; COLOR03 mem_upload_init(0xdff180); mem_write16(0x0000); mem_write16(0x0aaa); mem_write16(0x0a00); mem_write16(0x000a); mem_upload_fini(); //move.w #$0000,$dff088 ; COPJMP1, restart copper at location 1 mem_upload_init(0xdff088); mem_write16(0x0000); mem_upload_fini(); } //// BootInit() //// void BootInit() { BootEnableMem(); BootClearScreen(SCREEN_ADDRESS, SCREEN_MEM_SIZE); BootUploadLogo(); BootUploadBall(); BootUploadCopper(); BootCustomInit(); //int i; //char s[3]; //s[1] = 'A'; //s[2] = 0; //for (i=0; i<16; i++) { // s[0] = 49+i; // BootPrintEx(s); //} } //// BootPrint() //// void BootPrintEx(char * str) { char buf[2]; unsigned char i,j; unsigned char len; iprintf(str); iprintf("\r"); len = strlen(str); len = (len>80) ? 80 : len; for(j=0; j<8; j++) { mem_upload_init(bootscreen_adr); for(i=0; i