In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

User:Cboomf: Difference between revisions

From WiiBrew
Jump to navigation Jump to search
Cboomf (talk | contribs)
covering my back
Blooper4912 (talk | contribs)
m Reverted edits by Cboomf (Talk); changed back to last version by Doogez
Line 1: Line 1:
{{HomebrewPossiblyDangerous}}
I am a NERD ;-)


{{Infobox homebrewapp
PC SPECS :-
| image      =
 
| title      = [[Homebrew apps/Wii Web Server]]
1: PIII 750MHz (over clocked to 800MHz), 64MB Dual Screen Graphics Card, 256MB Ram, 20GB Hard Drive, Win 98 + Ubuntu 7.10<br>
| desc        = A web server running on wii
2: Celeron 1.2GHz, 16MB Graohics Card, 512 MB Ram, 2x 15GB Hard Drives, Ubuntu 7.10<br>
| type        = Server
3: Celeron 1.2GHz, 16MB Graphics Card, 256 MB Ram, 20GB Hard Drive, Win 98<br>
| author      = Cboomf
4: AMD Athlon 1.8GHz, 128MB Graphics Card, 512MB Ram, 80GB Hard Drive, Win XP<br>
| download    = [https://sourceforge.net/projects/wiiwebserver/ Project Page]
5: P1 233MHz, 8MB Graphics Card, 256MB Ram, 3GB Hard Drive, Win 95<br>
| peripherals = {{Wiimote1}}{{WiFi}}{{Internet}}{{FrontSD}}
6: LAPTOP : Celeron 1.7GHz, 230MB Graphics Card, 1GB Ram, 2x 20GB Hard Drives, Win XP + Ubuntu 7.10<br>
| hbc=1
 
| hbb=1
 
}}
I am currently coding ( attempting ;-) ) a package of seemingly random bits of code that may server a purpose, may not but, it is just to learn C and have some fun with my wii.
 
If someone can improve it put any improvements in the Updates section at the bottom ;-)
 
===Code dump : ===
 
<source lang="c">
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ogcsys.h>
#include <gccore.h>
#include <ogc/ipc.h>
#include <stdarg.h>
#include <ctype.h>
#include <unistd.h>
#include <assert.h>
 
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
 
#include "ios.c"
#include "stm.c"
#include "es.h"
#include "es.c"
#include "ipc.h"
#include "gu.c"
 
#include "GRRLIB.h"
 
#include "../gfx/music.h"


{{Infobox homebrewapp
typedef void (*Loader_Entry)(void);
| image      =
static u32 *xjb;
| title      = [[Homebrew apps/WebRator]]
| desc        = Interactive cyber fun for the whole family
| type        = Fakes/Jokes
| author      = Cboomf
| download    = [http://cbwii.ulmb.com/WebRator.zip Download]
| peripherals = {{Wiimote4}}{{WiFi}}{{Internet}}
}}


{{Infobox homebrewapp
Loader_Entry loader = (Loader_Entry)0x80001800;
| image      =  
| title      = [[User:Cboomf/libusbkbd|libusbkbd]]
| desc        = A library for usb keyboard usage
| type        = Library
| author      = Cboomf
| download    = yes
| peripherals = {{USBKeyboard}}
}}


{{Infobox homebrewapp
extern u16 *GRRLIB_buffer;
| image      =
| title      = [[User:Cboomf/libwiilight|libwiilight]]
| desc        = A library for the disc slot light
| type        = Library
| author      = Cboomf
| download    = [[Image:libwiilight.zip]]
| peripherals =
}}


void hello(void)
{
    printf("Hello world!\n");
printf("v 0.3");
}


void menutext(void)
{
    printf("Menu\n");
printf("----\n");
printf("Start + Z    = Return to loader\n");
printf("A !!        = Elf Loader\n");
printf("B !!        = System Utils\n");
printf("Y !          = Fun\n");
printf("X            = Reboot Wii\n");
    return;
}


void clearscreen(void)
{
int y;
    for(y=0;y<34;y++)
printf("                                                                          \n");
}


void checkAndReload(void) {
  PAD_ScanPads();
  int buttonsDown = PAD_ButtonsHeld(0);
  if( (buttonsDown & PAD_TRIGGER_Z) && (buttonsDown & PAD_BUTTON_START)) {
    loader();
  }
}


void console(void) {
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
xjb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
}


void sysutils(void) {
    bool pressed;
 
    pressed=false;
clearscreen();
    printf("System Utils Menu\n");
printf("-----------------\n\n");
    printf("X = Load IOS37\n");
printf("Y = Load IOS9\n");
printf("B = Go Back\n");
printf("Press A to continue \n");
while((pressed=false)) {
VIDEO_WaitVSync();
PAD_ScanPads();
int buttonsDown = PAD_ButtonsHeld(0);
if (buttonsDown & PAD_BUTTON_X){
            __IOS_LaunchNewIOS(37);
pressed=true;
    }
if (buttonsDown & PAD_BUTTON_Y){
    IOS_ReloadIOS(9);
pressed=true;
}
if (buttonsDown & PAD_BUTTON_B){
    pressed=true;
}
    }
return;
}


void shutdown(void) {
    __STM_Init();
STM_RebootSystem();
__STM_Close();
}


void fun(void) {


    clearscreen();
__STM_Init();
 
    printf("FUN\n");
printf("---\n\n");
int ver;
int revma;
int revmi;
int di_fd;
int es_fd;
int vec;
u32 wiiid;
static u8 stm_inbuf[0x20] ATTRIBUTE_ALIGN(32);
static u8 stm_iobuf[0x20] ATTRIBUTE_ALIGN(32);
ver=IOS_GetVersion();
revma=IOS_GetRevisionMajor();
revmi=IOS_GetRevisionMinor();
    printf("IOS Version : %d  Revision : %d.%d \n\n", ver, revma, revmi);
di_fd=IOS_Open("/dev/di",1);
    ((u32*)stm_inbuf)[0x00] = 0x70000000;
IOS_Ioctl( di_fd, stm_inbuf[0x00], stm_inbuf, 0x20, stm_iobuf, 0x20);
printf("DVD ID : %s \n\n",stm_iobuf);
IOS_Close(di_fd);
vec=0;
es_fd=IOS_Open("/dev/es",1);
vec = ES_GetDeviceID(&wiiid);
// printf("Console ID : %08x \n\n", wiiid);
IOS_Close(es_fd);
GRRLIB_DrawImg(10,50, music_width, music_high, music_img);
GRRLIB_Render();
printf("Press A to continue\n");
while(1) {
VIDEO_WaitVSync();
PAD_ScanPads();
int buttonsDown = PAD_ButtonsHeld(0);
if (buttonsDown & PAD_BUTTON_A){
    console();
            clearscreen();
        menutext();
__STM_Close();
        return;     
    }
}
}


void menu(void) {
    clearscreen();
menutext();
while(1) {
VIDEO_WaitVSync();
    checkAndReload();
PAD_ScanPads();
int buttonsDown = PAD_ButtonsHeld(0);
if (buttonsDown & PAD_BUTTON_Y){
            fun();
    }
if (buttonsDown & PAD_BUTTON_X){
            shutdown();
    }
if (buttonsDown & PAD_BUTTON_B){
    //sysutils();
}
if (buttonsDown & PAD_BUTTON_A){
    //elfloader();
}
    }
}




void start(void) {
    PAD_ScanPads();
    int buttonsDown = PAD_ButtonsHeld(0);
    if(buttonsDown & PAD_BUTTON_START) {
      menu();
    }
}


int main(int argc, char **argv) {


  /****************************************************************************
Initialise Video
  Initialise GCPad for input
****************************************************************************/


GRRLIB_buffer=(u16 *)malloc(640*240*2);
VIDEO_Init();
PAD_Init();
GRRLIB_InitVideo();
GRRLIB_Start();
GRRLIB_FillScreen(0x0000);
GRRLIB_Render();


switch(VIDEO_GetCurrentTvMode()) {
case VI_NTSC:
rmode = &TVNtsc480IntDf;
break;
case VI_PAL:
rmode = &TVPal528IntDf;
break;
case VI_MPAL:
rmode = &TVMpal480IntDf;
break;
default:
rmode = &TVNtsc480IntDf;
break;
}


I am a '''NERD''' ;-)
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
xjb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
    /****************************************************************************
Main code
****************************************************************************/


PC SPECS :-
hello();
printf("\n");
printf("My first native wii homebrew\n\n");
printf("Press Start :-)\n\n");
while(1) {
VIDEO_WaitVSync();
start();
}
return 0;
}
 
</source>
 
== Updates ==


1: PIII 750MHz (over clocked to 800MHz), 64MB Dual Screen Graphics Card, 256MB Ram, 20GB Hard Drive, Win 98 + Ubuntu 7.10<br>
These may be updates/fixes for the code above
2: Celeron 1.2GHz, 16MB Graohics Card, 512 MB Ram, 2x 15GB Hard Drives, Ubuntu 8.04<br>
-- I was able to compile your code. I think you need the most recent cvs of the libogc use Drack's guide
3: Celeron 1.2GHz, 16MB Graphics Card, 256 MB Ram, 20GB Hard Drive, Win 98<br>
http://www.tehskeen.com/forums/showthread.php?t=2968
4: AMD Athlon 1.8GHz, 128MB Graphics Card, 512MB Ram, 80GB Hard Drive, Win XP<br>
Also you should not include .c files in the header.
5: P1 233MHz, 8MB Graphics Card, 256MB Ram, 3GB Hard Drive, Win 95<br>
<source lang="c">
6: LAPTOP : Celeron 1.7GHz, 230MB Graphics Card, 1GB Ram, 2x 20GB Hard Drives, Win XP + Ubuntu 8.04<br>


Keep in the randomness : [http://cboomf.blogspot.com Random Entry Points]
</source>

Revision as of 23:31, 5 August 2008

I am a NERD ;-)

PC SPECS :-

1: PIII 750MHz (over clocked to 800MHz), 64MB Dual Screen Graphics Card, 256MB Ram, 20GB Hard Drive, Win 98 + Ubuntu 7.10
2: Celeron 1.2GHz, 16MB Graohics Card, 512 MB Ram, 2x 15GB Hard Drives, Ubuntu 7.10
3: Celeron 1.2GHz, 16MB Graphics Card, 256 MB Ram, 20GB Hard Drive, Win 98
4: AMD Athlon 1.8GHz, 128MB Graphics Card, 512MB Ram, 80GB Hard Drive, Win XP
5: P1 233MHz, 8MB Graphics Card, 256MB Ram, 3GB Hard Drive, Win 95
6: LAPTOP : Celeron 1.7GHz, 230MB Graphics Card, 1GB Ram, 2x 20GB Hard Drives, Win XP + Ubuntu 7.10


I am currently coding ( attempting ;-) ) a package of seemingly random bits of code that may server a purpose, may not but, it is just to learn C and have some fun with my wii.

If someone can improve it put any improvements in the Updates section at the bottom ;-)

Code dump :

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ogcsys.h>
#include <gccore.h>
#include <ogc/ipc.h>
#include <stdarg.h>
#include <ctype.h>
#include <unistd.h>
#include <assert.h>

static void *xfb = NULL;
static GXRModeObj *rmode = NULL;

#include "ios.c"
#include "stm.c"
#include "es.h"
#include "es.c"
#include "ipc.h"
#include "gu.c"

#include "GRRLIB.h"

#include "../gfx/music.h"

typedef void (*Loader_Entry)(void);
static u32 *xjb;

Loader_Entry loader = (Loader_Entry)0x80001800;

extern u16 *GRRLIB_buffer;

void hello(void)
{
    printf("Hello world!\n");
	printf("v 0.3");
}

void menutext(void)
{
    printf("Menu\n");
	printf("----\n");
	printf("Start + Z    = Return to loader\n");
	printf("A !!         = Elf Loader\n");
	printf("B !!         = System Utils\n");
	printf("Y !          = Fun\n");
	printf("X            = Reboot Wii\n");
    return;
}

void clearscreen(void)
{
		int y;
	    for(y=0;y<34;y++)
			printf("                                                                          \n");
}

void checkAndReload(void) {
  PAD_ScanPads();
  int buttonsDown = PAD_ButtonsHeld(0);
  if( (buttonsDown & PAD_TRIGGER_Z) && (buttonsDown & PAD_BUTTON_START)) {
    loader();
  }
}

void console(void) {
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	xjb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
	
	VIDEO_Configure(rmode);
	 VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
}

void sysutils(void) { 
    bool pressed;
   
    pressed=false;
	
	clearscreen();
	
    printf("System Utils Menu\n");
	printf("-----------------\n\n");
    printf("X = Load IOS37\n");
	printf("Y = Load IOS9\n");
	printf("B = Go Back\n");
	printf("Press A to continue \n");
	while((pressed=false)) {
		VIDEO_WaitVSync();
		PAD_ScanPads();
		int buttonsDown = PAD_ButtonsHeld(0);
		if (buttonsDown & PAD_BUTTON_X){
            __IOS_LaunchNewIOS(37);
			pressed=true;
	    }
		if (buttonsDown & PAD_BUTTON_Y){
		    IOS_ReloadIOS(9);
			pressed=true;
		}
		if (buttonsDown & PAD_BUTTON_B){
		    pressed=true;
		}
    }
	return;
}

void shutdown(void) {
    __STM_Init();
	STM_RebootSystem();
	__STM_Close();
}

void fun(void) {

    clearscreen();
	__STM_Init();
  
    printf("FUN\n");
	printf("---\n\n");
	
	int ver;
	int revma;
	int revmi;
	int di_fd;
	int es_fd;
	int vec;
	u32 wiiid;
	static u8 stm_inbuf[0x20] ATTRIBUTE_ALIGN(32);
	static u8 stm_iobuf[0x20] ATTRIBUTE_ALIGN(32);
	
	ver=IOS_GetVersion();
	revma=IOS_GetRevisionMajor();
	revmi=IOS_GetRevisionMinor();
    printf("IOS Version : %d   Revision : %d.%d \n\n", ver, revma, revmi);
	
	
	di_fd=IOS_Open("/dev/di",1);
    ((u32*)stm_inbuf)[0x00] = 0x70000000;
	IOS_Ioctl( di_fd, stm_inbuf[0x00], stm_inbuf, 0x20, stm_iobuf, 0x20);	
	printf("DVD ID : %s \n\n",stm_iobuf);
	IOS_Close(di_fd);
	
	vec=0;
	es_fd=IOS_Open("/dev/es",1);
	vec = ES_GetDeviceID(&wiiid);
	// printf("Console ID : %08x \n\n", wiiid);
	IOS_Close(es_fd);
	
	GRRLIB_DrawImg(10,50, music_width, music_high, music_img);
	GRRLIB_Render();
	
	printf("Press A to continue\n");
	while(1) {
		VIDEO_WaitVSync();
		PAD_ScanPads();
		int buttonsDown = PAD_ButtonsHeld(0);
		if (buttonsDown & PAD_BUTTON_A){
		    console();
            clearscreen();
	        menutext();
			__STM_Close();
	        return;       
	    }
	}
}

void menu(void) {
    clearscreen();
	menutext();
	while(1) {
		VIDEO_WaitVSync();
	    checkAndReload();
		PAD_ScanPads();
		int buttonsDown = PAD_ButtonsHeld(0);
		if (buttonsDown & PAD_BUTTON_Y){
            fun();
	    }
		if (buttonsDown & PAD_BUTTON_X){
            shutdown();
	    }
		if (buttonsDown & PAD_BUTTON_B){
		    //sysutils();
		}
		if (buttonsDown & PAD_BUTTON_A){
		    //elfloader();
		}
    }
}


void start(void) {
    PAD_ScanPads();
    int buttonsDown = PAD_ButtonsHeld(0);
    if(buttonsDown & PAD_BUTTON_START) {
      menu();
    }
}

int main(int argc, char **argv) {

   /**************************************************************************** 
	Initialise Video
   Initialise GCPad for input
	****************************************************************************/

	GRRLIB_buffer=(u16 *)malloc(640*240*2);
	
	VIDEO_Init();
	PAD_Init();
	
	GRRLIB_InitVideo();
	GRRLIB_Start();
	GRRLIB_FillScreen(0x0000);
	GRRLIB_Render();

	switch(VIDEO_GetCurrentTvMode()) {
		case VI_NTSC:
			rmode = &TVNtsc480IntDf;
			break;
		case VI_PAL:
			rmode = &TVPal528IntDf;
			break;
		case VI_MPAL:
			rmode = &TVMpal480IntDf;
			break;
		default:
			rmode = &TVNtsc480IntDf;
			break;
	}

	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	xjb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
	
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
	
    /**************************************************************************** 
	Main code
	****************************************************************************/

	hello();
	printf("\n");
	printf("My first native wii homebrew\n\n");
	printf("Press Start :-)\n\n");
	
	while(1) {
		VIDEO_WaitVSync();
		start();	
	}
	
	return 0;
}

Updates

These may be updates/fixes for the code above -- I was able to compile your code. I think you need the most recent cvs of the libogc use Drack's guide http://www.tehskeen.com/forums/showthread.php?t=2968 Also you should not include .c files in the header.