Difference between revisions of "Pk howto"

From Felixl.com
Jump to navigationJump to search
 
Line 36: Line 36:
  
 
where foo2.elf -- is name of your main executable, which should start upon disk boot-up.
 
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>
 +
 +
int task1(void * param1,void * param2);
 +
 +
 +
void main()
 +
{
 +
  int maintask;
 +
 
 +
  pg_init();
 +
  pc_init();
 +
  ps_init();
 +
 +
  maintask=pk_createtask(task1,100);
 +
 
 +
  while(maintask)
 +
    pk_yield();
 +
 +
  pk_destroytask(main);
 +
}
 +
 +
int task1(void * param1,void * param2)
 +
{
 +
    int m_vbl;
 +
    int m_bitmap;
 +
 +
    m_vbl=pg_createvbl(VBL_DEFAULT);
 +
    m_bitmap=pg_createbitmap(320,240,16);
 +
    pg_attachstream(m_bitmap,stdio);
 +
    pg_vblattachbitmap(m_vbl,m_bitmap);
 +
    pg_applyvbl(m_vbl);
 +
   
 +
    printf("Hello world\n");
 +
    printf("(c) 2006 Felix.\n");
 +
   
 +
    while(pc_padhit(0)==0)
 +
      pk_yield();
 +
 +
    pg_attachstream(m_bitmap,0);
 +
    pg_removevbl(m_vbl);
 +
    pg_vblremovebitmap(m_bitmap);
 +
    pg_destroybitmap(m_bitmap);
 +
    pg_destroyvbl(m_vbl);     
 +
   
 +
    pk_destroytask(task1);
 +
}

Revision as of 20:15, 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>
int task1(void * param1,void * param2);

void main()
{ 
  int maintask;
  
  pg_init();
  pc_init();
  ps_init();
  maintask=pk_createtask(task1,100);
  
  while(maintask)
    pk_yield();
  pk_destroytask(main);
}
int task1(void * param1,void * param2)
{
   int m_vbl;
   int m_bitmap;
   m_vbl=pg_createvbl(VBL_DEFAULT);
   m_bitmap=pg_createbitmap(320,240,16);
   pg_attachstream(m_bitmap,stdio);
   pg_vblattachbitmap(m_vbl,m_bitmap);
   pg_applyvbl(m_vbl);
   
   printf("Hello world\n");
   printf("(c) 2006 Felix.\n");
   
   while(pc_padhit(0)==0)
     pk_yield();
   pg_attachstream(m_bitmap,0);
   pg_removevbl(m_vbl);
   pg_vblremovebitmap(m_bitmap);
   pg_destroybitmap(m_bitmap);
   pg_destroyvbl(m_vbl);       
   
   pk_destroytask(task1);
}