Skip to content

Commit

Permalink
Merge pull request #495 from udo-munk/dev
Browse files Browse the repository at this point in the history
merge dev
  • Loading branch information
udo-munk authored Dec 21, 2024
2 parents b9041c9 + c50e91b commit 6541c9f
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ int __attribute__((weak))
error_message_printf(const char *func, int line,
const char *fmt, ...)
{
(void) func;
(void) line;
char buf[256] = {0};
va_list args;
va_start(args, fmt);
Expand Down Expand Up @@ -125,6 +127,8 @@ int __attribute__((weak))
debug_message_printf(const char *func, int line,
const char *fmt, ...)
{
(void) func;
(void) line;
char buf[256] = {0};
va_list args;
va_start(args, fmt);
Expand Down
6 changes: 5 additions & 1 deletion picosim/libs/stdio_msc_usb/msc_usb.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
Expand Down Expand Up @@ -123,6 +123,10 @@ bool tud_msc_prevent_allow_medium_removal_cb(uint8_t lun,
uint8_t prohibit_removal,
uint8_t control)
{
(void) lun;
(void) prohibit_removal;
(void) control;

return true;
}

Expand Down
8 changes: 4 additions & 4 deletions picosim/srcsim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ if(PICO_PLATFORM STREQUAL rp2040)
set(PICO_COMPILER pico_arm_cortex_m0plus_gcc)
elseif(PICO_PLATFORM STREQUAL rp2350-arm-s)
set(PICO_BOARD pico2)
#set(PICO_BOARD pico2_w)
set(PICO_COMPILER pico_arm_cortex_m33_gcc)
elseif(PICO_PLATFORM STREQUAL rp2350-riscv)
set(PICO_BOARD pico2)
#set(PICO_BOARD pico2_w)
set(PICO_COMPILER pico_riscv_gcc)
endif()

Expand Down Expand Up @@ -67,8 +69,8 @@ target_include_directories(${PROJECT_NAME} PUBLIC
)

add_subdirectory(../libs/no-OS-FatFS-SD-SDIO-SPI-RPi-Pico/src FatFs)
add_subdirectory(../libs/stdio_msc_usb stdio_msc_usb)
add_subdirectory(../libs/pico-ds3231/lib ds3231)
add_subdirectory(../libs/stdio_msc_usb stdio_msc_usb)

target_compile_definitions(${PROJECT_NAME} PRIVATE
PICO_STACK_SIZE=4096
Expand Down Expand Up @@ -98,8 +100,6 @@ target_compile_options(${PROJECT_NAME} PUBLIC -Wall -Wextra)
if(PICO_C_COMPILER_IS_CLANG)
target_compile_options(${PROJECT_NAME} PUBLIC -Weverything)
endif()
# -Wno-unused-parameter because no-OS-FatFS-SD-SDIO-SPI-RPi-Pico isn't clean
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-unused-parameter)

target_link_libraries(${PROJECT_NAME}
hardware_i2c
Expand All @@ -110,7 +110,7 @@ target_link_libraries(${PROJECT_NAME}
pico-ds3231
stdio_msc_usb
)
if(PICO_BOARD STREQUAL pico_w)
if(PICO_CYW43_SUPPORTED)
target_link_libraries(${PROJECT_NAME}
pico_cyw43_arch_none
)
Expand Down
18 changes: 16 additions & 2 deletions picosim/srcsim/simcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ void config(void)
f_read(&sd_file, &disks[2], DISKLEN, &br);
f_read(&sd_file, &disks[3], DISKLEN, &br);
f_close(&sd_file);
#if defined(EXCLUDE_I8080) || defined(EXCLUDE_Z80)
cpu = DEF_CPU;
#endif
}

/* Create a real-time clock structure and initiate this */
Expand Down Expand Up @@ -162,8 +165,15 @@ void config(void)
#if LIB_STDIO_MSC_USB
printf("u - enable USB mass storage access\n");
#endif
printf("c - switch CPU, currently %s\n",
(cpu == Z80) ? "Z80" : "8080");
printf("c - switch CPU, currently ");
#ifndef EXCLUDE_Z80
if (cpu == Z80)
puts("Z80");
#endif
#ifndef EXCLUDE_I8080
if (cpu == I8080)
puts("8080");
#endif
printf("s - CPU speed: ");
if (speed == 0)
puts("unlimited");
Expand Down Expand Up @@ -261,10 +271,14 @@ void config(void)
#endif

case 'c':
#if defined(EXCLUDE_I8080) || defined(EXCLUDE_Z80)
puts("Can't switch CPU");
#else
if (cpu == Z80)
switch_cpu(I8080);
else
switch_cpu(Z80);
#endif
break;

case 's':
Expand Down
8 changes: 4 additions & 4 deletions z80core/alt8080.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,11 @@
/* without a frontpanel DI + HALT
stops the machine */
cpu_error = OPHALT;
cpu_state = STOPPED;
cpu_state = ST_STOPPED;
} else {
/* else wait for INT or user interrupt */
while ((int_int == 0) &&
(cpu_state == CONTIN_RUN)) {
(cpu_state == ST_CONTIN_RUN)) {
sleep_for_ms(1);
}
}
Expand All @@ -776,7 +776,7 @@
if (IFF == 0) {
/* INT disabled, wait for
frontpanel reset or user interrupt */
while (!(cpu_state & RESET)) {
while (!(cpu_state & ST_RESET)) {
fp_clock++;
fp_sampleData();
sleep_for_ms(1);
Expand All @@ -787,7 +787,7 @@
/* else wait for INT,
frontpanel reset or user interrupt */
while ((int_int == 0) &&
!(cpu_state & RESET)) {
!(cpu_state & ST_RESET)) {
fp_clock++;
fp_sampleData();
sleep_for_ms(1);
Expand Down
8 changes: 4 additions & 4 deletions z80core/altz80.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,11 @@
/* without a frontpanel DI + HALT
stops the machine */
cpu_error = OPHALT;
cpu_state = STOPPED;
cpu_state = ST_STOPPED;
} else {
/* else wait for INT, NMI or user interrupt */
while ((int_int == 0) && (int_nmi == 0) &&
(cpu_state == CONTIN_RUN)) {
(cpu_state == ST_CONTIN_RUN)) {
sleep_for_ms(1);
R += 99;
}
Expand All @@ -840,7 +840,7 @@
/* INT disabled, wait for NMI,
frontpanel reset or user interrupt */
while ((int_nmi == 0) &&
!(cpu_state & RESET)) {
!(cpu_state & ST_RESET)) {
fp_clock++;
fp_sampleData();
sleep_for_ms(1);
Expand All @@ -852,7 +852,7 @@
/* else wait for INT, NMI,
frontpanel reset or user interrupt */
while ((int_int == 0) && (int_nmi == 0) &&
!(cpu_state & RESET)) {
!(cpu_state & ST_RESET)) {
fp_clock++;
fp_sampleData();
sleep_for_ms(1);
Expand Down
8 changes: 1 addition & 7 deletions z80core/simcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,9 @@ void reset_cpu(void)
void switch_cpu(int new_cpu)
{
if (cpu != new_cpu) {
switch (new_cpu) {
case Z80:
break;
case I8080:
if (new_cpu == I8080) {
F &= ~(Y_FLAG | X_FLAG);
F |= N_FLAG;
break;
default:
break;
}
cpu = new_cpu;
cpu_state = ST_MODEL_SWITCH;
Expand Down
26 changes: 8 additions & 18 deletions z80core/simdis.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ char Opcode_Str[64];
int disass(WORD addr)
{
register BYTE op;
register const char *tmpl;
register const char *tmpl = "";
register char *p;
BYTE b1, b2;
WORD a = addr;
Expand All @@ -210,9 +210,8 @@ int disass(WORD addr)
* select instruction template tmpl, decode operands, and
* flag undocumented Z80 DD/FD main block instructions
*/
switch (cpu) {
#ifndef EXCLUDE_Z80
case Z80:
if (cpu == Z80) {
op = getmem(a++);
/* index register prefix? */
if ((op & 0xdf) == 0xdd) {
Expand Down Expand Up @@ -279,10 +278,10 @@ int disass(WORD addr)
a--;
} else
tmpl = optab_67[op & 0x3f];
break;
}
#endif
#ifndef EXCLUDE_I8080
case I8080:
if (cpu == I8080) {
op = getmem(a++);
reg1 = (op >> 3) & 7;
reg2 = op & 7;
Expand All @@ -298,12 +297,8 @@ int disass(WORD addr)
reg1 = reg2;
} else
tmpl = optab_8080_67[op & 0x3f];
break;
#endif
default:
tmpl = "";
break;
}
#endif

/*
* expand instruction template tmpl into disassembly string
Expand All @@ -322,9 +317,8 @@ int disass(WORD addr)
p = wtoa((b2 << 8) | b1, p);
break;
case 'r': /* register */
switch (cpu) {
#ifndef EXCLUDE_Z80
case Z80:
if (cpu == Z80) {
switch (reg1) {
case 4: /* H */
case 5: /* L */
Expand Down Expand Up @@ -363,16 +357,12 @@ int disass(WORD addr)
default:
break;
}
break;
}
#endif
#ifndef EXCLUDE_I8080
case I8080:
if (cpu == I8080)
*p++ = "BCDEHLMA"[reg1];
break;
#endif
default:
break;
}
reg1 = reg2;
break;
#ifndef EXCLUDE_Z80
Expand Down
Loading

0 comments on commit 6541c9f

Please sign in to comment.