forked from X16Community/x16-rom
-
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.
[KERNAL] add legacy/c816 extended APIs (X16Community#280)
- Loading branch information
1 parent
f5a5bfd
commit 3ba934e
Showing
9 changed files
with
112 additions
and
9 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,8 @@ | ||
|
||
clear_status: | ||
stz status | ||
rts | ||
|
||
get_fa: | ||
lda fa | ||
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
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,42 @@ | ||
.import stack_push, stack_pop | ||
.import stack_enter_kernal_stack, stack_leave_kernal_stack | ||
|
||
.export extapi16 | ||
|
||
.include "65c816.inc" | ||
|
||
.segment "UTIL" | ||
|
||
.setcpu "65816" | ||
|
||
.A16 | ||
.I16 | ||
|
||
; This API call expects and requires m=0, x=0, e=0 | ||
extapi16: | ||
php ; preserve flags | ||
set_carry_if_65c816 | ||
bcc unsupported | ||
phx ; preserve X parameter | ||
asl ; translate API call number to jump table entry | ||
tax | ||
lda apitbl,x | ||
plx ; restore old X | ||
plp ; restore flags | ||
pha ; push api address-1 onto stack | ||
rts ; jump to api | ||
|
||
unsupported: | ||
plp | ||
secrts: | ||
sec | ||
rts | ||
|
||
apitbl: | ||
.word secrts-1 ; slot 0 is reserved | ||
.word stack_push-1 ; API 1 | ||
.word stack_pop-1 ; API 2 | ||
.word stack_enter_kernal_stack-1 ; API 3 | ||
.word stack_leave_kernal_stack-1 ; API 4 | ||
|
||
|
File renamed without changes.
File renamed without changes.
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,35 @@ | ||
.import clear_status | ||
.import get_fa | ||
|
||
.export extapi | ||
|
||
.segment "UTIL" | ||
|
||
; This API call expects and requires e=1 | ||
extapi: | ||
pha ; reserve two free spots on the stack | ||
pha | ||
php ; preserve caller flags | ||
phx ; preserve caller X parameter | ||
asl | ||
tax | ||
lda apitbl,x ; low byte of jump table entry | ||
pha | ||
lda apitbl+1,x ; high byte of jump table entry | ||
tsx | ||
sta $105,x ; store API high byte on stack | ||
pla | ||
sta $104,x ; store API low byte on stack | ||
plx ; restore caller X | ||
plp ; restore caller flags | ||
rts ; jump to api | ||
|
||
secrts: | ||
sec | ||
rts | ||
|
||
apitbl: | ||
.word secrts-1 ; slot 0 is reserved | ||
.word clear_status-1 ; API 1 | ||
.word get_fa-1 ; API 2 | ||
|
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