second: lens: hookup gr sprite code

This commit is contained in:
Vince Weaver 2023-11-02 12:02:08 -04:00
parent 4215f84611
commit 737e9af10e
4 changed files with 145 additions and 2 deletions

View File

@ -14,6 +14,7 @@ LENS: lens.o
lens.o: lens.s ../zx02_optim.s \
roto.s rotozoom.s \
graphics/lens_sprites.inc \
graphics/lenspic.gr.zx02 \
../zp.inc ../hardware.inc
ca65 -o lens.o lens.s -l lens.lst

View File

@ -0,0 +1,86 @@
;====================
; gr_put_sprite_mask
;====================
; Sprite to display in INL/INH
; MASK (for transparency) on MASKL/MASH
; Location is XPOS,YPOS
; Note, only works if YPOS is multiple of two
; trashes A,X,Y
gr_put_sprite_mask:
ldy #0
lda (INL),Y ; xsize
clc
adc XPOS
sta gps_xmax_smc+1 ; store xmas (self-modify)
iny ; 2
lda (INL),Y ; ysize
asl ; mul by 2
clc
adc YPOS
sta gps_ymax_smc+1
iny
tya
tax
lda INL
sta gps_src_smc+1
lda INH
sta gps_src_smc+2
lda MASKL
sta gps_mask_smc+1
lda MASKH
sta gps_mask_smc+2
gr_put_sprite_loop:
ldy YPOS
lda gr_offsets,Y
sta OUTL
lda gr_offsets+1,Y
clc
adc DRAW_PAGE
sta OUTH
ldy XPOS
gr_put_sprite_row:
cpy #40
bcs gr_put_sprite_dont_draw ; don't draw if out of bounds
; put the pixel
; based on monitor plot code
lda (OUTL),Y
gps_src_smc:
eor $f000,X ; load sprite data
gps_mask_smc:
and $f000,X
eor (OUTL),Y
sta (OUTL),Y
gr_put_sprite_dont_draw:
iny
inx
gps_xmax_smc:
cpy #40
bne gr_put_sprite_row
inc YPOS
inc YPOS
lda YPOS
gps_ymax_smc:
cmp #40
bne gr_put_sprite_loop
gr_put_sprite_done:
rts ; return ; 6

View File

@ -79,8 +79,58 @@ load_background:
jsr page_flip
jsr gr_copy_to_current
; wait
; TODO: draw lens
;=================================
;TODO: wait 5s?
;
;=================================
;TODO: play sound sample?
;=================================
; decompress audio to $6000
; lda #<transmission_data
; sta zx_src_l+1
; lda #>transmission_data
; sta zx_src_h+1
; lda #$60
; jsr zx02_full_decomp
; play audio
; lda #$00
; sta BTC_L
; lda #$60
; sta BTC_H
; sei ; stop music
; ldx #11
; jsr play_audio
; cli
;===============================
; draw lens
;===============================
lda #10
sta XPOS
lda #10
sta YPOS
lda #<lens_mask
sta MASKL
lda #>lens_mask
sta MASKH
lda #<lens_sprite
sta INL
lda #>lens_sprite
sta INH
jsr gr_put_sprite_mask
lda #15
jsr wait_seconds
@ -117,6 +167,8 @@ lens_end:
.include "../wait_keypress.s"
.include "../zx02_optim.s"
.include "../irq_wait.s"
.include "gr_putsprite_mask.s"
.include "../audio.s"
;===============================================
; Data
@ -125,3 +177,5 @@ lens_end:
lens_zx02:
.incbin "graphics/lenspic.gr.zx02"
.include "graphics/lens_sprites.inc"

View File

@ -118,6 +118,8 @@ FRAMEL = $E8
FRAMEH = $E9
BTC_L = $EA ; audio
BTC_H = $EB ; audio
MASKL = $EC ; gr_putsprite_mask
MASKH = $ED
;==============================================
; $F0-$FB can re-use in each file