CpcAlive est un
environnement
de programmation
compatible
Amstrad CPC
pour création
d'animations
 graphiques.




Les mots clés du basic Cpc

Les messages d'erreur du basic Cpc

La mémoire

La gestion des disquettes


Z80: opcodes et programmation

Installateur CpcAlive pour
Windows & DosBox

Documentation CpcAlive






English

**  Exemple de programme basic pour l'émulateur CpcAlive (version Dosbox) **
AFFICHE IMAGES AU FORMAT BMP NON COMPRESSE 16/256 COULEURS **
DISPLAY BMP IMAGES 16/256 COLORS NOT COMPRESSED **
(format généré par exemple par le programme "Paint" dans les accessoires de windows 7) **



BAS: <- file header for the emulator CpcAlive

        MEMORY &8FFF

        ScreenMode=1:MODE ScreenMode

        ImgName$="IMAGE.BMP":' <<<<<<<<<<<<< IMAGE NAME HERE >>>>>>
        ximg=0:yimg=0:'    image coordinates
        BackGround=-1:'    not transparent background
        FirstInk=0:'       first ink use in palette
        gosub BMPDISPLAY:' ** DISPLAY BMP IMAGES 16/256 COLORS NOT COMPRESSED **
        end

/****************************************************
AFFICHE IMAGES AU FORMAT BMP NON COMPRESSE 16/256 COULEURS
DISPLAY BMP IMAGES 16/256 COLORS NOT COMPRESSED
<ImgName$   =  nom image
                      image name
 ScreenMode =  mode ecran
                      screen mode
 FirstInk        =  numero 1er crayon pour images 16 couleurs
                      first ink use in palette for 16 colors images
 BackGround  =  crayon de fond (-1 si non transparent)
                      background pen (-1 if not transparent)
****************************************************/

BMPDISPLAY:

        er%=0:adr=himem+1:'buffer
        |INPUT,ImgName$+":D,&500,0,&"+HEX$(adr),@er%:'block_lenght,adr_block_source_in_file,adr_in_Cpc_memory,@error_code
        if er%<>0 then FileInputEr
        adrline=PEEK(adr+&A)+256*PEEK(adr+&B):'adresse ligne a traiter dans fichier/adr img line in file
        adrimg=adr+adrline:'adresse image dans fichier/adr img in file
        largeur=PEEK(adr+&12)+256*PEEK(adr+&13):'largeur/with image
        IF PEEK(adr+&E)+256*PEEK(adr+&F)<>12 THEN READ_BITMAPFILEHEADER:'header type

//** READ BITMAPCOREHEADER **
        x=PEEK(adr+&18)+256*PEEK(adr+&19):'nbr bits/pixel
        hauteur=PEEK(adr+&14)+256*PEEK(adr+&15):'hauteur/hight image
        IF x=8 THEN BITMAPCOREHEADER_256:'256 couleurs/colors
        IF x<>4 THEN MODE 2:PRINT"16 or 256 colors in image only accepted.":END

//** DISPLAY IMAGE 16 COULEURS/COLORS **
        GOSUB cpc_inks_ordering
        x=FirstInk:'1er crayon/first pen in color palette
        FOR i=0 TO 15*3 STEP 3
                |INK,x,PEEK(adr+&1C+i),PEEK(adr+&1B+i),PEEK(adr+&1A+i)
                x=x+1
        NEXT

DISPLAY16:

        reste=largeur MOD 2:x=INT(largeur/2)+reste
        WHILE x MOD 4 <> 0
                x=x+1
        WEND
        larbloc=x
        incry=2
        if ScreenMode=0 then incrx=4 \
                               else if ScreenMode=1 then incrx=2 \
                                                             else incrx=1
        FOR i=0 TO hauteur*incry STEP incry
                x=0
                |INPUT,ImgName$+":D,&"+HEX$(larbloc)+","+DEC$(adrline,"########")+",&"+HEX$(adr)
                FOR j=adr TO adr+INT(largeur/2)
                        pencil=FirstInk+(PEEK(j) AND &F0)/16:gosub PLOT_STEP:'plot with step
                        pencil=FirstInk+(PEEK(j) AND &F):gosub PLOT_STEP:'plot with step
                NEXT j
                adrline=adrline+larbloc
        NEXT i
        RETURN

//** READ BITMAPFILEHEADER 16 COLORS **
BITMAPFILEHEADER_16:

        GOSUB cpc_inks_ordering
        x=FirstInk:'1er crayon/first pen in color palette
        FOR i=0 TO 15*4 STEP 4
                |INK,x,PEEK(adr+&38+i),PEEK(adr+&37+i),PEEK(adr+&36+i):x=x+1
        NEXT
        GOTO DISPLAY16

//** BITMAPCOREHEADER 256 COULEURS/COLORS **
BITMAPCOREHEADER_256:

        x=0
        FOR i=0 TO 255*3 STEP 3
                |INK,x,PEEK(adr+&1C+i),PEEK(adr+&1B+i),PEEK(adr+&1A+i):x=x+1
        NEXT
        GOTO DISPLAY256

//** BITMAPFILEHEADER **
READ_BITMAPFILEHEADER:

        hauteur=PEEK(adr+&16)+256*PEEK(adr+&17)

        IF PEEK(adr+&E)+256*PEEK(adr+&F)<>40 THEN MODE 2:PRINT"Bitmap header error":END
        IF PEEK(adr+&1E)+256*PEEK(adr+&1F)<>0 THEN MODE 2:PRINT"Uncompressed bitmap only accepted":END
        IF PEEK(adr+&1C)+256*PEEK(adr+&1D)=4 THEN BITMAPFILEHEADER_16

        IF PEEK(adr+&1C)+256*PEEK(adr+&1D)<>8 THEN MODE 2:PRINT"256 or 16 colors only accepted":END

//** BITMAPFILEHEADER 256 COLORS **
        GOSUB cpc_inks_ordering
        x=0
        FOR i=0 TO 255*4 STEP 4
                |INK,x,PEEK(adr+&38+i),PEEK(adr+&37+i),PEEK(adr+&36+i):x=x+1
        NEXT

DISPLAY256:

        IF largeur MOD 4<>0 THEN larbloc=largeur+(4-(largeur MOD 4)) ELSE larbloc=largeur
        incry=2:incrx=2:' (MODE 1)
        FOR i=0 TO hauteur*incry STEP incry
                x=0
                |INPUT,ImgName$+":D,&"+HEX$(larbloc)+","+DEC$(adrline,"########")+",&"+HEX$(adr)
                        FOR j=adr TO adr+largeur-1
                                pencil=PEEK(j):gosub PLOT_STEP:'plot with step
                        NEXT j
                adrline=adrline+larbloc
        NEXT i
        RETURN


//** PLOT WITH STEP **
if BackGround<>-1 then transparent background
PLOT_STEP:

        if BackGround=-1 or pencil-FirstInk<>BackGround THEN PLOT ximg+x,yimg+i,pencil
        x=x+incrx
        RETURN


//** cpc inks ordering **
cpc_inks_ordering:

        FOR i=0 TO 15
                INK i,i
        NEXT
        RETURN


FileInputEr:

        mode 2
        if er%=1 then ? "|INPUT:"+ImgName$+" parameters error":end
        if er%=2 then ? ImgName$+" not found":end
        ? "|INPUT:"+ImgName$+" error":end