ds: some cycle counting

This commit is contained in:
Vince Weaver 2019-10-12 10:47:38 -04:00
parent a337813409
commit a1b7b778b6
7 changed files with 298 additions and 39 deletions

View File

@ -9,11 +9,12 @@ B2D = ../bmp2dhr/b2d
all: demosplash.dsk
demosplash.dsk: HELLO DEMOSPLASH LOADER BOOK_HGR2C.BIN
demosplash.dsk: HELLO DEMOSPLASH LOADER BOOK_HGR2C.BIN MUSICTEST
cp empty.dsk demosplash.dsk
$(DOS33) -y demosplash.dsk SAVE A HELLO
$(DOS33) -y demosplash.dsk BSAVE -a 0x1400 LOADER
$(DOS33) -y demosplash.dsk BSAVE -a 0x1700 DEMOSPLASH
$(DOS33) -y demosplash.dsk BSAVE -a 0x1700 MUSICTEST
####
@ -43,6 +44,20 @@ demosplash.o: demosplash.s \
#####
MUSICTEST: musictest.o
ld65 -o MUSICTEST musictest.o -C ../linker_scripts/apple2_1700.inc
musictest.o: musictest.s \
zp.inc hardware.inc \
appleII_intro.s \
pt3_lib_init.s pt3_lib_core.s pt3_lib_mockingboard.s \
interrupt_handler.s \
dya_space_demo2.pt3
ca65 -o musictest.o musictest.s -l musictest.lst
#####
LOADER: loader.o
ld65 -o LOADER loader.o -C ../linker_scripts/apple2_1400.inc

View File

@ -27,18 +27,18 @@ appleII_intro:
lda #$c
jsr load_rle_gr
lda #4
sta DRAW_PAGE
; lda #$4
; sta DRAW_PAGE
jsr gr_copy_to_current ; copy to page1
; jsr gr_copy_to_current ; copy to page1
; GR part
bit PAGE1
bit LORES ; 4
bit SET_GR ; 4
bit FULLGR ; 4
; bit PAGE1
; bit LORES ; 4
; bit SET_GR ; 4
; bit FULLGR ; 4
jsr wait_until_keypressed
; jsr wait_until_keypressed
;=============================
@ -48,18 +48,18 @@ appleII_intro:
sta GBASL
lda #>appleII_high
sta GBASH
lda #$c
lda #$10
jsr load_rle_gr
lda #0
sta DRAW_PAGE
; lda #$0
; sta DRAW_PAGE
jsr gr_copy_to_current
; jsr gr_copy_to_current
; GR part
bit PAGE0
jsr wait_until_keypressed
; jsr wait_until_keypressed
;==============================
@ -71,22 +71,33 @@ appleII_intro:
; vapor lock returns with us at beginning of hsync in line
; 114 (7410 cycles), so with 5070 lines to go
; 5070+17030=22100
; GR part
bit LORES ; 4
bit SET_GR ; 4
bit FULLGR ; 4
jsr gr_copy_to_current ; 6+ 9292
lda #0 ; 2
sta DRAW_PAGE ; 3
jsr gr_clear_all ; 6+ 5454
; now we have 322 left
lda #4 ; 2
sta DRAW_PAGE ; 3
jsr gr_clear_all ; 6+ 5454
; 322 - 12 = 310
; - 3 for jmp
; 307
; 22100
; -12
; -5465
; -5465
; -3 (jmp)
;==========
; 11155
; Try X=9 Y=6 cycles=307
ldy #6 ; 2
loopA: ldx #9 ; 2
; Try X=56 Y=39 cycles=11155
ldy #39 ; 2
loopA: ldx #56 ; 2
loopB: dex ; 2
bne loopB ; 2nt/3
dey ; 2
@ -144,9 +155,55 @@ page1_loop: ; delay 115+(7 loop)+4 (bit)+4(extra)
; We have 4550 cycles in the vblank, use them wisely
;======================================================
; do_nothing should be 4550+1 -2-9 -7= 4533
; 4550
; +1 (fallthrough)
; -2 initial conditions
; -1107
; -7 (keypress)
; -3 (jump)
; =====
; 3432
jsr do_nothing ; 6
;=====================
;=====================
; 4+ 24*(30+16)-1 = 1107
; page0 -- copy from $c00
ldx #4 ; 2
ldy #0 ; 2
;=====
; 4
page0_loopy:
lda gr_offsets,Y ; 4+
sta page0_store_smc+1 ; 4
sta page0_load_smc+1 ; 4
lda gr_offsets+1,Y ; 4+
clc ; 2
adc #$4 ; 2
sta page0_store_smc+2 ; 4
adc #$4 ; 2
sta page0_load_smc+2 ; 4
;=====
; 30
page0_load_smc:
lda $1000,X ; 4+
page0_store_smc:
sta $1000,X ; 5
iny ; 2
cpy #24 ; 2
bne page0_loopy ; 3
;================
; 16
; -1
;==========================
;==========================
lda KEYPRESS ; 4
bpl no_keypress2 ; 3
jmp appleii_done
@ -161,24 +218,20 @@ appleii_done:
;=================================
; do nothing
;=================================
; and take 4533-6 = 4527 cycles to do it
; and take 3432-12 = 3420 cycles to do it
do_nothing:
; Try X=4 Y=174 cycles=4525 R2
; Try X=39 Y=17 cycles=3418 R2
nop ; 2
ldy #174 ; 2
loop1:
ldx #4 ; 2
loop2:
dex ; 2
ldy #17 ; 2
loop1: ldx #39 ; 2
loop2: dex ; 2
bne loop2 ; 2nt/3
dey ; 2
bne loop1 ; 2nt/3
rts ; 6

View File

@ -110,7 +110,7 @@ wait_until_keypressed:
;.include "text_print.s"
.include "gr_pageflip.s"
;.include "gr_fast_clear.s"
.include "gr_fast_clear.s"
;.include "gr_overlay.s"
; missing

View File

@ -0,0 +1,51 @@
;=========================================================
; clear_all
;=========================================================
; clear 48 rows
; page in DRAW_PAGE
; 45+4+(45*120)+5 = 5454
gr_clear_all:
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __caf+2 ; 4
sta __caf+5 ; 4
adc #1 ; 2
sta __caf+8 ; 4
sta __caf+11 ; 4
adc #1 ; 2
sta __caf2+2 ; 4
sta __caf2+5 ; 4
adc #1 ; 2
sta __caf2+8 ; 4
sta __caf2+11 ; 4
;===========
; 45
ldy #120 ; 2
clear_all_color:
lda #0 ; 2
;============
; 4
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 ; 3
;============
; 45
; -1
rts ; 6

View File

@ -1,3 +1,3 @@
5 HOME
200 PRINT CHR$ (4)"BRUN LOADER"
200 PRINT CHR$ (4)"CATALOG"

140
demosplash/musictest.s Normal file
View File

@ -0,0 +1,140 @@
; Demosplash 2019
; by Vince "Deater" Weaver <vince@deater.net>
.include "zp.inc"
.include "hardware.inc"
demosplash2019:
;=========================
; set up sound
;=========================
lda #0
sta DONE_PLAYING
jsr mockingboard_init
jsr pt3_setup_interrupt
jsr reset_ay_both
jsr clear_ay_both
jsr pt3_init_song
; lda #1
; sta LOOP
;===========================
; Enable graphics
;===========================
bit LORES
bit SET_GR
bit FULLGR
bit KEYRESET
;===========================
; Setup pages (is this necessary?)
;===========================
lda #0
sta DRAW_PAGE
lda #1
sta DISP_PAGE
;===========================
; apple II intro
;============================
jsr appleII_intro
;===========================
; show some pictures
;============================
; start music
; cli ; enable interrupts
;===========================
; missing scene
;===========================
; jsr missing_intro
;===========================
; starbase scene
;===========================
; jsr starbase
;===========================
; escape scene
;===========================
; jsr escape
;===========================
; book scene
;===========================
; jsr book
; wait wait wait
; jsr wait_until_keypressed
;repeat_ending:
; jmp repeat_ending
;======================
; wait until keypressed
;======================
wait_until_keypressed:
lda KEYPRESS
bpl wait_until_keypressed
bit KEYRESET
rts
; Apple II intro
.include "appleII_intro.s"
.include "appleII_40_96.inc"
.include "vapor_lock.s"
.include "delay_a.s"
.include "gr_unrle.s"
.include "gr_offsets.s"
.include "gr_copy.s"
;.include "text_print.s"
;.include "gr_pageflip.s"
.include "gr_fast_clear.s"
;.include "gr_overlay.s"
; missing
;.include "missing.s"
; Starbase
;.include "starbase.s"
; escape
;.include "escape.s"
; book
;.include "book.s"
; Music player
.include "pt3_lib_core.s"
.include "pt3_lib_init.s"
.include "pt3_lib_mockingboard.s"
.include "interrupt_handler.s"
PT3_LOC = song
; must be page aligned
.align 256
song:
.incbin "dya_space_demo2.pt3"

View File

@ -1693,7 +1693,7 @@ do_frame:
jsr calculate_note ; 6+?
convert_177_smc1:
sec ; 2
clc ; 2
; Load up the Frequency Registers
@ -1739,7 +1739,7 @@ convert_177_smc1:
no_scale_a:
convert_177_smc2:
sec ; 2
clc ; 2
lda note_b+NOTE_TONE_L ; Note B Period L ; 4
sta AY_REGISTERS+2 ; into R2 ; 3
@ -1781,7 +1781,7 @@ convert_177_smc2:
no_scale_b:
convert_177_smc3:
sec ; 2
clc ; 2
lda note_c+NOTE_TONE_L ; Note C Period L ; 4
sta AY_REGISTERS+4 ; into R4 ; 3
@ -1833,7 +1833,7 @@ pt3_noise_add_smc:
sta AY_REGISTERS+6 ; 3
convert_177_smc4:
sec ; 2
clc ; 2
bcc no_scale_n ; 2/3
; Convert from 1.77MHz to 1MHz by multiplying by 9/16
@ -1896,7 +1896,7 @@ pt3_envelope_slide_h_smc:
sta AY_REGISTERS+12 ; 3
convert_177_smc5:
sec
clc
bcc no_scale_e ; 2/3
; Convert from 1.77MHz to 1MHz by multiplying by 9/16