demo: o: back below 256B

This commit is contained in:
Vince Weaver 2022-05-25 16:11:38 -04:00
parent ca945e3609
commit 031eb48e6a

View File

@ -1,15 +1,21 @@
; New Demo ; DSR Scroll Demo -- 256B Apple II Demo for Outline 2022
; by Vince `deater` Weaver ; by Vince `deater` Weaver / dSr
; 253 bytes -- initial implementation with no sound
; 253 bytes -- init with no sound
; 251 bytes -- no phase ; 251 bytes -- no phase
; 247 bytes -- move scale before so don't have to reload 0 ; 247 bytes -- move scale before so don't have to reload 0
; 243 bytes -- use BIT trick ; 243 bytes -- use BIT trick
; 242 bytes -- load frame into Y ; 242 bytes -- load frame into Y
; 240 bytes -- more BIT trick ; 240 bytes -- more BIT trick
; 239 bytes -- compare with BMI ; 239 bytes -- compare with BMI
; 263 bytes -- initially add sound
; 262 bytes -- make Y always 0 in xdraw
; 260 bytes -- ust BIT to determine phase
; 258 bytes -- no need to init PAGE at start
; 257 bytes -- remove a CLC as we know carry always set
; 256 bytes -- optimize phase now that we are setting 0/7 not 1/8
; 255 bytes -- optimize same area some more
; zero page locations ; zero page locations
HGR_SHAPE = $1A HGR_SHAPE = $1A
@ -23,10 +29,8 @@ YREG = $47
FRAME = $6D FRAME = $6D
PAGE = $6E PAGE = $6E
LINE = $6F
OUTL = $74 OUTL = $74
OUTH = $75 OUTH = $75
COUNT = $76
; C0-CF should be clear ; C0-CF should be clear
; D0-DF?? D0-D5 = HGR scratch? ; D0-DF?? D0-D5 = HGR scratch?
@ -90,7 +94,6 @@ dsr_scroll_intro:
jsr HGR2 ; Hi-res, full screen jsr HGR2 ; Hi-res, full screen
; Y=0, A=0 after this call ; Y=0, A=0 after this call
sta PAGE ; needed?
sta FRAME sta FRAME
sta OUTL sta OUTL
@ -101,8 +104,10 @@ dsr_scroll_intro:
hires_setup: hires_setup:
; A is 0 here ; A is 0 here
; Y is also 0 here
; lda #0 ; non-rotate, on HGR PAGE2 ; lda #0 ; non-rotate, on HGR PAGE2
jsr xdraw ; jsr xdraw ;
tay ; reset Y to 0
lda #$20 ; switch drawing to HGR PAGE1 lda #$20 ; switch drawing to HGR PAGE1
sta HGR_PAGE sta HGR_PAGE
@ -130,15 +135,12 @@ main_loop:
sta OUTH sta OUTH
; bit SPEAKER
;======================= ;=======================
; delay ; delay
;======================= ;=======================
lda #200 lda #200
jsr WAIT jsr play_sound
;======================= ;=======================
; handle state ; handle state
@ -148,49 +150,73 @@ main_loop:
; LO-RES DOWN SCROLL 128..191 ; LO-RES DOWN SCROLL 128..191
; TEXT RIGHT SCROLL 192..255 ; TEXT RIGHT SCROLL 192..255
ldx #0 ldx #0
inc FRAME inc FRAME
ldy FRAME lda #$1F
cpy #192 ; 192 bit FRAME ; puts bit 7 in N and bit 6 in V
bcs phase3 php ; save flags (zero is one we care)
tya
bmi phase2 ; 128 bpl n_clear
cpy #64 ; 64 bvc phase2
bcc phase0 bvs phase3
n_clear:
bvc phase0
; bvs phase1
phase1: phase1:
bit LORES ; enable lo-res ; LORES Vertical Scroll
lda #8 ; make vertical scroll
.byte $2C ; BIT trick to skip the load bit LORES ; enable lo-res
ldx #7 ; make vertical scroll
; .byte $24 ; BIT trick to skip the txa
phase2: phase2:
lda #1 ; make horizontal scroll ; LORES Horizontal Scroll
sta pattern_dir_smc+1
bne done_phase ; bra ; X is 7 or 0 here
; txa ; make horizontal scroll (0)
; lda #0 ; make horizontal scroll
stx pattern_dir_smc+1
jmp done_phase ; bra
phase0: phase0:
; HIRES on GRAPHICS on
bit HIRES bit HIRES
.byte $24 ; BIT trick .byte $24 ; BIT trick to skip the inx
phase3: phase3:
; TEXT ON
inx ; point to SET_TEXT rather than SET_GR inx ; point to SET_TEXT rather than SET_GR
lda SET_GR,X ; set mode lda SET_GR,X ; set mode
done_phase: done_phase:
plp ; restore flags
tya ; FRAME
and #$1f
bne not_zero bne not_zero
; rolled around, reset? was_zero:
; update pointer to "random" background color
inc pattern_smc+2 inc pattern_smc+2
ldy #135
boop_loop:
lda #8
jsr play_sound
lda #9
jsr play_sound
dey
bne boop_loop
not_zero: not_zero:
;============================ ;============================
; draw an interleaved line ; draw an interleaved line
full_loop: full_loop:
@ -251,7 +277,7 @@ done_bg:
;======================================= ;=======================================
; done drawing frame ; done drawing frame
;======================================= ;=======================================
bit $C030
;====================== ;======================
; draw bitmap ; draw bitmap
@ -304,11 +330,14 @@ its_black:
;========================= ;=========================
; scroll one line ; scroll one line
;=========================
; if +1 then horizontal
; if +8 then vertical
; to scroll up need to add 8? ; our current bitmap top line is all FFs
; inc pattern_smc+1 ; so we know carry will be set here
clc ; clc
lda pattern_smc+1 lda pattern_smc+1
pattern_dir_smc: pattern_dir_smc:
adc #$8 adc #$8
@ -334,11 +363,12 @@ flip_page:
; xdraw ; xdraw
;======================= ;=======================
; rotation in A ; rotation in A
; Y should be 0 on entry
xdraw: xdraw:
pha ; save rotation pha ; save rotation
; setup X and Y co-ords ; setup X and Y co-ords
ldy #0 ; XPOSH always 0 for us ; ldy #0 ; XPOSH always 0 for us
ldx #140 ldx #140
lda #80 ; 96 would be halfway? lda #80 ; 96 would be halfway?
jsr HPOSN ; X= (y,x) Y=(a) jsr HPOSN ; X= (y,x) Y=(a)
@ -358,6 +388,14 @@ xdraw:
; tail call ; tail call
;=============================
; play_sound
;=============================
play_sound:
bit $C030
jmp WAIT
; updated desire logo thanks to Jade/HMD ; updated desire logo thanks to Jade/HMD
;012|456|012|456| ;012|456|012|456|
@ -384,7 +422,6 @@ bitmap2:
.byte $FF .byte $FF
.byte $23 .byte $23
.byte $F9 .byte $F9
.byte $23 .byte $23
.byte $39 .byte $39
.byte $29 .byte $29