reshuffled for PICOZX platform with dual display

master
jean-marcharvengt 2023-04-20 23:21:15 +02:00
rodzic bb3ec50b4b
commit ef80369717
319 zmienionych plików z 3603 dodań i 142884 usunięć

Wyświetl plik

@ -6,7 +6,18 @@ include(pico_sdk_import.cmake)
# We also need PICO EXTRAS
#include(pico_extras_import.cmake)
project(mcume C CXX)
#set(TARGET testkeymax)
#set(TARGET pico20)
#set(TARGET pico64)
#set(TARGET pico81)
#set(TARGET picospeccy)
#set(TARGET pico800)
#set(TARGET pico5200)
#set(TARGET picocolem)
#set(TARGET picoo2em)
set(TARGET picovcs)
project(${TARGET} C CXX)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
@ -16,32 +27,66 @@ pico_sdk_init()
add_subdirectory(FatFs_SPI build)
include_directories(${TARGET})
include_directories(config)
include_directories(vga_t4)
include_directories(display)
#include_directories(vga_t4)
#include_directories(picovga_t4)
include_directories(tft_t)
#include_directories(tft_t)
include_directories(psram)
if( ${TARGET} MATCHES "pico20" )
set(PICO20_SOURCES
pico20/IC.cpp
pico20/mos6502.cpp
pico20/MOS6522.cpp
pico20/MOS6561.cpp
pico20/v20.cpp
pico20/pico20.cpp
)
#add_compile_definitions(OVERRULE_WIDTH=320 OVERRULE_HEIGHT=192)
endif()
if( ${TARGET} MATCHES "pico64" )
set(PICO64_SOURCES
pico64/c64.cpp
pico64/cia1.cpp
pico64/cia2.cpp
pico64/cpu.cpp
pico64/patches.cpp
pico64/pla.cpp
pico64/roms.cpp
pico64/sid.cpp
pico64/timerutil.cpp
pico64/vic.cpp
pico64/reSID.cpp
pico64/pico64.cpp
)
endif()
if( ${TARGET} MATCHES "pico81" )
set(PICO81_SOURCES
pico81/Z80.c
pico81/AY8910.c
pico81/zx81.c
pico81/emuapi.cpp
pico81/pico81.cpp
pico81/AudioPlaySystem.cpp
)
# ZX81,ZX Spectrum,Colem,Vic20
add_compile_definitions(OVERRULE_WIDTH=320 OVERRULE_HEIGHT=192)
endif()
if( ${TARGET} MATCHES "picospeccy" )
set(PICOSPECCY_SOURCES
picospeccy/Z80.c
picospeccy/AY8910.c
picospeccy/spec.c
picospeccy/zx_filetyp_z80.c
picospeccy/emuapi.cpp
picospeccy/picospeccy.cpp
picospeccy/AudioPlaySystem.cpp
)
add_compile_definitions(OVERRULE_WIDTH=320 OVERRULE_HEIGHT=192)
endif()
if( ${TARGET} MATCHES "pico800" )
set(PICO800_SOURCES
pico800/antic.c
pico800/atari800.c
@ -52,11 +97,11 @@ set(PICO800_SOURCES
pico800/pokey.c
pico800/pokeysnd.c
pico800/sio.c
pico800/emuapi.cpp
pico800/AudioPlaySystem.cpp
pico800/pico800.cpp
)
endif()
if( ${TARGET} MATCHES "pico5200" )
set(PICO5200_SOURCES
pico5200/antic.c
pico5200/atari5200.c
@ -65,53 +110,21 @@ set(PICO5200_SOURCES
pico5200/gtia.c
pico5200/pokey.c
pico5200/pokeysnd.c
pico5200/emuapi.cpp
pico5200/AudioPlaySystem.cpp
pico5200/pico5200.cpp
)
endif()
set(PICO20_SOURCES
pico20/IC.cpp
# pico20/MOS6502.cpp
# pico20/Register8.cpp
# pico20/Register16.cpp
# pico20/cpu.cpp
# pico20/cpu.c
pico20/mos6502.cpp
pico20/MOS6522.cpp
pico20/MOS6561.cpp
pico20/v20.cpp
pico20/emuapi.cpp
pico20/AudioPlaySystem.cpp
pico20/pico20.cpp
)
set(PICO64_SOURCES
pico64/c64.cpp
pico64/cia1.cpp
pico64/cia2.cpp
pico64/cpu.cpp
pico64/patches.cpp
pico64/pla.cpp
pico64/roms.cpp
pico64/sid.cpp
pico64/util.cpp
pico64/vic.cpp
pico64/reSID.cpp
pico64/emuapi.cpp
pico64/AudioPlaySystem.cpp
pico64/pico64.cpp
)
if( ${TARGET} MATCHES "picocolem" )
set(PICOCOLEM_SOURCES
picocolem/Z80.c
picocolem/SN76489.c
picocolem/Colem.c
picocolem/emuapi.cpp
picocolem/picocolem.cpp
picocolem/AudioPlaySystem.cpp
)
add_compile_definitions(OVERRULE_WIDTH=320 OVERRULE_HEIGHT=192)
endif()
if( ${TARGET} MATCHES "picoo2em" )
set(PICOO2EM_SOURCES
picoo2em/audio.c
picoo2em/cpu.c
@ -123,11 +136,12 @@ set(PICOO2EM_SOURCES
picoo2em/vmachine.c
picoo2em/vpp_cset.c
picoo2em/vpp.c
picoo2em/emuapi.cpp
picoo2em/picoo2em.cpp
picoo2em/AudioPlaySystem.cpp
)
add_compile_definitions(OVERRULE_WIDTH=320 OVERRULE_HEIGHT=192)
endif()
if( ${TARGET} MATCHES "picovcs" )
set(PICOVCS_SOURCES
picovcs/At2600.c
picovcs/Collision.c
@ -142,11 +156,11 @@ set(PICOVCS_SOURCES
picovcs/Tiasound.c
picovcs/Vcsemu.c
picovcs/Vmachine.c
picovcs/emuapi.cpp
picovcs/picovcs.cpp
picovcs/AudioPlaySystem.cpp
)
endif()
if( ${TARGET} MATCHES "piconofrendo" )
set(PICONOFRENDO_SOURCES
piconofrendo/bitmap.c
piconofrendo/config.c
@ -206,11 +220,11 @@ set(PICONOFRENDO_SOURCES
piconofrendo/nofrendo.c
piconofrendo/vid_drv.c
piconofrendo/vrcvisnd.c
piconofrendo/emuapi.cpp
piconofrendo/piconofrendo.cpp
piconofrendo/AudioPlaySystem.cpp
)
endif()
if( ${TARGET} MATCHES "pico8086" )
set(PICO8086_SOURCES
pico8086/cpu.cpp
pico8086/disk.cpp
@ -219,12 +233,44 @@ set(PICO8086_SOURCES
pico8086/i8253.cpp
pico8086/i8259.cpp
pico8086/pc.cpp
pico8086/emuapi.cpp
pico8086/pico8086.cpp
pico8086/AudioPlaySystem.cpp
)
endif()
if( ${TARGET} MATCHES "testio" )
set(TESTIO_SOURCES
testio/testio.cpp
testio/emuapi.cpp
)
endif()
if( ${TARGET} MATCHES "testvga" )
set(TESTVGA_SOURCES
testvga/testvga.cpp
)
endif()
if( ${TARGET} MATCHES "testkeymax" )
set(TESTKEYMAX_SOURCES
testkeymax/testkeymax.cpp
)
endif()
set(DISPLAY_SOURCES
display/pico_dsp.cpp
display/vga.cpp
display/vga_vmode.cpp
display/emuapi.cpp
display/AudioPlaySystem.cpp
)
set(PICOSND_SOURCES
#if( ${TARGET} MATCHES "gfxengine" )
#set(GFXENGINE_SOURCES
# gfxengine/gfxengine.cpp
# )
#endif()
#set(PICOSND_SOURCES
# picosnd/LibFC14/Dump.cpp
# picosnd/LibFC14/FC_Data.cpp
# picosnd/LibFC14/FC.cpp
@ -238,107 +284,88 @@ set(PICOSND_SOURCES
# picosnd/StSnd/Ymload.cpp
# picosnd/StSnd/YmMusic.cpp
# picosnd/StSnd/YmUserInterface.cpp
picosnd/sndplay.cpp
picosnd/sid.cpp
picosnd/reSID.cpp
picosnd/emuapi.cpp
picosnd/AudioPlaySystem.cpp
picosnd/picosnd.cpp
)
# picosnd/sndplay.cpp
# picosnd/sid.cpp
# picosnd/reSID.cpp
# picosnd/emuapi.cpp
# picosnd/AudioPlaySystem.cpp
# picosnd/picosnd.cpp
# )
set(PICOVALIDATION_SOURCES
picovalidation/c64.cpp
picovalidation/cia1.cpp
picovalidation/cia2.cpp
picovalidation/cpu.cpp
picovalidation/patches.cpp
picovalidation/pla.cpp
picovalidation/roms.cpp
picovalidation/sid.cpp
picovalidation/util.cpp
picovalidation/vic.cpp
picovalidation/reSID.cpp
picovalidation/emuapi.cpp
picovalidation/AudioPlaySystem.cpp
picovalidation/pico64.cpp
)
#set(PICOVALIDATION_SOURCES
# picovalidation/c64.cpp
# picovalidation/cia1.cpp
# picovalidation/cia2.cpp
# picovalidation/cpu.cpp
# picovalidation/patches.cpp
# picovalidation/pla.cpp
# picovalidation/roms.cpp
# picovalidation/sid.cpp
# picovalidation/util.cpp
# picovalidation/vic.cpp
# picovalidation/reSID.cpp
# picovalidation/emuapi.cpp
# picovalidation/AudioPlaySystem.cpp
# picovalidation/pico64.cpp
# )
set(VGA_T4_SOURCES
vga_t4/VGA_t4.cpp
vga_t4/scanvideo.c
)
#set(VGA_T4_SOURCES
# vga_t4/VGA_t4.cpp
# vga_t4/scanvideo.c
# )
set(PICOVGA_T4_SOURCES
picovga_t4/VGA_t4.cpp
picovga_t4/vga.cpp
picovga_t4/vga_vmode.cpp
)
#set(PICOVGA_T4_SOURCES
# picovga_t4/VGA_t4.cpp
# picovga_t4/vga.cpp
# picovga_t4/vga_vmode.cpp
# )
set(PSRAM_SOURCES
psram/psram_t.cpp
)
#set(PSRAM_SOURCES
# psram/psram_t.cpp
# )
set(TFT_T_SOURCES
tft_t/tft_t_dma.cpp
)
#set(TFT_T_SOURCES
# tft_t/tft_t_dma.cpp
# )
set(GFXENGINE_SOURCES
gfxengine/gfxengine.cpp
)
#set(TESTPSRAM_SOURCES
# testpsram/testpsram.cpp
# testpsram/emuapi.cpp
# )
set(TESTIO_SOURCES
testio/testio.cpp
testio/emuapi.cpp
)
set(TESTVGA_SOURCES
testvga/testvga.cpp
)
set(TESTKEYMAX_SOURCES
testkeymax/testkeymax.cpp
testkeymax/emuapi.cpp
)
set(TESTPSRAM_SOURCES
testpsram/testpsram.cpp
testpsram/emuapi.cpp
)
# Vic20,ZX81,ZX Spectrum,Colem
#add_compile_definitions(OVERRULE_WIDTH=320 OVERRULE_HEIGHT=192)
add_executable(mcume
# ${GFXENGINE_SOURCES}
# ${PICO20_SOURCES}
add_executable(${TARGET}
${PICO20_SOURCES}
${PICO64_SOURCES}
# ${PICO81_SOURCES}
# ${PICO800_SOURCES}
# ${PICO5200_SOURCES}
# ${PICO8086_SOURCES}
# ${PICOCOLEM_SOURCES}
# ${PICOO2EM_SOURCES}
# ${PICOVCS_SOURCES}
# ${PICOSPECCY_SOURCES}
# ${PICONOFRENDO_SOURCES}
${PICO81_SOURCES}
${PICO800_SOURCES}
${PICO5200_SOURCES}
${PICO8086_SOURCES}
${PICOCOLEM_SOURCES}
${PICOO2EM_SOURCES}
${PICOVCS_SOURCES}
${PICOSPECCY_SOURCES}
${PICONOFRENDO_SOURCES}
${TESTIO_SOURCES}
${TESTVGA_SOURCES}
${TESTKEYMAX_SOURCES}
# ${GFXENGINE_SOURCES}
# ${PICOSND_SOURCES}
# ${TESTIO_SOURCES}
# ${TESTVGA_SOURCES}
# ${TESTKEYMAX_SOURCES}
# ${TESTPSRAM_SOURCES}
# ${PICOVALIDATION_SOURCES}
# ${PSRAM_SOURCES}
# ${VGA_T4_SOURCES}
${PICOVGA_T4_SOURCES}
${TFT_T_SOURCES}
# ${PICOVGA_T4_SOURCES}
# ${TFT_T_SOURCES}
${DISPLAY_SOURCES}
)
#pico_generate_pio_header(mcume ${CMAKE_CURRENT_LIST_DIR}/vga_t4/timing.pio)
#pico_generate_pio_header(mcume ${CMAKE_CURRENT_LIST_DIR}/vga_t4/scanvideo.pio)
pico_generate_pio_header(mcume ${CMAKE_CURRENT_LIST_DIR}/picovga_t4/picovga.pio)
#pico_generate_pio_header(${TARGET} ${CMAKE_CURRENT_LIST_DIR}/vga_t4/timing.pio)
#pico_generate_pio_header(${TARGET} ${CMAKE_CURRENT_LIST_DIR}/vga_t4/scanvideo.pio)
pico_generate_pio_header(${TARGET} ${CMAKE_CURRENT_LIST_DIR}/display/picovga.pio)
target_link_libraries(mcume pico_multicore
target_link_libraries(${TARGET} pico_multicore
pico_stdlib
FatFs_SPI
# pico_scanvideo_dpi
@ -348,15 +375,15 @@ target_link_libraries(mcume pico_multicore
)
#target_compile_options(mcume PUBLIC -O3)
#target_compile_options(mcume PUBLIC -Wall -Wextra -Wno-unused-function -Wno-unused-parameter)
#target_compile_options(${TARGET} PUBLIC -O3)
#target_compile_options(${TARGET} PUBLIC -Wall -Wextra -Wno-unused-function -Wno-unused-parameter)
IF (NOT DEFINED N_SD_CARDS)
SET(N_SD_CARDS 1)
ENDIF()
target_compile_definitions(mcume PUBLIC N_SD_CARDS=${N_SD_CARDS})
target_compile_definitions(${TARGET} PUBLIC N_SD_CARDS=${N_SD_CARDS})
#pico_enable_stdio_uart(mcume 0)
#pico_enable_stdio_usb(mcume 0)
#pico_enable_stdio_uart(${TARGET} 0)
#pico_enable_stdio_usb(${TARGET} 0)
pico_add_extra_outputs(mcume)
pico_add_extra_outputs(${TARGET})

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -8,7 +8,6 @@
// Speaker
#define AUDIO_PIN 28
// VGA
/*
2-9 RRRGGGBB
@ -48,10 +47,10 @@
#define I2C_SCL_IO 15?
#define I2C_SDA_IO 14?
*/
#else
#if (defined(PICOMPUTER) && defined(USE_VGA) )
#if (defined(PICOMPUTER) && defined(USE_VGA) )
// Speaker
#define AUDIO_PIN 9
// VGA
@ -59,6 +58,18 @@
CSYNC */
#define VGA_COLORBASE 0
#define VGA_SYNCBASE 8
#else
#ifdef PICOZX
// Speaker
#define AUDIO_PIN 7
// VGA
/* RRGGBB
CSYNC */
#define VGA_COLORBASE 0
#define VGA_SYNCBASE 6
#else
// Speaker
#define AUDIO_PIN 0
@ -68,10 +79,23 @@
#define VGA_COLORBASE 2
#define VGA_SYNCBASE 14
#define VGA_VSYNC 15
#endif
#endif
#ifdef PICOZX
#define TFT_SPIREG spi0
#define TFT_SPIDREQ DREQ_SPI0_TX
#define TFT_SCLK 2
#define TFT_MOSI 3
#define TFT_MISO 255 // Not required, used for DC...
#define TFT_DC 6
#define TFT_RST 255
#define TFT_CS 5
#define TFT_BACKLIGHT 4
#else
// TFT
#define TFT_SPIREG spi0
#define TFT_SPIDREQ DREQ_SPI0_TX
@ -79,11 +103,13 @@
#define TFT_MOSI 19
#define TFT_MISO 255 // Not required, used for DC...
#define TFT_DC 16
#ifdef PICOMPUTER
#ifdef PICOMPUTERMAX
#define TFT_RST 255
#define TFT_CS 21
#define TFT_BACKLIGHT 20
#else
#define TFT_RST 21
#define TFT_CS 255
@ -95,7 +121,7 @@
#define TFT_CS 17
#define TFT_BACKLIGHT 255 // hardwired to 3.3v
#endif
#endif
// SD (see SPI0 in code!!!)
#define SD_SPIREG spi1
@ -103,7 +129,7 @@
#define SD_MOSI 11 //15
#define SD_MISO 12
#define SD_CS 13
#define SD_DETECT 255 // 22
#define SD_DETECT 255 //22
// PSRAM (exclusive with TFT)
#define PSRAM_SPIREG spi0
@ -114,7 +140,9 @@
#ifdef PICOMPUTER
#if defined(USE_VGA)
#if defined(USE_VGA)
// Keyboard matrix
//Cols (out)
#define KCOLOUT1 20
@ -130,6 +158,7 @@
#define KROWIN4 17
#define KROWIN5 18
#define KROWIN6 19
#else
// Keyboard matrix
//Cols (out)
@ -146,11 +175,12 @@
#define KROWIN4 8
#define KROWIN5 7
#define KROWIN6 22
#endif
#define KLED 25
#else
#ifdef MCUME_REV1
// Analog joystick (primary) for JOY2 and 2 extra buttons
@ -159,8 +189,30 @@
#define PIN_JOY2_BTN 22
#define PIN_KEY_USER1 20
#define PIN_KEY_USER2 21
#else
#ifdef PICOZX
// Keyboard matrix
//Cols (out)
#define KCOLOUT1 8
#define KCOLOUT2 9
#define KCOLOUT3 14
#define KCOLOUT4 15
#define KCOLOUT5 16
#define KCOLOUT6 17
#define KCOLOUT7 18
//Rows (in)
#define KROWIN1 19
#define KROWIN2 20
#define KROWIN3 21
#define KROWIN4 22
#define KROWIN5 26
#define KROWIN6 27
#define KROWIN7 28
#else
// Digital joystick (primary) for JOY2 and 2 extra buttons
//#define PIN_JOY2_A1X 26
//#define PIN_JOY2_A2Y 27
@ -175,7 +227,7 @@
#endif
#endif
#endif
#endif
// Second joystick (Not available on PICO)

Wyświetl plik

@ -6,11 +6,21 @@
// PICOMPUTER has support for TFT+keymatrix+Sound
#define PICOZX 1
//#define PICOMPUTER 1
//#define PICOMPUTERMAX 1
//#define PICORETROVGA 1
//#define MCUME_REV1 1
#define MCUME_REV2 1
//#define MCUME_REV2 1
#ifdef PICOZX
//#define USE_VGA 1
#define VGA222 1
#define ST7789 1
#define ST7789_POL 1
#define HAS_SND 1
#define INVX 1
#endif
#ifdef PICOMPUTER
//#define SWAP_ALT_DEL 1

Wyświetl plik

@ -87,10 +87,15 @@ static void snd_Reset(void)
}
#ifdef CUSTOM_SND
#ifdef CUSTOM_SND
#ifdef CUSTOM_SND_C
extern "C" {
#endif
void SND_Process(void *sndbuffer, int sndn);
#ifdef CUSTOM_SND_C
}
#endif
#endif
#include <stdio.h>
@ -173,7 +178,4 @@ void AudioPlaySystem::sound(int C, int F, int V) {
void AudioPlaySystem::step(void) {
}
void AudioPlaySystem::buzz(int size, int val) {
}
#endif

Wyświetl plik

@ -16,26 +16,17 @@ extern "C" {
static bool emu_writeConfig(void);
static bool emu_readConfig(void);
static bool emu_eraseConfig(void);
static bool emu_writeGfxConfig(void);
static bool emu_readGfxConfig(void);
static bool emu_eraseGfxConfig(void);
#if (defined(ILI9341) || defined(ST7789)) && defined(USE_VGA)
// Dual display config, initialize TFT
#include "tft_t_dma.h"
static TFT_T_DMA tft;
#else
// Non Dual display config
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
extern TFT_T_DMA tft;
#endif
#include "pico_dsp.h"
extern PICO_DSP tft;
#define MAX_FILENAME_PATH 64
#define NB_FILE_HANDLER 4
#define AUTORUN_FILENAME "autorun.txt"
#define GFX_CFG_FILENAME "gfxmode.txt"
#define MAX_FILES 64
#define MAX_FILENAME_SIZE 24
@ -66,9 +57,9 @@ static char selected_filename[MAX_FILENAME_SIZE]="";
static char files[MAX_FILES][MAX_FILENAME_SIZE];
static bool menuRedraw=true;
#ifdef PICOMPUTER
#if (defined(PICOMPUTER) || defined(PICOZX) )
static const unsigned short * keys;
static unsigned char keymatrix[6];
static unsigned char keymatrix[7];
static int keymatrix_hitrow=-1;
static bool key_fn=false;
static bool key_alt=false;
@ -218,6 +209,7 @@ static void drawOskb(void)
// lineOSKB2(KXOFF,KYOFF+0, (char *)"Q1W2E3R4T5Y6U7I8O9P0<=", 0);
// lineOSKB2(KXOFF,KYOFF+16, (char *)" A!S@D#F$G%H+J&K*L-EN", 1);
// lineOSKB2(KXOFF,KYOFF+32, (char *)" Z(X)C?V/B\"N<M>.,SP ", 2);
/*
if (oskbMap == 0) {
lineOSKB(KXOFF,KYOFF, keylables_map1_0, 0);
lineOSKB(KXOFF,KYOFF, keylables_map1_1, 1);
@ -233,6 +225,7 @@ static void drawOskb(void)
lineOSKB(KXOFF,KYOFF, keylables_map3_1, 1);
lineOSKB(KXOFF,KYOFF, keylables_map3_2, 2);
}
*/
}
void toggleOskb(bool forceoff) {
@ -498,13 +491,18 @@ int emu_ReadKeys(void)
if ( !gpio_get(PIN_KEY_USER4) ) retval |= MASK_KEY_USER4;
#endif
#ifdef PICOMPUTER
#if (defined(PICOMPUTER) || defined(PICOZX) )
keymatrix_hitrow = -1;
unsigned char row;
#ifdef PICOZX
unsigned short cols[7]={KCOLOUT1,KCOLOUT2,KCOLOUT3,KCOLOUT4,KCOLOUT5,KCOLOUT6,KCOLOUT7};
unsigned char keymatrixtmp[7];
for (int i=0;i<7;i++){
#else
unsigned short cols[6]={KCOLOUT1,KCOLOUT2,KCOLOUT3,KCOLOUT4,KCOLOUT5,KCOLOUT6};
unsigned char keymatrixtmp[6];
for (int i=0;i<6;i++){
#endif
gpio_set_dir(cols[i], GPIO_OUT);
gpio_put(cols[i], 0);
#ifdef SWAP_ALT_DEL
@ -512,6 +510,18 @@ int emu_ReadKeys(void)
//__asm volatile ("nop\n"); // 4-8ns
#endif
row=0;
#ifdef PICOZX
row |= (gpio_get(KROWIN1) ? 0 : 0x04);
row |= (gpio_get(KROWIN1) ? 0 : 0x04);
row |= (gpio_get(KROWIN1) ? 0 : 0x04);
row |= (gpio_get(KROWIN1) ? 0 : 0x04);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN3) ? 0 : 0x08);
row |= (gpio_get(KROWIN4) ? 0 : 0x02);
row |= (gpio_get(KROWIN5) ? 0 : 0x10);
row |= (gpio_get(KROWIN6) ? 0 : 0x20);
row |= (gpio_get(KROWIN7) ? 0 : 0x40);
#else
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
@ -521,6 +531,7 @@ int emu_ReadKeys(void)
row |= (gpio_get(KROWIN3) ? 0 : 0x08);
row |= (gpio_get(KROWIN5) ? 0 : 0x10);
row |= (gpio_get(KROWIN6) ? 0 : 0x20);
#endif
//gpio_set_dir(cols[i], GPIO_OUT);
gpio_put(cols[i], 1);
gpio_set_dir(cols[i], GPIO_IN);
@ -528,55 +539,7 @@ int emu_ReadKeys(void)
keymatrixtmp[i] = row;
}
#ifdef MULTI_DEBOUNCE
for (int i=0;i<6;i++){
gpio_set_dir(cols[i], GPIO_OUT);
gpio_put(cols[i], 0);
#ifdef SWAP_ALT_DEL
sleep_us(1);
//__asm volatile ("nop\n"); // 4-8ns
#endif
row=0;
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN4) ? 0 : 0x02);
row |= (gpio_get(KROWIN1) ? 0 : 0x04);
row |= (gpio_get(KROWIN3) ? 0 : 0x08);
row |= (gpio_get(KROWIN5) ? 0 : 0x10);
row |= (gpio_get(KROWIN6) ? 0 : 0x20);
//gpio_set_dir(cols[i], GPIO_OUT);
gpio_put(cols[i], 1);
gpio_set_dir(cols[i], GPIO_IN);
gpio_disable_pulls(cols[i]);
keymatrixtmp[i] |= row;
}
for (int i=0;i<6;i++){
gpio_set_dir(cols[i], GPIO_OUT);
gpio_put(cols[i], 0);
#ifdef SWAP_ALT_DEL
sleep_us(1);
//__asm volatile ("nop\n"); // 4-8ns
#endif
row=0;
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN2) ? 0 : 0x01);
row |= (gpio_get(KROWIN4) ? 0 : 0x02);
row |= (gpio_get(KROWIN1) ? 0 : 0x04);
row |= (gpio_get(KROWIN3) ? 0 : 0x08);
row |= (gpio_get(KROWIN5) ? 0 : 0x10);
row |= (gpio_get(KROWIN6) ? 0 : 0x20);
//gpio_set_dir(cols[i], GPIO_OUT);
gpio_put(cols[i], 1);
gpio_set_dir(cols[i], GPIO_IN);
gpio_disable_pulls(cols[i]);
keymatrixtmp[i] |= row;
}
#endif
#ifdef SWAP_ALT_DEL
// Swap ALT and DEL
@ -588,15 +551,48 @@ int emu_ReadKeys(void)
if (del) keymatrixtmp[0] |= 0x02;
#endif
#ifdef PICOZX
for (int i=0;i<7;i++){
#else
bool alt_pressed=false;
if ( keymatrixtmp[5] & 0x20 ) {alt_pressed=true; keymatrixtmp[5] &= ~0x20;};
for (int i=0;i<6;i++){
#endif
row = keymatrixtmp[i];
if (row) keymatrix_hitrow=i;
keymatrix[i] = row;
}
#ifdef PICOZX
key_fn = false;
key_alt = false;
if ( row & 0x02 ) retval |= MASK_KEY_USER1;
if ( row & 0x10 ) retval |= MASK_KEY_USER2;
if ( row & 0x20 ) retval |= MASK_KEY_USER3;
if ( row & 0x40 ) retval |= MASK_KEY_USER4;
row = keymatrix[0];
//19,20,21,22,26,27,28
#if INVX
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
if ( row & 0x1 ) retval |= MASK_JOY2_RIGHT;
#else
if ( row & 0x1 ) retval |= MASK_JOY2_LEFT;
if ( row & 0x2 ) retval |= MASK_JOY2_RIGHT;
#endif
#if INVY
if ( row & 0x8 ) retval |= MASK_JOY2_DOWN;
if ( row & 0x10 ) retval |= MASK_JOY2_UP;
#else
if ( row & 0x10 ) retval |= MASK_JOY2_DOWN;
if ( row & 0x8 ) retval |= MASK_JOY2_UP;
#endif
if ( row & 0x04 ) retval |= MASK_JOY2_BTN;
if ( row & 0x20 ) key_fn = true;
if ( row & 0x40 ) key_alt = true;
#else
//6,9,15,8,7,22
#if INVX
if ( row & 0x2 ) retval |= MASK_JOY2_LEFT;
@ -614,6 +610,9 @@ int emu_ReadKeys(void)
#endif
if ( row & 0x10 ) retval |= MASK_JOY2_BTN;
if ( key_fn ) retval |= MASK_KEY_USER2;
if ( ( key_fn ) && (keymatrix[0] == 0x02 )) retval |= MASK_KEY_USER1;
// Handle LED flash
uint32_t time_ms=to_ms_since_boot (get_absolute_time());
if ((time_ms-last_t_ms) > 100) {
@ -678,6 +677,7 @@ int emu_ReadKeys(void)
key_fn = false;
}
#ifdef KLED
// Handle LED
if (key_alt == true) {
gpio_put(KLED, (ledflash_toggle?1:0));
@ -690,9 +690,12 @@ int emu_ReadKeys(void)
gpio_put(KLED, 0);
}
}
#endif
#endif
if ( key_fn ) retval |= MASK_KEY_USER2;
if ( ( key_fn ) && (keymatrix[0] == 0x02 )) retval |= MASK_KEY_USER1;
#endif
//Serial.println(retval,HEX);
@ -722,7 +725,7 @@ unsigned short emu_DebounceLocalKeys(void)
int emu_ReadI2CKeyboard(void) {
int retval=0;
#ifdef PICOMPUTER
#if (defined(PICOMPUTER) || defined(PICOZX) )
if (key_alt) {
keys = (const unsigned short *)key_map3;
}
@ -752,7 +755,7 @@ int emu_ReadI2CKeyboard(void) {
unsigned char emu_ReadI2CKeyboard2(int row) {
int retval=0;
#ifdef PICOMPUTER
#if (defined(PICOMPUTER) || defined(PICOZX) )
retval = keymatrix[row];
#endif
return retval;
@ -826,8 +829,6 @@ void emu_InitJoysticks(void) {
gpio_set_dir(PIN_JOY2_BTN,GPIO_IN);
#endif
#ifdef PIN_JOY2_A1X
adc_init();
adc_gpio_init(PIN_JOY2_A1X);
@ -852,12 +853,13 @@ void emu_InitJoysticks(void) {
#endif
#endif
#ifdef PICOMPUTER
#if (defined(PICOMPUTER) || defined(PICOZX) )
// keyboard LED
#ifdef KLED
gpio_init(KLED);
gpio_set_dir(KLED, GPIO_OUT);
gpio_put(KLED, 1);
#endif
// Output (rows)
gpio_init(KCOLOUT1);
gpio_init(KCOLOUT2);
@ -865,18 +867,27 @@ void emu_InitJoysticks(void) {
gpio_init(KCOLOUT4);
gpio_init(KCOLOUT5);
gpio_init(KCOLOUT6);
#ifdef PICOZX
gpio_init(KCOLOUT7);
#endif
gpio_set_dir(KCOLOUT1, GPIO_OUT);
gpio_set_dir(KCOLOUT2, GPIO_OUT);
gpio_set_dir(KCOLOUT3, GPIO_OUT);
gpio_set_dir(KCOLOUT4, GPIO_OUT);
gpio_set_dir(KCOLOUT5, GPIO_OUT);
gpio_set_dir(KCOLOUT6, GPIO_OUT);
#ifdef PICOZX
gpio_set_dir(KCOLOUT7, GPIO_OUT);
#endif
gpio_put(KCOLOUT1, 1);
gpio_put(KCOLOUT2, 1);
gpio_put(KCOLOUT3, 1);
gpio_put(KCOLOUT4, 1);
gpio_put(KCOLOUT5, 1);
gpio_put(KCOLOUT6, 1);
#ifdef PICOZX
gpio_put(KCOLOUT7, 1);
#endif
// but set as input floating when not used!
gpio_set_dir(KCOLOUT1, GPIO_IN);
gpio_set_dir(KCOLOUT2, GPIO_IN);
@ -884,13 +895,18 @@ void emu_InitJoysticks(void) {
gpio_set_dir(KCOLOUT4, GPIO_IN);
gpio_set_dir(KCOLOUT5, GPIO_IN);
gpio_set_dir(KCOLOUT6, GPIO_IN);
#ifdef PICOZX
gpio_set_dir(KCOLOUT7, GPIO_IN);
#endif
gpio_disable_pulls(KCOLOUT1);
gpio_disable_pulls(KCOLOUT2);
gpio_disable_pulls(KCOLOUT3);
gpio_disable_pulls(KCOLOUT4);
gpio_disable_pulls(KCOLOUT5);
gpio_disable_pulls(KCOLOUT6);
#ifdef PICOZX
gpio_disable_pulls(KCOLOUT7);
#endif
// Input pins (cols)
gpio_init(KROWIN1);
gpio_init(KROWIN2);
@ -898,22 +914,32 @@ void emu_InitJoysticks(void) {
gpio_init(KROWIN4);
gpio_init(KROWIN5);
gpio_init(KROWIN6);
#ifdef PICOZX
gpio_init(KROWIN7);
#endif
gpio_set_dir(KROWIN1,GPIO_IN);
gpio_set_dir(KROWIN2,GPIO_IN);
gpio_set_dir(KROWIN3,GPIO_IN);
gpio_set_dir(KROWIN4,GPIO_IN);
gpio_set_dir(KROWIN5,GPIO_IN);
gpio_set_dir(KROWIN6,GPIO_IN);
#ifdef PICOZX
gpio_set_dir(KROWIN7,GPIO_IN);
#endif
gpio_pull_up(KROWIN1);
gpio_pull_up(KROWIN2);
gpio_pull_up(KROWIN3);
gpio_pull_up(KROWIN4);
gpio_pull_up(KROWIN5);
gpio_pull_up(KROWIN6);
#ifdef PICOZX
gpio_pull_up(KROWIN7);
#endif
#endif
}
int emu_setKeymap(int index) {
return 0;
}
@ -926,6 +952,7 @@ static FATFS fatfs;
static FIL file;
extern "C" int sd_init_driver(void);
#ifdef FILEBROWSER
static int readNbFiles(char * rootdir) {
int totalFiles = 0;
@ -973,16 +1000,32 @@ static void menuLeft(void)
#endif
}
bool menuActive(void)
{
return (menuOn);
}
void toggleMenu(bool on) {
if (on) {
menuOn = true;
backgroundMenu();
} else {
tft.fillScreenNoDma(RGBVAL16(0x00,0x00,0x00));
menuOn = false;
}
}
int handleMenu(uint16_t bClick)
{
if (autorun) {
menuLeft();
return (ACTION_RUNTFT);
toggleMenu(false);
menuRedraw=false;
return (ACTION_RUN);
}
int action = ACTION_NONE;
if ( (bClick & MASK_JOY2_BTN) ) {
if ( (bClick & MASK_JOY2_BTN) || (bClick & MASK_KEY_USER1) || (bClick & MASK_KEY_USER4) ) {
char newpath[MAX_FILENAME_PATH];
strcpy(newpath, selection);
strcat(newpath, "/");
@ -995,24 +1038,34 @@ int handleMenu(uint16_t bClick)
fr = f_stat(selection, &entry);
if ( (fr == FR_OK) && (entry.fattrib & AM_DIR) ) {
curFile = 0;
nbFiles = readNbFiles(selection);
nbFiles = readNbFiles(selection);
menuRedraw=true;
}
else
{
action = ACTION_RUNTFT;
#ifdef PICOMPUTER
if (key_alt) {
emu_writeConfig();
}
#endif
menuLeft();
#ifdef PICOZX
if (bClick & MASK_KEY_USER4) {
emu_writeConfig();
}
#endif
menuLeft();
toggleMenu(false);
menuRedraw=false;
#ifdef PICOZX
if ( tft.getMode() != MODE_VGA_320x240) {
if ( (bClick & MASK_KEY_USER1) ) {
tft.begin(MODE_VGA_320x240);
}
}
#endif
return (ACTION_RUN);
}
}
else if ( (bClick & MASK_KEY_USER1) ) {
menuRedraw=true;
action = ACTION_RUNVGA;
}
else if ( (bClick & MASK_JOY2_UP) || (bClick & MASK_JOY1_UP) ) {
if (curFile!=0) {
menuRedraw=true;
@ -1084,28 +1137,14 @@ int handleMenu(uint16_t bClick)
menuRedraw=false;
}
return (action);
}
bool menuActive(void)
{
return (menuOn);
}
void toggleMenu(bool on) {
if (on) {
menuOn = true;
backgroundMenu();
} else {
menuOn = false;
}
return (ACTION_NONE);
}
char * menuSelection(void)
{
return (selection);
}
#endif
/********************************
* File IO
@ -1195,6 +1234,32 @@ unsigned int emu_LoadFile(const char * filepath, void * buf, int size)
static FIL outfile;
static bool emu_writeGfxConfig(void)
{
bool retval = false;
if( !(f_open(&outfile, "/" GFX_CFG_FILENAME, FA_CREATE_NEW | FA_WRITE)) ) {
f_close(&outfile);
retval = true;
}
return retval;
}
static bool emu_readGfxConfig(void)
{
bool retval = false;
if( !(f_open(&outfile, "/" GFX_CFG_FILENAME, FA_READ)) ) {
f_close(&outfile);
retval = true;
}
return retval;
}
static bool emu_eraseGfxConfig(void)
{
f_unlink ("/" GFX_CFG_FILENAME);
return true;
}
static bool emu_writeConfig(void)
{
bool retval = false;
@ -1234,6 +1299,7 @@ static bool emu_readConfig(void)
static bool emu_eraseConfig(void)
{
f_unlink (ROMSDIR "/" AUTORUN_FILENAME);
return true;
}
@ -1242,20 +1308,20 @@ static bool emu_eraseConfig(void)
********************************/
void emu_init(void)
{
// Dual display config, initialize TFT
#if (defined(ILI9341) || defined(ST7789)) && defined(USE_VGA)
tft.begin();
#endif
bool forceVga = false;
#ifdef FILEBROWSER
sd_init_driver();
FRESULT fr = f_mount(&fatfs, "0:", 1);
forceVga = emu_readGfxConfig();
strcpy(selection,ROMSDIR);
nbFiles = readNbFiles(selection);
emu_printf("SD initialized, files found: ");
emu_printi(nbFiles);
#endif
emu_InitJoysticks();
#ifdef SWAP_JOYSTICK
joySwapped = true;
@ -1263,7 +1329,43 @@ void emu_init(void)
joySwapped = false;
#endif
int keypressed = emu_ReadKeys();
int keypressed = emu_ReadKeys();
#ifdef USE_VGA
tft.begin(MODE_VGA_320x240);
#else
#ifdef PICOZX
// Force VGA if LEFT/RIGHT pressed
if (keypressed & MASK_JOY2_UP)
{
tft.begin(MODE_VGA_320x240);
#ifdef FILEBROWSER
emu_writeGfxConfig();
#endif
}
else
{
if ( (keypressed & MASK_JOY2_LEFT) || (keypressed & MASK_JOY2_RIGHT) )
{
#ifdef FILEBROWSER
emu_eraseGfxConfig();
#endif
forceVga = false;
}
if (forceVga) {
tft.begin(MODE_VGA_320x240);
}
else
{
tft.begin(MODE_TFT_320x240);
}
}
#else
tft.begin(MODE_TFT_320x240);
#endif
#endif
#ifdef PICOMPUTER
// Flip screen if UP pressed
if (keypressed & MASK_JOY2_UP)
@ -1299,7 +1401,10 @@ void emu_init(void)
autorun = true;
}
}
#ifdef FILEBROWSER
toggleMenu(true);
#endif
}

Wyświetl plik

@ -2,68 +2,10 @@
#define EMUAPI_H
#include "platform_config.h"
#include "emucfg.h"
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
// Title: < >
#define TITLE " Atari2600 Emulator"
#define ROMSDIR "2600"
#define emu_Init(ROM) {vcs_Init();vcs_Start(ROM);}
#define emu_Step() {vcs_Step();}
#define emu_Input(x) {vcs_Input(x);}
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
//#define SINGLELINE_RENDERING 1
#define ACTION_NONE 0
#define ACTION_MAXKBDVAL 4
#define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129
#define ACTION_RUNVGA 130
#ifdef KEYMAP_PRESENT
#define keylables_map1_0 (char *)"1234 "
#define keylables_map1_1 (char *)" "
#define keylables_map1_2 (char *)" "
const unsigned short key_map1[] = {
1,2,3,4,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
#define keylables_map2_0 (char *)" "
#define keylables_map2_1 (char *)" "
#define keylables_map2_2 (char *)" "
const unsigned short key_map2[] = {
0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
#define keylables_map3_0 (char *)" "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" "
const unsigned short key_map3[] = {
0,0,0,0,0,0,0,0,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#define ACTION_NONE 0
#define ACTION_RUN 1
#define MASK_JOY2_RIGHT 0x0001
#define MASK_JOY2_LEFT 0x0002
@ -81,6 +23,12 @@ const unsigned short matkeys[] = {
#define MASK_KEY_USER4 0x2000
#define MASK_OSKB 0x8000
#define RGBVAL16(r,g,b) ( (((r>>3)&0x1f)<<11) | (((g>>2)&0x3f)<<5) | (((b>>3)&0x1f)<<0) )
#ifdef __cplusplus
extern "C"
{
#endif
extern void emu_init(void);
extern void emu_start(void);
extern void emu_resetSD(void);
@ -101,13 +49,14 @@ extern unsigned int emu_FileSize(const char * filepath);
extern unsigned int emu_LoadFile(const char * filepath, void * buf, int size);
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLinePal16(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
extern void emu_DrawScreenPal16(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawVsync(void);
extern int emu_FrameSkip(void);
extern void * emu_LineBuffer(int line);
extern int emu_IsVga(void);
//extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
//extern void * emu_LineBuffer(int line);
extern void emu_InitJoysticks(void);
extern int emu_SwapJoysticks(int statusOnly);
@ -117,8 +66,10 @@ extern int emu_GetPad(void);
extern int emu_ReadAnalogJoyX(int min, int max);
extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void);
extern unsigned char emu_ReadI2CKeyboard2(int row);
extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key);
extern int emu_oskbActive(void);
extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val);
@ -132,5 +83,9 @@ extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_printh(int val);
#ifdef __cplusplus
}
#endif
#endif

Wyświetl plik

@ -59,8 +59,8 @@ typedef unsigned char Bool;
// ----------------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------------
#define B0 (1<<0)
/*
#define B1 (1<<1)
#define B2 (1<<2)
#define B3 (1<<3)
@ -92,6 +92,7 @@ typedef unsigned char Bool;
#define B29 (1UL<<29)
#define B30 (1UL<<30)
#define B31 (1UL<<31)
*/
#define BIT(pos) (1UL<<(pos))
@ -102,7 +103,7 @@ typedef unsigned char Bool;
#define PI 3.14159265358979324
#define PI2 (3.14159265358979324*2)
#define VGA_RGB(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
//#define VGA_RGB(r,g,b) ( (((r>>5)&0x07)<<5) | (((g>>5)&0x07)<<2) | (((b>>6)&0x3)<<0) )
// system includes

Plik diff jest za duży Load Diff

Wyświetl plik

@ -0,0 +1,125 @@
/*
This file is part of DISPLAY library.
Supports VGA and TFT display
DISPLAY library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Teensy VGA inspired from the original Teensy3 uVGA library of Eric PREVOTEAU.
QTIMER/FlexIO code based on Teensy4 examples of KurtE, Manitou and easone
from the Teensy4 forum (https://forum.pjrc.com)
*/
#ifndef _PICO_DSP_H
#define _PICO_DSP_H
#ifdef __cplusplus
#include <stdio.h>
#include <math.h>
#include "pico.h"
#endif
#include "platform_config.h"
#include "iopins.h"
#ifdef LOHRES
#define TFT_WIDTH 240
#define TFT_REALWIDTH 240
#else
#ifdef OVERRULE_WIDTH
#define TFT_WIDTH OVERRULE_WIDTH
#else
#define TFT_WIDTH 320
#endif
#define TFT_REALWIDTH 320
#endif
#ifdef OVERRULE_HEIGHT
#define TFT_HEIGHT OVERRULE_HEIGHT
#else
#define TFT_HEIGHT 240
#endif
#define TFT_REALHEIGHT 240
#define AUDIO_SAMPLE_BUFFER_SIZE 256
#define DEFAULT_VSYNC_PIN 8
typedef uint8_t vga_pixel;
typedef uint16_t dsp_pixel;
typedef enum gfx_mode_t
{
MODE_UNDEFINED = 0,
MODE_TFT_320x240 = 1,
MODE_VGA_320x240 = 2
} gfx_mode_t;
typedef enum vga_error_t
{
GFX_OK = 0,
GFX_ERROR = -1
} gfx_error_t;
class PICO_DSP
{
public:
PICO_DSP();
// Initialization
gfx_error_t begin(gfx_mode_t mode);
gfx_mode_t getMode(void);
void end();
void startRefresh(void);
void stopRefresh();
void begin_audio(int samplesize, void (*callback)(short * stream, int len));
void end_audio();
// framebuffer/screen operation
int get_frame_buffer_size(int *width, int *height);
void setArea(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2);
void flipscreen(bool flip);
bool isflipped(void);
// wait next Vsync
void waitSync();
void waitLine(int line);
// =========================================================
// graphic primitives
// =========================================================
//dsp_pixel * getLineBuffer(int j);
void writeLine(int width, int height, int y, dsp_pixel *buf);
void writeLinePal(int width, int height, int y, uint8_t *buffer, dsp_pixel *palette16);
void writeScreenPal(int width, int height, int stride, uint8_t *buf, dsp_pixel *palette16);
void fillScreen(dsp_pixel color);
void drawText(int16_t x, int16_t y, const char * text, dsp_pixel fgcolor, dsp_pixel bgcolor, bool doublesize);
void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, dsp_pixel color);
void drawSprite(int16_t x, int16_t y, const dsp_pixel *bitmap);
void drawSprite(int16_t x, int16_t y, const dsp_pixel *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh);
// NoDMA functions
void fillScreenNoDma(dsp_pixel color);
void drawTextNoDma(int16_t x, int16_t y, const char * text, dsp_pixel fgcolor, dsp_pixel bgcolor, bool doublesize);
void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, dsp_pixel color);
void drawSpriteNoDma(int16_t x, int16_t y, const dsp_pixel *bitmap);
void drawSpriteNoDma(int16_t x, int16_t y, const dsp_pixel *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh);
private:
static uint8_t _vsync_pin;
protected:
uint8_t _rst, _cs, _dc;
uint8_t _miso, _mosi, _sclk, _bkl;
bool flipped=false;
};
#endif

Wyświetl plik

@ -34,8 +34,13 @@
// GP7 ... VGA R2
// GP8 ... VGA SYNC synchronization (inverted: negative SYNC=LOW=0x80, BLACK=HIGH=0x00)
#define VGA_GPIO_FIRST VGA_COLORBASE // first VGA GPIO
#define VGA_GPIO_NUM 9 // number of VGA GPIOs, including HSYNC and VSYNC
#ifdef VGA222
#define VGA_GPIO_OUTNUM 6 // number of VGA color GPIOs, without HSYNC and VSYNC
#define VGA_GPIO_NUM 7 // number of VGA GPIOs, including HSYNC and VSYNC
#else
#define VGA_GPIO_OUTNUM 8 // number of VGA color GPIOs, without HSYNC and VSYNC
#define VGA_GPIO_NUM 9 // number of VGA GPIOs, including HSYNC and VSYNC
#endif
#define VGA_GPIO_LAST (VGA_GPIO_FIRST+VGA_GPIO_NUM-1) // last VGA GPIO
#define VGA_GPIO_SYNC VGA_SYNCBASE // VGA SYNC GPIO

Wyświetl plik

@ -1,321 +0,0 @@
/*
* Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include <math.h>
#include "pico.h"
#include "pico/stdlib.h"
//#include "VGA_t4.h"
#include "vga_t_dma.h"
VGA_T4 vga;
const vga_pixel mario[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x24,0x24,0x24,0x24,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x24,0x24,0xe5,0xe1,0xe9,0xf9,0xe9,0x24,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x24,0xe1,0xe1,0xa1,0xa1,0xd0,0xf9,0xff,0x24,0x00,0x00,0x00,0x00,
0x00,0x00,0x24,0xa1,0xe5,0xa1,0x81,0x24,0x24,0x24,0x24,0x24,0x24,0x00,0x00,0x00,
0x00,0x24,0xa5,0xa1,0x81,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x00,0x00,
0x00,0x24,0xf6,0x24,0x24,0x44,0xe9,0x24,0xe9,0x24,0xed,0x00,0x00,0x00,0x00,0x00,
0x24,0xf6,0x8d,0xf6,0x24,0xe9,0xf6,0x24,0xf6,0x24,0xf6,0x8d,0x6c,0x00,0x00,0x00,
0x24,0xe9,0x88,0xf6,0x24,0x24,0xfa,0xf6,0xfa,0xf6,0xfa,0xf6,0xf6,0x68,0x00,0x00,
0x24,0x40,0xe9,0xf6,0x24,0xf6,0xf6,0x44,0xe9,0xed,0xe9,0xed,0xe9,0x68,0x00,0x00,
0x00,0x24,0x40,0xe9,0xed,0xf6,0x44,0x20,0x20,0x20,0x20,0x20,0x24,0x00,0x00,0x00,
0x00,0x00,0x24,0x84,0xe9,0xe9,0xe9,0xe9,0x20,0x24,0x24,0x24,0x00,0x00,0x00,0x00,
0x00,0x00,0x68,0x81,0x84,0x84,0x88,0x88,0x68,0x29,0x24,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x68,0xa5,0xa5,0xe9,0x68,0x4e,0x7a,0x7a,0x29,0x24,0x24,0x00,0x00,0x00,
0x00,0x24,0x68,0xff,0xff,0xff,0x8d,0xff,0xff,0x9b,0xff,0x49,0x24,0x24,0x00,0x00,
0x24,0x64,0x88,0xff,0xff,0x8d,0x4e,0xff,0xff,0x9b,0xff,0x24,0x88,0x88,0x24,0x00,
0x88,0x88,0x68,0xff,0xff,0x68,0x2e,0x4e,0x52,0x7a,0x29,0x20,0x88,0x88,0x24,0x00,
0x88,0x88,0x49,0x68,0x6c,0x2e,0x2e,0x2e,0x2e,0x09,0x00,0x88,0x88,0x88,0x00,0x00,
0x24,0x88,0x88,0x24,0x24,0x09,0x05,0x05,0x09,0x24,0x24,0x88,0x88,0x24,0x00,0x00,
0x00,0x24,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x24,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const unsigned char tilemapL0[] = {
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const unsigned char tilemapL1[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x05,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
// Hight of the tile map (size of 1 row above)
#define TILEMAP_H 30
// Only uses rows 3-11 from the TILEMAP_H above for the horizintal scroll
#define HSCR_BEG 3
#define HSCR_END 11
static int fb_width, fb_height;
static unsigned char * tilemapL0Pt;
static unsigned char * tilemapL1Pt;
static int tilemapL0Width;
static int tilemapL1Width;
static int hscrL0 = 0;
static int hscrL1 = 0;
static int hscrincL0 = 1;
static int hscrincL1 = 2;
static uint8_t spr_angle[SPRITES_MAX];
int main(void) {
stdio_init_all();
vga.begin(VGA_MODE_320x240);
//puts("Color bars ready, press SPACE to invert...");
vga.clear(VGA_RGB(0xff,0x00,0x00));
vga.get_frame_buffer_size(&fb_width, &fb_height);
// Initialize game engine
// 2 tiles layers (TILES_MAX_LAYERS)
// 32 sprites (SPRITES_MAX)
// 64 tiles + 64 sprites definitions
// Defaults or change VGA_t4.h:
// 20x15 tiles of 16x16 pixels in 256 colors
// 16x32 pixels sprites in 256 colors
vga.begin_gfxengine(2, 64, 64);
// Init tilemaps for entire screen
tilemapL0Pt= (unsigned char *)&tilemapL0[0];
tilemapL1Pt= (unsigned char *)&tilemapL1[0];
for (int c=0; c< TILES_COLS; c++) {
vga.tile_draw_col(0, c,0,tilemapL0Pt,TILEMAP_H);
vga.tile_draw_col(1, c,0,tilemapL1Pt,TILEMAP_H);
tilemapL0Pt += TILEMAP_H;
tilemapL1Pt += TILEMAP_H;
}
tilemapL0Width = ((sizeof(tilemapL0)/TILEMAP_H)-TILES_COLS+1)*TILES_W;
tilemapL1Width = ((sizeof(tilemapL1)/TILEMAP_H)-TILES_COLS+1)*TILES_W;
// Init horizontal scrolling area, mask last col (in pixels) at right to hide updates
vga.set_hscroll(0, HSCR_BEG,HSCR_END,TILES_W);
vga.set_hscroll(1, HSCR_BEG,HSCR_END,TILES_W);
// Init sprite animation
for (int i=0; i<SPRITES_MAX; i++)
{
spr_angle[i] += (255*i)/SPRITES_MAX;
}
vga.sprite_data(0, (vga_pixel *)mario, SPRITES_W*SPRITES_H);
while (true) {
hscrL0 = hscrL0 + hscrincL0;
if ( (hscrL0 & TILES_HMASK) == 0x0) {
int updcolL0 = (hscrL0 >> TILES_HBITS) % TILES_COLS;
if (hscrincL0>0) {
vga.tile_draw_col(0, (updcolL0+(TILES_COLS-1))%TILES_COLS,HSCR_BEG,tilemapL0Pt+HSCR_BEG,HSCR_END-HSCR_BEG+1);
tilemapL0Pt += TILEMAP_H;
if (hscrL0 >= tilemapL0Width) {
hscrincL0 = -hscrincL0;
vga.tile_draw_col(0, (updcolL0+(TILES_COLS-1))%TILES_COLS,HSCR_BEG,tilemapL0Pt-(TILES_COLS+1)*TILEMAP_H+HSCR_BEG,HSCR_END-HSCR_BEG+1);
}
}
else if (hscrincL0<0) {
updcolL0 -= 1; // row before !!!
if (updcolL0<0 ) updcolL0 += TILES_COLS;
if (( tilemapL0Pt-(TILES_COLS+2)*TILEMAP_H) >= tilemapL0)
vga.tile_draw_col(0, updcolL0,HSCR_BEG,tilemapL0Pt-(TILES_COLS+2)*TILEMAP_H+HSCR_BEG,HSCR_END-HSCR_BEG+1);
tilemapL0Pt -= TILEMAP_H;
if (hscrL0 <=0) {
hscrincL0 = -hscrincL0;
vga.tile_draw_col(0, updcolL0,HSCR_BEG,tilemapL0Pt-TILEMAP_H+HSCR_BEG,HSCR_END-HSCR_BEG+1);
}
}
}
vga.hscroll(0,hscrL0);
hscrL1 = hscrL1 + hscrincL1;
if ( (hscrL1 & TILES_HMASK) == 0x0) {
int updcolL1 = (hscrL1 >> TILES_HBITS) % TILES_COLS;
if (hscrincL1 > 0) {
vga.tile_draw_col(1, (updcolL1+(TILES_COLS-1))%TILES_COLS,HSCR_BEG,tilemapL1Pt+HSCR_BEG,HSCR_END-HSCR_BEG+1);
tilemapL1Pt += TILEMAP_H;
if (hscrL1 >= tilemapL1Width) {
hscrincL1 = -hscrincL1;
vga.tile_draw_col(1, (updcolL1+(TILES_COLS-1))%TILES_COLS,HSCR_BEG,tilemapL1Pt-(TILES_COLS+1)*TILEMAP_H+HSCR_BEG,HSCR_END-HSCR_BEG+1);
}
}
else if (hscrincL1 < 0) {
updcolL1 -= 1; // row before !!!
if (updcolL1<0 ) updcolL1 += TILES_COLS;
if (( tilemapL1Pt-(TILES_COLS+2)*TILEMAP_H) >= tilemapL1)
vga.tile_draw_col(1, updcolL1,HSCR_BEG,tilemapL1Pt-(TILES_COLS+2)*TILEMAP_H+HSCR_BEG,HSCR_END-HSCR_BEG+1);
tilemapL1Pt -= TILEMAP_H;
if (hscrL1 <=0) {
hscrincL1 = -hscrincL1;
vga.tile_draw_col(1, updcolL1,HSCR_BEG,tilemapL1Pt-TILEMAP_H+HSCR_BEG,HSCR_END-HSCR_BEG+1);
}
}
}
vga.hscroll(1,hscrL1);
for (int i=1; i<SPRITES_MAX; i++)
{
spr_angle[i] += 1;
vga.sprite(i, 150+160*calcco[(spr_angle[i]*360)>>8], 100+120*calcsi[(spr_angle[i]*360)>>8], i);
}
vga.sprite(0, 100, 100, 0);
vga.run_gfxengine();
int c = getchar_timeout_us(0);
switch (c) {
case ' ':
printf("Inverted: %d\n", 1);
break;
}
}
}

Wyświetl plik

@ -1,176 +0,0 @@
#include "emuapi.h"
#ifdef HAS_SND
#include "AudioPlaySystem.h"
#define SAMPLERATE AUDIO_SAMPLE_RATE_EXACT
#define CLOCKFREQ 985248
#ifndef CUSTOM_SND
static const short square[]={
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
};
const short noise[] {
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,-32767,-32767,
32767,-32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
};
#define NOISEBSIZE 0x100
typedef struct
{
unsigned int spos;
unsigned int sinc;
unsigned int vol;
} Channel;
static Channel chan[6] = {
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0} };
#endif
volatile bool playing = false;
static void snd_Reset(void)
{
#ifndef CUSTOM_SND
chan[0].vol = 0;
chan[1].vol = 0;
chan[2].vol = 0;
chan[3].vol = 0;
chan[4].vol = 0;
chan[5].vol = 0;
chan[0].sinc = 0;
chan[1].sinc = 0;
chan[2].sinc = 0;
chan[3].sinc = 0;
chan[4].sinc = 0;
chan[5].sinc = 0;
#endif
}
#ifdef CUSTOM_SND
//extern "C" {
void SND_Process(void *sndbuffer, int sndn);
//}
#endif
#include <stdio.h>
void AudioPlaySystem::snd_Mixer(short * stream, int len )
{
if (playing)
{
#ifdef CUSTOM_SND
//printf("s\n");
SND_Process((void*)stream, len);
#else
int i;
long s;
len = len >> 1;
short v0=chan[0].vol;
short v1=chan[1].vol;
short v2=chan[2].vol;
short v3=chan[3].vol;
short v4=chan[4].vol;
short v5=chan[5].vol;
for (i=0;i<len;i++)
{
s =((v0*square[(chan[0].spos>>8)&0x3f])>>11);
s+=((v1*square[(chan[1].spos>>8)&0x3f])>>11);
s+=((v2*square[(chan[2].spos>>8)&0x3f])>>11);
s+=((v3*noise[(chan[3].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v4*noise[(chan[4].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v5*noise[(chan[5].spos>>8)&(NOISEBSIZE-1)])>>11);
*stream++ = (short)(s);
*stream++ = (short)(s);
chan[0].spos += chan[0].sinc;
chan[1].spos += chan[1].sinc;
chan[2].spos += chan[2].sinc;
chan[3].spos += chan[3].sinc;
chan[4].spos += chan[4].sinc;
chan[5].spos += chan[5].sinc;
}
#endif
}
}
void AudioPlaySystem::begin(void)
{
this->reset();
}
void AudioPlaySystem::start(void)
{
playing = true;
}
void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
}
void AudioPlaySystem::reset(void)
{
snd_Reset();
}
void AudioPlaySystem::stop(void)
{
playing = false;
}
bool AudioPlaySystem::isPlaying(void)
{
return playing;
}
void AudioPlaySystem::sound(int C, int F, int V) {
#ifndef CUSTOM_SND
if (C < 6) {
chan[C].vol = V;
chan[C].sinc = F>>1;
}
#endif
}
void AudioPlaySystem::step(void) {
}
#endif

Wyświetl plik

@ -5,19 +5,12 @@ extern "C" {
#include "platform_config.h"
}
#ifdef USE_VGA
#include "vga_t_dma.h"
typedef uint8_t Pixel;
#else
#include "tft_t_dma.h"
#include "pico_dsp.h"
typedef uint16_t Pixel;
#endif
#define WIN_W TFT_WIDTH
#define WIN_H TFT_HEIGHT
//#include <stdio.h>
// definitions for easy access to registers
#define REG_COLPAGE_BASE (0x9400) // 0x9400+0x200 = 0x9600 unexpanded
@ -70,6 +63,8 @@ static uint16_t remap[16] = {
0x1c00
};
static Pixel linebuf[WIN_W];
MOS6561::MOS6561() : IC(), curRow(0), frameReady(true) {
// Set clock speed
this->setClockSpeed(1108000);
@ -102,10 +97,11 @@ void MOS6561::initialize() {
void MOS6561::renderBorder(uint16_t raster){
if (raster < WIN_H) {
Pixel bcol = vicPalette[REG_BORDER_COLOUR];
Pixel * dst = (Pixel *)emu_LineBuffer(raster);
Pixel * dst = &linebuf[0];
for (int x=0; x < WIN_W; x++) {
*dst++ = bcol;
}
}
emu_DrawLine16(&linebuf[0], WIN_W, WIN_H, raster);
}
}
@ -137,7 +133,7 @@ void MOS6561::renderLine(uint16_t raster, uint16_t row, uint8_t rowHeight, uint8
cols[bakcol] = vicPalette[REG_BACKGROUND_COLOUR];
// Border Left
Pixel * dst = (Pixel *)emu_LineBuffer(raster);
Pixel * dst = &linebuf[0];
for (int x=0; x < bWidth; x++) {
*dst++ = cols[borcol];
}
@ -179,7 +175,8 @@ void MOS6561::renderLine(uint16_t raster, uint16_t row, uint8_t rowHeight, uint8
// Border Right
for (int x=0; x < bWidth; x++) {
*dst++ = cols[borcol];
}
}
emu_DrawLine16(&linebuf[0], WIN_W, 1, raster);
}
}
@ -214,7 +211,7 @@ void MOS6561::renderRow(uint16_t raster, uint16_t row, uint8_t rowHeight)
for (int line=0; line < rowHeight; line++) {
// Border Left
Pixel * dst = (Pixel *)emu_LineBuffer(curRow*rowHeight+line+raster);
Pixel * dst = &linebuf[0];
for (int x=0; x < bWidth; x++) {
*dst++ = cols[borcol];
}
@ -230,25 +227,25 @@ void MOS6561::renderRow(uint16_t raster, uint16_t row, uint8_t rowHeight)
uint8_t multiColour = colPointer[x] & 0x8;
cols[forcol] = vicPalette[colour];
if (!multiColour) {
Pixel * dest = dst;
for (int a = 0; a < 8; a++) {
if ((characterByte << a) & 0x80) {
*dest++ = cols[forcol];
}
else {
*dest++ = cols[bakcol];
}
}
Pixel * dest = dst;
for (int a = 0; a < 8; a++) {
if ((characterByte << a) & 0x80) {
*dest++ = cols[forcol];
}
else {
*dest++ = cols[bakcol];
}
}
}
else {
Pixel * dest = dst;
cols[auxcol] = vicPalette[REG_AUXILIARY_COLOUR];
for (int a = 0; a < 8; a += 2) {
// Set colour
Pixel col = cols[((characterByte << a) & 0xC0) >> 6];
*dest++ = col;
*dest++ = col;
}
Pixel * dest = dst;
cols[auxcol] = vicPalette[REG_AUXILIARY_COLOUR];
for (int a = 0; a < 8; a += 2) {
// Set colour
Pixel col = cols[((characterByte << a) & 0xC0) >> 6];
*dest++ = col;
*dest++ = col;
}
}
dst +=8;
}
@ -256,7 +253,8 @@ void MOS6561::renderRow(uint16_t raster, uint16_t row, uint8_t rowHeight)
// Border Right
for (int x=0; x < bWidth; x++) {
*dst++ = cols[borcol];
}
}
emu_DrawLine16(&linebuf[0], WIN_W, 1, curRow*rowHeight+line+raster);
}
}
}

Wyświetl plik

@ -1,144 +0,0 @@
#ifndef EMUAPI_H
#define EMUAPI_H
#include "platform_config.h"
#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
// Title: < >
#define TITLE " V20 Emulator "
#define ROMSDIR "v20"
#define emu_Init(ROM) {v20_Init(); v20_Start(ROM);}
#define emu_Step(x) { v20_Step(); }
#define emu_Input(x) { v20_Input(x); }
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define ACTION_NONE 0
#define ACTION_MAXKBDVAL 12
#define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129
#define ACTION_RUNVGA 130
#ifdef KEYMAP_PRESENT
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
'Q','W','E','R','T','Y','U','I','O','P',157,
0,'A','S','D','F','G','H','J','K','L',0x0D,
0,'Z','X','C','V','B','N','M','.',' ',
0,0,0,0
};
#define keylables_map2_0 (char *)"1234567890 "
#define keylables_map2_1 (char *)" !@#$%+&*- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
'1','2','3','4','5','6','7','8','9','0',0,
31, '!','@','#','$','%','+','&','*','-','\/',
0, '(',')','?','\/','"','<','>',',',':',
145,157,29,17
};
#define keylables_map3_0 (char *)"\x11\x12\x13\x14\x15\x16\x17\x18 "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ;= "
const unsigned short key_map3[] = {
133,134,135,136,137,138,139,140,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,';','=',
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#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);
extern void emu_printf(const char * text);
extern void emu_printi(int val);
extern void * emu_Malloc(int size);
extern void emu_Free(void * pt);
extern int emu_FileOpen(const char * filepath, const char * mode);
extern int emu_FileRead(void * buf, int size, int handler);
extern int emu_FileGetc(int handler);
extern int emu_FileSeek(int handler, int seek, int origin);
extern int emu_FileTell(int handler);
extern void emu_FileClose(int handler);
extern unsigned int emu_FileSize(const char * filepath);
extern unsigned int emu_LoadFile(const char * filepath, void * buf, int size);
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
extern void emu_DrawVsync(void);
extern int emu_FrameSkip(void);
extern void * emu_LineBuffer(int line);
extern void emu_InitJoysticks(void);
extern int emu_SwapJoysticks(int statusOnly);
extern unsigned short emu_DebounceLocalKeys(void);
extern int emu_ReadKeys(void);
extern int emu_GetPad(void);
extern int emu_ReadAnalogJoyX(int min, int max);
extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void);
extern unsigned char emu_ReadI2CKeyboard2(int row);
extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key);
extern int emu_oskbActive(void);
extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val);
extern void emu_sndInit();
extern void emu_resetus(void);
extern int emu_us(void);
extern int emu_setKeymap(int index);
extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_printh(int val);
#endif

Wyświetl plik

@ -0,0 +1,94 @@
#ifndef EMUCFG_H
#define EMUCFG_H
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
#define FILEBROWSER
// Title: < >
#define TITLE " V20 Emulator "
#define ROMSDIR "v20"
#define emu_Init(ROM) {v20_Init(); v20_Start(ROM);}
#define emu_Step(x) { v20_Step(); }
#define emu_Input(x) { v20_Input(x); }
#ifdef KEYMAP_PRESENT
#ifdef PICOZX
const unsigned short key_map1[] = {
'1','2','3','4','5','6','7','8','9','0',
'Q','W','E','R','T','Y','U','I','O','P',
'A','S','D','F','G','H','J','K','L',0x0D,
0,'Z','X','C','V','B','N','M',0,' ',
145,157,29,17,157,29 //U L R D L R
};
const unsigned short key_map2[] = {
'!','@','#','$','%','&','\'','(',')','_',
0,0,0,'<','>',0,0,0,';','"',
0,0,0,0,0,'^','-','+','=',0x0D,
0,':',0,'?','\/','*',',','.',0,' ',
0,0,0,0,0,0
};
const unsigned short key_map3[] = {
133,134,135,136,137,138,139,140,0,0, // function keys
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short matkeys[] = {
0x104,0x101,0x108,0x102,0x110,0x120,0x140,0x204,0x201,0x208, // row 1
0x202,0x210,0x220,0x240,0x304,0x301,0x308,0x302,0x310,0x320, // row 2
0x340,0x404,0x401,0x408,0x402,0x410,0x420,0x440,0x504,0x501, // row 3
0x020,0x508,0x502,0x510,0x520,0x540,0x604,0x601,0x040,0x608, // row 4
0x008,0x001,0x002,0x010,0x620,0x640 }; // cursor keys up, left, right, down, <<<, >>>
#else
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
'Q','W','E','R','T','Y','U','I','O','P',157,
0,'A','S','D','F','G','H','J','K','L',0x0D,
0,'Z','X','C','V','B','N','M','.',' ',
145,157,29,17 //U L R D
};
#define keylables_map2_0 (char *)"1234567890 "
#define keylables_map2_1 (char *)" !@#$%+&*- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
'1','2','3','4','5','6','7','8','9','0',0,
0, '!','@','#','$','%','+','&','*','-','\/',
0, '(',')','?','\/','"','<','>',',',':',
0,0,0,0
};
#define keylables_map3_0 (char *)"\x11\x12\x13\x14\x15\x16\x17\x18 "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ;= "
const unsigned short key_map3[] = {
133,134,135,136,137,138,139,140,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,';','=',
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#endif
#endif

Wyświetl plik

@ -7,14 +7,9 @@ extern "C" {
}
#include "keyboard_osd.h"
#include "v20.h"
#include <stdio.h>
#include "pico_dsp.h"
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
volatile bool vbl=true;
bool repeating_timer_callback(struct repeating_timer *t) {
@ -27,8 +22,8 @@ bool repeating_timer_callback(struct repeating_timer *t) {
}
return true;
}
TFT_T_DMA tft;
PICO_DSP tft;
static int skip=0;
@ -47,55 +42,54 @@ int main(void) {
// set_sys_clock_khz(250000, true);
stdio_init_all();
#ifdef USE_VGA
// tft.begin(VGA_MODE_400x240);
tft.begin(VGA_MODE_320x240);
#else
tft.begin();
#endif
emu_init();
while (true) {
char * filename;
#ifdef FILEBROWSER
while (true) {
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(15, repeating_timer_callback, NULL, &timer);
}
filename = menuSelection();
if (action == ACTION_RUN) {
break;
}
tft.waitSync();
}
else {
//uint16_t bClick = emu_DebounceLocalKeys();
//emu_Input(bClick);
emu_Step();
}
//int c = getchar_timeout_us(0);
//switch (c) {
// case ' ':
// printf("test: %d\n", 1);
// break;
//}
}
#endif
emu_start();
emu_Init(filename);
tft.startRefresh();
struct repeating_timer timer;
add_repeating_timer_ms(15, repeating_timer_callback, NULL, &timer);
while (true) {
//uint16_t bClick = emu_DebounceLocalKeys();
//emu_Input(bClick);
emu_Step();
}
}
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_DrawLinePal16(unsigned char * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLinePal(width,height,line, VBuf, palette16);
}
}
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLine(width,height,line, VBuf);
}
}
void emu_DrawVsync(void)
{
@ -112,6 +106,7 @@ void emu_DrawVsync(void)
}
/*
void emu_DrawLine(unsigned char * VBuf, int width, int height, int line)
{
if (skip == 0) {
@ -132,16 +127,7 @@ void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line)
}
}
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
{
if (skip == 0) {
#ifdef USE_VGA
tft.writeLine16(width,height,line, VBuf);
#else
tft.writeLine(width,height,line, VBuf);
#endif
}
}
void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride)
{
@ -163,8 +149,7 @@ void * emu_LineBuffer(int line)
{
return (void*)tft.getLineBuffer(line);
}
*/
#ifdef HAS_SND

Wyświetl plik

@ -358,7 +358,7 @@ void v20_Step(void)
int hk=ihk;
#ifdef PICOMPUTER
#if (defined(PICOMPUTER) || defined(PICOZX) )
if (hk) {
int scan = ascii2scan[ihk];
if (scan & 0x10000) mos6522.setShiftPressed(true);
@ -373,7 +373,7 @@ void v20_Step(void)
int k=ik;
#ifdef PICOMPUTER
#if (defined(PICOMPUTER) || defined(PICOZX) )
// Ignore joypad if shift is pressed!!!
if ( !(k & MASK_KEY_USER2) )
#endif
@ -410,7 +410,8 @@ void v20_Step(void)
}
}
#ifndef PICOMPUTER
#if (defined(PICOMPUTER) || defined(PICOZX) )
#else
if ( !(pik & MASK_KEY_USER1) && (k & MASK_KEY_USER1) ) {
mos6522.setKeyPressed(0xEF7F);
mos6522.setShiftPressed(true);

Wyświetl plik

@ -1,176 +0,0 @@
#include "emuapi.h"
#ifdef HAS_SND
#include "AudioPlaySystem.h"
#define SAMPLERATE AUDIO_SAMPLE_RATE_EXACT
#define CLOCKFREQ 985248
#ifndef CUSTOM_SND
static const short square[]={
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
};
const short noise[] {
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,-32767,-32767,
32767,-32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
};
#define NOISEBSIZE 0x100
typedef struct
{
unsigned int spos;
unsigned int sinc;
unsigned int vol;
} Channel;
static Channel chan[6] = {
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0} };
#endif
volatile bool playing = false;
static void snd_Reset(void)
{
#ifndef CUSTOM_SND
chan[0].vol = 0;
chan[1].vol = 0;
chan[2].vol = 0;
chan[3].vol = 0;
chan[4].vol = 0;
chan[5].vol = 0;
chan[0].sinc = 0;
chan[1].sinc = 0;
chan[2].sinc = 0;
chan[3].sinc = 0;
chan[4].sinc = 0;
chan[5].sinc = 0;
#endif
}
#ifdef CUSTOM_SND
extern "C" {
void SND_Process(void *sndbuffer, int sndn);
}
#endif
#include <stdio.h>
void AudioPlaySystem::snd_Mixer(short * stream, int len )
{
if (playing)
{
#ifdef CUSTOM_SND
//printf("s\n");
SND_Process((void*)stream, len);
#else
int i;
long s;
len = len >> 1;
short v0=chan[0].vol;
short v1=chan[1].vol;
short v2=chan[2].vol;
short v3=chan[3].vol;
short v4=chan[4].vol;
short v5=chan[5].vol;
for (i=0;i<len;i++)
{
s =((v0*square[(chan[0].spos>>8)&0x3f])>>11);
s+=((v1*square[(chan[1].spos>>8)&0x3f])>>11);
s+=((v2*square[(chan[2].spos>>8)&0x3f])>>11);
s+=((v3*noise[(chan[3].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v4*noise[(chan[4].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v5*noise[(chan[5].spos>>8)&(NOISEBSIZE-1)])>>11);
*stream++ = (short)(s);
*stream++ = (short)(s);
chan[0].spos += chan[0].sinc;
chan[1].spos += chan[1].sinc;
chan[2].spos += chan[2].sinc;
chan[3].spos += chan[3].sinc;
chan[4].spos += chan[4].sinc;
chan[5].spos += chan[5].sinc;
}
#endif
}
}
void AudioPlaySystem::begin(void)
{
this->reset();
}
void AudioPlaySystem::start(void)
{
playing = true;
}
void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
}
void AudioPlaySystem::reset(void)
{
snd_Reset();
}
void AudioPlaySystem::stop(void)
{
playing = false;
}
bool AudioPlaySystem::isPlaying(void)
{
return playing;
}
void AudioPlaySystem::sound(int C, int F, int V) {
#ifndef CUSTOM_SND
if (C < 6) {
chan[C].vol = V;
chan[C].sinc = F>>1;
}
#endif
}
void AudioPlaySystem::step(void) {
}
#endif

Wyświetl plik

@ -1,26 +0,0 @@
#ifndef audioplaysystem_h_
#define audioplaysystem_h_
#ifdef HAS_SND
#include "platform_config.h"
class AudioPlaySystem
{
public:
AudioPlaySystem(void) { };
void begin(void);
void setSampleParameters(float clockfreq, float samplerate);
void reset(void);
void start(void);
void stop(void);
bool isPlaying(void);
void sound(int C, int F, int V);
void buzz(int size, int val);
void step(void);
static void snd_Mixer(short * stream, int len );
};
#endif
#endif

Wyświetl plik

@ -41,7 +41,7 @@ UWORD Screen_atari[ATARI_WIDTH / 2]; // = NULL;
#define DRAWLINE() \
if ( (ANTIC_ypos > 8) && (ANTIC_ypos < 248)) { \
emu_DrawLine((unsigned char *)&Screen_atari[32/sizeof(Screen_atari[0])], 320, 240, ANTIC_ypos-8); \
emu_DrawLinePal16((unsigned char *)&Screen_atari[32/sizeof(Screen_atari[0])], 320, 240, ANTIC_ypos-8); \
}

Wyświetl plik

@ -461,6 +461,9 @@ void emu_KeyboardOnDown(int keymodifer, int key) {
void emu_KeyboardOnUp(int keymodifer, int key) {
}
#define R32(rgb) ((rgb>>16)&0xff)
#define G32(rgb) ((rgb>>8)&0xff)
#define B32(rgb) (rgb & 0xff)
void at5_Init(void)
{

Wyświetl plik

@ -1,153 +0,0 @@
#ifndef EMUAPI_H
#define EMUAPI_H
#include "platform_config.h"
#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
// Title: < >
#define TITLE " Atari5200 Emulator"
#define ROMSDIR "5200"
#define emu_Init(ROM) {at5_Init(); at5_Start(ROM);}
#define emu_Step(x) {at5_Step();}
#define emu_Input(x) {}
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define R32(rgb) ((rgb>>16)&0xff)
#define G32(rgb) ((rgb>>8)&0xff)
#define B32(rgb) (rgb & 0xff)
#define ACTION_NONE 0
#define ACTION_MAXKBDVAL 16
#define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129
#define ACTION_RUNVGA 130
#ifdef KEYMAP_PRESENT
#define keylables_map1_0 (char *)" "
#define keylables_map1_1 (char *)" "
#define keylables_map1_2 (char *)" "
const unsigned short key_map1[] = {
15+1,14+1,13+1,11+1,10+1,9+1,7+1,6+1,5+1,2+1,0,
0,12+1,8+1,4+1,0+1,1+1,3+1,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
// These may be set to 1. The core handles clearing them.
// [BREAK] 0 [ # ] 1 [ 0 ] 2 [ * ] 3
// [RESET] 4 [ 9 ] 5 [ 8 ] 6 [ 7 ] 7
// [PAUSE] 8 [ 6 ] 9 [ 5 ] 10 [ 4 ] 11
// [START] 12 [ 3 ] 13 [ 2 ] 14 [ 1 ] 15
#define keylables_map2_0 (char *)" "
#define keylables_map2_1 (char *)" "
#define keylables_map2_2 (char *)" "
const unsigned short key_map2[] = {
0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
#define keylables_map3_0 (char *)" "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" "
const unsigned short key_map3[] = {
0,0,0,0,0,0,0,0,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#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);
extern void emu_printf(const char * text);
extern void emu_printi(int val);
extern void * emu_Malloc(int size);
extern void emu_Free(void * pt);
extern int emu_FileOpen(const char * filepath, const char * mode);
extern int emu_FileRead(void * buf, int size, int handler);
extern int emu_FileGetc(int handler);
extern int emu_FileSeek(int handler, int seek, int origin);
extern int emu_FileTell(int handler);
extern void emu_FileClose(int handler);
extern unsigned int emu_FileSize(const char * filepath);
extern unsigned int emu_LoadFile(const char * filepath, void * buf, int size);
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
extern void emu_DrawVsync(void);
extern int emu_FrameSkip(void);
extern void * emu_LineBuffer(int line);
extern void emu_InitJoysticks(void);
extern int emu_SwapJoysticks(int statusOnly);
extern unsigned short emu_DebounceLocalKeys(void);
extern int emu_ReadKeys(void);
extern int emu_GetPad(void);
extern int emu_ReadAnalogJoyX(int min, int max);
extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void);
extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key);
extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val);
extern void emu_sndInit();
extern void emu_resetus(void);
extern int emu_us(void);
extern int emu_setKeymap(int index);
extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_printh(int val);
#endif

Wyświetl plik

@ -0,0 +1,103 @@
#ifndef EMUCFG_H
#define EMUCFG_H
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define CUSTOM_SND 1
#define CUSTOM_SND_C 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
#define FILEBROWSER
// Title: < >
#define TITLE " Atari5200 Emulator"
#define ROMSDIR "5200"
#define emu_Init(ROM) {at5_Init(); at5_Start(ROM);}
#define emu_Step(x) {at5_Step();}
#define emu_Input(x) {}
#ifdef KEYMAP_PRESENT
#ifdef PICOZX
const unsigned short key_map1[] = {
15+1,14+1,13+1,11+1,10+1,9+1,7+1,6+1,5+1,2+1,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0 //U L R D L R
};
const unsigned short key_map2[] = {
0,0,1+1,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,3+3,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short key_map3[] = {
0+1,4+1,8+1,12+1,0,0,0,0,0,0, // function keys break,reset,pause,start
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short matkeys[] = {
0x104,0x101,0x108,0x102,0x110,0x120,0x140,0x204,0x201,0x208, // row 1
0x202,0x210,0x220,0x240,0x304,0x301,0x308,0x302,0x310,0x320, // row 2
0x340,0x404,0x401,0x408,0x402,0x410,0x420,0x440,0x504,0x501, // row 3
0x020,0x508,0x502,0x510,0x520,0x540,0x604,0x601,0x040,0x608, // row 4
0x008,0x001,0x002,0x010,0x620,0x640 }; // cursor keys up, left, right, down, <<<, >>>
#else
#define keylables_map1_0 (char *)" "
#define keylables_map1_1 (char *)" "
#define keylables_map1_2 (char *)" "
const unsigned short key_map1[] = {
15+1,14+1,13+1,11+1,10+1,9+1,7+1,6+1,5+1,2+1,0,
0,12+1,8+1,4+1,0+1,1+1,3+1,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
// These may be set to 1. The core handles clearing them.
// [BREAK] 0 [ # ] 1 [ 0 ] 2 [ * ] 3
// [RESET] 4 [ 9 ] 5 [ 8 ] 6 [ 7 ] 7
// [PAUSE] 8 [ 6 ] 9 [ 5 ] 10 [ 4 ] 11
// [START] 12 [ 3 ] 13 [ 2 ] 14 [ 1 ] 15
#define keylables_map2_0 (char *)" "
#define keylables_map2_1 (char *)" "
#define keylables_map2_2 (char *)" "
const unsigned short key_map2[] = {
0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
#define keylables_map3_0 (char *)" "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" "
const unsigned short key_map3[] = {
0,0,0,0,0,0,0,0,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#endif
#endif

Wyświetl plik

@ -1,135 +0,0 @@
// Font: c64_lower.64c
const unsigned char font8x8[128][8] PROGMEM =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
{ 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
{ 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
{ 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
{ 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
{ 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
{ 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
{ 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
{ 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
{ 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
{ 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
{ 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
{ 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
{ 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
{ 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
{ 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
{ 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
{ 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
{ 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
{ 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
{ 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
{ 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
{ 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
{ 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (//)
{ 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
{ 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
{ 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
{ 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
{ 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
{ 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
{ 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
{ 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
{ 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
{ 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
{ 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
{ 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
{ 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
{ 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
{ 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
{ 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
{ 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
{ 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
{ 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
{ 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
{ 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
{ 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
{ 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
{ 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
{ 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
{ 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
{ 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
{ 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
{ 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
{ 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
{ 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
{ 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
{ 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
{ 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
{ 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
{ 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
{ 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
{ 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
{ 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
{ 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
{ 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
{ 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
{ 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
{ 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
{ 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
{ 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
{ 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
{ 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
{ 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
{ 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
{ 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
{ 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
{ 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
{ 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
{ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
{ 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
{ 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F
};

Wyświetl plik

@ -1,5 +1,7 @@
#include "pico.h"
#include "pico/stdlib.h"
#include "hardware/clocks.h"
#include "hardware/vreg.h"
extern "C" {
#include "iopins.h"
@ -11,116 +13,115 @@ extern "C" {
#include "atari5200.h"
}
#include <stdio.h>
#include "pico_dsp.h"
#include "hardware/clocks.h"
#include "hardware/vreg.h"
volatile bool vbl=true;
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
TFT_T_DMA tft;
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;
}
PICO_DSP tft;
static int skip=0;
int main(void) {
vreg_set_voltage(VREG_VOLTAGE_1_05);
// 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);
set_sys_clock_khz(225000, true);
// set_sys_clock_khz(250000, true);
stdio_init_all();
#ifdef USE_VGA
// tft.begin(VGA_MODE_400x240);
tft.begin(VGA_MODE_320x240);
#else
tft.begin();
#endif
emu_init();
while (true) {
char * filename;
#ifdef FILEBROWSER
while (true) {
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();
}
filename = menuSelection();
if (action == ACTION_RUN) {
break;
}
tft.waitSync();
}
else {
emu_Step();
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
}
//int c = getchar_timeout_us(0);
//switch (c) {
// case ' ':
// printf("test: %d\n", 1);
// break;
//}
}
#endif
emu_start();
emu_Init(filename);
tft.startRefresh();
//struct repeating_timer timer;
//add_repeating_timer_ms(5, repeating_timer_callback, NULL, &timer);
while (true) {
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
emu_Step();
}
}
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_DrawLinePal16(unsigned char * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLinePal(width,height,line, VBuf, palette16);
}
}
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLine(width,height,line, VBuf);
}
}
void emu_DrawVsync(void)
{
skip += 1;
skip &= VID_FRAME_SKIP;
//tft.waitSync();
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);
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);
#else
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
#endif
}
}
@ -134,6 +135,7 @@ void * emu_LineBuffer(int line)
{
return (void*)tft.getLineBuffer(line);
}
*/
#ifdef HAS_SND

Plik diff jest za duży Load Diff

Wyświetl plik

@ -1,176 +0,0 @@
#include "emuapi.h"
#ifdef HAS_SND
#include "AudioPlaySystem.h"
#define SAMPLERATE AUDIO_SAMPLE_RATE_EXACT
#define CLOCKFREQ 985248
#ifndef CUSTOM_SND
static const short square[]={
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
};
const short noise[] {
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,-32767,-32767,
32767,-32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
};
#define NOISEBSIZE 0x100
typedef struct
{
unsigned int spos;
unsigned int sinc;
unsigned int vol;
} Channel;
static Channel chan[6] = {
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0} };
#endif
volatile bool playing = false;
static void snd_Reset(void)
{
#ifndef CUSTOM_SND
chan[0].vol = 0;
chan[1].vol = 0;
chan[2].vol = 0;
chan[3].vol = 0;
chan[4].vol = 0;
chan[5].vol = 0;
chan[0].sinc = 0;
chan[1].sinc = 0;
chan[2].sinc = 0;
chan[3].sinc = 0;
chan[4].sinc = 0;
chan[5].sinc = 0;
#endif
}
#ifdef CUSTOM_SND
//extern "C" {
void SND_Process(void *sndbuffer, int sndn);
//}
#endif
#include <stdio.h>
void AudioPlaySystem::snd_Mixer(short * stream, int len )
{
if (playing)
{
#ifdef CUSTOM_SND
//printf("s\n");
SND_Process((void*)stream, len);
#else
int i;
long s;
len = len >> 1;
short v0=chan[0].vol;
short v1=chan[1].vol;
short v2=chan[2].vol;
short v3=chan[3].vol;
short v4=chan[4].vol;
short v5=chan[5].vol;
for (i=0;i<len;i++)
{
s =((v0*square[(chan[0].spos>>8)&0x3f])>>11);
s+=((v1*square[(chan[1].spos>>8)&0x3f])>>11);
s+=((v2*square[(chan[2].spos>>8)&0x3f])>>11);
s+=((v3*noise[(chan[3].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v4*noise[(chan[4].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v5*noise[(chan[5].spos>>8)&(NOISEBSIZE-1)])>>11);
*stream++ = (short)(s);
*stream++ = (short)(s);
chan[0].spos += chan[0].sinc;
chan[1].spos += chan[1].sinc;
chan[2].spos += chan[2].sinc;
chan[3].spos += chan[3].sinc;
chan[4].spos += chan[4].sinc;
chan[5].spos += chan[5].sinc;
}
#endif
}
}
void AudioPlaySystem::begin(void)
{
this->reset();
}
void AudioPlaySystem::start(void)
{
playing = true;
}
void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
}
void AudioPlaySystem::reset(void)
{
snd_Reset();
}
void AudioPlaySystem::stop(void)
{
playing = false;
}
bool AudioPlaySystem::isPlaying(void)
{
return playing;
}
void AudioPlaySystem::sound(int C, int F, int V) {
#ifndef CUSTOM_SND
if (C < 6) {
chan[C].vol = V;
chan[C].sinc = F>>1;
}
#endif
}
void AudioPlaySystem::step(void) {
}
#endif

Wyświetl plik

@ -1,26 +0,0 @@
#ifndef audioplaysystem_h_
#define audioplaysystem_h_
#ifdef HAS_SND
#include "platform_config.h"
class AudioPlaySystem
{
public:
AudioPlaySystem(void) { };
void begin(void);
void setSampleParameters(float clockfreq, float samplerate);
void reset(void);
void start(void);
void stop(void);
bool isPlaying(void);
void sound(int C, int F, int V);
void buzz(int size, int val);
void step(void);
static void snd_Mixer(short * stream, int len );
};
#endif
#endif

Wyświetl plik

@ -1,150 +0,0 @@
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2017 PJRC.COM, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* 1. The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 2. If the Software is incorporated into a build system that allows
* selection among a list of target devices, then similar target
* devices manufactured by PJRC.COM must be included in the list of
* target devices and selectable in the same manner.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
Added :
- void setIntervalFast(float microseconds)
- bool setInterval(float microseconds)
F.B.
*/
#ifndef __INTERVALTIMERX_H__
#define __INTERVALTIMERX_H__
//#include "kinetis.h"
#ifdef __cplusplus
extern "C" {
#endif
class MyIntervalTimer {
private:
static const uint32_t MAX_PERIOD = UINT32_MAX / (F_BUS / 1000000.0);
public:
MyIntervalTimer() {
//channel = NULL;
nvic_priority = 128;
}
~MyIntervalTimer() {
end();
}
bool begin(void (*funct)(), unsigned int microseconds) {
if (microseconds == 0 || microseconds > MAX_PERIOD) return false;
uint32_t cycles = (F_BUS / 1000000) * microseconds - 1;
if (cycles < 36) return false;
return beginCycles(funct, cycles);
}
bool begin(void (*funct)(), int microseconds) {
if (microseconds < 0) return false;
return begin(funct, (unsigned int)microseconds);
}
bool begin(void (*funct)(), unsigned long microseconds) {
return begin(funct, (unsigned int)microseconds);
}
bool begin(void (*funct)(), long microseconds) {
return begin(funct, (int)microseconds);
}
bool begin(void (*funct)(), float microseconds) {
if (microseconds <= 0 || microseconds > MAX_PERIOD) return false;
uint32_t cycles = (float)(F_BUS / 1000000) * microseconds - 0.5;
if (cycles < 36) return false;
return beginCycles(funct, cycles);
}
bool begin(void (*funct)(), double microseconds) {
return begin(funct, (float)microseconds);
}
void setIntervalFast(float microseconds) { /*NEW*/
uint32_t cycles = (float)(F_BUS / 1000000) * microseconds - 0.5;
//channel->LDVAL = cycles;
}
bool setInterval(float microseconds) { /*NEW*/
//if (!channel) return false;
if (microseconds <= 0 || microseconds > MAX_PERIOD) return false;
setIntervalFast(microseconds);
return true;
}
void end() {};
void priority(uint8_t n) {
nvic_priority = n;
#if defined(KINETISK)
/*
if (channel) {
int index = channel - KINETISK_PIT_CHANNELS;
NVIC_SET_PRIORITY(IRQ_PIT_CH0 + index, nvic_priority);
}
*/
#elif defined(KINETISL)
/*
if (channel) {
int index = channel - KINETISK_PIT_CHANNELS;
nvic_priorites[index] = nvic_priority;
if (nvic_priorites[0] <= nvic_priorites[1]) {
NVIC_SET_PRIORITY(IRQ_PIT, nvic_priorites[0]);
} else {
NVIC_SET_PRIORITY(IRQ_PIT, nvic_priorites[1]);
}
}
*/
#endif
}
//operator IRQ_NUMBER_t() {
/*
if (channel) {
#if defined(KINETISK)
int index = channel - KINETISK_PIT_CHANNELS;
return (IRQ_NUMBER_t)(IRQ_PIT_CH0 + index);
#elif defined(KINETISL)
return IRQ_PIT;
#endif
}
*/
//return (IRQ_NUMBER_t)NVIC_NUM_INTERRUPTS;
//}
private:
//KINETISK_PIT_CHANNEL_t *channel;
uint8_t nvic_priority;
#if defined(KINETISL)
static uint8_t nvic_priorites[2];
#endif
bool beginCycles(void (*funct)(), uint32_t cycles);
};
#ifdef __cplusplus
}
#endif
#endif

Wyświetl plik

@ -51,19 +51,10 @@
#define NTSC (!PAL)
#define USBHOST (!PS2KEYBOARD)
extern "C" {
#include "emuapi.h"
}
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
extern TFT_T_DMA tft;
inline unsigned long millis() {
return (to_ms_since_boot(get_absolute_time ()));
}

Wyświetl plik

@ -297,6 +297,7 @@ static char textkey[1];
static bool res=false;
static bool firsttime=true;
static int loadtimeout=100; //100*20ms;
#ifndef PICOMPUTER
/*
@ -411,17 +412,22 @@ void c64_Input(int bClick) {
}
else
*/
#endif
#endif
if (loadtimeout > 0) {
loadtimeout--;
}
if ( (bClick & MASK_KEY_USER1) && !(emu_GetPad() & MASK_OSKB) ) {
if (firsttime) {
firsttime = false;
textseq = textload;
nbkeys = strlen(textseq);
kcnt=0;
if (loadtimeout == 0) {
if (firsttime) {
firsttime = false;
textseq = textload;
nbkeys = strlen(textseq);
kcnt=0;
}
else {
cpu.swapJoysticks = !cpu.swapJoysticks;
}
}
else {
cpu.swapJoysticks = !cpu.swapJoysticks;
}
}
else
{

Wyświetl plik

@ -49,7 +49,7 @@
#include "Teensy64.h"
#include "roms.h"
#include "patches.h"
#include "util.h"
#include "timerutil.h"
#include "pla.h"
#include "vic.h"
#include "keyboard.h"

Wyświetl plik

@ -1,144 +0,0 @@
#ifndef EMUAPI_H
#define EMUAPI_H
#include "platform_config.h"
#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
// Title: < >
#define TITLE " C64 Emulator "
#define ROMSDIR "c64"
#define emu_Init(ROM) {c64_Start(ROM); c64_Init(); }
#define emu_Step(x) { c64_Step(); }
#define emu_Input(x) { c64_Input(x); }
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define ACTION_NONE 0
#define ACTION_MAXKBDVAL 12
#define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129
#define ACTION_RUNVGA 130
#ifdef KEYMAP_PRESENT
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
'Q','W','E','R','T','Y','U','I','O','P',157,
0,'A','S','D','F','G','H','J','K','L',0x0D,
0,'Z','X','C','V','B','N','M','.',' ',
145,157,29,17
};
#define keylables_map2_0 (char *)"1234567890 "
#define keylables_map2_1 (char *)" !@#$%+&*- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
'1','2','3','4','5','6','7','8','9','0',0,
0, '!','@','#','$','%','+','&','*','-','\/',
0, '(',')','?','\/','"','<','>',',',':',
0,0,0,0
};
#define keylables_map3_0 (char *)"\x11\x12\x13\x14\x15\x16\x17\x18 "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ;= "
const unsigned short key_map3[] = {
133,134,135,136,137,138,139,140,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,';','=',
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#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);
extern void emu_printf(const char * text);
extern void emu_printi(int val);
extern void * emu_Malloc(int size);
extern void emu_Free(void * pt);
extern int emu_FileOpen(const char * filepath, const char * mode);
extern int emu_FileRead(void * buf, int size, int handler);
extern int emu_FileGetc(int handler);
extern int emu_FileSeek(int handler, int seek, int origin);
extern int emu_FileTell(int handler);
extern void emu_FileClose(int handler);
extern unsigned int emu_FileSize(const char * filepath);
extern unsigned int emu_LoadFile(const char * filepath, void * buf, int size);
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
extern void emu_DrawVsync(void);
extern int emu_FrameSkip(void);
extern void * emu_LineBuffer(int line);
extern void emu_InitJoysticks(void);
extern int emu_SwapJoysticks(int statusOnly);
extern unsigned short emu_DebounceLocalKeys(void);
extern int emu_ReadKeys(void);
extern int emu_GetPad(void);
extern int emu_ReadAnalogJoyX(int min, int max);
extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void);
extern unsigned char emu_ReadI2CKeyboard2(int row);
extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key);
extern int emu_oskbActive(void);
extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val);
extern void emu_sndInit();
extern void emu_resetus(void);
extern int emu_us(void);
extern int emu_setKeymap(int index);
extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_printh(int val);
#endif

Wyświetl plik

@ -0,0 +1,94 @@
#ifndef EMUCFG_H
#define EMUCFG_H
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
#define FILEBROWSER
// Title: < >
#define TITLE " C64 Emulator "
#define ROMSDIR "c64"
#define emu_Init(ROM) {c64_Start(ROM); c64_Init(); }
#define emu_Step(x) { c64_Step(); }
#define emu_Input(x) { c64_Input(x); }
#ifdef KEYMAP_PRESENT
#ifdef PICOZX
const unsigned short key_map1[] = {
'1','2','3','4','5','6','7','8','9','0',
'Q','W','E','R','T','Y','U','I','O','P',
'A','S','D','F','G','H','J','K','L',0x0D,
0,'Z','X','C','V','B','N','M',0,' ',
145,157,29,17,157,29 //U L R D L R
};
const unsigned short key_map2[] = {
'!','@','#','$','%','&','\'','(',')','_',
0,0,0,'<','>',0,0,0,';','"',
0,0,0,0,0,'^','-','+','=',0x0D,
0,':',0,'?','\/','*',',','.',0,' ',
0,0,0,0,0,0
};
const unsigned short key_map3[] = {
133,134,135,136,137,138,139,140,0,0, // function keys
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short matkeys[] = {
0x104,0x101,0x108,0x102,0x110,0x120,0x140,0x204,0x201,0x208, // row 1
0x202,0x210,0x220,0x240,0x304,0x301,0x308,0x302,0x310,0x320, // row 2
0x340,0x404,0x401,0x408,0x402,0x410,0x420,0x440,0x504,0x501, // row 3
0x020,0x508,0x502,0x510,0x520,0x540,0x604,0x601,0x040,0x608, // row 4
0x008,0x001,0x002,0x010,0x620,0x640 }; // cursor keys up, left, right, down, <<<, >>>
#else
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
'Q','W','E','R','T','Y','U','I','O','P',157,
0,'A','S','D','F','G','H','J','K','L',0x0D,
0,'Z','X','C','V','B','N','M','.',' ',
145,157,29,17 //U L R D
};
#define keylables_map2_0 (char *)"1234567890 "
#define keylables_map2_1 (char *)" !@#$%+&*- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
'1','2','3','4','5','6','7','8','9','0',0,
0, '!','@','#','$','%','+','&','*','-','\/',
0, '(',')','?','\/','"','<','>',',',':',
0,0,0,0
};
#define keylables_map3_0 (char *)"\x11\x12\x13\x14\x15\x16\x17\x18 "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ;= "
const unsigned short key_map3[] = {
133,134,135,136,137,138,139,140,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,';','=',
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#endif
#endif

Wyświetl plik

@ -9,12 +9,8 @@ extern "C" {
#include "c64.h"
#include <stdio.h>
#include "pico_dsp.h"
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
volatile bool vbl=true;
bool repeating_timer_callback(struct repeating_timer *t) {
@ -27,11 +23,10 @@ bool repeating_timer_callback(struct repeating_timer *t) {
}
return true;
}
TFT_T_DMA tft;
PICO_DSP tft;
static int skip=0;
#include "hardware/clocks.h"
#include "hardware/vreg.h"
@ -42,83 +37,74 @@ int main(void) {
// 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(230000, true);
// set_sys_clock_khz(225000, true);
// set_sys_clock_khz(250000, true);
set_sys_clock_khz(250000, true);
stdio_init_all();
#ifdef USE_VGA
// tft.begin(VGA_MODE_400x240);
tft.begin(VGA_MODE_320x240);
#else
tft.begin();
#endif
emu_init();
while (true) {
char * filename;
#ifdef FILEBROWSER
while (true) {
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(25, repeating_timer_callback, NULL, &timer);
}
filename = menuSelection();
if (action == ACTION_RUN) {
break;
}
tft.waitSync();
}
else {
emu_Step();
}
//int c = getchar_timeout_us(0);
//switch (c) {
// case ' ':
// printf("test: %d\n", 1);
// break;
//}
}
#endif
emu_start();
emu_Init(filename);
tft.startRefresh();
struct repeating_timer timer;
add_repeating_timer_ms(25, repeating_timer_callback, NULL, &timer);
while (true) {
//uint16_t bClick = emu_DebounceLocalKeys();
//emu_Input(bClick);
emu_Step();
}
}
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_DrawLinePal16(unsigned char * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLinePal(width,height,line, VBuf, palette16);
}
}
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLine(width,height,line, VBuf);
}
}
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) {};
//tft.waitSync();
#else
//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) {
@ -159,7 +145,7 @@ void * emu_LineBuffer(int line)
{
return (void*)tft.getLineBuffer(line);
}
*/

Wyświetl plik

@ -34,7 +34,7 @@ Copyright Frank Bösing, 2017
*/
#include <stdint.h>
#include <stdio.h>
#include "util.h"
#include "timerutil.h"
//Attention, don't use WFI-instruction - the CPU does not count cycles during sleep
void enableCycleCounter(void) {

Wyświetl plik

@ -52,6 +52,7 @@
#include <math.h>
#include <stdlib.h>
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
@ -69,11 +70,7 @@
#define BORDER_LEFT (400-320)/2
#define BORDER_RIGHT 0
#ifdef USE_VGA
typedef uint8_t tpixel;
#else
typedef uint16_t tpixel;
#endif
#define MAXCYCLESSPRITES0_2 3
#define MAXCYCLESSPRITES3_7 5
@ -1275,7 +1272,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*16];
void vic_do(void) {
@ -1396,11 +1393,7 @@ void vic_do(void) {
}
//max_x = (!cpu.vic.CSEL) ? 40:38;
#ifdef USE_VGA
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE));
#else
p = &linebuffer[0];
#endif
pe = p + SCREEN_WIDTH;
//Left Screenborder: Cycle 10
spl = &cpu.vic.spriteLine[24];
@ -1563,11 +1556,7 @@ g-Zugriff
if (!cpu.vic.CSEL) {
cpu_clock(1);
uint16_t col = cpu.vic.colors[0];
#ifdef USE_VGA
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + BORDER_LEFT;
#else
p = &linebuffer[0]; // tft.getLineBuffer((r - FIRSTDISPLAYLINE));
#endif
#if 0
// Sprites im Rand
uint16_t sprite;
@ -1589,11 +1578,7 @@ g-Zugriff
#endif
//Rand rechts:
#ifdef USE_VGA
p = (tpixel*)emu_LineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
#else
p = &linebuffer[SCREEN_WIDTH - 9 + BORDER_LEFT]; //tft.getLineBuffer((r - FIRSTDISPLAYLINE)) + SCREEN_WIDTH - 9 + BORDER_LEFT;
#endif
pe = p + 9;
#if 0
@ -1613,12 +1598,8 @@ g-Zugriff
}
#ifdef USE_VGA
//emu_DrawLine8(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
#else
emu_DrawLine16(&linebuffer[0], SCREEN_WIDTH, SCREEN_HEIGHT, (r - FIRSTDISPLAYLINE));
//memset(&linebuffer[0],0,320*2);
#endif
memset(&linebuffer[0],0,SCREEN_WIDTH*2);

Wyświetl plik

@ -1,176 +0,0 @@
#include "emuapi.h"
#ifdef HAS_SND
#include "AudioPlaySystem.h"
#define SAMPLERATE AUDIO_SAMPLE_RATE_EXACT
#define CLOCKFREQ 985248
#ifndef CUSTOM_SND
static const short square[]={
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
};
const short noise[] {
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,-32767,-32767,
32767,-32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
};
#define NOISEBSIZE 0x100
typedef struct
{
unsigned int spos;
unsigned int sinc;
unsigned int vol;
} Channel;
static Channel chan[6] = {
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0} };
#endif
volatile bool playing = false;
static void snd_Reset(void)
{
#ifndef CUSTOM_SND
chan[0].vol = 0;
chan[1].vol = 0;
chan[2].vol = 0;
chan[3].vol = 0;
chan[4].vol = 0;
chan[5].vol = 0;
chan[0].sinc = 0;
chan[1].sinc = 0;
chan[2].sinc = 0;
chan[3].sinc = 0;
chan[4].sinc = 0;
chan[5].sinc = 0;
#endif
}
#ifdef CUSTOM_SND
extern "C" {
void SND_Process(void *sndbuffer, int sndn);
}
#endif
#include <stdio.h>
void AudioPlaySystem::snd_Mixer(short * stream, int len )
{
if (playing)
{
#ifdef CUSTOM_SND
//printf("s\n");
SND_Process((void*)stream, len);
#else
int i;
long s;
len = len >> 1;
short v0=chan[0].vol;
short v1=chan[1].vol;
short v2=chan[2].vol;
short v3=chan[3].vol;
short v4=chan[4].vol;
short v5=chan[5].vol;
for (i=0;i<len;i++)
{
s =((v0*square[(chan[0].spos>>8)&0x3f])>>11);
s+=((v1*square[(chan[1].spos>>8)&0x3f])>>11);
s+=((v2*square[(chan[2].spos>>8)&0x3f])>>11);
s+=((v3*noise[(chan[3].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v4*noise[(chan[4].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v5*noise[(chan[5].spos>>8)&(NOISEBSIZE-1)])>>11);
*stream++ = (short)(s);
*stream++ = (short)(s);
chan[0].spos += chan[0].sinc;
chan[1].spos += chan[1].sinc;
chan[2].spos += chan[2].sinc;
chan[3].spos += chan[3].sinc;
chan[4].spos += chan[4].sinc;
chan[5].spos += chan[5].sinc;
}
#endif
}
}
void AudioPlaySystem::begin(void)
{
this->reset();
}
void AudioPlaySystem::start(void)
{
playing = true;
}
void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
}
void AudioPlaySystem::reset(void)
{
snd_Reset();
}
void AudioPlaySystem::stop(void)
{
playing = false;
}
bool AudioPlaySystem::isPlaying(void)
{
return playing;
}
void AudioPlaySystem::sound(int C, int F, int V) {
#ifndef CUSTOM_SND
if (C < 6) {
chan[C].vol = V;
chan[C].sinc = F>>1;
}
#endif
}
void AudioPlaySystem::step(void) {
}
#endif

Wyświetl plik

@ -1,26 +0,0 @@
#ifndef audioplaysystem_h_
#define audioplaysystem_h_
#ifdef HAS_SND
#include "platform_config.h"
class AudioPlaySystem
{
public:
AudioPlaySystem(void) { };
void begin(void);
void setSampleParameters(float clockfreq, float samplerate);
void reset(void);
void start(void);
void stop(void);
bool isPlaying(void);
void sound(int C, int F, int V);
void buzz(int size, int val);
void step(void);
static void snd_Mixer(short * stream, int len );
};
#endif
#endif

Wyświetl plik

@ -41,7 +41,7 @@ UWORD Screen_atari[ATARI_WIDTH / 2]; // = NULL;
#define DRAWLINE() \
if ( (ANTIC_ypos > 8) && (ANTIC_ypos < 248)) { \
emu_DrawLine((unsigned char *)&Screen_atari[32/sizeof(Screen_atari[0])], 320, 240, ANTIC_ypos-8); \
emu_DrawLinePal16((unsigned char *)&Screen_atari[32/sizeof(Screen_atari[0])], 320, 240, ANTIC_ypos-8); \
}

Wyświetl plik

@ -33,9 +33,6 @@ typedef struct
} CONTROLLER;
// global variables
unsigned char mem[MEMORY_SIZE];
unsigned char * memory=mem;
@ -247,6 +244,10 @@ static void Initialise(void)
//add_esc(0xe459, ESC_SIOV);
}
#define R32(rgb) ((rgb>>16)&0xff)
#define G32(rgb) ((rgb>>8)&0xff)
#define B32(rgb) (rgb & 0xff)
void at8_Init(void)
{
int i;

Wyświetl plik

@ -1,207 +0,0 @@
#ifndef EMUAPI_H
#define EMUAPI_H
#include "platform_config.h"
#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
// Title: < >
#define TITLE " Atari 800 Emulator"
#define ROMSDIR "800"
#define emu_Init(ROM) {at8_Init(); at8_Start(ROM);}
#define emu_Step(x) {at8_Step();}
#define emu_Input(x) {}
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define R32(rgb) ((rgb>>16)&0xff)
#define G32(rgb) ((rgb>>8)&0xff)
#define B32(rgb) (rgb & 0xff)
#define ACTION_NONE 0
#define ACTION_MAXKBDVAL 0X40
#define ACTION_EXITKBD 127
#define ACTION_RUNTFT 126
#define ACTION_RUNVGA 125
#ifdef KEYMAP_PRESENT
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
0x2F+1,0x2F,0x2A+1,0x28+1,0x2D+1,0x2B+1,0x0B+1,0x0D+1,0x08+1,0x0A+1,0x34+1,
0,0x3F+1,0x3F,0x3A+1,0x38+1,0x3D+1,0x39+1,0x01+1,0x05+1,0x00+1,0x0C+1,
0,0x17+1,0x16+1,0x12+1,0x10+1,0x15+1,0x23+1,0x25+1,0x22+1, 0x21+1,
0,0,0,0
};
#define keylables_map2_0 (char *)"1234567890="
#define keylables_map2_1 (char *)"T!@#$%+&*- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
0x1F+1,0x1F,0x1A+1,0x18+1,0x1D+1,0x1B+1,0x33+1,0x35+1,0x30+1,0x32+1,0x0F+1, // Digits
0x2C+1,95+1,117+1,90+1,88+1,93+1,0x06+1,91+1,0x07+1,0x0E + 1,0, // various
0, 112+1,114+1,102+1,0x26+1,94+1,0x36+1,0x37+1,0x20+1,66+1,
0,0,0,0
};
//0x07+1=*, 0x22+1=.,0x26+1=/, 0x02+1=;, 0x06+1=+, 0x36+1=<, 0x37+1=>, 0x0F+1==, 0x0E+1=-, 0x06+1=+
#define keylables_map3_0 (char *)"\x11\x12\x13\x14H "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ' ; "
const unsigned short key_map3[] = {
3+1,4+1,19+1,20+1,17+1,0,0,0,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,115+1,0,0,0x02+1,0,
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
/* Pokey code
KEY_A = 63
KEY_S = 62
KEY_G = 61
KEY_Cap = 60
KEY_D = 58
KEY_H = 57
KEY_F = 56
KEY_Great = 55
KEY_Less = 54
KEY_8 = 53
KEY_BSp = 52
KEY_7 = 51
KEY_0 = 50
KEY_9 = 48
KEY_Q = 47
KEY_W = 46
KEY_T = 45
KEY_Tab = 44
KEY_Y = 43
KEY_E = 42
KEY_R = 40
KEY_Inv = 39
KEY_Slash = 38
KEY_M = 37
KEY_N = 35
KEY_Dot = 34
KEY_Spa = 33
KEY_Comma = 32
KEY_1 = 31
KEY_2 = 30
KEY_5 = 29
KEY_Esc = 28
KEY_6 = 27
KEY_3 = 26
KEY_4 = 24
KEY_Z = 23
KEY_X = 22
KEY_B = 21
KEY_F4 = 20
KEY_F3 = 19
KEY_C = 18
KEY_Hlp = 17
KEY_V = 16
KEY_Equal = 15
KEY_Minus = 14
KEY_I = 13
KEY_Ret = 12
KEY_U = 11
KEY_P = 10
KEY_O = 8
KEY_Aster = 7
KEY_plus = 6
KEY_K = 5
KEY_F2 = 4
KEY_F1 = 3
KEY_Semi = 2
KEY_J = 1
KEY_L = 0
*/
#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);
extern void emu_printf(const char * text);
extern void emu_printi(int val);
extern void * emu_Malloc(int size);
extern void emu_Free(void * pt);
extern int emu_FileOpen(const char * filepath, const char * mode);
extern int emu_FileRead(void * buf, int size, int handler);
extern int emu_FileGetc(int handler);
extern int emu_FileSeek(int handler, int seek, int origin);
extern int emu_FileTell(int handler);
extern void emu_FileClose(int handler);
extern unsigned int emu_FileSize(const char * filepath);
extern unsigned int emu_LoadFile(const char * filepath, void * buf, int size);
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
extern void emu_DrawVsync(void);
extern int emu_FrameSkip(void);
extern void * emu_LineBuffer(int line);
extern void emu_InitJoysticks(void);
extern int emu_SwapJoysticks(int statusOnly);
extern unsigned short emu_DebounceLocalKeys(void);
extern int emu_ReadKeys(void);
extern int emu_GetPad(void);
extern int emu_ReadAnalogJoyX(int min, int max);
extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void);
extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key);
extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val);
extern void emu_sndInit();
extern void emu_resetus(void);
extern int emu_us(void);
extern int emu_setKeymap(int index);
extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_printh(int val);
#endif

Wyświetl plik

@ -0,0 +1,98 @@
#ifndef EMUCFG_H
#define EMUCFG_H
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define CUSTOM_SND 1
#define CUSTOM_SND_C 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
#define FILEBROWSER
// Title: < >
#define TITLE " Atari 800 Emulator"
#define ROMSDIR "800"
#define emu_Init(ROM) {at8_Init(); at8_Start(ROM);}
#define emu_Step(x) {at8_Step();}
#define emu_Input(x) {}
#ifdef KEYMAP_PRESENT
#ifdef PICOZX
const unsigned short key_map1[] = {
0x1F+1,0x1F,0x1A+1,0x18+1,0x1D+1,0x1B+1,0x33+1,0x35+1,0x30+1,0x32+1,
0x2F+1,0x2F,0x2A+1,0x28+1,0x2D+1,0x2B+1,0x0B+1,0x0D+1,0x08+1,0x0A+1,
0x3F+1,0x3F,0x3A+1,0x38+1,0x3D+1,0x39+1,0x01+1,0x05+1,0x00+1,0x0D,
0,0x17+1,0x16+1,0x12+1,0x10+1,0x15+1,0x23+1,0x25+1,0,0x21+1,
0,0,0,0,0,0 //U L R D L R
};
const unsigned short key_map2[] = {
95+1,117+1,90+1,88+1,93+1,91+1,115+1,112+1,114+1,0,
0,0,0,0x36+1,0x37+1,0,0,0,0x02+1,94+1,
0,0,0,0,0,0,0x0E + 1,0x06+1,0x0F+1,0x0D,
0,66+1,0,102+1,0x26+1,0x07+1,0x20+1,0x22+1,0,' ',
0,0,0,0,0,0
};
const unsigned short key_map3[] = {
3+1,4+1,19+1,20+1,17+1,0,0,0,0,0, // function keys
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short matkeys[] = {
0x104,0x101,0x108,0x102,0x110,0x120,0x140,0x204,0x201,0x208, // row 1
0x202,0x210,0x220,0x240,0x304,0x301,0x308,0x302,0x310,0x320, // row 2
0x340,0x404,0x401,0x408,0x402,0x410,0x420,0x440,0x504,0x501, // row 3
0x020,0x508,0x502,0x510,0x520,0x540,0x604,0x601,0x040,0x608, // row 4
0x008,0x001,0x002,0x010,0x620,0x640 }; // cursor keys up, left, right, down, <<<, >>>
#else
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
0x2F+1,0x2F,0x2A+1,0x28+1,0x2D+1,0x2B+1,0x0B+1,0x0D+1,0x08+1,0x0A+1,0x34+1,
0,0x3F+1,0x3F,0x3A+1,0x38+1,0x3D+1,0x39+1,0x01+1,0x05+1,0x00+1,0x0C+1,
0,0x17+1,0x16+1,0x12+1,0x10+1,0x15+1,0x23+1,0x25+1,0x22+1, 0x21+1,
0,0,0,0
};
#define keylables_map2_0 (char *)"1234567890="
#define keylables_map2_1 (char *)"T!@#$%+&*- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
0x1F+1,0x1F,0x1A+1,0x18+1,0x1D+1,0x1B+1,0x33+1,0x35+1,0x30+1,0x32+1,0x0F+1, // Digits
0x2C+1,95+1,117+1,90+1,88+1,93+1,0x06+1,91+1,0x07+1,0x0E + 1,0, // various
0, 112+1,114+1,102+1,0x26+1,94+1,0x36+1,0x37+1,0x20+1,66+1,
0,0,0,0
};
//0x07+1=*, 0x22+1=.,0x26+1=/, 0x02+1=;, 0x06+1=+, 0x36+1=<, 0x37+1=>, 0x0F+1==, 0x0E+1=-, 0x06+1=+
#define keylables_map3_0 (char *)"\x11\x12\x13\x14H "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ' ; "
const unsigned short key_map3[] = {
3+1,4+1,19+1,20+1,17+1,0,0,0,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,115+1,0,0,0x02+1,0,
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#endif
#endif

Wyświetl plik

@ -1,135 +0,0 @@
// Font: c64_lower.64c
const unsigned char PROGMEM font8x8[128][8] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
{ 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
{ 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
{ 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
{ 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
{ 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
{ 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
{ 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
{ 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
{ 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
{ 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
{ 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
{ 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
{ 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
{ 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
{ 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
{ 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
{ 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
{ 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
{ 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
{ 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
{ 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
{ 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
{ 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (//)
{ 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
{ 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
{ 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
{ 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
{ 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
{ 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
{ 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
{ 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
{ 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
{ 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
{ 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
{ 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
{ 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
{ 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
{ 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
{ 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
{ 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
{ 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
{ 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
{ 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
{ 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
{ 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
{ 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
{ 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
{ 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
{ 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
{ 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
{ 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
{ 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
{ 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
{ 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
{ 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
{ 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
{ 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
{ 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
{ 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
{ 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
{ 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
{ 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
{ 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
{ 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
{ 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
{ 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
{ 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
{ 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
{ 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
{ 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
{ 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
{ 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
{ 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
{ 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
{ 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
{ 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
{ 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
{ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
{ 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
{ 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F
};

Wyświetl plik

@ -6,23 +6,17 @@ extern "C" {
#include "emuapi.h"
}
#include "keyboard_osd.h"
extern "C" {
#include "atari800.h"
}
#include <stdio.h>
#include "pico_dsp.h"
#include "hardware/clocks.h"
#include "hardware/vreg.h"
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
volatile bool vbl=true;
bool repeating_timer_callback(struct repeating_timer *t) {
//uint16_t bClick = emu_DebounceLocalKeys();
//emu_Input(bClick);
if (vbl) {
vbl = false;
} else {
@ -30,8 +24,8 @@ bool repeating_timer_callback(struct repeating_timer *t) {
}
return true;
}
TFT_T_DMA tft;
PICO_DSP tft;
static int skip=0;
@ -47,102 +41,87 @@ int main(void) {
// set_sys_clock_khz(250000, true);
stdio_init_all();
#ifdef USE_VGA
// tft.begin(VGA_MODE_400x240);
tft.begin(VGA_MODE_320x240);
#else
tft.begin();
#endif
emu_init();
while (true) {
char * filename;
#ifdef FILEBROWSER
while (true) {
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);
}
filename = menuSelection();
if (action == ACTION_RUN) {
break;
}
tft.waitSync();
}
else {
emu_Step();
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
}
//int c = getchar_timeout_us(0);
//switch (c) {
// case ' ':
// printf("test: %d\n", 1);
// break;
//}
}
#endif
emu_start();
emu_Init(filename);
tft.startRefresh();
struct repeating_timer timer;
add_repeating_timer_ms(5, repeating_timer_callback, NULL, &timer);
while (true) {
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
emu_Step();
}
}
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_DrawLinePal16(unsigned char * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLinePal(width,height,line, VBuf, palette16);
}
}
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLine(width,height,line, VBuf);
}
}
void emu_DrawVsync(void)
{
skip += 1;
skip &= VID_FRAME_SKIP;
volatile bool vb=vbl;
while (vbl==vb) {};
#ifdef USE_VGA
// tft.waitSync();
#ifdef USE_VGA
//tft.waitSync();
#else
// volatile bool vb=vbl;
// while (vbl==vb) {};
//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);
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);
#else
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
#endif
}
}
@ -156,6 +135,7 @@ void * emu_LineBuffer(int line)
{
return (void*)tft.getLineBuffer(line);
}
*/
#ifdef HAS_SND

Wyświetl plik

@ -1,176 +0,0 @@
#include "emuapi.h"
#ifdef HAS_SND
#include "AudioPlaySystem.h"
#define SAMPLERATE AUDIO_SAMPLE_RATE_EXACT
#define CLOCKFREQ 985248
#ifndef CUSTOM_SND
static const short square[]={
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
};
const short noise[] {
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,-32767,-32767,
32767,-32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
};
#define NOISEBSIZE 0x100
typedef struct
{
unsigned int spos;
unsigned int sinc;
unsigned int vol;
} Channel;
static Channel chan[6] = {
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0} };
#endif
volatile bool playing = false;
static void snd_Reset(void)
{
#ifndef CUSTOM_SND
chan[0].vol = 0;
chan[1].vol = 0;
chan[2].vol = 0;
chan[3].vol = 0;
chan[4].vol = 0;
chan[5].vol = 0;
chan[0].sinc = 0;
chan[1].sinc = 0;
chan[2].sinc = 0;
chan[3].sinc = 0;
chan[4].sinc = 0;
chan[5].sinc = 0;
#endif
}
#ifdef CUSTOM_SND
//extern "C" {
void SND_Process(void *sndbuffer, int sndn);
//}
#endif
#include <stdio.h>
void AudioPlaySystem::snd_Mixer(short * stream, int len )
{
if (playing)
{
#ifdef CUSTOM_SND
//printf("s\n");
SND_Process((void*)stream, len);
#else
int i;
long s;
len = len >> 1;
short v0=chan[0].vol;
short v1=chan[1].vol;
short v2=chan[2].vol;
short v3=chan[3].vol;
short v4=chan[4].vol;
short v5=chan[5].vol;
for (i=0;i<len;i++)
{
s =((v0*square[(chan[0].spos>>8)&0x3f])>>11);
s+=((v1*square[(chan[1].spos>>8)&0x3f])>>11);
s+=((v2*square[(chan[2].spos>>8)&0x3f])>>11);
s+=((v3*noise[(chan[3].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v4*noise[(chan[4].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v5*noise[(chan[5].spos>>8)&(NOISEBSIZE-1)])>>11);
*stream++ = (short)(s);
*stream++ = (short)(s);
chan[0].spos += chan[0].sinc;
chan[1].spos += chan[1].sinc;
chan[2].spos += chan[2].sinc;
chan[3].spos += chan[3].sinc;
chan[4].spos += chan[4].sinc;
chan[5].spos += chan[5].sinc;
}
#endif
}
}
void AudioPlaySystem::begin(void)
{
this->reset();
}
void AudioPlaySystem::start(void)
{
playing = true;
}
void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
}
void AudioPlaySystem::reset(void)
{
snd_Reset();
}
void AudioPlaySystem::stop(void)
{
playing = false;
}
bool AudioPlaySystem::isPlaying(void)
{
return playing;
}
void AudioPlaySystem::sound(int C, int F, int V) {
#ifndef CUSTOM_SND
if (C < 6) {
chan[C].vol = V;
chan[C].sinc = F>>1;
}
#endif
}
void AudioPlaySystem::step(void) {
}
#endif

Wyświetl plik

@ -1,26 +0,0 @@
#ifndef audioplaysystem_h_
#define audioplaysystem_h_
#ifdef HAS_SND
#include "platform_config.h"
class AudioPlaySystem
{
public:
AudioPlaySystem(void) { };
void begin(void);
void setSampleParameters(float clockfreq, float samplerate);
void reset(void);
void start(void);
void stop(void);
bool isPlaying(void);
void sound(int C, int F, int V);
void buzz(int size, int val);
void step(void);
static void snd_Mixer(short * stream, int len );
};
#endif
#endif

Wyświetl plik

@ -1,257 +0,0 @@
#include <stdint.h>
#include <stdio.h>
#include "emu.h"
extern "C" {
#include "emuapi.h"
}
extern uint8_t bootdrive, hdcount;
extern uint16_t segregs[6];
extern uint8_t cf;
extern _bytewordregs_ regs;
int file;
struct struct_drive {
uint32_t filesize;
uint16_t cyls;
uint16_t sects;
uint16_t heads;
uint8_t inserted;
} disk[4];
uint8_t sectorbuffer[512];
uint8_t insertdisk(uint8_t drivenum) {
if (drivenum & 0x80) {
drivenum -= 126;
disk[drivenum].sects = 63;
disk[drivenum].heads = 16;
disk[drivenum].cyls = 1023; //up to 512 MB
hdcount = 1;
} else {
#ifdef FDD_144M
disk[drivenum].cyls = 80;
disk[drivenum].sects = 18;
disk[drivenum].heads = 2;
#endif
#ifdef FDD_122M
disk[drivenum].cyls = 80;
disk[drivenum].sects = 15;
disk[drivenum].heads = 2;
#endif
#ifdef FDD_720K
disk[drivenum].cyls = 80;
disk[drivenum].sects = 9;
disk[drivenum].heads = 2;
#endif
#ifdef FDD_360K
disk[drivenum].cyls = 40;
disk[drivenum].sects = 9;
disk[drivenum].heads = 2;
#endif
#ifdef FDD_320K
disk[drivenum].cyls = 40;
disk[drivenum].sects = 8;
disk[drivenum].heads = 2;
#endif
#ifdef FDD_180K
disk[drivenum].cyls = 40;
disk[drivenum].sects = 9;
disk[drivenum].heads = 1;
#endif
}
disk[drivenum].inserted = 1;
return 0;
}
void ejectdisk(uint8_t drivenum) {
if (drivenum & 0x80) drivenum -= 126;
disk[drivenum].inserted = 0;
}
extern uint16_t ramseg;
extern "C" {
extern void emu_SdReadBlock(int block, void * buf);
}
uint8_t sectdone;
void getsect(uint32_t lba, uint8_t *dst) {
#ifdef USB_DISK
uint8_t chksum;
uint32_t curmicros;
retrysectget:
Serial.write(0xFF);
Serial.write(0x05);
outByte(lba & 0xFF); chksum = lba & 0xFF;
outByte((lba >> 8) & 0xFF); chksum += (lba >> 8) & 0xFF;
outByte((lba >> 16) & 0xFF); chksum += (lba >> 16) & 0xFF;
outByte((lba >> 24) & 0xFF); chksum += (lba >> 24) & 0xFF;
outByte(chksum);
Serial.write(0xFE);
Serial.write(0x02);
sectdone = 0;
curmicros = micros();
while (!sectdone) {
if (micros() < curmicros) curmicros = micros();
if ((micros() - curmicros) >= 200000) goto retrysectget;
net_loop();
}
#else
if (file)
{
//printf("read block %d\n",lba);
emu_FileSeek(lba*512);
emu_FileRead((char *)dst,1*512);
}
#endif
}
void putsect(uint32_t lba, uint8_t *src) {
#ifdef USB_DISK
uint8_t chksum;
uint16_t i;
uint32_t curmicros;
retrysectput:
Serial.write(0xFF);
Serial.write(0x06);
outByte(lba & 0xFF); chksum = lba & 0xFF;
outByte((lba >> 8) & 0xFF); chksum += (lba >> 8) & 0xFF;
outByte((lba >> 16) & 0xFF); chksum += (lba >> 16) & 0xFF;
outByte((lba >> 24) & 0xFF); chksum += (lba >> 24) & 0xFF;
for (i=0; i<512; i++) {
outByte(src[i]);
chksum += src[i];
}
outByte(chksum);
Serial.write(0xFE);
Serial.write(0x02);
sectdone = 0;
curmicros = micros();
while (!sectdone) {
if (micros() < curmicros) curmicros = micros();
if ((micros() - curmicros) >= 200000) goto retrysectput;
net_loop();
}
#else
//card.writeBlock(lba, src);
#endif
}
void readdisk(uint8_t drivenum, uint16_t dstseg, uint16_t dstoff, uint16_t cyl, uint16_t sect, uint16_t head, uint16_t sectcount) {
uint32_t memdest, goodsects, dummy, lba;
if ((sect == 0) || !disk[drivenum].inserted) return;
#ifdef MEGA
SPI.setClockDivider(SPI_CLOCK_SDCARD);
#endif
lba = ((long)cyl * (long)disk[drivenum].heads + (long)head) * (long)disk[drivenum].sects + (long)sect - 1;
memdest = (uint32_t)dstseg * 16 + (uint32_t)dstoff;
for (goodsects = 0; goodsects < sectcount; goodsects++) {
getsect(lba, sectorbuffer);
memdest = (uint32_t)dstseg * 16 + (uint32_t)dstoff;
for (dummy = 0; dummy < 512; dummy++) {
write86(memdest++, sectorbuffer[dummy]);
//Serial.write(sectorbuffer[dummy]);
}
dstoff += 512;
lba++;
}
cf = 0; regs.byteregs[regah] = 0; regs.byteregs[regal] = sectcount;
#ifdef MEGA
SPI.setClockDivider(SPI_CLOCK_SPIRAM);
#endif
}
void writedisk(uint8_t drivenum, uint16_t dstseg, uint16_t dstoff, uint16_t cyl, uint16_t sect, uint16_t head, uint16_t sectcount) {
uint32_t memdest, goodsects, dummy, lba;
if ((sect == 0) || !disk[drivenum].inserted) return;
#ifdef MEGA
SPI.setClockDivider(SPI_CLOCK_SDCARD);
#endif
lba = ((long)cyl * (long)disk[drivenum].heads + (long)head) * (long)disk[drivenum].sects + (long)sect - 1;
for (goodsects = 0; goodsects < sectcount; goodsects++) {
memdest = (uint32_t)dstseg * 16 + (uint32_t)dstoff;
for (dummy = 0; dummy < 512; dummy++) {
sectorbuffer[dummy] = read86(memdest++);
}
//card.erase(lba, lba);
putsect(lba, sectorbuffer);
dstoff += 512;
lba++;
}
cf = 0; regs.byteregs[regah] = 0; regs.byteregs[regal] = sectcount;
#ifdef MEGA
SPI.setClockDivider(SPI_CLOCK_SPIRAM);
#endif
}
void diskhandler() {
static uint8_t lastdiskah[4], lastdiskcf[4];
uint8_t drivenum;
drivenum = regs.byteregs[regdl];
if (drivenum & 0x80) drivenum -= 126;
switch (regs.byteregs[regah]) {
case 0: //reset disk system
regs.byteregs[regah] = 0; cf = 0; //useless function in an emulator. say success and return.
break;
case 1: //return last status
regs.byteregs[regah] = lastdiskah[drivenum];
cf = lastdiskcf[drivenum];
return;
case 2: //read sector(s) into memory
if (disk[drivenum].inserted) {
readdisk(drivenum, segregs[reges], getreg16(regbx), (uint16_t)regs.byteregs[regch] + ((uint16_t)regs.byteregs[regcl] / 64) * 256, regs.byteregs[regcl] & 63, regs.byteregs[regdh], regs.byteregs[regal]);
cf = 0; regs.byteregs[regah] = 0;
} else {
cf = 1;
regs.byteregs[regah] = 1;
}
break;
case 3: //write sector(s) from memory
if (disk[drivenum].inserted) {
writedisk(drivenum, segregs[reges], getreg16(regbx), regs.byteregs[regch] + (regs.byteregs[regcl] / 64) * 256, regs.byteregs[regcl] & 63, regs.byteregs[regdh], regs.byteregs[regal]);
cf = 0; regs.byteregs[regah] = 0;
} else {
cf = 1;
regs.byteregs[regah] = 1;
}
break;
case 4:
case 5: //format track
cf = 0; regs.byteregs[regah] = 0;
break;
case 8: //get drive parameters
if (disk[drivenum].inserted) {
cf = 0; regs.byteregs[regah] = 0;
regs.byteregs[regch] = disk[drivenum].cyls - 1;
regs.byteregs[regcl] = disk[drivenum].sects & 63;
regs.byteregs[regcl] = regs.byteregs[regcl] + (disk[drivenum].cyls / 256) * 64;
regs.byteregs[regdh] = disk[drivenum].heads - 1;
//segregs[reges] = 0; regs.wordregs[regdi] = 0x7C0B; //floppy parameter table
if (drivenum < 2) {
regs.byteregs[regbl] = 4; //else regs.byteregs[regbl] = 0;
regs.byteregs[regdl] = 2;
} else regs.byteregs[regdl] = hdcount;
} else {
cf = 1; regs.byteregs[regah] = 0xAA;
}
break;
default:
cf = 1;
}
lastdiskah[drivenum] = regs.byteregs[regah];
lastdiskcf[drivenum] = cf;
if (regs.byteregs[regdl] & 0x80) write86(0x474, regs.byteregs[regah]);
}
void initDisk(char * filename) {
int len=emu_FileSize(filename);
file = emu_FileOpen(filename);
if (len) {
bootdrive = 0x80;
insertdisk(0x80);
hdcount = 1;
}
else {
bootdrive = 0xFF;
emu_FileClose();
file = NULL;
}
}

Wyświetl plik

@ -1,159 +0,0 @@
//Uncomment MEGA define if using a Mega 2560, otherwise leave undefined if using a Teensy 3.6
//#define MEGA
extern "C" {
#include "iopins.h"
#include "emuapi.h"
}
#define NATIVE_RAM (0x20000) // 128k total
#define NATIVE_START 0UL
#ifdef HAS_PSRAM
#define RAM_SIZE (0xA0000) // 640k total
#else
#define RAM_SIZE (0x24000) // 128+16k total
#endif
#define ROM_READ(a,b) a[b]
//#define INCLUDE_ROM_BASIC
//#define BOOT_FDD
#define BOOT_HDD
//#define BOOT_BASIC
//#define FDD_180K
//#define FDD_320K
//#define FDD_360K
//#define FDD_720K
//#define FDD_122M
//#define FDD_144M
#define BAUD_RATE 1000000
//#define USE_NETWORKING
//#define USE_PARALLEL
//#define PROFILING
// END ARDUINO86 USER CONFIGURABLE OPTIONS
#define regax 0
#define regcx 1
#define regdx 2
#define regbx 3
#define regsp 4
#define regbp 5
#define regsi 6
#define regdi 7
#define reges 0
#define regcs 1
#define regss 2
#define regds 3
#define regal 0
#define regah 1
#define regcl 2
#define regch 3
#define regdl 4
#define regdh 5
#define regbl 6
#define regbh 7
#define StepIP(x) ip+=x
#define getmem8(x,y) read86(segbase(x)+(uint32_t)y)
//#define getmem16(x,y) (read86(segbase(x)+y) | ((uint16_t)read86(segbase(x)+y+1)<<8))
#define getmem16(x,y) readw86(segbase(x)+(uint32_t)y)
#define putmem8(x,y,z) write86(segbase(x)+(uint32_t)y, z)
//#define putmem16(x,y,z) write86(segbase(x)+y, ((z)&0xFF)); write86(segbase(x)+y+1, (((z)>>8)&0xFF))
#define putmem16(x,y,z) writew86(segbase(x)+(uint32_t)y, z)
#define signext(value) ((((uint16_t)value&0x80)*0x1FE)|(uint16_t)value)
#define signext32(value) ((((uint32_t)value&0x8000)*0x1FFFE)|(uint32_t)value)
#define getreg16(regid) regs.wordregs[regid]
#define getreg8(regid) regs.byteregs[byteregtable[regid]]
#define putreg16(regid, writeval) regs.wordregs[regid] = writeval
#define putreg8(regid, writeval) regs.byteregs[byteregtable[regid]] = writeval
#define getsegreg(regid) segregs[regid]
#define putsegreg(regid, writeval) segregs[regid] = writeval
#define segbase(x) ((uint32_t)x<<4)
#define makeflagsword() (2 | (uint16_t)cf | ((uint16_t)pf << 2) | ((uint16_t)af << 4) | ((uint16_t)zf << 6) \
| ((uint16_t)sf << 7) | ((uint16_t)tf << 8) | ((uint16_t)ifl << 9) | ((uint16_t)df << 10) | ((uint16_t)of << 11))
#define decodeflagsword(x) {\
temp16 = x;\
cf = temp16 & 1;\
pf = (temp16 >> 2) & 1;\
af = (temp16 >> 4) & 1;\
zf = (temp16 >> 6) & 1;\
sf = (temp16 >> 7) & 1;\
tf = (temp16 >> 8) & 1;\
ifl = (temp16 >> 9) & 1;\
df = (temp16 >> 10) & 1;\
of = (temp16 >> 11) & 1;\
}
//#define RAM_write(a,v) {
//}
//#define RAM_read(a,v) {
//}
void setup_memory();
void setup_timer();
uint8_t insertdisk(uint8_t drivenum);
void reset86();
void exec86(uint32_t execloops);
uint8_t read86(uint32_t addr32);
void write86(uint32_t addr32, uint8_t value);
void doirq(uint8_t irqnum);
void incsends();
void init_display();
void write_video(uint16_t addr);
void clear_display();
void palettereset();
void display_CSIP();
void ps2poll();
void setup_ps2(uint8_t data_pin, uint8_t irq_pin);
void video_init();
uint8_t VRAM_read(uint32_t addr32);
void VRAM_write(uint32_t addr32, uint8_t value);
void setup_ps2(uint8_t data_pin, uint8_t irq_pin);
void ps2poll();
void out8253 (uint16_t portnum, uint8_t value);
uint8_t in8253 (uint16_t portnum);
void init8259();
void out8259(uint16_t portnum, uint8_t value);
uint8_t in8259(uint16_t portnum);
extern uint8_t port3da;
void initDisk(char * filename);
void init8253();
void net_init();
void net_loop();
void net_handler();
uint8_t cached_read(uint32_t addr32);
void cached_write(uint32_t addr32, uint8_t value);
void cache_init();
uint8_t net_read_ram(uint32_t addr32);
void diskhandler();
//extern uint8_t SPI_RAM_pins[8];
extern uint8_t net_mac[6];
extern uint8_t bufSerial[1600];
void outByte(uint8_t cc);
extern struct i8253_s i8253;
union _bytewordregs_{
uint16_t wordregs[8];
uint8_t byteregs[8];
} ;

Wyświetl plik

@ -1,147 +0,0 @@
#ifndef EMUAPI_H
#define EMUAPI_H
#include "platform_config.h"
#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
// Title: < >
#define TITLE " 8086 PC Emulator"
#define ROMSDIR "pc"
#define emu_Init(ROM) {apc_Start(ROM); apc_Init(); }
#define emu_Step(x) { apc_Step(); }
#define emu_Input(x) { apc_Input(x); }
#define PALETTE_SIZE 256
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define ACTION_NONE 0
#define ACTION_MAXKBDVAL 12
#define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129
#define ACTION_RUNVGA 130
#ifdef KEYMAP_PRESENT
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
'Q','W','E','R','T','Y','U','I','O','P',157,
0,'A','S','D','F','G','H','J','K','L',0x0D,
0,'Z','X','C','V','B','N','M','.',' ',
145,157,29,17
};
#define keylables_map2_0 (char *)"1234567890 "
#define keylables_map2_1 (char *)" !@#$%+&*- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
'1','2','3','4','5','6','7','8','9','0',0,
0, '!','@','#','$','%','+','&','*','-','\/',
0, '(',')','?','\/','"','<','>',',',':',
0,0,0,0
};
#define keylables_map3_0 (char *)"\x11\x12\x13\x14\x15\x16\x17\x18 "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ;= "
const unsigned short key_map3[] = {
133,134,135,136,137,138,139,140,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,';','=',
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#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);
extern void emu_printf(char * text);
extern void emu_printi(int val);
extern void * emu_Malloc(int size);
extern void emu_Free(void * pt);
extern int emu_FileOpen(char * filename);
extern int emu_FileRead(char * buf, int size);
extern unsigned char emu_FileGetc(void);
extern int emu_FileSeek(int seek);
extern void emu_FileClose(void);
extern int emu_FileSize(char * filename);
extern int emu_LoadFile(char * filename, char * buf, int size);
extern int emu_LoadFileSeek(char * filename, char * buf, int size, int seek);
extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
extern void emu_DrawVsync(void);
extern int emu_FrameSkip(void);
extern void * emu_LineBuffer(int line);
extern void emu_InitJoysticks(void);
extern int emu_SwapJoysticks(int statusOnly);
extern unsigned short emu_DebounceLocalKeys(void);
extern int emu_ReadKeys(void);
extern int emu_GetPad(void);
extern int emu_ReadAnalogJoyX(int min, int max);
extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void);
extern unsigned char emu_ReadI2CKeyboard2(int row);
extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key);
extern int emu_oskbActive(void);
extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val);
extern void emu_sndInit();
extern void emu_resetus(void);
extern int emu_us(void);
extern int emu_setKeymap(int index);
extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_printh(int val);
#endif

Wyświetl plik

@ -1,264 +0,0 @@
#ifdef MEGA
#include <Arduino.h>
const uint8_t font[2048] PROGMEM = {
#else
const uint8_t font[2048] = {
#endif
0,0,0,0,0,0,0,
0,126,129,165,129,189,153,129,
126,126,255,219,255,195,231,255,
126,54,127,127,127,62,28,8,
0,8,28,62,127,62,28,8,
0,28,62,28,127,127,62,28,
62,8,8,28,62,127,62,28,
62,0,0,0,0,0,0,0,
0,255,255,231,195,195,231,255,
255,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,254,198,254,198,198,230,103,
3,153,90,60,231,231,60,90,
153,1,7,31,127,31,7,1,
0,64,112,124,127,124,112,64,
0,24,60,126,24,24,126,60,
24,102,102,102,102,102,0,102,
0,254,219,219,222,216,216,216,
0,124,198,28,54,54,28,51,
30,0,0,0,0,126,126,126,
0,24,60,126,24,126,60,24,
255,24,60,126,24,24,24,24,
0,24,24,24,24,126,60,24,
0,0,24,48,127,48,24,0,
0,0,12,6,127,6,12,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,12,30,30,12,12,0,12,
0,54,54,54,0,0,0,0,
0,54,54,127,54,127,54,54,
0,12,62,3,30,48,31,12,
0,0,99,51,24,12,102,99,
0,28,54,28,110,59,51,110,
0,6,6,3,0,0,0,0,
0,24,12,6,6,6,12,24,
0,6,12,24,24,24,12,6,
0,0,102,60,255,60,102,0,
0,0,12,12,63,12,12,0,
0,0,0,0,0,0,12,12,
6,0,0,0,63,0,0,0,
0,0,0,0,0,0,12,12,
0,96,48,24,12,6,3,1,
0,62,99,115,123,111,103,62,
0,12,14,12,12,12,12,63,
0,30,51,48,28,6,51,63,
0,30,51,48,28,48,51,30,
0,56,60,54,51,127,48,120,
0,63,3,31,48,48,51,30,
0,28,6,3,31,51,51,30,
0,63,51,48,24,12,12,12,
0,30,51,51,30,51,51,30,
0,30,51,51,62,48,24,14,
0,0,12,12,0,0,12,12,
0,0,12,12,0,0,12,12,
6,24,12,6,3,6,12,24,
0,0,0,63,0,0,63,0,
0,6,12,24,48,24,12,6,
0,30,51,48,24,12,0,12,
0,62,99,123,123,123,3,30,
0,12,30,51,51,63,51,51,
0,63,102,102,62,102,102,63,
0,60,102,3,3,3,102,60,
0,31,54,102,102,102,54,31,
0,127,70,22,30,22,70,127,
0,127,70,22,30,22,6,15,
0,60,102,3,3,115,102,124,
0,51,51,51,63,51,51,51,
0,30,12,12,12,12,12,30,
0,120,48,48,48,51,51,30,
0,103,102,54,30,54,102,103,
0,15,6,6,6,70,102,127,
0,99,119,127,127,107,99,99,
0,99,103,111,123,115,99,99,
0,28,54,99,99,99,54,28,
0,63,102,102,62,6,6,15,
0,30,51,51,51,59,30,56,
0,63,102,102,62,54,102,103,
0,30,51,7,14,56,51,30,
0,63,45,12,12,12,12,30,
0,51,51,51,51,51,51,63,
0,51,51,51,51,51,30,12,
0,99,99,99,107,127,119,99,
0,99,99,54,28,28,54,99,
0,51,51,51,30,12,12,30,
0,127,99,49,24,76,102,127,
0,30,6,6,6,6,6,30,
0,3,6,12,24,48,96,64,
0,30,24,24,24,24,24,30,
0,8,28,54,99,0,0,0,
0,0,0,0,0,0,0,0,
255,12,12,24,0,0,0,0,
0,0,0,30,48,62,51,110,
0,7,6,6,62,102,102,59,
0,0,0,30,51,3,51,30,
0,56,48,48,62,51,51,110,
0,0,0,30,51,63,3,30,
0,28,54,6,15,6,6,15,
0,0,0,110,51,51,62,48,
31,7,6,54,110,102,102,103,
0,12,0,14,12,12,12,30,
0,48,0,48,48,48,51,51,
30,7,6,102,54,30,54,103,
0,14,12,12,12,12,12,30,
0,0,0,51,127,127,107,99,
0,0,0,31,51,51,51,51,
0,0,0,30,51,51,51,30,
0,0,0,59,102,102,62,6,
15,0,0,110,51,51,62,48,
120,0,0,59,110,102,6,15,
0,0,0,62,3,30,48,31,
0,8,12,62,12,12,44,24,
0,0,0,51,51,51,51,110,
0,0,0,51,51,51,30,12,
0,0,0,99,107,127,127,54,
0,0,0,99,54,28,54,99,
0,0,0,51,51,51,62,48,
31,0,0,63,25,12,38,63,
0,56,12,12,7,12,12,56,
0,24,24,24,0,24,24,24,
0,7,12,12,56,12,12,7,
0,110,59,0,0,0,0,0,
0,0,8,28,54,99,99,127,
0,30,51,3,51,30,24,48,
30,0,51,0,51,51,51,126,
0,56,0,30,51,63,3,30,
0,126,195,60,96,124,102,252,
0,51,0,30,48,62,51,126,
0,7,0,30,48,62,51,126,
0,12,12,30,48,62,51,126,
0,0,0,30,3,3,30,48,
28,126,195,60,102,126,6,60,
0,51,0,30,51,63,3,30,
0,7,0,30,51,63,3,30,
0,51,0,14,12,12,12,30,
0,62,99,28,24,24,24,60,
0,7,0,14,12,12,12,30,
0,99,28,54,99,127,99,99,
0,12,12,0,30,51,63,51,
0,56,0,63,6,30,6,63,
0,0,0,254,48,254,51,254,
0,124,54,51,127,51,51,115,
0,30,51,0,30,51,51,30,
0,0,51,0,30,51,51,30,
0,0,7,0,30,51,51,30,
0,30,51,0,51,51,51,126,
0,0,7,0,51,51,51,126,
0,0,51,0,51,51,62,48,
31,195,24,60,102,102,60,24,
0,51,0,51,51,51,51,30,
0,24,24,126,3,3,126,24,
24,28,54,38,15,6,103,63,
0,51,51,30,63,12,63,12,
12,31,51,51,95,99,243,99,
227,112,216,24,60,24,24,27,
14,56,0,30,48,62,51,126,
0,28,0,14,12,12,12,30,
0,0,56,0,30,51,51,30,
0,0,56,0,51,51,51,126,
0,0,31,0,31,51,51,51,
0,63,0,51,55,63,59,51,
0,60,54,54,124,0,126,0,
0,28,54,54,28,0,62,0,
0,12,0,12,6,3,51,30,
0,0,0,0,63,3,3,0,
0,0,0,0,63,48,48,0,
0,195,99,51,123,204,102,51,
240,195,99,51,219,236,246,243,
192,24,24,0,24,24,24,24,
0,0,204,102,51,102,204,0,
0,0,51,102,204,102,51,0,
0,68,17,68,17,68,17,68,
17,170,85,170,85,170,85,170,
85,219,238,219,119,219,238,219,
119,24,24,24,24,24,24,24,
24,24,24,24,24,31,24,24,
24,24,24,31,24,31,24,24,
24,108,108,108,108,111,108,108,
108,0,0,0,0,127,108,108,
108,0,0,31,24,31,24,24,
24,108,108,111,96,111,108,108,
108,108,108,108,108,108,108,108,
108,0,0,127,96,111,108,108,
108,108,108,111,96,127,0,0,
0,108,108,108,108,127,0,0,
0,24,24,31,24,31,0,0,
0,0,0,0,0,31,24,24,
24,24,24,24,24,248,0,0,
0,24,24,24,24,255,0,0,
0,0,0,0,0,255,24,24,
24,24,24,24,24,248,24,24,
24,0,0,0,0,255,0,0,
0,24,24,24,24,255,24,24,
24,24,24,248,24,248,24,24,
24,108,108,108,108,236,108,108,
108,108,108,236,12,252,0,0,
0,0,0,252,12,236,108,108,
108,108,108,239,0,255,0,0,
0,0,0,255,0,239,108,108,
108,108,108,236,12,236,108,108,
108,0,0,255,0,255,0,0,
0,108,108,239,0,239,108,108,
108,24,24,255,0,255,0,0,
0,108,108,108,108,255,0,0,
0,0,0,255,0,255,24,24,
24,0,0,0,0,255,108,108,
108,108,108,108,108,252,0,0,
0,24,24,248,24,248,0,0,
0,0,0,248,24,248,24,24,
24,0,0,0,0,252,108,108,
108,108,108,108,108,255,108,108,
108,24,24,255,24,255,24,24,
24,24,24,24,24,31,0,0,
0,0,0,0,0,248,24,24,
24,255,255,255,255,255,255,255,
255,0,0,0,0,255,255,255,
255,15,15,15,15,15,15,15,
15,240,240,240,240,240,240,240,
240,255,255,255,255,0,0,0,
0,0,0,110,59,19,59,110,
0,0,30,51,31,51,31,3,
3,0,63,51,3,3,3,3,
0,0,127,54,54,54,54,54,
0,63,51,6,12,6,51,63,
0,0,0,126,27,27,27,14,
0,0,102,102,102,102,62,6,
3,0,110,59,24,24,24,24,
0,63,12,30,51,51,30,12,
63,28,54,99,127,99,54,28,
0,28,54,99,99,54,54,119,
0,56,12,24,62,51,51,30,
0,0,0,126,219,219,126,0,
0,96,48,126,219,219,126,6,
3,28,6,3,31,3,6,28,
0,30,51,51,51,51,51,51,
0,0,63,0,63,0,63,0,
0,12,12,63,12,12,0,63,
0,6,12,24,12,6,0,63,
0,24,12,6,12,24,0,63,
0,112,216,216,24,24,24,24,
24,24,24,24,24,24,27,27,
14,12,12,0,63,0,12,12,
0,0,110,59,0,110,59,0,
0,28,54,54,28,0,0,0,
0,0,0,0,24,24,0,0,
0,0,0,0,0,24,0,0,
0,240,48,48,48,55,54,60,
56,30,54,54,54,54,0,0,
0,14,24,12,6,30,0,0,
0,0,0,60,60,60,60,0,
0,0,0,0,0,0,0,0,0
};

Wyświetl plik

@ -1,119 +0,0 @@
#include <stdint.h>
#include <string.h>
#ifdef MEGA
#include <Arduino.h>
#include <TimerOne.h>
#else
#include "pico.h"
#include "pico/stdlib.h"
struct repeating_timer timer;
#endif
#define PIT_MODE_LATCHCOUNT 0
#define PIT_MODE_LOBYTE 1
#define PIT_MODE_HIBYTE 2
#define PIT_MODE_TOGGLE 3
struct i8253_s {
uint16_t chandata[3];
uint8_t accessmode[3];
uint8_t bytetoggle[3];
uint32_t effectivedata[3];
float chanfreq[3];
uint8_t active[3];
uint16_t counter[3];
} i8253;
volatile uint8_t timerTick = 0;
#ifdef MEGA
void timer_isr() {
timerTick = 1;
}
#else
static bool timer_isr(struct repeating_timer *t) {
timerTick = 1;
return true;
}
#endif
void out8253 (uint16_t portnum, uint8_t value) {
uint8_t curbyte;
portnum &= 3;
switch (portnum) {
case 0:
case 1:
case 2: //channel data
if ( (i8253.accessmode[portnum] == PIT_MODE_LOBYTE) || ( (i8253.accessmode[portnum] == PIT_MODE_TOGGLE) && (i8253.bytetoggle[portnum] == 0) ) ) curbyte = 0;
else if ( (i8253.accessmode[portnum] == PIT_MODE_HIBYTE) || ( (i8253.accessmode[portnum] == PIT_MODE_TOGGLE) && (i8253.bytetoggle[portnum] == 1) ) ) curbyte = 1;
if (curbyte == 0) { //low byte
i8253.chandata[portnum] = (i8253.chandata[portnum] & 0xFF00) | value;
}
else { //high byte
i8253.chandata[portnum] = (i8253.chandata[portnum] & 0x00FF) | ( (uint16_t) value << 8);
}
if (i8253.chandata[portnum] == 0) i8253.effectivedata[portnum] = 65536;
else i8253.effectivedata[portnum] = i8253.chandata[portnum];
i8253.active[portnum] = 1;
if (i8253.accessmode[portnum] == PIT_MODE_TOGGLE) i8253.bytetoggle[portnum] = (~i8253.bytetoggle[portnum]) & 1;
//i8253.chanfreq[portnum] = (float) ( (uint32_t) ( ( (float) 1193182.0 / (float) i8253.effectivedata[portnum]) * (float) 1000.0) );
//Serial.print("period "); Serial.println((uint32_t) ((float)1000000.0 / ( ( (float) 1193182.0 / (float) i8253.effectivedata[portnum]))));
if (portnum == 0) {
uint32_t period;
period = (uint32_t) ((float)1000000.0 / ( ( (float) 1193182.0 / (float) i8253.effectivedata[portnum])));
#ifdef MEGA
if (period < 4000) period = 4000; //limit to 250 Hz, or the emulator just can't keep up on a Mega
//Serial.println((float)1000000.0 / (float)period);
Timer1.attachInterrupt(timer_isr, period);
#else
cancel_repeating_timer (&timer);
add_repeating_timer_us(period, timer_isr, NULL, &timer);
#endif
}
break;
case 3: //mode/command
i8253.accessmode[value>>6] = (value >> 4) & 3;
if (i8253.accessmode[value>>6] == PIT_MODE_TOGGLE) i8253.bytetoggle[value>>6] = 0;
break;
}
}
uint8_t in8253 (uint16_t portnum) {
uint8_t curbyte;
portnum &= 3;
switch (portnum) {
case 0:
case 1:
case 2: //channel data
if ( (i8253.accessmode[portnum] == 0) || (i8253.accessmode[portnum] == PIT_MODE_LOBYTE) || ( (i8253.accessmode[portnum] == PIT_MODE_TOGGLE) && (i8253.bytetoggle[portnum] == 0) ) ) curbyte = 0;
else if ( (i8253.accessmode[portnum] == PIT_MODE_HIBYTE) || ( (i8253.accessmode[portnum] == PIT_MODE_TOGGLE) && (i8253.bytetoggle[portnum] == 1) ) ) curbyte = 1;
if ( (i8253.accessmode[portnum] == 0) || (i8253.accessmode[portnum] == PIT_MODE_LOBYTE) || ( (i8253.accessmode[portnum] == PIT_MODE_TOGGLE) && (i8253.bytetoggle[portnum] == 0) ) ) curbyte = 0;
else if ( (i8253.accessmode[portnum] == PIT_MODE_HIBYTE) || ( (i8253.accessmode[portnum] == PIT_MODE_TOGGLE) && (i8253.bytetoggle[portnum] == 1) ) ) curbyte = 1;
if ( (i8253.accessmode[portnum] == 0) || (i8253.accessmode[portnum] == PIT_MODE_TOGGLE) ) i8253.bytetoggle[portnum] = (~i8253.bytetoggle[portnum]) & 1;
if (curbyte == 0) { //low byte
if (i8253.counter[portnum] < 10) i8253.counter[portnum] = i8253.chandata[portnum];
i8253.counter[portnum] -= 10;
return ( (uint8_t) i8253.counter[portnum]);
}
else { //high byte
return ( (uint8_t) (i8253.counter[portnum] >> 8) );
}
break;
}
return (0);
}
void init8253() {
memset (&i8253, 0, sizeof (i8253) );
#ifdef MEGA
Timer1.initialize(54925);
Timer1.attachInterrupt(timer_isr, 54925);
#else
add_repeating_timer_us(54925, timer_isr, NULL, &timer);
#endif
//set_port_write_redirector (0x40, 0x43, &out8253);
//set_port_read_redirector (0x40, 0x43, &in8253);
}

Wyświetl plik

@ -1,83 +0,0 @@
/* i8259.c - emulation code for the Intel 8259 controller.
Note: This is not a very complete i8259 interrupt controller
implementation, but for the purposes of a PC, it's all we need. */
#include <stdint.h>
#include <string.h>
struct structpic {
uint8_t imr; //mask register
uint8_t irr; //request register
uint8_t isr; //service register
uint8_t icwstep; //used during initialization to keep track of which ICW we're at
uint8_t icw[5];
uint8_t intoffset; //interrupt vector offset
uint8_t priority; //which IRQ has highest priority
uint8_t autoeoi; //automatic EOI mode
uint8_t readmode; //remember what to return on read register from OCW3
uint8_t enabled;
} i8259;
void init8259() {
memset((void *)&i8259, 0, sizeof(i8259));
}
uint8_t in8259(uint16_t portnum) {
switch (portnum & 1) {
case 0:
if (i8259.readmode==0) return(i8259.irr); else return(i8259.isr);
case 1: //read mask register
return(i8259.imr);
}
return(0); //can't get here, but the compiler bitches
}
extern uint32_t makeupticks;
void out8259(uint16_t portnum, uint8_t value) {
uint8_t i;
switch (portnum & 1) {
case 0:
if (value & 0x10) { //begin initialization sequence
i8259.icwstep = 1;
i8259.imr = 0; //clear interrupt mask register
i8259.icw[i8259.icwstep++] = value;
return;
}
if ((value & 0x98)==8) { //it's an OCW3
if (value & 2) i8259.readmode = value & 2;
}
if (value & 0x20) { //EOI command
for (i=0; i<8; i++)
if ((i8259.isr >> i) & 1) {
i8259.isr ^= (1 << i);
if ((i==0) && (makeupticks>0)) { makeupticks = 0; i8259.irr |= 1; }
return;
}
}
break;
case 1:
if ((i8259.icwstep==3) && (i8259.icw[1] & 2)) i8259.icwstep = 4; //single mode, so don't read ICW3
if (i8259.icwstep<5) { i8259.icw[i8259.icwstep++] = value; return; }
//if we get to this point, this is just a new IMR value
i8259.imr = value;
break;
}
}
uint8_t nextintr() {
uint8_t i, tmpirr;
tmpirr = i8259.irr & (~i8259.imr); //XOR request register with inverted mask register
for (i=0; i<8; i++)
if ((tmpirr >> i) & 1) {
i8259.irr ^= (1 << i);
i8259.isr |= (1 << i);
return(i8259.icw[2] + i);
}
return(0); //can't get here, but the compiler bitches
}
void doirq(uint8_t irqnum) {
i8259.irr |= (1 << irqnum);
}

Wyświetl plik

@ -1,146 +0,0 @@
#include <stdint.h>
#include <string.h>
#include "emu.h"
#ifdef USE_ENC28J60
#include <enc28j60.h>
byte ENC28J60::buffer[1514];
//uint8_t net_mac[6] = { 0x90, 0xAD, 0xBE, 0xEF, 0x13, 0x37 };
uint8_t net_mac[6] = { 0x2C, 0xFD, 0x13, 0x37, 0x13, 0x37 };
extern union _bytewordregs_ regs;
extern uint16_t segregs[6];
struct netstruct {
uint8_t enabled;
uint8_t canrecv;
uint16_t pktlen;
} net;
void net_handler() {
uint32_t i;
uint16_t j;
//if (ethif==254) return; //networking not enabled
switch (regs.byteregs[regah]) { //function number
case 0x00: //enable packet reception
net.enabled = 1;
net.canrecv = 1;
return;
case 0x01: //send packet of CX at DS:SI
//if (verbose) {
//Serial.println("Sending packet of %u bytes.", regs.wordregs[regcx]);
//}
//sendpkt (&RAM[ ( (uint32_t) segregs[regds] << 4) + (uint32_t) regs.wordregs[regsi]], regs.wordregs[regcx]);
i = ( (uint32_t) segregs[regds] << 4) + (uint32_t) regs.wordregs[regsi];
for (j=0; j<net.pktlen; j++) {
ENC28J60::buffer[j] = read86(i++);
}
SPI.setClockDivider(SPI_CLOCK_ENC28J60);
ENC28J60::packetSend(segregs[regcx]);
SPI.setClockDivider(SPI_CLOCK_SPIRAM);
return;
case 0x02: //return packet info (packet buffer in DS:SI, length in CX)
segregs[regds] = 0xD000;
regs.wordregs[regsi] = 0x0000;
regs.wordregs[regcx] = net.pktlen;
return;
case 0x03: //copy packet to final destination (given in ES:DI)
//memcpy (&RAM[ ( (uint32_t) segregs[reges] << 4) + (uint32_t) regs.wordregs[regdi]], &RAM[0xD0000], net.pktlen);
i = ( (uint32_t) segregs[reges] << 4) + (uint32_t) regs.wordregs[regdi];
for (j=0; j<net.pktlen; j++) {
write86(i++, ENC28J60::buffer[j]);
}
net.canrecv = 1;
net.pktlen = 0;
return;
case 0x04: //disable packets
net.enabled = 0;
net.canrecv = 0;
return;
case 0x05: //DEBUG: dump packet (DS:SI) of CX bytes to stdout
/*for (i=0; i<regs.wordregs[regcx]; i++) {
printf ("%c", RAM[ ( (uint32_t) segregs[regds] << 4) + (uint32_t) regs.wordregs[regsi] + i]);
}*/
return;
case 0x06: //DEBUG: print milestone string
//print("PACKET DRIVER MILESTONE REACHED\n");
return;
}
}
uint8_t net_read_ram(uint32_t addr32) {
if (addr32 < 1514) return ENC28J60::buffer[addr32];
return 0;
}
/*void net_write_ram(uint32_t addr32, uint8_t value) {
if (addr32 < 1514) ENC28J60::buffer[addr32] = value;
}*/
void net_loop() {
uint16_t i, len;
uint8_t cc;
if (!net.enabled || !net.canrecv) return;
SPI.setClockDivider(SPI_CLOCK_ENC28J60);
len = ENC28J60::packetReceive();
SPI.setClockDivider(SPI_CLOCK_SPIRAM);
if (len > 0) {
for (i=0; i<len; i++) {
Serial.print(ENC28J60::buffer[i], HEX);
Serial.write(' ');
}
Serial.println("");
Serial.println("");
net.canrecv = 0;
net.pktlen = len;
doirq(6);
}
}
void net_init() {
uint8_t ret;
Serial.println("enter net_init");
//SPI.setClockDivider(SPI_CLOCK_ENC28J60);
ret = ENC28J60::initialize(1514, net_mac, NET_PIN);
//SPI.setClockDivider(SPI_CLOCK_LCD);
Serial.print("net init result = ");
Serial.println(ret);
ENC28J60::enablePromiscuous();
//ENC28J60::broadcast_enabled = true;
while(1) {
uint16_t len, i;
//delay(100);
//SPI.setClockDivider(SPI_CLOCK_ENC28J60);
len = ENC28J60::packetReceive();
//SPI.setClockDivider(SPI_CLOCK_LCD);
if (len > 0) {
for (i=0; i<len; i++) {
Serial.print(ENC28J60::buffer[i], HEX);
Serial.write(' ');
}
Serial.println("");
Serial.println("");
}
}
}
#else
uint8_t net_mac[6] = { 0x2C, 0xFD, 0x13, 0x37, 0x13, 0x37 };
void net_init() {
}
void net_loop() {
}
void net_handler() {
}
uint8_t net_read_ram(uint32_t addr32) {
return 0;
}
#endif

Wyświetl plik

@ -1,664 +0,0 @@
#include "pico.h"
#include "pico/stdlib.h"
#include <stdio.h>
#include <string.h>
#include "emu.h"
#include "ps2.h"
static uint8_t LOMEM[NATIVE_RAM];
#ifdef HAS_PSRAM
#include "psram_t.h"
PSRAM_T psram = PSRAM_T(PSRAM_CS, PSRAM_MOSI, PSRAM_SCLK, PSRAM_MISO);
#else
static uint8_t HIMEM[RAM_SIZE-NATIVE_RAM];
#endif
extern void write_loram(int address, uint8_t val) {
LOMEM[address] = val;
}
extern uint8_t read_loram(int address) {
return LOMEM[address];
}
extern void write_hiram(int address, uint8_t val) {
#ifdef HAS_PSRAM
psram.pswrite(address,val);
#else
HIMEM[address] = val;
#endif
}
extern uint8_t read_hiram(int address) {
#ifdef HAS_PSRAM
return (psram.psread(address));
#else
return HIMEM[address];
#endif
}
#define PALMULT8(x) ((x)<<5)
#define RGBVAL16(r,g,b) ( (((r>>3)&0x1f)<<11) | (((g>>2)&0x3f)<<5) | (((b>>3)&0x1f)<<0) )
struct i8253_s {
uint16_t chandata[3];
uint8_t accessmode[3];
uint8_t bytetoggle[3];
uint32_t effectivedata[3];
float chanfreq[3];
uint8_t active[3];
uint16_t counter[3];
};
extern struct i8253_s i8253;
void doirq(uint8_t irqnum);
void write86(uint32_t addr32, uint8_t value);
uint8_t read86(uint32_t addr32);
uint8_t curkey = 0;
uint8_t VRAM[16384];
uint32_t updateaddrs[64];
uint8_t updatepos = 0;
void VRAM_write(uint32_t addr32, uint8_t value) {
if (addr32 < 16384) {
VRAM[addr32] = value;
//printf("%d %d\n",addr32,value);
}
}
uint8_t VRAM_read(uint32_t addr32) {
if (addr32 < 16384) return VRAM[addr32];
return 0;
}
uint8_t ansicolor[16] = { 0, 4, 2, 6, 1, 5, 3, 7, 0, 4, 2, 6, 1, 5, 3, 7 };
uint16_t palettecga[16], palettevga[256];
void installPalette(void) {
palettecga[0] = RGBVAL16(0, 0, 0);
palettecga[1] = RGBVAL16(0, 0, 0xAA);
palettecga[2] = RGBVAL16(0, 0xAA, 0);
palettecga[3] = RGBVAL16(0, 0xAA, 0xAA);
palettecga[4] = RGBVAL16(0xAA, 0, 0);
palettecga[5] = RGBVAL16(0xAA, 0, 0xAA);
palettecga[6] = RGBVAL16(0xAA, 0x55, 0);
palettecga[7] = RGBVAL16(0xAA, 0xAA, 0xAA);
palettecga[8] = RGBVAL16(0x55, 0x55, 0x55);
palettecga[9] = RGBVAL16(0x55, 0x55, 0xFF);
palettecga[10] = RGBVAL16(0x55, 0xFF, 0x55);
palettecga[11] = RGBVAL16(0x55, 0xFF, 0xFF);
palettecga[12] = RGBVAL16(0xFF, 0x55, 0x55);
palettecga[13] = RGBVAL16(0xFF, 0x55, 0xFF);
palettecga[14] = RGBVAL16(0xFF, 0xFF, 0x55);
palettecga[15] = RGBVAL16(0xFF, 0xFF, 0xFF);
palettevga[0] = RGBVAL16(0, 0, 0);
palettevga[1] = RGBVAL16(0, 0, 169);
palettevga[2] = RGBVAL16(0, 169, 0);
palettevga[3] = RGBVAL16(0, 169, 169);
palettevga[4] = RGBVAL16(169, 0, 0);
palettevga[5] = RGBVAL16(169, 0, 169);
palettevga[6] = RGBVAL16(169, 169, 0);
palettevga[7] = RGBVAL16(169, 169, 169);
palettevga[8] = RGBVAL16(0, 0, 84);
palettevga[9] = RGBVAL16(0, 0, 255);
palettevga[10] = RGBVAL16(0, 169, 84);
palettevga[11] = RGBVAL16(0, 169, 255);
palettevga[12] = RGBVAL16(169, 0, 84);
palettevga[13] = RGBVAL16(169, 0, 255);
palettevga[14] = RGBVAL16(169, 169, 84);
palettevga[15] = RGBVAL16(169, 169, 255);
palettevga[16] = RGBVAL16(0, 84, 0);
palettevga[17] = RGBVAL16(0, 84, 169);
palettevga[18] = RGBVAL16(0, 255, 0);
palettevga[19] = RGBVAL16(0, 255, 169);
palettevga[20] = RGBVAL16(169, 84, 0);
palettevga[21] = RGBVAL16(169, 84, 169);
palettevga[22] = RGBVAL16(169, 255, 0);
palettevga[23] = RGBVAL16(169, 255, 169);
palettevga[24] = RGBVAL16(0, 84, 84);
palettevga[25] = RGBVAL16(0, 84, 255);
palettevga[26] = RGBVAL16(0, 255, 84);
palettevga[27] = RGBVAL16(0, 255, 255);
palettevga[28] = RGBVAL16(169, 84, 84);
palettevga[29] = RGBVAL16(169, 84, 255);
palettevga[30] = RGBVAL16(169, 255, 84);
palettevga[31] = RGBVAL16(169, 255, 255);
palettevga[32] = RGBVAL16(84, 0, 0);
palettevga[33] = RGBVAL16(84, 0, 169);
palettevga[34] = RGBVAL16(84, 169, 0);
palettevga[35] = RGBVAL16(84, 169, 169);
palettevga[36] = RGBVAL16(255, 0, 0);
palettevga[37] = RGBVAL16(255, 0, 169);
palettevga[38] = RGBVAL16(255, 169, 0);
palettevga[39] = RGBVAL16(255, 169, 169);
palettevga[40] = RGBVAL16(84, 0, 84);
palettevga[41] = RGBVAL16(84, 0, 255);
palettevga[42] = RGBVAL16(84, 169, 84);
palettevga[43] = RGBVAL16(84, 169, 255);
palettevga[44] = RGBVAL16(255, 0, 84);
palettevga[45] = RGBVAL16(255, 0, 255);
palettevga[46] = RGBVAL16(255, 169, 84);
palettevga[47] = RGBVAL16(255, 169, 255);
palettevga[48] = RGBVAL16(84, 84, 0);
palettevga[49] = RGBVAL16(84, 84, 169);
palettevga[50] = RGBVAL16(84, 255, 0);
palettevga[51] = RGBVAL16(84, 255, 169);
palettevga[52] = RGBVAL16(255, 84, 0);
palettevga[53] = RGBVAL16(255, 84, 169);
palettevga[54] = RGBVAL16(255, 255, 0);
palettevga[55] = RGBVAL16(255, 255, 169);
palettevga[56] = RGBVAL16(84, 84, 84);
palettevga[57] = RGBVAL16(84, 84, 255);
palettevga[58] = RGBVAL16(84, 255, 84);
palettevga[59] = RGBVAL16(84, 255, 255);
palettevga[60] = RGBVAL16(255, 84, 84);
palettevga[61] = RGBVAL16(255, 84, 255);
palettevga[62] = RGBVAL16(255, 255, 84);
palettevga[63] = RGBVAL16(255, 255, 255);
palettevga[64] = RGBVAL16(255, 125, 125);
palettevga[65] = RGBVAL16(255, 157, 125);
palettevga[66] = RGBVAL16(255, 190, 125);
palettevga[67] = RGBVAL16(255, 222, 125);
palettevga[68] = RGBVAL16(255, 255, 125);
palettevga[69] = RGBVAL16(222, 255, 125);
palettevga[70] = RGBVAL16(190, 255, 125);
palettevga[71] = RGBVAL16(157, 255, 125);
palettevga[72] = RGBVAL16(125, 255, 125);
palettevga[73] = RGBVAL16(125, 255, 157);
palettevga[74] = RGBVAL16(125, 255, 190);
palettevga[75] = RGBVAL16(125, 255, 222);
palettevga[76] = RGBVAL16(125, 255, 255);
palettevga[77] = RGBVAL16(125, 222, 255);
palettevga[78] = RGBVAL16(125, 190, 255);
palettevga[79] = RGBVAL16(125, 157, 255);
palettevga[80] = RGBVAL16(182, 182, 255);
palettevga[81] = RGBVAL16(198, 182, 255);
palettevga[82] = RGBVAL16(218, 182, 255);
palettevga[83] = RGBVAL16(234, 182, 255);
palettevga[84] = RGBVAL16(255, 182, 255);
palettevga[85] = RGBVAL16(255, 182, 234);
palettevga[86] = RGBVAL16(255, 182, 218);
palettevga[87] = RGBVAL16(255, 182, 198);
palettevga[88] = RGBVAL16(255, 182, 182);
palettevga[89] = RGBVAL16(255, 198, 182);
palettevga[90] = RGBVAL16(255, 218, 182);
palettevga[91] = RGBVAL16(255, 234, 182);
palettevga[92] = RGBVAL16(255, 255, 182);
palettevga[93] = RGBVAL16(234, 255, 182);
palettevga[94] = RGBVAL16(218, 255, 182);
palettevga[95] = RGBVAL16(198, 255, 182);
palettevga[96] = RGBVAL16(182, 255, 182);
palettevga[97] = RGBVAL16(182, 255, 198);
palettevga[98] = RGBVAL16(182, 255, 218);
palettevga[99] = RGBVAL16(182, 255, 234);
palettevga[100] = RGBVAL16(182, 255, 255);
palettevga[101] = RGBVAL16(182, 234, 255);
palettevga[102] = RGBVAL16(182, 218, 255);
palettevga[103] = RGBVAL16(182, 198, 255);
palettevga[104] = RGBVAL16(0, 0, 113);
palettevga[105] = RGBVAL16(28, 0, 113);
palettevga[106] = RGBVAL16(56, 0, 113);
palettevga[107] = RGBVAL16(84, 0, 113);
palettevga[108] = RGBVAL16(113, 0, 113);
palettevga[109] = RGBVAL16(113, 0, 84);
palettevga[110] = RGBVAL16(113, 0, 56);
palettevga[111] = RGBVAL16(113, 0, 28);
palettevga[112] = RGBVAL16(113, 0, 0);
palettevga[113] = RGBVAL16(113, 28, 0);
palettevga[114] = RGBVAL16(113, 56, 0);
palettevga[115] = RGBVAL16(113, 84, 0);
palettevga[116] = RGBVAL16(113, 113, 0);
palettevga[117] = RGBVAL16(84, 113, 0);
palettevga[118] = RGBVAL16(56, 113, 0);
palettevga[119] = RGBVAL16(28, 113, 0);
palettevga[120] = RGBVAL16(0, 113, 0);
palettevga[121] = RGBVAL16(0, 113, 28);
palettevga[122] = RGBVAL16(0, 113, 56);
palettevga[123] = RGBVAL16(0, 113, 84);
palettevga[124] = RGBVAL16(0, 113, 113);
palettevga[125] = RGBVAL16(0, 84, 113);
palettevga[126] = RGBVAL16(0, 56, 113);
palettevga[127] = RGBVAL16(0, 28, 113);
palettevga[128] = RGBVAL16(56, 56, 113);
palettevga[129] = RGBVAL16(68, 56, 113);
palettevga[130] = RGBVAL16(84, 56, 113);
palettevga[131] = RGBVAL16(97, 56, 113);
palettevga[132] = RGBVAL16(113, 56, 113);
palettevga[133] = RGBVAL16(113, 56, 97);
palettevga[134] = RGBVAL16(113, 56, 84);
palettevga[135] = RGBVAL16(113, 56, 68);
palettevga[136] = RGBVAL16(113, 56, 56);
palettevga[137] = RGBVAL16(113, 68, 56);
palettevga[138] = RGBVAL16(113, 84, 56);
palettevga[139] = RGBVAL16(113, 97, 56);
palettevga[140] = RGBVAL16(113, 113, 56);
palettevga[141] = RGBVAL16(97, 113, 56);
palettevga[142] = RGBVAL16(84, 113, 56);
palettevga[143] = RGBVAL16(68, 113, 56);
palettevga[144] = RGBVAL16(56, 113, 56);
palettevga[145] = RGBVAL16(56, 113, 68);
palettevga[146] = RGBVAL16(56, 113, 84);
palettevga[147] = RGBVAL16(56, 113, 97);
palettevga[148] = RGBVAL16(56, 113, 113);
palettevga[149] = RGBVAL16(56, 97, 113);
palettevga[150] = RGBVAL16(56, 84, 113);
palettevga[151] = RGBVAL16(56, 68, 113);
palettevga[152] = RGBVAL16(80, 80, 113);
palettevga[153] = RGBVAL16(89, 80, 113);
palettevga[154] = RGBVAL16(97, 80, 113);
palettevga[155] = RGBVAL16(105, 80, 113);
palettevga[156] = RGBVAL16(113, 80, 113);
palettevga[157] = RGBVAL16(113, 80, 105);
palettevga[158] = RGBVAL16(113, 80, 97);
palettevga[159] = RGBVAL16(113, 80, 89);
palettevga[160] = RGBVAL16(113, 80, 80);
palettevga[161] = RGBVAL16(113, 89, 80);
palettevga[162] = RGBVAL16(113, 97, 80);
palettevga[163] = RGBVAL16(113, 105, 80);
palettevga[164] = RGBVAL16(113, 113, 80);
palettevga[165] = RGBVAL16(105, 113, 80);
palettevga[166] = RGBVAL16(97, 113, 80);
palettevga[167] = RGBVAL16(89, 113, 80);
palettevga[168] = RGBVAL16(80, 113, 80);
palettevga[169] = RGBVAL16(80, 113, 89);
palettevga[170] = RGBVAL16(80, 113, 97);
palettevga[171] = RGBVAL16(80, 113, 105);
palettevga[172] = RGBVAL16(80, 113, 113);
palettevga[173] = RGBVAL16(80, 105, 113);
palettevga[174] = RGBVAL16(80, 97, 113);
palettevga[175] = RGBVAL16(80, 89, 113);
palettevga[176] = RGBVAL16(0, 0, 64);
palettevga[177] = RGBVAL16(16, 0, 64);
palettevga[178] = RGBVAL16(32, 0, 64);
palettevga[179] = RGBVAL16(48, 0, 64);
palettevga[180] = RGBVAL16(64, 0, 64);
palettevga[181] = RGBVAL16(64, 0, 48);
palettevga[182] = RGBVAL16(64, 0, 32);
palettevga[183] = RGBVAL16(64, 0, 16);
palettevga[184] = RGBVAL16(64, 0, 0);
palettevga[185] = RGBVAL16(64, 16, 0);
palettevga[186] = RGBVAL16(64, 32, 0);
palettevga[187] = RGBVAL16(64, 48, 0);
palettevga[188] = RGBVAL16(64, 64, 0);
palettevga[189] = RGBVAL16(48, 64, 0);
palettevga[190] = RGBVAL16(32, 64, 0);
palettevga[191] = RGBVAL16(16, 64, 0);
palettevga[192] = RGBVAL16(0, 64, 0);
palettevga[193] = RGBVAL16(0, 64, 16);
palettevga[194] = RGBVAL16(0, 64, 32);
palettevga[195] = RGBVAL16(0, 64, 48);
palettevga[196] = RGBVAL16(0, 64, 64);
palettevga[197] = RGBVAL16(0, 48, 64);
palettevga[198] = RGBVAL16(0, 32, 64);
palettevga[199] = RGBVAL16(0, 16, 64);
palettevga[200] = RGBVAL16(32, 32, 64);
palettevga[201] = RGBVAL16(40, 32, 64);
palettevga[202] = RGBVAL16(48, 32, 64);
palettevga[203] = RGBVAL16(56, 32, 64);
palettevga[204] = RGBVAL16(64, 32, 64);
palettevga[205] = RGBVAL16(64, 32, 56);
palettevga[206] = RGBVAL16(64, 32, 48);
palettevga[207] = RGBVAL16(64, 32, 40);
palettevga[208] = RGBVAL16(64, 32, 32);
palettevga[209] = RGBVAL16(64, 40, 32);
palettevga[210] = RGBVAL16(64, 48, 32);
palettevga[211] = RGBVAL16(64, 56, 32);
palettevga[212] = RGBVAL16(64, 64, 32);
palettevga[213] = RGBVAL16(56, 64, 32);
palettevga[214] = RGBVAL16(48, 64, 32);
palettevga[215] = RGBVAL16(40, 64, 32);
palettevga[216] = RGBVAL16(32, 64, 32);
palettevga[217] = RGBVAL16(32, 64, 40);
palettevga[218] = RGBVAL16(32, 64, 48);
palettevga[219] = RGBVAL16(32, 64, 56);
palettevga[220] = RGBVAL16(32, 64, 64);
palettevga[221] = RGBVAL16(32, 56, 64);
palettevga[222] = RGBVAL16(32, 48, 64);
palettevga[223] = RGBVAL16(32, 40, 64);
palettevga[224] = RGBVAL16(44, 44, 64);
palettevga[225] = RGBVAL16(48, 44, 64);
palettevga[226] = RGBVAL16(52, 44, 64);
palettevga[227] = RGBVAL16(60, 44, 64);
palettevga[228] = RGBVAL16(64, 44, 64);
palettevga[229] = RGBVAL16(64, 44, 60);
palettevga[230] = RGBVAL16(64, 44, 52);
palettevga[231] = RGBVAL16(64, 44, 48);
palettevga[232] = RGBVAL16(64, 44, 44);
palettevga[233] = RGBVAL16(64, 48, 44);
palettevga[234] = RGBVAL16(64, 52, 44);
palettevga[235] = RGBVAL16(64, 60, 44);
palettevga[236] = RGBVAL16(64, 64, 44);
palettevga[237] = RGBVAL16(60, 64, 44);
palettevga[238] = RGBVAL16(52, 64, 44);
palettevga[239] = RGBVAL16(48, 64, 44);
palettevga[240] = RGBVAL16(44, 64, 44);
palettevga[241] = RGBVAL16(44, 64, 48);
palettevga[242] = RGBVAL16(44, 64, 52);
palettevga[243] = RGBVAL16(44, 64, 60);
palettevga[244] = RGBVAL16(44, 64, 64);
palettevga[245] = RGBVAL16(44, 60, 64);
palettevga[246] = RGBVAL16(44, 52, 64);
palettevga[247] = RGBVAL16(44, 48, 64);
palettevga[248] = RGBVAL16(0, 0, 0);
palettevga[249] = RGBVAL16(0, 0, 0);
palettevga[250] = RGBVAL16(0, 0, 0);
palettevga[251] = RGBVAL16(0, 0, 0);
palettevga[252] = RGBVAL16(0, 0, 0);
palettevga[253] = RGBVAL16(0, 0, 0);
palettevga[254] = RGBVAL16(0, 0, 0);
palettevga[255] = RGBVAL16(0, 0, 0);
}
extern uint8_t vidmode, portram[0x400];
#define XRES_MAX 640
#define XRES_HI 640
#define XRES_LO 320
#define YRES 200
#include "font.h"
static unsigned short line[XRES_MAX];
void drawscreentext80(void) {
uint16_t row, col, y, x, xpos;
uint16_t fontdata;
for (y=0; y<(25*8); y++)
{
row = y>>3;
uint8_t * vrampt=&VRAM[160*row];
xpos = 0;
for (col=0; col<80; col++)
{
uint8_t bold, attrib, cc, bg, fg;
cc = *vrampt++;
attrib = *vrampt++;
bg = (attrib >> 4) & 7;
fg = attrib & 0x0F;
//if (y == 0) {printf("0x%02X",cc);}
fontdata = ROM_READ(font, ((uint32_t)cc << 3) + (y&0x7));
for (x=0; x<8; x++)
//for (x=0; x<4; x++)
{
if (fontdata & 1) {
line[xpos++] = palettecga[fg];
} else {
line[xpos++] = palettecga[bg];
}
fontdata >>= 1;
//fontdata >>= 2;
}
}
emu_DrawLine16(&line[0], XRES_HI, YRES, y);
}
}
void drawscreenlorescga(void) {
uint16_t y, x, xpos;
uint8_t intensity, usepal;
uint16_t color;
usepal = (portram[0x3D9]>>5) & 1;
intensity = ( (portram[0x3D9]>>4) & 1) << 3;
for (y=0; y<(25*8); y++)
{
xpos = 0;
for (x=0; x<XRES_LO; x++)
{
int ychar = y;// >> 1;
int xchar = x;// >> 1;
uint8_t curchar = VRAM[((ychar & 1) * 8192 + (ychar >> 1) * 80 + (xchar >> 2))];
switch (xchar & 3) {
case 3: color = curchar & 3; break;
case 2: color = (curchar >> 2) & 3; break;
case 1: color = (curchar >> 4) & 3; break;
case 0: color = (curchar >> 6) & 3; break;
}
color = (color << 1) + usepal + intensity;
if (color == (usepal + intensity)) color = 0;
line[xpos++] = palettecga[color];
}
emu_DrawLine16(&line[0], XRES_LO, YRES, y);
}
}
void drawscreenhirescga(void) {
uint16_t y, x, xpos;
uint16_t color;
for (y=0; y<(25*8); y++)
{
xpos = 0;
for (x=0; x<XRES_HI; x++)
{
int ychar = y >> 1;
int xchar = x;
uint8_t curchar = VRAM[((ychar & 1) * 8192 + (ychar >> 1) * 80 + (xchar >> 3))];
color = ((curchar >> (7-(x&7))) & 1) ? 15 : 0;
line[xpos++] = palettecga[color];
}
emu_DrawLine16(&line[0], XRES_HI, YRES, y);
}
}
void updatescreen() {
switch (vidmode & 0x7F) {
case 0:
case 1:
//drawtext40(origaddr, value);
break;
case 2:
case 3:
//case 7:
drawscreentext80();
break;
case 4:
drawscreenlorescga();
break;
case 5:
drawscreenlorescga(); //change to BW function later
break;
case 6:
drawscreenhirescga();
break;
}
//printf("%d\n",vidmode & 0x7F);
}
static uint8_t nbkeys=0;
static uint8_t kcnt=0;
static int toggle=1;
static char * seq;
static char * seq1="PRINCE.BAT\r";
static char * seq2="CAT.EXE\r";
static char * seq3="y\r";
static int mouse_x = 160;
static int mouse_y = 100;
static int prev_key = 0;
static int prev_j = 0;
static int prev_mouseb = 0;
static bool isMouse = true;
static int joynum = 1;
static int hk = 0;
static int prev_hk = 0;
static int k = 0;
static void keyevent(int keysym, int isdown)
{
uint8_t scancode = translatescancode(keysym);
if (scancode != 0xFF) {
portram[0x60] = scancode;
if (!isdown) portram[0x60] |= 0x80;
portram[0x64] |= 2;
doirq(1);
}
}
extern void apc_Input(int bClick) {
hk = emu_ReadI2CKeyboard();
k = emu_ReadKeys();
if (nbkeys == 0) {
if ( (bClick & MASK_KEY_USER1) && (bClick & MASK_KEY_USER2) ) {
nbkeys = strlen(seq3);
seq=seq3;
kcnt=0;
}
else if (bClick & MASK_KEY_USER1) {
nbkeys = strlen(seq1);
seq=seq1;
kcnt=0;
}
else if (bClick & MASK_KEY_USER2) {
nbkeys = strlen(seq2);
seq=seq2;
kcnt=0;
}
}
else {
char k = seq[kcnt];
if (k == 13) keyevent(0xFF0D,toggle);
else keyevent(k,toggle);
//setKey(ascii2scan[k],toggle);
if (!toggle) {
kcnt++;
nbkeys--;
toggle = true;
}
else {
toggle = false;
}
}
}
static void do_events(void)
{
if (hk != prev_hk) {
prev_hk == hk;
if ( (hk != 0) && (hk != prev_key) ) {
prev_key = hk;
keyevent ( hk, 0 );
if (hk == 68) {
if (isMouse) isMouse = false;
else isMouse = true;
}
}
}
if ( (hk == 0) && (prev_key) ) {
keyevent ( prev_key, 1 );
prev_key = 0;
}
if (!isMouse)
{
int j = 0;
if (( k & MASK_JOY1_RIGHT) || ( k & MASK_JOY2_RIGHT)) {
j |= 0x08;
}
if (( k & MASK_JOY1_LEFT) || ( k & MASK_JOY2_LEFT)) {
j |= 0x04;
}
if (( k & MASK_JOY1_UP) || ( k & MASK_JOY2_UP)) {
j |= 0x01;
}
if (( k & MASK_JOY1_DOWN) || ( k & MASK_JOY2_DOWN)) {
j |= 0x02;
}
if ( k & MASK_JOY2_BTN) {
j |= 0x80;
}
if (j != prev_j) {
//IkbdJoystickChange(joynum,j);
prev_j = j;
}
}
else {
if (( k & MASK_JOY1_RIGHT) || ( k & MASK_JOY2_RIGHT)) {
if ( mouse_x < XRES_HI ) {
mouse_x += 1;
}
}
else if (( k & MASK_JOY1_LEFT) || ( k & MASK_JOY2_LEFT)) {
if ( mouse_x > 1 ) {
mouse_x -= 1;
}
}
else if (( k & MASK_JOY1_UP) || ( k & MASK_JOY2_UP)) {
if ( mouse_y > 1 ) {
mouse_y -= 1;
}
}
else if (( k & MASK_JOY1_DOWN) || ( k & MASK_JOY2_DOWN)) {
if ( mouse_y < YRES ) {
mouse_y += 1;
}
}
int mouseb=0;
if ( ( k & MASK_JOY2_BTN) ){
mouseb=1;
}
if ( (mouseb != prev_mouseb) ){
prev_mouseb = mouseb;
}
}
}
void emu_KeyboardOnDown(int keymodifer, int key) {
}
void emu_KeyboardOnUp(int keymodifer, int key) {
}
void apc_Step(void)
{
exec86(8000);
updatescreen();
do_events();
emu_DrawVsync();
}
void apc_Init(void)
{
#ifdef HAS_PSRAM
psram.begin();
#endif
installPalette();
init8253();
reset86();
init8259();
}
void apc_Start(char * filename)
{
emu_printf("init started");
initDisk(filename);
emu_printf("init done");
}

Wyświetl plik

@ -1,5 +0,0 @@
extern void apc_Init(void);
extern void apc_Step(void);
extern void apc_Start(char * filename);
extern void apc_Input(int click);

Wyświetl plik

@ -1,178 +0,0 @@
#include "pico.h"
#include "pico/stdlib.h"
extern "C" {
#include "iopins.h"
#include "emuapi.h"
}
#include "keyboard_osd.h"
#include "pc.h"
#include <stdio.h>
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
volatile bool vbl=true;
bool repeating_timer_callback(struct repeating_timer *t) {
if (vbl) {
vbl = false;
} else {
vbl = true;
}
return true;
}
TFT_T_DMA tft;
static int skip=0;
#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(150000, true);
stdio_init_all();
#ifdef USE_VGA
// tft.begin(VGA_MODE_400x240);
tft.begin(VGA_MODE_320x240);
#else
tft.begin();
#endif
emu_init();
while (true) {
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(15, repeating_timer_callback, NULL, &timer);
}
tft.waitSync();
}
else {
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
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;
#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);
#else
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
#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;
void emu_sndInit() {
tft.begin_audio(256, mymixer.snd_Mixer);
mymixer.start();
}
void emu_sndPlaySound(int chan, int volume, int freq)
{
if (chan < 6) {
mymixer.sound(chan, freq, volume);
}
}
void emu_sndPlayBuzz(int size, int val) {
mymixer.buzz(size,val);
}
#endif

Wyświetl plik

@ -1,98 +0,0 @@
/* ports.c - handles port I/O for Fake86 CPU core. it's ugly, will fix up later. */
#include <stdint.h>
#include "emu.h"
volatile uint16_t pit0counter = 65535;
volatile uint32_t speakercountdown, latch42, pit0latch, pit0command, pit0divisor;
uint8_t portram[0x400];
uint8_t crt_controller_idx, crt_controller[256], port3D9 = 0;
void portout(uint16_t portnum, uint16_t value) {
if (portnum < 0x400) portram[portnum] = value;
switch (portnum) {
case 0x20:
case 0x21: //i8259
out8259(portnum, value);
return;
case 0x40:
case 0x41:
case 0x42:
case 0x43: //i8253
out8253(portnum, value);
break;
case 0x3D4:
crt_controller_idx = value;
break;
case 0x3D5:
crt_controller[crt_controller_idx] = value;
if ((crt_controller_idx == 0x0E) || (crt_controller_idx == 0x0F)) {
//setcursor(((uint16_t)crt_controller[0x0E] << 8) | crt_controller[0x0F]);
//Serial.write(27); Serial.write('['); Serial.print(crt_controller[0x0E] + 1); Serial.write(';'); Serial.print(crt_controller[0x0F] + 1); Serial.write('H');
}
break;
case 0x3D9:
port3D9 = value;
break;
}
#ifdef ADVANCED_CLIENT
if ((portnum >= 0x3C0) && (portnum <= 0x3DA)) {
uint8_t chksum;
Serial.write(0xFF);
Serial.write(0x04);
outByte(portnum & 0xFF); chksum = portnum & 0xFF;
outByte(portnum >> 8); chksum += portnum >> 8;
outByte(value); chksum += value;
outByte(chksum);
Serial.write(0xFE);
Serial.write(0x02);
}
#endif
#ifdef VGA
if ((portnum >= 0x3C0) && (portnum <= 0x3DA)) outVGA(portnum, value);
#endif
}
uint16_t portin(uint16_t portnum) {
#ifdef VGA
if ((portnum >= 0x3C0) && (portnum <= 0x3DA)) return inVGA(portnum);
#endif
/* uint8_t chksum;
Serial.write(0xFF);
Serial.write(0x07);
outByte(portnum & 0xFF); chksum = portnum & 0xFF;
outByte((portnum >> 8) & 0xFF); chksum += (portnum >> 8) & 0xFF;
outByte(chksum);
Serial.write(0xFE);
Serial.write(0x02);*/
switch (portnum) {
case 0x20:
case 0x21: //i8259
return (in8259(portnum));
case 0x40:
case 0x41:
case 0x42:
case 0x43: //i8253
return in8253(portnum);
case 0x60:
case 0x64:
return portram[portnum];
case 0x3D4:
return crt_controller_idx;
break;
case 0x3D5:
return crt_controller[crt_controller_idx];
break;
case 0x3DA:
port3da ^= 1;
if (!(port3da & 1)) port3da ^= 8;
//port3da = random(256) & 9;
return (port3da);
default:
return (0xFF);
}
}

Wyświetl plik

@ -1,89 +0,0 @@
uint8_t translatescancode(uint32_t keysym) {
if ((keysym >= 'a') && (keysym <= 'z')) {
keysym -= 0x20;
}
switch (keysym) {
case 0xFF08: return 0x0E; //backspace
case 0xFF09: return 0x0F; //tab
case 0xFF0D: return 0x1C; //enter
case 0xFF1B: return 0x01; //escape
case 0xFF63: return 0x52; //KP 0 / insert
case 0xFFFF: return 0x53; //KP . / delete
case 0xFF55: return 0x49; //pgup
case 0xFF56: return 0x51; //pgdn
case 0xFF50: return 0x47; //home
case 0xFF57: return 0x4F; //end
case 'A': return 0x1E;
case 'B': return 0x30;
case 'C': return 0x2E;
case 'D': return 0x20;
case 'E': return 0x12;
case 'F': return 0x21;
case 'G': return 0x22;
case 'H': return 0x23;
case 'I': return 0x17;
case 'J': return 0x24;
case 'K': return 0x25;
case 'L': return 0x26;
case 'M': return 0x32;
case 'N': return 0x31;
case 'O': return 0x18;
case 'P': return 0x19;
case 'Q': return 0x10;
case 'R': return 0x13;
case 'S': return 0x1F;
case 'T': return 0x14;
case 'U': return 0x16;
case 'V': return 0x2F;
case 'W': return 0x11;
case 'X': return 0x2D;
case 'Y': return 0x15;
case 'Z': return 0x2C;
case '0': case ')': return 0x0B;
case '1': case '!': return 0x02;
case '2': case '@': return 0x03;
case '3': case '#': return 0x04;
case '4': case '$': return 0x05;
case '5': case '%': return 0x06;
case '6': case '^': return 0x07;
case '7': case '&': return 0x08;
case '8': case '*': return 0x09;
case '9': case '(': return 0x0A;
case '`': case '~': return 0x29;
case '-': case '_': return 0x0C;
case '=': case '+': return 0x0D;
case '[': case '{': return 0x1A;
case ']': case '}': return 0x1B;
case '\\': case '|': return 0x2B;
case ';': case ':': return 0x27;
case '\'': case '"': return 0x28;
case ' ': return 0x39;
case ',': case '<': return 0x33;
case '.': case '>': return 0x34;
case '/': case '?': return 0x35;
case 0xFFBE: return 0x3B; //F1
case 0xFFBF: return 0x3C; //F2
case 0xFFC0: return 0x3D; //F3
case 0xFFC1: return 0x3E; //F4
case 0xFFC2: return 0x3F; //F5
case 0xFFC3: return 0x40; //F6
case 0xFFC4: return 0x41; //F7
case 0xFFC5: return 0x42; //F8
case 0xFFC6: return 0x43; //F9
case 0xFFC7: return 0x44; //F10
case 0xFFC8: return 0x57; //F11
case 0xFFC9: return 0x58; //F12
case 0xFFE1: return 0x2A; //left shift
case 0xFFE2: return 0x36; //right shift
case 0xFFE3: case 0xFFE4: return 0x1D; //control
case 0xFFE9: case 0xFFEA: return 0x38; //alt
case 0xFF51: return 0x4B; //left
case 0xFF52: return 0x48; //up
case 0xFF53: return 0x4D; //right
case 0xFF54: return 0x50; //down
}
return 0xFF;
}

Plik diff jest za duży Load Diff

Wyświetl plik

@ -1,176 +0,0 @@
#include "emuapi.h"
#ifdef HAS_SND
#include "AudioPlaySystem.h"
#define SAMPLERATE AUDIO_SAMPLE_RATE_EXACT
#define CLOCKFREQ 985248
#ifndef CUSTOM_SND
static const short square[]={
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
};
const short noise[] {
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,-32767,-32767,
32767,-32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
};
#define NOISEBSIZE 0x100
typedef struct
{
unsigned int spos;
unsigned int sinc;
unsigned int vol;
} Channel;
static Channel chan[6] = {
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0} };
#endif
volatile bool playing = false;
static void snd_Reset(void)
{
#ifndef CUSTOM_SND
chan[0].vol = 0;
chan[1].vol = 0;
chan[2].vol = 0;
chan[3].vol = 0;
chan[4].vol = 0;
chan[5].vol = 0;
chan[0].sinc = 0;
chan[1].sinc = 0;
chan[2].sinc = 0;
chan[3].sinc = 0;
chan[4].sinc = 0;
chan[5].sinc = 0;
#endif
}
#ifdef CUSTOM_SND
extern "C" {
void SND_Process(void *sndbuffer, int sndn);
}
#endif
#include <stdio.h>
void AudioPlaySystem::snd_Mixer(short * stream, int len )
{
if (playing)
{
#ifdef CUSTOM_SND
//printf("s\n");
SND_Process((void*)stream, len);
#else
int i;
long s;
len = len >> 1;
short v0=chan[0].vol;
short v1=chan[1].vol;
short v2=chan[2].vol;
short v3=chan[3].vol;
short v4=chan[4].vol;
short v5=chan[5].vol;
for (i=0;i<len;i++)
{
s =((v0*square[(chan[0].spos>>8)&0x3f])>>11);
s+=((v1*square[(chan[1].spos>>8)&0x3f])>>11);
s+=((v2*square[(chan[2].spos>>8)&0x3f])>>11);
s+=((v3*noise[(chan[3].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v4*noise[(chan[4].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v5*noise[(chan[5].spos>>8)&(NOISEBSIZE-1)])>>11);
*stream++ = (short)(s);
*stream++ = (short)(s);
chan[0].spos += chan[0].sinc;
chan[1].spos += chan[1].sinc;
chan[2].spos += chan[2].sinc;
chan[3].spos += chan[3].sinc;
chan[4].spos += chan[4].sinc;
chan[5].spos += chan[5].sinc;
}
#endif
}
}
void AudioPlaySystem::begin(void)
{
this->reset();
}
void AudioPlaySystem::start(void)
{
playing = true;
}
void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
}
void AudioPlaySystem::reset(void)
{
snd_Reset();
}
void AudioPlaySystem::stop(void)
{
playing = false;
}
bool AudioPlaySystem::isPlaying(void)
{
return playing;
}
void AudioPlaySystem::sound(int C, int F, int V) {
#ifndef CUSTOM_SND
if (C < 6) {
chan[C].vol = V;
chan[C].sinc = F>>1;
}
#endif
}
void AudioPlaySystem::step(void) {
}
#endif

Wyświetl plik

@ -1,26 +0,0 @@
#ifndef audioplaysystem_h_
#define audioplaysystem_h_
#ifdef HAS_SND
#include "platform_config.h"
class AudioPlaySystem
{
public:
AudioPlaySystem(void) { };
void begin(void);
void setSampleParameters(float clockfreq, float samplerate);
void reset(void);
void start(void);
void stop(void);
bool isPlaying(void);
void sound(int C, int F, int V);
void buzz(int size, int val);
void step(void);
static void snd_Mixer(short * stream, int len );
};
#endif
#endif

Wyświetl plik

@ -1,149 +0,0 @@
#ifndef EMUAPI_H
#define EMUAPI_H
#include "platform_config.h"
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
// Title: < >
#define TITLE " ZX81/ZX80 Emulator"
#define ROMSDIR "z81"
#define emu_Init(ROM) {z81_Start(ROM); z81_Init(); }
#define emu_Step(x) {z81_Step();}
#define emu_Input(x) {z81_Input(x);}
#define PALETTE_SIZE 2
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define ACTION_NONE 0
#define ACTION_MAXKBDVAL 225
#define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129
#define ACTION_RUNVGA 130
#ifdef KEYMAP_PRESENT
/*
{25, 6,27,29,224},// vcxz<caps shift=Lshift>
{10, 9, 7,22, 4}, // gfdsa
{23,21, 8,26,20}, // trewq
{34,33,32,31,30}, // 54321
{35,36,37,38,39}, // 67890
{28,24,12,18,19}, // yuiop
{11,13,14,15,40}, // hjkl<enter>
{ 5,17,16,1,44}, // bnm. <space>
*/
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
20,26,8,21,23,28,24,12,18,19,39+64,
0, 4, 22, 7,9, 10,11,13,14,15,40,
0,29,27,6,25,5,17,16,1,44,
0,0,0,0 //up,left,right,down
};
#define keylables_map2_0 (char *)"1234567890="
#define keylables_map2_1 (char *)" $ + *- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
30,31,32,33,34,35,36,37,38,39,15+64,
0, 0,0,0,24+64,0,14+64,0,5+64,13+64,0,
0, 12+64,18+64,6+64,25+64,19+64,17+64,16+64,1+64,29+64,
36+64,34+64,37+64,35+64 //up,left,right,down
};
#define keylables_map3_0 (char *)" "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ; "
const unsigned short key_map3[] = {
0, 0,0,0,0,0,0,0,0,0,0, // Upper case
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,27+64,0,
36+64,34+64,37+64,35+64 //up,left,right,down
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#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);
extern void emu_printf(const char * text);
extern void emu_printi(int val);
extern void * emu_Malloc(int size);
extern void emu_Free(void * pt);
extern int emu_FileOpen(const char * filepath, const char * mode);
extern int emu_FileRead(void * buf, int size, int handler);
extern int emu_FileGetc(int handler);
extern int emu_FileSeek(int handler, int seek, int origin);
extern int emu_FileTell(int handler);
extern void emu_FileClose(int handler);
extern unsigned int emu_FileSize(const char * filepath);
extern unsigned int emu_LoadFile(const char * filepath, void * buf, int size);
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
extern void emu_DrawVsync(void);
extern int emu_FrameSkip(void);
extern void * emu_LineBuffer(int line);
extern void emu_InitJoysticks(void);
extern int emu_SwapJoysticks(int statusOnly);
extern unsigned short emu_DebounceLocalKeys(void);
extern int emu_ReadKeys(void);
extern int emu_GetPad(void);
extern int emu_ReadAnalogJoyX(int min, int max);
extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void);
extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key);
extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val);
extern void emu_sndInit();
extern void emu_resetus(void);
extern int emu_us(void);
extern int emu_setKeymap(int index);
extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_printh(int val);
#endif

Wyświetl plik

@ -0,0 +1,113 @@
#ifndef EMUCFG_H
#define EMUCFG_H
#define PALETTE_SIZE 2
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
//#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
#define FILEBROWSER
// Title: < >
#define TITLE " ZX81/ZX80 Emulator"
#define ROMSDIR "z81"
#define emu_Init(ROM) {z81_Start(ROM); z81_Init(); }
#define emu_Step(x) {z81_Step();}
#define emu_Input(x) {z81_Input(x);}
#ifdef KEYMAP_PRESENT
#ifdef PICOZX
const unsigned short key_map1[] = {
30,31,32,33,34,35,36,37,38,39,
20,26, 8,21,23,28,24,12,18,19,
4,22, 7, 9,10,11,13,14,15,40,
0,29,27, 6,25, 5,17,16, 0,44,
0,0,0,0,0,0
};
const unsigned short key_map2[] = {
0,0,0,24+64,34+64,35+64,36+64,37+64,18+64,0,
21+64,23+64,28+64,17+64,16+64,31+64,26+64,0,0,19+64,
0,0,0,12+64,18+64,0,13+64,14+64,15+64,40+64,
0,29+64,27+64, 6+64,25+64, 5+64,1+64,1,0,44+64,
0,0,0,0,0,0
};
// To be mapped
//30+64,0,32+64,33+64,0,0,0,0,38+64,39+64,
//20+64,0, 8+64,0,0,0,0,0,0,0,
//4+64,22+64, 7+64, 9+64,10+64,11+64,0,0,0,0,
//0, 0,0, 0,0, 0,0,0, 0,0,
//0,0,0,0,0,0
//};
const unsigned short key_map3[] = {
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short matkeys[] = {
0x104,0x101,0x108,0x102,0x110,0x120,0x140,0x204,0x201,0x208, // row 1
0x202,0x210,0x220,0x240,0x304,0x301,0x308,0x302,0x310,0x320, // row 2
0x340,0x404,0x401,0x408,0x402,0x410,0x420,0x440,0x504,0x501, // row 3
0x020,0x508,0x502,0x510,0x520,0x540,0x604,0x601,0x040,0x608, // row 4
0x008,0x001,0x002,0x010,0x620,0x640 }; // cursor keys up, left, right, down, <<<, >>>
#else
/*
{25, 6,27,29,224},// vcxz<caps shift=Lshift>
{10, 9, 7,22, 4}, // gfdsa
{23,21, 8,26,20}, // trewq
{34,33,32,31,30}, // 54321
{35,36,37,38,39}, // 67890
{28,24,12,18,19}, // yuiop
{11,13,14,15,40}, // hjkl<enter>
{ 5,17,16,1,44}, // bnm. <space>
*/
#define keylables_map1_0 (char *)"qwertyuiop\x1a"
#define keylables_map1_1 (char *)" asdfghjkl\x19"
#define keylables_map1_2 (char *)" zxcvbnm.\x10 "
const unsigned short key_map1[] = {
20,26,8,21,23,28,24,12,18,19,39+64,
0, 4, 22, 7,9, 10,11,13,14,15,40,
0,29,27,6,25,5,17,16,1,44,
0,0,0,0 //up,left,right,down
};
#define keylables_map2_0 (char *)"1234567890="
#define keylables_map2_1 (char *)" $ + *- "
#define keylables_map2_2 (char *)" ()?/\"<>,: "
const unsigned short key_map2[] = {
30,31,32,33,34,35,36,37,38,39,15+64,
0, 0,0,0,24+64,0,14+64,0,5+64,13+64,0,
0, 12+64,18+64,6+64,25+64,19+64,17+64,16+64,1+64,29+64,
36+64,34+64,37+64,35+64 //up,left,right,down
};
#define keylables_map3_0 (char *)" "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" ; "
const unsigned short key_map3[] = {
0, 0,0,0,0,0,0,0,0,0,0, // Upper case
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,27+64,0,
36+64,34+64,37+64,35+64 //up,left,right,down
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#endif
#endif

Wyświetl plik

@ -1,135 +0,0 @@
// Font: c64_lower.64c
const unsigned char font8x8[128][8] PROGMEM =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
{ 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
{ 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
{ 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
{ 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
{ 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
{ 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
{ 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
{ 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
{ 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
{ 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
{ 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
{ 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
{ 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
{ 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
{ 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
{ 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
{ 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
{ 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
{ 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
{ 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
{ 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
{ 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
{ 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (//)
{ 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
{ 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
{ 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
{ 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
{ 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
{ 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
{ 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
{ 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
{ 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
{ 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
{ 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
{ 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
{ 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
{ 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
{ 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
{ 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
{ 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
{ 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
{ 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
{ 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
{ 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
{ 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
{ 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
{ 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
{ 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
{ 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
{ 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
{ 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
{ 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
{ 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
{ 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
{ 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
{ 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
{ 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
{ 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
{ 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
{ 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
{ 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
{ 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
{ 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
{ 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
{ 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
{ 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
{ 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
{ 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
{ 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
{ 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
{ 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
{ 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
{ 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
{ 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
{ 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
{ 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
{ 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
{ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
{ 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
{ 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F
};

Wyświetl plik

@ -11,15 +11,11 @@ extern "C" {
#include "zx81.h"
}
#include <stdio.h>
#include "pico_dsp.h"
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
volatile bool vbl=true;
bool repeating_timer_callback(struct repeating_timer *t) {
bool repeating_timer_callback(struct repeating_timer *t) {
if (vbl) {
vbl = false;
} else {
@ -27,8 +23,8 @@ bool repeating_timer_callback(struct repeating_timer *t) {
}
return true;
}
TFT_T_DMA tft;
PICO_DSP tft;
static int skip=0;
#include "hardware/clocks.h"
@ -40,86 +36,85 @@ int main(void) {
// 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(240000, true);
// set_sys_clock_khz(250000, true);
stdio_init_all();
#ifdef USE_VGA
tft.begin(VGA_MODE_320x240);
#else
tft.begin();
#endif
emu_init();
while (true) {
char * filename;
#ifdef FILEBROWSER
while (true) {
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(15, repeating_timer_callback, NULL, &timer);
}
filename = menuSelection();
if (action == ACTION_RUN) {
break;
}
tft.waitSync();
}
else {
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
emu_Step();
}
//int c = getchar_timeout_us(0);
//switch (c) {
// case ' ':
// printf("test: %d\n", 1);
// break;
//}
}
#endif
emu_start();
emu_Init(filename);
tft.startRefresh();
struct repeating_timer timer;
add_repeating_timer_ms(15, repeating_timer_callback, NULL, &timer);
while (true) {
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
emu_Step();
}
}
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_DrawLinePal16(unsigned char * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLinePal(width,height,line, VBuf, palette16);
}
}
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLine(width,height,line, VBuf);
}
}
int emu_IsVga(void)
{
return (tft.getMode() == MODE_VGA_320x240?1:0);
}
void emu_DrawVsync(void)
{
skip += 1;
skip &= VID_FRAME_SKIP;
#ifdef USE_VGA
tft.waitSync();
#else
volatile bool vb=vbl;
while (vbl==vb) {};
#endif
if ( emu_IsVga() ) {
tft.waitSync();
}
else {
//while (vbl==vb) {};
}
}
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);
tft.writeLine(width,height,line, VBuf);
#endif
}
}
@ -129,6 +124,8 @@ void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
if (skip == 0) {
#ifdef USE_VGA
tft.writeLine16(width,height,line, VBuf);
#else
tft.writeLine(width,height,line, VBuf);
#endif
}
}
@ -138,6 +135,8 @@ 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);
#else
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
#endif
}
}
@ -151,6 +150,7 @@ void * emu_LineBuffer(int line)
{
return (void*)tft.getLineBuffer(line);
}
*/

Wyświetl plik

@ -29,7 +29,7 @@ int zx80=0;
int autoload=1;
struct { unsigned char R,G,B; } Palette[16] = {
struct { unsigned char R,G,B; } Palette[2] = {
{ 0, 0, 0},
{ 255, 255, 255}
};
@ -235,7 +235,7 @@ void bitbufBlit(unsigned char * buf)
d <<= 1;
}
}
emu_DrawLine(&XBuf[0], WIDTH, HEIGHT, y);
emu_DrawLinePal16(&XBuf[0], WIDTH, HEIGHT, y);
buf += (ZX_VID_FULLWIDTH/8);
}
}
@ -250,8 +250,7 @@ static void updateKeyboard (void)
//else
{
int shift = hk;
if (hk >=128) hk -= 128;
else if (hk >=64) hk -= 64;
if (hk >=64) hk -= 64;
// scan all possibilities
for (int j=0;j<8;j++) {
for(int i=0;i<5;i++){
@ -577,8 +576,8 @@ void z81_Start(char * filename)
//emu_setKeymap(1);
if ( (endsWith(filename, ".80")) || (endsWith(filename, ".o")) || (endsWith(filename, ".O"))) {
zx80=1;
ramsize=48;
zx80 = 1;
ramsize = 48;
//emu_setKeymap(0);
}
else if (endsWith(filename, ".56") ) {

Wyświetl plik

@ -1,179 +0,0 @@
#include "emuapi.h"
#ifdef HAS_SND
#include "AudioPlaySystem.h"
#define SAMPLERATE AUDIO_SAMPLE_RATE_EXACT
#define CLOCKFREQ 985248
#ifndef CUSTOM_SND
static const short square[]={
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
32767,32767,32767,32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,
};
const short noise[] {
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,
-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,-32767,32767,32767,-32767,
-32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,-32767,-32767,
32767,-32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,-32767,32767,-32767,32767,32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,-32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
32767,32767,-32767,-32767,-32767,32767,-32767,-32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,
32767,-32767,32767,-32767,-32767,32767,32767,32767,32767,32767,-32767,32767,-32767,32767,-32767,-32767,
};
#define NOISEBSIZE 0x100
typedef struct
{
unsigned int spos;
unsigned int sinc;
unsigned int vol;
} Channel;
static Channel chan[6] = {
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0} };
#endif
volatile bool playing = false;
static void snd_Reset(void)
{
#ifndef CUSTOM_SND
chan[0].vol = 0;
chan[1].vol = 0;
chan[2].vol = 0;
chan[3].vol = 0;
chan[4].vol = 0;
chan[5].vol = 0;
chan[0].sinc = 0;
chan[1].sinc = 0;
chan[2].sinc = 0;
chan[3].sinc = 0;
chan[4].sinc = 0;
chan[5].sinc = 0;
#endif
}
#ifdef CUSTOM_SND
extern "C" {
void SND_Process(void *sndbuffer, int sndn);
}
#endif
#include <stdio.h>
void AudioPlaySystem::snd_Mixer(short * stream, int len )
{
if (playing)
{
#ifdef CUSTOM_SND
//printf("s\n");
SND_Process((void*)stream, len);
#else
int i;
long s;
len = len >> 1;
short v0=chan[0].vol;
short v1=chan[1].vol;
short v2=chan[2].vol;
short v3=chan[3].vol;
short v4=chan[4].vol;
short v5=chan[5].vol;
for (i=0;i<len;i++)
{
s =((v0*square[(chan[0].spos>>8)&0x3f])>>11);
s+=((v1*square[(chan[1].spos>>8)&0x3f])>>11);
s+=((v2*square[(chan[2].spos>>8)&0x3f])>>11);
s+=((v3*noise[(chan[3].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v4*noise[(chan[4].spos>>8)&(NOISEBSIZE-1)])>>11);
s+=((v5*noise[(chan[5].spos>>8)&(NOISEBSIZE-1)])>>11);
*stream++ = (short)(s);
*stream++ = (short)(s);
chan[0].spos += chan[0].sinc;
chan[1].spos += chan[1].sinc;
chan[2].spos += chan[2].sinc;
chan[3].spos += chan[3].sinc;
chan[4].spos += chan[4].sinc;
chan[5].spos += chan[5].sinc;
}
#endif
}
}
void AudioPlaySystem::begin(void)
{
this->reset();
}
void AudioPlaySystem::start(void)
{
playing = true;
}
void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) {
}
void AudioPlaySystem::reset(void)
{
snd_Reset();
}
void AudioPlaySystem::stop(void)
{
playing = false;
}
bool AudioPlaySystem::isPlaying(void)
{
return playing;
}
void AudioPlaySystem::sound(int C, int F, int V) {
#ifndef CUSTOM_SND
if (C < 6) {
chan[C].vol = V;
chan[C].sinc = F>>1;
}
#endif
}
void AudioPlaySystem::step(void) {
}
void AudioPlaySystem::buzz(int size, int val) {
}
#endif

Wyświetl plik

@ -1,26 +0,0 @@
#ifndef audioplaysystem_h_
#define audioplaysystem_h_
#ifdef HAS_SND
#include "platform_config.h"
class AudioPlaySystem
{
public:
AudioPlaySystem(void) { };
void begin(void);
void setSampleParameters(float clockfreq, float samplerate);
void reset(void);
void start(void);
void stop(void);
bool isPlaying(void);
void sound(int C, int F, int V);
void buzz(int size, int val);
void step(void);
static void snd_Mixer(short * stream, int len );
};
#endif
#endif

Wyświetl plik

@ -284,7 +284,9 @@ void Joysticks(void)
JS[N]&=0xBFFF; //Fire 1
}
#if (defined(ILI9341) || defined(ST7789)) && defined(USE_VGA)
#else
#else
#ifdef PICOZX
#else
if (k & MASK_KEY_USER1)
{
JS[N]&=0xFFBF; //Fire 2
@ -293,6 +295,7 @@ void Joysticks(void)
{
JS[0]=(JS[0]&0xFFF0)|(2); //1
}
#endif
#endif
// JS[0]=(JS[0]&0xFFF0)|(12);
// JS[0]=(JS[0]&0xFFF0)|(13);
@ -437,7 +440,7 @@ word LoopZ80(Z80 *R, int * ras)
if(!UCount) {
(SCR[ScrMode].Refresh)(CurLine);
#if SINGLELINE_RENDERING
emu_DrawLine(XBuf, WIDTH, HEIGHT, CurLine);
emu_DrawLinePal16(XBuf, WIDTH, HEIGHT, CurLine);
#else
#endif
}

Wyświetl plik

@ -1,148 +0,0 @@
#ifndef EMUAPI_H
#define EMUAPI_H
#include "platform_config.h"
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
// Title: < >
#define TITLE " Coleco Emulator"
#define ROMSDIR "coleco"
#define emu_Init(ROM) {coc_Init();coc_Start(ROM);}
#define emu_Step() {coc_Step();}
#define emu_Input(x) {}
#define PALETTE_SIZE 16
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
#define ACTION_NONE 0
#define ACTION_MAXKBDVAL 12
#define ACTION_EXITKBD 128
#define ACTION_RUNTFT 129
#define ACTION_RUNVGA 130
#ifdef KEYMAP_PRESENT
#define keylables_map1_0 (char *)"1234567890 "
#define keylables_map1_1 (char *)" # * "
#define keylables_map1_2 (char *)" "
const unsigned short key_map1[] = {
2,3,4,5,6,7,8,9,10,1,0,
0,0,0,11,0,0,0,0,12,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
/*
const unsigned short key_map1[] = {
2,3,4,
5,6,7,
8,9,10,
11,1,12};
*/
#define keylables_map2_0 (char *)" "
#define keylables_map2_1 (char *)" "
#define keylables_map2_2 (char *)" "
const unsigned short key_map2[] = {
0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
#define keylables_map3_0 (char *)" "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" "
const unsigned short key_map3[] = {
0,0,0,0,0,0,0,0,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#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);
extern void emu_printf(const char * text);
extern void emu_printi(int val);
extern void * emu_Malloc(int size);
extern void emu_Free(void * pt);
extern int emu_FileOpen(const char * filepath, const char * mode);
extern int emu_FileRead(void * buf, int size, int handler);
extern int emu_FileGetc(int handler);
extern int emu_FileSeek(int handler, int seek, int origin);
extern int emu_FileTell(int handler);
extern void emu_FileClose(int handler);
extern unsigned int emu_FileSize(const char * filepath);
extern unsigned int emu_LoadFile(const char * filepath, void * buf, int size);
extern void emu_SetPaletteEntry(unsigned char r, unsigned char g, unsigned char b, int index);
extern void emu_DrawScreen(unsigned char * VBuf, int width, int height, int stride);
extern void emu_DrawLine(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine8(unsigned char * VBuf, int width, int height, int line);
extern void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line);
extern void emu_DrawVsync(void);
extern int emu_FrameSkip(void);
extern void * emu_LineBuffer(int line);
extern void emu_InitJoysticks(void);
extern int emu_SwapJoysticks(int statusOnly);
extern unsigned short emu_DebounceLocalKeys(void);
extern int emu_ReadKeys(void);
extern int emu_GetPad(void);
extern int emu_ReadAnalogJoyX(int min, int max);
extern int emu_ReadAnalogJoyY(int min, int max);
extern int emu_ReadI2CKeyboard(void);
extern void emu_KeyboardOnUp(int keymodifer, int key);
extern void emu_KeyboardOnDown(int keymodifer, int key);
extern void emu_sndPlaySound(int chan, int volume, int freq);
extern void emu_sndPlayBuzz(int size, int val);
extern void emu_sndInit();
extern void emu_resetus(void);
extern int emu_us(void);
extern int emu_setKeymap(int index);
extern void emu_FileTempInit(void);
extern void emu_FileTempRead(int addr, unsigned char * val, int n);
extern void emu_FileTempWrite(int addr, unsigned char val);
extern void emu_printh(int val);
#endif

Wyświetl plik

@ -0,0 +1,102 @@
#ifndef EMUCFG_H
#define EMUCFG_H
#define PALETTE_SIZE 16
#define VID_FRAME_SKIP 0x0
#define TFT_VBUFFER_YCROP 0
#define SINGLELINE_RENDERING 1
//#define CUSTOM_SND 1
//#define TIMER_REND 1
#define EXTRA_HEAP 0x10
#define FILEBROWSER
// Title: < >
#define TITLE " Coleco Emulator"
#define ROMSDIR "coleco"
#define emu_Init(ROM) {coc_Init();coc_Start(ROM);}
#define emu_Step() {coc_Step();}
#define emu_Input(x) {}
#ifdef KEYMAP_PRESENT
#ifdef PICOZX
const unsigned short key_map1[] = {
2,3,4,5,6,7,8,9,10,1,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short key_map2[] = {
0,0,11,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,12,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short key_map3[] = {
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0
};
const unsigned short matkeys[] = {
0x104,0x101,0x108,0x102,0x110,0x120,0x140,0x204,0x201,0x208, // row 1
0x202,0x210,0x220,0x240,0x304,0x301,0x308,0x302,0x310,0x320, // row 2
0x340,0x404,0x401,0x408,0x402,0x410,0x420,0x440,0x504,0x501, // row 3
0x020,0x508,0x502,0x510,0x520,0x540,0x604,0x601,0x040,0x608, // row 4
0x008,0x001,0x002,0x010,0x620,0x640 }; // cursor keys up, left, right, down, <<<, >>>
#else
#define keylables_map1_0 (char *)"1234567890 "
#define keylables_map1_1 (char *)" # * "
#define keylables_map1_2 (char *)" "
const unsigned short key_map1[] = {
2,3,4,5,6,7,8,9,10,1,0,
0,0,0,11,0,0,0,0,12,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
/*
const unsigned short key_map1[] = {
2,3,4,
5,6,7,
8,9,10,
11,1,12};
*/
#define keylables_map2_0 (char *)" "
#define keylables_map2_1 (char *)" "
#define keylables_map2_2 (char *)" "
const unsigned short key_map2[] = {
0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
#define keylables_map3_0 (char *)" "
#define keylables_map3_1 (char *)" "
#define keylables_map3_2 (char *)" "
const unsigned short key_map3[] = {
0,0,0,0,0,0,0,0,0,0,0, // function keys
0, 0,0,0,0,0,0,0,0,0,0,
0, 0,0,0,0,0,0,0,0,0,
0,0,0,0
};
const unsigned short matkeys[] = {
0x020,0x120,0x220,0x320,0x420,0x408,0x308,0x208,0x108,0x008,0x002, // row 1
0x510,0x010,0x110,0x210,0x310,0x410,0x401,0x301,0x201,0x101,0x001, // row 2
0x520,0x102,0x202,0x302,0x402,0x404,0x304,0x204,0x104,0x004, // row 3
0x508,0x501,0x502,0x504 }; // cursor keys
#endif
#endif
#endif

Wyświetl plik

@ -1,135 +0,0 @@
// Font: c64_lower.64c
const unsigned char font8x8[128][8] PROGMEM =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
{ 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
{ 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
{ 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
{ 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
{ 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
{ 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
{ 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
{ 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
{ 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
{ 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
{ 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
{ 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
{ 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
{ 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
{ 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
{ 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
{ 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
{ 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
{ 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
{ 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
{ 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
{ 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
{ 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (//)
{ 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
{ 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
{ 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
{ 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
{ 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
{ 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
{ 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
{ 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
{ 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
{ 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
{ 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
{ 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
{ 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
{ 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
{ 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
{ 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
{ 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
{ 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
{ 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
{ 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
{ 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
{ 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
{ 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
{ 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
{ 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
{ 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
{ 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
{ 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
{ 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
{ 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
{ 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
{ 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
{ 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
{ 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
{ 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
{ 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
{ 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
{ 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
{ 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
{ 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
{ 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
{ 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
{ 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
{ 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
{ 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
{ 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
{ 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
{ 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
{ 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
{ 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
{ 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
{ 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
{ 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
{ 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
{ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
{ 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
{ 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F
};

Wyświetl plik

@ -1,132 +0,0 @@
/****************************************************************************
* Purpose : Keyboard input driver.
* Module : Keyboard
* Author : J-M Harvengt
* History : 10/08/97 Creation
****************************************************************************/
#ifndef _KEYBOARD
#define _KEYBOARD
/****************************************************************************
* Macros / typedefs
****************************************************************************/
#define SOURCE_REM 0x01
#define SOURCE_PAD 0x02
#define SOURCE_KEYB 0x03
/* keys id */
#define KEY_UNKNOWN 0x00
#define KEY_LEFT 0x01
#define KEY_RIGHT 0x02
#define KEY_UP 0x03
#define KEY_DOWN 0x04
#define KEY_SPACE 0x05
#define KEY_FONE 0x06
#define KEY_FTWO 0x07
#define KEY_FTHREE 0x08
#define KEY_FFOUR 0x09
#define KEY_FFIVE 0x0a
#define KEY_FSIX 0x0b
#define KEY_FSEVEN 0x0c
#define KEY_FEIGHT 0x0d
#define KEY_FNINE 0x0e
#define KEY_FZERO 0x0f
#define KEY_ONE 0x10
#define KEY_TWO 0x11
#define KEY_THREE 0x12
#define KEY_FOUR 0x13
#define KEY_FIVE 0x14
#define KEY_SIX 0x15
#define KEY_SEVEN 0x16
#define KEY_EIGHT 0x17
#define KEY_NINE 0x18
#define KEY_ZERO 0x19
#define KEY_OK KEY_SPACE
#define KEY_BUT KEY_SPACE
#define KEY_BACK KEY_FONE
#define KEY_MENU KEY_FTWO
#define KEY_TELEWEB KEY_FTHREE
#define KEY_TELETEXT KEY_FFOUR
#define KEY_COIN KEY_FTHREE
#define KEY_ONEUP KEY_FFOUR
/* Bit mask for pad keys */
#define JKEY_PLEFT 0x0001
#define JKEY_PRIGHT 0x0002
#define JKEY_PUP 0x0004
#define JKEY_PDOWN 0x0008
#define JKEY_PSPACE 0x0010
#define JKEY_PONE 0x0020
#define JKEY_PTWO 0x0040
#define JKEY_PTHREE 0x0080
#define JKEY_PFOUR 0x0100
#define JKEY_PFIVE 0x0200
#define JKEY_PSIX 0x0400
#define JKEY_PSEVEN 0x0800
#define JKEY_PEIGHT 0x1000
#define JKEY_PNINE 0x2000
#define JKEY_PZERO 0x4000
#define JKEY_LEFT 0x00010000
#define JKEY_RIGHT 0x00020000
#define JKEY_UP 0x00040000
#define JKEY_DOWN 0x00080000
#define JKEY_SPACE 0x00100000
#define JKEY_ONE 0x00200000
#define JKEY_TWO 0x00400000
#define JKEY_THREE 0x00800000
#define JKEY_FOUR 0x01000000
#define JKEY_FIVE 0x02000000
#define JKEY_SIX 0x04000000
#define JKEY_SEVEN 0x08000000
#define JKEY_EIGHT 0x10000000
#define JKEY_NINE 0x20000000
#define JKEY_ZERO 0x40000000
#define JKEY_OK JKEY_SPACE
#define JKEY_BUT JKEY_SPACE
#define JKEY_BACK JKEY_ONE
#define JKEY_MENU JKEY_TWO
#define JKEY_TELEWEB JKEY_THREE
#define JKEY_TELETEXT JKEY_FOUR
#define JKEY_COIN JKEY_THREE
#define JKEY_ONEUP JKEY_FOUR
#define JKEY_PPLUS JKEY_EIGHT
#define JKEY_PMINUS JKEY_NINE
#define JKEY_POK JKEY_PSPACE
#define JKEY_PBUT JKEY_PSPACE
#define JKEY_PBACK JKEY_PONE
#define JKEY_PMENU JKEY_PTWO
#define JKEY_PTELEWEB JKEY_PTHREE
#define JKEY_PTELETEXT JKEY_PFOUR
#define JKEY_PEPG JKEY_PFIVE
#define JKEY_PCOIN JKEY_PTHREE
#define JKEY_PONEUP JKEY_PFOUR
#define JKEY_PPPLUS JKEY_PEIGHT
#define JKEY_PPMINUS JKEY_PNINE
/* Bit mask for mouse button */
#define LMOUSEDOWN 0x40
#define LMOUSEUP 0x80
/****************************************************************************
* Exported procedures
****************************************************************************/
extern void key_Init(void);
extern void key_TurnOn(void);
extern void key_TurnOff(void);
extern void key_OnKeyDown(int aSource, int aKey);
extern void key_OnKeyUp(int aSource, int aKey);
extern void key_SubscribeKeyUp(void * callback);
extern void key_SubscribeKeyDown(void * callback);
extern void key_OnKeyTimer(void);
extern int key_GetKeyPad(void);
extern void key_OnMouseMove(int x, int y, int b);
extern void key_GetMouseMove(int *x, int *y, int *b);
#endif

Wyświetl plik

@ -12,11 +12,9 @@ extern "C" {
}
#include <stdio.h>
#ifdef USE_VGA
#include "vga_t_dma.h"
#else
#include "tft_t_dma.h"
#endif
#include <stdio.h>
#include "pico_dsp.h"
volatile bool vbl=true;
bool repeating_timer_callback(struct repeating_timer *t) {
@ -27,8 +25,8 @@ bool repeating_timer_callback(struct repeating_timer *t) {
}
return true;
}
TFT_T_DMA tft;
PICO_DSP tft;
static int skip=0;
#include "hardware/clocks.h"
@ -40,87 +38,86 @@ int main(void) {
// 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(240000, true);
// set_sys_clock_khz(250000, true);
stdio_init_all();
#ifdef USE_VGA
tft.begin(VGA_MODE_320x240);
#else
tft.begin();
#endif
emu_init();
while (true) {
char * filename;
#ifdef FILEBROWSER
while (true) {
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(25, repeating_timer_callback, NULL, &timer);
}
filename = menuSelection();
if (action == ACTION_RUN) {
break;
}
tft.waitSync();
}
else {
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
emu_Step();
}
//int c = getchar_timeout_us(0);
//switch (c) {
// case ' ':
// printf("test: %d\n", 1);
// break;
//}
}
#endif
emu_start();
emu_Init(filename);
tft.startRefresh();
struct repeating_timer timer;
add_repeating_timer_ms(25, repeating_timer_callback, NULL, &timer);
while (true) {
uint16_t bClick = emu_DebounceLocalKeys();
emu_Input(bClick);
emu_Step();
}
}
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_DrawLinePal16(unsigned char * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLinePal(width,height,line, VBuf, palette16);
}
}
void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
{
if (skip == 0) {
tft.writeLine(width,height,line, VBuf);
}
}
int emu_IsVga(void)
{
return (tft.getMode() == MODE_VGA_320x240?1:0);
}
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
//while (vbl==vb) {};
if ( emu_IsVga() ) {
tft.waitSync();
}
else {
while (vbl==vb) {};
}
}
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);
tft.writeLine(width,height,line, VBuf);
#endif
}
}
@ -130,6 +127,8 @@ void emu_DrawLine16(unsigned short * VBuf, int width, int height, int line)
if (skip == 0) {
#ifdef USE_VGA
tft.writeLine16(width,height,line, VBuf);
#else
tft.writeLine(width,height,line, VBuf);
#endif
}
}
@ -139,6 +138,8 @@ 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);
#else
tft.writeScreen(width,height-TFT_VBUFFER_YCROP,stride, VBuf+(TFT_VBUFFER_YCROP/2)*stride, palette16);
#endif
}
}
@ -152,6 +153,7 @@ void * emu_LineBuffer(int line)
{
return (void*)tft.getLineBuffer(line);
}
*/
#ifdef HAS_SND

Wyświetl plik

@ -1,26 +0,0 @@
#ifndef audioplaysystem_h_
#define audioplaysystem_h_
#ifdef HAS_SND
#include "platform_config.h"
class AudioPlaySystem
{
public:
AudioPlaySystem(void) { };
void begin(void);
void setSampleParameters(float clockfreq, float samplerate);
void reset(void);
void start(void);
void stop(void);
bool isPlaying(void);
void sound(int C, int F, int V);
void buzz(int size, int val);
void step(void);
static void snd_Mixer(short * stream, int len );
};
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More