Skip to content

Commit b3d7c54

Browse files
committed
moviecart timecode display fixed
bottom edge of the screen is properly masked when the OSD is visible corrected masking of screen when the OSD isn't visible
1 parent 8ccae4e commit b3d7c54

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

hardware/memory/cartridge/moviecart/moviecart.go

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ type controlMode int
8989

9090
// list of control modes.
9191
const (
92-
modeVolume controlMode = 0
93-
modeBrightness controlMode = 1
94-
modeTime controlMode = 2
95-
modeMax controlMode = 2
92+
modeVolume controlMode = iota
93+
modeBrightness
94+
modeTime
95+
modeMax
9696
)
9797

9898
// a frame consists of two interlaced fields.
@@ -171,6 +171,9 @@ type state struct {
171171
// force of color or B&W
172172
forceBW bool
173173

174+
// mask bottom edge of the screen when the OSD is visible
175+
blankPartialLines bool
176+
174177
// transport
175178
directionLast transportDirection
176179
buttonsLast transportButtons
@@ -430,16 +433,15 @@ func (cart *Moviecart) updateDirection() {
430433
if direction.isUp() && !cart.state.directionLast.isUp() {
431434
cart.state.osdDuration = osdDuration
432435
if cart.state.controlMode == 0 {
433-
cart.state.controlMode = modeMax
436+
cart.state.controlMode = modeMax - 1
434437
} else {
435438
cart.state.controlMode--
436439
}
437440
} else if direction.isDown() && !cart.state.directionLast.isDown() {
438441
cart.state.osdDuration = osdDuration
442+
cart.state.controlMode++
439443
if cart.state.controlMode == modeMax {
440444
cart.state.controlMode = 0
441-
} else {
442-
cart.state.controlMode++
443445
}
444446
}
445447

@@ -572,6 +574,9 @@ func (cart *Moviecart) updateTransport() {
572574
}
573575

574576
func (cart *Moviecart) runStateMachine() {
577+
// reset blankPartialLines flag
578+
cart.state.blankPartialLines = false
579+
575580
switch cart.state.state {
576581
case stateMachineRight:
577582
if !cart.state.a7 {
@@ -615,6 +620,14 @@ func (cart *Moviecart) runStateMachine() {
615620
}
616621

617622
if cart.state.lines >= 1 {
623+
if cart.state.osdDuration > 0 {
624+
switch cart.state.controlMode {
625+
case modeTime:
626+
cart.state.blankPartialLines = cart.state.lines == 12 && cart.state.oddField
627+
default:
628+
cart.state.blankPartialLines = cart.state.lines == 22 && cart.state.oddField
629+
}
630+
}
618631
cart.fillAddrLeftLine(true)
619632
cart.state.lines--
620633
cart.state.state = stateMachineRight
@@ -747,10 +760,8 @@ func (cart *Moviecart) writeGraph(addr uint16) {
747760
// check if we need to draw OSD using stats graphics data
748761
switch cart.state.osdDisplay {
749762
case osdTime:
750-
if cart.state.osdIdx < cart.state.streamColor {
751-
b = cart.state.streamBuffer[cart.state.streamIndex][cart.state.osdIdx]
752-
cart.state.osdIdx++
753-
}
763+
b = cart.state.streamBuffer[cart.state.streamIndex][cart.state.osdIdx]
764+
cart.state.osdIdx++
754765
case osdLevels:
755766
if cart.state.osdIdx < levelBarsLen {
756767
if cart.state.oddField {
@@ -788,6 +799,11 @@ func (cart *Moviecart) writeGraph(addr uint16) {
788799
cart.state.streamGraph++
789800
}
790801

802+
// emit black when blankPartialLines flag is true
803+
if cart.state.blankPartialLines {
804+
b = 0x00
805+
}
806+
791807
cart.write8bit(addr, b)
792808
}
793809

@@ -814,6 +830,11 @@ func (cart *Moviecart) writeColor(addr uint16) {
814830
b &= 0x0f
815831
}
816832

833+
// emit black when blankPartialLines flag is true
834+
if cart.state.blankPartialLines {
835+
b = 0x00
836+
}
837+
817838
cart.write8bit(addr, b)
818839
}
819840

@@ -837,6 +858,11 @@ func (cart *Moviecart) writeBackground(addr uint16, readCol bool) {
837858
b &= 0x0f
838859
}
839860

861+
// emit black when blankPartialLines flag is true
862+
if cart.state.blankPartialLines {
863+
b = 0x00
864+
}
865+
840866
cart.write8bit(addr, b)
841867
}
842868

@@ -966,11 +992,12 @@ func (cart *Moviecart) nextField() {
966992
// how it is done in the reference implementation by Rob Bairos, which
967993
// calls blankPartialLines() during the stateMachineLeft phase
968994
if cart.state.oddField {
995+
// mask bottom line
969996
for i := 0; i < 5; i++ {
970997
cart.state.streamBuffer[1][cart.state.streamBackground-i-1] = 0
971998
}
972-
cart.state.streamBuffer[1][cart.state.streamTimecode-1] = 0
973999
} else {
1000+
// mask top line
9741001
for i := 0; i < 5; i++ {
9751002
cart.state.streamBuffer[0][cart.state.streamColor+i] = 0
9761003
}

0 commit comments

Comments
 (0)