Changeset 7cabd49 in thomson for code/C/HxCHost/main.c
- Timestamp:
- Mar 19, 2012, 7:51:49 AM (12 years ago)
- Branches:
- main
- Children:
- fe55aa5
- Parents:
- cc8f3af
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/C/HxCHost/main.c
rcc8f3af r7cabd49 9 9 void asm_write(); 10 10 11 #if PLATFORM == 5 12 #define DIRECTORY_BUFFER (FILINFO*)0x3000 13 #else 14 // Thomson TO8 code 15 #define DIRECTORY_BUFFER (FILINFO*)0xA000 16 #endif 11 FILINFO DIRECTORY_BUFFER[23]; 17 12 18 13 unsigned char mark[512 + 16] = "HxCFEDA"; … … 102 97 {"\x1B\x50\x0CHxC floppy emulator setup\r\n" 103 98 "UP/DOWN move - +/- change\r\n" 104 "space save - left quit\r\n "99 "space save - left quit\r\n\n" 105 100 "Step sound ", 16, 0}, 106 101 {"\r\nGUI sound ", 17, 0}, … … 112 107 }; 113 108 109 #define getcfg(off) *(char*)((int)confbuf+off) 110 #define putcfg(off, val) *(char*)((int)confbuf+off) = val 111 114 112 inline static void config() 115 113 { 116 unsigned char*confbuf[29];114 char confbuf[29]; 117 115 // If it's HXCSDFE.CFG, enter config mode 118 116 // Read the config part of the file … … 121 119 if (r != 0 || byteCount != 29) 122 120 { 123 my_puts("read error"); 121 my_puts("read error "); 122 printhex(r); 124 123 abort(); 125 124 } … … 133 132 mon_putc(selected == j ? 0x54: 0x50) // Blue 134 133 if(options[j].type) 135 printhex( *(confbuf+options[j].off));134 printhex(getcfg(options[j].off)); 136 135 else 137 my_puts( *(confbuf+options[j].off) ? "ON":"OFF");136 my_puts(getcfg(options[j].off) ? "ON":"OFF"); 138 137 mon_putc(0x1B); // Select back color 139 138 mon_putc(0x50); // Select back color … … 141 140 142 141 do { 143 asm(" SWI \t \t;\n"144 " .fcb \t0x0A\t;GETC\n");142 asm(" SWI\n" 143 " FCB 0x0A\n"); 145 144 } while(KEY == 0); 146 145 … … 170 169 } 171 170 // fall through 172 do {173 asm("SWI \t \t;\n"174 ".fcb \t0x0A\t;GETC\n");175 } while(KEY == 0);176 171 case 0x10: // LEFT 177 172 // Quit (without saving) … … 180 175 case 0x18: // DOWN 181 176 // select previous file 182 if (++selected > 7) selected = 7;177 if (++selected > 6) selected = 6; 183 178 // TODO previous page ? 184 179 break; … … 186 181 // decrease current option value 187 182 if(options[selected].type) 188 --*(c onfbuf+options[selected].off);183 --*(char*)((int)confbuf+options[selected].off); 189 184 else 190 *(confbuf+options[selected].off) = 0;185 putcfg(options[selected].off, 0); 191 186 break; 192 187 case 0x0B: // + 193 188 if(options[selected].type) 194 ++*(c onfbuf+options[selected].off);189 ++*(char*)((int)confbuf+options[selected].off); 195 190 else 196 *(confbuf+options[selected].off) = 0xFF;191 putcfg(options[selected].off, 0xFF); 197 192 break; 198 193 } … … 211 206 FATFS fs; 212 207 FRESULT r = pf_mount(&fs); 208 213 209 if (r != 0) { 214 210 my_puts("mount error "); … … 265 261 // Allow the user to select a file 266 262 do { 267 asm(" SWI \t \t;\n"268 " .fcb \t0x0A\t;GETC\n");263 asm(" SWI \n" 264 " fcb 0x0A\n"); 269 265 } while(KEY == 0); 270 266 … … 300 296 } else { 301 297 const char* cmp = HXCSDFECFG; 302 FRESULT res = pf_open(cmp);303 if (res) {304 my_puts("Can't open CFG file: ");305 printhex(res);306 exit(0);307 }308 298 if (*(long*)(fp->fname) == *(long*)(cmp) 309 299 && *(long*)(fp->fname + 4) == *(long*)(cmp+4) … … 311 301 ) 312 302 { 303 FRESULT res = pf_open(cmp); 304 if (res) { 305 my_puts("Can't open CFG file: "); 306 printhex(res); 307 exit(0); 308 } 313 309 config(); 314 310 } else { … … 316 312 // If it's an HFE file, load it in HxCSDFE.CFG, then reboot 317 313 314 // We need to open the file to get the starting cluster. 315 // This is a PFF "limitation". 316 pf_open(fp->fname); 317 long off = LD_DWORD(&fs.org_clust); 318 319 FRESULT res = pf_open(cmp); 320 if (res) { 321 my_puts("Can't open CFG file: "); 322 printhex(res); 323 exit(0); 324 } 325 pf_lseek(0x200); 326 327 int count = 12; 328 pf_write(fp->fname, count, &count); 329 count = 1; 330 pf_write(&fp->fattrib, count, &count); 331 count = 4; 332 pf_write(&off, count, &count); 333 off = LD_DWORD(&fp->fsize); 334 pf_write(&off, count, &count); 335 count = 17; 336 pf_write(fp->fname, count, &count); 337 pf_write(0,0,&count); 338 318 339 // reboot 319 exit(0); 340 asm(" SWI\n" 341 " FCB 0"); 320 342 } 321 343 }
Note:
See TracChangeset
for help on using the changeset viewer.