Changeset 5475ecf in buchla-emu


Ignore:
Timestamp:
09/03/2017 10:37:08 AM (7 years ago)
Author:
Alexander Heinrich <alex.heinrich@…>
Branches:
master
Children:
f51359c
Parents:
43ea417 (diff), 4f967e8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of ssh://bob.lopatic.de:11501/home/git/buchla-emu into lcda

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • .cproject

    r43ea417 r5475ecf  
    6868                </scannerConfigBuildInfo>
    6969        </storageModule>
     70        <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
    7071</cproject>
  • .settings/language.settings.xml

    r43ea417 r5475ecf  
    66                        <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
    77                        <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
    8                         <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-1750853831677083752" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
     8                        <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="617322979982056114" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
    99                                <language-scope id="org.eclipse.cdt.core.gcc"/>
    1010                                <language-scope id="org.eclipse.cdt.core.g++"/>
  • emu/ser.c

    r43ea417 r5475ecf  
    6060};
    6161
    62 static uint8_t mem[CON_H][CON_W + 1];
     62static uint8_t mem[CON_H][CON_W];
    6363
    6464static SDL_Window *win;
     
    8181static void scroll(void)
    8282{
    83         memmove(mem, mem + 1, (CON_H - 1) * (CON_W + 1));
     83        memmove(mem, mem + 1, (CON_H - 1) * CON_W);
    8484        memset(mem + (CON_H - 1), ' ', CON_W);
    8585}
     
    256256        for (int32_t y = 0; y < CON_H; ++y) {
    257257                char line[CON_W + 1];
     258                line[CON_W] = 0;
    258259
    259260                if (SDL_LockMutex(cpu_mutex) < 0) {
     
    261262                }
    262263
    263                 memcpy(line, mem[y], CON_W + 1);
     264                memcpy(line, mem[y], CON_W);
    264265
    265266                if (SDL_UnlockMutex(cpu_mutex) < 0) {
     
    515516                        mem[y][x] = ' ';
    516517                }
    517 
    518                 mem[y][CON_W] = 0;
    519518        }
    520519}
  • emu/vid.c

    r43ea417 r5475ecf  
    3434#define REG_ODTBA 7
    3535#define REG_ATBA 8
     36#define REG_CGBA 10
    3637#define REG_ATBAC 11
    3738
     
    4849#define OD0_BLA 0x0010
    4950#define OD0_CB 0x0800
     51
     52#define AT_CG 0x8000
    5053
    5154#define WIN_SZ_W 0x10000
     
    6366        uint16_t *mem;
    6467        bool tran;
    65 } bm_obj_t;
     68        int32_t fon_h;
     69} obj_t;
    6670
    6771static int32_t reg_off = REG_OFF;
     
    7276static uint32_t pal[16];
    7377
    74 static bm_obj_t bm_objs[16];
    75 static int32_t n_bm_objs = 0;
     78static obj_t objs[16];
     79static int32_t n_objs = 0;
    7680
    7781static SDL_Window *win;
     
    8084static SDL_atomic_t frame;
    8185
     86static void rend_bm(uint16_t *vid, int32_t w, int32_t h, uint32_t *pix, int32_t pitch)
     87{
     88        for (int32_t y = 0; y < h; ++y) {
     89                for (int32_t x = 0; x < w / 4; ++x) {
     90                        uint16_t v4 = *vid++;
     91
     92                        *pix++ = pal[(v4 & 0x000f) >>  0];
     93                        *pix++ = pal[(v4 & 0x00f0) >>  4];
     94                        *pix++ = pal[(v4 & 0x0f00) >>  8];
     95                        *pix++ = pal[(v4 & 0xf000) >> 12];
     96                }
     97
     98                pix += pitch / 4 - w;
     99        }
     100}
     101
     102static void rend_tx(uint16_t *vid, int32_t w, int32_t h, int32_t fon_h,
     103                uint32_t *pix, int32_t pitch)
     104{
     105        int32_t cgba = mem[REG_CGBA];
     106
     107        uint16_t *cg0 = mem + ((cgba & 0x00f0) <<  8);
     108        uint16_t *cg1 = mem + ((cgba & 0x000f) << 12);
     109
     110        int32_t line = fon_h - 1;
     111
     112        for (int32_t y = 0; y < h; ++y) {
     113                uint16_t *walk = vid;
     114
     115                for (int32_t col2 = 0; col2 < w / 16; ++col2) {
     116                        uint16_t ch2 = *walk++;
     117
     118                        for (int32_t i = 0; i < 2; ++i) {
     119                                int32_t ch = (uint8_t)ch2;
     120                                int32_t at = *walk++;
     121
     122                                int32_t bg = at & 0x000f;
     123                                int32_t fg = (at & 0x00f0) >> 4;
     124
     125                                uint16_t *cg = (at & AT_CG) != 0 ? cg0 : cg1;
     126                                int32_t bits = cg[256 * line + ch];
     127                                int32_t mask = 0x01;
     128
     129                                for (int32_t k = 0; k < 8; ++k) {
     130                                        *pix++ = (bits & mask) != 0 ? pal[fg] : pal[bg];
     131                                        mask <<= 1;
     132                                }
     133
     134                                ch2 >>= 8;
     135                        }
     136                }
     137
     138                if (--line < 0) {
     139                        line = fon_h - 1;
     140                        vid = walk;
     141                }
     142
     143                pix += pitch / 4 - w;
     144        }
     145}
     146
    82147void vid_sdl(void)
    83148{
     
    98163        }
    99164
    100         void *buf;
    101         int32_t pitch;
    102 
    103165        if (SDL_LockMutex(cpu_mutex) < 0) {
    104166                fail("SDL_LockMutex() failed: %s", SDL_GetError());
    105167        }
    106168
    107         for (int32_t i = 0; i < n_bm_objs; ++i) {
    108                 bm_obj_t *bm_obj = bm_objs + i;
    109 
    110                 pal[0] = bm_obj->tran ? pal[0] & 0xffffff00 : pal[0] | 0x000000ff;
     169        for (int32_t i = 0; i < n_objs; ++i) {
     170                obj_t *obj = objs + i;
     171
     172                pal[0] = obj->tran ? pal[0] & 0xffffff00 : pal[0] | 0x000000ff;
    111173
    112174                SDL_Rect src = {
    113                         .x = 0, .y = 0, .w = bm_obj->w, .h = bm_obj->h
     175                        .x = 0, .y = 0, .w = obj->w, .h = obj->h
    114176                };
     177
     178                void *buf;
     179                int32_t pitch;
    115180
    116181                if (SDL_LockTexture(tex, &src, &buf, &pitch) < 0) {
     
    118183                }
    119184
    120                 uint32_t *pix = buf;
    121                 uint16_t *vid = bm_obj->mem;
    122 
    123                 for (int32_t y = 0; y < src.h; ++y) {
    124                         for (int32_t x = 0; x < src.w / 4; ++x) {
    125                                 uint16_t v4 = *vid++;
    126 
    127                                 *pix++ = pal[(v4 & 0x000f) >>  0];
    128                                 *pix++ = pal[(v4 & 0x00f0) >>  4];
    129                                 *pix++ = pal[(v4 & 0x0f00) >>  8];
    130                                 *pix++ = pal[(v4 & 0xf000) >> 12];
    131                         }
    132 
    133                         pix += pitch / 4 - src.w;
     185                if (obj->fon_h < 0) {
     186                        rend_bm(obj->mem, obj->w, obj->h, buf, pitch);
     187                }
     188                else {
     189                        rend_tx(obj->mem, obj->w, obj->h, obj->fon_h, buf, pitch);
    134190                }
    135191
     
    137193
    138194                SDL_Rect dst = {
    139                         .x = SCALE(bm_obj->x), .y = SCALE(bm_obj->y),
    140                         .w = SCALE(bm_obj->w), .h = SCALE(bm_obj->h)
     195                        .x = SCALE(obj->x), .y = SCALE(obj->y),
     196                        .w = SCALE(obj->w), .h = SCALE(obj->h)
    141197                };
    142198
    143199                ver2("vid rend %d %dx%d -> (%d, %d) (%d, %d) %dx%d",
    144200                                i,
    145                                 bm_obj->w, bm_obj->h,
    146                                 bm_obj->x, bm_obj->y,
    147                                 SCALE(bm_obj->x), SCALE(bm_obj->y),
    148                                 SCALE(bm_obj->w), SCALE(bm_obj->h));
     201                                obj->w, obj->h,
     202                                obj->x, obj->y,
     203                                SCALE(obj->x), SCALE(obj->y),
     204                                SCALE(obj->w), SCALE(obj->h));
    149205
    150206                if (SDL_RenderCopy(ren, tex, &src, &dst) < 0) {
     
    250306        int32_t odtba = mem[REG_ODTBA] & 0xffc0;
    251307
    252         n_bm_objs = 0;
     308        n_objs = 0;
    253309
    254310        for (int32_t i = 0; i < 16; ++i) {
     
    263319                }
    264320
    265                 int32_t w = (od[1] & 0xfc00) >> 6;
    266 
    267                 if (w == 0) {
     321                int32_t w64 = (od[1] & 0xfc00) >> 10;
     322
     323                if (w64 == 0) {
    268324                        ver3("vid obj %d empty", i);
    269325                        continue;
     
    293349
    294350                int32_t x = (od[1] & 0x03ff) * 2;
    295                 int32_t off = ((od[0] & 0x00c0) << 10) | od[2];
     351                int32_t off, fon_h, w;
     352
     353                if (cb) {
     354                        off = od[2];
     355                        int32_t vcr1 = mem[REG_VCR1];
     356                        fon_h = (vcr1 & 0xf000) >> 12;
     357                        w = w64 * 4 / 3 * 2 * 8;
     358                }
     359                else {
     360                        off = ((od[0] & 0x00c0) << 10) | od[2];
     361                        fon_h = -1;
     362                        w = w64 * 16;
     363                }
     364
     365                obj_t *obj = objs + n_objs;
     366
     367                obj->x = x;
     368                obj->y = flips[0];
     369                obj->w = w;
     370                obj->h = flips[1] - flips[0];
     371                obj->mem = mem + off;
     372                obj->tran = tde;
     373                obj->fon_h = fon_h;
    296374
    297375                ver2("vid obj %d %c %c %d:%d %d+%d 0x%05x",
    298376                                i, cb ? 'c' : 'b', tde ? 't' : '-', flips[0], flips[1], x, w, off);
    299377
    300                 if (!cb) {
    301                         bm_obj_t *bm_obj = bm_objs + n_bm_objs;
    302 
    303                         bm_obj->x = x;
    304                         bm_obj->y = flips[0];
    305                         bm_obj->w = w;
    306                         bm_obj->h = flips[1] - flips[0];
    307                         bm_obj->mem = mem + off;
    308                         bm_obj->tran = tde;
    309 
    310                         ++n_bm_objs;
    311                 }
    312                 else {
    313                         int32_t vcr1 = mem[REG_VCR1];
    314                         int32_t fon_h = (vcr1 & 0xf000) >> 12;
    315                 }
     378                ++n_objs;
    316379        }
    317380
Note: See TracChangeset for help on using the changeset viewer.