Download module
This software module
1)
Controls the shift register that drives the download LEDs
2)
Senses the presence of the 3.5’ floppy drive
3)
Keeps track of the progress of the hypothetical download used in the game
Public Functions:
initDownload
Initialize
internal download state
If disk is already in
Can’t start download until disk is ejected
and reinserted
Update all timer variables with current time
Make sure all progress bar LEDs are off
resetDownload
Call initDownload
isDiskIn
Return
disk status with debouncing
clearDownloadDisplay
Clear
out shift register with all zeros
checkDownloadEvents
Read
disk status with debouncing software
State machine using internal state
Case Initial_State
If disk is in
If not waiting on disk eject
Start download progress
Update LEDs
Change state to Running
Else
Blink LEDs
Return NO_EVENT
Else
Blink LEDs
Return NO_EVENT
Case RUNNING
If disk is in
Update progress bar LEDs
If download is complete
Change state to completed
Return DOWNLOAD_COMPLETE_EVENT
Else
Change state to stopped
Return DOWNLOAD_STOPPED_EVENT
Case STOPPED
If disk is in
Change state to running
Return DOWNLOAD_STARTED_EVENT
Case COMPLETED
Blink LEDs
Return DOWNLOAD_COMPLETE_EVENT
For all states, if nothing was returned,
return DOWNLOAD_NO_EVENT
blinkDownloadLEDs
If enough time has passed blink the LEDs
If LEDs are
currently on
Fill shift register with all zeros
Else
Fill shift register will all ones
Module Functions:
checkDiskStatus
If enough time has passed (based on the cal
for debouncing the switch)
Read disk switch input
advanceDisplay
Load
a 1 into the shift register (turns on the next LED)
pulseShift
Set the
shift register clock line to HI
Kill some time
Set the shift register clock line to LO