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

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

slidelljohn

  • Full Member
  • ***
  • Posts: 197
    • 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: 9
    • 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

  • Full Member
  • ***
  • Posts: 197
    • 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: 9
    • 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

  • Full Member
  • ***
  • Posts: 197
    • 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

  • Full Member
  • ***
  • Posts: 197
    • 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: 9
    • 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: 49
    • 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 »