Skip to content

Commit ba79b83

Browse files
JoeMattclaude
andcommitted
Address review: HC bit 10 for OP half-line detection, clarify byte switch
- Set bit 10 (0x0400) on HC during odd halflines so the Object Processor's CONDITION_SECOND_HALF_LINE branch works correctly. This mirrors VC's field bit 11 pattern. - Use full addresses in JERRYReadByte switch cases to match the word read style and avoid confusion about the mask behavior. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent afddc33 commit ba79b83

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/jerry.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,13 @@ uint8_t JERRYReadByte(uint32_t offset, uint32_t who/*=UNKNOWN*/)
388388
{
389389
uint16_t value;
390390

391-
switch (offset & 0xFE)
391+
switch (offset & 0xFFFFFFFE)
392392
{
393-
case 0x36: value = JERRYPIT1Prescaler; break;
394-
case 0x38: value = JERRYPIT1Divider; break;
395-
case 0x3A: value = JERRYPIT2Prescaler; break;
396-
case 0x3C: value = JERRYPIT2Divider; break;
397-
default: value = 0; break;
393+
case 0xF10036: value = JERRYPIT1Prescaler; break;
394+
case 0xF10038: value = JERRYPIT1Divider; break;
395+
case 0xF1003A: value = JERRYPIT2Prescaler; break;
396+
case 0xF1003C: value = JERRYPIT2Divider; break;
397+
default: value = 0; break;
398398
}
399399

400400
return (offset & 0x01) ? (value & 0xFF) : (value >> 8);

src/tom.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,11 @@ void TOMExecHalfline(uint16_t halfline, bool render)
737737
halfline &= 0x07FF;
738738

739739
// Update HC to approximate position within the scanline.
740-
// Even halflines = start of scanline (HC near 0),
741-
// odd halflines = midpoint of scanline (HC near HP/2).
742-
// This is not cycle-accurate but gives the OP and games a
743-
// meaningful value instead of the previous rand() stub.
740+
// Bit 10 (0x0400) is the half-line indicator, analogous to VC's
741+
// field bit 11. The OP tests this via CONDITION_SECOND_HALF_LINE.
742+
// Bits 0-9 approximate the position within the half-line.
744743
if (halfline & 0x01)
745-
SET16(tomRam8, HC, (hp > 0 ? (hp + 1) / 2 : 0));
744+
SET16(tomRam8, HC, 0x0400 | (hp > 0 ? (hp + 1) / 2 : 0));
746745
else
747746
SET16(tomRam8, HC, 0);
748747

0 commit comments

Comments
 (0)