From 651b059e67ad7fe91195c7e7c8d2ff9920f4b2a8 Mon Sep 17 00:00:00 2001 From: marcobaye Date: Sun, 16 Aug 2015 20:19:00 +0000 Subject: [PATCH] Tiny change to support compilers without snprintf(). Added Makefile for examples. No change in functionality. git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@65 4df02467-bbd4-4a76-a152-e7ce94205b78 --- docs/AddrModes.txt | 2 +- examples/Makefile | 22 ++++++++++++++++++++++ examples/ddrv.a | 10 ++++++++-- src/acme.c | 2 +- src/input.c | 9 +++++++-- 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 examples/Makefile diff --git a/docs/AddrModes.txt b/docs/AddrModes.txt index 192c748..fbd4789 100644 --- a/docs/AddrModes.txt +++ b/docs/AddrModes.txt @@ -169,4 +169,4 @@ I admit that this algorithm sounds complicated, but it hasn't failed yet. :) And in everyday usage, it does exactly what one expects. If you want to take a closer look at the algorithm, examine the -"calc_arg_size" function in the "sources/mnemo.c" file. +"calc_arg_size" function in the "src/mnemo.c" file. diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..da74382 --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,22 @@ +ASSEMBLER6502 = acme +AS_FLAGS = -v9 -Wtype-mismatch +RM = rm + +PROGS = ddrv128.prg ddrv64.prg macedit.o trigono.o + +all: $(PROGS) + +ddrv128.prg: ddrv.a + $(ASSEMBLER6502) $(AS_FLAGS) --outfile ddrv128.prg --format cbm -DSYSTEM=128 ddrv.a + +ddrv64.prg: ddrv.a + $(ASSEMBLER6502) $(AS_FLAGS) --outfile ddrv64.prg --format cbm -DSYSTEM=64 ddrv.a + +macedit.o: macedit.a + $(ASSEMBLER6502) $(AS_FLAGS) --outfile macedit.o --format cbm macedit.a + +trigono.o: trigono.a + $(ASSEMBLER6502) $(AS_FLAGS) --outfile trigono.o --format cbm trigono.a + +clean: + -$(RM) -f *.o *.tmp $(PROGS) *~ core diff --git a/examples/ddrv.a b/examples/ddrv.a index abd40f4..3e97676 100644 --- a/examples/ddrv.a +++ b/examples/ddrv.a @@ -76,10 +76,12 @@ Sprite_HotspotX = 1 Sprite_HotspotY = 1 +; address definitions +!addr { + ; Locations to store button states, $ff = pressed, $00 = not pressed. ; Mouse uses both buttons, joystick only uses "LeftButton". ; Location to store pointer's current character coordinates. -!addr { !if SYSTEM = 64 { LeftButton = $a4 RightButton = $a5 @@ -111,6 +113,10 @@ cia1_prb = $dc01 cia1_ddrb = $dc03 mmu_cr = $ff00 ; c128 only + +; dummy value for self mod + MODIFIED16 = $ffff + };addr ; --- Label definitions @@ -422,7 +428,7 @@ StoreOF sta Sprites_OF ; set x overflow ; The initialisation routine sets the argument to the address of the ; previous IRQ routine. -mod16 = * + 1: jmp addr($ffff) ; (self-modifying) +mod16 = * + 1: jmp MODIFIED16 ; (self-modifying) ; This table is for part 8. ;OrTable !byte 0, 32, 64 ; VDC only diff --git a/src/acme.c b/src/acme.c index aa7e1b0..4238d3d 100644 --- a/src/acme.c +++ b/src/acme.c @@ -17,7 +17,7 @@ #define RELEASE "0.95.6" // update before release (FIXME) #define CODENAME "Fenchurch" // update before release -#define CHANGE_DATE "20 Jun" // update before release +#define CHANGE_DATE "16 Aug" // update before release #define CHANGE_YEAR "2015" // update before release //#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" // FIXME #define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME diff --git a/src/input.c b/src/input.c index 9c19a2b..171404a 100644 --- a/src/input.c +++ b/src/input.c @@ -55,12 +55,13 @@ void Input_new_file(const char *filename, FILE *fd) // remember source code character for report generator +#define HEXBUFSIZE 9 // actually, 4+1 is enough, but for systems without snprintf(), let's be extra-safe. #define IF_WANTED_REPORT_SRCCHAR(c) do { if (report->fd) report_srcchar(c); } while(0) static void report_srcchar(char new_char) { static char prev_char = '\0'; int ii; - char hex_address[5]; + char hex_address[HEXBUFSIZE]; char hexdump[2 * REPORT_BINBUFSIZE + 2]; // +2 for '.' and terminator // if input has changed, insert explanation @@ -77,7 +78,11 @@ static void report_srcchar(char new_char) fprintf(report->fd, "%6d ", Input_now->line_number - 1); // prepare outbytes' start address if (report->bin_used) - snprintf(hex_address, 5, "%04x", report->bin_address); +#if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L + snprintf(hex_address, HEXBUFSIZE, "%04x", report->bin_address); +#else + sprintf(hex_address, "%04x", report->bin_address); +#endif else hex_address[0] = '\0'; // prepare outbytes