diff --git a/src/devices/cdrom/cdrom_dosbox.cpp b/src/devices/cdrom/cdrom_dosbox.cpp index 1ff8ab6..c2ebc90 100644 --- a/src/devices/cdrom/cdrom_dosbox.cpp +++ b/src/devices/cdrom/cdrom_dosbox.cpp @@ -15,7 +15,7 @@ * **NOTE** This code will very soon be replaced with a C variant, so * no more changes will be done. * - * Version: @(#)cdrom_dosbox.cpp 1.0.11 2019/03/05 + * Version: @(#)cdrom_dosbox.cpp 1.0.12 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -223,7 +223,7 @@ CDROM_Interface_Image::GetMediaTrayStatus(bool& mediaPresent, bool& mediaChanged bool -CDROM_Interface_Image::ReadSectors(PhysPt buffer, bool raw, uint32_t sector, uint32_t num) +CDROM_Interface_Image::ReadSectors(size_t buffer, bool raw, uint32_t sector, uint32_t num) { int sectorSize = raw ? RAW_SECTOR_SIZE : COOKED_SECTOR_SIZE; uint8_t buflen = num * sectorSize; @@ -369,6 +369,7 @@ CDROM_Interface_Image::IsoLoadFile(const wchar_t *filename) // data track Track track = {0, 0, 0, 0, 0, 0, 0, 0, false, NULL}; bool error; + track.file = new BinaryFile(filename, error); if (error) { delete track.file; @@ -488,6 +489,7 @@ CDROM_Interface_Image::CueGetString(string &dest, char **line) } +/* Get a keyword from the input line, handling uppercasing. */ bool CDROM_Interface_Image::CueGetKeyword(string &dest, char **line) { @@ -502,39 +504,39 @@ CDROM_Interface_Image::CueGetKeyword(string &dest, char **line) } -/* Get a string from the input line, handling quotes properly. */ -uint64_t -CDROM_Interface_Image::CueGetNumber(char **line) +/* Get a number from the input line. */ +bool +CDROM_Interface_Image::CueGetNumber(int &arg, char **line) { char temp[128]; - uint64_t num; + bool success; + int num = 0; - if (! CueGetBuffer(temp, line, false)) - return 0; + success = CueGetBuffer(temp, line, false); + if (success) + success = (sscanf(temp, "%i", &num) == 1); - if (sscanf(temp, "%" PRIu64, &num) != 1) - return 0; + arg = num; - return num; + return success; } +/* Get a frame ID from the input line. */ bool -CDROM_Interface_Image::CueGetFrame(uint64_t &frames, char **line) +CDROM_Interface_Image::CueGetFrame(uint64_t &arg, char **line) { char temp[128]; int min, sec, fr; bool success; success = CueGetBuffer(temp, line, false); - if (! success) return false; + if (success) + success = (sscanf(temp, "%d:%d:%d", &min, &sec, &fr) == 3); - success = sscanf(temp, "%d:%d:%d", &min, &sec, &fr) == 3; - if (! success) return false; + arg = MSF_TO_FRAMES(min, sec, fr); - frames = MSF_TO_FRAMES(min, sec, fr); - - return true; + return success; } @@ -543,10 +545,14 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) { Track track = {0, 0, 0, 0, 0, 0, 0, 0, false, NULL}; wchar_t pathname[MAX_FILENAME_LENGTH]; + char buf[MAX_LINE_LENGTH], *line; uint64_t shift = 0; uint64_t currPregap = 0; uint64_t totalPregap = 0; uint64_t prestart = 0; + uint64_t frame; + int index; + string command, type; bool canAddTrack = false; bool success; FILE *fp; @@ -564,15 +570,13 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) success = false; for (;;) { - char buf[MAX_LINE_LENGTH]; - char *line = buf; + line = buf; /* Read a line from the cuesheet file. */ - if (fgets(buf, sizeof(buf), fp) == NULL || ferror(fp) || feof(fp)) + if (fgets(line, sizeof(buf), fp) == NULL || ferror(fp) || feof(fp)) break; - buf[strlen(buf) - 1] = '\0'; /* nuke trailing newline */ + buf[strlen(line) - 1] = '\0'; /* nuke trailing newline */ - string command; success = CueGetKeyword(command, &line); if (command == "TRACK") { @@ -580,20 +584,21 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) success = AddTrack(track, shift, prestart, totalPregap, currPregap); else success = true; + if (! success) break; + success = CueGetNumber(track.number, &line); + if (! success) break; + + track.track_number = track.number; track.start = 0; track.skip = 0; + track.form = 0; currPregap = 0; prestart = 0; - track.number = (int)CueGetNumber(&line); - track.track_number = track.number; - string type; success = CueGetKeyword(type, &line); if (! success) break; - track.form = 0; - if (type == "AUDIO") { track.sectorSize = RAW_SECTOR_SIZE; track.attr = AUDIO_TRACK; @@ -642,9 +647,11 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) canAddTrack = true; } else if (command == "INDEX") { - uint64_t frame, index; - index = CueGetNumber(&line); + success = CueGetNumber(index, &line); + if (! success) break; + success = CueGetFrame(frame, &line); + if (! success) break; switch(index) { case 0: @@ -664,11 +671,12 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) success = AddTrack(track, shift, prestart, totalPregap, currPregap); else success = true; + if (! success) break; + canAddTrack = false; char ansi[MAX_FILENAME_LENGTH]; wchar_t filename[MAX_FILENAME_LENGTH]; - string type; success = CueGetBuffer(ansi, &line, false); if (! success) break; diff --git a/src/devices/cdrom/cdrom_dosbox.h b/src/devices/cdrom/cdrom_dosbox.h index 9c095ca..8f1c525 100644 --- a/src/devices/cdrom/cdrom_dosbox.h +++ b/src/devices/cdrom/cdrom_dosbox.h @@ -8,7 +8,7 @@ * * Definitions for the CD-ROM image file handling module. * - * Version: @(#)cdrom_dosbox.h 1.0.3 2019/03/05 + * Version: @(#)cdrom_dosbox.h 1.0.4 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -47,16 +47,6 @@ #include #include -//typedef signed int Bits; -//typedef unsigned int Bitu; -//typedef int8_t Bit8s; -//typedef int16_t Bit16s; -//typedef uint16_t Bit16u; -//typedef int32_t Bit32s; -//typedef uint32_t Bit32u; - -typedef size_t PhysPt; - #define RAW_SECTOR_SIZE 2352 #define COOKED_SECTOR_SIZE 2048 @@ -103,7 +93,7 @@ public: virtual bool GetAudioSub(int sector, uint8_t& attr, uint8_t& track, uint8_t& index, TMSF& relPos, TMSF& absPos) = 0; virtual bool GetMediaTrayStatus(bool& mediaPresent, bool& mediaChanged, bool& trayOpen) = 0; - virtual bool ReadSectors(PhysPt buffer, bool raw, uint32_t sector, uint32_t num) = 0; + virtual bool ReadSectors(size_t buffer, bool raw, uint32_t sector, uint32_t num) = 0; virtual bool LoadUnloadMedia(bool unload) = 0; @@ -155,7 +145,7 @@ public: bool GetAudioTrackInfo(int track, int& number, TMSF& start, uint8_t& attr); bool GetAudioSub(int sector, uint8_t& attr, uint8_t& track, uint8_t& index, TMSF& relPos, TMSF& absPos); bool GetMediaTrayStatus(bool& mediaPresent, bool& mediaChanged, bool& trayOpen); - bool ReadSectors(PhysPt buffer, bool raw, uint32_t sector, uint32_t num); + bool ReadSectors(size_t buffer, bool raw, uint32_t sector, uint32_t num); bool LoadUnloadMedia(bool unload); bool ReadSector(uint8_t *buffer, bool raw, uint32_t sector); bool ReadSectorSub(uint8_t *buffer, uint32_t sector); @@ -179,7 +169,7 @@ private: bool CueGetBuffer(char *str, char **line, bool up); bool CueGetString(std::string &str, char **line); bool CueGetKeyword(std::string &keyword, char **line); - uint64_t CueGetNumber(char **line); + bool CueGetNumber(int &number, char **line); bool CueGetFrame(uint64_t &frames, char **line); bool CueLoadSheet(const wchar_t *cuefile); bool AddTrack(Track &curr, uint64_t &shift, uint64_t prestart, uint64_t &totalPregap, uint64_t currPregap); diff --git a/src/devices/video/vid_ati_mach64.c b/src/devices/video/vid_ati_mach64.c index c58b4b8..ef89211 100644 --- a/src/devices/video/vid_ati_mach64.c +++ b/src/devices/video/vid_ati_mach64.c @@ -8,7 +8,7 @@ * * ATi Mach64 graphics card emulation. * - * Version: @(#)vid_ati_mach64.c 1.0.15 2019/03/03 + * Version: @(#)vid_ati_mach64.c 1.0.16 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -2811,17 +2811,17 @@ void mach64_hwcursor_draw(svga_t *svga, int disp_line) for (x = 0; x < 64 - svga->hwcursor_latch.xoff; x += 4) { dat = svga->vram[svga->hwcursor_latch.addr + (offset >> 2)]; - if (!(dat & 2)) ((uint32_t *)buffer32->line[disp_line + y_add])[svga->hwcursor_latch.x + x + 32 + x_add] = (dat & 1) ? col1 : col0; - else if ((dat & 3) == 3) ((uint32_t *)buffer32->line[disp_line + y_add])[svga->hwcursor_latch.x + x + 32 + x_add] ^= 0xFFFFFF; + if (!(dat & 2)) screen->line[disp_line + y_add][svga->hwcursor_latch.x + x + 32 + x_add].val = (dat & 1) ? col1 : col0; + else if ((dat & 3) == 3) screen->line[disp_line + y_add][svga->hwcursor_latch.x + x + 32 + x_add].val ^= 0xFFFFFF; dat >>= 2; - if (!(dat & 2)) ((uint32_t *)buffer32->line[disp_line + y_add])[svga->hwcursor_latch.x + x + 33 + x_add] = (dat & 1) ? col1 : col0; - else if ((dat & 3) == 3) ((uint32_t *)buffer32->line[disp_line + y_add])[svga->hwcursor_latch.x + x + 33 + x_add] ^= 0xFFFFFF; + if (!(dat & 2)) screen->line[disp_line + y_add][svga->hwcursor_latch.x + x + 33 + x_add].val = (dat & 1) ? col1 : col0; + else if ((dat & 3) == 3) screen->line[disp_line + y_add][svga->hwcursor_latch.x + x + 33 + x_add].val ^= 0xFFFFFF; dat >>= 2; - if (!(dat & 2)) ((uint32_t *)buffer32->line[disp_line + y_add])[svga->hwcursor_latch.x + x + 34 + x_add] = (dat & 1) ? col1 : col0; - else if ((dat & 3) == 3) ((uint32_t *)buffer32->line[disp_line + y_add])[svga->hwcursor_latch.x + x + 34 + x_add] ^= 0xFFFFFF; + if (!(dat & 2)) screen->line[disp_line + y_add][svga->hwcursor_latch.x + x + 34 + x_add].val = (dat & 1) ? col1 : col0; + else if ((dat & 3) == 3) screen->line[disp_line + y_add][svga->hwcursor_latch.x + x + 34 + x_add].val ^= 0xFFFFFF; dat >>= 2; - if (!(dat & 2)) ((uint32_t *)buffer32->line[disp_line + y_add])[svga->hwcursor_latch.x + x + 35 + x_add] = (dat & 1) ? col1 : col0; - else if ((dat & 3) == 3) ((uint32_t *)buffer32->line[disp_line + y_add])[svga->hwcursor_latch.x + x + 35 + x_add] ^= 0xFFFFFF; + if (!(dat & 2)) screen->line[disp_line + y_add][svga->hwcursor_latch.x + x + 35 + x_add].val = (dat & 1) ? col1 : col0; + else if ((dat & 3) == 3) screen->line[disp_line + y_add][svga->hwcursor_latch.x + x + 35 + x_add].val ^= 0xFFFFFF; dat >>= 2; offset += 4; } @@ -2972,7 +2972,7 @@ void mach64_overlay_draw(svga_t *svga, int disp_line) int h_inc = mach64->overlay_scale_inc >> 16; int v_max = mach64->scaler_height_width & 0x3ff; int v_inc = mach64->overlay_scale_inc & 0xffff; - uint32_t *p; + pel_t *p; uint8_t *src = &svga->vram[svga->overlay.addr]; int old_y = mach64->overlay_v_acc; int y_diff; @@ -2980,7 +2980,7 @@ void mach64_overlay_draw(svga_t *svga, int disp_line) int graphics_key_fn = (mach64->overlay_key_cntl >> 4) & 5; int overlay_cmp_mix = (mach64->overlay_key_cntl >> 8) & 0xf; - p = &((uint32_t *)buffer32->line[disp_line])[32 + mach64->svga.overlay_latch.x]; + p = &screen->line[disp_line][32 + mach64->svga.overlay_latch.x]; if (mach64->scaler_update) { @@ -3017,7 +3017,7 @@ void mach64_overlay_draw(svga_t *svga, int disp_line) { int h = h_acc >> 12; - p[x] = mach64->overlay_dat[h]; + p[x].val = mach64->overlay_dat[h]; h_acc += h_inc; if (h_acc > (h_max << 12)) @@ -3043,8 +3043,8 @@ void mach64_overlay_draw(svga_t *svga, int disp_line) { case 0: gr_cmp = 0; break; case 1: gr_cmp = 1; break; - case 4: gr_cmp = (((p[x]) ^ mach64->overlay_graphics_key_clr) & mach64->overlay_graphics_key_msk & 0xffffff); break; - case 5: gr_cmp = !(((p[x]) ^ mach64->overlay_graphics_key_clr) & mach64->overlay_graphics_key_msk & 0xffffff); break; + case 4: gr_cmp = (((p[x].val) ^ mach64->overlay_graphics_key_clr) & mach64->overlay_graphics_key_msk & 0xffffff); break; + case 5: gr_cmp = !(((p[x].val) ^ mach64->overlay_graphics_key_clr) & mach64->overlay_graphics_key_msk & 0xffffff); break; } vid_cmp = vid_cmp ? -1 : 0; gr_cmp = gr_cmp ? -1 : 0; @@ -3070,7 +3070,7 @@ void mach64_overlay_draw(svga_t *svga, int disp_line) } if (use_video) - p[x] = mach64->overlay_dat[h]; + p[x].val = mach64->overlay_dat[h]; h_acc += h_inc; if (h_acc > (h_max << 12)) diff --git a/src/devices/video/vid_bt48x_ramdac.c b/src/devices/video/vid_bt48x_ramdac.c index ccf0a93..76cf451 100644 --- a/src/devices/video/vid_bt48x_ramdac.c +++ b/src/devices/video/vid_bt48x_ramdac.c @@ -8,7 +8,7 @@ * * Brooktree Bt48x series true color RAMDAC emulation. * - * Version: @(#)vid_bt48x_ramdac.c 1.0.10 2019/02/10 + * Version: @(#)vid_bt48x_ramdac.c 1.0.11 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -388,8 +388,9 @@ bt48x_hwcursor_draw(svga_t *svga, int displine) int offset = svga->hwcursor_latch.x - svga->hwcursor_latch.xoff; int y_add, x_add; int pitch, bppl, mode, x_pos, y_pos; - uint32_t clr1, clr2, clr3, *p; + uint32_t clr1, clr2, clr3; uint8_t *cd; + pel_t *p; clr1 = dev->extpallook[1]; clr2 = dev->extpallook[2]; @@ -428,22 +429,22 @@ bt48x_hwcursor_draw(svga_t *svga, int displine) y_pos = displine + y_add; x_pos = offset + 32 + x_add; - p = ((uint32_t *)buffer32->line[y_pos]); + p = &screen->line[y_pos][0]; if (offset >= svga->hwcursor_latch.x) { switch (mode) { case 1: /* Three Color */ switch (comb) { case 1: - p[x_pos] = clr1; + p[x_pos].val = clr1; break; case 2: - p[x_pos] = clr2; + p[x_pos].val = clr2; break; case 3: - p[x_pos] = clr3; + p[x_pos].val = clr3; break; } break; @@ -451,15 +452,15 @@ bt48x_hwcursor_draw(svga_t *svga, int displine) case 2: /* PM/Windows */ switch (comb) { case 0: - p[x_pos] = clr1; + p[x_pos].val = clr1; break; case 1: - p[x_pos] = clr2; + p[x_pos].val = clr2; break; case 3: - p[x_pos] ^= 0xffffff; + p[x_pos].val ^= 0xffffff; break; } break; @@ -467,11 +468,11 @@ bt48x_hwcursor_draw(svga_t *svga, int displine) case 3: /* X-Windows */ switch (comb) { case 2: - p[x_pos] = clr1; + p[x_pos].val = clr1; break; case 3: - p[x_pos] = clr2; + p[x_pos].val = clr2; break; } break; diff --git a/src/devices/video/vid_cga.c b/src/devices/video/vid_cga.c index b9eb4f8..572ec11 100644 --- a/src/devices/video/vid_cga.c +++ b/src/devices/video/vid_cga.c @@ -8,7 +8,7 @@ * * Emulation of the old and new IBM CGA graphics cards. * - * Version: @(#)vid_cga.c 1.0.13 2019/03/05 + * Version: @(#)vid_cga.c 1.0.14 2019/03/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -256,15 +256,15 @@ cga_read(uint32_t addr, void *priv) void -cga_hline(bitmap_t *b, int x1, int y, int x2, uint32_t col) +cga_hline(bitmap_t *b, int x1, int y, int x2, uint8_t col) { - if (y < 0 || y >= buffer->h) + int c; + + if (y < 0 || y >= b->h) return; - if (b == buffer) - memset(&b->line[y][x1], col, x2 - x1); - else - memset(&((uint32_t *)b->line[y])[x1], col, (x2 - x1) * 4); + for (c = 0; c < x2 - x1; c++) + b->line[y][x1].pal = col; } @@ -295,30 +295,30 @@ cga_poll(void *priv) if (dev->cgadispon) { if (dev->displine < dev->firstline) { dev->firstline = dev->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } dev->lastline = dev->displine; for (c = 0; c < 8; c++) { if ((dev->cgamode & 0x12) == 0x12) { - buffer->line[(dev->displine << 1)][c] = - buffer->line[(dev->displine << 1) + 1][c] = 0; + screen->line[(dev->displine << 1)][c].pal = + screen->line[(dev->displine << 1) + 1][c].pal = 0; if (dev->cgamode & 1) { - buffer->line[(dev->displine << 1)][c + (dev->crtc[1] << 3) + 8] = - buffer->line[(dev->displine << 1) + 1][c + (dev->crtc[1] << 3) + 8] = 0; + screen->line[(dev->displine << 1)][c + (dev->crtc[1] << 3) + 8].pal = + screen->line[(dev->displine << 1) + 1][c + (dev->crtc[1] << 3) + 8].pal = 0; } else { - buffer->line[(dev->displine << 1)][c + (dev->crtc[1] << 4) + 8] = - buffer->line[(dev->displine << 1) + 1][c + (dev->crtc[1] << 4) + 8] = 0; + screen->line[(dev->displine << 1)][c + (dev->crtc[1] << 4) + 8].pal = + screen->line[(dev->displine << 1) + 1][c + (dev->crtc[1] << 4) + 8].pal = 0; } } else { - buffer->line[(dev->displine << 1)][c] = - buffer->line[(dev->displine << 1) + 1][c] = (dev->cgacol & 15) + 16; + screen->line[(dev->displine << 1)][c].pal = + screen->line[(dev->displine << 1) + 1][c].pal = (dev->cgacol & 15) + 16; if (dev->cgamode & 1) { - buffer->line[(dev->displine << 1)][c + (dev->crtc[1] << 3) + 8] = - buffer->line[(dev->displine << 1) + 1][c + (dev->crtc[1] << 3) + 8] = (dev->cgacol & 15) + 16; + screen->line[(dev->displine << 1)][c + (dev->crtc[1] << 3) + 8].pal = + screen->line[(dev->displine << 1) + 1][c + (dev->crtc[1] << 3) + 8].pal = (dev->cgacol & 15) + 16; } else { - buffer->line[(dev->displine << 1)][c + (dev->crtc[1] << 4) + 8] = - buffer->line[(dev->displine << 1) + 1][c + (dev->crtc[1] << 4) + 8] = (dev->cgacol & 15) + 16; + screen->line[(dev->displine << 1)][c + (dev->crtc[1] << 4) + 8].pal = + screen->line[(dev->displine << 1) + 1][c + (dev->crtc[1] << 4) + 8].pal = (dev->cgacol & 15) + 16; } } } @@ -340,14 +340,14 @@ cga_poll(void *priv) cols[0] = (attr >> 4) + 16; if (drawcursor) { for (c = 0; c < 8; c++) { - buffer->line[(dev->displine << 1)][(x << 3) + c + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 3) + c + 8] = + screen->line[(dev->displine << 1)][(x << 3) + c + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 3) + c + 8].pal = cols[(fontdat[chr + dev->fontbase][dev->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } } else { for (c = 0; c < 8; c++) { - buffer->line[(dev->displine << 1)][(x << 3) + c + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 3) + c + 8] = + screen->line[(dev->displine << 1)][(x << 3) + c + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 3) + c + 8].pal = cols[(fontdat[chr + dev->fontbase][dev->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } } @@ -371,18 +371,18 @@ cga_poll(void *priv) dev->ma++; if (drawcursor) { for (c = 0; c < 8; c++) { - buffer->line[(dev->displine << 1)][(x << 4) + (c << 1) + 8] = - buffer->line[(dev->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = + screen->line[(dev->displine << 1)][(x << 4) + (c << 1) + 8].pal = + screen->line[(dev->displine << 1)][(x << 4) + (c << 1) + 1 + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdat[chr + dev->fontbase][dev->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } } else { for (c = 0; c < 8; c++) { - buffer->line[(dev->displine << 1)][(x << 4) + (c << 1) + 8] = - buffer->line[(dev->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = + screen->line[(dev->displine << 1)][(x << 4) + (c << 1) + 8].pal = + screen->line[(dev->displine << 1)][(x << 4) + (c << 1) + 1 + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdat[chr + dev->fontbase][dev->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } } @@ -411,10 +411,10 @@ cga_poll(void *priv) dat = 0; dev->ma++; for (c = 0; c < 8; c++) { - buffer->line[(dev->displine << 1)][(x << 4) + (c << 1) + 8] = - buffer->line[(dev->displine << 1)][(x << 4) + (c << 1) + 1 + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8] = + screen->line[(dev->displine << 1)][(x << 4) + (c << 1) + 8].pal = + screen->line[(dev->displine << 1)][(x << 4) + (c << 1) + 1 + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 4) + (c << 1) + 1 + 8].pal = cols[dat >> 14]; dat <<= 2; } @@ -428,8 +428,8 @@ cga_poll(void *priv) dat = 0; dev->ma++; for (c = 0; c < 16; c++) { - buffer->line[(dev->displine << 1)][(x << 4) + c + 8] = - buffer->line[(dev->displine << 1) + 1][(x << 4) + c + 8] = + screen->line[(dev->displine << 1)][(x << 4) + c + 8].pal = + screen->line[(dev->displine << 1) + 1][(x << 4) + c + 8].pal = cols[dat >> 15]; dat <<= 1; } @@ -438,11 +438,11 @@ cga_poll(void *priv) } else { cols[0] = ((dev->cgamode & 0x12) == 0x12) ? 0 : (dev->cgacol & 15) + 16; if (dev->cgamode & 1) { - cga_hline(buffer, 0, (dev->displine << 1), (dev->crtc[1] << 3) + 16, cols[0]); - cga_hline(buffer, 0, (dev->displine << 1) + 1, (dev->crtc[1] << 3) + 16, cols[0]); + cga_hline(screen, 0, (dev->displine << 1), (dev->crtc[1] << 3) + 16, cols[0]); + cga_hline(screen, 0, (dev->displine << 1) + 1, (dev->crtc[1] << 3) + 16, cols[0]); } else { - cga_hline(buffer, 0, (dev->displine << 1), (dev->crtc[1] << 4) + 16, cols[0]); - cga_hline(buffer, 0, (dev->displine << 1) + 1, (dev->crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, (dev->displine << 1), (dev->crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, (dev->displine << 1) + 1, (dev->crtc[1] << 4) + 16, cols[0]); } } @@ -452,18 +452,13 @@ cga_poll(void *priv) x = (dev->crtc[1] << 4) + 16; if (dev->composite) { - for (c = 0; c < x; c++) { - buffer32->line[(dev->displine << 1)][c] = buffer->line[(dev->displine << 1)][c] & 0xf; - buffer32->line[(dev->displine << 1) + 1][c] = buffer->line[(dev->displine << 1) + 1][c] & 0xf; - } - if (dev->cgamode & 0x10) border = 0x00; else border = dev->cgacol & 0x0f; - cga_comp_process(dev->cpriv, dev->cgamode, border, x >> 2, buffer32->line[(dev->displine << 1)]); - cga_comp_process(dev->cpriv, dev->cgamode, border, x >> 2, buffer32->line[(dev->displine << 1) + 1]); + cga_comp_process(dev->cpriv, dev->cgamode, border, x >> 2, screen->line[(dev->displine << 1)]); + cga_comp_process(dev->cpriv, dev->cgamode, border, x >> 2, screen->line[(dev->displine << 1) + 1]); } dev->sc = oldsc; @@ -560,10 +555,10 @@ cga_poll(void *priv) } if (dev->composite) - video_blit_memtoscreen(0, (dev->firstline - 4) << 1, 0, ((dev->lastline - dev->firstline) + 8) << 1, + video_blit_start(0, 0, (dev->firstline - 4) << 1, 0, ((dev->lastline - dev->firstline) + 8) << 1, xsize, ((dev->lastline - dev->firstline) + 8) << 1); else - video_blit_memtoscreen_8(0, (dev->firstline - 4) << 1, 0, ((dev->lastline - dev->firstline) + 8) << 1, + video_blit_start(1, 0, (dev->firstline - 4) << 1, 0, ((dev->lastline - dev->firstline) + 8) << 1, xsize, ((dev->lastline - dev->firstline) + 8) << 1); frames++; @@ -651,7 +646,7 @@ cga_standalone_init(const device_t *info) overscan_x = overscan_y = 16; cga_palette = (dev->rgb_type << 1); - cgapal_rebuild(); + video_palette_rebuild(); video_load_font(CGA_FONT_ROM_PATH, (dev->font_type) ? FONT_CGA_THICK : FONT_CGA_THIN); diff --git a/src/devices/video/vid_cga.h b/src/devices/video/vid_cga.h index 3e11a76..f313fbe 100644 --- a/src/devices/video/vid_cga.h +++ b/src/devices/video/vid_cga.h @@ -8,7 +8,7 @@ * * Definitions for the CGA driver. * - * Version: @(#)vid_cga.h 1.0.7 2019/03/04 + * Version: @(#)vid_cga.h 1.0.8 2019/03/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -93,13 +93,14 @@ extern const device_config_t cga_config[]; extern void cga_init(cga_t *cga); -extern void cga_out(uint16_t addr, uint8_t val, void *p); -extern uint8_t cga_in(uint16_t addr, void *p); -extern void cga_write(uint32_t addr, uint8_t val, void *p); -extern uint8_t cga_read(uint32_t addr, void *p); +extern void cga_out(uint16_t addr, uint8_t val, void *priv); +extern uint8_t cga_in(uint16_t addr, void *priv); +extern void cga_write(uint32_t addr, uint8_t val, void *priv); +extern uint8_t cga_read(uint32_t addr, void *priv); extern void cga_recalctimings(cga_t *cga); -extern void cga_poll(void *p); -extern void cga_hline(bitmap_t *b, int x1, int y, int x2, uint32_t col); +extern void cga_poll(void *priv); + +extern void cga_hline(bitmap_t *b, int x1, int y, int x2, uint8_t col); #endif /*VIDEO_CGA_H*/ diff --git a/src/devices/video/vid_cga_comp.c b/src/devices/video/vid_cga_comp.c index 59dc2de..b8e435f 100644 --- a/src/devices/video/vid_cga_comp.c +++ b/src/devices/video/vid_cga_comp.c @@ -15,7 +15,7 @@ * * Reworked to have its data on the heap. * - * Version: @(#)vid_cga_comp.c 1.0.6 2019/03/04 + * Version: @(#)vid_cga_comp.c 1.0.7 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -119,15 +119,15 @@ byte_clamp(int v) } -uint8_t * +void cga_comp_process(void *priv, uint8_t cgamode, uint8_t border, - uint32_t blocks/*, int8_t doublewidth*/, uint8_t *TempLine) + uint32_t blocks/*, int8_t doublewidth*/, pel_t *pels) { cga_comp_t *state = (cga_comp_t *)priv; - uint32_t x2, *srgb; + uint32_t x2; + pel_t *ptr; int x, w = blocks*4; int *o, *b2, *i, *ap, *bp; - uint8_t *rgbi; #define COMPOSITE_CONVERT(I, Q) do { \ i[1] = (i[1]<<3) - ap[1]; \ @@ -142,40 +142,40 @@ cga_comp_process(void *priv, uint8_t cgamode, uint8_t border, ++i; \ ++ap; \ ++bp; \ - *srgb = (byte_clamp(rr)<<16) | (byte_clamp(gg)<<8) | byte_clamp(bb); \ - ++srgb; \ + ptr[0].val = (byte_clamp(rr)<<16) | (byte_clamp(gg)<<8) | byte_clamp(bb); \ + ptr++; \ } while (0) #define OUT(v) do { *o = (v); ++o; } while (0) /* Simulate CGA composite output. */ + ptr = pels; o = state->temp; - rgbi = TempLine; b2 = &state->table[border * 68]; for (x = 0; x < 4; ++x) OUT(b2[(x+3)&3]); - OUT(state->table[(border<<6) | ((*rgbi)<<2) | 3]); + OUT(state->table[(border<<6) | ((ptr[0].pal & 0x0f)<<2) | 3]); for (x = 0; x < w-1; ++x) { - OUT(state->table[(rgbi[0]<<6) | (rgbi[1]<<2) | (x&3)]); - ++rgbi; + OUT(state->table[((ptr[0].pal & 0x0f)<<6) | ((ptr[1].pal & 0x0f)<<2) | (x&3)]); + ptr++; } - OUT(state->table[((*rgbi)<<6) | (border<<2) | 3]); + OUT(state->table[((ptr[0].pal & 0x0f)<<6) | (border<<2) | 3]); for (x = 0; x < 5; ++x) OUT(b2[x&3]); + ptr = pels; if ((cgamode & 4) != 0) { /* Decode. */ i = state->temp + 5; - srgb = (uint32_t *)TempLine; for (x2 = 0; x2 < blocks*4; ++x2) { int c = (i[0]+i[0])<<3; int d = (i[-1]+i[1])<<3; int y = ((c+d)<<8) + state->video_sharpness*(c-d); ++i; - *srgb = byte_clamp(y)*0x10101; - ++srgb; + ptr[0].val = byte_clamp(y)*0x10101; + ptr++; } } else { /* Store chroma. */ @@ -192,7 +192,6 @@ cga_comp_process(void *priv, uint8_t cgamode, uint8_t border, i = state->temp + 5; i[-1] = (i[-1]<<3) - ap[-1]; i[0] = (i[0]<<3) - ap[0]; - srgb = (uint32_t *)TempLine; for (x2 = 0; x2 < blocks; ++x2) { int y,a,b,c,d,rr,gg,bb; @@ -202,8 +201,6 @@ cga_comp_process(void *priv, uint8_t cgamode, uint8_t border, COMPOSITE_CONVERT(b, -a); } } - - return TempLine; } diff --git a/src/devices/video/vid_cga_comp.h b/src/devices/video/vid_cga_comp.h index dfdbf27..416918c 100644 --- a/src/devices/video/vid_cga_comp.h +++ b/src/devices/video/vid_cga_comp.h @@ -8,7 +8,7 @@ * * Definitions for the IBM CGA composite filter. * - * Version: @(#)vid_cga_comp.h 1.0.2 2019/03/04 + * Version: @(#)vid_cga_comp.h 1.0.3 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -43,9 +43,9 @@ extern void *cga_comp_init(int revision); extern void cga_comp_close(void *); extern void cga_comp_update(void *, uint8_t cgamode); -extern uint8_t *cga_comp_process(void *, uint8_t cgamode, uint8_t border, - uint32_t blocks, /*int8_t doublewidth,*/ - uint8_t *TempLine); +extern void cga_comp_process(void *, uint8_t cgamode, uint8_t border, + uint32_t blocks, /*int8_t doublewidth,*/ + pel_t *pels); #endif /*VIDEO_CGA_COMP_H*/ diff --git a/src/devices/video/vid_cga_compaq.c b/src/devices/video/vid_cga_compaq.c index 03e83cf..a23600b 100644 --- a/src/devices/video/vid_cga_compaq.c +++ b/src/devices/video/vid_cga_compaq.c @@ -8,7 +8,7 @@ * * Implementation of CGA used by Compaq PC's. * - * Version: @(#)vid_cga_compaq.c 1.0.6 2019/03/04 + * Version: @(#)vid_cga_compaq.c 1.0.7 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -91,7 +91,7 @@ compaq_poll(void *priv) int x, c; int oldvc; uint8_t chr, attr; - uint32_t cols[4]; + uint8_t cols[4]; int oldsc; int underline = 0; int blink = 0; @@ -101,8 +101,9 @@ compaq_poll(void *priv) overscan_x = overscan_y = 16; cga_poll(&dev->cga); return; - } else - overscan_x = overscan_y = 0; + } + + overscan_x = overscan_y = 0; /* We are in Compaq 350-line CGA territory */ if (! dev->cga.linepos) { @@ -117,18 +118,18 @@ compaq_poll(void *priv) if (dev->cga.cgadispon) { if (dev->cga.displine < dev->cga.firstline) { dev->cga.firstline = dev->cga.displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } dev->cga.lastline = dev->cga.displine; cols[0] = (dev->cga.cgacol & 15); for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[dev->cga.displine])[c] = cols[0]; + screen->line[dev->cga.displine][c].val = cols[0]; if (dev->cga.cgamode & 1) - ((uint32_t *)buffer32->line[dev->cga.displine])[c + (dev->cga.crtc[1] << 3) + 8] = cols[0]; + screen->line[dev->cga.displine][c + (dev->cga.crtc[1] << 3) + 8].pal = cols[0]; else - ((uint32_t *)buffer32->line[dev->cga.displine])[c + (dev->cga.crtc[1] << 4) + 8] = cols[0]; + screen->line[dev->cga.displine][c + (dev->cga.crtc[1] << 4) + 8].pal = cols[0]; } if (dev->cga.cgamode & 1) { @@ -162,13 +163,13 @@ compaq_poll(void *priv) if (dev->flags && underline) { for (c = 0; c < 8; c++) - ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 3) + c + 8] = dev->attr[attr][blink][1]; + screen->line[dev->cga.displine][(x << 3) + c + 8].pal = dev->attr[attr][blink][1]; } else if (drawcursor) { for (c = 0; c < 8; c++) - ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 3) + c + 8] = cols[(fontdatm[chr + dev->cga.fontbase][dev->cga.sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0xffffff; + screen->line[dev->cga.displine][(x << 3) + c + 8].pal = cols[(fontdatm[chr + dev->cga.fontbase][dev->cga.sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0xffffff; } else { for (c = 0; c < 8; c++) - ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 3) + c + 8] = cols[(fontdatm[chr + dev->cga.fontbase][dev->cga.sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->cga.displine][(x << 3) + c + 8].pal = cols[(fontdatm[chr + dev->cga.fontbase][dev->cga.sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; } dev->cga.ma++; } @@ -204,40 +205,34 @@ compaq_poll(void *priv) if (dev->flags && underline) { for (c = 0; c < 8; c++) - ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 4)+(c << 1) + 8] = ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 4)+(c << 1) + 9] = dev->attr[attr][blink][1]; + screen->line[dev->cga.displine][(x << 4)+(c << 1) + 8].pal = screen->line[dev->cga.displine][(x << 4)+(c << 1) + 9].pal = dev->attr[attr][blink][1]; } else if (drawcursor) { for (c = 0; c < 8; c++) - ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 4)+(c << 1) + 8] = ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr + dev->cga.fontbase][dev->cga.sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + screen->line[dev->cga.displine][(x << 4)+(c << 1) + 8].pal = screen->line[dev->cga.displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdatm[chr + dev->cga.fontbase][dev->cga.sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { for (c = 0; c < 8; c++) - ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 4) + (c << 1) + 8] = ((uint32_t *)buffer32->line[dev->cga.displine])[(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr + dev->cga.fontbase][dev->cga.sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->cga.displine][(x << 4) + (c << 1) + 8].pal = screen->line[dev->cga.displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdatm[chr + dev->cga.fontbase][dev->cga.sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; } } } } else { cols[0] = (dev->cga.cgacol & 15) + 16; if (dev->cga.cgamode & 1) - cga_hline(buffer32, 0, dev->cga.displine, (dev->cga.crtc[1] << 3) + 16, cols[0]); + cga_hline(screen, 0, dev->cga.displine, (dev->cga.crtc[1] << 3) + 16, cols[0]); else - cga_hline(buffer32, 0, dev->cga.displine, (dev->cga.crtc[1] << 4) + 16, cols[0]); - } + cga_hline(screen, 0, dev->cga.displine, (dev->cga.crtc[1] << 4) + 16, cols[0]); + } - if (dev->cga.cgamode & 1) - x = (dev->cga.crtc[1] << 3) + 16; - else - x = (dev->cga.crtc[1] << 4) + 16; - - if (dev->cga.composite) { - for (c = 0; c < x; c++) - buffer32->line[dev->cga.displine][c] = ((uint32_t *)buffer32->line[dev->cga.displine])[c] & 0xf; + if (dev->cga.cgamode & 1) + x = (dev->cga.crtc[1] << 3) + 16; + else + x = (dev->cga.crtc[1] << 4) + 16; + if (dev->cga.composite) { if (dev->flags) - cga_comp_process(dev->cga.cpriv, dev->cga.cgamode & 0x7F, 0, x >> 2, buffer32->line[dev->cga.displine]); + cga_comp_process(dev->cga.cpriv, dev->cga.cgamode & 0x7F, 0, x >> 2, screen->line[dev->cga.displine]); else - cga_comp_process(dev->cga.cpriv, dev->cga.cgamode, 0, x >> 2, buffer32->line[dev->cga.displine]); - } else { - for (c = 0; c < x; c++) - buffer->line[dev->cga.displine][c] = ((uint32_t *)buffer32->line[dev->cga.displine])[c]; + cga_comp_process(dev->cga.cpriv, dev->cga.cgamode, 0, x >> 2, screen->line[dev->cga.displine]); } dev->cga.sc = oldsc; @@ -317,9 +312,9 @@ compaq_poll(void *priv) } if (dev->cga.composite) - video_blit_memtoscreen(8, dev->cga.firstline, 0, ysize, xsize, ysize); + video_blit_start(0, 8, dev->cga.firstline, 0, ysize, xsize, ysize); else - video_blit_memtoscreen_8(8, dev->cga.firstline, 0, ysize, xsize, ysize); + video_blit_start(1, 8, dev->cga.firstline, 0, ysize, xsize, ysize); frames++; video_res_x = xsize - 16; @@ -419,7 +414,7 @@ compaq_cga_init(const device_t *info) overscan_x = overscan_y = 16; cga_palette = (dev->cga.rgb_type << 1); - cgapal_rebuild(); + video_palette_rebuild(); video_inform(VID_TYPE_CGA, info->vid_timing); diff --git a/src/devices/video/vid_cl54xx.c b/src/devices/video/vid_cl54xx.c index 2b01120..3daebb3 100644 --- a/src/devices/video/vid_cl54xx.c +++ b/src/devices/video/vid_cl54xx.c @@ -9,7 +9,7 @@ * Emulation of select Cirrus Logic cards (CL-GD 5428, * CL-GD 5429, 5430, 5434 and 5436 are supported). * - * Version: @(#)vid_cl54xx.c 1.0.25 2019/02/10 + * Version: @(#)vid_cl54xx.c 1.0.26 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1066,16 +1066,16 @@ hwcursor_draw(svga_t *svga, int displine) break; case 1: /* The pixel is shown in the cursor background color */ - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] = bgcol; + screen->line[displine + y_add][offset + 32 + x_add].val = bgcol; break; case 2: /* The pixel is shown as the inverse of the original screen pixel (XOR cursor) */ - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] ^= 0xffffff; + screen->line[displine + y_add][offset + 32 + x_add].val ^= 0xffffff; break; case 3: /* The pixel is shown in the cursor foreground color */ - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] = fgcol; + screen->line[displine + y_add][offset + 32 + x_add].val = fgcol; break; } } diff --git a/src/devices/video/vid_colorplus.c b/src/devices/video/vid_colorplus.c index 06b592e..7f205f6 100644 --- a/src/devices/video/vid_colorplus.c +++ b/src/devices/video/vid_colorplus.c @@ -8,7 +8,7 @@ * * Plantronics ColorPlus emulation. * - * Version: @(#)vid_colorplus.c 1.0.10 2019/03/04 + * Version: @(#)vid_colorplus.c 1.0.11 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -78,8 +78,8 @@ typedef struct { static const int cols16[16] = { - 0x10,0x12,0x14,0x16, 0x18,0x1A,0x1C,0x1E, - 0x11,0x13,0x15,0x17, 0x19,0x1B,0x1D,0x1F + 0x10,0x12,0x14,0x16, 0x18,0x1a,0x1c,0x1e, + 0x11,0x13,0x15,0x17, 0x19,0x1b,0x1d,0x1f }; @@ -185,14 +185,13 @@ colorplus_poll(void *priv) if (dev->cga.cgadispon) { if (dev->cga.displine < dev->cga.firstline) { dev->cga.firstline = dev->cga.displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } dev->cga.lastline = dev->cga.displine; /* Left / right border */ for (c = 0; c < 8; c++) { - buffer->line[dev->cga.displine][c] = - buffer->line[dev->cga.displine][c + (dev->cga.crtc[1] << 4) + 8] = (dev->cga.cgacol & 15) + 16; + screen->line[dev->cga.displine][c].pal = screen->line[dev->cga.displine][c + (dev->cga.crtc[1] << 4) + 8].pal = (dev->cga.cgacol & 15) + 16; } if (dev->control & COLORPLUS_320x200_MODE) { @@ -204,7 +203,7 @@ colorplus_poll(void *priv) dev->cga.ma++; for (c = 0; c < 8; c++) { - buffer->line[dev->cga.displine][(x << 4) + (c << 1) + 8] = buffer->line[dev->cga.displine][(x << 4) + (c << 1) + 1 + 8] = cols16[(dat0 >> 14) | ((dat1 >> 14) << 2)]; + screen->line[dev->cga.displine][(x << 4) + (c << 1) + 8].pal = screen->line[dev->cga.displine][(x << 4) + (c << 1) + 1 + 8].pal = cols16[(dat0 >> 14) | ((dat1 >> 14) << 2)]; dat0 <<= 2; dat1 <<= 2; } @@ -234,7 +233,7 @@ colorplus_poll(void *priv) dev->cga.ma++; for (c = 0; c < 16; c++) { - buffer->line[dev->cga.displine][(x << 4) + c + 8] = cols[(dat0 >> 15) | ((dat1 >> 15) << 1)]; + screen->line[dev->cga.displine][(x << 4) + c + 8].pal = cols[(dat0 >> 15) | ((dat1 >> 15) << 1)]; dat0 <<= 1; dat1 <<= 1; } @@ -242,17 +241,13 @@ colorplus_poll(void *priv) } } else { /* Top / bottom border */ cols[0] = (dev->cga.cgacol & 15) + 16; - cga_hline(buffer, 0, dev->cga.displine, (dev->cga.crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, dev->cga.displine, (dev->cga.crtc[1] << 4) + 16, cols[0]); } x = (dev->cga.crtc[1] << 4) + 16; - if (dev->cga.composite) { - for (c = 0; c < x; c++) - buffer32->line[dev->cga.displine][c] = buffer->line[dev->cga.displine][c] & 0xf; - - cga_comp_process(dev->cga.cpriv, dev->cga.cgamode, 0, x >> 2, buffer32->line[dev->cga.displine]); - } + if (dev->cga.composite) + cga_comp_process(dev->cga.cpriv, dev->cga.cgamode, 0, x >> 2, screen->line[dev->cga.displine]); dev->cga.sc = oldsc; if (dev->cga.vc == dev->cga.crtc[7] && !dev->cga.sc) @@ -331,9 +326,9 @@ colorplus_poll(void *priv) } if (dev->cga.composite) - video_blit_memtoscreen(0, dev->cga.firstline - 4, 0, (dev->cga.lastline - dev->cga.firstline) + 8, xsize, (dev->cga.lastline - dev->cga.firstline) + 8); + video_blit_start(0, 0, dev->cga.firstline - 4, 0, (dev->cga.lastline - dev->cga.firstline) + 8, xsize, (dev->cga.lastline - dev->cga.firstline) + 8); else - video_blit_memtoscreen_8(0, dev->cga.firstline - 4, 0, (dev->cga.lastline - dev->cga.firstline) + 8, xsize, (dev->cga.lastline - dev->cga.firstline) + 8); + video_blit_start(1, 0, dev->cga.firstline - 4, 0, (dev->cga.lastline - dev->cga.firstline) + 8, xsize, (dev->cga.lastline - dev->cga.firstline) + 8); frames++; video_res_x = xsize - 16; @@ -386,9 +381,6 @@ colorplus_init(const device_t *info) dev = (colorplus_t *)mem_alloc(sizeof(colorplus_t)); memset(dev, 0x00, sizeof(colorplus_t)); - /* Copied from the CGA init. Ideally this would be done by - * calling a helper function rather than duplicating code. - */ display_type = device_get_config_int("display_type"); dev->cga.composite = (display_type != CGA_RGB); dev->cga.revision = device_get_config_int("composite_type"); diff --git a/src/devices/video/vid_ega.c b/src/devices/video/vid_ega.c index 5431b5f..6557b8b 100644 --- a/src/devices/video/vid_ega.c +++ b/src/devices/video/vid_ega.c @@ -9,7 +9,7 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.c 1.0.10 2019/02/10 + * Version: @(#)vid_ega.c 1.0.11 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -92,10 +92,12 @@ typedef struct { uint16_t end; } fontxTbl; -static __inline int ega_jega_enabled(ega_t *ega) + +static __inline int +ega_jega_enabled(ega_t *ega) { if (! ega->is_jega) - return 0; + return 0; return !(ega->RMOD1 & 0x40); } @@ -127,6 +129,7 @@ ega_jega_write_font(ega_t *ega) ega->font_index = 0; jfont_sbcs_19[(chr * 19) + ega->font_index] = ega->RDFAP; /* 8x19 font */ } + ega->font_index++; ega->RSTAT |= 0x02; } @@ -158,6 +161,7 @@ ega_jega_read_font(ega_t *ega) ega->font_index = 0; ega->RDFAP = jfont_sbcs_19[(chr * 19) + ega->font_index]; /* 8x19 font */ } + ega->font_index++; ega->RSTAT |= 0x02; } @@ -234,7 +238,6 @@ ega_poll(void *priv) int x_add_ex = enable_overscan ? 16 : 0; int wx = 640, wy = 350; int drawcursor = 0; - uint32_t *q; int i, j, x; if (! dev->linepos) { @@ -246,7 +249,7 @@ ega_poll(void *priv) if (dev->dispon) { if (dev->firstline == 2000) { dev->firstline = dev->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } if (dev->scrblank) @@ -378,28 +381,22 @@ ega_poll(void *priv) if ((x >= 160) && ((dev->lastline - dev->firstline) >= 120)) { /* Draw (overscan_size - scroll size) lines of overscan on top. */ for (i = 0; i < (y_add - (dev->crtc[8] & 0x1f)); i++) { - q = &((uint32_t *)buffer32->line[i & 0x7ff])[32]; - for (j = 0; j < (xsize + x_add_ex); j++) { - q[j] = dev->pallook[dev->attrregs[0x11]]; + screen->line[i & 0x7ff][32 + j].val = dev->pallook[dev->attrregs[0x11]]; } } /* Draw (overscan_size + scroll size) lines of overscan on the bottom. */ for (i = 0; i < (y_add + (dev->crtc[8] & 0x1f)); i++) { - q = &((uint32_t *)buffer32->line[(ysize + y_add + i - (dev->crtc[8] & 0x1f)) & 0x7ff])[32]; - for (j = 0; j < (xsize + x_add_ex); j++) { - q[j] = dev->pallook[dev->attrregs[0x11]]; + screen->line[(ysize + y_add + i - (dev->crtc[8] & 0x1f)) & 0x7ff][32 + j].val = dev->pallook[dev->attrregs[0x11]]; } } for (i = (y_add - (dev->crtc[8] & 0x1f)); i < (ysize + y_add - (dev->crtc[8] & 0x1f)); i ++) { - q = &((uint32_t *)buffer32->line[(i - (dev->crtc[8] & 0x1f)) & 0x7ff])[32]; - for (j = 0; j < x_add; j++) { - q[j] = dev->pallook[dev->attrregs[0x11]]; - q[xsize + x_add + j] = dev->pallook[dev->attrregs[0x11]]; + screen->line[(i - (dev->crtc[8] & 0x1f)) & 0x7ff][32 + j].val = dev->pallook[dev->attrregs[0x11]]; + screen->line[(i - (dev->crtc[8] & 0x1f)) & 0x7ff][32 + xsize + x_add + j].val = dev->pallook[dev->attrregs[0x11]]; } } } @@ -407,17 +404,14 @@ ega_poll(void *priv) if (dev->crtc[8] & 0x1f) { /* Draw (scroll size) lines of overscan on the bottom. */ for (i = 0; i < (dev->crtc[8] & 0x1f); i++) { - q = &((uint32_t *)buffer32->line[(ysize + i - (dev->crtc[8] & 0x1f)) & 0x7ff])[32]; - for (j = 0; j < xsize; j++) { - q[j] = dev->pallook[dev->attrregs[0x11]]; + screen->line[(ysize + i - (dev->crtc[8] & 0x1f)) & 0x7ff][32 + j].val = dev->pallook[dev->attrregs[0x11]]; } } } } - video_blit_memtoscreen(32, 0, dev->firstline, dev->lastline + 1 + y_add_ex, xsize + x_add_ex, dev->lastline - dev->firstline + 1 + y_add_ex); - + video_blit_start(0, 32, 0, dev->firstline, dev->lastline + 1 + y_add_ex, xsize + x_add_ex, dev->lastline - dev->firstline + 1 + y_add_ex); frames++; dev->video_res_x = wx; diff --git a/src/devices/video/vid_ega_render.c b/src/devices/video/vid_ega_render.c index d091804..9520da9 100644 --- a/src/devices/video/vid_ega_render.c +++ b/src/devices/video/vid_ega_render.c @@ -9,13 +9,13 @@ * EGA renderers. * NOTE: FIXME: make sure this works (line 99 shadow parameter) * - * Version: @(#)vid_ega_render.c 1.0.3 2018/05/06 + * Version: @(#)vid_ega_render.c 1.0.4 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -50,522 +50,478 @@ #include "vid_ega_render.h" -int ega_display_line(ega_t *ega) +int +ega_display_line(ega_t *ega) { - int y_add = (enable_overscan) ? (overscan_y >> 1) : 0; - unsigned int dl = ega->displine; - if (ega->crtc[9] & 0x1f) - { - dl -= (ega->crtc[8] & 0x1f); - } - dl += y_add; - dl &= 0x7ff; - return dl; + int y_add = (enable_overscan) ? (overscan_y >> 1) : 0; + unsigned int dl = ega->displine; + + if (ega->crtc[9] & 0x1f) + dl -= (ega->crtc[8] & 0x1f); + dl += y_add; + dl &= 0x7ff; + + return dl; } -void ega_render_blank(ega_t *ega) -{ - int x_add = (enable_overscan) ? 8 : 0; - int dl = ega_display_line(ega); - int x, xx; - for (x = 0; x < ega->hdisp; x++) - { - switch (ega->seqregs[1] & 9) - { - case 0: - for (xx = 0; xx < 9; xx++) ((uint32_t *)buffer32->line[dl])[(x * 9) + xx + 32 + x_add] = 0; - break; - case 1: - for (xx = 0; xx < 8; xx++) ((uint32_t *)buffer32->line[dl])[(x * 8) + xx + 32 + x_add] = 0; - break; - case 8: - for (xx = 0; xx < 18; xx++) ((uint32_t *)buffer32->line[dl])[(x * 18) + xx + 32 + x_add] = 0; - break; - case 9: - for (xx = 0; xx < 16; xx++) ((uint32_t *)buffer32->line[dl])[(x * 16) + xx + 32 + x_add] = 0; - break; +void +ega_render_blank(ega_t *ega) +{ + int x_add = (enable_overscan) ? 8 : 0; + int dl = ega_display_line(ega); + int x, xx; + + for (x = 0; x < ega->hdisp; x++) switch (ega->seqregs[1] & 9) { + case 0: + for (xx = 0; xx < 9; xx++) + screen->line[dl][(x * 9) + xx + 32 + x_add].val = 0; + break; + + case 1: + for (xx = 0; xx < 8; xx++) + screen->line[dl][(x * 8) + xx + 32 + x_add].val = 0; + break; + + case 8: + for (xx = 0; xx < 18; xx++) + screen->line[dl][(x * 18) + xx + 32 + x_add].val = 0; + break; + + case 9: + for (xx = 0; xx < 16; xx++) + screen->line[dl][(x * 16) + xx + 32 + x_add].val = 0; + break; + } +} + + +void +ega_render_text_standard(ega_t *ega, int draw) +{ + int x_add = (enable_overscan) ? 8 : 0; + int dl = ega_display_line(ega); + int x, xx; + + for (x = 0; x < ega->hdisp; x++) { + int do_draw = ((ega->ma == ega->ca) && ega->con && ega->cursoron); + uint8_t chr = ega->vram[(ega->ma << 1) & ega->vrammask]; + uint8_t attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask]; + uint8_t dat; + uint32_t fg, bg; + uint32_t charaddr; + + if (attr & 8) + charaddr = ega->charsetb + (chr * 128); + else + charaddr = ega->charseta + (chr * 128); + + if (do_draw) { + bg = ega->pallook[ega->egapal[attr & 15]]; + fg = ega->pallook[ega->egapal[attr >> 4]]; + } else { + fg = ega->pallook[ega->egapal[attr & 15]]; + bg = ega->pallook[ega->egapal[attr >> 4]]; + if (attr & 0x80 && ega->attrregs[0x10] & 8) { + bg = ega->pallook[ega->egapal[(attr >> 4) & 7]]; + if (ega->blink & 16) + fg = bg; } } + + dat = ega->vram[charaddr + (ega->sc << 2)]; + if (ega->seqregs[1] & 8) { + if (ega->seqregs[1] & 1) { + for (xx = 0; xx < 8; xx++) + screen->line[dl][((x << 4) + 32 + (xx << 1) + x_add) & 2047].val = screen->line[dl][((x << 4) + 33 + (xx << 1) + x_add) & 2047].val = (dat & (0x80 >> xx)) ? fg : bg; + } else { + for (xx = 0; xx < 8; xx++) + screen->line[dl][((x * 18) + 32 + (xx << 1) + x_add) & 2047].val = screen->line[dl][((x * 18) + 33 + (xx << 1) + x_add) & 2047].val = (dat & (0x80 >> xx)) ? fg : bg; + if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4)) + screen->line[dl][((x * 18) + 32 + 16 + x_add) & 2047].val = screen->line[dl][((x * 18) + 32 + 17 + x_add) & 2047].val = bg; + else + screen->line[dl][((x * 18) + 32 + 16 + x_add) & 2047].val = screen->line[dl][((x * 18) + 32 + 17 + x_add) & 2047].val = (dat & 1) ? fg : bg; + } + } else { + if (ega->seqregs[1] & 1) { + for (xx = 0; xx < 8; xx++) + screen->line[dl][((x << 3) + 32 + xx + x_add) & 2047].val = (dat & (0x80 >> xx)) ? fg : bg; + } else { + for (xx = 0; xx < 8; xx++) + screen->line[dl][((x * 9) + 32 + xx + x_add) & 2047].val = (dat & (0x80 >> xx)) ? fg : bg; + if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4)) + screen->line[dl][((x * 9) + 32 + 8 + x_add) & 2047].val = bg; + else + screen->line[dl][((x * 9) + 32 + 8 + x_add) & 2047].val = (dat & 1) ? fg : bg; + } + } + + ega->ma += 4; + ega->ma &= ega->vrammask; + } } -void ega_render_text_standard(ega_t *ega, int draw) -{ - int x, xx; - int x_add = (enable_overscan) ? 8 : 0; - int dl = ega_display_line(ega); - - for (x = 0; x < ega->hdisp; x++) - { - int do_draw = ((ega->ma == ega->ca) && ega->con && ega->cursoron); - uint8_t chr = ega->vram[(ega->ma << 1) & ega->vrammask]; - uint8_t attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask]; - uint8_t dat; - uint32_t fg, bg; - uint32_t charaddr; - - if (attr & 8) - charaddr = ega->charsetb + (chr * 128); - else - charaddr = ega->charseta + (chr * 128); - - if (do_draw) - { - bg = ega->pallook[ega->egapal[attr & 15]]; - fg = ega->pallook[ega->egapal[attr >> 4]]; - } - else - { - fg = ega->pallook[ega->egapal[attr & 15]]; - bg = ega->pallook[ega->egapal[attr >> 4]]; - if (attr & 0x80 && ega->attrregs[0x10] & 8) - { - bg = ega->pallook[ega->egapal[(attr >> 4) & 7]]; - if (ega->blink & 16) - fg = bg; - } - } - - dat = ega->vram[charaddr + (ega->sc << 2)]; - if (ega->seqregs[1] & 8) - { - if (ega->seqregs[1] & 1) - { - for (xx = 0; xx < 8; xx++) - ((uint32_t *)buffer32->line[dl])[((x << 4) + 32 + (xx << 1) + x_add) & 2047] = - ((uint32_t *)buffer32->line[dl])[((x << 4) + 33 + (xx << 1) + x_add) & 2047] = (dat & (0x80 >> xx)) ? fg : bg; - } - else - { - for (xx = 0; xx < 8; xx++) - ((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + (xx << 1) + x_add) & 2047] = - ((uint32_t *)buffer32->line[dl])[((x * 18) + 33 + (xx << 1) + x_add) & 2047] = (dat & (0x80 >> xx)) ? fg : bg; - if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4)) - ((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + 16 + x_add) & 2047] = - ((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + 17 + x_add) & 2047] = bg; - else - ((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + 16 + x_add) & 2047] = - ((uint32_t *)buffer32->line[dl])[((x * 18) + 32 + 17 + x_add) & 2047] = (dat & 1) ? fg : bg; - } - } - else - { - if (ega->seqregs[1] & 1) - { - for (xx = 0; xx < 8; xx++) - ((uint32_t *)buffer32->line[dl])[((x << 3) + 32 + xx + x_add) & 2047] = (dat & (0x80 >> xx)) ? fg : bg; - } - else - { - for (xx = 0; xx < 8; xx++) - ((uint32_t *)buffer32->line[dl])[((x * 9) + 32 + xx + x_add) & 2047] = (dat & (0x80 >> xx)) ? fg : bg; - if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4)) - ((uint32_t *)buffer32->line[dl])[((x * 9) + 32 + 8 + x_add) & 2047] = bg; - else - ((uint32_t *)buffer32->line[dl])[((x * 9) + 32 + 8 + x_add) & 2047] = (dat & 1) ? fg : bg; - } - } - ega->ma += 4; - ega->ma &= ega->vrammask; - } -} #ifdef JEGA -static __inline int is_kanji1(uint8_t chr) +static __inline int +is_kanji1(uint8_t chr) { - return (chr >= 0x81 && chr <= 0x9f) || (chr >= 0xe0 && chr <= 0xfc); + return (chr >= 0x81 && chr <= 0x9f) || (chr >= 0xe0 && chr <= 0xfc); } -static __inline int is_kanji2(uint8_t chr) + +static __inline int +is_kanji2(uint8_t chr) { - return (chr >= 0x40 && chr <= 0x7e) || (chr >= 0x80 && chr <= 0xfc); + return (chr >= 0x40 && chr <= 0x7e) || (chr >= 0x80 && chr <= 0xfc); } -void ega_jega_render_blit_text(ega_t *ega, int x, int dl, int start, int width, uint16_t dat, int cw, uint32_t fg, uint32_t bg) + +void +ega_jega_render_blit_text(ega_t *ega, int x, int dl, int start, int width, uint16_t dat, int cw, uint32_t fg, uint32_t bg) { - int x_add = (enable_overscan) ? 8 : 0; + int x_add = (enable_overscan) ? 8 : 0; + int xx = 0; + int xxx = 0; - int xx = 0; - int xxx = 0; - - if (ega->seqregs[1] & 8) - { - for (xx = start; xx < (start + width); xx++) - for (xxx = 0; xxx < cw; xxx++) - ((uint32_t *)buffer32->line[dl])[(((x * width) + 32 + (xxx << 1) + ((xx << 1) * cw)) & 2047) + x_add] = - ((uint32_t *)buffer32->line[dl])[(((x * width) + 33 + (xxx << 1) + ((xx << 1) * cw)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; - } - else - { - for (xx = start; xx < (start + width); xx++) - ((uint32_t *)buffer32->line[dl])[(((x * width) + 32 + xxx + (xx * cw)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; - } + if (ega->seqregs[1] & 8) { + for (xx = start; xx < (start + width); xx++) + for (xxx = 0; xxx < cw; xxx++) + screen->line[dl][(((x * width) + 32 + (xxx << 1) + ((xx << 1) * cw)) & 2047) + x_add].val = screen->line[dl][(((x * width) + 33 + (xxx << 1) + ((xx << 1) * cw)) & 2047) + x_add].val = (dat & (0x80 >> xx)) ? fg : bg; + } else { + for (xx = start; xx < (start + width); xx++) + screen->line[dl][(((x * width) + 32 + xxx + (xx * cw)) & 2047) + x_add].val = (dat & (0x80 >> xx)) ? fg : bg; + } } -void ega_render_text_jega(ega_t *ega, int draw) + +void +ega_render_text_jega(ega_t *ega, int draw) { - int dl = ega_display_line(ega); - uint8_t chr, attr; - uint16_t dat = 0, dat2; - int x; - uint32_t fg = 0, bg = 0; + int dl = ega_display_line(ega); + uint8_t chr, attr; + uint16_t dat = 0, dat2; + uint32_t fg = 0, bg = 0; + int x; - /* Temporary for DBCS. */ - unsigned int chr_left = 0; - unsigned int bsattr = 0; - int chr_wide = 0; - uint32_t bg_ex = 0; - uint32_t fg_ex = 0; + /* Temporary for DBCS. */ + unsigned int chr_left = 0; + unsigned int bsattr = 0; + int chr_wide = 0; + uint32_t bg_ex = 0; + uint32_t fg_ex = 0; - int blocks = ega->hdisp; - int fline; + int blocks = ega->hdisp; + int fline; - unsigned int pad_y, exattr; + unsigned int pad_y, exattr; - if (fullchange) - { - for (x = 0; x < ega->hdisp; x++) - { - draw = ((ega->ma == ega->ca) && ega->con && ega->cursoron); - chr = ega->vram[(ega->ma << 1) & ega->vrammask]; - attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask]; + if (fullchange) { + for (x = 0; x < ega->hdisp; x++) { + draw = ((ega->ma == ega->ca) && ega->con && ega->cursoron); + chr = ega->vram[(ega->ma << 1) & ega->vrammask]; + attr = ega->vram[((ega->ma << 1) + 1) & ega->vrammask]; - if (chr_wide == 0) - { - if (ega->RMOD2 & 0x80) - { + if (chr_wide == 0) { + if (ega->RMOD2 & 0x80) { + fg_ex = ega->pallook[ega->egapal[attr & 15]]; + + if (attr & 0x80 && ega->attrregs[0x10] & 8) { + bg_ex = ega->pallook[ega->egapal[(attr >> 4) & 7]]; + } else { + bg_ex = ega->pallook[ega->egapal[attr >> 4]]; + } + } else { + if (attr & 0x40) { + /* Reversed in JEGA mode */ + bg_ex = ega->pallook[ega->egapal[attr & 15]]; + fg_ex = ega->pallook[0]; + } else { + /* Reversed in JEGA mode */ fg_ex = ega->pallook[ega->egapal[attr & 15]]; - - if (attr & 0x80 && ega->attrregs[0x10] & 8) - { - bg_ex = ega->pallook[ega->egapal[(attr >> 4) & 7]]; - } - else - { - bg_ex = ega->pallook[ega->egapal[attr >> 4]]; - } - } - else - { - if (attr & 0x40) - { - /* Reversed in JEGA mode */ - bg_ex = ega->pallook[ega->egapal[attr & 15]]; - fg_ex = ega->pallook[0]; - } - else - { - /* Reversed in JEGA mode */ - fg_ex = ega->pallook[ega->egapal[attr & 15]]; - bg_ex = ega->pallook[0]; - } - } - - if (draw) - { - bg = fg_ex; - fg = bg_ex; - } - else - { - fg = fg_ex; - bg = bg_ex; - } - - if (attr & 0x80 && ega->attrregs[0x10] & 8) - { - if (ega->blink & 16) - fg = bg; - } - - /* Stay drawing if the char code is DBCS and not at last column. */ - if (is_kanji1(dat) && (blocks > 1)) - { - /* Set the present char/attr code to the next loop. */ - chr_left = chr; - chr_wide = 1; - } - else - { - /* The char code is ANK (8 dots width). */ - dat = jfont_sbcs_19[chr*19+(ega->sc)]; /* w8xh19 font */ - ega_jega_render_blit_text(ega, x, dl, 0, 8, dat, 1, fg, bg); - if (bsattr & 0x20) - { - /* Vertical line. */ - dat = 0x18; - ega_jega_render_blit_text(ega, x, fline, 0, 8, dat, 1, fg, bg); - } - if (ega->sc == 18 && bsattr & 0x10) - { - /* Underline. */ - dat = 0xff; - ega_jega_render_blit_text(ega, x, fline, 0, 8, dat, 1, fg, bg); - } - chr_wide = 0; - blocks--; + bg_ex = ega->pallook[0]; } } - else - { - /* The char code may be in DBCS. */ - pad_y = ega->RPSSC; - exattr = 0; - /* Note: The second column should be applied its basic attribute. */ - if (ega->RMOD2 & 0x40) - { - /* If JEGA Extended Attribute is enabled. */ - exattr = attr; - if ((exattr & 0x30) == 0x30) pad_y = ega->RPSSL; /* Set top padding of lower 2x character. */ - else if (exattr & 0x30) pad_y = ega->RPSSU; /* Set top padding of upper 2x character. */ + if (draw) { + bg = fg_ex; + fg = bg_ex; + } else { + fg = fg_ex; + bg = bg_ex; + } + + if (attr & 0x80 && ega->attrregs[0x10] & 8) { + if (ega->blink & 16) + fg = bg; + } + + /* Stay drawing if the char code is DBCS and not at last column. */ + if (is_kanji1(dat) && (blocks > 1)) { + /* Set the present char/attr code to the next loop. */ + chr_left = chr; + chr_wide = 1; + } else { + /* The char code is ANK (8 dots width). */ + dat = jfont_sbcs_19[chr*19+(ega->sc)]; /* w8xh19 font */ + ega_jega_render_blit_text(ega, x, dl, 0, 8, dat, 1, fg, bg); + if (bsattr & 0x20) { + /* Vertical line. */ + dat = 0x18; + ega_jega_render_blit_text(ega, x, fline, 0, 8, dat, 1, fg, bg); } + if (ega->sc == 18 && bsattr & 0x10) { + /* Underline. */ + dat = 0xff; + ega_jega_render_blit_text(ega, x, fline, 0, 8, dat, 1, fg, bg); + } + chr_wide = 0; + blocks--; + } + } else { + /* The char code may be in DBCS. */ + pad_y = ega->RPSSC; + exattr = 0; - if (ega->sc >= pad_y && ega->sc < 16 + pad_y) - { - /* Check the char code is in Wide charset of Shift-JIS. */ - if (is_kanji2(chr)) - { - fline = ega->sc - pad_y; - chr_left <<= 8; - /* Fix vertical position. */ - chr |= chr_left; - /* Horizontal wide font (Extended Attribute). */ - if (exattr & 0x20) - { - if (exattr & 0x10) fline = (fline >> 1) + 8; - else fline = fline >> 1; - } - /* Vertical wide font (Extended Attribute). */ - if (exattr & 0x40) - { - dat = jfont_dbcs_16[chr * 32 + fline * 2]; - if (!(exattr & 0x08)) - dat = jfont_dbcs_16[chr * 32 + fline * 2 + 1]; - /* Draw 8 dots. */ - ega_jega_render_blit_text(ega, x, dl, 0, 8, dat, 2, fg, bg); - } - else - { - /* Get the font pattern. */ - dat = jfont_dbcs_16[chr * 32 + fline * 2]; - dat <<= 8; - dat |= jfont_dbcs_16[chr * 32 + fline * 2 + 1]; - /* Bold (Extended Attribute). */ - if (exattr &= 0x80) - { - dat2 = dat; - dat2 >>= 1; - dat |= dat2; - /* Original JEGA colours the last row with the next column's attribute. */ - } - /* Draw 16 dots */ - ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); - } + /* Note: The second column should be applied its basic attribute. */ + if (ega->RMOD2 & 0x40) { + /* If JEGA Extended Attribute is enabled. */ + exattr = attr; + if ((exattr & 0x30) == 0x30) pad_y = ega->RPSSL; /* Set top padding of lower 2x character. */ + else if (exattr & 0x30) pad_y = ega->RPSSU; /* Set top padding of upper 2x character. */ + } + + if (ega->sc >= pad_y && ega->sc < 16 + pad_y) { + /* Check the char code is in Wide charset of Shift-JIS. */ + if (is_kanji2(chr)) { + fline = ega->sc - pad_y; + chr_left <<= 8; + /* Fix vertical position. */ + chr |= chr_left; + /* Horizontal wide font (Extended Attribute). */ + if (exattr & 0x20) { + if (exattr & 0x10) fline = (fline >> 1) + 8; + else fline = fline >> 1; } - else - { - /* Ignore wide char mode, put blank. */ - dat = 0; + /* Vertical wide font (Extended Attribute). */ + if (exattr & 0x40) { + dat = jfont_dbcs_16[chr * 32 + fline * 2]; + if (!(exattr & 0x08)) + dat = jfont_dbcs_16[chr * 32 + fline * 2 + 1]; + /* Draw 8 dots. */ + ega_jega_render_blit_text(ega, x, dl, 0, 8, dat, 2, fg, bg); + } else { + /* Get the font pattern. */ + dat = jfont_dbcs_16[chr * 32 + fline * 2]; + dat <<= 8; + dat |= jfont_dbcs_16[chr * 32 + fline * 2 + 1]; + /* Bold (Extended Attribute). */ + if (exattr &= 0x80) { + dat2 = dat; + dat2 >>= 1; + dat |= dat2; + /* Original JEGA colours the last row with the next column's attribute. */ + } + /* Draw 16 dots */ ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); } - } - else if (ega->sc == (17 + pad_y) && (bsattr & 0x10)) - { - /* Underline. */ - dat = 0xffff; - ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); - } - else - { - /* Draw blank */ + } else { + /* Ignore wide char mode, put blank. */ dat = 0; ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); } - - if (bsattr & 0x20) - { - /* Vertical line draw at last. */ - dat = 0x0180; - ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); - } - - chr_wide = 0; - blocks -= 2; /* Move by 2 columns. */ + } else if (ega->sc == (17 + pad_y) && (bsattr & 0x10)) { + /* Underline. */ + dat = 0xffff; + ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); + } else { + /* Draw blank */ + dat = 0; + ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); } - ega->ma += 4; - ega->ma &= ega->vrammask; + if (bsattr & 0x20) { + /* Vertical line draw at last. */ + dat = 0x0180; + ega_jega_render_blit_text(ega, x, dl, 0, 16, dat, 1, fg, bg); + } + + chr_wide = 0; + blocks -= 2; /* Move by 2 columns. */ } + + ega->ma += 4; + ega->ma &= ega->vrammask; } + } } #endif -void ega_render_2bpp(ega_t *ega) + +void +ega_render_2bpp(ega_t *ega) { - int x; - int dl = ega_display_line(ega); - int offset = ((8 - ega->scrollcache) << 1) + 16; - - for (x = 0; x <= ega->hdisp; x++) - { - uint8_t edat[2]; - uint32_t addr = ega->ma; - - if (!(ega->crtc[0x17] & 0x40)) - { - addr = (addr << 1) & ega->vrammask; - addr &= ~7; - if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000)) - addr |= 4; - if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000)) - addr |= 4; - } - if (!(ega->crtc[0x17] & 0x01)) - addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0); - if (!(ega->crtc[0x17] & 0x02)) - addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0); - - edat[0] = ega->vram[addr]; - edat[1] = ega->vram[addr | 0x1]; - if (ega->seqregs[1] & 4) - ega->ma += 2; - else - ega->ma += 4; - - ega->ma &= ega->vrammask; - - ((uint32_t *)buffer32->line[dl])[(x << 4) + 14 + offset] = ((uint32_t *)buffer32->line[ega->displine])[(x << 4) + 15 + offset] = ega->pallook[ega->egapal[edat[1] & 3]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 12 + offset] = ((uint32_t *)buffer32->line[ega->displine])[(x << 4) + 13 + offset] = ega->pallook[ega->egapal[(edat[1] >> 2) & 3]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 10 + offset] = ((uint32_t *)buffer32->line[ega->displine])[(x << 4) + 11 + offset] = ega->pallook[ega->egapal[(edat[1] >> 4) & 3]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 8 + offset] = ((uint32_t *)buffer32->line[ega->displine])[(x << 4) + 9 + offset] = ega->pallook[ega->egapal[(edat[1] >> 6) & 3]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 6 + offset] = ((uint32_t *)buffer32->line[ega->displine])[(x << 4) + 7 + offset] = ega->pallook[ega->egapal[(edat[0] >> 0) & 3]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 4 + offset] = ((uint32_t *)buffer32->line[ega->displine])[(x << 4) + 5 + offset] = ega->pallook[ega->egapal[(edat[0] >> 2) & 3]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 2 + offset] = ((uint32_t *)buffer32->line[ega->displine])[(x << 4) + 3 + offset] = ega->pallook[ega->egapal[(edat[0] >> 4) & 3]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + offset] = ((uint32_t *)buffer32->line[ega->displine])[(x << 4) + 1 + offset] = ega->pallook[ega->egapal[(edat[0] >> 6) & 3]]; - } -} - -void ega_render_4bpp_lowres(ega_t *ega) -{ - int x_add = (enable_overscan) ? 8 : 0; - int dl = ega_display_line(ega); - int x; - int offset = ((8 - ega->scrollcache) << 1) + 16; - - for (x = 0; x <= ega->hdisp; x++) - { - uint8_t edat[4]; - uint8_t dat; - uint32_t addr = ega->ma; - int oddeven = 0; - - if (!(ega->crtc[0x17] & 0x40)) - { - addr = (addr << 1) & ega->vrammask; - if (ega->seqregs[1] & 4) - oddeven = (addr & 4) ? 1 : 0; - addr &= ~7; - if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000)) - addr |= 4; - if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000)) - addr |= 4; - } - if (!(ega->crtc[0x17] & 0x01)) - addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0); - if (!(ega->crtc[0x17] & 0x02)) - addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0); - - if (ega->seqregs[1] & 4) - { - edat[0] = ega->vram[addr | oddeven]; - edat[2] = ega->vram[addr | oddeven | 0x2]; - edat[1] = edat[3] = 0; - ega->ma += 2; - } - else - { - edat[0] = ega->vram[addr]; - edat[1] = ega->vram[addr | 0x1]; - edat[2] = ega->vram[addr | 0x2]; - edat[3] = ega->vram[addr | 0x3]; - ega->ma += 4; - } - ega->ma &= ega->vrammask; - - dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); - ((uint32_t *)buffer32->line[dl])[(x << 4) + 14 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 15 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 12 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 13 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; - dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2); - ((uint32_t *)buffer32->line[dl])[(x << 4) + 10 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 11 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 8 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 9 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; - dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2); - ((uint32_t *)buffer32->line[dl])[(x << 4) + 6 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 7 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + 4 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 5 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; - dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2); - ((uint32_t *)buffer32->line[dl])[(x << 4) + 2 + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 3 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[dl])[(x << 4) + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 4) + 1 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + int dl = ega_display_line(ega); + int offset = ((8 - ega->scrollcache) << 1) + 16; + int x; + + for (x = 0; x <= ega->hdisp; x++) { + uint8_t edat[2]; + uint32_t addr = ega->ma; + + if (!(ega->crtc[0x17] & 0x40)) { + addr = (addr << 1) & ega->vrammask; + addr &= ~7; + if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000)) + addr |= 4; + if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000)) + addr |= 4; } + if (!(ega->crtc[0x17] & 0x01)) + addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0); + if (!(ega->crtc[0x17] & 0x02)) + addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0); + + edat[0] = ega->vram[addr]; + edat[1] = ega->vram[addr | 0x1]; + if (ega->seqregs[1] & 4) + ega->ma += 2; + else + ega->ma += 4; + + ega->ma &= ega->vrammask; + + screen->line[dl][(x << 4) + 14 + offset].val = screen->line[ega->displine][(x << 4) + 15 + offset].val = ega->pallook[ega->egapal[edat[1] & 3]]; + screen->line[dl][(x << 4) + 12 + offset].val = screen->line[ega->displine][(x << 4) + 13 + offset].val = ega->pallook[ega->egapal[(edat[1] >> 2) & 3]]; + screen->line[dl][(x << 4) + 10 + offset].val = screen->line[ega->displine][(x << 4) + 11 + offset].val = ega->pallook[ega->egapal[(edat[1] >> 4) & 3]]; + screen->line[dl][(x << 4) + 8 + offset].val = screen->line[ega->displine][(x << 4) + 9 + offset].val = ega->pallook[ega->egapal[(edat[1] >> 6) & 3]]; + screen->line[dl][(x << 4) + 6 + offset].val = screen->line[ega->displine][(x << 4) + 7 + offset].val = ega->pallook[ega->egapal[(edat[0] >> 0) & 3]]; + screen->line[dl][(x << 4) + 4 + offset].val = screen->line[ega->displine][(x << 4) + 5 + offset].val = ega->pallook[ega->egapal[(edat[0] >> 2) & 3]]; + screen->line[dl][(x << 4) + 2 + offset].val = screen->line[ega->displine][(x << 4) + 3 + offset].val = ega->pallook[ega->egapal[(edat[0] >> 4) & 3]]; + screen->line[dl][(x << 4) + offset].val = screen->line[ega->displine][(x << 4) + 1 + offset].val = ega->pallook[ega->egapal[(edat[0] >> 6) & 3]]; + } } -void ega_render_4bpp_highres(ega_t *ega) + +void +ega_render_4bpp_lowres(ega_t *ega) { - int x_add = (enable_overscan) ? 8 : 0; - int dl = ega_display_line(ega); - int x; - int offset = (8 - ega->scrollcache) + 24; - - for (x = 0; x <= ega->hdisp; x++) - { - uint8_t edat[4]; - uint8_t dat; - uint32_t addr = ega->ma; - int oddeven = 0; + int x_add = (enable_overscan) ? 8 : 0; + int dl = ega_display_line(ega); + int offset = ((8 - ega->scrollcache) << 1) + 16; + int x; - if (!(ega->crtc[0x17] & 0x40)) - { - addr = (addr << 1) & ega->vrammask; - if (ega->seqregs[1] & 4) - oddeven = (addr & 4) ? 1 : 0; - addr &= ~7; - if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000)) - addr |= 4; - if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000)) - addr |= 4; - } - if (!(ega->crtc[0x17] & 0x01)) - addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0); - if (!(ega->crtc[0x17] & 0x02)) - addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0); + for (x = 0; x <= ega->hdisp; x++) { + uint8_t edat[4]; + uint8_t dat; + uint32_t addr = ega->ma; + int oddeven = 0; - if (ega->seqregs[1] & 4) - { - edat[0] = ega->vram[addr | oddeven]; - edat[2] = ega->vram[addr | oddeven | 0x2]; - edat[1] = edat[3] = 0; - ega->ma += 2; - } - else - { - edat[0] = ega->vram[addr]; - edat[1] = ega->vram[addr | 0x1]; - edat[2] = ega->vram[addr | 0x2]; - edat[3] = ega->vram[addr | 0x3]; - ega->ma += 4; - } - ega->ma &= ega->vrammask; - - dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); - ((uint32_t *)buffer32->line[dl])[(x << 3) + 7 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[dl])[(x << 3) + 6 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; - dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2); - ((uint32_t *)buffer32->line[dl])[(x << 3) + 5 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[dl])[(x << 3) + 4 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; - dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2); - ((uint32_t *)buffer32->line[dl])[(x << 3) + 3 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[dl])[(x << 3) + 2 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; - dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2); - ((uint32_t *)buffer32->line[dl])[(x << 3) + 1 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[dl])[(x << 3) + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + if (!(ega->crtc[0x17] & 0x40)) { + addr = (addr << 1) & ega->vrammask; + if (ega->seqregs[1] & 4) + oddeven = (addr & 4) ? 1 : 0; + addr &= ~7; + if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000)) + addr |= 4; + if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000)) + addr |= 4; } + if (!(ega->crtc[0x17] & 0x01)) + addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0); + if (!(ega->crtc[0x17] & 0x02)) + addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0); + + if (ega->seqregs[1] & 4) { + edat[0] = ega->vram[addr | oddeven]; + edat[2] = ega->vram[addr | oddeven | 0x2]; + edat[1] = edat[3] = 0; + ega->ma += 2; + } else { + edat[0] = ega->vram[addr]; + edat[1] = ega->vram[addr | 0x1]; + edat[2] = ega->vram[addr | 0x2]; + edat[3] = ega->vram[addr | 0x3]; + ega->ma += 4; + } + ega->ma &= ega->vrammask; + + dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); + screen->line[dl][(x << 4) + 14 + offset + x_add].val = screen->line[dl][(x << 4) + 15 + offset + x_add].val = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; + screen->line[dl][(x << 4) + 12 + offset + x_add].val = screen->line[dl][(x << 4) + 13 + offset + x_add].val = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + + dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2); + screen->line[dl][(x << 4) + 10 + offset + x_add].val = screen->line[dl][(x << 4) + 11 + offset + x_add].val = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; + screen->line[dl][(x << 4) + 8 + offset + x_add].val = screen->line[dl][(x << 4) + 9 + offset + x_add].val = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + + dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2); + screen->line[dl][(x << 4) + 6 + offset + x_add].val = screen->line[dl][(x << 4) + 7 + offset + x_add].val = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; + screen->line[dl][(x << 4) + 4 + offset + x_add].val = screen->line[dl][(x << 4) + 5 + offset + x_add].val = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + + dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2); + screen->line[dl][(x << 4) + 2 + offset + x_add].val = screen->line[dl][(x << 4) + 3 + offset + x_add].val = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; + screen->line[dl][(x << 4) + offset + x_add].val = screen->line[dl][(x << 4) + 1 + offset + x_add].val = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + } +} + + +void +ega_render_4bpp_highres(ega_t *ega) +{ + int x_add = (enable_overscan) ? 8 : 0; + int dl = ega_display_line(ega); + int offset = (8 - ega->scrollcache) + 24; + int x; + + for (x = 0; x <= ega->hdisp; x++) { + uint8_t edat[4]; + uint8_t dat; + uint32_t addr = ega->ma; + int oddeven = 0; + + if (!(ega->crtc[0x17] & 0x40)) { + addr = (addr << 1) & ega->vrammask; + if (ega->seqregs[1] & 4) + oddeven = (addr & 4) ? 1 : 0; + addr &= ~7; + if ((ega->crtc[0x17] & 0x20) && (ega->ma & 0x20000)) + addr |= 4; + if (!(ega->crtc[0x17] & 0x20) && (ega->ma & 0x8000)) + addr |= 4; + } + if (!(ega->crtc[0x17] & 0x01)) + addr = (addr & ~0x8000) | ((ega->sc & 1) ? 0x8000 : 0); + if (!(ega->crtc[0x17] & 0x02)) + addr = (addr & ~0x10000) | ((ega->sc & 2) ? 0x10000 : 0); + + if (ega->seqregs[1] & 4) { + edat[0] = ega->vram[addr | oddeven]; + edat[2] = ega->vram[addr | oddeven | 0x2]; + edat[1] = edat[3] = 0; + ega->ma += 2; + } else { + edat[0] = ega->vram[addr]; + edat[1] = ega->vram[addr | 0x1]; + edat[2] = ega->vram[addr | 0x2]; + edat[3] = ega->vram[addr | 0x3]; + ega->ma += 4; + } + ega->ma &= ega->vrammask; + + dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); + screen->line[dl][(x << 3) + 7 + offset + x_add].val = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; + screen->line[dl][(x << 3) + 6 + offset + x_add].val = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + + dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2); + screen->line[dl][(x << 3) + 5 + offset + x_add].val = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; + screen->line[dl][(x << 3) + 4 + offset + x_add].val = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + + dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2); + screen->line[dl][(x << 3) + 3 + offset + x_add].val = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; + screen->line[dl][(x << 3) + 2 + offset + x_add].val = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + + dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2); + screen->line[dl][(x << 3) + 1 + offset + x_add].val = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; + screen->line[dl][(x << 3) + offset + x_add].val = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + } } diff --git a/src/devices/video/vid_et4000w32.c b/src/devices/video/vid_et4000w32.c index 68d9c85..04b642e 100644 --- a/src/devices/video/vid_et4000w32.c +++ b/src/devices/video/vid_et4000w32.c @@ -12,13 +12,13 @@ * * FIXME: Note the madness on line 1163, fix that somehow? --FvK * - * Version: @(#)vid_et4000w32.c 1.0.16 2018/10/20 + * Version: @(#)vid_et4000w32.c 1.0.17 2010/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -1094,17 +1094,17 @@ static void et4000w32p_hwcursor_draw(svga_t *svga, int displine) for (x = 0; x < 64 - svga->hwcursor_latch.xoff; x += 4) { dat = svga->vram[svga->hwcursor_latch.addr + (offset >> 2)]; - if (!(dat & 2)) ((uint32_t *)buffer32->line[displine + y_add])[svga->hwcursor_latch.x + x_add + x + 32] = (dat & 1) ? 0xFFFFFF : 0; - else if ((dat & 3) == 3) ((uint32_t *)buffer32->line[displine + y_add])[svga->hwcursor_latch.x + x_add + x + 32] ^= 0xFFFFFF; + if (!(dat & 2)) screen->line[displine + y_add][svga->hwcursor_latch.x + x_add + x + 32].val = (dat & 1) ? 0xFFFFFF : 0; + else if ((dat & 3) == 3) screen->line[displine + y_add][svga->hwcursor_latch.x + x_add + x + 32].val ^= 0xFFFFFF; dat >>= 2; - if (!(dat & 2)) ((uint32_t *)buffer32->line[displine + y_add])[svga->hwcursor_latch.x + x_add + x + 33 + x_add] = (dat & 1) ? 0xFFFFFF : 0; - else if ((dat & 3) == 3) ((uint32_t *)buffer32->line[displine + y_add])[svga->hwcursor_latch.x + x_add + x + 33 + x_add] ^= 0xFFFFFF; + if (!(dat & 2)) screen->line[displine + y_add][svga->hwcursor_latch.x + x_add + x + 33 + x_add].val = (dat & 1) ? 0xFFFFFF : 0; + else if ((dat & 3) == 3) screen->line[displine + y_add][svga->hwcursor_latch.x + x_add + x + 33 + x_add].val ^= 0xFFFFFF; dat >>= 2; - if (!(dat & 2)) ((uint32_t *)buffer32->line[displine + y_add])[svga->hwcursor_latch.x + x_add + x + 34] = (dat & 1) ? 0xFFFFFF : 0; - else if ((dat & 3) == 3) ((uint32_t *)buffer32->line[displine + y_add])[svga->hwcursor_latch.x + x_add + x + 34] ^= 0xFFFFFF; + if (!(dat & 2)) screen->line[displine + y_add][svga->hwcursor_latch.x + x_add + x + 34].val = (dat & 1) ? 0xFFFFFF : 0; + else if ((dat & 3) == 3) screen->line[displine + y_add][svga->hwcursor_latch.x + x_add + x + 34].val ^= 0xFFFFFF; dat >>= 2; - if (!(dat & 2)) ((uint32_t *)buffer32->line[displine + y_add])[svga->hwcursor_latch.x + x_add + x + 35] = (dat & 1) ? 0xFFFFFF : 0; - else if ((dat & 3) == 3) ((uint32_t *)buffer32->line[displine + y_add])[svga->hwcursor_latch.x + x_add + x + 35] ^= 0xFFFFFF; + if (!(dat & 2)) screen->line[displine + y_add][svga->hwcursor_latch.x + x_add + x + 35].val = (dat & 1) ? 0xFFFFFF : 0; + else if ((dat & 3) == 3) screen->line[displine + y_add][svga->hwcursor_latch.x + x_add + x + 35].val ^= 0xFFFFFF; dat >>= 2; offset += 4; } diff --git a/src/devices/video/vid_genius.c b/src/devices/video/vid_genius.c index 4aef9d4..24108b3 100644 --- a/src/devices/video/vid_genius.c +++ b/src/devices/video/vid_genius.c @@ -63,7 +63,7 @@ * reducing the height of characters so they fit in an 8x12 cell * if necessary. * - * Version: @(#)vid_genius.c 1.0.9 2019/03/03 + * Version: @(#)vid_genius.c 1.0.10 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -154,7 +154,7 @@ typedef struct { uint32_t pal[4]; - int cols[256][2][2]; + uint32_t cols[256][2][2]; uint8_t fontdat[256][16]; @@ -311,7 +311,7 @@ text_line(genius_t *dev, uint8_t background) { int x; int w = 80; /* 80 characters across */ - int cw = 9; /* Each character is 9 pixels wide */ + int cw = 9; /* Each character is 9 pixels wide */ uint8_t chr, attr; uint8_t bitmap[2]; int blink, c, row; @@ -321,7 +321,7 @@ text_line(genius_t *dev, uint8_t background) int charh; uint16_t ma = (dev->mda_crtc[13] | (dev->mda_crtc[12] << 8)) & 0x3fff; uint16_t ca = (dev->mda_crtc[15] | (dev->mda_crtc[14] << 8)) & 0x3fff; - unsigned char *framebuf = dev->vram + 0x10000; + uint8_t *framebuf = dev->vram + 0x10000; uint32_t col; /* Character height is 12-15 */ @@ -369,7 +369,7 @@ text_line(genius_t *dev, uint8_t background) for (c = 0; c < cw; c++) { if (col != background) - ((uint32_t *)buffer32->line[dev->displine])[(x * cw) + c] = col; + screen->line[dev->displine][(x * cw) + c].val = col; } } else { /* Draw 8 pixels of character */ @@ -383,15 +383,15 @@ text_line(genius_t *dev, uint8_t background) col ^= 0xffffff; if (col != background) - ((uint32_t *)buffer32->line[dev->displine])[(x * cw) + c] = col; + screen->line[dev->displine][(x * cw) + c].val = col; } /* The ninth pixel column... */ if ((chr & ~0x1f) == 0xc0) { /* Echo column 8 for the graphics chars */ - col = ((uint32_t *)buffer32->line[dev->displine])[(x * cw) + 7]; + col = screen->line[dev->displine][(x * cw) + 7].val; if (col != background) - ((uint32_t *)buffer32->line[dev->displine])[(x * cw) + 8] = col; + screen->line[dev->displine][(x * cw) + 8].val = col; } else { /* Otherwise fill with background */ col = dev->cols[attr][blink][0]; @@ -400,11 +400,11 @@ text_line(genius_t *dev, uint8_t background) if (col != background) if (col != background) - ((uint32_t *)buffer32->line[dev->displine])[(x * cw) + 8] = col; + screen->line[dev->displine][(x * cw) + 8].val = col; } if (drawcursor) { for (c = 0; c < cw; c++) - ((uint32_t *)buffer32->line[dev->displine])[(x * cw) + c] ^= dev->cols[attr][0][1]; + screen->line[dev->displine][(x * cw) + c].val ^= dev->cols[attr][0][1]; } ++ma; } @@ -416,10 +416,10 @@ text_line(genius_t *dev, uint8_t background) static void cga_line(genius_t *dev) { - int x, c; uint32_t dat; uint32_t ink; uint32_t addr; + int x, c; ink = (dev->genius_control & 0x20) ? dev->pal[0] : dev->pal[3]; @@ -436,7 +436,7 @@ cga_line(genius_t *dev) for (c = 0; c < 8; c++) { if (dat & 0x80) - ((uint32_t *)buffer32->line[dev->displine])[x*8 + c] = ink; + screen->line[dev->displine][x*8 + c].val = ink; dat = dat << 1; } } @@ -447,10 +447,10 @@ cga_line(genius_t *dev) static void hires_line(genius_t *dev) { - int x, c; uint32_t dat; uint32_t ink; uint32_t addr; + int x, c; ink = (dev->genius_control & 0x20) ? dev->pal[0] : dev->pal[3]; @@ -468,7 +468,7 @@ hires_line(genius_t *dev) for (c = 0; c < 8; c++) { if (dat & 0x80) - ((uint32_t *)buffer32->line[dev->displine])[x*8 + c] = ink; + screen->line[dev->displine][x*8 + c].val = ink; dat = dat << 1; } } @@ -494,11 +494,11 @@ genius_poll(void *priv) background = dev->pal[0]; if (dev->displine == 0) - video_wait_for_buffer(); + video_blit_wait_buffer(); /* Start off with a blank line */ for (x = 0; x < GENIUS_XSIZE; x++) - ((uint32_t *)buffer32->line[dev->displine])[x] = background; + screen->line[dev->displine][x].val = background; /* If graphics display enabled, draw graphics on top * of the blanked line */ @@ -549,8 +549,8 @@ genius_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + video_blit_start(0, 0, 0, 0, ysize, xsize, ysize); frames++; /* Fixed 728x1008 resolution */ diff --git a/src/devices/video/vid_hercules.c b/src/devices/video/vid_hercules.c index f656afa..4c07590 100644 --- a/src/devices/video/vid_hercules.c +++ b/src/devices/video/vid_hercules.c @@ -8,7 +8,7 @@ * * Hercules emulation. * - * Version: @(#)vid_hercules.c 1.0.14 2019/02/12 + * Version: @(#)vid_hercules.c 1.0.15 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -84,7 +84,7 @@ typedef struct { int blend; int64_t vsynctime; - int cols[256][2][2]; + uint8_t cols[256][2][2]; uint8_t *vram; } hercules_t; @@ -256,8 +256,8 @@ hercules_poll(void *priv) if (dev->dispon) { if (dev->displine < dev->firstline) { - dev->firstline = dev->displine; - video_wait_for_buffer(); + dev->firstline = dev->displine; + video_blit_wait_buffer(); } dev->lastline = dev->displine; @@ -273,7 +273,7 @@ hercules_poll(void *priv) dat = 0; dev->ma++; for (c = 0; c < 16; c++) { - buffer->line[dev->displine][(x << 4) + c] = (dat & (32768 >> c)) ? 7 : 0; + screen->line[dev->displine][(x << 4) + c].pal = (dat & (32768 >> c)) ? 7 : 0; } @@ -294,21 +294,21 @@ hercules_poll(void *priv) if (dev->sc == 12 && ((attr & 7) == 1)) { for (c = 0; c < 9; c++) - buffer->line[dev->displine][(x * 9) + c] = dev->cols[attr][blink][1]; + screen->line[dev->displine][(x * 9) + c].pal = dev->cols[attr][blink][1]; } else { for (c = 0; c < 8; c++) - buffer->line[dev->displine][(x * 9) + c] = dev->cols[attr][blink][(fontdatm[chr][dev->sc] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->displine][(x * 9) + c].pal = dev->cols[attr][blink][(fontdatm[chr][dev->sc] & (1 << (c ^ 7))) ? 1 : 0]; if ((chr & ~0x1f) == 0xc0) - buffer->line[dev->displine][(x * 9) + 8] = dev->cols[attr][blink][fontdatm[chr][dev->sc] & 1]; + screen->line[dev->displine][(x * 9) + 8].pal = dev->cols[attr][blink][fontdatm[chr][dev->sc] & 1]; else - buffer->line[dev->displine][(x * 9) + 8] = dev->cols[attr][blink][0]; + screen->line[dev->displine][(x * 9) + 8].pal = dev->cols[attr][blink][0]; } dev->ma++; if (drawcursor) { for (c = 0; c < 9; c++) - buffer->line[dev->displine][(x * 9) + c] ^= dev->cols[attr][0][1]; + screen->line[dev->displine][(x * 9) + c].pal ^= dev->cols[attr][0][1]; } } } @@ -372,7 +372,7 @@ hercules_poll(void *priv) if (dev->vc == dev->crtc[7]) { dev->dispon = 0; dev->displine = 0; - dev->vsynctime = 16;//(crtcm[3]>>4)+1; + dev->vsynctime = 16; //(crtcm[3]>>4)+1; if (dev->crtc[7]) { if ((dev->ctrl & 2) && (dev->ctrl2 & 1)) x = dev->crtc[1] << 4; @@ -392,8 +392,9 @@ hercules_poll(void *priv) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, dev->firstline, 0, ysize, xsize, ysize); + video_blit_start(1, 0, dev->firstline, 0, ysize, xsize, ysize); frames++; + if ((dev->ctrl & 2) && (dev->ctrl2 & 1)) { video_res_x = dev->crtc[1] * 16; video_res_y = dev->crtc[6] * 4; @@ -480,7 +481,7 @@ hercules_init(const device_t *info) cga_palette = device_get_config_int("rgb_type") << 1; if (cga_palette > 6) cga_palette = 0; - cgapal_rebuild(); + video_palette_rebuild(); video_inform(VID_TYPE_MDA, info->vid_timing); diff --git a/src/devices/video/vid_herculesplus.c b/src/devices/video/vid_herculesplus.c index ce3562f..09df897 100644 --- a/src/devices/video/vid_herculesplus.c +++ b/src/devices/video/vid_herculesplus.c @@ -8,7 +8,7 @@ * * Hercules InColor emulation. * - * Version: @(#)vid_hercules_plus.c 1.0.15 2019/02/12 + * Version: @(#)vid_hercules_plus.c 1.0.16 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -104,7 +104,7 @@ typedef struct { int blend; int64_t vsynctime; - int cols[256][2][2]; + uint8_t cols[256][2][2]; uint8_t *vram; } herculesplus_t; @@ -275,7 +275,7 @@ draw_char_rom(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) } for (i = 0; i < cw; i++) { - buffer->line[dev->displine][x * cw + i] = (val & 0x100) ? ifg : ibg; + screen->line[dev->displine][x * cw + i].pal = (val & 0x100) ? ifg : ibg; val = val << 1; } } @@ -338,7 +338,7 @@ draw_char_ram4(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) if ((attr & 0x77) == 0) cfg = ibg; /* 'blank' attribute */ - buffer->line[dev->displine][x * cw + i] = dev->cols[attr][blink][cfg]; + screen->line[dev->displine][x * cw + i].pal = dev->cols[attr][blink][cfg]; val = val << 1; } } @@ -423,7 +423,7 @@ draw_char_ram48(herculesplus_t *dev, int x, uint8_t chr, uint8_t attr) else cfg |= ibg; - buffer->line[dev->displine][(x * cw) + i] = dev->cols[attr][blink][cfg]; + screen->line[dev->displine][(x * cw) + i].pal = dev->cols[attr][blink][cfg]; val = val << 1; } } @@ -467,7 +467,7 @@ text_line(herculesplus_t *dev, uint16_t ca) col = dev->cols[attr][0][1]; for (c = 0; c < cw; c++) - buffer->line[dev->displine][x * cw + c] = col; + screen->line[dev->displine][x * cw + c].pal = col; } } } @@ -496,7 +496,7 @@ graphics_line(herculesplus_t *dev) for (c = 0; c < 16; c++) { val >>= 1; - buffer->line[dev->displine][(x << 4) + c] = (val & 1) ? 7 : 0; + screen->line[dev->displine][(x << 4) + c].pal = (val & 1) ? 7 : 0; } if (dev->blend) { @@ -524,9 +524,10 @@ herculesplus_poll(void *priv) if (dev->dispon) { if (dev->displine < dev->firstline) { dev->firstline = dev->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } dev->lastline = dev->displine; + if ((dev->ctrl & HERCULESPLUS_CTRL_GRAPH) && (dev->ctrl2 & HERCULESPLUS_CTRL2_GRAPH)) graphics_line(dev); else @@ -604,8 +605,10 @@ herculesplus_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, dev->firstline, 0, dev->lastline - dev->firstline, xsize, dev->lastline - dev->firstline); + + video_blit_start(1, 0, dev->firstline, 0, dev->lastline - dev->firstline, xsize, dev->lastline - dev->firstline); frames++; + if ((dev->ctrl & HERCULESPLUS_CTRL_GRAPH) && (dev->ctrl2 & HERCULESPLUS_CTRL2_GRAPH)) { video_res_x = dev->crtc[1] * 16; video_res_y = dev->crtc[6] * 4; @@ -646,7 +649,7 @@ herculesplus_init(const device_t *info) cga_palette = device_get_config_int("rgb_type") << 1; if (cga_palette > 6) cga_palette = 0; - cgapal_rebuild(); + video_palette_rebuild(); dev->vram = (uint8_t *)mem_alloc(0x10000); /* 64k VRAM */ diff --git a/src/devices/video/vid_incolor.c b/src/devices/video/vid_incolor.c index 2964c74..90f4b07 100644 --- a/src/devices/video/vid_incolor.c +++ b/src/devices/video/vid_incolor.c @@ -8,7 +8,7 @@ * * Hercules InColor emulation. * - * Version: @(#)vid_incolor.c 1.0.13 2019/02/12 + * Version: @(#)vid_incolor.c 1.0.14 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -102,7 +102,7 @@ /* Default palette */ static const uint8_t defpal[16] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f }; /* Mapping of inks to RGB */ @@ -319,14 +319,14 @@ static void incolor_write(uint32_t addr, uint8_t val, void *priv) { incolor_t *dev = (incolor_t *)priv; - unsigned char wmask = dev->crtc[INCOLOR_CRTC_MASK]; - unsigned char wmode = dev->crtc[INCOLOR_CRTC_RWCTRL] & INCOLOR_RWCTRL_WRMODE; - unsigned char fg = dev->crtc[INCOLOR_CRTC_RWCOL] & 0x0F; - unsigned char bg = (dev->crtc[INCOLOR_CRTC_RWCOL] >> 4)&0x0F; - unsigned char w = 0; - unsigned char vmask; /* Mask of bit within byte */ - unsigned char pmask; /* Mask of plane within colour value */ - unsigned char latch; + uint8_t wmask = dev->crtc[INCOLOR_CRTC_MASK]; + uint8_t wmode = dev->crtc[INCOLOR_CRTC_RWCTRL] & INCOLOR_RWCTRL_WRMODE; + uint8_t fg = dev->crtc[INCOLOR_CRTC_RWCOL] & 0x0F; + uint8_t bg = (dev->crtc[INCOLOR_CRTC_RWCOL] >> 4)&0x0F; + uint8_t w = 0; + uint8_t vmask; /* Mask of bit within byte */ + uint8_t pmask; /* Mask of plane within colour value */ + uint8_t latch; int plane; addr &= 0xffff; @@ -385,13 +385,13 @@ static uint8_t incolor_read(uint32_t addr, void *priv) { incolor_t *dev = (incolor_t *)priv; - unsigned plane; - unsigned char lp = dev->crtc[INCOLOR_CRTC_PROTECT]; - unsigned char value = 0; - unsigned char dc; /* "don't care" register */ - unsigned char bg; /* background colour */ - unsigned char fg; - unsigned char mask, pmask; + uint8_t plane; + uint8_t lp = dev->crtc[INCOLOR_CRTC_PROTECT]; + uint8_t value = 0; + uint8_t dc; /* "don't care" register */ + uint8_t bg; /* background colour */ + uint8_t fg; + uint8_t mask, pmask; addr &= 0xffff; @@ -433,99 +433,78 @@ incolor_read(uint32_t addr, void *priv) static void draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { - int i; - int elg, blk; - unsigned ull; - unsigned val; - unsigned ifg, ibg; - const unsigned char *fnt; - uint32_t fg, bg; - int cw = INCOLOR_CW; + const uint8_t *fnt; + unsigned ull; + unsigned val; + unsigned ifg, ibg; + uint32_t fg, bg; + int cw = INCOLOR_CW; + int elg, blk; + int i; - blk = 0; - if (dev->ctrl & INCOLOR_CTRL_BLINK) - { - if (attr & 0x80) - { - blk = (dev->blink & 16); - } - attr &= 0x7f; + blk = 0; + if (dev->ctrl & INCOLOR_CTRL_BLINK) { + if (attr & 0x80) + blk = (dev->blink & 16); + attr &= 0x7f; + } + + if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR) { + /* MDA-compatible attributes */ + ibg = 0; + ifg = 7; + if ((attr & 0x77) == 0x70) { + ifg = 0; /* Invert */ + ibg = 7; + } + if (attr & 8) { + ifg |= 8; /* High intensity FG */ } - - if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR) - { - /* MDA-compatible attributes */ - ibg = 0; - ifg = 7; - if ((attr & 0x77) == 0x70) /* Invert */ - { - ifg = 0; - ibg = 7; - } - if (attr & 8) - { - ifg |= 8; /* High intensity FG */ - } - if (attr & 0x80) - { - ibg |= 8; /* High intensity BG */ - } - if ((attr & 0x77) == 0) /* Blank */ - { - ifg = ibg; - } - ull = ((attr & 0x07) == 1) ? 13 : 0xffff; - } - else - { + if (attr & 0x80) { + ibg |= 8; /* High intensity BG */ + } + if ((attr & 0x77) == 0) /* Blank */ { + ifg = ibg; + } + ull = ((attr & 0x07) == 1) ? 13 : 0xffff; + } else { /* CGA-compatible attributes */ ull = 0xffff; ifg = attr & 0x0F; ibg = (attr >> 4) & 0x0F; } - if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) - { + if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) { fg = dev->rgb[dev->palette[ifg]]; bg = dev->rgb[dev->palette[ibg]]; - } - else - { + } else { fg = dev->rgb[defpal[ifg]]; bg = dev->rgb[defpal[ibg]]; } /* ELG set to stretch 8px character to 9px */ - if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) - { + if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) { elg = 0; - } - else - { + } else { elg = ((chr >= 0xc0) && (chr <= 0xdf)); } fnt = &(fontdatm[chr][dev->sc]); - if (blk) - { + if (blk) { val = 0x000; /* Blinking, draw all background */ - } - else if (dev->sc == ull) - { + } else if (dev->sc == ull) { val = 0x1ff; /* Underscore, draw all foreground */ - } - else + } else { val = fnt[0] << 1; - if (elg) - { + if (elg) { val |= (val >> 1) & 1; } } - for (i = 0; i < cw; i++) - { - ((uint32_t *)buffer32->line[dev->displine])[x * cw + i] = (val & 0x100) ? fg : bg; + + for (i = 0; i < cw; i++) { + screen->line[dev->displine][x * cw + i].val = (val & 0x100) ? fg : bg; val = val << 1; } } @@ -534,281 +513,236 @@ draw_char_rom(incolor_t *dev, int x, uint8_t chr, uint8_t attr) static void draw_char_ram4(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { - int i; - int elg, blk; - unsigned ull; - unsigned val[4]; - unsigned ifg, ibg, cfg, pmask, plane; - const unsigned char *fnt; - uint32_t fg; - int cw = INCOLOR_CW; - int blink = dev->ctrl & INCOLOR_CTRL_BLINK; - int altattr = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR; - int palette = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE; + const uint8_t *fnt; + unsigned ull; + unsigned val[4]; + unsigned ifg, ibg, cfg, pmask, plane; + uint32_t fg; + int cw = INCOLOR_CW; + int blink = dev->ctrl & INCOLOR_CTRL_BLINK; + int altattr = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR; + int palette = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE; + int elg, blk; + int i; + + blk = 0; + if (blink) { + if (attr & 0x80) + blk = (dev->blink & 16); + attr &= 0x7f; + } - blk = 0; - if (blink) - { - if (attr & 0x80) - { - blk = (dev->blink & 16); - } - attr &= 0x7f; + if (altattr) { + /* MDA-compatible attributes */ + ibg = 0; + ifg = 7; + if ((attr & 0x77) == 0x70) { + ifg = 0; /* Invert */ + ibg = 7; + } + if (attr & 8) { + ifg |= 8; /* High intensity FG */ + } + if (attr & 0x80) { + ibg |= 8; /* High intensity BG */ + } + if ((attr & 0x77) == 0) { + ifg = ibg; /* Blank */ + } + ull = ((attr & 0x07) == 1) ? 13 : 0xffff; + } else { + /* CGA-compatible attributes */ + ull = 0xffff; + ifg = attr & 0x0F; + ibg = (attr >> 4) & 0x0F; + } + + if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) { + elg = 0; + } else { + elg = ((chr >= 0xc0) && (chr <= 0xdf)); + } + + fnt = dev->vram + 0x4000 + 16 * chr + dev->sc; + + if (blk) { + /* Blinking, draw all background */ + val[0] = val[1] = val[2] = val[3] = 0x000; + } else if (dev->sc == ull) { + /* Underscore, draw all foreground */ + val[0] = val[1] = val[2] = val[3] = 0x1ff; + } else { + val[0] = fnt[0x00000] << 1; + val[1] = fnt[0x10000] << 1; + val[2] = fnt[0x20000] << 1; + val[3] = fnt[0x30000] << 1; + + if (elg) { + val[0] |= (val[0] >> 1) & 1; + val[1] |= (val[1] >> 1) & 1; + val[2] |= (val[2] >> 1) & 1; + val[3] |= (val[3] >> 1) & 1; + } + } + + for (i = 0; i < cw; i++) { + /* Generate pixel colour */ + cfg = 0; + pmask = 1; + for (plane = 0; plane < 4; plane++, pmask = pmask << 1) { + if (val[plane] & 0x100) + cfg |= (ifg & pmask); + else + cfg |= (ibg & pmask); } - if (altattr) - { - /* MDA-compatible attributes */ - ibg = 0; - ifg = 7; - if ((attr & 0x77) == 0x70) /* Invert */ - { - ifg = 0; - ibg = 7; - } - if (attr & 8) - { - ifg |= 8; /* High intensity FG */ - } - if (attr & 0x80) - { - ibg |= 8; /* High intensity BG */ - } - if ((attr & 0x77) == 0) /* Blank */ - { - ifg = ibg; - } - ull = ((attr & 0x07) == 1) ? 13 : 0xffff; - } - else - { - /* CGA-compatible attributes */ - ull = 0xffff; - ifg = attr & 0x0F; - ibg = (attr >> 4) & 0x0F; + /* cfg = colour of foreground pixels */ + if (altattr && (attr & 0x77) == 0) cfg = ibg; /* 'blank' attribute */ + if (palette) { + fg = dev->rgb[dev->palette[cfg]]; + } else { + fg = dev->rgb[defpal[cfg]]; } - if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) - { - elg = 0; - } - else - { - elg = ((chr >= 0xc0) && (chr <= 0xdf)); - } - fnt = dev->vram + 0x4000 + 16 * chr + dev->sc; - - if (blk) - { - /* Blinking, draw all background */ - val[0] = val[1] = val[2] = val[3] = 0x000; - } - else if (dev->sc == ull) - { - /* Underscore, draw all foreground */ - val[0] = val[1] = val[2] = val[3] = 0x1ff; - } - else - { - val[0] = fnt[0x00000] << 1; - val[1] = fnt[0x10000] << 1; - val[2] = fnt[0x20000] << 1; - val[3] = fnt[0x30000] << 1; - - if (elg) - { - val[0] |= (val[0] >> 1) & 1; - val[1] |= (val[1] >> 1) & 1; - val[2] |= (val[2] >> 1) & 1; - val[3] |= (val[3] >> 1) & 1; - } - } - for (i = 0; i < cw; i++) - { - /* Generate pixel colour */ - cfg = 0; - pmask = 1; - for (plane = 0; plane < 4; plane++, pmask = pmask << 1) - { - if (val[plane] & 0x100) cfg |= (ifg & pmask); - else cfg |= (ibg & pmask); - } - /* cfg = colour of foreground pixels */ - if (altattr && (attr & 0x77) == 0) cfg = ibg; /* 'blank' attribute */ - if (palette) - { - fg = dev->rgb[dev->palette[cfg]]; - } - else - { - fg = dev->rgb[defpal[cfg]]; - } - ((uint32_t *)buffer32->line[dev->displine])[x * cw + i] = fg; - val[0] = val[0] << 1; - val[1] = val[1] << 1; - val[2] = val[2] << 1; - val[3] = val[3] << 1; - } + screen->line[dev->displine][x * cw + i].val = fg; + val[0] = val[0] << 1; + val[1] = val[1] << 1; + val[2] = val[2] << 1; + val[3] = val[3] << 1; + } } static void draw_char_ram48(incolor_t *dev, int x, uint8_t chr, uint8_t attr) { - int i; - int elg, blk, ul, ol, bld; - unsigned ull, oll, ulc = 0, olc = 0; - unsigned val[4]; - unsigned ifg = 0, ibg, cfg, pmask, plane; - const unsigned char *fnt; - uint32_t fg; - int cw = INCOLOR_CW; - int blink = dev->ctrl & INCOLOR_CTRL_BLINK; - int altattr = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR; - int palette = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE; - int font = (attr & 0x0F); + const uint8_t *fnt; + int i; + int elg, blk, ul, ol, bld; + unsigned ull, oll, ulc = 0, olc = 0; + unsigned val[4]; + unsigned ifg = 0, ibg, cfg, pmask, plane; + uint32_t fg; + int cw = INCOLOR_CW; + int blink = dev->ctrl & INCOLOR_CTRL_BLINK; + int altattr = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR; + int palette = dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE; + int font = (attr & 0x0F); - if (font >= 12) font &= 7; + if (font >= 12) font &= 7; - blk = 0; - if (blink && altattr) - { - if (attr & 0x40) - { - blk = (dev->blink & 16); - } - attr &= 0x7f; - } - if (altattr) - { - /* MDA-compatible attributes */ - if (blink) - { - ibg = (attr & 0x80) ? 8 : 0; - bld = 0; - ol = (attr & 0x20) ? 1 : 0; - ul = (attr & 0x10) ? 1 : 0; - } - else - { - bld = (attr & 0x80) ? 1 : 0; - ibg = (attr & 0x40) ? 0x0F : 0; - ol = (attr & 0x20) ? 1 : 0; - ul = (attr & 0x10) ? 1 : 0; - } - } - else - { - /* CGA-compatible attributes */ - ibg = 0; - ifg = (attr >> 4) & 0x0F; - ol = 0; - ul = 0; + blk = 0; + if (blink && altattr) { + if (attr & 0x40) + blk = (dev->blink & 16); + attr &= 0x7f; + } + + if (altattr) { + /* MDA-compatible attributes */ + if (blink) { + ibg = (attr & 0x80) ? 8 : 0; bld = 0; + ol = (attr & 0x20) ? 1 : 0; + ul = (attr & 0x10) ? 1 : 0; + } else { + bld = (attr & 0x80) ? 1 : 0; + ibg = (attr & 0x40) ? 0x0F : 0; + ol = (attr & 0x20) ? 1 : 0; + ul = (attr & 0x10) ? 1 : 0; } - if (ul) - { - ull = dev->crtc[INCOLOR_CRTC_UNDER] & 0x0F; - ulc = (dev->crtc[INCOLOR_CRTC_UNDER] >> 4) & 0x0F; - if (ulc == 0) ulc = 7; - } - else - { - ull = 0xFFFF; + } else { + /* CGA-compatible attributes */ + ibg = 0; + ifg = (attr >> 4) & 0x0F; + ol = 0; + ul = 0; + bld = 0; + } + + if (ul) { + ull = dev->crtc[INCOLOR_CRTC_UNDER] & 0x0F; + ulc = (dev->crtc[INCOLOR_CRTC_UNDER] >> 4) & 0x0F; + if (ulc == 0) ulc = 7; + } else { + ull = 0xFFFF; + } + + if (ol) { + oll = dev->crtc[INCOLOR_CRTC_OVER] & 0x0F; + olc = (dev->crtc[INCOLOR_CRTC_OVER] >> 4) & 0x0F; + if (olc == 0) olc = 7; + } else { + oll = 0xFFFF; + } + + if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) { + elg = 0; + } else { + elg = ((chr >= 0xc0) && (chr <= 0xdf)); + } + + fnt = dev->vram + 0x4000 + 16 * chr + 4096 * font + dev->sc; + + if (blk) { + /* Blinking, draw all background */ + val[0] = val[1] = val[2] = val[3] = 0x000; + } else if (dev->sc == ull) { + /* Underscore, draw all foreground */ + val[0] = val[1] = val[2] = val[3] = 0x1ff; + } else { + val[0] = fnt[0x00000] << 1; + val[1] = fnt[0x10000] << 1; + val[2] = fnt[0x20000] << 1; + val[3] = fnt[0x30000] << 1; + + if (elg) { + val[0] |= (val[0] >> 1) & 1; + val[1] |= (val[1] >> 1) & 1; + val[2] |= (val[2] >> 1) & 1; + val[3] |= (val[3] >> 1) & 1; } - if (ol) - { - oll = dev->crtc[INCOLOR_CRTC_OVER] & 0x0F; - olc = (dev->crtc[INCOLOR_CRTC_OVER] >> 4) & 0x0F; - if (olc == 0) olc = 7; - } - else - { - oll = 0xFFFF; + if (bld) { + val[0] |= (val[0] >> 1); + val[1] |= (val[1] >> 1); + val[2] |= (val[2] >> 1); + val[3] |= (val[3] >> 1); + } + } + + for (i = 0; i < cw; i++) { + /* Generate pixel colour */ + cfg = 0; + pmask = 1; + if (dev->sc == oll) { + cfg = olc ^ ibg; /* Strikethrough */ + } else if (dev->sc == ull) { + cfg = ulc ^ ibg; /* Underline */ + } else { + for (plane = 0; plane < 4; plane++, pmask = pmask << 1) { + if (val[plane] & 0x100) { + if (altattr) + cfg |= ((~ibg) & pmask); + else + cfg |= ((~ifg) & pmask); + } else if (altattr) + cfg |= (ibg & pmask); + } } - if (dev->crtc[INCOLOR_CRTC_XMODE] & INCOLOR_XMODE_90COL) - { - elg = 0; - } - else - { - elg = ((chr >= 0xc0) && (chr <= 0xdf)); + if (palette) { + fg = dev->rgb[dev->palette[cfg]]; + } else { + fg = dev->rgb[defpal[cfg]]; } - fnt = dev->vram + 0x4000 + 16 * chr + 4096 * font + dev->sc; - - if (blk) - { - /* Blinking, draw all background */ - val[0] = val[1] = val[2] = val[3] = 0x000; - } - else if (dev->sc == ull) - { - /* Underscore, draw all foreground */ - val[0] = val[1] = val[2] = val[3] = 0x1ff; - } - else - { - val[0] = fnt[0x00000] << 1; - val[1] = fnt[0x10000] << 1; - val[2] = fnt[0x20000] << 1; - val[3] = fnt[0x30000] << 1; - if (elg) - { - val[0] |= (val[0] >> 1) & 1; - val[1] |= (val[1] >> 1) & 1; - val[2] |= (val[2] >> 1) & 1; - val[3] |= (val[3] >> 1) & 1; - } - if (bld) - { - val[0] |= (val[0] >> 1); - val[1] |= (val[1] >> 1); - val[2] |= (val[2] >> 1); - val[3] |= (val[3] >> 1); - } - } - for (i = 0; i < cw; i++) - { - /* Generate pixel colour */ - cfg = 0; - pmask = 1; - if (dev->sc == oll) - { - cfg = olc ^ ibg; /* Strikethrough */ - } - else if (dev->sc == ull) - { - cfg = ulc ^ ibg; /* Underline */ - } - else - { - for (plane = 0; plane < 4; plane++, pmask = pmask << 1) - { - if (val[plane] & 0x100) - { - if (altattr) cfg |= ((~ibg) & pmask); - else cfg |= ((~ifg) & pmask); - } - else if (altattr) cfg |= (ibg & pmask); - } - } - if (palette) - { - fg = dev->rgb[dev->palette[cfg]]; - } - else - { - fg = dev->rgb[defpal[cfg]]; - } - - ((uint32_t *)buffer32->line[dev->displine])[x * cw + i] = fg; - val[0] = val[0] << 1; - val[1] = val[1] << 1; - val[2] = val[2] << 1; - val[3] = val[3] << 1; - } + screen->line[dev->displine][x * cw + i].val = fg; + + val[0] = val[0] << 1; + val[1] = val[1] << 1; + val[2] = val[2] << 1; + val[3] = val[3] << 1; + } } @@ -852,21 +786,18 @@ text_line(incolor_t *dev, uint16_t ca) /* In MDA-compatible mode, cursor brightness comes from * background */ - if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR) - { + if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_ALTATTR) { ink = (attr & 0x08) | (ink & 7); } - if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) - { + + if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) { col = dev->rgb[dev->palette[ink]]; - } - else - { + } else { col = dev->rgb[defpal[ink]]; } - for (c = 0; c < cw; c++) - { - ((uint32_t *)buffer32->line[dev->displine])[x * cw + c] = col; + + for (c = 0; c < cw; c++) { + screen->line[dev->displine][x * cw + c].val = col; } } } @@ -912,9 +843,10 @@ graphics_line(incolor_t *dev) /* Is palette in use? */ if (dev->crtc[INCOLOR_CRTC_EXCEPT] & INCOLOR_EXCEPT_PALETTE) col = dev->palette[ink]; - else col = defpal[ink]; + else + col = defpal[ink]; - ((uint32_t *)buffer32->line[dev->displine])[(x << 4) + c] = dev->rgb[col]; + screen->line[dev->displine][(x << 4) + c].val = dev->rgb[col]; } } } @@ -925,9 +857,7 @@ incolor_poll(void *priv) { incolor_t *dev = (incolor_t *)priv; uint16_t ca = (dev->crtc[15] | (dev->crtc[14] << 8)) & 0x3fff; - int x; - int oldvc; - int oldsc; + int oldsc, oldvc, x; if (! dev->linepos) { dev->vidtime += dev->dispofftime; @@ -940,7 +870,7 @@ incolor_poll(void *priv) if (dev->dispon) { if (dev->displine < dev->firstline) { dev->firstline = dev->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } dev->lastline = dev->displine; if ((dev->ctrl & INCOLOR_CTRL_GRAPH) && (dev->ctrl2 & INCOLOR_CTRL2_GRAPH)) @@ -1018,8 +948,10 @@ incolor_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, dev->firstline, 0, dev->lastline - dev->firstline, xsize, dev->lastline - dev->firstline); + + video_blit_start(0, 0, dev->firstline, 0, dev->lastline - dev->firstline, xsize, dev->lastline - dev->firstline); frames++; + if ((dev->ctrl & INCOLOR_CTRL_GRAPH) && (dev->ctrl2 & INCOLOR_CTRL2_GRAPH)) { video_res_x = dev->crtc[1] * 16; video_res_y = dev->crtc[6] * 4; diff --git a/src/devices/video/vid_mda.c b/src/devices/video/vid_mda.c index dd86280..9655b0f 100644 --- a/src/devices/video/vid_mda.c +++ b/src/devices/video/vid_mda.c @@ -8,13 +8,13 @@ * * MDA emulation. * - * Version: @(#)vid_mda.c 1.0.9 2018/11/11 + * Version: @(#)vid_mda.c 1.0.10 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -73,7 +73,7 @@ typedef struct { int64_t vsynctime; int vadj; - int cols[256][2][2]; + uint8_t cols[256][2][2]; uint8_t *vram; } mda_t; @@ -191,19 +191,23 @@ mda_poll(void *priv) uint8_t chr, attr; int oldsc; int blink; + pel_t *pels; if (! dev->linepos) { dev->vidtime += dev->dispofftime; dev->stat |= 1; dev->linepos = 1; oldsc = dev->sc; + pels = screen->line[dev->displine]; if ((dev->crtc[8] & 3) == 3) dev->sc = (dev->sc << 1) & 7; if (dev->dispon) { - if (dev->displine < dev->firstline) + if (dev->displine < dev->firstline) { dev->firstline = dev->displine; + video_blit_wait_buffer(); + } dev->lastline = dev->displine; for (x = 0; x < dev->crtc[1]; x++) { @@ -213,20 +217,20 @@ mda_poll(void *priv) blink = ((dev->blink & 16) && (dev->ctrl & 0x20) && (attr & 0x80) && !drawcursor); if (dev->sc == 12 && ((attr & 7) == 1)) { for (c = 0; c < 9; c++) - buffer->line[dev->displine][(x * 9) + c] = dev->cols[attr][blink][1]; + pels[(x * 9) + c].pal = dev->cols[attr][blink][1]; } else { for (c = 0; c < 8; c++) - buffer->line[dev->displine][(x * 9) + c] = dev->cols[attr][blink][(fontdatm[chr][dev->sc] & (1 << (c ^ 7))) ? 1 : 0]; + pels[(x * 9) + c].pal = dev->cols[attr][blink][(fontdatm[chr][dev->sc] & (1 << (c ^ 7))) ? 1 : 0]; if ((chr & ~0x1f) == 0xc0) - buffer->line[dev->displine][(x * 9) + 8] = dev->cols[attr][blink][fontdatm[chr][dev->sc] & 1]; + pels[(x * 9) + 8].pal = dev->cols[attr][blink][fontdatm[chr][dev->sc] & 1]; else - buffer->line[dev->displine][(x * 9) + 8] = dev->cols[attr][blink][0]; + pels[(x * 9) + 8].pal = dev->cols[attr][blink][0]; } dev->ma++; if (drawcursor) { for (c = 0; c < 9; c++) - buffer->line[dev->displine][(x * 9) + c] ^= dev->cols[attr][0][1]; + pels[(x * 9) + c].pal ^= dev->cols[attr][0][1]; } } } @@ -236,7 +240,7 @@ mda_poll(void *priv) dev->stat |= 8; dev->displine++; if (dev->displine >= 500) - dev->displine=0; + dev->displine = 0; } else { dev->vidtime += dev->dispontime; if (dev->dispon) @@ -300,8 +304,10 @@ mda_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, dev->firstline, 0, ysize, xsize, ysize); + + video_blit_start(1, 0, dev->firstline, 0, ysize, xsize, ysize); frames++; + video_res_x = dev->crtc[1]; video_res_y = dev->crtc[6]; video_bpp = 0; @@ -372,7 +378,7 @@ mda_init(const device_t *info) cga_palette = device_get_config_int("rgb_type") << 1; if (cga_palette > 6) cga_palette = 0; - cgapal_rebuild(); + video_palette_rebuild(); video_inform(VID_TYPE_MDA, info->vid_timing); diff --git a/src/devices/video/vid_pgc.c b/src/devices/video/vid_pgc.c index eeb25d4..d9a3109 100644 --- a/src/devices/video/vid_pgc.c +++ b/src/devices/video/vid_pgc.c @@ -44,7 +44,7 @@ * * This is expected to be done shortly. * - * Version: @(#)vid_pgc.c 1.0.2 2019/03/04 + * Version: @(#)vid_pgc.c 1.0.3 2019/03/07 * * Authors: Fred N. van Kempen, * John Elliott, @@ -2249,7 +2249,6 @@ pgc_read(uint32_t addr, void *priv) void pgc_cga_text(pgc_t *dev, int w) { - int x, c; uint8_t chr, attr; int drawcursor = 0; uint32_t cols[2]; @@ -2259,6 +2258,7 @@ pgc_cga_text(pgc_t *dev, int w) uint16_t ca = (dev->mapram[0x3ef] | (dev->mapram[0x3ee] << 8)) & 0x3fff; uint8_t *addr; uint32_t val; + int x, c; int cw = (w == 80) ? 8 : 16; addr = &dev->cga_vram[(((ma << 1) + ((dev->displine / pitch)*w)) * 2) & 0x3ffe]; @@ -2291,7 +2291,7 @@ pgc_cga_text(pgc_t *dev, int w) val = cols[(fontdatm[chr + dev->fontbase][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; else val = cols[(fontdatm[chr + dev->fontbase][sc] & (1 << (c ^ 7))) ? 1 : 0]; - buffer->line[dev->displine][(x * cw) + c] = val; + screen->line[dev->displine][(x * cw) + c].pal = val; } ma++; @@ -2304,7 +2304,7 @@ void pgc_cga_gfx40(pgc_t *dev) { int x, c; - uint32_t cols[4]; + uint8_t cols[4]; int col; uint16_t ma = (dev->mapram[0x3ed] | (dev->mapram[0x3ec] << 8)) & 0x3fff; uint8_t *addr; @@ -2332,8 +2332,7 @@ pgc_cga_gfx40(pgc_t *dev) dat = (addr[0] << 8) | addr[1]; dev->ma++; for (c = 0; c < 8; c++) { - buffer->line[dev->displine][(x << 4) + (c << 1)] = - buffer->line[dev->displine][(x << 4) + (c << 1) + 1] = cols[dat >> 14]; + screen->line[dev->displine][(x << 4) + (c << 1)].pal = screen->line[dev->displine][(x << 4) + (c << 1) + 1].pal = cols[dat >> 14]; dat <<= 2; } } @@ -2345,7 +2344,7 @@ void pgc_cga_gfx80(pgc_t *dev) { int x, c; - uint32_t cols[2]; + uint8_t cols[2]; uint16_t ma = (dev->mapram[0x3ed] | (dev->mapram[0x3ec] << 8)) & 0x3fff; uint8_t *addr; uint16_t dat; @@ -2358,7 +2357,7 @@ pgc_cga_gfx80(pgc_t *dev) dat = (addr[0] << 8) | addr[1]; dev->ma++; for (c = 0; c < 16; c++) { - buffer->line[dev->displine][(x << 4) + c] = cols[dat >> 15]; + screen->line[dev->displine][(x << 4) + c].val = cols[dat >> 15]; dat <<= 1; } } @@ -2369,7 +2368,7 @@ pgc_cga_gfx80(pgc_t *dev) void pgc_cga_poll(pgc_t *dev) { - uint32_t cols[2]; + uint8_t cols[2]; if (! dev->linepos) { dev->vidtime += dev->dispofftime; @@ -2378,7 +2377,7 @@ pgc_cga_poll(pgc_t *dev) if (dev->cgadispon) { if (dev->displine == 0) - video_wait_for_buffer(); + video_blit_wait_buffer(); if ((dev->mapram[0x03d8] & 0x12) == 0x12) pgc_cga_gfx80(dev); @@ -2390,7 +2389,7 @@ pgc_cga_poll(pgc_t *dev) pgc_cga_text(dev, 40); } else { cols[0] = ((dev->mapram[0x03d8] & 0x12) == 0x12) ? 0 : ((dev->mapram[0x03d9] & 15) + 16); - cga_hline(buffer, 0, dev->displine, PGC_CGA_WIDTH, cols[0]); + cga_hline(screen, 0, dev->displine, PGC_CGA_WIDTH, cols[0]); } if (++dev->displine == PGC_CGA_HEIGHT) { @@ -2417,7 +2416,7 @@ pgc_cga_poll(pgc_t *dev) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, 0, 0, ysize, xsize, ysize); + video_blit_start(1, 0, 0, 0, ysize, xsize, ysize); frames++; /* We have a fixed 640x400 screen for CGA modes. */ @@ -2461,7 +2460,7 @@ pgc_poll(void *priv) dev->linepos = 1; if (dev->cgadispon && (uint32_t)dev->displine < dev->maxh) { if (dev->displine == 0) - video_wait_for_buffer(); + video_blit_wait_buffer(); /* Don't know why pan needs to be multiplied by -2, but * the IM1024 driver uses PAN -112 for an offset of @@ -2469,12 +2468,13 @@ pgc_poll(void *priv) y = dev->displine - 2 * dev->pan_y; for (x = 0; x < dev->screenw; x++) { if (x + dev->pan_x < dev->maxw) - ((uint32_t *)buffer32->line[dev->displine])[x] = dev->palette[dev->vram[y * dev->maxw + x]]; + screen->line[dev->displine][x].val = dev->palette[dev->vram[y * dev->maxw + x]]; else - ((uint32_t *)buffer32->line[dev->displine])[x] = dev->palette[0]; + screen->line[dev->displine][x].val = dev->palette[0]; } } else { - cga_hline(buffer32, 0, dev->displine, dev->screenw, dev->palette[0]); + for (x = 0; x < dev->screenw; x++) + screen->line[dev->displine][x].val = dev->palette[0]; } if (++dev->displine == dev->screenh) { @@ -2502,7 +2502,8 @@ pgc_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + + video_blit_start(0, 0, 0, 0, ysize, xsize, ysize); frames++; video_res_x = dev->screenw; diff --git a/src/devices/video/vid_s3.c b/src/devices/video/vid_s3.c index a6f7b38..2325655 100644 --- a/src/devices/video/vid_s3.c +++ b/src/devices/video/vid_s3.c @@ -10,7 +10,7 @@ * * NOTE: ROM images need more/better organization per chipset. * - * Version: @(#)vid_s3.c 1.0.14 2019/02/10 + * Version: @(#)vid_s3.c 1.0.15 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -2676,9 +2676,9 @@ void s3_hwcursor_draw(svga_t *svga, int displine) if (offset >= svga->hwcursor_latch.x) { if (!(dat[0] & 0x8000)) - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] = (dat[1] & 0x8000) ? fg : bg; + screen->line[displine + y_add][offset + 32 + x_add].val = (dat[1] & 0x8000) ? fg : bg; else if (dat[1] & 0x8000) - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] ^= 0xffffff; + screen->line[displine + y_add][offset + 32 + x_add].val ^= 0xffffff; } offset++; diff --git a/src/devices/video/vid_s3_virge.c b/src/devices/video/vid_s3_virge.c index 51eafb3..9502332 100644 --- a/src/devices/video/vid_s3_virge.c +++ b/src/devices/video/vid_s3_virge.c @@ -8,7 +8,7 @@ * * S3 ViRGE emulation. * - * Version: @(#)vid_s3_virge.c 1.0.15 2019/02/10 + * Version: @(#)vid_s3_virge.c 1.0.16 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -3467,7 +3467,7 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine) if (offset >= svga->hwcursor_latch.x) { if (dat[0] & 0x8000) - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] = (dat[1] & 0x8000) ? fg : bg; + screen->line[displine + y_add][offset + 32 + x_add].val = (dat[1] & 0x8000) ? fg : bg; } offset++; @@ -3483,9 +3483,9 @@ static void s3_virge_hwcursor_draw(svga_t *svga, int displine) if (offset >= svga->hwcursor_latch.x) { if (!(dat[0] & 0x8000)) - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] = (dat[1] & 0x8000) ? fg : bg; + screen->line[displine + y_add][offset + 32 + x_add].val = (dat[1] & 0x8000) ? fg : bg; else if (dat[1] & 0x8000) - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] ^= 0xffffff; + screen->line[displine + y_add][offset + 32 + x_add].val ^= 0xffffff; } offset++; @@ -3734,12 +3734,12 @@ static void s3_virge_overlay_draw(svga_t *svga, int displine) int r[8], g[8], b[8]; int x_size, x_read = 4, x_write = 4; int x; - uint32_t *p; uint8_t *src = &svga->vram[svga->overlay_latch.addr]; int y_add = enable_overscan ? 16 : 0; int x_add = enable_overscan ? 8 : 0; + pel_t *p; - p = &((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add]; + p = &screen->line[displine + y_add][offset + 32 + x_add]; if ((offset + virge->streams.sec_w) > virge->streams.pri_w) x_size = (virge->streams.pri_w - virge->streams.sec_x) + 1; @@ -3750,7 +3750,8 @@ static void s3_virge_overlay_draw(svga_t *svga, int displine) for (x = 0; x < x_size; x++) { - *p++ = r[x_read] | (g[x_read] << 8) | (b[x_read] << 16); + p[0].val = r[x_read] | (g[x_read] << 8) | (b[x_read] << 16); + p++; h_acc += virge->streams.k1_horiz_scale; if (h_acc >= 0) diff --git a/src/devices/video/vid_sigma.c b/src/devices/video/vid_sigma.c index 33936db..abaa4e3 100644 --- a/src/devices/video/vid_sigma.c +++ b/src/devices/video/vid_sigma.c @@ -41,7 +41,7 @@ * even-numbered columns, so the top bit of the control register * at 0x2D9 is used to adjust the position. * - * Version: @(#)vid_sigma.c 1.0.3 2019/03/03 + * Version: @(#)vid_sigma.c 1.0.4 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -462,7 +462,7 @@ sigma_text80(sigma_t *dev) uint8_t *vram = dev->vram + (ma << 1); int drawcursor, x, c; uint8_t chr, attr; - uint32_t cols[4]; + uint8_t cols[4]; ca = ca << 1; if (dev->sigma_ctl & CTL_CURSOR) @@ -489,16 +489,16 @@ sigma_text80(sigma_t *dev) if (drawcursor) { for (c = 0; c < 8; c++) { if (dev->sigmamode & MODE_FONT16) - buffer->line[dev->displine][(x << 3) + c + 8] = cols[(dev->fontdat16[chr][dev->sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; + screen->line[dev->displine][(x << 3) + c + 8].pal = cols[(dev->fontdat16[chr][dev->sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; else - buffer->line[dev->displine][(x << 3) + c + 8] = cols[(dev->fontdat[chr][dev->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; + screen->line[dev->displine][(x << 3) + c + 8].pal = cols[(dev->fontdat[chr][dev->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; } } else { for (c = 0; c < 8; c++) { if (dev->sigmamode & MODE_FONT16) - buffer->line[dev->displine][(x << 3) + c + 8] = cols[(dev->fontdat16[chr][dev->sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->displine][(x << 3) + c + 8].pal = cols[(dev->fontdat16[chr][dev->sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; else - buffer->line[dev->displine][(x << 3) + c + 8] = cols[(dev->fontdat[chr][dev->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->displine][(x << 3) + c + 8].pal = cols[(dev->fontdat[chr][dev->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } } ++ma; @@ -517,7 +517,7 @@ sigma_text40(sigma_t *dev) uint8_t *vram = dev->vram + ((ma << 1) & 0x3FFF); int drawcursor, x, c; uint8_t chr, attr; - uint32_t cols[4]; + uint8_t cols[4]; ca = ca << 1; if (dev->sigma_ctl & CTL_CURSOR) @@ -543,13 +543,11 @@ sigma_text40(sigma_t *dev) if (drawcursor) { for (c = 0; c < 8; c++) { - buffer->line[dev->displine][(x << 4) + 2*c + 8] = - buffer->line[dev->displine][(x << 4) + 2*c + 9] = cols[(dev->fontdat16[chr][dev->sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; + screen->line[dev->displine][(x << 4) + 2*c + 8].pal = screen->line[dev->displine][(x << 4) + 2*c + 9].pal = cols[(dev->fontdat16[chr][dev->sc & 15] & (1 << (c ^ 7))) ? 1 : 0] ^ 0x0f; } } else { for (c = 0; c < 8; c++) { - buffer->line[dev->displine][(x << 4) + 2*c + 8] = - buffer->line[dev->displine][(x << 4) + 2*c + 9] = cols[(dev->fontdat16[chr][dev->sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->displine][(x << 4) + 2*c + 8].pal = screen->line[dev->displine][(x << 4) + 2*c + 9].pal = cols[(dev->fontdat16[chr][dev->sc & 15] & (1 << (c ^ 7))) ? 1 : 0]; } } ma++; @@ -580,7 +578,7 @@ sigma_gfx400(sigma_t *dev) ((plane[1] & mask) ? 2 : 0) | ((plane[0] & mask) ? 1 : 0); col |= 16; - buffer->line[dev->displine][(x << 3) + c + 8] = col; + screen->line[dev->displine][(x << 3) + c + 8].pal = col; } if (x & 1) dev->ma++; @@ -613,7 +611,7 @@ sigma_gfx200(sigma_t *dev) ((plane[1] & mask) ? 2 : 0) | ((plane[0] & mask) ? 1 : 0); col |= 16; - buffer->line[dev->displine][(x << 3) + c + 8] = col; + screen->line[dev->displine][(x << 3) + c + 8].pal = col; } if (x & 1) dev->ma++; @@ -646,8 +644,7 @@ sigma_gfx4col(sigma_t *dev) col |= 16; mask = mask >> 1; - buffer->line[dev->displine][(x << 3) + (c << 1) + 8] = - buffer->line[dev->displine][(x << 3) + (c << 1) + 9] = col; + screen->line[dev->displine][(x << 3) + (c << 1) + 8].pal = screen->line[dev->displine][(x << 3) + (c << 1) + 9].pal = col; } if (x & 1) dev->ma++; @@ -659,7 +656,7 @@ static void sigma_poll(void *priv) { sigma_t *dev = (sigma_t *)priv; - uint32_t cols[4]; + uint8_t cols[4]; int oldsc, oldvc; int x, c; @@ -673,7 +670,7 @@ sigma_poll(void *priv) if (dev->cgadispon) { if (dev->displine < dev->firstline) { dev->firstline = dev->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } dev->lastline = dev->displine; @@ -681,11 +678,11 @@ sigma_poll(void *priv) /* Left overscan */ for (c = 0; c < 8; c++) { - buffer->line[dev->displine][c] = cols[0]; + screen->line[dev->displine][c].pal = cols[0]; if (dev->sigmamode & MODE_80COLS) - buffer->line[dev->displine][c + (dev->crtc[1] << 4) + 8] = cols[0]; + screen->line[dev->displine][c + (dev->crtc[1] << 4) + 8].pal = cols[0]; else - buffer->line[dev->displine][c + (dev->crtc[1] << 5) + 8] = cols[0]; + screen->line[dev->displine][c + (dev->crtc[1] << 5) + 8].pal = cols[0]; } if (dev->sigmamode & MODE_GRAPHICS) { @@ -704,9 +701,9 @@ sigma_poll(void *priv) } else { cols[0] = 16; if (dev->sigmamode & MODE_80COLS) - cga_hline(buffer, 0, dev->displine, (dev->crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, dev->displine, (dev->crtc[1] << 4) + 16, cols[0]); else - cga_hline(buffer, 0, dev->displine, (dev->crtc[1] << 5) + 16, cols[0]); + cga_hline(screen, 0, dev->displine, (dev->crtc[1] << 5) + 16, cols[0]); } if (dev->sigmamode & MODE_80COLS) @@ -715,7 +712,7 @@ sigma_poll(void *priv) x = (dev->crtc[1] << 5) + 16; for (c = 0; c < x; c++) - buffer->line[dev->displine][c] = dev->palette[buffer->line[dev->displine][c] & 0xf] | 16; + screen->line[dev->displine][c].pal = dev->palette[screen->line[dev->displine][c].pal & 0x0f] | 16; dev->sc = oldsc; if (dev->vc == dev->crtc[7] && !dev->sc) @@ -797,7 +794,7 @@ sigma_poll(void *priv) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, dev->firstline - 4, 0, (dev->lastline - dev->firstline) + 8, xsize, (dev->lastline - dev->firstline) + 8); + video_blit_start(1, 0, dev->firstline - 4, 0, (dev->lastline - dev->firstline) + 8, xsize, (dev->lastline - dev->firstline) + 8); frames++; video_res_x = xsize - 16; @@ -887,7 +884,7 @@ sigma_init(const device_t *info) cga_palette = device_get_config_int("rgb_type") << 1; if (cga_palette > 6) cga_palette = 0; - cgapal_rebuild(); + video_palette_rebuild(); dev->vram = malloc(0x8000 * 4); diff --git a/src/devices/video/vid_svga.c b/src/devices/video/vid_svga.c index febd5b8..5ab3fad 100644 --- a/src/devices/video/vid_svga.c +++ b/src/devices/video/vid_svga.c @@ -11,13 +11,13 @@ * This is intended to be used by another SVGA driver, * and not as a card in it's own right. * - * Version: @(#)vid_svga.c 1.0.15 2019/01/08 + * Version: @(#)vid_svga.c 1.0.16 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -626,7 +626,7 @@ svga_poll(void *p) svga->ma &= svga->vram_display_mask; if (svga->firstline == 2000) { svga->firstline = svga->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } if (svga->hwcursor_on || svga->overlay_on) { @@ -1162,7 +1162,6 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) { int y_add = (enable_overscan) ? overscan_y : 0; int x_add = (enable_overscan) ? 16 : 0; - uint32_t *p; int i, j; svga->frames++; @@ -1175,7 +1174,7 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) suppress_overscan = 0; if (y1 > y2) { - video_blit_memtoscreen(32, 0, 0, 0, xsize + x_add, ysize + y_add); + video_blit_start(0, 32, 0, 0, 0, xsize + x_add, ysize + y_add); return; } @@ -1198,32 +1197,26 @@ svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) if ((wx >= 160) && ((wy + 1) >= 120)) { /* Draw (overscan_size - scroll size) lines of overscan on top. */ for (i = 0; i < (y_add >> 1); i++) { - p = &((uint32_t *)buffer32->line[i & 0x7ff])[32]; - for (j = 0; j < (xsize + x_add); j++) - p[j] = svga->overscan_color; + screen->line[i & 0x7ff][32 + j].val = svga->overscan_color; } /* Draw (overscan_size + scroll size) lines of overscan on the bottom. */ for (i = 0; i < (y_add >> 1); i++) { - p = &((uint32_t *)buffer32->line[(ysize + (y_add >> 1) + i) & 0x7ff])[32]; - for (j = 0; j < (xsize + x_add); j++) - p[j] = svga->overscan_color; + screen->line[(ysize + (y_add >> 1) + i) & 0x7ff][32 + j].val = svga->overscan_color; } for (i = (y_add >> 1); i < (ysize + (y_add >> 1)); i ++) { - p = &((uint32_t *)buffer32->line[i & 0x7ff])[32]; - for (j = 0; j < 8; j++) { - p[j] = svga->pallook[svga->overscan_color]; - p[xsize + (x_add >> 1) + j] = svga->overscan_color; + screen->line[i & 0x7ff][32 + j].val = svga->pallook[svga->overscan_color]; + screen->line[i & 0x7ff][32 + xsize + (x_add >> 1) + j].val = svga->overscan_color; } } } } - video_blit_memtoscreen(32, 0, y1, y2 + y_add, xsize + x_add, ysize + y_add); + video_blit_start(0, 32, 0, y1, y2 + y_add, xsize + x_add, ysize + y_add); } diff --git a/src/devices/video/vid_svga_render.c b/src/devices/video/vid_svga_render.c index 010cd42..6274eee 100644 --- a/src/devices/video/vid_svga_render.c +++ b/src/devices/video/vid_svga_render.c @@ -8,7 +8,7 @@ * * SVGA renderers. * - * Version: @(#)vid_svga_render.c 1.0.14 2019/03/03 + * Version: @(#)vid_svga_render.c 1.0.15 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -58,24 +58,26 @@ svga_render_blank(svga_t *svga) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; - for (x = 0; x < svga->hdisp; x++) { - switch (svga->seqregs[1] & 9) { - case 0: - for (xx = 0; xx < 9; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 9) + xx + 32 + x_add] = 0; - break; + for (x = 0; x < svga->hdisp; x++) switch (svga->seqregs[1] & 9) { + case 0: + for (xx = 0; xx < 9; xx++) + screen->line[svga->displine + y_add][(x * 9) + xx + 32 + x_add].val = 0; + break; - case 1: - for (xx = 0; xx < 8; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 8) + xx + 32 + x_add] = 0; - break; + case 1: + for (xx = 0; xx < 8; xx++) + screen->line[svga->displine + y_add][(x * 8) + xx + 32 + x_add].val = 0; + break; - case 8: - for (xx = 0; xx < 18; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 18) + xx + 32 + x_add] = 0; - break; + case 8: + for (xx = 0; xx < 18; xx++) + screen->line[svga->displine + y_add][(x * 18) + xx + 32 + x_add].val = 0; + break; - case 9: - for (xx = 0; xx < 16; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 16) + xx + 32 + x_add] = 0; - break; - } + case 9: + for (xx = 0; xx < 16; xx++) + screen->line[svga->displine + y_add][(x * 16) + xx + 32 + x_add].val = 0; + break; } } @@ -90,14 +92,14 @@ svga_render_text_40(svga_t *svga) uint32_t charaddr; int bg, fg, x, xx; int drawcursor; - uint32_t *p; + pel_t *p; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; if (svga->fullchange) { - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[32 + x_add]; + p = &screen->line[svga->displine + y_add][32 + x_add]; for (x = 0; x < svga->hdisp; x += xinc) { drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron); @@ -124,18 +126,20 @@ svga_render_text_40(svga_t *svga) dat = svga->vram[charaddr + (svga->sc << 2)]; if (svga->seqregs[1] & 1) { for (xx = 0; xx < 16; xx += 2) - p[xx] = p[xx + 1] = (dat & (0x80 >> (xx >> 1))) ? fg : bg; + p[xx].val = p[xx + 1].val = (dat & (0x80 >> (xx >> 1))) ? fg : bg; } else { for (xx = 0; xx < 16; xx += 2) - p[xx] = p[xx + 1] = (dat & (0x80 >> (xx >> 1))) ? fg : bg; + p[xx].val = p[xx + 1].val = (dat & (0x80 >> (xx >> 1))) ? fg : bg; if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4)) - p[16] = p[17] = bg; + p[16].val = p[17].val = bg; else - p[16] = p[17] = (dat & 1) ? fg : bg; + p[16].val = p[17].val = (dat & 1) ? fg : bg; } + svga->ma += 4; p += xinc; } + svga->ma &= svga->vram_display_mask; } } @@ -151,14 +155,14 @@ svga_render_text_80(svga_t *svga) uint32_t charaddr; int bg, fg, x, xx; int drawcursor; - uint32_t *p; + pel_t *p; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; if (svga->fullchange) { - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[32 + x_add]; + p = &screen->line[svga->displine + y_add][32 + x_add]; for (x = 0; x < svga->hdisp; x += xinc) { drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron); @@ -187,15 +191,16 @@ svga_render_text_80(svga_t *svga) dat = svga->vram[charaddr + (svga->sc << 2)]; if (svga->seqregs[1] & 1) { for (xx = 0; xx < 8; xx++) - p[xx] = (dat & (0x80 >> xx)) ? fg : bg; + p[xx].val = (dat & (0x80 >> xx)) ? fg : bg; } else { for (xx = 0; xx < 8; xx++) - p[xx] = (dat & (0x80 >> xx)) ? fg : bg; + p[xx].val = (dat & (0x80 >> xx)) ? fg : bg; if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4)) - p[8] = bg; + p[8].val = bg; else - p[8] = (dat & 1) ? fg : bg; + p[8].val = (dat & 1) ? fg : bg; } + svga->ma += 4; p += xinc; } @@ -215,14 +220,14 @@ svga_render_text_80_ksc5601(svga_t *svga) uint32_t charaddr; int bg, fg, x, xx; int drawcursor; - uint32_t *p; + pel_t *p; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; svga->lastline_draw = svga->displine; if (svga->fullchange) { - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[32 + x_add]; + p = &screen->line[svga->displine + y_add][32 + x_add]; for (x = 0; x < svga->hdisp; x += xinc) { drawcursor = ((svga->ma == svga->ca) && svga->con && svga->cursoron); @@ -262,19 +267,20 @@ svga_render_text_80_ksc5601(svga_t *svga) if (svga->seqregs[1] & 1) { for (xx = 0; xx < 8; xx++) - p[xx] = (dat & (0x80 >> xx)) ? fg : bg; + p[xx].val = (dat & (0x80 >> xx)) ? fg : bg; } else { for (xx = 0; xx < 8; xx++) - p[xx] = (dat & (0x80 >> xx)) ? fg : bg; + p[xx].val = (dat & (0x80 >> xx)) ? fg : bg; if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4)) - p[8] = bg; + p[8].val = bg; else - p[8] = (dat & 1) ? fg : bg; + p[8].val = (dat & 1) ? fg : bg; } + svga->ma += 4; p += xinc; - if(x + xinc < svga->hdisp && (chr & (nextchr | svga->ksc5601_sbyte_mask) & 0x80)) { + if (x + xinc < svga->hdisp && (chr & (nextchr | svga->ksc5601_sbyte_mask) & 0x80)) { attr = svga->vram[((svga->ma << 1) + 1) & svga->vram_display_mask]; if (drawcursor) { @@ -300,14 +306,14 @@ svga_render_text_80_ksc5601(svga_t *svga) if (svga->seqregs[1] & 1) { for (xx = 0; xx < 8; xx++) - p[xx] = (dat & (0x80 >> xx)) ? fg : bg; + p[xx].val = (dat & (0x80 >> xx)) ? fg : bg; } else { for (xx = 0; xx < 8; xx++) - p[xx] = (dat & (0x80 >> xx)) ? fg : bg; + p[xx].val = (dat & (0x80 >> xx)) ? fg : bg; if ((chr & ~0x1F) != 0xC0 || !(svga->attrregs[0x10] & 4)) - p[8] = bg; + p[8].val = bg; else - p[8] = (dat & 1) ? fg : bg; + p[8].val = (dat & 1) ? fg : bg; } svga->ma += 4; @@ -329,13 +335,13 @@ svga_render_2bpp_lowres(svga_t *svga) int changed_offset, x; int offset; uint8_t dat[2]; - uint32_t *p; + pel_t *p; changed_offset = ((svga->ma << 1) + (svga->sc & ~svga->crtc[0x17] & 3) * 0x8000) >> 12; if (svga->changedvram[changed_offset] || svga->changedvram[changed_offset + 1] || svga->fullchange) { offset = ((8 - svga->scrollcache) << 1) + 16; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -347,14 +353,14 @@ svga_render_2bpp_lowres(svga_t *svga) svga->ma += 4; svga->ma &= svga->vram_display_mask; - p[0] = p[1] = svga->pallook[svga->egapal[(dat[0] >> 6) & 3]]; - p[2] = p[3] = svga->pallook[svga->egapal[(dat[0] >> 4) & 3]]; - p[4] = p[5] = svga->pallook[svga->egapal[(dat[0] >> 2) & 3]]; - p[6] = p[7] = svga->pallook[svga->egapal[dat[0] & 3]]; - p[8] = p[9] = svga->pallook[svga->egapal[(dat[1] >> 6) & 3]]; - p[10] = p[11] = svga->pallook[svga->egapal[(dat[1] >> 4) & 3]]; - p[12] = p[13] = svga->pallook[svga->egapal[(dat[1] >> 2) & 3]]; - p[14] = p[15] = svga->pallook[svga->egapal[dat[1] & 3]]; + p[0].val = p[1].val = svga->pallook[svga->egapal[(dat[0] >> 6) & 3]]; + p[2].val = p[3].val = svga->pallook[svga->egapal[(dat[0] >> 4) & 3]]; + p[4].val = p[5].val = svga->pallook[svga->egapal[(dat[0] >> 2) & 3]]; + p[6].val = p[7].val = svga->pallook[svga->egapal[dat[0] & 3]]; + p[8].val = p[9].val = svga->pallook[svga->egapal[(dat[1] >> 6) & 3]]; + p[10].val = p[11].val = svga->pallook[svga->egapal[(dat[1] >> 4) & 3]]; + p[12].val = p[13].val = svga->pallook[svga->egapal[(dat[1] >> 2) & 3]]; + p[14].val = p[15].val = svga->pallook[svga->egapal[dat[1] & 3]]; p += 16; } @@ -370,13 +376,13 @@ svga_render_2bpp_highres(svga_t *svga) int changed_offset; int offset, x; uint8_t dat[2]; - uint32_t *p; + pel_t *p; changed_offset = ((svga->ma << 1) + (svga->sc & ~svga->crtc[0x17] & 3) * 0x8000) >> 12; if (svga->changedvram[changed_offset] || svga->changedvram[changed_offset + 1] || svga->fullchange) { offset = (8 - svga->scrollcache) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -388,14 +394,14 @@ svga_render_2bpp_highres(svga_t *svga) svga->ma += 4; svga->ma &= svga->vram_display_mask; - p[0] = svga->pallook[svga->egapal[(dat[0] >> 6) & 3]]; - p[1] = svga->pallook[svga->egapal[(dat[0] >> 4) & 3]]; - p[2] = svga->pallook[svga->egapal[(dat[0] >> 2) & 3]]; - p[3] = svga->pallook[svga->egapal[dat[0] & 3]]; - p[4] = svga->pallook[svga->egapal[(dat[1] >> 6) & 3]]; - p[5] = svga->pallook[svga->egapal[(dat[1] >> 4) & 3]]; - p[6] = svga->pallook[svga->egapal[(dat[1] >> 2) & 3]]; - p[7] = svga->pallook[svga->egapal[dat[1] & 3]]; + p[0].val = svga->pallook[svga->egapal[(dat[0] >> 6) & 3]]; + p[1].val = svga->pallook[svga->egapal[(dat[0] >> 4) & 3]]; + p[2].val = svga->pallook[svga->egapal[(dat[0] >> 2) & 3]]; + p[3].val = svga->pallook[svga->egapal[dat[0] & 3]]; + p[4].val = svga->pallook[svga->egapal[(dat[1] >> 6) & 3]]; + p[5].val = svga->pallook[svga->egapal[(dat[1] >> 4) & 3]]; + p[6].val = svga->pallook[svga->egapal[(dat[1] >> 2) & 3]]; + p[7].val = svga->pallook[svga->egapal[dat[1] & 3]]; p += 8; } @@ -409,13 +415,13 @@ svga_render_4bpp_lowres(svga_t *svga) int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; int offset, x; - uint32_t *p; uint8_t edat[4], dat; uint32_t *eptr = (uint32_t *)edat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = ((8 - svga->scrollcache) << 1) + 16; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -428,17 +434,17 @@ svga_render_4bpp_lowres(svga_t *svga) svga->ma &= svga->vram_display_mask; dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2); - p[0] = p[1] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; - p[2] = p[3] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + p[0].val = p[1].val = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[2].val = p[3].val = svga->pallook[svga->egapal[dat & svga->plane_mask]]; dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2); - p[4] = p[5] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; - p[6] = p[7] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + p[4].val = p[5].val = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[6].val = p[7].val = svga->pallook[svga->egapal[dat & svga->plane_mask]]; dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2); - p[8] = p[9] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; - p[10] = p[11] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + p[8].val = p[9].val = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[10].val = p[11].val = svga->pallook[svga->egapal[dat & svga->plane_mask]]; dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); - p[12] = p[13] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; - p[14] = p[15] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + p[12].val = p[13].val = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[14].val = p[15].val = svga->pallook[svga->egapal[dat & svga->plane_mask]]; p += 16; } @@ -453,15 +459,15 @@ svga_render_4bpp_highres(svga_t *svga) int x_add = enable_overscan ? 8 : 0; int changed_offset; int offset, x; - uint32_t *p; uint8_t edat[4], dat; uint32_t *eptr = (uint32_t *)edat; + pel_t *p; changed_offset = (svga->ma + (svga->sc & ~svga->crtc[0x17] & 3) * 0x8000) >> 12; if (svga->changedvram[changed_offset] || svga->changedvram[changed_offset + 1] || svga->fullchange) { offset = (8 - svga->scrollcache) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -473,17 +479,17 @@ svga_render_4bpp_highres(svga_t *svga) svga->ma &= svga->vram_display_mask; dat = edatlookup[edat[0] >> 6][edat[1] >> 6] | (edatlookup[edat[2] >> 6][edat[3] >> 6] << 2); - p[0] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; - p[1] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + p[0].val = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[1].val = svga->pallook[svga->egapal[dat & svga->plane_mask]]; dat = edatlookup[(edat[0] >> 4) & 3][(edat[1] >> 4) & 3] | (edatlookup[(edat[2] >> 4) & 3][(edat[3] >> 4) & 3] << 2); - p[2] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; - p[3] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + p[2].val = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[3].val = svga->pallook[svga->egapal[dat & svga->plane_mask]]; dat = edatlookup[(edat[0] >> 2) & 3][(edat[1] >> 2) & 3] | (edatlookup[(edat[2] >> 2) & 3][(edat[3] >> 2) & 3] << 2); - p[4] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; - p[5] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + p[4].val = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[5].val = svga->pallook[svga->egapal[dat & svga->plane_mask]]; dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); - p[6] = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; - p[7] = svga->pallook[svga->egapal[dat & svga->plane_mask]]; + p[6].val = svga->pallook[svga->egapal[(dat >> 4) & svga->plane_mask]]; + p[7].val = svga->pallook[svga->egapal[dat & svga->plane_mask]]; p += 8; } @@ -496,12 +502,13 @@ svga_render_8bpp_lowres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = (8 - (svga->scrollcache & 6)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -510,14 +517,15 @@ svga_render_8bpp_lowres(svga_t *svga) for (x = 0; x <= svga->hdisp; x += 8) { dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]); - p[0] = p[1] = svga->pallook[dat & 0xff]; - p[2] = p[3] = svga->pallook[(dat >> 8) & 0xff]; - p[4] = p[5] = svga->pallook[(dat >> 16) & 0xff]; - p[6] = p[7] = svga->pallook[(dat >> 24) & 0xff]; + p[0].val = p[1].val = svga->pallook[dat & 0xff]; + p[2].val = p[3].val = svga->pallook[(dat >> 8) & 0xff]; + p[4].val = p[5].val = svga->pallook[(dat >> 16) & 0xff]; + p[6].val = p[7].val = svga->pallook[(dat >> 24) & 0xff]; svga->ma += 4; p += 8; } + svga->ma &= svga->vram_display_mask; } } @@ -528,12 +536,13 @@ svga_render_8bpp_highres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -541,20 +550,21 @@ svga_render_8bpp_highres(svga_t *svga) for (x = 0; x <= svga->hdisp; x += 8) { dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]); - p[0] = svga->pallook[dat & 0xff]; - p[1] = svga->pallook[(dat >> 8) & 0xff]; - p[2] = svga->pallook[(dat >> 16) & 0xff]; - p[3] = svga->pallook[(dat >> 24) & 0xff]; + p[0].val = svga->pallook[dat & 0xff]; + p[1].val = svga->pallook[(dat >> 8) & 0xff]; + p[2].val = svga->pallook[(dat >> 16) & 0xff]; + p[3].val = svga->pallook[(dat >> 24) & 0xff]; dat = *(uint32_t *)(&svga->vram[(svga->ma + 4) & svga->vram_display_mask]); - p[4] = svga->pallook[dat & 0xff]; - p[5] = svga->pallook[(dat >> 8) & 0xff]; - p[6] = svga->pallook[(dat >> 16) & 0xff]; - p[7] = svga->pallook[(dat >> 24) & 0xff]; + p[4].val = svga->pallook[dat & 0xff]; + p[5].val = svga->pallook[(dat >> 8) & 0xff]; + p[6].val = svga->pallook[(dat >> 16) & 0xff]; + p[7].val = svga->pallook[(dat >> 24) & 0xff]; svga->ma += 8; p += 8; } + svga->ma &= svga->vram_display_mask; } } @@ -565,12 +575,13 @@ svga_render_15bpp_lowres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = (8 - (svga->scrollcache & 6)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -579,14 +590,15 @@ svga_render_15bpp_lowres(svga_t *svga) for (x = 0; x <= svga->hdisp; x += 4) { dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]); - p[x] = video_15to32[dat & 0xffff]; - p[x + 1] = video_15to32[dat >> 16]; + p[x].val = video_15to32[dat & 0xffff]; + p[x + 1].val = video_15to32[dat >> 16]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]); - p[x] = video_15to32[dat & 0xffff]; - p[x + 1] = video_15to32[dat >> 16]; + p[x + 2].val = video_15to32[dat & 0xffff]; + p[x + 3].val = video_15to32[dat >> 16]; } + svga->ma += x << 1; svga->ma &= svga->vram_display_mask; } @@ -598,12 +610,13 @@ svga_render_15bpp_highres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -611,21 +624,22 @@ svga_render_15bpp_highres(svga_t *svga) for (x = 0; x <= svga->hdisp; x += 8) { dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]); - p[x] = video_15to32[dat & 0xffff]; - p[x + 1] = video_15to32[dat >> 16]; + p[x].val = video_15to32[dat & 0xffff]; + p[x + 1].val = video_15to32[dat >> 16]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]); - p[x + 2] = video_15to32[dat & 0xffff]; - p[x + 3] = video_15to32[dat >> 16]; + p[x + 2].val = video_15to32[dat & 0xffff]; + p[x + 3].val = video_15to32[dat >> 16]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 8) & svga->vram_display_mask]); - p[x + 4] = video_15to32[dat & 0xffff]; - p[x + 5] = video_15to32[dat >> 16]; + p[x + 4].val = video_15to32[dat & 0xffff]; + p[x + 5].val = video_15to32[dat >> 16]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 12) & svga->vram_display_mask]); - p[x + 6] = video_15to32[dat & 0xffff]; - p[x + 7] = video_15to32[dat >> 16]; + p[x + 6].val = video_15to32[dat & 0xffff]; + p[x + 7].val = video_15to32[dat >> 16]; } + svga->ma += x << 1; svga->ma &= svga->vram_display_mask; } @@ -637,12 +651,13 @@ svga_render_mixed_highres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -651,49 +666,50 @@ svga_render_mixed_highres(svga_t *svga) for (x = 0; x <= svga->hdisp; x += 8) { dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]); if (dat & 0x8000) - p[x] = svga->pallook[dat & 0xff]; + p[x].val = svga->pallook[dat & 0xff]; else - p[x] = video_15to32[dat & 0x7fff]; + p[x].val = video_15to32[dat & 0x7fff]; if ((dat >> 16) & 0x8000) - p[x + 1] = svga->pallook[(dat >> 16) & 0xff]; + p[x + 1].val = svga->pallook[(dat >> 16) & 0xff]; else - p[x + 1] = video_15to32[(dat >> 16) & 0x7fff]; + p[x + 1].val = video_15to32[(dat >> 16) & 0x7fff]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]); if (dat & 0x8000) - p[x + 2] = svga->pallook[dat & 0xff]; + p[x + 2].val = svga->pallook[dat & 0xff]; else - p[x + 2] = video_15to32[dat & 0x7fff]; + p[x + 2].val = video_15to32[dat & 0x7fff]; if ((dat >> 16) & 0x8000) - p[x + 3] = svga->pallook[(dat >> 16) & 0xff]; + p[x + 3].val = svga->pallook[(dat >> 16) & 0xff]; else - p[x + 3] = video_15to32[(dat >> 16) & 0x7fff]; + p[x + 3].val = video_15to32[(dat >> 16) & 0x7fff]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 8) & svga->vram_display_mask]); if (dat & 0x8000) - p[x + 4] = svga->pallook[dat & 0xff]; + p[x + 4].val = svga->pallook[dat & 0xff]; else - p[x + 4] = video_15to32[dat & 0x7fff]; + p[x + 4].val = video_15to32[dat & 0x7fff]; if ((dat >> 16) & 0x8000) - p[x + 5] = svga->pallook[(dat >> 16) & 0xff]; + p[x + 5].val = svga->pallook[(dat >> 16) & 0xff]; else - p[x + 5] = video_15to32[(dat >> 16) & 0x7fff]; + p[x + 5].val = video_15to32[(dat >> 16) & 0x7fff]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 12) & svga->vram_display_mask]); if (dat & 0x8000) - p[x + 6] = svga->pallook[dat & 0xff]; + p[x + 6].val = svga->pallook[dat & 0xff]; else - p[x + 6] = video_15to32[dat & 0x7fff]; + p[x + 6].val = video_15to32[dat & 0x7fff]; if ((dat >> 16) & 0x8000) - p[x + 7] = svga->pallook[(dat >> 16) & 0xff]; + p[x + 7].val = svga->pallook[(dat >> 16) & 0xff]; else - p[x + 7] = video_15to32[(dat >> 16) & 0x7fff]; + p[x + 7].val = video_15to32[(dat >> 16) & 0x7fff]; } + svga->ma += x << 1; svga->ma &= svga->vram_display_mask; } @@ -705,12 +721,13 @@ svga_render_16bpp_lowres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = (8 - (svga->scrollcache & 6)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -719,14 +736,15 @@ svga_render_16bpp_lowres(svga_t *svga) for (x = 0; x <= svga->hdisp; x += 4) { dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]); - p[x] = video_16to32[dat & 0xffff]; - p[x + 1] = video_16to32[dat >> 16]; + p[x].val = video_16to32[dat & 0xffff]; + p[x + 1].val = video_16to32[dat >> 16]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]); - p[x] = video_16to32[dat & 0xffff]; - p[x + 1] = video_16to32[dat >> 16]; + p[x + 2].val = video_16to32[dat & 0xffff]; + p[x + 3].val = video_16to32[dat >> 16]; } + svga->ma += x << 1; svga->ma &= svga->vram_display_mask; } @@ -738,12 +756,13 @@ svga_render_16bpp_highres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -751,20 +770,20 @@ svga_render_16bpp_highres(svga_t *svga) for (x = 0; x <= svga->hdisp; x += 8) { dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1)) & svga->vram_display_mask]); - p[x] = video_16to32[dat & 0xffff]; - p[x + 1] = video_16to32[dat >> 16]; + p[x].val = video_16to32[dat & 0xffff]; + p[x + 1].val = video_16to32[dat >> 16]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 4) & svga->vram_display_mask]); - p[x + 2] = video_16to32[dat & 0xffff]; - p[x + 3] = video_16to32[dat >> 16]; + p[x + 2].val = video_16to32[dat & 0xffff]; + p[x + 3].val = video_16to32[dat >> 16]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 8) & svga->vram_display_mask]); - p[x + 4] = video_16to32[dat & 0xffff]; - p[x + 5] = video_16to32[dat >> 16]; + p[x + 4].val = video_16to32[dat & 0xffff]; + p[x + 5].val = video_16to32[dat >> 16]; dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 1) + 12) & svga->vram_display_mask]); - p[x + 6] = video_16to32[dat & 0xffff]; - p[x + 7] = video_16to32[dat >> 16]; + p[x + 6].val = video_16to32[dat & 0xffff]; + p[x + 7].val = video_16to32[dat >> 16]; } svga->ma += x << 1; @@ -778,8 +797,8 @@ svga_render_24bpp_lowres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t dat; int offset, x; + uint32_t dat; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { if (svga->firstline_draw == 2000) @@ -792,7 +811,8 @@ svga_render_24bpp_lowres(svga_t *svga) dat = svga->vram[svga->ma] | (svga->vram[svga->ma + 1] << 8) | (svga->vram[svga->ma + 2] << 16); svga->ma += 3; svga->ma &= svga->vram_display_mask; - ((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + offset + x_add] = ((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + 1 + offset + x_add] = dat; + + screen->line[svga->displine + y_add][(x << 1) + offset + x_add].val = screen->line[svga->displine + y_add][(x << 1) + 1 + offset + x_add].val = dat; } } } @@ -803,12 +823,13 @@ svga_render_24bpp_highres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -816,19 +837,20 @@ svga_render_24bpp_highres(svga_t *svga) for (x = 0; x <= svga->hdisp; x += 4) { dat = *(uint32_t *)(&svga->vram[svga->ma & svga->vram_display_mask]); - p[x] = dat & 0xffffff; + p[x].val = dat & 0xffffff; dat = *(uint32_t *)(&svga->vram[(svga->ma + 3) & svga->vram_display_mask]); - p[x + 1] = dat & 0xffffff; + p[x + 1].val = dat & 0xffffff; dat = *(uint32_t *)(&svga->vram[(svga->ma + 6) & svga->vram_display_mask]); - p[x + 2] = dat & 0xffffff; + p[x + 2].val = dat & 0xffffff; dat = *(uint32_t *)(&svga->vram[(svga->ma + 9) & svga->vram_display_mask]); - p[x + 3] = dat & 0xffffff; + p[x + 3].val = dat & 0xffffff; svga->ma += 12; } + svga->ma &= svga->vram_display_mask; } } @@ -853,7 +875,8 @@ svga_render_32bpp_lowres(svga_t *svga) fg = svga->vram[svga->ma] | (svga->vram[svga->ma + 1] << 8) | (svga->vram[svga->ma + 2] << 16); svga->ma += 4; svga->ma &= svga->vram_display_mask; - ((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + offset + x_add] = ((uint32_t *)buffer32->line[svga->displine + y_add])[(x << 1) + 1 + offset + x_add] = fg; + + screen->line[svga->displine + y_add][(x << 1) + offset + x_add].val = screen->line[svga->displine + y_add][(x << 1) + 1 + offset + x_add].val = fg; } } } @@ -866,12 +889,13 @@ svga_render_32bpp_highres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange) { offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -879,7 +903,7 @@ svga_render_32bpp_highres(svga_t *svga) for (x = 0; x <= svga->hdisp; x++) { dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]); - p[x] = dat & 0xffffff; + p[x].val = dat & 0xffffff; } svga->ma += 4; @@ -893,12 +917,13 @@ svga_render_ABGR8888_highres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange) { offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -906,7 +931,7 @@ svga_render_ABGR8888_highres(svga_t *svga) for (x = 0; x <= svga->hdisp; x++) { dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]); - p[x] = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); + p[x].val = ((dat & 0xff0000) >> 16) | (dat & 0x00ff00) | ((dat & 0x0000ff) << 16); } svga->ma += 4; @@ -920,12 +945,13 @@ svga_render_RGBA8888_highres(svga_t *svga) { int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - uint32_t *p, dat; int offset, x; + uint32_t dat; + pel_t *p; if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->changedvram[(svga->ma >> 12) + 2] || svga->fullchange) { offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + p = &screen->line[svga->displine + y_add][offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -933,7 +959,7 @@ svga_render_RGBA8888_highres(svga_t *svga) for (x = 0; x <= svga->hdisp; x++) { dat = *(uint32_t *)(&svga->vram[(svga->ma + (x << 2)) & svga->vram_display_mask]); - p[x] = dat >> 8; + p[x].val = dat >> 8; } svga->ma += 4; diff --git a/src/devices/video/vid_tgui9440.c b/src/devices/video/vid_tgui9440.c index d2e966c..18bf034 100644 --- a/src/devices/video/vid_tgui9440.c +++ b/src/devices/video/vid_tgui9440.c @@ -47,7 +47,7 @@ * access size or host data has any affect, but the Windows 3.1 * driver always reads bytes and write words of 0xffff. * - * Version: @(#)vid_tgui9440.c 1.0.11 2019/02/10 + * Version: @(#)vid_tgui9440.c 1.0.12 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -718,10 +718,10 @@ void tgui_hwcursor_draw(svga_t *svga, int disp_line) if (offset >= svga->hwcursor_latch.x) { if (!(dat[0] & 0x80000000)) - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] = (dat[1] & 0x80000000) ? 0xffffff : 0; + screen->line[displine + y_add][offset + 32 + x_add].val = (dat[1] & 0x80000000) ? 0xffffff : 0; else if (dat[1] & 0x80000000) - ((uint32_t *)buffer32->line[displine + y_add])[offset + 32 + x_add] ^= 0xffffff; + screen->line[displine + y_add][offset + 32 + x_add].val ^= 0xffffff; } offset++; diff --git a/src/devices/video/vid_voodoo.c b/src/devices/video/vid_voodoo.c index 4e02f57..1f522e9 100644 --- a/src/devices/video/vid_voodoo.c +++ b/src/devices/video/vid_voodoo.c @@ -8,14 +8,14 @@ * * Emulation of the 3DFX Voodoo Graphics controller. * - * Version: @(#)vid_voodoo.c 1.0.14 2019/01/16 + * Version: @(#)vid_voodoo.c 1.0.15 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, * leilei, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 leilei. * Copyright 2008-2018 Sarah Walker. @@ -7402,7 +7402,7 @@ void voodoo_callback(void *priv) if (draw_voodoo->dirty_line[draw_line]) { - uint32_t *p = &((uint32_t *)buffer32->line[voodoo->line + y_add])[32 + x_add]; + pel_t *p = &screen->line[voodoo->line + y_add][32 + x_add]; uint16_t *src = (uint16_t *)&draw_voodoo->fb_mem[draw_voodoo->front_offset + draw_line*draw_voodoo->row_width]; int x; @@ -7411,7 +7411,7 @@ void voodoo_callback(void *priv) if (voodoo->line < voodoo->dirty_line_low) { voodoo->dirty_line_low = voodoo->line; - video_wait_for_buffer(); + video_blit_wait_buffer(); } if (voodoo->line > voodoo->dirty_line_high) voodoo->dirty_line_high = voodoo->line; @@ -7436,14 +7436,14 @@ void voodoo_callback(void *priv) for (x = 0; x < voodoo->h_disp; x++) { - p[x] = (voodoo->clutData256[fil[x*3]].b << 0 | voodoo->clutData256[fil[x*3+1]].g << 8 | voodoo->clutData256[fil[x*3+2]].r << 16); + p[x].val = (voodoo->clutData256[fil[x*3]].b << 0 | voodoo->clutData256[fil[x*3+1]].g << 8 | voodoo->clutData256[fil[x*3+2]].r << 16); } } else { for (x = 0; x < voodoo->h_disp; x++) { - p[x] = draw_voodoo->video_16to32[src[x]]; + p[x].val = draw_voodoo->video_16to32[src[x]]; } } } diff --git a/src/devices/video/vid_wy700.c b/src/devices/video/vid_wy700.c index e806057..94c8c96 100644 --- a/src/devices/video/vid_wy700.c +++ b/src/devices/video/vid_wy700.c @@ -20,7 +20,7 @@ * memory ranges. Either range can be disabled by means of * jumpers; this allows the Wy700 to coexist with a CGA or MDA. * - * wy700->wy700_mode indicates which of the supported video + * dev->wy700_mode indicates which of the supported video * modes is in use: * * 0x00: 40x 25 text (CGA compatible) [32x32 char cell] @@ -53,7 +53,7 @@ * What doesn't work, is untested or not well understood: * - Cursor detach (commands 4 and 5) * - * Version: @(#)vid_wy700.c 1.0.6 2019/03/03 + * Version: @(#)vid_wy700.c 1.0.7 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -215,7 +215,7 @@ typedef struct { uint8_t wy700_control; /* Native control / command register */ uint8_t wy700_mode; /* Current mode (see list at top of file) */ uint8_t cga_ctrl; /* Emulated MDA/CGA control register */ - uint8_t cga_colour; /* Emulated CGA colour register (ignored) */ + uint8_t cga_color; /* Emulated CGA color register (ignored) */ uint8_t mda_stat; /* MDA status (IN 0x3BA) */ uint8_t cga_stat; /* CGA status (IN 0x3DA) */ @@ -232,11 +232,11 @@ typedef struct { int dispon, blink; int64_t vsynctime; - /* Mapping of attributes to colours, in CGA emulation... */ - int cgacols[256][2][2]; + /* Mapping of attributes to colors, in CGA emulation... */ + uint8_t cgacols[256][2][2]; /* ... and MDA emulation. */ - int mdacols[256][2][2]; + uint8_t mdacols[256][2][2]; /* Font ROM: Two fonts, each containing 256 characters, 16x16 pixels */ uint8_t fontdat[512][32]; @@ -426,7 +426,6 @@ wy700_out(uint16_t port, uint8_t val, void *priv) case 0x3b1: case 0x3b3: case 0x3b5: case 0x3b7: case 0x3d1: case 0x3d3: case 0x3d5: case 0x3d7: dev->cga_crtc[dev->cga_crtcreg] = val; - check_changes(dev); recalc_timings(dev); return; @@ -438,9 +437,9 @@ wy700_out(uint16_t port, uint8_t val, void *priv) check_changes(dev); return; - /* Emulated CGA colour register */ + /* Emulated CGA color register */ case 0x3d9: - dev->cga_colour = val; + dev->cga_color = val; return; } } @@ -464,7 +463,7 @@ wy700_in(uint16_t port, void *priv) return dev->cga_ctrl; case 0x3d9: - return dev->cga_colour; + return dev->cga_color; case 0x3ba: return dev->mda_stat; @@ -572,28 +571,29 @@ text_line(wy700_t *dev) /* MDA underline */ if (sc == 14 && mda && ((attr & 7) == 1)) { for (c = 0; c < cw; c++) - buffer->line[dev->displine][(x * cw) + c] = - dev->mdacols[attr][blink][1]; + screen->line[dev->displine][(x * cw) + c].pal = dev->mdacols[attr][blink][1]; } else { /* Draw 16 pixels of character */ bitmap[0] = fontbase[chr * 32 + 2 * sc]; bitmap[1] = fontbase[chr * 32 + 2 * sc + 1]; for (c = 0; c < 16; c++) { - int col; + uint8_t col; + if (c < 8) col = (mda ? dev->mdacols : dev->cgacols)[attr][blink][(bitmap[0] & (1 << (c ^ 7))) ? 1 : 0]; else col = (mda ? dev->mdacols : dev->cgacols)[attr][blink][(bitmap[1] & (1 << ((c & 7) ^ 7))) ? 1 : 0]; if (!(dev->enabled) || !(dev->cga_ctrl & 8)) col = dev->mdacols[0][0][0]; + if (w == 40) { - buffer->line[dev->displine][(x * cw) + 2*c] = col; - buffer->line[dev->displine][(x * cw) + 2*c + 1] = col; + screen->line[dev->displine][(x * cw) + 2*c].pal = col; + screen->line[dev->displine][(x * cw) + 2*c + 1].pal = col; } else - buffer->line[dev->displine][(x * cw) + c] = col; + screen->line[dev->displine][(x * cw) + c].pal = col; } if (drawcursor) { for (c = 0; c < cw; c++) - buffer->line[dev->displine][(x * cw) + c] ^= (mda ? dev->mdacols : dev->cgacols)[attr][0][1]; + screen->line[dev->displine][(x * cw) + c].pal ^= (mda ? dev->mdacols : dev->cgacols)[attr][0][1]; } ++ma; } @@ -628,7 +628,7 @@ cga_line(wy700_t *dev) ink = (dat & 0x80000000) ? 16 + 15: 16 + 0; if (!(dev->enabled) || !(dev->cga_ctrl & 8)) ink = 16; - buffer->line[dev->displine][x*64 + 2*c] = buffer->line[dev->displine][x*64 + 2*c+1] = ink; + screen->line[dev->displine][x*64 + 2*c].pal = screen->line[dev->displine][x*64 + 2*c+1].pal = ink; dat = dat << 1; } } else { @@ -641,7 +641,7 @@ cga_line(wy700_t *dev) } if (!(dev->enabled) || !(dev->cga_ctrl & 8)) ink = 16; - buffer->line[dev->displine][x*64 + 4*c] = buffer->line[dev->displine][x*64 + 4*c+1] = buffer->line[dev->displine][x*64 + 4*c+2] = buffer->line[dev->displine][x*64 + 4*c+3] = ink; + screen->line[dev->displine][x*64 + 4*c].pal = screen->line[dev->displine][x*64 + 4*c+1].pal = screen->line[dev->displine][x*64 + 4*c+2].pal = screen->line[dev->displine][x*64 + 4*c+3].pal = ink; dat = dat << 2; } } @@ -678,7 +678,7 @@ medres_line(wy700_t *dev) /* Display disabled? */ if (!(dev->wy700_mode & 8)) ink = 16; - buffer->line[dev->displine][x*64 + 4*c] = buffer->line[dev->displine][x*64 + 4*c+1] = buffer->line[dev->displine][x*64 + 4*c+2] = buffer->line[dev->displine][x*64 + 4*c+3] = ink; + screen->line[dev->displine][x*64 + 4*c].pal = screen->line[dev->displine][x*64 + 4*c+1].pal = screen->line[dev->displine][x*64 + 4*c+2].pal = screen->line[dev->displine][x*64 + 4*c+3].pal = ink; dat = dat << 2; } } else { @@ -687,7 +687,7 @@ medres_line(wy700_t *dev) /* Display disabled? */ if (!(dev->wy700_mode & 8)) ink = 16; - buffer->line[dev->displine][x*64 + 2*c] = buffer->line[dev->displine][x*64 + 2*c+1] = ink; + screen->line[dev->displine][x*64 + 2*c].pal = screen->line[dev->displine][x*64 + 2*c+1].pal = ink; dat = dat << 1; } } @@ -728,7 +728,7 @@ hires_line(wy700_t *dev) /* Display disabled? */ if (!(dev->wy700_mode & 8)) ink = 16; - buffer->line[dev->displine][x*32 + 2*c] = buffer->line[dev->displine][x*32 + 2*c+1] = ink; + screen->line[dev->displine][x*32 + 2*c].pal = screen->line[dev->displine][x*32 + 2*c+1].pal = ink; dat = dat << 2; } } else { @@ -737,7 +737,7 @@ hires_line(wy700_t *dev) /* Display disabled? */ if (!(dev->wy700_mode & 8)) ink = 16; - buffer->line[dev->displine][x*32 + c] = ink; + screen->line[dev->displine][x*32 + c].pal = ink; dat = dat << 1; } } @@ -758,7 +758,7 @@ wy700_poll(void *priv) dev->linepos = 1; if (dev->dispon) { if (dev->displine == 0) - video_wait_for_buffer(); + video_blit_wait_buffer(); if (dev->wy700_mode & 0x80) mode = dev->wy700_mode & 0xF0; @@ -826,8 +826,8 @@ wy700_poll(void *priv) if (video_force_resize_get()) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, 0, 0, ysize, xsize, ysize); + video_blit_start(1, 0, 0, 0, ysize, xsize, ysize); frames++; /* Fixed 1280x800 resolution */ diff --git a/src/devices/video/video.c b/src/devices/video/video.c index 26d770d..f43663b 100644 --- a/src/devices/video/video.c +++ b/src/devices/video/video.c @@ -8,39 +8,7 @@ * * Main video-rendering module. * - * Video timing settings - - * - * 8-bit - 1mb/sec - * B = 8 ISA clocks - * W = 16 ISA clocks - * L = 32 ISA clocks - * - * Slow 16-bit - 2mb/sec - * B = 6 ISA clocks - * W = 8 ISA clocks - * L = 16 ISA clocks - * - * Fast 16-bit - 4mb/sec - * B = 3 ISA clocks - * W = 3 ISA clocks - * L = 6 ISA clocks - * - * Slow VLB/PCI - 8mb/sec (ish) - * B = 4 bus clocks - * W = 8 bus clocks - * L = 16 bus clocks - * - * Mid VLB/PCI - - * B = 4 bus clocks - * W = 5 bus clocks - * L = 10 bus clocks - * - * Fast VLB/PCI - - * B = 3 bus clocks - * W = 3 bus clocks - * L = 4 bus clocks - * - * Version: @(#)video.c 1.0.25 2019/03/05 + * Version: @(#)video.c 1.0.26 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -98,24 +66,23 @@ uint8_t fontdatm[1024][16]; /* IBM MDA font */ dbcs_font_t *fontdatk = NULL, /* Korean KSC-5601 font */ *fontdatk_user = NULL; /* Korean KSC-5601 font (user)*/ -bitmap_t *buffer = NULL, - *buffer32 = NULL; -uint32_t pal_lookup[256]; -int xsize = 1, - ysize = 1; -int cga_palette = 0; +bitmap_t *screen = NULL; + uint32_t *video_6to8 = NULL, *video_15to32 = NULL, *video_16to32 = NULL; +uint8_t edatlookup[4][4]; +int xsize = 1, + ysize = 1; +int cga_palette = 0; int changeframecount = 2; -uint8_t rotatevga[8][256]; int frames = 0; int fullchange = 0; int displine = 0; -uint8_t edatlookup[4][4]; int update_overscan = 0; int overscan_x = 0, overscan_y = 0; + int video_timing_read_b = 0, video_timing_read_w = 0, video_timing_read_l = 0; @@ -125,6 +92,7 @@ int video_timing_write_b = 0, int video_res_x = 0, video_res_y = 0, video_bpp = 0; + PALETTE cgapal = { {0,0,0}, {0,42,0}, {42,0,0}, {42,21,0}, {0,0,0}, {0,42,42}, {42,0,42}, {42,42,42}, @@ -201,7 +169,6 @@ static const video_timings_t timing_default = { VID_ISA, 8, 16, 32, 8, 16, 32 }; static const video_timings_t *video_timing; -static int video_card_type; static const uint32_t shade[5][256] = { {0},/* RGB Color (unused) */ {0},/* RGB Grayscale (unused) */ @@ -405,103 +372,93 @@ static const uint32_t shade[5][256] = { } }; static uint32_t cga_2_table[16]; - - -static struct { - int x, y, y1, y2, w, h; - int busy; - int buffer_in_use; - - thread_t *blit_thread; - event_t *wake_blit_thread; - event_t *blit_complete; - event_t *buffer_not_in_use; -} blit_data; +static uint32_t pal_lookup[256]; +static uint8_t rotatevga[8][256]; static int video_force_resize; -static void (*blit_func)(int x, int y, int y1, int y2, int w, int h); +static int video_card_type; + + +static struct blitter { + int x, y, y1, y2, w, h; + + volatile int busy; + event_t *busy_ev; + + volatile int inuse; + event_t *inuse_ev; + + thread_t *thread; + event_t *wake_ev; + + void (*func)(bitmap_t *,int x, int y, int y1, int y2, int w, int h); +} video_blit; static void blit_thread(void *param) { - while (1) { - thread_wait_event(blit_data.wake_blit_thread, -1); - thread_reset_event(blit_data.wake_blit_thread); + struct blitter *blit = (struct blitter *)param; - if (blit_func != NULL) - blit_func(blit_data.x, blit_data.y, - blit_data.y1, blit_data.y2, - blit_data.w, blit_data.h); + for (;;) { + thread_wait_event(blit->wake_ev, -1); + thread_reset_event(blit->wake_ev); - blit_data.busy = 0; + if (blit->func != NULL) + blit->func(screen, blit->x, blit->y, + blit->y1, blit->y2, blit->w, blit->h); - thread_set_event(blit_data.blit_complete); + blit->busy = 0; + thread_set_event(blit->busy_ev); } } +/* Set address of renderer blit function. */ void -video_setblit(void(*blit)(int,int,int,int,int,int)) +video_blit_set(void(*blit)(bitmap_t *,int,int,int,int,int,int)) { - blit_func = blit; + video_blit.func = blit; +} + + +/* Renderer blit function is done. */ +void +video_blit_done(void) +{ + video_blit.inuse = 0; + + thread_set_event(video_blit.inuse_ev); } void -video_blit_complete(void) +video_blit_wait(void) { - blit_data.buffer_in_use = 0; + while (video_blit.busy) + thread_wait_event(video_blit.busy_ev, -1); - thread_set_event(blit_data.buffer_not_in_use); + thread_reset_event(video_blit.busy_ev); } void -video_wait_for_blit(void) +video_blit_wait_buffer(void) { - while (blit_data.busy) - thread_wait_event(blit_data.blit_complete, -1); - thread_reset_event(blit_data.blit_complete); -} + while (video_blit.inuse) + thread_wait_event(video_blit.inuse_ev, -1); - -void -video_wait_for_buffer(void) -{ - while (blit_data.buffer_in_use) - thread_wait_event(blit_data.buffer_not_in_use, -1); - thread_reset_event(blit_data.buffer_not_in_use); -} - - -void -video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) -{ - if (h <= 0) return; - - video_wait_for_blit(); - - blit_data.busy = 1; - blit_data.buffer_in_use = 1; - blit_data.x = x; - blit_data.y = y; - blit_data.y1 = y1; - blit_data.y2 = y2; - blit_data.w = w; - blit_data.h = h; - - thread_set_event(blit_data.wake_blit_thread); + thread_reset_event(video_blit.inuse_ev); } static uint8_t -pixels8(uint8_t *pixels) +pixels8(pel_t *pixels) { uint8_t temp = 0; int i; for (i = 0; i < 8; i++) - temp |= (!!*(pixels + i) << (i ^ 7)); + temp |= (!!pixels[i].val << (i ^ 7)); return temp; } @@ -543,7 +500,7 @@ video_blend(int x, int y) if (x == 0) carry = 0; - val1 = pixels8(&(buffer->line[y][x])); + val1 = pixels8(&screen->line[y][x]); val2 = (val1 >> 1) + carry; carry = (val1 & 1) << 7; @@ -551,32 +508,55 @@ video_blend(int x, int y) pixels32_2 = cga_2_table[val1 & 0xf] + cga_2_table[val2 & 0xf]; for (xx = 0; xx < 4; xx++) { - buffer->line[y][x + xx] = pixel_to_color((uint8_t *)&pixels32_1, xx); - buffer->line[y][x + (xx | 4)] = pixel_to_color((uint8_t *)&pixels32_2, xx); + screen->line[y][x + xx].val = pixel_to_color((uint8_t *)&pixels32_1, xx); + screen->line[y][x + (xx | 4)].val = pixel_to_color((uint8_t *)&pixels32_2, xx); } } +/* Set up the blitter, and then wake it up to process the screen buffer. */ void -video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h) +video_blit_start(int pal, int x, int y, int y1, int y2, int w, int h) { int yy, xx; + uint32_t val; + pel_t *p; if (h <= 0) return; - for (yy = 0; yy < h; yy++) { - if ((y + yy) >= 0 && (y + yy) < buffer->h) { - for (xx = 0; xx < w; xx++) - *(uint32_t *) &(buffer32->line[y + yy][(x + xx) << 2]) = pal_lookup[buffer->line[y + yy][x + xx]]; + if (pal) { + /* In palette mode, first convert the values. */ + for (yy = 0; yy < h; yy++) { + if ((y + yy) >= 0 && (y + yy) < screen->h) { + for (xx = 0; xx < w; xx++) { + p = &screen->line[y + yy][x + xx]; + val = pal_lookup[p->pal]; + p->val = val; + } + } } } - video_blit_memtoscreen(x, y, y1, y2, w, h); + /* Wait for access to the blitter. */ + video_blit_wait(); + + video_blit.busy = 1; + video_blit.inuse = 1; + + video_blit.x = x; + video_blit.y = y; + video_blit.y1 = y1; + video_blit.y2 = y2; + video_blit.w = w; + video_blit.h = h; + + /* Wake up the blitter. */ + thread_set_event(video_blit.wake_ev); } void -cgapal_rebuild(void) +video_palette_rebuild(void) { int c; @@ -689,8 +669,9 @@ calc_16to32(int c) static void destroy_bitmap(bitmap_t *b) { - if (b->dat != NULL) - free(b->dat); + if (b->pels != NULL) + free(b->pels); + free(b); } @@ -698,15 +679,17 @@ destroy_bitmap(bitmap_t *b) static bitmap_t * create_bitmap(int x, int y) { - bitmap_t *b = (bitmap_t *)mem_alloc(sizeof(bitmap_t) + (y * sizeof(uint8_t *))); + bitmap_t *b; int c; - b->dat = (uint8_t *)mem_alloc(x * y * 4); - for (c = 0; c < y; c++) - b->line[c] = b->dat + (c * x * 4); + b = (bitmap_t *)mem_alloc(sizeof(bitmap_t) + (y * sizeof(pel_t *))); b->w = x; b->h = y; + b->pels = (pel_t *)mem_alloc(x * y * sizeof(pel_t)); + for (c = 0; c < y; c++) + b->line[c] = &b->pels[c * x]; + return(b); } @@ -741,13 +724,6 @@ video_init(void) (total[(c >> 0) & 1] << 24); } - /* Initialize video type and timing. */ - video_inform(VID_TYPE_DFLT, NULL); - - /* Account for overscan. */ - buffer32 = create_bitmap(2048, 2048); - buffer = create_bitmap(2048, 2048); - for (c = 0; c < 64; c++) { cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; cgapal[c + 64].g = (((c & 2) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; @@ -768,6 +744,7 @@ video_init(void) e = (e >> 1) | ((e & 1) ? 0x80 : 0); } } + for (c = 0; c < 4; c++) { for (d = 0; d < 4; d++) { edatlookup[c][d] = 0; @@ -782,42 +759,39 @@ video_init(void) for (c = 0; c < 256; c++) video_6to8[c] = calc_6to8(c); video_15to32 = (uint32_t *)mem_alloc(4 * 65536); -#if 0 - for (c = 0; c < 65536; c++) - video_15to32[c] = ((c & 31) << 3) | (((c >> 5) & 31) << 11) | (((c >> 10) & 31) << 19); -#endif for (c = 0; c < 65536; c++) video_15to32[c] = calc_15to32(c); video_16to32 = (uint32_t *)mem_alloc(4 * 65536); -#if 0 - for (c = 0; c < 65536; c++) - video_16to32[c] = ((c & 31) << 3) | (((c >> 5) & 63) << 10) | (((c >> 11) & 31) << 19); -#endif for (c = 0; c < 65536; c++) video_16to32[c] = calc_16to32(c); - blit_data.wake_blit_thread = thread_create_event(); - blit_data.blit_complete = thread_create_event(); - blit_data.buffer_not_in_use = thread_create_event(); - blit_data.blit_thread = thread_create(blit_thread, NULL); + /* Create the screen buffer. */ + screen = create_bitmap(2048, 2048); + + video_blit.wake_ev = thread_create_event(); + video_blit.busy_ev = thread_create_event(); + video_blit.inuse_ev = thread_create_event(); + video_blit.thread = thread_create(blit_thread, &video_blit); + + /* Initialize video type and timing. */ + video_inform(VID_TYPE_DFLT, NULL); } void video_close(void) { - thread_kill(blit_data.blit_thread); - thread_destroy_event(blit_data.buffer_not_in_use); - thread_destroy_event(blit_data.blit_complete); - thread_destroy_event(blit_data.wake_blit_thread); + thread_kill(video_blit.thread); + thread_destroy_event(video_blit.inuse_ev); + thread_destroy_event(video_blit.busy_ev); + thread_destroy_event(video_blit.wake_ev); free(video_6to8); free(video_15to32); free(video_16to32); - destroy_bitmap(buffer); - destroy_bitmap(buffer32); + destroy_bitmap(screen); video_reset_font(); } @@ -899,14 +873,14 @@ video_reset_font(void) /* Load a font from its ROM source. */ void -video_load_font(const wchar_t *s, fontformat_t num) +video_load_font(const wchar_t *fn, fontformat_t num) { FILE *fp; int c; - fp = plat_fopen(rom_path(s), L"rb"); + fp = plat_fopen(rom_path(fn), L"rb"); if (fp == NULL) { - ERRLOG("VIDEO: cannot load font '%ls', fmt=%i\n", s, num); + ERRLOG("VIDEO: cannot load font '%ls', fmt=%i\n", fn, num); return; } @@ -929,7 +903,7 @@ video_load_font(const wchar_t *s, fontformat_t num) break; } - DEBUG("VIDEO: font #%i loaded\n", num); + DEBUG("VIDEO: font #%i loaded from %ls\n", num, fn); (void)fclose(fp); } @@ -990,13 +964,10 @@ video_color_transform(uint32_t color) void -video_transform_copy(uint32_t *dst, uint32_t *src, int len) +video_transform_copy(uint32_t *dst, pel_t *src, int len) { int i; - for (i = 0; i < len; i++) { - *dst = video_color_transform(*src); - dst++; - src++; - } + for (i = 0; i < len; i++) + *dst++ = video_color_transform(src[i].val); } diff --git a/src/devices/video/video.h b/src/devices/video/video.h index cf2cf46..11ca6d3 100644 --- a/src/devices/video/video.h +++ b/src/devices/video/video.h @@ -8,7 +8,7 @@ * * Definitions for the video controller module. * - * Version: @(#)video.h 1.0.28 2019/03/05 + * Version: @(#)video.h 1.0.29 2019/03/08 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -87,35 +87,34 @@ typedef enum { extern "C" { #endif - typedef struct video_timings { int type; int write_b, write_w, write_l; int read_b, read_w, read_l; } video_timings_t; -typedef struct { - int w, h; - uint8_t *dat; -#if 1 - /* Most compilers are OK with this, as long as its at end of struct. */ - uint8_t *line[]; -#else - /* However, just in case we need it... */ - uint8_t *line[2048]; -#endif -} bitmap_t; - typedef struct { uint8_t r, g, b; } rgb_t; +typedef union { + uint32_t val; /* pel, accessed as 32b value */ + uint8_t pal; /* pel, accessed as 8b palette index */ + rgb_t rgb; /* pel, accessed as RGB value */ +} pel_t; + +typedef struct { + int w, h; /* screen buffer sizes */ + pel_t *pels; /* pointer to actual pels */ + pel_t *line[]; /* array with line pointers */ +} bitmap_t; + +typedef rgb_t PALETTE[256]; + typedef struct { uint8_t chr[32]; } dbcs_font_t; -typedef rgb_t PALETTE[256]; - extern int changeframecount; @@ -125,11 +124,7 @@ extern uint8_t fontdatm[1024][16]; /* 1024 characters */ extern dbcs_font_t *fontdatk, *fontdatk_user; -extern bitmap_t *buffer, - *buffer32; -extern PALETTE cgapal, - cgapal_mono[6]; -extern uint32_t pal_lookup[256]; +extern bitmap_t *screen; extern uint32_t *video_6to8, *video_15to32, *video_16to32; @@ -332,15 +327,14 @@ extern int video_card_has_config(int card); extern const device_t *video_card_getdevice(int card); #endif -extern void video_setblit(void(*blit)(int,int,int,int,int,int)); +extern void video_blit_set(void(*)(bitmap_t *,int,int,int,int,int,int)); +extern void video_blit_done(void); +extern void video_blit_wait(void); +extern void video_blit_wait_buffer(void); +extern void video_blit_start(int pal, int x, int y, + int y1, int y2, int w, int h); extern void video_blend(int x, int y); -extern void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h); -extern void video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h); -extern void video_blit_complete(void); -extern void video_wait_for_blit(void); -extern void video_wait_for_buffer(void); - -extern void cgapal_rebuild(void); +extern void video_palette_rebuild(void); #ifdef VIDEO_SVGA_H extern int ati28800k_load_font(svga_t *, const wchar_t *); @@ -358,7 +352,7 @@ extern void video_load_font(const wchar_t *s, fontformat_t num); extern uint8_t video_force_resize_get(void); extern void video_force_resize_set(uint8_t res); extern uint32_t video_color_transform(uint32_t color); -extern void video_transform_copy(uint32_t *dst, uint32_t *src, int len); +extern void video_transform_copy(uint32_t *dst, pel_t *src, int len); extern void updatewindowsize(int x, int y); extern int get_actual_size_x(void); diff --git a/src/devices/video/video_dev.c b/src/devices/video/video_dev.c index f48d434..8610697 100644 --- a/src/devices/video/video_dev.c +++ b/src/devices/video/video_dev.c @@ -12,7 +12,7 @@ * "extern" reference to its device into the video.h file, * and add an entry for it into the table here. * - * Version: @(#)video_dev.c 1.0.33 2019/03/05 + * Version: @(#)video_dev.c 1.0.34 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -204,7 +204,7 @@ video_reset(void) /* Reset the CGA palette. */ cga_palette = 0; - cgapal_rebuild(); + video_palette_rebuild(); /* * Clear (deallocate) any video font memory. diff --git a/src/machines/m_amstrad.c b/src/machines/m_amstrad.c index ce378a7..8a9a34f 100644 --- a/src/machines/m_amstrad.c +++ b/src/machines/m_amstrad.c @@ -32,7 +32,7 @@ * BIOSES: I need to re-do the bios.txt format so we can load non-BIOS * ROM files for a given machine, such as font roms here.. * - * Version: @(#)m_amstrad.c 1.0.23 2019/03/06 + * Version: @(#)m_amstrad.c 1.0.23 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -319,22 +319,23 @@ vid_poll_1512(void *priv) if (vid->dispon) { if (vid->displine < vid->firstline) { vid->firstline = vid->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } vid->lastline = vid->displine; + for (c = 0; c < 8; c++) { if ((vid->cgamode & 0x12) == 0x12) { - buffer->line[vid->displine][c] = (vid->border & 15) + 16; + screen->line[vid->displine][c].pal = (vid->border & 15) + 16; if (vid->cgamode & 1) - buffer->line[vid->displine][c + (vid->crtc[1] << 3) + 8] = 0; + screen->line[vid->displine][c + (vid->crtc[1] << 3) + 8].pal = 0; else - buffer->line[vid->displine][c + (vid->crtc[1] << 4) + 8] = 0; + screen->line[vid->displine][c + (vid->crtc[1] << 4) + 8].pal = 0; } else { - buffer->line[vid->displine][c] = (vid->cgacol & 15) + 16; + screen->line[vid->displine][c].pal = (vid->cgacol & 15) + 16; if (vid->cgamode & 1) - buffer->line[vid->displine][c + (vid->crtc[1] << 3) + 8] = (vid->cgacol & 15) + 16; + screen->line[vid->displine][c + (vid->crtc[1] << 3) + 8].pal = (vid->cgacol & 15) + 16; else - buffer->line[vid->displine][c + (vid->crtc[1] << 4) + 8] = (vid->cgacol & 15) + 16; + screen->line[vid->displine][c + (vid->crtc[1] << 4) + 8].pal = (vid->cgacol & 15) + 16; } } if (vid->cgamode & 1) { @@ -353,10 +354,10 @@ vid_poll_1512(void *priv) } if (drawcursor) { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 3) + c + 8] = cols[(vid->fontdat[chr + vid->fontbase][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + screen->line[vid->displine][(x << 3) + c + 8].pal = cols[(vid->fontdat[chr + vid->fontbase][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 3) + c + 8] = cols[(vid->fontdat[chr + vid->fontbase][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[vid->displine][(x << 3) + c + 8].pal = cols[(vid->fontdat[chr + vid->fontbase][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } vid->ma++; } @@ -377,12 +378,12 @@ vid_poll_1512(void *priv) vid->ma++; if (drawcursor) { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(vid->fontdat[chr + vid->fontbase][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(vid->fontdat[chr + vid->fontbase][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(vid->fontdat[chr + vid->fontbase][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(vid->fontdat[chr + vid->fontbase][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } } } else if (! (vid->cgamode & 16)) { @@ -405,8 +406,8 @@ vid_poll_1512(void *priv) dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000) + 1]; vid->ma++; for (c = 0; c < 8; c++) { - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[dat >> 14]; dat <<= 2; } } @@ -420,7 +421,7 @@ vid_poll_1512(void *priv) vid->ma++; for (c = 0; c < 16; c++) { - buffer->line[vid->displine][(x << 4) + c + 8] = (((dat >> 15) | ((dat2 >> 15) << 1) | ((dat3 >> 15) << 2) | ((dat4 >> 15) << 3)) & (vid->cgacol & 15)) + 16; + screen->line[vid->displine][(x << 4) + c + 8].pal = (((dat >> 15) | ((dat2 >> 15) << 1) | ((dat3 >> 15) << 2) | ((dat4 >> 15) << 3)) & (vid->cgacol & 15)) + 16; dat <<= 1; dat2 <<= 1; dat3 <<= 1; @@ -431,9 +432,9 @@ vid_poll_1512(void *priv) } else { cols[0] = ((vid->cgamode & 0x12) == 0x12) ? 0 : (vid->cgacol & 15) + 16; if (vid->cgamode & 1) - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 3) + 16, cols[0]); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 3) + 16, cols[0]); else - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 4) + 16, cols[0]); } vid->sc = oldsc; @@ -505,7 +506,7 @@ vid_poll_1512(void *priv) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, vid->firstline - 4, 0, (vid->lastline - vid->firstline) + 8, xsize, (vid->lastline - vid->firstline) + 8); + video_blit_start(1, 0, vid->firstline - 4, 0, (vid->lastline - vid->firstline) + 8, xsize, (vid->lastline - vid->firstline) + 8); video_res_x = xsize - 16; video_res_y = ysize; @@ -608,7 +609,7 @@ vid_init_1512(amstrad_t *ams, const wchar_t *fn, int num) overscan_x = overscan_y = 16; - cgapal_rebuild(); + video_palette_rebuild(); video_inform(VID_TYPE_CGA, &pc1512_timing); @@ -953,7 +954,7 @@ vid_init_200(amstrad_t *dev, const wchar_t *fn) overscan_x = overscan_y = 16; - cgapal_rebuild(); + video_palette_rebuild(); video_inform(VID_TYPE_CGA, &pc200_timing); diff --git a/src/machines/m_at_t3100e_vid.c b/src/machines/m_at_t3100e_vid.c index 301184e..69ab1d1 100644 --- a/src/machines/m_at_t3100e_vid.c +++ b/src/machines/m_at_t3100e_vid.c @@ -22,7 +22,7 @@ * 61 50 52 0F 19 06 19 19 02 0D 0B 0C MONO * 2D 28 22 0A 67 00 64 67 02 03 06 07 640x400 * - * Version: @(#)m_at_t3100e_vid.c 1.0.7 2019/03/03 + * Version: @(#)m_at_t3100e_vid.c 1.0.8 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -316,7 +316,7 @@ t3100e_read(uint32_t addr, void *priv) } -/* Draw a row of text in 80-column mode */ +/* Draw a row of text in 80-column mode. */ static void text_row80(t3100e_t *dev) { @@ -369,18 +369,18 @@ text_row80(t3100e_t *dev) if (drawcursor) { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[dev->displine])[(x << 3) + c] = cols[(dev->fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (amber ^ black); + screen->line[dev->displine][(x << 3) + c].val = cols[(dev->fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (amber ^ black); } } else { for (c = 0; c < 8; c++) - ((uint32_t *)buffer32->line[dev->displine])[(x << 3) + c] = cols[(dev->fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->displine][(x << 3) + c].val = cols[(dev->fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; } ++ma; } } -/* Draw a row of text in 40-column mode */ +/* Draw a row of text in 40-column mode. */ static void text_row40(t3100e_t *dev) { @@ -433,11 +433,11 @@ text_row40(t3100e_t *dev) if (drawcursor) { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[dev->displine])[(x << 4) + c*2] = ((uint32_t *)buffer32->line[dev->displine])[(x << 4) + c*2 + 1] = cols[(dev->fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (amber ^ black); + screen->line[dev->displine][(x << 4) + c*2].val = screen->line[dev->displine][(x << 4) + c*2 + 1].val = cols[(dev->fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (amber ^ black); } } else { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[dev->displine])[(x << 4) + c*2] = ((uint32_t *)buffer32->line[dev->displine])[(x << 4) + c*2+1] = cols[(dev->fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->displine][(x << 4) + c*2].val = screen->line[dev->displine][(x << 4) + c*2+1].val = cols[(dev->fontdatm[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; } } ++ma; @@ -445,7 +445,7 @@ text_row40(t3100e_t *dev) } -/* Draw a line in CGA 640x200 or T3100e 640x400 mode */ +/* Draw a line in CGA 640x200 or T3100e 640x400 mode. */ static void cga_line6(t3100e_t *dev) { @@ -476,7 +476,7 @@ cga_line6(t3100e_t *dev) ink = (dat & 0x80) ? fg : bg; if (!(dev->cga.cgamode & 8)) ink = black; - ((uint32_t *)buffer32->line[dev->displine])[x*8+c] = ink; + screen->line[dev->displine][x*8+c].val = ink; dat = dat << 1; } } @@ -540,8 +540,8 @@ cga_line4(t3100e_t *dev) } - ((uint32_t *)buffer32->line[dev->displine])[x*8+2*c] = ink0; - ((uint32_t *)buffer32->line[dev->displine])[x*8+2*c+1] = ink1; + screen->line[dev->displine][x*8+2*c].val = ink0; + screen->line[dev->displine][x*8+2*c+1].val = ink1; dat = dat << 2; } } @@ -584,7 +584,7 @@ t3100e_poll(void *priv) dev->linepos = 1; if (dev->dispon) { if (dev->displine == 0) - video_wait_for_buffer(); + video_blit_wait_buffer(); /* Graphics */ if (dev->cga.cgamode & 0x02) { @@ -626,7 +626,8 @@ t3100e_poll(void *priv) if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + + video_blit_start(1, 0, 0, 0, ysize, xsize, ysize); frames++; /* Fixed 640x400 resolution */ diff --git a/src/machines/m_olivetti_m24.c b/src/machines/m_olivetti_m24.c index e6cea81..751470c 100644 --- a/src/machines/m_olivetti_m24.c +++ b/src/machines/m_olivetti_m24.c @@ -8,7 +8,7 @@ * * Emulation of the Olivetti M24. * - * Version: @(#)m_olivetti_m24.c 1.0.14 2019/02/16 + * Version: @(#)m_olivetti_m24.c 1.0.15 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -260,7 +260,7 @@ vid_poll(void *priv) int col; int oldsc; - if (!dev->linepos) { + if (! dev->linepos) { dev->vidtime += dev->dispofftime; dev->stat |= 1; dev->linepos = 1; @@ -270,21 +270,22 @@ vid_poll(void *priv) if (dev->dispon) { if (dev->displine < dev->firstline) { dev->firstline = dev->displine; + video_blit_wait_buffer(); } dev->lastline = dev->displine; for (c = 0; c < 8; c++) { if ((dev->cgamode & 0x12) == 0x12) { - buffer->line[dev->displine][c] = 0; + screen->line[dev->displine][c].pal = 0; if (dev->cgamode & 1) - buffer->line[dev->displine][c + (dev->crtc[1] << 3) + 8] = 0; + screen->line[dev->displine][c + (dev->crtc[1] << 3) + 8].pal = 0; else - buffer->line[dev->displine][c + (dev->crtc[1] << 4) + 8] = 0; + screen->line[dev->displine][c + (dev->crtc[1] << 4) + 8].pal = 0; } else { - buffer->line[dev->displine][c] = (dev->cgacol & 15) + 16; + screen->line[dev->displine][c].pal = (dev->cgacol & 15) + 16; if (dev->cgamode & 1) - buffer->line[dev->displine][c + (dev->crtc[1] << 3) + 8] = (dev->cgacol & 15) + 16; + screen->line[dev->displine][c + (dev->crtc[1] << 3) + 8].pal = (dev->cgacol & 15) + 16; else - buffer->line[dev->displine][c + (dev->crtc[1] << 4) + 8] = (dev->cgacol & 15) + 16; + screen->line[dev->displine][c + (dev->crtc[1] << 4) + 8].pal = (dev->cgacol & 15) + 16; } } if (dev->cgamode & 1) { @@ -303,10 +304,10 @@ vid_poll(void *priv) } if (drawcursor) { for (c = 0; c < 8; c++) - buffer->line[dev->displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((dev->sc & 7) << 1) | dev->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + screen->line[dev->displine][(x << 3) + c + 8].pal = cols[(fontdatm[chr][((dev->sc & 7) << 1) | dev->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { for (c = 0; c < 8; c++) - buffer->line[dev->displine][(x << 3) + c + 8] = cols[(fontdatm[chr][((dev->sc & 7) << 1) | dev->lineff] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->displine][(x << 3) + c + 8].pal = cols[(fontdatm[chr][((dev->sc & 7) << 1) | dev->lineff] & (1 << (c ^ 7))) ? 1 : 0]; } dev->ma++; } @@ -327,12 +328,12 @@ vid_poll(void *priv) dev->ma++; if (drawcursor) { for (c = 0; c < 8; c++) - buffer->line[dev->displine][(x << 4) + (c << 1) + 8] = - buffer->line[dev->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((dev->sc & 7) << 1) | dev->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; + screen->line[dev->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[dev->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdatm[chr][((dev->sc & 7) << 1) | dev->lineff] & (1 << (c ^ 7))) ? 1 : 0] ^ 15; } else { for (c = 0; c < 8; c++) - buffer->line[dev->displine][(x << 4) + (c << 1) + 8] = - buffer->line[dev->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdatm[chr][((dev->sc & 7) << 1) | dev->lineff] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[dev->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[dev->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdatm[chr][((dev->sc & 7) << 1) | dev->lineff] & (1 << (c ^ 7))) ? 1 : 0]; } } } else if (! (dev->cgamode & 16)) { @@ -356,8 +357,8 @@ vid_poll(void *priv) dev->vram[((dev->ma << 1) & 0x1fff) + ((dev->sc & 1) * 0x2000) + 1 + dev->base]; dev->ma++; for (c = 0; c < 8; c++) { - buffer->line[dev->displine][(x << 4) + (c << 1) + 8] = - buffer->line[dev->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; + screen->line[dev->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[dev->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[dat >> 14]; dat <<= 2; } } @@ -374,7 +375,7 @@ vid_poll(void *priv) dat = (dev->vram[((dev->ma << 1) & 0x1fff) + dat2] << 8) | dev->vram[((dev->ma << 1) & 0x1fff) + dat2 + 1]; dev->ma++; for (c = 0; c < 16; c++) { - buffer->line[dev->displine][(x << 4) + c + 8] = cols[dat >> 15]; + screen->line[dev->displine][(x << 4) + c + 8].pal = cols[dat >> 15]; dat <<= 1; } } @@ -382,9 +383,9 @@ vid_poll(void *priv) } else { cols[0] = ((dev->cgamode & 0x12) == 0x12) ? 0 : (dev->cgacol & 15) + 16; if (dev->cgamode & 1) - cga_hline(buffer, 0, dev->displine, (dev->crtc[1] << 3) + 16, cols[0]); + cga_hline(screen, 0, dev->displine, (dev->crtc[1] << 3) + 16, cols[0]); else - cga_hline(buffer, 0, dev->displine, (dev->crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, dev->displine, (dev->crtc[1] << 4) + 16, cols[0]); } if (dev->cgamode & 1) @@ -469,7 +470,7 @@ vid_poll(void *priv) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, dev->firstline - 8, 0, (dev->lastline - dev->firstline) + 16, xsize, (dev->lastline - dev->firstline) + 16); + video_blit_start(1, 0, dev->firstline - 8, 0, (dev->lastline - dev->firstline) + 16, xsize, (dev->lastline - dev->firstline) + 16); frames++; video_res_x = xsize - 16; diff --git a/src/machines/m_pcjr.c b/src/machines/m_pcjr.c index f85b305..2de8cb0 100644 --- a/src/machines/m_pcjr.c +++ b/src/machines/m_pcjr.c @@ -8,7 +8,7 @@ * * Emulation of the IBM PCjr. * - * Version: @(#)m_pcjr.c 1.0.14 2019/03/04 + * Version: @(#)m_pcjr.c 1.0.15 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -277,16 +277,16 @@ vid_poll(void *p) if (pcjr->displine < pcjr->firstline) { pcjr->firstline = pcjr->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } pcjr->lastline = pcjr->displine; cols[0] = (pcjr->array[2] & 0xf) + 16; for (c = 0; c < 8; c++) { - buffer->line[pcjr->displine][c] = cols[0]; + screen->line[pcjr->displine][c].pal = cols[0]; if (pcjr->array[0] & 1) - buffer->line[pcjr->displine][c + (pcjr->crtc[1] << 3) + 8] = cols[0]; + screen->line[pcjr->displine][c + (pcjr->crtc[1] << 3) + 8].pal = cols[0]; else - buffer->line[pcjr->displine][c + (pcjr->crtc[1] << 4) + 8] = cols[0]; + screen->line[pcjr->displine][c + (pcjr->crtc[1] << 4) + 8].pal = cols[0]; } switch (pcjr->addr_mode) { @@ -301,45 +301,48 @@ vid_poll(void *p) offset = (pcjr->sc & 3) * 0x2000; break; } + switch ((pcjr->array[0] & 0x13) | ((pcjr->array[3] & 0x08) << 5)) { case 0x13: /*320x200x16*/ for (x = 0; x < pcjr->crtc[1]; x++) { dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; pcjr->ma++; - buffer->line[pcjr->displine][(x << 3) + 8] = - buffer->line[pcjr->displine][(x << 3) + 9] = pcjr->array[((dat >> 12) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 3) + 10] = - buffer->line[pcjr->displine][(x << 3) + 11] = pcjr->array[((dat >> 8) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 3) + 12] = - buffer->line[pcjr->displine][(x << 3) + 13] = pcjr->array[((dat >> 4) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 3) + 14] = - buffer->line[pcjr->displine][(x << 3) + 15] = pcjr->array[(dat & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 3) + 8].pal = + screen->line[pcjr->displine][(x << 3) + 9].pal = pcjr->array[((dat >> 12) & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 3) + 10].pal = + screen->line[pcjr->displine][(x << 3) + 11].pal = pcjr->array[((dat >> 8) & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 3) + 12].pal = + screen->line[pcjr->displine][(x << 3) + 13].pal = pcjr->array[((dat >> 4) & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 3) + 14].pal = + screen->line[pcjr->displine][(x << 3) + 15].pal = pcjr->array[(dat & pcjr->array[1]) + 16] + 16; } break; + case 0x12: /*160x200x16*/ for (x = 0; x < pcjr->crtc[1]; x++) { dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; pcjr->ma++; - buffer->line[pcjr->displine][(x << 4) + 8] = - buffer->line[pcjr->displine][(x << 4) + 9] = - buffer->line[pcjr->displine][(x << 4) + 10] = - buffer->line[pcjr->displine][(x << 4) + 11] = pcjr->array[((dat >> 12) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 4) + 12] = - buffer->line[pcjr->displine][(x << 4) + 13] = - buffer->line[pcjr->displine][(x << 4) + 14] = - buffer->line[pcjr->displine][(x << 4) + 15] = pcjr->array[((dat >> 8) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 4) + 16] = - buffer->line[pcjr->displine][(x << 4) + 17] = - buffer->line[pcjr->displine][(x << 4) + 18] = - buffer->line[pcjr->displine][(x << 4) + 19] = pcjr->array[((dat >> 4) & pcjr->array[1]) + 16] + 16; - buffer->line[pcjr->displine][(x << 4) + 20] = - buffer->line[pcjr->displine][(x << 4) + 21] = - buffer->line[pcjr->displine][(x << 4) + 22] = - buffer->line[pcjr->displine][(x << 4) + 23] = pcjr->array[(dat & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 4) + 8].pal = + screen->line[pcjr->displine][(x << 4) + 9].pal = + screen->line[pcjr->displine][(x << 4) + 10].pal = + screen->line[pcjr->displine][(x << 4) + 11].pal = pcjr->array[((dat >> 12) & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 4) + 12].pal = + screen->line[pcjr->displine][(x << 4) + 13].pal = + screen->line[pcjr->displine][(x << 4) + 14].pal = + screen->line[pcjr->displine][(x << 4) + 15].pal = pcjr->array[((dat >> 8) & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 4) + 16].pal = + screen->line[pcjr->displine][(x << 4) + 17].pal = + screen->line[pcjr->displine][(x << 4) + 18].pal = + screen->line[pcjr->displine][(x << 4) + 19].pal = pcjr->array[((dat >> 4) & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 4) + 20].pal = + screen->line[pcjr->displine][(x << 4) + 21].pal = + screen->line[pcjr->displine][(x << 4) + 22].pal = + screen->line[pcjr->displine][(x << 4) + 23].pal = pcjr->array[(dat & pcjr->array[1]) + 16] + 16; } break; + case 0x03: /*640x200x4*/ for (x = 0; x < pcjr->crtc[1]; x++) { dat = (pcjr->vram[((pcjr->ma << 1) & mask) + offset] << 8) | @@ -348,11 +351,12 @@ vid_poll(void *p) for (c = 0; c < 8; c++) { chr = (dat >> 7) & 1; chr |= ((dat >> 14) & 2); - buffer->line[pcjr->displine][(x << 3) + 8 + c] = pcjr->array[(chr & pcjr->array[1]) + 16] + 16; + screen->line[pcjr->displine][(x << 3) + 8 + c].pal = pcjr->array[(chr & pcjr->array[1]) + 16] + 16; dat <<= 1; } } break; + case 0x01: /*80 column text*/ for (x = 0; x < pcjr->crtc[1]; x++) { chr = pcjr->vram[((pcjr->ma << 1) & mask) + offset]; @@ -369,18 +373,19 @@ vid_poll(void *p) } if (pcjr->sc & 8) { for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 3) + c + 8] = cols[0]; + screen->line[pcjr->displine][(x << 3) + c + 8].pal = cols[0]; } else { for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 3) + c + 8] = cols[(fontdat[chr][pcjr->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[pcjr->displine][(x << 3) + c + 8].pal = cols[(fontdat[chr][pcjr->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } if (drawcursor) { for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 3) + c + 8] ^= 15; + screen->line[pcjr->displine][(x << 3) + c + 8].pal ^= 15; } pcjr->ma++; } break; + case 0x00: /*40 column text*/ for (x = 0; x < pcjr->crtc[1]; x++) { chr = pcjr->vram[((pcjr->ma << 1) & mask) + offset]; @@ -398,19 +403,20 @@ vid_poll(void *p) pcjr->ma++; if (pcjr->sc & 8) { for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[0]; + screen->line[pcjr->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[0]; } else { for (c = 0; c < 8; c++) - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][pcjr->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[pcjr->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdat[chr][pcjr->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } if (drawcursor) { for (c = 0; c < 16; c++) - buffer->line[pcjr->displine][(x << 4) + c + 8] ^= 15; + screen->line[pcjr->displine][(x << 4) + c + 8].pal ^= 15; } } break; + case 0x02: /*320x200x4*/ cols[0] = pcjr->array[0 + 16] + 16; cols[1] = pcjr->array[1 + 16] + 16; @@ -421,12 +427,13 @@ vid_poll(void *p) pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; pcjr->ma++; for (c = 0; c < 8; c++) { - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 8] = - buffer->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; + screen->line[pcjr->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[pcjr->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[dat >> 14]; dat <<= 2; } } break; + case 0x102: /*640x200x2*/ cols[0] = pcjr->array[0 + 16] + 16; cols[1] = pcjr->array[1 + 16] + 16; @@ -435,7 +442,7 @@ vid_poll(void *p) pcjr->vram[((pcjr->ma << 1) & mask) + offset + 1]; pcjr->ma++; for (c = 0; c < 16; c++) { - buffer->line[pcjr->displine][(x << 4) + c + 8] = cols[dat >> 15]; + screen->line[pcjr->displine][(x << 4) + c + 8].pal = cols[dat >> 15]; dat <<= 1; } } @@ -444,25 +451,25 @@ vid_poll(void *p) } else { if (pcjr->array[3] & 4) { if (pcjr->array[0] & 1) - cga_hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 3) + 16, (pcjr->array[2] & 0xf) + 16); + cga_hline(screen, 0, pcjr->displine, (pcjr->crtc[1] << 3) + 16, (pcjr->array[2] & 0xf) + 16); else - cga_hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 4) + 16, (pcjr->array[2] & 0xf) + 16); + cga_hline(screen, 0, pcjr->displine, (pcjr->crtc[1] << 4) + 16, (pcjr->array[2] & 0xf) + 16); } else { cols[0] = pcjr->array[0 + 16] + 16; if (pcjr->array[0] & 1) - cga_hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 3) + 16, cols[0]); + cga_hline(screen, 0, pcjr->displine, (pcjr->crtc[1] << 3) + 16, cols[0]); else - cga_hline(buffer, 0, pcjr->displine, (pcjr->crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, pcjr->displine, (pcjr->crtc[1] << 4) + 16, cols[0]); } } - if (pcjr->array[0] & 1) x = (pcjr->crtc[1] << 3) + 16; - else x = (pcjr->crtc[1] << 4) + 16; - if (pcjr->composite) { - for (c = 0; c < x; c++) - buffer32->line[pcjr->displine][c] = buffer->line[pcjr->displine][c] & 0xf; + if (pcjr->array[0] & 1) + x = (pcjr->crtc[1] << 3) + 16; + else + x = (pcjr->crtc[1] << 4) + 16; + + if (pcjr->composite) + cga_comp_process(pcjr->cpriv, pcjr->array[0], 0, x >> 2, screen->line[pcjr->displine]); - cga_comp_process(pcjr->cpriv, pcjr->array[0], 0, x >> 2, buffer32->line[pcjr->displine]); - } pcjr->sc = oldsc; if (pcjr->vc == pcjr->crtc[7] && !pcjr->sc) { pcjr->stat |= 8; @@ -510,8 +517,10 @@ vid_poll(void *p) pcjr->dispon = 1; if (!pcjr->vadj) pcjr->ma = pcjr->maback = (pcjr->crtc[13] | (pcjr->crtc[12] << 8)) & 0x3fff; - if ((pcjr->crtc[10] & 0x60) == 0x20) pcjr->cursoron = 0; - else pcjr->cursoron = pcjr->blink & 16; + if ((pcjr->crtc[10] & 0x60) == 0x20) + pcjr->cursoron = 0; + else + pcjr->cursoron = pcjr->blink & 16; } if (pcjr->vc == pcjr->crtc[7]) { pcjr->dispon = 0; @@ -519,8 +528,10 @@ vid_poll(void *p) pcjr->vsynctime = 16; picint(1 << 5); if (pcjr->crtc[7]) { - if (pcjr->array[0] & 1) x = (pcjr->crtc[1] << 3) + 16; - else x = (pcjr->crtc[1] << 4) + 16; + if (pcjr->array[0] & 1) + x = (pcjr->crtc[1] << 3) + 16; + else + x = (pcjr->crtc[1] << 4) + 16; pcjr->lastline++; if ((x != xsize) || ((pcjr->lastline - pcjr->firstline) != ysize) || video_force_resize_get()) { xsize = x; @@ -534,9 +545,9 @@ vid_poll(void *p) } if (pcjr->composite) - video_blit_memtoscreen(0, pcjr->firstline-4, 0, (pcjr->lastline - pcjr->firstline) + 8, xsize, (pcjr->lastline - pcjr->firstline) + 8); + video_blit_start(0, 0, pcjr->firstline-4, 0, (pcjr->lastline - pcjr->firstline) + 8, xsize, (pcjr->lastline - pcjr->firstline) + 8); else - video_blit_memtoscreen_8(0, pcjr->firstline-4, 0, (pcjr->lastline - pcjr->firstline) + 8, xsize, (pcjr->lastline - pcjr->firstline) + 8); + video_blit_start(1, 0, pcjr->firstline-4, 0, (pcjr->lastline - pcjr->firstline) + 8, xsize, (pcjr->lastline - pcjr->firstline) + 8); frames++; video_res_x = xsize - 16; diff --git a/src/machines/m_tandy.c b/src/machines/m_tandy.c index f9217ee..c4fd866 100644 --- a/src/machines/m_tandy.c +++ b/src/machines/m_tandy.c @@ -11,7 +11,7 @@ * NOTE: It might be better (after all..) to split off the video * driver from the main code, to keep it a little cleaner. * - * Version: @(#)m_tandy.c 1.0.16 2019/03/04 + * Version: @(#)m_tandy.c 1.0.17 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -688,29 +688,29 @@ vid_poll(void *priv) if (vid->dispon) { if (vid->displine < vid->firstline) { vid->firstline = vid->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } vid->lastline = vid->displine; cols[0] = (vid->array[2] & 0xf) + 16; for (c = 0; c < 8; c++) { if (vid->array[3] & 4) { - buffer->line[vid->displine][c] = cols[0]; + screen->line[vid->displine][c].pal = cols[0]; if (vid->mode & 1) - buffer->line[vid->displine][c + (vid->crtc[1] << 3) + 8] = cols[0]; + screen->line[vid->displine][c + (vid->crtc[1] << 3) + 8].pal = cols[0]; else - buffer->line[vid->displine][c + (vid->crtc[1] << 4) + 8] = cols[0]; + screen->line[vid->displine][c + (vid->crtc[1] << 4) + 8].pal = cols[0]; } else if ((vid->mode & 0x12) == 0x12) { - buffer->line[vid->displine][c] = 0; + screen->line[vid->displine][c].pal = 0; if (vid->mode & 1) - buffer->line[vid->displine][c + (vid->crtc[1] << 3) + 8] = 0; + screen->line[vid->displine][c + (vid->crtc[1] << 3) + 8].pal = 0; else - buffer->line[vid->displine][c + (vid->crtc[1] << 4) + 8] = 0; + screen->line[vid->displine][c + (vid->crtc[1] << 4) + 8].pal = 0; } else { - buffer->line[vid->displine][c] = (vid->col & 15) + 16; + screen->line[vid->displine][c].pal = (vid->col & 15) + 16; if (vid->mode & 1) - buffer->line[vid->displine][c + (vid->crtc[1] << 3) + 8] = (vid->col & 15) + 16; + screen->line[vid->displine][c + (vid->crtc[1] << 3) + 8].pal = (vid->col & 15) + 16; else - buffer->line[vid->displine][c + (vid->crtc[1] << 4) + 8] = (vid->col & 15) + 16; + screen->line[vid->displine][c + (vid->crtc[1] << 4) + 8].pal = (vid->col & 15) + 16; } } @@ -719,36 +719,36 @@ vid_poll(void *priv) dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000) + 1]; vid->ma++; - buffer->line[vid->displine][(x << 3) + 8] = - buffer->line[vid->displine][(x << 3) + 9] = vid->array[((dat >> 12) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 3) + 10] = - buffer->line[vid->displine][(x << 3) + 11] = vid->array[((dat >> 8) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 3) + 12] = - buffer->line[vid->displine][(x << 3) + 13] = vid->array[((dat >> 4) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 3) + 14] = - buffer->line[vid->displine][(x << 3) + 15] = vid->array[(dat & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 8].pal = + screen->line[vid->displine][(x << 3) + 9].pal = vid->array[((dat >> 12) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 10].pal = + screen->line[vid->displine][(x << 3) + 11].pal = vid->array[((dat >> 8) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 12].pal = + screen->line[vid->displine][(x << 3) + 13].pal = vid->array[((dat >> 4) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 14].pal = + screen->line[vid->displine][(x << 3) + 15].pal = vid->array[(dat & vid->array[1]) + 16] + 16; } } else if (vid->array[3] & 0x10) { /*160x200x16*/ for (x = 0; x < vid->crtc[1]; x++) { dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000) + 1]; vid->ma++; - buffer->line[vid->displine][(x << 4) + 8] = - buffer->line[vid->displine][(x << 4) + 9] = - buffer->line[vid->displine][(x << 4) + 10] = - buffer->line[vid->displine][(x << 4) + 11] = vid->array[((dat >> 12) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 4) + 12] = - buffer->line[vid->displine][(x << 4) + 13] = - buffer->line[vid->displine][(x << 4) + 14] = - buffer->line[vid->displine][(x << 4) + 15] = vid->array[((dat >> 8) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 4) + 16] = - buffer->line[vid->displine][(x << 4) + 17] = - buffer->line[vid->displine][(x << 4) + 18] = - buffer->line[vid->displine][(x << 4) + 19] = vid->array[((dat >> 4) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 4) + 20] = - buffer->line[vid->displine][(x << 4) + 21] = - buffer->line[vid->displine][(x << 4) + 22] = - buffer->line[vid->displine][(x << 4) + 23] = vid->array[(dat & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 4) + 8].pal = + screen->line[vid->displine][(x << 4) + 9].pal = + screen->line[vid->displine][(x << 4) + 10].pal = + screen->line[vid->displine][(x << 4) + 11].pal = vid->array[((dat >> 12) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 4) + 12].pal = + screen->line[vid->displine][(x << 4) + 13].pal = + screen->line[vid->displine][(x << 4) + 14].pal = + screen->line[vid->displine][(x << 4) + 15].pal = vid->array[((dat >> 8) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 4) + 16].pal = + screen->line[vid->displine][(x << 4) + 17].pal = + screen->line[vid->displine][(x << 4) + 18].pal = + screen->line[vid->displine][(x << 4) + 19].pal = vid->array[((dat >> 4) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 4) + 20].pal = + screen->line[vid->displine][(x << 4) + 21].pal = + screen->line[vid->displine][(x << 4) + 22].pal = + screen->line[vid->displine][(x << 4) + 23].pal = vid->array[(dat & vid->array[1]) + 16] + 16; } } else if (vid->array[3] & 0x08) { /*640x200x4 - this implementation is a complete guess!*/ for (x = 0; x < vid->crtc[1]; x++) { @@ -758,7 +758,7 @@ vid_poll(void *priv) for (c = 0; c < 8; c++) { chr = (dat >> 7) & 1; chr |= ((dat >> 14) & 2); - buffer->line[vid->displine][(x << 3) + 8 + c] = vid->array[(chr & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 8 + c].pal = vid->array[(chr & vid->array[1]) + 16] + 16; dat <<= 1; } } @@ -778,14 +778,14 @@ vid_poll(void *priv) } if (vid->sc & 8) { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 3) + c + 8] = cols[0]; + screen->line[vid->displine][(x << 3) + c + 8].pal = cols[0]; } else { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 3) + c + 8] = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[vid->displine][(x << 3) + c + 8].pal = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } if (drawcursor) { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 3) + c + 8] ^= 15; + screen->line[vid->displine][(x << 3) + c + 8].pal ^= 15; } vid->ma++; } @@ -806,16 +806,16 @@ vid_poll(void *priv) vid->ma++; if (vid->sc & 8) { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[0]; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[0]; } else { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } if (drawcursor) { for (c = 0; c < 16; c++) - buffer->line[vid->displine][(x << 4) + c + 8] ^= 15; + screen->line[vid->displine][(x << 4) + c + 8].pal ^= 15; } } } else if (! (vid->mode& 16)) { @@ -839,8 +839,8 @@ vid_poll(void *priv) vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000) + 1]; vid->ma++; for (c = 0; c < 8; c++) { - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[dat >> 14]; dat <<= 2; } } @@ -852,7 +852,7 @@ vid_poll(void *priv) vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000) + 1]; vid->ma++; for (c = 0; c < 16; c++) { - buffer->line[vid->displine][(x << 4) + c + 8] = cols[dat >> 15]; + screen->line[vid->displine][(x << 4) + c + 8].pal = cols[dat >> 15]; dat <<= 1; } } @@ -860,15 +860,15 @@ vid_poll(void *priv) } else { if (vid->array[3] & 4) { if (vid->mode & 1) - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 3) + 16, (vid->array[2] & 0xf) + 16); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 3) + 16, (vid->array[2] & 0xf) + 16); else - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 4) + 16, (vid->array[2] & 0xf) + 16); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 4) + 16, (vid->array[2] & 0xf) + 16); } else { cols[0] = ((vid->mode & 0x12) == 0x12) ? 0 : (vid->col & 0xf) + 16; if (vid->mode & 1) - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 3) + 16, cols[0]); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 3) + 16, cols[0]); else - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 4) + 16, cols[0]); } } @@ -876,12 +876,9 @@ vid_poll(void *priv) x = (vid->crtc[1] << 3) + 16; else x = (vid->crtc[1] << 4) + 16; - if (vid->composite) { - for (c = 0; c < x; c++) - buffer32->line[vid->displine][c] = buffer->line[vid->displine][c] & 0xf; + if (vid->composite) + cga_comp_process(vid->cpriv, vid->mode, 0, x >> 2, screen->line[vid->displine]); - cga_comp_process(vid->cpriv, vid->mode, 0, x >> 2, buffer32->line[vid->displine]); - } vid->sc = oldsc; if (vid->vc == vid->crtc[7] && !vid->sc) vid->stat |= 8; @@ -952,9 +949,9 @@ vid_poll(void *priv) video_force_resize_set(0); } if (vid->composite) - video_blit_memtoscreen(0, vid->firstline-4, 0, (vid->lastline - vid->firstline) + 8, xsize, (vid->lastline - vid->firstline) + 8); + video_blit_start(0, 0, vid->firstline-4, 0, (vid->lastline - vid->firstline) + 8, xsize, (vid->lastline - vid->firstline) + 8); else - video_blit_memtoscreen_8(0, vid->firstline-4, 0, (vid->lastline - vid->firstline) + 8, xsize, (vid->lastline - vid->firstline) + 8); + video_blit_start(1, 0, vid->firstline-4, 0, (vid->lastline - vid->firstline) + 8, xsize, (vid->lastline - vid->firstline) + 8); frames++; @@ -1023,29 +1020,29 @@ vid_poll_sl(void *priv) if (vid->dispon) { if (vid->displine < vid->firstline) { vid->firstline = vid->displine; - video_wait_for_buffer(); + video_blit_wait_buffer(); } vid->lastline = vid->displine; cols[0] = (vid->array[2] & 0xf) + 16; for (c = 0; c < 8; c++) { if (vid->array[3] & 4) { - buffer->line[vid->displine][c] = cols[0]; + screen->line[vid->displine][c].pal = cols[0]; if (vid->mode & 1) - buffer->line[vid->displine][c + (vid->crtc[1] << 3) + 8] = cols[0]; + screen->line[vid->displine][c + (vid->crtc[1] << 3) + 8].pal = cols[0]; else - buffer->line[vid->displine][c + (vid->crtc[1] << 4) + 8] = cols[0]; + screen->line[vid->displine][c + (vid->crtc[1] << 4) + 8].pal = cols[0]; } else if ((vid->mode & 0x12) == 0x12) { - buffer->line[vid->displine][c] = 0; + screen->line[vid->displine][c].pal = 0; if (vid->mode & 1) - buffer->line[vid->displine][c + (vid->crtc[1] << 3) + 8] = 0; + screen->line[vid->displine][c + (vid->crtc[1] << 3) + 8].pal = 0; else - buffer->line[vid->displine][c + (vid->crtc[1] << 4) + 8] = 0; + screen->line[vid->displine][c + (vid->crtc[1] << 4) + 8].pal = 0; } else { - buffer->line[vid->displine][c] = (vid->col & 15) + 16; + screen->line[vid->displine][c].pal = (vid->col & 15) + 16; if (vid->mode & 1) - buffer->line[vid->displine][c + (vid->crtc[1] << 3) + 8] = (vid->col & 15) + 16; + screen->line[vid->displine][c + (vid->crtc[1] << 3) + 8].pal = (vid->col & 15) + 16; else - buffer->line[vid->displine][c + (vid->crtc[1] << 4) + 8] = (vid->col & 15) + 16; + screen->line[vid->displine][c + (vid->crtc[1] << 4) + 8].pal = (vid->col & 15) + 16; } } if (vid->array[5] & 1) { /*640x200x16*/ @@ -1053,46 +1050,46 @@ vid_poll_sl(void *priv) dat = (vid->vram[(vid->ma << 1) & 0xffff] << 8) | vid->vram[((vid->ma << 1) + 1) & 0xffff]; vid->ma++; - buffer->line[vid->displine][(x << 2) + 8] = vid->array[((dat >> 12) & 0xf)/*vid->array[1])*/ + 16] + 16; - buffer->line[vid->displine][(x << 2) + 9] = vid->array[((dat >> 8) & 0xf)/*vid->array[1])*/ + 16] + 16; - buffer->line[vid->displine][(x << 2) + 10] = vid->array[((dat >> 4) & 0xf)/*vid->array[1])*/ + 16] + 16; - buffer->line[vid->displine][(x << 2) + 11] = vid->array[(dat & 0xf)/*vid->array[1])*/ + 16] + 16; + screen->line[vid->displine][(x << 2) + 8].pal = vid->array[((dat >> 12) & 0xf)/*vid->array[1])*/ + 16] + 16; + screen->line[vid->displine][(x << 2) + 9].pal = vid->array[((dat >> 8) & 0xf)/*vid->array[1])*/ + 16] + 16; + screen->line[vid->displine][(x << 2) + 10].pal = vid->array[((dat >> 4) & 0xf)/*vid->array[1])*/ + 16] + 16; + screen->line[vid->displine][(x << 2) + 11].pal = vid->array[(dat & 0xf)/*vid->array[1])*/ + 16] + 16; } } else if ((vid->array[3] & 0x10) && (vid->mode & 1)) { /*320x200x16*/ for (x = 0; x < vid->crtc[1]; x++) { dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 3) * 0x2000) + 1]; vid->ma++; - buffer->line[vid->displine][(x << 3) + 8] = - buffer->line[vid->displine][(x << 3) + 9] = vid->array[((dat >> 12) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 3) + 10] = - buffer->line[vid->displine][(x << 3) + 11] = vid->array[((dat >> 8) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 3) + 12] = - buffer->line[vid->displine][(x << 3) + 13] = vid->array[((dat >> 4) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 3) + 14] = - buffer->line[vid->displine][(x << 3) + 15] = vid->array[(dat & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 8].pal = + screen->line[vid->displine][(x << 3) + 9].pal = vid->array[((dat >> 12) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 10].pal = + screen->line[vid->displine][(x << 3) + 11].pal = vid->array[((dat >> 8) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 12].pal = + screen->line[vid->displine][(x << 3) + 13].pal = vid->array[((dat >> 4) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 14].pal = + screen->line[vid->displine][(x << 3) + 15].pal = vid->array[(dat & vid->array[1]) + 16] + 16; } } else if (vid->array[3] & 0x10) { /*160x200x16*/ for (x = 0; x < vid->crtc[1]; x++) { dat = (vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000)] << 8) | vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000) + 1]; vid->ma++; - buffer->line[vid->displine][(x << 4) + 8] = - buffer->line[vid->displine][(x << 4) + 9] = - buffer->line[vid->displine][(x << 4) + 10] = - buffer->line[vid->displine][(x << 4) + 11] = vid->array[((dat >> 12) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 4) + 12] = - buffer->line[vid->displine][(x << 4) + 13] = - buffer->line[vid->displine][(x << 4) + 14] = - buffer->line[vid->displine][(x << 4) + 15] = vid->array[((dat >> 8) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 4) + 16] = - buffer->line[vid->displine][(x << 4) + 17] = - buffer->line[vid->displine][(x << 4) + 18] = - buffer->line[vid->displine][(x << 4) + 19] = vid->array[((dat >> 4) & vid->array[1]) + 16] + 16; - buffer->line[vid->displine][(x << 4) + 20] = - buffer->line[vid->displine][(x << 4) + 21] = - buffer->line[vid->displine][(x << 4) + 22] = - buffer->line[vid->displine][(x << 4) + 23] = vid->array[(dat & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 4) + 8].pal = + screen->line[vid->displine][(x << 4) + 9].pal = + screen->line[vid->displine][(x << 4) + 10].pal = + screen->line[vid->displine][(x << 4) + 11].pal = vid->array[((dat >> 12) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 4) + 12].pal = + screen->line[vid->displine][(x << 4) + 13].pal = + screen->line[vid->displine][(x << 4) + 14].pal = + screen->line[vid->displine][(x << 4) + 15].pal = vid->array[((dat >> 8) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 4) + 16].pal = + screen->line[vid->displine][(x << 4) + 17].pal = + screen->line[vid->displine][(x << 4) + 18].pal = + screen->line[vid->displine][(x << 4) + 19].pal = vid->array[((dat >> 4) & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 4) + 20].pal = + screen->line[vid->displine][(x << 4) + 21].pal = + screen->line[vid->displine][(x << 4) + 22].pal = + screen->line[vid->displine][(x << 4) + 23].pal = vid->array[(dat & vid->array[1]) + 16] + 16; } } else if (vid->array[3] & 0x08) { /*640x200x4 - this implementation is a complete guess!*/ for (x = 0; x < vid->crtc[1]; x++) { @@ -1102,7 +1099,7 @@ vid_poll_sl(void *priv) for (c = 0; c < 8; c++) { chr = (dat >> 7) & 1; chr |= ((dat >> 14) & 2); - buffer->line[vid->displine][(x << 3) + 8 + c] = vid->array[(chr & vid->array[1]) + 16] + 16; + screen->line[vid->displine][(x << 3) + 8 + c].pal = vid->array[(chr & vid->array[1]) + 16] + 16; dat <<= 1; } } @@ -1122,14 +1119,14 @@ vid_poll_sl(void *priv) } if (vid->sc & 8) { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 3) + c + 8] = cols[0]; + screen->line[vid->displine][(x << 3) + c + 8].pal = cols[0]; } else { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 3) + c + 8] = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[vid->displine][(x << 3) + c + 8].pal = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } if (drawcursor) { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 3) + c + 8] ^= 15; + screen->line[vid->displine][(x << 3) + c + 8].pal ^= 15; } vid->ma++; } @@ -1150,16 +1147,16 @@ vid_poll_sl(void *priv) vid->ma++; if (vid->sc & 8) { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[0]; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[0]; } else { for (c = 0; c < 8; c++) - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[(fontdat[chr][vid->sc & 7] & (1 << (c ^ 7))) ? 1 : 0]; } if (drawcursor) { for (c = 0; c < 16; c++) - buffer->line[vid->displine][(x << 4) + c + 8] ^= 15; + screen->line[vid->displine][(x << 4) + c + 8].pal ^= 15; } } } else if (! (vid->mode & 16)) { @@ -1184,8 +1181,8 @@ vid_poll_sl(void *priv) vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000) + 1]; vid->ma++; for (c = 0; c < 8; c++) { - buffer->line[vid->displine][(x << 4) + (c << 1) + 8] = - buffer->line[vid->displine][(x << 4) + (c << 1) + 1 + 8] = cols[dat >> 14]; + screen->line[vid->displine][(x << 4) + (c << 1) + 8].pal = + screen->line[vid->displine][(x << 4) + (c << 1) + 1 + 8].pal = cols[dat >> 14]; dat <<= 2; } } @@ -1197,7 +1194,7 @@ vid_poll_sl(void *priv) vid->vram[((vid->ma << 1) & 0x1fff) + ((vid->sc & 1) * 0x2000) + 1]; vid->ma++; for (c = 0; c < 16; c++) { - buffer->line[vid->displine][(x << 4) + c + 8] = cols[dat >> 15]; + screen->line[vid->displine][(x << 4) + c + 8].pal = cols[dat >> 15]; dat <<= 1; } } @@ -1205,15 +1202,15 @@ vid_poll_sl(void *priv) } else { if (vid->array[3] & 4) { if (vid->mode & 1) - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 3) + 16, (vid->array[2] & 0xf) + 16); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 3) + 16, (vid->array[2] & 0xf) + 16); else - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 4) + 16, (vid->array[2] & 0xf) + 16); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 4) + 16, (vid->array[2] & 0xf) + 16); } else { cols[0] = ((vid->mode & 0x12) == 0x12) ? 0 : (vid->col & 0xf) + 16; if (vid->mode & 1) - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 3) + 16, cols[0]); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 3) + 16, cols[0]); else - cga_hline(buffer, 0, vid->displine, (vid->crtc[1] << 4) + 16, cols[0]); + cga_hline(screen, 0, vid->displine, (vid->crtc[1] << 4) + 16, cols[0]); } } @@ -1300,7 +1297,7 @@ vid_poll_sl(void *priv) video_force_resize_set(0); } - video_blit_memtoscreen_8(0, vid->firstline-4, 0, (vid->lastline - vid->firstline) + 8, xsize, (vid->lastline - vid->firstline) + 8); + video_blit_start(1, 0, vid->firstline-4, 0, (vid->lastline - vid->firstline) + 8, xsize, (vid->lastline - vid->firstline) + 8); frames++; video_res_x = xsize - 16; diff --git a/src/machines/m_xt_t1000_vid.c b/src/machines/m_xt_t1000_vid.c index 871fef2..f2736a1 100644 --- a/src/machines/m_xt_t1000_vid.c +++ b/src/machines/m_xt_t1000_vid.c @@ -9,13 +9,13 @@ * Implementation of the Toshiba T1000 plasma display, which * has a fixed resolution of 640x200 pixels. * - * Version: @(#)m_xt_t1000_vid.c 1.0.7 2018/09/24 + * Version: @(#)m_xt_t1000_vid.c 1.0.8 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, * John Elliott, * - * Copyright 2018 Fred N. van Kempen. + * Copyright 2018,2019 Fred N. van Kempen. * Copyright 2017,2018 Miran Grca. * Copyright 2017,2018 John Elliott. * @@ -71,9 +71,9 @@ static uint8_t langid; * Bit 1: Danish * Bit 0: Thin font */ -static uint8_t st_video_options; -static uint8_t st_enabled = 1; -static int8_t st_display_internal = -1; +static uint8_t st_video_options; +static uint8_t st_enabled = 1; +static int8_t st_display_internal = -1; void @@ -84,7 +84,8 @@ t1000_video_options_set(uint8_t options) } -void t1000_video_enable(uint8_t enabled) +void +t1000_video_enable(uint8_t enabled) { st_enabled = enabled; } @@ -237,73 +238,70 @@ t1000_recalctimings(t1000_t *t1000) static void t1000_text_row80(t1000_t *t1000) { - uint32_t cols[2]; - int x, c; - uint8_t chr, attr; - int drawcursor; - int cursorline; - int bold; - int blink; - uint16_t addr; - uint8_t sc; - uint16_t ma = (t1000->cga.crtc[13] | (t1000->cga.crtc[12] << 8)) & 0x3fff; - uint16_t ca = (t1000->cga.crtc[15] | (t1000->cga.crtc[14] << 8)) & 0x3fff; + uint32_t cols[2]; + int x, c; + uint8_t chr, attr; + int drawcursor; + int cursorline; + int bold; + int blink; + uint16_t addr; + uint8_t sc; + uint16_t ma = (t1000->cga.crtc[13] | (t1000->cga.crtc[12] << 8)) & 0x3fff; + uint16_t ca = (t1000->cga.crtc[15] | (t1000->cga.crtc[14] << 8)) & 0x3fff; - sc = (t1000->displine) & 7; - addr = ((ma & ~1) + (t1000->displine >> 3) * 80) * 2; - ma += (t1000->displine >> 3) * 80; + sc = (t1000->displine) & 7; + addr = ((ma & ~1) + (t1000->displine >> 3) * 80) * 2; + ma += (t1000->displine >> 3) * 80; - if ((t1000->cga.crtc[10] & 0x60) == 0x20) - { - cursorline = 0; + if ((t1000->cga.crtc[10] & 0x60) == 0x20) { + cursorline = 0; + } else { + cursorline = ((t1000->cga.crtc[10] & 0x0F) <= sc) && + ((t1000->cga.crtc[11] & 0x0F) >= sc); + } + + for (x = 0; x < 80; x++) { + chr = t1000->vram[(addr + 2 * x) & 0x3FFF]; + attr = t1000->vram[(addr + 2 * x + 1) & 0x3FFF]; + drawcursor = ((ma == ca) && cursorline && + (t1000->cga.cgamode & 8) && (t1000->cga.cgablink & 16)); + + blink = ((t1000->cga.cgablink & 16) && (t1000->cga.cgamode & 0x20) && + (attr & 0x80) && !drawcursor); + + if (t1000->video_options & 1) + bold = boldcols[attr] ? chr : chr + 256; + else + bold = boldcols[attr] ? chr + 256 : chr; + if (t1000->video_options & 2) + bold += 512; + + if (t1000->cga.cgamode & 0x20) /* Blink */ + { + cols[1] = blinkcols[attr][1]; + cols[0] = blinkcols[attr][0]; + if (blink) cols[1] = cols[0]; } else { - cursorline = ((t1000->cga.crtc[10] & 0x0F) <= sc) && - ((t1000->cga.crtc[11] & 0x0F) >= sc); + cols[1] = normcols[attr][1]; + cols[0] = normcols[attr][0]; } - for (x = 0; x < 80; x++) + if (drawcursor) { - chr = t1000->vram[(addr + 2 * x) & 0x3FFF]; - attr = t1000->vram[(addr + 2 * x + 1) & 0x3FFF]; - drawcursor = ((ma == ca) && cursorline && - (t1000->cga.cgamode & 8) && (t1000->cga.cgablink & 16)); - - blink = ((t1000->cga.cgablink & 16) && (t1000->cga.cgamode & 0x20) && - (attr & 0x80) && !drawcursor); - - if (t1000->video_options & 1) - bold = boldcols[attr] ? chr : chr + 256; - else - bold = boldcols[attr] ? chr + 256 : chr; - if (t1000->video_options & 2) - bold += 512; - - if (t1000->cga.cgamode & 0x20) /* Blink */ - { - cols[1] = blinkcols[attr][1]; - cols[0] = blinkcols[attr][0]; - if (blink) cols[1] = cols[0]; - } - else + for (c = 0; c < 8; c++) { - cols[1] = normcols[attr][1]; - cols[0] = normcols[attr][0]; + screen->line[t1000->displine][(x << 3) + c].val = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (blue ^ grey); } - if (drawcursor) - { - for (c = 0; c < 8; c++) - { - ((uint32_t *)buffer32->line[t1000->displine])[(x << 3) + c] = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (blue ^ grey); - } - } - else - { - for (c = 0; c < 8; c++) - ((uint32_t *)buffer32->line[t1000->displine])[(x << 3) + c] = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; - } - ++ma; } + else + { + for (c = 0; c < 8; c++) + screen->line[t1000->displine][(x << 3) + c].val = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; + } + ++ma; + } } @@ -368,16 +366,16 @@ t1000_text_row40(t1000_t *t1000) { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2] = - ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2 + 1] = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (blue ^ grey); + screen->line[t1000->displine][(x << 4) + c*2].val = + screen->line[t1000->displine][(x << 4) + c*2 + 1].val = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0] ^ (blue ^ grey); } } else { for (c = 0; c < 8; c++) { - ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2] = - ((uint32_t *)buffer32->line[t1000->displine])[(x << 4) + c*2+1] = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; + screen->line[t1000->displine][(x << 4) + c*2].val = + screen->line[t1000->displine][(x << 4) + c*2+1].val = cols[(fontdat[bold][sc] & (1 << (c ^ 7))) ? 1 : 0]; } } ++ma; @@ -412,7 +410,7 @@ t1000_cgaline6(t1000_t *t1000) ink = (dat & 0x80) ? fg : bg; if (!(t1000->cga.cgamode & 8)) ink = grey; - ((uint32_t *)buffer32->line[t1000->displine])[x*8+c] = ink; + screen->line[t1000->displine][x*8+c].val = ink; dat = dat << 1; } } @@ -469,8 +467,8 @@ t1000_cgaline4(t1000_t *t1000) case 3: ink0 = ink1 = blue; break; } - ((uint32_t *)buffer32->line[t1000->displine])[x*8+2*c] = ink0; - ((uint32_t *)buffer32->line[t1000->displine])[x*8+2*c+1] = ink1; + screen->line[t1000->displine][x*8+2*c].val = ink0; + screen->line[t1000->displine][x*8+2*c+1].val = ink1; dat = dat << 2; } } @@ -518,7 +516,7 @@ t1000_poll(void *p) { if (t1000->displine == 0) { - video_wait_for_buffer(); + video_blit_wait_buffer(); } /* Graphics */ @@ -572,9 +570,10 @@ t1000_poll(void *p) if (ysize < 32) ysize = 200; set_screen_size(xsize, ysize); } - video_blit_memtoscreen(0, 0, 0, ysize, xsize, ysize); + video_blit_start(0, 0, 0, 0, ysize, xsize, ysize); frames++; + /* Fixed 640x200 resolution */ video_res_x = T1000_XSIZE; video_res_y = T1000_YSIZE; diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index b769a6d..4abd519 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -11,11 +11,11 @@ * This code is called by the UI frontend modules, and, also, * depends on those same modules for lower-level functions. * - * Version: @(#)ui_main.c 1.0.21 2018/11/20 + * Version: @(#)ui_main.c 1.0.22 2019/03/07 * * Author: Fred N. van Kempen, * - * Copyright 2018 Fred N. van Kempen. + * Copyright 2018,2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -272,7 +272,7 @@ static void toggle_video_item(int idm, int *val) { plat_startblit(); - video_wait_for_blit(); + video_blit_wait(); *val ^= 1; plat_endblit(); @@ -508,7 +508,7 @@ ui_menu_command(int idm) case IDM_CGA_CONTR: /* DISPLAY menu */ vid_cga_contrast ^= 1; menu_set_item(idm, vid_cga_contrast); - cgapal_rebuild(); + video_palette_rebuild(); config_save(); break; @@ -641,7 +641,7 @@ ui_fullscreen(int on) /* OK, claim the video. */ plat_startblit(); - video_wait_for_blit(); + video_blit_wait(); // plat_mouse_close(); diff --git a/src/ui/ui_vidapi.c b/src/ui/ui_vidapi.c index 6f09eca..edacc06 100644 --- a/src/ui/ui_vidapi.c +++ b/src/ui/ui_vidapi.c @@ -8,11 +8,11 @@ * * Handle the various video renderer modules. * - * Version: @(#)ui_vidapi.c 1.0.4 2018/11/20 + * Version: @(#)ui_vidapi.c 1.0.5 2019/03/07 * * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -125,7 +125,7 @@ vidapi_set(int api) plat_startblit(); /* Wait for it to be ours. */ - video_wait_for_blit(); + video_blit_wait(); /* Close the (old) API. */ plat_vidapis[vid_api]->close(); @@ -162,7 +162,7 @@ vidapi_resize(int x, int y) plat_startblit(); /* Wait for it to be ours. */ - video_wait_for_blit(); + video_blit_wait(); plat_vidapis[vid_api]->resize(x, y); diff --git a/src/vnc.c b/src/vnc.c index 8c689d3..9d58980 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -10,12 +10,12 @@ * * TODO: Implement screenshots, and Audio Redirection. * - * Version: @(#)vnc.c 1.0.8 2018/11/20 + * Version: @(#)vnc.c 1.0.9 2019/03/08 * * Author: Fred N. van Kempen, * Based on raw code by RichardG, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -245,7 +245,7 @@ vnc_display(rfbClientPtr cl) static void -vnc_blit(int x, int y, int y1, int y2, int w, int h) +vnc_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) { uint32_t *p; int yy; @@ -255,13 +255,13 @@ vnc_blit(int x, int y, int y1, int y2, int w, int h) if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y) { if (vid_grayscale || invert_display) - video_transform_copy(p, &(((uint32_t *)buffer32->line[y+yy])[x]), w); + video_transform_copy(p, &scr->line[y+yy][x], w); else - memcpy(p, &(((uint32_t *)buffer32->line[y+yy])[x]), w*4); + memcpy(p, &scr->line[y+yy][x], w*4); } } - video_blit_complete(); + video_blit_done(); if (! updatingSize) f_rfbMarkRectAsModified(rfb, 0,0, allowedX,allowedY); @@ -312,8 +312,6 @@ vnc_init(int fs) rfbLogEnable(1); #endif - cgapal_rebuild(); - if (rfb == NULL) { wcstombs(title, ui_window_title(NULL), sizeof(title)); updatingSize = 0; @@ -341,7 +339,7 @@ vnc_init(int fs) } /* Set up our BLIT handlers. */ - video_setblit(vnc_blit); + video_blit_set(vnc_blit); clients = 0; @@ -354,7 +352,7 @@ vnc_init(int fs) static void vnc_close(void) { - video_setblit(NULL); + video_blit_set(NULL); if (rfb != NULL) { free(rfb->frameBuffer); diff --git a/src/win/win_d2d.cpp b/src/win/win_d2d.cpp index 2ce0728..4a8fb3e 100644 --- a/src/win/win_d2d.cpp +++ b/src/win/win_d2d.cpp @@ -8,12 +8,12 @@ * * Rendering module for Microsoft Direct2D. * - * Version: @(#)win_d2d.cpp 1.0.3 2018/11/20 + * Version: @(#)win_d2d.cpp 1.0.4 2019/03/08 * * Authors: Fred N. van Kempen, * David Hrdlicka, * - * Copyright 2018 Fred N. van Kempen. + * Copyright 2018,2019 Fred N. van Kempen. * Copyright 2018 David Hrdlicka. * * This program is free software; you can redistribute it and/or modify @@ -180,7 +180,7 @@ d2d_stretch(float *w, float *h, float *x, float *y) static void -d2d_blit(int x, int y, int y1, int y2, int w, int h) +d2d_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) { ID2D1Bitmap *fs_bitmap; ID2D1RenderTarget *RT; @@ -215,28 +215,26 @@ d2d_blit(int x, int y, int y1, int y2, int w, int h) } } - if ((y1 == y2) || (buffer32 == NULL)) { - video_blit_complete(); + if ((y1 == y2) || (scr == NULL)) { + video_blit_done(); return; } // TODO: Copy data directly from buffer32 to d2d_bitmap srcdata = mem_alloc(h * w * 4); for (yy = y1; yy < y2; yy++) { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) { + if ((y + yy) >= 0 && (y + yy) < scr->h) { if (vid_grayscale || invert_display) video_transform_copy( (uint32_t *)&(((uint8_t *)srcdata)[yy * w * 4]), - &(((uint32_t *)buffer32->line[y + yy])[x]), - w); + &scr->line[y + yy][x], w); else memcpy( (uint32_t *)&(((uint8_t *)srcdata)[yy * w * 4]), - &(((uint32_t *)buffer32->line[y + yy])[x]), - w * 4); + &scr->line[y + yy][x], w * 4); } } - video_blit_complete(); + video_blit_done(); rectU = D2D1::RectU(0, 0, w, h); hr = d2d_bitmap->CopyFromMemory(&rectU, srcdata, w * 4); @@ -294,7 +292,7 @@ d2d_close(void) { DEBUG("D2D: close()\n"); - video_setblit(NULL); + video_blit_set(NULL); if (d2d_bitmap) { d2d_bitmap->Release(); @@ -342,8 +340,6 @@ d2d_init(int fs) INFO("D2D: init(fs=%d)\n", fs); - cgapal_rebuild(); - #if USE_D2D == 2 /* Try loading the DLL. */ d2d_handle = dynld_module(PATH_D2D_DLL, d2d_imports); @@ -422,7 +418,7 @@ d2d_init(int fs) atexit(d2d_close); /* Register our renderer! */ - video_setblit(d2d_blit); + video_blit_set(d2d_blit); return(1); } diff --git a/src/win/win_d3d.cpp b/src/win/win_d3d.cpp index ff74757..73866a6 100644 --- a/src/win/win_d3d.cpp +++ b/src/win/win_d3d.cpp @@ -8,13 +8,13 @@ * * Rendering module for Microsoft Direct3D 9. * - * Version: @(#)win_d3d.cpp 1.0.13 2018/11/20 + * Version: @(#)win_d3d.cpp 1.0.14 2019/03/08 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -183,7 +183,7 @@ d3d_size(RECT w_rect, double *l, double *t, double *r, double *b, int w, int h) static void -d3d_blit_fs(int x, int y, int y1, int y2, int w, int h) +d3d_blit_fs(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) { HRESULT hr = D3D_OK; HRESULT hbsr = D3D_OK; @@ -194,7 +194,7 @@ d3d_blit_fs(int x, int y, int y1, int y2, int w, int h) double l = 0, t = 0, r = 0, b = 0; if ((y1 == y2) || (h <= 0)) { - video_blit_complete(); + video_blit_done(); return; /*Nothing to do*/ } @@ -209,22 +209,22 @@ d3d_blit_fs(int x, int y, int y1, int y2, int w, int h) hr = d3dTexture->LockRect(0, &dr, &lock_rect, 0); if (hr == D3D_OK) { for (yy = y1; yy < y2; yy++) { - if (buffer32) { + if (scr) { if (vid_grayscale || invert_display) - video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w); + video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &scr->line[yy + y][x], w); else - memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); + memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &scr->line[yy + y][x], w * 4); } } - video_blit_complete(); + video_blit_done(); d3dTexture->UnlockRect(0); } else { - video_blit_complete(); + video_blit_done(); return; } } else - video_blit_complete(); + video_blit_done(); d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0; d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0; @@ -297,7 +297,7 @@ d3d_blit_fs(int x, int y, int y1, int y2, int w, int h) static void -d3d_blit(int x, int y, int y1, int y2, int w, int h) +d3d_blit(bitmap_t *b, int x, int y, int y1, int y2, int w, int h) { HRESULT hr = D3D_OK; HRESULT hbsr = D3D_OK; @@ -307,7 +307,7 @@ d3d_blit(int x, int y, int y1, int y2, int w, int h) int yy; if ((y1 == y2) || (h <= 0)) { - video_blit_complete(); + video_blit_done(); return; /*Nothing to do*/ } @@ -319,20 +319,20 @@ d3d_blit(int x, int y, int y1, int y2, int w, int h) hr = d3dTexture->LockRect(0, &dr, &r, 0); if (hr == D3D_OK) { for (yy = y1; yy < y2; yy++) { - if (buffer32) { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) { + if (b) { + if ((y + yy) >= 0 && (y + yy) < screen->h) { if (vid_grayscale || invert_display) - video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w); + video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &b->line[yy + y][x], w); else - memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4); + memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &b->line[yy + y][x], w * 4); } } } - video_blit_complete(); + video_blit_done(); d3dTexture->UnlockRect(0); } else { - video_blit_complete(); + video_blit_done(); return; } @@ -446,7 +446,7 @@ d3d_reset(int fs) static void d3d_close(void) { - video_setblit(NULL); + video_blit_set(NULL); if (d3dTexture) { d3dTexture->Release(); @@ -486,8 +486,6 @@ d3d_init(int fs) d3d_hwnd = hwndRender; - cgapal_rebuild(); - if (fs) { d3d_w = GetSystemMetrics(SM_CXSCREEN); d3d_h = GetSystemMetrics(SM_CYSCREEN); @@ -587,9 +585,9 @@ d3d_init(int fs) d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); if (fs) - video_setblit(d3d_blit_fs); + video_blit_set(d3d_blit_fs); else - video_setblit(d3d_blit); + video_blit_set(d3d_blit); return(1); } diff --git a/src/win/win_ddraw.cpp b/src/win/win_ddraw.cpp index 1a64aa9..5d2bafd 100644 --- a/src/win/win_ddraw.cpp +++ b/src/win/win_ddraw.cpp @@ -8,13 +8,13 @@ * * Rendering module for Microsoft DirectDraw 9. * - * Version: @(#)win_ddraw.cpp 1.0.18 2018/10/05 + * Version: @(#)win_ddraw.cpp 1.0.19 2019/03/08 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -245,7 +245,7 @@ ddraw_fs_size(RECT w_rect, RECT *r_dest, int w, int h) static void -ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h) +ddraw_blit_fs(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) { DDSURFACEDESC2 ddsd; RECT r_src, r_dest, w_rect; @@ -253,13 +253,8 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h) HRESULT hr; int yy; - if (lpdds_back == NULL) { - video_blit_complete(); - return; /*Nothing to do*/ - } - - if ((y1 == y2) || (h <= 0)) { - video_blit_complete(); + if ((lpdds_back == NULL) || (y1 == y2) || (h <= 0)) { + video_blit_done(); return; } @@ -275,20 +270,21 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h) device_force_redraw(); } if (! ddsd.lpSurface) { - video_blit_complete(); + video_blit_done(); return; } for (yy = y1; yy < y2; yy++) { - if (buffer32) { + if (scr) { if (vid_grayscale || invert_display) - video_transform_copy((uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w); + video_transform_copy((uint32_t *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &scr->line[y + yy][x], w); else - memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4); + memcpy((void *)((uintptr_t)ddsd.lpSurface + (yy * ddsd.lPitch)), &scr->line[y + yy][x], w * 4); } } - video_blit_complete(); + video_blit_done(); + lpdds_back->Unlock(NULL); w_rect.left = 0; @@ -323,7 +319,7 @@ ddraw_blit_fs(int x, int y, int y1, int y2, int w, int h) static void -ddraw_blit(int x, int y, int y1, int y2, int w, int h) +ddraw_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) { DDSURFACEDESC2 ddsd; RECT r_src, r_dest; @@ -331,13 +327,8 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h) POINT po; int yy; - if (lpdds_back == NULL) { - video_blit_complete(); - return; /*Nothing to do*/ - } - - if ((y1 == y2) || (h <= 0)) { - video_blit_complete(); + if ((lpdds_back == NULL) || (y1 == y2) || (h <= 0)) { + video_blit_done(); return; } @@ -354,22 +345,23 @@ ddraw_blit(int x, int y, int y1, int y2, int w, int h) } if (! ddsd.lpSurface) { - video_blit_complete(); + video_blit_done(); return; } for (yy = y1; yy < y2; yy++) { - if (buffer32) { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) { + if (scr) { + if ((y + yy) >= 0 && (y + yy) < scr->h) { if (vid_grayscale || invert_display) - video_transform_copy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w); + video_transform_copy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &scr->line[y + yy][x], w); else - memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4); + memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &scr->line[y + yy][x], w * 4); } } } - video_blit_complete(); + video_blit_done(); + lpdds_back->Unlock(NULL); po.x = po.y = 0; @@ -404,7 +396,7 @@ ddraw_close(void) { DEBUG("DDRAW: close\n"); - video_setblit(NULL); + video_blit_set(NULL); if (lpdds_back2 != NULL) { lpdds_back2->Release(); @@ -440,8 +432,6 @@ ddraw_init(int fs) INFO("DDraw: initializing (fs=%d)\n", fs); - cgapal_rebuild(); - hr = DirectDrawCreate(NULL, &lpdd, NULL); if (FAILED(hr)) { ERRLOG("DDRAW: cannot create an instance (%s)\n", GetError(hr)); @@ -568,9 +558,9 @@ ddraw_init(int fs) ddraw_hwnd = h; if (fs) - video_setblit(ddraw_blit_fs); + video_blit_set(ddraw_blit_fs); else - video_setblit(ddraw_blit); + video_blit_set(ddraw_blit); return(1); } diff --git a/src/win/win_sdl.c b/src/win/win_sdl.c index 3a4e79a..575a0df 100644 --- a/src/win/win_sdl.c +++ b/src/win/win_sdl.c @@ -12,12 +12,12 @@ * we will not use that, but, instead, use a new window which * coverrs the entire desktop. * - * Version: @(#)win_sdl.c 1.0.7 2018/11/20 + * Version: @(#)win_sdl.c 1.0.8 2019/03/08 * * Authors: Fred N. van Kempen, * Michael Drüing, * - * Copyright 2018 Fred N. van Kempen. + * Copyright 2018,2019 Fred N. van Kempen. * Copyright 2018 Michael Drüing. * * Redistribution and use in source and binary forms, with @@ -245,20 +245,15 @@ sdl_resize(int x, int y) static void -sdl_blit(int x, int y, int y1, int y2, int w, int h) +sdl_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) { SDL_Rect r_src; void *pixeldata; int xx, yy, ret; int pitch; - if (y1 == y2) { - video_blit_complete(); - return; - } - - if (buffer32 == NULL) { - video_blit_complete(); + if ((y1 == y2) || (scr == NULL)) { + video_blit_done(); return; } @@ -270,15 +265,15 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h) sdl_LockTexture(sdl_tex, 0, &pixeldata, &pitch); for (yy = y1; yy < y2; yy++) { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) { + if ((y + yy) >= 0 && (y + yy) < scr->h) { if (vid_grayscale || invert_display) - video_transform_copy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w); + video_transform_copy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &scr->line[y + yy][x], w); else - memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(((uint32_t *)buffer32->line[y + yy])[x]), w * 4); + memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &scr->line[y + yy][x], w * 4); } } - video_blit_complete(); + video_blit_done(); sdl_UnlockTexture(sdl_tex); @@ -307,7 +302,7 @@ static void sdl_close(void) { /* Unregister our renderer! */ - video_setblit(NULL); + video_blit_set(NULL); if (sdl_tex != NULL) { sdl_DestroyTexture(sdl_tex); @@ -358,8 +353,6 @@ sdl_init(int fs) INFO("SDL: init (fs=%d)\n", fs); - cgapal_rebuild(); - /* Try loading the DLL. */ sdl_handle = dynld_module(PATH_SDL_DLL, sdl_imports); if (sdl_handle == NULL) { @@ -464,7 +457,7 @@ sdl_init(int fs) atexit(sdl_close); /* Register our renderer! */ - video_setblit(sdl_blit); + video_blit_set(sdl_blit); return(1); } diff --git a/src/win/win_ui.c b/src/win/win_ui.c index e4731fd..b6adecb 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -8,13 +8,13 @@ * * Implement the user Interface module. * - * Version: @(#)win_ui.c 1.0.33 2018/11/20 + * Version: @(#)win_ui.c 1.0.34 2019/03/07 * * Authors: Fred N. van Kempen, * Miran Grca, * Sarah Walker, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * Copyright 2016-2018 Miran Grca. * Copyright 2008-2018 Sarah Walker. * @@ -923,7 +923,7 @@ ui_resize(int x, int y) /* First, see if we should resize the UI window. */ if (vid_resize) return; - video_wait_for_blit(); + video_blit_wait(); /* Re-position and re-size the main window. */ GetWindowRect(hwndMain, &r);