-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmac.c
More file actions
108 lines (82 loc) · 2.62 KB
/
mac.c
File metadata and controls
108 lines (82 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#if 0
/*===========================================================================
M A C . C
MAC 65 record format.
The data is recorded as a series of ASCII records. The format of the
records is as follows:
DC.B dd, dd, dd, ...
Where each dd is a 2 character hex representations of the each data byte.
Copyright 1991 Atari Games. All rights reserved.
Author: Jim Petrick
---------------------------------------------------------------------------
Revision history:
---------------------------------------------------------------------------
Known bugs/features/limitations:
===========================================================================*/
#endif
#include "mixit.h"
extern uint32_t last_address, base_address;
extern char current_fname[];
/*==========================================================================*/
int macGetRec(InRecord *rec)
{
return (rec->recType = REC_ERR);
} /* end macGetRec */
char *header[] = {
".MACRO BYT .0,.1,.2,.3,.4,.5,.6,.7,.8,.9,.A,.B,.C,.D,.E,.F",
" .irp a,<.0,.1,.2,.3,.4,.5,.6,.7,.8,.9,.A,.B,.C,.D,.E,.F>",
" .iif b,<a>,.rexit",
" .iif dif,<a>,<XX>,.byte 0x'a",
" .iif idn,<a>,<XX>,.blkb 1",
" .endr",
".endm",
"",
".MACRO ROM_ORG base address",
". = MIXIT_BEGIN + 0x'base + 0x'address",
".endm",
"",
" .RADIX 16",
" .ASECT",
"",
"MIXIT_BEGIN:",
0 };
/*==========================================================================
* Puts out any header info for the file.
*==========================================================================*/
int PutHead_mac( FILE *file, uint32_t addr, uint32_t hi )
{
int i;
if ( !noDate )
fprintf(file, "\n\n; File name = %s\n\n", current_fname);
for( i=0; header[i]; ++i )
fprintf( file, "%s\n", header[i]);
base_address = addr;
last_address = (uint32_t)-1L;
return 1;
} /* end PutHead_mac */
/*==========================================================================*
* Outputs a single record in MAC format.
*==========================================================================*/
int PutRec_mac( FILE *file, uint8_t *data, int recsize, uint32_t recstart )
{
int j;
char *cp;
char outbuf[140];
if (recstart != last_address)
fprintf( file, "\n\tROM_ORG %05X %05X\n",
base_address, recstart - base_address);
last_address = recstart + recsize;
cp = outbuf;
sprintf(cp, "\tBYT %02X", *data++ );
cp += strlen(cp);
/* Append data to the record */
for (j=1; j < recsize; ++j)
{
sprintf( cp, ",%02X", *data++ );
cp += strlen(cp);
}
*cp++ = '\n';
*cp++ = 0;
fputs(outbuf, file); /* Output the record to the file */
return 1;
} /* end PutRec_mac */