space_bars: add sprite

weird problem was because size of game > 4k and was running into
HGR page0
This commit is contained in:
Vince Weaver 2018-10-07 21:18:40 -04:00
parent d4b45d2ec8
commit e8514067e5
7 changed files with 286 additions and 186 deletions

View File

@ -35,11 +35,19 @@ shadow_left:
ship_forward:
.byte $9,$5
.byte $00,$00,$00,$00,$ff,$00,$00,$00,$00
.byte $00,$00,$00,$66,$ff,$66,$00,$00,$00
.byte $00,$00,$70,$2f,$12,$2f,$70,$00,$00
.byte $f0,$f7,$f7,$f2,$d9,$f2,$f7,$f7,$f0
.byte $00,$00,$00,$00,$0d,$00,$00,$00,$00
.byte $00,$00,$00,$00,$ff,$00,$00,$00,$00 ; 00=8 0X=0 X0=0 XX=1
.byte $00,$00,$00,$66,$ff,$66,$00,$00,$00 ; 00=6 0x=0 X0=0 XX=3
.byte $00,$00,$70,$2f,$12,$2f,$70,$00,$00 ; 00=4 0x=0 X0=2 XX=3
.byte $f0,$f7,$f7,$f2,$d9,$f2,$f7,$f7,$f0 ; 00=0 0x=0 X0=2 XX=7
.byte $00,$00,$00,$00,$0d,$00,$00,$00,$00 ; 00=8 0x=1 X0=0 XX=0
;=====================
; 26 1 4 14
; 00=26 0X=1 X0=4 XX=14
; = 33 + Y*(52)+ [30A + 64B + 69C + 54D]-Y
; = 33 + 5*52 + 30*26 + 64*1 + 69*4 + 54*14 - 5
; = 2164
ship_right:
.byte $9,$5
@ -67,148 +75,5 @@ ship_tiny:
.byte $3,$1
.byte $f0,$9f,$f0
sphere_offset:
.byte 0,27,54,81, 108,135,162,189
.if 0
sphere0:
.byte $5,$5
.byte $00,$b0,$b3,$b0,$00
.byte $b0,$bb,$bb,$bb,$30
.byte $bb,$bb,$bb,$bb,$33
.byte $bb,$bb,$bb,$bb,$33
.byte $00,$3b,$3b,$3b,$00
sphere1:
.byte $5,$5
.byte $00,$30,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$b0
.byte $bb,$bb,$bb,$bb,$bb
.byte $bb,$bb,$bb,$bb,$bb
.byte $00,$bb,$bb,$bb,$00
sphere2:
.byte $5,$5
.byte $00,$30,$b3,$b0,$00
.byte $30,$b3,$bb,$bb,$b0
.byte $33,$bb,$bb,$bb,$bb
.byte $33,$bb,$bb,$bb,$bb
.byte $00,$33,$3b,$3b,$00
sphere3:
.byte $5,$5
.byte $00,$30,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$b0
.byte $33,$3b,$bb,$bb,$bb
.byte $33,$33,$3b,$bb,$bb
.byte $00,$33,$33,$3b,$00
sphere4:
.byte $5,$5
.byte $00,$b0,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$b0
.byte $33,$33,$3b,$bb,$bb
.byte $33,$33,$33,$33,$3b
.byte $00,$33,$33,$33,$00
sphere5:
.byte $5,$5
.byte $00,$b0,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$30
.byte $33,$3b,$3b,$3b,$33
.byte $33,$33,$33,$33,$33
.byte $00,$33,$33,$33,$00
sphere6:
.byte $5,$5
.byte $00,$30,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$30
.byte $bb,$bb,$bb,$3b,$33
.byte $33,$3b,$33,$33,$33
.byte $00,$33,$33,$33,$00
sphere7:
.byte $5,$5
.byte $00,$30,$bb,$b0,$00
.byte $b0,$bb,$bb,$bb,$30
.byte $bb,$bb,$bb,$bb,$33
.byte $bb,$bb,$bb,$3b,$33
.byte $00,$33,$33,$33,$00
.endif
sphere0:
.byte $5,$5
.byte $00,$30,$bb,$b0,$00
.byte $b0,$bb,$bb,$bb,$30
.byte $bb,$bb,$bb,$bb,$33
.byte $bb,$bb,$bb,$3b,$33
.byte $00,$33,$33,$33,$00
sphere1:
.byte $5,$5
.byte $00,$30,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$30
.byte $bb,$bb,$bb,$3b,$33
.byte $33,$3b,$33,$33,$33
.byte $00,$33,$33,$33,$00
sphere2:
.byte $5,$5
.byte $00,$b0,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$30
.byte $33,$3b,$3b,$3b,$33
.byte $33,$33,$33,$33,$33
.byte $00,$33,$33,$33,$00
sphere3:
.byte $5,$5
.byte $00,$b0,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$b0
.byte $33,$33,$3b,$bb,$bb
.byte $33,$33,$33,$33,$3b
.byte $00,$33,$33,$33,$00
sphere4:
.byte $5,$5
.byte $00,$30,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$b0
.byte $33,$3b,$bb,$bb,$bb
.byte $33,$33,$3b,$bb,$bb
.byte $00,$33,$33,$3b,$00
sphere5:
.byte $5,$5
.byte $00,$30,$b3,$b0,$00
.byte $30,$b3,$bb,$bb,$b0
.byte $33,$bb,$bb,$bb,$bb
.byte $33,$bb,$bb,$bb,$bb
.byte $00,$33,$3b,$3b,$00
sphere6:
.byte $5,$5
.byte $00,$30,$bb,$b0,$00
.byte $30,$bb,$bb,$bb,$b0
.byte $bb,$bb,$bb,$bb,$bb
.byte $bb,$bb,$bb,$bb,$bb
.byte $00,$bb,$bb,$bb,$00
sphere7:
.byte $5,$5
.byte $00,$b0,$b3,$b0,$00
.byte $b0,$bb,$bb,$bb,$30
.byte $bb,$bb,$bb,$bb,$33
.byte $bb,$bb,$bb,$bb,$33
.byte $00,$3b,$3b,$3b,$00
sphere_shadow1:
.byte $5,$1
.byte $00,$a0,$a0,$a0,$00
sphere_shadow2:
.byte $5,$1
.byte $00,$00,$a0,$00,$00

View File

@ -7,13 +7,13 @@ B2D = ../bmp2dhr/b2d
all: space_bars.dsk
space_bars.dsk: SPACE_BARS
$(DOS33) -y space_bars.dsk BSAVE -a 0x1000 SPACE_BARS
$(DOS33) -y space_bars.dsk BSAVE -a 0x4000 SPACE_BARS
####
SPACE_BARS: space_bars.o
ld65 -o SPACE_BARS space_bars.o -C ../linker_scripts/apple2_1000.inc
ld65 -o SPACE_BARS space_bars.o -C ../linker_scripts/apple2_4000.inc
space_bars.o: space_bars.s instructions.s game.s \
game_over.s gr_copy.s text_print.s title.s \
@ -37,6 +37,6 @@ SB_BACKGROUNDC.BIN: sb_background.bmp
###
clean:
rm -f *~ *.o *.lst *.inc SPACE_BARS
rm -f *~ *.o *.lst SPACE_BARS

9
space_bars/TODO Normal file
View File

@ -0,0 +1,9 @@
Is it possible to get 40x96 as well as HGR?
Have same HGR background page0/page1
Alternate PAGE0/PAGE1 every two lines... do this in SPLIT?
Is it even possible to draw the lines/sprites fast enough in the
space remaining?
Only draw the top half on odd frames, bottom on even?

View File

@ -9,9 +9,10 @@ game:
;===================
; init vars
lda #0
sta DRAW_PAGE
lda #15
sta XPOS
lda #38
sta YPOS
;=============================
@ -36,44 +37,29 @@ game:
;=============================
; Load graphic page0
lda #8
sta DRAW_PAGE
lda #22
jsr clear_gr
; Load graphic page1 $800
lda #4
sta DRAW_PAGE
jsr gr_copy_to_current ; copy to page1
lda #$22
jsr clear_gr
; GR part
bit PAGE1
bit LORES ; 4
bit SET_GR ; 4
bit FULLGR ; 4
;=============================
; Load graphic page1
; Load graphic page2 $c00
lda #8
sta DRAW_PAGE
lda #44
lda #$44
jsr clear_gr
;===================
; copy to page3
lda #0
sta DRAW_PAGE
jsr gr_copy_to_current
; GR part
bit PAGE0
@ -186,13 +172,28 @@ sb_hgr_loop:
bit SET_GR ; 4
bit HIRES ; 4
; draw sprite at same time
lda #>ship_forward ; 2
sta INH ; 3
lda #<ship_forward ; 2
sta INL ; 3
jsr put_sprite ; 6
; + 2164
;===========
; 2180
; Try X=1 Y=235 cycles=2586 R5
nop ; 2
lda $0 ; 3
; Try X=7 Y=10 cycles=411
; nop ; 2
; lda $0 ; 3
ldy #235 ; 2
sbloopC:ldx #1 ; 2
ldy #10 ; 2
sbloopC:ldx #7 ; 2
sbloopD:dex ; 2
bne sbloopD ; 2nt/3
dey ; 2
@ -202,7 +203,7 @@ sbloopD:dex ; 2
sb_mixed:
nop ;kill 6 cycles (room for rts) ; 2
lda $0 ;kill 6 cycles (room for rts) ; 2
ldx #9 ; 2
ldy #14 ; 126 ; 2
@ -260,13 +261,17 @@ sbloopF:dex ; 2
; do_nothing should be 4550
; -10 keypress
; -1 adjust center mark back
; ===========
; 4540
; 4539
; Try X=9 Y=89 cycles=4540
; Try X=3 Y=216 cycles=4537 R2
ldy #89 ; 2
sbloop1:ldx #9 ; 2
nop
ldy #216 ; 2
sbloop1:ldx #3 ; 2
sbloop2:dex ; 2
bne sbloop2 ; 2nt/3
dey ; 2

137
space_bars/gr_putsprite.s Normal file
View File

@ -0,0 +1,137 @@
;=============================================
; put_sprite
;=============================================
; Sprite to display in INH,INL
; Location is XPOS,YPOS
; Note, only works if YPOS is multiple of two
; time= 28 setup
; Y*outerloop
; outerloop = 34 setup
; X*innerloop
; innerloop = 30 if $00 17+13(done)
; 64 if $0X 16+7+8+20(put_sprite_mask)+13(done)
; 69 if $X0 16+8+7+5+20(put_sprite_mask)+13(done)
; 54 if if $XX 16+8+8+9(put_all)+13(done)
; -1 for last iteration
; 18 (-1 for last)
; 6 return
; so cost = 28 + Y*(34+18)+ (INNER-Y) -1 + 6
; = 33 + Y*(52)+(INNER-Y)
; = 33 + Y*(52)+ [30A + 64B + 69C + 54D]-Y
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 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 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
; check if completely transparent
; if so, skip
cmp #$0 ; if all zero, transparent ; 2
beq put_sprite_done_draw ; don't draw it ; 2nt/3
;==============
; 16/17
sta COLOR ; save color for later ; 3
; check if top pixel transparent
and #$f0 ; check if top nibble zero ; 2
bne put_sprite_bottom ; if not skip ahead ; 2nt/3
;==============
; 7/8
lda #$f0 ; setup mask ; 2
sta MASK ; 3
bmi put_sprite_mask ; always? ; 3
;=============
; 8
put_sprite_bottom:
lda COLOR ; re-load color ; 3
and #$0f ; check if bottom nibble zero ; 2
bne put_sprite_all ; if not, skip ahead ; 2nt/3
;=============
; 7/8
lda #$0f ; 2
sta MASK ; setup mask ; 3
;===========
; 5
put_sprite_mask:
lda (OUTL),Y ; get color at output ; 5
and MASK ; mask off unneeded part ; 3
ora COLOR ; or the color in ; 3
sta (OUTL),Y ; store it back ; 6
jmp put_sprite_done_draw ; we are done ; 3
;===========
; 20
put_sprite_all:
lda COLOR ; load color ; 3
sta (OUTL),Y ; and write it out ; 6
;============
; 9
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 ; 2nt/3
;==============
; 12/13
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 ; 2nt/3
;==============
; 17/18
rts ; return ; 6

View File

@ -0,0 +1,79 @@
;================
; Ship Sprites
;================
splash_forward:
.byte $7,$2
.byte $00,$ee,$00,$00,$00,$ee,$00
.byte $ee,$00,$00,$00,$00,$00,$ee
splash_right:
.byte $7,$2
.byte $00,$00,$00,$00,$00,$ee,$00
.byte $00,$00,$00,$00,$00,$00,$ee
splash_left:
.byte $7,$2
.byte $00,$ee,$00,$00,$00,$00,$00
.byte $ee,$00,$00,$00,$00,$00,$00
shadow_forward:
.byte $3,$2
.byte $00,$aa,$00
.byte $a0,$aa,$a0
shadow_right:
.byte $3,$2
.byte $a0,$00,$aa
.byte $00,$0a,$a0
shadow_left:
.byte $3,$2
.byte $aa,$00,$a0
.byte $a0,$0a,$00
ship_forward:
.byte $9,$5
.byte $00,$00,$00,$00,$ff,$00,$00,$00,$00 ; 00=8 0X=0 X0=0 XX=1
.byte $00,$00,$00,$66,$ff,$66,$00,$00,$00 ; 00=6 0x=0 X0=0 XX=3
.byte $00,$00,$70,$2f,$12,$2f,$70,$00,$00 ; 00=4 0x=0 X0=2 XX=3
.byte $f0,$f7,$f7,$f2,$d9,$f2,$f7,$f7,$f0 ; 00=0 0x=0 X0=2 XX=7
.byte $00,$00,$00,$00,$0d,$00,$00,$00,$00 ; 00=8 0x=1 X0=0 XX=0
;=====================
; 26 1 4 14
; 00=26 0X=1 X0=4 XX=14
; = 33 + Y*(52)+ [30A + 64B + 69C + 54D]-Y
; = 33 + 5*52 + 30*26 + 64*1 + 69*4 + 54*14 - 5
; = 2164
ship_right:
.byte $9,$5
.byte $00,$00,$00,$00,$00,$60,$60,$f0,$00
.byte $00,$f0,$70,$70,$f6,$f6,$6f,$66,$00
.byte $00,$07,$ff,$2f,$12,$27,$f6,$00,$00
.byte $00,$00,$00,$dd,$d9,$f2,$77,$00,$00
.byte $00,$00,$00,$00,$00,$0f,$ff,$70,$00
ship_left:
.byte $9,$5
.byte $00,$f0,$60,$60,$00,$00,$00,$00,$00
.byte $00,$66,$6f,$f6,$f6,$70,$70,$f0,$00
.byte $00,$00,$f6,$27,$12,$2f,$ff,$07,$00
.byte $00,$00,$77,$f2,$d9,$dd,$00,$00,$00
.byte $00,$70,$ff,$0f,$00,$00,$00,$00,$00
ship_small:
.byte $5,$3
.byte $00,$00,$ff,$00,$00
.byte $00,$76,$2f,$76,$00
.byte $0f,$0f,$d9,$0f,$0f
ship_tiny:
.byte $3,$1
.byte $f0,$9f,$f0

View File

@ -17,21 +17,25 @@ LZ4_END = $04
COUNT = $06
DELTA = $08
YPOS = $10
YPOS_SIN = $11
CH = $24
CV = $25
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
MASK = $2E
COLOR = $30
FRAME = $60
BLARGH = $69
DRAW_PAGE = $EE
LASTKEY = $F1
PADDLE_STATUS = $F2
XPOS = $F3
YPOS = $F4
TEMP = $FA
TEMPY = $FB
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF
@ -147,6 +151,7 @@ gr_offsets:
.include "vapor_lock.s"
.include "delay_a.s"
.include "lz4_decode.s"
.include "gr_putsprite.s"
.include "spacebars_title.inc"
.include "mode7_sprites.inc"