Skip to content

Commit e42aaeb

Browse files
Fix spacing and clean up examples to use more defines; user headers rebuild sources
1 parent b8709f0 commit e42aaeb

File tree

51 files changed

+1010
-1258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1010
-1258
lines changed

CEdev/bin/main_makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ $(OBJDIR)/%.obj : $(SRCDIR)/%.asm
229229
@$(AS) $(ASM_FLAGS) $(call WINPATH,$(addprefix $(CURDIR)/,$<))
230230

231231
#These rules compile the source files into object files
232-
$(OBJDIR)/%.obj : $(SRCDIR)/%.c
232+
$(OBJDIR)/%.obj : $(SRCDIR)/%.c $(USERHEADERS)
233233
@if not exist $(OBJDIR) mkdir $(OBJDIR)
234234
@$(CD) $(OBJDIR) && \
235235
@$(CC) $(CFLAGS) $(call WINPATH,$(addprefix $(CURDIR)/,$<))
236236

237-
$(OBJDIR)/%.obj : $(GFXDIR)/%.c
237+
$(OBJDIR)/%.obj : $(GFXDIR)/%.c $(USERHEADERS)
238238
@if not exist $(OBJDIR) mkdir $(OBJDIR)
239239
@$(CD) $(OBJDIR) && \
240240
@$(CC) $(CFLAGS) $(call WINPATH,$(addprefix $(CURDIR)/,$<))

CEdev/examples/demo_0/bin/DEMO0.8xp

-128 Bytes
Binary file not shown.

CEdev/examples/demo_0/src/main.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,27 @@
1111
#include <string.h>
1212

1313
/* Other available headers */
14-
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h
14+
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h, intce.h
1515

1616
/* Put function prototypes here */
1717
void printText(const char *text, uint8_t x, uint8_t y);
1818
void printTextSmall(const char *text, uint8_t xpos, uint8_t ypos);
1919

20-
/* Initialize some strings -- It is faster to place strings as globals */
21-
const char HelloWorld[] = "Hello World!";
22-
const char Welcome[] = "Welcome to C!";
23-
char Apples[] = "Apples!";
24-
char Oranges[] = "Oranges";
20+
/* Initialize some strings */
21+
const char *HelloWorld = "Hello World!";
22+
const char *Welcome = "Welcome to C!";
2523

2624
/* Put all your code here */
2725
void main(void) {
28-
/* uint8_t is an unsigned integer that can range from 0-255. It generally performs faster than just an int, so try to use it when possible */
26+
/* uint8_t is an unsigned integer that can range from 0-255. It performs faster than just an int, so try to use it (or int8_t) when possible */
2927
uint8_t count;
3028

3129
/* This function cleans up the screen and gets everything ready for the OS */
3230
prgm_CleanUp();
3331

3432
/* Print a few strings */
35-
printText(HelloWorld, 0, 0);
36-
printText(Welcome, 0, 1);
37-
38-
/* This will print 'Apples' */
39-
for(count=3; count<6; count++) {
40-
printText(Apples, 0, count);
41-
}
42-
43-
/* Copy the 'Oranges' string to the 'Apples' location */
44-
strcpy(Apples, Oranges);
45-
46-
/* This will print 'Oranges'. Therefore, apples are oranges */
47-
for(count=6; count<9; count++) {
48-
printText(Apples, 0, count);
49-
}
33+
printText( HelloWorld, 0, 0 );
34+
printText( Welcome, 0, 1 );
5035

5136
/* Wait for a key press */
5237
while( !os_GetCSC() );

CEdev/examples/demo_1/bin/DEMO1.8xp

-568 Bytes
Binary file not shown.

CEdev/examples/demo_1/src/main.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@
1111
#include <string.h>
1212

1313
/* Other available headers */
14-
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h
14+
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h, intce.h
1515

1616
/* Put function prototypes here */
1717
void fillScreen(uint8_t color);
1818

19-
/* Location of memory-mapped screen */
20-
uint16_t *lcd_vramArray = (uint16_t*)0xD40000;
21-
2219
/* Put all your code here */
2320
void main(void) {
2421
/* Turn the whole screen black */
@@ -40,5 +37,5 @@ void main(void) {
4037
/* Fill the screen with a given color */
4138
void fillScreen(uint8_t color) {
4239
/* memset_fast is a way faster implementation of memset; either one will work here though */
43-
memset_fast(lcd_vramArray, color, 320*240*2);
40+
memset_fast(lcd_Ram, color, LCD_SIZE);
4441
}

CEdev/examples/demo_2/src/main.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,31 @@
1111
#include <string.h>
1212

1313
/* Other available headers */
14-
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h
14+
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h, intce.h
1515

1616
/* Put function prototypes here */
1717

1818
/* Put all your code here */
1919
void main(void) {
20-
uint8_t i, bl_level_copy;
21-
22-
bl_level_copy = lcd_BacklightLevel;
23-
24-
for(i = bl_level_copy; i > 0; i--) {
25-
boot_WaitShort();
26-
lcd_BacklightLevel = i;
27-
}
28-
29-
for(i = 0; i < 255; i++) {
30-
boot_WaitShort();
31-
lcd_BacklightLevel = i;
32-
}
20+
uint8_t i, level;
21+
22+
/* Store the current brightness level */
23+
level = lcd_BacklightLevel;
24+
25+
/* Change lcd brightness levels */
26+
for(i = level; i > 0; i--) {
27+
boot_WaitShort();
28+
lcd_BacklightLevel = i;
29+
}
30+
31+
for(i = 0; i < 255; i++) {
32+
boot_WaitShort();
33+
lcd_BacklightLevel = i;
34+
}
3335

34-
lcd_BacklightLevel = bl_level_copy;
36+
/* Restore the old brightness level */
37+
lcd_BacklightLevel = level;
3538

36-
/* Clean up for the return to the OS */
37-
prgm_CleanUp();
39+
/* Clean up for the return to the OS */
40+
prgm_CleanUp();
3841
}

CEdev/examples/demo_3/src/main.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,42 @@
1111
#include <string.h>
1212

1313
/* Other available headers */
14-
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h
14+
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h, intce.h
1515

16-
#define ONE_SECOND 32768/1
17-
#define HALF_SECOND 32768/2
18-
#define QUARTER_SECOND 32768/4
16+
#define ONE_SECOND 32768/1
17+
#define HALF_SECOND 32768/2
18+
#define QUARTER_SECOND 32768/4
1919

2020
/* Put all your code here */
2121
void main(void) {
22-
unsigned seconds = 0;
23-
char str[10];
22+
unsigned seconds = 0;
23+
char str[10];
2424

25-
/* Clean up the home screen */
26-
prgm_CleanUp();
27-
28-
/* Disable the timer so it doesn't run when we don't want it to be running */
29-
timer_Control = TIMER1_DISABLE;
30-
31-
/* By using the 32768 kHz clock, we can count for exactly 1 second here, or a different interval of time */
32-
timer_1_ReloadValue = timer_1_Counter = ONE_SECOND;
33-
34-
/* Enable the timer, set it to the 32768 kHz clock, enable an interrupt once it reaches 0, and make it count down */
35-
timer_Control = TIMER1_ENABLE | TIMER1_32K | TIMER1_0INT | TIMER1_DOWN;
36-
37-
do {
38-
/* If the timer is reloaded, we reached 0 */
39-
if(timer_IntStatus & TIMER1_RELOADED) {
40-
/* Print a string */
41-
sprintf( str, "%u", seconds++ );
42-
os_SetCursorPos( 0, 0 );
43-
os_PutStrFull( str );
44-
45-
/* Acknowledge the reload */
46-
timer_IntStatus = TIMER1_RELOADED;
47-
}
48-
} while(!os_GetCSC());
49-
50-
/* Clean up for the return to the OS */
51-
prgm_CleanUp();
25+
/* Clean up the home screen */
26+
prgm_CleanUp();
27+
28+
/* Disable the timer so it doesn't run when we don't want it to be running */
29+
timer_Control = TIMER1_DISABLE;
30+
31+
/* By using the 32768 kHz clock, we can count for exactly 1 second here, or a different interval of time */
32+
timer_1_ReloadValue = timer_1_Counter = ONE_SECOND;
33+
34+
/* Enable the timer, set it to the 32768 kHz clock, enable an interrupt once it reaches 0, and make it count down */
35+
timer_Control = TIMER1_ENABLE | TIMER1_32K | TIMER1_0INT | TIMER1_DOWN;
36+
37+
do {
38+
/* If the timer is reloaded, we reached 0 */
39+
if(timer_IntStatus & TIMER1_RELOADED) {
40+
/* Print a string */
41+
sprintf( str, "%u", seconds++ );
42+
os_SetCursorPos( 0, 0 );
43+
os_PutStrFull( str );
44+
45+
/* Acknowledge the reload */
46+
timer_IntAcknowledge = TIMER1_RELOADED;
47+
}
48+
} while(!os_GetCSC());
49+
50+
/* Clean up for the return to the OS */
51+
prgm_CleanUp();
5252
}

CEdev/examples/demo_4/src/main.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,55 @@
1111
#include <string.h>
1212

1313
/* Other available headers */
14-
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h
14+
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h, intce.h
1515

16-
#define ONE_SECOND 32768/1
17-
#define HALF_SECOND 32768/2
18-
#define QUARTER_SECOND 32768/4
16+
#define ONE_SECOND 32768/1
17+
#define HALF_SECOND 32768/2
18+
#define QUARTER_SECOND 32768/4
1919

2020
/* Function Prototypes */
2121
void reset_counter(void);
2222

2323
/* Put all your code here */
2424
void main(void) {
25-
unsigned count = 0;
26-
char str[10];
27-
28-
timer_1_MatchValue_1 = ONE_SECOND;
29-
30-
/* Clean up the home screen */
31-
prgm_CleanUp();
32-
33-
/* Reset the counter */
34-
reset_counter();
35-
36-
do {
37-
/* If the timer is reloaded, we reached 0 */
38-
if(timer_IntStatus & TIMER1_MATCH1) {
39-
/* Print the count */
40-
sprintf( str, "%u", count++ );
41-
os_SetCursorPos( 0, 0 );
42-
os_PutStrFull( str );
43-
44-
/* Reset the count */
45-
reset_counter();
46-
47-
/* Acknowledge the interrupt */
48-
timer_IntStatus = TIMER1_MATCH1;
49-
}
50-
} while(!os_GetCSC());
51-
52-
/* Clean up for the return to the OS */
53-
prgm_CleanUp();
25+
unsigned count = 0;
26+
char str[10];
27+
28+
timer_1_MatchValue_1 = ONE_SECOND;
29+
30+
/* Clean up the home screen */
31+
prgm_CleanUp();
32+
33+
/* Reset the counter */
34+
reset_counter();
35+
36+
do {
37+
/* Count until we reach the match value */
38+
if(timer_IntStatus & TIMER1_MATCH1) {
39+
/* Print the count */
40+
sprintf( str, "%u", count++ );
41+
os_SetCursorPos( 0, 0 );
42+
os_PutStrFull( str );
43+
44+
/* Reset the count */
45+
reset_counter();
46+
47+
/* Acknowledge the interrupt */
48+
timer_IntStatus = TIMER1_MATCH1;
49+
}
50+
} while(!os_GetCSC());
51+
52+
/* Clean up for the return to the OS */
53+
prgm_CleanUp();
5454
}
5555

5656
void reset_counter(void) {
57-
/* Disable the timer so it doesn't run when we don't want it to be running */
58-
timer_Control = TIMER1_DISABLE;
59-
60-
/* By using the 32768 kHz clock, we can count for exactly 1 second here, or a different interval of time */
61-
timer_1_Counter = 0;
62-
63-
/* Enable the timer, set it to the 32768 kHz clock, enable an interrupt once it reaches 0, and make it count down */
64-
timer_Control = TIMER1_ENABLE | TIMER1_32K | TIMER1_NOINT | TIMER1_UP;
57+
/* Disable the timer so it doesn't run when we don't want it to be running */
58+
timer_Control = TIMER1_DISABLE;
59+
60+
/* By using the 32768 kHz clock, we can count for exactly 1 second here, or a different interval of time */
61+
timer_1_Counter = 0;
62+
63+
/* Enable the timer, set it to the 32768 kHz clock, enable an interrupt once it reaches 0, and make it count down */
64+
timer_Control = TIMER1_ENABLE | TIMER1_32K | TIMER1_NOINT | TIMER1_UP;
6565
}

CEdev/examples/demo_5/src/main.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@
1111
#include <string.h>
1212

1313
/* Other available headers */
14-
// stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h, debug.h
14+
// stdarg.h, setjmp.h, ctype.h, float.h, iso646.h, limits.h, errno.h, intce.h
1515
#include <assert.h>
1616
#include <debug.h>
1717

1818
/* Put function prototypes here */
1919

2020
/* Put all your code here */
2121
void main(void) {
22-
/* Set the intial value of some variables */
23-
int dbg_test_var_1 = 10;
24-
uint8_t dbg_test_var_2 = 3;
25-
26-
/* Print a simple debugging string */
27-
dbg_sprintf(dbgout, "This is the start of a CEmu debugging test\n");
28-
29-
/* Set a watchpoint that will break anytime we write/change this varaible */
30-
dbg_SetWriteWatchpoint( &dbg_test_var_1, sizeof dbg_test_var_1 );
31-
32-
/* Set a non breaking watchpoint just so we can see what is in this variable at any given time */
33-
dbg_SetWatchpoint( &dbg_test_var_2, sizeof dbg_test_var_2 );
34-
35-
/* Now, let's write to the varaible to see what happens (Go to the 'Watchpoints' tab in CEmu to view the status) */
36-
dbg_test_var_1 = 5;
37-
38-
/* Remove the watchpoint that we had set */
39-
dbg_RemoveWatchpoint( &dbg_test_var_1 );
40-
dbg_RemoveWatchpoint( &dbg_test_var_2 );
41-
42-
/* Clean up everything */
43-
prgm_CleanUp();
22+
/* Set the intial value of some variables */
23+
int dbg_test_var_1 = 10;
24+
uint8_t dbg_test_var_2 = 3;
25+
26+
/* Print a simple debugging string */
27+
dbg_sprintf(dbgout, "This is the start of a CEmu debugging test\n");
28+
29+
/* Set a watchpoint that will break anytime we write/change this varaible */
30+
dbg_SetWriteWatchpoint( &dbg_test_var_1, sizeof dbg_test_var_1 );
31+
32+
/* Set a non breaking watchpoint just so we can see what is in this variable at any given time */
33+
dbg_SetWatchpoint( &dbg_test_var_2, sizeof dbg_test_var_2 );
34+
35+
/* Now, let's write to the varaible to see what happens (Go to the 'Watchpoints' tab in CEmu to view the status) */
36+
dbg_test_var_1 = 5;
37+
38+
/* Remove the watchpoint that we had set */
39+
dbg_RemoveWatchpoint( &dbg_test_var_1 );
40+
dbg_RemoveWatchpoint( &dbg_test_var_2 );
41+
42+
/* Clean up everything */
43+
prgm_CleanUp();
4444
}

CEdev/examples/demo_6/bin/DEMO6.8xp

-5 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)