Skip to content

Commit 7d2a5cd

Browse files
committed
CoCo: Fix memory overflow bug and "macro redfined" warning
1 parent 811c2b8 commit 7d2a5cd

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
- [coco] Fix bug in fuji_set_appkey_details that overwrote the first byte of data of a project that includes fujinet-lib
6+
- [coco] Remove unneccesary makefile block for mac - make runs fine on mac
7+
- [coco] Removed legacy -D_CMOC_VERSION_=1 CFLAG, which floods output with "macro redefined" warnings. CMOC already defines this.
58
- [build] Guarded hex_dump.c with flag `FN_LIB_DEBUG` which can be enabled via `application.mk`.
69
Added additional docs to `README.md` to explain this.
710
Added comments to top of `build.mk` to explain a little bit about paths that are included.

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
# Set the TARGETS and PROGRAM values as required.
44
# See makefiles/build.mk for details on directory structure for src files and how to add custom extensions to the build.
55

6-
# Require GNU Make 4.0 or later for $(file ...) function
7-
ifeq ($(filter 4.%,$(MAKE_VERSION)),)
8-
$(error This Makefile requires GNU Make 4.0 or later. You are using $(MAKE_VERSION). Please use 'gmake' instead of 'make' on macOS.)
9-
endif
10-
116
TARGETS = adam apple2 apple2enh atari c64 coco msdos
127
PROGRAM := fujinet.lib
138

common/src/fn_fuji/fuji_set_appkey_details.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99

1010
extern uint16_t ak_creator_id;
1111
extern uint8_t ak_app_id;
12-
extern enum AppKeySize ak_appkey_size;
12+
13+
// IMPORTANT: Instead of "enum AppKeySize", explicitly matching the underlying uint8_t data type, othwerise
14+
// CMOC will write a 16 bit enum value at the location, overflowing into the next byte, causing corruption
15+
extern uint8_t ak_appkey_size;
1316

1417
void fuji_set_appkey_details(uint16_t creator_id, uint8_t app_id, enum AppKeySize keysize)
1518
{
16-
ak_appkey_size = keysize;
19+
ak_appkey_size = (uint8_t)keysize;
1720
ak_app_id = app_id;
1821
ak_creator_id = creator_id;
1922
}

makefiles/compiler-cmoc.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CC := cmoc
22
AR := lwar
3-
CFLAGS := -O2 -D_CMOC_VERSION_=1
3+
CFLAGS := -O2
44

55
INCC_ARG := -I
66
INCS_ARG := -I

0 commit comments

Comments
 (0)