diff --git a/FrenchFest.sln b/FrenchFest.sln new file mode 100644 index 0000000..2e02dbc --- /dev/null +++ b/FrenchFest.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextSlides", "TextSlides\TextSlides.vcxproj", "{A119D358-6E9D-4BDA-B5D8-1659DA9BF571}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\HelloWorld.vcxproj", "{B7CAA483-C7F2-4927-AE75-89BF588AF970}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PerfTest", "PerfTest\PerfTest.vcxproj", "{EC61A5AA-7BC1-418F-9B7E-F2100F30714B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A119D358-6E9D-4BDA-B5D8-1659DA9BF571}.Debug|Win32.ActiveCfg = Debug|Win32 + {A119D358-6E9D-4BDA-B5D8-1659DA9BF571}.Debug|Win32.Build.0 = Debug|Win32 + {A119D358-6E9D-4BDA-B5D8-1659DA9BF571}.Release|Win32.ActiveCfg = Release|Win32 + {A119D358-6E9D-4BDA-B5D8-1659DA9BF571}.Release|Win32.Build.0 = Release|Win32 + {B7CAA483-C7F2-4927-AE75-89BF588AF970}.Debug|Win32.ActiveCfg = Debug|Win32 + {B7CAA483-C7F2-4927-AE75-89BF588AF970}.Debug|Win32.Build.0 = Debug|Win32 + {B7CAA483-C7F2-4927-AE75-89BF588AF970}.Release|Win32.ActiveCfg = Release|Win32 + {B7CAA483-C7F2-4927-AE75-89BF588AF970}.Release|Win32.Build.0 = Release|Win32 + {EC61A5AA-7BC1-418F-9B7E-F2100F30714B}.Debug|Win32.ActiveCfg = Debug|Win32 + {EC61A5AA-7BC1-418F-9B7E-F2100F30714B}.Debug|Win32.Build.0 = Debug|Win32 + {EC61A5AA-7BC1-418F-9B7E-F2100F30714B}.Release|Win32.ActiveCfg = Release|Win32 + {EC61A5AA-7BC1-418F-9B7E-F2100F30714B}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/HelloWorld/HelloWorld.c b/HelloWorld/HelloWorld.c new file mode 100644 index 0000000..58a1530 --- /dev/null +++ b/HelloWorld/HelloWorld.c @@ -0,0 +1,6 @@ +#include + +void main(void) +{ + printf("Hello World\n"); +} diff --git a/HelloWorld/HelloWorld.vcxproj b/HelloWorld/HelloWorld.vcxproj new file mode 100644 index 0000000..e14a996 --- /dev/null +++ b/HelloWorld/HelloWorld.vcxproj @@ -0,0 +1,85 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {B7CAA483-C7F2-4927-AE75-89BF588AF970} + MakeFileProj + SAK + SAK + SAK + SAK + + + + Makefile + true + v140 + + + Makefile + false + v140 + + + + + + + + + + + + + $(PRG) + + + $(PATH); + $(CC65ROOT)\include; + + $(CC65ROOT)lib; + + + + nmake.exe + nmake.exe all + nmake.exe clean + D:\CC65\include;C:\Users\Olivier\SkyDrive\Apple\CC65\include; + + + $(PRG) + + + $(PATH); + $(CC65ROOT)\include; + + $(CC65ROOT)lib; + + + + D:\CC65\include;C:\Users\Olivier\SkyDrive\Apple\CC65\include; + nmake.exe + nmake.exe all + nmake.exe clean + + + + + + + + + + + + + \ No newline at end of file diff --git a/HelloWorld/MAKEFILE b/HelloWorld/MAKEFILE new file mode 100644 index 0000000..bb0ffd7 --- /dev/null +++ b/HelloWorld/MAKEFILE @@ -0,0 +1,61 @@ +PRG=HelloWorld +SYSTEM=apple2enh +#L'ordinateur Maison s'appelle M... +!if "$(COMPUTERNAME)" == "M" +# That's the location where I have programs such as AppleWin, or a DOS blank disk image +MyAppleFolder="C:\Users\Olivier\OneDrive\Apple" +!else +#Environnement au bureau... +MyAppleFolder=D: +!endif + +# Misc. vars +# https://github.com/AppleWin/AppleWin +APPLEWIN=$(MyAppleFolder)\AppleWin\Applewin.exe +# http://applecommander.sourceforge.net/ +APPLECOMMANDER=$(MyAppleFolder)\AppleCommander-1.3.5-ac.jar +ACJAR=java.exe -jar $(APPLECOMMANDER) +CC65ROOT=$(MyDrive)\cc65 +CC65=$(CC65ROOT)\bin\CC65.exe +CL65=$(CC65ROOT)\bin\CL65.exe + + +$(PRG): $(PRG).c + @Echo *************************************************************** + @Echo *** On compile l'exécutable + @Echo *************************************************************** +# Quand je compilais avec les chaines de caractere dans text.s, j'utilisais la ligne suivante +# $(CL65) --verbose -O -t $(SYSTEM) $(PRG).c text.s + $(CL65) --verbose -O -t $(SYSTEM) $(PRG).c + +GetFloppyAndCopyDSK: + @Echo *************************************************************** + @Echo *** On copie la disquette vierge à partir du répertoire parent + @Echo *** et on copie dessus les fichiers executables et autres + @Echo *************************************************************** + copy /Y $(MyAppleFolder)\prodos.dsk .\$(PRG).dsk + $(ACJAR) -cc65 $(PRG).dsk $(PRG) bin < $(PRG) + +SaveAssemblyFile: +# To get the non-optimized assembly source file and keep it (in the .backup file) + @Echo *************************************************************** + @Echo *** On génère le fichier source en assembleur, pour référence + @Echo *************************************************************** + $(CC65) -v -t $(SYSTEM) $(PRG).c text.s + copy /Y $(PRG).s $(PRG).s.bak + +LaunchAppleWin: + @Echo *************************************************************** + @Echo *** On lance le tout dans AppleWin + @Echo *************************************************************** + $(APPLEWIN) -d1 $(PRG).dsk + +clean: + @Echo *************************************************************** + @Echo *** On efface les fichiers programme, objet et backup + @Echo *************************************************************** + del $(PRG) *.o *.bak + +all: clean SaveAssemblyFile $(PRG) GetFloppyAndCopyDSK LaunchAppleWin + + diff --git a/PerfTest/MAKEFILE b/PerfTest/MAKEFILE new file mode 100644 index 0000000..5794be3 --- /dev/null +++ b/PerfTest/MAKEFILE @@ -0,0 +1,60 @@ +PRG=PerfCC65 +SYSTEM=apple2enh +#L'ordinateur Maison s'appelle M... +!if "$(COMPUTERNAME)" == "M" +# That's the location where I have programs such as AppleWin, or a DOS blank disk image +MyAppleFolder="C:\Users\Olivier\OneDrive\Apple" +!else +#Environnement au bureau... +MyAppleFolder=D: +!endif + +# Misc. vars +# https://github.com/AppleWin/AppleWin +APPLEWIN=$(MyAppleFolder)\AppleWin\Applewin.exe +# http://applecommander.sourceforge.net/ +APPLECOMMANDER=$(MyAppleFolder)\AppleCommander-1.3.5-ac.jar +ACJAR=java.exe -jar $(APPLECOMMANDER) +CC65ROOT=$(MyDrive)\cc65 +CC65=$(CC65ROOT)\bin\CC65.exe +CL65=$(CC65ROOT)\bin\CL65.exe + +$(PRG): $(PRG).c +# La ligne suivante ne marche pas pour moi, a moins d'enlever -C apple2enh-system.cfg +# cl65 --verbose -O -t $(SYSTEM) -C $(SYSTEM)-system.cfg $(PRG).c + @Echo *************************************************************** + @Echo *** On compile l'exécutable + @Echo *************************************************************** + $(CL65) --verbose -O -t $(SYSTEM) $(PRG).c + +GetFloppyAndCopyDSK: + @Echo *************************************************************** + @Echo *** On copie la disquette vierge à partir du répertoire parent + @Echo *** et on copie dessus les fichiers executables et autres + @Echo *************************************************************** + copy /Y $(MyAppleFolder)\prodos.dsk .\$(PRG).dsk + $(ACJAR) -cc65 $(PRG).dsk $(PRG) bin < $(PRG) + +SaveAssemblyFile: +# To get the assembly source file and keep it (in the .backup file) + @Echo *************************************************************** + @Echo *** On génère le fichier source en assembleur, pour référence + @Echo *************************************************************** + $(CC65) -v -t $(SYSTEM) $(PRG).c + copy /Y $(PRG).s $(PRG).s.bak + +LaunchAppleWin: + @Echo *************************************************************** + @Echo *** On lance le tout dans AppleWin + @Echo *************************************************************** + $(APPLEWIN) -d1 $(PRG).dsk + +clean: + @Echo *************************************************************** + @Echo *** On efface les fichiers programme, objet et backup + @Echo *************************************************************** + del $(PRG) *.o *.s *.bak + +all: clean SaveAssemblyFile $(PRG) GetFloppyAndCopyDSK LaunchAppleWin + + diff --git a/PerfTest/PerfBasic.dsk b/PerfTest/PerfBasic.dsk new file mode 100644 index 0000000..110d2f5 Binary files /dev/null and b/PerfTest/PerfBasic.dsk differ diff --git a/PerfTest/PerfCC65.c b/PerfTest/PerfCC65.c new file mode 100644 index 0000000..90e4910 --- /dev/null +++ b/PerfTest/PerfCC65.c @@ -0,0 +1,54 @@ +/* + * "Performance" "comparison". BASIC and C versions on DSK to be launched at the same time... + */ + + + +#include +#include +#include +#include +// stdio.h est necessaire si appel a printf +// #include + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + +static const char Barres [] = "\\|/-"; + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + +int main (void) +{ + int i, j; + + /* Clear the screen, put cursor in upper left corner */ + clrscr (); + + /* Write the animated star in the mid of the screen */ + for (i = 0; i < 1000; i++) + { + // for (j = 0; j < iLen; j++) + for (j = 0; j < 4; j++) + { + // gotoxy(iMidX, iMidY); + gotoxy(20, 12); + cprintf("%c", Barres[j]); + } + } + // printf("C'est fini !"); + /* Clear the screen again */ + // clrscr (); + + /* Done */ + return EXIT_SUCCESS; +} + + + diff --git a/PerfTest/PerfTest.vcxproj b/PerfTest/PerfTest.vcxproj new file mode 100644 index 0000000..f247861 --- /dev/null +++ b/PerfTest/PerfTest.vcxproj @@ -0,0 +1,89 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {EC61A5AA-7BC1-418F-9B7E-F2100F30714B} + MakeFileProj + SAK + SAK + SAK + SAK + + + + Makefile + true + v140 + + + Makefile + false + v140 + + + + + + + + + + + + + $(PRG) + + + $(PATH); + $(CC65ROOT)\include; + + $(CC65ROOT)\lib; + + + + nmake.exe + nmake.exe all + nmake.exe clean + D:\CC65\include;C:\Users\Olivier\SkyDrive\Apple\CC65\include; + + + $(PRG) + + + $(PATH); + $(CC65ROOT)\include; + + $(CC65ROOT)\lib; + + + + nmake.exe + nmake.exe all + nmake.exe clean + D:\CC65\include;C:\Users\Olivier\SkyDrive\Apple\CC65\include; + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PerfTest/perfbas.bas b/PerfTest/perfbas.bas new file mode 100644 index 0000000..20be409 --- /dev/null +++ b/PerfTest/perfbas.bas @@ -0,0 +1,2 @@ +01 REM TRANSFERED TO FLOPPY WITH CIDERPRESS (ACTIONS MENU, IMPORT BAS FROM TEXT OPTION) +10 DATA "/", "-", "\", "|" 15 HOME 20 FOR I = 1 TO 1000 25 FOR J = 1 TO 4 30 HTAB 20 40 VTAB 12 50 READ C$ 60 PRINT C$ 70 NEXT J 80 RESTORE 90 NEXT I 95 END \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7d382c1 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# CC65 Build Solution +Visual Studio makefile solution to build Apple II projects with CC65. + +This is a boilerplate VS solution to jumpstart CC65 projects development. The most important file is MAKEFILE: this is where you set your paths to your local tools, e.g. AppleWin, prodos.dsk, Merlin32, AppleCommander, GSPort, etc... + +The solution includes 3 projects which were demo'ed at the 2015 [APPLE II FESTIVAL FRANCE (A2FF)](http://www.apple2festivalfrance.fr/). diff --git a/TextSlides/Diapos.txt b/TextSlides/Diapos.txt new file mode 100644 index 0000000..8c861b3 --- /dev/null +++ b/TextSlides/Diapos.txt @@ -0,0 +1,115 @@ +Atelier CC65 (Olivier Guinart) +Apple French Festival 2015 +AGENDA +11 +* Qu'est-ce que CC65 ? + +* Fonctionnalites + +* Developper aujourd'hui avec CC65 + +* Demo ! + +* Ressources + +* Remerciements +QU'EST-CE QUE CC65 ? +11 +* Ensemble d'outils (Windows, OS X, GNU/Linux, AmigaOS) : + + 1- Un compilateur C + + 2- Un assembleur + + 3- Des librairies de fonctions + + 4- Des librairies de cibles 6502 (Apple II, C64, Atari 2600, GEOS, ...) + + 5- De la documentation, des examples, une communaute +FONCTIONNALITES +11 +* Texte + +* Graphisme (http://www.appleoldies.ca/graphics/index.htm) + +* PEEK et POKE + +* Acces disquette (en-tete dio.h pour routines R/W de secteurs) + +* Pilotes joystick, souris, RS232 + +* Langage machine en ligne (e.g. asm("sta $c050"); /* GRAPHICS */) +EXEMPLE #1 +12 +#include + +void main(void) +{ + printf("Hello, world!\n"); +} + + +* La commande "cl65 hello.c" genere un fichier “hello.o” + et un executable C64 (defaut), “hello” + +* Pour la version Apple II, "cl65 -t apple2 hello.c" +EXEMPLE #2 +14 +#include +#include + +extern const char text[]; /* In text.s */ + +int main (void) +{ + printf ("%s\n", text); + return EXIT_SUCCESS; +} + +Text.s: + .export _text + _text: .asciiz "Hello world!" +Developper aujourd'hui avec CC65 +15 +* Visual Studio pour developper : + - dans un environnment moderne, + - avec Intellisense, + - dans le cloud, + - avec gestion de versions, + - en collaboratif, + - gratuit ! + +* MAKEFILE et NMake pour generer + +* Apple Commander pour transferer sous environnement Apple II + (option -cc65 pour le transfert du programme) + +* Emulateur AppleWin pour tester + (e.g. AppleWin.exe -d1 Prodos.dsk) +Demo ! +0 +Ressources +12 +* CC65 : http://cc65.github.io/cc65/ et http://www.cc65.org/index.php + +* Visual Studio : + https://www.visualstudio.com/downloads/download-visual-studio-vs + Express 2015 pour Windows Desktop ou Visual Studio Community 2015 + +* AppleCommander : http://applecommander.sourceforge.net/ + (requiert Java) + +* AppleWin : https://github.com/AppleWin/AppleWin + +* Me contacter : olivier_guinart@live.com +Remerciements +9 +* Ullrich von Bassewitz et Oliver Schmidt (CC65) + +* http://atarilynxdeveloper.wordpress.com (parametres Visual Studio) + +* Bill Buckels (Source de demo graphique) + +* Le Maska + +* Le comite organisateur :) \ No newline at end of file diff --git a/TextSlides/MAKEFILE b/TextSlides/MAKEFILE new file mode 100644 index 0000000..5ff85fc --- /dev/null +++ b/TextSlides/MAKEFILE @@ -0,0 +1,60 @@ +PRG=TextSlides +SYSTEM=apple2enh +#L'ordinateur Maison s'appelle M... +!if "$(COMPUTERNAME)" == "M" +# That's the location where I have programs such as AppleWin, or a DOS blank disk image +MyAppleFolder="C:\Users\Olivier\OneDrive\Apple" +!else +#Environnement au bureau... +MyAppleFolder=D: +!endif + +# Misc. vars +# https://github.com/AppleWin/AppleWin +APPLEWIN=$(MyAppleFolder)\AppleWin\Applewin.exe +# http://applecommander.sourceforge.net/ +APPLECOMMANDER=$(MyAppleFolder)\AppleCommander-1.3.5-ac.jar +ACJAR=java.exe -jar $(APPLECOMMANDER) +CC65ROOT=$(MyDrive)\cc65 +CC65=$(CC65ROOT)\bin\CC65.exe +CL65=$(CC65ROOT)\bin\CL65.exe + +$(PRG): $(PRG).c + @Echo *************************************************************** + @Echo *** On compile l'exécutable + @Echo *************************************************************** +# Quand je compilais avec les chaines de caractere dans text.s, j'utilisais la ligne suivante +# $(CL65) --verbose -O -t $(SYSTEM) $(PRG).c text.s + $(CL65) --verbose -O -t $(SYSTEM) $(PRG).c + +GetFloppyAndCopyDSK: + @Echo *************************************************************** + @Echo *** On copie la disquette vierge à partir du répertoire parent + @Echo *** et on copie dessus les fichiers executables et autres + @Echo *************************************************************** + copy /Y $(MyAppleFolder)\prodos.dsk .\$(PRG).dsk + $(ACJAR) -cc65 $(PRG).dsk $(PRG) bin < $(PRG) + $(ACJAR) -p $(PRG).dsk Diapos.txt text < Diapos.txt + +SaveAssemblyFile: +# To get the non-optimized assembly source file and keep it (in the .backup file) + @Echo *************************************************************** + @Echo *** On génère le fichier source en assembleur, pour référence + @Echo *************************************************************** + $(CC65) -v -t $(SYSTEM) $(PRG).c text.s + copy /Y $(PRG).s $(PRG).s.bak + +LaunchAppleWin: + @Echo *************************************************************** + @Echo *** On lance le tout dans AppleWin + @Echo *************************************************************** + $(APPLEWIN) -d1 $(PRG).dsk + +clean: + @Echo *************************************************************** + @Echo *** On efface les fichiers programme, objet et backup + @Echo *************************************************************** + del $(PRG) *.o *.bak + +all: clean SaveAssemblyFile $(PRG) GetFloppyAndCopyDSK LaunchAppleWin + diff --git a/TextSlides/TextSlides.c b/TextSlides/TextSlides.c new file mode 100644 index 0000000..6690231 --- /dev/null +++ b/TextSlides/TextSlides.c @@ -0,0 +1,407 @@ +/* ------------------------------------------------------------------------ +System : cc65 cross-development environment +Platform : Apple IIe +Program : TextSlides (C) Copyright Olivier Guinart 2015. + All rights reserved. + +Description : Apple //e ProDOS 8 Text-based Slideshow Program + +Written by : Olivier Guinart +Date Written : April 2015 +Revision : 1.0 First Release (CC65) +Date Revised : xxxxx + +Licence : You may use this program for whatever you wish as long + as you agree that Olivier Guinart has no warranty or + liability obligations whatsoever from said use. +------------------------------------------------------------------------ */ + +#ifndef __APPLE2__ +#define __APPLE2__ +#endif + +#include +#include +#include +#include +#include +#include "_file.h" + + +#define iMaxStrLen 256 +#define ELLIPSIS "...\0" // Used to truncate the slide title if it's longer than screen width + +unsigned char XSize, YSize; // Used to store screen size +int iSlidesPosition[iMaxStrLen]; // Used to store slides position within Diapos.txt for fseek purposes +char strTemp[iMaxStrLen]; // Temp string +int ch; // Temp char +int iPos; // Temp var that tracks the current line of the slides txt file +int iCurrentSlide; // Tracks the current slide being displayed + +/* 1MHZ timing loop settings - increase for faster machines */ +#define YTIME 60L +#define XTIME 2L +char wait(unsigned duration) +{ + char c = 0; + long y, x; + + while (duration > 0) { + for (y = 0; y < YTIME; y++) { + for (x = 0; x < XTIME; x++) { + if (kbhit()) { + c = cgetc(); + /* clear keyboard buffer */ + while (kbhit())cgetc(); + return c; + } + } + } + duration--; + } + return c; +} + +void sound(int duration, int pitch) +{ + char *speaker = (char*) 0xC030; + int i, j; + char c; + + for (i = 0; i < duration; i++) + { + c += *speaker; + for (j = 0; j < pitch; j++); + } +} + +/* fgets for Apple II text files - read native apple II text files properly! +the cc65 version doesn't! Which means that you need to use unix text files +unless you roll your own fgets... */ +/* Created in Windows, text file lines end with CRLF, chr(13) + chr(10) */ +char* __fastcall__ fgets(char* s, unsigned size, register FILE* f) +{ + register char* p = s; + unsigned i; + int c; + + if (size == 0) { + /* Invalid size */ + return (char*)_seterrno(EINVAL); + } + + /* Read input */ + i = 0; + c = fgetc(f); + while (c != EOF && ((char)c != (char)13)) { + //printf("'%i' ",c); + /* One char more */ + *p = c; + ++p; + ++i; + c = fgetc(f); + } + + if (c == EOF) { + // printf("DEBUG: in fgets with EOF%c",(char)13); + /* Error or EOF */ + if ((f->f_flags & _FERROR) != 0 || i == 0) { + /* ERROR or EOF on first char */ + // printf("DEBUG: in fgets returning %i%c",NULL,(char)13); + *p = '\0'; + return NULL; + } + } + /* On lit le charactere LF, on l'ignore */ + c = fgetc(f); + /* Terminate the string */ + *p = '\0'; + + /* Done */ + return s; +} + +//////////////////////////////////////////////////////////////////////////////////// +/// Repositions the file pointer to line iLine +/// iLine line number were the next read will happen +/// fp file from which to read the iBullets points +//////////////////////////////////////////////////////////////////////////////////// +int PositionFilePointer(int iLine, FILE *fp) +{ + int i; + + // If we are here, it means we need to close the file, re-open it and reposition the pointer to the line #iLine... + fclose(fp); + /* We test/open the files of slides */ + if ((fp = fopen("Diapos.txt", "r")) == NULL) + { + printf("Files 'Diapos.txt' couldn't be opened. Press a key to exit."); + cgetc(); + return EXIT_FAILURE; + } + for (i = 1; i < iLine; i++) + { + fgets(strTemp, iMaxStrLen, fp); + } + return EXIT_SUCCESS; +} + +/////////////////////////////////////////////////////////////////////////////// +/// Print slide frame +/////////////////////////////////////////////////////////////////////////////// +void SlideFrame() +{ + /* Set screen colors, hide the cursor */ + //textcolor(COLOR_WHITE); + //bordercolor(COLOR_BLACK); + //bgcolor(COLOR_BLACK); + //cursor(0); + + /* Clear the screen, put cursor in upper left corner */ + clrscr(); + + /* Draw a border around the screen */ + + /* Top line */ + cputc(CH_ULCORNER); + chline(XSize - 2); + cputc(CH_URCORNER); + + /* Vertical line, left side */ + cvlinexy(0, 1, YSize - 2); + + /* Bottom line */ + cputc(CH_LLCORNER); + chline(XSize - 2); + cputc(CH_LRCORNER); + + /* Vertical line, right side */ + cvlinexy(XSize - 1, 1, YSize - 2); +} + +/////////////////////////////////////////////////////////////////////////////// +/// Slide #0 with title and subtitle of the presentation +/// strTitles, 2 strings arrays for title and subtitle +/////////////////////////////////////////////////////////////////////////////// +void ShowOpeningSlide(char strTitles[2][iMaxStrLen]) +{ + int ilenTitle, ilenSubTitle, iMidX, iMidY; + + ilenTitle = strlen(strTitles[0]); + ilenSubTitle = strlen(strTitles[1]); + + // If Title and subtitle are empty, no need to even display an opening slides... + if ((ilenTitle + ilenSubTitle) > 0) + { + SlideFrame(); + + // printf("DEBUG: ilen '%i'%c", ilen, (char)13); + // printf("DEBUG: XSize '%i'%c", XSize, (char)13); + iMidX = XSize / 2; + iMidY = YSize / 2; + + // printf("DEBUG: iMidX '%i'%c", iMidX, (char)13); + // Printing first the frame of the title + /* Vertical line, left side (x, y, longueur) */ + // cvlinexy(iMidX - 2, 1, 1); + /* Ligne horizontale sous le texte */ + // chlinexy(iMidX - 1, 2, ilen + 2); + /* Vertical line, right side */ + // cvlinexy(iMidX + ilen + 1, 1, 1); + // Handling the title now, it will print from both right and left sides, animation effect... + gotoxy(iMidX - (ilenTitle / 2), iMidY - 4); // -4 to print a little bit above the middle + printf("%s", strTitles[0]); + gotoxy(iMidX - (ilenSubTitle / 2), iMidY); + printf("%s", strTitles[1]); + } +} + +/////////////////////////////////////////////////////////////////////////////// +/// Reads the slides file and call the ShowOpeningSlide procedure +/// strTitles, 2 strings arrays for title and subtitle +/// fp the slides text file +/////////////////////////////////////////////////////////////////////////////// +int OpenAndShowOpeningSlide(char strTitles[2][iMaxStrLen], FILE *fp) +{ + iPos = 0; // iPos will record the current line of the slides txt file + iCurrentSlide = 0; + PositionFilePointer(iPos, fp); + fgets(strTitles[0], iMaxStrLen, fp); + iPos++; + iSlidesPosition[iCurrentSlide] = iPos; // the opening slide is always on first (and second) line of the slides text file + fgets(strTitles[1], iMaxStrLen, fp); + iPos++; + ShowOpeningSlide(strTitles); + return cgetc(); +} + +/////////////////////////////////////////////////////////////////////////////// +/// Print slide titles, below top frame line, centered and boxed +/// strTitle, the title of the slide read in Main() loop +/////////////////////////////////////////////////////////////////////////////// +void SlideTitle(char strTitle[iMaxStrLen]) +{ + int i, j, ilen, iMidX; + int iMargin = 5; + register char* p; + + ilen = strlen(strTitle); + // printf("DEBUG: ilen '%i'%c", ilen, (char)13); + // printf("DEBUG: XSize '%i'%c", XSize, (char)13); + // We need to test if the title is longer than the screen width + some buffer = 5 + // If yes, we truncate with ellipsis... + if (ilen >= (XSize - iMargin)) + { + p = strTitle + XSize - iMargin - strlen(ELLIPSIS); + memcpy(p, ELLIPSIS, strlen(ELLIPSIS)); + ilen = strlen(strTitle); + } + iMidX = (XSize - ilen) / 2; + // printf("DEBUG: iMidX '%i'%c", iMidX, (char)13); + // printf("DEBUG: ilen = %i%c",ilen,(char)13); + // Printing first the frame of the title + /* Vertical line, left side (x, y, longueur) */ + cvlinexy(iMidX - 2, 1, 1); + /* Ligne horizontale sous le texte */ + chlinexy(iMidX - 1 , 2, ilen + 2); + /* Vertical line, right side */ + cvlinexy(iMidX + ilen + 1, 1, 1); + // Handling the title now, it will print from both right and left sides, animation effect... + i = 0; + j = ilen - 1; // zero-index string array... + while (i <= j) { + gotoxy(iMidX + i, 1); + printf("%c", strTitle[i]); + gotoxy(iMidX + j, 1); + printf("%c", strTitle[j]); + sound(5, 30); + wait(1); + i++; + j--; + } +} + +///////////////////////////////////////////////////////////////////////////////////// +/// Reads bullets from text files and prints them on screen, with margins x = 5, start y = 7 +/// iBullets number of bullets/points of the slide +/// fp file from which to read the iBullets points +///////////////////////////////////////////////////////////////////////////////////// +void SlideBullets(int iBullets, FILE *fp) +{ + const int iHmarge = 5; + const int iVmarge = 5; + int i; + + for (i = 0; i < iBullets; i++) { + gotoxy(iHmarge, iVmarge + i); + fgets(strTemp, iMaxStrLen, fp); + printf("%s", strTemp); + } +} + +//////////////////////////////////////////////////////////////////////////////////// +/// Draws the whole slide +/// strTitle, the title of the slide read in Main() loop +/// iBullets number of bullets/points of the slide +/// fp file from which to read the iBullets points +//////////////////////////////////////////////////////////////////////////////////// +void TitleAndContentSlide(char strTitle[iMaxStrLen], int iBullets, FILE *fp) +{ + // We draw the frame of the slide + SlideFrame(); + // We print the slide title + SlideTitle(strTitle); + // We load and print iBullets bullets from text file fp + SlideBullets(iBullets, fp); +} + +//////////////////////////////////////////////////////////////////////////////////// +/// Main :) +//////////////////////////////////////////////////////////////////////////////////// +int main(void) +{ + char strTitles[2][iMaxStrLen]; + char strSlideTitle[iMaxStrLen]; + int iBullets; + FILE *fp; + + /* We test/open the files of slides */ + if ((fp = fopen("Diapos.txt", "r")) == NULL) { + printf("Files 'Diapos.txt' couldn't be opened. Press a key to exit."); + cgetc(); + return EXIT_FAILURE; + } + + videomode(VIDEOMODE_80COL); + + /* Ask for the screen size */ + screensize(&XSize, &YSize); + + // Slides are read from file + // File structure: + // 1st line = Presentation title (to be printed in Opening Slide) + // 2nd line = Presentation subtitle (to be printed in Opening Slide) + // 3rd line = Title of the first slide + // 4th line = n number of bullets for that slide + // n following lines = bullets of the slide + // Repeat with 3rd, 4th and n lines structure for next slides + + ch = OpenAndShowOpeningSlide(strTitles, fp); + + // First slide, First line = title... + while (fgets(strSlideTitle, iMaxStrLen, fp) != NULL) { + // We record the slide position in the slides text file + iCurrentSlide++; + iPos++; // +1 because of the title + // printf("DEBUG: iCurrentSlide='%i' iPos='%i'%c", iCurrentSlide, iPos, (char)13); + // cgetc(); + iSlidesPosition[iCurrentSlide] = iPos; // We save the line position of the slide title + // Second line = Number of bullets in current slide... + fgets(strTemp, iMaxStrLen, fp); + iPos++; // +1 because of the count of bullets + // printf("DEBUG: strTemp '%s'%c", strTemp, (char)13); + iBullets = atoi(strTemp); + iPos+=iBullets; // And adding the bullets themselves + TitleAndContentSlide(strSlideTitle, iBullets, fp); + // We pause before going to next slide + ch = cgetc(); + if (ch == CH_ESC) // If escape key pressed, exit loop + { + break; + } + if (ch == CH_CURS_LEFT) // Back to previous slide with left arrow letter (for now) + { + iCurrentSlide--; + if (iCurrentSlide > 0) + { + iPos = iSlidesPosition[iCurrentSlide]; + PositionFilePointer(iPos, fp); + // When we entered the loop the first time, we weren't yet on the line, now we are, so + // to avoid counting it twice, we decrease it here by one... + iPos--; + // And same for the slide #... + iCurrentSlide--; + } + else + { + // we are back to the opening slide + // and we keep looping if users keeps pressing left arrow + ch = OpenAndShowOpeningSlide(strTitles, fp); + while (ch == CH_CURS_LEFT) + { + ch = cgetc(); + }; + // but we exit loop if ESC + if (ch == CH_ESC) + { + break; + } + } + } + } + + // Close the file + fclose(fp); + clrscr(); + return EXIT_SUCCESS; +} diff --git a/TextSlides/TextSlides.vcxproj b/TextSlides/TextSlides.vcxproj new file mode 100644 index 0000000..812ce07 --- /dev/null +++ b/TextSlides/TextSlides.vcxproj @@ -0,0 +1,90 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {A119D358-6E9D-4BDA-B5D8-1659DA9BF571} + MakeFileProj + SAK + SAK + SAK + SAK + + + + Makefile + true + v140 + + + Makefile + false + v140 + + + + + + + + + + + + + $(PRG) + + + $(PATH); + $(CC65ROOT)\include; + + $(CC65ROOT)\lib; + + + + nmake.exe + nmake.exe all + nmake.exe clean + D:\CC65\include;C:\Users\Olivier\SkyDrive\Apple\CC65\include; + + + $(PRG) + + + $(PATH); + $(CC65ROOT)\include; + + $(CC65ROOT)\lib; + + + + nmake.exe + nmake.exe all + nmake.exe clean + D:\CC65\include;C:\Users\Olivier\SkyDrive\Apple\CC65\include; + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TextSlides/_file.h b/TextSlides/_file.h new file mode 100644 index 0000000..8479b58 --- /dev/null +++ b/TextSlides/_file.h @@ -0,0 +1,51 @@ +/* + * _file.h + * + * (C) Copyright 1998, 2002 Ullrich von Bassewitz (uz@cc65.org) + * + */ + + + +#ifndef __FILE_H +#define __FILE_H + + + +#include + + + +/* Definition of struct _FILE */ +struct _FILE { + char f_fd; + char f_flags; + unsigned char f_pushback; +}; + +/* File table. Beware: FOPEN_MAX is hardcoded in the ASM files! */ +extern FILE _filetab[FOPEN_MAX]; + +/* Flags field */ +#define _FCLOSED 0x00 +#define _FOPEN 0x01 +#define _FEOF 0x02 +#define _FERROR 0x04 +#define _FPUSHBACK 0x08 + + + +FILE* __fastcall__ _fopen (const char* name, const char* mode, FILE* f); +/* Open the specified file and fill the descriptor values into f */ + +FILE* _fdesc (void); +/* Find a free FILE descriptor */ + + + +/* End of _file.h */ +#endif + + + +