Changeset ee447bf in thomson for code/C/HxCHost/main.c


Ignore:
Timestamp:
Mar 10, 2012, 7:58:02 PM (12 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
99bc67a
Parents:
1b74fa2
Message:

More work on write support :

  • Avoid using the same buffer over and over again for everything, when writing this creates some problems.
  • Editing the configuration now works.

git-svn-id: svn://localhost/thomson@19 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/C/HxCHost/main.c

    r1b74fa2 ree447bf  
    1919unsigned char* secbuf = mark+16;
    2020
    21 const char* HXCSDFECFG = "HXCTEST.CFG";
     21const char* HXCSDFECFG = "HXCSDFE.CFG";
    2222
    2323void printhex(unsigned char n)
     
    114114inline static void config()
    115115{
     116        unsigned char* confbuf[29];
    116117        // If it's HXCSDFE.CFG, enter config mode
    117118        // Read the config part of the file
    118119        WORD byteCount = 29;
    119         FRESULT r = pf_read(secbuf, byteCount, &byteCount);
     120        FRESULT r = pf_read(confbuf, byteCount, &byteCount);
    120121        if (r != 0 || byteCount != 29)
    121122        {
     
    132133                        mon_putc(selected == j ? 0x54: 0x50) // Blue
    133134                        if(options[j].type)
    134                                 printhex(*(secbuf+options[j].off));
     135                                printhex(*(confbuf+options[j].off));
    135136                        else
    136                                 my_puts(*(secbuf+options[j].off) ? "ON":"OFF");
     137                                my_puts(*(confbuf+options[j].off) ? "ON":"OFF");
    137138                        mon_putc(0x1B); // Select back color
    138139                        mon_putc(0x50); // Select back color
     
    154155                        case 0x19: // SPACE
    155156                                // save configuration
    156                                 r = pf_open(HXCSDFECFG);
    157                                 if (r) {
    158                                         my_puts("can't open cfg");
    159                                         printhex(r);
    160                                 }
     157                                pf_lseek(0);
    161158                                byteCount = 29;
    162                                 r = pf_write(secbuf, byteCount, &byteCount);
     159                                r = pf_write(confbuf, byteCount, &byteCount);
    163160                                if (r || byteCount != 29) {
    164161                                        my_puts("can't write cfg");
    165162                                        printhex(r);
     163                                        abort();
    166164                                }
    167165                                r = pf_write(0, 0, &byteCount); // flush sector
     
    169167                                        my_puts("can't close cfg");
    170168                                        printhex(r);
     169                                        abort();
    171170                                }
    172171                                // fall through
     172                do {
     173                        asm("SWI \t    \t;\n"
     174                                ".fcb \t0x0A\t;GETC\n");
     175                } while(KEY == 0);
    173176                        case 0x10: // LEFT
    174177                                // Quit (without saving)
    175178                                return;
    176                                 break;
    177179
    178180                        case 0x18: // DOWN
     
    184186                                // decrease current option value
    185187                                if(options[selected].type)
    186                                         --*(secbuf+options[selected].off);
     188                                        --*(confbuf+options[selected].off);
    187189                                else
    188                                         *(secbuf+options[selected].off) = 0;
     190                                        *(confbuf+options[selected].off) = 0;
    189191                                break;
    190192                        case 0x0B: // +
    191193                                if(options[selected].type)
    192                                         ++*(secbuf+options[selected].off);
     194                                        ++*(confbuf+options[selected].off);
    193195                                else
    194                                         *(secbuf+options[selected].off) = 0xFF;
     196                                        *(confbuf+options[selected].off) = 0xFF;
    195197                                break;
    196198                }
Note: See TracChangeset for help on using the changeset viewer.