]> git.sur5r.net Git - cc65/blob - libsrc/c64/acc_turbomaster_speed.s
Optimized the code a bit, thanks to Greg for the suggestions/comments.
[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         asl
42         cpy     #SPEED_4X
43         ror
44 store_speed:
45         sta     TURBOMASTER_SPEED_REG
46
47 _get_turbomaster_speed:
48         ldx     #$00
49         lda     TURBOMASTER_SPEED_REG
50         and     #$80
51         beq     is_slow_speed
52 is_high_speed:
53         lda     #SPEED_4X
54 is_slow_speed:
55         rts
56