; love duck + bouncing hearts ; by Vince `deater` Weaver ; -- dSr-- ; Lovebyte 2023 ; soft switches SPEAKER = $C030 SET_GR = $C050 SET_TEXT = $C051 FULLGR = $C052 PAGE1 = $C054 PAGE2 = $C055 LORES = $C056 ; Enable LORES graphics HGR2 = $F3D8 HGR = $F3E2 HPOSN = $F411 ; (Y,X),(A) (valued stores in HGRX,XH,Y) XDRAW0 = $F65D PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved) PLOT1 = $F80E ; PLOT at (GBASL),Y (need MASK to be $0f or $f0) GBASCALC = $F847 ; Y in A, put addr in GBASL/GBASH (what is C?) SETCOL = $F864 ; COLOR=A SETGR = $FB40 WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us GBASL = $26 GBASH = $27 MASK = $2E COLOR = $30 hgr_lookup_h = $40 ; $40-$70 hgr_lookup_l = $70 ; $70-$A0 gr_lookup_l = $A0 ; $A0-$B8 gr_lookup_h = $B8 ; $B8-$C0 HGR_X = $E0 HGR_Y = $E2 HGR_COLOR = $E4 HGR_HORIZ = $E5 HGR_PAGE = $E6 HGR_SCALE = $E7 YPOS = $F0 XPOS = $F1 DRAW_PAGE = $F2 ROTATION = $FA FRAME = $FB FRAMEH = $FC YY = $FD BB = $FE XX = $FF love_duck: .include "dsr_lores.s" ; bit SET_GR ; switch to lo-res mode ; bit FULLGR ; set full screen ; inc FRAME ; want frame #0 ; maybe not necessary main_loop: ;====================== ; flip page ;====================== jsr flip_page ;=============== ; handle duck ;=============== lda FRAME and #$7f bne check_beep ldx #NOTE_D3 ldy #50 jsr speaker_xy ldx #NOTE_E3 ldy #50 jsr speaker_xy ldx #10 long_wait: lda #200 jsr WAIT dex bne long_wait ; beq no_beep ;=================== ; handle click ;=================== check_beep: and #$3 bne no_beep ; every 4th cycle beep ldx #NOTE_C4 ldy #10 jsr speaker_xy ; Y zero here? no_beep: ;===================== ; handle color cycle ;===================== lda FRAME and #$1f ; cycle colors ever 32 frames bne no_color_cycle inc bg_smc+1 no_color_cycle: lda #100 ; pause a bit jsr WAIT sta GBASL ; A is 0 ; increment frame inc FRAME ; increment frame # bne frame_noflo inc FRAMEH frame_noflo: lda FRAMEH cmp #3 bne keep_going jmp big_loop ; back to beginning keep_going: ; 0000 -> 0100 ; 0100 -> 1000 ;================================= ; clear lo-res screen, page1/page2 ;================================= ; proper with avoiding screen holes is ~25 instructions ; this is more like 16 ; assume GBASL/GBASH already points to proper $400 or $800 ldx #4 ; lores is 1k, so 4 pages txa clc adc DRAW_PAGE sta GBASH full_loop: ldy #$00 ; clear whole page bg_smc: lda #$54 ; color inner_loop: sta (GBASL),Y dey bne inner_loop inc GBASH ; point to next page dex bne full_loop ; X=0 ; Y=0 ; A=color ;==================== ; draw the hearts ;==================== lda #32 ; start from right to save a byte ;======================= ; draw 8x8 bitmap hearts ;======================= ; A is XPOS on entry draw_heart: ; calculate YPOS sta XPOS lsr ; make middle star offset+4 from others lsr adc FRAME ; look up bounce amount and #$7 tax lda bounce,X sta YPOS ldx #