peasant: all hardware detection at beginning

This commit is contained in:
Vince Weaver 2021-09-23 14:59:07 -04:00
parent 84f286ea2e
commit f624b3332c
11 changed files with 780 additions and 349 deletions

View File

@ -50,7 +50,7 @@ HPLOT0 = $F457 ; plot at (Y,X), (A)
;ROM_TEXT2COPY = $F962 ; iigs ;ROM_TEXT2COPY = $F962 ; iigs
TEXT = $FB36 ; qboot TEXT = $FB36 ; qboot
;TABV = $FB5B ; VTAB to A ;TABV = $FB5B ; VTAB to A
;ROM_MACHINEID = $FBB3 ; iigs ROM_MACHINEID = $FBB3 ; iigs
;BELL = $FBDD ; ring the bell ;BELL = $FBDD ; ring the bell
;BASCALC = $FBC1 ; ;BASCALC = $FBC1 ;
;VTAB = $FC22 ; VTAB to CV ;VTAB = $FC22 ; VTAB to CV

40
games/peasant/lc_detect.s Normal file
View File

@ -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

View File

@ -0,0 +1,54 @@
; 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

View File

@ -28,16 +28,22 @@
; if card was found, X = #$Cn where n is the slot number of the card ; if card was found, X = #$Cn where n is the slot number of the card
; C clear if no Mockingboard found ; C clear if no Mockingboard found
; other flags clobbered ; other flags clobbered
; zp $65-$67 clobbered
; A/Y clobbered ; A/Y clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
mockingboard_detect: mockingboard_detect:
; activate IIc mockingboard? ; activate Mockingboard IIc
; this might only be necessary to allow detection ; + the Mockingboard has to take over Slot#4 (IIc has no slots)
; I get the impression the Mockingboard 4c activates ; in theory any write to the firmware area in $C400 will
; when you access any of the 6522 ports in Slot 4 ; 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 .ifdef PT3_ENABLE_APPLE_IIC
lda APPLEII_MODEL lda APPLEII_MODEL
@ -46,10 +52,10 @@ mockingboard_detect:
lda #$ff lda #$ff
; don't bother patching these, IIc mockingboard always slot 4? ; don't bother patching these, IIc mockingboard always slot 4
sta MOCK_6522_DDRA1 sta MOCK_6522_DDRA1 ; $C403
sta MOCK_6522_T1CL sta MOCK_6522_T1CL ; $C404
.endif .endif
not_iic: not_iic:
@ -90,126 +96,6 @@ mb_timer_check_done:
;===================================================================
; code to patch mockingboard if not in slot#4
;===================================================================
; this is the brute force version, we have to patch 39 locations
; see further below if you want to try a smaller, more dangerous, patch
.if 0
mockingboard_patch:
lda MB_ADDR_H
sta pt3_irq_smc1+2 ; 1
sta pt3_irq_smc2+2 ; 2
sta pt3_irq_smc2+5 ; 3
sta pt3_irq_smc3+2 ; 4
sta pt3_irq_smc3+5 ; 5
sta pt3_irq_smc4+2 ; 6
sta pt3_irq_smc4+5 ; 7
sta pt3_irq_smc5+2 ; 8
sta pt3_irq_smc5+5 ; 9
sta pt3_irq_smc6+2 ; 10
sta pt3_irq_smc6+5 ; 11
sta pt3_irq_smc7+2 ; 12
sta pt3_irq_smc7+5 ; 13
sta mock_init_smc1+2 ; 14
sta mock_init_smc1+5 ; 15
sta mock_init_smc2+2 ; 16
sta mock_init_smc2+5 ; 17
sta reset_ay_smc1+2 ; 18
sta reset_ay_smc2+2 ; 19
sta reset_ay_smc3+2 ; 20
sta reset_ay_smc4+2 ; 21
sta write_ay_smc1+2 ; 22
sta write_ay_smc1+5 ; 23
sta write_ay_smc2+2 ; 24
sta write_ay_smc2+5 ; 25
sta write_ay_smc3+2 ; 26
sta write_ay_smc3+5 ; 27
sta write_ay_smc4+2 ; 28
sta write_ay_smc4+5 ; 29
sta write_ay_smc5+2 ; 30
sta write_ay_smc5+5 ; 31
sta write_ay_smc6+2 ; 32
sta write_ay_smc6+5 ; 33
sta setup_irq_smc1+2 ; 34
sta setup_irq_smc2+2 ; 35
sta setup_irq_smc3+2 ; 36
sta setup_irq_smc4+2 ; 37
sta setup_irq_smc5+2 ; 38
sta setup_irq_smc6+2 ; 39
sta disable_irq_smc1+2 ; 34
sta disable_irq_smc2+2 ; 35
rts
.endif
;===================================================================
; dangerous code to patch mockingboard if not in slot#4
;===================================================================
; this code patches any $C4 value to the proper slot# if not slot4
; this can be dangerous, it might over-write other important values
; that should be $C4
; safer ways to do this:
; only do this if 2 bytes after a LDA/STA/LDX/STX
; count total and if not 39 then print error message
mockingboard_patch:
; from mockingboard_init $1BBF
; to done_pt3_irq_handler $1D85
ldx MB_ADDR_H
ldy #0
lda #<mockingboard_init
sta MB_ADDR_L
lda #>mockingboard_init
sta MB_ADDR_H
mb_patch_loop:
lda (MB_ADDR_L),Y
cmp #$C4
bne mb_patch_nomatch
txa
sta (MB_ADDR_L),Y
mb_patch_nomatch:
inc MB_ADDR_L
lda MB_ADDR_L
bne mb_patch_oflo
inc MB_ADDR_H
mb_patch_oflo:
lda MB_ADDR_H
cmp #>done_pt3_irq_handler
bne mb_patch_loop
lda MB_ADDR_L
cmp #<done_pt3_irq_handler
bne mb_patch_loop
mb_patch_done:
rts
.if 0 .if 0

View File

@ -182,8 +182,6 @@ mockingboard_setup_interrupt:
sei ; disable interrupts sei ; disable interrupts
copy_rom_loop: copy_rom_loop:
lda $c089 ; read ROM, write RAM1 lda $c089 ; read ROM, write RAM1
lda $c089 lda $c089
@ -214,11 +212,12 @@ write_rom_loop:
lda #>interrupt_handler lda #>interrupt_handler
sta $ffff sta $ffff
lda #$EA ; nop out the "lda $45" in the irq handler
; nop out the "lda $45" in the irq handler
lda #$EA
sta interrupt_smc sta interrupt_smc
sta interrupt_smc+1 sta interrupt_smc+1
.endif .endif
done_iic_hack: done_iic_hack:
@ -279,88 +278,10 @@ setup_irq_smc6:
;============================= ;=============================
; Setup ; Disable Interrupt
;============================= ;=============================
mockingboard_disable_interrupt: mockingboard_disable_interrupt:
;.ifdef PT3_ENABLE_APPLE_IIC
; lda APPLEII_MODEL
; cmp #'C'
; bne done_iic_hack
;
; ; bypass the firmware interrupt handler
; ; should we do this on IIe too? probably faster
;
; ; first we have to copy the ROM to the language card
;
; sei ; disable interrupts
;
;
;
;copy_rom_loop:
; lda $c089 ; read ROM, write RAM1
; lda $c089
; ldy #0
;read_rom_loop:
; lda $D000,Y
; sta $400,Y ; note this uses text page as
; temporary data store
; iny
; bne read_rom_loop
; lda $c08B ; read/write RAM1
; lda $c08B ;
;write_rom_loop:
; lda $400,Y
; sta $D000,Y
; iny
; bne write_rom_loop
; inc read_rom_loop+2
; inc write_rom_loop+5
; bne copy_rom_loop
; lda #<interrupt_handler
; sta $fffe
; lda #>interrupt_handler
; sta $ffff
; lda #$EA ; nop out the "lda $45" in the irq handler
; sta interrupt_smc
; sta interrupt_smc+1
;.endif
;
;done_iic_hack:
;=========================
; 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 sei ; disable interrupts just in case
lda #$40 ; Continuous interrupts, don't touch PB7 lda #$40 ; Continuous interrupts, don't touch PB7
@ -370,22 +291,126 @@ disable_irq_smc1:
disable_irq_smc2: disable_irq_smc2:
sta MOCK_6522_IER ; IER register (interrupt enable) sta MOCK_6522_IER ; IER register (interrupt enable)
; lda #$C0 rts
;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 ; code to patch mockingboard if not in slot#4
; lda #$20 ;===================================================================
;setup_irq_smc5: ; this is the brute force version, we have to patch 39 locations
; sta MOCK_6522_T1CL ; write into low-order latch ; see further below if you want to try a smaller, more dangerous, patch
; lda #$4f
; lda #$4E .if 0
;setup_irq_smc6: mockingboard_patch:
; sta MOCK_6522_T1CH ; write into high-order latch,
; ; load both values into counter lda MB_ADDR_H
; ; clear interrupt and start counting
sta pt3_irq_smc1+2 ; 1
sta pt3_irq_smc2+2 ; 2
sta pt3_irq_smc2+5 ; 3
sta pt3_irq_smc3+2 ; 4
sta pt3_irq_smc3+5 ; 5
sta pt3_irq_smc4+2 ; 6
sta pt3_irq_smc4+5 ; 7
sta pt3_irq_smc5+2 ; 8
sta pt3_irq_smc5+5 ; 9
sta pt3_irq_smc6+2 ; 10
sta pt3_irq_smc6+5 ; 11
sta pt3_irq_smc7+2 ; 12
sta pt3_irq_smc7+5 ; 13
sta mock_init_smc1+2 ; 14
sta mock_init_smc1+5 ; 15
sta mock_init_smc2+2 ; 16
sta mock_init_smc2+5 ; 17
sta reset_ay_smc1+2 ; 18
sta reset_ay_smc2+2 ; 19
sta reset_ay_smc3+2 ; 20
sta reset_ay_smc4+2 ; 21
sta write_ay_smc1+2 ; 22
sta write_ay_smc1+5 ; 23
sta write_ay_smc2+2 ; 24
sta write_ay_smc2+5 ; 25
sta write_ay_smc3+2 ; 26
sta write_ay_smc3+5 ; 27
sta write_ay_smc4+2 ; 28
sta write_ay_smc4+5 ; 29
sta write_ay_smc5+2 ; 30
sta write_ay_smc5+5 ; 31
sta write_ay_smc6+2 ; 32
sta write_ay_smc6+5 ; 33
sta setup_irq_smc1+2 ; 34
sta setup_irq_smc2+2 ; 35
sta setup_irq_smc3+2 ; 36
sta setup_irq_smc4+2 ; 37
sta setup_irq_smc5+2 ; 38
sta setup_irq_smc6+2 ; 39
rts
.endif
;===================================================================
; dangerous code to patch mockingboard if not in slot#4
;===================================================================
; this code patches any $C4 value to the proper slot# if not slot4
; this can be dangerous, it might over-write other important values
; that should be $C4
; safer ways to do this:
; only do this if 2 bytes after a LDA/STA/LDX/STX
; count total and if not 39 then print error message
mockingboard_patch:
; from mockingboard_init $1BBF
; to done_pt3_irq_handler $1D85
ldx MB_ADDR_H
ldy #0
lda #<mockingboard_init
sta MB_ADDR_L
lda #>mockingboard_init
sta MB_ADDR_H
mb_patch_loop:
lda (MB_ADDR_L),Y
cmp #$C4
bne mb_patch_nomatch
txa
sta (MB_ADDR_L),Y
mb_patch_nomatch:
inc MB_ADDR_L
lda MB_ADDR_L
bne mb_patch_oflo
inc MB_ADDR_H
mb_patch_oflo:
lda MB_ADDR_H
cmp #>done_pt3_irq_handler
bne mb_patch_loop
lda MB_ADDR_L
cmp #<done_pt3_irq_handler
bne mb_patch_loop
mb_patch_done:
rts rts

View File

@ -225,7 +225,7 @@ sector_array:
.byte 0 ; .byte 0 ;
length_array: length_array:
.byte 28, 50, 60, 20 ; VID_LOGO, TITLE, INTRO, COPY_CHECK .byte 32, 50, 60, 20 ; VID_LOGO, TITLE, INTRO, COPY_CHECK
.byte 80, 80, 80, 80 ; PEASANT1, PEASANT2, PEASANT3, PEASANT4 .byte 80, 80, 80, 80 ; PEASANT1, PEASANT2, PEASANT3, PEASANT4
.byte 80, 80,159,109 ; TROGDOR, ENDING .byte 80, 80,159,109 ; TROGDOR, ENDING
.byte 20, 33, 27, 78 ; .byte 20, 33, 27, 78 ;

View File

@ -0,0 +1,137 @@
; This code detects a SSI263 chip on a Mockingboard
; it does this by trying to enable the chip and waiting for
; the SSI-263 to signal an interrupt when done.
; If the interrupt never comes then assume no SSI-263 is present
; The code assumes the SSI-263 is hooked to VIA6522 #2 (?)
;=============================
;=============================
; detect SSI263
;=============================
;=============================
; A = slot of mockingboard
detect_ssi263:
sta ssi263_slot ; store for later
and #$7
ora #$c0 ; turn slot number into address
sta ssid_wc_smc1+2 ; update the read/write routines
sei ; disable IRQ
lda $3fe ; backup the IRQ handler
sta irq1backup
lda $3ff
sta irq2backup
lda #<mb_irq ; point IRQ handler to our code
sta $3fe
lda #>mb_irq
sta $3ff
; Set 6522#2 peripheral control register to recognize the signal
; from the speech chip.
lda #(VIA6522_PCR2_CA2_LOW|VIA6522_PCR2_CA1_NEG)
ldx #VIA6522_PCR2
jsr ssi263_d_write_chip
; Raise control bit in register 3 of SSI-263
lda #SSI263_CAA_CTL
ldx #SSI263_CAA
jsr ssi263_d_write_chip
; Transitioned inflection (when CTL is toggled)
lda #SSI263_DRP_TRANSITIONED_INFLECTION
ldx #SSI263_DRP
jsr ssi263_d_write_chip
; Lower control bit in SSI-263
lda #$70 ; CTL=0, T=6, AMP=0
ldx #SSI263_CAA
jsr ssi263_d_write_chip
; Enable 6522 interrupt on input CA2
lda #(VIA6522_IER2_SET|VIA6522_IER2_CA1)
ldx #VIA6522_IER2
jsr ssi263_d_write_chip
ldx #0 ; clear counts
ldy #0
cli ; enable interrupts
wait_irq:
lda irq_count ; see if irq happened
bne got_irq
iny ; otherwise increase counts
bne wait_irq
inx ;
bne wait_irq
got_irq:
sei ; disable interrupts
rts
;========================
; detection IRQ handler
;========================
mb_irq:
txa ; save X
pha
; Clear the 6522 interrupt flag
lda #VIA6522_IFR2_CA1
ldx #VIA6522_IFR2
jsr ssi263_d_write_chip
; disable speech
; Raise control bit in register 3 of SSI-263
lda #SSI263_CAA_CTL
ldx #SSI263_CAA
jsr ssi263_d_write_chip
; Disable talking on SSI-263 (when CTL is toggled)
lda #SSI263_DRP_DISABLE_AR
ldx #SSI263_DRP
jsr ssi263_d_write_chip
; Lower control bit in SSI-263
lda #$70 ; also T=7?
ldx #SSI263_CAA
jsr ssi263_d_write_chip
; increment our irq count
inc irq_count
; Disable 6522 interrupts
lda #VIA6522_IER2_CA1
ldx #VIA6522_IER2
jsr ssi263_d_write_chip
pla ; restore X
tax
lda $45 ; restore accumulator
rti ; return from interrupt
;========================
; write_chip
;========================
ssi263_d_write_chip:
ssid_wc_smc1:
sta $C000,X
rts
irq_count: .byte $00
irq1backup: .byte $00
irq2backup: .byte $00
ssi263_slot: .byte $00

145
games/peasant/text_print.s Normal file
View File

@ -0,0 +1,145 @@
;================================
; move_and_print
;================================
; get X,Y from OUTL/OUTH
; then print following string to that address
; stop at NUL
; convert to APPLE ASCII (or with 0x80)
; leave OUTL/OUTH pointing to next string
move_and_print:
ldy #0
lda (OUTL),Y
sta CH
iny
lda (OUTL),Y
asl
tay
lda gr_offsets,Y ; lookup low-res memory address
clc
adc CH ; add in xpos
sta BASL ; store out low byte of addy
lda gr_offsets+1,Y ; look up high byte
adc DRAW_PAGE ;
sta BASH ; and store it out
; BASH:BASL now points at right place
clc
lda OUTL
adc #2
sta OUTL
lda OUTH
adc #0
sta OUTH
;================================
; print_string
;================================
print_string:
ldy #0
print_string_loop:
lda (OUTL),Y
beq done_print_string
ps_smc1:
and #$3f ; make sure we are inverse
sta (BASL),Y
iny
bne print_string_loop
done_print_string:
iny
clc
tya
adc OUTL
sta OUTL
lda OUTH
adc #0
sta OUTH
rts
.if 0
;================================
; move and print a list of lines
;================================
move_and_print_list:
jsr move_and_print
ldy #0
lda (OUTL),Y
bpl move_and_print_list
rts
;================================
; move and print a list of lines
;================================
move_and_print_list_both_pages:
lda DRAW_PAGE
pha
lda OUTL
pha
lda OUTH
pha
lda #0
sta DRAW_PAGE
jsr move_and_print_list
pla
sta OUTH
pla
sta OUTL
lda #4
sta DRAW_PAGE
jsr move_and_print_list
pla
sta DRAW_PAGE
rts
;=======================
; print to both pages
;=======================
print_both_pages:
lda DRAW_PAGE
pha
lda OUTL
pha
lda OUTH
pha
lda #0
sta DRAW_PAGE
jsr move_and_print
pla
sta OUTH
pla
sta OUTL
lda #4
sta DRAW_PAGE
jsr move_and_print
pla
sta DRAW_PAGE
rts
.endif

View File

@ -9,32 +9,186 @@
; with apologies to everyone ; with apologies to everyone
.include "hardware.inc" .include "hardware.inc"
.include "zp.inc"
NIBCOUNT = $09
GBASL = $26
GBASH = $27
CURSOR_X = $62
CURSOR_Y = $63
HGR_COLOR = $E4
HGR_PAGE = $E6
DISP_PAGE = $F0
DRAW_PAGE = $F1
;P0 = $F1
;P1 = $F2
;P2 = $F3
;P3 = $F4
;P4 = $F5
;P5 = $F6
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF
intro_text:
hgr_display: jsr TEXT
jsr HOME
lda #0
sta DRAW_PAGE
; print non-inverse
lda #$80
sta ps_smc1+1
lda #09 ; ora
sta ps_smc1
lda #<boot_message
sta OUTL
lda #>boot_message
sta OUTH
ldx #7
text_loop:
jsr move_and_print
dex
bne text_loop
;===================
; detect model
;===================
jsr detect_appleii_model
;===================
; machine workarounds
;===================
; mostly IIgs
;===================
; thanks to 4am who provided this code from Total Replay
lda ROM_MACHINEID
cmp #$06
bne not_a_iigs
sec
jsr $FE1F ; check for IIgs
bcs not_a_iigs
; gr/text page2 handling broken on early IIgs models
; in theory this game we don't need that?
;jsr ROM_TEXT2COPY ; set alternate display mode on IIgs
cli ; enable VBL interrupts
; also set background color to black instead of blue
lda NEWVIDEO
and #%00011111 ; bit 7 = 0 -> IIgs Apple II-compat video modes
; bit 6 = 0 -> IIgs 128K memory map same as IIe
; bit 5 = 0 -> IIgs DHGR is color, not mono
; bits 0-4 unchanged
sta NEWVIDEO
lda #$F0
sta TBCOLOR ; white text on black background
lda #$00
sta CLOCKCTL ; black border
sta CLOCKCTL ; set twice for VidHD
not_a_iigs:
;===================
; print config
;===================
lda #<config_string
sta OUTL
lda #>config_string
sta OUTH
jsr move_and_print
; print detected model
lda APPLEII_MODEL
ora #$80
sta $7d0+8 ; 23,8
; if GS print the extra S
cmp #'G'|$80
bne not_gs
lda #'S'|$80
sta $7d0+9
not_gs:
;=========================================
; detect if we have a language card (64k)
; and load sound into it if possible
;===================================
lda #0
sta SOUND_STATUS ; clear out, sound enabled
jsr detect_language_card
bcs no_language_card
yes_language_card:
; update status
lda #'6'|$80
sta $7d0+11 ; 23,11
lda #'4'|$80
sta $7d0+12 ; 23,12
; update sound status
lda SOUND_STATUS
ora #SOUND_IN_LC
sta SOUND_STATUS
no_language_card:
;===================================
; Detect Mockingboard
;===================================
PT3_ENABLE_APPLE_IIC = 1
lda #0
sta DONE_PLAYING
sta LOOP
; detect mockingboard
jsr mockingboard_detect
bcc mockingboard_notfound
mockingboard_found:
; print detected location
lda #'S'+$80 ; change NO to slot
sta $7d0+30
lda MB_ADDR_H ; $C4 = 4, want $B4 1100 -> 1011
and #$87
ora #$30
sta $7d0+31 ; 23,31
lda SOUND_STATUS
ora #SOUND_MOCKINGBOARD
sta SOUND_STATUS
;===========================
; detect SSI-263 too
;===========================
detect_ssi:
lda MB_ADDR_H
and #$87 ; slot
jsr detect_ssi263
lda irq_count
beq ssi_not_found
lda #'Y'+$80
sta $7d0+39 ; 23,39
lda #SOUND_SSI263
ora SOUND_STATUS
sta SOUND_STATUS
ssi_not_found:
mockingboard_notfound:
lda #30
jsr wait_a_bit
videlectrix_intro:
jsr HGR2 ; Hi-res graphics, no text at bottom jsr HGR2 ; Hi-res graphics, no text at bottom
; Y=0, A=0 after this called ; Y=0, A=0 after this called
; HGR_PAGE=$40 ; HGR_PAGE=$40
@ -142,35 +296,21 @@ done_loop:
; jmp forever ; jmp forever
animation_low: animation_low:
.byte <videlectrix_lzsa .byte <videlectrix_lzsa ; .byte <title_anim01_lzsa
; .byte <title_anim01_lzsa
.byte <title_anim02_lzsa .byte <title_anim02_lzsa
.byte <title_anim03_lzsa .byte <title_anim03_lzsa ; .byte <title_anim04_lzsa
; .byte <title_anim04_lzsa .byte <title_anim05_lzsa ; .byte <title_anim06_lzsa
.byte <title_anim05_lzsa .byte <title_anim07_lzsa ; .byte <title_anim08_lzsa
; .byte <title_anim06_lzsa .byte <title_anim09_lzsa ; .byte <title_anim10_lzsa
.byte <title_anim07_lzsa .byte <title_anim11_lzsa ; .byte <title_anim12_lzsa
; .byte <title_anim08_lzsa .byte <title_anim13_lzsa ; .byte <title_anim14_lzsa
.byte <title_anim09_lzsa .byte <title_anim15_lzsa ; .byte <title_anim16_lzsa
; .byte <title_anim10_lzsa .byte <title_anim17_lzsa ; .byte <title_anim18_lzsa
.byte <title_anim11_lzsa .byte <title_anim19_lzsa ; .byte <title_anim20_lzsa
; .byte <title_anim12_lzsa .byte <title_anim21_lzsa ; .byte <title_anim22_lzsa
.byte <title_anim13_lzsa .byte <title_anim23_lzsa ; .byte <title_anim24_lzsa
; .byte <title_anim14_lzsa .byte <title_anim25_lzsa ; .byte <title_anim26_lzsa
.byte <title_anim15_lzsa .byte <title_anim27_lzsa ; .byte <title_anim28_lzsa
; .byte <title_anim16_lzsa
.byte <title_anim17_lzsa
; .byte <title_anim18_lzsa
.byte <title_anim19_lzsa
; .byte <title_anim20_lzsa
.byte <title_anim21_lzsa
; .byte <title_anim22_lzsa
.byte <title_anim23_lzsa
; .byte <title_anim24_lzsa
.byte <title_anim25_lzsa
; .byte <title_anim26_lzsa
.byte <title_anim27_lzsa
; .byte <title_anim28_lzsa
.byte <title_anim29_lzsa .byte <title_anim29_lzsa
.byte <title_anim30_lzsa .byte <title_anim30_lzsa
.byte <title_anim31_lzsa .byte <title_anim31_lzsa
@ -182,35 +322,21 @@ animation_low:
.byte <title_anim34_lzsa .byte <title_anim34_lzsa
animation_high: animation_high:
.byte >videlectrix_lzsa .byte >videlectrix_lzsa ; .byte >title_anim01_lzsa
; .byte >title_anim01_lzsa
.byte >title_anim02_lzsa .byte >title_anim02_lzsa
.byte >title_anim03_lzsa .byte >title_anim03_lzsa ; .byte >title_anim04_lzsa
; .byte >title_anim04_lzsa .byte >title_anim05_lzsa ; .byte >title_anim06_lzsa
.byte >title_anim05_lzsa .byte >title_anim07_lzsa ; .byte >title_anim08_lzsa
; .byte >title_anim06_lzsa .byte >title_anim09_lzsa ; .byte >title_anim10_lzsa
.byte >title_anim07_lzsa .byte >title_anim11_lzsa ; .byte >title_anim12_lzsa
; .byte >title_anim08_lzsa .byte >title_anim13_lzsa ; .byte >title_anim14_lzsa
.byte >title_anim09_lzsa .byte >title_anim15_lzsa ; .byte >title_anim16_lzsa
; .byte >title_anim10_lzsa .byte >title_anim17_lzsa ; .byte >title_anim18_lzsa
.byte >title_anim11_lzsa .byte >title_anim19_lzsa ; .byte >title_anim20_lzsa
; .byte >title_anim12_lzsa .byte >title_anim21_lzsa ; .byte >title_anim22_lzsa
.byte >title_anim13_lzsa .byte >title_anim23_lzsa ; .byte >title_anim24_lzsa
; .byte >title_anim14_lzsa .byte >title_anim25_lzsa ; .byte >title_anim26_lzsa
.byte >title_anim15_lzsa .byte >title_anim27_lzsa ; .byte >title_anim28_lzsa
; .byte >title_anim16_lzsa
.byte >title_anim17_lzsa
; .byte >title_anim18_lzsa
.byte >title_anim19_lzsa
; .byte >title_anim20_lzsa
.byte >title_anim21_lzsa
; .byte >title_anim22_lzsa
.byte >title_anim23_lzsa
; .byte >title_anim24_lzsa
.byte >title_anim25_lzsa
; .byte >title_anim26_lzsa
.byte >title_anim27_lzsa
; .byte >title_anim28_lzsa
.byte >title_anim29_lzsa .byte >title_anim29_lzsa
.byte >title_anim30_lzsa .byte >title_anim30_lzsa
.byte >title_anim31_lzsa .byte >title_anim31_lzsa
@ -251,35 +377,21 @@ notes:
delays: delays:
.byte 1 ; title .byte 1 ; title ; .byte 1 ; 1
; .byte 1 ; 1
.byte 1 ; 2 .byte 1 ; 2
.byte 1 ; 3 .byte 1 ; 3 ; .byte 1 ; 4
; .byte 1 ; 4 .byte 1 ; 5 ; .byte 1 ; 6
.byte 1 ; 5 .byte 1 ; 7 ; .byte 1 ; 8
; .byte 1 ; 6 .byte 1 ; 9 ; .byte 1 ; 10
.byte 1 ; 7 .byte 1 ; 11 ; .byte 1 ; 12
; .byte 1 ; 8 .byte 1 ; 13 ; .byte 1 ; 14
.byte 1 ; 9 .byte 1 ; 15 ; .byte 1 ; 16
; .byte 1 ; 10 .byte 1 ; 17 ; .byte 1 ; 18
.byte 1 ; 11 .byte 1 ; 19 ; .byte 1 ; 20
; .byte 1 ; 12 .byte 1 ; 21 ; .byte 1 ; 22
.byte 1 ; 13 .byte 1 ; 23 ; .byte 1 ; 24
; .byte 1 ; 14 .byte 1 ; 25 ; .byte 1 ; 26
.byte 1 ; 15 .byte 1 ; 27 ; .byte 1 ; 28
; .byte 1 ; 16
.byte 1 ; 17
; .byte 1 ; 18
.byte 1 ; 19
; .byte 1 ; 20
.byte 1 ; 21
; .byte 1 ; 22
.byte 1 ; 23
; .byte 1 ; 24
.byte 1 ; 25
; .byte 1 ; 26
.byte 1 ; 27
; .byte 1 ; 28
.byte 1 ; 29 .byte 1 ; 29
.byte 1 ; 30 .byte 1 ; 30
.byte 1 ; 31 .byte 1 ; 31
@ -298,7 +410,35 @@ delays:
.include "speaker_beeps.s" .include "speaker_beeps.s"
;.include "wait_keypress.s" .include "text_print.s"
.include "gr_offsets.s"
.include "wait_a_bit.s"
.include "lc_detect.s"
.include "pt3_lib_mockingboard.inc"
.include "pt3_lib_detect_model.s"
.include "pt3_lib_mockingboard_detect.s"
.include "ssi263.inc"
.include "ssi263_detect.s"
.include "graphics_vid/vid_graphics.inc" .include "graphics_vid/vid_graphics.inc"
; 0123456789012345678901234567890123456789
boot_message:
.byte 0,0, "LOADING PEASANT'S QUEST V0.7",0
.byte 0,3,"ORIGINAL BY VIDELECTRIX",0
.byte 0,5,"APPLE II PORT: VINCE WEAVER",0
.byte 0,6,"DISK CODE : QKUMBA",0
.byte 0,7,"LZSA CODE : EMMANUEL MARTY",0
.byte 7,19,"______",0
.byte 5,20,"A \/\/\/ SOFTWARE PRODUCTION",0
config_string:
; 0123456789012345678901234567890123456789
.byte 0,23,"APPLE II?, 48K, MOCKINGBOARD: NO, SSI: N",0
; MOCKINGBOARD: NONE

View File

@ -1,7 +1,6 @@
;==================================== ;====================================
; wait for keypress or a few seconds ; wait for keypress or a few seconds
;==================================== ;====================================
; A is length to wait
wait_a_bit: wait_a_bit:
@ -17,20 +16,13 @@ keyloop:
dex dex
bne keyloop bne keyloop
beq no_escape
done_keyloop: done_keyloop:
and #$7f
cmp #27
bne no_escape
lda #1
sta ESC_PRESSED
no_escape:
bit KEYRESET bit KEYRESET
rts rts

View File

@ -1,3 +1,13 @@
JS_BUTTON_STATE = $04
JOYSTICK_ENABLED= $05
SOUND_STATUS = $06
SOUND_DISABLED = $80
SOUND_IN_LC = $01 ; sound in language card
SOUND_MOCKINGBOARD = $02 ; mockingboard detected
SOUND_SSI263 = $04 ; SSI-263 speech chip detected
DISP_PAGE = $07 ; only in videlectrix intro?
DRAW_PAGE = $08
NIBCOUNT = $09 NIBCOUNT = $09
TEMP0 = $10 TEMP0 = $10
@ -9,6 +19,8 @@ TEMP5 = $15
HGR_BITS = $1C HGR_BITS = $1C
CH = $24
CV = $25
GBASL = $26 GBASL = $26
GBASH = $27 GBASH = $27
BASL = $28 BASL = $28