From 16ab5c75c2d9090e70c2caeb0f00cb419ba57253 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 13 Jun 2019 12:35:51 -0400 Subject: [PATCH] sprites: asteroid moves --- interlace_demo/random.data | Bin 0 -> 256 bytes interlace_demo/sprites.s | 67 ++++++++++++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 interlace_demo/random.data diff --git a/interlace_demo/random.data b/interlace_demo/random.data new file mode 100644 index 0000000000000000000000000000000000000000..d2e3622b8b78f9585b02e3b991a42ad757da6f94 GIT binary patch literal 256 zcmV+b0ssE*PP)LBfe=%u12}Y!Kp;Y4t>Vr&;7?(BhotuH6guSsAuGZ%PkctLC@gQ& zSq`d{sus*7Wm-`mD^Cj8Hg5_fCzar~4yp{T{j*r8j&MCUQ@`|!9YS9jJV1iW={-H1 zEtv2f9qoTEWAci*j10&_?8MUu0|kKkZxah0t1lVMl{EoLc_K5D(E}wE2zol?m8Cxl zGHD2q`l2i-r%ujcds&2jxV(B3qd_@%mJv8viS$2zP4pA*an(}Av1`v~l|k)12rR%H zMf#LPUDBw|yOK1poQ5G6n*haZ$E0TvK#0i5h&%E7FngRMWUw*`|DQor2ca4s4~U9Y GyI18%hH;Vr literal 0 HcmV?d00001 diff --git a/interlace_demo/sprites.s b/interlace_demo/sprites.s index b18da715..f6041355 100644 --- a/interlace_demo/sprites.s +++ b/interlace_demo/sprites.s @@ -25,6 +25,11 @@ FRAME = $60 BLARGH = $69 SPRITE_XPOS = $E0 SPRITE_YPOS = $E1 +RANDOM_PTR = $E2 + +ASTEROID_X = $E3 +ASTEROID_Y = $E4 + DRAW_PAGE = $EE @@ -99,6 +104,12 @@ start_sprites: lda #$ff sta GREEN2 + lda #$36 + sta ASTEROID_X + + lda #$12 + sta ASTEROID_Y + lda #64 sta YPOS @@ -231,13 +242,14 @@ display_loop: ; -167 -- erase fire ; -31 -- move ship ; -17 -- move fire + ; -36 -- move asteroid ; -436 -- draw fire - ; -335 -- draw asteroid + ; -337 -- draw asteroid ; -61 -- keypress ; -33 -- handle fire press ; -8 -- loop ;======= - ; 812 + ; 774 ;================ ; erase old ship @@ -301,6 +313,43 @@ display_loop: + ;========================== + ; move/collide the asteroid + ;========================== + ; move ok: 8 [28] + ; move off screen: 8+28 = 36 + ; game over: who cares + + dec ASTEROID_X ; 5 + bne no_new_asteroid ; 3 +new_asteroid: + ; -1 + inc RANDOM_PTR ; 5 + ldy RANDOM_PTR ; 3 + lda random_values,Y ; 4 + and #$1e ; 2 + clc ; 2 + adc #$4 ; 2 + sta ASTEROID_Y ; 3 + lda #36 ; 2 + sta ASTEROID_X ; 3 + jmp done_move_asteroid ; 3 + ;=========== + ; 28 + +no_new_asteroid: + inc TEMP ; 5 + inc TEMP ; 5 + inc TEMP ; 5 + inc TEMP ; 5 + inc TEMP ; 5 + lda TEMP ; 3 + + +done_move_asteroid: + + + ;========================== ; move the fire ;========================== @@ -601,13 +650,13 @@ done_draw_fire: sta INL ; 3 lda #>asteroid_p1 ; 2 sta INH ; 3 - lda #30 ; 2 + lda ASTEROID_X ; 3 sta SPRITE_XPOS ; 3 - lda #12 ; 2 + lda ASTEROID_Y ; 3 sta SPRITE_YPOS ; 3 jsr put_sprite ; 6+304 ;====== - ; 335 + ; 337 @@ -633,12 +682,12 @@ pad_time: wait_loop: - ; Try X=161 Y=1 cycles=812 -; nop + ; Try X=153 Y=1 cycles=772R2 + nop ; nop ldy #1 ; 2 -loop1: ldx #161 ; 2 +loop1: ldx #153 ; 2 loop2: dex ; 2 bne loop2 ; 2nt/3 dey ; 2 @@ -1033,6 +1082,8 @@ erase_fire: .include "../asm_routines/gr_unrle.s" ;.include "../asm_routines/keypress.s" .align $100 +random_values: +.incbin "random.data" .include "sprites_table.s" .include "gr_offsets.s"