summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/export/split_version_2.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/export/split_version_2.c b/src/export/split_version_2.c
index 324e61d..54e2313 100644
--- a/src/export/split_version_2.c
+++ b/src/export/split_version_2.c
@@ -98,16 +98,16 @@ static void finish_record( ) {
98 g_state.outbuf[file][g_state.outfill[file]++] = '\n'; 98 g_state.outbuf[file][g_state.outfill[file]++] = '\n';
99} 99}
100 100
101static uint16_t load_word( uint8_t *table_start, uint16_t base, int offset ) { 101static uint16_t load_word( uint8_t *record, uint16_t base, int offset ) {
102 int dword_offset = offset >> 1; 102 int dword_offset = offset >> 1;
103 103
104 /* If a word(subflag, t_off) would span over the end of a 0x4000 104 /* If a word(subflag, t_off) would span over the end of a 0x4000
105 byte page, it is placed on the next page. All other words are 105 byte page, it is placed on the next page. All other words are
106 shifted backwards, as well. */ 106 shifted backwards, as well. */
107 if( base + 4 + 4 * dword_offset > 0x1ffc ) 107 if( base + 4 + 4 * dword_offset > 0x1ffc )
108 table_start += 3 & ( 4 - ( base & 3 ) ); 108 record += 3 & ( 4 - ( base & 3 ) );
109 109
110 return ((uint16_t*)table_start)[offset + 2]; 110 return ((uint16_t*)record)[offset + 2];
111} 111}
112 112
113static void dump_primary( uint8_t *end, uint32_t flags ) { 113static void dump_primary( uint8_t *end, uint32_t flags ) {
@@ -158,27 +158,26 @@ static void dump_primary( uint8_t *end, uint32_t flags ) {
158 dump_field( &end, 15 ); 158 dump_field( &end, 15 );
159} 159}
160 160
161static void act_on_record( uint8_t * end, uint16_t base ) { 161static void act_on_record( uint8_t * rec, uint16_t base ) {
162 uint16_t *rec = (uint16_t*)end; 162 uint16_t entries = ((uint16_t*)rec)[0];
163 uint8_t *e = end; 163 uint16_t flagbytes = ((uint16_t*)rec)[1];
164 uint16_t num_dwords = rec[0];
165 uint16_t flagbytes = rec[1];
166 uint32_t flags = 0; 164 uint32_t flags = 0;
165 uint8_t *end = rec;
167 int i; 166 int i;
168 167
169 while(flagbytes--) flags = (flags<<8) | *--end; 168 while(flagbytes--) flags = (flags<<8) | *--end;
170 169
171// printf( "-------- %03d: %06X\n", num_dwords, flags ); 170 //printf( "-------- %03d: %06X\n", entries, flags );
172 for (i = 0; i < num_dwords; i++ ) { 171 for (i = 0; i < entries; i++ ) {
173 uint16_t subflag = load_word( e, base, 2*i ); 172 uint16_t subflag = load_word( rec, base, 2*i );
174 uint16_t t_off = load_word( e, base, 2*i+1 ); 173 uint16_t t_off = load_word( rec, base, 2*i+1 );
175 uint8_t *rec_start = end - t_off; 174 uint8_t *rec_start = end - t_off;
176 175
177 if (i == 0) { 176 if (i == 0) {
178 dump_string( num_dwords > 1 ? (uint8_t*)"01" : (uint8_t*)"00", 2, 0 ); 177 dump_string( entries > 1 ? (uint8_t*)"01" : (uint8_t*)"00", 2, 0 );
179 dump_primary( rec_start, flags ); 178 dump_primary( rec_start, flags );
180 } else { 179 } else {
181 uint8_t * rec_end = end - ( ( i+1 == num_dwords ) ? 0 : load_word( e, base, 2*i+3 ) ); 180 uint8_t * rec_end = end - ( ( i+1 == entries ) ? 0 : load_word( rec, base, 2*i+3 ) );
182 int file = g_outfilemap[g_cd][subflag&0x1F]; 181 int file = g_outfilemap[g_cd][subflag&0x1F];
183 if( subflag == 0x4003 ) { 182 if( subflag == 0x4003 ) {
184 finish_record(); 183 finish_record();