summaryrefslogtreecommitdiff
path: root/src/spec.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2026-06-13 17:19:51 +0100
committerIan C <ianc@noddybox.co.uk>2026-06-13 17:19:51 +0100
commit8f4656b7920d37b3f1df5944dfe9307264a52f0b (patch)
treee5540480b3e8aced36c7c1f738f90d26c685e103 /src/spec.c
parent24a7e3ac0103979dcef910f0b87f3eea234d2353 (diff)
Reorganised tape files a bit and select one if none selected when patch is hit
Diffstat (limited to 'src/spec.c')
-rw-r--r--src/spec.c69
1 files changed, 19 insertions, 50 deletions
diff --git a/src/spec.c b/src/spec.c
index 7066292..3a872dd 100644
--- a/src/spec.c
+++ b/src/spec.c
@@ -32,6 +32,7 @@
#include "gui.h"
#include "config.h"
#include "exit.h"
+#include "tape.h"
#include "util.h"
#ifndef TRUE
@@ -52,8 +53,8 @@ static const int ROMLEN=0x4000;
static const int ROM_SAVE=0x4c6;
static const int ROM_LOAD=0x562;
-static FILE *tape_in;
-static FILE *tape_out;
+static int selected_in_tape = FALSE;
+static int selected_out_tape = FALSE;
#define LOAD_PATCH 0xf0
#define SAVE_PATCH 0xf1
@@ -350,13 +351,19 @@ static int EDCallback(Z80 *z80, Z80Val data)
case SAVE_PATCH:
Z80GetState(z80,&state);
- if (!tape_out)
+ if (!TAPEFile(TAP_OUT) && !selected_out_tape)
+ {
+ TAPESelectOutput();
+ selected_out_tape = TRUE;
+ }
+
+ if (!TAPEFile(TAP_OUT))
{
state.AF|=eZ80_Carry;
}
else
{
- if (TAPSave(tape_out,
+ if (TAPSave(TAPEFile(TAP_OUT),
HIBYTE(state.AF),
&state.IX,
&state.DE,
@@ -377,13 +384,19 @@ static int EDCallback(Z80 *z80, Z80Val data)
case LOAD_PATCH:
Z80GetState(z80,&state);
- if (!tape_in)
+ if (!TAPEFile(TAP_IN) && !selected_in_tape)
+ {
+ TAPESelectInput();
+ selected_in_tape = TRUE;
+ }
+
+ if (!TAPEFile(TAP_IN))
{
state.AF|=eZ80_Carry;
}
else
{
- if (TAPLoad(tape_in,
+ if (TAPLoad(TAPEFile(TAP_IN),
HIBYTE(state.AF),
&state.IX,
&state.DE,
@@ -858,48 +871,4 @@ void SPECReset(Z80 *z80)
}
-void SPECMount(SPECMountType type, const char *path)
-{
- switch(type)
- {
- case SPEC_TAPE_IN:
- if (tape_in)
- fclose(tape_in);
-
- tape_in=fopen(path,"rb");
- break;
-
- case SPEC_TAPE_OUT:
- if (tape_out)
- fclose(tape_out);
-
- tape_out=fopen(path,"wb");
- break;
- }
-}
-
-
-void SPECUnmount(SPECMountType type)
-{
- switch(type)
- {
- case SPEC_TAPE_IN:
- if (tape_in)
- {
- fclose(tape_in);
- tape_in=NULL;
- }
- break;
-
- case SPEC_TAPE_OUT:
- if (tape_out)
- {
- fclose(tape_out);
- tape_out=NULL;
- }
- break;
- }
-}
-
-
/* END OF FILE */