diff --git a/x68k/adpcm.c b/x68k/adpcm.c index 871d91ad..a8939ea8 100644 --- a/x68k/adpcm.c +++ b/x68k/adpcm.c @@ -267,9 +267,6 @@ void ADPCM_Update(int16_t *buffer, size_t length, uint8_t *pbsp, uint8_t *pbep) ADPCM_DifBuf += ADPCM_BufSize; } -/* - * 1nibble(4bit)をデコード - */ static INLINE void ADPCM_WriteOne(uint8_t val) { ADPCM_Out += dif_table[(ADPCM_Step << 4) + val]; @@ -358,12 +355,9 @@ void ADPCM_SetVolume(uint8_t vol) if ( vol ) ADPCM_VolumeShift = (int)((double)16/pow(1.189207115, (16-vol))); else - ADPCM_VolumeShift = 0; /* Mute */ + ADPCM_VolumeShift = 0; } -/* - * Panning - */ void ADPCM_SetPan(int n) { if ( (ADPCM_Pan&0x0c)!=(n&0x0c) ) @@ -375,10 +369,6 @@ void ADPCM_SetPan(int n) ADPCM_Pan = n; } - -/* - * Clock - */ void ADPCM_SetClock(int n) { if ( (ADPCM_Clock&4)!=n ) diff --git a/x68k/bg.c b/x68k/bg.c index 8d2d67da..beae7032 100644 --- a/x68k/bg.c +++ b/x68k/bg.c @@ -1,3 +1,8 @@ +/* + * BG.C - BG and sprites + * TODO: Check transparent color processing (especially with Text) + */ + #include #include "common.h" @@ -148,7 +153,7 @@ void FASTCALL BG_Write(uint32_t adr, uint8_t data) else if ((adr>=0xeb0800)&&(adr<0xeb0812)) { adr -= 0xeb0800; - if (BG_Regs[adr]==data) return; /* データに変化が無ければ帰る */ + if (BG_Regs[adr]==data) return; /* return if no data is changed */ BG_Regs[adr] = data; switch(adr) { @@ -178,11 +183,11 @@ void FASTCALL BG_Write(uint32_t adr, uint8_t data) break; case 0x0d: - BG_HAdjust = ((int32_t)BG_Regs[0x0d] - (CRTC_HSTART + 4)) * 8; /* 水平方向は解像度による1/2はいらない?(Tetris) */ + BG_HAdjust = ((int32_t)BG_Regs[0x0d] - (CRTC_HSTART + 4)) * 8; /* Isn't it necessary to divide the horizontal resolution by 1/2? (Tetris) */ TVRAM_SetAllDirty(); break; case 0x0f: - BG_VLINE = ((int32_t)BG_Regs[0x0f] - CRTC_VSTART) / ((BG_Regs[0x11] & 4) ? 1 : 2); /* BGとその他がずれてる時の差分 */ + BG_VLINE = ((int32_t)BG_Regs[0x0f] - CRTC_VSTART) / ((BG_Regs[0x11] & 4) ? 1 : 2); /* Difference when BG and other elements are misaligned */ TVRAM_SetAllDirty(); break; @@ -200,8 +205,8 @@ void FASTCALL BG_Write(uint32_t adr, uint8_t data) BG_CHREND = 0x2000; BG_CHRSIZE = ((data&3)?16:8); BG_AdrMask = ((data&3)?1023:511); - BG_HAdjust = ((int32_t)BG_Regs[0x0d] - (CRTC_HSTART + 4)) * 8; /* 水平方向は解像度による1/2はいらない?(Tetris) */ - BG_VLINE = ((int32_t)BG_Regs[0x0f] - CRTC_VSTART) / ((BG_Regs[0x11] & 4) ? 1 : 2); /* BGとその他がずれてる時の差分 */ + BG_HAdjust = ((int32_t)BG_Regs[0x0d] - (CRTC_HSTART + 4)) * 8; /*Isn't it necessary to divide the horizontal resolution by 1/2? (Tetris) */ + BG_VLINE = ((int32_t)BG_Regs[0x0f] - CRTC_VSTART) / ((BG_Regs[0x11] & 4) ? 1 : 2); /* Difference when BG and other elements are misaligned */ break; case 0x09: /* BG Plane Cfg Changed */ TVRAM_SetAllDirty(); @@ -252,7 +257,7 @@ void FASTCALL BG_Write(uint32_t adr, uint8_t data) else if ((adr>=0xeb8000)&&(adr<0xec0000)) { adr -= 0xeb8000; - if (BG[adr]==data) return; /* データに変化が無ければ帰る */ + if (BG[adr]==data) return; /* return if no data is changed */ BG[adr] = data; if (adr<0x2000) { @@ -263,11 +268,11 @@ void FASTCALL BG_Write(uint32_t adr, uint8_t data) BGCHR16[bg16chr] = data>>4; BGCHR16[bg16chr+1] = data&15; - if (adr=BG_BG1TOP)&&(adr=BG_BG1TOP)&&(adr=BG_BG0TOP)&&(adr=BG_BG0TOP)&&(adr CRTC_HSTART) TextDotX = (CRTC_HEND-CRTC_HSTART)*8; - BG_HAdjust = ((long)BG_Regs[0x0d]-(CRTC_HSTART+4))*8; /* 水平方向は解像度による1/2はいらない?(Tetris) */ + BG_HAdjust = ((long)BG_Regs[0x0d]-(CRTC_HSTART+4))*8; /* Isn't it necessary to divide the horizontal resolution by 1/2? (Tetris) */ break; case 0x06: case 0x07: @@ -219,43 +243,25 @@ void FASTCALL CRTC_Write(uint32_t adr, uint8_t data) break; case 0x08: case 0x09: - VLINE_TOTAL = (((uint16_t)CRTC_Regs[8]<<8)+CRTC_Regs[9]); + VLINE_TOTAL = (((uint16_t)CRTC_Regs[8]<<8)+CRTC_Regs[9]) & 1023; HSYNC_CLK = ((CRTC_Regs[0x29]&0x10)?VSYNC_HIGH:VSYNC_NORM)/VLINE_TOTAL; break; + case 0x0a: + case 0x0b: + /* VSYNC end */ + break; case 0x0c: case 0x0d: CRTC_VSTART = (((uint16_t)CRTC_Regs[0xc] << 8) + CRTC_Regs[0xd]) & 1023; - BG_VLINE = ((long)BG_Regs[0x0f]-CRTC_VSTART)/((BG_Regs[0x11]&4)?1:2); /* BGとその他がずれてる時の差分 */ + BG_VLINE = ((long)BG_Regs[0x0f]-CRTC_VSTART)/((BG_Regs[0x11]&4)?1:2); /* Difference when BG and other elements are misaligned */ TextDotY = CRTC_VEND-CRTC_VSTART; - if ((CRTC_Regs[0x29]&0x14)==0x10) - { - TextDotY/=2; - CRTC_VStep = 1; - } - else if ((CRTC_Regs[0x29]&0x14)==0x04) - { - TextDotY*=2; - CRTC_VStep = 4; - } - else - CRTC_VStep = 2; + CRTC_ScreenChanged(); break; case 0x0e: case 0x0f: CRTC_VEND = (((uint16_t)CRTC_Regs[0xe] << 8) + CRTC_Regs[0xf]) & 1023; TextDotY = CRTC_VEND-CRTC_VSTART; - if ((CRTC_Regs[0x29]&0x14)==0x10) - { - TextDotY/=2; - CRTC_VStep = 1; - } - else if ((CRTC_Regs[0x29]&0x14)==0x04) - { - TextDotY*=2; - CRTC_VStep = 4; - } - else - CRTC_VStep = 2; + CRTC_ScreenChanged(); break; case 0x28: TVRAM_SetAllDirty(); @@ -264,23 +270,11 @@ void FASTCALL CRTC_Write(uint32_t adr, uint8_t data) HSYNC_CLK = ((CRTC_Regs[0x29]&0x10)?VSYNC_HIGH:VSYNC_NORM)/VLINE_TOTAL; VID_MODE = !!(CRTC_Regs[0x29]&0x10); TextDotY = CRTC_VEND-CRTC_VSTART; - if ((CRTC_Regs[0x29]&0x14)==0x10) - { - TextDotY/=2; - CRTC_VStep = 1; - } - else if ((CRTC_Regs[0x29]&0x14)==0x04) - { - TextDotY*=2; - CRTC_VStep = 4; - } - else - CRTC_VStep = 2; - if (VID_MODE != old_vidmode) - { - old_vidmode = VID_MODE; - CHANGEAV_TIMING=1; - } + CRTC_ScreenChanged(); + break; + case 0x10: + case 0x11: + /* EXT sync horizontal adjust */ break; case 0x12: case 0x13: @@ -329,9 +323,9 @@ void FASTCALL CRTC_Write(uint32_t adr, uint8_t data) case 0x2a: case 0x2b: break; - case 0x2c: /* CRTC動作ポートのラスタコピーをONにしておいて(しておいたまま)、 */ - case 0x2d: /* Src/Dstだけ次々変えていくのも許されるらしい(ドラキュラとか) */ - CRTC_RCFlag[reg-0x2c] = 1; /* Dst変更後に実行される? */ + case 0x2c: /* Turn on the raster copy of the CRTC operation port (and leave it on), */ + case 0x2d: /* Apparently it's also permissible to change only the Src/Dst (like Dracula) */ + CRTC_RCFlag[reg-0x2c] = 1; /* Is it executed after changing Dst? */ if ((CRTC_Mode&8)&&/*(CRTC_RCFlag[0])&&*/(CRTC_RCFlag[1])) { CRTC_RasterCopy(); @@ -342,7 +336,7 @@ void FASTCALL CRTC_Write(uint32_t adr, uint8_t data) } } else if (adr==0xe80481) - { /* CRTC動作ポート */ + { /* CRTC operation port */ CRTC_Mode = (data|(CRTC_Mode&2)); if (CRTC_Mode&8) { /* Raster Copy */ @@ -350,10 +344,10 @@ void FASTCALL CRTC_Write(uint32_t adr, uint8_t data) CRTC_RCFlag[0] = 0; CRTC_RCFlag[1] = 0; } - if (CRTC_Mode&2) + if (CRTC_Mode&2) /* FastClear */ { CRTC_FastClrLine = vline; - /* この時点のマスクが有効らしい(クォース) */ + /* The mask at this point seems to be valid (quote) */ CRTC_FastClrMask = FastClearMask[CRTC_Regs[0x2b]&15]; } } diff --git a/x68k/fdc.c b/x68k/fdc.c index 13a1fb85..02b51e2c 100644 --- a/x68k/fdc.c +++ b/x68k/fdc.c @@ -1,5 +1,7 @@ /* * FDC.C - Floppy Disk Controller (uPD72065) + * ToDo: Review of unimplemented commands, suspicious parts (numerous), review of the link with DMAC + * The error handling in D88 should have gotten better... but it's also messy... */ #include "fdc.h" @@ -125,9 +127,6 @@ int FDC_StateAction(StateMem *sm, int load, int data_only) #define MF(p) ((p->us>>6)&1) #define MT(p) ((p->us>>7)&1) -/* - * 割り込みベクタ - */ uint32_t FASTCALL FDC_Int(uint8_t irq) { IRQH_IRQCallBack(irq); @@ -136,10 +135,6 @@ uint32_t FASTCALL FDC_Int(uint8_t irq) return -1; } - -/* - * 初期化 - */ void FDC_Init(void) { memset(&fdc, 0, sizeof(FDC)); @@ -160,7 +155,7 @@ static void FDC_SetInt(void) /* - * Excution Phase の終了 + * End of Execution Phase */ static void FDC_EPhaseEnd(void) { @@ -299,11 +294,11 @@ static void FDC_ExecCmd(void) fdc.st0 = prm1->us&7; fdc.cyl = 0; if ( (!FDD_IsReady(fdc.drv))&&(!fdc.ready) ) { - fdc.st0 |= 0x48; /* FDなし */ + fdc.st0 |= 0x48; /* no FD */ } else if ( (fdc.drv>=0)&&(fdc.drv<2) ) { - fdc.st0 |= 0x20; /* FDあり、ドライブあり */ + fdc.st0 |= 0x20; /* with FD and drive */ } else { - fdc.st0 |= 0x50; /* ドライブなし */ + fdc.st0 |= 0x50; /* no drive */ } FDC_SetInt(); break; diff --git a/x68k/gvram.c b/x68k/gvram.c index 3d24d2db..a3d89d66 100644 --- a/x68k/gvram.c +++ b/x68k/gvram.c @@ -14,10 +14,10 @@ uint8_t GVRAM[0x80000]; uint16_t Grp_LineBuf[1024]; -uint16_t Grp_LineBufSP[1024]; /* ?真真真真真真真真真綽 */ -uint16_t Grp_LineBufSP2[1024]; /* 真真真真真真真真水真真真真真真綽真真 */ +uint16_t Grp_LineBufSP[1024]; /* Special priority/semi-transparent buffer */ +uint16_t Grp_LineBufSP2[1024]; /* Buffer for semi-transparent base plane (stores non-semi-transparent bits) */ static uint16_t Grp_LineBufSP_Tr[1024]; -static uint16_t Pal16Adr[256]; /* 16bit color 真水真真真真真 */ +static uint16_t Pal16Adr[256]; /* Buffer for semi-transparent base plane (stores non-semi-transparent bits) */ int GVRAM_StateAction(StateMem *sm, int load, int data_only) { @@ -44,25 +44,18 @@ int GVRAM_StateAction(StateMem *sm, int load, int data_only) #define GET_WORD_W8(src) (*(uint8_t *)(src) | *((uint8_t *)(src) + 1) << 8) #endif -/* - * 真真真 - */ void GVRAM_Init(void) { int i; memset(GVRAM, 0, 0x80000); - for (i=0; i<128; i++) /* 16bit color 真水真真真真真 */ + for (i=0; i<128; i++) /* For 16bit color palette address calculation */ { Pal16Adr[i*2] = i*4; Pal16Adr[i*2+1] = i*4+1; } } -/* - * 真真真真真真 - */ - void FASTCALL GVRAM_FastClear(void) { uint32_t v = ((CRTC_Regs[0x29]&4)?512:256); @@ -98,153 +91,300 @@ void FASTCALL GVRAM_FastClear(void) } } -/* - * VRAM Read - */ uint8_t FASTCALL GVRAM_Read(uint32_t adr) { -#ifndef MSB_FIRST - adr ^= 1; -#endif - adr -= 0xc00000; + int type; + + adr &= 0x1fffff; if (CRTC_Regs[0x28] & 8) + type = 4; + else if (CRTC_Regs[0x28] & 4) + type = 0; + else + type = (CRTC_Regs[0x28] & 3) + 1; + + switch (type) { + case 0: /* 1024 dot, 16 colors */ + if ((adr & 1) == 0) + return 0; + + if (adr & 0x100000) + { + if (adr & 0x400) + { + /* page 3 */ + adr = ((adr >> 1) & 0x7fc00) | (adr & 0x3ff); + return (GVRAM[adr] >> 4); + } + else + { + /* page 2 */ + adr = ((adr >> 1) & 0x7fc00) | (adr & 0x3ff); + return (GVRAM[adr] & 0x0f); + } + } + else + { + if (adr & 0x400) + { + /* page 1 */ + adr = ((adr >> 1) & 0x7fc00) | (adr & 0x3ff); + return (GVRAM[adr ^ 1] >> 4); + } + else + { + /* page 0 */ + adr = ((adr >> 1) & 0x7fc00) | (adr & 0x3ff); + return (GVRAM[adr ^ 1] & 0x0f); + } + } + break; + + case 1: /* 512 dot, 16 colors */ + if ((adr & 1) == 0) + return 0; + + if (adr < 0x80000) + { + /* page 0: Low byte of word b0-b3 */ + return (GVRAM[adr ^ 1] & 0x0f); + } + + if (adr < 0x100000) + { + /* page 1: Low byte of word b4-b7 */ + adr &= 0x7ffff; + return (GVRAM[adr ^ 1] >> 4); + } + + if (adr < 0x180000) + { + /* page 2: High byte of word b0-b3 */ + adr &= 0x7ffff; + return (GVRAM[adr] & 0x0f); + } + + /* page 3: High byte of word b4-b7 */ + adr &= 0x7ffff; + return (GVRAM[adr] >> 4); + + case 2: /* 512 dot, 256 colors */ + case 3: /* unknown */ + /* page 0 */ if (adr < 0x80000) - return GVRAM[adr]; + { + if (adr & 1) + { + /* Low byte of word */ + return GVRAM[adr ^ 1]; + } + return 0; + } + + /* page 1 */ + if (adr < 0x100000) + { + adr &= 0x7ffff; + if (adr & 1) + { + /* High byte of word */ + return GVRAM[adr]; + } + return 0; + } +#if 0 + else + { + /* bus error */ + BusErrFlag = 1; + return 0xff; + } +#endif + break; + + + case 4: /* 65536 */ + if (adr < 0x80000) { + return GVRAM[adr ^ 1]; + } +#if 0 + else + { + /* bus error */ + BusErrFlag = 1; + return 0xff; + } +#endif + break; + } - else - { - switch(CRTC_Regs[0x28] & 3) - { - case 0: /* 16 colors */ - if (!(adr&1)) - { - uint16_t *ram; - uint8_t page; - if (CRTC_Regs[0x28] & 4) /* 1024dot */ - { - ram = (uint16_t*)(&GVRAM[((adr & 0xff800) >> 1)+(adr & 0x3fe)]); - page = (uint8_t)((adr >> 17) & 0x08); - page += (uint8_t)((adr >> 8) & 4); - } - else - { - ram = (uint16_t*)(&GVRAM[adr & 0x7fffe]); - page = (uint8_t)((adr >> 17) & 0x0c); - } - return (((*ram) >> page) & 15); - } - break; - case 1: /* 256 */ - case 2: /* Unknown */ - if ( adr<0x100000 ) - { - if (!(adr&1)) - { - uint16_t *ram = (uint16_t*)(&GVRAM[adr & 0x7fffe]); - uint8_t page = (uint8_t)((adr >> 16) & 0x08); - return (uint8_t)((*ram) >> page); - } - } - break; - case 3: /* 65536 */ - if (adr < 0x80000) - return GVRAM[adr]; - break; - } - } + return 0; } - -/* - * VRAM Write - */ void FASTCALL GVRAM_Write(uint32_t adr, uint8_t data) { - int line = 1023; + int line = 1023, scr = 0; + uint32_t temp; + int type; -#ifndef MSB_FIRST - adr ^= 1; -#endif - adr -= 0xc00000; + adr &= 0x1fffff; - if (CRTC_Regs[0x28]&8) /* 65536真真VRAM真真真Nemesis真 */ - { - if ( adr<0x80000 ) - { - GVRAM[adr] = data; - line = (((adr & 0x7ffff) / 1024)-GrphScrollY[0]) & 511; - } - } + if (CRTC_Regs[0x28] & 8) + type = 4; + else if (CRTC_Regs[0x28] & 4) + type = 0; else - { - switch(CRTC_Regs[0x28] & 3) - { - case 0: /* 16 colors */ - if (adr & 1) - break; - if (CRTC_Regs[0x28] & 4) /* 1024dot */ - { - uint16_t temp; - uint16_t *ram = (uint16_t*)(&GVRAM[((adr & 0xff800) >> 1)+(adr & 0x3fe)]); - uint8_t page = (uint8_t)((adr >> 17) & 0x08); - page += (uint8_t)((adr >> 8) & 4); - temp = ((uint16_t)data & 15) << page; - *ram = ((*ram) & (~(0xf << page))) | temp; - line = ((adr / 2048)-GrphScrollY[0]) & 1023; - } - else - { - int scr = 0; - uint16_t *ram = (uint16_t*)(&GVRAM[adr&0x7fffe]); - uint8_t page = (uint8_t)((adr >> 17) & 0x0c); - uint16_t temp = ((uint16_t)data & 15) << page; - *ram = ((*ram) & (~(0xf << page))) | temp; - switch(adr/0x80000) - { - case 0: scr = GrphScrollY[0]; break; - case 1: scr = GrphScrollY[1]; break; - case 2: scr = GrphScrollY[2]; break; - case 3: scr = GrphScrollY[3]; break; - } - line = (((adr & 0x7ffff) / 1024) - scr) & 511; - } - break; - case 1: /* 256 colors */ - case 2: /* Unknown */ - if (adr < 0x100000) - { - if (!(adr & 1)) - { - int scr = GrphScrollY[(adr >> 18) & 2]; - line = (((adr & 0x7ffff) >> 10)-scr) & 511; - TextDirtyLine[line] = 1; - scr = GrphScrollY[((adr >> 18) & 2)+1]; - line = (((adr & 0x7ffff) >> 10)-scr) & 511; - if (adr & 0x80000) - adr += 1; - adr &= 0x7ffff; - GVRAM[adr] = data; - } - } - break; - case 3: /* 65536 colors */ - if (adr < 0x80000) - { - GVRAM[adr] = data; - line = (((adr & 0x7ffff) >> 10)-GrphScrollY[0]) & 511; - } - break; - } - TextDirtyLine[line] = 1; - } + type = (CRTC_Regs[0x28] & 3) + 1; + + switch (type) + { + case 0: /* 1024 dot, 16 colors */ + if ((adr & 1) == 0) + break; + + line = ((adr / 2048) - GrphScrollY[0]) & 1023; + + if (adr & 0x100000) + { + if (adr & 0x400) + { + adr = ((adr & 0xff800) >> 1) + (adr & 0x3ff); + temp = GVRAM[adr] & 0x0f; + temp |= (data & 0x0f) << 4; + GVRAM[adr] = (uint8_t)temp; + } + else + { + adr = ((adr & 0xff800) >> 1) + (adr & 0x3ff); + temp = GVRAM[adr] & 0xf0; + temp |= data & 0x0f; + GVRAM[adr] = (uint8_t)temp; + } + } + else + { + if (adr & 0x400) + { + adr = ((adr & 0xff800) >> 1) + (adr & 0x3ff); + temp = GVRAM[adr ^ 1] & 0x0f; + temp |= (data & 0x0f) << 4; + GVRAM[adr ^ 1] = (uint8_t)temp; + } + else + { + adr = ((adr & 0xff800) >> 1) + (adr & 0x3ff); + temp = GVRAM[adr ^ 1] & 0xf0; + temp |= data & 0x0f; + GVRAM[adr ^ 1] = (uint8_t)temp; + } + } + break; + + case 1: /* 16 colors */ + if ((adr & 1) == 0) + break; + + scr = GrphScrollY[(adr >> 19) & 3]; + line = (((adr & 0x7ffff) >> 10) - scr) & 511; + + if (adr < 0x80000) + { + /* page 0: low byte of word b0-b3 */ + temp = (GVRAM[adr ^ 1] & 0xf0); + temp |= (data & 0x0f); + GVRAM[adr ^ 1] = (uint8_t)temp; + } + else if (adr < 0x100000) + { + /* page 1: low byte of word b4-b7 */ + adr &= 0x7ffff; + temp = (GVRAM[adr ^ 1] & 0x0f); + temp |= (data << 4); + GVRAM[adr ^ 1] = (uint8_t)temp; + } + else if (adr < 0x180000) + { + /* page 2: high byte of word b0-b3 */ + adr &= 0x7ffff; + temp = (GVRAM[adr] & 0xf0); + temp |= (data & 0x0f); + GVRAM[adr] = (uint8_t)temp; + } + else + { + /* page 3: high byte of word b4-b7 */ + adr &= 0x7ffff; + temp = (GVRAM[adr] & 0x0f); + temp |= (data << 4); + GVRAM[adr] = (uint8_t)temp; + } + break; + + case 2: /* 256 colors */ + case 3: /* unknown */ + if ((adr & 1) == 0) + break; + + if (adr < 0x100000) + { + scr = GrphScrollY[(adr >> 18) & 2]; + line = (((adr & 0x7ffff) >> 10) - scr) & 511; + + TextDirtyLine[line] = 1; /* When used like 32 colors, 4 sides */ + + scr = GrphScrollY[((adr >> 18) & 2) + 1]; + line = (((adr & 0x7ffff) >> 10) - scr) & 511; + + /* page 0 */ + if (adr < 0x80000) + { + /* low byte of word */ + GVRAM[adr ^ 1] = (uint8_t)data; + } + /* page 1 */ + else + { + /* high byte of word */ + adr &= 0x7ffff; + GVRAM[adr] = (uint8_t)data; + } + } +#if 0 + /* TODO: */ + else + { + BusErrFlag = 1; + return; + } +#endif + break; + + case 4: /* 65536 */ + if (adr < 0x80000) + { + line = (((adr & 0x7ffff) >> 10) - GrphScrollY[0]) & 511; + GVRAM[adr ^ 1] = (uint8_t)data; + } +#if 0 + /* TODO: */ + else + { + BusErrFlag = 1; + return; + } +#endif + break; + } + + TextDirtyLine[line] = 1; } /* - * 真推真真真真?真真真真真 + * From here on, the screen will be expanded line by line. */ void Grp_DrawLine16(void) { @@ -384,7 +524,7 @@ void FASTCALL Grp_DrawLine8(int page, int opaq) } } -/* Manhattan Requiem Opening 7.0真7.5MHz */ +/* Manhattan Requiem Opening 7.0鐔随戎7.5MHz */ void FASTCALL Grp_DrawLine4(uint32_t page, int opaq) { uint16_t *srcp, *destp; /* XXX: ALIGN */ @@ -490,7 +630,6 @@ void FASTCALL Grp_DrawLine4(uint32_t page, int opaq) } } -/* 真真真真真真真真真真真真 */ void FASTCALL Grp_DrawLine4h(void) { uint16_t *srcp, *destp; @@ -532,7 +671,7 @@ void FASTCALL Grp_DrawLine4h(void) /* - * --- 真真真?Pri真真真真真真真真真真 --- + * --- 鐚号Pri若鴻若吾 --- */ void FASTCALL Grp_DrawLine16SP(void) { diff --git a/x68k/mem_wrap.c b/x68k/mem_wrap.c index 3469574f..9a5f35ee 100644 --- a/x68k/mem_wrap.c +++ b/x68k/mem_wrap.c @@ -78,7 +78,7 @@ uint8_t (*MemReadTable[])(uint32_t) = { rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, rm_font, -/* SCSI の場合は rm_buserr になる? */ + /* In the case of SCSI, will it be rm_buserr? */ rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, rm_ipl, @@ -106,7 +106,7 @@ void (*MemWriteTable[])(uint32_t, uint8_t) = { SRAM_Write, SRAM_Write, SRAM_Write, SRAM_Write, SRAM_Write, SRAM_Write, SRAM_Write, SRAM_Write, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, -/* ROMエリアへの書きこみは全てバスエラー */ + /* Any write to the ROM area results in a bus error */ wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, wm_buserr, diff --git a/x68k/mercury.c b/x68k/mercury.c index 68460c71..7a166bc6 100644 --- a/x68k/mercury.c +++ b/x68k/mercury.c @@ -49,9 +49,7 @@ int Mcry_IsReady(void) return (Mcry_SampleCnt > 0); } -/* - * MPU経過クロック時間分だけデータをバッファに溜める - */ +/* Store data in the buffer for the amount of MPU clock time elapsed */ void FASTCALL Mcry_PreUpdate(uint32_t clock) { Mcry_PreCounter += (Mcry_ClockRate*clock); @@ -63,9 +61,7 @@ void FASTCALL Mcry_PreUpdate(uint32_t clock) M288_Timer(clock); } -/* - * DSoundからの要求分だけバッファを埋める - */ +/* Fill the buffer as requested by DSound */ void FASTCALL Mcry_Update(int16_t *buffer, size_t length) { int data; @@ -104,9 +100,7 @@ void FASTCALL Mcry_Update(int16_t *buffer, size_t length) } } -/* - * 1回分(1Word x 2ch)のデータをバッファに書き出し - */ +/* Write one chunk of data (1word x 2ch) to the buffer */ static INLINE void Mcry_WriteOne(void) { while (Mcry_Count=0xecc0c0)&&(adr<=0xecc0c7)&&(adr&1) ) /* 満開版まーきゅりー OPN */ + else if ( (adr>=0xecc0c0)&&(adr<=0xecc0c7)&&(adr&1) ) /* Full-bloom version of Mercury OPN */ M288_Write((uint8_t)((adr>>1)&3), data); } - -/* - * I/O Read - */ uint8_t FASTCALL Mcry_Read(uint32_t adr) { uint8_t ret = 0; @@ -206,16 +192,14 @@ uint8_t FASTCALL Mcry_Read(uint32_t adr) } else if ( adr== 0xecc0b1 ) /* Int Vector */ ret = Mcry_Vector; - else if ( (adr>=0xecc0c0)&&(adr<=0xecc0c7)&&(adr&1) ) /* 満開版まーきゅりー OPN */ + else if ( (adr>=0xecc0c0)&&(adr<=0xecc0c7)&&(adr&1) ) /* Full-bloom version of Mercury OPN */ ret = M288_Read((uint8_t)((adr>>1)&3)); else if ( adr>=0xecc100 ) /* Bus Error? */ BusErrFlag = 1; return ret; } -/* - * 再生クロック設定 - */ +/* Regenerated Clock Settings */ void Mcry_SetClock(void) { static int32_t Mcry_Clocks[8] = { 22050, 16000, 22050, 24000 }; @@ -227,7 +211,7 @@ void Mcry_SetClock(void) } /* - * ぼりゅーむ設定 + * Volume setting */ void Mcry_SetVolume(uint8_t vol) { @@ -242,7 +226,7 @@ void Mcry_SetVolume(uint8_t vol) } /* - * 初期化~ + * Initialization~ */ void Mcry_Init(const char* path) { diff --git a/x68k/mfp.c b/x68k/mfp.c index bd1cbd01..626cc04f 100644 --- a/x68k/mfp.c +++ b/x68k/mfp.c @@ -207,7 +207,7 @@ void FASTCALL MFP_Write(uint32_t adr, uint8_t data) case MFP_IERA: case MFP_IERB: MFP[reg] = data; - MFP[reg+2] &= data; /* 禁止されたものはIPRA/Bを落とす */ + MFP[reg+2] &= data; /* Prohibited items drop IPRA/B */ MFP_RecheckInt(); break; case MFP_IPRA: @@ -235,7 +235,7 @@ void FASTCALL MFP_Write(uint32_t adr, uint8_t data) Timer_Reload[3] = MFP[reg] = data; break; case MFP_TSR: - MFP[reg] = data | 0x80; /* Txは常にEnableに */ + MFP[reg] = data | 0x80; /* Tx is always enabled */ break; case MFP_UDR: break; diff --git a/x68k/midi.c b/x68k/midi.c index a0c8fae4..488fad33 100644 --- a/x68k/midi.c +++ b/x68k/midi.c @@ -12,12 +12,12 @@ #include "midi.h" #include "m68000.h" -#define MIDIBUFFERS 1024 /* 1024は流石に越えないでしょう^_^; */ -#define MIDIBUFTIMER 3200 /* 10MHz / (31.25K / 10bit) = 3200 が正解になります... */ +#define MIDIBUFFERS 1024 /* 1024 (should never needed more than this) */ +#define MIDIBUFTIMER 3200 /* 10MHz / (31.25K / 10bit) = 3200 */ #define MIDIFIFOSIZE 256 -#define MIDIDELAYBUF 4096 /* 31250/10 = 3125 byts (1s分) あればおっけ? */ +#define MIDIDELAYBUF 4096 /* is it ok to have 31250/10 = 3125 byts (1sec)? */ -enum { /* 各機種リセット用に一応。 */ +enum { MIDI_NOTUSED, MIDI_DEFAULT, MIDI_MT32, @@ -27,7 +27,7 @@ MIDI_CM500, MIDI_SC55, MIDI_SC88, - MIDI_LA, /* 意味もなく追加してみたり */ + MIDI_LA, MIDI_GM, MIDI_GS, MIDI_XG @@ -41,7 +41,7 @@ static uint8_t MIDI_LAST; static uint8_t MIDI_BUF[MIDIBUFFERS]; static uint8_t MIDI_EXCVBUF[MIDIBUFFERS]; -static uint8_t MIDI_RegHigh = 0; /* X68K用 */ +static uint8_t MIDI_RegHigh = 0; static uint8_t MIDI_Vector = 0; static uint8_t MIDI_IntEnable = 0; static uint8_t MIDI_IntVect = 0; @@ -55,7 +55,7 @@ static int32_t MIDI_GTimerVal = 0; static int32_t MIDI_MTimerVal = 0; static uint8_t MIDI_MODULE = MIDI_NOTUSED; -static uint8_t MIDI_ResetType[5] = { /* Config.MIDI_Type に合わせて… */ +static uint8_t MIDI_ResetType[5] = { MIDI_LA, MIDI_GM, MIDI_GS, MIDI_XG }; @@ -68,9 +68,7 @@ static DELAYBUFITEM DelayBuf[MIDIDELAYBUF]; static int DBufPtrW = 0; static int DBufPtrR = 0; -/* - * ねこみぢ6、MIMPIトーンマップ対応関係 - */ +/* Nekomichi 6, MIMPI tone map compatibility */ enum { MIMPI_LA = 0, @@ -85,7 +83,7 @@ static uint8_t TONE_CH[16]; static uint8_t TONEBANK[3][128]; static uint8_t TONEMAP[3][128]; -static uint8_t EXCV_MTRESET[] = { 0xfe, 0xfe, 0xfe}; +static uint8_t EXCV_MTRESET[] = { 0xf0, 0x41, 0x10, 0x16, 0x12, 0x7f, 0x00, 0x00, 0x00, 0x01, 0xf7 }; static uint8_t EXCV_GMRESET[] = { 0xf0, 0x7e, 0x7f, 0x09, 0x01, 0xf7}; static uint8_t EXCV_GSRESET[] = { 0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7}; static uint8_t EXCV_XGRESET[] = { 0xf0, 0x43, 0x10, 0x4C, 0x00, 0x00, 0x7E, 0x00, 0xf7}; @@ -161,7 +159,7 @@ static uint32_t FASTCALL MIDI_Int(uint8_t irq) void FASTCALL MIDI_Timer(uint32_t clk) { - if ( !Config.MIDI_SW ) return; /* MIDI OFF時は帰る */ + if ( !Config.MIDI_SW ) return; /* return when MIDI is OFF */ MIDI_BufTimer -= clk; if (MIDI_BufTimer<0) @@ -170,7 +168,7 @@ void FASTCALL MIDI_Timer(uint32_t clk) if (MIDI_Buffered) { MIDI_Buffered--; - if ( (MIDI_Buffered= MIDIBUFFERS) /* おーばーふろー */ + else if (MIDI_POS >= MIDIBUFFERS) /* overflow */ MIDI_CTRL = MIDICTRL_READY; break; case MIDICTRL_TIMECODE: if (MIDI_POS >= 2) { - /* exclusiveと同じでいい筈… */ + /* it should be the same as exclusive */ if ((mes == 0x7e) || (mes == 0x7f)) MIDI_CTRL = MIDICTRL_EXCLUSIVE; else @@ -466,17 +469,13 @@ void MIDI_Message(uint8_t mes) } } - -/* - * I/O Read - */ uint8_t FASTCALL MIDI_Read(uint32_t adr) { uint8_t ret = 0; - if ( (adr<0xeafa01)||(adr>=0xeafa10)||(!Config.MIDI_SW) ) /* 変なアドレスか、 */ + if ( (adr<0xeafa01)||(adr>=0xeafa10)||(!Config.MIDI_SW) ) /* 紊≪鴻 */ { - /* MIDI OFF時にはバスエラーにする */ + /* When MIDI is OFF, a bus error occurs */ BusErrFlag = 1; return 0; } @@ -533,13 +532,11 @@ void MIDI_DelayOut(unsigned int delay) } } -/* - * I/O Write - */ void FASTCALL MIDI_Write(uint32_t adr, uint8_t data) { if ( (adr<0xeafa01)||(adr>=0xeafa10)||(!Config.MIDI_SW) ) { + /* When MIDI is OFF, a bus error occurs */ BusErrFlag = 1; return; } diff --git a/x68k/pia.c b/x68k/pia.c index c9d1d1ae..a3d61284 100644 --- a/x68k/pia.c +++ b/x68k/pia.c @@ -1,5 +1,5 @@ /* - * PIA.C - uPD8255 + * PIA.C - uPD8255 (only the bare minimum) */ #include "common.h" diff --git a/x68k/rtc.c b/x68k/rtc.c index 1eba5e9a..3bf7b2ac 100644 --- a/x68k/rtc.c +++ b/x68k/rtc.c @@ -81,10 +81,10 @@ void FASTCALL RTC_Write(uint32_t adr, uint8_t data) { if ( adr==0xe8a001 ) return; - if ( adr==0xe8a01b ) /* Alarm/Timer Enable制御 */ + if ( adr==0xe8a01b ) /* Alarm/Timer Enable control */ RTC_Regs[0][13] = RTC_Regs[1][13] = data & 0x0c; - else if ( adr==0xe8a01f ) /* Alarm端子出力制御 */ - RTC_Regs[0][15] = RTC_Regs[1][15] = data & 0x0c; + else if ( adr==0xe8a01f ) /* Alarm terminal output control */ + RTC_Regs[0][15] = RTC_Regs[1][15] = data & 0x0c; } void RTC_Timer(int clock) diff --git a/x68k/sasi.c b/x68k/sasi.c index 2567edc3..c71e2963 100644 --- a/x68k/sasi.c +++ b/x68k/sasi.c @@ -123,9 +123,6 @@ static int16_t SASI_Flush(void) return 0; } -/* - * I/O Read - */ uint8_t FASTCALL SASI_Read(uint32_t adr) { uint8_t ret = 0; @@ -141,7 +138,7 @@ uint8_t FASTCALL SASI_Read(uint32_t adr) ret |= 8; /* C/D */ if ((SASI_Phase==3)&&(SASI_RW)) /* SASI_RW=1:Read */ ret |= 4; /* I/O */ - if (SASI_Phase==9) /* Phase=9:SenseStatus中 */ + if (SASI_Phase==9) /* Phase=9:SenseStatus筝 */ ret |= 4; /* I/O */ if ((SASI_Phase==4)||(SASI_Phase==5)) ret |= 0x0c; /* I/O & C/D */ @@ -180,14 +177,14 @@ uint8_t FASTCALL SASI_Read(uint32_t adr) SASI_Phase++; } else if (SASI_Phase==5) /* MessagePhase */ - SASI_Phase = 0; - else if (SASI_Phase==9) /* DataPhase(SenseStat専用) */ + SASI_Phase = 0; /* Just return 0. Return to BusFree */ + else if (SASI_Phase==9) /* DataPhase(SenseStatExclusive) */ { ret = SASI_SenseStatBuf[SASI_SenseStatPtr++]; if (SASI_SenseStatPtr==4) { SASI_Error = 0; - SASI_Phase = 4; /* StatusPhaseへ */ + SASI_Phase = 4; /* StatusPhase */ } } if (SASI_Phase==4) @@ -202,6 +199,11 @@ uint8_t FASTCALL SASI_Read(uint32_t adr) return ret; } +/* Check the command. To be honest, the description in InsideX68k is not enough ^^;. +* As for what is not described, +* - C2h (initialization?). No parameters other than Unit. Write 10 pieces of data in DataPhase. +* - 06h (format?). Logical block specified (specified every 21h). 6 is specified for the number of blocks. +*/ static void SASI_CheckCmd(void) { int16_t result; @@ -295,10 +297,6 @@ static void SASI_CheckCmd(void) } } - -/* - * I/O Write - */ void FASTCALL SASI_Write(uint32_t adr, uint8_t data) { int16_t result; diff --git a/x68k/scc.c b/x68k/scc.c index 8df96af0..b3906691 100644 --- a/x68k/scc.c +++ b/x68k/scc.c @@ -1,5 +1,5 @@ /* - * SCC.C - Z8530 SCC + * SCC.C - Z8530 SCC (mouse only) */ #include "common.h" @@ -89,9 +89,6 @@ void SCC_Init(void) SCC_DatNum = 0; } -/* - * I/O Write - */ void FASTCALL SCC_Write(uint32_t adr, uint8_t data) { if (adr>=0xe98008) @@ -167,10 +164,6 @@ void FASTCALL SCC_Write(uint32_t adr, uint8_t data) } } - -/* - * I/O Read - */ uint8_t FASTCALL SCC_Read(uint32_t adr) { uint8_t ret = 0; diff --git a/x68k/scsi.c b/x68k/scsi.c index ee750f12..2131cc6c 100644 --- a/x68k/scsi.c +++ b/x68k/scsi.c @@ -1,3 +1,9 @@ +/* +* SCSI.C - External SCSI board (CZ-6BS1) +* Supported by taking over SCSI IOCS (SPC is not emulated) +* Built-in SCSI (dummy) IPL is defined in winx68k.c +*/ + #include "common.h" #include "../libretro/dosio.h" #include "winx68k.h" @@ -8,20 +14,24 @@ uint8_t SCSIIPL[0x2000]; void SCSI_Init(void) { + /* Original SCSI ROM + * Operation: When SCSI IOCS is called, the SCSI IOCS number is output to $e9f800. + * Booting from a SCSI device is not possible, the initialization routine only sets the vector for SCSI IOCS ($F5). + */ static uint8_t SCSIIMG[] = { - 0x00, 0xea, 0x00, 0x34, /* $ea0020 SCSI起動用のエントリアドレス */ - 0x00, 0xea, 0x00, 0x36, /* $ea0024 IOCSベクタ設定のエントリアドレス(必ず"Human"の8バイト前) */ - 0x00, 0xea, 0x00, 0x4a, /* $ea0028 SCSI IOCSエントリアドレス */ - 0x48, 0x75, 0x6d, 0x61, /* $ea002c ↓ */ - 0x6e, 0x36, 0x38, 0x6b, /* $ea0030 ID "Human68k" (必ず起動エントリポイントの直前) */ - 0x4e, 0x75, /* $ea0034 "rts" (起動エントリポイント、何もしないよ) */ - 0x23, 0xfc, 0x00, 0xea, 0x00, 0x4a, /* $ea0036 ↓ (IOCSベクタ設定エントリポイント) */ - 0x00, 0x00, 0x07, 0xd4, /* $ea003c "move.l #$ea004a, $7d4.l" (IOCS $F5のベクタ設定) */ - 0x74, 0xff, /* $ea0040 "moveq #-1, d2" */ - 0x4e, 0x75, /* $ea0042 "rts" */ - 0x53, 0x43, 0x53, 0x49, 0x45, 0x58, /* $ea0044 ID "SCSIEX" (SCSIカードのID) */ - 0x13, 0xc1, 0x00, 0xe9, 0xf8, 0x00, /* $ea004a "move.b d1, $e9f800" (SCSI IOCSコールエントリポイント) */ - 0x4e, 0x75, /* $ea0050 "rts" */ + 0x00, 0xea, 0x00, 0x34, /* $ea0020 Entry address for SCSI startup */ + 0x00, 0xea, 0x00, 0x36, /* $ea0024 Entry address of IOCS vector setting (must be 8 bytes before "Human") */ + 0x00, 0xea, 0x00, 0x4a, /* $ea0028 SCSI IOCS entry address */ + 0x48, 0x75, 0x6d, 0x61, /* $ea002c */ + 0x6e, 0x36, 0x38, 0x6b, /* $ea0030 ID "Human68k" (always right before the startup entry point) */ + 0x4e, 0x75, /* $ea0034 "rts" (startup entry point, does nothing) */ + 0x23, 0xfc, 0x00, 0xea, 0x00, 0x4a, /* $ea0036 (IOCS vector setting entry point) */ + 0x00, 0x00, 0x07, 0xd4, /* $ea003c "move.l #$ea004a, $7d4.l" (IOCS $F5 vector setting) */ + 0x74, 0xff, /* $ea0040 "moveq #-1, d2" */ + 0x4e, 0x75, /* $ea0042 "rts" */ + 0x53, 0x43, 0x53, 0x49, 0x45, 0x58, /* $ea0044 ID "SCSIEX" (SCSI card ID) */ + 0x13, 0xc1, 0x00, 0xe9, 0xf8, 0x00, /* $ea004a "move.b d1, $e9f800" (SCSI IOCS call entry point) */ + 0x4e, 0x75, /* $ea0050 "rts" */ }; int i; uint8_t tmp; diff --git a/x68k/tvram.c b/x68k/tvram.c index c3fc800d..0f7560d8 100644 --- a/x68k/tvram.c +++ b/x68k/tvram.c @@ -1,5 +1,6 @@ /* * TVRAM.C - Text VRAM + * TODO: Transparent color processing and more */ #include "common.h" @@ -48,7 +49,7 @@ void TVRAM_Init(void) memset(TextDrawWork, 0, 1024*1024); TVRAM_SetAllDirty(); - memset(TextDrawPattern, 0, 2048*4); /* パターンテーブル初期化 */ + memset(TextDrawPattern, 0, 2048*4); for (i=0; i<256; i++) { for (j=0, bit=0x80; j<8; j++, bit>>=1) @@ -99,7 +100,7 @@ void FASTCALL TVRAM_Write(uint32_t adr, uint8_t data) #ifndef MSB_FIRST adr ^= 1; #endif - if (CRTC_Regs[0x2a]&1) + if (CRTC_Regs[0x2a]&1) /* Concurrent access */ { adr &= 0x1ffff; if (CRTC_Regs[0x2a]&2) /* Text Mask */ @@ -117,7 +118,7 @@ void FASTCALL TVRAM_Write(uint32_t adr, uint8_t data) if (CRTC_Regs[0x2b]&0x80) TVRAM_WriteByte(adr+0x60000, data); } } - else + else /* single access */ { if (CRTC_Regs[0x2a]&2) /* Text Mask */ TVRAM_WriteByteMask(adr, data);