Skip to content

Commit

Permalink
Get all tests working (barring two that are still TODOs), fix the joy…
Browse files Browse the repository at this point in the history
…stick betterer
  • Loading branch information
mattgodbolt committed Sep 13, 2024
1 parent 6e3f88a commit 027b8aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
8 changes: 4 additions & 4 deletions tests/integration/via.js
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,8 @@ REM REAL BBC! YES: 128
PRINT ?(R%)`);
expectArray(testMachine, [128]);
});
// TODO fix! this is broken currently
it.skip("VIA.PB7 - sys via checks", async function () {
// @scarybeasts' original talks about "SYSVIA" below but this is the user VIA
it("VIA.PB7 - user via checks", async function () {
const testMachine = await runViaProgram(`
PRINT "RUN AFTER FRESH BOOT"
R% = ${resultAddress}
Expand All @@ -838,7 +838,7 @@ PROCcheck(0, ?&FE6B, "SYSVIA ACR")
REM READ QUICKLY BEFORE TIMER HITS
A% = ?&FE60
REM TIMER EXPIRES IN 65MS
B% = INKEY(10)
T%=TIME+10:REPEAT UNTIL TIME>T%
PROCcheck(127, A%, "SYSVIA PORT B INPUT PB7 LOW")
PROCcheck(255, ?&FE60, "SYSVIA PORT B INPUT PB7 HIGH")
?&FE62 = 255
Expand All @@ -852,7 +852,7 @@ DEF PROCcheck(E%, A%, N$)
R$ = "OK"
IF E% <> A% THEN R$ = "FAIL!"
IF E% <> A% THEN ?R% = 255
PRINT R$ + ": " + N$ + ": " + STR$(A%)
PRINT R$ + ": " + N$ + ": " + STR$(A%) + " (expected " + STR$(E%) + ")"
ENDPROC`);
expectArray(testMachine, [0]);
});
Expand Down
27 changes: 10 additions & 17 deletions via.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,6 @@ class Via {
temp |= this.t1_pb7 << 7;
}

const buttons = this.getJoysticks();

// clear PB4 and PB5
temp = temp & 0xcf; // 11001111

// AUG p418
// PB4 and PB5 inputs
// These are the inputs from the joystick FIRE buttons. They are
// normally at logic 1 with no button pressed and change to 0
// when a button is pressed
if (!buttons.button1) {
temp |= 1 << 4;
}
if (!buttons.button2) {
temp |= 1 << 5;
}

return temp;
}
case DDRA:
Expand Down Expand Up @@ -368,6 +351,16 @@ class Via {

recalculatePortBPins() {
this.portbpins = this.orb & this.ddrb;
const buttons = this.getJoysticks();

// AUG p418
// ### PB4 and PB5 inputs
// These are the inputs from the joystick FIRE buttons. They are
// normally at logic 1 with no button pressed and change to 0 when a
// button is pressed
if (!buttons.button1) this.portbpins |= 1 << 4;
if (!buttons.button2) this.portbpins |= 1 << 5;

this.portbpins |= ~this.ddrb & 0xff;
this.drivePortB();
this.portBUpdated();
Expand Down

0 comments on commit 027b8aa

Please sign in to comment.