' Please have your graphics mode set to 24- or 32-bit color in order
' for the palette fading routines to work in AFlib III, as it will not
' work in any other color depth whatsoever.  Thanks so much!!!  ;)
'
'                                              - Adigun Azikiwe Polack


#include "AFlib3_Sprite.bi"
#include "AFlib3_Font.bi"
#include "AFlib3_Palette.bi"
#include "AFlib3_Primitives.bi"
#include "AFlib3_Screen.bi"
#include "AFlib3_Miscellaneous.bi"
#include "AFlib3_Constants.bi"
#include "AFlib3_GraphicsFilter.bi"
#include "AFlib3_Resize2X.bi"



const Scr_horiz = 640
const Scr_vert = 480

ScreenRes Scr_horiz, Scr_vert, 24, 2, 0
WindowTitle "AFlib III -- Amstrad CPC Palette Fade-in/Fade-out Test"
SetMouse , , 0


Declare Sub CPC_PaletteFadeIn (x as integer, y as integer, image as any ptr, _
                               resize_gfx as integer, LowRes_type as integer)
Declare Sub CPC_PaletteFadeOut (x as integer, y as integer, image as any ptr, _
                                resize_gfx as integer, LowRes_type as integer)

Declare Sub PressKey_Notice (End_or_Not as integer = 0)

Dim Shared as Integer PalColList_X, PalColList_Y, PalPos_X, PalPos_Y, Pal_Size, FadeCTRL
Dim As Any Ptr Scr_ColChanger
Dim Shared as Integer PicSetupNum

Dim CPCTestIma_1 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_2 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_3 As Any Ptr = ImageCreate(640, 200)
Dim CPCTestIma_4 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_5 As Any Ptr = ImageCreate(156, 208)
Dim CPCTestIma_6 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_7 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_8 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_9 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_10 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_11 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_12 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_13 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_14 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_15 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_16 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_17 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_18 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_19 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_20 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_21 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_22 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_23 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_24 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_25 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_26 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_27 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_28 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_29 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_30 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_31 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_32 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_33 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_34 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_35 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_36 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_37 As Any Ptr = ImageCreate(320, 200)
Dim CPCTestIma_38 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_39 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_40 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_41 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_42 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_43 As Any Ptr = ImageCreate(160, 200)
Dim CPCTestIma_44 As Any Ptr = ImageCreate(160, 200)

BLoad "AF3_PaletteCPC_1.bmp", CPCTestIma_1
BLoad "AF3_PaletteCPC_2.bmp", CPCTestIma_2
BLoad "AF3_PaletteCPC_3.bmp", CPCTestIma_3
BLoad "AF3_PaletteCPC_4.bmp", CPCTestIma_4
BLoad "AF3_PaletteCPC_5.bmp", CPCTestIma_5
BLoad "AF3_PaletteCPC_6.bmp", CPCTestIma_6
BLoad "AF3_PaletteCPC_7.bmp", CPCTestIma_7
BLoad "AF3_PaletteCPC_8.bmp", CPCTestIma_8
BLoad "AF3_PaletteCPC_9.bmp", CPCTestIma_9
BLoad "AF3_PaletteCPC_10.bmp", CPCTestIma_10
BLoad "AF3_PaletteCPC_11.bmp", CPCTestIma_11
BLoad "AF3_PaletteCPC_12.bmp", CPCTestIma_12
BLoad "AF3_PaletteCPC_13.bmp", CPCTestIma_13
BLoad "AF3_PaletteCPC_14.bmp", CPCTestIma_14
BLoad "AF3_PaletteCPC_15.bmp", CPCTestIma_15
BLoad "AF3_PaletteCPC_16.bmp", CPCTestIma_16
BLoad "AF3_PaletteCPC_17.bmp", CPCTestIma_17
BLoad "AF3_PaletteCPC_18.bmp", CPCTestIma_18
BLoad "AF3_PaletteCPC_19.bmp", CPCTestIma_19
BLoad "AF3_PaletteCPC_20.bmp", CPCTestIma_20
BLoad "AF3_PaletteCPC_21.bmp", CPCTestIma_21
BLoad "AF3_PaletteCPC_22.bmp", CPCTestIma_22
BLoad "AF3_PaletteCPC_23.bmp", CPCTestIma_23
BLoad "AF3_PaletteCPC_24.bmp", CPCTestIma_24
BLoad "AF3_PaletteCPC_25.bmp", CPCTestIma_25
BLoad "AF3_PaletteCPC_26.bmp", CPCTestIma_26
BLoad "AF3_PaletteCPC_27.bmp", CPCTestIma_27
BLoad "AF3_PaletteCPC_28.bmp", CPCTestIma_28
BLoad "AF3_PaletteCPC_29.bmp", CPCTestIma_29
BLoad "AF3_PaletteCPC_30.bmp", CPCTestIma_30
BLoad "AF3_PaletteCPC_31.bmp", CPCTestIma_31
BLoad "AF3_PaletteCPC_32.bmp", CPCTestIma_32
BLoad "AF3_PaletteCPC_33.bmp", CPCTestIma_33
BLoad "AF3_PaletteCPC_34.bmp", CPCTestIma_34
BLoad "AF3_PaletteCPC_35.bmp", CPCTestIma_35
BLoad "AF3_PaletteCPC_36.bmp", CPCTestIma_36
BLoad "AF3_PaletteCPC_37.bmp", CPCTestIma_37
BLoad "AF3_PaletteCPC_38.bmp", CPCTestIma_38
BLoad "AF3_PaletteCPC_39.bmp", CPCTestIma_39
BLoad "AF3_PaletteCPC_40.bmp", CPCTestIma_40
BLoad "AF3_PaletteCPC_41.bmp", CPCTestIma_41
BLoad "AF3_PaletteCPC_42.bmp", CPCTestIma_42
BLoad "AF3_PaletteCPC_43.bmp", CPCTestIma_43
BLoad "AF3_PaletteCPC_44.bmp", CPCTestIma_44

ScreenSet 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_1, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_1, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_2, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_2, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_3, 0, 1
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_3, 0, 1

CPC_PaletteFadeIn 0, 19, CPCTestIma_4, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_4, 1, 2

CPC_PaletteFadeIn 2, 15, CPCTestIma_5, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 2, 15, CPCTestIma_5, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_6, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_6, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_7, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_7, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_8, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_8, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_9, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_9, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_10, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_10, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_11, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_11, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_12, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_12, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_13, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_13, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_14, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_14, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_15, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_15, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_16, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_16, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_17, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_17, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_18, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_18, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_19, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_19, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_20, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_20, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_21, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_21, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_22, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_22, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_23, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_23, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_24, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_24, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_25, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_25, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_26, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_26, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_27, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_27, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_28, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_28, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_29, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_29, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_30, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_30, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_31, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_31, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_32, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_32, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_33, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_33, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_34, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_34, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_35, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_35, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_36, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_36, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_37, 1, 0
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_37, 1, 0

CPC_PaletteFadeIn 0, 19, CPCTestIma_38, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_38, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_39, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_39, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_40, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_40, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_41, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_41, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_42, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_42, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_43, 1, 2
PressKey_Notice
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_43, 1, 2

CPC_PaletteFadeIn 0, 19, CPCTestIma_44, 1, 2
PressKey_Notice 1
Sleep
CPC_PaletteFadeOut 0, 19, CPCTestIma_44, 1, 2

ImageDestroy CPCTestIma_1
ImageDestroy CPCTestIma_2
ImageDestroy CPCTestIma_3
ImageDestroy CPCTestIma_4
ImageDestroy CPCTestIma_5
ImageDestroy CPCTestIma_6
ImageDestroy CPCTestIma_7
ImageDestroy CPCTestIma_8
ImageDestroy CPCTestIma_9
ImageDestroy CPCTestIma_10
ImageDestroy CPCTestIma_11
ImageDestroy CPCTestIma_12
ImageDestroy CPCTestIma_13
ImageDestroy CPCTestIma_14
ImageDestroy CPCTestIma_15
ImageDestroy CPCTestIma_16
ImageDestroy CPCTestIma_17
ImageDestroy CPCTestIma_18
ImageDestroy CPCTestIma_19
ImageDestroy CPCTestIma_20
ImageDestroy CPCTestIma_21
ImageDestroy CPCTestIma_22
ImageDestroy CPCTestIma_23
ImageDestroy CPCTestIma_24
ImageDestroy CPCTestIma_25
ImageDestroy CPCTestIma_26
ImageDestroy CPCTestIma_27
ImageDestroy CPCTestIma_28
ImageDestroy CPCTestIma_29
ImageDestroy CPCTestIma_30
ImageDestroy CPCTestIma_31
ImageDestroy CPCTestIma_32
ImageDestroy CPCTestIma_33
ImageDestroy CPCTestIma_34
ImageDestroy CPCTestIma_35
ImageDestroy CPCTestIma_36
ImageDestroy CPCTestIma_37
ImageDestroy CPCTestIma_38
ImageDestroy CPCTestIma_39
ImageDestroy CPCTestIma_40
ImageDestroy CPCTestIma_41
ImageDestroy CPCTestIma_42
ImageDestroy CPCTestIma_43
ImageDestroy CPCTestIma_44

AFlibIII_EndProgram



Sub CPC_PaletteFadeIn (x as integer, y as integer, image as any ptr, _
                       resize_gfx as integer, LowRes_type as integer)
  For FadeCTRL = -8 to 0 step 1
    AFlibIII_ClearDisplay RGB(1, 1, 1)
    
    AFlibIII_SprBlit x, y, image   
    
    If resize_gfx >= 1 then AFlibIII_Resize2X_640x480
    Select Case LowRes_type
      Case 1: AFlibIII_LowRes_vert
      Case 2: AFlibIII_LowRes_horiz
    End Select
    
    AFlibIII_FadeCPC , FadeCTRL
    AFlibIII_Scanlines_H 
    
    AFlibIII_DisplayPal_CPC 7, 7, 10  '<---- Displays the Amstrad CPC 27-color Palette.
    
    'AFlibIII_MakeMonochrome 
    ScreenCopy 1, 0
    AFlibIII_CustomSync fps5
  Next
  AFlibIII_ClearKeyBuffer
End Sub

Sub CPC_PaletteFadeOut (x as integer, y as integer, image as any ptr, _
                        resize_gfx as integer, LowRes_type as integer)
  For FadeCTRL = 0 to -8 step -1
    AFlibIII_ClearDisplay RGB(1, 1, 1)
    
    AFlibIII_SprBlit x, y, image   
    
    If resize_gfx >= 1 then AFlibIII_Resize2X_640x480
    Select Case LowRes_type
      Case 1: AFlibIII_LowRes_vert
      Case 2: AFlibIII_LowRes_horiz
    End Select
    
    AFlibIII_FadeCPC , FadeCTRL
    AFlibIII_Scanlines_H 

    AFlibIII_DisplayPal_CPC 7, 7, 10  '<---- Displays the Amstrad CPC 27-color Palette.

    'AFlibIII_MakeMonochrome 
    ScreenCopy 1, 0
    AFlibIII_CustomSync fps5
  Next
  AFlibIII_ClearKeyBuffer
End Sub

Sub PressKey_Notice (End_or_Not as integer = 0)
  Dim SetMessage as String
  If End_or_Not <> 0 then
    SetMessage = "Press any key to end."
  else
    SetMessage = "Press any key, please."
  End if
  
  AFlibIII_Print SetMessage, 1, 464, 1, 1, CPCcol(13), 0, 2, 7
  AFlibIII_Print SetMessage, 1, 465, 1, 1, CPCcol(13), 0, 2, 7
  AFlibIII_Print SetMessage, 0, 465, 1, 1, CPCcol(13), 0, 2, 7
  AFlibIII_Print SetMessage, 0, 464, 1, 1, CPCcol(26), 0, 2, 7
  ScreenCopy 1,0
End Sub



