]> git.sur5r.net Git - cc65/blob - libsrc/c128/acc_c128_speed.s
Fixed gcc compiler warning (#867)
[cc65] / libsrc / c128 / acc_c128_speed.s
1 ;
2 ; 2018-04-23, Marco van den Heuvel
3 ; 2018-04-26, Greg King
4 ;
5
6 ; unsigned char __fastcall__ set_c128_speed (unsigned char speed);
7 ;
8 ;/* Set the speed of the C128 8502 CPU; using SPEED_SLOW will switch to
9 ; * 1 Mhz (slow) mode, SPEED_2X or SPEED_FAST will switch to 2Mhz (fast) mode.
10 ; *
11 ; * Note that any value higher or equal to SPEED_2X will switch to fast mode.
12 ; *
13 ; * This function will return the actual speed the CPU is at, after trying
14 ; * to set the requested speed; to my knowledge, the switching should not fail.
15 ; *
16 ; * For C64 programs, a check for a C128 in C64 mode is needed; make sure you
17 ; * use 'detect_c128();' before using.
18 ; *
19 ; * For C128 programs, no detect function call is needed.
20 ; */
21
22 ; unsigned char get_c128_speed (void);
23 ;
24 ;/* Get the speed of the C128 8502 CPU.
25 ; *
26 ; * Possible return values:
27 ; * SPEED_SLOW  : Slow mode
28 ; * SPEED_2X    : Fast mode
29 ; *
30 ; * For C64 programs, a check for a C128 in C64 mode is needed; make sure you
31 ; * use 'detect_c128();' before using.
32 ; *
33 ; * For C128 programs, no detect function call is needed.
34 ; */
35
36         .export         _set_c128_speed
37         .export         _get_c128_speed
38
39         .include        "accelerator.inc"
40
41 _set_c128_speed:
42         cmp     #SPEED_2X
43         lda     #$00                    ; clear VIC-IIe test bit
44         rol     a                       ; carry flag is speed bit
45         sta     C128_VICIIE_CLK
46
47 _get_c128_speed:
48         lda     C128_VICIIE_CLK
49         and     #$01
50         ldx     #>$0000
51         rts