From 08c96a1f321ca74f4e83fd0b7571635e61e979bc Mon Sep 17 00:00:00 2001 From: Christopher RYU Date: Fri, 20 Oct 2023 09:06:40 +0900 Subject: [PATCH 1/2] Use logic to determine which (if any) accelerators we enable/disable --- src/client/main.asm | 75 ++++++++++++++++++++++++- src/client/prodos/ethernet/ethproto.asm | 22 -------- 2 files changed, 74 insertions(+), 23 deletions(-) diff --git a/src/client/main.asm b/src/client/main.asm index 9479b867..5d1c6d13 100644 --- a/src/client/main.asm +++ b/src/client/main.asm @@ -41,6 +41,9 @@ entrypoint: tsx ; Get a handle to the stackptr stx top_stack ; Save it for full pops during aborts + jsr DETECT_CPU ; Try to figure out if we're running an accelerator + jsr ACCEL_DISABLE ; disable accelerators (if present) + jsr INIT_SCREEN ; Sets up the screen for behaviors we expect jsr MAKETBL ; Prepare our CRC tables JSR_GET_PREFIX ; Get our current prefix (ProDOS only) @@ -170,6 +173,7 @@ KQUIT: KQUITENTRY: lda #MENU_QUIT jsr HILIGHT_MENU + jsr ACCEL_ENABLE jmp QUIT ; Head into OS oblivion KLEFT: @@ -354,6 +358,75 @@ BumpA1: BumpA1Done: rts +;--------------------------------------------------------- +; ACCEL_* - disable/enable accelerators (if present) +;--------------------------------------------------------- +ACCEL_DISABLE: + lda CPU_TYPE + beq AD_EXIT ; if NMOS, no accel, exit + cmp #2 ; if 65816, do UltraWarp + beq AD_65816 + lda #$5a ; ... otherwise, we're 65C02, do Zip/TransWarp + sta $c05a + sta $c05a + sta $c05a + sta $c05a ; Unlock ZipChip + + lda #$00 + sta $c05a ; Disable ZipChip + lda #$01 + sta $C074 ; Disable TransWarp + bne AD_EXIT + +AD_65816: + lda #$01 + sta $C05D ; Slow down UltraWarp +AD_EXIT: + rts + +ACCEL_ENABLE: + lda CPU_TYPE + beq AE_EXIT ; if NMOS, no accel, exit + cmp #2 ; if 65816, do UltraWarp + beq AE_65816 + lda #$00 + sta $c05b ; Enable ZipChip + + lda #$a5 + sta $c05a ; Lock ZipChip + + lda #$00 ; Enable TransWarp + sta $C074 + beq AE_EXIT + +AE_65816: + lda #$01 + sta $C05C ; Speed up UltraWarp +AE_EXIT: + rts + +;--------------------------------------------------------- +;DETECT_CPU - identify CPU, to try to logic our way through +; accelerator detection +;--------------------------------------------------------- +CPU_TYPE: .byte 0 ; default to NMOS 6502 +DETECT_CPU: +.setcpu "6502" + lda #0 +.setcpu "65C02" + bra :+ ; undocumented two-byte NOP on NMOS +.setcpu "6502" + beq CT_OUT ; we have an NMOS 6502 +: inc CPU_TYPE ; we have a CMOS 65C02/65C816 ... +.setcpu "65816" + lda CPU_TYPE + xba ; exchange B and A (65C816 only) + dec ; A=0 (65C02), A=1 (65C816, via B) + xba ; swap back (again, 65C816 only) + inc ; A=1 (65C02), A=2 (65C816, via B) + sta CPU_TYPE +.setcpu "6502" +CT_OUT: rts ;--------------------------------------------------------- ; Table of menu highlighting coordinates @@ -374,4 +447,4 @@ MENUHITBL: CUR_MENU: .byte MENU_CONFIG PREV_MENU: - .byte $ff \ No newline at end of file + .byte $ff diff --git a/src/client/prodos/ethernet/ethproto.asm b/src/client/prodos/ethernet/ethproto.asm index 80f9fb1e..d899145b 100644 --- a/src/client/prodos/ethernet/ethproto.asm +++ b/src/client/prodos/ethernet/ethproto.asm @@ -956,31 +956,9 @@ RECEIVE_LOOP_WARM: rts RECEIVE_LOOP_PAUSE: - lda #$5a - sta $c05a - sta $c05a - sta $c05a - sta $c05a ; Unlock ZipChip - - lda #$00 - sta $c05a ; Disable ZipChip - - lda #$01 - sta $C074 ; Disable TransWarp - PauseValue: lda #$7f jsr DELAY ; Wait! - - lda #$00 - sta $c05b ; Enable ZipChip - - lda #$a5 - sta $c05a ; Lock ZipChip - - lda #$00 ; Enable TransWarp - sta $C074 - jmp RECEIVE_LOOP_WARM From bd8a5d471f4466fb2d6667cb995a2ba55658ab15 Mon Sep 17 00:00:00 2001 From: Christopher RYU Date: Sat, 21 Oct 2023 10:52:47 +0900 Subject: [PATCH 2/2] Detect GS (so that we can handle ZipGS/TransWarpGS) and disable accelerators after generating CRC table. --- src/client/main.asm | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/client/main.asm b/src/client/main.asm index 5d1c6d13..14b549f2 100644 --- a/src/client/main.asm +++ b/src/client/main.asm @@ -41,11 +41,10 @@ entrypoint: tsx ; Get a handle to the stackptr stx top_stack ; Save it for full pops during aborts - jsr DETECT_CPU ; Try to figure out if we're running an accelerator - jsr ACCEL_DISABLE ; disable accelerators (if present) - jsr INIT_SCREEN ; Sets up the screen for behaviors we expect jsr MAKETBL ; Prepare our CRC tables + jsr DETECT_CPU ; Try to figure out if we're running an accelerator + jsr ACCEL_DISABLE ; disable accelerators (if present) JSR_GET_PREFIX ; Get our current prefix (ProDOS only) jsr BLOAD ; Load up user parameters, if any jsr PARMDFT ; Set up parameters @@ -362,22 +361,25 @@ BumpA1Done: ; ACCEL_* - disable/enable accelerators (if present) ;--------------------------------------------------------- ACCEL_DISABLE: + lda $FE1F ; ][ and //e have $60, GS has detect routine + cmp #$60 + bne AD_65C02 ; if GS, do Zip/TransWarp lda CPU_TYPE - beq AD_EXIT ; if NMOS, no accel, exit - cmp #2 ; if 65816, do UltraWarp + beq AD_EXIT ; NMOS 6502 isn't accelerated, skip + cmp #2 ; non-GS 65816 is UltraWarp beq AD_65816 - lda #$5a ; ... otherwise, we're 65C02, do Zip/TransWarp +AD_65C02: + lda #$5a ; Unlock ZipChip sta $c05a sta $c05a sta $c05a - sta $c05a ; Unlock ZipChip + sta $c05a ; Unlock finished lda #$00 sta $c05a ; Disable ZipChip lda #$01 sta $C074 ; Disable TransWarp bne AD_EXIT - AD_65816: lda #$01 sta $C05D ; Slow down UltraWarp @@ -385,10 +387,14 @@ AD_EXIT: rts ACCEL_ENABLE: + lda $FE1F ; ][ and //e have $60, GS has detect routine + cmp #$60 + bne AE_65C02 ; if GS, do Zip/TransWarp lda CPU_TYPE - beq AE_EXIT ; if NMOS, no accel, exit - cmp #2 ; if 65816, do UltraWarp + beq AE_EXIT ; NMOS 6502 isn't accelerated, skip + cmp #2 ; non-GS 65816 is UltraWarp beq AE_65816 +AE_65C02: lda #$00 sta $c05b ; Enable ZipChip @@ -398,7 +404,6 @@ ACCEL_ENABLE: lda #$00 ; Enable TransWarp sta $C074 beq AE_EXIT - AE_65816: lda #$01 sta $C05C ; Speed up UltraWarp