Changeset 7cabd49 in thomson


Ignore:
Timestamp:
Mar 19, 2012, 7:51:49 AM (12 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
fe55aa5
Parents:
cc8f3af
Message:

HxC host software : work at Forever XIII party

  • Switch to lwtools gcc toolchain
  • Fix some bugs.
  • Editing the HxC settings works
  • Selecting a floppy image works (sometimes)

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

Location:
code/C/HxCHost
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/C/HxCHost/Makefile

    rcc8f3af r7cabd49  
    55ifeq ($(TARGET),TO8)
    66  CFLAGS += -DPLATFORM=8
    7 endif
    8 
     7else
    98ifeq ($(TARGET),MO5)
    109  CFLAGS += -DPLATFORM=5
     10else
     11# No target defined. Fail.
     12all:
     13        echo "make TARGET=MO5 or make TARGET=TO8"
     14        false
     15endif
    1116endif
    1217
    1318# System settings -----------------------------------------------
    14 CC=m6809-thomson-none-gcc
    15 AS=m6809-thomson-none-as
     19PREFIX=m6809-thomson
     20CC=$(PREFIX)-gcc
     21AS=$(PREFIX)-as
    1622
    1723# Generic rules -------------------------------------------------
     
    1925out_sap.hfe: out.sap
    2026        hxcfloppyemulator_convert out.sap -HFE
     27        cp out_sap.hfe /mo5/MO5/
     28        unmount /mo5
     29        rm -r /mo5
    2130
    2231# Disk Image
     
    2635
    2736# Linking
    28 TEST.BIN: $(OBJECTS)
    29         $(CC) -Os $(OBJECTS) -o TEST.BIN -Wl,--map -Wl,-Ttext,0x6100 -nostdlib -lgcc
     37TEST.BIN TEST.map: $(OBJECTS) TEST.script
     38        #$(CC) -v -Os $(OBJECTS) -o TEST.BIN -Wl,--map -Wl,-m -Wl,-Ttext,0x6100 -nostdlib -lgcc
     39        lwlink --decb $(OBJECTS) --output=TEST.BIN --map=TEST.map --script=TEST.script --library-path=/boot/home/config/lib/gcc/m6809-thomson/4.6.1 --library-path=/boot/home/config/m6809-thomson/lib -lgcc
    3040
    3141#Compiling
    3242obj/$(TARGET)/%.o: %.c obj/$(TARGET)
    33         $(CC) $(CFLAGS) -c $< -o $@
     43        $(CC) -save-temps $(CFLAGS) -c $< -o $@
    3444
    3545obj/$(TARGET)/%.o: pff/%.c obj/$(TARGET)
  • code/C/HxCHost/macros.h

    rcc8f3af r7cabd49  
    44        #error "make TARGET=TO8 or make TARGET=MO5"
    55#endif
     6
     7#define FCB "fcb"
    68
    79///////////////////////////////////////
     
    4042        /* MONITOR ENTRY POINTS */
    4143        #define mon_putc(car) { \
    42         asm("swi \t  \t; MO5 monitor\n"\
    43                     ".fcb \t2 \t; putc"\
     44        asm(" swi \n"\
     45                    " fcb 2"\
    4446                        ::"B" ((unsigned char) (car))\
    4547                ); \
     
    5355                DKBUF = (unsigned int)buffer;\
    5456\
    55         asm("swi \t  \t; MO5 monitor\n"\
    56                     ".fcb \t0x26 \t; DKCONT"\
     57        asm(" swi \n"\
     58                    " fcb 0x26"\
    5759                        ); \
    5860        }
     
    6870                DKBUF = (unsigned int)output;
    6971
    70         asm("swi \t  \t; MO5 monitor\n"
    71                     ".fcb \t0x26 \t; DKCONT"
     72        asm(" swi \n"
     73                    " fcb 0x26"
    7274                        );
    7375
  • code/C/HxCHost/main.c

    rcc8f3af r7cabd49  
    99void asm_write();
    1010
    11 #if PLATFORM == 5
    12         #define DIRECTORY_BUFFER (FILINFO*)0x3000
    13 #else
    14         // Thomson TO8 code
    15         #define DIRECTORY_BUFFER (FILINFO*)0xA000
    16 #endif
     11FILINFO DIRECTORY_BUFFER[23];
    1712
    1813unsigned char mark[512 + 16] = "HxCFEDA";
     
    10297        {"\x1B\x50\x0CHxC floppy emulator setup\r\n"
    10398        "UP/DOWN move - +/- change\r\n"
    104         "space save - left quit\r\n"
     99        "space save - left quit\r\n\n"
    105100                 "Step sound       ", 16, 0},
    106101        {"\r\nGUI sound        ", 17, 0},
     
    112107};
    113108
     109#define getcfg(off) *(char*)((int)confbuf+off)
     110#define putcfg(off, val) *(char*)((int)confbuf+off) = val
     111
    114112inline static void config()
    115113{
    116         unsigned char* confbuf[29];
     114        char confbuf[29];
    117115        // If it's HXCSDFE.CFG, enter config mode
    118116        // Read the config part of the file
     
    121119        if (r != 0 || byteCount != 29)
    122120        {
    123                 my_puts("read error");
     121                my_puts("read error ");
     122                printhex(r);
    124123                abort();
    125124        }
     
    133132                        mon_putc(selected == j ? 0x54: 0x50) // Blue
    134133                        if(options[j].type)
    135                                 printhex(*(confbuf+options[j].off));
     134                                printhex(getcfg(options[j].off));
    136135                        else
    137                                 my_puts(*(confbuf+options[j].off) ? "ON":"OFF");
     136                                my_puts(getcfg(options[j].off) ? "ON":"OFF");
    138137                        mon_putc(0x1B); // Select back color
    139138                        mon_putc(0x50); // Select back color
     
    141140
    142141                do {
    143                         asm("SWI \t    \t;\n"
    144                                 ".fcb \t0x0A\t;GETC\n");
     142                        asm(" SWI\n"
     143                                " FCB 0x0A\n");
    145144                } while(KEY == 0);
    146145
     
    170169                                }
    171170                                // fall through
    172                 do {
    173                         asm("SWI \t    \t;\n"
    174                                 ".fcb \t0x0A\t;GETC\n");
    175                 } while(KEY == 0);
    176171                        case 0x10: // LEFT
    177172                                // Quit (without saving)
     
    180175                        case 0x18: // DOWN
    181176                                // select previous file
    182                                 if (++selected > 7) selected = 7;
     177                                if (++selected > 6) selected = 6;
    183178                                // TODO previous page ?
    184179                                break;
     
    186181                                // decrease current option value
    187182                                if(options[selected].type)
    188                                         --*(confbuf+options[selected].off);
     183                                        --*(char*)((int)confbuf+options[selected].off);
    189184                                else
    190                                         *(confbuf+options[selected].off) = 0;
     185                                        putcfg(options[selected].off, 0);
    191186                                break;
    192187                        case 0x0B: // +
    193188                                if(options[selected].type)
    194                                         ++*(confbuf+options[selected].off);
     189                                        ++*(char*)((int)confbuf+options[selected].off);
    195190                                else
    196                                         *(confbuf+options[selected].off) = 0xFF;
     191                                        putcfg(options[selected].off, 0xFF);
    197192                                break;
    198193                }
     
    211206        FATFS fs;
    212207        FRESULT r = pf_mount(&fs);
     208
    213209        if (r != 0) {
    214210                my_puts("mount error ");
     
    265261                // Allow the user to select a file
    266262                do {
    267                         asm("SWI \t    \t;\n"
    268                                 ".fcb \t0x0A\t;GETC\n");
     263                        asm(" SWI \n"
     264                                " fcb 0x0A\n");
    269265                } while(KEY == 0);
    270266
     
    300296                                } else {
    301297                                        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                                         }
    308298                                        if (*(long*)(fp->fname) == *(long*)(cmp)
    309299                                                && *(long*)(fp->fname + 4) == *(long*)(cmp+4)
     
    311301                                        )
    312302                                        {
     303                                                FRESULT res = pf_open(cmp);
     304                                                if (res) {
     305                                                        my_puts("Can't open CFG file: ");
     306                                                        printhex(res);
     307                                                        exit(0);
     308                                                }
    313309                                                config();
    314310                                        } else {
     
    316312                                                // If it's an HFE file, load it in HxCSDFE.CFG, then reboot
    317313                                               
     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
    318339                                                // reboot
    319                                                 exit(0);
     340                                                asm(" SWI\n"
     341                                                        " FCB 0");
    320342                                        }
    321343                                }
  • code/C/HxCHost/pff/diskio.c

    rcc8f3af r7cabd49  
    9696
    9797DRESULT disk_writep (
    98         const BYTE* buff,/* Pointer to the data to be written, NULL:Initiate/Finalize write operation */
     98        const BYTE* buff,
     99        /* Pointer to the data to be written,
     100         * NULL:Initiate/Finalize write operation */
    99101        DWORD sc                /* Sector number (LBA) or Number of bytes to send */
    100102)
    101103{
    102104        static WORD ptr;
    103         static char* wrbuf[256];
     105        static char wrbuf[256];
    104106                // Separate buffer because we need to use map_sector, and it kills secbuf
    105107
     
    114116                        for(;ptr < 512; ++ptr)
    115117                        {
    116                                 *(wrbuf + ptr) = 0;
     118                                wrbuf[ptr] = 0;
    117119                        }
    118120
     
    126128                for(int j = 0; j <sc;++j)
    127129                {
    128                 *(char*)(wrbuf+ptr) = *(char*)(ptr++ + buff);
     130                wrbuf[ptr] = *(char*)(j+buff);
     131                        ++ptr;
    129132                }
     133        mon_putc(' ');
    130134        }
    131135
Note: See TracChangeset for help on using the changeset viewer.