2020-02-17 04:38:38 +00:00
//
// disk.h
2020-07-13 17:23:33 +00:00
// Steve ][
2020-02-17 04:38:38 +00:00
//
// Created by Tamas Rudnai on 2/15/20.
2020-07-13 17:16:37 +00:00
// Copyright © 2019, 2020 Tamas Rudnai. All rights reserved.
2020-07-13 17:10:33 +00:00
//
// This file is part of Steve ][ -- The Apple ][ Emulator.
//
// Steve ][ is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Steve ][ is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Steve ][. If not, see <https://www.gnu.org/licenses/>.
2020-02-17 04:38:38 +00:00
//
# ifndef disk_h
# define disk_h
2020-02-23 00:37:54 +00:00
# include "../../util/common.h"
2020-02-17 04:38:38 +00:00
# define minDiskTrackNum 0
# define maxDiskTrackNum 39
# define minDiskPhaseStates 8 // 4 quarters * 2 because of two neighbouring magnets can be activated at the same time which leaves motor in a half quarter movement
# define minDiskPhaseNum 0
# define maxDiskPhaseNum (minDiskPhaseStates * maxDiskTrackNum)
2020-02-18 06:22:14 +00:00
2020-02-17 04:38:38 +00:00
typedef struct phase_s {
uint8_t lastMagnet : 4 ;
uint8_t magnet : 4 ;
int count ;
} phase_t ;
2020-02-18 06:22:14 +00:00
2020-02-17 04:38:38 +00:00
typedef struct disk_s {
phase_t phase ;
2020-02-18 06:22:14 +00:00
uint64_t clk_last_access ;
uint64_t clk_last_read ;
2020-06-19 22:16:27 +00:00
uint8_t drive ;
2020-02-17 04:38:38 +00:00
} disk_t ;
2020-02-18 06:22:14 +00:00
2020-02-17 04:38:38 +00:00
extern disk_t disk ;
// Magnet States --> Stepper Motor Position
//
// N
// 0001
// NW | NE
// 1001 | 0011
// |
// W 1000 ------- o ------- 0010 E
// |
// 1100 | 0110
// SW | SE
// 0100
// S
extern const int magnet_to_Poistion [ 16 ] ;
extern const int position_to_direction [ 8 ] [ 8 ] ;
2020-02-23 00:37:54 +00:00
2020-02-25 08:14:05 +00:00
extern const int diskAccelerator_frames ; // number of frames disk acceleration will be on
extern int diskAccelerator_count ; // counter for the disk acceleration frames
extern int diskAccelerator_speed ; // if less than the actual CPU speed, no acceleration
2020-06-12 05:44:53 +00:00
extern int diskAccelerator_enabled ;
2020-06-12 06:16:26 +00:00
extern int disk_sfx_enabled ;
2020-02-17 04:38:38 +00:00
2020-02-17 07:09:29 +00:00
extern void disk_phase ( void ) ;
2020-06-07 04:09:00 +00:00
extern void disk_phase_on ( uint8_t currentMagnet ) ;
extern void disk_phase_off ( uint8_t currentMagnet ) ;
2020-02-17 07:09:29 +00:00
extern uint8_t disk_read ( void ) ;
2020-02-17 04:38:38 +00:00
2020-06-12 01:29:26 +00:00
extern void disk_motor_on ( void ) ;
extern void disk_motor_off ( void ) ;
2020-07-12 01:46:55 +00:00
extern void disk_accelerator_speedup ( void ) ;
2020-02-17 04:38:38 +00:00
# endif /* disk_h */