1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 19:29:37 +00:00

Handlers which manage the banking in and out of the ROM.

This commit is contained in:
Christian Groessler 2013-05-31 01:45:53 +02:00
parent 9908561e80
commit 9228b002b0

View File

@ -0,0 +1,175 @@
;
; Atari XL shadow RAM handlers
;
; Christian Groessler, chris@groessler.org, 2013
;
.if .defined(__ATARIXL__)
.include "atari.inc"
.include "save_area.inc"
.import __CHARGEN_START__
.export sram_init
.export KEYBDV_wrapper
.macro disable_rom
lda PORTB
and #$fe
sta PORTB
.endmacro
.macro enable_rom
lda PORTB
ora #1
sta PORTB
.endmacro
.segment "INIT"
; Turn off ROMs, install system and interrupt wrappers, set new chargen pointer
sram_init:
; disable all interrupts
sei
ldx #0
stx NMIEN ; disable NMI
disable_rom
; setup interrupt vectors
lda #<my_IRQ_han
sta $fffe
lda #>my_IRQ_han
sta $ffff
lda #<my_RESET_han
sta $fffc
lda #>my_RESET_han
sta $fffd
lda #<my_NMI_han
sta $fffa
lda #>my_NMI_han
sta $fffb
; setup pointers to CIOV and SIOV wrappers
lda #$4C ; JMP opcode
sta CIOV
lda #<my_CIOV
sta CIOV+1
lda #>my_CIOV
sta CIOV+2
lda #$4C ; JMP opcode
sta SIOV
lda #<my_SIOV
sta SIOV+1
lda #>my_SIOV
sta SIOV+2
; set new chargen
lda #>__CHARGEN_START__
sta CHBAS
sta CHBASE
; enable interrupts
lda #$40
sta NMIEN
cli
rts
.segment "LOWCODE"
.macro int_wrap orgvec
.local ret
pha
enable_rom
lda #>ret
pha
lda #<ret
pha
php
jmp (orgvec)
ret: disable_rom
pla
rti
.endmacro
my_IRQ_han:
int_wrap IRQ_save
my_NMI_han:
int_wrap NMI_save
my_RESET_han:
int_wrap RESET_save
my_CIOV:
pha
enable_rom
pla
jsr CIOV_org
php
pha
disable_rom
pla
plp
rts
my_SIOV:
pha
enable_rom
pla
jsr SIOV_org
php
pha
disable_rom
pla
plp
rts
KEYBDV_wrapper:
lda #>(kret-1)
pha
lda #<(kret-1)
pha
enable_rom
lda KEYBDV+5
pha
lda KEYBDV+4
pha
rts ; call keyboard handler
kret: pha
disable_rom
pla
rts
.if 0
.import KEYBDV_wrapper
.import cursor,mul40
_cgetc:
jsr setcursor
.if .not .defined(__ATARIXL__)
jsr @1
.else
jsr KEYBDV_wrapper
.endif
ldx #0
rts
.if .not .defined(__ATARIXL__)
@1: lda KEYBDV+5
pha
lda KEYBDV+4
pha
lda #12
sta ICAX1Z ; fix problems with direct call to KEYBDV
rts
.endif
.endif
.endif ; .if .defined(__ATARIXL__)