Force ADB stuff into the same bank, and fix unbalanced stack issue in SRQ handler

This commit is contained in:
dwsJason 2018-08-18 21:27:42 -04:00
parent 19dfb38262
commit debde24b60
1 changed files with 34 additions and 30 deletions

View File

@ -10,18 +10,22 @@
longa on longa on
longi on longi on
mcopy 13:AInclude:M16.MiscTool mcopy 2:AInclude:M16.MiscTool
mcopy 13:AInclude:M16.ADB mcopy 2:AInclude:M16.ADB
setModes GEQU $0004
clearModes GEQU $0005
resetSys GEQU $0010
keyCode GEQU $0011
Dummy2 start ASMCODE Dummy2 start ASMCODE
end end
KeyArray start ASMCODE KeyArray start ASMCODE
ds 128 ds 128
end
RemoveKeyboardDriver start ASMCODE RemoveKeyboardDriver entry
using Globals
phb phb
phk phk
plb plb
@ -43,10 +47,9 @@ RemoveKeyboardDriver start ASMCODE
plb plb
rtl rtl
end
AddKeyboardDriver start ASMCODE AddKeyboardDriver entry
using Globals
phb phb
phk phk
plb plb
@ -103,9 +106,8 @@ clear stz KeyArray,x
rtl ; Back to C rtl ; Back to C
* end for the AddKeyboardDriver * end for the AddKeyboardDriver
end
CallSendInfo start CallSendInfo entry
sta >ADBTemp sta >ADBTemp
phx phx
pea ADBTemp|-16 pea ADBTemp|-16
@ -117,13 +119,12 @@ CallSendInfo start
rts rts
ADBTemp ds 6 ADBTemp ds 6
end
* *
* SRQ Completion Routine * SRQ Completion Routine
* *
SRQCompRoutine start ASMCODE SRQCompRoutine entry
using Globals
longa off longa off
longi off longi off
DataPtr equ 9 DataPtr equ 9
@ -135,6 +136,10 @@ DataPtr equ 9
lda [DataPtr] ;# bytes? lda [DataPtr] ;# bytes?
beq SRExit ;No data beq SRExit ;No data
phb
phk
plb
longa on longa on
longi on longi on
@ -154,7 +159,8 @@ DataPtr equ 9
and #$00ff ; Second Byte and #$00ff ; Second Byte
bra SRMerge1 bra SRMerge1
SRExit pld SRExit clc
pld
rtl rtl
* *
* Handle Reset Key if need be * Handle Reset Key if need be
@ -172,6 +178,7 @@ SRMerge1 phx ; Save 2nd
txa txa
jsr PostIt jsr PostIt
plx plx
pha
* Forward Keys to ADB * Forward Keys to ADB
@ -181,6 +188,8 @@ SRMerge1 phx ; Save 2nd
jsr PassADBKeyIfOk jsr PassADBKeyIfOk
sep #$30 sep #$30
clc
plb
pld pld
rtl rtl
@ -191,17 +200,17 @@ SRMerge1 phx ; Save 2nd
longi on longi on
PostIt pha ; Save Key PostIt pha ; Save Key
sep #$10 * sep #$20
longa off * longa off
cmp #$80 ; set/clear c cmp #$80 ; set/clear c
and #$7f ; keycode idx and #$7f ; keycode idx
tax tax
lda #$00 lda #$00
rol a ; key state rol a ; key state
eor #$01 ; 0 for key up eor #$01 ; 0 for key up
sta >KeyArray,x sta KeyArray,x
rep #$30 * rep #$30
longa on * longa on
pla pla
rts rts
@ -215,7 +224,7 @@ KeyModTbl anop
* *
* Pass Keys to ADB when appropriate * Pass Keys to ADB when appropriate
* *
PassADBKeyIfOK cmp #$00E0 ; Pfx Code? PassADBKeyIfOk cmp #$00E0 ; Pfx Code?
bge PAExit bge PAExit
cmp #$0036 ; Spec Case? cmp #$0036 ; Spec Case?
blt PASendADB blt PASendADB
@ -257,7 +266,7 @@ ProcessReset anop
PRNoReset ldy #$00ff ; Zap Reset Key PRNoReset ldy #$00ff ; Zap Reset Key
tya tya
rts rts
PRResetSystem anop
; Reset Hit ; Reset Hit
ldx #0 ldx #0
txa txa
@ -266,19 +275,16 @@ PRNoReset ldy #$00ff ; Zap Reset Key
PR tya PR tya
rts rts
end
* *
* Return the keyboard modifer register * Return the keyboard modifer register
* *
GetModKeyReg entry
GetModKeyReg start ASMCODE
sep #$20 ;8 bit sep #$20 ;8 bit
lda >$00C025 ;Get the register lda >$00C025 ;Get the register
rep #$20 ;16 bit rep #$20 ;16 bit
and #$ff ;Fix Acc and #$ff ;Fix Acc
rts ;Exit rts ;Exit
end
* *
* This code is a tail patch to BRam setup since the BRam setup * This code is a tail patch to BRam setup since the BRam setup
@ -286,8 +292,7 @@ GetModKeyReg start ASMCODE
* This is bad. * This is bad.
* *
VecBRamSetup start ASMCODE VecBRamSetup entry
using Globals
jsl >$000000 ;Call the real code jsl >$000000 ;Call the real code
php ;Save mxc php ;Save mxc
@ -298,9 +303,8 @@ VecBRamSetup start ASMCODE
jsr CallSendInfo ;Call ADB jsr CallSendInfo ;Call ADB
plp ;Restore MX plp ;Restore MX
rtl ;Exit rtl ;Exit
end
toBRamSetupVector start ASMCODE toBRamSetupVector entry
ds 4 ds 4
end end