Skip to content

Commit 1d9dbab

Browse files
authored
Add ROM PAR mapping quirk to the MMU (#121)
* Add ROM PAR mapping quirk to the MMU. * Update the Codecov GitHub action. * Update the GitHub action runner to ubuntu-latest * Update Codecov action to version 5.
1 parent 3480d36 commit 1d9dbab

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

.github/workflows/gradle.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build Test Coverage
22
on: [push, pull_request]
33
jobs:
44
run:
5-
runs-on: ubuntu-20.04
5+
runs-on: ubuntu-latest
66
steps:
77
- name: Checkout
88
uses: actions/checkout@v3
@@ -16,4 +16,6 @@ jobs:
1616
- name: Build with Gradle
1717
run: ./gradlew build
1818
- name: Codecov
19-
uses: codecov/codecov-action@v3.1.0
19+
uses: codecov/codecov-action@v5
20+
env:
21+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

src/main/java/ca/craigthomas/yacoco3e/components/Memory.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,24 +318,61 @@ public void setROMMode(UnsignedByte mode) {
318318

319319
/**
320320
* Sets the EXECUTIVE page address register to the specified value.
321+
* Note that ROM pages $3C - $3F are a special case - the effective
322+
* page written to the par is the high 6 bits of the page requested,
323+
* with the bottom two bits of the slot requested.
321324
*
322325
* @param par the PAR number to set
323326
* @param value the value to set it to
324327
*/
325328
public void setExecutivePAR(int par, UnsignedByte value) {
329+
switch (value.getShort()) {
330+
case 0x3C:
331+
case 0x3D:
332+
case 0x3E:
333+
case 0x3F:
334+
value.and(~0x3);
335+
value.or(par & 0x3);
336+
break;
337+
338+
default:
339+
break;
340+
}
326341
executivePAR[par] = value.getShort();
327342
}
328343

329344
/**
330345
* Sets the TASK page address register to the specified value.
346+
* Note that ROM pages $3C - $3F are a special case - the effective
347+
* page written to the par is the high 6 bits of the page requested,
348+
* with the bottom two bits of the slot requested.
331349
*
332350
* @param par the PAR number to set
333351
* @param value the value to set it to
334352
*/
335353
public void setTaskPAR(int par, UnsignedByte value) {
354+
switch (value.getShort()) {
355+
case 0x3C:
356+
case 0x3D:
357+
case 0x3E:
358+
case 0x3F:
359+
value.and(~0x3);
360+
value.or(par & 0x3);
361+
break;
362+
363+
default:
364+
break;
365+
}
336366
taskPAR[par] = value.getShort();
337367
}
338368

369+
/**
370+
* A convenience function for reading a byte by specifying the address
371+
* as an integer instead of an UnsignedWord.
372+
*
373+
* @param address an integer address to read from
374+
* @return an UnsignedByte from the specified location
375+
*/
339376
public UnsignedByte readByte(int address) {
340377
return readByte(new UnsignedWord(address));
341378
}

src/test/java/ca/craigthomas/yacoco3e/components/MemoryTest.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017 Craig Thomas
2+
* Copyright (C) 2017-2025 Craig Thomas
33
* This project uses an MIT style license - see LICENSE for details.
44
*/
55
package ca.craigthomas.yacoco3e.components;
@@ -21,7 +21,7 @@ public void setUp() {
2121

2222
@Test
2323
public void testDefaultConstructorSetsSizeTo512K() {
24-
assertEquals(memory.memory.length, Memory.MEM_512K);
24+
assertEquals(Memory.MEM_512K, memory.memory.length);
2525
}
2626

2727
@Test
@@ -34,7 +34,7 @@ public void testReadByteReadsCorrectByte() {
3434
@Test
3535
public void testWriteByteWritesCorrectByte() {
3636
memory.writeByte(new UnsignedWord(0xBEEF), new UnsignedByte(0xAB));
37-
assertEquals(memory.memory[0x7BEEF], 0xAB);
37+
assertEquals(0xAB, memory.memory[0x7BEEF]);
3838
}
3939

4040
@Test
@@ -71,6 +71,13 @@ public void testSetExecutivePARWorksCorrectly() {
7171
assertEquals(0xB8, memory.executivePAR[7]);
7272
}
7373

74+
@Test
75+
public void testSetExecutiveParROMPagesQuirks() {
76+
UnsignedByte requestedPage = new UnsignedByte(0x3D);
77+
memory.setExecutivePAR(2, requestedPage);
78+
assertEquals(0x3E, memory.executivePAR[2]);
79+
}
80+
7481
@Test
7582
public void testSetTaskPARWorksCorrectly() {
7683
memory.setTaskPAR(0, new UnsignedByte(0xB1));
@@ -98,6 +105,13 @@ public void testSetTaskPARWorksCorrectly() {
98105
assertEquals(0xB8, memory.taskPAR[7]);
99106
}
100107

108+
@Test
109+
public void testSetTaskParROMPagesQuirks() {
110+
UnsignedByte requestedPage = new UnsignedByte(0x3D);
111+
memory.setTaskPAR(2, requestedPage);
112+
assertEquals(0x3E, memory.taskPAR[2]);
113+
}
114+
101115
@Test
102116
public void testReadPhysicalByteReadsFromRAMOnly() {
103117
memory.enableAllRAMMode();

0 commit comments

Comments
 (0)