double: add more detection code

This commit is contained in:
Vince Weaver 2023-05-11 00:33:10 -04:00
parent 81c2b777ee
commit 2ecf50f2c6
8 changed files with 558 additions and 51 deletions

View File

@ -25,7 +25,8 @@ DOUBLE: double.o
double.o: double.s \
zp.inc hardware.inc pt3_lib_mockingboard_detect.s \
pt3_lib_mockingboard_setup.s pt3_lib_detect_model.s \
zx02_optim.s copy_400.s gr_offsets.s \
zx02_optim.s copy_400.s gr_offsets.s vblank.s \
lc_detect.s text_print.s title.s gr_fast_clear.s \
graphics/sworg_hgr.hgr.zx02 \
graphics/sworg_dhgr.aux.zx02 \
graphics/sworg_dhgr.bin.zx02 \

View File

@ -51,6 +51,114 @@ double:
not_a_iigs:
;================================
; setup vblank routine
;================================
lda APPLEII_MODEL
cmp #'G'
beq setup_vblank_iigs
cmp #'C'
beq setup_vblank_iic
setup_vblank_iie:
lda #<wait_vblank_iie
sta vblank_smc+1
lda #>wait_vblank_iie
sta vblank_smc+2
jmp done_setup_vblank
setup_vblank_iigs:
lda #<wait_vblank_iigs
sta vblank_smc+1
lda #>wait_vblank_iigs
sta vblank_smc+2
jmp done_setup_vblank
setup_vblank_iic:
lda #<wait_vblank_iic
sta vblank_smc+1
lda #>wait_vblank_iic
sta vblank_smc+2
jmp done_setup_vblank
done_setup_vblank:
;====================
; show title message
;====================
lda #0
sta DRAW_PAGE
jsr show_title
;===================
; 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
;===========================================
; skip checks if open-apple being held down
lda $C061
and #$80 ; only bit 7 is affected
bne skip_all_checks ; rest is floating bus
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
jmp done_language_card
no_language_card:
done_language_card:
skip_all_checks:
jsr wait_until_keypress
;================================
; Clear screen and setup graphics
;================================
@ -236,30 +344,27 @@ stringing_done:
sta FULLGR
; wait for vblank on IIe
; positive? during vblank
wait_vblank_iie:
lda VBLANK
bmi wait_vblank_iie ; wait for positive (in vblank)
wait_vblank_done_iie:
lda VBLANK ; wait for negative (vlank done)
bpl wait_vblank_done_iie
;
double_loop:
;===========================
; text mode first 6*4 (24) lines
;=================================
; main static loop
;=================================
; each line 65 cycles (25 hblank+40 bytes)
double_loop:
; note, coming out of vblank routines might be
; 8-12 cycles in already
vblank_smc:
jsr $ffff
; 3 LINES 80-COL TEXT AN3=0 PAGE=2
bit PAGE2
nop
nop
sta SET80COL ; 4
; nop
; nop
; sta SET80COL ; 4
bit SET_TEXT ; 4
; wait 6*4=24 lines
@ -353,28 +458,7 @@ double_loop:
jsr delay_1552
jmp skip_vblank
.align $100
;==================================
; vblank = 4550 cycles
; -6
; 4544
; Try X=226 Y=4 cycles=4545
; Try X=9 Y=89 cycles=4540
skip_vblank:
nop
nop
ldy #89 ; 2
loop3: ldx #9 ; 2
loop4: dex ; 2
bne loop4 ; 2nt/3
dey ; 2
bne loop3 ; 2nt/3
jmp double_loop ; 3
@ -384,6 +468,8 @@ loop4: dex ; 2
.align $100
.include "vblank.s"
; actually want 1552-12 (6 each for jsr/rts)
; 1540
; Try X=15 Y=19 cycles=1540
@ -406,6 +492,12 @@ loop6: dex ; 2
rts
wait_until_keypress:
lda KEYBOARD
bpl wait_until_keypress
bit KEYRESET
rts
.include "pt3_lib_detect_model.s"
; .include "pt3_lib_mockingboard_setup.s"
@ -430,8 +522,19 @@ a2_string:
; 012345678901234567 8 9
.byte "Apple II Forever!! ",'@'+$80," "
.byte "Apple II Forever! ",'@'+$80," ",0
.byte "Apple II Forever! ",'@'+$80," "
.byte "Apple II Forever! ",'@'+$80," "
.byte "Apple II Forever! ",'@'+$80," "
top_string:
.byte "DOUBLE DOUBLE by DEATER / DsR ",0
.byte " Graphics based on art by @YYYYYYYYY Music: N. OOOOOOO",0
config_string:
; 0123456789012345678901234567890123456789
.byte 0,23,"APPLE II?, 48K, MOCKINGBOARD: NO, SSI: N",0
.include "gr_offsets.s"
.include "lc_detect.s"
.include "text_print.s"
.include "title.s"
.include "gr_fast_clear.s"

View File

@ -0,0 +1,201 @@
;clear_screens:
; ;===================================
; ; Clear top/bottom of page 0
; ;===================================
;
; lda #$0
; sta DRAW_PAGE
; jsr clear_top
; jsr clear_bottom
; ;===================================
; ; Clear top/bottom of page 1
; ;===================================
;
; lda #$4
; sta DRAW_PAGE
; jsr clear_top
; jsr clear_bottom
;
; rts
;=========================================================
; clear_top
;=========================================================
; clear DRAW_PAGE
; original = 14,558 cycles(?) 15ms, 70Hz
; OPTIMIZED MAX (page0,48rows): 45*120+4+6 = 5410 = 5.4ms 185Hz
; (pageX,40rows): 50*120+4+6 = 6010 = 6.0ms 166Hz
; 50*120+4+6+37 = 6055 = 6.0ms 166Hz
clear_top:
lda #0 ; 2
clear_top_a:
sta COLOR ; 3
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __ctf+2 ; 3
sta __ctf+5 ; 3
adc #1 ; 2
sta __ctf+8 ; 3
sta __ctf+11 ; 3
adc #1 ; 2
sta __ctf2+2 ; 3
sta __ctf2+5 ; 3
adc #1 ; 2
sta __ctf2+8 ; 3
sta __ctf2+11 ; 3
ldy #120 ; 2
lda COLOR ; 3
clear_top_fast_loop:
__ctf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
cpy #80 ; 2
bpl no_draw_bottom ; 2nt/3
__ctf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
no_draw_bottom:
dey ; 2
bpl clear_top_fast_loop ; 2nt/3
rts ; 6
;=========================================================
; clear_bottom
;=========================================================
; clear bottom of draw page
clear_bottom:
clc ; 2
lda DRAW_PAGE ; 3
adc #6 ; 2
sta __cbf2+2 ; 3
sta __cbf2+5 ; 3
adc #1 ; 2
sta __cbf2+8 ; 3
sta __cbf2+11 ; 3
ldy #120 ; 2
lda #$a0 ; Normal Space ; 2
clear_bottom_fast_loop:
__cbf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
cpy #80 ; 2
bpl clear_bottom_fast_loop ; 2nt/3
rts ; 6
;clear_screens_notext:
;===================================
; Clear top/bottom of page 0
;===================================
; lda #$0
; sta DRAW_PAGE
; jsr clear_all
;===================================
; Clear top/bottom of page 1
;===================================
; lda #$4
; sta DRAW_PAGE
; jsr clear_all
; rts
clear_bottoms:
lda DRAW_PAGE
pha
;===================================
; Clear bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_bottom
;===================================
; Clear bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_bottom
pla
sta DRAW_PAGE
rts
;=========================================================
; clear_all
;=========================================================
; clear 48 rows
clear_all:
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __caf+2 ; 3
sta __caf+5 ; 3
adc #1 ; 2
sta __caf+8 ; 3
sta __caf+11 ; 3
adc #1 ; 2
sta __caf2+2 ; 3
sta __caf2+5 ; 3
adc #1 ; 2
sta __caf2+8 ; 3
sta __caf2+11 ; 3
ldy #120 ; 2
clear_all_color:
lda #' '|$80 ; 2
clear_all_fast_loop:
__caf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
__caf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
bpl clear_all_fast_loop ; 2nt/3
rts ; 6

View File

@ -8,6 +8,7 @@ CLR80COL = $C00C
SET80COL = $C00D
SETMOUSETEXT = $C00F ; (write) enable mouse text
KEYRESET = $C010
VBLANK = $C019 ; *not* RDVBL (VBL signal low) (iie, opposite iigs)
RDVBLBAR = $C019 ; iic

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,93 @@
;================================
; 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_l,Y ; lookup low-res memory address
clc
adc CH ; add in xpos
sta BASL ; store out low byte of addy
lda gr_offsets_h,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
; set normal text
set_normal:
lda #$80
sta ps_smc1+1
lda #09 ; ora
sta ps_smc1
rts
; restore inverse text
set_inverse:
lda #$29
sta ps_smc1
lda #$3f
sta ps_smc1+1
rts
;================================
; move and print a list of lines
;================================
; look for negative X meaning done
move_and_print_list:
jsr move_and_print
ldy #0
lda (OUTL),Y
bpl move_and_print_list
rts

View File

@ -0,0 +1,51 @@
;=====================================
; print the title screen
;=====================================
show_title:
; clear text screen
jsr clear_all
; print non-inverse
jsr set_normal
; print messages
lda #<title_text
sta OUTL
lda #>title_text
sta OUTH
; print the text
ldx #16
title_loop:
jsr move_and_print
dex
bne title_loop
jsr set_inverse
rts
title_text:
.byte 0, 0,"LOADING LEMM V1.01 (17 APR 2022)",0
.byte 0, 1," HOMESTAR RUNNER LEVEL PACK ",0
.byte 0, 3,"BASED ON LEMMINGS BY DMA DESIGN",0
.byte 0, 5," APPLE II PORT: VINCE WEAVER",0
.byte 0, 6," DISK : QKUMBA ",0
.byte 0, 7," LZSA : E. MARTY AUDIO: O. SCHMIDT",0
.byte 0, 8," ",0
.byte 0,10,"DIRECTIONS:",0
.byte 0,11," WASD/ARROWS : MOVE POINTER",0
.byte 0,12," ENTER/SPACE : ACTION",0
.byte 0,13," 1...8 : FAST JOB SELECT",0
.byte 0,14," J,! : ENABLE JOYSTICK,CHEAT",0
.byte 0,16," ______",0
.byte 0,17," A \/\/\/ SOFTWARE PRODUCTION",0
.byte 0,19," HTTP://WWW.DEATER.NET/WEAVE/VMWPROD",0
.byte 4,21,"PRESS 1-9 TO CHOOSE START LEVEL",0

View File

@ -12,25 +12,42 @@ ZX0_dst = ZP+4
bitr = ZP+6
pntr = ZP+7
CH = $24
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
V2 = $2D
COLOR = $30
DRAW_PAGE = $7A
APPLEII_MODEL = $8B
SOUND_STATUS = $DE
SOUND_DISABLED = $80
SOUND_IN_LC = $01 ; $01 sound effects in language card
SOUND_MOCKINGBOARD = $02 ; mockingboard detected
HGRPAGE = $E6
TEMPY = $F0
XX = $F1
INL = $F2
INH = $F3
MB_VALUE = $F5
MB_ADDR_L = $F6
MB_ADDR_H = $F7
YPOS = $FE
TCOLOR = $FF
MB_VALUE = $F7
MB_ADDR_L = $F8
MB_ADDR_H = $F9
YPOS = $FA
TCOLOR = $FB
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF