By the way, mostly look at the metasprite and object files. The rest are from walker and are pretty much fine.
Anyway, here's the file: (Sorry about this.
Moderator: Moderators
Yeah, that fixed everything.Khaz wrote:Very quick appraisal: You say you're using direct page, but in your vBlank you don't "PHD" to preserve the direct page register.
I know, I just want to try to make it faster before I make the transition to fastrom. I don't want to get too comfy with fastrom, so I'm using slowrom until I've optimized everything as good as it can be.psycopathicteen wrote:It's running from the $00 bank, which is always slowROM speed. It needs to run from bank $80 or higher to run at fastROM speed.
Code: Select all
.proc start_metasprite
phx
phy
rep #$30 ; A=16, X/Y=16
ldy a:SpriteCount
ldx a:MetaspriteTableOffset
lda a:MetaspriteCount
cmp #$0001
bne horizontal_flip_check
brl single_metasprite
horizontal_flip_check:
stz a:HFlipMask
lda Attributes
bit #$4000
beq vertical_flip_check
lda #$FFFF
sta a:HFlipMask
vertical_flip_check:
stz a:VFlipMask
lda Attributes
bit #$8000
beq metasprite_loop
lda #$FFFF
sta a:VFlipMask
metasprite_loop:
cpy #$0200 ; sees if all 128 sprites are used up
beq done
and #$00FF
sta a:SpriteBuf1+1,y ; Store sprite Y position in SpriteBuf1+1,y
lda a:MetaspriteCount ; If MetaspriteCount is zero, then we're done. Otherwise we have
beq done ; metasprites to iterate over and populate for DMA (see VBlank)
lda a:Empty,x ; 1st byte = sprite X position (value 0-255)
eor a:HFlipMask
clc
adc XPosition
cmp #256
bcc sprite_x_not_out_of_bounds
cmp #65504
bcs sprite_x_not_out_of_bounds
bra sprite_out_of_bounds
sprite_x_not_out_of_bounds:
and #$01FF
sta a:SpriteBuf3,y ; Store sprite X position SpriteBuf1+y
and #$00FF
sta a:SpriteBuf1,y ; Store sprite X position SpriteBuf1+y
lda a:Empty+2,x ; 1st byte = sprite X position (value 0-255)
eor a:VFlipMask
clc
adc YPosition
cmp #224
bcc sprite_y_not_out_of_bounds
cmp #65504
bcs sprite_y_not_out_of_bounds
bra sprite_out_of_bounds
sprite_y_not_out_of_bounds:
sta a:SpriteBuf1+1,y
lda a:Empty+4,x
sta a:SpriteBuf3+2,y ; Sprite size
lda a:Empty+6,x
eor Attributes
sta a:SpriteBuf1+2,y ; Palette/Character word
iny
iny
iny
iny
sprite_out_of_bounds:
txa
clc
adc #$0008
tax
dec a:MetaspriteCount ; Decrement MetaspriteCount by 1
bra metasprite_loop ; Back to the loop...
done:
sty a:SpriteCount ; Says how many sprites have been made
single_done:
ply
plx
rts
single_metasprite:
cpy #$0200 ; sees if all 128 sprites are used up
beq single_done
and #$00FF
sta a:SpriteBuf1+1,y ; Store sprite Y position in SpriteBuf1+1,y
lda a:Empty,x ; 1st byte = sprite X position (value 0-255)
clc
adc XPosition
cmp #256
bcc single_sprite_x_not_out_of_bounds
cmp #65504
bcs single_sprite_x_not_out_of_bounds
bra single_sprite_out_of_bounds
single_sprite_x_not_out_of_bounds:
and #$01FF
sta a:SpriteBuf3,y ; Store sprite X position SpriteBuf1+y
and #$00FF
sta a:SpriteBuf1,y ; Store sprite X position SpriteBuf1+y
lda a:Empty+2,x ; 1st byte = sprite X position (value 0-255)
clc
adc YPosition
cmp #224
bcc single_sprite_y_not_out_of_bounds
cmp #65504
bcs single_sprite_y_not_out_of_bounds
bra single_sprite_out_of_bounds
single_sprite_y_not_out_of_bounds:
sta a:SpriteBuf1+1,y
lda a:Empty+4,x
sta a:SpriteBuf3+2,y ; Sprite size
lda a:Empty+6,x
eor Attributes
sta a:SpriteBuf1+2,y ; Palette/Character word
lda a:SpriteCount ; Says how many sprites have been made
clc
adc #$0004
sta a:SpriteCount ; Says how many sprites have been made
single_sprite_out_of_bounds:
ply
plx
rts
.endprocCode: Select all
.segment "BSS"This is a table in ram though, so it shouldn't have anything to do with rom space or whatever.Khaz wrote:I am assuming that your assembler is taking each "segment" and storing it in the first free space it finds in one of the banks of $8000 in your ROM. If you make a segment bigger than $8000 it can't fit in a bank and I'm guessing that's your problem.
The table is coming FROM rom, though. Either it has to fit inside a single bank, or you have to work around splitting your data across multiple banks.Espozo wrote:This is a table in ram though, so it shouldn't have anything to do with rom space or whatever.