mirror of
https://github.com/jscrane/r65emu.git
synced 2024-06-19 20:29:41 +00:00
commit
5af9e7b373
34
hardware.h
34
hardware.h
|
@ -6,35 +6,23 @@
|
||||||
#define __HARDWARE_H__
|
#define __HARDWARE_H__
|
||||||
|
|
||||||
// TFT display...
|
// TFT display...
|
||||||
// NOTE: edit memorysaver.h to select the correct chip for your display!
|
#undef TFT_BACKLIGHT
|
||||||
// Daniel Rebollo's boosterpack
|
#define TFT_MODEL ILI9325C
|
||||||
#define TFT_BACKLIGHT PD_6
|
#define TFT_RS 32
|
||||||
#define TFT_MODEL SSD1289
|
#define TFT_WR 33
|
||||||
// TFT01_2.4: http://www.elecfreaks.com/store/24-tft-lcd-tft0124-p-110.html
|
#define TFT_CS 27
|
||||||
// #undef TFT_BACKLIGHT
|
#define TFT_RST 26
|
||||||
// #define TFT_MODEL S6D1121_8
|
|
||||||
#define TFT_RS PC_6
|
|
||||||
#define TFT_WR PC_5
|
|
||||||
#define TFT_CS PC_7
|
|
||||||
#define TFT_RST PC_4
|
|
||||||
|
|
||||||
// PS/2 keyboard
|
// PS/2 keyboard
|
||||||
#define KBD_DATA PE_4
|
#define KBD_DATA 14
|
||||||
#define KBD_IRQ PE_5
|
#define KBD_IRQ 12
|
||||||
|
|
||||||
// SPI-RAM
|
// SPI-RAM
|
||||||
#define SPIRAM_CS PE_0
|
#undef SPIRAM_CS
|
||||||
//#define SPIRAM_CS PF_3
|
|
||||||
#define SPIRAM_SPI 1
|
|
||||||
#define SPIRAM_DEV SPI_for_SD
|
|
||||||
#define SPIRAM_SIZE 65536
|
|
||||||
|
|
||||||
// "tape" storage...
|
// "tape" storage...
|
||||||
#define SD_CS PF_3
|
#undef SD_CS
|
||||||
//#define SD_CS PE_0
|
#define USE_SPIFFS 1
|
||||||
#define SD_SPI 1
|
|
||||||
|
|
||||||
#define SPI_CS PF_3
|
|
||||||
|
|
||||||
bool hardware_reset();
|
bool hardware_reset();
|
||||||
void hardware_init(class CPU &);
|
void hardware_init(class CPU &);
|
||||||
|
|
2
r6502.h
2
r6502.h
|
@ -2,6 +2,8 @@
|
||||||
#define __R6502_H__
|
#define __R6502_H__
|
||||||
|
|
||||||
#undef PC
|
#undef PC
|
||||||
|
#undef cli
|
||||||
|
#undef sei
|
||||||
class Stream;
|
class Stream;
|
||||||
|
|
||||||
class r6502: public CPU {
|
class r6502: public CPU {
|
||||||
|
|
1
r65emu.h
1
r65emu.h
|
@ -13,5 +13,6 @@
|
||||||
#include "timed.h"
|
#include "timed.h"
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
#include "checkpoint.h"
|
#include "checkpoint.h"
|
||||||
|
#include "sound.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
67
sound.cpp
Normal file
67
sound.cpp
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <hardware.h>
|
||||||
|
#include "timed.h"
|
||||||
|
#include "sound.h"
|
||||||
|
|
||||||
|
#if defined(DAC_SOUND) && defined(ESP_PLATFORM)
|
||||||
|
#include <driver/dac.h>
|
||||||
|
|
||||||
|
static portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
|
||||||
|
static dac_channel_t channel;
|
||||||
|
|
||||||
|
static volatile const uint8_t *_bytes;
|
||||||
|
static volatile unsigned _size, _off;
|
||||||
|
static hw_timer_t *timer;
|
||||||
|
|
||||||
|
void IRAM_ATTR timer_callback() {
|
||||||
|
portENTER_CRITICAL_ISR(&mux);
|
||||||
|
|
||||||
|
if (_off < _size)
|
||||||
|
dac_output_voltage(channel, _bytes[_off++]);
|
||||||
|
else {
|
||||||
|
_bytes = 0;
|
||||||
|
dac_output_disable(channel);
|
||||||
|
timerAlarmDisable(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
portEXIT_CRITICAL_ISR(&mux);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sound::begin(unsigned pin, unsigned freq) {
|
||||||
|
if (pin == 25)
|
||||||
|
channel = DAC_CHANNEL_1;
|
||||||
|
else if (pin == 26)
|
||||||
|
channel = DAC_CHANNEL_2;
|
||||||
|
|
||||||
|
timer = timerBegin(1, 80, true);
|
||||||
|
timerAttachInterrupt(timer, &timer_callback, true);
|
||||||
|
timerAlarmWrite(timer, 1000000 / freq, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t *Sound::play(const uint8_t *bytes, unsigned size) {
|
||||||
|
portENTER_CRITICAL_ISR(&mux);
|
||||||
|
|
||||||
|
const uint8_t *play = (const uint8_t *)_bytes;
|
||||||
|
if (_off == _size) {
|
||||||
|
_bytes = bytes;
|
||||||
|
_size = size;
|
||||||
|
_off = 0;
|
||||||
|
dac_output_enable(channel);
|
||||||
|
timerAlarmEnable(timer);
|
||||||
|
play = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
portEXIT_CRITICAL_ISR(&mux);
|
||||||
|
return play;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// does nothing by default
|
||||||
|
void Sound::begin(unsigned channel, unsigned freq) {
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t *Sound::play(const uint8_t *bytes, unsigned size) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
10
sound.h
Normal file
10
sound.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef __SOUND_H__
|
||||||
|
#define __SOUND_H__
|
||||||
|
|
||||||
|
class Sound {
|
||||||
|
public:
|
||||||
|
void begin(unsigned pin, unsigned freq);
|
||||||
|
const uint8_t *play(const uint8_t *bytes, unsigned size);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
13
timed.cpp
13
timed.cpp
|
@ -1,5 +1,4 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#if defined(__LM4F120H5QR__)
|
#if defined(__LM4F120H5QR__)
|
||||||
#include <inc/hw_ints.h>
|
#include <inc/hw_ints.h>
|
||||||
|
@ -29,4 +28,16 @@ void timer_create(unsigned freq, Timed *client) {
|
||||||
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
||||||
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet() / freq);
|
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet() / freq);
|
||||||
}
|
}
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
|
||||||
|
void IRAM_ATTR onTimer() {
|
||||||
|
t->tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
void timer_create(unsigned freq, Timed *client) {
|
||||||
|
hw_timer_t *timer = timerBegin(3, 80, true); // prescaler of 80
|
||||||
|
timerAttachInterrupt(timer, &onTimer, true);
|
||||||
|
timerAlarmWrite(timer, 1000000 / freq, true);
|
||||||
|
timerAlarmEnable(timer);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user