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