second: play music

This commit is contained in:
Vince Weaver 2023-10-03 16:27:24 -04:00
parent 23984e9ee4
commit 64f16c560f
4 changed files with 287 additions and 9 deletions

View File

@ -13,7 +13,7 @@ all: second.dsk
# $(DOS33) -y second.dsk SAVE A HELLO
# $(DOS33) -y second.dsk BSAVE -a 0x6000 ZW
second.dsk: QBOOT QLOAD SECOND MUSIC \
second.dsk: QBOOT QLOAD SECOND MUSIC START \
./part18_3d/THREED
cp $(EMPTY_DISK) second.dsk
$(DOS33_RAW) second.dsk 0 0 QBOOT 0 1
@ -22,7 +22,8 @@ second.dsk: QBOOT QLOAD SECOND MUSIC \
$(DOS33_RAW) second.dsk 1 0 QLOAD 0 0
$(DOS33_RAW) second.dsk 3 0 MUSIC 0 0
# $(DOS33_RAW) second.dsk 5 0 SECOND 0 0
$(DOS33_RAW) second.dsk 5 0 ./part18_3d/THREED 0 0
$(DOS33_RAW) second.dsk 5 0 START 0 0
$(DOS33_RAW) second.dsk 8 0 ./part18_3d/THREED 0 0
####
@ -67,6 +68,17 @@ second.o: second.s zx02_optim.s \
####
START: start.o
ld65 -o START start.o -C ../../linker_scripts/apple2_4000.inc
start.o: start.s zx02_optim.s \
text_print.s title.s \
zp.inc hardware.inc qload.inc music.inc
ca65 -o start.o start.s -l start.lst
####
qload.inc: generate_common QLOAD
./generate_common -a 0x1200 -s load_file qload.lst > qload.inc
./generate_common -a 0x1200 -s detect_appleii_model qload.lst >> qload.inc
@ -130,4 +142,4 @@ generate_common.o: generate_common.c
clean:
rm -f *~ *.o *.lst HELLO SECOND QBOOT QLOAD MUSIC
rm -f *~ *.o *.lst HELLO SECOND QBOOT QLOAD MUSIC START

View File

@ -27,5 +27,6 @@ PT3_ENABLE_APPLE_IIC = 1
.align $100
PT3_LOC:
.incbin "music/z00m_unreal2_part1.pt3"
;.incbin "music/z00m_unreal2_part1.pt3"
.incbin "music/z00m_unreal2_part2.pt3"

View File

@ -23,7 +23,7 @@ qload_start:
jsr load_file
jmp $6000 ; jump to ZW
jmp $4000 ; jump to ZW
;====================================
; loads file specified by WHICH_LOAD
@ -160,19 +160,19 @@ error_string:
.endif
which_disk_array:
.byte 1,1,1,1 ; SECOND, MUSIC, ?, ?
.byte 1,1,1,1 ; SECOND, MUSIC, 3D , ?
load_address_array:
.byte $60,$D0,$90,$90 ; SECOND, MUSIC, ?, ?
.byte $40,$D0,$60,$90 ; SECOND, MUSIC, ?, ?
track_array:
.byte 5, 3, 9,12 ; SECOND, MUSIC, ?, ?
.byte 5, 3, 8,12 ; SECOND, MUSIC, ?, ?
sector_array:
.byte 0, 0, 0, 0 ; SECOND, MUSIC, ?, ?
length_array:
.byte 84, 32, 48, 48 ; SECOND, MUSIC, ?, ?
.byte 16, 32, 84, 48 ; SECOND, MUSIC, ?, ?
.include "lc_detect.s"
.include "wait.s"

265
demos/second/start.s Normal file
View File

@ -0,0 +1,265 @@
; Unwisely messing with Second Reality
;
; by deater (Vince Weaver) <vince@deater.net>
.include "zp.inc"
.include "hardware.inc"
.include "qload.inc"
.include "music.inc"
second_start:
;=====================
; initializations
;=====================
;=====================
; detect model
;=====================
jsr detect_appleii_model
;=====================
; Machine workarounds
;=====================
; mostly IIgs
; thanks to 4am for 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
; this enables the workaround
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:
;===================
; restart?
;===================
restart:
lda #0
sta DRAW_PAGE
;===================
; show title screen
;===================
jsr show_title
;===================
; print config
;===================
jsr set_normal
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)
;===================================
; we might want to later load sound high,
; for now always enable sound
lda #0
sta SOUND_STATUS ; clear out, sound enabled
jsr detect_language_card
bcs no_language_card
yes_language_card:
; update status on title screen
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:
;===================================
; Detect Mockingboard
;===================================
; 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
; for now, don't require language card
lda SOUND_STATUS
and #SOUND_IN_LC
beq dont_enable_mc
lda SOUND_STATUS
ora #SOUND_MOCKINGBOARD
sta SOUND_STATUS
;==================================
; load sound into the language card
; into $D000 set 1
;==================================
; read/write RAM, use $d000 bank1
bit $C083
bit $C083
lda #1
sta WHICH_LOAD
jsr load_file
lda #0
sta DONE_PLAYING
lda #1
sta LOOP
; patch mockingboard
jsr mockingboard_patch ; patch to work in slots other than 4?
;=======================
; Set up 50Hz interrupt
;========================
jsr mockingboard_init
jsr mockingboard_setup_interrupt
;============================
; Init the Mockingboard
;============================
jsr reset_ay_both
jsr clear_ay_both
;==================
; init song
;==================
jsr pt3_init_song
dont_enable_mc:
mockingboard_notfound:
skip_all_checks:
;=======================
; wait for keypress
;=======================
; jsr wait_until_keypress
lda #25
jsr wait_a_bit
;===================
; Load graphics
;===================
load_loop:
; jsr HGR
bit SET_GR
bit HIRES
bit FULLGR
bit PAGE1
;=======================
; start music
;=======================
lda #2
sta WHICH_LOAD
jsr load_file
cli
jmp $6000
forever:
jmp forever
.align $100
.include "wait_keypress.s"
.include "zx02_optim.s"
.include "title.s"
config_string:
; 0123456789012345678901234567890123456789
.byte 0,23,"APPLE II?, 48K, MOCKINGBOARD: NO, SSI: N",0
.include "pt3_lib_mockingboard_patch.s"