2019-03-10 23:12:34 +00:00
|
|
|
package apple2
|
|
|
|
|
2019-05-23 22:33:45 +00:00
|
|
|
/*
|
|
|
|
See:
|
|
|
|
"Beneath Apple DOS" https://fabiensanglard.net/fd_proxy/prince_of_persia/Beneath%20Apple%20DOS.pdf
|
|
|
|
https://github.com/TomHarte/CLK/wiki/Apple-GCR-disk-encoding
|
2019-03-10 23:12:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
type diskette16sector struct {
|
2019-12-21 10:16:07 +00:00
|
|
|
nib *fileNib
|
|
|
|
position int
|
2019-03-10 23:12:34 +00:00
|
|
|
}
|
|
|
|
|
2019-12-22 13:15:19 +00:00
|
|
|
func newDisquette16Sector(f *fileNib) *diskette16sector {
|
|
|
|
var d diskette16sector
|
|
|
|
d.nib = f
|
|
|
|
return &d
|
|
|
|
}
|
|
|
|
|
2019-12-09 19:40:00 +00:00
|
|
|
func (d *diskette16sector) powerOn(cycle uint64) {
|
2019-12-21 10:16:07 +00:00
|
|
|
// Not used
|
2019-12-02 22:16:35 +00:00
|
|
|
}
|
|
|
|
func (d *diskette16sector) powerOff(_ uint64) {
|
2019-12-21 10:16:07 +00:00
|
|
|
// Not used
|
2019-12-09 19:40:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *diskette16sector) read(quarterTrack int, cycle uint64) uint8 {
|
2019-12-21 10:16:07 +00:00
|
|
|
track := d.nib.track[quarterTrack/stepsPerTrack]
|
2019-12-09 19:40:00 +00:00
|
|
|
value := track[d.position]
|
2019-12-02 22:16:35 +00:00
|
|
|
d.position = (d.position + 1) % nibBytesPerTrack
|
2019-12-09 19:40:00 +00:00
|
|
|
//fmt.Printf("%v, %v, %v, %x\n", 0, 0, d.position, uint8(value))
|
2019-12-02 22:16:35 +00:00
|
|
|
return value
|
2019-03-10 23:12:34 +00:00
|
|
|
}
|
|
|
|
|
2019-12-02 22:16:35 +00:00
|
|
|
func (d *diskette16sector) write(quarterTrack int, value uint8, _ uint64) {
|
|
|
|
track := quarterTrack / stepsPerTrack
|
2019-12-21 10:16:07 +00:00
|
|
|
d.nib.track[track][d.position] = value
|
2019-12-02 22:16:35 +00:00
|
|
|
d.position = (d.position + 1) % nibBytesPerTrack
|
2019-05-23 22:33:45 +00:00
|
|
|
}
|