From 60e97f4d96a61f8ea9ccfe772aa4d4fc588483f5 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Thu, 19 Sep 2013 23:21:09 +0200 Subject: [PATCH] move macros to enable and disable the ROM into a separate include file --- libsrc/atari/crt0.s | 2 +- libsrc/atari/ostype.s | 54 +++++++++------------- libsrc/atari/romswitch.inc | 73 ++++++++++++++++++++++++++++++ libsrc/atari/shadow_ram_handlers.s | 53 +--------------------- 4 files changed, 97 insertions(+), 85 deletions(-) create mode 100644 libsrc/atari/romswitch.inc diff --git a/libsrc/atari/crt0.s b/libsrc/atari/crt0.s index f28439802..f1cadd992 100644 --- a/libsrc/atari/crt0.s +++ b/libsrc/atari/crt0.s @@ -222,7 +222,7 @@ _exit: jsr donelib ; Run module destructors .bss SP_save: .res 1 -SHFLOK_save .res 1 +SHFLOK_save: .res 1 LMARGN_save: .res 1 .ifndef __ATARIXL__ APPMHI_save: .res 2 diff --git a/libsrc/atari/ostype.s b/libsrc/atari/ostype.s index 4fbeaaf70..d2bf8888e 100644 --- a/libsrc/atari/ostype.s +++ b/libsrc/atari/ostype.s @@ -40,40 +40,38 @@ .export _get_ostype + .include "atari.inc" + .include "romswitch.inc" + .ifdef __ATARIXL__ - .include "atari.inc" .import __CHARGEN_START__ .segment "LOWCODE" -.macro disable_rom + +.macro disable_rom_save_a pha - lda PORTB - and #$fe - sta PORTB - lda #>__CHARGEN_START__ - sta CHBAS - sta CHBASE - pla -.endmacro -.macro enable_rom - lda PORTB - ora #1 - sta PORTB - lda #$E0 - sta CHBAS - sta CHBASE + disable_rom + pla .endmacro .else ; above atarixl, below atari -.macro disable_rom -.endmacro -.macro enable_rom +.macro disable_rom_save_a .endmacro -.endif +.endif ; .ifdef __ATARIXL__ -.proc _get_ostype + +; unknown ROM + +_unknown: + lda #0 + tax + disable_rom_save_a + rts + + +_get_ostype: enable_rom lda $fcd8 @@ -97,15 +95,7 @@ and #%00111000 ora #%11 _fin: ldx #0 - disable_rom - rts - -; unknown ROM - -_unknown: - lda #0 - tax - disable_rom + disable_rom_save_a rts ; 1200XL ROM @@ -184,5 +174,3 @@ _400800_3: lda #%00010001 bne _fin - -.endproc diff --git a/libsrc/atari/romswitch.inc b/libsrc/atari/romswitch.inc new file mode 100644 index 000000000..58e09042a --- /dev/null +++ b/libsrc/atari/romswitch.inc @@ -0,0 +1,73 @@ +; +; Macros to disable and enable the ROM on Atari XL systems. +; +; Christian Groessler, chris@groessler.org, 19-Sep-2013 +; + + +.ifdef __ATARIXL__ + +USEWSYNC= 1 + +.if USEWSYNC +.macro wsync + sta WSYNC +.endmacro +.else +.macro wsync +.endmacro +.endif + + +.macro disable_rom + lda PORTB + and #$fe + wsync + sta PORTB + lda #>__CHARGEN_START__ + sta CHBAS + sta CHBASE +.endmacro +.macro disable_rom_quick + lda PORTB + and #$fe + sta PORTB + lda #>__CHARGEN_START__ + sta CHBAS + sta CHBASE +.endmacro +.macro disable_rom_val val + lda val + wsync + sta PORTB + lda #>__CHARGEN_START__ + sta CHBAS + sta CHBASE +.endmacro + +.macro enable_rom + lda PORTB + ora #1 + wsync + sta PORTB + lda #$E0 + sta CHBAS + sta CHBASE +.endmacro +.macro enable_rom_quick + lda PORTB + ora #1 + sta PORTB + lda #$E0 + sta CHBAS + sta CHBASE +.endmacro + +.else ; above __ATARIXL__, below not + +.macro disable_rom +.endmacro +.macro enable_rom +.endmacro + +.endif diff --git a/libsrc/atari/shadow_ram_handlers.s b/libsrc/atari/shadow_ram_handlers.s index 9714644ad..ddc7b0842 100644 --- a/libsrc/atari/shadow_ram_handlers.s +++ b/libsrc/atari/shadow_ram_handlers.s @@ -5,7 +5,6 @@ ; DEBUG = 1 -USEWSYNC= 1 CHKBUF = 1 ; check if bounce buffering is needed (bounce buffering is always done if set to 0) .ifdef __ATARIXL__ @@ -14,6 +13,8 @@ CHKBUF = 1 ; check if bounce buffering is needed (bounce buffering is always don .include "atari.inc" .include "save_area.inc" .include "zeropage.inc" + .include "romswitch.inc" + .import __CHARGEN_START__ .export sram_init @@ -25,56 +26,6 @@ CHKBUF = 1 ; check if bounce buffering is needed (bounce buffering is always don BUFSZ = 128 ; bounce buffer size BUFSZ_SIO = 256 -.macro wsync -.if USEWSYNC - sta WSYNC -.endif -.endmacro - -.macro disable_rom - lda PORTB - and #$fe - wsync - sta PORTB - lda #>__CHARGEN_START__ - sta CHBAS - sta CHBASE -.endmacro -.macro disable_rom_quick - lda PORTB - and #$fe - sta PORTB - lda #>__CHARGEN_START__ - sta CHBAS - sta CHBASE -.endmacro -.macro disable_rom_val val - lda val - wsync - sta PORTB - lda #>__CHARGEN_START__ - sta CHBAS - sta CHBASE -.endmacro - -.macro enable_rom - lda PORTB - ora #1 - wsync - sta PORTB - lda #$E0 - sta CHBAS - sta CHBASE -.endmacro -.macro enable_rom_quick - lda PORTB - ora #1 - sta PORTB - lda #$E0 - sta CHBAS - sta CHBASE -.endmacro - .segment "INIT" ; Turn off ROMs, install system and interrupt wrappers, set new chargen pointer -- 2.39.5