Changeset ee447bf in thomson


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

Location:
code/C/HxCHost
Files:
3 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                }
  • code/C/HxCHost/pff/diskio.c

    r1b74fa2 ree447bf  
    106106        if (!buff) {
    107107                if (sc) {
    108                         mon_putc('A');
    109108                        // Initiate write process
    110109                        prevsec = sc;
    111110                        ptr = 0;
    112111                } else {
    113                         mon_putc('C');
    114                         mon_putc(' ');
    115                         printhex(ptr);
    116112                        // Called with both param = 0 - flush buffer to disk
    117113                        // First make sure it's zero-filled
     
    124120                        map_sector(prevsec, 0xA5);
    125121
    126                         for(int j = 0; j < 40; j++)
    127                                 printhex(*(char*)(wrbuf + j));
    128 
    129122                        write(255,1,wrbuf);
    130123                }
    131124        } else {
    132                 mon_putc('B');
    133125                // Here SC is a bytecount. copy that much bytes to the buffer
    134126                for(int j = 0; j <sc;++j)
  • code/C/HxCHost/pff/pff.h

    r1b74fa2 ree447bf  
    3131#define _USE_DIR        1       /* 1:Enable pf_opendir() and pf_readdir() */
    3232
    33 #define _USE_LSEEK      0       /* 1:Enable pf_lseek() */
     33#define _USE_LSEEK      1       /* 1:Enable pf_lseek() */
    3434
    3535#define _USE_WRITE      1       /* 1:Enable pf_write() */
Note: See TracChangeset for help on using the changeset viewer.