Fadest :
Comme vous le savez, la ram de la Lynx fait 64ko, donc cotre programme ne peut pas dépasser cette taille.
As you probably know, Lyn Ram is 64ko wide, (as on each 8 bit system)
So the program musn't be wider than this
Ce qui est très limitatif une fois linké les sprites, fonds, sons...
It quickly becomes a problem, regarding to sprite size, backgrounds, sounds...
Pourtant, une cartouche Lynx fait 256ko en moyenne.
But as you can have read on the link in the other thread, Rom (cart) size can be 64ko to a maximum of 1Mo, with 256ko of average size in most of comercial lynx games
Vous pouvez donc choisir de faire une compil en mettant plusieurs jeux sur le même cartouche, ou ajouter les datas en externes et les charger en mémoire vive.
You can chose to make a "compilation" of some games on the same cartdrige, or to add external data and then loading them into RAM
Malheureusement, les fonctions de gestion des fichiers ne sont pas terminées dans le kit BLL (à priori, le source ASM existe dans les librairies, mais elles ne sont pas disponibles pour els développement C car pas finalisées), mais il est possible de se débrouiller en faisant des lectures par blocs.
Unfortunately, file management functions in the BLL kit (the ASM source is available in libraries but C header aren't provided). But it's possible to manage using this feature reading by blocs.
C'est ce point que nous allons aborder maintenant :
Tout d'abord le source C
Let's have a see to the C source code

#include <stdlib.h>
#include <lynx.h>
#include <lynxlib.h>
#include "titre.pal"
/* LYNX-specific #defines: */
#define BUTTON_OUTER 0x01
extern char FileEntry[8];
/*_FileEntry : struct of 8 bytes
FileStartBlock ds 1
FileBlockOffset ds 2
FileExecFlag ds 1
FileDestAddr ds 2
FileFileLen ds 2
*/
char titre[2048];
char musak[35000];
char SCREEN[8160] at (0xfff8-16320); // screen 1
extern char SCB1[];
#asm
_SCB1 dc.b $c7,$10,$20
dc.w 0,0
dc.w 0,0,$100,$100
; Because we didn't use -C when calling SPRPCK we can
; use the same colour palette indexes for all tiles
dc.b $01,$23,$45,$67,$89,$Ab,$cd,$ef
#endasm
/*********************/
/* wait for a button */
/*********************/
char WaitButton()
{
char key;
while (joystick);
while ( (key = joystick) != BUTTON_OUTER) ;
/* wait for the button to be released */
while ( joystick ) ;
return key;
}
/**************************************************************************
** **
** **
**************************************************************************/
main()
{
char i;
InitIRQ();
CLI;
SetBuffers(SCREEN, 0,0);
SmpInit(0,1);
EnableIRQ(1);
/* set the palette */
SetRGB(pal);
LoadCartDir(2);
DrawFBox(0,0,160,102,i);
LoadCartBlock(FileEntry[0], titre);
LoadCartBlock(FileEntry[0]+1, titre+1024);
SCBDATA(SCB1) = titre;
DrawSprite(SCB1);
WaitButton();
LoadCartDir(5);
for (i=0; i<33; i++)
LoadCartBlock(FileEntry[0]+i, musak+i*1024);
SmpStart(musak,0);
for( ; ; );
}
Le programme est compilé, assemblé et liké, on obtient un fichier test.o
once compiled & assembled, the program gives us a TEST.O file
Il faut ensuite créer une image Lynx avec le programme LYNXER
Then use the LYNXER utility to make an Lynx image
Pour celà, on crée un fichier test.mak et on appelle la commande LYNXER test.mak
Contenu de test.mak :
To do so, we must create a TEST.MAK file and then call the Lynxer command with test.mak as argument
INSERT.O
test.o
#ALIGN
fond.spr
#ALIGN
ti002000.spr
#ALIGN
ti003000.spr
#ALIGN
test.lsf
insert.o = traitement d'init de la lynx
init of the lynx system (boot code)
test.o = notre programme
our program
Ensuite, il s'agit des fichiers à inclure, soit :
Then files to include
fond.spr
ti00200.spr
ti003000.spr : 3 sprites 160x102 dans ce cas (gérénés par sprpck sans préciser l'option -p0)
3 160*102 sprites, generated with sprpck WITHOUT specifying the -p0 option
test.lsf : un sample généré par wav2lsf (voir tuto sonorisez votre lynx)
A sound sample, made with WAV2LSF.EXE
Pour simplifier la gestion, les fichiers sont alignés sur le début d'un bloc grâce à la commande #ALIGN à mettre sur la ligne précédente.
Each file is bloc aligned with the #ALIGN command on each previous lign
On obtient un fichier test.lyx à flasher sur cartouche.
We have a TEST.LYX ready to be used on the cartdrige
Pour tester avec Handy, il faut le transformer en image avec make_lnx test.lyx -b0 256k
If you prefer Testing with HANDY emulator, you have to make an handy image calling MAKE_LNX TEST.LYX -b0 256k
Bon, maintenant, l'explication du programme :
So now how does it works ?

On définit donc 2 espaces mémoire titre (un sprite 160x102 prend 2048 octets) et musak (taille en fonction du fichier .lsf).
We define two empty spaces for the title
Chargement et affichage du fond :
Loading & displaying background sprite
LoadCartDir(2);
LoadCartBlock(FileEntry[0], titre);
LoadCartBlock(FileEntry[0]+1, titre+1024);
SCBDATA(SCB1) = titre;
DrawSprite(SCB1);
LoadCartDir permet d'initialiser le tableau FileEntry pour le fichier passé en paramètre (ici 2, donc fond.spr)
LoadCartDir allows Filentry table initialisation for the file that is passed (here 2, so FOND.SPR)
FileEntry[ 0] contient le n° de bloc contenant le début du fichier, comme on a spécifié #ALIGN, on sait que le fichier débute en début de bloc.
FileEntry[0] contain the bloc number containing the start of th file, and because we specified #ALIGN, we know that the files start a the begining of the bloc
LoadCartBlock charge 1 bloc de 1024 octets spécifié en premier paramètre à l'adresse donnée dans le deuxième paramètre.
LoadCartBlock loads a 1024 Bytes bloc specified as first parameter at the adress given as second parameter
Comme un sprite fond fait 2 blocs, on duplique LoadCartBlock (chargement du bloc suivant 1024 octets plus loin dans titre)
As a background sprite has a size of 2 blocs, we call LoadCartBlock twice
Ensuite, on affiche le sprite
Then display of the sprite
Pour le sample, chez moi, il fait 33 ko, donc au lieu de dupliquer 33 fois LoadCartBlock, j'ai fait une boucle, mais le principe est le même :
My sound sample is 33ko, so instead of calling 33 times LoadCartBlock, I've made a loop, but the functionment is the same
LoadCartDir(5);
for (i=0; i<33; i++)
LoadCartBlock(FileEntry[0]+i, musak+i*1024);
SmpStart(musak,0);
Une fois musak chargée, il suffit de la jouer.
As soon as the NOISE

is loaded, we only have to play it.
Voilà, c'est rapide et nouveau pour moi, mais je pense que ça peut être utile à quelqu'un.
et si vous avez des questions ou des précisions à apporter, n'hésitez pas.
So it's a quick translation, if you need more details, don't Hesitate
POUR TOUS LES AUTRES, ON CONTINUE EN ANGLAIS
(we continue in english in your threads

)