Skip to content

Commit

Permalink
x68k: Change file encoding from Shift JIS/EUC-JP to UTF-8, translate
Browse files Browse the repository at this point in the history
some comments to English and cleanup

- covert encoding from jis/euc-jp to utf-8
- translate a few comments to english
- gvram: unroll gvram read/write function
- minor cleanups
  • Loading branch information
negativeExponent committed Sep 13, 2024
1 parent 1f4d6c0 commit 393deaa
Show file tree
Hide file tree
Showing 15 changed files with 443 additions and 337 deletions.
12 changes: 1 addition & 11 deletions x68k/adpcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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) )
Expand All @@ -375,10 +369,6 @@ void ADPCM_SetPan(int n)
ADPCM_Pan = n;
}


/*
* Clock
*/
void ADPCM_SetClock(int n)
{
if ( (ADPCM_Clock&4)!=n )
Expand Down
23 changes: 14 additions & 9 deletions x68k/bg.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* BG.C - BG and sprites
* TODO: Check transparent color processing (especially with Text)
*/

#include <string.h>

#include "common.h"
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand All @@ -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();
Expand Down Expand Up @@ -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)
{
Expand All @@ -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_CHREND) /* パターンエリア */
if (adr<BG_CHREND) /* pattern area */
TVRAM_SetAllDirty();
if ((adr>=BG_BG1TOP)&&(adr<BG_BG1END)) /* BG1 MAPエリア */
if ((adr>=BG_BG1TOP)&&(adr<BG_BG1END)) /* BG1 MAP Area */
TVRAM_SetAllDirty();
if ((adr>=BG_BG0TOP)&&(adr<BG_BG0END)) /* BG0 MAPエリア */
if ((adr>=BG_BG0TOP)&&(adr<BG_BG0END)) /* BG0 MAP Area */
TVRAM_SetAllDirty();
}
}
Expand Down
94 changes: 44 additions & 50 deletions x68k/crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ void CRTC_Init(void)
TextScrollY = 0;
}

static void CRTC_ScreenChanged(void)
{
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;
}

uint8_t FASTCALL CRTC_Read(uint32_t adr)
{
uint8_t ret;
Expand Down Expand Up @@ -204,12 +220,20 @@ void FASTCALL CRTC_Write(uint32_t adr, uint8_t data)
TVRAM_SetAllDirty();
switch(reg)
{
case 0x00:
case 0x01:
/* HTOTAL */
break;
case 0x02:
case 0x03:
/* HSYNC End */
break;
case 0x04:
case 0x05:
CRTC_HSTART = (((uint16_t)CRTC_Regs[0x4] << 8) + CRTC_Regs[0x5]) & 1023;
if (CRTC_HEND > 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:
Expand All @@ -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();
Expand All @@ -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:
Expand Down Expand Up @@ -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();
Expand All @@ -342,18 +336,18 @@ 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 */
CRTC_RasterCopy();
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];
}
}
Expand Down
17 changes: 6 additions & 11 deletions x68k/fdc.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -136,10 +135,6 @@ uint32_t FASTCALL FDC_Int(uint8_t irq)
return -1;
}


/*
* 初期化
*/
void FDC_Init(void)
{
memset(&fdc, 0, sizeof(FDC));
Expand All @@ -160,7 +155,7 @@ static void FDC_SetInt(void)


/*
* Excution Phase の終了
* End of Execution Phase
*/
static void FDC_EPhaseEnd(void)
{
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 393deaa

Please sign in to comment.