From b71e3212366b371f8758aa1a05e5467fff1ae9ee Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Tue, 27 May 2025 22:03:11 -0400 Subject: [PATCH] Assorted cleaning --- src/cdrom/cdrom.c | 24 +- src/floppy/fdd.c | 2 +- src/include/86box/cdrom.h | 16 +- src/include/86box/cdrom_image.h | 2 +- src/include/86box/hdd.h | 4 +- src/include/86box/mo.h | 14 +- src/include/86box/zip.h | 16 +- src/qt/qt_glsl_parser.cpp | 16 +- src/video/vid_ega.c | 125 +++++------ src/video/vid_ps55da2.c | 377 ++++++++++++++++---------------- src/video/video.c | 4 +- 11 files changed, 292 insertions(+), 308 deletions(-) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 44bf2811c..e0fa8b0b6 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -979,28 +979,28 @@ cdrom_toc_dump(cdrom_t *dev) uint8_t b[65536] = { 0 }; int len = cdrom_read_toc(dev, b, CD_TOC_RAW, 0, 0, 65536); const char *fn2 = "d:\\86boxnew\\toc_cue.dmp"; - FILE * f = fopen(fn2, "wb"); - fwrite(b, 1, len, f); - fflush(f); - fclose(f); + FILE * fp = fopen(fn2, "wb"); + fwrite(b, 1, len, fp); + fflush(fp); + fclose(fp); cdrom_log(dev->log, "Written TOC of %i bytes to %s\n", len, fn2); memset(b, 0x00, 65536); len = cdrom_read_toc(dev, b, CD_TOC_NORMAL, 0, 0, 65536); fn2 = "d:\\86boxnew\\toc_cue_cooked.dmp"; - f = fopen(fn2, "wb"); - fwrite(b, 1, len, f); - fflush(f); - fclose(f); + fp = fopen(fn2, "wb"); + fwrite(b, 1, len, fp); + fflush(fp); + fclose(fp); cdrom_log(dev->log, "Written cooked TOC of %i bytes to %s\n", len, fn2); memset(b, 0x00, 65536); len = cdrom_read_toc(dev, b, CD_TOC_SESSION, 0, 0, 65536); fn2 = "d:\\86boxnew\\toc_cue_session.dmp"; - f = fopen(fn2, "wb"); - fwrite(b, 1, len, f); - fflush(f); - fclose(f); + fp = fopen(fn2, "wb"); + fwrite(b, 1, len, fp); + fflush(fp); + fclose(fp); cdrom_log(dev->log, "Written session TOC of %i bytes to %s\n", len, fn2); } #endif diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index d3d513b9f..31811069f 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -467,7 +467,7 @@ fdd_load(int drive, char *fn) int c = 0; int size; const char *p; - FILE * fp; + FILE *fp; fdd_log("FDD: loading drive %d with '%s'\n", drive, fn); diff --git a/src/include/86box/cdrom.h b/src/include/86box/cdrom.h index 5ff4170a2..a962a8635 100644 --- a/src/include/86box/cdrom.h +++ b/src/include/86box/cdrom.h @@ -106,10 +106,10 @@ enum { #define CDV EMU_VERSION_EX static const struct cdrom_drive_types_s { - const char * vendor; - const char * model; - const char * revision; - const char * internal_name; + const char *vendor; + const char *model; + const char *revision; + const char *internal_name; const int bus_type; /* SCSI standard for SCSI (or both) devices, early for IDE. */ const int scsi_std; @@ -296,7 +296,7 @@ typedef struct cdrom { uint8_t speed; uint8_t cur_speed; - void * priv; + void *priv; char image_path[1024]; char prev_image_path[1280]; @@ -322,10 +322,10 @@ typedef struct cdrom { const cdrom_ops_t *ops; - char * image_history[CD_IMAGE_HISTORY]; + char *image_history[CD_IMAGE_HISTORY]; - void * local; - void * log; + void *local; + void *log; void (*insert)(void *priv); void (*close)(void *priv); diff --git a/src/include/86box/cdrom_image.h b/src/include/86box/cdrom_image.h index 84dd66f37..e0760ff7e 100644 --- a/src/include/86box/cdrom_image.h +++ b/src/include/86box/cdrom_image.h @@ -33,6 +33,6 @@ typedef struct track_file_t { int motorola; } track_file_t; -extern void * image_open(cdrom_t *dev, const char *path); +extern void *image_open(cdrom_t *dev, const char *path); #endif /*CDROM_IMAGE_H*/ diff --git a/src/include/86box/hdd.h b/src/include/86box/hdd.h index eda4396ef..53514740d 100644 --- a/src/include/86box/hdd.h +++ b/src/include/86box/hdd.h @@ -159,7 +159,7 @@ typedef struct hard_disk_t { uint8_t pad; uint8_t pad0; - void * priv; + void *priv; char fn[1024]; /* Name of current image file */ /* Differential VHD parent file */ @@ -185,7 +185,7 @@ typedef struct hard_disk_t { uint8_t max_multiple_block; uint8_t pad1[3]; - const char * model; + const char *model; hdd_zone_t zones[HDD_MAX_ZONES]; diff --git a/src/include/86box/mo.h b/src/include/86box/mo.h index f4e7e9809..fc297ffbb 100644 --- a/src/include/86box/mo.h +++ b/src/include/86box/mo.h @@ -110,13 +110,13 @@ typedef struct mo_drive_t { uint8_t pad; uint8_t pad0; - FILE * fp; - void * priv; + FILE *fp; + void *priv; char image_path[1024]; char prev_image_path[1024]; - char * image_history[MO_IMAGE_HISTORY]; + char *image_history[MO_IMAGE_HISTORY]; uint32_t type; uint32_t medium_size; @@ -129,16 +129,16 @@ typedef struct mo_drive_t { typedef struct mo_t { mode_sense_pages_t ms_pages_saved; - mo_drive_t * drv; + mo_drive_t *drv; #ifdef EMU_IDE_H - ide_tf_t * tf; + ide_tf_t *tf; #else - void * tf; + void *tf; #endif void * log; - uint8_t * buffer; + uint8_t *buffer; uint8_t atapi_cdb[16]; uint8_t current_cdb[16]; uint8_t sense[256]; diff --git a/src/include/86box/zip.h b/src/include/86box/zip.h index 443ab1327..969ce27f5 100644 --- a/src/include/86box/zip.h +++ b/src/include/86box/zip.h @@ -58,13 +58,13 @@ typedef struct zip_drive_t { uint8_t pad; uint8_t pad0; - FILE * fp; - void * priv; + FILE *fp; + void *priv; char image_path[1024]; char prev_image_path[1024]; - char * image_history[ZIP_IMAGE_HISTORY]; + char *image_history[ZIP_IMAGE_HISTORY]; uint32_t is_250; uint32_t medium_size; @@ -74,16 +74,16 @@ typedef struct zip_drive_t { typedef struct zip_t { mode_sense_pages_t ms_pages_saved; - zip_drive_t * drv; + zip_drive_t *drv; #ifdef EMU_IDE_H - ide_tf_t * tf; + ide_tf_t *tf; #else - void * tf; + void *tf; #endif - void * log; + void *log; - uint8_t * buffer; + uint8_t *buffer; uint8_t atapi_cdb[16]; uint8_t current_cdb[16]; uint8_t sense[256]; diff --git a/src/qt/qt_glsl_parser.cpp b/src/qt/qt_glsl_parser.cpp index 6e107bc19..599a95452 100644 --- a/src/qt/qt_glsl_parser.cpp +++ b/src/qt/qt_glsl_parser.cpp @@ -104,22 +104,22 @@ glsl_detect_bom(const char *fn) static char *load_file(const char *fn) { int bom = glsl_detect_bom(fn); - FILE *f = plat_fopen(fn, "rb"); - if (!f) + FILE *fp = plat_fopen(fn, "rb"); + if (!fp) return 0; - fseek(f, 0, SEEK_END); - long fsize = ftell(f); - fseek(f, 0, SEEK_SET); + fseek(fp, 0, SEEK_END); + long fsize = ftell(fp); + fseek(fp, 0, SEEK_SET); if (bom) { fsize -= 3; - fseek(f, 3, SEEK_SET); + fseek(fp, 3, SEEK_SET); } char *data = (char*)malloc(fsize + 1); - fread(data, fsize, 1, f); - fclose(f); + (void *) !fread(data, fsize, 1, fp); + fclose(fp); data[fsize] = 0; diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index b828239c0..1022bda88 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -47,7 +47,7 @@ void ega_doblit(int wx, int wy, ega_t *ega); static video_timings_t timing_ega = { .type = VIDEO_ISA, .write_b = 8, .write_w = 16, .write_l = 32, .read_b = 8, .read_w = 16, .read_l = 32 }; static uint8_t ega_rotate[8][256]; -static int active = 0; +static int active = 0; uint32_t pallook16[256]; uint32_t pallook64[256]; static int ega_type = EGA_TYPE_IBM; @@ -154,7 +154,7 @@ ega_out(uint16_t addr, uint8_t val, void *priv) ega_recalctimings(ega); if ((type == EGA_TYPE_COMPAQ) && !(val & 0x02)) mem_mapping_disable(&ega->mapping); - else switch (ega->gdcreg[6] & 0xc) { + else switch (ega->gdcreg[6] & 0xc) { case 0x0: /*128k at A0000*/ mem_mapping_set_addr(&ega->mapping, 0xa0000, 0x20000); break; @@ -225,7 +225,7 @@ ega_out(uint16_t addr, uint8_t val, void *priv) case 6: if ((type == EGA_TYPE_COMPAQ) && !(ega->miscout & 0x02)) mem_mapping_disable(&ega->mapping); - else switch (val & 0xc) { + else switch (val & 0xc) { case 0x0: /*128k at A0000*/ mem_mapping_set_addr(&ega->mapping, 0xa0000, 0x20000); break; @@ -289,7 +289,7 @@ ega_out(uint16_t addr, uint8_t val, void *priv) if ((idx == 7) && (ega->crtc[0x11] & 0x80)) val = (ega->crtc[7] & ~0x10) | (val & 0x10); } - old = ega->crtc[idx]; + old = ega->crtc[idx]; ega->crtc[idx] = val; if (old != val) { if ((idx < 0xe) || (idx > 0x10)) { @@ -305,7 +305,9 @@ ega_out(uint16_t addr, uint8_t val, void *priv) } break; - } default: + } + + default: break; } } @@ -313,7 +315,7 @@ ega_out(uint16_t addr, uint8_t val, void *priv) uint8_t ega_in(uint16_t addr, void *priv) { - ega_t *ega = (ega_t *) priv; + ega_t *ega = (ega_t *) priv; uint8_t ret = 0xff; int type = ega_type; int atype = ega->actual_type; @@ -494,7 +496,7 @@ ega_in(uint16_t addr, void *priv) } break; case 0x7c6: - ret = 0xfd; /* EGA mode supported. */ + ret = 0xfd; /* EGA mode supported. */ break; case 0xbc6: /* 0000 = None; @@ -696,7 +698,7 @@ ega_recalctimings(ega_t *ega) timer_disable(&ega->dot_timer); timer_set_delay_u64(&ega->dot_timer, ega->dot_time); ega->cca = 0; - active = 1; + active = 1; ega->dot = 0; } @@ -708,30 +710,30 @@ ega_recalctimings(ega_t *ega) void ega_dot_poll(void *priv) { - ega_t *ega = (ega_t *) priv; - static uint8_t chr; - static uint8_t attr; - const bool doublewidth = ((ega->seqregs[1] & 8) != 0); - const bool attrblink = ((ega->attrregs[0x10] & 8) != 0); - const bool attrlinechars = (ega->attrregs[0x10] & 4); - const bool crtcreset = ((ega->crtc[0x17] & 0x80) == 0); - const bool seq9dot = ((ega->seqregs[1] & 1) == 0); - const bool blinked = ega->blink & 0x10; - const int dwshift = doublewidth ? 1 : 0; - const int dotwidth = 1 << dwshift; - const int charwidth = dotwidth * (seq9dot ? 9 : 8); - const int cursoron = (ega->sc == (ega->crtc[10] & 31)); - const int cursoraddr = (ega->crtc[0xe] << 8) | ega->crtc[0xf]; - uint32_t addr; - int drawcursor; - uint32_t charaddr; - static int fg = 0; - static int bg = 0; - static uint32_t dat = 0x00000000; - static int cclock = 0; - static int disptime; - static int _dispontime; - static int _dispofftime; + ega_t *ega = (ega_t *) priv; + static uint8_t chr; + static uint8_t attr; + const bool doublewidth = ((ega->seqregs[1] & 8) != 0); + const bool attrblink = ((ega->attrregs[0x10] & 8) != 0); + const bool attrlinechars = (ega->attrregs[0x10] & 4); + const bool crtcreset = ((ega->crtc[0x17] & 0x80) == 0); + const bool seq9dot = ((ega->seqregs[1] & 1) == 0); + const bool blinked = ega->blink & 0x10; + const int dwshift = doublewidth ? 1 : 0; + const int dotwidth = 1 << dwshift; + const int charwidth = dotwidth * (seq9dot ? 9 : 8); + const int cursoron = (ega->sc == (ega->crtc[10] & 31)); + const int cursoraddr = (ega->crtc[0xe] << 8) | ega->crtc[0xf]; + uint32_t addr; + int drawcursor; + uint32_t charaddr; + static int fg = 0; + static int bg = 0; + static uint32_t dat = 0x00000000; + static int cclock = 0; + static int disptime; + static int _dispontime; + static int _dispofftime; if (ega->seqregs[1] & 8) { disptime = ((ega->crtc[0] + 2) << 1); @@ -803,11 +805,9 @@ void ega_poll(void *priv) { ega_t *ega = (ega_t *) priv; - int x, y; int old_ma; int wx = 640; int wy = 350; - uint32_t blink_delay; if (!ega->linepos) { timer_advance_u64(&ega->timer, ega->dispofftime); @@ -826,7 +826,7 @@ ega_poll(void *priv) old_ma = ega->ma; ega->displine *= ega->vres + 1; ega->y_add *= ega->vres + 1; - for (y = 0; y <= ega->vres; y++) { + for (int y = 0; y <= ega->vres; y++) { /* Render scanline */ ega->render(ega); @@ -925,7 +925,7 @@ ega_poll(void *priv) } if (ega->vc == ega->dispend) { ega->dispon = 0; - blink_delay = (ega->crtc[11] & 0x60) >> 5; + uint32_t blink_delay = (ega->crtc[11] & 0x60) >> 5; if (ega->crtc[10] & 0x20) ega->cursoron = 0; else if (blink_delay == 2) @@ -946,14 +946,14 @@ ega_poll(void *priv) #if 0 picint(1 << 2); #endif - x = ega->hdisp; +// x = ega->hdisp; if (ega->interlace && !ega->oddeven) ega->lastline++; if (ega->interlace && ega->oddeven) ega->firstline--; - wx = x; + wx = ega->hdisp; if (ega->vres) { wy = (ega->lastline - ega->firstline) << 1; @@ -1024,9 +1024,6 @@ ega_doblit(int wx, int wy, ega_t *ega) int y_start = enable_overscan ? 0 : (unscaled_overscan_y >> 1); int x_start = enable_overscan ? 0 : (overscan_x >> 1); int bottom = (unscaled_overscan_y >> 1); - uint32_t *p; - int i; - int j; int xs_temp; int ys_temp; @@ -1073,17 +1070,17 @@ ega_doblit(int wx, int wy, ega_t *ega) if ((wx >= 160) && ((wy + 1) >= 120)) { /* Draw (overscan_size - scroll size) lines of overscan on top and bottom. */ - for (i = 0; i < ega->y_add; i++) { - p = &buffer32->line[i & 0x7ff][0]; + for (int i = 0; i < ega->y_add; i++) { + uint32_t *p = &buffer32->line[i & 0x7ff][0]; - for (j = 0; j < (xsize + x_add); j++) + for (int j = 0; j < (xsize + x_add); j++) p[j] = ega->overscan_color; } - for (i = 0; i < bottom; i++) { - p = &buffer32->line[(ysize + ega->y_add + i) & 0x7ff][0]; + for (int i = 0; i < bottom; i++) { + uint32_t *p = &buffer32->line[(ysize + ega->y_add + i) & 0x7ff][0]; - for (j = 0; j < (xsize + x_add); j++) + for (int j = 0; j < (xsize + x_add); j++) p[j] = ega->overscan_color; } } @@ -1107,12 +1104,11 @@ ega_remap_cpu_addr(uint32_t inaddr, ega_t *ega) // bit 2: 1 = 128K mapping, 0 = other mapping (from memory decode PROM) a0mux = 0; - if (ega->gdcreg[6] & 2) { + if (ega->gdcreg[6] & 2) a0mux |= 2; - } - if (ega->vram_limit <= 64 * 1024) { + + if (ega->vram_limit <= 64 * 1024) a0mux |= 1; - } switch (ega->gdcreg[6] & 0xC) { case 0x0: // 128K A000 @@ -1179,9 +1175,8 @@ ega_write(uint32_t addr, uint8_t val, void *priv) cycles -= video_timing_write_b; - if (ega->chain2_write) { + if (ega->chain2_write) writemask2 &= 0x5 << (addr & 1); - } addr = ega_remap_cpu_addr(addr, ega); @@ -1361,9 +1356,8 @@ ega_read(uint32_t addr, void *priv) cycles -= video_timing_read_b; - if (ega->chain2_read) { + if (ega->chain2_read) readplane = (readplane & 2) | (addr & 1); - } addr = ega_remap_cpu_addr(addr, ega); @@ -1401,23 +1395,19 @@ ega_read(uint32_t addr, void *priv) void ega_init(ega_t *ega, int monitor_type, int is_mono) { - int c; - int d; - int e; - ega->vram = malloc(0x40000); ega->vrammask = 0x3ffff; - for (c = 0; c < 256; c++) { - e = c; - for (d = 0; d < 8; d++) { + for (uint16_t c = 0; c < 256; c++) { + int e = c; + for (uint8_t d = 0; d < 8; d++) { ega_rotate[d][c] = e; e = (e >> 1) | ((e & 1) ? 0x80 : 0); } } if (is_mono) { - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { if (((c >> 3) & 3) == 0) pallook64[c] = pallook16[c] = makecol32(0, 0, 0); else @@ -1476,7 +1466,7 @@ ega_init(ega_t *ega, int monitor_type, int is_mono) io_sethandler(0x03a0, 0x0020, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); } else { - for (c = 0; c < 256; c++) { + for (uint16_t c = 0; c < 256; c++) { pallook64[c] = makecol32(((c >> 2) & 1) * 0xaa, ((c >> 1) & 1) * 0xaa, (c & 1) * 0xaa); pallook64[c] += makecol32(((c >> 5) & 1) * 0x55, ((c >> 4) & 1) * 0x55, ((c >> 3) & 1) * 0x55); pallook16[c] = makecol32(((c >> 2) & 1) * 0xaa, ((c >> 1) & 1) * 0xaa, (c & 1) * 0xaa); @@ -1562,11 +1552,9 @@ ega_set_type(void *priv, uint32_t local) static void * ega_standalone_init(const device_t *info) { - ega_t *ega = malloc(sizeof(ega_t)); + ega_t *ega = calloc(1, sizeof(ega_t)); int monitor_type; - memset(ega, 0x00, sizeof(ega_t)); - video_inform(VIDEO_FLAG_TYPE_SPECIAL, &timing_ega); overscan_x = 16; @@ -1635,8 +1623,7 @@ ega_standalone_init(const device_t *info) if (ega->chipset) { io_sethandler(0x01ce, 0x0002, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); - ega->eeprom = malloc(sizeof(ati_eeprom_t)); - memset(ega->eeprom, 0, sizeof(ati_eeprom_t)); + ega->eeprom = calloc(1, sizeof(ati_eeprom_t)); ati_eeprom_load((ati_eeprom_t *) ega->eeprom, "egawonder800p.nvr", 0); } else if (info->local == EGA_COMPAQ) { io_sethandler(0x0084, 0x0001, ega_in, NULL, NULL, ega_out, NULL, NULL, ega); diff --git a/src/video/vid_ps55da2.c b/src/video/vid_ps55da2.c index 9a95e6ce6..567d60347 100644 --- a/src/video/vid_ps55da2.c +++ b/src/video/vid_ps55da2.c @@ -310,16 +310,16 @@ typedef struct da2_t { uint8_t fctl[32]; uint16_t crtc[32]; uint16_t crtc_vpreg[128]; - uint8_t crtc_vpsel; + uint8_t crtc_vpsel; uint8_t gdcreg[64]; uint8_t reg3ee[16]; int gdcaddr; uint8_t attrc[0x40]; int attraddr, attrff; int attr_palette_enable; - int outflipflop; - int inflipflop; - int iolatch; + int outflipflop; + int inflipflop; + int iolatch; int ioctladdr; int fctladdr; @@ -385,8 +385,7 @@ typedef struct da2_t { card should not attempt to display anything */ int override; - struct - { + struct { int enable; mem_mapping_t mapping; uint8_t ram[DA2_SIZE_GAIJIRAM]; @@ -435,9 +434,9 @@ typedef struct da2_t { uint32_t mmrdbg_vidaddr; #endif - uint8_t pos_regs[8]; - svga_t *mb_vga; - uint8_t monitorid; + uint8_t pos_regs[8]; + svga_t *mb_vga; + uint8_t monitorid; pc_timer_t timer_vidupd; int old_pos2; @@ -520,7 +519,7 @@ da2_WritePlaneDataWithBitmask(uint32_t destaddr, const uint16_t mask, pixel32 *s da2->changedvram[(DA2_MASK_VRAMPLANE & destaddr) >> 9] = changeframecount; destaddr <<= 3; /* read destination data with big endian order */ - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) writepx[i] = da2_vram_r((destaddr + 24) | i, da2) | (da2_vram_r((destaddr + 16) | i, da2) << 8) | (da2_vram_r((destaddr + 8) | i, da2) << 16) @@ -532,7 +531,7 @@ da2_WritePlaneDataWithBitmask(uint32_t destaddr, const uint16_t mask, pixel32 *s mask32.b[3] = mask32in.b[0]; mask32.b[2] = mask32in.b[1]; mask32.d &= 0xffff0000; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (da2->bitblt.bitshift_destr > 0) srcpx->p8[i] <<= 16 - da2->bitblt.bitshift_destr; // #ifdef ENABLE_DA2_DEBUGBLT @@ -560,7 +559,7 @@ da2_WritePlaneDataWithBitmask(uint32_t destaddr, const uint16_t mask, pixel32 *s break; } } - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { da2_vram_w(destaddr | i, (writepx[i] >> 24) & 0xff, da2); da2_vram_w((destaddr + 8) | i, (writepx[i] >> 16) & 0xff, da2); } @@ -571,7 +570,7 @@ da2_DrawColorWithBitmask(uint32_t destaddr, uint8_t color, uint16_t mask, da2_t { pixel32 srcpx; /* fill data with input color */ - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) srcpx.p8[i] = (color & (1 << i)) ? 0xffffffff : 0; /* read in word */ da2_WritePlaneDataWithBitmask(destaddr, mask, &srcpx, da2); @@ -582,7 +581,7 @@ da2_CopyPlaneDataWithBitmask(uint32_t srcaddr, uint32_t destaddr, uint16_t mask, pixel32 srcpx; srcaddr &= 0xfffffffe; srcaddr <<= 3; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) srcpx.p8[i] = da2_vram_r((srcaddr + 24) | i, da2) | (da2_vram_r((srcaddr + 16) | i, da2) << 8) | (da2_vram_r((srcaddr + 8) | i, da2) << 16) @@ -592,9 +591,9 @@ da2_CopyPlaneDataWithBitmask(uint32_t srcaddr, uint32_t destaddr, uint16_t mask, } /* get font data for bitblt operation */ static uint32_t -getRAMFont(int32_t code, int line, int x, void *p) +getRAMFont(int32_t code, int line, int x, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint32_t font = 0; #ifdef RESERVED_FOR_FUTURE_USE int fline = line - 2; /* Start line of drawing character (line >= 1 AND line < 24 + 1 ) */ @@ -617,8 +616,7 @@ getRAMFont(int32_t code, int line, int x, void *p) font |= da2->mmio.ram[code + 2]; font <<= 8; font |= da2->mmio.ram[code + 3]; - } - else + } else font = 0; return font; } @@ -641,12 +639,12 @@ da2_PutcharWithBitmask(uint32_t codeIBMJ, int width, uint16_t attr, int line, ui uint32_t fontinv; if (width <= 2) { fontinv = ~font; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font >> 16 : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv >> 16 : 0; } da2_WritePlaneDataWithBitmask(destaddr, maskl, &srcpx, da2); - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv : 0; } @@ -654,12 +652,12 @@ da2_PutcharWithBitmask(uint32_t codeIBMJ, int width, uint16_t attr, int line, ui } else { font = (font & 0xfff80000) | ((font & 0x0000ffff) << 3); fontinv = ~font; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font >> 16 : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv >> 16 : 0; } da2_WritePlaneDataWithBitmask(destaddr, maskl, &srcpx, da2); - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv : 0; } @@ -667,7 +665,7 @@ da2_PutcharWithBitmask(uint32_t codeIBMJ, int width, uint16_t attr, int line, ui da2_WritePlaneDataWithBitmask(destaddr + 2, maskr, &srcpx, da2); } else { da2_WritePlaneDataWithBitmask(destaddr + 2, 0xffff, &srcpx, da2); - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { srcpx.p8[i] = (fg & (1 << i)) ? font << 16 : 0; srcpx.p8[i] |= (bg & (1 << i)) ? fontinv << 16 : 0; } @@ -680,8 +678,8 @@ static uint8_t pixel1tohex(uint32_t addr, int index, da2_t *da2) { uint8_t pixeldata = 0; - for (int j = 0; j < 8; j++) { - if (da2_vram_r(((addr << 3) | j) & (1 << (7 - index)), da2)) + for (uint8_t i = 0; i < 8; j++) { + if (da2_vram_r(((addr << 3) | i) & (1 << (7 - index)), da2)) pixeldata++; } return pixeldata; @@ -689,14 +687,14 @@ pixel1tohex(uint32_t addr, int index, da2_t *da2) static void print_pixelbyte(uint32_t addr, da2_t *da2) { - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { pclog("%X", pixel1tohex(addr, i, da2)); } } static void print_bytetobin(uint8_t b) { - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (b & 0x80) pclog("1"); else @@ -723,13 +721,13 @@ IBMJtoSJIS(uint16_t knj) knj -= 0x100; if (knj <= 0x1f7d) ; /* do nothing */ - else if (knj >= 0xb700 && knj <= 0xb75f) { + else if (knj >= 0xb700 && knj <= 0xb75f) knj -= 0x90ec; - } else if (knj >= 0xb3f0 && knj <= 0xb67f) { + else if (knj >= 0xb3f0 && knj <= 0xb67f) knj -= 0x906c; - } else if (knj >= 0x8000 && knj <= 0x8183) { + else if (knj >= 0x8000 && knj <= 0x8183) knj -= 0x5524; - } else + else return 0xffff; uint32_t knj1 = knj / 0xBC; uint32_t knj2 = knj - (knj1 * 0xBC); @@ -850,8 +848,7 @@ da2_bitblt_load(da2_t *da2) DOS/V Extension 1040x725 some DBCS uses 0xB0 others 0x90 */ da2->bitblt.destoption = da2->bitblt.reg[0x2F]; - if (da2->bitblt.destoption & 0x10) /* destaddr -= 2, length += 1; */ - { + if (da2->bitblt.destoption & 0x10) { /* destaddr -= 2, length += 1; */ da2->bitblt.destaddr -= 2; da2->bitblt.size_x += 1; da2->bitblt.destpitch -= 2; @@ -892,9 +889,9 @@ da2_bitblt_load(da2_t *da2) da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y); #endif - } + /* Draw a line */ - else if (da2->bitblt.reg[0x5] == 0x43) { + } else if (da2->bitblt.reg[0x5] == 0x43) { da2->bitblt.exec = DA2_BLT_CLINE; da2->bitblt.dest_x = (da2->bitblt.reg[0x32] & 0xffff); da2->bitblt.dest_y = (da2->bitblt.reg[0x34] & 0xffff); @@ -922,17 +919,17 @@ da2_bitblt_load(da2_t *da2) da2_log(" ux1=%d,ux2=%d,uy1=%d,uy2=%d\n", (da2->bitblt.reg[0x32] >> 16) & 0x7ff, (da2->bitblt.reg[0x33] >> 16) & 0x7ff, (da2->bitblt.reg[0x34] >> 16) & 0x7ff, (da2->bitblt.reg[0x35] >> 16) & 0x7ff); - } + /* Fill a rectangle (or draw a horizontal / vertical line) */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x40 && da2->bitblt.reg[0x3D] == 0) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x40 && da2->bitblt.reg[0x3D] == 0) { da2_log("fillrect x=%d, y=%d, w=%d, h=%d, c=%d, 2f=%x, rowcount=%x\n", da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y, da2->bitblt.reg[0x0], da2->bitblt.reg[0x2F], da2->rowoffset * 2); da2->bitblt.exec = DA2_BLT_CFILLRECT; da2->bitblt.destaddr += 2; - } + /* Tiling a rectangle ??(transfer tile data multiple times) os/2 only */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x0040 && da2->bitblt.reg[0x3D] == 0x40) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x0040 && da2->bitblt.reg[0x3D] == 0x40) { da2->bitblt.exec = DA2_BLT_CFILLTILE; da2->bitblt.destaddr += 2; da2->bitblt.srcaddr = da2->bitblt.reg[0x2B]; @@ -942,9 +939,9 @@ da2_bitblt_load(da2_t *da2) da2->bitblt.reg[0x2B] % (da2->rowoffset * 2), da2->bitblt.reg[0x2B] / (da2->rowoffset * 2), da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y); - } + /* Tiling a rectangle (transfer tile data multiple times) */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1040 && da2->bitblt.reg[0x3D] == 0x40) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1040 && da2->bitblt.reg[0x3D] == 0x40) { da2->bitblt.exec = DA2_BLT_CFILLTILE; da2->bitblt.destaddr += 2; da2->bitblt.srcaddr = da2->bitblt.reg[0x2B]; @@ -954,9 +951,9 @@ da2_bitblt_load(da2_t *da2) da2->bitblt.reg[0x2B] % (da2->rowoffset * 2), da2->bitblt.reg[0x2B] / (da2->rowoffset * 2), da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y); - } + /* Block copy */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1040 && da2->bitblt.reg[0x3D] == 0x00) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1040 && da2->bitblt.reg[0x3D] == 0x00) { da2->bitblt.exec = DA2_BLT_CCOPYF; da2->bitblt.srcaddr = da2->bitblt.reg[0x2A]; da2->bitblt.destaddr += 2; @@ -965,9 +962,9 @@ da2_bitblt_load(da2_t *da2) da2->bitblt.reg[0x2A] % (da2->rowoffset * 2), da2->bitblt.reg[0x2A] / (da2->rowoffset * 2), da2->bitblt.reg[0x29] % (da2->rowoffset * 2), da2->bitblt.reg[0x29] / (da2->rowoffset * 2), da2->bitblt.size_x, da2->bitblt.size_y); - } + /* Block copy but reversed direction */ - else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1140 && da2->bitblt.reg[0x3D] == 0x00) { + } else if ((da2->bitblt.reg[0x5] & 0xfff0) == 0x1140 && da2->bitblt.reg[0x3D] == 0x00) { da2->bitblt.exec = DA2_BLT_CCOPYR; da2->bitblt.srcaddr = da2->bitblt.reg[0x2A]; da2->bitblt.destaddr -= 2; @@ -980,9 +977,9 @@ da2_bitblt_load(da2_t *da2) } } static void -da2_bitblt_exec(void *p) +da2_bitblt_exec(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // timer_set_delay_u64(&da2->bitblt.timer, da2->bitblt.timerspeed); #ifdef ENABLE_DA2_DEBUGBLT_DETAIL if (!(da2->bitblt.debug_exesteps & 0xff)) @@ -1180,9 +1177,9 @@ da2_bitblt_dopayload(void *priv) } } static void -da2_bitblt_addpayload(uint8_t val, void *p) +da2_bitblt_addpayload(uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->bitblt.indata = 1; if (da2->bitblt.payload_addr >= DA2_BLT_MEMSIZE) da2_log("da2_mmio_write payload overflow! addr %x, val %x\n", da2->bitblt.payload_addr, val); @@ -1222,9 +1219,9 @@ da2_bitblt_addpayload(uint8_t val, void *p) } static void -da2_out(uint16_t addr, uint16_t val, void *p) +da2_out(uint16_t addr, uint16_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; int oldval; /* 3E0 3E1 Sequencer Registers (undoc) @@ -1403,7 +1400,7 @@ da2_out(uint16_t addr, uint16_t val, void *p) if (da2->attraddr < 16) da2->fullchange = changeframecount; if (da2->attraddr == LV_MODE_CONTROL || da2->attraddr < 0x10) { - for (int c = 0; c < 16; c++) { + for (uint8_t c = 0; c < 16; c++) { // if (da2->attrc[LV_MODE_CONTROL] & 0x80) da2->egapal[c] = (da2->attrc[c] & 0xf) | ((da2->attrc[0x14] & 0xf) << 4); // else da2->egapal[c] = (da2->attrc[c] & 0x3f) | ((da2->attrc[0x14] & 0xc) << 4); if (da2->attrc[LV_MODE_CONTROL] & 0x80) @@ -1486,9 +1483,9 @@ da2_out(uint16_t addr, uint16_t val, void *p) } static uint16_t -da2_in(uint16_t addr, void *p) +da2_in(uint16_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint16_t temp = 0xff; switch (addr) { @@ -1620,9 +1617,9 @@ da2_in(uint16_t addr, void *p) * out b(idx), in w(data) */ static void -da2_outb(uint16_t addr, uint8_t val, void *p) +da2_outb(uint16_t addr, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2_iolog("DA2 Outb addr %03X val %02X %04X:%04X es:di=%x:%x ds:si=%x:%x\n", addr, val, cs >> 4, cpu_state.pc, ES, DI, DS, SI); da2->inflipflop = 0; switch (addr) { @@ -1651,10 +1648,10 @@ da2_outb(uint16_t addr, uint8_t val, void *p) da2_out(addr, da2->iolatch, da2); } void -da2_outw(uint16_t addr, uint16_t val, void *p) +da2_outw(uint16_t addr, uint16_t val, void *priv) { da2_iolog("DA2 Outw addr %03X val %04X\n", addr, val); - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->inflipflop = 0; switch (addr) { case LS_INDEX: @@ -1703,10 +1700,10 @@ da2_outw(uint16_t addr, uint16_t val, void *p) } } static uint8_t -da2_inb(uint16_t addr, void *p) +da2_inb(uint16_t addr, void *priv) { uint8_t temp; - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->outflipflop = 0; switch (addr) { case LC_DATA: @@ -1736,10 +1733,10 @@ da2_inb(uint16_t addr, void *p) return temp; } static uint16_t -da2_inw(uint16_t addr, void *p) +da2_inw(uint16_t addr, void *priv) { uint16_t temp; - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->inflipflop = 0; da2->outflipflop = 0; temp = da2_in(addr, da2); @@ -1748,9 +1745,9 @@ da2_inw(uint16_t addr, void *p) } /* IO 03DAh : Input Status Register 2 for DOSSHELL used by DOS J4.0 */ static uint8_t -da2_in_ISR(uint16_t addr, void *p) +da2_in_ISR(uint16_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint8_t temp = 0; if (addr == 0x3da) { if (da2->cgastat & 0x01) @@ -1764,9 +1761,9 @@ da2_in_ISR(uint16_t addr, void *p) } static void -da2_out_ISR(uint16_t addr, uint8_t val, void *p) +da2_out_ISR(uint16_t addr, uint8_t val, void *priv) { - // da2_t* da2 = (da2_t*)p; + // da2_t* da2 = (da2_t*) priv; da2_iolog("DA2D Out %04X %04X %04X:%04X\n", addr, val, cs >> 4, cpu_state.pc); } @@ -1872,9 +1869,9 @@ The Font ROM can be accessed via 128 KB memory window located at A0000-BFFFFh. /* Get character line pattern from jfont rom or gaiji volatile memory */ static uint32_t -getfont_ps55dbcs(int32_t code, int32_t line, void *p) +getfont_ps55dbcs(int32_t code, int32_t line, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint32_t font = 0; int32_t fline = line - 2; /* Start line of drawing character (line >= 1 AND line < 24 + 1 ) */ if (code >= 0x8000 && code <= 0x8183) @@ -2424,7 +2421,7 @@ da2_mapping_update(da2_t *da2) // da2_recalc_mapping(da2); if (da2->pos_regs[2] & 0x01) { da2_log("DA2 enable registers\n"); - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2_log("DA2 POS[%d]: %x\n", i, da2->pos_regs[i]); io_sethandler(0x03c0, 0x000a, da2_inb, da2_inw, NULL, da2_outb, da2_outw, NULL, da2); io_sethandler(0x03e0, 0x0010, da2_inb, da2_inw, NULL, da2_outb, da2_outw, NULL, da2); @@ -2444,16 +2441,16 @@ da2_mapping_update(da2_t *da2) } static uint8_t -da2_mca_read(int port, void *p) +da2_mca_read(int port, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; return da2->pos_regs[port & 7]; } static void -da2_mca_write(int port, uint8_t val, void *p) +da2_mca_write(int port, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2_log("da2_mca_write: port=%04x val=%02x\n", port, val); @@ -2473,9 +2470,9 @@ da2_mca_feedb(void *priv) } static void -da2_mca_reset(void *p) +da2_mca_reset(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2_log("da2_mca_reset called.\n"); da2_reset(da2); da2_mca_write(0x102, 0, da2); @@ -2485,7 +2482,7 @@ da2_mca_reset(void *p) static void da2_gdcropB(uint32_t addr,uint8_t bitmask, da2_t *da2) { - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (da2->planemask & (1 << i)) { // da2_log("da2_gdcropB o%x a%x d%x p%d m%x\n", da2->gdcreg[LG_COMMAND] & 0x03, addr, da2->gdcinput[i], i, bitmask); switch (da2->gdcreg[LG_COMMAND] & 0x03) { @@ -2518,7 +2515,7 @@ da2_gdcropW(uint32_t addr, uint16_t bitmask, da2_t *da2) // if((addr & 8)) bitmask = da2_rightrotate(bitmask, 8); uint8_t bitmask_l = bitmask & 0xff; uint8_t bitmask_h = bitmask >> 8; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (da2->planemask & (1 << i)) { // da2_log("da2_gdcropW m%x a%x d%x i%d ml%x mh%x\n", da2->gdcreg[LG_COMMAND] & 0x03, addr, da2->gdcinput[i], i, da2->gdcreg[LG_BIT_MASK_LOW], da2->gdcreg[LG_BIT_MASK_HIGH]); switch (da2->gdcreg[LG_COMMAND] & 0x03) { @@ -2556,9 +2553,9 @@ da2_gdcropW(uint32_t addr, uint16_t bitmask, da2_t *da2) } static uint8_t -da2_mmio_read(uint32_t addr, void *p) +da2_mmio_read(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint32_t index = 0; addr &= DA2_MASK_MMIO; if (da2->ioctl[LS_MMIO] & 0x10) { @@ -2604,14 +2601,14 @@ da2_mmio_read(uint32_t addr, void *p) } } else if (!(da2->ioctl[LS_MODE] & 1)) { /* 16 or 256 color mode */ cycles -= video_timing_read_b; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcla[i] = da2->vram[(addr << 3) | i]; /* read in byte */ #ifdef ENABLE_DA2_DEBUGVRAM da2_log("da2_Rb: %05x=%02x\n", addr, da2->gdcla[da2->readplane]); #endif if (da2->gdcreg[LG_MODE] & 0x08) { /* compare data across planes if the read mode bit (3EB 05, bit 3) is 1 */ uint8_t ret = 0; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (~da2->gdcreg[LG_COLOR_DONT_CARE] & (1 << i)) /* color don't care register */ ret |= da2->gdcla[i] ^ ((da2->gdcreg[LG_COLOR_COMPAREJ] & (1 << i)) ? 0xff : 0); } @@ -2624,9 +2621,9 @@ da2_mmio_read(uint32_t addr, void *p) } } static uint16_t -da2_mmio_readw(uint32_t addr, void *p) +da2_mmio_readw(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // da2_log("da2_readW: %x %x %x %x %x\n", da2->ioctl[LS_MMIO], da2->fctl[LF_MMIO_SEL], da2->fctl[LF_MMIO_MODE], da2->fctl[LF_MMIO_ADDR], addr); // da2_log("da2_readW: %x %x %x %x %x CS:PC=%4x:%4x\n", da2->ioctl[LS_MMIO], da2->fctl[LF_MMIO_SEL], da2->fctl[LF_MMIO_MODE], da2->fctl[LF_MMIO_ADDR], addr, CS, cpu_state.pc); @@ -2635,7 +2632,7 @@ da2_mmio_readw(uint32_t addr, void *p) } else if (!(da2->ioctl[LS_MODE] & 1)) {/* 16 color or 256 color mode */ cycles -= video_timing_read_w; addr &= DA2_MASK_MMIO; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcla[i] = (uint16_t) (da2->vram[(addr << 3) | i]) | ((uint16_t) (da2->vram[((addr << 3) + 8) | i]) << 8); /* read vram into latch */ #ifdef ENABLE_DA2_DEBUGVRAM @@ -2643,10 +2640,10 @@ da2_mmio_readw(uint32_t addr, void *p) // if (((int)addr - (int)da2->mmrdbg_vidaddr) > 2 || (((int)da2->mmrdbg_vidaddr - (int)addr) > 2) || da2->mmrdbg_vidaddr == addr) //{ // fprintf(da2->mmrdbg_fp, "\nR %x ", addr); - // for (int i = 0; i <= 0xb; i++) + // for (uint8_t i = 0; i <= 0xb; i++) // fprintf(da2->mmrdbg_fp, "%02x ", da2->gdcreg[i]); // } - // for (int i = 0; i < 16; i++) + // for (uint8_t i = 0; i < 16; i++) //{ // int pixeldata = 0; // if (da2->gdcla[da2->readplane] & (1 << (15 - i))) pixeldata = 1; @@ -2658,7 +2655,7 @@ da2_mmio_readw(uint32_t addr, void *p) if (da2->gdcreg[LG_MODE] & 0x08) { /* compare data across planes if the read mode bit (3EB 05, bit 3) is 1 */ uint16_t ret = 0; - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (~da2->gdcreg[LG_COLOR_DONT_CARE] & (1 << i)) /* color don't care register */ ret |= da2->gdcla[i] ^ ((da2->gdcreg[LG_COLOR_COMPAREJ] & (1 << i)) ? 0xffff : 0); } @@ -2674,9 +2671,9 @@ da2_mmio_readw(uint32_t addr, void *p) } } static void -da2_mmio_write(uint32_t addr, uint8_t val, void *p) +da2_mmio_write(uint32_t addr, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint32_t index = 0; // da2_log("da2_mmio_write %x %x\n", addr, val); // if ((addr & ~DA2_MASK_MMIO) != 0xA0000) @@ -2735,10 +2732,10 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) //{ if (((int) addr - (int) da2->mmdbg_vidaddr) > 2 || (((int) da2->mmdbg_vidaddr - (int) addr) > 2) || da2->mmdbg_vidaddr == addr) { fprintf(da2->mmdbg_fp, "\nB %x %02x ", addr, val); - for (int i = 0; i <= 0xb; i++) + for (uint8_t i = 0; i <= 0xb; i++) fprintf(da2->mmdbg_fp, "%02x ", da2->gdcreg[i]); } - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { int pixeldata = 0; if (val & (1 << (7 - i))) pixeldata = (da2->planemask & 0xf); @@ -2751,14 +2748,14 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) da2->changedvram[addr >> 9] = changeframecount;/* 0x1FFFF -> 0x1F */ addr <<= 3; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcsrc[i] = da2->gdcla[i]; /* use latch */ // da2_log("da2_Wb m%02x r%02x %05x:%02x %x:%x\n", da2->gdcreg[0x5], da2->gdcreg[LG_COMMAND], addr >> 3, val, cs >> 4, cpu_state.pc); // da2_log("da2_Wb m%02x r%02x %05x:%02x=%02x%02x%02x%02x->", da2->gdcreg[0x5], da2->gdcreg[LG_COMMAND], addr >> 3, val, da2->vram[addr + 0], da2->vram[addr + 1], da2->vram[addr + 2], da2->vram[addr + 3]); if (!(da2->gdcreg[LG_COMMAND] & 0x08)) { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->gdcreg[LG_ENABLE_SRJ] & (1 << i)) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xff : 0; else if (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) @@ -2771,7 +2768,7 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) switch (da2->writemode) { case 2: /* equiv to vga write mode 1 */ - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->planemask & (1 << i)) da2_vram_w(addr | i, da2->gdcsrc[i], da2); break; @@ -2779,11 +2776,11 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) if (da2->gdcreg[LG_DATA_ROTATION] & 7) val = svga_rotate[da2->gdcreg[LG_DATA_ROTATION] & 7][val]; if (bitmask == 0xff && !(da2->gdcreg[LG_COMMAND] & 0x03) && (!da2->gdcreg[LG_ENABLE_SRJ])) { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->planemask & (1 << i)) da2_vram_w(addr | i, val, da2); } else { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->gdcreg[LG_ENABLE_SRJ] & (1 << i)) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xff : 0; else @@ -2792,7 +2789,7 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) } break; case 1:/* equiv to vga write mode 2 */ - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcinput[i] = ((val & (1 << i)) ? 0xff : 0); da2_gdcropB(addr, bitmask, da2); break; @@ -2801,7 +2798,7 @@ da2_mmio_write(uint32_t addr, uint8_t val, void *p) val = svga_rotate[da2->gdcreg[LG_DATA_ROTATION] & 7][val]; bitmask &= val; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xff : 0; da2_gdcropB(addr, bitmask, da2); break; @@ -2818,9 +2815,9 @@ da2_rightrotate(uint16_t data, uint8_t count) return (data >> count) | (data << (sizeof(data) * 8 - count)); } static void -da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) +da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint16_t bitmask; addr &= DA2_MASK_MMIO; bitmask = da2->gdcreg[LG_BIT_MASK_HIGH]; @@ -2832,10 +2829,10 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) if (((int) addr - (int) da2->mmdbg_vidaddr) > 2 || (((int) da2->mmdbg_vidaddr - (int) addr) > 2) || da2->mmdbg_vidaddr == addr) { fprintf(da2->mmdbg_fp, "\nW %x %x ", addr, val); - for (int i = 0; i <= 0xb; i++) + for (uint8_t i = 0; i <= 0xb; i++) fprintf(da2->mmdbg_fp, "%02x ", da2->gdcreg[i]); } - for (int i = 0; i < 16; i++) { + for (uint8_t i = 0; i < 16; i++) { int pixeldata = 0; if (val & (1 << (15 - i))) pixeldata = (da2->planemask & 0xf); @@ -2851,11 +2848,11 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) da2->changedvram[addr >> 9] = changeframecount; addr <<= 3; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcsrc[i] = da2->gdcla[i]; /* use latch */ if (!(da2->gdcreg[LG_COMMAND] & 0x08)) { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->gdcreg[LG_ENABLE_SRJ] & (1 << i)) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xffff : 0; else if (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) @@ -2869,7 +2866,7 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) // , da2->vram[addr + 8], da2->vram[addr + 9], da2->vram[addr + 10], da2->vram[addr + 11]); switch (da2->writemode) { case 2: - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->planemask & (1 << i)) { da2_vram_w(addr | i, da2->gdcsrc[i] & 0xff, da2); da2_vram_w((addr + 8) | i, da2->gdcsrc[i] >> 8, da2); @@ -2879,13 +2876,13 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) if (da2->gdcreg[LG_DATA_ROTATION] & 15) val = da2_rightrotate(val, da2->gdcreg[LG_DATA_ROTATION] & 15); if (bitmask == 0xffff && !(da2->gdcreg[LG_COMMAND] & 0x03) && (!da2->gdcreg[LG_ENABLE_SRJ])) { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->planemask & (1 << i)) { da2_vram_w(addr | i, val & 0xff, da2); da2_vram_w((addr + 8) | i, val >> 8, da2); } } else { - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) if (da2->gdcreg[LG_ENABLE_SRJ] & (1 << i)) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xffff : 0; else @@ -2895,7 +2892,7 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) } break; case 1: - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcinput[i] = ((val & (1 << i)) ? 0xffff : 0); da2_gdcropW(addr, bitmask, da2); break; @@ -2904,7 +2901,7 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) val = da2_rightrotate(val, da2->gdcreg[LG_DATA_ROTATION] & 15); bitmask &= val; - for (int i = 0; i < 8; i++) + for (uint8_t i = 0; i < 8; i++) da2->gdcinput[i] = (da2->gdcreg[LG_SET_RESETJ] & (1 << i)) ? 0xffff : 0; da2_gdcropW(addr, bitmask, da2); break; @@ -2913,9 +2910,9 @@ da2_mmio_gc_writeW(uint32_t addr, uint16_t val, void *p) // , da2->vram[addr + 8], da2->vram[addr + 9], da2->vram[addr + 10], da2->vram[addr + 11]); } static void -da2_mmio_writew(uint32_t addr, uint16_t val, void *p) +da2_mmio_writew(uint32_t addr, uint16_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // if (da2->bitblt.exec != DA2_BLT_CIDLE) /* Bitblt is in operation. */ // return; // if ((addr & ~0x1ffff) != 0xA0000) return; @@ -2941,52 +2938,52 @@ da2_mmio_writew(uint32_t addr, uint16_t val, void *p) } static void -da2_code_write(uint32_t addr, uint8_t val, void *p) +da2_code_write(uint32_t addr, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // if ((addr & ~0xfff) != 0xE0000) return; addr &= DA2_MASK_CRAM; da2->cram[addr] = val; da2->fullchange = 2; } static void -da2_code_writeb(uint32_t addr, uint8_t val, void *p) +da2_code_writeb(uint32_t addr, uint8_t val, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // da2_log("DA2_code_writeb: Write to %x, val %x\n", addr, val); cycles -= video_timing_write_b; da2_code_write(addr, val, da2); } static void -da2_code_writew(uint32_t addr, uint16_t val, void *p) +da2_code_writew(uint32_t addr, uint16_t val, void *priv) { // da2_log("DA2_code_writ ew: Write to %x, val %x\n", addr, val); - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; cycles -= video_timing_write_w; da2_code_write(addr, val & 0xff, da2); da2_code_write(addr + 1, val >> 8, da2); } static uint8_t -da2_code_read(uint32_t addr, void *p) +da2_code_read(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; // if ((addr & ~DA2_MASK_CRAM) != 0xE0000) // return DA2_INVALIDACCESS8; addr &= DA2_MASK_CRAM; return da2->cram[addr]; } static uint8_t -da2_code_readb(uint32_t addr, void *p) +da2_code_readb(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; cycles -= video_timing_read_b; return da2_code_read(addr, da2); } static uint16_t -da2_code_readw(uint32_t addr, void *p) +da2_code_readw(uint32_t addr, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; cycles -= video_timing_read_w; return da2_code_read(addr, da2) | (da2_code_read(addr + 1, da2) << 8); } @@ -3153,9 +3150,9 @@ da2_poll(void *priv) } static void -da2_loadfont(char *fname, void *p) +da2_loadfont(char *fname, void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; uint8_t buf; uint64_t fsize; if (!fname) @@ -3239,7 +3236,7 @@ da2_reset(void *priv) da2->attr_palette_enable = 0; /* disable attribute generator */ /* Set default color palette (Windows 3.1 display driver won't reset palette) */ - for (int i = 0; i < 256; i++) { + for (uint16_t i = 0; i < 256; i++) { da2->vgapal[i].r = ps55_palette_color[i & 0x3F][0]; da2->vgapal[i].g = ps55_palette_color[i & 0x3F][1]; da2->vgapal[i].b = ps55_palette_color[i & 0x3F][2]; @@ -3320,95 +3317,95 @@ da2_available(void) } static void -da2_close(void *p) +da2_close(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; /* dump mem for debug */ #ifdef ENABLE_DA2_LOG - FILE *f; - f = fopen("da2_cram.dmp", "wb"); - if (f != NULL) { - fwrite(da2->cram, DA2_SIZE_CRAM, 1, f); - fclose(f); + FILE *fp; + fp = fopen("da2_cram.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->cram, DA2_SIZE_CRAM, 1, fp); + fclose(fp); } - f = fopen("da2_vram.dmp", "wb"); - if (f != NULL) { - fwrite(da2->vram, DA2_SIZE_VRAM, 1, f); - fclose(f); + fp = fopen("da2_vram.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->vram, DA2_SIZE_VRAM, 1, fp); + fclose(fp); } - f = fopen("da2_gram.dmp", "wb"); - if (f != NULL) { - fwrite(da2->mmio.ram, DA2_SIZE_GAIJIRAM, 1, f); - fclose(f); + fp = fopen("da2_gram.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->mmio.ram, DA2_SIZE_GAIJIRAM, 1, fp); + fclose(fp); } - f = fopen("da2_attrpal.dmp", "wb"); - if (f != NULL) { - fwrite(da2->attrc, 32, 1, f); - fclose(f); + fp = fopen("da2_attrpal.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->attrc, 32, 1, fp); + fclose(fp); } - f = fopen("da2_dacrgb.dmp", "wb"); - if (f != NULL) { - fwrite(da2->vgapal, 3 * 256, 1, f); - fclose(f); + fp = fopen("da2_dacrgb.dmp", "wb"); + if (fp != NULL) { + fwrite(da2->vgapal, 3 * 256, 1, fp); + fclose(fp); } - f = fopen("da2_daregs.txt", "w"); - if (f != NULL) { - for (int i = 0; i < 0x10; i++) - fprintf(f, "3e1(ioctl) %02X: %4X\n", i, da2->ioctl[i]); - for (int i = 0; i < 0x20; i++) - fprintf(f, "3e3(fctl) %02X: %4X\n", i, da2->fctl[i]); - for (int i = 0; i < 0x20; i++) - fprintf(f, "3e5(crtc) %02X: %4X\n", i, da2->crtc[i]); - for (int i = 0; i < 0x40; i++) - fprintf(f, "3e8(attr) %02X: %4X\n", i, da2->attrc[i]); - for (int i = 0; i < 0x10; i++) - fprintf(f, "3eb(gcr) %02X: %4X\n", i, da2->gdcreg[i]); - for (int i = 0; i < 0x10; i++) - fprintf(f, "3ee(?) %02X: %4X\n", i, da2->reg3ee[i]); - for (int i = 0; i < 0x20; i++) { - fprintf(f, "vp %02X: %4X %4X %4X %4X\n", i, + fp = fopen("da2_daregs.txt", "w"); + if (fp != NULL) { + for (uint8_t i = 0; i < 0x10; i++) + fprintf(fp, "3e1(ioctl) %02X: %4X\n", i, da2->ioctl[i]); + for (uint8_t i = 0; i < 0x20; i++) + fprintf(fp, "3e3(fctl) %02X: %4X\n", i, da2->fctl[i]); + for (uint8_t i = 0; i < 0x20; i++) + fprintf(fp, "3e5(crtc) %02X: %4X\n", i, da2->crtc[i]); + for (uint8_t i = 0; i < 0x40; i++) + fprintf(fp, "3e8(attr) %02X: %4X\n", i, da2->attrc[i]); + for (uint8_t i = 0; i < 0x10; i++) + fprintf(fp, "3eb(gcr) %02X: %4X\n", i, da2->gdcreg[i]); + for (uint8_t i = 0; i < 0x10; i++) + fprintf(fp, "3ee(?) %02X: %4X\n", i, da2->reg3ee[i]); + for (uint8_t i = 0; i < 0x20; i++) { + fprintf(fp, "vp %02X: %4X %4X %4X %4X\n", i, da2->crtc_vpreg[0 + i], da2->crtc_vpreg[0x20 + i], da2->crtc_vpreg[0x40 + i], da2->crtc_vpreg[0x60 + i]); } - fclose(f); + fclose(fp); } - f = fopen("ram_low.dmp", "wb"); - if (f != NULL) { - fwrite(&ram[0x0], 0x100000, 1, f); - fclose(f); + fp = fopen("ram_low.dmp", "wb"); + if (fp != NULL) { + fwrite(&ram[0x0], 0x100000, 1, fp); + fclose(fp); } pclog("closed %04X:%04X DS %04X\n", cs >> 4, cpu_state.pc, DS); #endif #ifdef ENABLE_DA2_DEBUGBLT - f = fopen("da2_bltdump.csv", "w"); - if (f != NULL && da2->bitblt.debug_reg_ip > 0) { + fp = fopen("da2_bltdump.csv", "w"); + if (fp != NULL && da2->bitblt.debug_reg_ip > 0) { /* print header */ for (int y = 0; y < DA2_DEBUG_BLTLOG_SIZE; y++) { if (da2->bitblt.debug_reg[(da2->bitblt.debug_reg_ip - 1) * DA2_DEBUG_BLTLOG_SIZE + y] != DA2_DEBUG_BLT_NEVERUSED) - fprintf(f, "\"%02X\"\t", y); + fprintf(fp, "\"%02X\"\t", y); } - fprintf(f, "\n"); + fprintf(fp, "\n"); /* print data */ for (int x = 0; x < da2->bitblt.debug_reg_ip; x++) { for (int y = 0; y < DA2_DEBUG_BLTLOG_SIZE; y++) { if (da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + y] == DA2_DEBUG_BLT_NEVERUSED) ; else if (da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + y] == DA2_DEBUG_BLT_USEDRESET) - fprintf(f, "\"\"\t"); + fprintf(fp, "\"\"\t"); else { - fprintf(f, "\"%X\"\t", da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + y]); + fprintf(fp, "\"%X\"\t", da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + y]); if (y == 0x12) { int chr = da2->bitblt.debug_reg[x * DA2_DEBUG_BLTLOG_SIZE + 0x12]; if ((chr >= 0x20) && (chr < 0x7f)) - fprintf(f, "\"%c\"\t", chr); + fprintf(fp, "\"%c\"\t", chr); else - fprintf(f, "\"\"\t"); + fprintf(fp, "\"\"\t"); } } } - fprintf(f, "\n"); + fprintf(fp, "\n"); } - fclose(f); + fclose(fp); } free(da2->bitblt.debug_reg); #endif @@ -3426,28 +3423,28 @@ da2_close(void *p) } static void -da2_speed_changed(void *p) +da2_speed_changed(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->da2const = (uint64_t) ((cpuclock / DA2_PIXELCLOCK) * (double) (1ull << 32)); da2_recalctimings(da2); } static void -da2_force_redraw(void *p) +da2_force_redraw(void *priv) { - da2_t *da2 = (da2_t *) p; + da2_t *da2 = (da2_t *) priv; da2->fullchange = changeframecount; } static const device_config_t da2_configuration[] = { // clang-format off { - .name = "charset", + .name = "charset", .description = "Charset", - .type = CONFIG_SELECTION, + .type = CONFIG_SELECTION, .default_int = DA2_DCONFIG_CHARSET_JPAN, - .selection = { + .selection = { { .description = "932 (Japanese)", .value = DA2_DCONFIG_CHARSET_JPAN @@ -3460,11 +3457,11 @@ static const device_config_t da2_configuration[] = { } }, { - .name = "montype", + .name = "montype", .description = "Monitor type", - .type = CONFIG_SELECTION, + .type = CONFIG_SELECTION, .default_int = DA2_DCONFIG_MONTYPE_COLOR, - .selection = { + .selection = { { .description = "Color", .value = DA2_DCONFIG_MONTYPE_COLOR diff --git a/src/video/video.c b/src/video/video.c index 11edbc3f4..785479e15 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -1017,8 +1017,8 @@ loadfont_common(FILE *fp, int format) for (uint8_t d = 0; d < 8; d++) fontdatm[c][d + 8] = fgetc(fp) & 0xff; (void) fseek(fp, 4096 + 2048, SEEK_SET); - for (uint16_t c = 0; c < 256; c++) - for (uint8_t d = 0; d < 8; d++) /* 8x8 CGA (thick, primary) */ + for (uint16_t c = 0; c < 256; c++) /* 8x8 CGA (thick, primary) */ + for (uint8_t d = 0; d < 8; d++) fontdat[c][d] = fgetc(fp) & 0xff; break;