diff --git a/src/devices/cdrom/cdrom_dosbox.cpp b/src/devices/cdrom/cdrom_dosbox.cpp index c2ebc90..f8358dd 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.12 2019/03/07 + * Version: @(#)cdrom_dosbox.cpp 1.0.13 2019/03/11 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -516,7 +516,8 @@ CDROM_Interface_Image::CueGetNumber(int &arg, char **line) if (success) success = (sscanf(temp, "%i", &num) == 1); - arg = num; + if (success) + arg = num; return success; } @@ -534,7 +535,8 @@ CDROM_Interface_Image::CueGetFrame(uint64_t &arg, char **line) if (success) success = (sscanf(temp, "%d:%d:%d", &min, &sec, &fr) == 3); - arg = MSF_TO_FRAMES(min, sec, fr); + if (success) + arg = MSF_TO_FRAMES(min, sec, fr); return success; } @@ -545,6 +547,9 @@ 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]; + wchar_t filename[MAX_FILENAME_LENGTH]; + wchar_t temp[MAX_FILENAME_LENGTH]; + char ansi[MAX_FILENAME_LENGTH]; char buf[MAX_LINE_LENGTH], *line; uint64_t shift = 0; uint64_t currPregap = 0; @@ -577,6 +582,9 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) break; buf[strlen(line) - 1] = '\0'; /* nuke trailing newline */ + /* Ignore empty lines, and 'comment' lines. */ + if (*line == '\0' || *line == '#' || *line == ';') continue; + success = CueGetKeyword(command, &line); if (command == "TRACK") { @@ -675,11 +683,9 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) canAddTrack = false; - char ansi[MAX_FILENAME_LENGTH]; - wchar_t filename[MAX_FILENAME_LENGTH]; - success = CueGetBuffer(ansi, &line, false); if (! success) break; + success = CueGetKeyword(type, &line); if (! success) break; @@ -687,9 +693,9 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) bool error = true; if (type == "BINARY") { - wchar_t temp[MAX_FILENAME_LENGTH]; mbstowcs(temp, ansi, sizeof_w(temp)); + memset(filename, 0x00, sizeof(filename)); plat_append_filename(filename, pathname, temp); track.file = new BinaryFile(filename, error); } @@ -705,9 +711,9 @@ CDROM_Interface_Image::CueLoadSheet(const wchar_t *cuefile) else if (command == "CATALOG") { success = CueGetString(mcn, &line); // ignored commands - } else if (command == "CDTEXTFILE" || command == "FLAGS" || command == "ISRC" - || command == "PERFORMER" || command == "POSTGAP" || command == "REM" - || command == "SONGWRITER" || command == "TITLE" || command == "") success = true; + } else if (command == "CDTEXTFILE" || command == "FLAGS" || command == "ISRC" || + command == "PERFORMER" || command == "POSTGAP" || command == "REM" || + command == "SONGWRITER" || command == "TITLE" || command == "") success = true; // failure else { ERRLOG("CUE: unsupported command '%s' in cue sheet!\n", diff --git a/src/devices/video/vid_mda.c b/src/devices/video/vid_mda.c index 9655b0f..d06d76e 100644 --- a/src/devices/video/vid_mda.c +++ b/src/devices/video/vid_mda.c @@ -8,7 +8,7 @@ * * MDA emulation. * - * Version: @(#)vid_mda.c 1.0.10 2019/03/07 + * Version: @(#)vid_mda.c 1.0.11 2019/03/09 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,37 +50,14 @@ #include "../system/pit.h" #include "../ports/parallel.h" #include "video.h" +#include "vid_mda.h" -typedef struct { - mem_map_t mapping; - - uint8_t crtc[32]; - int crtcreg; - - uint8_t ctrl, stat; - - int64_t dispontime, dispofftime; - int64_t vidtime; - - int firstline, lastline; - - int linepos, displine; - int vc, sc; - uint16_t ma, maback; - int con, coff, cursoron; - int dispon, blink; - int64_t vsynctime; - int vadj; - - uint8_t cols[256][2][2]; - - uint8_t *vram; -} mda_t; +static const video_timings_t mda_timings = { VID_ISA,8,16,32,8,16,32 }; -static void -recalc_timings(mda_t *dev) +void +mda_recalctimings(mda_t *dev) { double _dispontime, _dispofftime, disptime; @@ -95,23 +72,23 @@ recalc_timings(mda_t *dev) } -static void +void mda_out(uint16_t port, uint8_t val, void *priv) { mda_t *dev = (mda_t *)priv; switch (port) { - case 0x3b0: - case 0x3b2: - case 0x3b4: - case 0x3b6: + case 0x03b0: + case 0x03b2: + case 0x03b4: + case 0x03b6: dev->crtcreg = val & 31; break; - case 0x3b1: - case 0x3b3: - case 0x3b5: - case 0x3b7: + case 0x03b1: + case 0x03b3: + case 0x03b5: + case 0x03b7: dev->crtc[dev->crtcreg] = val; if (dev->crtc[10] == 6 && dev->crtc[11] == 7) { /*Fix for Generic Turbo XT BIOS, @@ -119,38 +96,38 @@ mda_out(uint16_t port, uint8_t val, void *priv) dev->crtc[10] = 0xb; dev->crtc[11] = 0xc; } - recalc_timings(dev); + mda_recalctimings(dev); break; - case 0x3b8: + case 0x03b8: dev->ctrl = val; break; } } -static uint8_t +uint8_t mda_in(uint16_t port, void *priv) { mda_t *dev = (mda_t *)priv; uint8_t ret = 0xff; switch (port) { - case 0x3b0: - case 0x3b2: - case 0x3b4: - case 0x3b6: + case 0x03b0: + case 0x03b2: + case 0x03b4: + case 0x03b6: ret = dev->crtcreg; break; - case 0x3b1: - case 0x3b3: - case 0x3b5: - case 0x3b7: + case 0x03b1: + case 0x03b3: + case 0x03b5: + case 0x03b7: ret = dev->crtc[dev->crtcreg]; break; - case 0x3ba: + case 0x03ba: ret = dev->stat | 0xF0; break; @@ -162,7 +139,7 @@ mda_in(uint16_t port, void *priv) } -static void +void mda_write(uint32_t addr, uint8_t val, void *priv) { mda_t *dev = (mda_t *)priv; @@ -171,7 +148,7 @@ mda_write(uint32_t addr, uint8_t val, void *priv) } -static uint8_t +uint8_t mda_read(uint32_t addr, void *priv) { mda_t *dev = (mda_t *)priv; @@ -180,7 +157,7 @@ mda_read(uint32_t addr, void *priv) } -static void +void mda_poll(void *priv) { mda_t *dev = (mda_t *)priv; @@ -312,6 +289,7 @@ mda_poll(void *priv) video_res_y = dev->crtc[6]; video_bpp = 0; } + dev->firstline = 1000; dev->lastline = 0; dev->blink++; @@ -329,26 +307,11 @@ mda_poll(void *priv) } -static void * -mda_init(const device_t *info) +void +mda_init(mda_t *dev) { - mda_t *dev; int c; - dev = (mda_t *)mem_alloc(sizeof(mda_t)); - memset(dev, 0x00, sizeof(mda_t)); - - dev->vram = (uint8_t *)mem_alloc(0x1000); - - timer_add(mda_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); - - mem_map_add(&dev->mapping, 0xb0000, 0x08000, - mda_read,NULL,NULL, mda_write,NULL,NULL, - NULL, MEM_MAPPING_EXTERNAL, dev); - - io_sethandler(0x03b0, 16, - mda_in,NULL,NULL, mda_out,NULL,NULL, dev); - for (c = 0; c < 256; c++) { dev->cols[c][0][0] = dev->cols[c][1][0] = dev->cols[c][1][1] = 16; if (c & 8) @@ -380,13 +343,37 @@ mda_init(const device_t *info) cga_palette = 0; video_palette_rebuild(); - video_inform(VID_TYPE_MDA, info->vid_timing); + timer_add(mda_poll, &dev->vidtime, TIMER_ALWAYS_ENABLED, dev); + + mem_map_add(&dev->mapping, 0xb0000, 0x08000, + mda_read,NULL,NULL, mda_write,NULL,NULL, + NULL, MEM_MAPPING_EXTERNAL, dev); + + io_sethandler(0x03b0, 16, + mda_in,NULL,NULL, mda_out,NULL,NULL, dev); + + video_inform(VID_TYPE_MDA, &mda_timings); +} + + +static void * +mda_standalone_init(const device_t *info) +{ + mda_t *dev; + + dev = (mda_t *)mem_alloc(sizeof(mda_t)); + memset(dev, 0x00, sizeof(mda_t)); + dev->type = info->local; + + dev->vram = (uint8_t *)mem_alloc(0x1000); + + mda_init(dev); /* Force the LPT3 port to be enabled. */ parallel_enabled[2] = 1; parallel_setup(2, 0x03bc); - return dev; + return(dev); } @@ -396,6 +383,7 @@ mda_close(void *priv) mda_t *dev = (mda_t *)priv; free(dev->vram); + free(dev); } @@ -404,12 +392,12 @@ static void speed_changed(void *priv) { mda_t *dev = (mda_t *)priv; - - recalc_timings(dev); + + mda_recalctimings(dev); } -static const device_config_t mda_config[] = { +const device_config_t mda_config[] = { { "rgb_type", "Display type", CONFIG_SELECTION, "", 0, { @@ -435,16 +423,21 @@ static const device_config_t mda_config[] = { } }; -static const video_timings_t mda_timings = { VID_ISA,8,16,32,8,16,32 }; - const device_t mda_device = { "MDA", DEVICE_ISA, 0, - mda_init, mda_close, NULL, + mda_standalone_init, mda_close, NULL, NULL, speed_changed, NULL, - &mda_timings, + NULL, mda_config }; + + +void +mda_setcol(mda_t *dev, int chr, int blink, int fg, uint8_t cga_ink) +{ + dev->cols[chr][blink][fg] = pal_lookup[cga_ink]; +} diff --git a/src/devices/video/vid_mda.h b/src/devices/video/vid_mda.h new file mode 100644 index 0000000..146af2f --- /dev/null +++ b/src/devices/video/vid_mda.h @@ -0,0 +1,86 @@ +/* + * VARCem Virtual ARchaeological Computer EMulator. + * An emulator of (mostly) x86-based PC systems and devices, + * using the ISA,EISA,VLB,MCA and PCI system buses, roughly + * spanning the era between 1981 and 1995. + * + * This file is part of the VARCem Project. + * + * Definitions for the MDA driver. + * + * Version: @(#)vid_mda.h 1.0.1 2019/03/09 + * + * Authors: Fred N. van Kempen, + * + * Copyright 2017-2019 Fred N. van Kempen. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the: + * + * Free Software Foundation, Inc. + * 59 Temple Place - Suite 330 + * Boston, MA 02111-1307 + * USA. + */ +#ifndef VIDEO_MDA_H +# define VIDEO_MDA_H + + +#define MDA_FONT_ROM_PATH L"video/ibm/mda/mda.rom" + + +typedef struct { + int type; + + mem_map_t mapping; + + uint8_t crtc[32]; + int crtcreg; + + uint8_t ctrl, stat; + + int64_t dispontime, dispofftime; + int64_t vidtime; + + int firstline, lastline; + + int linepos, displine; + int vc, sc; + uint16_t ma, maback; + int con, coff, cursoron; + int dispon, blink; + int64_t vsynctime; + int vadj; + + uint8_t cols[256][2][2]; + + uint8_t *vram; +} mda_t; + + +#ifdef EMU_DEVICE_H +extern const device_config_t mda_config[]; +#endif + + +extern void mda_init(mda_t *); +extern void mda_out(uint16_t port, uint8_t val, void *priv); +extern uint8_t mda_in(uint16_t port, void *priv); +extern void mda_write(uint32_t addr, uint8_t val, void *priv); +extern uint8_t mda_read(uint32_t addr, void *priv); +extern void mda_recalctimings(mda_t *); +extern void mda_poll(void *priv); +extern void mda_setcol(mda_t *, int chr, int blink, int fg, uint8_t ink); + + +#endif /*VIDEO_MDA_H*/ diff --git a/src/devices/video/video.c b/src/devices/video/video.c index f43663b..2a3f7f2 100644 --- a/src/devices/video/video.c +++ b/src/devices/video/video.c @@ -8,7 +8,7 @@ * * Main video-rendering module. * - * Version: @(#)video.c 1.0.26 2019/03/07 + * Version: @(#)video.c 1.0.27 2019/03/09 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -61,8 +61,8 @@ int video_do_log = ENABLE_VIDEO_LOG; #endif /* These will go away soon. */ -uint8_t fontdat[1024][8]; /* IBM CGA font */ -uint8_t fontdatm[1024][16]; /* IBM MDA font */ +uint8_t fontdat[2048][8]; /* IBM CGA font */ +uint8_t fontdatm[2048][16]; /* IBM MDA font */ dbcs_font_t *fontdatk = NULL, /* Korean KSC-5601 font */ *fontdatk_user = NULL; /* Korean KSC-5601 font (user)*/ @@ -71,6 +71,7 @@ bitmap_t *screen = NULL; uint32_t *video_6to8 = NULL, *video_15to32 = NULL, *video_16to32 = NULL; +uint32_t pal_lookup[256]; uint8_t edatlookup[4][4]; int xsize = 1, ysize = 1; @@ -372,7 +373,6 @@ static const uint32_t shade[5][256] = { } }; static uint32_t cga_2_table[16]; -static uint32_t pal_lookup[256]; static uint8_t rotatevga[8][256]; static int video_force_resize; static int video_card_type; diff --git a/src/devices/video/video.h b/src/devices/video/video.h index 11ca6d3..b534e39 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.29 2019/03/08 + * Version: @(#)video.h 1.0.30 2019/03/09 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -119,8 +119,8 @@ typedef struct { extern int changeframecount; /* These will go away soon. */ -extern uint8_t fontdat[1024][8]; /* 1024 characters */ -extern uint8_t fontdatm[1024][16]; /* 1024 characters */ +extern uint8_t fontdat[2048][8]; /* 2048!! characters */ +extern uint8_t fontdatm[2048][16]; /* 2048!! characters */ extern dbcs_font_t *fontdatk, *fontdatk_user; @@ -128,6 +128,7 @@ extern bitmap_t *screen; extern uint32_t *video_6to8, *video_15to32, *video_16to32; +extern uint32_t pal_lookup[256]; extern int fullchange; extern int xsize,ysize; extern int update_overscan; diff --git a/src/devices/video/video_dev.c b/src/devices/video/video_dev.c index 8610697..326ea5d 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.34 2019/03/07 + * Version: @(#)video_dev.c 1.0.35 2019/03/09 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,6 +51,7 @@ #include "../../device.h" #include "../../plat.h" #include "video.h" +#include "vid_mda.h" #ifdef ENABLE_VIDEO_DEV_LOG @@ -216,7 +217,7 @@ video_reset(void) video_reset_font(); /* Initialize the video font tables. */ - video_load_font(L"video/ibm/mda/mda.rom", FONT_MDA); + video_load_font(MDA_FONT_ROM_PATH, FONT_MDA); /* Do not initialize internal cards here. */ if ((video_card == VID_NONE) || \