Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build Test Coverage
on: [push, pull_request]
jobs:
run:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -16,4 +16,6 @@ jobs:
- name: Build with Gradle
run: ./gradlew build
- name: Codecov
uses: codecov/codecov-action@v3.1.0
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
37 changes: 37 additions & 0 deletions src/main/java/ca/craigthomas/yacoco3e/components/Memory.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,24 +318,61 @@ public void setROMMode(UnsignedByte mode) {

/**
* Sets the EXECUTIVE page address register to the specified value.
* Note that ROM pages $3C - $3F are a special case - the effective
* page written to the par is the high 6 bits of the page requested,
* with the bottom two bits of the slot requested.
*
* @param par the PAR number to set
* @param value the value to set it to
*/
public void setExecutivePAR(int par, UnsignedByte value) {
switch (value.getShort()) {
case 0x3C:
case 0x3D:
case 0x3E:
case 0x3F:
value.and(~0x3);
value.or(par & 0x3);
break;

default:
break;
}
executivePAR[par] = value.getShort();
}

/**
* Sets the TASK page address register to the specified value.
* Note that ROM pages $3C - $3F are a special case - the effective
* page written to the par is the high 6 bits of the page requested,
* with the bottom two bits of the slot requested.
*
* @param par the PAR number to set
* @param value the value to set it to
*/
public void setTaskPAR(int par, UnsignedByte value) {
switch (value.getShort()) {
case 0x3C:
case 0x3D:
case 0x3E:
case 0x3F:
value.and(~0x3);
value.or(par & 0x3);
break;

default:
break;
}
taskPAR[par] = value.getShort();
}

/**
* A convenience function for reading a byte by specifying the address
* as an integer instead of an UnsignedWord.
*
* @param address an integer address to read from
* @return an UnsignedByte from the specified location
*/
public UnsignedByte readByte(int address) {
return readByte(new UnsignedWord(address));
}
Expand Down
20 changes: 17 additions & 3 deletions src/test/java/ca/craigthomas/yacoco3e/components/MemoryTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 Craig Thomas
* Copyright (C) 2017-2025 Craig Thomas
* This project uses an MIT style license - see LICENSE for details.
*/
package ca.craigthomas.yacoco3e.components;
Expand All @@ -21,7 +21,7 @@ public void setUp() {

@Test
public void testDefaultConstructorSetsSizeTo512K() {
assertEquals(memory.memory.length, Memory.MEM_512K);
assertEquals(Memory.MEM_512K, memory.memory.length);
}

@Test
Expand All @@ -34,7 +34,7 @@ public void testReadByteReadsCorrectByte() {
@Test
public void testWriteByteWritesCorrectByte() {
memory.writeByte(new UnsignedWord(0xBEEF), new UnsignedByte(0xAB));
assertEquals(memory.memory[0x7BEEF], 0xAB);
assertEquals(0xAB, memory.memory[0x7BEEF]);
}

@Test
Expand Down Expand Up @@ -71,6 +71,13 @@ public void testSetExecutivePARWorksCorrectly() {
assertEquals(0xB8, memory.executivePAR[7]);
}

@Test
public void testSetExecutiveParROMPagesQuirks() {
UnsignedByte requestedPage = new UnsignedByte(0x3D);
memory.setExecutivePAR(2, requestedPage);
assertEquals(0x3E, memory.executivePAR[2]);
}

@Test
public void testSetTaskPARWorksCorrectly() {
memory.setTaskPAR(0, new UnsignedByte(0xB1));
Expand Down Expand Up @@ -98,6 +105,13 @@ public void testSetTaskPARWorksCorrectly() {
assertEquals(0xB8, memory.taskPAR[7]);
}

@Test
public void testSetTaskParROMPagesQuirks() {
UnsignedByte requestedPage = new UnsignedByte(0x3D);
memory.setTaskPAR(2, requestedPage);
assertEquals(0x3E, memory.taskPAR[2]);
}

@Test
public void testReadPhysicalByteReadsFromRAMOnly() {
memory.enableAllRAMMode();
Expand Down