From 1ead39db6ea680a769184cc97e3f27652d08cba7 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Mon, 28 Aug 2023 21:45:35 -0400 Subject: [PATCH] fake_bios: detect language card --- graphics/hgr/fake_bios/Makefile | 2 +- graphics/hgr/fake_bios/fake_bios.s | 44 ++++++++++++++++++++++++------ graphics/hgr/fake_bios/lc_detect.s | 40 +++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 graphics/hgr/fake_bios/lc_detect.s diff --git a/graphics/hgr/fake_bios/Makefile b/graphics/hgr/fake_bios/Makefile index d7be85a8..a4c32c78 100644 --- a/graphics/hgr/fake_bios/Makefile +++ b/graphics/hgr/fake_bios/Makefile @@ -26,7 +26,7 @@ FAKE_BIOS: fake_bios.o fake_bios.o: fake_bios.s \ hgr_clear_screen.s \ font_console_1x8.s fonts/a2_cga_thin.inc \ - pt3_lib_detect_model.s \ + pt3_lib_detect_model.s lc_detect.s \ zx02_optim.s graphics/a2_energy.hgr.zx02 ca65 -o fake_bios.o fake_bios.s -l fake_bios.lst diff --git a/graphics/hgr/fake_bios/fake_bios.s b/graphics/hgr/fake_bios/fake_bios.s index 6afe5a86..552eecea 100644 --- a/graphics/hgr/fake_bios/fake_bios.s +++ b/graphics/hgr/fake_bios/fake_bios.s @@ -18,9 +18,9 @@ bios_test: jsr build_tables - ;=================== - ; Hardware Detect - ;=================== + ;======================= + ; Hardware Detect Model + ;======================= jsr detect_appleii_model @@ -52,6 +52,31 @@ not_iigs: lda APPLEII_MODEL sta model_patch_1+8 ; patch to ' ' '+' 'e' 'c' or 'g' + ;======================= + ; Hardware Detect RAM + ;======================= + + lda #48 ; FIXME: detect less on earlier models? + sta TOTAL_RAM + + jsr detect_language_card + bcs ram_no_lc +ram_yes_lc: + ; carry clear here + lda #16 + adc TOTAL_RAM + sta TOTAL_RAM + + ; update text string + lda #'1' + sta lang_card_patch+34 + lda #'6' + sta lang_card_patch+35 + + +ram_no_lc: + + ;=================== ; Load graphics @@ -91,7 +116,7 @@ not_iigs: ;========================= ; do fake memory count - lda #128 + lda TOTAL_RAM sta MEMCOUNT memcount_loop: lda KEYPRESS ; 4 @@ -102,7 +127,7 @@ memcount_loop: jsr increment_memory dec MEMCOUNT - bpl memcount_loop + bne memcount_loop done_memcount: @@ -238,9 +263,11 @@ bios_message_2: .byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E .byte $1E,$1E,$1E,$1E,$1E,$1E .byte $1C, 13,0 - .byte $1F," CPU Type: 65C02 ",$14," Base Memory: 48K ",$1F,13,0 ; 16 - .byte $1F," Co-Proc: NONE ",$14," Lang Card: 16K ",$1F,13,0 ; 24 - .byte $1F," Clock: 1.023MHz ",$14," AUX Memory: 64K ",$1F,13,0 ; 32 + .byte $1F," CPU Type: 6502 ",$14," Base Memory: 48K ",$1F,13,0 ; 16 +lang_card_patch: ; +34 + .byte $1F," Co-Proc: NONE ",$14," Lang Card: 0K ",$1F,13,0 ; 24 +aux_mem_patch: ; +34 + .byte $1F," Clock: 1.023MHz ",$14," AUX Memory: 0K ",$1F,13,0 ; 32 .byte $19 ; 40 .byte $1E,$1E,$1E,$1E,$1E,$1E,$1E,$1E @@ -562,3 +589,4 @@ early_out: .include "hgr_clear_screen.s" .include "pt3_lib_detect_model.s" +.include "lc_detect.s" diff --git a/graphics/hgr/fake_bios/lc_detect.s b/graphics/hgr/fake_bios/lc_detect.s new file mode 100644 index 00000000..3123a6ae --- /dev/null +++ b/graphics/hgr/fake_bios/lc_detect.s @@ -0,0 +1,40 @@ +; Code from TotalReplay by 4am and qkumba + +;------------------------------------------------------------------------------ +; Has64K +; Checks whether computer has functioning language card (64K) +; +; in: none +; out: C clear if 64K detected +; C set if 64K not detected +; all other flags and registers clobbered +; ROM in memory (not LC RAM bank) +;------------------------------------------------------------------------------ + +detect_language_card: + + ; enable language card + ; READ_RAM1_WRITE_RAM1 + + bit $C08B + bit $C08B + + lda #$AA ; test #1 for $D0 page + sta $D000 + eor $D000 + bne no_lc + lsr $D000 ; test #2 for $D0 page + lda #$55 + eor $D000 + bne no_lc + clc + bcc done_detect + +no_lc: + sec + +done_detect: + ; READ_ROM_NO_WRITE + bit $C08A + + rts