#include "psub.h"
#include "timer.h"
#include "../i8255.h"
-#include "../../fileio.h"
#define STICK0_SPACE 0x80
#define STICK0_LEFT 0x20
#define EVENT_STRIG 1
/* normal (small alphabet) */
-byte Keys1[256][2] =
+uint8_t Keys1[256][2] =
{
/* 0 1 2 3 4 5 6 7 */
/* 00 */
};
/* normal (small alphabet) + shift */
-byte Keys2[256][2] =
+uint8_t Keys2[256][2] =
{
/* 00 */
{0,0x35},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},
};
/* hiragana */
-byte Keys3[256][2] =
+uint8_t Keys3[256][2] =
{
/* 00 */
{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},
};
/* hiragana + shift */
-byte Keys4[256][2] =
+uint8_t Keys4[256][2] =
{
/* 00 */
{0,0x35},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},
};
/* katakana */
-byte Keys5[256][2] =
+uint8_t Keys5[256][2] =
{
/* 00 */
{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},
};
/* katakana + shift */
-byte Keys6[256][2] =
+uint8_t Keys6[256][2] =
{
/* 00 */
{0,0x35},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},
};
/* with graph key */
-byte Keys7[256][2] =
+uint8_t Keys7[256][2] =
{
/* 00 */
{0,0x35},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},{0,0x00},
{
for (int code=0; code < 256; code++) {
if (key_stat[code] & 0x80) {
+ if (code == VK_LSHIFT || code == VK_LCONTROL || code == VK_LMENU ||
+ code == VK_RSHIFT || code == VK_RCONTROL || code == VK_RMENU) continue;
if (code == VK_SHIFT || code == VK_CONTROL) continue;
key_stat[code]=0;
if (code == 0x75) {kanaMode = -1 * (kanaMode-1);continue;} // VK_F6
if (code == 0x76) {katakana = -1 * (katakana-1);continue;} // VK_F7
if (code == 0x77) {kbFlagGraph = -1 * (kbFlagGraph-1);continue;} // VK_F8
p6key=code;
- byte *Keys;
- byte ascii=0;
+ uint8_t *Keys;
+ uint8_t ascii=0;
if (kbFlagGraph) {
Keys = Keys7[code];
} else if (kanaMode) {
}
}
-bool PSUB::play_tape(_TCHAR* file_path)
+bool PSUB::play_tape(const _TCHAR* file_path)
{
close_tape();
fio->Fseek(length, FILEIO_SEEK_SET);
char id_p = fio->Fgetc();
char id_6 = fio->Fgetc();
- uint8 ver = fio->FgetUint8();
+ uint8_t ver = fio->FgetUint8();
if(id_p == 'P' && id_6 == '6' && ver == 2) {
- uint8 blocks = fio->FgetUint8();
+ uint8_t blocks = fio->FgetUint8();
if(blocks >= 1) {
fio->FgetUint8();
fio->FgetUint8();
fio->FgetUint8();
- uint16 cmd = fio->FgetUint16();
+ uint16_t cmd = fio->FgetUint16();
fio->Fseek(cmd, FILEIO_SEEK_CUR);
- uint16 exp = fio->FgetUint16();
+ uint16_t exp = fio->FgetUint16();
fio->Fseek(exp, FILEIO_SEEK_CUR);
// check 1st data block
char id_t = fio->Fgetc();
FileBaud = (int)fio->FgetUint16();
}
}
- remain = min(length, sizeof(CasData));
+ remain = min(length, (int)sizeof(CasData));
}
}
fio->Fseek(0, FILEIO_SEEK_SET);
return play;
}
-bool PSUB::rec_tape(_TCHAR* file_path)
+bool PSUB::rec_tape(const _TCHAR* file_path)
{
close_tape();
if(fio->Fopen(file_path, FILEIO_READ_WRITE_NEW_BINARY)) {
- _tcscpy_s(rec_file_path, _MAX_PATH, file_path);
+ my_tcscpy_s(rec_file_path, _MAX_PATH, file_path);
CasIndex=0;
rec = true;
is_wav = check_file_extension(file_path, _T(".wav"));
return rec;
}
-#pragma pack(1)
-typedef struct {
- char id[4];
- uint32 size;
-} wav_chunk_t;
-#pragma pack()
-
-#pragma pack(1)
-typedef struct {
- wav_chunk_t riff_chunk;
- char wave[4];
- wav_chunk_t fmt_chunk;
- uint16 format_id;
- uint16 channels;
- uint32 sample_rate;
- uint32 data_speed;
- uint16 block_size;
- uint16 sample_bits;
-} wav_header_t;
-#pragma pack()
-
-static const uint8 pulse_1200hz[40] = {
+static const uint8_t pulse_1200hz[40] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
-static const uint8 pulse_2400hz[20] = {
+static const uint8_t pulse_2400hz[20] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
-static const uint8 pulse_2400hz_x2[40] = {
+static const uint8_t pulse_2400hz_x2[40] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
fio->Fwrite((void *)pulse_2400hz_x2, sizeof(pulse_2400hz_x2), 1);
}
#endif
- uint32 length = fio->Ftell();
+ uint32_t length = fio->Ftell();
+ pair_t __riff_chunk_size;
+ pair_t __fmt_chunk_size;
+ pair_t __wav_chunk_size;
+ pair16_t __fmt_id;
+ pair16_t __channels;
+ pair_t __sample_rate;
+ pair16_t __block_size;
+ pair16_t __sample_bits;
+
+ __riff_chunk_size.d = length - 8;
+ __fmt_chunk_size.d = 16;
+ __fmt_id.w = 1;
+ __channels.w = 1;
+ __sample_rate.d = sample_rate;
+ __block_size.w = 1;
+ __sample_bits.w = 8;
+
memcpy(wav_header.riff_chunk.id, "RIFF", 4);
- wav_header.riff_chunk.size = length - 8;
+ wav_header.riff_chunk.size = __riff_chunk_size.get_4bytes_le_to();
+
memcpy(wav_header.wave, "WAVE", 4);
memcpy(wav_header.fmt_chunk.id, "fmt ", 4);
- wav_header.fmt_chunk.size = 16;
- wav_header.format_id = 1;
- wav_header.channels = 1;
- wav_header.sample_rate = sample_rate;
- wav_header.data_speed = sample_rate;
- wav_header.block_size = 1;
- wav_header.sample_bits = 8;
-
+ wav_header.fmt_chunk.size = __riff_chunk_size.get_4bytes_le_to();
+ wav_header.format_id = __fmt_id.get_2bytes_le_to();
+ wav_header.channels = __channels.get_2byte_le_to();
+ wav_header.sample_rate = __sample_rate.get_4bytes_le_to();
+ wav_header.data_speed = __sample_rate.get_4bytes_le_to();
+ wav_header.block_size = __block_size.get_2bytes_le_to();
+ wav_header.sample_bits = __sample_bits_get_2bytes_le_to();
+
memcpy(wav_chunk.id, "data", 4);
- wav_chunk.size = length - sizeof(wav_header) - sizeof(wav_chunk);
-
+ __wav_chunk_size.d = length - sizeof(wav_header) - sizeof(wav_chunk);
+ wav_chunk.size = __wav_chunk_size.get_4bytes_le_to();
+
fio->Fseek(0, FILEIO_SEEK_SET);
fio->Fwrite(&wav_header, sizeof(wav_header), 1);
fio->Fwrite(&wav_chunk, sizeof(wav_chunk), 1);
fio = new FILEIO();
play = rec = false;
- key_stat = emu->key_buffer();
+// key_stat = emu->get_key_buffer();
+ memset(key_stat, 0, sizeof(key_stat));
+
kbFlagCtrl=0;
kbFlagGraph=0;
kbFlagFunc=0;
}
}
-uint32 PSUB::intr_ack()
+uint32_t PSUB::get_intr_ack()
{
if (CasMode != CAS_NONE && p6key == 0xFA && kbFlagGraph) {
return(INTADDR_CMTSTOP); /* Press STOP while CMT Load or Save */
return(INTADDR_TIMER);
}
-void PSUB::write_io8(uint32 addr, uint32 data)
+void PSUB::write_io8(uint32_t addr, uint32_t data)
{
- uint16 port=(addr & 0x00ff);
+ uint16_t port=(addr & 0x00ff);
if (port == 0x90) {
if (CasMode == CAS_SAVEBYTE) { /* CMT SAVE */
if (CasIndex<0x10000) {
d_pio->write_io8(addr, data);
}
-uint32 PSUB::read_io8(uint32 addr)
+uint32_t PSUB::read_io8(uint32_t addr)
{
- uint16 port=(addr & 0x00ff);
- byte Value=0xff;
+ uint16_t port=(addr & 0x00ff);
+ uint8_t Value=0xff;
if (port == 0x90) {
if (CasMode == CAS_LOADING) {
Value=CasRecv;
return Value;
}
+void PSUB::key_down(int code)
+{
+ key_stat[code] = 0x80;
+}
+
+void PSUB::key_up(int code)
+{
+ key_stat[code] = 0x00;
+}
+
#define STATE_VERSION 1
void PSUB::save_state(FILEIO* state_fio)
fio->Fseek(0, FILEIO_SEEK_SET);
state_fio->FputInt32(length_tmp);
while(length_tmp != 0) {
- uint8 buffer_tmp[1024];
- int length_rw = min(length_tmp, sizeof(buffer_tmp));
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
fio->Fread(buffer_tmp, length_rw, 1);
state_fio->Fwrite(buffer_tmp, length_rw, 1);
length_tmp -= length_rw;
if(rec) {
fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
while(length_tmp != 0) {
- uint8 buffer_tmp[1024];
- int length_rw = min(length_tmp, sizeof(buffer_tmp));
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
state_fio->Fread(buffer_tmp, length_rw, 1);
if(fio->IsOpened()) {
fio->Fwrite(buffer_tmp, length_rw, 1);