kopia lustrzana https://github.com/Jean-MarcHarvengt/MCUME
got rid of some emuapi.cpp and picocpc.cpp errors
rodzic
435475c231
commit
5048271416
Plik diff jest za duży
Load Diff
|
@ -3,16 +3,19 @@
|
|||
|
||||
#include "platform_config.h"
|
||||
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
||||
/* Title */
|
||||
#define TITLE " Amstrad CPC Emulator"
|
||||
#define ROMSDIR "cpc"
|
||||
|
||||
#define emu_Init(ROM) {cpc_Init(); cpc_Start();}
|
||||
#define emu_Init(ROM) {cpc_Init(); cpc_Start(ROM);}
|
||||
#define emu_Step(x) {cpc_Step();}
|
||||
#define emu_Input(x) {cpc_Input(x);}
|
||||
|
||||
#define PALETTE_SIZE 27
|
||||
#define VID_FRAME_SKIP 0x0
|
||||
#define TFT_VBUFFER_YCROP 0
|
||||
#define TFT_VUBFFER_YCROP 0
|
||||
|
||||
#define ACTION_NONE 0
|
||||
|
@ -27,6 +30,22 @@
|
|||
|
||||
// here are joystick mask mappings in emuapi.h for picospeccy
|
||||
|
||||
#define MASK_JOY2_RIGHT 0x0001
|
||||
#define MASK_JOY2_LEFT 0x0002
|
||||
#define MASK_JOY2_UP 0x0004
|
||||
#define MASK_JOY2_DOWN 0x0008
|
||||
#define MASK_JOY2_BTN 0x0010
|
||||
#define MASK_KEY_USER1 0x0020
|
||||
#define MASK_KEY_USER2 0x0040
|
||||
#define MASK_KEY_USER3 0x0080
|
||||
#define MASK_JOY1_RIGHT 0x0100
|
||||
#define MASK_JOY1_LEFT 0x0200
|
||||
#define MASK_JOY1_UP 0x0400
|
||||
#define MASK_JOY1_DOWN 0x0800
|
||||
#define MASK_JOY1_BTN 0x1000
|
||||
#define MASK_KEY_USER4 0x2000
|
||||
#define MASK_OSKB 0x8000
|
||||
|
||||
extern void emu_init(void);
|
||||
extern void emu_start(void);
|
||||
extern void emu_resetSD(void);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#ifndef keyboard_osd_h_
|
||||
#define keyboard_osd_h_
|
||||
|
||||
extern bool virtualkeyboardIsActive(void);
|
||||
extern void drawVirtualkeyboard(void);
|
||||
extern void toggleVirtualkeyboard(bool keepOn);
|
||||
extern void handleVirtualkeyboard(void);
|
||||
|
||||
extern bool callibrationActive(void);
|
||||
extern int handleCallibration(uint16_t bClick);
|
||||
|
||||
extern bool menuActive(void);
|
||||
extern char * menuSelection(void);
|
||||
extern void toggleMenu(bool on);
|
||||
extern int handleMenu(uint16_t bClick);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,50 +1,187 @@
|
|||
#include "pico.h"
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
#include "vga_t_dma.h"
|
||||
extern "C" {
|
||||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
}
|
||||
#include "keyboard_osd.h"
|
||||
|
||||
extern "C" {
|
||||
#include "cpc.h"
|
||||
}
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
TFT_T_DMA vga;
|
||||
#ifdef USE_VGA
|
||||
#include "vga_t_dma.h"
|
||||
#else
|
||||
#include "tft_t_dma.h"
|
||||
#endif
|
||||
volatile bool vbl=true;
|
||||
|
||||
#define BLACK VGA_RGB(0,0,0)
|
||||
bool repeating_timer_callback(struct repeating_timer *t) {
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
emu_Input(bClick);
|
||||
if (vbl) {
|
||||
vbl = false;
|
||||
} else {
|
||||
vbl = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
TFT_T_DMA tft;
|
||||
|
||||
static int skip=0;
|
||||
|
||||
#define BLUE VGA_RGB(0, 0, 170)
|
||||
#define LIGHT_BLUE VGA_RGB(0, 136, 255)
|
||||
#define GREEN VGA_RGB(0, 170, 0)
|
||||
#define LIGHT_GREEN VGA_RGB(144, 238, 144)
|
||||
|
||||
static int fb_width, fb_height;
|
||||
|
||||
static char * digits = "0123456789";
|
||||
#include "hardware/clocks.h"
|
||||
#include "hardware/vreg.h"
|
||||
|
||||
int main(void) {
|
||||
set_sys_clock_khz(230000, true);
|
||||
// vreg_set_voltage(VREG_VOLTAGE_1_05);
|
||||
// set_sys_clock_khz(125000, true);
|
||||
// set_sys_clock_khz(150000, true);
|
||||
// set_sys_clock_khz(133000, true);
|
||||
// set_sys_clock_khz(200000, true);
|
||||
// set_sys_clock_khz(210000, true);
|
||||
set_sys_clock_khz(230000, true);
|
||||
// set_sys_clock_khz(225000, true);
|
||||
// set_sys_clock_khz(250000, true);
|
||||
stdio_init_all();
|
||||
|
||||
vga.begin(VGA_MODE_320x240);
|
||||
vga.clear(LIGHT_BLUE);
|
||||
vga.get_frame_buffer_size(&fb_width, &fb_height);
|
||||
|
||||
vga.drawRect((fb_width-320)/2, (fb_height-200), 320, 200, BLUE);
|
||||
|
||||
auto w = std::to_string(fb_width);
|
||||
auto h = std::to_string(fb_height);
|
||||
char* width = new char[w.length() + 1];
|
||||
char* height = new char[h.length() + 1];
|
||||
strcpy(width,w.c_str());
|
||||
strcpy(height,h.c_str());
|
||||
|
||||
#ifdef USE_VGA
|
||||
tft.begin(VGA_MODE_320x240);
|
||||
#else
|
||||
tft.begin();
|
||||
#endif
|
||||
emu_init();
|
||||
while (true) {
|
||||
vga.waitSync();
|
||||
vga.clear(BLUE);
|
||||
vga.drawText((fb_width-320)/2 + 1*8,(fb_height-200)/2+1*8,"Soon to be CPC emulator",LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8,(fb_height-200)/2+3*8,"fb_width: ",LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8 + 10*8,(fb_height-200)/2+3*8,width,LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8,(fb_height-200)/2+5*8,"fb_height: ",LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8 + 10*8,(fb_height-200)/2+3*8,height,LIGHT_BLUE,BLUE,false);
|
||||
if (menuActive()) {
|
||||
uint16_t bClick = emu_DebounceLocalKeys();
|
||||
int action = handleMenu(bClick);
|
||||
char * filename = menuSelection();
|
||||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
emu_start();
|
||||
emu_Init(filename);
|
||||
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
||||
tft.startDMA();
|
||||
struct repeating_timer timer;
|
||||
add_repeating_timer_ms(5, repeating_timer_callback, NULL, &timer);
|
||||
}
|
||||
tft.waitSync();
|
||||
}
|
||||
else {
|
||||
emu_Step();
|
||||
}
|
||||
//int c = getchar_timeout_us(0);
|
||||
//switch (c) {
|
||||
// case ' ':
|
||||
// printf("test: %d\n", 1);
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
|
||||
void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index)
|
||||
{
|
||||
if (index<PALETTE_SIZE) {
|
||||
palette8[index] = RGBVAL8(r,g,b);
|
||||
palette16[index] = RGBVAL16(r,g,b);
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawVsync(void)
|
||||
{
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
volatile bool vb=vbl;
|
||||
while (vbl==vb) {};
|
||||
#ifdef USE_VGA
|
||||
// tft.waitSync();
|
||||
#else
|
||||
// volatile bool vb=vbl;
|
||||
// while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf, palette8);
|
||||
#else
|
||||
tft.writeLine(width,height,line, VBuf, palette16);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeLine16(width,height,line, VBuf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
|
||||
{
|
||||
if (skip == 0) {
|
||||
#ifdef USE_VGA
|
||||
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette8);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int emu_FrameSkip(void)
|
||||
{
|
||||
return skip;
|
||||
}
|
||||
|
||||
void * emu_LineBuffer(int line)
|
||||
{
|
||||
return (void*)tft.getLineBuffer(line);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
//#include "AudioPlaySystem.h"
|
||||
//AudioPlaySystem mymixer;
|
||||
#include "hardware/pwm.h"
|
||||
void emu_sndInit() {
|
||||
tft.begin_audio(256, mymixer.snd_Mixer);
|
||||
mymixer.start();
|
||||
//gpio_init(AUDIO_PIN);
|
||||
//gpio_set_dir(AUDIO_PIN, GPIO_OUT);
|
||||
}
|
||||
|
||||
void emu_sndPlaySound(int chan, int volume, int freq)
|
||||
{
|
||||
if (chan < 6) {
|
||||
mymixer.sound(chan, freq, volume);
|
||||
}
|
||||
}
|
||||
|
||||
void emu_sndPlayBuzz(int size, int val) {
|
||||
#ifndef CUSTOM_SND
|
||||
//gpio_put(AUDIO_PIN, (val?1:0));
|
||||
pwm_set_gpio_level(AUDIO_PIN, (val?255:128));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -41,9 +41,10 @@ int main(void) {
|
|||
while (true) {
|
||||
vga.waitSync();
|
||||
vga.clear(BLUE);
|
||||
vga.drawText((fb_width-320)/2 + 1*8,(fb_height-200)/2+1*8,"fb_width: ",LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8 + 10*8,(fb_height-200)/2+1*8,width,LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8,(fb_height-200)/2+3*8,"fb_height: ",LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8,(fb_height-200)/2+1*8,"Soon to be CPC emulator",LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8,(fb_height-200)/2+3*8,"fb_width: ",LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8 + 10*8,(fb_height-200)/2+3*8,width,LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8,(fb_height-200)/2+5*8,"fb_height: ",LIGHT_BLUE,BLUE,false);
|
||||
vga.drawText((fb_width-320)/2 + 1*8 + 10*8,(fb_height-200)/2+3*8,height,LIGHT_BLUE,BLUE,false);
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue