From d790d8e0a94d8435be1dd427904e0ed303057d3e Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 24 Mar 2024 21:59:14 +0100 Subject: avr8: some registers were missing from addressmap, avr8: fix regression with C flag on SBIW opcode, fix V flag on DEC/SBIW opcodes (cherry picked from commit fbabb96113d690ea562a3258cdf52823d799c1e2) --- src/devices/cpu/avr8/avr8.cpp | 3 +++ src/devices/cpu/avr8/avr8ops.hxx | 38 +++++++++++++++++++------------------- src/mame/homebrew/lft_phasor.cpp | 2 +- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/devices/cpu/avr8/avr8.cpp b/src/devices/cpu/avr8/avr8.cpp index f949ed0ef03..7779648d057 100644 --- a/src/devices/cpu/avr8/avr8.cpp +++ b/src/devices/cpu/avr8/avr8.cpp @@ -566,6 +566,9 @@ void avr8_device::base_internal_map(address_map &map) map(0x003f, 0x003f).w(FUNC(avr8_device::eecr_w)); map(0x0043, 0x0043).w(FUNC(avr8_device::gtccr_w)); map(0x0044, 0x0044).w(FUNC(avr8_device::tccr0a_w)); + map(0x0045, 0x0045).w(FUNC(avr8_device::tccr0b_w)); + map(0x0047, 0x0047).w(FUNC(avr8_device::ocr0a_w)); + map(0x0048, 0x0048).w(FUNC(avr8_device::ocr0b_w)); map(0x004a, 0x004a).w(FUNC(avr8_device::gpior1_w)); map(0x004b, 0x004b).w(FUNC(avr8_device::gpior2_w)); map(0x004c, 0x004c).w(FUNC(avr8_device::spcr_w)); diff --git a/src/devices/cpu/avr8/avr8ops.hxx b/src/devices/cpu/avr8/avr8ops.hxx index 07fb035c7c7..0ac10342616 100644 --- a/src/devices/cpu/avr8/avr8ops.hxx +++ b/src/devices/cpu/avr8/avr8ops.hxx @@ -1047,9 +1047,7 @@ void avr8_base_device::op_neg(uint16_t op) const uint8_t res = 0 - rd; m_r[SREG] &= ~(SREG_MASK_C | SREG_MASK_Z | SREG_MASK_N | SREG_MASK_V | SREG_MASK_S | SREG_MASK_H); if (res == 0) - { m_r[SREG] |= SREG_MASK_Z; - } else { m_r[SREG] |= SREG_MASK_C; @@ -1122,7 +1120,7 @@ void avr8_base_device::op_clrf(uint16_t op) void avr8_base_device::op_ijmp(uint16_t op) { - m_pc = (ZREG - 1) << 1; + m_pc = (ZREG << 1) - 2; } void avr8_base_device::op_eijmp(uint16_t op) @@ -1135,12 +1133,12 @@ void avr8_base_device::op_dec(uint16_t op) const uint8_t rd = m_r[RD5(op)]; const uint8_t res = rd - 1; m_r[SREG] &= ~(SREG_MASK_V | SREG_MASK_N | SREG_MASK_S | SREG_MASK_Z); - if (rd == 0x7f) + if (res == 0) + m_r[SREG] |= SREG_MASK_Z; + else if (res == 0x7f) m_r[SREG] |= SREG_MASK_V | SREG_MASK_S; else if (BIT(res, 7)) m_r[SREG] |= SREG_MASK_N | SREG_MASK_S; - else if (res == 0) - m_r[SREG] |= SREG_MASK_Z; m_r[RD5(op)] = res; } @@ -1148,8 +1146,7 @@ void avr8_base_device::op_jmp(uint16_t op) { uint32_t offs = KCONST22(op) << 16; m_pc += 2; - uint16_t wordval = m_program->read_word(m_pc); - offs |= wordval; + offs |= m_program->read_word(m_pc); m_pc = offs << 1; m_pc -= 2; } @@ -1234,9 +1231,7 @@ void avr8_base_device::op_adiw(uint16_t op) const uint8_t rr = m_r[25 + (DCONST(op) << 1)]; const uint16_t pd = ((rr << 8) | rd) + KCONST6(op); m_r[SREG] &= ~(SREG_MASK_V | SREG_MASK_N | SREG_MASK_S | SREG_MASK_Z | SREG_MASK_C); - if (pd == 0) - m_r[SREG] |= SREG_MASK_Z; - else if (BIT(pd, 15)) + if (BIT(pd, 15)) { m_r[SREG] |= SREG_MASK_N; if (!BIT(rr, 7)) @@ -1244,8 +1239,13 @@ void avr8_base_device::op_adiw(uint16_t op) else m_r[SREG] |= SREG_MASK_S; } - if (BIT(rr, 7) && !BIT(pd, 15)) - m_r[SREG] |= SREG_MASK_C; + else + { + if (pd == 0) + m_r[SREG] |= SREG_MASK_Z; + if (BIT(rr, 7)) + m_r[SREG] |= SREG_MASK_C; + } m_r[24 + (DCONST(op) << 1)] = pd & 0x00ff; m_r[25 + (DCONST(op) << 1)] = (pd >> 8) & 0x00ff; } @@ -1256,16 +1256,16 @@ void avr8_base_device::op_sbiw(uint16_t op) const uint8_t rr = m_r[25 + (DCONST(op) << 1)]; const uint16_t pd = ((rr << 8) | rd) - KCONST6(op); m_r[SREG] &= ~(SREG_MASK_V | SREG_MASK_N | SREG_MASK_S | SREG_MASK_Z | SREG_MASK_C); - m_r[SREG] |= (pd == 0) ? SREG_MASK_Z : 0; if (BIT(pd, 15)) { - if (BIT(rr, 7)) - m_r[SREG] |= SREG_MASK_N | SREG_MASK_S | SREG_MASK_C; + m_r[SREG] |= SREG_MASK_N; + if (!BIT(rr, 7)) + m_r[SREG] |= SREG_MASK_V | SREG_MASK_C; else - m_r[SREG] |= SREG_MASK_N | SREG_MASK_S; + m_r[SREG] |= SREG_MASK_S; } - else if (BIT(rr, 7)) - m_r[SREG] |= SREG_MASK_V | SREG_MASK_S; + else if (pd == 0) + m_r[SREG] |= SREG_MASK_Z; m_r[24 + (DCONST(op) << 1)] = pd & 0x00ff; m_r[25 + (DCONST(op) << 1)] = (pd >> 8) & 0x00ff; } diff --git a/src/mame/homebrew/lft_phasor.cpp b/src/mame/homebrew/lft_phasor.cpp index 365ea9a0293..c6a4acc61f8 100644 --- a/src/mame/homebrew/lft_phasor.cpp +++ b/src/mame/homebrew/lft_phasor.cpp @@ -86,8 +86,8 @@ void lft_phasor_state::data_map(address_map &map) void lft_phasor_state::port_b_w(uint8_t data) { - m_gpio_b = data; video_update(); + m_gpio_b = data; } //************************************************************************** -- cgit v1.2.3-70-g09d2 From 5abb7f4df29ca67be124e242266b6a4c3ccca2bd Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 24 Mar 2024 22:46:26 +0100 Subject: avr8: fix SBIW V flag once more (cherry picked from commit 6517b66f3e9f3be8d709872652432eab541b709e) --- src/devices/cpu/avr8/avr8ops.hxx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/devices/cpu/avr8/avr8ops.hxx b/src/devices/cpu/avr8/avr8ops.hxx index 0ac10342616..614adac97b5 100644 --- a/src/devices/cpu/avr8/avr8ops.hxx +++ b/src/devices/cpu/avr8/avr8ops.hxx @@ -1234,10 +1234,10 @@ void avr8_base_device::op_adiw(uint16_t op) if (BIT(pd, 15)) { m_r[SREG] |= SREG_MASK_N; - if (!BIT(rr, 7)) - m_r[SREG] |= SREG_MASK_V; - else + if (BIT(rr, 7)) m_r[SREG] |= SREG_MASK_S; + else + m_r[SREG] |= SREG_MASK_V; } else { @@ -1258,14 +1258,17 @@ void avr8_base_device::op_sbiw(uint16_t op) m_r[SREG] &= ~(SREG_MASK_V | SREG_MASK_N | SREG_MASK_S | SREG_MASK_Z | SREG_MASK_C); if (BIT(pd, 15)) { - m_r[SREG] |= SREG_MASK_N; + m_r[SREG] |= SREG_MASK_N | SREG_MASK_S; if (!BIT(rr, 7)) - m_r[SREG] |= SREG_MASK_V | SREG_MASK_C; - else - m_r[SREG] |= SREG_MASK_S; + m_r[SREG] |= SREG_MASK_C; + } + else + { + if (pd == 0) + m_r[SREG] |= SREG_MASK_Z; + if (BIT(rr, 7)) + m_r[SREG] |= SREG_MASK_V | SREG_MASK_S; } - else if (pd == 0) - m_r[SREG] |= SREG_MASK_Z; m_r[24 + (DCONST(op) << 1)] = pd & 0x00ff; m_r[25 + (DCONST(op) << 1)] = (pd >> 8) & 0x00ff; } -- cgit v1.2.3-70-g09d2 From 8be0d3eb2955cd8efb0d019535708f5b02477d67 Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 25 Mar 2024 14:15:36 +0100 Subject: avr8: fix port D bit 7 toggle on timer2 (cherry picked from commit 2db21a34b5be8782c1ba510c4fdfc96d37cabea4) --- src/devices/cpu/avr8/avr8.cpp | 8 ++++---- src/mame/homebrew/uzebox.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/devices/cpu/avr8/avr8.cpp b/src/devices/cpu/avr8/avr8.cpp index 7779648d057..e6e1aa54561 100644 --- a/src/devices/cpu/avr8/avr8.cpp +++ b/src/devices/cpu/avr8/avr8.cpp @@ -1961,7 +1961,7 @@ void avr8_device::update_timer_waveform_gen_mode(uint8_t t, uint8_t m if (m_timer_top[t] == -1) { m_timer_top[t] = 0; - LOGMASKED((LOG_TIMER0 + t), "%s: update_timer_waveform_gen_mode: Timer %d - Unsupported waveform generation type: %d\n", machine().describe_context(), t, mode); + LOGMASKED((LOG_TIMER0 << t), "%s: update_timer_waveform_gen_mode: Timer %d - Unsupported waveform generation type: %d\n", machine().describe_context(), t, mode); } } @@ -2028,7 +2028,7 @@ void avr8_device::timer2_tick_fast_pwm() if (m_ocr2_not_reached_yet) { // Turn off - m_r[PORTD] |= 1 << 7; + m_r[PORTD] &= ~(1 << 7); m_gpio_out_cb[GPIOD](m_r[PORTD]); m_ocr2_not_reached_yet = false; } @@ -2191,11 +2191,11 @@ void avr8_device::update_timer_clock_source(uint8_t clock_select, con const uint16_t old_prescale = s_prescale_values[(Timer == 2) ? 1 : 0][old_clock_select]; m_timer_prescale[Timer] = (uint16_t)prescale_divisor; - LOGMASKED(LOG_TIMER0 + Timer, "%s: update_timer_clock_source: t = %d, cs = %d\n", machine().describe_context(), Timer, clock_select); + LOGMASKED(LOG_TIMER0 << Timer, "%s: update_timer_clock_source: t = %d, cs = %d\n", machine().describe_context(), Timer, clock_select); if (prescale_divisor == -1) { - LOGMASKED(LOG_TIMER0 + Timer, "%s: timer%d: update_timer_clock_source: External trigger mode not implemented yet\n", machine().describe_context(), Timer); + LOGMASKED(LOG_TIMER0 << Timer, "%s: timer%d: update_timer_clock_source: External trigger mode not implemented yet\n", machine().describe_context(), Timer); m_timer_prescale[Timer] = 0xffff; } diff --git a/src/mame/homebrew/uzebox.cpp b/src/mame/homebrew/uzebox.cpp index 3e7d6b678d7..dac24881d9e 100644 --- a/src/mame/homebrew/uzebox.cpp +++ b/src/mame/homebrew/uzebox.cpp @@ -128,7 +128,7 @@ void uzebox_state::port_a_w(uint8_t data) uint8_t uzebox_state::port_a_r() { - return m_port_a | 0xf0; + return m_port_a | 0xf0; } void uzebox_state::port_b_w(uint8_t data) -- cgit v1.2.3-70-g09d2 From 5b670ad51ff961c7a3e57f03affd02248e18f59b Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 26 Mar 2024 01:00:46 +1100 Subject: Bumped version to 0.264 --- android-project/app/src/main/AndroidManifest.xml | 4 ++-- makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android-project/app/src/main/AndroidManifest.xml b/android-project/app/src/main/AndroidManifest.xml index ab0dbdce70e..2eee6d99cac 100644 --- a/android-project/app/src/main/AndroidManifest.xml +++ b/android-project/app/src/main/AndroidManifest.xml @@ -4,8 +4,8 @@ --> diff --git a/makefile b/makefile index 3567ccd3f7d..3a886bbf6bb 100644 --- a/makefile +++ b/makefile @@ -1578,7 +1578,7 @@ endif ifeq (posix,$(SHELLTYPE)) $(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS) - @echo '#define BARE_BUILD_VERSION "0.263"' > $@ + @echo '#define BARE_BUILD_VERSION "0.264"' > $@ @echo '#define BARE_VCS_REVISION "$(NEW_GIT_VERSION)"' >> $@ @echo 'extern const char bare_build_version[];' >> $@ @echo 'extern const char bare_vcs_revision[];' >> $@ @@ -1588,7 +1588,7 @@ $(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS) @echo 'const char build_version[] = BARE_BUILD_VERSION " (" BARE_VCS_REVISION ")";' >> $@ else $(GENDIR)/version.cpp: makefile $(GENDIR)/git_desc | $(GEN_FOLDERS) - @echo #define BARE_BUILD_VERSION "0.263" > $@ + @echo #define BARE_BUILD_VERSION "0.264" > $@ @echo #define BARE_VCS_REVISION "$(NEW_GIT_VERSION)" >> $@ @echo extern const char bare_build_version[]; >> $@ @echo extern const char bare_vcs_revision[]; >> $@ -- cgit v1.2.3-70-g09d2