Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example projects #43

Merged
merged 7 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 2 additions & 4 deletions compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ Rem pause
Rem copy over .exe's from CEdev release - CEdev GitHub actions pull each .exe's repo and build, but we shouldn't need to do that.
robocopy "%BASEDIR%\CEdev_zip\bin" "%CEDEV_PLUS_AGDEV%\CEdev\bin" /e

Rem copy over AgDev example folders
robocopy "%AGDEV_GIT%\AgExamples" "%CEDEV_PLUS_AGDEV%\CEdev\AgExamples" /e
robocopy "%AGDEV_GIT%\sprite-demos" "%CEDEV_PLUS_AGDEV%\CEdev\sprite-demos" /e
robocopy "%AGDEV_GIT%\tests" "%CEDEV_PLUS_AGDEV%\CEdev\tests" /e
Rem copy over AgDev example folder
robocopy "%AGDEV_GIT%\examples" "%CEDEV_PLUS_AGDEV%\CEdev\examples" /e

Rem copy resulting build to base directory
if exist "%ORIGDIR%\AgDev_build" rmdir /s /q "%ORIGDIR%\AgDev_build"
Expand Down
10 changes: 3 additions & 7 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,9 @@ make install V=1 DESTDIR=$CEDEV_PLUS_AGDEV/ --debug=j,m
mkdir $CEDEV_PLUS_AGDEV/CEdev/bin/
cp -r $BASEDIR/CEdev_zip/bin/. $CEDEV_PLUS_AGDEV/CEdev/bin/
#
# copy over AgDev example folders
mkdir $CEDEV_PLUS_AGDEV/CEdev/AgExamples/
cp -r $AGDEV_GIT/AgExamples/* $CEDEV_PLUS_AGDEV/CEdev/AgExamples/
mkdir $CEDEV_PLUS_AGDEV/CEdev/sprite-demos/
cp -r $AGDEV_GIT/sprite-demos/* $CEDEV_PLUS_AGDEV/CEdev/sprite-demos/
mkdir $CEDEV_PLUS_AGDEV/CEdev/tests/
cp -r $AGDEV_GIT/tests/* $CEDEV_PLUS_AGDEV/CEdev/tests/
# copy over AgDev example folder
mkdir $CEDEV_PLUS_AGDEV/CEdev/examples/
cp -r $AGDEV_GIT/examples/* $CEDEV_PLUS_AGDEV/CEdev/examples/
#
# copy resulting build to base directory
if [ -d $ORIGDIR/AgDev_build/ ]; then
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/args/makefile → examples/args/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ----------------------------

NAME = args
DESCRIPTION = "Ag C Toolchain Demo"
DESCRIPTION = "AgDev Arguments Demo"
COMPRESSED = NO
LDHAS_ARG_PROCESSING = 1

Expand Down
File renamed without changes.
60 changes: 30 additions & 30 deletions tests/args/src/args.c → examples/args/src/args.c
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
/*
* Title: args - argc and argv example
* Author: Paul Cawte
* Created: 22/06/2022
* Last Updated: 08/06/2023 - adapted from example by Dean Belfield
*
* Modinfo:
*/
#include <stdio.h>
// Parameters:
// - argc: Argument count
// - argv: Pointer to the argument string - zero terminated, parameters separated by spaces
//
int main(int argc, char * argv[])
{
printf("Args example:\n\r");
printf("Arguments:\n\r");
printf("- argc: %d\n\r", argc);
for(int i = 0; i < argc; i++)
{
printf("- argv[%d]: %s\n\r", i, argv[i]);
}
printf("Press any key to quit\n\r");
getchar();
return 0;
/*
* Title: args - argc and argv example
* Author: Paul Cawte
* Created: 22/06/2022
* Last Updated: 08/06/2023 - adapted from example by Dean Belfield
*
* Modinfo:
*/

#include <stdio.h>

// Parameters:
// - argc: Argument count
// - argv: Pointer to the argument string - zero terminated, parameters separated by spaces
//

int main(int argc, char * argv[])
{
printf("Args example:\n\r");

printf("Arguments:\n\r");
printf("- argc: %d\n\r", argc);

for(int i = 0; i < argc; i++)
{
printf("- argv[%d]: %s\n\r", i, argv[i]);
}
printf("Press any key to quit\n\r");
getchar();
return 0;
}
37 changes: 37 additions & 0 deletions examples/big-bitmap/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ----------------------------
# Makefile Options
# ----------------------------

NAME = big-bitmap
DESCRIPTION = "Big Bitmap Demo"
COMPRESSED = NO
LDHAS_ARG_PROCESSING = 0

BSSHEAP_LOW = 060000
BSSHEAP_HIGH = 09FFFF

CFLAGS = -Wall -Wextra -Oz
CXXFLAGS = -Wall -Wextra -Oz

IMAGES = $(call NATIVEPATH,$(SRCDIR)/img/*.rgba)
IMAGES_DEST = $(call NATIVEPATH,$(BINDIR)/img)

DEPS = $(IMAGES)

#Unsure why the copy of this in makefile.mk doesn't cover this already...
ifeq ($(OS),Windows_NT)
COPYDIR ?= ( xcopy $1 $2 /S /Q /Y /I /K 1>nul 2>nul || call )
else
COPYDIR ?= cp -r $1 $2
endif

# ----------------------------

include $(shell cedev-config --makefile)

#copy images to /bin
$(IMAGES):
$(Q)$(call NATIVEMKDR,$(IMAGES_DEST))
$(Q)$(call COPYDIR,$(IMAGES),$(IMAGES_DEST))


35 changes: 35 additions & 0 deletions examples/big-bitmap/src/big-bitmap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// VDU commands

#include <stdio.h>
#include <mos_api.h>
#include <stdbool.h>
#include <stdlib.h>
#include <agon/vdp_vdu.h>

int main( void )
{
volatile SYSVAR *sv = vdp_vdu_init();

int img_width;
int img_height;
char fname[41];
int screen_mode;

printf( "Enter file name for RGBA bitmap: " );
scanf( "%40s", fname );
printf( "Enter width and height: " );
scanf( "%d %d", &img_width, &img_height );
printf( "Enter screen mode to use: " );
scanf( "%d", &screen_mode );

vdp_select_bitmap( 1 );
printf( "Sending bitmap to VDP...\n");
if ( vdp_load_bitmap_file( fname, img_width, img_height ) ) {
printf( "Error loading bitmap. Quitting.\n" );
return 1;
}
vdp_mode( screen_mode );
vdp_logical_scr_dims( false );
vdp_clear_screen();
vdp_draw_bitmap( (sv->scrWidth)/2-(img_width/2), (sv->scrHeight)/2-(img_height)/2 );
}
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/complex/makefile → examples/complex/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ----------------------------

NAME = complex
DESCRIPTION = "Ag C Toolchain Demo"
DESCRIPTION = "Complex Numbers Demo"
COMPRESSED = NO

CFLAGS = -Wall -Wextra -Oz
Expand Down
File renamed without changes.
132 changes: 66 additions & 66 deletions tests/complex/src/complex.cpp → examples/complex/src/complex.cpp
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
/*
* Title: C++ complex number example
* Author: Paul Cawte
* Created: 30/06/2022
*
* Modinfo:
*/
#include <stdio.h>
class complex {
double re, im;
public:
complex( double r, double i ) { re=r; im=i; }
complex( double r ) { re=r; im=0.0; }
double real() { return re; }
double imag() { return im; }
friend complex operator+(complex, complex);
friend complex operator-(complex, complex); // subtraction
friend complex operator-(complex); // negation
friend complex operator*(complex, complex);
friend complex operator/(complex, complex);
};
int main()
{
printf( "Complex Number C++Test Program\r\n\r\n" );
complex a = 2.3;
complex b = 1/a;
complex c = a + (b*complex(1, 2.3));
printf( "Result = (%f, %fi)\r\n", c.real(), c.imag() );
return 0;
}
complex operator+( complex z1, complex z2 )
{
return complex( z1.re + z2.re, z1.im + z2.im );
}
complex operator-( complex z1, complex z2 )
{
return complex( z1.re - z2.re, z1.im - z2.im );
}
complex operator-( complex z )
{
return complex( -z.re, -z.im );
}
complex operator*( complex z1, complex z2 )
{
return complex( z1.re*z2.re - z1.im*z2.im, z1.re*z2.im + z1.im*z2.re );
}
complex operator/( complex z1, complex z2 )
{
double divisor = z2.re*z2.re + z2.im*z2.im;
return complex( ( z1.re*z2.re + z1.im*z2.im ) / divisor,
( z1.im*z2.re - z1.re*z2.im ) / divisor );
}
/*
* Title: C++ complex number example
* Author: Paul Cawte
* Created: 30/06/2022
*
* Modinfo:
*/

#include <stdio.h>

class complex {
double re, im;
public:
complex( double r, double i ) { re=r; im=i; }
complex( double r ) { re=r; im=0.0; }
double real() { return re; }
double imag() { return im; }

friend complex operator+(complex, complex);
friend complex operator-(complex, complex); // subtraction
friend complex operator-(complex); // negation
friend complex operator*(complex, complex);
friend complex operator/(complex, complex);
};

int main()
{
printf( "Complex Number C++Test Program\r\n\r\n" );

complex a = 2.3;
complex b = 1/a;
complex c = a + (b*complex(1, 2.3));

printf( "Result = (%f, %fi)\r\n", c.real(), c.imag() );

return 0;
}


complex operator+( complex z1, complex z2 )
{
return complex( z1.re + z2.re, z1.im + z2.im );
}

complex operator-( complex z1, complex z2 )
{
return complex( z1.re - z2.re, z1.im - z2.im );
}

complex operator-( complex z )
{
return complex( -z.re, -z.im );
}

complex operator*( complex z1, complex z2 )
{
return complex( z1.re*z2.re - z1.im*z2.im, z1.re*z2.im + z1.im*z2.re );
}

complex operator/( complex z1, complex z2 )
{
double divisor = z2.re*z2.re + z2.im*z2.im;
return complex( ( z1.re*z2.re + z1.im*z2.im ) / divisor,
( z1.im*z2.re - z1.re*z2.im ) / divisor );
}

File renamed without changes.
2 changes: 1 addition & 1 deletion tests/exit/makefile → examples/exit/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ----------------------------

NAME = exit
DESCRIPTION = "Ag C Toolchain Demo"
DESCRIPTION = "AgDev exit example"
COMPRESSED = NO
LDHAS_ARG_PROCESSING = 0
LDHAS_EXIT_HANDLER = 1
Expand Down
42 changes: 21 additions & 21 deletions tests/exit/src/exit.c → examples/exit/src/exit.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
* Title: exit example
* Author: Paul Cawte
* Created: 24/07/2023
* Last Updated: 24/07/2023
*
* Modinfo:
*/
#include <stdlib.h>
void f1( void );
int main( void )
{
f1();
return 0;
}
void f1( void ) {
exit( EXIT_ABORT );
/*
* Title: exit example
* Author: Paul Cawte
* Created: 24/07/2023
* Last Updated: 24/07/2023
*
* Modinfo:
*/

#include <stdlib.h>

void f1( void );

int main( void )
{
f1();
return 0;
}

void f1( void ) {
exit( -1 );
}
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/fdiv/makefile → examples/fdiv/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ----------------------------

NAME = fdiv
DESCRIPTION = "Ag C Toolchain Demo"
DESCRIPTION = "Float Division Demo"
COMPRESSED = NO

CFLAGS = -Wall -Wextra -Oz
Expand Down
File renamed without changes.
Loading