From 3943db72e88659e1effb8dcb696094db5f41bd81 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 8 Nov 2023 23:59:36 -0500 Subject: [PATCH] second: iigs support seems to be working --- demos/second/Makefile | 2 ++ demos/second/gs_interrupt.s | 9 +++++++ demos/second/hardware.inc | 1 + demos/second/hardware_detect.s | 27 ++++++++++++++++++-- demos/second/{ => old}/second.s | 0 demos/second/part00_boot/fake_bios.s | 31 +++++++++++++++++++---- demos/second/pt3_lib_mockingboard_setup.s | 2 ++ demos/second/qload2.s | 1 + demos/second/start.s | 13 +++++++++- 9 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 demos/second/gs_interrupt.s rename demos/second/{ => old}/second.s (100%) diff --git a/demos/second/Makefile b/demos/second/Makefile index 3caaf08a..2b1b07b6 100644 --- a/demos/second/Makefile +++ b/demos/second/Makefile @@ -243,6 +243,7 @@ music.inc: generate_common MUSIC ./generate_common -a 0xd000 -s copy_aux_main music.lst >> music.inc ./generate_common -a 0xd000 -s mute_ay_both music.lst >> music.inc ./generate_common -a 0xd000 -s unmute_ay_both music.lst >> music.inc + ./generate_common -a 0xd000 -s interrupt_handler music.lst >> music.inc music2.inc: generate_common MUSIC2 ./generate_common -a 0xd000 -s pt3_init_song music2.lst > music2.inc @@ -258,6 +259,7 @@ music2.inc: generate_common MUSIC2 ./generate_common -a 0xd000 -s copy_aux_main music2.lst >> music2.inc ./generate_common -a 0xd000 -s mute_ay_both music2.lst >> music2.inc ./generate_common -a 0xd000 -s unmute_ay_both music2.lst >> music2.inc + ./generate_common -a 0xd000 -s interrupt_handler music2.lst >> music2.inc #### diff --git a/demos/second/gs_interrupt.s b/demos/second/gs_interrupt.s new file mode 100644 index 00000000..cec38027 --- /dev/null +++ b/demos/second/gs_interrupt.s @@ -0,0 +1,9 @@ + +gs_interrupt_handler: + ; swap back in language card + + ; read/write RAM, use $d000 bank1 + bit $C083 + bit $C083 + + jmp interrupt_handler diff --git a/demos/second/hardware.inc b/demos/second/hardware.inc index 3024b697..1cf29d20 100644 --- a/demos/second/hardware.inc +++ b/demos/second/hardware.inc @@ -12,6 +12,7 @@ TBCOLOR = $C022 ; IIgs text fg/bg colors NEWVIDEO = $C029 ; IIgs graphics modes SPEAKER = $C030 CLOCKCTL = $C034 ; bits 0-3 are IIgs border color +CYAREG = $C036 ; iigs motor detect and clock speed SET_GR = $C050 SET_TEXT = $C051 FULLGR = $C052 diff --git a/demos/second/hardware_detect.s b/demos/second/hardware_detect.s index 782b3381..296878e3 100644 --- a/demos/second/hardware_detect.s +++ b/demos/second/hardware_detect.s @@ -1,7 +1,10 @@ ;==================== ; Hardware Detect +; called for disk1 and disk2 -; simplified version for disk2 +; simplified version that just detects model and mockingboard +; for the fake BIOS we do a bit more, but we do rely +; on this being run first hardware_detect: @@ -13,10 +16,24 @@ hardware_detect: jsr detect_appleii_model lda APPLEII_MODEL - cmp 'g' + cmp #'g' bne not_iigs is_a_iigs: + + ; enable 1MHz mode + ; see hw.accel.a in 4cade +setspeed: + lda CYAREG + and #$7f + sta CYAREG + + ; gr/text page2 handling broken on early IIgs models + ; this enables the workaround + + jsr ROM_TEXT2COPY ; set alternate display mode on IIgs + + ; set background color to black instead of blue lda NEWVIDEO and #%00011111 ; bit 7 = 0 -> IIgs Apple II-compat video modes @@ -30,6 +47,12 @@ is_a_iigs: sta CLOCKCTL ; black border sta CLOCKCTL ; set twice for VidHD + ; gs always swaps in RAM + lda #gs_interrupt_handler + sta $3FF + not_iigs: diff --git a/demos/second/second.s b/demos/second/old/second.s similarity index 100% rename from demos/second/second.s rename to demos/second/old/second.s diff --git a/demos/second/part00_boot/fake_bios.s b/demos/second/part00_boot/fake_bios.s index c790be4b..eda52467 100644 --- a/demos/second/part00_boot/fake_bios.s +++ b/demos/second/part00_boot/fake_bios.s @@ -36,6 +36,17 @@ bios_test: bne not_iigs is_a_iigs: + + ; we do this earlier in detect_hardware +.if 0 + ; enable 1MHz mode + ; see hw.accel.a in 4cade +setspeed: + lda CYAREG + and #$7f + sta CYAREG + + ; set background color to black instead of blue lda NEWVIDEO and #%00011111 ; bit 7 = 0 -> IIgs Apple II-compat video modes @@ -48,6 +59,7 @@ is_a_iigs: lda #$00 sta CLOCKCTL ; black border sta CLOCKCTL ; set twice for VidHD +.endif lda #'s' sta model_patch_1+9 @@ -198,14 +210,24 @@ done_detect_cpu: ;===================== ; Detect mockingboard ;===================== - + ; did this earlier too +.if 0 lda #0 sta SOUND_STATUS + PT3_ENABLE_APPLE_IIC = 1 + jsr mockingboard_detect bcc mockingboard_notfound +.endif + + ; patch if necessary + + lda SOUND_STATUS + and #SOUND_MOCKINGBOARD + beq mockingboard_notfound mockingboard_found: lda MB_ADDR_H @@ -214,13 +236,12 @@ mockingboard_found: sta mock_slot_patch+7 - lda SOUND_STATUS - ora #SOUND_MOCKINGBOARD - sta SOUND_STATUS +; lda SOUND_STATUS +; ora #SOUND_MOCKINGBOARD +; sta SOUND_STATUS mockingboard_notfound: - ;=================== ; Load graphics ;=================== diff --git a/demos/second/pt3_lib_mockingboard_setup.s b/demos/second/pt3_lib_mockingboard_setup.s index e05be8b7..7f925ad1 100644 --- a/demos/second/pt3_lib_mockingboard_setup.s +++ b/demos/second/pt3_lib_mockingboard_setup.s @@ -212,6 +212,8 @@ mockingboard_setup_interrupt: lda #>interrupt_handler sta $ffff + ; note elsewhere we put gs_interrupt_handler in $3FE/$3FF + ; nop out the "lda $45" since we are bypassing the ROM irq handler ; that puts A in $45 lda #$EA diff --git a/demos/second/qload2.s b/demos/second/qload2.s index 5000843b..de0ff9ab 100644 --- a/demos/second/qload2.s +++ b/demos/second/qload2.s @@ -191,6 +191,7 @@ PT3_ENABLE_APPLE_IIC = 1 .include "pt3_lib_detect_model.s" .include "pt3_lib_mockingboard_detect.s" + .include "gs_interrupt.s" mod7_table = $1c00 div7_table = $1d00 diff --git a/demos/second/start.s b/demos/second/start.s index fda3980e..f4451d26 100644 --- a/demos/second/start.s +++ b/demos/second/start.s @@ -15,7 +15,7 @@ second_start: ; initializations ;===================== - jsr hardware_detect ; FIXME: remove when hook up part00 + jsr hardware_detect jsr hgr_make_tables @@ -62,8 +62,13 @@ restart: ; patch mockingboard + lda SOUND_STATUS + beq skip_mbp1 + jsr mockingboard_patch ; patch to work in slots other than 4? +skip_mbp1: + ;======================= ; Set up 50Hz interrupt ;======================== @@ -200,7 +205,11 @@ load_program_loop: ;======================== ; patch mockingboard + lda SOUND_STATUS + beq skip_mbp2 jsr mockingboard_patch ; patch to work in slots other than 4? +skip_mbp2: + jsr mockingboard_init ;======================= ; Set up 50Hz interrupt @@ -542,6 +551,8 @@ forever: .include "wait_keypress.s" .include "zx02_optim.s" + .include "gs_interrupt.s" + ;.include "title.s" disk_change_string: