Skip to content

Commit

Permalink
ray4: convert all command argument processing
Browse files Browse the repository at this point in the history
- Camel case renaming in random locations.
- Got rid of some defines.
- No longer read from stdin by default.
- Add double-dash options.
- Delete aspect ratio parameters.
- Scan range replaced with option to select single Z slice.
- Upgraded parameter processing code.
- Replace global header struct with main-local instance.
- Keep parameters in main-local instance, pass as function argument. No
  more global parameters struct.
  • Loading branch information
hollasch committed Nov 6, 2024
1 parent 4263f26 commit 208df11
Show file tree
Hide file tree
Showing 4 changed files with 319 additions and 326 deletions.
4 changes: 2 additions & 2 deletions ray4/src/r4_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@

// Macro Definitions

#define R4_IMAGE_ID 0x52617934L // 'Ray4'
const uint32_t ray4FormatMagic = 0x52617934L; // 'Ray4'


// Structure Definitions

struct ImageHeader_1 {
unsigned long magic; // Magic Number = R4_IMAGE_ID
unsigned char version; // Image File Version Number = 1
unsigned char bitsperpixel; // Number of Bits per Pixel
unsigned char bitsPerPixel; // Number of Bits per Pixel
unsigned short aspect[3]; // Aspect Ratios [X,Y,Z]
unsigned short start[3]; // Starting Image Pixels for [X,Y,Z]
unsigned short end[3]; // Ending Image Pixels for [X,Y,Z]
Expand Down
20 changes: 8 additions & 12 deletions ray4/src/r4_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ FILE *outstream = nullptr; // Output Stream
void CloseInput () {
// Closes the input stream.

if (!infile || (*infile == 0) || (!instream))
if (!instream)
return;
fclose (instream);
instream = nullptr;
Expand Down Expand Up @@ -89,27 +89,23 @@ void UnreadChar (int c) {

//__________________________________________________________________________________________________

void OpenInput () {
void OpenInput (const char* fileName) {
// This subroutine opens the input file. If no filename was given in the command-line arguments,
// we'll use the standard input stream.

if (!infile || (*infile == 0))
instream = stdin;
else if (! (instream = fopen (infile, "r")))
Halt ("Open failed on input file (%s).", infile);
instream = fopen (fileName, "r");
if (!instream)
Halt ("Open failed on input file (%s).", fileName);
}

//__________________________________________________________________________________________________

void OpenOutput () {
void OpenOutput (const char* fileName) {
// This subroutine opens the output file.

if (!outfile || (*outfile == 0))
Halt ("No output file specified.");

outstream = fopen (outfile, "wb");
outstream = fopen (fileName, "wb");
if (!outstream)
Halt ("Open failed on output file (%s).", outfile);
Halt ("Open failed on output file (%s).", fileName);
}

//__________________________________________________________________________________________________
Expand Down
Loading

0 comments on commit 208df11

Please sign in to comment.