Skip to content

Commit

Permalink
Implemented CD support from WinUAE
Browse files Browse the repository at this point in the history
- Added support for CD mounting under AmigaOS - fixes #37
- Added CDTV implementation (WIP #658)
  • Loading branch information
midwan committed Jun 17, 2020
1 parent 3938d97 commit 725f2c7
Show file tree
Hide file tree
Showing 55 changed files with 20,682 additions and 2,195 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ OBJS = \
src/cd32_fmv.o \
src/cd32_fmv_genlock.o \
src/cdrom.o \
src/cdtv.o \
src/cdtvcr.o \
src/cfgfile.o \
src/cia.o \
src/crc32.o \
Expand All @@ -315,6 +317,7 @@ OBJS = \
src/hrtmon.rom.o \
src/ide.o \
src/inputdevice.o \
src/isofs.o \
src/keybuf.o \
src/main.o \
src/memory.o \
Expand All @@ -324,6 +327,7 @@ OBJS = \
src/savestate.o \
src/scp.o \
src/scsi.o \
src/scsiemul.o \
src/statusline.o \
src/traps.o \
src/uaelib.o \
Expand Down
9 changes: 9 additions & 0 deletions VisualGDB/Amiberry/Amiberry.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
<ClCompile Include="..\..\src\cd32_fmv.cpp" />
<ClCompile Include="..\..\src\cd32_fmv_genlock.cpp" />
<ClCompile Include="..\..\src\cdrom.cpp" />
<ClCompile Include="..\..\src\cdtv.cpp" />
<ClCompile Include="..\..\src\cdtvcr.cpp" />
<ClCompile Include="..\..\src\cfgfile.cpp" />
<ClCompile Include="..\..\src\cia.cpp" />
<ClCompile Include="..\..\src\cpudefs.cpp" />
Expand Down Expand Up @@ -233,6 +235,7 @@
<ClCompile Include="..\..\src\hrtmon.rom.cpp" />
<ClCompile Include="..\..\src\ide.cpp" />
<ClCompile Include="..\..\src\inputdevice.cpp" />
<ClCompile Include="..\..\src\isofs.cpp" />
<ClCompile Include="..\..\src\jit\compemu.cpp" />
<ClCompile Include="..\..\src\jit\compemu_fpp.cpp" />
<ClCompile Include="..\..\src\jit\compemu_support.cpp" />
Expand Down Expand Up @@ -296,6 +299,7 @@
<ClCompile Include="..\..\src\savestate.cpp" />
<ClCompile Include="..\..\src\scp.cpp" />
<ClCompile Include="..\..\src\scsi.cpp" />
<ClCompile Include="..\..\src\scsiemul.cpp" />
<ClCompile Include="..\..\src\sounddep\sound.cpp" />
<ClCompile Include="..\..\src\statusline.cpp" />
<ClCompile Include="..\..\src\traps.cpp" />
Expand Down Expand Up @@ -367,6 +371,8 @@
<ClInclude Include="..\..\src\include\bsdsocket.h" />
<ClInclude Include="..\..\src\include\calc.h" />
<ClInclude Include="..\..\src\include\cd32_fmv.h" />
<ClInclude Include="..\..\src\include\cdtv.h" />
<ClInclude Include="..\..\src\include\cdtvcr.h" />
<ClInclude Include="..\..\src\include\cia.h" />
<ClInclude Include="..\..\src\include\commpipe.h" />
<ClInclude Include="..\..\src\include\cpummu.h" />
Expand Down Expand Up @@ -394,6 +400,8 @@
<ClInclude Include="..\..\src\include\gui.h" />
<ClInclude Include="..\..\src\include\ide.h" />
<ClInclude Include="..\..\src\include\inputdevice.h" />
<ClInclude Include="..\..\src\include\isofs.h" />
<ClInclude Include="..\..\src\include\isofs_api.h" />
<ClInclude Include="..\..\src\include\keyboard.h" />
<ClInclude Include="..\..\src\include\keybuf.h" />
<ClInclude Include="..\..\src\include\memory.h" />
Expand All @@ -409,6 +417,7 @@
<ClInclude Include="..\..\src\include\savestate.h" />
<ClInclude Include="..\..\src\include\scp.h" />
<ClInclude Include="..\..\src\include\scsi.h" />
<ClInclude Include="..\..\src\include\scsidev.h" />
<ClInclude Include="..\..\src\include\statusline.h" />
<ClInclude Include="..\..\src\include\sysdeps.h" />
<ClInclude Include="..\..\src\include\traps.h" />
Expand Down
27 changes: 27 additions & 0 deletions VisualGDB/Amiberry/Amiberry.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,18 @@
<ClCompile Include="..\..\src\def_icons.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cdtv.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cdtvcr.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\isofs.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\scsiemul.cpp">
<Filter>Source files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\threaddep\thread.h">
Expand Down Expand Up @@ -975,5 +987,20 @@
<ClInclude Include="..\..\src\include\scp.h">
<Filter>Source files\include</Filter>
</ClInclude>
<ClInclude Include="..\..\src\include\cdtv.h">
<Filter>Source files\include</Filter>
</ClInclude>
<ClInclude Include="..\..\src\include\cdtvcr.h">
<Filter>Source files\include</Filter>
</ClInclude>
<ClInclude Include="..\..\src\include\isofs.h">
<Filter>Source files\include</Filter>
</ClInclude>
<ClInclude Include="..\..\src\include\isofs_api.h">
<Filter>Source files\include</Filter>
</ClInclude>
<ClInclude Include="..\..\src\include\scsidev.h">
<Filter>Source files\include</Filter>
</ClInclude>
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/ar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1698,9 +1698,9 @@ int hrtmon_load (void)
cart_type = CART_AR;
hrtmem_start = 0xa10000;
if(!_tcscmp(currprefs.cartfile, _T(":HRTMon")))
rd = getromdatabyid(63);
rd = getromdatabyid(63);
else
rd = getromdatabypath(currprefs.cartfile);
rd = getromdatabypath(currprefs.cartfile);
if (rd) {
if (rd->id == 63)
isinternal = 1;
Expand Down
92 changes: 47 additions & 45 deletions src/autoconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ addrbank rtarea_bank = {
rtarea_lput, rtarea_wput, rtarea_bput,
rtarea_xlate, rtarea_check, NULL, _T("rtarea"), _T("UAE Boot ROM"),
rtarea_wget,
ABFLAG_ROMIN, S_READ, S_WRITE
ABFLAG_ROMIN | ABFLAG_PPCIOSPACE, S_READ, S_WRITE
};

#define MAX_ABSOLUTE_ROM_ADDRESS 1024
Expand Down Expand Up @@ -96,6 +96,7 @@ static void rethink_traps(void)
rethink_traps2();
}


#define RTAREA_WRITEOFFSET 0xfff0

static bool rtarea_trap_data(uaecptr addr)
Expand Down Expand Up @@ -123,7 +124,7 @@ static bool rtarea_trap_status_extra(uaecptr addr)
return false;
}

static uae_u8 *REGPARAM2 rtarea_xlate(uaecptr addr)
static uae_u8 *REGPARAM2 rtarea_xlate (uaecptr addr)
{
addr &= 0xFFFF;
return rtarea_bank.baseaddr + addr;
Expand Down Expand Up @@ -334,8 +335,8 @@ void rtarea_reset(void)
}

/* some quick & dirty code to fill in the rt area and save me a lot of
* scratch paper
*/
* scratch paper
*/

static int rt_addr;
static int rt_straddr;
Expand Down Expand Up @@ -370,7 +371,7 @@ void df(uae_u8 b, int len)
rt_addr += len;
}

uae_u8 dbg(uaecptr addr)
uae_u8 dbg (uaecptr addr)
{
addr &= 0xffff;
return rtarea_bank.baseaddr[addr];
Expand Down Expand Up @@ -407,17 +408,17 @@ uae_u32 dsf(uae_u8 b, int len)
return addr(rt_straddr);
}

uae_u32 ds_bstr_ansi(const uae_char *str)
uae_u32 ds_bstr_ansi (const uae_char *str)
{
int len;

len = strlen(str) + 2;
len = strlen (str) + 2;
rt_straddr -= len;
while (rt_straddr & 3)
rt_straddr--;
rtarea_bank.baseaddr[rt_straddr] = len - 2;
strcpy((uae_char*)rtarea_bank.baseaddr + rt_straddr + 1, str);
return addr(rt_straddr) >> 2;
strcpy ((uae_char*)rtarea_bank.baseaddr + rt_straddr + 1, str);
return addr (rt_straddr) >> 2;
}

void save_rom_absolute(uaecptr addr)
Expand Down Expand Up @@ -511,26 +512,26 @@ void calltrap (uae_u32 n)
}
}

void org(uae_u32 a)
void org (uae_u32 a)
{
if (((a & 0xffff0000) != 0x00f00000) && ((a & 0xffff0000) != rtarea_base))
write_log(_T("ORG: corrupt address! %08X"), a);
if ( ((a & 0xffff0000) != 0x00f00000) && ((a & 0xffff0000) != rtarea_base) )
write_log (_T("ORG: corrupt address! %08X"), a);
rt_addr = a & 0xffff;
}

uae_u32 here(void)
uae_u32 here (void)
{
return addr(rt_addr);
return addr (rt_addr);
}

void align(int b)
void align (int b)
{
rt_addr = (rt_addr + b - 1) & ~(b - 1);
}

static uae_u32 REGPARAM2 nullfunc(TrapContext *ctx)
static uae_u32 REGPARAM2 nullfunc (TrapContext *ctx)
{
write_log(_T("Null function called\n"));
write_log (_T("Null function called\n"));
return 0;
}

Expand All @@ -544,19 +545,19 @@ static uae_u32 REGPARAM2 getchipmemsize (TrapContext *ctx)
static uae_u32 REGPARAM2 uae_puts (TrapContext *ctx)
{
uae_char buf[MAX_DPATH];
trap_get_string(ctx, buf, trap_get_areg(ctx, 0), sizeof (uae_char));
trap_get_string(ctx, buf, trap_get_areg(ctx, 0), sizeof(uae_char));
TCHAR *s = au(buf);
write_log(_T("%s"), s);
xfree(s);
return 0;
}

static void rtarea_init_mem (void)
void rtarea_init_mem (void)
{
rtarea_bank.reserved_size = RTAREA_SIZE;
rtarea_bank.start = rtarea_base;
if (!mapped_malloc(&rtarea_bank)) {
write_log(_T("virtual memory exhausted (rtarea)!\n"));
if (!mapped_malloc (&rtarea_bank)) {
write_log (_T("virtual memory exhausted (rtarea)!\n"));
abort ();
}
}
Expand All @@ -578,21 +579,21 @@ void rtarea_init(void)
trap_entry = 0;
absolute_rom_address = 0;
rombase_new = 0;

init_traps();

rtarea_init_mem();
memset(rtarea_bank.baseaddr, 0, RTAREA_SIZE);
init_traps ();

rtarea_init_mem ();
memset (rtarea_bank.baseaddr, 0, RTAREA_SIZE);

_stprintf(uaever, _T("uae-%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
_stprintf (uaever, _T("uae-%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);

EXPANSION_uaeversion = ds (uaever);
EXPANSION_explibname = ds (_T("expansion.library"));
EXPANSION_doslibname = ds (_T("dos.library"));
EXPANSION_uaedevname = ds (_T("uae.device"));

dw(0);
dw(0);
dw (0);
dw (0);

#ifdef FILESYS
filesys_install_code();
Expand All @@ -604,38 +605,38 @@ void rtarea_init(void)
uae_sem_init(&hardware_trap_event[i], 0, 0);
uae_sem_init(&hardware_trap_event2[i], 0, 0);
}

#endif

deftrap(NULL); /* Generic emulator trap */

a = here();
a = here ();
/* Dummy trap - removing this breaks the filesys emulation. */
org(rtarea_base + 0xFF00);
calltrap(deftrap2(nullfunc, TRAPFLAG_NO_RETVAL, _T("")));
org (rtarea_base + 0xFF00);
calltrap (deftrap2 (nullfunc, TRAPFLAG_NO_RETVAL, _T("")));

org(rtarea_base + 0xFF80);
calltrap(deftrapres(getchipmemsize, TRAPFLAG_DORET, _T("getchipmemsize")));
org (rtarea_base + 0xFF80);
calltrap (deftrapres (getchipmemsize, TRAPFLAG_DORET, _T("getchipmemsize")));
dw(RTS);

org (rtarea_base + 0xFF10);
calltrap (deftrapres (uae_puts, TRAPFLAG_NO_RETVAL, _T("uae_puts")));
dw (RTS);

org(a);

uae_boot_rom_size = here() - rtarea_base;
org (a);

uae_boot_rom_size = here () - rtarea_base;
if (uae_boot_rom_size >= RTAREA_TRAPS) {
write_log(_T("RTAREA_TRAPS needs to be increased!"));
write_log (_T("RTAREA_TRAPS needs to be increased!"));
abort ();
}

#ifdef PICASSO96
uaegfx_install_code(rtarea_base + RTAREA_RTG);
uaegfx_install_code (rtarea_base + RTAREA_RTG);
#endif

org(RTAREA_TRAPS | rtarea_base);
init_extended_traps();
org (RTAREA_TRAPS | rtarea_base);
init_extended_traps ();

if (currprefs.uaeboard >= 2) {
device_add_rethink(rethink_traps);
Expand All @@ -644,11 +645,11 @@ void rtarea_init(void)

volatile uae_atomic uae_int_requested = 0;

void rtarea_setup(void)
void rtarea_setup (void)
{
uaecptr base = need_uae_boot_rom(&currprefs);
uaecptr base = need_uae_boot_rom (&currprefs);
if (base) {
write_log(_T("RTAREA located at %08X\n"), base);
write_log (_T("RTAREA located at %08X\n"), base);
rtarea_base = base;
}
}
Expand Down Expand Up @@ -681,3 +682,4 @@ uaecptr makedatatable (uaecptr resid, uaecptr resname, uae_u8 type, uae_s8 prior
dw (0x0000); /* end of table */
return datatable;
}

Loading

0 comments on commit 725f2c7

Please sign in to comment.