forked from cc65/cc65
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apple2: implement sleep using MONWAIT
Also publish apple2_slowdown() and apple2_speedup() that could be useful to users, and refactor to only store one apple2_ostype variable.
- Loading branch information
1 parent
8c329df
commit 1015bc6
Showing
6 changed files
with
120 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; | ||
; Colin Leroy-Mira <[email protected]>, 2024 | ||
; | ||
; void __fastcall__ apple2_slowdown(void) | ||
; void __fastcall__ apple2_speedup(void) | ||
; | ||
|
||
.export _apple2_slowdown | ||
.export _apple2_speedup | ||
.import apple2_ostype | ||
|
||
.include "apple2.inc" | ||
|
||
_apple2_slowdown: | ||
bit apple2_ostype | ||
bpl :+ | ||
lda CYAREG | ||
sta cyareg_orig | ||
and #%01111111 | ||
sta CYAREG | ||
: rts | ||
|
||
_apple2_speedup: | ||
bit apple2_ostype | ||
bpl :+ | ||
lda cyareg_orig | ||
sta CYAREG | ||
: rts | ||
|
||
.bss | ||
|
||
cyareg_orig: | ||
.res 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
; | ||
; Colin Leroy-Mira <[email protected]>, 2024 | ||
; | ||
; void __fastcall__ sleep(unsigned s) | ||
; | ||
; | ||
|
||
.export _sleep | ||
.import _apple2_slowdown | ||
.import _apple2_speedup | ||
.importzp tmp1 | ||
|
||
MONWAIT := $FCA8 | ||
|
||
_sleep: | ||
stx tmp1 | ||
tay | ||
ora tmp1 | ||
beq out | ||
jsr _apple2_slowdown; Down to 1MHz for consistency around MONWAIT | ||
bit $C082 | ||
sleep_1s: | ||
ldx #10 ; Loop 10 times | ||
: lda #200 ; About 100ms | ||
jsr MONWAIT | ||
dex | ||
bne :- | ||
dey | ||
bne sleep_1s | ||
dec tmp1 | ||
bmi done | ||
ldy #$FF | ||
bne sleep_1s | ||
done: | ||
bit $C080 | ||
jsr _apple2_speedup | ||
out: | ||
rts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters