Skip to content

Commit

Permalink
[MC6809E] Fix reset sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
tgtakaoka committed May 2, 2024
1 parent be2699d commit 2d5dc3c
Show file tree
Hide file tree
Showing 14 changed files with 939 additions and 946 deletions.
8 changes: 2 additions & 6 deletions debugger/mc6809/pins_mc6809.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ constexpr uint8_t PINS_HIGH[] = {
PIN_BREQ,
};

constexpr uint8_t PINS_PULLUP[] = {
PIN_XTAL,
};

constexpr uint8_t PINS_INPUT[] = {
PIN_D0,
PIN_D1,
Expand Down Expand Up @@ -177,6 +173,7 @@ constexpr uint8_t PINS_INPUT[] = {
PIN_E,
PIN_BS,
PIN_BA,
PIN_XTAL,
};

inline void extal_cycle() {
Expand All @@ -191,7 +188,6 @@ inline void extal_cycle() {
void PinsMc6809::resetPins() {
pinsMode(PINS_LOW, sizeof(PINS_LOW), OUTPUT, LOW);
pinsMode(PINS_HIGH, sizeof(PINS_HIGH), OUTPUT, HIGH);
pinsMode(PINS_PULLUP, sizeof(PINS_PULLUP), INPUT_PULLUP);
pinsMode(PINS_INPUT, sizeof(PINS_INPUT), INPUT);

assert_reset();
Expand Down Expand Up @@ -232,7 +228,6 @@ void PinsMc6809::reset() {
Signals *PinsMc6809::rawCycle() const {
// C1H
extal_hi();
busMode(D, INPUT);
auto signals = Signals::put();
delayNanoseconds(c1_hi_ns);
// C2L
Expand Down Expand Up @@ -288,6 +283,7 @@ Signals *PinsMc6809::rawCycle() const {
// C1L
signals->clearControl();
extal_lo();
busMode(D, INPUT);

return signals;
}
Expand Down
14 changes: 9 additions & 5 deletions debugger/mc6809/pins_mc6809e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ inline void c4_clock() {
digitalWriteFast(PIN_Q, LOW);
}

inline auto signal_avma() {
return digitalReadFast(PIN_AVMA);
}

void negate_irq() {
digitalWriteFast(PIN_IRQ, HIGH);
}
Expand Down Expand Up @@ -165,9 +169,8 @@ void PinsMc6809E::resetPins() {
}

mc6809::Signals *PinsMc6809E::rawCycle() const {
static uint8_t vma = LOW;
static uint8_t local_vma = LOW;
// c1
busMode(D, INPUT);
auto signals = Signals::put();
// c2
c2_clock();
Expand All @@ -177,7 +180,7 @@ mc6809::Signals *PinsMc6809E::rawCycle() const {
// c3
c3_clock();
signals->getLowAddr();
if (vma == LOW) {
if (local_vma == LOW) {
delayNanoseconds(c3_novma);
// c4
c4_clock();
Expand Down Expand Up @@ -209,10 +212,11 @@ mc6809::Signals *PinsMc6809E::rawCycle() const {
Signals::nextCycle();
delayNanoseconds(c4_read);
}
// c1
signals->getControl();
local_vma = signal_avma();
// c1
c1_clock();
vma = signals->avma();
busMode(D, INPUT);

return signals;
}
Expand Down
1 change: 0 additions & 1 deletion debugger/mc6809/signals_mc6809.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void Signals::getDirection() {

void Signals::clearControl() {
lic() = 0;
avma() = 0;
vma() = 1;
}

Expand Down
2 changes: 0 additions & 2 deletions debugger/mc6809/signals_mc6809.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ struct Signals : SignalsBase<Signals, mc6800::Signals> {

bool vector() const { return status() == S_VEC; }
uint8_t lic() const { return _signals[4]; }
uint8_t avma() const { return _signals[5]; }
uint8_t &lic() { return _signals[4]; }
uint8_t &avma() { return _signals[5]; }

protected:
enum Status : uint8_t {
Expand Down
1 change: 0 additions & 1 deletion debugger/mc6809/signals_mc6809e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace mc6809e {

void Signals::getControl() {
lic() = digitalReadFast(PIN_LIC);
avma() = digitalReadFast(PIN_AVMA);
vma() = 1;
}

Expand Down
2 changes: 2 additions & 0 deletions debugger/mems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ uint32_t Mems::disassemble(uint32_t addr, uint8_t numInsn) const {
cli.print('\'');
}
cli.println();
if (insn.getError() == libasm::NO_MEMORY)
break;
}
addr += insn.length();
++num;
Expand Down
5 changes: 2 additions & 3 deletions samples/hd6309/mandelbrot.asm
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ main:
sta ACIA+2 ; set #FIRQ name for MC6805 emulator
andcc #~CC_FIRQ ; Clear FIRQ mask

loop:
jsr mandelbrot
jsr newline
wait: tst tx_queue ; tx queue len
bne wait
swi
bra loop

;;; Get character
;;; @return A
Expand Down
4 changes: 2 additions & 2 deletions samples/hd6309/mandelbrot.inc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ print_char:
jsr getchar
bcc next_x
tsta
beq mandelbrot_end ; break
bne next_x
swi ; halt to system
next_x:
inc vX ; X+=1
lda vX
Expand All @@ -165,5 +166,4 @@ next_x:
lda vY
cmpa #13
lblt loop_y ; if Y<13
mandelbrot_end:
rts
Loading

0 comments on commit 2d5dc3c

Please sign in to comment.