draft multicore processing

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2025-10-21 20:07:06 +03:00
parent c583156d1b
commit 7f03664870
13 changed files with 302 additions and 25 deletions

View File

@ -29,6 +29,10 @@ type (
InstrEditor Model
InstrPresets Model
InstrComment Model
Core1 Model
Core2 Model
Core3 Model
Core4 Model
)
func MakeBool(valueEnabler interface {
@ -66,6 +70,43 @@ func (v Bool) Enabled() bool {
return v.enabler.Enabled()
}
// Core methods
func (m *Model) getCoresBit(bit int) bool {
if m.d.InstrIndex < 0 || m.d.InstrIndex >= len(m.d.Song.Patch) {
return false
}
return m.d.Song.Patch[m.d.InstrIndex].CoreBitMask&(1<<bit) != 0
}
func (m *Model) setCoresBit(bit int, value bool) {
if m.d.InstrIndex < 0 || m.d.InstrIndex >= len(m.d.Song.Patch) {
return
}
defer (*Model)(m).change("CoreBitMask", PatchChange, MinorChange)()
if value {
m.d.Song.Patch[m.d.InstrIndex].CoreBitMask |= (1 << bit)
} else {
m.d.Song.Patch[m.d.InstrIndex].CoreBitMask &^= (1 << bit)
}
}
func (m *Model) Core1() Bool { return MakeEnabledBool((*Core1)(m)) }
func (m *Core1) Value() bool { return (*Model)(m).getCoresBit(0) }
func (m *Core1) SetValue(val bool) { (*Model)(m).setCoresBit(0, val) }
func (m *Model) Core2() Bool { return MakeEnabledBool((*Core2)(m)) }
func (m *Core2) Value() bool { return (*Model)(m).getCoresBit(1) }
func (m *Core2) SetValue(val bool) { (*Model)(m).setCoresBit(1, val) }
func (m *Model) Core3() Bool { return MakeEnabledBool((*Core3)(m)) }
func (m *Core3) Value() bool { return (*Model)(m).getCoresBit(2) }
func (m *Core3) SetValue(val bool) { (*Model)(m).setCoresBit(2, val) }
func (m *Model) Core4() Bool { return MakeEnabledBool((*Core4)(m)) }
func (m *Core4) Value() bool { return (*Model)(m).getCoresBit(3) }
func (m *Core4) SetValue(val bool) { (*Model)(m).setCoresBit(3, val) }
// Panic methods
func (m *Model) Panic() Bool { return MakeEnabledBool((*Panic)(m)) }