Skip to content

Commit

Permalink
Revert "stopping support for .p2000t extension"
Browse files Browse the repository at this point in the history
This reverts commit 6acce33.
  • Loading branch information
dionoid committed Jul 27, 2024
1 parent 6acce33 commit 5862afe
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 14 deletions.
20 changes: 20 additions & 0 deletions package/M2000.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<key>LSItemContentTypes</key>
<array>
<string>org.m2000.cassette</string>
<string>org.m2000.cassette2</string>
</array>
</dict>
</array>
Expand All @@ -62,6 +63,25 @@
<key>UTTypeIconFile</key>
<string>cas_icon.icns</string>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>org.m2000.cassette2</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>p2000t</string>
</array>
</dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>M2000 cassette file</string>
<key>UTTypeIconFile</key>
<string>p2000t_icon.icns</string>
</dict>
</array>

</dict>
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions package/WiX/product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,21 @@
<RegistryValue Root="HKLM" Key="SOFTWARE\M2000\Capabilities" Name="ApplicationDescription" Value="M2000 - Philips P2000 Emulator" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\M2000\Capabilities" Name="ApplicationName" Value="M2000" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\M2000\Capabilities\FileAssociations" Name=".cas" Value="M2000.Cassette" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\M2000\Capabilities\FileAssociations" Name=".p2000t" Value="M2000.Cassette2" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\RegisteredApplications" Name="M2000" Value="SOFTWARE\M2000\Capabilities" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\M2000.exe\SupportedTypes" Name=".cas" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\M2000.exe\SupportedTypes" Name=".p2000t" Value="" Type="string" />
<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\M2000.exe\shell\open" Name="FriendlyAppName" Value="M2000 - Philips P2000 Emulator" Type="string" />
<ProgId Id="M2000.Cassette" Description="M2000 Cassette" Icon="cassette_blue.ico">
<Extension Id="cas">
<Verb Id="open_cas" Command="Open" TargetFile="M2000.exe" Argument='"%1"' />
</Extension>
</ProgId>
<ProgId Id="M2000.Cassette2" Description="M2000 Cassette" Icon="cassette_red.ico">
<Extension Id="p2000t">
<Verb Id="open_p2000t" Command="Open" TargetFile="M2000.exe" Argument='"%1"' />
</Extension>
</ProgId>
</Component>
</Directory>
</Directory>
Expand Down
39 changes: 27 additions & 12 deletions src/P2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
#include <time.h>
#include <unistd.h>

#define HEADER_SIZE 256
#define HEADER_OFFSET 48
#define TAPE_256_BYTE_HEADER_SIZE 256
#define TAPE_256_BYTE_HEADER_OFFSET 48
#define TAPE_32_BYTE_HEADER_SIZE 32
#define TAPE_32_BYTE_HEADER_OFFSET 0
#define SPACE 32 // space character

byte Verbose = 0;
Expand All @@ -37,6 +39,8 @@ const char *CartName = "BASIC.bin";
const char *FontName = "Default.fnt";
const char *TapeName = "Default.cas";
const char *PrnName = "Printer.out";
int TapeHeaderSize = TAPE_256_BYTE_HEADER_SIZE;
int TapeHeaderOffset = TAPE_256_BYTE_HEADER_OFFSET;
FILE *PrnStream = NULL;
FILE *TapeStream = NULL;
int TapeProtect = 0;
Expand Down Expand Up @@ -370,6 +374,17 @@ void InsertCassette(const char *filename, FILE *f, int readOnly)
strcpy (_TapeName,filename);
TapeName=_TapeName;

char *dot = strrchr(TapeName, '.');
if (dot && strcasecmp(dot, ".p2000t") == 0) {
// .p2000t format uses 32-byte headers
TapeHeaderSize = TAPE_32_BYTE_HEADER_SIZE;
TapeHeaderOffset = TAPE_32_BYTE_HEADER_OFFSET;
} else {
// .cas (default) format uses 256-byte headers (of which 224 are unused)
TapeHeaderSize = TAPE_256_BYTE_HEADER_SIZE;
TapeHeaderOffset = TAPE_256_BYTE_HEADER_OFFSET;
}

if (TapeStream) fclose (TapeStream); //close previous stream
TapeProtect = readOnly;
TapeStream = f;
Expand Down Expand Up @@ -500,7 +515,7 @@ void Z80_Patch (Z80_Regs *R)
if (TapeStream)
{
j=ftell (TapeStream);
if (fseek (TapeStream,j+i*(1024+HEADER_SIZE)-1,SEEK_SET))
if (fseek (TapeStream,j+i*(1024+TapeHeaderSize)-1,SEEK_SET))
{
rewind (TapeStream);
Z80_WRMEM (caserror,0x45);
Expand Down Expand Up @@ -529,7 +544,7 @@ void Z80_Patch (Z80_Regs *R)
if (TapeStream)
{
j=ftell (TapeStream);
if (fseek (TapeStream,j-i*(1024+HEADER_SIZE),SEEK_SET))
if (fseek (TapeStream,j-i*(1024+TapeHeaderSize),SEEK_SET))
{
rewind (TapeStream);
Z80_WRMEM (caserror,0x45);
Expand Down Expand Up @@ -589,16 +604,16 @@ void Z80_Patch (Z80_Regs *R)
{
Z80_WRMEM (recnum,i);
for (j=0x00;j<0x20;++j)
tapebuf[j+HEADER_OFFSET]=Z80_RDMEM (0x6030+j);
tapebuf[j+TapeHeaderOffset]=Z80_RDMEM (0x6030+j);
l=m=Z80_RDWORD (lengte);
if (l>1024) l=1024;
Z80_WRWORD (lengte,m-l);
for (j=0;j<l;++j)
tapebuf[j+HEADER_SIZE]=Z80_RDMEM ((k+j)&0xFFFF);
tapebuf[j+TapeHeaderSize]=Z80_RDMEM ((k+j)&0xFFFF);
for (j=l;j<1024;++j)
tapebuf[j+HEADER_SIZE]=0;
tapebuf[j+TapeHeaderSize]=0;
k=(k+1024)&0xFFFF;
if (!fwrite(tapebuf,1024+HEADER_SIZE,1,TapeStream))
if (!fwrite(tapebuf,1024+TapeHeaderSize,1,TapeStream))
{
rewind (TapeStream);
Z80_WRMEM (caserror,0x45);
Expand Down Expand Up @@ -629,13 +644,13 @@ void Z80_Patch (Z80_Regs *R)
{
for (;i;--i)
{
if (!fread(tapebuf,1024+HEADER_SIZE,1,TapeStream))
if (!fread(tapebuf,1024+TapeHeaderSize,1,TapeStream))
{
Z80_WRMEM (caserror,0x4D);
break;
}
for (j=0;j<0x20;++j)
Z80_WRMEM (0x6030+j,tapebuf[j+HEADER_OFFSET]);
Z80_WRMEM (0x6030+j,tapebuf[j+TapeHeaderOffset]);
l=m=Z80_RDWORD (lengte);
if (l>1024) l=1024;
Z80_WRWORD (lengte,m-l);
Expand All @@ -645,7 +660,7 @@ void Z80_Patch (Z80_Regs *R)
for (j=0;j<l;j+=80)
{
for (m=j;m<l && m<(j+80);++m)
Z80_WRMEM((k+m)&0xFFFF,tapebuf[m+HEADER_SIZE]);
Z80_WRMEM((k+m)&0xFFFF,tapebuf[m+TapeHeaderSize]);
RefreshScreen ();
Keyboard ();
if (!Z80_Running) return;
Expand All @@ -655,7 +670,7 @@ void Z80_Patch (Z80_Regs *R)
else
{
for (j=0;j<l;++j)
Z80_WRMEM((k+j)&0xFFFF,tapebuf[j+HEADER_SIZE]);
Z80_WRMEM((k+j)&0xFFFF,tapebuf[j+TapeHeaderSize]);
}
k=(k+1024)&0xFFFF;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libretro/info/m2000_libretro.info
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Core Information
display_name = "Philips - P2000T (M2000)"
authors = "Dion Olsthoorn|Marcel de Kogel"
supported_extensions = "cas"
supported_extensions = "cas|p2000t"
corename = "M2000"
license = "GPLv3"
permissions = ""
Expand Down
2 changes: 1 addition & 1 deletion src/libretro/m2000_libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void retro_get_system_info(struct retro_system_info *info)
info->library_name = "M2000";
info->library_version = "v0.9.2";
info->need_fullpath = true;
info->valid_extensions = "cas";
info->valid_extensions = "cas|p2000t";
}

void retro_get_system_av_info(struct retro_system_av_info *info)
Expand Down
Binary file added test/SAA5050/SAA5050.p2000t
Binary file not shown.

0 comments on commit 5862afe

Please sign in to comment.