]> git.sur5r.net Git - cc65/blob - libsrc/c64/acc_turbomaster_speed.s
679003b039cc4ffe8245f2a650e73038cd1bab49
[cc65] / libsrc / c64 / acc_turbomaster_speed.s
1 ;
2 ; Marco van den Heuvel, 2018-04-30
3 ;
4
5 ; unsigned char __fastcall__ set_turbomaster_speed (unsigned char speed);
6 ;
7 ;/* Set the speed of the Turbo Master cartridge, using SPEED_SLOW will switch to
8 ; * 1 Mhz mode, SPEED_4X or SPEED_FAST will switch to 4 Mhz mode.
9 ; *
10 ; * Note that any value higher or equal to SPEED_4X will switch to 4 Mhz mode,
11 ; * any value lower than SPEED_4X will switch to 1 Mhz mode.
12 ; *
13 ; * This function will return the actual speed the CPU is at after trying
14 ; * to set the requested speed, if the speed is different it might indicate
15 ; * that the hardware switch has locked the speed.
16 ; *
17 ; * This function does not check for the presence of a Turbo Master cartridge,
18 ; * make sure you use 'detect_turbomaster();' before using.
19 ; */
20
21 ; unsigned char get_turbomaster_speed (void);
22 ;
23 ;/* Get the speed of the Turbo Master cartridge.
24 ; *
25 ; * Possible return values:
26 ; * SPEED_SLOW  : 1 Mhz mode
27 ; * SPEED_4X    : 4 Mhz mode
28 ; *
29 ; * This function does not check for the presence of a Turbo Master cartridge,
30 ; * make sure you use 'detect_turbomaster();' before using.
31 ; */
32
33         .export         _set_turbomaster_speed
34         .export         _get_turbomaster_speed
35
36         .include        "accelerator.inc"
37
38 _set_turbomaster_speed:
39         tay
40         lda     TURBOMASTER_SPEED_REG
41         cpy     #SPEED_4X
42         bcs     high_speed
43 low_speed:
44         and     #$7F
45 store_speed:
46         sta     TURBOMASTER_SPEED_REG
47         jmp     _get_turbomaster_speed
48
49 high_speed:
50         ora     #$80
51         bne     store_speed
52
53
54 _get_turbomaster_speed:
55         ldx     #$00
56         lda     TURBOMASTER_SPEED_REG
57         and     #$80
58         beq     is_slow_speed
59 is_high_speed:
60         lda     #SPEED_4X
61 is_slow_speed:
62         rts
63