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

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

No more pointer-int conversions.

  • 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
60*/
61 /* write program header to disk */
62
63 from = &mphead;
64
65 for (wrtlen = sizeof mphead; wrtlen--; )
66 if (EOF EQ putc(*from++, fp)) {
67
68 defect = 2; /* couldn't write program header */
69 fclose(fp);
70 postio(); /* restore LCD backlight */
71 return(FAILURE);
72 }
73
74 /* write MIDAS-VII to disk */
75
76 from = &Lo_RAM;
77
78 for (wrtlen = loadlen; wrtlen--; )
79 if (EOF EQ putc(*from++, fp)) {
80
81 defect = 3; /* couldn't write program */
82 fclose(fp);
83 postio(); /* restore LCD backlight */
84 return(FAILURE);
85 }
86
87 /* flush and close file */
88
89 fflush(fp);
90 fclose(fp);
91 postio(); /* restore LCD backlight */
92 return(SUCCESS);
93}
94
Note: See TracBrowser for help on using the repository browser.