From 8b00636f6687bf9e8d524322b496ca03797db4c9 Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sat, 10 May 2014 11:56:54 -0700 Subject: [PATCH] refactor PAGE2 switch to C --- src/asm386/memory.S | 57 --------------------------------------------- src/vm.c | 52 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 57 deletions(-) diff --git a/src/asm386/memory.S b/src/asm386/memory.S index 7cfabd49..a3a862ee 100644 --- a/src/asm386/memory.S +++ b/src/asm386/memory.S @@ -149,63 +149,6 @@ enabled. ----------------------------------------------------------------- */ -/* PAGE2 off. if 80STORE on then we use main text page1, and if HIRES - on we also use main hires page1, regardless of RAMRD and - RAMWRT. */ -E(iie_page2_off) - testl $SS_PAGE2, SN(softswitches) # already off? - jz ram_nop - andl $~(SS_PAGE2|SS_SCREEN), SN(softswitches) - testl $SS_80STORE, SN(softswitches) - jz _iie_page2_off_hires_off # no 80STORE - andl $~(SS_TEXTRD|SS_TEXTWRT), SN(softswitches) - movl $SN(apple_ii_64k), SN(base_textrd) - movl $SN(apple_ii_64k), SN(base_textwrt) - testl $SS_HIRES, SN(softswitches) - jz _iie_page2_off_hires_off # no HIRES - andl $~(SS_HGRRD|SS_HGRWRT), SN(softswitches) - movl $SN(apple_ii_64k), SN(base_hgrrd) - movl $SN(apple_ii_64k), SN(base_hgrwrt) -_iie_page2_off_hires_off: - pushal - pushl $0 # page 1 main - call SN(video_setpage) - addl $4, %esp - popal -/* call SN(video_redraw)# redraw */ - ret - - -/* PAGE2 on. if 80STORE on then we use aux text page 1, and if HIRES - on we also use aux hires page 1, regardless of RAMRD and - RAMWRT. */ -E(iie_page2_on) - testl $SS_PAGE2, SN(softswitches) # already on? - jnz ram_nop - orl $SS_PAGE2, SN(softswitches) - testl $SS_80STORE, SN(softswitches) - jz _iie_page2_on_80store_off # no 80STORE - orl $(SS_TEXTRD|SS_TEXTWRT), SN(softswitches) - movl $SN(apple_ii_64k)+BANK2, SN(base_textrd) - movl $SN(apple_ii_64k)+BANK2, SN(base_textwrt) - testl $(SS_HIRES), SN(softswitches) - jz _iie_page2_on_cont - orl $(SS_HGRRD|SS_HGRWRT), SN(softswitches) - movl $SN(apple_ii_64k)+BANK2, SN(base_hgrrd) - movl $SN(apple_ii_64k)+BANK2, SN(base_hgrwrt) -_iie_page2_on_cont: - ret - -_iie_page2_on_80store_off: # no 80STORE - orl $SS_SCREEN, SN(softswitches) - pushal - pushl $1 # page 2 main - call SN(video_setpage) - addl $4, %esp - popal -/* call SN(video_redraw)# redraw */ - ret - E(read_switch_graphics) testl $SS_TEXT, SN(softswitches) jz ram_nop diff --git a/src/vm.c b/src/vm.c index d3f5e70f..3ac415c2 100644 --- a/src/vm.c +++ b/src/vm.c @@ -61,3 +61,55 @@ GLUE_C_READ(speaker_toggle) return 0; } +// ---------------------------------------------------------------------------- +// Softswitches + +GLUE_C_READ(iie_page2_off) +{ + if (!(softswitches & SS_PAGE2)) { + return 0x0; // TODO: no early return? + } + + softswitches &= ~(SS_PAGE2|SS_SCREEN); + + if (softswitches & SS_80STORE) { + softswitches &= ~(SS_TEXTRD|SS_TEXTWRT); + base_textrd = apple_ii_64k[0]; + base_textwrt = apple_ii_64k[0]; + if (softswitches & SS_HIRES) { + softswitches &= ~(SS_HGRRD|SS_HGRWRT); + base_hgrrd = apple_ii_64k[0]; + base_hgrwrt = apple_ii_64k[0]; + } + } + + video_setpage(0); + + return 0x0; +} + +GLUE_C_READ(iie_page2_on) +{ + if (softswitches & SS_PAGE2) { + return 0x0; // TODO: no early return? + } + + softswitches |= SS_PAGE2; + + if (softswitches & SS_80STORE) { + softswitches |= (SS_TEXTRD|SS_TEXTWRT); + base_textrd = apple_ii_64k[1]; + base_textwrt = apple_ii_64k[1]; + if (softswitches & SS_HIRES) { + softswitches |= (SS_HGRRD|SS_HGRWRT); + base_hgrrd = apple_ii_64k[1]; + base_hgrwrt = apple_ii_64k[1]; + } + } else { + softswitches |= SS_SCREEN; + video_setpage(1); + } + + return 0x0; +} +