Skip to content

Commit

Permalink
Merge pull request #26 from EremusOne/develop
Browse files Browse the repository at this point in the history
Release candidate 2 to master
  • Loading branch information
EremusOne authored Sep 1, 2023
2 parents e6690c9 + f3edecd commit 54d5047
Show file tree
Hide file tree
Showing 46 changed files with 6,712 additions and 3,713 deletions.
11 changes: 7 additions & 4 deletions include/AySound.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ typedef struct
int env_c; /**< R10 bit 4 */
int env_freq; /**< R11, R12 */
int env_style; /**< R13 */
int IOPortA; /**< R14 */
int IOPortB; /**< R15 */
}
ayemu_regdata_t;

Expand All @@ -140,7 +142,9 @@ class AySound
static void updVolC();
static void updEnvFreq();
static void updEnvType();

static void updIOPortA();
static void updIOPortB();

static void reset();
static uint8_t getRegisterData();
static void selectRegister(uint8_t data);
Expand All @@ -153,9 +157,8 @@ class AySound
static int set_sound_format(int freq, int chans, int bits);
static void prepare_generation();
static void gen_sound(int bufsize, int bufpos);
static void gen_sound_speech_test(unsigned char *buff, size_t sound_bufsize, int bufpos);

static void(*updateReg[14])();
static void(*updateReg[16])();

static uint8_t SamplebufAY[ESP_AUDIO_SAMPLES_48];

Expand Down Expand Up @@ -196,7 +199,7 @@ class AySound
static int env_pos; /**< current position in envelop (0...127) */
static int Cur_Seed; /**< random numbers counter */

static uint8_t regs[14];
static uint8_t regs[16];
static uint8_t selectedRegister;

};
Expand Down
24 changes: 18 additions & 6 deletions include/CPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@ visit https://zxespectrum.speccy.org/contacto

#include <inttypes.h>
#include "ESPectrum.h"
#include "ESP32Lib/ESP32Lib.h"

#define TSTATES_PER_FRAME_48 69888
#define TSTATES_PER_FRAME_128 70908

#define INT_START48 0
#define INT_END48 32
#define INT_START128 0
#define INT_END128 36

class CPU
{
public:
// call this for initializing CPU
static void setup();

// call this for executing a frame's worth of instructions
// // call this for executing a frame's worth of instructions
static void IRAM_ATTR loop();

// call this for resetting the CPU
Expand All @@ -55,9 +62,6 @@ class CPU
// Flush screen
static void FlushOnHalt();

// get the number of CPU Tstates per frame (machine dependant)
static uint32_t statesPerFrame();

// get the number of microseconds per frame (machine dependant)
static uint32_t microsPerFrame();

Expand All @@ -70,12 +74,20 @@ class CPU
// CPU Tstates in frame
static uint32_t statesInFrame;

// Late timing
static uint8_t latetiming;

// INT signal lenght
static uint8_t IntStart;
static uint8_t IntEnd;

// Frames elapsed
static uint32_t framecnt;

};

static const unsigned char wait_st[228] = {
static const unsigned char DRAM_ATTR wait_st[243] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6, 5, 4, 3, 2, 1, 0, 0, 6, 5, 4, 3, 2, 1, 0, 0,
6, 5, 4, 3, 2, 1, 0, 0, 6, 5, 4, 3, 2, 1, 0, 0,
6, 5, 4, 3, 2, 1, 0, 0, 6, 5, 4, 3, 2, 1, 0, 0,
Expand Down
4 changes: 4 additions & 0 deletions include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ class Config
// static string kbd_layout;
static uint8_t lang;
static bool AY48;
static bool Issue2;
static bool flashload;
static uint8_t joystick;
static uint8_t videomode;
static uint8_t AluTiming;

// config persistence
static void load();
static void save();
static void save(string value);

// // list of snapshot file names
// static string sna_file_list;
Expand Down
2 changes: 2 additions & 0 deletions include/ESPectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class ESPectrum
static int sync_cnt;
static uint8_t *audbuffertosend;

static int TapeNameScroller;

// static bool Audio_restart;

static int64_t target;
Expand Down
53 changes: 0 additions & 53 deletions include/FileSNA.h

This file was deleted.

10 changes: 7 additions & 3 deletions include/FileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ using namespace std;

// Defines
#define ASCII_NL 10
#define ON true
#define OFF false

class FileUtils
{
public:
static void initFileSystem();
static bool mountSDCard();
static bool mountSDCard(int PIN_MISO, int PIN_MOSI, int PIN_CLK, int PIN_CS);
static void unmountSDCard();
// static String getAllFilesFrom(const String path);
// static void listAllFiles();
Expand All @@ -71,6 +69,12 @@ class FileUtils
static string MountPoint;
static bool SDReady;

static string SNA_Path; // Current SNA path on the SD (for future folder support)
static string TAP_Path; // Current TAP path on the SD (for future folder support)

static int curSNAFile; // Current SNA file index on browser
static int curTAPFile; // Current TAP file index on browser

private:
friend class Config;
static sdmmc_card_t *card;
Expand Down
23 changes: 12 additions & 11 deletions include/OSDMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,24 @@ class OSD
static void osdCenteredMsg(string msg, uint8_t warn_level, uint16_t millispause);

// // Menu
static void newMenu(string new_menu);
static void menuRecalc();
// static void newMenu(string new_menu);
// static void menuRecalc();
static unsigned short menuRealRowFor(uint8_t virtual_row_num);
static bool menuIsSub(uint8_t virtual_row_num);
static void menuPrintRow(uint8_t virtual_row_num, uint8_t line_type);
static void menuDraw();
// static void menuDraw();
static void menuRedraw();
static string getArchMenu();
static string getRomsetMenu(string arch);
// static string getArchMenu();
// static string getRomsetMenu(string arch);
static void WindowDraw();
static unsigned short menuRun(string new_menu);
static string menuFile(string new_menu, string title, string extensions);
static string menuFile(string new_menu, string title, string extensions, int currentFile);
static int menuTape(string title);
static void menuScroll(bool up);
// static void filemenuDraw();
static void filemenuRedraw(string title);
static void filemenuPrintRow(uint8_t virtual_row_num, uint8_t line_type);
static void tapemenuRedraw(string title);
static void PrintRow(uint8_t virtual_row_num, uint8_t line_type);
static void menuAt(short int row, short int col);
static void menuScrollBar();
static void click();
Expand All @@ -105,13 +109,10 @@ class OSD
static unsigned short menu_curopt;
static unsigned int SaveRectpos;

// // Rows
// Rows
static unsigned short rowCount(string menu);
static string rowGet(string menu, unsigned short row_number);

// // Snapshot (SNA/Z80) Management
static void changeSnapshot(string sna_filename);

static void esp_hard_reset();

};
Expand Down
2 changes: 2 additions & 0 deletions include/Ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ class Ports
{
public:
static uint8_t port[128];
static uint8_t port254;
static uint8_t IRAM_ATTR input(uint16_t address);
static void IRAM_ATTR output(uint16_t address, uint8_t data);
// static void ContendedIODelay(uint16_t portNumber);
};


Expand Down
19 changes: 16 additions & 3 deletions include/FileZ80.h → include/Snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,32 @@ visit https://zxespectrum.speccy.org/contacto
*/

#ifndef FileZ80_h
#define FileZ80_h
#ifndef Snapshot_h
#define Snapshot_h

#include <stdio.h>
#include <inttypes.h>
#include <string>

using namespace std;

bool LoadSnapshot(string filename);

class FileSNA
{
public:
static string load(string sna_fn);
static bool save(string sna_fn);
static bool save(string sna_fn, bool blockMode);
static bool isPersistAvailable(string filename);
};

class FileZ80
{
public:
static bool load(string z80_fn);
static string load(string z80_fn);
static void loader48();
static void loader128();
private:
static void loadCompressedMemData(FILE *f, uint16_t dataLen, uint16_t memStart, uint16_t memlen);
static void loadCompressedMemPage(FILE *f, uint16_t dataLen, uint8_t* memPage, uint16_t memlen);
Expand Down
36 changes: 35 additions & 1 deletion include/Tape.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ visit https://zxespectrum.speccy.org/contacto
#define Tape_h

#include <inttypes.h>
#include <vector>
#include <string>

using namespace std;
Expand Down Expand Up @@ -72,23 +73,56 @@ using namespace std;
#define TAPE_BLK_PAUSELEN 1750000UL // 1/2 second of pause between blocks
//#define TAPE_BLK_PAUSELEN 875000UL // 1/4 second of pause between blocks

class TapeBlock
{
public:
enum BlockType {
Program_header,
Number_array_header,
Character_array_header,
Code_header,
Data_block,
Info,
Unassigned
};
// uint8_t Index; // Index (position) of the tape block in the tape file.
// BlockType Type; // Type of tape block (enum).
// char FileName[11]; // File name in header block.
// bool IsHeaderless; // Set to true for data blocks without a header.
// uint8_t Checksum; // Header checksum byte.
// uint8_t BlockTypeNum; // Block type, 0x00 = header; 0xFF = data block.
uint32_t StartPosition; // Start point of this block?
// uint16_t BlockLength;
};

class Tape
{
public:

// Tape
static FILE *tape;
static string tapeFileName;
static string tapeSaveName;
static uint8_t tapeEarBit;
static uint8_t tapeStatus;
static uint8_t SaveStatus;
static uint8_t romLoading;
static uint16_t tapeCurBlock;
static uint16_t tapeNumBlocks;
static uint32_t tapebufByteCount;
static uint32_t tapePlayOffset;
static size_t tapeFileSize;

static std::vector<TapeBlock> TapeListing;

static void Init();
static void Open(string name);
static void TAP_Play();
static void TAP_Stop();
static void TAP_Read();
static void IRAM_ATTR TAP_Read();
static bool FlashLoad();
static void Save();
static uint32_t CalcTapBlockPos(int block);

};

Expand Down
Loading

0 comments on commit 54d5047

Please sign in to comment.