From 93e0f4af41f4c79722175f535287bfa861c87375 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 13 Jun 2019 11:47:58 -0400 Subject: [PATCH] sprites: start adding putsprite for asteroids --- interlace_demo/gr_putsprite.s | 80 +++++++++++++++++++++++++++++++++++ interlace_demo/sprites.s | 25 ++++++----- 2 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 interlace_demo/gr_putsprite.s diff --git a/interlace_demo/gr_putsprite.s b/interlace_demo/gr_putsprite.s new file mode 100644 index 00000000..10c09bc3 --- /dev/null +++ b/interlace_demo/gr_putsprite.s @@ -0,0 +1,80 @@ + ;============================================= + ; put_sprite + ;============================================= + ; Sprite to display in INH,INL + ; Location is SPRITE_XPOS,SPRITE_YPOS + ; Note, only works if SPRITE_YPOS is multiple of two + + ; NO TRANSPARENCY + + ; 28+ Y*(34+17+X*(18+13) + 5 + ; 33 + Y*(51+31*X) + + ; so if 3*2 = 321 cycles?? + +put_sprite: + + ldy #0 ; byte 0 is xsize ; 2 + lda (INL),Y ; 5 + sta CH ; xsize is in CH ; 3 + iny ; 2 + + lda (INL),Y ; byte 1 is ysize ; 5 + sta CV ; ysize is in CV ; 3 + iny ; 2 + + lda SPRITE_YPOS ; make a copy of ypos ; 3 + sta TEMPY ; as we modify it ; 3 + ;=========== + ; 28 +put_sprite_loop: + sty TEMP ; save sprite pointer ; 3 + ldy TEMPY ; 3 + lda gr_offsets,Y ; lookup low-res memory address ; 4 + clc ; 2 + adc SPRITE_XPOS ; add in xpos ; 3 + sta OUTL ; store out low byte of addy ; 3 + lda gr_offsets+1,Y ; look up high byte ; 4 + adc DRAW_PAGE ; ; 3 + sta OUTH ; and store it out ; 3 + ldy TEMP ; restore sprite pointer ; 3 + + ; OUTH:OUTL now points at right place + + ldx CH ; load xsize into x ; 3 + ;=========== + ; 34 +put_sprite_pixel: + lda (INL),Y ; get sprite colors ; 5 + iny ; increment sprite pointer ; 2 + + sty TEMP ; save sprite pointer ; 3 + ldy #$0 ; 2 + sta (OUTL),Y ; and write it out ; 6 + ;============ + ; 18 + +put_sprite_done_draw: + + ldy TEMP ; restore sprite pointer ; 3 + + inc OUTL ; increment output pointer ; 5 + dex ; decrement x counter ; 2 + bne put_sprite_pixel ; if not done, keep looping ; 3 + ;============== + ; 13 + + ; -1 + inc TEMPY ; each line has two y vars ; 5 + inc TEMPY ; 5 + dec CV ; decemenet total y count ; 5 + bne put_sprite_loop ; loop if not done ; 3 + ;============== + ; 17 + + ; -1 + rts ; return ; 6 + + + + diff --git a/interlace_demo/sprites.s b/interlace_demo/sprites.s index ba3de79e..8098d8e6 100644 --- a/interlace_demo/sprites.s +++ b/interlace_demo/sprites.s @@ -23,20 +23,25 @@ BASL = $28 BASH = $29 FRAME = $60 BLARGH = $69 +SPRITE_XPOS = $E0 +SPRITE_YPOS = $E1 DRAW_PAGE = $EE + FIRE_X = $F0 FIRE_Y = $F1 +YPOS = $F2 +YADD = $F3 +BLAST1 = $F4 +BLAST2 = $F5 +FIRE = $F6 +TEMP = $F7 +WHICH = $F8 +TEMPY = $F9 +LEVEL_DONE = $FA -YPOS = $F3 -YADD = $F4 -BLAST1 = $F5 -BLAST2 = $F6 -FIRE = $F7 -TEMP = $FA -WHICH = $FB -TEMPY = $FC -LEVEL_DONE = $FD +INL = $FC +INH = $FD OUTL = $FE OUTH = $FF @@ -1013,7 +1018,7 @@ erase_fire: .include "gr_copy.s" .include "vapor_lock.s" .include "delay_a.s" - +.include "gr_putsprite.s" .assert >gr_offsets = >gr_offsets_done, error, "gr_offsets crosses page" .assert >wait_loop = >(wait_loop_end-1), error, "wait_loop crosses page"