Skip to content

Commit

Permalink
Merge pull request #13 from ckormanyos/improve_syntax
Browse files Browse the repository at this point in the history
Improve syntax
  • Loading branch information
ckormanyos authored Jan 7, 2024
2 parents 804e778 + 0bca17c commit 2f504d1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
13 changes: 5 additions & 8 deletions src/app/app_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,27 @@ void main(void)
{
app_util_init();

volatile uint8_t exit_flag = (uint8_t) UINT8_C(0);
bool exit_flag = false;

for(;;)
{
app_led_clr();
app_led_on();

for(volatile uint_fast16_t i = (uint_fast16_t) UINT16_C(0x0);
((i < (uint_fast16_t) UINT16_C(0x0F80)) && ((exit_flag = app_util_wants_exit()) == (uint8_t) UINT8_C(0)));
((i < (uint_fast16_t) UINT16_C(0x0F80)) && ((exit_flag = app_util_wants_exit()) == false));
++i) { ; }

if(exit_flag != (uint8_t) UINT8_C(0)) { break; }
if(exit_flag) { break; }

app_led_clr();
app_led_off();

for(volatile uint_fast16_t i = (uint_fast16_t) UINT16_C(0x0);
((i < (uint_fast16_t) UINT16_C(0x0F80)) && ((exit_flag = app_util_wants_exit()) == (uint8_t) UINT8_C(0)));
((i < (uint_fast16_t) UINT16_C(0x0F80)) && ((exit_flag = app_util_wants_exit()) == false));
++i) { ; }

if(exit_flag != (uint8_t) UINT8_C(0))
{
break;
}
if(exit_flag) { break; }
}

// Exit the Application and return to the home screen
Expand Down
34 changes: 18 additions & 16 deletions src/app/app_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,11 @@

#include <app/app_util.h>

static bool app_util_check_crt0(void);

extern uint8_t app_dummy_test_non_initialized;
extern uint8_t app_dummy_test_initialized;

static bool app_util_check_crt0(void)
{
// Check static initialization.

bool result_crt0_non_init_is_ok = ((app_dummy_test_non_initialized == (uint8_t) UINT8_C(0)) ? true : false);
bool result_crt0_init_is_ok = ((app_dummy_test_initialized == (uint8_t) UINT8_C(42)) ? true : false);

bool result_check_crt0_is_ok = ((result_crt0_non_init_is_ok && result_crt0_init_is_ok) ? true : false);

return result_check_crt0_is_ok;
}

void app_util_init(void)
{
while(!app_util_check_crt0())
Expand All @@ -33,18 +23,18 @@ void app_util_init(void)
__asm__("rst 0x28\n" ".dw #0x4558\n");
}

uint8_t app_util_wants_exit(void)
bool app_util_wants_exit(void)
{
volatile uint8_t exit_flag = (uint8_t) UINT8_C(0);
volatile bool exit_flag = false;

__asm__
(
"rst 0x28\n" ".dw #0x4018\n"
"cp #0x9\n"
"jp nz,no_exit\n"
"jp nz, no_exit\n"
);

exit_flag = (uint8_t) UINT8_C(1);
exit_flag = true;

__asm__
(
Expand All @@ -53,3 +43,15 @@ uint8_t app_util_wants_exit(void)

return exit_flag;
}

static bool app_util_check_crt0(void)
{
// Check static initialization.

const bool result_crt0_non_init_is_ok = ((app_dummy_test_non_initialized == (uint8_t) UINT8_C(0)) ? true : false);
const bool result_crt0_init_is_ok = ((app_dummy_test_initialized == (uint8_t) UINT8_C(42)) ? true : false);

const bool result_check_crt0_is_ok = ((result_crt0_non_init_is_ok && result_crt0_init_is_ok) ? true : false);

return result_check_crt0_is_ok;
}
5 changes: 3 additions & 2 deletions src/app/app_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#ifndef APP_UTIL_2024_01_7_H
#define APP_UTIL_2024_01_7_H

#include <stdbool.h>
#include <stdint.h>

#if defined(_MSC_VER)
Expand All @@ -22,7 +23,7 @@
// curCol #0x844C
// _PutC #0x4504

void app_util_init (void);
uint8_t app_util_wants_exit(void);
void app_util_init (void);
bool app_util_wants_exit(void);

#endif // APP_UTIL_2024_01_7_H

0 comments on commit 2f504d1

Please sign in to comment.