diff --git a/MCUME_pico/bin/mcume_pico64.uf2 b/MCUME_pico/bin/mcume_pico64.uf2 index ccc9ec6..14a630a 100644 Binary files a/MCUME_pico/bin/mcume_pico64.uf2 and b/MCUME_pico/bin/mcume_pico64.uf2 differ diff --git a/MCUME_pico/pico64/c64.cpp b/MCUME_pico/pico64/c64.cpp index 647a24d..7156956 100644 --- a/MCUME_pico/pico64/c64.cpp +++ b/MCUME_pico/pico64/c64.cpp @@ -17,6 +17,10 @@ AudioPlaySID playSID; using namespace std; +#define OSKB_YPOS (240-16) +static bool oskbActive=false; + + /* IRAM_ATTR */ static void oneRasterLine(void) { static unsigned short lc = 1; @@ -157,7 +161,8 @@ uint8_t cia1PORTA(void) { uint8_t v; v = ~cpu.cia1.R[0x02] | (cpu.cia1.R[0x00] & cpu.cia1.R[0x02]); - int keys = emu_ReadKeys(); + int keys = 0; + if (!oskbActive) keys = emu_ReadKeys(); if (!cpu.swapJoysticks) { if (keys & MASK_JOY2_BTN) v &= 0xEF; if (keys & MASK_JOY2_UP) v &= 0xFE; @@ -197,7 +202,6 @@ uint8_t cia1PORTA(void) { } return v; - } @@ -206,8 +210,8 @@ uint8_t cia1PORTB(void) { uint8_t v; v = ~cpu.cia1.R[0x03] | (cpu.cia1.R[0x00] & cpu.cia1.R[0x02]) ; - - int keys = emu_ReadKeys(); + int keys = 0; + if (!oskbActive) keys = emu_ReadKeys(); if (!cpu.swapJoysticks) { if (keys & MASK_JOY1_BTN) v &= 0xEF; if (keys & MASK_JOY1_UP) v &= 0xFE; @@ -274,19 +278,87 @@ void c64_Start(char * filename) } -static uint8_t nbkeys=0; -static uint8_t kcnt=0; -static bool toggle=true; +static uint8_t nbkeys = 0; +static uint8_t kcnt = 0; +static bool toggle = true; -static char * seq="LOAD\"\"\r RUN\r"; +static char * textseq; +static char * textload = "LOAD\"\"\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tRUN\r"; +static char textkey[1]; static bool res=false; +static bool firsttime=true; + + +static unsigned char dummyline[320]; + +static char * oskbtext1 = "1234567890 \"$,ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +static char * oskbtext2 = "FFFFFFFF "; +static int oskbXPos = 10; +static int oskbYPos = 0; + +#define OSKB_TEXT VGA_RGB(0, 0, 170) +#define OSKB_BG VGA_RGB(255, 255, 255) +#define OSKB_HL VGA_RGB(255, 255, 0) + +void emu_DrawVsync(void) +{ + char sel[2]={0,0}; + if (oskbActive) { + tft.drawText(0,OSKB_YPOS,oskbtext1,OSKB_TEXT,OSKB_BG,false); + tft.drawText(0,OSKB_YPOS+8,oskbtext2,OSKB_TEXT,OSKB_BG,false); + sel[0]=(oskbYPos==0)?oskbtext1[oskbXPos]:oskbtext2[oskbXPos]; + tft.drawText(oskbXPos*8,OSKB_YPOS+8*oskbYPos,sel,OSKB_TEXT,OSKB_HL,false); + } + //skip += 1; + //skip &= VID_FRAME_SKIP; + tft.waitSync(); +} + + +void * emu_LineBuffer(int line) +{ + if ( (line >= OSKB_YPOS) && (oskbActive) ) + return &dummyline[0]; + + return (void*)tft.getLineBuffer(line); +} + void c64_Input(int bClick) { + if (oskbActive) { + if (bClick & MASK_JOY2_BTN) { + textkey[0] = oskbtext1[oskbXPos]; + if (oskbYPos==1) if (oskbXPos<8) textkey[0] = 0x85+oskbXPos; + textseq = textkey; + nbkeys = 1; + kcnt = 0; + } + if (bClick & MASK_JOY2_RIGHT) if (oskbXPos != 0) oskbXPos--; + if (bClick & MASK_JOY2_LEFT) if (oskbXPos != 39) oskbXPos++; + if (bClick & MASK_JOY2_UP) oskbYPos = 0; + if (bClick & MASK_JOY2_DOWN) oskbYPos = 1; + } + if (nbkeys == 0) { - if (bClick) { - nbkeys = strlen(seq); - kcnt=0; + if (bClick & MASK_KEY_USER1) { + if (!oskbActive) { + oskbActive = true; + } + else { + oskbActive = false; + } + } + else if (bClick & MASK_KEY_USER2) { + if (firsttime) { + firsttime = false; + textseq = textload; + nbkeys = strlen(textseq); + kcnt=0; + } + else { + cpu.swapJoysticks = !cpu.swapJoysticks; + } } else { @@ -302,8 +374,8 @@ void c64_Input(int bClick) { } } else { - char k = seq[kcnt]; - if (k != ' ') setKey(ascii2scan[k],toggle); + char k = textseq[kcnt]; + if (k != '\t') setKey(ascii2scan[k],toggle); if (!toggle) { kcnt++; nbkeys--; diff --git a/MCUME_pico/pico64/pico64.cpp b/MCUME_pico/pico64/pico64.cpp index 2a77d9b..e1c2644 100644 --- a/MCUME_pico/pico64/pico64.cpp +++ b/MCUME_pico/pico64/pico64.cpp @@ -21,7 +21,18 @@ bool repeating_timer_callback(struct repeating_timer *t) { return true; } +#include "hardware/clocks.h" +#include "hardware/vreg.h" + int main(void) { + 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(225000, true); + set_sys_clock_khz(250000, true); + stdio_init_all(); tft.begin(VGA_MODE_320x240); @@ -65,12 +76,7 @@ void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int } } -void emu_DrawVsync(void) -{ - skip += 1; - skip &= VID_FRAME_SKIP; - tft.waitSync(); -} + void emu_DrawLine(unsigned char * VBuf, int width, int height, int line) { @@ -106,10 +112,6 @@ int emu_FrameSkip(void) return skip; } -void * emu_LineBuffer(int line) -{ - return (void*)tft.getLineBuffer(line); -} diff --git a/MCUME_pico/pico64/vic.cpp b/MCUME_pico/pico64/vic.cpp index 5545a02..8c03677 100644 --- a/MCUME_pico/pico64/vic.cpp +++ b/MCUME_pico/pico64/vic.cpp @@ -1271,7 +1271,7 @@ typedef void (*modes_t)( tpixel *p, const tpixel *pe, uint16_t *spl, const uint1 const modes_t modes[8] = {mode0, mode1, mode2, mode3, mode4, mode5, mode6, mode7}; -static tpixel linebuffer[SCREEN_WIDTH]; +//static tpixel linebuffer[SCREEN_WIDTH]; void vic_do(void) { @@ -1291,7 +1291,6 @@ void vic_do(void) { */ if ( cpu.vic.rasterLine >= LINECNT ) { - //reSID sound needs much time - too much to keep everything in sync and with stable refreshrate //but it is not called very often, so most of the time, we have more time than needed. //We can measure the time needed for a frame and calc a correction factor to speed things up. @@ -1303,9 +1302,9 @@ void vic_do(void) { cpu.vic.rasterLine = 0; cpu.vic.vcbase = 0; cpu.vic.denLatch = 0; - //if (cpu.vic.rasterLine == LINECNT) - //delay(50); - emu_DrawVsync(); + //if (cpu.vic.rasterLine == LINECNT) { + emu_DrawVsync(); + //} } else cpu.vic.rasterLine++; @@ -1394,7 +1393,8 @@ void vic_do(void) { //max_x = (!cpu.vic.CSEL) ? 40:38; //p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH; - p = &linebuffer[0]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)); + //p = &linebuffer[0]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)); + p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)); pe = p + SCREEN_WIDTH; //Left Screenborder: Cycle 10 spl = &cpu.vic.spriteLine[24]; @@ -1559,7 +1559,8 @@ g-Zugriff uint16_t col = cpu.vic.colors[0]; //p = &screen[r - FIRSTDISPLAYLINE][0]; //p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + BORDER_LEFT; - p = &linebuffer[0]; // tft.getLineBuffer((r - FIRSTDISPLAYLINE)); + //p = &linebuffer[0]; // tft.getLineBuffer((r - FIRSTDISPLAYLINE)); + p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)); #if 0 // Sprites im Rand uint16_t sprite; @@ -1583,7 +1584,8 @@ g-Zugriff //Rand rechts: //p = &screen[r - FIRSTDISPLAYLINE][SCREEN_WIDTH - 9]; //p = SCREENMEM + (r - FIRSTDISPLAYLINE) * LINE_MEM_WIDTH + SCREEN_WIDTH - 9 + BORDER_LEFT; - p = &linebuffer[SCREEN_WIDTH - 9 + BORDER_LEFT]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT; + //p = &linebuffer[SCREEN_WIDTH - 9 + BORDER_LEFT]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT; + p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT; pe = p + 9; #if 0 @@ -1603,7 +1605,7 @@ g-Zugriff } - emu_DrawLine8(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE)); +// emu_DrawLine8(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE)); //Rechter Rand nach CSEL, im Textbereich diff --git a/MCUME_pico/testvga/testvga.cpp b/MCUME_pico/testvga/testvga.cpp new file mode 100644 index 0000000..8572893 --- /dev/null +++ b/MCUME_pico/testvga/testvga.cpp @@ -0,0 +1,73 @@ +#include "pico.h" +#include "pico/stdlib.h" + +#include "vga_t_dma.h" + +#include +#include + +TFT_T_DMA vga; + +#define BLUE VGA_RGB(0, 0, 170) +#define LIGHT_BLUE VGA_RGB(0, 136, 255) + +static int fb_width, fb_height; + +static char * digits = "0123456789"; + +#include "hardware/clocks.h" +#include "hardware/vreg.h" + +static uint8_t pix = 0; +int main(void) { + 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(225000, true); + set_sys_clock_khz(250000, true); + + stdio_init_all(); + + printf("start\n"); + vga.begin(VGA_MODE_320x240); + //tft.fillScreenNoDma( RGBVAL16(0xff,0x00,0x00) ); + vga.clear(LIGHT_BLUE); + vga.get_frame_buffer_size(&fb_width, &fb_height); + vga.drawRect((fb_width-320)/2,(fb_height-200)/2, 320,200, BLUE); + vga.drawText((fb_width-320)/2,(fb_height-200)/2+1*8," **** COMMODORE 64 BASIC V2 **** ",LIGHT_BLUE,BLUE,false); + vga.drawText((fb_width-320)/2,(fb_height-200)/2+3*8," 64K RAM SYSTEM 38911 BASIC BYTES FREE ",LIGHT_BLUE,BLUE,false); + vga.drawText((fb_width-320)/2,(fb_height-200)/2+5*8,"READY.",LIGHT_BLUE,BLUE,false); + + char buf[4] = {32,32,32,0}; + uint sys_clk = clock_get_hz(clk_sys)/1000000; + uint r1 = sys_clk/100; + uint r = sys_clk - r1*100; + uint r2 = r/10; + r = sys_clk - r1*100 - r2*10; + uint r3 = r; + buf[0] = digits[r1]; + buf[1] = digits[r2]; + buf[2] = digits[r3]; + vga.drawText(0,0,buf,BLUE,LIGHT_BLUE,false); + + + while (true) { + //tft.fillScreenNoDma( pix++ ); + vga.waitSync(); + vga.drawText((fb_width-320)/2,(fb_height-200)/2+6*8," ",BLUE,LIGHT_BLUE,false); + sleep_ms(500); + //vga.waitSync(); + vga.drawText((fb_width-320)/2,(fb_height-200)/2+6*8," ",BLUE,BLUE,false); + sleep_ms(500); + //vga.waitSync(); + printf("x\n"); + } +} + + + + + + diff --git a/MCUME_pico/vga_t4/VGA_t4.cpp b/MCUME_pico/vga_t4/VGA_t4.cpp index 7c6999d..70ddd42 100755 --- a/MCUME_pico/vga_t4/VGA_t4.cpp +++ b/MCUME_pico/vga_t4/VGA_t4.cpp @@ -1696,7 +1696,7 @@ void VGA_T4::begin_audio(int samplesize, void (*callback)(short * stream, int le // Setup PWM for audio output pwm_config config = pwm_get_default_config(); // pwm_config_set_clkdiv(&config, 5.5f); - pwm_config_set_clkdiv(&config, 40.0f); + pwm_config_set_clkdiv(&config, 50.0f); pwm_config_set_wrap(&config, 254); pwm_init(audio_pin_slice, &config, true); diff --git a/MCUME_pico/vga_t4_old_driver.zip b/MCUME_pico/vga_t4_old_driver.zip deleted file mode 100644 index b6b5c68..0000000 Binary files a/MCUME_pico/vga_t4_old_driver.zip and /dev/null differ