diff --git a/src/SOUND/sound.c b/src/SOUND/sound.c index c3086b8e1..24cf2c1c1 100644 --- a/src/SOUND/sound.c +++ b/src/SOUND/sound.c @@ -143,18 +143,6 @@ static void sound_cd_thread(void *param) cd_out_buffer[c] = 0.0; cd_out_buffer[c+1] = 0.0; } - has_audio = 0; - for (i = 0; i < CDROM_NUM; i++) - { - if (cdrom_drives[i].bus_type && cdrom_drives[i].sound_on) - { - has_audio++; - } - } - if (!has_audio) - { - return; - } for (i = 0; i < CDROM_NUM; i++) { has_audio = 0; diff --git a/src/VIDEO/vid_ega.c b/src/VIDEO/vid_ega.c index d97f13ba1..b64f30324 100644 --- a/src/VIDEO/vid_ega.c +++ b/src/VIDEO/vid_ega.c @@ -243,6 +243,8 @@ void ega_recalctimings(ega_t *ega) ega->hdisp++; ega->rowoffset = ega->crtc[0x13]; + ega->rowcount = ega->crtc[9] & 0x1f; + overscan_y = (ega->rowcount + 1) << 1; if (ega->vidclock) crtcconst = (ega->seqregs[1] & 1) ? MDACONST : (MDACONST * (9.0 / 8.0)); else crtcconst = (ega->seqregs[1] & 1) ? CGACONST : (CGACONST * (9.0 / 8.0)); @@ -253,8 +255,13 @@ void ega_recalctimings(ega_t *ega) if (ega->seqregs[1] & 8) { disptime*=2; - _dispontime*=2; + _dispontime*=2; + overscan_y <<= 1; } + if (overscan_y < 16) + { + overscan_y = 16; + } _dispofftime = disptime - _dispontime; _dispontime *= crtcconst; _dispofftime *= crtcconst; @@ -263,6 +270,19 @@ void ega_recalctimings(ega_t *ega) ega->dispofftime = (int)(_dispofftime * (1 << TIMER_SHIFT)); } +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; +} + void ega_poll(void *p) { ega_t *ega = (ega_t *)p; @@ -273,12 +293,13 @@ void ega_poll(void *p) int offset; uint8_t edat[4]; int drawcursor = 0; - int y_add = enable_overscan ? 14 : 0; + int y_add = enable_overscan ? (overscan_y >> 1) : 0; int x_add = enable_overscan ? 8 : 0; - int y_add_ex = enable_overscan ? 28 : 0; + int y_add_ex = enable_overscan ? overscan_y : 0; int x_add_ex = enable_overscan ? 16 : 0; - uint32_t *q, *r, i, j; + uint32_t *q, i, j; int wx = 640, wy = 350; + int dl = ega_display_line(ega); if (!ega->linepos) { @@ -302,16 +323,16 @@ void ega_poll(void *p) switch (ega->seqregs[1] & 9) { case 0: - for (xx = 0; xx < 9; xx++) ((uint32_t *)buffer32->line[ega->displine + y_add])[(x * 9) + xx + 32 + x_add] = 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[ega->displine + y_add])[(x * 8) + xx + 32 + x_add] = 0; + 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[ega->displine + y_add])[(x * 18) + xx + 32 + x_add] = 0; + 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[ega->displine + y_add])[(x * 16) + xx + 32 + x_add] = 0; + for (xx = 0; xx < 16; xx++) ((uint32_t *)buffer32->line[dl])[(x * 16) + xx + 32 + x_add] = 0; break; } } @@ -352,20 +373,20 @@ void ega_poll(void *p) if (ega->seqregs[1] & 1) { for (xx = 0; xx < 8; xx++) - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x << 4) + 32 + (xx << 1)) & 2047) + x_add] = - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x << 4) + 33 + (xx << 1)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; + ((uint32_t *)buffer32->line[dl])[(((x << 4) + 32 + (xx << 1)) & 2047) + x_add] = + ((uint32_t *)buffer32->line[dl])[(((x << 4) + 33 + (xx << 1)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; } else { for (xx = 0; xx < 8; xx++) - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 18) + 32 + (xx << 1)) & 2047) + x_add] = - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 18) + 33 + (xx << 1)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; + ((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + (xx << 1)) & 2047) + x_add] = + ((uint32_t *)buffer32->line[dl])[(((x * 18) + 33 + (xx << 1)) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4)) - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 18) + 32 + 16) & 2047) + x_add] = - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 18) + 32 + 17) & 2047) + x_add] = bg; + ((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 16) & 2047) + x_add] = + ((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 17) & 2047) + x_add] = bg; else - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 18) + 32 + 16) & 2047) + x_add] = - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 18) + 32 + 17) & 2047) + x_add] = (dat & 1) ? fg : bg; + ((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 16) & 2047) + x_add] = + ((uint32_t *)buffer32->line[dl])[(((x * 18) + 32 + 17) & 2047) + x_add] = (dat & 1) ? fg : bg; } } else @@ -373,16 +394,16 @@ void ega_poll(void *p) if (ega->seqregs[1] & 1) { for (xx = 0; xx < 8; xx++) - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x << 3) + 32 + xx) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; + ((uint32_t *)buffer32->line[dl])[(((x << 3) + 32 + xx) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; } else { for (xx = 0; xx < 8; xx++) - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 9) + 32 + xx) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; + ((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + xx) & 2047) + x_add] = (dat & (0x80 >> xx)) ? fg : bg; if ((chr & ~0x1f) != 0xc0 || !(ega->attrregs[0x10] & 4)) - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 9) + 32 + 8) & 2047) + x_add] = bg; + ((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + 8) & 2047) + x_add] = bg; else - ((uint32_t *)buffer32->line[ega->displine + y_add])[(((x * 9) + 32 + 8) & 2047) + x_add] = (dat & 1) ? fg : bg; + ((uint32_t *)buffer32->line[dl])[(((x * 9) + 32 + 8) & 2047) + x_add] = (dat & 1) ? fg : bg; } } ega->ma += 4; @@ -418,17 +439,17 @@ void ega_poll(void *p) ega->ma &= ega->vrammask; dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 14 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 15 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 12 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 13 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + ((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[ega->displine + y_add])[(x << 4) + 10 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 11 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 8 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 9 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + ((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[ega->displine + y_add])[(x << 4) + 6 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 7 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 4 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 5 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + ((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[ega->displine + y_add])[(x << 4) + 2 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 3 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 1 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + ((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]]]; } } else @@ -454,17 +475,17 @@ void ega_poll(void *p) ega->ma &= ega->vrammask; dat = edatlookup[edat[0] & 3][edat[1] & 3] | (edatlookup[edat[2] & 3][edat[3] & 3] << 2); - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 3) + 7 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 3) + 6 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + ((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[ega->displine + y_add])[(x << 3) + 5 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 3) + 4 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + ((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[ega->displine + y_add])[(x << 3) + 3 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 3) + 2 + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + ((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[ega->displine + y_add])[(x << 3) + 1 + offset + x_add] = ega->pallook[ega->egapal[(dat & 0xf) & ega->attrregs[0x12]]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 3) + offset + x_add] = ega->pallook[ega->egapal[(dat >> 4) & ega->attrregs[0x12]]]; + ((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]]]; } } break; @@ -485,14 +506,14 @@ void ega_poll(void *p) ega->ma += 4; ega->ma &= ega->vrammask; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 14 + offset + x_add]= ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 15 + offset + x_add] = ega->pallook[ega->egapal[edat[1] & 3]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 12 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 13 + offset + x_add] = ega->pallook[ega->egapal[(edat[1] >> 2) & 3]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 10 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 11 + offset + x_add] = ega->pallook[ega->egapal[(edat[1] >> 4) & 3]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 8 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 9 + offset + x_add] = ega->pallook[ega->egapal[(edat[1] >> 6) & 3]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 6 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 7 + offset + x_add] = ega->pallook[ega->egapal[(edat[0] >> 0) & 3]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 4 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 5 + offset + x_add] = ega->pallook[ega->egapal[(edat[0] >> 2) & 3]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 2 + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 3 + offset + x_add] = ega->pallook[ega->egapal[(edat[0] >> 4) & 3]]; - ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + offset + x_add] = ((uint32_t *)buffer32->line[ega->displine + y_add])[(x << 4) + 1 + offset + x_add] = ega->pallook[ega->egapal[(edat[0] >> 6) & 3]]; + ((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[edat[1] & 3]]; + ((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[(edat[1] >> 2) & 3]]; + ((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[(edat[1] >> 4) & 3]]; + ((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[(edat[1] >> 6) & 3]]; + ((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[(edat[0] >> 0) & 3]]; + ((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[(edat[0] >> 2) & 3]]; + ((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[(edat[0] >> 4) & 3]]; + ((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[(edat[0] >> 6) & 3]]; } break; } @@ -570,7 +591,7 @@ void ega_poll(void *p) y_add_ex = enable_overscan ? 28 : 0; x_add_ex = enable_overscan ? 16 : 0; - if ((xsize > 2032) || (ysize > 2032)) + if ((xsize > 2032) || ((ysize + y_add_ex) > 2048)) { x_add = x_add_ex = 0; y_add = y_add_ex = 0; @@ -591,21 +612,31 @@ void ega_poll(void *p) { if ((x >= 160) && ((ega->lastline - ega->firstline) >= 120)) { - for (i = 0; i < y_add; i++) + /* Draw (overscan_size - scroll size) lines of overscan on top. */ + for (i = 0; i < (y_add - (ega->crtc[8] & 0x1f)); i++) { - q = &((uint32_t *)buffer32->line[i])[32]; - r = &((uint32_t *)buffer32->line[ysize + y_add + i])[32]; + q = &((uint32_t *)buffer32->line[i & 0x7ff])[32]; for (j = 0; j < (xsize + x_add_ex); j++) { q[j] = ega->pallook[ega->attrregs[0x11]]; - r[j] = ega->pallook[ega->attrregs[0x11]]; } } - for (i = y_add; i < (ysize + y_add); i ++) + /* Draw (overscan_size + scroll size) lines of overscan on the bottom. */ + for (i = 0; i < (y_add + (ega->crtc[8] & 0x1f)); i++) { - q = &((uint32_t *)buffer32->line[i])[32]; + q = &((uint32_t *)buffer32->line[(ysize + y_add + i - (ega->crtc[8] & 0x1f)) & 0x7ff])[32]; + + for (j = 0; j < (xsize + x_add_ex); j++) + { + q[j] = ega->pallook[ega->attrregs[0x11]]; + } + } + + for (i = (y_add - (ega->crtc[8] & 0x1f)); i < (ysize + y_add - (ega->crtc[8] & 0x1f)); i ++) + { + q = &((uint32_t *)buffer32->line[(i - (ega->crtc[8] & 0x1f)) & 0x7ff])[32]; for (j = 0; j < x_add; j++) { @@ -615,6 +646,22 @@ void ega_poll(void *p) } } } + else + { + if (ega->crtc[8] & 0x1f) + { + /* Draw (scroll size) lines of overscan on the bottom. */ + for (i = 0; i < (ega->crtc[8] & 0x1f); i++) + { + q = &((uint32_t *)buffer32->line[(ysize + i - (ega->crtc[8] & 0x1f)) & 0x7ff])[32]; + + for (j = 0; j < xsize; j++) + { + q[j] = ega->pallook[ega->attrregs[0x11]]; + } + } + } + } video_blit_memtoscreen(32, 0, ega->firstline, ega->lastline + y_add_ex, xsize + x_add_ex, ega->lastline - ega->firstline + y_add_ex); @@ -631,8 +678,7 @@ void ega_poll(void *p) else { if (ega->crtc[9] & 0x80) - ega->video_res_y /= 2; - if (!(ega->crtc[0x17] & 1)) + ega->video_res_y /= 2; if (!(ega->crtc[0x17] & 1)) ega->video_res_y *= 2; ega->video_res_y /= (ega->crtc[9] & 31) + 1; if (ega->seqregs[1] & 8) diff --git a/src/VIDEO/vid_s3.c b/src/VIDEO/vid_s3.c index ae5c8c701..de67496d7 100644 --- a/src/VIDEO/vid_s3.c +++ b/src/VIDEO/vid_s3.c @@ -407,11 +407,19 @@ static void s3_accel_out_fifo_w(s3_t *s3, uint16_t port, uint16_t val) if ((s3->accel.multifunc[0xa] & 0xc0) == 0x80) { if (s3->accel.cmd & 0x1000) - val = (val >> 8) | (val << 8); - s3_accel_start(16, 1, val | (val << 16), 0, s3); + val = (val >> 8) | (val << 8); + if ((s3->accel.cmd & 0x600) == 0x000) + s3_accel_start(8, 1, val | (val << 16), 0, s3); + else + s3_accel_start(16, 1, val | (val << 16), 0, s3); } else - s3_accel_start(2, 1, 0xffffffff, val | (val << 16), s3); + { + if ((s3->accel.cmd & 0x600) == 0x000) + s3_accel_start(1, 1, 0xffffffff, val | (val << 16), s3); + else + s3_accel_start(2, 1, 0xffffffff, val | (val << 16), s3); + } } } @@ -421,38 +429,40 @@ static void s3_accel_out_fifo_l(s3_t *s3, uint16_t port, uint32_t val) { if ((s3->accel.multifunc[0xa] & 0xc0) == 0x80) { - if (s3->accel.cmd & 0x1000) - val = ((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24); - if ((s3->accel.cmd & 0x600) == 0x400) + if (s3->accel.cmd & 0x400) + { + if (s3->accel.cmd & 0x1000) + val = ((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24); s3_accel_start(32, 1, val, 0, s3); + } else if ((s3->accel.cmd & 0x600) == 0x200) { - s3_accel_start(16, 1, val >> 16, 0, s3); + if (s3->accel.cmd & 0x1000) + val = ((val & 0xff00ff00) >> 8) | ((val & 0x00ff00ff) << 8); s3_accel_start(16, 1, val, 0, s3); + s3_accel_start(16, 1, val >> 16, 0, s3); } - else if (!(s3->accel.cmd & 0x600)) + else { - s3_accel_start(8, 1, val >> 24, 0, s3); + if (s3->accel.cmd & 0x1000) + val = ((val & 0xff00ff00) >> 8) | ((val & 0x00ff00ff) << 8); + s3_accel_start(8, 1, val, 0, s3); s3_accel_start(8, 1, val >> 16, 0, s3); - s3_accel_start(8, 1, val >> 8, 0, s3); - s3_accel_start(8, 1, val, 0, s3); } } else { - if ((s3->accel.cmd & 0x600) == 0x400) + if (s3->accel.cmd & 0x400) s3_accel_start(4, 1, 0xffffffff, val, s3); else if ((s3->accel.cmd & 0x600) == 0x200) { - s3_accel_start(2, 1, 0xffffffff, val >> 16, s3); s3_accel_start(2, 1, 0xffffffff, val, s3); + s3_accel_start(2, 1, 0xffffffff, val >> 16, s3); } - else if (!(s3->accel.cmd & 0x600)) + else { - s3_accel_start(1, 1, 0xffffffff, val >> 24, s3); - s3_accel_start(1, 1, 0xffffffff, val >> 16, s3); - s3_accel_start(1, 1, 0xffffffff, val >> 8, s3); s3_accel_start(1, 1, 0xffffffff, val, s3); + s3_accel_start(1, 1, 0xffffffff, val >> 16, s3); } } } @@ -565,78 +575,88 @@ static void s3_accel_write_fifo(s3_t *s3, uint32_t addr, uint8_t val) static void s3_accel_write_fifo_w(s3_t *s3, uint32_t addr, uint16_t val) { - if (addr & 0x8000) - { - s3_accel_write_fifo(s3, addr, val); - s3_accel_write_fifo(s3, addr + 1, val >> 8); - } - else - { - if (s3->accel.cmd & 0x100) - { - if ((s3->accel.multifunc[0xa] & 0xc0) == 0x80) - { - if (s3->accel.cmd & 0x1000) - val = (val >> 8) | (val << 8); - s3_accel_start(16, 1, val | (val << 16), 0, s3); - } - else - s3_accel_start(2, 1, 0xffffffff, val | (val << 16), s3); - } - } + if (addr & 0x8000) + { + s3_accel_write_fifo(s3, addr, val); + s3_accel_write_fifo(s3, addr + 1, val >> 8); + } + else + { + if (s3->accel.cmd & 0x100) + { + if ((s3->accel.multifunc[0xa] & 0xc0) == 0x80) + { + if (s3->accel.cmd & 0x1000) + val = (val >> 8) | (val << 8); + if ((s3->accel.cmd & 0x600) == 0x000) + s3_accel_start(8, 1, val | (val << 16), 0, s3); + else + s3_accel_start(16, 1, val | (val << 16), 0, s3); + } + else + { + if ((s3->accel.cmd & 0x600) == 0x000) + s3_accel_start(1, 1, 0xffffffff, val | (val << 16), s3); + else + s3_accel_start(2, 1, 0xffffffff, val | (val << 16), s3); + } + } + } } static void s3_accel_write_fifo_l(s3_t *s3, uint32_t addr, uint32_t val) { - if (addr & 0x8000) - { - s3_accel_write_fifo(s3, addr, val); - s3_accel_write_fifo(s3, addr + 1, val >> 8); - s3_accel_write_fifo(s3, addr + 2, val >> 16); - s3_accel_write_fifo(s3, addr + 3, val >> 24); - } - else - { - if (s3->accel.cmd & 0x100) - { - if ((s3->accel.multifunc[0xa] & 0xc0) == 0x80) - { - if (s3->accel.cmd & 0x1000) - val = ((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24); - if ((s3->accel.cmd & 0x600) == 0x400) - s3_accel_start(32, 1, val, 0, s3); - else if ((s3->accel.cmd & 0x600) == 0x200) - { - s3_accel_start(16, 1, val >> 16, 0, s3); - s3_accel_start(16, 1, val, 0, s3); - } - else if (!(s3->accel.cmd & 0x600)) - { - s3_accel_start(8, 1, val >> 24, 0, s3); - s3_accel_start(8, 1, val >> 16, 0, s3); - s3_accel_start(8, 1, val >> 8, 0, s3); - s3_accel_start(8, 1, val, 0, s3); - } - } - else - { - if ((s3->accel.cmd & 0x600) == 0x400) - s3_accel_start(4, 1, 0xffffffff, val, s3); - else if ((s3->accel.cmd & 0x600) == 0x200) - { - s3_accel_start(2, 1, 0xffffffff, val, s3); - s3_accel_start(2, 1, 0xffffffff, val >> 16, s3); - } - else if (!(s3->accel.cmd & 0x600)) - { - s3_accel_start(1, 1, 0xffffffff, val, s3); - s3_accel_start(1, 1, 0xffffffff, val >> 8, s3); - s3_accel_start(1, 1, 0xffffffff, val >> 16, s3); - s3_accel_start(1, 1, 0xffffffff, val >> 24, s3); - } - } - } - } + if (addr & 0x8000) + { + s3_accel_write_fifo(s3, addr, val); + s3_accel_write_fifo(s3, addr + 1, val >> 8); + s3_accel_write_fifo(s3, addr + 2, val >> 16); + s3_accel_write_fifo(s3, addr + 3, val >> 24); + } + else + { + if (s3->accel.cmd & 0x100) + { + if ((s3->accel.multifunc[0xa] & 0xc0) == 0x80) + { + if (s3->accel.cmd & 0x400) + { + if (s3->accel.cmd & 0x1000) + val = ((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24); + s3_accel_start(32, 1, val, 0, s3); + } + else if ((s3->accel.cmd & 0x600) == 0x200) + { + if (s3->accel.cmd & 0x1000) + val = ((val & 0xff00ff00) >> 8) | ((val & 0x00ff00ff) << 8); + s3_accel_start(16, 1, val, 0, s3); + s3_accel_start(16, 1, val >> 16, 0, s3); + } + else + { + if (s3->accel.cmd & 0x1000) + val = ((val & 0xff00ff00) >> 8) | ((val & 0x00ff00ff) << 8); + s3_accel_start(8, 1, val, 0, s3); + s3_accel_start(8, 1, val >> 16, 0, s3); + } + } + else + { + if (s3->accel.cmd & 0x400) + s3_accel_start(4, 1, 0xffffffff, val, s3); + else if ((s3->accel.cmd & 0x600) == 0x200) + { + s3_accel_start(2, 1, 0xffffffff, val, s3); + s3_accel_start(2, 1, 0xffffffff, val >> 16, s3); + } + else + { + s3_accel_start(1, 1, 0xffffffff, val, s3); + s3_accel_start(1, 1, 0xffffffff, val >> 16, s3); + } + } + } + } } static void fifo_thread(void *param) diff --git a/src/VIDEO/vid_svga.c b/src/VIDEO/vid_svga.c index 6da19608d..69c954bc9 100644 --- a/src/VIDEO/vid_svga.c +++ b/src/VIDEO/vid_svga.c @@ -542,6 +542,7 @@ void svga_recalctimings(svga_t *svga) { if (svga->seqregs[1] & 8) /*40 column*/ { +#if 0 if (svga->hdisp == 120) { svga->render = svga_render_text_40_12; @@ -549,12 +550,16 @@ void svga_recalctimings(svga_t *svga) } else { +#endif svga->render = svga_render_text_40; svga->hdisp *= (svga->seqregs[1] & 1) ? 16 : 18; +#if 0 } +#endif } else { +#if 0 if (svga->hdisp == 120) { svga->render = svga_render_text_80_12; @@ -562,9 +567,12 @@ void svga_recalctimings(svga_t *svga) } else { +#endif svga->render = svga_render_text_80; svga->hdisp *= (svga->seqregs[1] & 1) ? 8 : 9; +#if 0 } +#endif } svga->hdisp_old = svga->hdisp; } @@ -628,6 +636,16 @@ void svga_recalctimings(svga_t *svga) svga->linedbl = svga->crtc[9] & 0x80; svga->rowcount = svga->crtc[9] & 31; + overscan_y = (svga->rowcount + 1) << 1; + if (svga->seqregs[1] & 8) /*Low res (320)*/ + { + overscan_y <<= 1; + } + if (overscan_y < 16) + { + overscan_y = 16; + } + /* pclog("SVGA row count: %i (scroll: %i)\n", svga->rowcount, svga->crtc[8] & 0x1f); */ if (svga->recalctimings_ex) svga->recalctimings_ex(svga); @@ -1210,12 +1228,14 @@ void svga_write(uint32_t addr, uint8_t val, void *p) break; } +#if 0 if (svga->render == svga_render_text_80_12) { FILE *f = fopen("hecon.dmp", "wb"); fwrite(svga->vram, 1, svga->vram_limit, f); fclose(f); } +#endif } uint8_t svga_read(uint32_t addr, void *p) @@ -1555,9 +1575,9 @@ uint8_t svga_read_linear(uint32_t addr, void *p) void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) { - int y_add = (enable_overscan) ? 32 : 0; + int y_add = (enable_overscan) ? overscan_y : 0; int x_add = (enable_overscan) ? 16 : 0; - uint32_t *p, *q, i, j; + uint32_t *p, i, j; svga->frames++; @@ -1619,21 +1639,31 @@ void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) { if ((wx >= 160) && ((wy + 1) >= 120)) { - for (i = 0; i < (y_add >> 1); i++) + /* Draw (overscan_size - scroll size) lines of overscan on top. */ + for (i = 0; i < ((y_add >> 1) - (svga->crtc[8] & 0x1f)); i++) { - p = &((uint32_t *)buffer32->line[i])[32]; - q = &((uint32_t *)buffer32->line[ysize + (y_add >> 1) + i])[32]; + p = &((uint32_t *)buffer32->line[i & 0x7ff])[32]; for (j = 0; j < (xsize + x_add); j++) { p[j] = svga_color_transform(svga->pallook[svga->attrregs[0x11]]); - q[j] = svga_color_transform(svga->pallook[svga->attrregs[0x11]]); } } - for (i = (y_add >> 1); i < (ysize + (y_add >> 1)); i ++) + /* Draw (overscan_size + scroll size) lines of overscan on the bottom. */ + for (i = 0; i < ((y_add >> 1) + (svga->crtc[8] & 0x1f)); i++) { - p = &((uint32_t *)buffer32->line[i])[32]; + p = &((uint32_t *)buffer32->line[(ysize + (y_add >> 1) + i - (svga->crtc[8] & 0x1f)) & 0x7ff])[32]; + + for (j = 0; j < (xsize + x_add); j++) + { + p[j] = svga_color_transform(svga->pallook[svga->attrregs[0x11]]); + } + } + + for (i = ((y_add >> 1) - (svga->crtc[8] & 0x1f)); i < (ysize + (y_add >> 1) - (svga->crtc[8] & 0x1f)); i ++) + { + p = &((uint32_t *)buffer32->line[i & 0x7ff])[32]; for (j = 0; j < 8; j++) { @@ -1643,6 +1673,22 @@ void svga_doblit(int y1, int y2, int wx, int wy, svga_t *svga) } } } + else + { + if ((wx >= 160) && ((wy + 1) >= 120) && (svga->crtc[8] & 0x1f)) + { + /* Draw (scroll size) lines of overscan on the bottom. */ + for (i = 0; i < (svga->crtc[8] & 0x1f); i++) + { + p = &((uint32_t *)buffer32->line[(ysize + i - (svga->crtc[8] & 0x1f)) & 0x7ff])[32]; + + for (j = 0; j < xsize; j++) + { + p[j] = svga_color_transform(svga->pallook[svga->attrregs[0x11]]); + } + } + } + } video_blit_memtoscreen(32, 0, y1, y2 + y_add, xsize + x_add, ysize + y_add); } diff --git a/src/VIDEO/vid_svga_render.c b/src/VIDEO/vid_svga_render.c index fb8845a75..d51d6d249 100644 --- a/src/VIDEO/vid_svga_render.c +++ b/src/VIDEO/vid_svga_render.c @@ -28,11 +28,25 @@ uint32_t svga_color_transform(uint32_t color) return temp; } +int svga_display_line(svga_t *svga) +{ + int y_add = (enable_overscan) ? 16 : 0; + unsigned int dl = svga->displine; + if (svga->crtc[9] & 0x1f) + { + dl -= (svga->crtc[8] & 0x1f); + } + dl += y_add; + dl &= 0x7ff; + return dl; +} + void svga_render_blank(svga_t *svga) { int x, xx; int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -43,16 +57,16 @@ void svga_render_blank(svga_t *svga) 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] = svga_color_transform(0); + for (xx = 0; xx < 9; xx++) ((uint32_t *)buffer32->line[dl])[(x * 9) + xx + 32 + x_add] = svga_color_transform(0); break; case 1: - for (xx = 0; xx < 8; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 8) + xx + 32 + x_add] = svga_color_transform(0); + for (xx = 0; xx < 8; xx++) ((uint32_t *)buffer32->line[dl])[(x * 8) + xx + 32 + x_add] = svga_color_transform(0); break; case 8: - for (xx = 0; xx < 18; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 18) + xx + 32 + x_add] = svga_color_transform(0); + for (xx = 0; xx < 18; xx++) ((uint32_t *)buffer32->line[dl])[(x * 18) + xx + 32 + x_add] = svga_color_transform(0); break; case 9: - for (xx = 0; xx < 16; xx++) ((uint32_t *)buffer32->line[svga->displine + y_add])[(x * 16) + xx + 32 + x_add] = svga_color_transform(0); + for (xx = 0; xx < 16; xx++) ((uint32_t *)buffer32->line[dl])[(x * 16) + xx + 32 + x_add] = svga_color_transform(0); break; } } @@ -62,6 +76,7 @@ void svga_render_text_40(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -69,7 +84,7 @@ void svga_render_text_40(svga_t *svga) if (svga->fullchange) { - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[32 + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[32 + x_add]; int x, xx; int drawcursor; uint8_t chr, attr, dat; @@ -124,10 +139,12 @@ void svga_render_text_40(svga_t *svga) } } +#if 0 void svga_render_text_40_12(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = (enable_overscan) ? 12 : 0; + int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -135,7 +152,7 @@ void svga_render_text_40_12(svga_t *svga) if (svga->fullchange) { - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[32 + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[32 + x_add]; int x, xx; int drawcursor; uint8_t chr, attr; @@ -178,11 +195,13 @@ void svga_render_text_40_12(svga_t *svga) } } } +#endif void svga_render_text_80(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -190,7 +209,7 @@ void svga_render_text_80(svga_t *svga) if (svga->fullchange) { - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[32 + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[32 + x_add]; int x, xx; int drawcursor; uint8_t chr, attr, dat; @@ -245,10 +264,12 @@ void svga_render_text_80(svga_t *svga) } } +#if 0 void svga_render_text_80_12(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = (enable_overscan) ? 12 : 0; + int dl = svga_display_line(svga); if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -256,7 +277,7 @@ void svga_render_text_80_12(svga_t *svga) if (svga->fullchange) { - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[32 + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[32 + x_add]; int x, xx; int drawcursor; uint8_t chr, attr; @@ -300,12 +321,14 @@ void svga_render_text_80_12(svga_t *svga) } } } +#endif void svga_render_2bpp_lowres(svga_t *svga) { int changed_offset; int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->sc & 1 && !(svga->crtc[0x17] & 1)) changed_offset = (svga->ma << 1) >> 12; @@ -316,7 +339,7 @@ void svga_render_2bpp_lowres(svga_t *svga) { int x; int offset = ((8 - svga->scrollcache) << 1) + 16; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -358,7 +381,8 @@ void svga_render_2bpp_highres(svga_t *svga) int changed_offset; int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; - + int dl = svga_display_line(svga); + if (svga->sc & 1 && !(svga->crtc[0x17] & 1)) changed_offset = ((svga->ma << 1) | 0x8000) >> 12; else @@ -368,7 +392,7 @@ void svga_render_2bpp_highres(svga_t *svga) { int x; int offset = (8 - svga->scrollcache) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -409,12 +433,13 @@ void svga_render_4bpp_lowres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[(svga->ma >> 12) + 1] || svga->fullchange) { int x; int offset = ((8 - svga->scrollcache) << 1) + 16; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -453,6 +478,7 @@ void svga_render_4bpp_highres(svga_t *svga) int changed_offset2; int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->sc & 1 && !(svga->crtc[0x17] & 1)) changed_offset = svga_mask_addr(svga->ma | 0x8000, svga) >> 12; @@ -468,7 +494,7 @@ void svga_render_4bpp_highres(svga_t *svga) { int x; int offset = (8 - svga->scrollcache) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -508,12 +534,13 @@ void svga_render_8bpp_lowres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { int x; int offset = (8 - (svga->scrollcache & 6)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -539,12 +566,13 @@ void svga_render_8bpp_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { int x; int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -576,12 +604,13 @@ void svga_render_15bpp_lowres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { int x; int offset = (8 - (svga->scrollcache & 6)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -608,12 +637,13 @@ void svga_render_15bpp_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { int x; int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -646,12 +676,13 @@ void svga_render_16bpp_lowres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { int x; int offset = (8 - (svga->scrollcache & 6)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -678,12 +709,13 @@ void svga_render_16bpp_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { int x; int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -718,6 +750,7 @@ void svga_render_24bpp_lowres(svga_t *svga) uint32_t fg; int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { @@ -732,7 +765,7 @@ void svga_render_24bpp_lowres(svga_t *svga) fg = svga->vram[svga->ma] | (svga->vram[svga_mask_addr(svga->ma + 1, svga)] << 8) | (svga->vram[svga_mask_addr(svga->ma + 2, svga)] << 16); svga->ma += 3; svga->ma = svga_mask_addr(svga->ma, svga); - ((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] = svga_color_transform(fg); + ((uint32_t *)buffer32->line[dl])[(x << 1) + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 1) + 1 + offset + x_add] = svga_color_transform(fg); } } } @@ -741,12 +774,13 @@ void svga_render_24bpp_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { int x; int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -778,6 +812,7 @@ void svga_render_32bpp_lowres(svga_t *svga) uint32_t fg; int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->fullchange) { @@ -792,7 +827,7 @@ void svga_render_32bpp_lowres(svga_t *svga) fg = svga->vram[svga->ma] | (svga->vram[svga_mask_addr(svga->ma + 1, svga)] << 8) | (svga->vram[svga_mask_addr(svga->ma + 2, svga)] << 16); svga->ma += 4; svga->ma = svga_mask_addr(svga->ma, svga); - ((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] = svga_color_transform(fg); + ((uint32_t *)buffer32->line[dl])[(x << 1) + offset + x_add] = ((uint32_t *)buffer32->line[dl])[(x << 1) + 1 + offset + x_add] = svga_color_transform(fg); } } } @@ -803,12 +838,13 @@ void svga_render_32bpp_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) { int x; int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -828,12 +864,13 @@ void svga_render_ABGR8888_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) { int x; int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; @@ -853,12 +890,13 @@ void svga_render_RGBA8888_highres(svga_t *svga) { int y_add = (enable_overscan) ? 16 : 0; int x_add = y_add >> 1; + int dl = svga_display_line(svga); if (svga->changedvram[svga->ma >> 12] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 1, svga)] || svga->changedvram[svga_mask_changedaddr((svga->ma >> 12) + 2, svga)] || svga->fullchange) { int x; int offset = (8 - ((svga->scrollcache & 6) >> 1)) + 24; - uint32_t *p = &((uint32_t *)buffer32->line[svga->displine + y_add])[offset + x_add]; + uint32_t *p = &((uint32_t *)buffer32->line[dl])[offset + x_add]; if (svga->firstline_draw == 2000) svga->firstline_draw = svga->displine; diff --git a/src/WIN/86Box.rc b/src/WIN/86Box.rc index fb5d56296..a593212e4 100644 --- a/src/WIN/86Box.rc +++ b/src/WIN/86Box.rc @@ -61,7 +61,7 @@ BEGIN MENUITEM "&Mute", IDM_CDROM_1_MUTE MENUITEM SEPARATOR MENUITEM "E&mpty", IDM_CDROM_1_EMPTY - MENUITEM "&Reload previous disc", IDM_CDROM_1_RELOAD + MENUITEM "&Reload previous image", IDM_CDROM_1_RELOAD MENUITEM SEPARATOR MENUITEM "&Image...", IDM_CDROM_1_IMAGE END @@ -70,7 +70,7 @@ BEGIN MENUITEM "&Mute", IDM_CDROM_2_MUTE MENUITEM SEPARATOR MENUITEM "E&mpty", IDM_CDROM_2_EMPTY - MENUITEM "&Reload previous disc", IDM_CDROM_2_RELOAD + MENUITEM "&Reload previous image", IDM_CDROM_2_RELOAD MENUITEM SEPARATOR MENUITEM "&Image...", IDM_CDROM_2_IMAGE END @@ -79,7 +79,7 @@ BEGIN MENUITEM "&Mute", IDM_CDROM_3_MUTE MENUITEM SEPARATOR MENUITEM "E&mpty", IDM_CDROM_3_EMPTY - MENUITEM "&Reload previous disc", IDM_CDROM_3_RELOAD + MENUITEM "&Reload previous image", IDM_CDROM_3_RELOAD MENUITEM SEPARATOR MENUITEM "&Image...", IDM_CDROM_3_IMAGE END @@ -88,10 +88,138 @@ BEGIN MENUITEM "&Mute", IDM_CDROM_4_MUTE MENUITEM SEPARATOR MENUITEM "E&mpty", IDM_CDROM_4_EMPTY - MENUITEM "&Reload previous disc", IDM_CDROM_4_RELOAD + MENUITEM "&Reload previous image", IDM_CDROM_4_RELOAD MENUITEM SEPARATOR MENUITEM "&Image...", IDM_CDROM_4_IMAGE END + POPUP "Removable disk 01" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_01_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_01_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_01_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_01_EIMAGE + END + POPUP "Removable disk 02" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_02_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_02_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_02_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_02_EIMAGE + END + POPUP "Removable disk 03" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_03_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_03_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_03_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_03_EIMAGE + END + POPUP "Removable disk 04" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_04_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_04_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_04_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_04_EIMAGE + END + POPUP "Removable disk 05" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_05_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_05_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_05_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_05_EIMAGE + END + POPUP "Removable disk 06" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_06_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_06_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_06_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_06_EIMAGE + END + POPUP "Removable disk 07" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_07_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_07_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_07_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_07_EIMAGE + END + POPUP "Removable disk 08" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_08_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_08_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_08_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_08_EIMAGE + END + POPUP "Removable disk 09" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_09_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_09_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_09_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_09_EIMAGE + END + POPUP "Removable disk 10" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_10_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_10_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_10_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_10_EIMAGE + END + POPUP "Removable disk 11" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_11_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_11_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_11_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_11_EIMAGE + END + POPUP "Removable disk 12" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_12_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_12_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_12_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_12_EIMAGE + END + POPUP "Removable disk 13" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_13_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_13_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_13_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_13_EIMAGE + END + POPUP "Removable disk 14" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_14_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_14_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_14_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_14_EIMAGE + END + POPUP "Removable disk 15" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_15_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_15_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_15_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_15_EIMAGE + END + POPUP "Removable disk 16" + BEGIN + MENUITEM "E&mpty", IDM_RDISK_16_EMPTY + MENUITEM "&Reload previous image", IDM_RDISK_16_RELOAD + MENUITEM SEPARATOR + MENUITEM "&New image...", IDM_RDISK_16_IMAGE + MENUITEM "&Existing image...", IDM_RDISK_16_EIMAGE + END END MAINMENU MENU DISCARDABLE @@ -536,14 +664,14 @@ END 163 ICON DISCARDABLE "ICONS/cdrom_atapi_dma_active.ico" 164 ICON DISCARDABLE "ICONS/cdrom_scsi.ico" 165 ICON DISCARDABLE "ICONS/cdrom_scsi_active.ico" -176 ICON DISCARDABLE "ICONS/hard_disk_mfm.ico" -177 ICON DISCARDABLE "ICONS/hard_disk_mfm_active.ico" -178 ICON DISCARDABLE "ICONS/hard_disk.ico" -179 ICON DISCARDABLE "ICONS/hard_disk_active.ico" -180 ICON DISCARDABLE "ICONS/hard_disk_ide.ico" -181 ICON DISCARDABLE "ICONS/hard_disk_ide_active.ico" -182 ICON DISCARDABLE "ICONS/hard_disk_scsi.ico" -183 ICON DISCARDABLE "ICONS/hard_disk_scsi_active.ico" +192 ICON DISCARDABLE "ICONS/hard_disk_mfm.ico" +193 ICON DISCARDABLE "ICONS/hard_disk_mfm_active.ico" +194 ICON DISCARDABLE "ICONS/hard_disk.ico" +195 ICON DISCARDABLE "ICONS/hard_disk_active.ico" +196 ICON DISCARDABLE "ICONS/hard_disk_ide.ico" +197 ICON DISCARDABLE "ICONS/hard_disk_ide_active.ico" +198 ICON DISCARDABLE "ICONS/hard_disk_scsi.ico" +199 ICON DISCARDABLE "ICONS/hard_disk_scsi_active.ico" 256 ICON DISCARDABLE "ICONS/machine.ico" 257 ICON DISCARDABLE "ICONS/video.ico" 258 ICON DISCARDABLE "ICONS/input_devices.ico" diff --git a/src/WIN/resource.h b/src/WIN/resource.h index 5364bf674..d70d84a2d 100644 --- a/src/WIN/resource.h +++ b/src/WIN/resource.h @@ -180,6 +180,71 @@ #define IDM_CDROM_4_EMPTY 40179 #define IDM_CDROM_4_REAL 40195 +#define IDM_RDISK_01_IMAGE 3200 +#define IDM_RDISK_01_EIMAGE 3216 +#define IDM_RDISK_01_RELOAD 3232 +#define IDM_RDISK_01_EMPTY 3248 +#define IDM_RDISK_02_IMAGE 3201 +#define IDM_RDISK_02_EIMAGE 3217 +#define IDM_RDISK_02_RELOAD 3233 +#define IDM_RDISK_02_EMPTY 3249 +#define IDM_RDISK_03_IMAGE 3202 +#define IDM_RDISK_03_EIMAGE 3218 +#define IDM_RDISK_03_RELOAD 3234 +#define IDM_RDISK_03_EMPTY 3250 +#define IDM_RDISK_04_IMAGE 3203 +#define IDM_RDISK_04_EIMAGE 3219 +#define IDM_RDISK_04_RELOAD 3235 +#define IDM_RDISK_04_EMPTY 3251 +#define IDM_RDISK_05_IMAGE 3204 +#define IDM_RDISK_05_EIMAGE 3220 +#define IDM_RDISK_05_RELOAD 3236 +#define IDM_RDISK_05_EMPTY 3252 +#define IDM_RDISK_06_IMAGE 3205 +#define IDM_RDISK_06_EIMAGE 3221 +#define IDM_RDISK_06_RELOAD 3237 +#define IDM_RDISK_06_EMPTY 3253 +#define IDM_RDISK_07_IMAGE 3206 +#define IDM_RDISK_07_EIMAGE 3222 +#define IDM_RDISK_07_RELOAD 3238 +#define IDM_RDISK_07_EMPTY 3254 +#define IDM_RDISK_08_IMAGE 3207 +#define IDM_RDISK_08_EIMAGE 3223 +#define IDM_RDISK_08_RELOAD 3239 +#define IDM_RDISK_08_EMPTY 3255 +#define IDM_RDISK_09_IMAGE 3208 +#define IDM_RDISK_09_EIMAGE 3224 +#define IDM_RDISK_09_RELOAD 3240 +#define IDM_RDISK_09_EMPTY 3256 +#define IDM_RDISK_10_IMAGE 3209 +#define IDM_RDISK_10_EIMAGE 3225 +#define IDM_RDISK_10_RELOAD 3241 +#define IDM_RDISK_10_EMPTY 3257 +#define IDM_RDISK_11_IMAGE 3210 +#define IDM_RDISK_11_EIMAGE 3226 +#define IDM_RDISK_11_RELOAD 3242 +#define IDM_RDISK_11_EMPTY 3258 +#define IDM_RDISK_12_IMAGE 3211 +#define IDM_RDISK_12_EIMAGE 3227 +#define IDM_RDISK_12_RELOAD 3243 +#define IDM_RDISK_12_EMPTY 3259 +#define IDM_RDISK_13_IMAGE 3212 +#define IDM_RDISK_13_EIMAGE 3228 +#define IDM_RDISK_13_RELOAD 3244 +#define IDM_RDISK_13_EMPTY 3260 +#define IDM_RDISK_14_IMAGE 3213 +#define IDM_RDISK_14_EIMAGE 3229 +#define IDM_RDISK_14_RELOAD 3245 +#define IDM_RDISK_14_EMPTY 3261 +#define IDM_RDISK_15_IMAGE 3214 +#define IDM_RDISK_15_EIMAGE 3230 +#define IDM_RDISK_15_RELOAD 3246 +#define IDM_RDISK_15_EMPTY 3262 +#define IDM_RDISK_16_IMAGE 3215 +#define IDM_RDISK_16_EIMAGE 3231 +#define IDM_RDISK_16_RELOAD 3247 +#define IDM_RDISK_16_EMPTY 3263 + #define IDM_IDE_TER_ENABLED 44000 #define IDM_IDE_TER_IRQ9 44009 #define IDM_IDE_TER_IRQ10 44010 diff --git a/src/WIN/win.c b/src/WIN/win.c index a56660e20..010b67f61 100644 --- a/src/WIN/win.c +++ b/src/WIN/win.c @@ -107,7 +107,7 @@ LRESULT CALLBACK subWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); -LONG OriginalStatusBarProcedure; +LONG_PTR OriginalStatusBarProcedure; HWND ghwnd; @@ -696,7 +696,7 @@ void update_status_bar_icon(int tag, int active) int found = -1; int temp_flags = 0; - if ((tag & 0xf0) >= 0x30) + if ((tag & 0xf0) >= 0x40) { return; } @@ -833,7 +833,7 @@ void update_tip(int meaning) if (part != -1) { - switch(meaning & 0x30) + switch(meaning & 0xf0) { case 0x00: create_floppy_tip(part); @@ -841,7 +841,12 @@ void update_tip(int meaning) case 0x10: create_cdrom_tip(part); break; +#if 0 case 0x20: + create_removable_hd_tip(part); + break; +#endif + case 0x30: create_hd_tip(part); break; default: @@ -883,7 +888,7 @@ void status_settextw(wchar_t *wstr) for (i = 0; i < sb_parts; i++) { - if (sb_part_meanings[i] == 0x30) + if (sb_part_meanings[i] == 0x40) { part = i; } @@ -949,32 +954,44 @@ void update_status_bar_panes(HWND hwnds) sb_parts++; } } +#if 0 + for (i = 0; i < 16; i++) + { + if (hdc[i].bus == 5) + { + edge += sb_icon_width; + iStatusWidths[sb_parts] = edge; + sb_part_meanings[sb_parts] = 0x20 | i; + sb_parts++; + } + } +#endif if (c_mfm && !(models[model].flags & MODEL_HAS_IDE) && !!memcmp(hdd_controller_name, "none", 4) && !!memcmp(hdd_controller_name, "xtide", 5)) { edge += sb_icon_width; iStatusWidths[sb_parts] = edge; - sb_part_meanings[sb_parts] = 0x20; + sb_part_meanings[sb_parts] = 0x30; sb_parts++; } if (c_ide_pio && ((models[model].flags & MODEL_HAS_IDE) || !memcmp(hdd_controller_name, "xtide", 5))) { edge += sb_icon_width; iStatusWidths[sb_parts] = edge; - sb_part_meanings[sb_parts] = 0x21; + sb_part_meanings[sb_parts] = 0x31; sb_parts++; } if (c_ide_dma && ((models[model].flags & MODEL_HAS_IDE) || !memcmp(hdd_controller_name, "xtide", 5))) { edge += sb_icon_width; iStatusWidths[sb_parts] = edge; - sb_part_meanings[sb_parts] = 0x22; + sb_part_meanings[sb_parts] = 0x32; sb_parts++; } if (c_scsi) { edge += sb_icon_width; iStatusWidths[sb_parts] = edge; - sb_part_meanings[sb_parts] = 0x23; + sb_part_meanings[sb_parts] = 0x33; sb_parts++; } if (sb_parts) @@ -982,14 +999,14 @@ void update_status_bar_panes(HWND hwnds) iStatusWidths[sb_parts - 1] += (24 - sb_icon_width); } iStatusWidths[sb_parts] = -1; - sb_part_meanings[sb_parts] = 0x30; + sb_part_meanings[sb_parts] = 0x40; sb_parts++; SendMessage(hwnds, SB_SETPARTS, (WPARAM) sb_parts, (LPARAM) iStatusWidths); for (i = 0; i < sb_parts; i++) { - switch (sb_part_meanings[i] & 0x30) + switch (sb_part_meanings[i] & 0xf0) { case 0x00: /* Floppy */ @@ -1030,12 +1047,20 @@ void update_status_bar_panes(HWND hwnds) sb_part_icons[i] = j | sb_icon_flags[i]; create_cdrom_tip(i); break; +#if 0 case 0x20: + /* Removable hard disk */ + sb_icon_flags[i] = (wcslen(discfns[sb_part_meanings[i] & 0xf]) == 0) ? 256 : 0; + sb_part_icons[i] = 176 + sb_icon_flags[i]; + create_floppy_tip(i); + break; +#endif + case 0x30: /* Hard disk */ - sb_part_icons[i] = 176 + ((sb_part_meanings[i] & 0xf) << 1); + sb_part_icons[i] = 192 + ((sb_part_meanings[i] & 0xf) << 1); create_hd_tip(i); break; - case 0x30: + case 0x40: /* Status text */ SendMessage(hwnds, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM) L"Welcome to Unicode 86Box! :p"); sb_part_icons[i] = -1; @@ -1082,7 +1107,14 @@ HWND EmulatorStatusBar(HWND hwndParent, int idStatus, HINSTANCE hinst) hIcon[i] = LoadIconEx((PCTSTR) i); } - for (i = 176; i < 184; i++) +#if 0 + for (i = 176; i < 178; i++) + { + hIcon[i] = LoadIconEx((PCTSTR) i); + } +#endif + + for (i = 192; i < 200; i++) { hIcon[i] = LoadIconEx((PCTSTR) i); } @@ -1107,6 +1139,13 @@ HWND EmulatorStatusBar(HWND hwndParent, int idStatus, HINSTANCE hinst) hIcon[i] = LoadIconEx((PCTSTR) i); } +#if 0 + for (i = 432; i < 434; i++) + { + hIcon[i] = LoadIconEx((PCTSTR) i); + } +#endif + GetWindowRect(hwndParent, &rectDialog); dw = rectDialog.right - rectDialog.left; dh = rectDialog.bottom - rectDialog.top; @@ -1255,8 +1294,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance, hwndStatus = EmulatorStatusBar(hwnd, IDC_STATUS, hThisInstance); - OriginalStatusBarProcedure = GetWindowLong(hwndStatus, GWL_WNDPROC); - SetWindowLong(hwndStatus, GWL_WNDPROC, (LONG) &StatusBarProcedure); + OriginalStatusBarProcedure = GetWindowLongPtr(hwndStatus, GWLP_WNDPROC); + SetWindowLongPtr(hwndStatus, GWL_WNDPROC, (LONG_PTR) &StatusBarProcedure); smenu = LoadMenu(hThisInstance, TEXT("StatusBarMenu")); initmenu(); @@ -1273,10 +1312,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance, } } - if (vid_resize) SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW|WS_VISIBLE); - else SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX)|WS_VISIBLE); - - SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX); + if (vid_resize) SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_MINIMIZEBOX)|WS_VISIBLE); + else SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX&~WS_MINIMIZEBOX)|WS_VISIBLE); /* Note by Kiririn: I've redone this since the CD-ROM can be disabled but still have something inside it. */ for (e = 0; e < CDROM_NUM; e++) @@ -1754,9 +1791,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDM_VID_RESIZE: vid_resize=!vid_resize; CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize)?MF_CHECKED:MF_UNCHECKED); - if (vid_resize) SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW|WS_VISIBLE); - else SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX)|WS_VISIBLE); - SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX); + if (vid_resize) SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_MINIMIZEBOX)|WS_VISIBLE); + else SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX&~WS_MINIMIZEBOX)|WS_VISIBLE); GetWindowRect(hwnd,&rect); SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED); GetWindowRect(hwndStatus,&rect); @@ -2195,14 +2231,20 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, int id) pt.x = id * sb_icon_width; /* Justify to the left. */ pt.y = 0; /* Justify to the top. */ ClientToScreen(hwnd, (LPPOINT) &pt); - if ((sb_part_meanings[id] & 0x30) == 0x00) + if ((sb_part_meanings[id] & 0xf0) == 0x00) { menu_id = sb_part_meanings[id] & 0xf; } - else if ((sb_part_meanings[id] & 0x30) == 0x10) + else if ((sb_part_meanings[id] & 0xf0) == 0x10) { menu_id = (sb_part_meanings[id] & 0xf) + 4; } +#if 0 + else if ((sb_part_meanings[id] & 0xf0) == 0x20) + { + menu_id = (sb_part_meanings[id] & 0xf) + 8; + } +#endif if (menu_id != -1) { pmenu = GetSubMenu(smenu, menu_id); diff --git a/src/WIN/win.h b/src/WIN/win.h index 0e09db88f..ffe8fea2f 100644 --- a/src/WIN/win.h +++ b/src/WIN/win.h @@ -49,3 +49,5 @@ void update_status_bar_panes(HWND hwnds); int fdd_type_to_icon(int type); extern HWND hwndStatus; + +void hard_disk_add_open(HWND hwnd, int is_existing); diff --git a/src/WIN/win_midi.c b/src/WIN/win_midi.c index 2fdf58bec..5ce523a0a 100644 --- a/src/WIN/win_midi.c +++ b/src/WIN/win_midi.c @@ -7,7 +7,7 @@ #include "../config.h" #include "plat_midi.h" -int midi_id; +int midi_id = 0; static HMIDIOUT midi_out_device = NULL; HANDLE m_event; @@ -57,8 +57,6 @@ void midi_init() midi_sysex_start = midi_sysex_delay = 0; - midi_id = config_get_int(NULL, "midi", 0); - m_event = CreateEvent(NULL, TRUE, TRUE, NULL); hr = midiOutOpen(&midi_out_device, midi_id, (DWORD) m_event, diff --git a/src/WIN/win_settings.c b/src/WIN/win_settings.c index 6916bca28..db4f7da46 100644 --- a/src/WIN/win_settings.c +++ b/src/WIN/win_settings.c @@ -39,40 +39,40 @@ /* Machine category */ -int temp_model, temp_cpu_m, temp_cpu, temp_wait_states, temp_mem_size, temp_dynarec, temp_fpu, temp_sync; +static int temp_model, temp_cpu_m, temp_cpu, temp_wait_states, temp_mem_size, temp_dynarec, temp_fpu, temp_sync; /* Video category */ -int temp_gfxcard, temp_video_speed, temp_voodoo; +static int temp_gfxcard, temp_video_speed, temp_voodoo; /* Input devices category */ -int temp_mouse, temp_joystick; +static int temp_mouse, temp_joystick; /* Sound category */ -int temp_sound_card, temp_midi_id, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type; +static int temp_sound_card, temp_midi_id, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type; /* Network category */ -int temp_net_type, temp_net_card; -char temp_pcap_dev[520]; +static int temp_net_type, temp_net_card; +static char temp_pcap_dev[520]; /* Peripherals category */ -int temp_scsi_card, hdc_ignore, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq; -int temp_serial[2], temp_lpt, temp_bugger; +static int temp_scsi_card, hdc_ignore, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq; +static int temp_serial[2], temp_lpt, temp_bugger; -char temp_hdc_name[16]; +static char temp_hdc_name[16]; /* Hard disks category */ -hard_disk_t temp_hdc[HDC_NUM]; -wchar_t temp_hdd_fn[HDC_NUM][512]; +static hard_disk_t temp_hdc[HDC_NUM]; +static wchar_t temp_hdd_fn[HDC_NUM][512]; /* Removable devices category */ -int temp_fdd_types[FDD_NUM]; -cdrom_drive_t temp_cdrom_drives[CDROM_NUM]; +static int temp_fdd_types[FDD_NUM]; +static cdrom_drive_t temp_cdrom_drives[CDROM_NUM]; static HWND hwndParentDialog, hwndChildDialog; int hdd_controller_current; -int displayed_category = 0; +static int displayed_category = 0; extern int is486; static int romstolist[ROM_MAX], listtomodel[ROM_MAX], romstomodel[ROM_MAX], modeltolist[ROM_MAX]; @@ -2219,6 +2219,8 @@ uint64_t selection = 127; uint64_t spt, hpc, tracks, size; wchar_t hd_file_name[512]; +static hard_disk_t *hdc_ptr; + static int hdconf_initialize_hdt_combo(HWND hdlg) { HWND h; @@ -2287,19 +2289,26 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W case WM_INITDIALOG: memset(hd_file_name, 0, 512); - SetWindowText(hdlg, win_language_get_string_from_id(existing ? 2197 : 2196)); + hdc_ptr = (existing & 2) ? hdc : temp_hdc; + + if (existing & 2) + { + next_free_id = (existing & 0xf0) >> 4; + } + + SetWindowText(hdlg, win_language_get_string_from_id((existing & 1) ? 2197 : 2196)); no_update = 1; - spt = existing ? 0 : 17; + spt = (existing & 1) ? 0 : 17; set_edit_box_contents(hdlg, IDC_EDIT_HD_SPT, spt); - hpc = existing ? 0 : 15; + hpc = (existing & 1) ? 0 : 15; set_edit_box_contents(hdlg, IDC_EDIT_HD_HPC, hpc); - tracks = existing ? 0 : 1023; + tracks = (existing & 1) ? 0 : 1023; set_edit_box_contents(hdlg, IDC_EDIT_HD_CYL, tracks); size = (tracks * hpc * spt) << 9; set_edit_box_contents(hdlg, IDC_EDIT_HD_SIZE, size >> 20); hdconf_initialize_hdt_combo(hdlg); - if (existing) + if (existing & 1) { h = GetDlgItem(hdlg, IDC_EDIT_HD_SPT); EnableWindow(h, FALSE); @@ -2339,25 +2348,44 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W return TRUE; } - get_edit_box_contents(hdlg, IDC_EDIT_HD_SPT, &(temp_hdc[next_free_id].spt)); - get_edit_box_contents(hdlg, IDC_EDIT_HD_HPC, &(temp_hdc[next_free_id].hpc)); - get_edit_box_contents(hdlg, IDC_EDIT_HD_CYL, &(temp_hdc[next_free_id].tracks)); + get_edit_box_contents(hdlg, IDC_EDIT_HD_SPT, &(hdc_ptr[next_free_id].spt)); + get_edit_box_contents(hdlg, IDC_EDIT_HD_HPC, &(hdc_ptr[next_free_id].hpc)); + get_edit_box_contents(hdlg, IDC_EDIT_HD_CYL, &(hdc_ptr[next_free_id].tracks)); + spt = hdc_ptr[next_free_id].spt; + hpc = hdc_ptr[next_free_id].hpc; + tracks = hdc_ptr[next_free_id].tracks; h = GetDlgItem(hdlg, IDC_COMBO_HD_BUS); - temp_hdc[next_free_id].bus = SendMessage(h, CB_GETCURSEL, 0, 0) + 1; + hdc_ptr[next_free_id].bus = SendMessage(h, CB_GETCURSEL, 0, 0) + 1; h = GetDlgItem(hdlg, IDC_COMBO_HD_CHANNEL); - temp_hdc[next_free_id].mfm_channel = SendMessage(h, CB_GETCURSEL, 0, 0); + hdc_ptr[next_free_id].mfm_channel = SendMessage(h, CB_GETCURSEL, 0, 0); h = GetDlgItem(hdlg, IDC_COMBO_HD_ID); - temp_hdc[next_free_id].scsi_id = SendMessage(h, CB_GETCURSEL, 0, 0); + hdc_ptr[next_free_id].scsi_id = SendMessage(h, CB_GETCURSEL, 0, 0); h = GetDlgItem(hdlg, IDC_COMBO_HD_LUN); - temp_hdc[next_free_id].scsi_lun = SendMessage(h, CB_GETCURSEL, 0, 0); + hdc_ptr[next_free_id].scsi_lun = SendMessage(h, CB_GETCURSEL, 0, 0); h = GetDlgItem(hdlg, IDC_COMBO_HD_CHANNEL_IDE); - temp_hdc[next_free_id].ide_channel = SendMessage(h, CB_GETCURSEL, 0, 0); - memset(temp_hdd_fn[next_free_id], 0, 1024); - memcpy(temp_hdd_fn[next_free_id], hd_file_name, (wcslen(hd_file_name) << 1) + 2); + hdc_ptr[next_free_id].ide_channel = SendMessage(h, CB_GETCURSEL, 0, 0); + if (existing & 2) + { +#if 0 + if (hdc[next_free_id].bus == 5) + { + memset(prev_hdd_fn[next_free_id], 0, 1024); + memcpy(prev_hdd_fn[next_free_id], hdd_fn[next_free_id], (wcslen(hdd_fn[next_free_id]) << 1) + 2); + } +#endif + + memset(hdd_fn[next_free_id], 0, 1024); + memcpy(hdd_fn[next_free_id], hd_file_name, (wcslen(hd_file_name) << 1) + 2); + } + else + { + memset(temp_hdd_fn[next_free_id], 0, 1024); + memcpy(temp_hdd_fn[next_free_id], hd_file_name, (wcslen(hd_file_name) << 1) + 2); + } sector_size = 512; - if (!existing && (wcslen(hd_file_name) > 0)) + if (!(existing & 1) && (wcslen(hd_file_name) > 0)) { f = _wfopen(hd_file_name, L"wb"); @@ -2414,6 +2442,14 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W msgbox_info(hwndParentDialog, 2059); } +#if 0 + if ((existing & 2) && (hdc[next_free_id].bus == 5)) + { + scsi_hd_insert(id); + update_status_bar_icon_state(0x20 | next_free_id, 0); + } +#endif + hard_disk_added = 1; EndDialog(hdlg, 0); return TRUE; @@ -2424,7 +2460,7 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W return TRUE; case IDC_CFILE: - if (!file_dlg_w(hdlg, win_language_get_string_from_id(2172), L"", !existing)) + if (!file_dlg_w(hdlg, win_language_get_string_from_id(2172), L"", !(existing & 1))) { if (!existing) { @@ -2439,13 +2475,13 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W } } - f = _wfopen(wopenfilestring, existing ? L"rb" : L"wb"); + f = _wfopen(wopenfilestring, (existing & 1) ? L"rb" : L"wb"); if (f == NULL) { - msgbox_error(hwndParentDialog, existing ? 2060 : 2057); + msgbox_error(hwndParentDialog, (existing & 1) ? 2060 : 2057); return TRUE; } - if (existing) + if (existing & 1) { if (image_is_hdi(wopenfilestring) || image_is_hdx(wopenfilestring, 1)) { @@ -2672,7 +2708,7 @@ void hard_disk_add_open(HWND hwnd, int is_existing) { BOOL ret; - existing = !!is_existing; + existing = is_existing; hard_disk_added = 0; ret = DialogBox(hinstance, (LPCWSTR) CONFIGUREDLG_HARD_DISKS_ADD, hwnd, win_settings_hard_disks_add_proc); } @@ -3355,7 +3391,7 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); if (temp_cdrom_drives[cdlv_current_sel].bus_type > 1) { - SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[cdlv_current_sel].bus_type, 0); + SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[cdlv_current_sel].bus_type - 1, 0); } else { @@ -3413,7 +3449,7 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); if (temp_cdrom_drives[cdlv_current_sel].bus_type > 1) { - SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[cdlv_current_sel].bus_type, 0); + SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[cdlv_current_sel].bus_type - 1, 0); } else { diff --git a/src/cdrom.c b/src/cdrom.c index 60ad3afe5..6540846ba 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -2920,7 +2920,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) max_len |= cdb[8]; msf = (cdb[1] >> 1) & 1; - cdrom_log("CD-ROM %i: Getting page %i\n", id, cdb[3]); + cdrom_log("CD-ROM %i: Getting page %i (%s)\n", id, cdb[3], msf ? "MSF" : "LBA"); if ((cdrom_drives[id].handler->pass_through) && (cdb[3] != 1)) { ret = cdrom_pass_through(id, &len, cdrom[id].current_cdb, cdbufferb); @@ -3100,7 +3100,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) break; case GPCMD_START_STOP_UNIT: - switch(cdbufferb[4] & 3) + switch(cdb[4] & 3) { case 0: /* Stop the disc. */ if (cdrom_drives[id].handler->stop) diff --git a/src/cdrom_dosbox.cpp b/src/cdrom_dosbox.cpp index e076fb9b1..53223a775 100644 --- a/src/cdrom_dosbox.cpp +++ b/src/cdrom_dosbox.cpp @@ -125,7 +125,9 @@ bool CDROM_Interface_Image::GetAudioSub(int sector, unsigned char& attr, unsigne attr = tracks[track - 1].attr; index = 1; FRAMES_TO_MSF(sector + 150, &absPos.min, &absPos.sec, &absPos.fr); - FRAMES_TO_MSF(sector - tracks[track - 1].start + 150, &relPos.min, &relPos.sec, &relPos.fr); + /* FRAMES_TO_MSF(sector - tracks[track - 1].start + 150, &relPos.min, &relPos.sec, &relPos.fr); */ + /* Note by Kotori: Yes, the absolute position should be adjusted by 150, but not the relative position. */ + FRAMES_TO_MSF(sector - tracks[track - 1].start, &relPos.min, &relPos.sec, &relPos.fr); return true; } diff --git a/src/cdrom_image.cc b/src/cdrom_image.cc index 831255db8..6c14bf2c2 100644 --- a/src/cdrom_image.cc +++ b/src/cdrom_image.cc @@ -59,8 +59,12 @@ void image_close(uint8_t id); void image_audio_callback(uint8_t id, int16_t *output, int len) { - if ((cdrom_image[id].cd_state != CD_PLAYING) || (cdrom_image[id].image_is_iso)) + if (!cdrom_drives[id].sound_on || (cdrom_image[id].cd_state != CD_PLAYING) || cdrom_image[id].image_is_iso) { + if (cdrom_ioctl[id].cd_state == CD_PLAYING) + { + cdrom[id].seek_pos += (len >> 11); + } memset(output, 0, len * 2); return; } @@ -292,22 +296,20 @@ static uint8_t image_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf) if (msf) { - uint32_t dat = MSFtoLBA(absPos.min, absPos.sec, absPos.fr); - b[pos + 3] = (uint8_t)(dat % 75); dat /= 75; - b[pos + 2] = (uint8_t)(dat % 60); dat /= 60; - b[pos + 1] = (uint8_t)dat; + b[pos + 3] = (uint8_t) absPos.fr; + b[pos + 2] = (uint8_t) absPos.sec; + b[pos + 1] = (uint8_t) absPos.min; b[pos] = 0; pos += 4; - dat = MSFtoLBA(relPos.min, relPos.sec, relPos.fr); - b[pos + 3] = (uint8_t)(dat % 75); dat /= 75; - b[pos + 2] = (uint8_t)(dat % 60); dat /= 60; - b[pos + 1] = (uint8_t)dat; + b[pos + 3] = (uint8_t) relPos.fr; + b[pos + 2] = (uint8_t) relPos.sec; + b[pos + 1] = (uint8_t) relPos.min; b[pos] = 0; pos += 4; } else { - uint32_t dat = MSFtoLBA(absPos.min, absPos.sec, absPos.fr); + uint32_t dat = MSFtoLBA(absPos.min, absPos.sec, absPos.fr) - 150; b[pos++] = (dat >> 24) & 0xff; b[pos++] = (dat >> 16) & 0xff; b[pos++] = (dat >> 8) & 0xff; diff --git a/src/cdrom_ioctl.c b/src/cdrom_ioctl.c index 8d8e28612..5da98bda6 100644 --- a/src/cdrom_ioctl.c +++ b/src/cdrom_ioctl.c @@ -53,8 +53,12 @@ void ioctl_audio_callback(uint8_t id, int16_t *output, int len) RAW_READ_INFO in; DWORD count; - if (cdrom_ioctl[id].cd_state != CD_PLAYING) + if (!cdrom_drives[id].sound_on || (cdrom_ioctl[id].cd_state != CD_PLAYING)) { + if (cdrom_ioctl[id].cd_state == CD_PLAYING) + { + cdrom[id].seek_pos += (len >> 11); + } memset(output, 0, len * 2); return; } @@ -395,7 +399,7 @@ static uint8_t ioctl_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf) if (msf) { - dat = cdpos; + dat = cdpos + 150; b[pos + 3] = (uint8_t)(dat % 75); dat /= 75; b[pos + 2] = (uint8_t)(dat % 60); dat /= 60; b[pos + 1] = (uint8_t)dat; diff --git a/src/config.c b/src/config.c index a24772e19..a335ab55a 100644 --- a/src/config.c +++ b/src/config.c @@ -997,15 +997,7 @@ static void loadconfig_hard_disks(void) sprintf(temps, "hdd_%02i_scsi_location", c + 1); sprintf(temps2, "%02u:%02u", c, 0); p = config_get_string(cat, temps, temps2); - if (p != NULL) - { - sscanf(p, "%02u:%02u", &hdc[c].scsi_id, &hdc[c].scsi_lun); - } - else - { - /* FIXME: Can never happen, 'temps' above is non-NULL. */ - sscanf(temps2, "%02u:%02u", &hdc[c].scsi_id, &hdc[c].scsi_lun); - } + sscanf(p, "%02u:%02u", &hdc[c].scsi_id, &hdc[c].scsi_lun); if (hdc[c].scsi_id > 15) { @@ -1019,12 +1011,7 @@ static void loadconfig_hard_disks(void) memset(hdd_fn[c], 0, 1024); sprintf(temps, "hdd_%02i_fn", c + 1); wp = config_get_wstring(cat, temps, L""); - /*FIXME: wcslen(wp) instead of 512? */ - if (wp) memcpy(hdd_fn[c], wp, 512); - else { - memcpy(hdd_fn[c], L"", 2); - hdd_fn[c][0] = L'\0'; - } + memcpy(hdd_fn[c], wp, (wcslen(wp) << 1) + 2); } } @@ -1044,10 +1031,7 @@ static void loadconfig_removable_devices(void) { sprintf(temps, "fdd_%02i_type", c + 1); p = config_get_string(cat, temps, (c < 2) ? "525_2dd" : "none"); - if (p) - fdd_set_type(c, fdd_get_from_internal_name(p)); - else /*FIXME: never happens, "none" is non-NULL */ - fdd_set_type(c, (c < 2) ? 2 : 0); + fdd_set_type(c, fdd_get_from_internal_name(p)); if (fdd_get_type(c) > 13) { fdd_set_type(c, 13); @@ -1055,12 +1039,7 @@ static void loadconfig_removable_devices(void) sprintf(temps, "fdd_%02i_fn", c + 1); wp = config_get_wstring(cat, temps, L""); - /*FIXME: see above, wcslen(wp) ? */ - if (wp) memcpy(discfns[c], wp, 512); - else { - memcpy(discfns[c], L"", 2); - discfns[c][0] = L'\0'; - } + memcpy(discfns[c], wp, (wcslen(wp) << 1) + 2); printf("Floppy: %ws\n", discfns[c]); sprintf(temps, "fdd_%02i_writeprot", c + 1); ui_writeprot[c] = !!config_get_int(cat, temps, 0); @@ -1096,15 +1075,7 @@ static void loadconfig_removable_devices(void) sprintf(temps, "cdrom_%02i_scsi_location", c + 1); sprintf(temps2, "%02u:%02u", c + 2, 0); p = config_get_string(cat, temps, temps2); - if (p != NULL) - { - sscanf(p, "%02u:%02u", &cdrom_drives[c].scsi_device_id, &cdrom_drives[c].scsi_device_lun); - } - else /*FIXME: never happens, 'temps2' is non-NULL */ - { - sscanf(temps2, "%02u:%02u", &cdrom_drives[c].scsi_device_id, &cdrom_drives[c].scsi_device_lun); - } - + sscanf(p, "%02u:%02u", &cdrom_drives[c].scsi_device_id, &cdrom_drives[c].scsi_device_lun); if (cdrom_drives[c].scsi_device_id > 15) { @@ -1117,12 +1088,7 @@ static void loadconfig_removable_devices(void) sprintf(temps, "cdrom_%02i_image_path", c + 1); wp = config_get_wstring(cat, temps, L""); - /*FIXME see above, wcslen(wp) */ - if (wp != NULL) memcpy(cdrom_image[c].image_path, wp, 512); - else { - memcpy(cdrom_image[c].image_path, L"", 2); - cdrom_image[c].image_path[0] = L'\0'; - } + memcpy(cdrom_image[c].image_path, wp, (wcslen(wp) << 1) + 2); } } diff --git a/src/hdd_esdi.c b/src/hdd_esdi.c index f40345933..a6f5ce466 100644 --- a/src/hdd_esdi.c +++ b/src/hdd_esdi.c @@ -433,7 +433,7 @@ static void esdi_callback(void *p) fatal("Read past end of drive\n"); fseek(drive->hdfile, esdi->rba * 512, SEEK_SET); fread(esdi->data, 512, 1, drive->hdfile); - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); } while (esdi->data_pos < 256) { @@ -522,11 +522,11 @@ static void esdi_callback(void *p) fwrite(esdi->data, 512, 1, drive->hdfile); esdi->rba++; esdi->sector_pos++; - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); esdi->data_pos = 0; } - update_status_bar_icon(0x20, 0); + update_status_bar_icon(0x30, 0); esdi->status = STATUS_CMD_IN_PROGRESS; esdi->cmd_state = 2; diff --git a/src/ide.c b/src/ide.c index 18db7d4d6..1308fcf89 100644 --- a/src/ide.c +++ b/src/ide.c @@ -1399,7 +1399,7 @@ uint32_t ide_read_data(int ide_board, int length) } else { - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 0); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 0); } } } @@ -1722,7 +1722,7 @@ void callbackide(int ide_board) ide_irq_raise(ide); - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 1); return; case WIN_READ_DMA: @@ -1756,12 +1756,12 @@ void callbackide(int ide_board) ide_next_sector(ide); ide->atastat = BUSY_STAT; idecallback[ide_board]=6*IDE_TIME; - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 1); } else { ide_irq_raise(ide); - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 0); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 0); } } } @@ -1799,7 +1799,7 @@ void callbackide(int ide_board) ide->blockcount = 0; } - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 1); return; case WIN_WRITE: @@ -1822,12 +1822,12 @@ void callbackide(int ide_board) ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT; ide->pos=0; ide_next_sector(ide); - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 1); } else { ide->atastat = READY_STAT | DSC_STAT; - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 0); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 0); } return; @@ -1863,12 +1863,12 @@ void callbackide(int ide_board) ide_next_sector(ide); ide->atastat = BUSY_STAT; idecallback[ide_board]=6*IDE_TIME; - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 1); } else { ide_irq_raise(ide); - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 0); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 0); } } } @@ -1899,12 +1899,12 @@ void callbackide(int ide_board) ide->atastat = DRQ_STAT | READY_STAT | DSC_STAT; ide->pos=0; ide_next_sector(ide); - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 1); } else { ide->atastat = READY_STAT | DSC_STAT; - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 0); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 0); } return; @@ -1921,7 +1921,7 @@ void callbackide(int ide_board) ide->pos=0; ide->atastat = READY_STAT | DSC_STAT; ide_irq_raise(ide); - update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); + update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 1); return; case WIN_FORMAT: @@ -1943,7 +1943,7 @@ void callbackide(int ide_board) ide->atastat = READY_STAT | DSC_STAT; ide_irq_raise(ide); - /* update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x22 : 0x21, 1); */ + /* update_status_bar_icon((hdc[ide->hdc_num].bus == 3) ? 0x32 : 0x31, 1); */ return; case WIN_DRIVE_DIAGNOSTICS: diff --git a/src/mfm_at.c b/src/mfm_at.c index c4c1be484..f0dd98ed1 100644 --- a/src/mfm_at.c +++ b/src/mfm_at.c @@ -439,7 +439,7 @@ uint16_t mfm_readw(uint16_t port, void *p) } else { - update_status_bar_icon(0x20, 0); + update_status_bar_icon(0x30, 0); } } } @@ -505,7 +505,7 @@ void mfm_callback(void *p) mfm->pos = 0; mfm->status = STAT_DRQ | STAT_READY | STAT_DSC; mfm_irq_raise(mfm); - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); break; case CMD_WRITE: @@ -526,12 +526,12 @@ void mfm_callback(void *p) mfm->status = STAT_DRQ | STAT_READY | STAT_DSC; mfm->pos = 0; mfm_next_sector(mfm); - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); } else { mfm->status = STAT_READY | STAT_DSC; - update_status_bar_icon(0x20, 0); + update_status_bar_icon(0x30, 0); } break; @@ -540,7 +540,7 @@ void mfm_callback(void *p) mfm->pos = 0; mfm->status = STAT_READY | STAT_DSC; mfm_irq_raise(mfm); - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); break; case CMD_FORMAT: @@ -560,7 +560,7 @@ void mfm_callback(void *p) } mfm->status = STAT_READY | STAT_DSC; mfm_irq_raise(mfm); - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); break; case CMD_DIAGNOSE: diff --git a/src/mfm_xebec.c b/src/mfm_xebec.c index fdbe7e7b3..d7b80d831 100644 --- a/src/mfm_xebec.c +++ b/src/mfm_xebec.c @@ -374,7 +374,7 @@ static void xebec_callback(void *p) xebec_complete(xebec); - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); break; default: @@ -431,7 +431,7 @@ static void xebec_callback(void *p) fseeko64(drive->hdfile, addr * 512, SEEK_SET); fread(xebec->sector_buf, 512, 1, drive->hdfile); - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); } if (xebec->irq_dma_mask & DMA_ENA) xebec->callback = XEBEC_TIME; @@ -485,7 +485,7 @@ static void xebec_callback(void *p) fseeko64(drive->hdfile, addr * 512, SEEK_SET); fread(xebec->sector_buf, 512, 1, drive->hdfile); - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); xebec->state = STATE_SEND_DATA; @@ -500,7 +500,7 @@ static void xebec_callback(void *p) else { xebec_complete(xebec); - update_status_bar_icon(0x20, 0); + update_status_bar_icon(0x30, 0); } break; @@ -572,7 +572,7 @@ static void xebec_callback(void *p) fwrite(xebec->sector_buf, 512, 1, drive->hdfile); } - update_status_bar_icon(0x20, 1); + update_status_bar_icon(0x30, 1); xebec_next_sector(xebec); xebec->data_pos = 0; diff --git a/src/net_pcap.c b/src/net_pcap.c index 5eb57bb4c..3ca2e9089 100644 --- a/src/net_pcap.c +++ b/src/net_pcap.c @@ -220,6 +220,7 @@ int network_devlist(netdev_t *list) { char errbuf[PCAP_ERRBUF_SIZE]; + char *temp_dev; pcap_if_t *devlist, *dev; int i = 0; @@ -228,6 +229,14 @@ network_devlist(netdev_t *list) strcpy(list->description, "None"); list++; i++; + /* See if WinPcap is even present, and get out of here if it's not. */ + temp_dev = (char *)pcap_lib_version(); + if (temp_dev == NULL) { + /* Hmm, WinPcap doesn't seem to be alive.. */ + pclog("PCAP: WinPcap library not found, not processing the networks list further!\n"); + return(i); + } + /* Retrieve the device list from the local machine */ if (pcap_findalldevs(&devlist, errbuf) == -1) { pclog("NETWORK: error in pcap_findalldevs: %s\n", errbuf); diff --git a/src/scsi_disk.c b/src/scsi_disk.c index 31623fbed..26f900e55 100644 --- a/src/scsi_disk.c +++ b/src/scsi_disk.c @@ -73,7 +73,9 @@ uint8_t scsi_hd_command_flags[0x100] = 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED | ALLOW_UA, /* 0x12 */ IMPLEMENTED | CHECK_READY | NONDATA | SCSI_ONLY, /* 0x13 */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + IMPLEMENTED | CHECK_READY, /* 0x1B */ + 0, 0, IMPLEMENTED | CHECK_READY, /* 0x1E */ 0, 0, 0, 0, 0, 0, IMPLEMENTED | CHECK_READY, /* 0x25 */ @@ -475,6 +477,10 @@ static void scsi_hd_sense_clear(int id, int command) static void scsi_hd_cmd_error(uint8_t id) { shdc[id].error = ((scsi_hd_sense_key & 0xf) << 4) | ABRT_ERR; + if (shdc[id].unit_attention) + { + shdc[id].error |= MCR_ERR; + } shdc[id].status = READY_STAT | ERR_STAT; shdc[id].phase = 3; shdc[id].packet_status = 0x80; @@ -482,6 +488,28 @@ static void scsi_hd_cmd_error(uint8_t id) scsi_hd_log("SCSI HD %i: ERROR: %02X/%02X/%02X\n", id, scsi_hd_sense_key, scsi_hd_asc, scsi_hd_ascq); } +static void scsi_hd_unit_attention(uint8_t id) +{ + shdc[id].error = (SENSE_UNIT_ATTENTION << 4) | ABRT_ERR; + if (cdrom[id].unit_attention) + { + shdc[id].error |= MCR_ERR; + } + shdc[id].status = READY_STAT | ERR_STAT; + shdc[id].phase = 3; + shdc[id].packet_status = 0x80; + shdc[id].callback = 50 * CDROM_TIME; + scsi_hd_log("SCSI HD %i: UNIT ATTENTION\n", id); +} + +static void scsi_hd_not_ready(uint8_t id) +{ + scsi_hd_sense_key = SENSE_NOT_READY; + scsi_hd_asc = ASC_MEDIUM_NOT_PRESENT; + scsi_hd_ascq = 0; + scsi_hd_cmd_error(id); +} + static void scsi_hd_invalid_lun(uint8_t id) { scsi_hd_sense_key = SENSE_ILLEGAL_REQUEST; @@ -625,6 +653,11 @@ int scsi_hd_read_blocks(uint8_t id, uint32_t *len, int first_batch) return 1; } +void scsi_disk_insert(uint8_t id) +{ + shdc[id].unit_attention = (hdc[id].bus == 5) ? 1 : 0; +} + /*SCSI Sense Initialization*/ void scsi_hd_sense_code_ok(uint8_t id) { @@ -635,6 +668,8 @@ void scsi_hd_sense_code_ok(uint8_t id) int scsi_hd_pre_execution_check(uint8_t id, uint8_t *cdb) { + int ready = 1; + if (((shdc[id].request_length >> 5) & 7) != hdc[id].scsi_lun) { scsi_hd_log("SCSI HD %i: Attempting to execute a unknown command targeted at SCSI LUN %i\n", id, ((shdc[id].request_length >> 5) & 7)); @@ -649,6 +684,55 @@ int scsi_hd_pre_execution_check(uint8_t id, uint8_t *cdb) return 0; } + if (hdc[id].bus == 5) + { + /* Removable disk, set ready state. */ + if (wcslen(hdd_fn[id]) > 0) + { + ready = 1; + } + else + { + ready = 0; + } + } + else + { + /* Fixed disk, clear UNIT ATTENTION, just in case it might have been set when the disk was removable). */ + shdc[id].unit_attention = 0; + } + + if (!ready && shdc[id].unit_attention) + { + /* If the drive is not ready, there is no reason to keep the + UNIT ATTENTION condition present, as we only use it to mark + disc changes. */ + shdc[id].unit_attention = 0; + } + + /* If the UNIT ATTENTION condition is set and the command does not allow + execution under it, error out and report the condition. */ + if (shdc[id].unit_attention == 1) + { + /* Only increment the unit attention phase if the command can not pass through it. */ + if (!(scsi_hd_command_flags[cdb[0]] & ALLOW_UA)) + { + /* scsi_hd_log("SCSI HD %i: Unit attention now 2\n", id); */ + shdc[id].unit_attention = 2; + scsi_hd_log("SCSI HD %i: UNIT ATTENTION: Command %02X not allowed to pass through\n", id, cdb[0]); + scsi_hd_unit_attention(id); + return 0; + } + } + else if (shdc[id].unit_attention == 2) + { + if (cdb[0] != GPCMD_REQUEST_SENSE) + { + /* scsi_hd_log("SCSI HD %i: Unit attention now 0\n", id); */ + shdc[id].unit_attention = 0; + } + } + /* Unless the command is REQUEST SENSE, clear the sense. This will *NOT* the UNIT ATTENTION condition if it's set. */ if (cdb[0] != GPCMD_REQUEST_SENSE) @@ -656,6 +740,14 @@ int scsi_hd_pre_execution_check(uint8_t id, uint8_t *cdb) scsi_hd_sense_clear(id, cdb[0]); } + /* Next it's time for NOT READY. */ + if ((scsi_hd_command_flags[cdb[0]] & CHECK_READY) && !ready) + { + scsi_hd_log("SCSI HD %i: Not ready (%02X)\n", id, cdb[0]); + scsi_hd_not_ready(id); + return 0; + } + scsi_hd_log("SCSI HD %i: Continuing with command\n", id); return 1; @@ -692,14 +784,56 @@ void scsi_hd_request_sense(uint8_t id, uint8_t *buffer, uint8_t alloc_length) buffer[0] = 0x70; + if (shdc[id].unit_attention && (scsi_hd_sense_key == 0)) + { + buffer[2]=SENSE_UNIT_ATTENTION; + buffer[12]=ASC_MEDIUM_MAY_HAVE_CHANGED; + buffer[13]=0; + } + /* scsi_hd_log("SCSI HD %i: Reporting sense: %02X %02X %02X\n", id, hdbufferb[2], hdbufferb[12], hdbufferb[13]); */ + if (buffer[2] == SENSE_UNIT_ATTENTION) + { + /* If the last remaining sense is unit attention, clear + that condition. */ + shdc[id].unit_attention = 0; + } + /* Clear the sense stuff as per the spec. */ scsi_hd_sense_clear(id, GPCMD_REQUEST_SENSE); } void scsi_hd_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length) { + int ready = 1; + + if (hdc[id].bus == 5) + { + /* Removable disk, set ready state. */ + if (wcslen(hdd_fn[id]) > 0) + { + ready = 1; + } + else + { + ready = 0; + } + } + else + { + /* Fixed disk, clear UNIT ATTENTION, just in case it might have been set when the disk was removable). */ + shdc[id].unit_attention = 0; + } + + if (!ready && shdc[id].unit_attention) + { + /* If the drive is not ready, there is no reason to keep the + UNIT ATTENTION condition present, as we only use it to mark + disc changes. */ + shdc[id].unit_attention = 0; + } + /* Do *NOT* advance the unit attention phase. */ scsi_hd_request_sense(id, buffer, alloc_length); @@ -852,11 +986,11 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb) shdc[id].all_blocks_total = shdc[id].block_total; if (shdc[id].packet_status != CDROM_PHASE_COMPLETE) { - update_status_bar_icon(0x23, 1); + update_status_bar_icon((hdc[id].bus == 5) ? (0x20 | id) : 0x23, 1); } else { - update_status_bar_icon(0x23, 0); + update_status_bar_icon((hdc[id].bus == 5) ? (0x20 | id) : 0x23, 0); } return; @@ -913,14 +1047,45 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb) shdc[id].all_blocks_total = shdc[id].block_total; if (shdc[id].packet_status != CDROM_PHASE_COMPLETE) { - update_status_bar_icon(0x23, 1); + update_status_bar_icon((hdc[id].bus == 5) ? (0x20 | id) : 0x23, 1); } else { - update_status_bar_icon(0x23, 0); + update_status_bar_icon((hdc[id].bus == 5) ? (0x20 | id) : 0x23, 0); } return; + case GPCMD_START_STOP_UNIT: + if (hdc[id].bus != 5) + { + scsi_hd_illegal_opcode(id); + break; + } + + switch(cdb[4] & 3) + { + case 0: /* Stop the disc. */ + case 1: /* Start the disc and read the TOC. */ + break; + case 2: /* Eject the disc if possible. */ +#ifndef __unix +#if 0 + win_removable_disk_eject(id); +#endif +#endif + break; + case 3: /* Load the disc (close tray). */ +#ifndef __unix +#if 0 + win_removable_disk_reload(id); +#endif +#endif + break; + } + + scsi_hd_command_complete(id); + break; + case GPCMD_INQUIRY: max_len = cdb[3]; max_len <<= 8; @@ -985,7 +1150,14 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb) memset(hdbufferb, 0, 8); hdbufferb[0] = 0; /*SCSI HD*/ - hdbufferb[1] = 0; /*Fixed*/ + if (hdc[id].bus == 5) + { + hdbufferb[1] = 0x80; /*Removable*/ + } + else + { + hdbufferb[1] = 0; /*Fixed*/ + } hdbufferb[2] = 0x02; /*SCSI-2 compliant*/ hdbufferb[3] = 0x02; hdbufferb[4] = 31; @@ -1129,7 +1301,7 @@ void scsi_hd_callback(uint8_t id) shdc[id].status = READY_STAT; shdc[id].phase = 3; shdc[id].packet_status = 0xFF; - update_status_bar_icon(0x23, 0); + update_status_bar_icon((hdc[id].bus == 5) ? (0x20 | id) : 0x23, 0); return; case CDROM_PHASE_DATA_OUT: scsi_hd_log("SCSI HD %i: PHASE_DATA_OUT\n", id); @@ -1142,7 +1314,7 @@ void scsi_hd_callback(uint8_t id) shdc[id].packet_status = CDROM_PHASE_COMPLETE; shdc[id].status = READY_STAT; shdc[id].phase = 3; - update_status_bar_icon(0x23, 0); + update_status_bar_icon((hdc[id].bus == 5) ? (0x20 | id) : 0x23, 0); return; case CDROM_PHASE_DATA_IN: scsi_hd_log("SCSI HD %i: PHASE_DATA_IN\n", id); @@ -1155,7 +1327,7 @@ void scsi_hd_callback(uint8_t id) shdc[id].packet_status = CDROM_PHASE_COMPLETE; shdc[id].status = READY_STAT; shdc[id].phase = 3; - update_status_bar_icon(0x23, 0); + update_status_bar_icon((hdc[id].bus == 5) ? (0x20 | id) : 0x23, 0); return; case CDROM_PHASE_ERROR: scsi_hd_log("SCSI HD %i: PHASE_ERROR\n", id);