Skip to content

Commit

Permalink
PCEAS: Use xgetopt on all target platforms to avoid annoying differen…
Browse files Browse the repository at this point in the history
…ces in behavior.

Display "--" for the long options in the help message, even though a single "-" works
in order to maintain backwards compatibility.
  • Loading branch information
jbrandwood committed Apr 14, 2024
1 parent e191ca7 commit 9ee573a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/mkit/as/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include ../../Make_src.inc

OBJS = main.o input.o assemble.o expr.o code.o command.o\
macro.o func.o proc.o symbol.o pcx.o output.o crc.o\
pce.o map.o mml.o nes.o atari.o
pce.o map.o mml.o nes.o atari.o xgetopt.o

LIBS = pngread/pngread.a

Expand Down
52 changes: 29 additions & 23 deletions src/mkit/as/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
#include "xgetopt.h"
#else
#include <getopt.h>
#endif
#include <ctype.h>
#include "defs.h"
#include "externs.h"
#include "protos.h"
#include "vars.h"
#include "inst.h"
#include "overlay.h"
#include "xgetopt.h"

/* defines */
#define STANDARD_CD 1
Expand Down Expand Up @@ -361,6 +357,9 @@ main(int argc, char **argv)
switch(opt)
{
case 'I':
// /* GNU optarg can add a leading space on linux */
// while (*optarg == ' ') { ++optarg; }

if (*optarg == '-') {
fprintf(stderr, "%s: include path missing after \"-I\"!\n", argv[0]);
return (1);
Expand All @@ -384,6 +383,9 @@ main(int argc, char **argv)
return (0);

case 'l':
// /* GNU optarg can add a leading space on linux */
// while (*optarg == ' ') { ++optarg; }

if ((isdigit(*optarg) == 0) || (optarg[1] != '\0')) {
fprintf(stderr, "%s: \"-l\" option must be followed by a single digit\n", argv[0]);
return (1);
Expand All @@ -402,6 +404,9 @@ main(int argc, char **argv)
break;

case 'o':
// /* GNU optarg can add a leading space on linux */
// while (*optarg == ' ') { ++optarg; }

if (*optarg == '-') {
fprintf(stderr, "%s: output filename missing after \"-o\"\n", argv[0]);
return (1);
Expand Down Expand Up @@ -1082,29 +1087,30 @@ help(void)
prg_name = machine->asm_name;

/* display help */
printf("%s [-options] [-h (for help)] [-o outfile] infiles\n\n", prg_name);
printf("-s/S : show segment usage\n");
printf("-l # : listing file output level (0-3)\n");
printf("%s [options] [-h (for help)] [-o outfile] infiles\n\n", prg_name);
printf("-s : show segment usage\n");
printf("-S : show segment usage and contents\n");
printf("-l <0..3> : listing file output level (0-3), default is 2\n");
printf("-m : force macro expansion in listing\n");
printf("-raw : prevent adding a ROM header\n");
printf("-pad : pad ROM size to power-of-two\n");
printf("-trim : strip unused head and tail from ROM\n");
printf("--raw : prevent adding a ROM header\n");
printf("--pad : pad ROM size to power-of-two\n");
printf("--trim : strip unused head and tail from ROM\n");
printf("-I : add include path\n");
if (machine->type == MACHINE_PCE) {
printf("-sf2 : create a StreetFighterII HuCARD\n");
printf("-cd : create a CD-ROM track image\n");
printf("-scd : create a Super CD-ROM track image\n");
printf("-sgx : add a SuperGRAFX signature to the CD-ROM\n");
printf("-overlay : create an executable 'overlay' program segment\n");
printf("-ipl : create a custom CD-ROM IPL file\n");
printf("-develo : assemble and run on the Develo Box\n");
printf("-mx : create a Develo MX file\n");
printf("--sf2 : create a StreetFighterII HuCARD\n");
printf("--cd : create a CD-ROM track image\n");
printf("--scd : create a Super CD-ROM track image\n");
printf("--sgx : add a SuperGRAFX signature to the CD-ROM\n");
printf("--overlay : create an executable 'overlay' program segment\n");
printf("--ipl : create a custom CD-ROM IPL file\n");
printf("--develo : assemble and run on the Develo Box\n");
printf("--mx : create a Develo MX file\n");
printf("-O : optimize .proc packing (compared to HuC v3.21)\n");
printf("-strip : strip unused .proc & .procgroup\n");
printf("-newproc : run .proc code in MPR6, instead of MPR5\n");
printf("--strip : strip unused .proc & .procgroup\n");
printf("--newproc : run .proc code in MPR6, instead of MPR5\n");
}
printf("-kc : assemble code generated by the KickC compiler\n");
printf("-srec : create a Motorola S-record file\n");
printf("--kc : assemble code generated by the KickC compiler\n");
printf("--srec : create a Motorola S-record file\n");
printf("infiles : one or more files to be assembled\n");
printf("\n");
}
Expand Down

0 comments on commit 9ee573a

Please sign in to comment.