Difference between revisions of "Pk howto"
From Felixl.com
Jump to navigationJump to search(One intermediate revision by the same user not shown) | |||
Line 42: | Line 42: | ||
#include <phantom.h> | #include <phantom.h> | ||
#include <stdio.h> | #include <stdio.h> | ||
− | + | // | |
+ | //definition of virtual task1 function | ||
int task1(void * param1,void * param2); | int task1(void * param1,void * param2); | ||
− | + | // | |
− | + | //our main | |
void main() | void main() | ||
{ | { | ||
− | int maintask; | + | int maintask;// this will be our task handler |
− | + | // | |
− | pg_init(); | + | // |
− | pc_init(); | + | pg_init(); // init of graphics subsystem |
− | ps_init(); | + | pc_init(); // init of control subsystem |
− | + | ps_init(); // init of systemwide parameters, including libc | |
− | maintask=pk_createtask(task1,100); | + | // |
− | + | maintask=pk_createtask(task1,100);//task creation -- priority is set to average (255 - max. 0 - min) | |
− | while(maintask) | + | // |
− | pk_yield(); | + | // |
− | + | while(maintask) // waiting for task completion -- the handler of destroyed task will be 0 | |
− | pk_destroytask(main); | + | pk_yield(); // yield CPU time to any one.... be nice to others |
+ | // | ||
+ | pk_destroytask(main); //perform suicide :) | ||
} | } | ||
− | + | // | |
+ | // | ||
int task1(void * param1,void * param2) | int task1(void * param1,void * param2) | ||
{ | { | ||
− | int m_vbl; | + | int m_vbl; /// our vbl handler |
− | int m_bitmap; | + | int m_bitmap; // our bitmap handler |
− | + | // | |
− | m_vbl=pg_createvbl(VBL_DEFAULT); | + | m_vbl=pg_createvbl(VBL_DEFAULT); // create standard vbl |
− | m_bitmap=pg_createbitmap(320,240,16); | + | // |
− | pg_attachstream(m_bitmap,stdio); | + | m_bitmap=pg_createbitmap(320,240,16); // create bitmap, 320x240 pixels with 16 bit colors |
− | pg_vblattachbitmap(m_vbl,m_bitmap); | + | // |
− | pg_applyvbl(m_vbl); | + | pg_attachstream(m_bitmap,stdio); // attach our stdio stream, to appear on bitmap as text |
− | + | pg_vblattachbitmap(m_vbl,m_bitmap); // attach our bitmap to our vbl -- currently no other parameters | |
+ | pg_applyvbl(m_vbl); // attach our vbl into system display list -- enables our display | ||
+ | // | ||
printf("Hello world\n"); | printf("Hello world\n"); | ||
− | printf("(c) 2006 Felix.\n"); | + | printf("(c) 2006 Felix.\n"); // :) |
− | + | // | |
− | while(pc_padhit(0)==0) | + | while(pc_padhit(0)==0) //wait for any button press on joypad 0 |
− | pk_yield(); | + | pk_yield(); //be nice to others |
− | + | // | |
− | pg_attachstream(m_bitmap,0); | + | pg_attachstream(m_bitmap,0); // remove stream attachement |
− | pg_removevbl(m_vbl); | + | pg_removevbl(m_vbl); // remove our vbl from system display list --- at this point all user will see is a blank screen |
− | pg_vblremovebitmap(m_bitmap); | + | pg_vblremovebitmap(m_vbl,m_bitmap); // remove our bitmap from our vbl |
− | pg_destroybitmap(m_bitmap); | + | pg_destroybitmap(m_bitmap); // destroy our bitmap |
− | pg_destroyvbl(m_vbl); | + | pg_destroyvbl(m_vbl); // destroy our vbl |
− | + | // | |
− | pk_destroytask(task1); | + | pk_destroytask(task1); // perform suicide |
} | } |
Latest revision as of 20:24, 5 September 2006
The typical Phantom development flow is
development of the title -> compilation -> creating the disk structure -> mkisofs -> blessiso -> sign
all steps are obvious besides, may be, creating of the disk structure.
here is the sample disk structure
/ | +---Phantom.sys | | +---foo | | | | | +--- foo2.elf | +--- autostart.cmd
where -- Phantom.sys is directory, supplied with Phantom SDK, just copy it to the root of the disk; foo -- sample directory, foo2.elf -- sample file executable file, autostart.cmd -- script, executed upon disk booting.
In order to sucessfully initialize Phantom SDK one should include following lines in the begining of the autostart.cmd
!kernel.complete !graphics.load !sound.load !hardware.complete !hardware.authorize !device.load !device.createevents /foo/foo2.elf
where foo2.elf -- is name of your main executable, which should start upon disk boot-up.
And here is the sample "Hello world" program.
#include <phantom.h> #include <stdio.h> // //definition of virtual task1 function int task1(void * param1,void * param2); // //our main void main() { int maintask;// this will be our task handler // // pg_init(); // init of graphics subsystem pc_init(); // init of control subsystem ps_init(); // init of systemwide parameters, including libc // maintask=pk_createtask(task1,100);//task creation -- priority is set to average (255 - max. 0 - min) // // while(maintask) // waiting for task completion -- the handler of destroyed task will be 0 pk_yield(); // yield CPU time to any one.... be nice to others // pk_destroytask(main); //perform suicide :) } // // int task1(void * param1,void * param2) { int m_vbl; /// our vbl handler int m_bitmap; // our bitmap handler // m_vbl=pg_createvbl(VBL_DEFAULT); // create standard vbl // m_bitmap=pg_createbitmap(320,240,16); // create bitmap, 320x240 pixels with 16 bit colors // pg_attachstream(m_bitmap,stdio); // attach our stdio stream, to appear on bitmap as text pg_vblattachbitmap(m_vbl,m_bitmap); // attach our bitmap to our vbl -- currently no other parameters pg_applyvbl(m_vbl); // attach our vbl into system display list -- enables our display // printf("Hello world\n"); printf("(c) 2006 Felix.\n"); // :) // while(pc_padhit(0)==0) //wait for any button press on joypad 0 pk_yield(); //be nice to others // pg_attachstream(m_bitmap,0); // remove stream attachement pg_removevbl(m_vbl); // remove our vbl from system display list --- at this point all user will see is a blank screen pg_vblremovebitmap(m_vbl,m_bitmap); // remove our bitmap from our vbl pg_destroybitmap(m_bitmap); // destroy our bitmap pg_destroyvbl(m_vbl); // destroy our vbl // pk_destroytask(task1); // perform suicide }