mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-07 08:30:20 +00:00
fake_bios: add 6502, aux, and mockingboard detection
This commit is contained in:
parent
1ead39db6e
commit
9aa045e297
10
graphics/hgr/fake_bios/65c02_detect.s
Normal file
10
graphics/hgr/fake_bios/65c02_detect.s
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
; relies on different behavior of decimal mode on 6502 vs 65c02
|
||||
detect_65c02:
|
||||
sed ; set decimal mode
|
||||
clc ; clear carry for add
|
||||
lda #$99 ; 99 decimal
|
||||
adc #$01 ; +1 gives 00 and sets Z on 65C02
|
||||
cld ; exit decimal mode
|
||||
|
||||
rts
|
|
@ -26,7 +26,9 @@ 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 lc_detect.s \
|
||||
pt3_lib_detect_model.s lc_detect.s aux_detect.s \
|
||||
65c02_detect.s pt3_lib_mockingboard_detect.s \
|
||||
pt3_lib_mockingboard_setup.s \
|
||||
zx02_optim.s graphics/a2_energy.hgr.zx02
|
||||
ca65 -o fake_bios.o fake_bios.s -l fake_bios.lst
|
||||
|
||||
|
|
51
graphics/hgr/fake_bios/aux_detect.s
Normal file
51
graphics/hgr/fake_bios/aux_detect.s
Normal file
|
@ -0,0 +1,51 @@
|
|||
detect_aux_ram:
|
||||
|
||||
; if Apple IIgs or IIc assume 128k
|
||||
; FIXME: Apple IIgs there are routines to get more accurate count
|
||||
|
||||
lda APPLEII_MODEL
|
||||
cmp #'g'
|
||||
beq return_64k
|
||||
cmp #'c'
|
||||
beq return_64k
|
||||
|
||||
cmp #'e'
|
||||
bne return_0k ; assume none if not IIe
|
||||
|
||||
; enable AUX zp
|
||||
sta $C009
|
||||
|
||||
; write $AA to $FF FF:AUX = AA, FF:MAIN=??
|
||||
lda #$AA
|
||||
sta $FF
|
||||
|
||||
; disable AUX zp
|
||||
sta $C008
|
||||
|
||||
; write $55 to $FF FF:AUX=AA, FF:MAIN=55
|
||||
lda #$55
|
||||
sta $FF
|
||||
|
||||
; enable AUX zp
|
||||
sta $C009
|
||||
ldx $FF
|
||||
|
||||
; disable AUX zp ; if aux, then X=AA, else X=55
|
||||
sta $C008
|
||||
|
||||
cpx #$AA
|
||||
bne return_0k
|
||||
|
||||
return_64k:
|
||||
lda #64
|
||||
rts
|
||||
|
||||
return_1k:
|
||||
lda #1
|
||||
rts
|
||||
|
||||
return_0k:
|
||||
lda #0
|
||||
rts
|
||||
|
||||
|
|
@ -21,6 +21,7 @@ bios_test:
|
|||
;=======================
|
||||
; Hardware Detect Model
|
||||
;=======================
|
||||
; Yes Michaelangel007 I will eventually update linux_logo 6502
|
||||
|
||||
jsr detect_appleii_model
|
||||
|
||||
|
@ -42,23 +43,56 @@ is_a_iigs:
|
|||
sta CLOCKCTL ; black border
|
||||
sta CLOCKCTL ; set twice for VidHD
|
||||
|
||||
lda 's'
|
||||
lda #'s'
|
||||
sta model_patch_1+9
|
||||
|
||||
lda #'C'
|
||||
sta cpu_patch_1+14
|
||||
sta cpu_patch_2+2
|
||||
lda #'8'
|
||||
sta cpu_patch_1+15
|
||||
sta cpu_patch_2+3
|
||||
lda #'1'
|
||||
sta cpu_patch_1+16
|
||||
sta cpu_patch_2+4
|
||||
lda #'6'
|
||||
sta cpu_patch_1+17
|
||||
sta cpu_patch_2+5
|
||||
not_iigs:
|
||||
|
||||
; update text printed
|
||||
|
||||
lda APPLEII_MODEL
|
||||
cmp #'3'
|
||||
bne no_not_a_iii
|
||||
|
||||
lda #'/' ; 3 slashes
|
||||
sta model_patch_1+6
|
||||
sta model_patch_1+7
|
||||
sta model_patch_1+8
|
||||
bne hardware_detect_ram ; bra
|
||||
|
||||
no_not_a_iii:
|
||||
|
||||
lda APPLEII_MODEL
|
||||
sta model_patch_1+8 ; patch to ' ' '+' 'e' 'c' or 'g'
|
||||
|
||||
;=======================
|
||||
; Hardware Detect RAM
|
||||
;=======================
|
||||
hardware_detect_ram:
|
||||
|
||||
;=================================================
|
||||
; assume 48k for base model (not necessarily true)
|
||||
|
||||
lda #48 ; FIXME: detect less on earlier models?
|
||||
sta TOTAL_RAM
|
||||
|
||||
;================================================
|
||||
; detect language card 16k
|
||||
; could cheat and just make it 64k in this case
|
||||
; can you have a language card on a 4k system?
|
||||
|
||||
jsr detect_language_card
|
||||
bcs ram_no_lc
|
||||
ram_yes_lc:
|
||||
|
@ -73,10 +107,110 @@ ram_yes_lc:
|
|||
lda #'6'
|
||||
sta lang_card_patch+35
|
||||
|
||||
|
||||
ram_no_lc:
|
||||
|
||||
;================================================
|
||||
; detect aux memory
|
||||
; iigs we're lazy and say 64k
|
||||
; iic always 64k AUX
|
||||
; iie we have to probe
|
||||
; in theory can have 0k, 1k or 64k of it
|
||||
|
||||
jsr detect_aux_ram
|
||||
|
||||
cmp #0
|
||||
beq ram_no_aux
|
||||
|
||||
cmp #1
|
||||
beq ram_1k_aux
|
||||
ram_64k_aux:
|
||||
clc
|
||||
lda TOTAL_RAM
|
||||
adc #64
|
||||
sta TOTAL_RAM
|
||||
|
||||
lda #'6'
|
||||
sta aux_mem_patch+34
|
||||
lda #'4'
|
||||
sta aux_mem_patch+35
|
||||
|
||||
|
||||
|
||||
bne ram_done_aux ; bra
|
||||
|
||||
ram_1k_aux:
|
||||
inc TOTAL_RAM
|
||||
lda #'1'
|
||||
sta aux_mem_patch+35
|
||||
|
||||
ram_no_aux:
|
||||
ram_done_aux:
|
||||
;====================
|
||||
; detect CPU
|
||||
;====================
|
||||
|
||||
lda APPLEII_MODEL
|
||||
cmp #'g' ; already handled IIgs
|
||||
beq done_detect_cpu
|
||||
|
||||
jsr detect_65c02
|
||||
bne was_not_65c02
|
||||
|
||||
lda #'C'
|
||||
sta cpu_patch_1+14
|
||||
sta cpu_patch_2+2
|
||||
lda #'0'
|
||||
sta cpu_patch_1+15
|
||||
sta cpu_patch_2+3
|
||||
lda #'2'
|
||||
sta cpu_patch_1+16
|
||||
sta cpu_patch_2+4
|
||||
|
||||
was_not_65c02:
|
||||
|
||||
done_detect_cpu:
|
||||
|
||||
;====================
|
||||
; detect disk slot
|
||||
;====================
|
||||
; this depends on DOS3.3 loading
|
||||
|
||||
lda $B5F7 ; slot*16
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
adc #'0'
|
||||
sta slot_patch1+1
|
||||
sta slot_patch2+1
|
||||
sta slot_patch3+1
|
||||
sta slot_patch5+7
|
||||
sta slot_patch6+7
|
||||
|
||||
;=====================
|
||||
; Detect mockingboard
|
||||
;=====================
|
||||
|
||||
lda #0
|
||||
sta SOUND_STATUS
|
||||
|
||||
PT3_ENABLE_APPLE_IIC = 1
|
||||
|
||||
jsr mockingboard_detect
|
||||
bcc mockingboard_notfound
|
||||
|
||||
mockingboard_found:
|
||||
lda MB_ADDR_H
|
||||
and #$7
|
||||
ora #$30
|
||||
|
||||
sta mock_slot_patch+7
|
||||
|
||||
lda SOUND_STATUS
|
||||
ora #SOUND_MOCKINGBOARD
|
||||
sta SOUND_STATUS
|
||||
|
||||
mockingboard_notfound:
|
||||
|
||||
;===================
|
||||
; Load graphics
|
||||
|
@ -172,6 +306,7 @@ done_memcount:
|
|||
|
||||
jsr BELL
|
||||
|
||||
; print first part of message
|
||||
|
||||
lda #10
|
||||
sta CH
|
||||
|
@ -180,9 +315,26 @@ done_memcount:
|
|||
|
||||
lda #<bios_message_2
|
||||
ldy #>bios_message_2
|
||||
ldx #11
|
||||
ldx #8
|
||||
jsr draw_multiple_strings
|
||||
|
||||
; optionally print mockingboard text
|
||||
|
||||
lda SOUND_STATUS
|
||||
beq print_rest
|
||||
|
||||
jsr DrawCondensedStringAgain
|
||||
|
||||
print_rest:
|
||||
|
||||
; print rest
|
||||
lda #<super_serial_text
|
||||
ldy #>super_serial_text
|
||||
ldx #2
|
||||
jsr draw_multiple_strings
|
||||
|
||||
|
||||
|
||||
ldx #10
|
||||
jsr long_wait
|
||||
|
||||
|
@ -244,9 +396,10 @@ end:
|
|||
bios_message_1:
|
||||
.byte "Apple II Modular BIOS",13,0
|
||||
.byte "Copyright (C) 1977-1991",13,13,0
|
||||
model_patch_1: ;+8
|
||||
model_patch_1: ; +8
|
||||
.byte "Apple II ",13,13,0
|
||||
.byte "65C02 CPU at 1.023MHz",13,0
|
||||
cpu_patch_2: ; +2
|
||||
.byte "6502 CPU at 1.023MHz",13,0
|
||||
.byte "Memory Test: 0B OK",13,0
|
||||
bios_message_1a:
|
||||
.byte "Press ",$17,"-D to enter SETUP",13,0
|
||||
|
@ -263,9 +416,10 @@ 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: 6502 ",$14," Base Memory: 48K ",$1F,13,0 ; 16
|
||||
cpu_patch_1: ; +14
|
||||
.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
|
||||
.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
|
||||
|
||||
|
@ -277,9 +431,16 @@ aux_mem_patch: ; +34
|
|||
.byte $1E,$1E,$1E,$1E,$1E,$1E
|
||||
.byte $18, 13, 0
|
||||
|
||||
disk_text:
|
||||
slot_patch5: ;+7
|
||||
.byte $1F," Slot 6 Disk 1: Disk II 140K ",$1F,13,0 ; 48
|
||||
slot_patch6:
|
||||
.byte $1F," Slot 6 Disk 2: Disk II 140K ",$1F,13,0 ; 56
|
||||
|
||||
mockingboard_text:
|
||||
mock_slot_patch: ; +7
|
||||
.byte $1F," Slot 4 : VIA 6522/Mockingboard ",$1F,13,0 ; 64
|
||||
super_serial_text:
|
||||
.byte $1F," Slot 1 : Super Serial Card ",$1F,13,0 ; 72
|
||||
|
||||
|
||||
|
@ -296,6 +457,7 @@ bios_message3:
|
|||
|
||||
|
||||
bios_message4:
|
||||
slot_patch1:
|
||||
.byte "S6D1>",0 ; 104
|
||||
.byte "c",0
|
||||
.byte "d",0
|
||||
|
@ -317,6 +479,7 @@ bios_message4:
|
|||
|
||||
bios_message5:
|
||||
.byte 13,0
|
||||
slot_patch2:
|
||||
.byte "S6D1>",0 ; 112
|
||||
.byte "d",0
|
||||
.byte "i",0
|
||||
|
@ -335,6 +498,7 @@ bios_message_6:
|
|||
.byte " 2 Dir(s) 52,736 Bytes free.",13,13,0
|
||||
|
||||
bios_message7:
|
||||
slot_patch3:
|
||||
.byte "S6D1>",0 ; 184
|
||||
.byte "l",0
|
||||
.byte "e",0
|
||||
|
@ -590,3 +754,7 @@ early_out:
|
|||
|
||||
.include "pt3_lib_detect_model.s"
|
||||
.include "lc_detect.s"
|
||||
.include "aux_detect.s"
|
||||
.include "65c02_detect.s"
|
||||
.include "pt3_lib_mockingboard_setup.s"
|
||||
.include "pt3_lib_mockingboard_detect.s"
|
||||
|
|
|
@ -4,30 +4,54 @@
|
|||
; this is mostly for IIc support
|
||||
; as it does interrupts differently
|
||||
|
||||
; ' ' ($20) = Apple II
|
||||
; '+' ($2B) = Apple II+
|
||||
; 'e' ($45) = Apple IIe
|
||||
; 'c' ($43) = Apple IIc
|
||||
; 'g' ($47) = Apple IIgs
|
||||
; some of this info from the document:
|
||||
; Apple II Family Identification Routines 2.2
|
||||
;
|
||||
|
||||
; ' ' = Apple II
|
||||
; '+' = Apple II+
|
||||
; 'e' = Apple IIe
|
||||
; 'c' = Apple IIc
|
||||
; 'g' = Apple IIgs
|
||||
; 'm' = mac L/C with board
|
||||
; 'j' = jplus
|
||||
; '3' = Apple III
|
||||
|
||||
detect_appleii_model:
|
||||
lda #' '
|
||||
|
||||
ldx $FBB3
|
||||
|
||||
; II is $38
|
||||
; J-plus is $C9
|
||||
; II+ is $EA (so is III)
|
||||
; IIe and newer is $06
|
||||
|
||||
cpx #$38
|
||||
cpx #$38 ; ii
|
||||
beq done_apple_detect
|
||||
|
||||
lda #'+'
|
||||
|
||||
; ii+ is EA FB1E=AD
|
||||
; iii is EA FB1E=8A 00
|
||||
|
||||
cpx #$EA
|
||||
bne not_ii_iii
|
||||
ii_or_iii:
|
||||
|
||||
lda #'+' ; ii+/iii
|
||||
|
||||
ldx $FB1E
|
||||
cpx #$AD
|
||||
beq done_apple_detect ; ii+
|
||||
|
||||
lda #'3'
|
||||
bne done_apple_detect ; bra iii
|
||||
|
||||
not_ii_iii:
|
||||
lda #'j' ; jplus
|
||||
cpx #$C9
|
||||
beq done_apple_detect
|
||||
|
||||
; TODO: check for J-plus or III?
|
||||
|
||||
cpx #$06
|
||||
bne done_apple_detect
|
||||
|
|
222
graphics/hgr/fake_bios/pt3_lib_mockingboard_detect.s
Normal file
222
graphics/hgr/fake_bios/pt3_lib_mockingboard_detect.s
Normal file
|
@ -0,0 +1,222 @@
|
|||
;===================================================================
|
||||
; code to detect mockingboard
|
||||
;===================================================================
|
||||
; this isn't always easy
|
||||
; my inclination is to just assume slot #4 but that isn't always realistic
|
||||
|
||||
; code below based on "hw.mockingboard.a" from "Total Replay"
|
||||
|
||||
;license:MIT
|
||||
; By Andrew Roughan
|
||||
; in the style of 4am for Total Replay
|
||||
;
|
||||
; Mockingboard support functions
|
||||
;
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; HasMockingboard
|
||||
; detect Mockingboard card by searching for 6522 timers across all slots
|
||||
; access 6522 timers with deterministic cycle counts
|
||||
;
|
||||
; based on prior art in Mockingboard Developers Toolkit
|
||||
; with optimisation from deater/french touch
|
||||
; also takes into account FastChip //e clock difference
|
||||
;
|
||||
; in: none
|
||||
; accelerators should be off
|
||||
; out: C set if Mockingboard found in any slot
|
||||
; if card was found, X = #$Cn where n is the slot number of the card
|
||||
; C clear if no Mockingboard found
|
||||
; other flags clobbered
|
||||
; A/Y clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
mockingboard_detect:
|
||||
|
||||
; activate Mockingboard IIc
|
||||
; + the Mockingboard has to take over Slot#4 (IIc has no slots)
|
||||
; in theory any write to the firmware area in $C400 will
|
||||
; activate it, but that might not be fast enough when detecting
|
||||
; so writing $FF to $C403/$C404 is official way to enable
|
||||
; + Note this disables permanently the mouse firmware in $C400
|
||||
; so "normal" interrupts are broken :( The hack to fix things
|
||||
; is to switch in RAM for $F000 and just replace the IRQ
|
||||
; vectors at $FFFE/$FFFF instead of $3FE/$3FF but that makes
|
||||
; it difficult if you actually wanted to use any
|
||||
; Applesoft/Monitor ROM routines
|
||||
|
||||
;.ifdef PT3_ENABLE_APPLE_IIC
|
||||
lda APPLEII_MODEL
|
||||
cmp #'C'
|
||||
bne not_iic
|
||||
|
||||
lda #$ff
|
||||
|
||||
; don't bother patching these, IIc mockingboard always slot 4
|
||||
|
||||
sta MOCK_6522_DDRA1 ; $C403
|
||||
sta MOCK_6522_T1CL ; $C404
|
||||
;.endif
|
||||
|
||||
not_iic:
|
||||
lda #$00
|
||||
sta MB_ADDR_L
|
||||
ldx #$C7 ; start at slot #7
|
||||
mb_slot_loop:
|
||||
stx MB_ADDR_H
|
||||
ldy #$04 ; 6522 #1 $Cx04
|
||||
jsr mb_timer_check
|
||||
bne mb_next_slot
|
||||
ldy #$84 ; 6522 #2 $Cx84
|
||||
jsr mb_timer_check
|
||||
bne mb_next_slot
|
||||
mb_found:
|
||||
sec ; found
|
||||
rts
|
||||
|
||||
mb_next_slot:
|
||||
dex
|
||||
cpx #$C0
|
||||
bne mb_slot_loop
|
||||
|
||||
clc ; not found
|
||||
rts
|
||||
|
||||
mb_timer_check:
|
||||
lda (MB_ADDR_L),Y ; read 6522 timer low byte
|
||||
sta MB_VALUE
|
||||
lda (MB_ADDR_L),Y ; second time
|
||||
sec
|
||||
sbc MB_VALUE
|
||||
cmp #$F8 ; looking for (-)8 cycles between reads
|
||||
beq mb_timer_check_done
|
||||
cmp #$F7 ; FastChip //e clock is different
|
||||
mb_timer_check_done:
|
||||
rts
|
||||
|
||||
|
||||
|
||||
.if 0
|
||||
|
||||
|
||||
;=======================================
|
||||
; Detect a Mockingboard card
|
||||
;=======================================
|
||||
; Based on code from the French Touch "Pure Noise" Demo
|
||||
; Attempts to time an instruction sequence with a 6522
|
||||
;
|
||||
; If found, puts in bMB
|
||||
; MB_ADDRL:MB_ADDRH has address of Mockingboard
|
||||
; returns X=0 if not found, X=1 if found
|
||||
|
||||
mockingboard_detect:
|
||||
lda #0
|
||||
sta MB_ADDRL
|
||||
|
||||
mb_detect_loop: ; self-modifying
|
||||
lda #$07 ; we start in slot 7 ($C7) and go down to 0 ($C0)
|
||||
ora #$C0 ; make it start with C
|
||||
sta MB_ADDRH
|
||||
ldy #04 ; $CX04
|
||||
ldx #02 ; 2 tries?
|
||||
mb_check_cycle_loop:
|
||||
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
|
||||
; count down
|
||||
sta PT3_TEMP ; 3 cycles
|
||||
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
|
||||
; between the two accesses to the timer
|
||||
sec
|
||||
sbc PT3_TEMP ; subtract to see if we had 8 cycles
|
||||
cmp #$f8 ; -8
|
||||
bne mb_not_in_this_slot
|
||||
dex ; decrement, try one more time
|
||||
bne mb_check_cycle_loop ; loop detection
|
||||
inx ; Mockingboard found (X=1)
|
||||
done_mb_detect:
|
||||
;stx bMB ; store result to bMB
|
||||
rts ; return
|
||||
|
||||
mb_not_in_this_slot:
|
||||
dec mb_detect_loop+1 ; decrement the "slot" (self_modify)
|
||||
bne mb_detect_loop ; loop down to one
|
||||
ldx #00
|
||||
beq done_mb_detect
|
||||
|
||||
;alternative MB detection from Nox Archaist
|
||||
; lda #$04
|
||||
; sta MB_ADDRL
|
||||
; ldx #$c7
|
||||
;
|
||||
;find_mb:
|
||||
; stx MB_ADDRH
|
||||
;
|
||||
; ;detect sound I
|
||||
;
|
||||
; sec
|
||||
; ldy #$00
|
||||
; lda (MB_ADDRL), y
|
||||
; sbc (MB_ADDRL), y
|
||||
; cmp #$05
|
||||
; beq found_mb
|
||||
; dex
|
||||
; cpx #$c0
|
||||
; bne find_mb
|
||||
; ldx #$00 ;no mockingboard found
|
||||
; rts
|
||||
;
|
||||
;found_mb:
|
||||
; ldx #$01 ;mockingboard found
|
||||
; rts
|
||||
;
|
||||
; ;optionally detect sound II
|
||||
;
|
||||
; sec
|
||||
; ldy #$80
|
||||
; lda (MB_ADDRL), y
|
||||
; sbc (MB_ADDRL), y
|
||||
; cmp #$05
|
||||
; beq found_mb
|
||||
|
||||
|
||||
;=======================================
|
||||
; Detect a Mockingboard card in Slot4
|
||||
;=======================================
|
||||
; Based on code from the French Touch "Pure Noise" Demo
|
||||
; Attempts to time an instruction sequence with a 6522
|
||||
;
|
||||
; MB_ADDRL:MB_ADDRH has address of Mockingboard
|
||||
; returns X=0 if not found, X=1 if found
|
||||
|
||||
mockingboard_detect_slot4:
|
||||
lda #0
|
||||
sta MB_ADDRL
|
||||
|
||||
mb4_detect_loop: ; self-modifying
|
||||
lda #$04 ; we're only looking in Slot 4
|
||||
ora #$C0 ; make it start with C
|
||||
sta MB_ADDRH
|
||||
ldy #04 ; $CX04
|
||||
ldx #02 ; 2 tries?
|
||||
mb4_check_cycle_loop:
|
||||
lda (MB_ADDRL),Y ; timer 6522 (Low Order Counter)
|
||||
; count down
|
||||
sta PT3_TEMP ; 3 cycles
|
||||
lda (MB_ADDRL),Y ; + 5 cycles = 8 cycles
|
||||
; between the two accesses to the timer
|
||||
sec
|
||||
sbc PT3_TEMP ; subtract to see if we had 8 cycles
|
||||
cmp #$f8 ; -8
|
||||
bne mb4_not_in_this_slot
|
||||
dex ; decrement, try one more time
|
||||
bne mb4_check_cycle_loop ; loop detection
|
||||
inx ; Mockingboard found (X=1)
|
||||
done_mb4_detect:
|
||||
rts ; return
|
||||
|
||||
mb4_not_in_this_slot:
|
||||
ldx #00
|
||||
beq done_mb4_detect
|
||||
|
||||
|
||||
|
||||
.endif
|
262
graphics/hgr/fake_bios/pt3_lib_mockingboard_setup.s
Normal file
262
graphics/hgr/fake_bios/pt3_lib_mockingboard_setup.s
Normal file
|
@ -0,0 +1,262 @@
|
|||
; Mockingboad programming:
|
||||
; + Has two 6522 I/O chips connected to two AY-3-8910 chips
|
||||
; + Optionally has some speech chips controlled via the outport on the AY
|
||||
; + Often in slot 4
|
||||
; TODO: how to auto-detect?
|
||||
; References used:
|
||||
; http://macgui.com/usenet/?group=2&id=8366
|
||||
; 6522 Data Sheet
|
||||
; AY-3-8910 Data Sheet
|
||||
|
||||
;========================
|
||||
; Mockingboard card
|
||||
; Essentially two 6522s hooked to the Apple II bus
|
||||
; Connected to AY-3-8910 chips
|
||||
; PA0-PA7 on 6522 connected to DA0-DA7 on AY
|
||||
; PB0 on 6522 connected to BC1
|
||||
; PB1 on 6522 connected to BDIR
|
||||
; PB2 on 6522 connected to RESET
|
||||
|
||||
|
||||
; left speaker
|
||||
MOCK_6522_ORB1 = $C400 ; 6522 #1 port b data
|
||||
MOCK_6522_ORA1 = $C401 ; 6522 #1 port a data
|
||||
MOCK_6522_DDRB1 = $C402 ; 6522 #1 data direction port B
|
||||
MOCK_6522_DDRA1 = $C403 ; 6522 #1 data direction port A
|
||||
MOCK_6522_T1CL = $C404 ; 6522 #1 t1 low order latches
|
||||
MOCK_6522_T1CH = $C405 ; 6522 #1 t1 high order counter
|
||||
MOCK_6522_T1LL = $C406 ; 6522 #1 t1 low order latches
|
||||
MOCK_6522_T1LH = $C407 ; 6522 #1 t1 high order latches
|
||||
MOCK_6522_T2CL = $C408 ; 6522 #1 t2 low order latches
|
||||
MOCK_6522_T2CH = $C409 ; 6522 #1 t2 high order counters
|
||||
MOCK_6522_SR = $C40A ; 6522 #1 shift register
|
||||
MOCK_6522_ACR = $C40B ; 6522 #1 auxilliary control register
|
||||
MOCK_6522_PCR = $C40C ; 6522 #1 peripheral control register
|
||||
MOCK_6522_IFR = $C40D ; 6522 #1 interrupt flag register
|
||||
MOCK_6522_IER = $C40E ; 6522 #1 interrupt enable register
|
||||
MOCK_6522_ORANH = $C40F ; 6522 #1 port a data no handshake
|
||||
|
||||
|
||||
; right speaker
|
||||
MOCK_6522_ORB2 = $C480 ; 6522 #2 port b data
|
||||
MOCK_6522_ORA2 = $C481 ; 6522 #2 port a data
|
||||
MOCK_6522_DDRB2 = $C482 ; 6522 #2 data direction port B
|
||||
MOCK_6522_DDRA2 = $C483 ; 6522 #2 data direction port A
|
||||
|
||||
; AY-3-8910 commands on port B
|
||||
; RESET BDIR BC1
|
||||
MOCK_AY_RESET = $0 ; 0 0 0
|
||||
MOCK_AY_INACTIVE = $4 ; 1 0 0
|
||||
MOCK_AY_READ = $5 ; 1 0 1
|
||||
MOCK_AY_WRITE = $6 ; 1 1 0
|
||||
MOCK_AY_LATCH_ADDR = $7 ; 1 1 1
|
||||
|
||||
.if 0
|
||||
;========================
|
||||
; Mockingboard Init
|
||||
;========================
|
||||
; Initialize the 6522s
|
||||
; set the data direction for all pins of PortA/PortB to be output
|
||||
|
||||
mockingboard_init:
|
||||
lda #$ff ; all output (1)
|
||||
|
||||
mock_init_smc1:
|
||||
sta MOCK_6522_DDRB1
|
||||
sta MOCK_6522_DDRA1
|
||||
mock_init_smc2:
|
||||
sta MOCK_6522_DDRB2
|
||||
sta MOCK_6522_DDRA2
|
||||
rts
|
||||
|
||||
;===================================
|
||||
;===================================
|
||||
; Reset Both AY-3-8910s
|
||||
;===================================
|
||||
;===================================
|
||||
|
||||
;======================
|
||||
; Reset Left AY-3-8910
|
||||
;======================
|
||||
reset_ay_both:
|
||||
lda #MOCK_AY_RESET
|
||||
reset_ay_smc1:
|
||||
sta MOCK_6522_ORB1
|
||||
lda #MOCK_AY_INACTIVE
|
||||
reset_ay_smc2:
|
||||
sta MOCK_6522_ORB1
|
||||
|
||||
;======================
|
||||
; Reset Right AY-3-8910
|
||||
;======================
|
||||
;reset_ay_right:
|
||||
;could be merged with both
|
||||
lda #MOCK_AY_RESET
|
||||
reset_ay_smc3:
|
||||
sta MOCK_6522_ORB2
|
||||
lda #MOCK_AY_INACTIVE
|
||||
reset_ay_smc4:
|
||||
sta MOCK_6522_ORB2
|
||||
rts
|
||||
|
||||
|
||||
; Write sequence
|
||||
; Inactive -> Latch Address -> Inactive -> Write Data -> Inactive
|
||||
|
||||
;=========================================
|
||||
; Write Right/Left to save value AY-3-8910
|
||||
;=========================================
|
||||
; register in X
|
||||
; value in MB_VALUE
|
||||
|
||||
write_ay_both:
|
||||
; address
|
||||
|
||||
write_ay_smc1:
|
||||
stx MOCK_6522_ORA1 ; put address on PA1 ; 4
|
||||
stx MOCK_6522_ORA2 ; put address on PA2 ; 4
|
||||
lda #MOCK_AY_LATCH_ADDR ; latch_address on PB1 ; 2
|
||||
write_ay_smc2:
|
||||
sta MOCK_6522_ORB1 ; latch_address on PB1 ; 4
|
||||
sta MOCK_6522_ORB2 ; latch_address on PB2 ; 4
|
||||
ldy #MOCK_AY_INACTIVE ; go inactive ; 2
|
||||
write_ay_smc3:
|
||||
sty MOCK_6522_ORB1 ; 4
|
||||
sty MOCK_6522_ORB2 ; 4
|
||||
;===========
|
||||
; 28
|
||||
; value
|
||||
lda MB_VALUE ; 3
|
||||
write_ay_smc4:
|
||||
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
|
||||
sta MOCK_6522_ORA2 ; put value on PA2 ; 4
|
||||
lda #MOCK_AY_WRITE ; ; 2
|
||||
write_ay_smc5:
|
||||
sta MOCK_6522_ORB1 ; write on PB1 ; 4
|
||||
sta MOCK_6522_ORB2 ; write on PB2 ; 4
|
||||
write_ay_smc6:
|
||||
sty MOCK_6522_ORB1 ; 4
|
||||
sty MOCK_6522_ORB2 ; 4
|
||||
;===========
|
||||
; 29
|
||||
|
||||
rts ; 6
|
||||
;===========
|
||||
; 63
|
||||
write_ay_both_end:
|
||||
;.assert >write_ay_both = >write_ay_both_end, error, "write_ay_both crosses page"
|
||||
|
||||
;=======================================
|
||||
; clear ay -- clear all 14 AY registers
|
||||
; should silence the card
|
||||
;=======================================
|
||||
; 7+(74*14)+5=1048
|
||||
clear_ay_both:
|
||||
ldx #13 ; 2
|
||||
lda #0 ; 2
|
||||
sta MB_VALUE ; 3
|
||||
clear_ay_left_loop:
|
||||
jsr write_ay_both ; 6+63
|
||||
dex ; 2
|
||||
bpl clear_ay_left_loop ; 3
|
||||
; -1
|
||||
rts ; 6
|
||||
|
||||
clear_ay_end:
|
||||
;.assert >clear_ay_both = >clear_ay_end, error, "clear_ay_both crosses page"
|
||||
|
||||
;=============================
|
||||
; Setup
|
||||
;=============================
|
||||
mockingboard_setup_interrupt:
|
||||
|
||||
|
||||
; for this game with things in language card including
|
||||
; irq handler, always force IIc mode (where RAM swapped in
|
||||
; and we put the irq handler address directly up at $FFFE)
|
||||
|
||||
lda #<interrupt_handler
|
||||
sta $fffe
|
||||
lda #>interrupt_handler
|
||||
sta $ffff
|
||||
|
||||
; nop out the "lda $45" since we are bypassing the ROM irq handler
|
||||
; that puts A in $45
|
||||
lda #$EA
|
||||
sta interrupt_smc
|
||||
sta interrupt_smc+1
|
||||
|
||||
|
||||
;=========================
|
||||
; Setup Interrupt Handler
|
||||
;=========================
|
||||
; Vector address goes to 0x3fe/0x3ff
|
||||
; FIXME: should chain any existing handler
|
||||
|
||||
; lda #<interrupt_handler
|
||||
; sta $03fe
|
||||
; lda #>interrupt_handler
|
||||
; sta $03ff
|
||||
|
||||
;============================
|
||||
; Enable 50Hz clock on 6522
|
||||
;============================
|
||||
|
||||
|
||||
; Note, on Apple II the clock isn't 1MHz but is actually closer to
|
||||
; roughly 1.023MHz, and every 65th clock is stretched (it's complicated)
|
||||
|
||||
; 4fe7 / 1.023e6 = .020s, 50Hz
|
||||
; 9c40 / 1.023e6 = .040s, 25Hz
|
||||
; 411a / 1.023e6 = .016s, 60Hz
|
||||
|
||||
; French Touch uses
|
||||
; 4e20 / 1.000e6 = .020s, 50Hz, which assumes 1MHz clock freq
|
||||
|
||||
sei ; disable interrupts just in case
|
||||
|
||||
lda #$40 ; Continuous interrupts, don't touch PB7
|
||||
setup_irq_smc1:
|
||||
sta MOCK_6522_ACR ; ACR register
|
||||
lda #$7F ; clear all interrupt flags
|
||||
setup_irq_smc2:
|
||||
sta MOCK_6522_IER ; IER register (interrupt enable)
|
||||
|
||||
lda #$C0
|
||||
setup_irq_smc3:
|
||||
sta MOCK_6522_IFR ; IFR: 1100, enable interrupt on timer one oflow
|
||||
setup_irq_smc4:
|
||||
sta MOCK_6522_IER ; IER: 1100, enable timer one interrupt
|
||||
|
||||
lda #$E7
|
||||
; lda #$20
|
||||
setup_irq_smc5:
|
||||
sta MOCK_6522_T1CL ; write into low-order latch
|
||||
lda #$4f
|
||||
; lda #$4E
|
||||
setup_irq_smc6:
|
||||
sta MOCK_6522_T1CH ; write into high-order latch,
|
||||
; load both values into counter
|
||||
; clear interrupt and start counting
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;=============================
|
||||
; Disable Interrupt
|
||||
;=============================
|
||||
mockingboard_disable_interrupt:
|
||||
|
||||
sei ; disable interrupts just in case
|
||||
|
||||
lda #$40 ; Continuous interrupts, don't touch PB7
|
||||
disable_irq_smc1:
|
||||
sta MOCK_6522_ACR ; ACR register
|
||||
lda #$7F ; clear all interrupt flags
|
||||
disable_irq_smc2:
|
||||
sta MOCK_6522_IER ; IER register (interrupt enable)
|
||||
|
||||
rts
|
||||
|
||||
.endif
|
|
@ -27,6 +27,14 @@ CURSOR_X = $62
|
|||
CURSOR_Y = $63
|
||||
|
||||
APPLEII_MODEL = $8B
|
||||
TOTAL_RAM = $8C
|
||||
|
||||
MB_VALUE = $DB
|
||||
MB_ADDR_L = $DC
|
||||
MB_ADDR_H = $DD
|
||||
SOUND_STATUS = $DE
|
||||
SOUND_MOCKINGBOARD = $02
|
||||
|
||||
|
||||
HGR_COLOR = $E4
|
||||
P0 = $F1
|
||||
|
|
Loading…
Reference in New Issue
Block a user