News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: slidelljohn (a.k.a.[J]) snes projects page  (Read 25003 times)

slidelljohn

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #20 on: April 01, 2019, 02:30:34 am »
@darkmoon2321
Cool, thanks for uploading your modifications. I’m going to try to start working on some more of the gradius 3 stuff this week or next week. I have been putting most of my free time into much needed snes c++ tools but I get burned out working on the same thing so it’s almost time to work on something other than my c++ projects.

Aaendi

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #21 on: April 02, 2019, 01:42:37 pm »
Here's some more optimizations:

Code: [Select]
arch snes.cpu

macro seek(n) {
origin (({n} & 0x7f0000) >> 1) | ({n} & 0x7fff)
base {n}
}

seek($809d7e)

rep #$30
lda $66
bne ++
ldx #$1200
-;
lda $00,x
beq +
stx $fc
jsl $809da0
ldx $fc
+;
txa
clc
adc #$0010
tax
cpx #$1280
bcc -
+;
rtl


seek($80ed75)
jml collision_a

seek($80ebeb)
jsl collision_b

seek($80ed7e)
jml collision_b

seek($80edd4)
jml collision_c

seek($8df100)
collision_a:
clc
lda $10
adc #$0003
sta $0c
sec
lda $000a,y
sbc $08
bpl +
eor #$ffff
inc
+;
cmp $0c
bcs ++
clc
lda $12
adc #$0003
sta $0e
sec
lda $000e,y
sbc $0a
bpl +
eor #$ffff
inc
+;
cmp $0e
+;
rtl



collision_b:
clc
lda $10
adc $0028,y
sta $0c
sec
lda $000a,y
sbc $08
bpl +
eor #$ffff
inc
+;
cmp $0c
bcs ++
clc
lda $12
adc $002a,y
sta $0e
sec
lda $000e,y
sbc $0a
bpl +
eor #$ffff
inc
+;
cmp $0e
+;
rtl

collision_c:

clc
lda $10
adc #$000b
sta $0c
clc
lda $0028,y
adc $000a,y
sec
sbc #$000b
sec
sbc $08
bpl +
eor #$ffff
inc
+;
cmp $0c
bcc +
jml $80eb57
+;
lda $12
adc #$0003
sta $0e
sec
lda $000e,y
sbc $0a
bpl +
eor #$ffff
inc
+;
cmp $0e
bcc +
jml $80eb57
+;
jml $80eb2f


sprite_processing:
lda $0000,x
-;
lsr
lsr
bcc -
sta $0000,x


inx
inx
cpx #$3e19
bcs +
txa
-;
stz $0000,x
stz $0002,x
stz $0004,x
stz $0006,x
adc #$0008
tax
cpx #$3e1a
bcc -
+;

cpx #$3e20
bcs +
-;
stz $0000,x
inx
inx
cpx #$3e20
bcc -
+;


cpy #$3d64
bcs +

-;
sep #$20
lda #$f0
sta $0001,y
sta $0005,y
sta $0009,y
sta $000d,y
sta $0011,y
sta $0015,y
sta $0019,y
sta $001d,y
rep #$21
tya
adc #$0020
tay
cpy #$3d64
bcc -

+;

cpy #$3d74
bcs +

lda #$00f0
sta $0001,y
sta $0005,y
sta $0009,y
sta $000d,y
tya
adc #$0010
tay

+;


cpy #$3d80
bcs +

sep #$20
lda #$f0
-;
sta $0001,y
iny #4
cpy #$3d80
bcc -
rep #$20

+;
lda $92
ora $66
ora $12f8
sta $18

tya
lsr
and #$003e
tax

-;
lda lut_b,x
cmp $0002,y
beq +
sta $0002,y

lda lut_c,x
sta $0000,y
+;


lda $18
bne big_jump


lda lut_a,x
and $1e
bne +
sep #$20
lda $0000,y
dec
sta $0000,y
rep #$20
+;


big_jump:

inx
inx
iny
iny
iny
iny
cpy #$3e00
bcc -
sep #$20
lda #$01
pha
plb
rep #$20
rtl

lut_a:
dw $000f,$0007,$0007,$0007,$0003,$0003,$0001,$0000,$000f,$0007,$0007,$0007,$0003,$0003,$0001,$0000
dw $000f,$0007,$0007,$0007,$0003,$0003,$0001,$0000,$000f,$0007,$0007,$0007,$0003,$0003,$0001,$0000


lut_b:
dw $08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef
dw $08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef,$08ff,$02ef,$04fe,$02ef


lut_c:
dw $a850,$0858,$4040,$c848,$2070,$9878,$7060,$b468,$6810,$0018,$b800,$5808,$3030,$8838,$6020,$9028
dw $28d0,$d8d8,$48c0,$a0c8,$38f0,$b0f8,$80e0,$48e8,$1890,$9498,$7880,$1088,$50b0,$c0b8,$d0a0,$6ca8




seek($8281f5)

ldy #$1280
phx
tyx
clc
lda $00,x
adc $0a
sta $10

and #$01f8
bit #$0100
beq +
eor #$2100
+;
lsr
lsr

sta $00
clc
lda $18,x
adc $0e
sec
sbc #$0010
and $90
sta $12

and #$01fc
asl
asl
asl
adc #$0800

and #$17e0

bit #$0020
beq +
eor #$0021
+;
ora $00


sta $14
eor #$8000
tax
stx $16
lda $7dffff,x
plx
and #$c000
rtl



seek($829903)
phy
lda $18,x
ldy $1c,x
sty $18,x
sta $1c,x

lda $1a,x
ldy $1e,x
sty $1a,x
sta $1e,x

ply

bra +
+;


seek($829819)
lda $18
clc
adc #$0004
sta $18

seek($8096d5)
-;
ldx $00
ldy $0000,x
inx
inx
stx $00
jsl $808ea0
lda $f6
beq +
sty $f2
+;
stz $02
ldx $00

-;
lda $0000,x
inx
and #$00ff
cmp #$00ff
beq label_0
cmp #$00fe
beq label_1
cmp #$00fd
beq label_2
ldy $f0
beq +
lda #$0000
+;
ora $04
stx $00
jsl $808ed8
ldx $00
lda $f6
beq -
stx $f4
lda $04
sta $f8
inc $f2
lda $0000,x
and #$00ff
cmp #$00ff
bne +
label_0:
stz $f0
stz $f6
+;
stx $00
jml $808ee3


label_2:
lda $0000,x
sta $05
inx
bra -

label_1:
stx $00
jsl $808ee3
bra --


seek($808f6e)
jml sprite_processing

slidelljohn

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #22 on: April 02, 2019, 03:49:30 pm »
The way I do my hacking I’m not able to use your codes. Do you have any patches that I can use to test and compare with the fastrom mod I did and the improvements darkmoon did? I have been trying to get in touch with you. I tried responding to your email and I tried messaging you on here but no reply.

Aaendi

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #23 on: April 02, 2019, 08:26:45 pm »
I'm not home right now so I'll make an IPS file when I get home.


http://www.mediafire.com/file/g1ql7oqmo99qud3/Gradius_III_optimization.ips/file

Quote
Do you have any patches that I can use to test and compare with the fastrom mod I did and the improvements darkmoon did?


Well this patch includes your patch and darkmoon's patch, since I was modifying a rom that already had both of your patches applied.

Edit:

I think it will be easy to optimize code if I take your disassembly and modify it to be reassembleable. That way I don't have to worry about alignment.

« Last Edit: April 03, 2019, 02:17:36 pm by Aaendi »

slidelljohn

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #24 on: April 03, 2019, 06:41:09 pm »
Wow! That’s a nice little speed up! About 3 seconds. I did a timing test and it looks like you nearly removed the rest of the slowdown from that one function(JSL 80/8EF1). I think there is only about a .75 second slowdown left in it but the code has to use up some time so might not be too much more that could be done to optimize that function. I haven’t played through the whole game yet to make sure everything is still working properly but the first demo stage is.

I think I’ve found out something interesting but to be sure I would need you and darkmoon to create your patches without using my fastrom patch. Would you two be willing to do that so I can run some more tests?

There is some minor slowdown coming from this function as well:  80/9F19 // updates graphics for your ship and boss

It’s only about a 2.5 second slowdown compared to the 15 second slowdown for the other sprite function 80/8EF1.
« Last Edit: April 03, 2019, 06:48:28 pm by slidelljohn »

slidelljohn

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #25 on: April 11, 2019, 02:35:31 am »
[quote author=darkmoon2321 link=topic

I didn't know this.  I'll have to take a look and see if I can find out what's happening.  I must have missed something.
Edit: I'm not convinced this is from me.  I just ran both versions up to this boss using an invincibility cheat to test, and both showed some pretty glitchy graphics.  I think there are just too many overlapping sprites trying to be displayed at once.  The way the boss curls around on itself makes it particularly prone to glitchy sprites.  However, I did find a potential bug.  At $80/9166, it should be changed to:

Code: [Select]
LDA $00
STA ($02)
CPY #$3E00
BCS $18

In other words, extended OAM data needs to be saved prior to checking whether there are too many sprites on-screen. Otherwise the extended OAM data (size toggle, X MSB) might not be saved for the last few sprite tiles in the event that there are too many sprites on-screen at once.
[/quote]

There actually was glitchy graphics in the fire stage while fighting the boss but the 4 lines of code you posted fixed it.

@darkmoon2321 and Aaendi
The optimizations that you two have done so far are great! Not sure if you two can optimize anymore of the code but there are still significant slowdowns on the 2nd level with all the big bubbles. The slowdown looks like it’s coming from the function before the sprites function at 00:878E.

I played around a little bit with the assembly and I was able to optimize some of the code but it’s not better than the optimizations that have already been done. I’ll probably look into optimizations at a later time if there are still slowdowns. Right now I’m currently rewriting all of the assembly for gradius 3. Gradius 3 uses a lot of long jumps (JSL’s) instead of using JSR’s and the assembly has a lot of rep 10, rep 20 when it should be rep 30. I’m also finding a lot of spots where they are using too many reps and seps by not organizing the code inside of the functions. So yea I’m doing a complete rewrite. It’s probably going to take several weeks to complete.
Wish me luck :crazy:
Hopefully this will give a minor speed up. I’m not really expecting much of a speed up if any but it is possible to get some speed up. After the assembly rewrite is completed, I’ll complete the fastrom hack, and then I’ll rip out all of the compression and expand the rom. I’ll probably start getting some of the sram features implemented after all of that.


Aaendi

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #26 on: April 13, 2019, 10:20:38 pm »
They also NEVER used the direct page register.

http://www.mediafire.com/file/pipd3v1t4pkillc/Gradius_III_optimization.ips/file

Here is an update.  I think I'm getting close to eliminating slowdown for good.
« Last Edit: April 19, 2019, 01:58:01 pm by Aaendi »

Zimgief

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #27 on: April 20, 2019, 06:07:51 pm »
I tried it (first two stages). The game is so much better, even if the bubbles still slow down (but much more less).

For me, the game had three majors flaws:

- slowdowns

- flickering (especially when the four options are on the same horizontal line as the player) which makes some bullets or enemies invisible

- the ramping of difficulty on the same difficulty level. Proportional to the upgrades I think, or maybe the longer we progress without dying. They abandoned this in later Gradius/Parodius console games, and for a good reason. As someone who doesn't have very good reflexes, having much more bullets, moving a a much faster pace, just because I am playing successfully, makes it difficult for me to finish the game on normal (when I can with the last Snes Parodius game, or Gradius Advance for example).
« Last Edit: April 20, 2019, 06:28:57 pm by Zimgief »

slidelljohn

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #28 on: April 29, 2019, 02:12:56 pm »
@Aaendi
Yea, I also noticed that they didn’t use the direct page register much. They changed the direct page register a few times in the asm in bank $00 but they never change it in bank $02. Definitely noticed less slowdown in your latest patch. I’m still not even close to finishing cleaning up gradius’s asm but I’m making good progress and I’m noticing less slowdown but not a lot.

@Zimgief
All slowdowns will hopefully be removed. Most of the flickering can be removed if you use a super nt or a emulator that supports no sprite per line limit. There is still some flickering left after using that feature but I’m hoping I can remove all of the flickering by increasing the vram size to 128kb. Yes, the difficulty does change. I believe each level has its own difficulty. The difficulty that you choose plus the levels difficulty gets added together to create the difficulty for the level. I could probably put together something that shows you how to change the difficulty for each level if you want.

Zimgief

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #29 on: April 30, 2019, 01:54:46 pm »
Quote
I could probably put together something that shows you how to change the difficulty for each level if you want.
Yes, I would be interested! :)

Aaendi

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #30 on: May 05, 2019, 05:57:01 pm »
I have some bad news.  I completely wrecked the source code for my optimization hack trying to fit code inside what little free ROM I have left, and I can't get it to work at all. :banghead:

I guess I'll have to start over but with a larger ROM this time.

slidelljohn

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #31 on: May 06, 2019, 05:27:52 am »
@Zimgief
I tried looking for the files that had the information but I cant seem to find them right now.
I have them somewhere. Its with the same docs for my fastrom hack that I added 4 new difficulties to.
Whenever I find them I'll let you know.

@Aaendi
That's unfortunate. I hope you didn't loose any valuable information on what you have already done.

Aaendi

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #32 on: May 06, 2019, 10:04:16 am »
I got it to work again.  Expanding the ROM size did help.

slidelljohn

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #33 on: May 08, 2019, 12:12:23 am »
Awesome! Glad the work you did wasn't lost. The extra rom space is definitely going to help.

Well, I just found out someone created a sa-1 hack for gradius 3:
https://www.youtube.com/watch?time_continue=152&v=pmJyQiL9wYg

Its kinda funny that person started working on it after I posted my stuff about gradius 3.
It makes me not want to release anymore docs until I finish my projects first. It took a
long time to write that assembly doc and the sa-1 stuff I did already. How can I write and
release docs if I have to worry about someone 1uping something that I'm currently working on?
I don't know if I should throw my gradius 3 work in the trash or continue with it. I guess
on the bright side we all now have a sa-1 gradius 3.

@Aaendi @darkmoon2321
You both did some good work optimizing the gradius 3 code and maybe it might be best to try
and get your new optimizations inserted into that new sa-1 hack. The sa-1 hack is definitely
going to be faster than the fastrom hack.

niuus

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #34 on: May 08, 2019, 02:07:02 am »
Awesome! Glad the work you did wasn't lost. The extra rom space is definitely going to help.

Well, I just found out someone created a sa-1 hack for gradius 3:
https://www.youtube.com/watch?time_continue=152&v=pmJyQiL9wYg

Its kinda funny that person started working on it after I posted my stuff about gradius 3.
It makes me not want to release anymore docs until I finish my projects first. It took a
long time to write that assembly doc and the sa-1 stuff I did already. How can I write and
release docs if I have to worry about someone 1uping something that I'm currently working on?
I don't know if I should throw my gradius 3 work in the trash or continue with it. I guess
on the bright side we all now have a sa-1 gradius 3.

@Aaendi @darkmoon2321
You both did some good work optimizing the gradius 3 code and maybe it might be best to try
and get your new optimizations inserted into that new sa-1 hack. The sa-1 hack is definitely
going to be faster than the fastrom hack.
Please don't abandon your work. An SA-1 hack sounds nice, but it would increase the power requirements for playing on low powered devices at full speed, doesn't play nice on SNES Classic canoe emulator, it's unusable on flash carts not compatible with special chips, etc.

I'd rather have a plain Gradius III optimized, than a special chip assisted game (that didn't required it on the first place) any day.
« Last Edit: May 08, 2019, 02:22:56 am by niuus »

Zimgief

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #35 on: May 08, 2019, 08:09:42 am »
Moreover, the guy insists, on his twitter, that the game is "impossblu", because it is running so fast with this method.
Even "I just found out that with SA-1 the game runs so fast that it's impossible right now to unlock arcade mode because in options the game expects you to alternatively press the A button at 120 Hz which is impossible on hardware. Used to be 60 Hz alternate presses, which is viable".

So, as you can guess considering my latest comments, I am absolutely not a fan of. :p I would expect a game running at same speed but without slowdowns, faithful to the original difficulty.
You and Aaendi have done an impressive work. I hope you will continue, if you find it still meaningful.

Samus12345

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #36 on: May 08, 2019, 10:47:52 am »
Please don't abandon your work. An SA-1 hack sounds nice, but it would increase the power requirements for playing on low powered devices at full speed, doesn't play nice on SNES Classic canoe emulator, it's unusable on flash carts not compatible with special chips, etc.

I second this. There is still a place for a non-SA-1 speedup hack.

snesfanboi

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #37 on: May 08, 2019, 12:27:00 pm »
Hi, I just tried your fastrom patch for gradius III and the difference is incredible.

Like the above post, please continue your work if have the time and motivation!
 
The Sa-1 patch just speeds the game up far too much, whereas your one just reduces the slowdown in bad spots. It still plays like the original.

Great work once again, and it's a shame Konami didn't release this game later as they fixed most of the slowdown issues in Parodius da!.


slidelljohn

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #38 on: May 08, 2019, 03:28:36 pm »
Unfortunately I'm probably not going to be doing much more gradius 3 stuff.
I mainly starting playing around with gradius 3 so I could learn how to make
a snes game use the sa-1 chip. Vitor Vilela's sa-1 work is really amazing and
hats off to him for everything he has done. sa-1 is the future of snes rom
hacking. I think anyone that was interested in the gradius 3 fastrom hack should
be more interested in Vitor Vilela's gradius 3 sa-1 hack. The sa-1 hack may not
be perfect now due to no slowdowns but the gameplay could be modified to make it
right just like how Vitor Vilela modified the unlock arcade mode button presses.
I'm going to continue learning the sa-1 so I could one day add to the list of
sa-1 hacks. Hopefully Vitor saves mmx for me to do. :laugh:

Samus12345

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: slidelljohn (a.k.a.[J]) snes projects page
« Reply #39 on: May 08, 2019, 10:31:32 pm »
Unfortunately I'm probably not going to be doing much more gradius 3 stuff.

That's a shame. :( The SA-1 version is no good to me since I use Canoe on my SNES Classic and it doesn't load the graphics properly. Is there any chance you could upload the most recent version you've done, at least? I'm still using the first version you uploaded.

Thanks for your hard work, everyone who's worked on the fastrom patch!