]> git.sur5r.net Git - cc65/blob - libsrc/c64/acc_c64dtv_speed.s
Improved the accelerator code. Fixed an infinite loop.
[cc65] / libsrc / c64 / acc_c64dtv_speed.s
1 ;
2 ; Marco van den Heuvel, 2018-04-14
3 ;
4
5 ; extern unsigned char __fastcall__ set_c64dtv_speed (unsigned char speed);
6 ;
7 ;/* Set the speed of the C64DTV, using SPEED_SLOW will switch to
8 ; * slow mode, SPEED_2X or SPEED_FAST will switch to 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 the C64DTV,
16 ; * make sure you use 'detect_c64dtv();' before using.
17 ; */
18
19 ; extern unsigned char get_c64dtv_speed (void);
20 ;
21 ;/* Get the speed of the C64DTV.
22 ; *
23 ; * Possible return values:
24 ; * SPEED_1X    : slow mode
25 ; * SPEED_2X    : fast mode
26 ; *
27 ; * This function does not check for the presence of the C64DTV,
28 ; * make sure you use 'detect_c64dtv();' before using.
29 ; */
30
31         .export         _set_c64dtv_speed
32         .export         _get_c64dtv_speed
33
34         .include        "accelerator.inc"
35
36 _set_c64dtv_speed:
37         cmp     #SPEED_2X
38         bcs     high_speed
39 low_speed:
40         ldx     #C64DTV_Slow
41 set_speed:
42         .byte   $32,$99               ; SAC #$99   set accumulator to reg 9 (cpu control)
43         txa                           ; (re)set skip and burst bits
44         .byte   $32,$00               ; SAC #$00   set accumulator back to reg 0
45         jmp     _get_c64dtv_speed
46
47 high_speed:
48         ldx     #C64DTV_Fast
49         bne     set_speed
50
51
52 _get_c64dtv_speed:
53         .byte   $32,$99               ; SAC #$99   set accumulator to reg 9 (cpu control)
54         tax
55         .byte   $32,$00               ; SAC #$00   set accumulator back to reg 0
56         txa
57         and     #C64DTV_Fast
58         bne     in_fast_mode
59         lda     #$00
60         .byte   $2C
61 in_fast_mode:
62         lda     #$01
63         ldx     #$00
64         rts