Skip to content

Commit

Permalink
Focus on .cas support
Browse files Browse the repository at this point in the history
  • Loading branch information
dionoid committed Aug 8, 2024
1 parent 5862afe commit 7f1253c
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# M2000 - Philips P2000T Home Computer Emulator
Version 0.9.2
Version 0.9.3

![P2000T](/img/P2000T.png)

Expand Down
22 changes: 1 addition & 21 deletions package/M2000.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<key>CFBundleName</key>
<string>M2000</string>
<key>CFBundleShortVersionString</key>
<string>0.9.2</string>
<string>0.9.3</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
Expand All @@ -37,7 +37,6 @@
<key>LSItemContentTypes</key>
<array>
<string>org.m2000.cassette</string>
<string>org.m2000.cassette2</string>
</array>
</dict>
</array>
Expand All @@ -63,25 +62,6 @@
<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.
2 changes: 1 addition & 1 deletion package/M2000_amd64/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: M2000
Version: 0.9.2
Version: 0.9.3
Maintainer: M2000 team
Architecture: amd64
Depends: liballegro5.2 (>=5.2.7), liballegro-dialog5.2 (>=5.2.7), liballegro-audio5.2 (>=5.2.7), liballegro-image5.2 (>=5.2.7)
Expand Down
15 changes: 4 additions & 11 deletions package/WiX/product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<Product Id="*" UpgradeCode="50c2a4d4-747d-4ee1-8aa5-cca780d1f544"
Name="M2000"
Version="0.9.2"
Version="0.9.3"
Manufacturer="M2000"
Language="1033">

Expand All @@ -24,15 +24,15 @@
<Property Id="ARPPRODUCTICON" Value="P2000T.ico" />

<Upgrade Id="50c2a4d4-747d-4ee1-8aa5-cca780d1f544">
<UpgradeVersion Minimum="0.9.2" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
<UpgradeVersion Minimum="0.0.0" Maximum="0.9.2" IncludeMinimum="yes" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED"/>
<UpgradeVersion Minimum="0.9.3" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
<UpgradeVersion Minimum="0.0.0" Maximum="0.9.3" IncludeMinimum="yes" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED"/>
</Upgrade>
<Condition Message="A newer version of this software is already installed.">NOT NEWERVERSIONDETECTED</Condition>

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.Program_Files)">
<Directory Id="INSTALLDIR" Name="M2000">
<Component Id="ApplicationFiles" Guid="e5d50ebc-5354-45a1-8438-f0f51d5855e1">
<Component Id="ApplicationFiles" Guid="e5d50ebc-5354-45a1-8438-f0f51d5855e2">
<File Id="M2000.exe" Source="..\..\M2000.exe" />
<File Id="cassette_blue.ico" Source="cassette_blue.ico" />
<File Id="cassette_red.ico" Source="cassette_red.ico" />
Expand All @@ -53,21 +53,14 @@
<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: 12 additions & 27 deletions src/P2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
#include <time.h>
#include <unistd.h>

#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 HEADER_SIZE 256 // .cas files uses 256 byte block-headers, while actual P2000T uses 32 byte block-headers
#define HEADER_OFFSET 48 // actual 32 bytes of header data starts at offset 48 in the 256 byte .cas block-header
#define SPACE 32 // space character

byte Verbose = 0;
Expand All @@ -39,8 +37,6 @@ 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 @@ -374,17 +370,6 @@ 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 @@ -515,7 +500,7 @@ void Z80_Patch (Z80_Regs *R)
if (TapeStream)
{
j=ftell (TapeStream);
if (fseek (TapeStream,j+i*(1024+TapeHeaderSize)-1,SEEK_SET))
if (fseek (TapeStream,j+i*(1024+HEADER_SIZE)-1,SEEK_SET))
{
rewind (TapeStream);
Z80_WRMEM (caserror,0x45);
Expand Down Expand Up @@ -544,7 +529,7 @@ void Z80_Patch (Z80_Regs *R)
if (TapeStream)
{
j=ftell (TapeStream);
if (fseek (TapeStream,j-i*(1024+TapeHeaderSize),SEEK_SET))
if (fseek (TapeStream,j-i*(1024+HEADER_SIZE),SEEK_SET))
{
rewind (TapeStream);
Z80_WRMEM (caserror,0x45);
Expand Down Expand Up @@ -604,16 +589,16 @@ void Z80_Patch (Z80_Regs *R)
{
Z80_WRMEM (recnum,i);
for (j=0x00;j<0x20;++j)
tapebuf[j+TapeHeaderOffset]=Z80_RDMEM (0x6030+j);
tapebuf[j+HEADER_OFFSET]=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+TapeHeaderSize]=Z80_RDMEM ((k+j)&0xFFFF);
tapebuf[j+HEADER_SIZE]=Z80_RDMEM ((k+j)&0xFFFF);
for (j=l;j<1024;++j)
tapebuf[j+TapeHeaderSize]=0;
tapebuf[j+HEADER_SIZE]=0;
k=(k+1024)&0xFFFF;
if (!fwrite(tapebuf,1024+TapeHeaderSize,1,TapeStream))
if (!fwrite(tapebuf,1024+HEADER_SIZE,1,TapeStream))
{
rewind (TapeStream);
Z80_WRMEM (caserror,0x45);
Expand Down Expand Up @@ -644,13 +629,13 @@ void Z80_Patch (Z80_Regs *R)
{
for (;i;--i)
{
if (!fread(tapebuf,1024+TapeHeaderSize,1,TapeStream))
if (!fread(tapebuf,1024+HEADER_SIZE,1,TapeStream))
{
Z80_WRMEM (caserror,0x4D);
break;
}
for (j=0;j<0x20;++j)
Z80_WRMEM (0x6030+j,tapebuf[j+TapeHeaderOffset]);
Z80_WRMEM (0x6030+j,tapebuf[j+HEADER_OFFSET]);
l=m=Z80_RDWORD (lengte);
if (l>1024) l=1024;
Z80_WRWORD (lengte,m-l);
Expand All @@ -660,7 +645,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+TapeHeaderSize]);
Z80_WRMEM((k+m)&0xFFFF,tapebuf[m+HEADER_SIZE]);
RefreshScreen ();
Keyboard ();
if (!Z80_Running) return;
Expand All @@ -670,7 +655,7 @@ void Z80_Patch (Z80_Regs *R)
else
{
for (j=0;j<l;++j)
Z80_WRMEM((k+j)&0xFFFF,tapebuf[j+TapeHeaderSize]);
Z80_WRMEM((k+j)&0xFFFF,tapebuf[j+HEADER_SIZE]);
}
k=(k+1024)&0xFFFF;
}
Expand Down
2 changes: 1 addition & 1 deletion src/P2000.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <stdio.h>
#include "Z80.h" /* Z80 emulation declarations */

#define EMULATOR_VERSION "0.9.2"
#define EMULATOR_VERSION "0.9.3"

#if defined(_WIN32) // Windows
#define PATH_SEPARATOR '\\'
Expand Down
4 changes: 2 additions & 2 deletions src/libretro/info/m2000_libretro.info
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Core Information
display_name = "Philips - P2000T (M2000)"
authors = "Dion Olsthoorn|Marcel de Kogel"
supported_extensions = "cas|p2000t"
supported_extensions = "cas"
corename = "M2000"
license = "GPLv3"
permissions = ""
display_version = "0.9.2"
display_version = "0.9.3"
categories = "Emulator"

# Hardware Information
Expand Down
4 changes: 2 additions & 2 deletions src/libretro/m2000_libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ void retro_get_system_info(struct retro_system_info *info)
{
memset(info, 0, sizeof(*info));
info->library_name = "M2000";
info->library_version = "v0.9.2";
info->library_version = "v0.9.3";
info->need_fullpath = true;
info->valid_extensions = "cas|p2000t";
info->valid_extensions = "cas";
}

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

0 comments on commit 7f1253c

Please sign in to comment.