Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
interrupt_scheduler [2016/06/01 14:33]
ex_writer [Interrupt Scheduler]
— (current)
Line 1: Line 1:
-====== Interrupt Scheduler ====== 
- 
-The Interrupt Scheduler handles systems dependent upon timing, i.e., counters, timers, music, and interrupts. 
- 
-===== Interrupt Scheduler Routines ===== 
- 
-^ Name ^ Description ^ 
-| [[interrupt scheduler#​actint|ACTINT]] | Activate automatic interrupt service (timers, music, blackout) | 
-| [[interrupt scheduler#​bmusic|BMUSIC]] | Begin playing music | 
-| [[interrupt scheduler#​ctimer|CTIMER]] | Call custom timer |  
-| [[interrupt scheduler#​deccts|DECCTS]] | Decrement counters/​timers under mask (used by ACTINT and DECCTS) | 
-| [[interrupt scheduler#​emusic|EMUSIC]] | Stop music | 
-| [[interrupt scheduler#​stimer|STIMER]] | Track and decrement game timers | 
-===== Interrupt Scheduler Routine Descriptions ===== 
- 
-==== ACTINT ==== 
- 
-ACTIVE INTERRUPTS 
- 
-| Calling Sequence: | <code z80>​SYSTEM ​   ACTINT</​code>​ or <code z80>​SYSSUK ​   ACTINT</​code>​| 
-| Arguments: | None | 
-| Outputs: | None | 
-| Description:​ | ACTINT provides automatic interrupt service and runs the seconds timer, the game timer, the music processor, and blackout timers, plus CT0–CT3. Functions as 60<​sup>​th</​sup>​ of a second timers. | 
- 
-Once ACTINT is called, it sets:  
-  * Z80 Interrupt mode 2 (IM 2)  ​ 
-  * INLIN = 200 (line 100)  ​ 
-  * I register and Interrupt Feedback (INFBK)  ​ 
-  * Enable interrupts (EI) 
- 
-ACTINT also calls TIMEX and TIMEY which decrement counters/​timers. 
-==== CTIMER ==== 
- 
-CUSTOM TIMER 
- 
-| Calling Sequence: | <code z80>​CALL ​     CTIMER</​code>​| 
-| Input: | HL = address of custom time base\\ B = value to load into time base 1 to 0 transition\\ C = counter mask as in [[interrupt scheduler#​deccts|DECCTS]] | 
-| Description:​ | HL is loaded and decremented. If HL != 0, then a return is executed, otherwise, HL is loaded with B and [[interrupt scheduler#​deccts|DECCTS]] is called.\\ Registers HL, DE, BC, and AF are undefined upon exit. | 
- 
-==== BMUSIC ==== 
- 
-BEGIN PLAYING MUSIC 
- 
-| Calling Sequence: | <code z80>​SYSTEM ​   BMUSIC</​code>​ or <code z80>​SYSSUK ​   BMUSIC 
-DW        (music stack) 
-DB        (voices byte) 
-DW        (score)</​code>​| 
-| Arguments: | A = voices to start with\\ HL = music program counter (score)\\ IX = music stack pointer | 
-| Notes: | None | 
-| Description:​ | Quiets any previous music, then interprets specified "​score."​ | 
-| Restrictions:​ | None | 
- 
-==== DECCTS ==== 
- 
-DECREMENT COUNTERS/​TIMERS 
- 
-| Calling Sequence: | <code z80>​SYSTEM ​   DECCTS</​code>​ or <code z80>​SYSSUK ​   DECCTS 
-DB        (mask)</​code>​| 
-| Arguments: | C = mask for which counters to decrement | 
-| Outputs: | [[human interface#​sentry|SENTRY]] will notify the program | 
-| Description:​ | Decrements counter if they are non-zero. If any counters go from 1 to 0, [[human interface#​sentry|SENTRY]] is notified. | 
- 
-==== EMUSIC ==== 
- 
-STOP MUSIC 
- 
-| Calling Sequence: | <code z80>​SYSTEM ​   EMUSIC</​code>​ or <code z80>​SYSSUK ​   EMUSIC</​code>​| 
-| Arguments: | None | 
-| Notes: | None | 
-| Description:​ | Outputs 0 to volume ports and halt music processor. | 
-| Restrictions:​ | None | 
- 
-==== STIMER ==== 
- 
-DECREMENT TIMERS 
- 
-| Calling Sequence: | <code z80>​PUSH ​     AF 
-PUSH      BC 
-PUSH      DE 
-PUSH      HL 
-PUSH      IX 
-PUSH      IY 
-CALL      STIMER 
-POP       IY 
-POP       IX 
-POP       HL 
-POP       DE 
-POP       BC 
-POP       ​AF</​code>​| 
-| Input: | None | 
-| Description:​ | STIMER keeps track of game time. If it hits 0, then bit 7 (GSBEND, i.e., game end) in the game status byte (GAMSTB) is set. | 
-| Uses: | AF, BC, DE, HL | 
-| Calls: | Music processor on note (duration) expiration | 
-| Note: | Sets bit 7 of KEYSEX (KEYS-EX tracking byte) to 1 on every second |