Hey there,
today I'll share a little command line tool, probably most useful if your project uses CHR RAM.
It does this:
Personally, I use it for the animation of the main character in Banana Nana, freeing up a substantial amount of space for enemies in the sprite pattern table - while still leaving enough vblank time for animated background tiles.
ROM space does not seem to be much of an issue for homebrews nowadays, so why not!
Another use case: Let's say you have 70 cycles left in vblank...
The tool automatically chooses a lower optimization level in this case, which stays below 70 cycles, but generates smaller code (see subroutines.asm in the zip archive).
Be warned, the output may often not be optimal, but it should be usable at least. I'll see if I can improve the algorithm one of these days.
Let me know if you find any bugs.
ATTENTION: Check out russelsprouts's post below for his tool, which should generate better output!
today I'll share a little command line tool, probably most useful if your project uses CHR RAM.
It does this:
Code:
;data.chr
00 00 00 00 BB BB BC 00
00 00 00 00 BB BB BC 00
Code:
C:\>ppunroll data.chr
ldx #$00
stx $2007 ;00
stx $2007 ;00
stx $2007 ;00
stx $2007 ;00
ldy #$BB
sty $2007 ;BB
sty $2007 ;BB
iny
sty $2007 ;BC
stx $2007 ;00
;-O7
;size:29
;cycles:38
ldx #$00
stx $2007 ;00
stx $2007 ;00
stx $2007 ;00
stx $2007 ;00
ldy #$BB
sty $2007 ;BB
sty $2007 ;BB
iny
sty $2007 ;BC
stx $2007 ;00
;-O7
;size:29
;cycles:38
Personally, I use it for the animation of the main character in Banana Nana, freeing up a substantial amount of space for enemies in the sprite pattern table - while still leaving enough vblank time for animated background tiles.
ROM space does not seem to be much of an issue for homebrews nowadays, so why not!
Another use case: Let's say you have 70 cycles left in vblank...
Code:
C:\>ppunroll -Oc 70 data.chr
ldx #$00
jsr stx4 ;00 00 00 00
ldy #$BB
jsr sty2 ;BB BB
iny
sty $2007 ;BC
stx $2007 ;00
;-O1
;size:17
;cycles:62
ldx #$00
jsr stx4 ;00 00 00 00
ldy #$BB
jsr sty2 ;BB BB
iny
sty $2007 ;BC
stx $2007 ;00
;-O1
;size:17
;cycles:62
The tool automatically chooses a lower optimization level in this case, which stays below 70 cycles, but generates smaller code (see subroutines.asm in the zip archive).
Be warned, the output may often not be optimal, but it should be usable at least. I'll see if I can improve the algorithm one of these days.
Let me know if you find any bugs.
ATTENTION: Check out russelsprouts's post below for his tool, which should generate better output!