Newsgroup: it.comp.os.dibattiti
Titolo: Nanodesktop Demo 1 Source Code

#include <nanodesktop.h>
#include <css1.c>
#include <css2.c>
#include <leon.c>
struct ndImage_Type Image1, Image2, ImageWallPaper;
void Window1 ()
{
     unsigned char WndHeader;
     unsigned short int CounterX, CounterY;
     unsigned short int MagicNumber;
     unsigned short int ColorR, ColorG, ColorB;
     char *StrA = "Finestra nr.1: Palette colori";
     WndHeader=ndLP_AllocateWindow (0, 0, 460, 256, StrA, COLOR_WHITE, 
COLOR_BLUE, COLOR_BLACK, COLOR_WHITE);
     ndLP_MaximizeWindow (WndHeader);
     ndWS_WriteLn ("Questa è una demo della libreria NanoDesktop", 
COLOR_WHITE, WndHeader, NORENDER);
     ndWS_WriteLn ("creata da Filippo Battaglia.", COLOR_WHITE, WndHeader, 
NORENDER);
     ndWS_CarriageReturn (WndHeader);
     ndWS_CarriageReturn (WndHeader);
     XWindowRender (WndHeader);
     ndDelay (1);
     ndWS_ClrALL (WndHeader);
     ndWS_WriteLn ("La libreria Nanodesktop consente ai programmi", 
COLOR_WHITE, WndHeader, NORENDER);
     ndWS_WriteLn ("l'uso di un semplice ambiente grafico a", COLOR_WHITE, 
WndHeader, NORENDER);
     ndWS_WriteLn ("finestre. ", COLOR_WHITE, WndHeader, NORENDER);
     XWindowRender (WndHeader);
     ndDelay (1);
     ndWS_ClrALL (WndHeader);
     ndWS_WriteLn ("Su PSP la libreria gestisce 65.535 colori", COLOR_WHITE, 
WndHeader, NORENDER);
     for (CounterY=0; CounterY<255; CounterY++)
     {
         for (CounterX=0; CounterX<255; CounterX++)
         {
             ColorR = CounterX;
             ColorG = CounterY;
             ColorB = 255*( ((float)CounterX) / 255.0)*( ((float)CounterY) / 
255.0);
             MagicNumber = ndHAL_RGBToMagicNumber (ColorR, ColorG, ColorB);
             ndWS_PutPixel (10+CounterX, 20+CounterY, MagicNumber, 
WndHeader, NORENDER);
         }
     }
     XWindowRender (WndHeader);
     ndDelay (1);
     ndWS_ClrALL (WndHeader);
     ndLP_DestroyWindow (WndHeader);
}
void Window2()
{
     unsigned char WndHeader [7];
     unsigned int Counter;
     for (Counter=0; Counter<12; Counter++)
     {
         WndHeader [Counter]=ndLP_AllocateWindow (10+10*Counter, 
10+5*Counter, 340+10*Counter, 140+5*Counter, "Finestra", COLOR_WHITE, 
PSPWndColorVector [Counter+1], COLOR_BLACK, COLOR_WHITE);
         ndLP_MaximizeWindow (WndHeader [Counter]);
     }
     ndLP_PutWindowInFirstPlane (3);
     ndWS_WriteLn ("Sono supportate 12 finestre, ma", COLOR_WHITE, 3, 
NORENDER);
     ndWS_WriteLn ("questo valore può essere cambiato", COLOR_WHITE, 3, 
NORENDER);
     ndWS_WriteLn ("dal programmatore, compatibilmente", COLOR_WHITE, 3, 
NORENDER);
     ndWS_WriteLn ("con la memoria disponibile sulla", COLOR_WHITE, 3, 
NORENDER);
     ndWS_WriteLn ("piattaforma.", COLOR_WHITE, 3, NORENDER);
     XWindowRender (3);
     ndDelay (1);
     ndLP_MinimizeWindow (3);
     ndLP_MaximizeWindow (3);
     for (Counter=0; Counter<12; Counter++)
     {
         ndLP_DestroyWindow (WndHeader[Counter]);
     }
}
void Window3 (void)
{
     unsigned char WndHeader1, WndHeader2;
     unsigned short int Counter;
     WndHeader1=ndLP_AllocateWindow (10, 10, 380, 120, "Finestra A", 
COLOR_WHITE, COLOR_BLUE, COLOR_WHITE, COLOR_BLACK);
     ndLP_MaximizeWindow (WndHeader1);
     WndHeader2=ndLP_AllocateWindow (100, 100, 430, 220, "Finestra B", 
COLOR_WHITE, COLOR_RED, COLOR_WHITE, COLOR_BLACK);
     ndLP_MaximizeWindow (WndHeader2);
     ndWS_WriteLn ("Naturalmente non sono obbligato", COLOR_BLACK, 
WndHeader2, NORENDER);
     ndWS_WriteLn ("ad usare uno sfondo nero per", COLOR_BLACK, WndHeader2, 
NORENDER);
     ndWS_WriteLn ("per le finestre", COLOR_BLACK, WndHeader2, NORENDER);
     XWindowRender (WndHeader2);
     ndDelay (1);
     ndLP_PutWindowInFirstPlane (WndHeader1);
     ndWS_WriteLn ("Anzi, posso anche cambiare il colore", COLOR_BLACK, 
WndHeader1, NORENDER);
     ndWS_WriteLn ("della finestra", COLOR_BLACK, WndHeader1, NORENDER);
     ndWS_CarriageReturn (WndHeader1);
     ndWS_WriteLn ("Proprio come sto facendo ora", COLOR_BLACK, WndHeader1, 
NORENDER);
     XWindowRender (WndHeader1);
     for (Counter=0; Counter<7; Counter++)
        ndLP_ChangeWndColor (PSPWndColorVector [Counter], WndHeader2);
     ndLP_PutWindowInFirstPlane (WndHeader2);
     for (Counter=0; Counter<7; Counter++)
        ndLP_ChangeWndColor (PSPWndColorVector [Counter], WndHeader2);
     ndLP_DestroyWindow (WndHeader2);
     ndLP_DestroyWindow (WndHeader1);
}
void Window4()
{
     unsigned char WndHeader1, WndHeader2, WndHeader3;
     unsigned short int Counter;
     WndHeader1=ndLP_AllocateWindow (0, 0, 330, 230, "Finestra A", 
COLOR_WHITE, COLOR_BLUE, COLOR_WHITE, COLOR_BLACK);
     ndLP_MaximizeWindow (WndHeader1);
     ndIMG_InitImage (&Image1);
     ndIMG_LoadImageFromNDFArray (&Image1, css1Width, css1Height, css1, 
NDRGB);
     ndIMG_ShowImage (&Image1, 0, 0, WndHeader1, RENDER);
     ndWS_WriteLn ("La libreria NanoDesktop gestisce", 0xFFFF, WndHeader1, 
RENDER);
     ndWS_WriteLn ("in modo automatico lo scrolling" , 0xFFFF, WndHeader1, 
RENDER);
     ndWS_WriteLn ("dei caratteri sullo schermo", 0xFFFF, WndHeader1, 
RENDER);
     ndWS_CarriageReturn (WndHeader1);
     ndWS_WriteLn ("Inoltre gestisce l'overscan", 0xFFFF, WndHeader1, 
RENDER);
     ndWS_WriteLn ("dei caratteri, come mostra questa", 0xFFFF, WndHeader1, 
RENDER);
     ndWS_WriteLn ("demo", 0xFFFF, WndHeader1, RENDER);
     for (Counter=0; Counter<10; Counter++)
     {
         ndWS_WriteLn ("Guarda lo scrolling....", COLOR_WHITE, WndHeader1, 
RENDER);
         ndWS_WriteLn ("Guarda lo scrolling....", COLOR_LBLUE, WndHeader1, 
RENDER);
     }
     ndLP_ResizeWindow (250, 100, WndHeader1);
     for (Counter=0; Counter<10; Counter++)
     {
         ndWS_WriteLn ("Guarda lo scrolling....", COLOR_GREEN, WndHeader1, 
RENDER);
         ndWS_WriteLn ("Guarda lo scrolling....", COLOR_RED, WndHeader1, 
RENDER);
     }
     ndLP_ResizeWindow (330, 230, WndHeader1);
     for (Counter=0; Counter<10; Counter++)
     {
         ndWS_WriteLn ("Guarda lo scrolling....", COLOR_GREEN, WndHeader1, 
RENDER);
         ndWS_WriteLn ("Guarda lo scrolling....", COLOR_RED, WndHeader1, 
RENDER);
     }
     WndHeader2=ndLP_AllocateWindow (200, 50, 360, 170, "Finestra B", 
COLOR_WHITE, COLOR_GREEN, COLOR_WHITE, COLOR_BLACK);
     ndLP_MaximizeWindow (WndHeader2);
     ndIMG_InitImage (&Image2);
     ndIMG_LoadImageFromNDFArray (&Image2, css2Width, css2Height, css2, 
NDRGB);
     ndIMG_ShowImage (&Image2, 0, 0, WndHeader2, RENDER);
     for (Counter=0; Counter<5; Counter++)
     {
         ndWS_WriteLn ("Scrolling....", COLOR_WHITE, WndHeader1, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_LGREEN, WndHeader2, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_LBLUE, WndHeader1, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_RED, WndHeader2, RENDER);
     }
     WndHeader3=ndLP_AllocateWindow (20, 180, 440, 250, "", COLOR_WHITE, 
COLOR_RED, COLOR_WHITE, COLOR_BLACK);
     ndLP_MaximizeWindow (WndHeader3);
     ndWS_WriteLn ("Le funzioni di scrolling e overscan", COLOR_BLACK, 
WndHeader3, RENDER);
     ndWS_WriteLn ("funzionano anche in caso di spostamento", COLOR_BLACK, 
WndHeader3, RENDER);
     ndWS_WriteLn ("delle finestre.", COLOR_BLACK, WndHeader3, RENDER);
     ndLP_MoveWindow (180, 40, WndHeader2);
     for (Counter=0; Counter<3; Counter++)
     {
         ndWS_WriteLn ("Scrolling....", COLOR_WHITE, WndHeader1, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_LGREEN, WndHeader2, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_LBLUE, WndHeader1, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_RED, WndHeader2, RENDER);
     }
     ndLP_MoveWindow (150, 80, WndHeader2);
     for (Counter=0; Counter<3; Counter++)
     {
         ndWS_WriteLn ("Scrolling....", COLOR_WHITE, WndHeader1, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_LGREEN, WndHeader2, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_LBLUE, WndHeader1, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_RED, WndHeader2, RENDER);
     }
     ndLP_MoveWindow (120, 100, WndHeader2);
     for (Counter=0; Counter<3; Counter++)
     {
         ndWS_WriteLn ("Scrolling....", COLOR_WHITE, WndHeader1, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_LGREEN, WndHeader2, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_LBLUE, WndHeader1, RENDER);
         ndWS_WriteLn ("Scrolling....", COLOR_RED, WndHeader2, RENDER);
     }
     ndLP_DestroyWindow (WndHeader3);
     ndLP_DestroyWindow (WndHeader2);
     ndLP_DestroyWindow (WndHeader1);
}
void Window5 ()
{
     unsigned char WndHeader;
     unsigned short int Counter;
     WndHeader=ndLP_AllocateWindowComplex (10, 10, 400, 250, 
"INGRANDIMENTO", COLOR_WHITE, COLOR_BLUE, COLOR_WHITE, COLOR_BLACK, 470, 
270);
     ndLP_MaximizeWindow (WndHeader);
     ndWS_WriteLn ("La libreria Nanodesktop supporta", COLOR_BLACK, 
WndHeader, NORENDER);
     ndWS_WriteLn ("La visualizzazione delle immagini", COLOR_BLACK, 
WndHeader, NORENDER);
     ndWS_WriteLn ("con differenti ingrandimenti", COLOR_BLACK, WndHeader, 
NORENDER);
     XWindowRender (WndHeader);
     ndDelay (1);
     ndWS_ClrALL (WndHeader);
     ndLP_ChangeWndTitle ("Scala x=1 y=1", COLOR_WHITE, COLOR_BLUE, 
WndHeader);
     ndIMG_LoadImageFromNDFArray (&Image2, css2Width, css2Height, css2, 
NDRGB);
     ndIMG_ShowImage (&Image2, 0, 0, WndHeader, RENDER);
     ndDelay (1);
     ndWS_ClrALL (WndHeader);
     ndLP_ChangeWndTitle ("Scala x=0.5 y=0.5", COLOR_WHITE, COLOR_BLUE, 
WndHeader);
     ndIMG_ShowImageScaled (&Image2, 0, 0, 0.5, 0.5, WndHeader, RENDER);
     ndDelay (1);
     ndWS_ClrALL (WndHeader);
     ndLP_ChangeWndTitle ("Scala x=2 y=2", COLOR_WHITE, COLOR_BLUE, 
WndHeader);
     ndIMG_ShowImageScaled (&Image2, 0, 0, 2, 2, WndHeader, RENDER);
     for (Counter=0; Counter<=10; Counter++)
     {
         ndLP_ChangeWindowROI (0, Counter*10, WndHeader);
     }
     ndDelay (1);
     ndWS_ClrALL (WndHeader);
     ndLP_ChangeWndTitle ("Scala x=3 y=3", COLOR_WHITE, COLOR_BLUE, 
WndHeader);
     ndIMG_ShowImageScaled (&Image2, 0, 0, 3, 3, WndHeader, RENDER);
     for (Counter=0; Counter<=10; Counter++)
     {
         ndLP_ChangeWindowROI (0, Counter*10, WndHeader);
     }
     ndDelay (1);
     ndIMG_ReleaseImage (&Image1);
     ndIMG_ReleaseImage (&Image2);
     ndLP_DestroyWindow (WndHeader);
}
void Window6()
{
  unsigned char WndHeader;
  ndIMG_LoadImageFromNDFArray (&ImageWallPaper, sfondoWidth, sfondoHeight, 
sfondo, NDRGB);
  ndLP_LoadWallPaperFromNDImage (&ImageWallPaper);
  ndIMG_ReleaseImage (&ImageWallPaper);
  ndLP_EnableTrasparency ();
  WndHeader=ndLP_AllocateWindow (10, 10, 380, 120, "Trasparenze", 
COLOR_WHITE, COLOR_BLUE, COLOR_GRAY, COLOR_BLACK);
  ndLP_MaximizeWindow (WndHeader);
  ndWS_WriteLn ("La libreria Nanodesktop supporta", COLOR_BLACK, WndHeader, 
NORENDER);
  ndWS_WriteLn ("la gestione degli sfondi e delle", COLOR_BLACK, WndHeader, 
NORENDER);
  ndWS_WriteLn ("trasparenze.", COLOR_BLACK, WndHeader, NORENDER);
  XWindowRender (WndHeader);
  ndDelay (1);
  ndLP_DisableTrasparency ();
  ndLP_DisableWallPaper ();
  ndLP_DestroyWindow (WndHeader);
}
void main()
{
       ndInitSystem ();
       Window1();
       Window2();
       Window3();
       Window4();
       Window5();
       Window6();
       ndSystemHalt(0);
}


The optimist thinks this is the best of all possible worlds.
The pessimist fears it is true.      [J. Robert Oppenheimer]


No, ha una libreria che gestisce i thread che si chiama pthread
(e che č diversa dalle librerie thread degli Unix).
Solo che per ora, per semplificare il problema, ho deciso che
le applicazioni Nanodesktop sono monoprocesso e monothread.
Al solito, parto da cose semplici e poi le faccio crescere
piano, piano.
Nota che tutto quel codice per la gestione dei threads che si vedeva
sotto l'Hello world per PSP č ora nascosto dentro ndInitSystem
e che i sorgenti iniziano sempre con main() (non piů xmain
per PSPE).
Ciao
Pegasus

 Al solito, parto da cose semplici e poi le faccio crescere piano, piano.
moolto piano ...
 certo che ce ne sono  di FANATICI in giro .
saluti 
il programmatore supremo e modesto . 

 per PSPE).
Ringraziamo il cielo, gia` era un abominio winmain(), una xmain() non 
sarebbe stata perdonata da nessuno.



Viene dal PSPSDK di pspdev.

 monothread.
Beh, il fatto che non implementi tutte le funzioni non e` pesante. Il 
fatto che le funzionalita` dei posix threads siano wrappati nei thread 
psp e` una cosa normalissima, lo standard impone il comportamento e 
alcune specifiche, poi come la implementi e` affar tuo.


      XWindowRender (WndHeader);
XWindow? ammazza che fantasia..... :-)
non vedo api per gestire le callback per interagire con l'utenza

 ha scritto nel messaggio 
news:44f2b...@x-privat.org...

Perchè questo è un source-code di un demo non
interattivo....