source: buchla-68k/ram/dcopy.c@ dade7a0

Last change on this file since dade7a0 was fa38804, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Removed form-feed comments.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 =============================================================================
3 dcopy.c -- copy MIDAS-VII to disk
4 Version 3 -- 1988-09-01 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "ram.h"
9
10#define PROGID "midas.abs" /* MIDAS-VII program file name */
11
12/*
13*/
14
15/*
16 =============================================================================
17 dcopy() -- copy MIDAS-VII to disk
18 =============================================================================
19*/
20
21int16_t dcopy(void)
22{
23 register FILE *fp;
24 register int8_t *from;
25 register int32_t wrtlen, loadlen, bsslen, txtlen;
26
27 defect = 0; /* reset error word */
28
29 txtlen = (int32_t)&etext - (int32_t)&Lo_RAM; /* calculate text length */
30 bsslen = (int32_t)&end - (int32_t)&edata; /* calculate BSS length */
31
32 loadlen = (int32_t)&edata - (int32_t)&Lo_RAM; /* calculate write length */
33
34 /* create the object file header */
35
36 mphead.F_Magic = F_R_C; /* magic = contiguous file */
37 mphead.F_Text = txtlen; /* text length */
38 mphead.F_Data = p_dlen; /* data length */
39 mphead.F_BSS = bsslen; /* BSS length */
40 mphead.F_Symtab = 0L; /* symbol table length */
41 mphead.F_Res1 = 0L; /* reserved area #1 */
42 mphead.F_Res2 = (int32_t)&Lo_RAM; /* text base */
43 mphead.F_Res3 = 0xFFFF; /* flag word */
44
45 /* ***** initialize for a (possibly) new disk here ***** */
46
47 /* open MIDAS-VII object file for writing */
48
49 preio(); /* kill the LCD backlight */
50
51 if ((FILE *)NULL EQ (fp = fopenb(PROGID, "w"))) {
52
53 defect = 1; /* couldn't open file */
54 postio(); /* restore LCD backlight */
55 return(FAILURE);
56 }
57
58
59 /* write program header to disk */
60
61 from = &mphead;
62
63 for (wrtlen = sizeof mphead; wrtlen--; )
64 if (EOF EQ putc(*from++, fp)) {
65
66 defect = 2; /* couldn't write program header */
67 fclose(fp);
68 postio(); /* restore LCD backlight */
69 return(FAILURE);
70 }
71
72 /* write MIDAS-VII to disk */
73
74 from = &Lo_RAM;
75
76 for (wrtlen = loadlen; wrtlen--; )
77 if (EOF EQ putc(*from++, fp)) {
78
79 defect = 3; /* couldn't write program */
80 fclose(fp);
81 postio(); /* restore LCD backlight */
82 return(FAILURE);
83 }
84
85 /* flush and close file */
86
87 fflush(fp);
88 fclose(fp);
89 postio(); /* restore LCD backlight */
90 return(SUCCESS);
91}
92
Note: See TracBrowser for help on using the repository browser.