Commit e9179096 authored by Sergio Costas's avatar Sergio Costas

Now the tape class works

Renamed the files to C++ syntax

Added MAKER.PY base file to simplify managing the Makefile
parent 99be5a99
CC=g++
CPP=g++
CC=g++ -c
CPP=g++ -c
LN=g++
CFLAGS += `pkg-config --cflags sdl libpulse-simple alsa` -O2 -D D_SOUND_PULSE -D D_SOUND_ALSA -D D_SOUND_OSS
CPPFLAGS += `pkg-config --cflags sdl libpulse-simple alsa` -O2 -Wall -D D_SOUND_PULSE -D D_SOUND_ALSA -D D_SOUND_OSS
CPPFLAGS += `pkg-config --cflags sdl libpulse-simple alsa` -O2 -D D_SOUND_PULSE -D D_SOUND_ALSA -D D_SOUND_OSS
LDFLAGS += `pkg-config --libs sdl libpulse-simple alsa`
fbzx: tapep.o computer.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o emulator.o cargador.o characters.o menus.o sound.o tape.o spk_ay.o microdrive.o
$(CC) -o fbzx tapep.o computer.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o emulator.o cargador.o characters.o menus.o sound.o tape.o spk_ay.o microdrive.o $(LDFLAGS)
spk_ay.o: spk_ay.c spk_ay.h emulator.h sound.h computer.h z80free/Z80free.h
$(CC) $(CFLAGS) -c -o spk_ay.o spk_ay.c
microdrive.o: microdrive.c microdrive.h z80free/Z80free.h computer.h emulator.h z80free/Z80free.h
$(CC) $(CFLAGS) -c -o microdrive.o microdrive.c
sound.o: sound.c sound.h computer.h emulator.h z80free/Z80free.h
$(CC) $(CFLAGS) -c -o sound.o sound.c
emulator.o: emulator.c z80free/Z80free.h computer.h emulator.h characters.h menus.h cargador.h sound.h tape.h microdrive.h
$(CC) $(CFLAGS) -c -o emulator.o emulator.c
computer.o: computer.c z80free/Z80free.h computer.h emulator.h characters.h menus.h cargador.h sound.h tape.h spk_ay.h microdrive.h
$(CC) $(CFLAGS) -c -o computer.o computer.c
tapep.o: tape.cpp z80free/Z80free.h computer.h emulator.h menus.h tape.hpp computer.h
$(CPP) $(CPPFLAGS) -c -o tapep.o tape.cpp
tape.o: tape.c z80free/Z80free.h computer.h emulator.h menus.h tape.h computer.h
$(CC) $(CFLAGS) -c -o tape.o tape.c
cargador.o: cargador.c cargador.h computer.h emulator.h z80free/Z80free.h characters.h menus.h computer.h
$(CC) $(CFLAGS) -c -o cargador.o cargador.c
characters.o: characters.c characters.h emulator.h computer.h
$(CC) $(CFLAGS) -c -o characters.o characters.c
menus.o: menus.c menus.h characters.h computer.h emulator.h z80free/Z80free.h cargador.h tape.h
$(CC) $(CFLAGS) -c -o menus.o menus.c
fbzx: cargador.o characters.o computer.o emulator.o menus.o microdrive.o sound.o spk_ay.o tape.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o
$(LN) -o fbzx cargador.o characters.o computer.o emulator.o menus.o microdrive.o sound.o spk_ay.o tape.o Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o $(LDFLAGS)
Z80free.o: z80free/Z80free.c z80free/Z80free.h
$(CC) $(CFLAGS) -c -o Z80free.o z80free/Z80free.c
$(CC) -o Z80free.o z80free/Z80free.c
Z80free_codes.o: z80free/Z80free_codes.c z80free/Z80free.h
$(CC) $(CFLAGS) -c -o Z80free_codes.o z80free/Z80free_codes.c
$(CC) -o Z80free_codes.o z80free/Z80free_codes.c
Z80free_codesCB.o: z80free/Z80free_codesCB.c z80free/Z80free.h
$(CC) $(CFLAGS) -c -o Z80free_codesCB.o z80free/Z80free_codesCB.c
$(CC) -o Z80free_codesCB.o z80free/Z80free_codesCB.c
Z80free_codesED.o: z80free/Z80free_codesED.c z80free/Z80free.h
$(CC) $(CFLAGS) -c -o Z80free_codesED.o z80free/Z80free_codesED.c
$(CC) -o Z80free_codesED.o z80free/Z80free_codesED.c
Z80free_codesDD.o: z80free/Z80free_codesDD.c z80free/Z80free.h
$(CC) $(CFLAGS) -c -o Z80free_codesDD.o z80free/Z80free_codesDD.c
$(CC) -o Z80free_codesDD.o z80free/Z80free_codesDD.c
Z80free_codesFD.o: z80free/Z80free_codesFD.c z80free/Z80free.h
$(CC) $(CFLAGS) -c -o Z80free_codesFD.o z80free/Z80free_codesFD.c
$(CC) -o Z80free_codesFD.o z80free/Z80free_codesFD.c
Z80free_codesDDCB.o: z80free/Z80free_codesDDCB.c z80free/Z80free.h
$(CC) $(CFLAGS) -c -o Z80free_codesDDCB.o z80free/Z80free_codesDDCB.c
$(CC) -o Z80free_codesDDCB.o z80free/Z80free_codesDDCB.c
Z80free_codesFDCB.o: z80free/Z80free_codesFDCB.c z80free/Z80free.h
$(CC) $(CFLAGS) -c -o Z80free_codesFDCB.o z80free/Z80free_codesFDCB.c
$(CC) -o Z80free_codesFDCB.o z80free/Z80free_codesFDCB.c
cargador.o: cargador.cpp emulator.hh z80free/Z80free.h computer.hh tape.hh cargador.hh
$(CPP) -o cargador.o cargador.cpp
characters.o: characters.cpp emulator.hh z80free/Z80free.h computer.hh tape.hh characters.hh
$(CPP) -o characters.o characters.cpp
computer.o: computer.cpp tape.hh computer.hh z80free/Z80free.h spk_ay.hh sound.hh microdrive.hh menus.hh emulator.hh characters.hh
$(CPP) -o computer.o computer.cpp
emulator.o: emulator.cpp sound.hh microdrive.hh z80free/Z80free.h menus.hh computer.hh tape.hh characters.hh cargador.hh emulator.hh
$(CPP) -o emulator.o emulator.cpp
menus.o: menus.cpp menus.hh tape.hh computer.hh z80free/Z80free.h emulator.hh characters.hh cargador.hh
$(CPP) -o menus.o menus.cpp
microdrive.o: microdrive.cpp emulator.hh z80free/Z80free.h computer.hh tape.hh microdrive.hh
$(CPP) -o microdrive.o microdrive.cpp
sound.o: sound.cpp sound.hh emulator.hh z80free/Z80free.h computer.hh tape.hh
$(CPP) -o sound.o sound.cpp
spk_ay.o: spk_ay.cpp sound.hh emulator.hh z80free/Z80free.h computer.hh tape.hh
$(CPP) -o spk_ay.o spk_ay.cpp
tape.o: tape.cpp tape.hh computer.hh z80free/Z80free.h
$(CPP) -o tape.o tape.cpp
CC=g++ -c
CPP=g++ -c
LN=g++
CFLAGS += `pkg-config --cflags sdl libpulse-simple alsa` -O2 -D D_SOUND_PULSE -D D_SOUND_ALSA -D D_SOUND_OSS
CPPFLAGS += `pkg-config --cflags sdl libpulse-simple alsa` -O2 -D D_SOUND_PULSE -D D_SOUND_ALSA -D D_SOUND_OSS
LDFLAGS += `pkg-config --libs sdl libpulse-simple alsa`
#basecmd $(CPP)
#extra_obj Z80free.o Z80free_codes.o Z80free_codesCB.o Z80free_codesED.o Z80free_codesDD.o Z80free_codesFD.o Z80free_codesDDCB.o Z80free_codesFDCB.o
fbzx: %c
$(LN) -o fbzx %c $(LDFLAGS)
Z80free.o: z80free/Z80free.c z80free/Z80free.h
$(CC) -o Z80free.o z80free/Z80free.c
Z80free_codes.o: z80free/Z80free_codes.c z80free/Z80free.h
$(CC) -o Z80free_codes.o z80free/Z80free_codes.c
Z80free_codesCB.o: z80free/Z80free_codesCB.c z80free/Z80free.h
$(CC) -o Z80free_codesCB.o z80free/Z80free_codesCB.c
Z80free_codesED.o: z80free/Z80free_codesED.c z80free/Z80free.h
$(CC) -o Z80free_codesED.o z80free/Z80free_codesED.c
Z80free_codesDD.o: z80free/Z80free_codesDD.c z80free/Z80free.h
$(CC) -o Z80free_codesDD.o z80free/Z80free_codesDD.c
Z80free_codesFD.o: z80free/Z80free_codesFD.c z80free/Z80free.h
$(CC) -o Z80free_codesFD.o z80free/Z80free_codesFD.c
Z80free_codesDDCB.o: z80free/Z80free_codesDDCB.c z80free/Z80free.h
$(CC) -o Z80free_codesDDCB.o z80free/Z80free_codesDDCB.c
Z80free_codesFDCB.o: z80free/Z80free_codesFDCB.c z80free/Z80free.h
$(CC) -o Z80free_codesFDCB.o z80free/Z80free_codesFDCB.c
\ No newline at end of file
......@@ -17,12 +17,13 @@
*
*/
#include "cargador.hh"
#include "z80free/Z80free.h"
#include "computer.h"
#include "emulator.h"
#include "cargador.h"
#include <stdio.h>
#include <string.h>
#include "computer.hh"
#include "emulator.hh"
void uncompress_z80(FILE *fichero,int length,unsigned char *memo) {
......
......@@ -17,9 +17,9 @@
*
*/
#include "computer.hh"
#include "emulator.hh"
#include "z80free/Z80free.h"
#include "computer.h"
#include "emulator.h"
struct z80snapshot {
......
......@@ -17,9 +17,11 @@
*
*/
#include "characters.h"
#include "characters.hh"
#include <string.h>
#include "emulator.h"
#include "emulator.hh"
// prints the ASCII character CHARAC in the framebuffer MEMO, at X,Y with ink color COLOR and paper color BACK, asuming that the screen width is WIDTH
......@@ -59,12 +61,13 @@ void printchar(unsigned char *memo, unsigned char carac, int x, int y, unsigned
// prints the string CADENA in X,Y (centered if X=-1), with colors COLOR and BACK
void print_string(unsigned char *memo, char *cadena, int x, int y, unsigned char color, unsigned char back, int width) {
void print_string(unsigned char *memo, char *o_cadena, int x, int y, unsigned char color, unsigned char back, int width) {
int length, ncarac, bucle, xx;
int xxx, yyy;
int w,h;
char *str2;
unsigned char *cadena = (unsigned char *)o_cadena;
unsigned char *str2;
if (ordenador.text_mini==1) {
if (x!=-1)
......
......@@ -17,20 +17,22 @@
*
*/
#include "computer.hh"
#include "z80free/Z80free.h"
#include "computer.h"
#include "emulator.h"
#include "menus.h"
#include "characters.h"
#include "sound.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/wait.h>
#include "microdrive.h"
#include "tape.h"
#include "spk_ay.h"
#include "characters.hh"
#include "emulator.hh"
#include "menus.hh"
#include "microdrive.hh"
#include "sound.hh"
#include "spk_ay.hh"
#include "tape.hh"
/* Returns the bus value when reading a port without a periferial */
......@@ -54,7 +56,10 @@ void emulate (int tstados) {
show_screen (tstados);
play_ay (tstados);
play_sound (tstados);
tape_read (ordenador.tap_file, tstados);
//tape_read (ordenador.tap_file, tstados);
ordenador.OOTape.play(tstados);
ordenador.tape_readed = ordenador.OOTape.read_signal() == 0 ? 0 : 1;
microdrive_emulate(tstados);
if (!ordenador.pause) {
if (ordenador.tape_readed)
......@@ -440,7 +445,7 @@ void set_memory_pointers () {
ordenador.block2 = ordenador.memoria + 65536;
ordenador.block3 = ordenador.memoria + 65536;
if (last_st != 0) {
printf("FullRAM 0\n");
//printf("FullRAM 0\n");
last_st = 0;
}
break;
......@@ -450,7 +455,7 @@ void set_memory_pointers () {
ordenador.block2 = ordenador.memoria + 131072;
ordenador.block3 = ordenador.memoria + 131072;
if (last_st != 1) {
printf("FullRAM 1\n");
//printf("FullRAM 1\n");
last_st = 1;
}
break;
......@@ -460,7 +465,7 @@ void set_memory_pointers () {
ordenador.block2 = ordenador.memoria + 131072;
ordenador.block3 = ordenador.memoria + 65536;
if (last_st != 2) {
printf("FullRAM 2\n");
//printf("FullRAM 2\n");
last_st = 2;
}
break;
......@@ -470,7 +475,7 @@ void set_memory_pointers () {
ordenador.block2 = ordenador.memoria + 131072;
ordenador.block3 = ordenador.memoria + 65536;
if (last_st != 3) {
printf("FullRAM 3\n");
//printf("FullRAM 3\n");
last_st = 3;
}
break;
......@@ -506,7 +511,7 @@ void set_memory_pointers () {
ram = 1 + ((unsigned int) (ordenador.mport1 & 0x07)); // RAM page for block3 plus 1
ordenador.block3 = ordenador.memoria + (16384 * ram); // page n minus 49152
if (last_st != ram+3) {
printf("Pagina superior %d\n",ram-1);
//printf("Pagina superior %d\n",ram-1);
last_st = ram+3;
}
}
......@@ -880,11 +885,13 @@ void read_keyboard (SDL_Event *pevento2) {
case SDLK_F5: // STOP tape
if ((ordenador.tape_fast_load == 0) || (ordenador.tape_file_type==TAP_TZX))
ordenador.pause = 1;
ordenador.OOTape.set_pause(true);
break;
case SDLK_F6: // PLAY tape
if ((ordenador.tape_fast_load == 0) || (ordenador.tape_file_type==TAP_TZX))
ordenador.pause = 0;
ordenador.OOTape.set_pause(false);
break;
case SDLK_F9:
......@@ -896,7 +903,8 @@ void read_keyboard (SDL_Event *pevento2) {
ordenador.pause = 1;
if (ordenador.tap_file != NULL) {
ordenador.tape_current_mode = TAP_TRASH;
rewind_tape (ordenador.tap_file,1);
ordenador.OOTape.rewind();
//rewind_tape (ordenador.tap_file,1);
}
break;
......@@ -1547,7 +1555,7 @@ byte Z80free_In (register word Port) {
pines |= 0x40;
}
} else {
if (ordenador.tape_readed)
if (ordenador.OOTape.read_signal() != 0)
pines |= 0x40; // sound input
else
pines &= 0xBF; // sound input
......
......@@ -22,8 +22,9 @@
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include "tape.hh"
#include "z80free/Z80free.h"
#include "tape.hpp"
// #define MUT
......
......@@ -17,23 +17,24 @@
*
*/
#include "emulator.hh"
#include "z80free/Z80free.h"
#include "computer.h"
#include "emulator.h"
#include "cargador.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "characters.h"
#include "menus.h"
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include "sound.h"
#include "microdrive.h"
#include "tape.h"
#include "cargador.hh"
#include "characters.hh"
#include "computer.hh"
#include "menus.hh"
#include "microdrive.hh"
#include "sound.hh"
char debug_var=1;
......@@ -311,22 +312,23 @@ void load_main_game(char *nombre) {
}
if ((0==strcasecmp(".tap",puntero))||(0==strcasecmp(".tzx",puntero))) {
char char_id[10];
/*char char_id[10];
ordenador.tape_write = 0; // by default, can't record
ordenador.tap_file=fopen(nombre,"r+"); // read and write
if(ordenador.tap_file==NULL)
return;
return;*/
strcpy(ordenador.current_tap,nombre);
retval=fread(char_id,10,1,ordenador.tap_file); // read the (maybe) TZX header
/*retval=fread(char_id,10,1,ordenador.tap_file); // read the (maybe) TZX header
if((!strncmp(char_id,"ZXTape!",7)) && (char_id[7]==0x1A)&&(char_id[8]==1)) {
ordenador.tape_file_type = TAP_TZX;
rewind_tape(ordenador.tap_file,1);
//rewind_tape(ordenador.tap_file,1);
} else {
ordenador.tape_file_type = TAP_TAP;
rewind_tape(ordenador.tap_file,1);
}
//rewind_tape(ordenador.tap_file,1);
}*/
ordenador.OOTape.load_file(nombre);
return;
}
}
......@@ -699,26 +701,26 @@ int main(int argc,char *argv[]) {
/* if PC is 0x0556, a call to LD_BYTES has been made, so if
FAST_LOAD is 1, we must load the block in memory and return */
if((!ordenador.mdr_paged) && (PC==0x0556) && (ordenador.tape_fast_load==1) && (ordenador.tape_file_type==TAP_TAP) && (ordenador.page48k == 1)) {
/*if((!ordenador.mdr_paged) && (PC==0x0556) && (ordenador.tape_fast_load==1) && (ordenador.tape_file_type==TAP_TAP) && (ordenador.page48k == 1)) {
if(ordenador.tap_file!=NULL)
fastload_block(ordenador.tap_file);
else {
sprintf(ordenador.osd_text,"No TAP file selected");
ordenador.osd_time=50;
}
}
}*/
/* if PC is 0x04C2, a call to SA_BYTES has been made, so if
we want to save to the TAP file, we do it */
if((!ordenador.mdr_paged)&&(PC==0x04C2)&&(ordenador.tape_write==1)&&(ordenador.tape_file_type==TAP_TAP)) {
/*if((!ordenador.mdr_paged)&&(PC==0x04C2)&&(ordenador.tape_write==1)&&(ordenador.tape_file_type==TAP_TAP)) {
if(ordenador.tap_file!=NULL)
save_file(ordenador.tap_file);
else {
sprintf(ordenador.osd_text,"No TAP file selected");
ordenador.osd_time=50;
}
}
}*/
/* if ordenador.mdr_paged is 2, we have executed the RET at 0x0700, so
we have to return to the classic ROM */
......
......@@ -17,8 +17,8 @@
*
*/
#include "computer.hh"
#include "z80free/Z80free.h"
#include "computer.h"
#ifndef emulator_h
#define emulator_h
......
......@@ -17,10 +17,6 @@
*
*/
#include "z80free/Z80free.h"
#include "computer.h"
#include "emulator.h"
#include "cargador.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
......@@ -28,12 +24,15 @@
#include <sys/stat.h>
#include <dirent.h>
#include <string.h>
#include "characters.h"
#include "menus.h"
#include "z80free/Z80free.h"
#include <SDL/SDL.h>
#include "tape.h"
#include "cargador.hh"
#include "characters.hh"
#include "computer.hh"
#include "emulator.hh"
#include "tape.hh"
#include "menus.hh"
// shows the settings menu
......@@ -636,7 +635,8 @@ void taps_menu() {
ordenador.pause=1;
if(ordenador.tap_file!=NULL) {
ordenador.tape_current_mode=TAP_TRASH;
rewind_tape(ordenador.tap_file,1);
ordenador.OOTape.rewind();
//rewind_tape(ordenador.tap_file,1);
}
sprintf(ordenador.osd_text,"Tape rewinded");
ordenador.osd_time=50;
......@@ -645,8 +645,9 @@ void taps_menu() {
ordenador.pause=1;
ordenador.tape_fast_load=1-ordenador.tape_fast_load;
if(ordenador.tap_file!=NULL) {
ordenador.tape_current_mode=TAP_TRASH;
rewind_tape(ordenador.tap_file,1);
/*ordenador.tape_current_mode=TAP_TRASH;
rewind_tape(ordenador.tap_file,1);*/
ordenador.OOTape.rewind();
}
break;
case SDLK_4:
......@@ -678,8 +679,9 @@ void select_tapfile() {
clean_screen();
if(ordenador.tap_file!=NULL)
/*if(ordenador.tap_file!=NULL) {
rewind_tape(ordenador.tap_file,1);
}*/
ordenador.tape_current_bit=0;
ordenador.tape_current_mode=TAP_TRASH;
......@@ -721,14 +723,15 @@ void select_tapfile() {
break;
}
retval=fread(char_id,10,1,ordenador.tap_file); // read the (maybe) TZX header
ordenador.OOTape.load_file(ordenador.current_tap);
/*retval=fread(char_id,10,1,ordenador.tap_file); // read the (maybe) TZX header
if((!strncmp(char_id,"ZXTape!",7)) && (char_id[7]==0x1A)&&(char_id[8]==1)) {
ordenador.tape_file_type = TAP_TZX;
rewind_tape(ordenador.tap_file,1);
} else {
ordenador.tape_file_type = TAP_TAP;
rewind_tape(ordenador.tap_file,1);
}
}*/
clean_screen();
}
......
......@@ -17,9 +17,9 @@
*
*/
#include "microdrive.h"
#include "computer.h"
#include "emulator.h"
#include "microdrive.hh"
#include "computer.hh"
#include "emulator.hh"
byte basura;
......
......@@ -18,22 +18,18 @@
*/
#include "z80free/Z80free.h"
#include "computer.h"
#include "emulator.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "computer.hh"
#include "emulator.hh"
char tabla[1024];
#include <fcntl.h>
#include <sys/ioctl.h>
/*#include <SDL/SDL.h>
#include "SDL/SDL_audio.h"
#include "SDL_thread.h"*/
#include "sound.h"
#include "sound.hh"
#ifdef D_SOUND_OSS
#include <sys/soundcard.h>
......
......@@ -20,9 +20,9 @@
* MAME's licence explicitly permits free use of info (even encourages it).
*/
#include "emulator.h"
#include "sound.h"
#include <stdlib.h>
#include "emulator.hh"
#include "sound.hh"
/* emulates the AY-3-8912 during TSTADOS tstates */
......@@ -313,7 +313,8 @@ void play_sound (int tstados) {
if (ordenador.sound_bit && sample_v)
//Sound bit volume max 96
ordenador.sound_current_value=ordenador.volume*6;
else ordenador.sound_current_value=0;
else
ordenador.sound_current_value=0;
value = ordenador.sound_current_value;
//Mixer
......
......@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#if 0
#include <stdio.h>
#include "tape.h"
#include "z80free/Z80free.h"
......@@ -772,3 +772,4 @@ void fastload_block (FILE * fichero) {
return;
}
#endif
......@@ -5,8 +5,9 @@
* Author: raster
*/
#include "tape.hh"
#include <stdio.h>
#include "tape.hpp"
#include <string.h>
class TapeBlock {
......@@ -161,7 +162,7 @@ class TAPBlock : public TapeBlock {
}
public:
TAPBlock(uint8_t *data,uint16_t size) {
TAPBlock(uint8_t *data,uint16_t size) :TapeBlock() {
this->data = new uint8_t[size];
this->data_size = size;
......@@ -174,6 +175,8 @@ public:
}
void reset() {
this->counter0 = 0;
this->counter1 = 0;
this->set_state(TAPBLOCK_GUIDE);
}
......@@ -209,12 +212,13 @@ public:
}
current_bit = ((*(this->data+this->pointer)) & this->bit) == 0;
if (current_bit) {
this->counter0 = 1710;
this->counter1 = 1710;
} else {
this->counter0 = 852;
this->counter1 = 852;
} else {
this->counter0 = 1710;
this->counter1 = 1710;
}
this->bit /=2;
return true;
break;
case TAPBLOCK_PAUSE:
......@@ -252,12 +256,21 @@ void Tape::delete_blocks() {
this->current_block = NULL;
}
bool Tape::load_file(char *filename, bool TAP) {
bool Tape::load_file(char *filename) {
char char_id[10];
int retval;
this->delete_blocks();
if (TAP) {
return this->load_tap(filename);
} else {
FILE *file = fopen(filename,"rb");
if (file == NULL) {
return true; // error while opening the file
}
retval=fread(char_id,10,1,file); // read the (maybe) TZX header
fclose(file);
if((!strncmp(char_id,"ZXTape!",7)) && (char_id[7]==0x1A)&&(char_id[8]==1)) {
return this->load_tzx(filename);
} else {
return this->load_tap(filename);
}
}
......@@ -301,12 +314,23 @@ void Tape::play(uint32_t tstates) {
uint32_t residue = tstates;
if (this->current_block == NULL) {
return;
}
if (this->paused) {
return;
}
while(true) {
residue = this->current_block->play(residue);
if (residue != 0) {
this->current_block = this->current_block->next_block();
if (this->current_block == NULL) {
this->current_block = this->blocks;
if (this->current_block->next_bit() == false) {
this->current_block = this->current_block->next_block();
if (this->current_block == NULL) {
this->current_block = this->blocks;
}
this->current_block->reset();
}
} else {
break;
......@@ -322,3 +346,14 @@ uint8_t Tape::read_signal() {
return this->current_block->read_signal();
}
}
void Tape::rewind() {
this->current_block = this->blocks;
if (this->current_block != NULL) {
this->current_block->reset();
}
}
void Tape::set_pause(bool pause) {
this->paused = pause;
}
......@@ -19,7 +19,7 @@
#ifndef H_TAPE
#define H_TAPE
/*
void tape_read(FILE *, int);
void tape_read_tap(FILE *, int);
void tape_read_tzx(FILE *, int);
......@@ -27,5 +27,5 @@ void rewind_tape(FILE *,unsigned char);
unsigned char file_empty(FILE *);
void fastload_block (FILE *);
void save_file(FILE *);
*/
#endif
......@@ -7,7 +7,8 @@
#include <inttypes.h>
#include <stdio.h>
#include "computer.h"
#include "computer.hh"
#ifndef SRC_TAPE_HPP_
#define SRC_TAPE_HPP_
......@@ -27,9 +28,11 @@ public:
Tape();
~Tape();
void play(uint32_t);
bool load_file(char *, bool);
bool load_file(char *);
void set_pause(bool pause);
uint8_t read_signal();
void rewind();
bool fast_read(uint16_t,uint16_t,uint8_t);
};
#endif /* SRC_TAPE_HPP_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment