Romhacking.net

Romhacking => ROM Hacking Discussion => Topic started by: Jiggers on January 04, 2019, 05:36:47 am

Title: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 04, 2019, 05:36:47 am
Hi! This is a project I've been working on for... I think 2 years now? It upgrades Final Fantasy 1 to use the MMC5 mapper... then goes crazy with what I hope are improvements to the game. It's based of Disch's FF1 Disassembly. He did a bunch of things to help get me started with it. I've done my best to credit a few other people as well.

https://github.com/JiggeryPonkery/FF1-MMC5 - Here is the newest versions maybe.

Everything below this line is kinda old and not updated.



Here is a zip file with the entire project.
https://drive.google.com/open?id=1G699Vc47Qr5he4zcBEi2JPTdc0a9h14n

Updated 15/01/2019

(I don't know what other emulators will work besides Mesen by the way...)

This is far from finished, but I've hit a wall and need help again. Before I get into that... I should apologize for how long this is. Wow. Sorry!

General Changes

Battle Changes

Audio Changes

ASM Changes

Changes I'd Like To Make

Known Bugs

Maybe Bugs

Why?
I've had a lot of fun tinkering with ASM doing this project. FF1 is a simple, classic game that's surprisingly easy to tweak and full of incomprehensible coding choices that make it frustrating to impliment those fun tweaks. Originally I was going to use FF1 as a base for a whole other RPG world--but, you know, fitting a whole cat person sprite into 16x16 pixels is hard when you have no idea what you're doing.

So I abandoned my original goal and focused on doing little quality of life upgrades. I see a lot of people wanting to get into hacking by doing pure hex editing or using FFHackster, and I want to provide an alternative, to give people a deeper understanding of how the game really works. The switch to MMC5 allows for experimentation that simply wasn't possible in the crammed MMC3 format. I want other people to experience this! My code can be as hopelessly messy as it takes to get my ideas down before I have the skills to trim it down and speed it up. Your code can be that, too! Using this project as a base for your own ideas, you too can learn Assembly and put together all those "wouldn't it be nice if FF1 had..." ideas!


And again... many thanks to Disch, Gil Galad, Lenophis, anomie, and everyone else whose helped out by trailblazing this silly game's code and data jungles and providing little (and huge) improvements!
Title: Re: FF1 MMC5 Updates
Post by: Bregalad on January 04, 2019, 05:47:40 am
Nice ! At first I tought this would be yet another shitty uninteresting mapper hack, but no you really planned to use the MMC5 so this is great. Perhaps a better name than "FF1 MMC5" would make up for the concept a little bit better. Keep up the good work !!

EDIT: Also please PLEASE use a patch, not a ROM ! This is very important !
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 04, 2019, 03:49:34 pm
WHOOPS. Forgot about that. Deleted the rom from the zip file now. Thanks for the reminder!

I'm not good with names. But since it is an "upgrade" from Disch's disassembly, I guess throwing that word in there would help? Its not really meant to be a patch, just the source code and the tools needed to piece it together. Is that still legal...?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on January 04, 2019, 04:49:08 pm
This is a fantastic way to make alot of improvements even better. I'm looking forward on this one despite the fact that this is for beta (I believe, if its unfinished). So does the ATB. That is WAY better of what it should've been for all future FF games. Im saying this, because im a fan of FF. So, this massive improvement does very well done.  :thumbsup:
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Orochi Kusanagi on January 04, 2019, 05:15:36 pm
This is some amazing work!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: A.D.R.I.A.N on January 04, 2019, 08:39:34 pm
Guess my idea of a gil-stealing Thief finally became reality. Truly, well done!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 06, 2019, 12:36:10 am
Aw, thanks!

I did some more work on the hiding stuff. As far as I can tell, all hiding bugs are FIXED! The stat boosts are now in effect. I mean, I think they are. I haven't actually super tested it yet...

I tracked down the "everyone uses character 4's items" bug to this area:

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  BattleDrawLoadSubSrcPtr  [$FC00 :: 0x3FC10]
;;
;;  input:       XA = 16-bit pointer to the start of a pointer table
;;
;;  output:  btldraw_subsrc
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

BattleDrawLoadSubSrcPtr:
    STA $97             ; high byte of pointer table
   
    JSR DrawBattle_IncSrcPtr
    LDA ($90), Y        ; get the desired index
   
    ASL A               ; multiply by 2 (2 bytes per pointer)
    PHP                 ; backup the carry
    STA $96             ; use as low byte
   
    TXA                 ; get X (low byte of pointer table)
    CLC
    ADC $96             ; add with low byte of index
    STA $96             ; use as final low byte
   
    LDA #$00            ; add the carry from the X addition
    ADC $97
    PLP                 ; also add the carry from the above *2
    ADC #$00
    STA $97             ; use as final high byte
   
    LDY #$00            ; get the pointer, store in btldraw_subsrc
    LDA ($96), Y
    STA btldraw_subsrc
    INY
    LDA ($96), Y
    STA btldraw_subsrc+1
   
    RTS

I'll need to go over this a bunch more to see just what's causing it, but once it gets out of here it starts drawing up the text for the "Small @Knife" my black mage has...

I also got distracted and made magic sprites move towards enemies! So that was a fun 5 minutes where nothing went wrong.

There was a bug I forgot about where you could choose a blank spot under Hide and Flee and crash the game. That's been fixed.

For testing purposes, the random roll when doing a critical hit to see if you do the special attack has been removed--every time you do a critical hit, it should do the special attack. If it doesn't, then something's broken. Note that fighters are OP and have no special attacks (unless you go enable the Cleric thing in Bank Z, which should let them mow down undead and were creatures...)

Um... at the moment stealing gold crashes the game. I'm sure it has to do with undrawing battle blocks. I only changed a $02 to a $03...? I'll try to fix it tomorrow. This now works. All special attack messaging should draw properly!

I also fixed up the battle message and enemy name LUTs to be editable. Was going to expand the level up data for 12 classes, but there's not enough room in Bank B for that. Will look into moving that data safely to another bank.

.zip file in main post is updated with changes!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on January 07, 2019, 05:52:49 am
This is pretty awesome.
It could be a very good basis for a more complete battle system overhaul to bring it up to par with FF3.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 09, 2019, 03:24:15 am
Updated the Enemy Regeneration routine and Player poison routine! Players take 1/8 max HP in damage from poison, making it actually scary in battle. 8 turns to cure it or dead!

Enemies... Enemies do this. I am not sure if it works, but if it does, I think it should regenerate a little under 1/10th their max HP per turn. So... WarMech real scary. Anything much lower than that and common enemies are push-overs. (It's still better than 2 HP per turn.)

Code: [Select]
LDY #ENROMSTAT_HPMAX
    LDA (@rom), Y
    STA math_basedamage
    STA btl_mathbuf+2
    INY
    LDA (@rom), Y
    STA math_basedamage+1
    STA btl_mathbuf+3
   
    LSR math_basedamage+1   ; divide by 2
    ROR math_basedamage
    LSR math_basedamage+1   ; divide by 2
    ROR math_basedamage
   
    LDA math_basedamage
    STA tmp
    LDA math_basedamage+1
    STA tmp+1               ; tmp is now 25% max HP
   
    LSR math_basedamage+1   ; divide by 2 again
    ROR math_basedamage     ; math_basedamage is now 12.5% max HP
       
    LDA math_basedamage+1   
    CLC
    ADC tmp+1
    STA math_basedamage+1
    LDA math_basedamage
    CLC
    ADC tmp                 ; math_basedamage is now 37.5% max HP?
    STA math_basedamage
   
    LSR math_basedamage+1   ; divide by 2 again
    ROR math_basedamage     ; math_basedamage is now
    LSR math_basedamage+1   ; divide by 2 again
    ROR math_basedamage     ; math_basedamage is now 9.??% ? 

Both poison and regeneration will now message between turns.

I also fixed a bug where poison would be displayed by the stone icon out of battle, because for some reason they thought it best to shift poison from $04 to $03??? Rather than worry about why they did that, I just added a few more bytes to my code that draws the proper icon.

Currently working on buying more than 1 item at a time.

Question: Using the MMC5's multiplication registers, how would you multiply a 24-bit number by an 8-bit number? I'm completely stumped. I would prefer it if it could do it on the fly, so to say. I have room for a stupidly large LUT, so that's an option, but people would have to change the LUT if they change an item price... And you can't buy more than 21 houses without going over the 16-bit limit for how the game handles buying. Hell the price for 99 houses won't even display correctly in the main menu...

I guess since no item is over 16-bits to start with, I only have to multiply so that the result FILLS 3 bytes... Still no idea how to do that.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Bregalad on January 09, 2019, 08:26:29 am
Question: Using the MMC5's multiplication registers, how would you multiply a 24-bit number by an 8-bit number? I'm completely stumped. I would prefer it if it could do it on the fly, so to say.
You do it like you multiply a 3-digit number by a single-digit number in real life. This requires 3 multiplications and 3 additions.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 09, 2019, 10:58:33 pm
I need a bit more help. I spent all day on this. I just don't understand the logic... What am I missing?

Code: [Select]
BuyLotsPrice:
    LDA #0
    STA MMC5_tmp+6 ; clear this first
    LDA shop_curitem
    JSR LoadPrice ; gets the price of the item you're trying to buy
    ; tmp, tmp+1, and tmp+2 now carry the price...
    ; MMC5_tmp carries the amount
    ; when using MultiplyXA
    ; A = lower 8 bits (automatically saved to MMC5_multiplyA)
    ; X = higher 8 bits (automatically saved to MMC5_multiplyX)
    LDX MMC5_tmp        ; quantity
    LDA tmp             ; low byte of price
    JSR MultiplyXA
    STA MMC5_tmp+2      ; low byte of combined price
    STX MMC5_tmp+3
   
    LDX MMC5_tmp        ; quantity
    LDA tmp+1           ; middle byte of price
    JSR MultiplyXA
    STA MMC5_tmp+4      ; middle byte of combined price
    STX MMC5_tmp+5
   
    LDA MMC5_tmp+4       
    CLC
    ADC MMC5_tmp+3
    STA MMC5_tmp+4
   
    LDA MMC5_tmp+5
    ;CLC                ; do I need this?
    ADC MMC5_tmp+4
    STA MMC5_tmp+5
   
    LDA MMC5_tmp+6      ; saving carry from last addition
    ADC #0
    STA MMC5_tmp+6
   
    RTS

Code: [Select]
            high mid  low
99 x 3000 = $04, $88, $28
98 x 3000 = $04, $7C, $70
^ my tests...

https://imgur.com/a/RUS2lad - I arranged the things so I can see what's going on with the numbers in memory. Should I be using the high bits of the second multiply for the high byte of the combined price? That would work to make those two tests work, but then at 93 houses, it comes to: $04, $41, $D8 -- except then the high bits from the last multiply are $03...

I just really confused... I'm not a math person. I don't know the steps. I lucked into getting this close by trying stupid things until it got close with a few difficult patterns.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on January 09, 2019, 11:48:04 pm
Rather than debug your code I just wrote my own routine to do it.  I commented and drew a little diagram to show how it works so hopefully you can follow what it's doing.  Note it is completely untested:

Code: [Select]
; SUPPORT ROUTINE
; This routine may or may not be necessary depending on how MultiplyXA works.
;   The important bit here is that C needs to be
;   unchanged by the call.  The PHP/PLP here assure that.  If MultiplyXA preseves
;   C then this routine is not needed and MultiplyXA can be called directly
MultiplyXA_Safe:
    PHP
    JSR MultiplyXA
    PLP
    RTS
   
; The actual multiplication routine
;
;   Goal:  $AABBCC * $EE   (24 bit value * 8 bit value)
;   Visualization:
;
;       AA BB CC
; x           EE
; --------------
;          BD A8   (EE * CC = BDA8)
;       AD DA ..   (EE * BB = ADDA)     (dots are effectively zeros)
; +  9E 0C .. ..   (EE * AA = 9E0C)     (note that all addition must include carry)
; --------------
;    9E BA 97 A8   <-  End result, $AABBCC * $EE = $9EBA97A8

Multiply_24x8:
    @in_24  =   ; low byte of 24-bit value (assume +1 and +2 are med/high bytes)
    @in_8   =   ; low byte of 8-bit value
    @out_32 =   ; output (32-bit value)
    @temp   =   ; some area of temp ram (only 1 byte needed for this code)
   
    CLC                     ; start with C clear
   
    ; low byte (EE * CC)
    LDA @in_8
    LDX @in_24
    JSR MultiplyXA_Safe
    STA @out_32             ; no addition needed for low byte
    STX @temp               ; addition needed for high byte, stuff it for later
   
    ; middle byte (EE * BB)
    LDA @in_8
    LDX @in_24+1
    JSR MultiplyXA_Safe
    ADC $temp               ; add with previous high byte
    STA $out_32+1
    STX $temp               ; for future addition
   
    ; high byte (EE * AA)
    LDA @in_8
    LDX @in_24+2
    JSR MultiplyXA_Safe
    ADC @temp
    STA @out_32+2
   
    ; high byte currently in X.  It does not need full addition, but we do need to add to it
    ;  any carry from the previous addition
    BCC :+
       INX
    :
    STX @out_32+3
   
    ; Done!
    RTS



EDIT:

I should also mention I'm assuming MultiplyXA outputs high byte in X and low byte in A -- since that's the most logical/useful way for that function to work.

EDIT 2:

Typo in code, had a STA instead of a STX
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 10, 2019, 11:16:21 pm
Oooohh my gosh. It works. Thank you. I still don't get HOW it works... but it does! I actually thought I could trim it down a bit, because the base item price is only ever going to be 2 bytes--so, 2 bytes into 3 bytes. But it only works with all 4 bytes? THEN I thought I could save space by having it output to tmp AND shop_curprice, but somehow doing two STAs in a row was corrupting the second one. So just had to do LDA tmp, STA shop_curprice for all the parts...

I'm close to updating the main file again with all this stuff. Its looking really good. But then I had a thought: I can trim down the hiding code even MORE if I don't have to deal with the IB/OB stats being loaded different during magical and physical attacks.

Code: [Select]
  @Hide:
  LDA CurrentCharacter ; ($00, $01, $02, $03)
  JSR PrepHide
  LDA #01           ; toggle hiding byte
  STA (tmp+12), Y   ; trouble spot
  RTS 
 
PrepHide:
    ASL A
    TAX
    LDA HideTable, X         
    STA tmp+12           ; these two bytes of tmp are either not used in battle
    LDA HideTable+1, X
    STA tmp+13           ; or not used during a player's turn. So they should be safe to tamper with?
    RTS   
   
HideTable:
  .WORD Character1Hidden ; $5D1F
  .WORD Character2Hidden ; $5D3F
  .WORD Character3Hidden ; $5D5F
  .WORD Character4Hidden ; $5D7F

So I'm debugging this and its working fine. PrepHide loads tmp+12 and tmp+13 with $5D and $xF. But that "STA (tmp+12), Y"... its saving a little bit past there. Screenshot to explain better... Red box: where its saving to. Blue box: Where it should be saving to.

https://imgur.com/a/Dkxeeua

I'll keep fiddling with it...

Edit: I got it. I forgot to set Y.  :P Like a total idiot.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on January 11, 2019, 12:01:47 am
I still don't get HOW it works

The code?  Or the mathematical concept?

The mathematical concept is the same as what is used in standard multiplication:

123 * 5 = (100 * 5) + (20 * 5) + (3 * 5)


Which can be determined with some basic algebra:

Code: [Select]
123 * 5                   (original)
(100 + 20 + 3) * 5        (separate digits)
5*100 + 5*20 + 5*3        (distribute the 5)


I'm effectively doing the exact same thing, only rather that separating digits, I'm separating bytes:

Code: [Select]
$112233 * $44                      (original)
($110000 + $2200 + $33) * $44      (separate bytes)
$44*$110000 + $44*$2200 + $44*$33  (distribute)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 12, 2019, 05:27:27 am
The math concept, I think, is where I get lost. I'd need step by step, line diagram drawings showing every single change, with an explanation of why and how. Probably with Elmo and Big Bird. I had someone try explaining how to multiply without a calculator and after a while I just went "But that CAN'T work with a NES! The numbers aren't connected at all! 256 times 2 doesn't make 512, it makes 256+256!"

After staring a bit, I think I can sense how it works. The distribute line makes the most sense. That's how I handled math in school. Break larger numbers down into easier ones, then re-build the final number. Kind of what I was trying to do--which was correct except for where to add in the high bits?

Anyway, just glad that's all over! Time for another update!



* Added sequence data to restore default Duty settings to all original songs, since my new Marsh Cave song changes it but there was nothing to change it back for other songs.
* Battle and Prologue music's Square 2 channel is now played by the MMC5's SQ2 channel so its not interrupted by SFX.
* Re-wrote Hiding code to be even more space-efficient!
* Wrote some un-space-efficient code to allow buying 1-99 items in Item shops only.
* Re-organized Character Stat data storage. Now have 24 continuous free bytes for each character.
* Re-organized my new MMC5 variables to share space where possible.
* Did a few more spots of data cleanup. Enemy stats now ready for direct editing thanks to the FFbytes docs by Dienyddiwr Da - http://www.romhacking.net/documents/81/

To-Do:
* Figure out how ChaosDeath erases the battle background, because the background is now smaller and it will erase the boxes...?
* Go through the zero-page RAM wossits to find any unused spots and see if I can shift things around to put more audio channel stuff there instead of in MMC5 RAM. Might not be worth the effort.
* Use 24 leftover ch_stat bytes to index spells. 3 spells, 8 levels, 24 bytes!
* Combine ch_class and ch_sprite into high/low bytes. 1 more byte to use.
* ch_exptonext probably doesn't have to be saved. If it can be calculated and saved, it can be calculated and printed each time the status screen is looked at. 2 more bytes saved.
* ch_hidden doesn't need to be in the 64 bytes per character. 4 bytes saved in total!
* Character level can be used to index max MP. Current MP can be squeezed into 4 bytes possibly. First byte high: level 1. First byte low: level 2, and so on.
* This would free up 256 bytes for more game_flags (chests, npcs, events?). Possibly makes room to save more than 1 game at a time??



Question: Is it normal for an MMC5 rom's save file to be 64kb (using Mesen)? First $400 bytes is the "unsram" stuff, which I figured was UNSaved RAM. Second $400 bytes is a copy; the saved RAM. Then $1200 bytes of other stuff (I see its map data) and then like $8000 of 0s. So uh. Do I even need to be making space to make more save game slots??

Even the original game's save file is 8kb...

I suppose I could make a "Save and quit" feature that over-writes the map data, and be more vigilant about the original variables while moving them over to the work RAM in $5C00--freeing up another $400 for save data. Makes 2 save games and a third save file that gets clobbered on load and clobbers map data when saving and shutting down...?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on January 12, 2019, 02:32:34 pm
Even the original game's save file is 8kb

There's a single RAM chip and the entire thing gets saved.  So the whole 8K chunk is saved -- but the game doesn't actually USE all of it for saved data.  Most of it is just used for additional workspace RAM and doesn't NEED to be saved, even though it still is.

Quote
Is it normal for an MMC5 rom's save file to be 64kb (using Mesen)?

Yes, that's normal.  Determining how much SRAM an MMC5 game has is difficult/unreliable, so the easiest way for an emu is to assume it's just using the most possible (which for the MMC5 is 64K) and just save all of it.

Realistically, I think the typical setup is to only have one of the SRAM chips battery backed, so it would probably make more sense to only save 32K --- but saving 64K is easier and safer for the emulator.  If you're worried about which SRAM would actually get saved on a real cartridge, that's a slightly trickier question that I don't immediately have the answer to.  I *think* it's the 2nd chip (so the second block of 32K, not the first) that has the battery on most carts.  But don't quote me on that.

Quote
Do I even need to be making space to make more save game slots??

Probably.  Whatever RAM you're using for save data can't be used by anything else in the game ever -- it has to exclusively hold the save data (unless you want the save data to get clobbered for some reason).  And FF uses most of the RAM for things like map data and whatnot.

Quote
I suppose I could make a "Save and quit" feature that over-writes the map data,

If you do that, the save data will be clobbered as soon as you resume the game and map data overwrites your save game.  I wouldn't recommend it.  And what happens when someone tries to resume a game that wasn't saved this way, and you just end up "resuming" a trash game that gets built out of arbitrary map data that happened to be in memory at the time?

Quote
moving them over to the work RAM in $5C00

It'd probably be a lot easier to just swap to a different RAM page and put your saved games there.  Remember, even without ExRAM MMC5 gives you a full 64K to work with.  You just have to swap to it.

Quote
a third save file that gets clobbered on load and clobbers map data when saving and shutting down...?

You can try that if you want, but personally I don't think that's a very good idea.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 12, 2019, 04:30:40 pm
It'd probably be a lot easier to just swap to a different RAM page and put your saved games there.  Remember, even without ExRAM MMC5 gives you a full 64K to work with.  You just have to swap to it.

O...oh. Well... I think I'll just do that, then.

Was a nice thought experiment to cram magic and MP into 28 bytes anyway though. XD
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Bregalad on January 12, 2019, 04:54:21 pm
The math concept, I think, is where I get lost.
Did you learn how to do multiplications by hand in columns back you when at primary scool ? I learnt that but I don't know if it's still taught to kids... hopefully it is. When multiplying two numbers on the 6502 which lacks a multiply instruction, it's exactly the same technique, except you use "1" and "0" digits instead of the regular "0-9" digits (this makes single-bit multiplication extremely simple as it becomes a simple AND operation), and use binary addition instread of regular addition.

When you're lucky enough to have a MMC5 that can do a 8x8->16 multiply in a couple of cycles you do it using bytes istead of "0-9" digits, still the same technique. Inidivual digits (that is, bytes) within the large numbers have to be multiplied each with eachother, and then shifted and added using the good old primary scool technique.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 15, 2019, 02:08:06 am
Well, uh... I was only really in school for a few months. We were given a math book a grade above ours and given calculators. Most of it was about shapes and doing weird puzzle things like... "8(12+4)(17-12)" and so on... just really long strings of those, is what I remember. So I never had to do multiplication or division the hard way. Trying to get my GED someday is going to suck probably. Eh.

Only a small update today...

Added in a new way to calculate who goes first in battle. Takes the player's luck stat, adds it with a random number between 1 and 50; takes the enemy's morale, divides it twice, adds it with a number between 1 and 50. If there are two identical numbers, it favours the second in line from the initial LUT of enemies 1-9, players 1-4. Not sure yet if it this is going to be fair later on. Or if its fair now.

Fixed a minor bug I caused that was turning everyone's weapons into their own palettes. It was only supposed to do that for fists! Then I thought all unarmed attacks should have fists. Then I changed my mind.

I figured out how to swap RAM, but I have to do more poking to see how to swap things over. I had it swap before a battle transition and it basically put me in battle with everyone's stats being 0s. All fighters, no names, no health... hah.


Some new bugs popped up now... White Mage's critical strength boost mucks up their sprite. Casting magic on someone puts them IN hiding now... fun things.
Fixed those, but Garland gives 1 point of experience with EXP Gain on HIGH? Fixed that, too. Guess ya gotta start with the low byte when multiplying with ASL and ROL.

Also made yet another thief boost: they will now try to hide during their turn when the party is surprised. Too much? Is it enough that the critical hit chance of weapons is fixed, that they can earn gold when doing a critical hit, and that their stats are boosted while attacking from hiding? I guess I can stop un-nerfing them now?  :P

Question: How show INT work? I know Anomie did something, but then FF Restored did it a different way... which do people prefer? Keeping in mind I have no idea how to copy their work exactly...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on January 15, 2019, 08:18:43 pm
Short of actually adding a Steal command, I think the Thief is good without the auto-hide on surprise attacks. Maybe, if you could have them try to auto-hide when they are critical it might work better as a final un-nerf.

I think the INT patch by Anomie and the one used in FF Restored is like pretty much the same, no? Or at least very similar. Either one is fine.

As for the turn order, I think what would make sense is if it was mainly based on the AGI stat. With the LCK stat adding to the random number. This would make predicting turn order for your party more reliable.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 17, 2019, 04:36:54 pm
I was thinking Agility, then looked up how much Agility each class actually earns per level, and the Fighter earns more than the Thief...

In 49 level-ups, each class earns:
Fighter: 35 agility, 24 luck
Thief: 32 agility, 49 luck
BlackBelt: 25 agility, 30 luck
RedMage: 17 agility, 25 luck
WhiteMage: 18 agility, 20 luck
BlackMage: 13 agility, 14 luck

So it really does feel like a speed stat more than agility. Thief is fast, BB second fastest, Red Mage a teensy bit faster but limited to lighter swords...

But the point of my project is that anyone who wants to change stuff can do so easier! If you want agility instead of luck, that's changing one line. If you want to fiddle with the level up data, its organized so you just have to change a few 1s and 0s.

But you're right about the hide thing, I disabled that for now. Code's still in there if people want to enable it, though. I just wrote the hiding-when-critical code, but its also disabled until I have time to test it.

Working out the kinks for 3 save slots now. Looootta bugs going on due to the RAM switching. Loading and saving screens are working though, except for displaying which sprites each save game is using. It's a monsterous mess...

January 17, 2019, 11:51:13 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
I did it. I don't really know how I did it, but I did it. It's super messy... but... I DID IT.

There are now 3 save slots. Saving on the overworld works. Saving in inns works. You can load from the title screen. You can cancel saving and cancel loading and everything should be fine.

The MMC5's exRAM ($5C00) is now the base game data, where the current game draws from. That way its not wiped out when swapping RAM.

But please stress test the heck out of it!

https://drive.google.com/open?id=1G699Vc47Qr5he4zcBEi2JPTdc0a9h14n
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Orochi Kusanagi on January 18, 2019, 01:46:02 am
Wow, the amount of changes done on this has been nothing short of astounding. I love that these classics still get so much love from the fans.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on January 18, 2019, 02:19:49 am
Since you mentioned making things easy for other to make changes, how about adding commands?
Or having interchangeable commands?
One of my dreams has been to add class specific commands to help spice things up.

I'd also like to try to add a new screen for changing jobs like in the later games, but that's a whole other can of worms I'm ill prepared to even think about.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 19, 2019, 02:40:13 pm
Wow, the amount of changes done on this has been nothing short of astounding. I love that these classics still get so much love from the fans.
Thanks :D

Since you mentioned making things easy for other to make changes, how about adding commands?
Or having interchangeable commands?
One of my dreams has been to add class specific commands to help spice things up.

I'd also like to try to add a new screen for changing jobs like in the later games, but that's a whole other can of worms I'm ill prepared to even think about.

There's still 14 more banks to work with... I think? Both these things are ideas I wanted to do eventually. The Hide command came from trying to do class-specific things. I was having trouble changing the text when a new character's turn comes up. But I think I can do that now.

At the moment I think I reached the limit of what I can just "patch in", though. Further changes are going to require massively cleaning up the battle code at least. There's either 1 bit left in the battle command byte for a different action, or the hide command took it up.

I also want to clean up how in-battle and out-of-battle stats are loaded and used, how magic is stored out-of-battle, and clean up what bits of RAM are used for things, so its easier to tell what's safe to use and when.

Aaand I need to comment all my code better, and I think I'll stop keeping the original code commented out once a change I make works 100%. Its getting very messy to read. So for the next few weeks, that will probably be my focus. Along with minor bug fixes as I run into them. One slightly big "bug" is that the 4 big enemies have a gap between them, which pushes them too close to the heroes. That's going to require some nametable editing--or if that's impossible, I have to change the cool spell movement animation I made. :(
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on January 19, 2019, 11:06:38 pm
Ah, the dreaded commenting.
My work in Game Maker Studio sometimes feels slower than molasses because I'm always commenting everything so thoroughly.

Having to rewrite some of the code was probably inevitable given how the original code is kinda ... sloppy.
If you've read Anomie's bugfix and enhancement notes, you know how many issues there are.

Good luck, though!
If I can make some time to contribute, I'll try to do so. :)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 21, 2019, 03:33:50 am
I tackled the dialogue data today. Only 256 lines in the game! Didn't know that. Should have expected it. Gotta figure out how to double that at least. Really hope I didn't screw up a pointer.

There was a game-freezing bug where the magic menu was looking at "$6300" instead of "ch_magicdata"--which used to be the same thing, but aren't anymore.

So I went through and looked for every place there was a variable that wasn't in variables.inc. Mostly they were in battle code. There's like, 8 different places they just chose at random to use as loop counters and temporary backup spots. So about 60% of the way through I just gave up labeling things very well because I was making new variable labels for the same damn thing. So a few spots it'll be saving to like, "math_basedamage" and it has nothing to do with damage at all.  :P I'll get around to that eventually...

Also updated the Checksum verification so now it tries to check the right spots for each save slot, instead of just the first one.

https://drive.google.com/open?id=1SQn4b5UpQcAA7HXzkRCTJ0Ls4RzsnLB6 - So here's a new upload. Rather than overwrite the old upload with every new change, which may or may not break everything, I'll start updating this one instead. Version... 0.2 or something. I should learn how to do project updates maybe.

If anyone is actually trying to play the game with this, please let me know when something looks way off.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: POWCo-op on January 24, 2019, 05:06:37 pm
Great work Jiggers. Thanks for that.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 26, 2019, 06:15:01 pm
Welcome!

Version 0.21 - https://drive.google.com/open?id=1SQn4b5UpQcAA7HXzkRCTJ0Ls4RzsnLB6

EDIT: False alarm, some bugs are still there. Working on it! Sorry!

Bugs Remaining:
* Sound Test screen plays weird stuff if you try to play a song twice.
* Being killed and poisoned in one hit will leave the dead character with the poisoned icon instead of the broken heart icon. Same for other ailments I assume.
* There's a small pause when enemies strike first; where players should be acting, but it skips over them. Not really a bug, but something I want to clear up soon.


Bugs Fixed: (thanks Mari42 for bringing some of these to my attention!)
* Save music was supposed to stop playing when leaving the save screen. Now it does!
* Treasure chests weren't displaying items because the dialogue box didn't know that item names and dialogue strings are in different banks. Now it does!
* I forgot to fix shop inventories after making consumables use different item IDs. This also stopped Heals and Pures displaying in the Drink menu in battle. Now they do!
* The highest byte of item prices when trying to purchase wasn't getting set to 0, making it impossible to buy things after a battle (my battle turn order list writes to the same spot). Fixed it. Edit: And DOUBLE fixed it because it wasn't updating in the right spot to be useful.
* Item prices were being loaded weirdly (shifted one way, then shifted the other to add in the carry), and it was breaking things. Fixed that by loading it normally and adding 0 without clearing the carry first? I'm not sure why it broke. Very weird.
* Fixed the after-battle party sorting so dead characters actually get shoved to the back row.
* More spell spelling fixes. Lokk 2 = Lock 2, Foice = Voice, Qauke = Quake... Holy and Wall were mixed up, as were Flare and Stop. Dumb things like that. Could still be some errors around.
Edit: * Treasure chests should now open the right items. Instead of a Canoe and a Fire Orb, you get a Cabin and a Heal! As you should.

Changes Made:
* Out of Battle Poison is now $04 instead of $03. This basically means all the OB/IB stuff Bank B does is stupid and pointless except for changing the character levels from 0-based to 1-based... So I took all that out and the levels are changed in like 12 bytes or something small like that.

* Character spells are now stored in 8 bytes with the rest of their data. Current and Max MP share a byte (current is high bits, max is low bits.) It took a lot of code, but to free up $100 of RAM in each save game, I think its worth it. The only trade off is that you can't really sort your spells in order of which you purchased first. However, with some tweaks to the numbers, (and a heck of a lot of menu and display changes, not to mention how battle selection grabs spells...) you could learn all 64 spells on a character--still in those 8 bytes. I'm very proud of this!!

* All character stat bytes are used up now. Weapons and armour take up 8 each. Spells and MP are 8 each. If more stats are needed I'll have to move Hiding out of there or something.

* There is now 256 bytes of unused space in each save game slot. Could be double game flag data! More treasure chests! More NPC triggers! Whatever game flags are used for!

Edit: * Bank 0 now exists as an editable ASM file. Had to quickly organize that and find the treasure data to fix the item bytes. Thanks to http://finalfantasyrandomizer.com/ for having a list of treasure stuff I could quickly refer to, and ... anomie, I think? For already having broken down the data structure of that bank! I kinda just copied their notes on it, sorry... Was a rush job!



Please look for potential bugs anywhere where magic is concerned! I haven't yet tested leveling up granting MP. All battle spells should be doing what they're supposed to do.

The next things I want to work on (after a week or two break) is updating weapons and armour screens. This will be a big one, too. Each character can have double the equipment, so each character will get their own screen. I'll play around with it and see how that comes out after my break.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on January 26, 2019, 06:33:03 pm
Cool stuff, man.

About the character equipment...
Before I got to the end of your post I was thinking about that already since you mentioned the changes to item IDs.
Is it feasible to merge the item and equipment functions in the game like later games do?
I always found it tedious having them separate and it sucks having to have 2 commands for using different kinds of items.
I imaging it would require some significant rewriting of the item screen and the associated commands.
Is my supposition correct?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 30, 2019, 04:05:46 pm
I'm not sure if its feasible or not, yet. Both ideas will require learning how to scroll item windows, either in shops or... in shops AND the item list in the menu. What I'd love to do is have an equipment list seperate from items, and an equip character screen for each character. Then select what item from the list you want them to equip from the slot you choose. So that way a character only has 6 bytes of equipment data, and if its full, its ALWAYS equipped, while the equipment bag takes up some of the unused item list bytes.

Version 0.22 - https://drive.google.com/open?id=1SQn4b5UpQcAA7HXzkRCTJ0Ls4RzsnLB6

Changes:
* Character sprite and class are the same byte again--but low and high bits. So each time the game needs to get the class data it has to AND #$0F to clear the sprite bits out, or AND #$F0 to clear the class bits out for sprite use.
* Same thing for the hiding byte; the high bits are hiding, and the low bits... aren't used yet, but I want to code in a regeneration spell. So a character will be healed between turns, then it ticks down by 1, and stops at 0. So the Battle Turn number has a good reason for being there (counting how long until regen spells fade.)
* The EXP-to-Next bytes are unused now. The game calculates this every time you go to look at the status screen.
* Treasure chests not containing key items should be silent now... not sure about key item ones yet.

Bugs Fixed:
* Pressing right in the options menu would set a variable to 1. This variable is also used to tell shops to display a price... So if you used the options menu, then went to buy something, the shop would ask, "____g okay?" And possibly also mess up what you buy. Anyway, now the options menu clears its variables on exit.
* Forgot to set my Y loop counter to 0 when magic shops check the 3 slots per level, so it was only letting you learn 2 level 2 spells and I think 1 level 3 spell. Should now let you learn 3 spells per level as intended!

Bugs:
* Selling stuff is wonky. Gives too much money. Edit: Fixed. - Edit: Not fixed. Need to re-write a whole bunch of code. Taking out the equipment sorting routine really breaks a lot of stuff--but the routine itself was broken somehow... I don't want to deal with it. If you want to sell things for now, put them in the first slot.
* The other bugs I know of are still there...

I never really got that break I was looking forward to. Its always just, "Oh, this one last idea should be easy..." Then I swap stat bytes around and forget to change another thing and then think the first thing I changed is broken but its FINE and the fact that its fine drives me crazy because if its fine why is it bugging out so much and then I realize I forgot to change one tiny part. That's coding for ya.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on January 31, 2019, 06:40:25 am
... and then I realize I forgot to change one tiny part. That's coding for ya.

Ha! It sure is. I once spent a week rewriting an entire script in a GameMaker project thinking I had terribly messed it up somehow only to sleep on it and come back to it the next day and realize I had only forgotten to update a constant in another part of the game.

I had a Japanese FF hack a while back that did the separate equip screen per character thing.
Can't remember where I got it. Or if it could be of any help.

EDIT:
Found it. It's called Final Fantasy Revised.
It seems what they did was restructure the Weapon and Armor menus and add an extra mini inventory exclusively for equipment that all characters can access while in either of the equipment menus.
When you go to either equipment menu you choose a character like you do with the magic menu and only that character's stuff is shown.
Additionally, they added commands to the equipment menus so that you can directly switch between armor and weapons menus and swap to the next or previous character in the lineup.
It's kind of ingenious really.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on January 31, 2019, 11:26:35 am
Ha! It sure is. I once spent a week rewriting an entire script in a GameMaker project thinking I had terribly messed it up somehow only to sleep on it and come back to it the next day and realize I had only forgotten to update a constant in another part of the game.

I had a Japanese FF hack a while back that did the separate equip screen per character thing.
Can't remember where I got it. Or if it could be of any help.

EDIT:
Found it. It's called Final Fantasy Revised.
It seems what they did was restructure the Weapon and Armor menus and add an extra mini inventory exclusively for equipment that all characters can access while in either of the equipment menus.
When you go to either equipment menu you choose a character like you do with the magic menu and only that character's stuff is shown.
Additionally, they added commands to the equipment menus so that you can directly switch between armor and weapons menus and swap to the next or previous character in the lineup.
It's kind of ingenious really.

You mean as in from PS1, Wonderswan, etc?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 31, 2019, 04:14:41 pm
...and realize I had only forgotten to update a constant in another part of the game.

That was exactly the issue. I keep trying to organize the layout of character stats better, for easier reading in the memory viewer, and moved the hiding stat to $10 from $09, then shifted experience over to $09. Meanwhile the battle code was still clearing the hidden stat at the start of battle, so experience was getting reset... All because another variable I was using to point directly to the hidden stat...  :P

It seems what they did was restructure the Weapon and Armor menus and add an extra mini inventory exclusively for equipment that all characters can access while in either of the equipment menus.
When you go to either equipment menu you choose a character like you do with the magic menu and only that character's stuff is shown.

That's a lot like what I want to do, yeah. Except without switching armour and weapons. I think I can squeeze that in one screen and show the stats that update, too. Only show what they have equipped, but picking a slot opens the bag to choose what to try and wear.

I made a quick fix for selling weapons and armour (Link in previous post still). Instead of trying to match up the item box with character inventory, it just scans their inventory for the item you're selling, and if it finds a match, deletes it. So if you have 4 short swords and sell the 4th one, it will delete the 1st, equipped or not. I could add in a safety catch for selling equipped gear, but at the moment I'd rather focus on not burning myself out and, when I do get back to it, doing that whole upgraded weapon/armour inventory and shop update.

Also realized that something weird happened with the intro text and the fading-in sprites were offset by 4 and showing garbage characters... nooo idea how that happened, I haven't touched that code since it first worked... but I put in a fix for that, too.

And, just a reminder (to myself as well)... I don't consider what I'm doing to be updating FF1 anymore. Rather, I'm trying to make more sense of its code and expand on certain features, so that this disassembly can be used for other hacks. My ultimate goal is to make my own NES RPG. So at some point, things may start diverging wildly. I don't want to spend a lot of time doing something just to make this use features that other FF1 remakes use--unless those features are a sensible upgrade that would make other games better, too.

...that said, I have been working on a new song for boss battles...

https://drive.google.com/open?id=1ydVqBt_c8Tata1h4w-9C_8YsUhr_wXuM

(Its only midi square channels, so no triangle bass or duty settings or anything like that. Very rough draft.)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on January 31, 2019, 07:01:40 pm
You mean as in from PS1, Wonderswan, etc?

Sorta, yeah. But the equipment is still separated from the consumable items and quest items in their own inventory apart.


...that said, I have been working on a new song for boss battles...

https://drive.google.com/open?id=1ydVqBt_c8Tata1h4w-9C_8YsUhr_wXuM

(Its only midi square channels, so no triangle bass or duty settings or anything like that. Very rough draft.)

Huh. Nice work there so far. Interesting choice to base it off the temple theme.
I've always been partial to using the Dungeon theme as a boss theme in my custom playlists.
If I had any kind of musical talent I would have actually made it into a real boss theme in Famitracker a long time ago.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on January 31, 2019, 09:21:46 pm
Thanks! There's some volcano and undersea shrine in there, too (and if you really want to stretch it, a brief reference to the original earth/marsh cave music.) I don't think Sky Castle would fit in at all though.

Meanwhile... the game is completely broken! Winning battles still doesn't award XP properly, and I have absolutely no idea why. Or, maybe XP is awarded properly, but the levelup routine is not granting the level when they reach the needed amount. I don't know when I'll get around to checking why and fixing it. I really just wanted to play for a while and not stare at the code for ten hours a day.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 01, 2019, 04:31:13 pm
First off, fantastic job on the new features so far, the options menu alone is beyond epic.
The selectable number of items to buy in the item shop is also great. As is the save menu and selectable character sprites.


Now on to issues I noticed...

Magic doesn't seem to be redirecting to a new target.
I only checked while using a red mage and casting Fire 1.

I noticed the experience values were wonky but you already know about that.


Suggestions for farther down the line that would benefit your future project and probably my own...

Being able to buy multiple items in the weapon and armor shops would be cool, though I imagine it would require having the items in a separate inventory for sure.

One thing I just realized would make shopping much simpler and less annoying is being able to open your party menu while you are in a shop.

And one idea that I had a while back was adding the ability to see at the very least whether or not a character can equip a given item.
I was thinking that perhaps the sprites used to display the party could change when you are pointing at a given item.
If they can equip it they change to the win pose.
If they can't equip it they change to the near death pose.
And if they already have it on they use the normal standing pose.
Alternatively, you have a plus, minus or equals sign appear over their heads instead.

I think that's it for now. :)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 02, 2019, 10:44:14 pm
*flop* I fixed it. I fixed it all. I think.

Auto-target option now effect single-cast spells (on enemies, not on players.) I just never got around to poking that, but it was a super simple thing to do!

I fixed a bug where the black belt's fists were cyan. Because the code to give them a proper palette was only triggering if no weapon graphic was set (no weapon equipped I thought!), but the routine that figures out weapon stats sets the graphic to fists... So now it checks for fists and no weapon.

I was being dramatic in saying it was unplayably broken. The level up routine is working fine after all. And so is the EXP to Next display. In fact... code was perfect.

Quote
[22:13] Jiggers: when swapping banks from inside a bank... I thought it would be wise to backup the registers and some temp variables that are always being used. Just in case there's a situation where I needed to inject a bank switch and keep the bytes in those intact.
[22:13] Jiggers: But I never actually had to DO THAT
[22:14] Jiggers: Until this one thing, where... the only reason I need to do that is because my own backing up code WILL WIPE THOSE TEMPORARY VARIABLES CLEAR
[22:14] Jiggers: *cry*
[22:14] Jiggers: Anyway...
[22:14] Jiggers: LongCall_tmp    = $5CFB ; These backup tmp, tmp+1, and the A, X, and Y registers
LongCall_A      = $5CFD ; The LongCall routine restores them after it swaps banks
LongCall_Y      = $5CFE
LongCall_X      = $5CFF
[22:14] Jiggers: I fixed it
[22:15] Jiggers: LongCall_tmp was 5CFC and yet it was set to use +1 as well
[22:15] Jiggers: but that meant the accumulator was clearing out the high byte of tmp

... so I just decided to ditch the whole "backing up tmp and tmp+1 variables" idea. Right? They don't get wiped by the LongCall routine. I was just being super caurious and paranoid back then because I still barely knew how it all worked.

So experience gain is fine, and the status page shows it properly.

And I was trying to do a thing where Surprised attacks don't have a long pause, but just made it so enemies don't attack during their surprise attack turn. Fixed THAT, too. But the pause comes back if your characters die or are stoned or stunned or whatever. Not much I can do about it at the moment!

Version 0.23 https://drive.google.com/open?id=1SQn4b5UpQcAA7HXzkRCTJ0Ls4RzsnLB6

As far as shops go, at this point, I'm just thinking I'll re-write the whole inventory system and shops from scratch, when I am able to spend a few weeks on that... I think I can think of a way to show what they can equip... but entering the menu from the shop might be a bit too much. There's just soo many little sub-menus that poll for A or B or up or down or left or right. Making every little menu also check for start... oof. ( . .) Sorry.

Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 03, 2019, 01:49:31 am
Wait a minute, does that mean that the shops are actually a menu?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 03, 2019, 03:25:56 pm
Menus within menus pretty much!

Buy/Sell/Exit - menu.
Selecting an item - menu.
Selecting who learns a spell/gets weapons or armour - menu.
Selecting yes/no - menu.
Everything in this game is menus! XD

I fiddled around with it. Every shop menu does call the same routine to re-draw the character sprites and keep music playing, so I put in a check for the start button to go into the menu. It worked... the problem is re-drawing the shop after. The list of items, the last message the shopkeeper says, whatever logic is going on prior to entering the menu... I can backup the main dialogue box, but the item lists and price being displayed in the dialogue box, all that would need to be backed up and re-drawn, and I'm really not sure how to do that. Its simpler to just re-enter the shop after going to the menu, but then at that point, is it really too annoying to leave and re-enter the shop manually? >.< And because of the other menu changes I did, the town music won't start up again after leaving the shop...

I'll keep that feature in mind for when I do get around to doing the shops over from scratch though.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 04, 2019, 03:02:16 pm
Ah, I see.

Yeah it's only a minor annoyance, so it's not that big a deal.

So I guess that is my better suggestion.
1) add an equipment indicator of some sort.
2) add an option to equip the item after selecting who will receive it.

Being able to see who can equip the currently selected item and whether putting on increases or decreases your stats would go a long way in not having to spend so much time swapping around equipment and leaving and entering the shops.

Combined with an equip now option and there will never be a need to leave the shop to check stats.

And because I can never leave well enough alone, if there was some way to directly display at least the basic stats of the currently selected equipment, that would be awesome and asking for way too much. :D

Regardless, thanks for all of your work so far.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 08, 2019, 10:49:36 pm
https://drive.google.com/open?id=1U0Ohq7_6GKZ6NQQOY_prcDbVtLMJ6dlJ

Version 0.30

Visibly, not much new...

Battle stats are now integrated into general Character stats. Things like Elemental resistance and weakness, weapon sprite, palette, element, and category; number of hits, plus the multiplyer, and critical hit rate. The routine that adjusts stats based on what's equipped now fills in those stats as well, outside of battle. (This also means, for now, the whole 8 weapons and 8 armours per character thing is shafted. But that won't matter once I start the inventory stuff.)

During battle preperations, any stats that could be changed by a spell is backed up, and then restored after battle (but before level up stats are tweaked). In battle, character stats are edited directly, by both spells and attacks, so only one or two pointers are needed at a time, instead of the... like 8 or so there were before. No more IB/OB stat nonsense; if I find any more, I'll keep updating.

All the btl_defender, btl_attacker, and btlmag_xxx variables have been shifted up into the $6000 area of RAM, as part of my ongoing attempt to organize what's used and what's not.

As usual... probably some bugs. Just finished this, haven't tested it much. Actually just noticed I messed up some of the weapon stats with the Unadjust/readjust routines, and think I fixed them...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 09, 2019, 01:59:10 am
Groovy. I'll give it a whirl and let you know if I find anything wierd.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 09, 2019, 10:04:28 pm
Guh, sorry. Fixed bank was too full, had to move some stuff to Bank C (luckily made room by doing those edits.) So now the game will actually compile... File in last post updated!

Edit: Found some bugs. Not sure what the issue is or how to describe it. But Garland always messes up things. I'll poke at it some more in the next few days. So bad at testing this stuff.

Bug was in the explosions drawing for 2 Big Enemies and 6 Small Enemies, which the Garland battle uses, I guess! I just made it use DrawExplosions_PreserveX and then cut out some stuff that didn't look like it was needed anymore, so the routine looked more like the other ones. Okay. So, far as I can tell now, all the battle stuff works! Woo!

NOW WHERE THE HELL HAS THE KING GONE???

What could I have possibly edited to make his sprite entirely vanish?! I can walk on the throne now!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 11, 2019, 07:47:44 am
o_O That is odd.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Thanatos-Zero on February 11, 2019, 11:01:39 am
Thinking about it, we could have a FF HD pack version using Mesen.

But now that I consider it. Final Fantasy III would profit the most by using HD scaled graphics.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 11, 2019, 04:38:12 pm
HD pack would be awesome. And how I wish someone like Disch had done a diassembly of FF3 to play with...

Version 0.30 zip file is updated with my fixes. Also poked a few more things, since at some point I broke some features. Overworld music was resetting when exiting the menu, now it doesn't. Moved the Readjust/Unadjust equip stats routines to Bank E, so there's more space in Bank F again, and did some more RAM arrangement. There's a slight timing error warning but I doubt its anything too serious.

Still no King.  :'(
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 11, 2019, 06:08:50 pm
yeah. Ever since the first few HD packs started coming out I've had those possibilities in the back of my mind. A nice hack of FF1, 2, & 3 with graphics like the Anniversary Editions would be pretty slick.

*Daydreaming*
FF1 with updated item and equipment system, MP instead of Vancian casting, and an expanded jobs system with unique commands for each class.
*Drooling now*
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on February 11, 2019, 07:35:31 pm
And how I wish someone like Disch had done a diassembly of FF3 to play with...

Hah.  Honestly the only reason I bothered with FF1 was because of my familiarity with the game.  I only played FF3 for 20 minutes and didn't get very far.

But, of course... there's nothing stopping YOU from doing an FF3 disassembly  ;)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on February 11, 2019, 09:25:04 pm
I'm one of I'm sure quite a number of people who played FF3 to the final dungeon and stopped at its unforgiving length.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 12, 2019, 01:11:27 am
I never got off the floating continent. It and FF5 are the only two I've never beaten.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 17, 2019, 06:13:40 pm
Good news everyone! I found the King. He was undone by a rogue elemental weakness variable.

https://drive.google.com/open?id=1pHO5ooyLaS7UscYMlHvjDS1-NRI7RYXy - Version 0.31

New Thing - Red tint when player is attacked! Will add jam sprites and veins to the screen edges next.

New Thing - Press select in the start menu to swap characters. Expected behaviour: Press select, choose character, press A, (character should now be in cheer pose to indicate they're selected!) choose second character, press A: swap successful with original menu SFX noise, if SFX is turned on. Pressing B at any time should cancel the swap and return the cursor to the main list. Trying to swap dead and stoned characters, or the same character with themselves, should cause the "cr-kow" error SFX or screen shake without red tint.

New Thing - Press Start + Select while loading or saving a game to clear that slot. You will be warned! Press B to cancel, or A to accept. This feature added 2 new tiles: One skull'n'crossbones with a black background located in 0D_B4C9_menuorbs.bin, and one plain black tile in bank_09_data.bin -- but $C1 really should be the black tile, if $FF is the normal background colour, right...? Eh.

New Thing - After Character 4 picks their battle command, a prompt shows up asking: Ready? Yes/No answers. Press B to return to Character 4's input. Press A on yes to continue the battle turn, or Press A on No to return to Character 4's input.

New Thing - Pause game with select! Screen darkens, music stops, sprites may flicker in standard maps... otherwise, seems to work fine. Music will resume after (triangle may take a while to kick back in if you paused on a long note.)


Fixed Thing - Instead of a second A button press stopping music in the sound test menu, it would play the healing jingle; now music stops properly.
Fixed Thing - Temple of Fiends and Sea Shrine song names were swapped in the sound test menu.
Fixed Thing - Victory music would persist in the overworld after battle and other such music not starting/not stopping nonsense. Fixed.
Fixed Thing - All Square 2 music tracks swapped to MMC5 Square 2, so that Square 2 for default music tracks is solely for SFX.
Fixed Thing - Exiting the armour equip screen was overwriting the King of Coneria's visibility flag somehow.
Fixed Thing - Weapon and Armour stats (critical hits, elemental weaknesses, etc) are updated for characters at the start of each battle
Fixed Thing? - Physical attack ailments *should* no longer be given to a character after they die.

Bug? - Square 2 holding high note when using healing items or spells in the menu - fixed? Maybe?
Bug - Listening to the old healing jingle in the sound test menu twice in a row produces a short high-pitched note. No idea how to fix. Not really important?

To Do - Find the King.
To Do - Go over enemy stat loading for physical and magical attacks and make sure everything's there.
To Do - Options cursor finickyness
To Do - Intelligence stuff! See below
To Do - Option to clear save data Done
To Do - Battle turn confirmation after 4th character picks command (have had so many oopsie moments here)
To Do - Have hidden icon be updated separately from the rest of the names/HP/ailments.
To Do - ChaosDeath routine tweaks for smaller battle screen (still)?
To Do - Sorting menu needs to be bigger, sprites need to move further to the right and less to the left, which will be undone by--
To Do - Swap characters on menu screen intead of select screen Done.
To Do - Delete old swap routines and make lots of space in Bank E. Done
To Do - Inventory/Weapons/Armour screens and mechanics re-write
To Do - Save overworld / map music in place when transitioning to battle, then return to playing from where it left off after battle. (May not be possible?)
To Do - Move enemy stats permanently from Bank C to Z, in order to add more; specifically, a stat that holds an "item" to be stolen from them. And then make sure all routines loading stats can reference them properly.



Someone else will need to work on some battle stuff for this, at some point. It's the math again. I just don't know what to do with it. I don't know how intelligence should work to do anything, or how the extra critical hit/effectivity thing for damage should work... Its all... just too much.  :-[ I don't like it, its not fun for me, and the game is fully playable without tweaking it... so whatever. If someone out there wants it--the files are free for editing! Pitch in!



Far as FF3 goes... I love the first third of it, and then get to that damn giant warzone city and remember why I always quit. The pacing just breaks there, for me. Seems like everything's a side-dungeon to grind out, when there wasn't that much grinding to do in getting off the floating continent. Assuming I can even get past the weird king bird enemy that you need dragoons for--but oops, there's no way to train dragoons while trapped in the city, is there? (Is there??)

FF3 Disassembly... I've been off and on about that idea. It seems like a big project. And which version would be best to do it with? One already patched with a translation? Looking it up, I just found out there's another translation, too, never played that one... but it has more hacky-ness done to it, so maybe not a good pick for a disassembly? Someone suggested making an MMC5 patch... Hmm...

Well, for now, I ignored this project for a while to come back with a clearer head. So I guess I'll continue again when I have time.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on February 18, 2019, 01:38:59 am
I would say if you are going to do a full game disassembly, do it off an official version. (that would be Japanese)
Disassembling a hack seems to make less sense, because it would be easier to disassemble the differences later.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on February 18, 2019, 02:30:41 am
I would personally do whatever English translation is most prominent.

Whether or not something is "official" is largely irrelevant, IMO.  I'd want to do something my target audience is most likely going to be interested in.  And if the disassembly is going to be in English, the English version makes way more sense.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 18, 2019, 10:04:27 pm
I guess I'd look at which translation is the least edited. So not the one with the B to dash and other stuff.

FF1 stuff: Now that I've got a pretty much stable version up, I'm working on tearing apart the inventory. How's this look for an equip screen? (The . in "Left H." got squished over by accident.)

https://cdn.discordapp.com/attachments/523953073308303360/547247964926509056/FinalFantasy_026.png

At the moment, the weapon/armour offset is basically getting hard-coded. It reads 6 bytes of character inventory data, the first byte is $00 so it goes, okay, add the weapon items offset. After that, it adds the armour one. Doing away with "high bit set = equipped" because no need for it. If it exists in the inventory, its equip-able (eventually; haven't gotten that far yet.) But what I want to do at some point is work out a better way to differentiate between weapon and armour in the same screen... So that someday dual-wielding is possible. Or go the whole Bravely Second route and let the fighter equip swords to the head and body too. (8-Bit Theatre Fighter would be proud.) Wild ideas.

But how's it look? Not sure what to do with the extra space around the top and to the right of the weapon and left hand...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 18, 2019, 10:53:06 pm
It looks pretty good so far.
Are you planning to expand the character limit on equipment names at all?
If so it might be better to arrange things differently; with the stats and equipment slots all in one large square and the stats by themselves on the top 2 lines.

Something like this:
Code: [Select]
/-----------------------------\
| Attack   XXX   Defense  XXX |
| Accuracy XXX   Evasion  XXX |
/-----------------------------\
|    Left Hand  [XXXXXXX@]    |
|    Right Hand [XXXXXXX@]    |
|                             |
|    Head       [XXXXXXX@]    |
|    Body       [XXXXXXX@]    |
|    Arms       [XXXXXXX@]    |
|    Accessory  [XXXXXXX@]    |
\-----------------------------/
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 19, 2019, 02:27:50 am
Ooh, I like that! Good suggestion :D

https://cdn.discordapp.com/attachments/509200240092643338/547315828715159552/Capture.PNG

Gonna go with 32 weapon slots, 32 armour slots... because that's what fits nicely on one screen. Its still twice what you could hold before so... Seems fair. Getting the screens looking right is finicky, but easy. All the tiny details and mechanics are gonna get hard from here. Really not looking forward to scrolling lists in the shops and battle.

Removing Armour and Weapons from the main menu to just put "Equip" instead also allowed me to remove the "WEAPON" squishy tiles. I will need to re-arrange the tileset some more now, maybe. And add a trash can icon? Maybe not... Lazy...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on February 19, 2019, 04:27:07 pm
I wish there would’ve been as stocks when you have same items, weapons, etc. Like as:

“Weapon x3”
“Weapon x4”
“Weapon x5”
Etc
Etc
Etc

So therefore it can prevent from having the same items, weapons, etc taking over it’s inventory.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 19, 2019, 10:50:06 pm
Glad I could help! :D

As much as it may terrorize your dreams to make scrolling menus, if you do manage it (fingers crossed) it might be a good idea to apply that to the weapon and armor inventories.

One of the things I've always found that makes an RPG feel unpolished is when you can't have at least one of every piece of equipment. Partially it is the completionist in me, but it is also a bit of me playing dress up during the end game.

You see, once everyone's level is maxed out I like to 'dress up' my party in whatever equipment I feel best fits their personality.

So FF1 by default has 40 weapons and 40 armors. As long as RAM isn't an issue it would add a lot of polish to have a scrolling inventory. And having multiples of weapons would be rad.

At this point I'm imagining an inventory similar to FF6 with a single column with a multiplier.

And one last thought, how about rewriting the discard button into a discard action? Instead of it taking space on the screen/inventory have it mapped to select or A + B.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 20, 2019, 02:45:18 am
Its just a matter of having the shop window start and stop displaying things in the list, I figure...

I've been playing around with how the discard option works. Code is getting pretty big, I think I have to do it a different way. Haven't even gotten to being able to equip items from the list yet. Problem is, the cursor is the item number, but when there's a space--should there even be a space? Should the list delete spaces so you don't have to scroll, or should it let you move items around in the list--I haven't even thought of moving items, oh boy...

So, with the edits I made to magic, there is 256 bytes free. I was thinking that could double the gameflags. But it could also be for equipment. 64 unique weapons, 64 unique armours... and then 128 bytes for the amount of each one. Otherwise, the issue is that the edits I made to the music driver require a bunch of non-consecutive bytes somewhere in RAM. It can't be in the part that gets swapped for saving the game, because all that becomes unusable, and music that uses it would mess up--which is the Prelude's melody, now. So right now I have those bytes being stored just before character data and after item data. If I didn't use that spot, there would be 192 bytes for items.

I want to add a few consumable item types as well--hi-potion, ether, pheonix down, eyedrops, smokebombs, wake-up bell, so 6 bytes for those. That would leave 46 bytes for weapons and armour each, including amount. But then no more room for any more consumables or key items...

Just kinda thinking aloud here now.

I put the Discard option where it is because it fills out the screen nicely. I got it set up to turn the cursor red, then you select the item to delete, then it goes bonkers because there's a sudden 0 in the middle of the lists. So, it could totally be the select button to do that. Or put it up at the top of the screen like the old screens had it.

Personally, I like not being able to keep every single piece of equipment. Striking a balance between really tight item management and having more space than there is equipment to fill it is how I'd make a game; but as this project is a base for what other people want to do with it... I'll try my best to work out a way for your requests!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 20, 2019, 06:02:39 pm
That would be very much appreciated!
You do make a good point for inventory management. Maybe you could throw in a variable that could control inventory capacity? That way it could be an easy option for users.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 25, 2019, 05:20:56 am
So its 5 AM and I can't see straight no more.

I got the equip menu working just about how I want it to, for now.

I got some scroll going on in the shops.


Code: [Select]
@ScrollListDown:
    LDA #4
    STA cursor
    LDA item_box_offset
    CMP #$1B
    BCC :+
    JMP @DownReturn
  : INC item_box_offset
    JSR WaitForVBlank_L
    LDA #0
    STA menustall
    STA $2001 
    JMP ShopSelectBuyItem


@ScrollListUp:
    LDA #0
    STA cursor
    LDA item_box_offset
    BNE :+
    JMP @UpReturn
  : DEC item_box_offset
    JSR WaitForVBlank_L
    LDA #0
    STA menustall
    STA $2001
    JMP ShopSelectBuyItem

Problem at the moment is there's massive screen flicker when updating the list... and then after pressing A or B, the screen goes all janky. https://cdn.discordapp.com/attachments/509200240092643338/549532406227664906/unknown.png

The menus seem to work normally despite this.


Some maybe-dumb questions:
If the screen is already turned on, and I turn it on again, does that harm anything?

I thought calling WaitForVBlank would wait for... you know, and then do the drawing in that time, so there wouldn't be flickering from the screen turning off at the wrong time? Basically, um, how do I get rid of that screen flicker. Should I be setting scroll too?

If I can get that fixed, then I can fix the weird pause in battle when it updates the side-bar with HP and stuff, too...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on February 25, 2019, 12:09:59 pm
Quote
If the screen is already turned on, and I turn it on again, does that harm anything?

No.  That's fine.

Quote
I thought calling WaitForVBlank would wait for... you know, and then do the drawing in that time, so there wouldn't be flickering from the screen turning off at the wrong time?

"Flicker" can describe a lot of things, so it's hard to say for sure.  But if you are waiting for VBlank before turning the screen off, then doing your drawing, you should be fine as long as you finish all your drawing and turn the screen back on before VBlank ends.  If you fail to do that, you'll get black bars and probably a garbled scroll on the following frame, which might be the flicker you're talking about.

Note that VBlank is a fixed length of time, regardless of whether or not the screen is off.  Turning the screen off for VBlank doesn't really gain you anything.


Quote
Basically, um, how do I get rid of that screen flicker. Should I be setting scroll too?

Yes.  The scroll and the PPU address set by $2006 are actually the exact same thing (the NES basically uses the PPU address to determine where to start drawing from, effectively making it the scroll value).  So any time you draw anything with $2006/2007, you should be resetting the scroll to whatever you want it to be immediately after.



EDIT:

Note that the game has a built-in mechanism for drawing things in menus without turning off the screen.  The 'menustall' variable you're clearing will split large draws across multiple frames so as never to spill outside of VBlank.  So.... if I'm remembering properly (and I might not be)... to scroll the shop inventory all you'd have to do is build a big string in RAM of the text you want to display in that box, then draw that single string using DrawComplexString with menustall=1, and the game will automatically draw a bit, wait for vblank, draw a bit more, etc.

.... but that MIGHT be too slow as I think it only draws a few lines per frame, and that shop box is pretty tall.  I dunno.  *shrug*
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 25, 2019, 04:45:30 pm
Ughhh...

Code: [Select]
    LDA SellingEquipment ; JIGS - if this is 2, turn screen off to draw
    CMP #02
    BNE :+
   
    JSR WaitForVBlank_L
    LDA #0
    STA menustall
    STA $2001
    DEC SellingEquipment
   
    :
   
    LDA #$02
    JSR DrawShopBox        ; draw shop box #2 (inv list box)

    LDA #<(str_buf+$21)    ; load up the pointer to our string
    STA text_ptr
    LDA #>(str_buf+$21)
    STA text_ptr+1
    JSR DrawShopComplexString  ; and draw it

    LDA #$1E
    STA $2001 ; turn screen on if it was off   

From Screen off to Screen on, its 14936 cycles... If I move the DrawShopBox part, it is 11258 cycles. I guess its just too big of a string to draw with the screen off at all.

Unless I write another drawing routine just for this--the string buffer is mostly control codes, so the drawing routine basically has to swap banks to get the actual names each time. Either I do that or set up inventory to scroll 5 items at a time... Which means it would be best if the inventory was divisible by 5. Or 12 5s and a 4 with a blank at the end. Well! I'll get to it then.

In other news, I feel like I reached peak programmer with this:

Quote
;; this routine temporarily sets cursor to bytes in the string buffer
;; which make it think its pointing to a 41st weapon or armor
;; which has its permission bits all set so no one can equip it...
;; which causes everyone to return to normal pose!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 25, 2019, 06:20:29 pm
Yeah, that last bit is pretty slick.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on February 25, 2019, 06:46:36 pm
From Screen off to Screen on, its 14936 cycles... If I move the DrawShopBox part, it is 11258 cycles. I guess its just too big of a string to draw with the screen off at all.

Yeah VBlank is a little over 2000 cycles.  If you're doing a sprite DMA, it's closer to 1700.  So... yeah that's way too much to draw in a single frame.

Might have to just have a custom draw routine.


.... then again.... this is MMC5... and MMC5 has a vertical split screen mode....  In fact... this would be the absolute perfect use for it.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 26, 2019, 08:07:24 pm
https://drive.google.com/open?id=1M8Sv419Dvb2fn95olNiu2gYYUTt288d-

Version 0.32!

What's new and fixed:

* Buying in an item shop and pressing B to cancel now actually cancels...

* Shop keeper text has been updated (most of it) to be more centered in the box, and spread out with double line breaks to look neater, hopefully.

* New equip inventory stuff! Weapons and Armor options in main menu consolidated into "Equip" option. Press left and right in equip window to swap characters faster. Press A on an inventory slot to swap gear. Weapons and Armour have different windows, but all armor types share the same window.

* Weapon and Armor capacity is 64 items each.

* Mages start with a staff, fighter and thief start with small knives. Blackbelt has nothing but fists. Everyone has cloth armor.

* Equipping and un-equipping things should change stats properly... but if you know they're not, let me know.

Weapon and Armor inventory window:
* Press A to select item (tries to equip it). If item is equippable in that slot, to that character, it will swap the currently equipped item (seen in upper right little box) with the selected item.

* Press Select to access swap mode. Cursor turns a colour, pick the item you want to swap! Cursor turns another colour, pick the second item to swap! Errors if you try to swap the same item, the Discard option, or the currently equipped item (it was going to be a HUGE headache to allow swapping in that slot, sorry.) You cannot have blank spaces between items; the list will auto-sort to remove blank spots.

* Selecting the Discard option turns the cursor red, and from there, you can delete anything but the Discard option itself. Even works with currently equipped item!

* The way the cursor moves in this menu is a little wonky, but I tried to make it make sense. If you're in the first or second column and move down, it will wrap to the top of the second and third, and same going backwards. Up from the top of first column and down from the bottom of third will both hit the currently equipped item box.

Buying and Selling:
* At the moment, selling a character's equipped items is not supported. You can only sell from the inventory. The inventory scrolls by 5 items if you have them. It will scan ahead 5 slots, and if it sees a 0 in the list (first item on the next "page"), it will not scroll.

* If you have room in your gear inventory, you can choose to currently equip what you buy in the appropriate slot--if its equippable by that character. The current item will be moved to inventory. Or you can skip equipping it and put it directly in inventory.

* Characters have been moved into a straight line, and they also do a little jig when the cursor is hovering over something they can equip! Please let me know if they dance in magic shops or item shops or the inn or the clinic! They should not be doing that.



BUGS:

* I haven't even touched the battle menu for non-potion items... Expect it to be super, super screwy.

* The inventory window only shows 32 items still. So even if you have 64, you can only see the first 32 for now.

More stuff:

* I haven't gotten around to getting weapons and armor having a quantity yet.

* I wanna add little arrows to the boxes like in FF3, showing when you can scroll up or down, maybe.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 26, 2019, 10:24:50 pm
Dude, is that a new text effect on the opening story?
It's frickin' awesome!!

Will play a bit more tonight.

EDIT: Did some quick testing and everything seems to be working perfectly. I have to do a closer inspection of the equipment stats.

One thing that stuck out to me though is that sometimes the pose used by the characters in the shop menu isn't always super clear who changed poses if you aren't paying attention. If it is possible, I suggest that when the poses are updated, that characters that can't equip an item use either the stone palette or switch to the critically injured or death pose.

And I know you aren't working on the battle stuff right now, but it stuck out to me once again, like it always does when I play FF1, that there is no way for a character to skip their turn besides using an item with no spell effect. (Which is pretty lame.) So a defend command might be a great addition in the future.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 26, 2019, 11:05:16 pm
Yeah, its been there since the start of this thread. XD Thanks!

Also updated the .32 zip file again... I had the "pose if equip" variable getting set inside a shop routine that was being used for more than the weapon and armor shops; moved it out, so the characters don't get over-excited about purchasing heal potions anymore! Bug testing is rough.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 27, 2019, 01:13:24 am
Logic errors are the bane of my existence. :/
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 27, 2019, 08:16:13 pm
So... how should using an item in battle work?

My current idea is:
Take away the DRINK menu option.
Make the ITEMS option open a sub-menu: POTION, EQUIPMENT, WEAPONS, ARMOR
Then, choosing POTION opens the old DRINK menu.
Choosing EQUIPMENT (or EQUIPPED, whatever sounds better), shows a list of that character's items.
Choosing WEAPONS will allow scrolling through the weapon inventory...
Same for ARMOR.

Why move the DRINK menu? Because Battle menus have to be an even number for some reason. While I could just write a new menu routine just for the ITEMS option to only have 3 choices, its easier just to use what's already there. Plus, that makes a spot for having a unique command for each class...

I definitely do not like the idea of swapping equipment in battle. From an "I'd have to code it" perspective, anyway. That's just adding a whole other layer of confusion to how stats are handled by magic and equipment... Maybe much later when I'm more confident nothing is broken.

What I've done tonight is moved all the weapon, armor, and enemy data into Bank Z, except for the spells weapons and armor cast. Bank C now has 3,219 bytes free. $B00 of Enemy ROM data is stored in RAM (swapped to the other side, where save games are.) This is either temporary... or not. I'll either move all the routines that need to check Enemy ROM data to Bank Z, or swap RAM to have it do that.

The swap thing is kinda dumb. Even if its basically immediate, its just too much turning it on and off for every single byte load.

One thing that stuck out to me though is that sometimes the pose used by the characters in the shop menu isn't always super clear who changed poses if you aren't paying attention. If it is possible, I suggest that when the poses are updated, that characters that can't equip an item use either the stone palette or switch to the critically injured or death pose.

And I know you aren't working on the battle stuff right now, but it stuck out to me once again, like it always does when I play FF1, that there is no way for a character to skip their turn besides using an item with no spell effect. (Which is pretty lame.) So a defend command might be a great addition in the future.

Yeah, the difficulty in seeing some poses (white mage in particular) was the reason for moving their sprites into a straight line. I gotta think about how I'd do that. Adding the stun ailment? Basically every frame its adding the confusion ailment to characters, and I updated the out of battle sprite drawing to have them cheer-pose when that happens. Same thing done when swapping them in the menu. Then it has to wipe the ailment out after, without taking away poison or death or stone... So, adding stun in should make them crouch easily enough... I hope.

I generally use the Hide option to skip a turn, now. But yeah... defending would be more useful for that. Just not sure there's a bit left for it in the command byte. I'll put it on the To Do list!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on February 27, 2019, 09:00:29 pm
So... how should using an item in battle work?

My current idea is:
Take away the DRINK menu option.
Make the ITEMS option open a sub-menu: POTION, EQUIPMENT, WEAPONS, ARMOR
Then, choosing POTION opens the old DRINK menu.
Choosing EQUIPMENT (or EQUIPPED, whatever sounds better), shows a list of that character's items.
Choosing WEAPONS will allow scrolling through the weapon inventory...
Same for ARMOR.

Why move the DRINK menu? Because Battle menus have to be an even number for some reason. While I could just write a new menu routine just for the ITEMS option to only have 3 choices, its easier just to use what's already there. Plus, that makes a spot for having a unique command for each class...

I definitely do not like the idea of swapping equipment in battle. From an "I'd have to code it" perspective, anyway. That's just adding a whole other layer of confusion to how stats are handled by magic and equipment... Maybe much later when I'm more confident nothing is broken.

What I've done tonight is moved all the weapon, armor, and enemy data into Bank Z, except for the spells weapons and armor cast. Bank C now has 3,219 bytes free. $B00 of Enemy ROM data is stored in RAM (swapped to the other side, where save games are.) This is either temporary... or not. I'll either move all the routines that need to check Enemy ROM data to Bank Z, or swap RAM to have it do that.

That’s a perfect idea, so therefore people will have more options to be able to use/cast items IB where the players won’t be using too much magic since the “Drink” option is odd name for a title and slots are very short. That bothered me, but with you doing so it’s a perfect idea.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on February 27, 2019, 09:07:12 pm
Drink was originally "kusuri" (medicine) but I guess DRINK was what they came up with in the official translation to fit within the original screen space/character limit.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 27, 2019, 10:22:24 pm
So... how should using an item in battle work?

Having a sub-menu set up is a good idea.

Drink: USE ITEM might be a good alternative since they are found under the ITEMS menu.
Equipment: is fine.
Weapons: has an issue...
Armor: has the same issue... and it isn't the names...

The issue is that access to all of the items that can cast a spell throws things a bit off balance.
I'm pretty sure the remakes handle it by making spells cast from an item ignore the user's INT when calculating the effects of the spell so that they are minimally effective.

So you'd probably want to do something like that here.
Or come up with some other limiter so that a bunch of spells don't suddenly become obsolete.

Some ideas:
- create a limit to how many time a character can use items to cast spells in any given battle.
- expand each character's equipment slots so they can carry extra 2 or 3 extra items for casting and/or swapping purposes. And don't include the WEAPONS or ARMOR options in the ITEMS sub-menu.
- replace all the spells used by items with new exclusive spells that are weaker than the originals and are not available to be learned in magic shops.
- do the INT patch upgrade to increase spell effectiveness but but don't include that boost when casting from an item.

Doing an equipment swap thing would probably be a can of worms programming wise.
And realistically you should only be able to swap weapons and shields.

Edit: On a side note, is it feasible to rearrange palettes so that the there are 3 available for character sprites like in Final Fantasy 3?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 28, 2019, 06:59:12 pm
https://cdn.discordapp.com/attachments/516487781091115009/550824025593479168/Capture.PNG

Leaving that last menu slot open in case I figure out something new to add (Class change???)--meanwhile, made it more modern FF-styled!

I like the idea of each character having a little gear bag of spare weapons to cast with. That would be so much simpler than scrolling 64 or 32 weapons in battle. (Drawing battle boxes is the worst thing ever.) I guess it would look like the old equip menu, but 2 slots for each character. That would be 8 items displayed in the battle menu...

And that would leave 3 character stat bytes left.

3 palettes: I've thought about this.

From my understanding, once something is drawn to the background, it can't be changed, right? That's how they get a ton of colours on screen at once, changing palettes mid frame-draw, as well as having huge intro screens that use more unique tiles than can be loaded at once?

So each time a character is stoned, it would be feasible to undraw the sprite, load the sprite into background tile RAM instead, swap a background palette to grey (or the blues if you want to add in a frozen statue ailment!), draw it where the character used to stand.

For now... I did a thing! For every enemy in battle, their ROM stats are loaded with the RAM stats for easier access. This is 27 bytes per enemy, 243 in total. This could be upped to 28 bytes per enemy if there's another stat to add. For now, I've given them 1 extra--an item that can be stolen from. I haven't coded this in at all yet, its just there, waiting to be used. And now that I think about it, it probably won't work just like that at all.

It might have been simpler to add a RAM byte instead of a ROM byte (to switch when their item is gone), then have a LUT based on the enemy type. The LUT could randomize the item they have--imps could have cloth armour as well as small knives, and it could swap between which one you steal--as well as have an offset byte so that the stealing code would know if its weapon, armour, potion, or what have you. Ah, well... one extra ROM byte isn't hurting, for now. :P

I'm gonna keep poking at it before I upload another update though.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on February 28, 2019, 07:46:46 pm
From my understanding, once something is drawn to the background, it can't be changed, right?

The long and short answer to this question is "no, that's not correct."

But I'm not sure I understand the question properly, because OBVIOUSLY the background can be changed or else all games would have to be just 1 static screen.  Do you mean changed between frames?  Changed mid-frame?  Both of those are possible, but the latter is difficult.

Quote
That's how they get a ton of colours on screen at once, changing palettes mid frame-draw, as well as having huge intro screens that use more unique tiles than can be loaded at once?

I'm not SUPER familiar with FF3 but I don't think it does anything really fancy like this.  AFAIK the only screen-splitting it does is for the battle menu that pans to the side.

That said... palette changes mid-frame are EXTREMELY tricky and there are only a small handful of games which actually do it -- I'm pretty sure FF3 isn't one of them.

More common techniques to get more graphics on screen would be a CHR bankswap (or a nametable switch) mid-frame.  Both of those usually can be done in 1 or 2 writes and aren't SUPER timing critical.  But again I don't even think FF3 does this.  I could be wrong though.


Quote
So each time a character is stoned, it would be feasible to undraw the sprite, load the sprite into background tile RAM instead, swap a background palette to grey (or the blues if you want to add in a frozen statue ailment!), draw it where the character used to stand.

This is definitely possible.  The tricky part is finding the space for the player sprites in the BG CHR.  Most of it is in use already.

This would be sort of "easier" with MMC5's extended attribute mode, but "easier" is misleading because that's an entirely different can of worms that would require rewriting a ton of drawing code.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on February 28, 2019, 08:06:43 pm
Oh, I mean like... if you draw something to the background, then change the palette that was used to draw it, that doesn't automatically change what was already drawn. You'd have to re-draw the background again to apply that palette, wouldn't you? I wouldn't dare try to do anything mid-frame.

And there is space for 6 tiles of character! Between the enemy graphics and the lettering, there's some Japanese text with a / in front of it. Its actually there at the end of every batch of enemy tiles. I'm just not sure if those tiles have to stay there every time the screen updates...?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on February 28, 2019, 10:56:44 pm
Oh, I mean like... if you draw something to the background, then change the palette that was used to draw it, that doesn't automatically change what was already drawn. You'd have to re-draw the background again to apply that palette, wouldn't you?

No.  You can change the palette without rewriting to the nametable, and the new palette will take effect immediately.

Some basics about how the frame is rendered:

- The game sets some data.  Notably:  nametables, attribute tables, and palettes
- The NES, during frame rendering, will read that data and draw pixels based on the contents of that data in real time, at that exact moment
- Once an individual PIXEL is visibly on the screen, then and only then* is it too late to change it (at least until next frame)

* Note that there's some buffering going on so it's actually too late to change it a few cycles before it's actually visible -- but for a general idea this is "close enough"


So if you want to write to the attribute table to change palette assignment for a 16x16 block -- that will IMMEDIATELY change the attributes for that block.  You do not need to redraw the block -- the nametable still contains the old data that it used to.


Quote
And there is space for 6 tiles of character!

That's enough for 1 character.  What if multiple people in your party are turned to stone?  I guess you could have a common "stone" graphic that is used for every class.

Quote
I'm just not sure if those tiles have to stay there every time the screen updates...?

I *THINK* the '/' slash is used somewhere (maybe in the original start menu?), but I'm 100% sure the other characters are not used anywhere and can be safely replaced.  =)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on February 28, 2019, 11:32:32 pm
Final Fantasy 3 doesn't do anything wierd with the palettes as far as I know.
In battle and in the menu, there are three palettes dedicated to the character graphics and one that changes as needed.
The remaining palette changes as needed.
It is used by the hand pointer, weapon graphics, and spell affects.

Final Fantasy 1 uses only two dedicated palettes for the character graphics and one is dedicated to the hand pointer.
The remaining palette functions just like in FF3 except that it isn't used by the hand pointer.

So I imagine the only thing you need to do is change the hand pointer object to use the revolving palette and add appropriate code to change the colors in the revolving palette whenever you need to load the hand pointer.

That should leave things set up just like FF3 and now some of the classes can have a 3rd color scheme.

Anywho...

Love the menu layout. Now just shift all the little boxes to the right side and we're in business!! :P

I am 100,000% behind having a class change command!!!!!
My ideal set up for the classes is to have the 6 basic ones available as normal, having the option to class change at will, and the 6 advanced ones are all locked until after the Bahamut event is completed.

Speaking of which, one of the things I suggest adding in is something like the enhanced magic menu that Grond did in his hack. Being able to change around your spells would be very useful in general, but even moreso in tandem with being able to change classes.

Oh! About the gear bag. If I understand, you are saying that each party member gets to hold 2 extra items and all 8 are available to the whole party during battle? That would be like the perfect middle ground between limited personal inventories and full open party inventory!! Love it!

That thing you did: Damn! That's great. That pretty much paves the way for both random item drops and a Steal command! BTW, having each monster drop items that make sense has always been a thing I prefer to have.

I'd probably take it even further. Maybe too far. See I think that if I could, I would actually rather have non-intelligent monsters not drop Gil at all. I actually think that as tedious as it could become I'd prefer to go around getting monster hides, fangs, scales, etc. that I could sell of for gold. I kinda dig the whole monster hunting aspect. Though it would probably be necessary to create a whole big-ass array of new items that basically do nothing at all and expand the item inventory space

Either way, I dig the work you're doing it's pretty sick!

Last thing, I thought of something for the weapon and armor inventories. It would be a good QOL thing if the names of the equipment that the character can't use were drawn in a darker color like most of the later games do. That way the players don't get the annoyance of trying to equip gear that can't be equipped.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Lasciel on March 01, 2019, 04:57:08 am
OK, this is going to sound pretty stupid, but how do I apply this to a FF1 ROM, and to which version do I apply it? The NES version, or the GBA Dawn of Souls version?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on March 01, 2019, 02:24:35 pm
OK, this is going to sound pretty stupid, but how do I apply this to a FF1 ROM, and to which version do I apply it? The NES version, or the GBA Dawn of Souls version?

FF1 NES version  :)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Lasciel on March 01, 2019, 03:05:17 pm
FF1 NES version  :)

Alright, so that takes care of that. I presume that I use the LD65 executable file in the zip, then?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 01, 2019, 03:13:53 pm
Run the build.bat file and it will create a ROM file from the source code.
Then you can rename the ROM to whatever you like and play it as normal.

@Jiggers: I made a moch-up of how I would arrange the party menu. It basically matches the FF3 one.
It's just the most basic arrangement you could make really.

(https://i256.photobucket.com/albums/hh189/koala_knight/Stuff/th_FF1%20MMC5%20Menu%20WIP%20Moch-up_zpsf2arm18t.png) (https://s256.photobucket.com/user/koala_knight/media/Stuff/FF1%20MMC5%20Menu%20WIP%20Moch-up_zpsf2arm18t.png.html)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 01, 2019, 03:28:44 pm
OK, this is going to sound pretty stupid, but how do I apply this to a FF1 ROM, and to which version do I apply it? The NES version, or the GBA Dawn of Souls version?

Not a stupid question! I didn't explain it at all. You don't need a ROM, you just click "build.bat" in and it will assemble all the code into a working game. (Oops I took so long replying to everything else it got answered!)

No.  You can change the palette without rewriting to the nametable, and the new palette will take effect immediately.

OHHHHhhhhh, damn. I completely mis-understood everything I was reading about all that, then. So now I wonder how FF3 does it. Do they just not have stone? No, they do. Okay, looking at that game, it must be swapping graphics, and its using the menu palette for stone, which is silly, 'cos there's blue dots on the people. So, that seems a bit complicated for me at the moment.

Love the menu layout. Now just shift all the little boxes to the right side and we're in business!! :P

...

Speaking of which, one of the things I suggest adding in is something like the enhanced magic menu that Grond did in his hack. Being able to change around your spells would be very useful in general, but even moreso in tandem with being able to change classes.

Oh! About the gear bag. If I understand, you are saying that each party member gets to hold 2 extra items and all 8 are available to the whole party during battle? That would be like the perfect middle ground between limited personal inventories and full open party inventory!! Love it!

...

I'd probably take it even further. Maybe too far. See I think that if I could, I would actually rather have non-intelligent monsters not drop Gil at all. I actually think that as tedious as it could become I'd prefer to go around getting monster hides, fangs, scales, etc. that I could sell of for gold. I kinda dig the whole monster hunting aspect. Though it would probably be necessary to create a whole big-ass array of new items that basically do nothing at all and expand the item inventory space

Either way, I dig the work you're doing it's pretty sick!

Last thing, I thought of something for the weapon and armor inventories. It would be a good QOL thing if the names of the equipment that the character can't use were drawn in a darker color like most of the later games do. That way the players don't get the annoyance of trying to equip gear that can't be equipped.
.

Whew... I still need to do some more background work before something like magic swapping is possible. The way item names are set up is complicated and I want to simplify it while making it easier to add more of everything. I think the area that needs work on next would be the printing routines, for that. And then I'd have to undo my cool "64 spells in 8 bytes of storage" thing. XD

Pros: 8 more character stat bytes.
Cons: Armour and Weapon inventories limited to 40 each (if using stacked items), or 80 each if each item of the same type takes up its own slot.

As it is now, its possible...? But the limit would be 64 spells in the game, as it is now. If you wanted to add other magic types and have more spells, magic bytes it would definitely need to be moved out of character stats again.

The monster item idea is neat, too. Would just need to, again, fix up the way items are labeled by the game. There's definitely room in the items part of save RAM for lots of things. And then fix up the way to sell them the way buying 99 potions works. Not too difficult, just finicky. Bank E is getting kinda full now though...

Gear Bag: I was actually thinking it would be 2 personal items each. 1 main weapon, 5 equipped armours, and 2 of either type for spell-casting. There's only really room to display 8, and it seems fairly balanced to me, closest to the original, considering how few items actually cast spells.

I'll look into a way to better highlight what you can equip in the armour menu. Maybe put the dancing sprite in there somewhere...

Run the build.bat file and it will create a ROM file from the source code.
Then you can rename the ROM to whatever you like and play it as normal.

@Jiggers: I made a moch-up of how I would arrange the party menu. It basically matches the FF3 one.
It's just the most basic arrangement you could make really.

I think all the orbs gotta be closer in the box, because of the nametable attributes. I tried moving them up, before, but lighting one made glitches where the bottom half and top half of one would be lit instead. :P (I also kinda like the menu on the left more... I think I'm either just so used to it... Japanese read right to left, right? So they're expecting to look to the menu on the right first... But heck, isn't too hard to change once I figure out the orb colour thing, so I'll figure out a way to do it.)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 01, 2019, 03:52:23 pm
I think all the orbs gotta be closer in the box, because of the nametable attributes. I tried moving them up, before, but lighting one made glitches where the bottom half and top half of one would be lit instead. :P (I also kinda like the menu on the left more... I think I'm either just so used to it... Japanese read right to left, right? So they're expecting to look to the menu on the right first... But heck, isn't too hard to change once I figure out the orb colour thing, so I'll figure out a way to do it.)

Sounds like it's just a case of the current code trying to change something that has been moved, depending how it was coded it could be as simple as changing coordinates or it could be a pain in the butt.

Japanese being read right-to-left probably is the reason for the FF1 menu position, but that pretty quickly flew out the door. FF2 is still arranged vertically instead and the commands themselves are arranged left-to-right as in English. Then FF3 set the trend for the next7 or so games.
I guess it just depends on how much of the original game's set up you want to preserve.

Incidentally, which bank has the code for the menus?
I'd like to learn more about how they actually work.



PS- Another idea for you.
Have the shops and clinic not reset the town music.
Just like how the party menu doesn't interrupt the music and just lowers the volume.
That would free up the shop theme for use in other parts of the game.

Actually I keep a custom soundtrack of FF1 around and rename the menu, shop, and clinic themes into extra town themes. I imagine places like Pravoka would use the livelier shop theme, more sleepy towns could use the menu theme, and the standard town theme would be for the larger towns.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on March 01, 2019, 05:41:16 pm
Vertical Japanese is top-to-bottom right-to-left.

But horizontally-printed Japanese is read just the same any western language.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 01, 2019, 05:46:01 pm
Yeah, that might be something nice to do for town music. I'll put it on the To Do list if I remember. Usually I re-read this thread and fill up the To Do list when I run out of other things I want to work on. XD

I really don't know why FF1 has a different layout from the other games, if its not the language thing... I was looking at FF3's menu and thinking, "this looks cluttered and kinda bad..." I don't remember thinking that about the SNES games, but I also haven't been actively thinking about menu positions at all when I last played any of them! So my next guess... FF3 did it like that to save space (I think I saved space by changing the menu layout a bit!) And it just kinda stuck...?

Bank E is the one for the main menu and shops!

https://drive.google.com/open?id=1d8XpfheXVsEln6EU5FYCRpxedbAWy68V -- here's the last update I did to it.

The usual logic is something like:

Turn off screen, reset buttons, clear nametable, load graphics (this is usually done in the fixed bank, before swapping to Bank E for menu logic), do any data filling (putting shop items into RAM for instance), draw boxes, fill boxes with text, turn on screen... (these are usually labeled Enter-something. EnterShop, EnterMainMenu, etc.)

Then the frame things: Clear old sprites, re-draw sprites, do audio updates, and check buttons, and loop until a button is pressed. (ShopFrame, MenuFrame)

Then, when buttons are pressed: If directional buttons, move the cursor around the screen. If A, use the cursor positioning to get character data, or item data, for whatever needs doing. If B, go back to previous menu or exit.

Every little thing has its own LUT, usually. For placing boxes, for placing sprites (both character and cursor), and so on. So if you want to swap the menu positions yourself... Look for "DrawMainMenu" which then goes through DrawOrbBox, DrawMainMenuGoldBox, and DrawMainMenuOptionBox, before drawing the main character box/boxes. What you really want to change is in:

lut_MainItemBoxes (menu box positions)
lut_MainMenuSubCursor (cursor positions for choosing a character)
lut_MainMenuCursor_Y (cursor positions for choosing menu option) (and then find the X coordinate in DrawMainMenuCursor)
DrawOrbBox (position of orb tiles is here instead of using a LUT; this also handles the nametable attribute byte the orbs use, but I don't immediately understand how to change it to move them over. Just know they need to be in the same attribute box.)
DrawMainMenu (text string positions for character names, level, hp, mp)

Moving the boxes is usually enough to change the text positioning, though. Sometimes I have to do INC/DEC dest_y/dest_x before it goes to DrawMenu/Shop/ComplexString to get things more centered and nice looking.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 01, 2019, 07:19:27 pm
Thanks for all the info! I appreciate it.

As for the Menu layout origin, I think it's just a case of this being the first time they did a fully separate menu for an RPG. And the FF3 layout ended up being the most popular.

Bug report time:
I noticed some screwiness in the shops this time.
I went in bought some stuff and everything was fine.
Bought a bunch of extra stuff to see the scrolling inventory; no issue.
Sold something and then there was a problem.
The stuff in my inventory changes into a bunch of wierd stuff.
This is in the armor shop.
I had a bunch of cloth armors, sold one, then backed out of selling, and all my cloths turned into 360g.
I then sold the 360g for 180g (LOL), and the remaining 360g turned into an ice shield that I sold for 2000g.
Then the first empty slot turned into a LUTE. Discarded it.
I tried again to but a bunch of cloth armors, sell one and back out with B.
This time I tried to go back to buying stuff and the store inventory went all screwy.
Eventually I was able to select the armor shop itself by pressing up on an empty store inventory...
I appeared to buy the shop itself, but alas this is not Fable and it only turned out to be a LUTE.
Discarded that one, too.

So it looks like there is something funky going on there with loading the wrong data. Seems like at one point it might have been loading data from the treasure table.

Also Garland appears to have the wrong AI or something as the text windows refer to him as SCORPION and he can heal himself.

EDIT:

In other news the owner of the Cornelia Weapon Shop is under investigation for suspicion of human trafficking...

(https://i256.photobucket.com/albums/hh189/koala_knight/Stuff/FinalFantasy_000_zpsdrdnsgxn.png) (https://s256.photobucket.com/user/koala_knight/media/Stuff/FinalFantasy_000_zpsdrdnsgxn.png.html)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 01, 2019, 09:19:46 pm
Also Garland appears to have the wrong AI or something as the text windows refer to him as SCORPION and he can heal himself.

XD This is why I was waiting to upload version .33 ... I've only had time to battle imps so far, and their stats were checking out. (I did have to edit the way enemy names were drawn to even get that right though.)

I see what the issue is. Items are stored in inventory as $01-$40, then transferred to the shop's item box and their item offset thing is added. So a small knife ($01) becomes ($1D) but then, that's not subtracted when I put them back in the inventory... whoops! I'll get right on that.

I've been looking over how FF3 uses its save RAM, and discovered that they do the exact same thing I did with the magic! They cram it all into 8 bytes, using the bits to denote if a character has it in their list. Sneaky beans.



This is annoying me. I can't figure it out.

So each enemy has 28 bytes of RAM data, not 27 as I thought. (0 based stuff is messing with my mind too much.) They have 21 bytes of ROM data.

So, get RAM pointers...

Code: [Select]
GetEnemyRAMPtr:
    LDX #28                ; multiply enemy index by 28  (number of bytes per enemy)
    JSR MultiplyXA
    CLC                    ; then add btl_enemystats to the result (btl_enemystats is $6100)
    ADC #<btl_enemystats         
    STA EnemyRAMPointer
    TXA
    ADC #>btl_enemystats         
    STA EnemyRAMPointer+1
    RTS

Then load stats from ROM, and add in the last few RAM-only bytes:

Code: [Select]
LoadEnemyStats:
    LDA #$09
    STA btl_loadenemystats_counter              ; loop down-counter
    LDA #$00
    STA btl_loadenemystats_index               ; loop up-counter / enemy index
   
  @EnemyLoop:
    LDA btl_loadenemystats_index              ; Put a pointer to the current enemy's stat RAM
    JSR GetEnemyRAMPtr                          ;    in btltmp+A
   
    LDX btl_loadenemystats_index              ; Check to see if this enemy even exists
    JSR DoesEnemyXExist
    BNE :+
      JMP @NextEnemy        ; if it doesn't, skip ahead...
     
  : LDX #21                ; multiply current enemy ID by #$15  ($15 bytes of data per enemy)
    JSR MultiplyXA          ;   add the result to data_EnemyStats to generate a pointer to the enemy
    CLC                     ;   data in ROM.
    ADC #<data_EnemyStats 
    STA EnemyROMPointer
    TXA
    ADC #>data_EnemyStats
    STA EnemyROMPointer+1
   
    LDY #0
   @Loop:
    LDA (EnemyROMPointer), Y
    STA (EnemyRAMPointer), Y
    INY
    CPY #21               ; copy 21 bytes of ROM data into RAM.
    BNE @Loop
   
    LDA #0
    STA (EnemyRAMPointer), Y ; <- en_aimagpos
    INY                 
    STA (EnemyRAMPointer), Y ; <- en_aiatkpos
    INY
    LDA #$01
    STA (EnemyRAMPointer), Y ; en_numhitsmult, default to hit multiplier of 1
   
    INY
    LDA #0
    STA (EnemyRAMPointer), Y ; <- en_ailments

    LDY #04
    LDA (EnemyROMPointer), Y ; load max HP low byte
    PHA                      ; push low byte
    INY
    LDA (EnemyROMPointer), Y ; load max HP high byte
   
    LDY #en_hp+1
    STA (EnemyRAMPointer), Y ; save as current HP high byte
    PLA                      ; pull low byte
    DEY
    STA (EnemyRAMPointer), Y ; save as current HP low byte
   
    LDX btl_loadenemystats_index   ; get the enemy ID
    LDA btl_enemyIDs, X
    LDY #en_enemyid
    STA (EnemyRAMPointer), Y   
   
  @NextEnemy:
    INC btl_loadenemystats_index           ; inc up-counter to look at next enemy
    DEC btl_loadenemystats_counter           ; dec down-counter
    BEQ :+
      JMP @EnemyLoop    ; loop until all 9 enemies processed
     
  :  RTS

Everything looks okay? Here's six wolves in RAM:

(https://cdn.discordapp.com/attachments/509200240092643338/551262957632487464/6_Wolves.PNG)

Wolf ROM bytes, for comparison:
.byte $18,$00,$06,$00,$14,$00,$69,$FF,$24,$00,$01,$05,$08,$01,$00,$00,$00,$1C,$00,$00,$00

Now then, to print the name, this little routine has to combine the enemy stat index ($0 to $8 for 9 enemies)...

Code: [Select]
    LDX #28
    JSR MultiplyXA
    TAX
    LDA btl_enemystats + en_enemyid, X
   
;original code:
    ;ASL A           ; mulitply A by $14  ($14 bytes per entry in btl_enemystats)
    ;ASL A           ; first, multiply by 4
    ;STA $94         ;    store it in temp
    ;ASL A           ; then multiply by $10
    ;ASL A
    ;CLC
    ;ADC $94         ; add with stored *4
    ;TAX             ; put in X to index
    ;LDA btl_enemystats + en_enemyid, X   ; get this enemy's ID

What is it doing wrong, that 2 out of 4 wolves are labeled IMP (the code is fetching $00 instead of $02)?

Edit again: And after all that... I guess it works after all? Maybe I was so tired I forgot to build after my last change...

https://drive.google.com/open?id=1d8XpfheXVsEln6EU5FYCRpxedbAWy68V - So selling and enemies should work now...

Also fixed:
* EXP and money earning.
* Garland is not using Cure anymore
* Imps do not run away from level 1 parties
* Selecting a character to swap won't reset the cursor back to the first character
* Cursor can't even touch the save option outside of the overworld (like FF3)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 02, 2019, 01:58:48 am
Heya. More bugs.

-When I'm in any shop (magic, item, clinic, inn, etc.) if I press the start button at any time it starts looping a scratch sound effect that doesn't stop until I leave the shop. Doesn't happen in the party menu.

-In every shop and in the party menu, every time I press the A button it plays that same scratch sound as above, but only once per press. Additionally every time I move the finger pointer. Battle menus aren't affected.

-When I sell stuff, no matter which item I choose it always removes the item at the top of the currently displayed page of items instead of the one I was pointing at.

-When I buy an item and immediately equip it to the character in the 1st slot it removes their current weapon just fine and equips the item I just bought. However when I do the same thing with the characters in the other slots instead of adding the weapons they are holding into the inventory it adds a copy of whatever weapon the character in the 1st slot is holding.

-When I try to cast a spell that doesn't have an out of battle effect, it tells me that I'm out of charges for that level instead of saying that the spell can't be used outside now.

-There still seems to be some funkiness going on because at the end of the battle when I killed Garland, the message box referred to him as an IMP and then for a split second as a GrIMP.


Question: Are the experience point and gil values for enemies out of whack? I seem to get some pretty wierd results. Is it because of the options menu effects?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 02, 2019, 02:20:50 am
Heya. More bugs.

-When I'm in any shop (magic, item, clinic, inn, etc.) if I press the start button at any time it starts looping a scratch sound effect that doesn't stop until I leave the shop. Doesn't happen in the party menu.

That is weird! I'll look at it tomorrow. I remember in some menu code or other, it was clearing the start button, and the comments were like, "Why does it do this, the start button does nothing here"? Maybe its a bug in the original game's code that they fixed by doing that?? *shrug*

-In every shop and in the party menu, every time I press the A button it plays that same scratch sound as above, but only once per press. Additionally every time I move the finger pointer. Battle menus aren't affected.

XD This is on purpose. I thought the bloopy SFX were too annoying so I played around with the noise channel and made some SFX I thought were kind of okay, not too grating, not too loud. Both this and the start-button bug can be turned off in the options menu. I only used the original menu SFX for swapping characters because my noise channel things were too subdued for a success sound, and the visual changes happened too fast to be satisfying.

You can use the old square 2 SFX too. Look for "PlaySFX_MenuSel" and "PlaySFX_MenuMove" in Bank E, and comment out my code and delete the ;s in front of the original code.

-When I sell stuff, no matter which item I choose it always removes the item at the top of the currently displayed page of items instead of the one I was pointing at.

...weird. I didn't notice that happening. But that is definitely not right, will poke it tomorrow.

-When I buy an item and immediately equip it to the character in the 1st slot it removes their current weapon just fine and equips the item I just bought. However when I do the same thing with the characters in the other slots instead of adding the weapons they are holding into the inventory it adds a copy of whatever weapon the character in the 1st slot is holding.

I just noticed this and fixed it (edited my previous post, but forgot to mention this bug.) It was caused by using Y where I should have used X.

-When I try to cast a spell that doesn't have an out of battle effect, it tells me that I'm out of charges for that level instead of saying that the spell can't be used outside now.

Oopsie. Should be an easy fix, just gotta find the right byte for the right message. I wouldn't even think of trying that, so good catch.

-There still seems to be some funkiness going on because at the end of the battle when I killed Garland, the message box referred to him as an IMP and then for a split second as a GrIMP.

Weiiird... if you have time, try again with the last update in my previous post?

Question: Are the experience point and gil values for enemies out of whack? I seem to get some pretty wierd results. Is it because of the options menu effects?

They were, definitely. While I fixed enemy RAM loading 27 bytes when it first loads enemies, I forgot to change that in the battle bank, so morale and AI were wonky, and also in Bank B, where the after-battle stuff happens, was still using the original game's enemy RAM size, so it was loading random values for experience and money. It should work now!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 02, 2019, 04:52:23 am
OK. I tested everything out again. All the battle related options (Experience, Money, Encounter Rate) seem to be working flawlessly.

No issues fighting Garland either.

One thing I noticed is that I was able to get the cap from the first treasure chest on the left side of the Temple of Fiends. It wasn't visible initially in the armor inventory, but when I first pressed A to equip the empty space it appeared in the body slot, then I removed it from there and it appeared properly and was able to equip it on the head slot.

I have to say that being able to set XP and Gil to high and manipulate the encounter rate as I need is awesome.
It saves time when I need to level up by setting everything to HIGH and being able to set the encounter rate to LOW removes a lot of the annoyance of battles interrupting me while I'm trying to concentrate on exploration.

Another thing, in the party creation menu is the palette for the frames supposed to have dark blue instead of medium gray?

On to some suggestions...

Party Menu stuff...
I love being able to switch between characters when I'm in the equip menu.
I'd love to be able to do the same thing in the Magic and Status menus.
I imagine it would be pretty simple to get that done in the Status menu.
However, I'm thinking it might be a hassle in the Magic menu since it already uses all 4 directions for navigation.
It would need to either use an alternative method to switch characters (which would cause an inconsistent controls situation) or you would have to add a command that you start on. While on this command (call it CAST or USE) press A to switch to the normal interaction mode or Left/Right to switch characters.
That way the controls in all the menus would remain standardized.

I think I mentioned this before but, there is a little annoyance in the name input menu that might be worth fixing. If I input a name that is shorter than 7 characters I'm forced to input blank spaces. That blows. I suggest having the start button end name input prematurely.

Oh! When I used a tent just now, after exiting the tent menu I noticed that the character in the 1st slot (which was a Fighter with the Monk sprite) momentarily switched back to using the Fighter sprite although the palette was still the Monk's.

I think that's all for now.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 02, 2019, 06:48:00 pm
Yay for Garland being normal! Whenever I edit battle stuff, fighting him is the basic "Did I screw up?" check, since his data is so far down the list from imps and wolves...

I did forget to update the getting items from treasure chests for the new inventory... will do that next!

I really liked the ability to set individual difficulty settings in Bravely Default. Setting EXP and money gain to high at the start, I don't think you'd need to do the marsh cave grind very much at all. Last time I was able to play without going "I want to change this", I got to level 7 not long after getting the ship... Which I used to do at level 3.

"Another thing, in the party creation menu is the palette for the frames supposed to have dark blue instead of medium gray?" -- Yep, its not something I can easily change. I thought the black background would be better for seeing how your characters will look for 90% of the game, but the boxes don't align on the attribute table. Can't make the outside the box background classic blue without changing the frames of the boxes. *shrug*

I'm updating the status menu a lot now, and the equip menu. I forgot about DTE text, and now I'm using it as much as possible to save space... You can now swap characters in the status screen! I'm not sure I want to bother with the magic menu, though. I still need to set up the 2 extra weapons stuff, and there's very little space left... If I finish it up and I do have space, I'll give it a try.

I fixed up the name input menu to allow pressing start. It won't let you press start without at least 1 non-space character input. Also you can press B on a blank name to go back to class/sprite select, since that bothered me too.

Quote
When I try to cast a spell that doesn't have an out of battle effect, it tells me that I'm out of charges for that level instead of saying that the spell can't be used outside now.

Which spell were you trying? I used Fire, and got the correct message. The code looks okay...

Quote
Oh! When I used a tent just now, after exiting the tent menu I noticed that the character in the 1st slot (which was a Fighter with the Monk sprite) momentarily switched back to using the Fighter sprite although the palette was still the Monk's.

Got it fixed, I think. Needed to re-load some graphics after using the save screen, which loads up the standing sprites for all 12 classes.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 02, 2019, 07:42:55 pm
Fire and Bolt both did it. Haven't checked the others yet.
I'll let you know.

Edit: Just checked again, It only happens on the 2nd and 3rd spells, not the 1st one.
Just to make sure I downloaded the zip again and rebuilt the ROM and started a new game.

Since you are working on the status screen, would you consider moving the level display to the same box as the name and instead adding the Magic Evade stat? Having the M.Evade % visible is one of those things other mods have done that I find really convenient. No need to add it to the equip menu either since it isn't affected by equipment at all.

Also, I have another editing question, how do I know how much space has been used in a bank while working on the asm file?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 02, 2019, 11:22:34 pm
Actually already have the status screen showing Magic... well, defense. Did that before you posted, sorry. >.>

I think I have the two extra battle items working now, I just need to re-write how its drawn in the box and make sure the battle code will select the right thing... This might take a while. Other than that, I think the only bug I haven't fixed yet is the magic one you just found.

For checking the space in each bank, I put "END OF BANK X" text at the end of each file I want to check, then load the .nes file up in something.

(https://cdn.discordapp.com/attachments/509200240092643338/551620347791802369/Capture.PNG)



https://drive.google.com/open?id=1d8XpfheXVsEln6EU5FYCRpxedbAWy68V

!! Yay, I think I got everything.

For the spells having an improper message, I don't know what my brain was thinking. Cursor was being used to index an 8-byte long LUT, when cursor could have been up to 24... So, made a new LUT 3x as large, because heck if I know how to divide a single byte by 3 instead.

Dumb thing: I made the Thief and Ninja's names in the party generation screen centered in their boxes. Thief at least. Ninja should work. But then I forgot to move the space from the front of Ninja's text. I did it now but I already uploaded the file...

There's two new slots in the Equip menu. This meant squishing everything into 1 box. I don't know if it looks okay. But its all working, as far as I can tell. And using items in battle is back in business! 3 weapons, 5 armors.

The item battle box is sorted like this:
0 Weapon - 1 Shield
2 Head - 3 Body
4 Hands - 5 Accessory
6 Item 1 - 7 Item 2

I'm afraid any other way to sort it would be ridiculously difficult... Except this one, more like the original code:
0 Weapon - 4 Head
1 Shield - 5 Body
2 Item 1 - 6 Hands
3 Item 2 - 7 Accessory

Which would require moving Item 1 and 2's stats around. Having Shield be in slot 3 would save the equip menus maybe a dozen bytes of code (not having to compare 6 and then compare 0 to see what's a weapon and what's armor), but just... looks wrong to my dumb brain somehow.

I also found and fixed the BlackBelt armour bug.

I think that wraps it up for all the big changes I had going on... There's just no room left in Bank E for adding code for 99 stacks of stuff. I'm gonna take a break for a few days (unless you find more bugs) and then think about what I want to do next. Either organizing item names better so the amount of gold in treasure chests isn't taking up item slots, or working out how game flags can use more than the 3-4 bits it currently does. Or just slowly start documenting more things... Or move NPC dialogue stuff to another bank so E has 5000 free bytes again...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 04, 2019, 02:42:49 am
Cool beans. I was out of town for the weekend and just got back. I'll do some testing tomorrow.

I'm very interested in the moving of NPC dialogue to another bank. I think it would be worth it for further changes to the menus.

Before I got to the end of your post I was already thinking of asking if would be possible to split the contents of Bank E in some way to make more room for editing the party menu more.

Also, is the ROM this disassembly produces expanded as far as MMC5 can go?


EDIT:

Something got borked because in the Temple Ruins I encountered a ghoul that was actually a Frost Lizard and Garland was actually a Frost Giant.

That selling bug still seems to be there. It always takes the top item on the list no matter which one I choose to sell.

And I can get the potion and cabin from the chests just fine, but the cap didn't appear in inventory.

The new equip menu layout is pretty good, but might benefit from a bit more rearrangement. I'll post a mock-up image later so I can just show you what I'm thinking.

The Status screen, on the other hand, needs a lot more work. It just feels wierd.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 04, 2019, 04:23:26 pm
Also, is the ROM this disassembly produces expanded as far as MMC5 can go?

Nope. Chaos Rush's FF3 translation uses MMC5 and is 1 megabyte. This is currently half that. And most of it is still filler.dat. I don't know if you'd need to completely re-organize the whole game structure, though. If its just more banks, or if the banks have to be bigger or smaller or anything... not my area of understanding stuff.

Blegh... I forgot about the selling bug. I see the problem, at least.

And this time I'll test the treasure chest and enemies before I call it fixed... (Garland worked last time though! *whine*)

The new equip menu layout is pretty good, but might benefit from a bit more rearrangement. I'll post a mock-up image later so I can just show you what I'm thinking.

The Status screen, on the other hand, needs a lot more work. It just feels wierd.

Yeah, it is weird. Could put the orb box there to make it more filled out? Code in some more stat printing routines to show critical hit and whatnot? Or just use more boxes again once Bank E has more space for it...

For the selling bug, if you want to try this...

Code: [Select]
@ItemsForSale:
    LDA #01
    STA inv_canequipinshop ; turn on the ability to dance to equipable items!
    JSR ShopSelectBuyItem        ; have the user select an item to sell
    BCS @_Loop                   ; if they pressed B, jump back to the loop
   
    LDA cursor       ; add this
    STA ItemToEquip  ; and this
   
    DEC SellingEquipment
    JSR DrawShopSellItemConfirm  ; draw the sell confirmation dialogue
    JSR ShopLoop_YesNo           ; give them the yes/no option
    BCS @_Cancel                 ; if they pressed B, canecl
    LDA cursor
    BNE @_Cancel                 ; if they selected "No", cancel

    LDA ItemToEquip   ; change "cursor" to "ItemToEquip"
    CLC
    ADC item_box_offset
    TAX
    LDA #0
    STA item_box, X

And for the missing cap: Its actually a bigger bug. But an easy fix.

Code: [Select]
FillEquipInventoryWithItemBox: ;; fill inventory from item box - after equipping, swapping, deleting an item!
    LDX equipoffset
    BEQ :+      ; if 0, its a weapon, so skip ahead
    CPX #06
    BCS :+

    LDX #$40    ; 64 bytes past weapon list
    JMP :++     ; X is now the start of weapons or the start of armors 
   
  : LDX #0
  : LDY #0

Add the JMP :++ and the second : in front of the LDY at the end, and do the same for FillItemBoxWithEquipInventory below that.

I wonder if all these dumb equipoffset checks would be better done with a LUT...? How many bytes does that bit of code take up, compared to:

LDX equipoffset
LDA EquipmentOffset_Lut, X
TAX

plus 8 bytes of: $00, $01, $01, $01, $01, $01, $00, $00
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 04, 2019, 05:06:26 pm
The LUT might be a smidge less bytes, I think, but I'm not 100% sure.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 07, 2019, 01:42:41 am
...it saved like 9 bytes. But I moved the talking routines to the Dialogue data bank and now there's looooots of space.

Fixed the selling (pretty sure) and missing cap. Fixed a few more battle things with enemy RAM stats. (forgot a # in front of a variable name and suddenly 1 wolf out of 6 was regenerative...) Can't replicate the enemy names being off anymore, though, so it seems fixed to me still.

https://drive.google.com/open?id=1rmHbc4YZg0NkobkkmNSZroZHykFfCuc1 - Version 0.34 ?

Removing 0.33 because I overwrote the file with a buggy mess.

Asking someone about the status screen, they prefer the old one, too. Are the lowercase, longer words alright, though? If I split them into two boxes, I'd either need to have them stacked up, or pushed to the edges of the screen like the magic menu is. I sorta like having room to add another box of information. Job level, capacity points, someday, maybe...

Also amazed at how cluttered everything in FF3 is!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 07, 2019, 03:32:43 am
I like the longer names for the base stats, yeah.

Please, for the love all that is good in the world do not add the capacity point system from FF3 into this.
There's a good reason they never used anything like that ever again.
Personally, I'm just fine with keeping things super simple.
A simple Job menu that just lets me change jobs is more than good enough.

I don't think separate Job Levels are necessary really.
Jobs in this game only really affect 2 things; how your stats grow and access to spells.
So there isn't as much of a need for specific job leveling with no abilities to gain or commands to learn and allocate.

But...
If I was going to go all out, I'd pretty much copy the job system from FF5 and maybe a spattering of features from later FFs.

One thing to keep in mind if you are going to add a job system is that you will have to figure out a way to deal with magic. That's why I've been pushy about making the magic menu more flexible. If the magic menu allows for easily exchangeable spells, then switching jobs won't be much of an issue.

Speaking of changing jobs, another thing to keep in mind is what to do with equipment.
I think the best thing to do is have it give a warning before automatically unequip everything.
FF3 gives a warning bout having to unequip before trying to change jobs, but then you have to trudge back to the equip menu and manually do it yourself. That blows.

EDIT:

Bug reports...
Buying and selling in the equipment shops seems to be working fine now.
I did notice, though, that after I had only 4 items in inventory it already allowed me to scroll down to the second page where I could start selling empty slots for 0 gil.
It didn't seem to have any adverse effect on the actual inventory itself.

The experience and gil reward values are out of whack again. Goblins are giving out hundreds of XP on the low setting.


Buying things in the item shop is overwriting the amount of the item I purchased instead of adding it to the ones I already have.

I noticed something about the glitch with FrGiant Garland. He changed into a FrGiant after I hit him with magic. So it's maybe loading the wrong index somewhere in the end of the spell casting routine?

After Leveling up above 9 the level up text is overwriting the text box on the right side due to the longer name strings.

I can confirm that the treasure chests in the Ruined Temple are all functioning properly.
(Love my shiny new cap!)

EDIT2:

Suggestions I thought of during tonight's playtest...

Character creation menu:

After I'm done with all 4 characters, can you make it so I can press START to begin the game instead of B? Most of the other games have you confirm with START instead of the cancel button.

Add a confirmation message after pressing Start to finalize character creation and start the game.

Depending on how involved you want to get with it, you could allow players to press START at any time and have different subroutines take effect depending on the circumstances.
-Press START without entering any names at all: starts the game with the default party and changes their names to those of the core members of the development team.
Code: [Select]
(Fighter   , Thief, Monk , RedMage.)
(Hiro[nobu], Nasir, Amano, Uematsu.)
-Press START with only 1, 2, or 3, names filled in: Start the game with that many characters, and the remaining blanks are not present at all. Playing through the whole game on HIGH encounter rate and LOW XP and gil would be brutal as a solo party. It's basically formalizing what some people already do for a challenge by letting some characters die and never reviving them.

I was thinking about the blue frames in this menu, what about doing a graphics bank swap instead of changing the palette? That way you could have that menu use alternate graphics that allow you to keep the frame colors consistent.

Speaking of graphics bank swapping, What about having a full set of male and female sprites for each class? Something like... press SELECT to switch graphics sets while selecting the class and sprite? I can provide the graphics even.

Other Stuff:

Add a sell command to the item shop.

Add a delete command to the File Load menu.

Add an option to remember cursor position on the main menu.
Even if it is limited to only functioning while you are on the main menu and it resets when you exit it would be great QoL.

Remove the "Nothing here." message when I press A and there is nothing there.
Save some of that text space for something more useful than the obvious.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 08, 2019, 01:15:41 am
Whew, that's a lot... I'll just touch on a few things for now:

You can delete in the save/load screen! Press Start + Select at the same time (holding down one and then the other doesn't work, haven't figured that out yet. Gotta press both at once.)

Garland being a Frost Giant--I see it now. It shows up for a split second after displaying the damage dealt. While undrawing boxes... I hate battle boxes so much. EDIT: I could have sworn I went over the battle magic stat loading and saving routines before, but... I guess I didn't? So, I fixed that. Garland's enemy ID was being overwritten by his defense or something. I think this was also making imps give extra money? Did that only happen if you cast magic on them? Updated the last link with the fix!

"I did notice, though, that after I had only 4 items in inventory it already allowed me to scroll down to the second page where I could start selling empty slots for 0 gil." -- I fixed this by changing a CPY #4 to a CPY #6 in the subroutine "@ScrollDownLoop:" Must have thought it was 0-based, since it needs to scan 5 ahead... except it needs to scan 6 ahead, actually.

That's all I got time to report for now. (And Capacity points are dumb, I agree.)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 08, 2019, 05:43:41 am
No worries! After all this is just a hobby at the end of the day.

I'll have a look at that new update as soon as I get a chance.
I've been pretty busy, too actually. (Still want to try doing some mock ups to illustrate my ideas.)

EDIT:
Fuck it! I did it live!

Magic Changing Frost Giant Garland Bug: Fixed. Tested on the CREEPS too and they didn't change either.

Premature Inventory Scrolling in Shops: Fixed. Tested with 1, 2, 3, 4, 5, and 6 items in the inventory to make sextuple-sure it worked right.

However...

The XP/Gil rewards are still coming in from every enemy, not just IMPs, way too high. Has nothing to do with the magic change bug as far as I can tell.

I noticed another bug in the shops. The EXIT command is borked. It just opens the sell menu instead of leaving the shop.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on March 08, 2019, 11:12:50 am
Is there a git page for this?  If not, it might be worth considering setting one up.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on March 08, 2019, 01:27:03 pm
Whew, that's a lot... I'll just touch on a few things for now:

You can delete in the save/load screen! Press Start + Select at the same time (holding down one and then the other doesn't work, haven't figured that out yet. Gotta press both at once.)

NES games usually program it to store both HELD and PUSHED states of the controller buttons, somewhere in RAM.
(HELD being the exact state of the controller data, PUSHED being the state after some filtering to remove buttons held on continuous frames, or whatever the polling interval is)
I suppose you could experiment with those.

It would be very easy to find the RAM, just do a breakpoint for $4016 and look where its shifting the data to.

Maybe mess with combinations like Start+Select "HELD" (I suppose consequential repeated erasing of SRAM wouldn't hurt).
Or check if Select PUSHED + Start HELD and the reverse.
Or maybe two flags, one for each button, set when pushed, and erase when both are set.

There's probably a simpler way I'm missing.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 08, 2019, 11:09:05 pm
Maybe mess with combinations like Start+Select "HELD" (I suppose consequential repeated erasing of SRAM wouldn't hurt).

I figured it out! It does have variables for different button states, but whatever I was trying last time to read them wasn't working, but it does now. When Start + Select are held, the "joy" variable is #$30, and I was able to have it branch off a CMP. I don't remember why I was having trouble before when I tried almost the same thing...

Is there a git page for this?  If not, it might be worth considering setting one up.

I've been afraid to spend a day figuring out how github works... But yeah, that's really something I should sort out real soon. Edit: Someone helped me out with it!

https://github.com/JiggeryPonkery/FF1-MMC5

The XP/Gil rewards are still coming in from every enemy, not just IMPs, way too high. Has nothing to do with the magic change bug as far as I can tell.

I noticed another bug in the shops. The EXIT command is borked. It just opens the sell menu instead of leaving the shop.

Oops, my bad with the exit shop. I tried to save a few bytes (me: why does it need to CMP #1 there's only buy and sell... one BNE and one BEQ!) and forgot there was actually a third option...

So for the XP/Gil... This is how it looks when the game is checking the stats. (Using Mesen's RAM viewer.)

(https://cdn.discordapp.com/attachments/509200240092643338/553786914034155521/Capture.PNG)

For some reason, LoadEnemyStats wasn't filling the whole area that enemy stats actually occupy. It grabs all those bytes and combines them into the Gil/XP rewards. So there were some random non-0 bytes where the blue is, maybe? I updated the routine to clear those 256 bytes to 0 before writing enemy stats, so it might be fixed, or that might not have been the issue. But the rest of the code seems fine, and from the looks of things, its definitely grabbing the right bytes to check... I can't think of what else it could be.

So, again, all those little fixes in the last link!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 09, 2019, 04:34:59 am
Groovy! I can confirm that the XP/Gil, file delete, and exit commands are all fixed.
There are still a few more things left, plus I noticed another one.
Whenever I appear on the world map the party is always facing right.
This occurs even if I just enter the menu and then exit.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 09, 2019, 03:22:07 pm
Yay! And Boo.

So I was trying to cheat to check out the pirates, to make sure battles with 9 enemies were loading right. I thought, maybe changing these two positioning variables would teleport me - "unsram_ow_scroll_x" and "unsram_ow_scroll_y". That didn't work, so I looked them up to see what they do, and far as I can tell, they're only used to set the starting positions. So I thought, well that's silly to fill up two bytes of SRAM for something you can just hardcode. But what if people want to change it? I'll set up some constants! But then I forgot you needed a # in front of constant variables to actually make them work as numbers, so it was loading new games at coordinates 0, 0. So I just undid everything I changed and left it alone because I needed to get back on track and not be distracted from my original goal.

Except... I didn't undo everything I changed, I guess? I don't know how I could have messed up the direction you face on loading the overworld. But now I see that Standard maps have this:
LDA #DOWN
STA facing
...and the overworld doesn't seem to set facing at all? It just clears it to 0, then does a routine that sets it to 8 but gets set to 0 again after.


Edit: So for a while I'm going to focus on cleaning up the code that's there. Re-arrange things, make fancy headers for routines, make it look good, like Disch had it before.

Also, I re-arranged all of Bank 0 and freed up 736 bytes. Lots of padding in there to make sure data was on page boundaries or whatnot. I just swapped the data around so there's less need for padding. And re-wrote the game_flags initialization, since its 7 0s and 249 1s. So now it fills with 1s with a loop, then writes the 7 0s to the proper spots. Have not uploaded these changes yet.

I ran into Kary during testing and she cast Fire 3, which was ineffective. Gotta look into that, too.

Gave imps Kary's AI and they were able to cast Fire 3 just fine?



For the item buying bug:

 @CompletePurchase:   
    LDA MMC5_tmp
    LDX shop_curitem
    ORA items, X ; <- add this line
    STA items, X
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 10, 2019, 05:49:37 am
Cool. Tidying up and rearranging the code will help to better manage the new additions you want to do and make it easier on anyone else who wants to edit the game.

I’m going to go back and review my posts so i can double check any remaining bugs I noticed.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 14, 2019, 10:37:06 am
(https://cdn.discordapp.com/attachments/527351555779723266/555629776929423363/Capture.PNG)

Anyone know what this means? Despite the error, it seems to compile just fine...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on March 14, 2019, 11:02:47 am
(https://cdn.discordapp.com/attachments/527351555779723266/555629776929423363/Capture.PNG)

Anyone know what this means? Despite the error, it seems to compile just fine...

https://forums.nesdev.com/viewtopic.php?f=10&t=14315#p172009
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 14, 2019, 09:00:15 pm
Huh, I didn't change anything to do with that, but its not doing it anymore.

Hey, @Disch! FFHackster is the only source for FF1's treasure table converted into items that I've been able to find. Is there any chance you still have the raw, but converted data? Would save me from having to go through the drop-down and tag every single byte... like this:

Code: [Select]
lut_Treasure:
.byte $00, $00 ; 00 ; "Unused" ;
.byte $00, $47 ; 01 ; "Coneria 1" ; Iron Armor
.byte $00, $55 ; 02 ; "Coneria 2" ; Iron shield
.byte $00, $06 ; 03 ; "Coneria 3" ; TNT
.byte $00, $26 ; 04 ; "Coneria 4" ; Iron staff
.byte $00, $27 ; 05 ; "Coneria 5" ; Sabre
.byte $00, $2B ; 06 ; "Coneria 6" ; Silver knife

I'm poking at the treasure chest system. Now the first byte informs what kind of item it is, so that there can be more than 256 item IDs. Weapons and armor are split from other items so there can be more of them. But now I gotta re-do every single byte, after figuring out what the original item was supposed to be!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on March 14, 2019, 11:55:05 pm
Hey, @Disch! FFHackster is the only source for FF1's treasure table converted into items that I've been able to find. Is there any chance you still have the raw, but converted data? Would save me from having to go through the drop-down and tag every single byte... like this:

"raw but converted"?  lol   :P

So going by your example it looks like there are 2 strings you're looking for:  The label name, and the actual item name.

Hackster pulls the label names from the FFHackster.dat file in its directory.  It's a binary file -- I was young... sorry.  You can open it with a hex editor though and the labels are visible at offset 0x51AA, and each label name is exactly 31 characters (if the label is shorter, it's padded with zeros).

The item name ares looked up from the in-game item table, though, so those are not stored anywhere.


I could probably write up a quick-ish Python script to generate that lut_Treasure table in your example.  And while I'm doing that, I might as well convert to the new format you're looking for so you don't have to do it manually.

Can you describe the final format you're shooting for?  You said the first byte is the item type, is it 00=item, 01=weapon, 02=armor, etc?  And are weapons/armor now zero based (weapon 0 = small knife)?  Full spec plz.

Once I have that I'll throw together a script for ya.


EDIT:  The other question is, if I convert the table, do you need the item names?  Extracting the item names would actually be the hardest part because I have to parse a table file and all that nonsense.  Although I might have some python code for loading tables lying around....

Like if I just gave you a file that looked like this:

Code: [Select]
lut_Treasure:
.byte $00, $00     ; Unused
.byte $02, $07     ; Coneria 1
.byte $02, $13     ; Coneria 2
; ...

Would that be good enough?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 15, 2019, 12:45:55 am
Ooo... no, its the item names I want! I got the label list from something else--one of the other FF1 docs floating around here, I think.

The format is...
;; If the first byte is $00, the second byte is $70 or higher (80 possible amounts of gold)
;; If the first byte is $01, its an item, key item, or magic:
;; second byte: $1 through $0F are consumables   (15 possible items)
;; second byte: $10 through $2F are key items    (32 possible key items)
;; second byte: $30 through $6F are magic spells (64 possible spells)
;; If the first byte is $02, its weapons or armor:
;; $0 through $3F are weapons     (64 possible weapons)
;; $40 through $7F are armors     (64 possible armors)

The weapons/armour table is 0 based, so that it caps at $7F, but I think I kept the IDs the same, so nunchucks are 01, small knife is 02.. Everything else shares the same table as before, but spells are moved up before the amount of gold in chests.

This is how I've got the items organized now... probably not going to change them after this unless something drastic happens, but I think this is a good enough amount of new items.
Code: [Select]
lut_ItemNamePtrTbl:
.word BLANK             ; 00
.word NAME_HEAL         ; 01
.word NAME_X_HEAL       ; 02
.word NAME_ETHER        ; 03
.word NAME_ELIXIR       ; 04
.word NAME_PURE         ; 05
.word NAME_SOFT         ; 06
.word NAME_P_DOWN       ; 07
.word NAME_TENT         ; 08
.word NAME_CABIN        ; 09
.word NAME_HOUSE        ; 0A
.word NAME_EYEDROPS     ; 0B
.word NAME_SMOKEBOMB    ; 0C
.word NAME_HORN         ; 0D
.word BLANK             ; 0E
.word BLANK             ; 0F

;; Key Items
.word NAME_LUTE         ; 10
.word NAME_CROWN        ; 11
.word NAME_CRYSTAL      ; 12
.word NAME_HERB         ; 13
.word NAME_KEY          ; 14
.word NAME_TNT          ; 15
.word NAME_ADAMANT      ; 16
.word NAME_SLAB         ; 17
.word NAME_RUBY         ; 18
.word NAME_ROD          ; 19
.word NAME_FLOATER      ; 1A
.word NAME_CHIME        ; 1B
.word NAME_TAIL         ; 1C
.word NAME_CUBE         ; 1D
.word NAME_BOTTLE       ; 1E
.word NAME_OXYALE       ; 1F
.word NAME_CANOE        ; 20
.word BLANK             ; 21
.word BLANK             ; 22
.word BLANK             ; 23
.word BLANK             ; 24
.word BLANK             ; 25
.word BLANK             ; 26
.word BLANK             ; 27
.word BLANK             ; 28
.word BLANK             ; 29
.word BLANK             ; 2A
.word BLANK             ; 2B
.word ORB1              ; 2C
.word ORB2              ; 2D
.word ORB3              ; 2E
.word ORB4              ; 2F

.word SPELL1       ; 30
.word SPELL2       ; 31
.word SPELL3       ; 32
.word SPELL4       ; 33
.word SPELL5       ; 34
.word SPELL6       ; 35
.word SPELL7       ; 36
.word SPELL8       ; 37
.word SPELL9       ; 38
.word SPELL10      ; 39
.word SPELL11      ; 3A
.word SPELL12      ; 3B
.word SPELL13      ; 3C
.word SPELL14      ; 3D
.word SPELL15      ; 3E
.word SPELL16      ; 3F
.word SPELL17      ; 40
.word SPELL18      ; 41
.word SPELL19      ; 42
.word SPELL20      ; 43
.word SPELL21      ; 44
.word SPELL22      ; 45
.word SPELL23      ; 46
.word SPELL24      ; 47
.word SPELL25      ; 48
.word SPELL26      ; 49
.word SPELL27      ; 4A
.word SPELL28      ; 4B
.word SPELL29      ; 4C
.word SPELL30      ; 4D
.word SPELL31      ; 4E
.word SPELL32      ; 4F
.word SPELL33      ; 50
.word SPELL34      ; 51
.word SPELL35      ; 52
.word SPELL36      ; 53
.word SPELL37      ; 54
.word SPELL38      ; 55
.word SPELL39      ; 56
.word SPELL40      ; 57
.word SPELL41      ; 58
.word SPELL42      ; 59
.word SPELL43      ; 5A
.word SPELL44      ; 5B
.word SPELL45      ; 5C
.word SPELL46      ; 5D
.word SPELL47      ; 5E
.word SPELL48      ; 5F
.word SPELL49      ; 60
.word SPELL50      ; 61
.word SPELL51      ; 62
.word SPELL52      ; 63
.word SPELL53      ; 64
.word SPELL54      ; 65
.word SPELL55      ; 66
.word SPELL56      ; 67
.word SPELL57      ; 68
.word SPELL58      ; 69
.word SPELL59      ; 6A
.word SPELL60      ; 6B
.word SPELL61      ; 6C
.word SPELL62      ; 6D
.word SPELL63      ; 6E
.word SPELL64      ; 6F

.word MoneyChest1  ; 70
.word MoneyChest2  ; 71
.word MoneyChest3  ; 72
.word MoneyChest4  ; 73
.word MoneyChest5  ; 74
.word MoneyChest6  ; 75
.word MoneyChest7  ; 76
.word MoneyChest8  ; 77
.word MoneyChest9  ; 78
.word MoneyChest10 ; 79
.word MoneyChest11 ; 7A
.word MoneyChest12 ; 7B
.word MoneyChest13 ; 7C
.word MoneyChest14 ; 7D
.word MoneyChest15 ; 7E
.word MoneyChest16 ; 7F
.word MoneyChest17 ; 80
.word MoneyChest18 ; 81
.word MoneyChest19 ; 82
.word MoneyChest20 ; 83
.word MoneyChest21 ; 84
.word MoneyChest22 ; 85
.word MoneyChest23 ; 86
.word MoneyChest24 ; 87
.word MoneyChest25 ; 88
.word MoneyChest26 ; 89
.word MoneyChest27 ; 8A
.word MoneyChest28 ; 8B
.word MoneyChest29 ; 8C
.word MoneyChest30 ; 8D
.word MoneyChest31 ; 8E
.word MoneyChest32 ; 8F
.word MoneyChest33 ; 90
.word MoneyChest34 ; 91
.word MoneyChest35 ; 92
.word MoneyChest36 ; 93
.word MoneyChest37 ; 94
.word MoneyChest38 ; 95
.word MoneyChest39 ; 96
.word MoneyChest40 ; 97
.word MoneyChest41 ; 98
.word MoneyChest42 ; 99
.word MoneyChest43 ; 9A
.word MoneyChest44 ; 9B
.word MoneyChest45 ; 9C
.word MoneyChest46 ; 9D
.word MoneyChest47 ; 9E
.word MoneyChest48 ; 9F
.word MoneyChest49 ; A0
.word MoneyChest50 ; A1
.word MoneyChest51 ; A2
.word MoneyChest52 ; A3
.word MoneyChest53 ; A4
.word MoneyChest54 ; A5
.word MoneyChest55 ; A6
.word MoneyChest56 ; A7
.word MoneyChest57 ; A8
.word MoneyChest58 ; A9
.word MoneyChest59 ; AA
.word MoneyChest60 ; AB
.word MoneyChest61 ; AC
.word MoneyChest62 ; AD
.word MoneyChest63 ; AE
.word MoneyChest64 ; AF
.word MoneyChest65 ; B0
.word MoneyChest66 ; B1
.word MoneyChest67 ; B2
.word MoneyChest68 ; B3
.word MoneyChest69 ; B4
.word MoneyChest70 ; B5
.word MoneyChest71 ; B6
.word MoneyChest72 ; B7
.word MoneyChest73 ; B8
.word MoneyChest74 ; B9
.word MoneyChest75 ; BA
.word MoneyChest76 ; BB
.word MoneyChest77 ; BC
.word MoneyChest78 ; BD
.word MoneyChest79 ; BE
.word MoneyChest80 ; BF

My treasure table looks like this so far:
Code: [Select]
lut_Treasure:
.byte $00, $00      ; 00 ; "Unused" ;
.byte $02, ARMOR4   ; 01 ; "Coneria 1" ; Iron Armor
.byte $02, $55      ; 02 ; "Coneria 2" ; Iron shield
.byte $01, TNT      ; 03 ; "Coneria 3" ; TNT
.byte $02, $26      ; 04 ; "Coneria 4" ; Iron staff
.byte $02, $27      ; 05 ; "Coneria 5" ; Sabre
.byte $02, $2B      ; 06 ; "Coneria 6" ; Silver knife
.byte $01, CABIN    ; 07 ; "Temple of Fiends 1" ; Cabin
.byte $01, HEAL     ; 08 ; "Temple of Fiends 2" ; Heal
.byte $02, $5D      ; 09 ; "Temple of Fiends 3" ; Cap
.byte $02, $36      ; 0A ; "Temple of Fiends 4" ; Rune sword
.byte $02, $35      ; 0B ; "Temple of Fiends 5" ; Were sword
.byte $01, SOFT     ; 0C ; "Temple of Fiends 6" ; Soft
.byte $02, $2D      ; 0D ; "Elfland 1" ; Silver helm
.byte $00, $81      ; 0E ; "Elfland 2" ; 400 g
.byte $00, $7E      ; 0F ; "Elfland 3" ; 330 g
.byte $02, $65      ; 10 ; "Elfland 4" ; Copper gloves
.byte $02, $37      ; 11 ; "NorthWest Castle 1" ; Power staff
.byte $02, $66      ; 12 ; "NorthWest Castle 2" ; Iron gloves
.byte $02, $2A      ; 13 ; "NorthWest Castle 3" ; Falchon
.byte $00, $7B      ; 14 ; "Marsh Cave 1" ; 259 g
.byte $00, $4E      ; 15 ; "Marsh Cave 2" ;
.byte $01, HOUSE    ; 16 ; "Marsh Cave 3" ; House
.byte $00, $80      ; 17 ; "Marsh Cave 4" ;
.byte $00, $86      ; 18 ; "Marsh Cave 5" ;
.byte $00, $21      ; 19 ; "Marsh Cave 6" ;
.byte $00, $87      ; 1A ; "Marsh Cave 7" ;
.byte $00, $25      ; 1B ; "Marsh Cave 8" ;
.byte $01, CROWN    ; 1C ; "Marsh Cave 9" ; CROWN

I was gonna make it really easy to edit by putting like, WEAPON1, WEAPON2, etc, in Constants. Maybe even sub-categorize that, so its KNIFE1, SWORD1, HAMMER1, STAFF1, and so on for weapons, and BODY1, HEAD1, ARMS1 and such for armors.

Just having the original item for reference in a list would be a big help, so don't go out of your way to convert it all perfectly unless... that's fun for you? XD
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on March 15, 2019, 01:08:27 pm
Okay well I got lazy and scrapped the idea of doing the conversion and just have the labels and item names:

Code: [Select]
Unused                 -
Coneria 1              - Iron   Armor
Coneria 2              - Iron   Shield
Coneria 3              - TNT   
Coneria 4              - Iron   Staff
Coneria 5              - Sabre 
Coneria 6              - Silver Knife
Temple of Fiends 1     - CABIN 
Temple of Fiends 2     - HEAL Potion
Temple of Fiends 3     - Cap   
Temple of Fiends 4     - Rune   Sword
Temple of Fiends 5     - Were   Sword
Temple of Fiends 6     - SOFT Potion 
Elfland 1              - Silver Hammer
Elfland 2              - 400 G
Elfland 3              - 330 G
Elfland 4              - Copper Gauntlets
NorthWest Castle 1     - Power  Staff
NorthWest Castle 2     - Iron   Gauntlets
NorthWest Castle 3     - Falchon
Marsh Cave 1           - 295 G
Marsh Cave 2           - Copper Bracelet
Marsh Cave 3           - HOUSE 
Marsh Cave 4           - 385 G
Marsh Cave 5           - 620 G
Marsh Cave 6           - Short  Sword
Marsh Cave 7           - 680 G
Marsh Cave 8           - Large  Knife
Marsh Cave 9           - CROWN 
Marsh Cave 10          - Iron   Armor
Marsh Cave 11          - Silver Bracelet
Marsh Cave 12          - Silver Knife
Marsh Cave 13          - 1020 G
Dwarf Cave 1           - 450 G
Dwarf Cave 2           - 575 G
Dwarf Cave 3           - CABIN 
Dwarf Cave 4           - Iron   Helmet
Dwarf Cave 5           - Wooden Helmet
Dwarf Cave 6           - Dragon Sword
Dwarf Cave 7           - Silver Knife
Dwarf Cave 8           - Silver Armor
Dwarf Cave 9           - 575 G
Dwarf Cave 10          - HOUSE 
Matoya's Cave 1        - HEAL Potion
Matoya's Cave 2        - PURE Potion
Matoya's Cave 3        - HEAL Potion
Earth Cave 1           - 880 G
Earth Cave 2           - HEAL Potion
Earth Cave 3           - PURE Potion
Earth Cave 4           - 795 G
Earth Cave 5           - 1975 G
Earth Cave 6           - Coral  Sword
Earth Cave 7           - CABIN 
Earth Cave 8           - 330 G
Earth Cave 9           - 5000 G
Earth Cave 10          - Wooden Shield
Earth Cave 11          - 575 G
Earth Cave 12          - 1020 G
Earth Cave 13          - 3400 G
Earth Cave 14          - TENT   
Earth Cave 15          - HEAL Potion
Earth Cave 16          - RUBY   
Earth Cave 17          - 1250 G
Earth Cave 18          - Silver Shield
Earth Cave 19          - CABIN 
Earth Cave 20          - 5450 G
Earth Cave 21          - 1520 G
Earth Cave 22          - Wooden Staff
Earth Cave 23          - 3400 G
Earth Cave 24          - 1455 G
Titan's Tunnel 1       - Silver Helmet
Titan's Tunnel 2       - 450 G
Titan's Tunnel 3       - 620 G
Titan's Tunnel 4       - Great  Axe
Gurgu Volcano 1        - HEAL Potion
Gurgu Volcano 2        - CABIN 
Gurgu Volcano 3        - 1975 G
Gurgu Volcano 4        - PURE Potion
Gurgu Volcano 5        - HEAL Potion
Gurgu Volcano 6        - 1455 G
Gurgu Volcano 7        - Silver Shield
Gurgu Volcano 8        - 1520 G
Gurgu Volcano 9        - Silver Helmet
Gurgu Volcano 10       - Silver Gauntlets
Gurgu Volcano 11       - 1760 G
Gurgu Volcano 12       - Silver Axe
Gurgu Volcano 13       - 795 G
Gurgu Volcano 14       - 750 G
Gurgu Volcano 15       - Giant  Sword
Gurgu Volcano 16       - 4150 G
Gurgu Volcano 17       - 1520 G
Gurgu Volcano 18       - Silver Helmet
Gurgu Volcano 19       - SOFT Potion 
Gurgu Volcano 20       - 2750 G
Gurgu Volcano 21       - 1760 G
Gurgu Volcano 22       - Wooden Staff
Gurgu Volcano 23       - 1250 G
Gurgu Volcano 24       - 10 G
Gurgu Volcano 25       - 155 G
Gurgu Volcano 26       - HOUSE 
Gurgu Volcano 27       - 2000 G
Gurgu Volcano 28       - Ice    Sword
Gurgu Volcano 29       - 880 G
Gurgu Volcano 30       - PURE Potion
Gurgu Volcano 31       - Flame  Shield
Gurgu Volcano 32       - 7340 G
Gurgu Volcano 33       - Flame  Armor
Ice Cave 1             - HEAL Potion
Ice Cave 2             - 10000 G
Ice Cave 3             - 9500 G
Ice Cave 4             - TENT   
Ice Cave 5             - Ice    Shield
Ice Cave 6             - Cloth 
Ice Cave 7             - Flame  Sword
Ice Cave 8             - FLOATER
Ice Cave 9             - 7900 G
Ice Cave 10            - 5450 G
Ice Cave 11            - 9900 G
Ice Cave 12            - 5000 G
Ice Cave 13            - 180 G
Ice Cave 14            - 12350 G
Ice Cave 15            - Silver Gauntlets
Ice Cave 16            - Ice    Armor
Castle of Ordeal 1     - Zeus   Gauntlets
Castle of Ordeal 2     - HOUSE 
Castle of Ordeal 3     - 1455 G
Castle of Ordeal 4     - 7340 G
Castle of Ordeal 5     - Gold   Bracelet
Castle of Ordeal 6     - Ice    Sword
Castle of Ordeal 7     - Iron   Gauntlets
Castle of Ordeal 8     - Heal   Staff
Castle of Ordeal 9     - TAIL   
Cardia 1               - 1455 G
Cardia 2               - 2000 G
Cardia 3               - 2750 G
Cardia 4               - 2750 G
Cardia 5               - 1520 G
Cardia 6               - 10 G
Cardia 7               - 500 G
Cardia 8               - HOUSE 
Cardia 9               - 575 G
Cardia 10              - SOFT Potion 
Cardia 11              - CABIN 
Cardia 12              - 9500 G
Cardia 13              - 160 G
Not Used 1             - 530 G
Not Used 2             - Small  Knife
Not Used 3             - Cap   
Not Used 4             - Zeus   Gauntlets
Sea Shrine 1           - Ribbon 
Sea Shrine 2           - 9900 G
Sea Shrine 3           - 7340 G
Sea Shrine 4           - 2750 G
Sea Shrine 5           - 7690 G
Sea Shrine 6           - 8135 G
Sea Shrine 7           - 5450 G
Sea Shrine 8           - 385 G
Sea Shrine 9           - Power  Gauntlets
Sea Shrine 10          - Light  Axe
Sea Shrine 11          - 9900 G
Sea Shrine 12          - 2000 G
Sea Shrine 13          - 450 G
Sea Shrine 14          - 110 G
Sea Shrine 15          - Light  Axe
Sea Shrine 16          - Opal   Armor
Sea Shrine 17          - 20 G
Sea Shrine 18          - Mage   Staff
Sea Shrine 19          - 12350 G
Sea Shrine 20          - 9000 G
Sea Shrine 21          - 1760 G
Sea Shrine 22          - Opal   Bracelet
Sea Shrine 23          - 2750 G
Sea Shrine 24          - 10000 G
Sea Shrine 25          - 10 G
Sea Shrine 26          - 4150 G
Sea Shrine 27          - 5000 G
Sea Shrine 28          - PURE Potion
Sea Shrine 29          - Opal   Shield
Sea Shrine 30          - Opal   Helmet
Sea Shrine 31          - Opal   Gauntlets
Sea Shrine 32          - SLAB   
Waterfall 1            - Wizard Staff
Waterfall 2            - Ribbon 
Waterfall 3            - 13450 G
Waterfall 4            - 6400 G
Waterfall 5            - 5000 G
Waterfall 6            - Defense
Not Used 5             - HEAL Potion
Not Used 6             - HEAL Potion
Not Used 7             - HEAL Potion
Not Used 8             - HEAL Potion
Not Used 9             - HEAL Potion
Not Used 10            - HEAL Potion
Not Used 11            - HEAL Potion
Not Used 12            - HEAL Potion
Not Used 13            - HEAL Potion
Mirage Tower 1         - Aegis  Shield
Mirage Tower 2         - 2750 G
Mirage Tower 3         - 3400 G
Mirage Tower 4         - 18010 G
Mirage Tower 5         - CABIN 
Mirage Tower 6         - Heal   Helmet
Mirage Tower 7         - 880 G
Mirage Tower 8         - Vorpal
Mirage Tower 9         - HOUSE 
Mirage Tower 10        - 7690 G
Mirage Tower 11        - Sun    Sword
Mirage Tower 12        - 10000 G
Mirage Tower 13        - Dragon Armor
Mirage Tower 14        - 8135 G
Mirage Tower 15        - 7900 G
Mirage Tower 16        - Thor   Hammer
Mirage Tower 17        - 12350 G
Mirage Tower 18        - 13000 G
Sky Palace 1           - 9900 G
Sky Palace 2           - HEAL Potion
Sky Palace 3           - 4150 G
Sky Palace 4           - 7900 G
Sky Palace 5           - 5000 G
Sky Palace 6           - ProRing
Sky Palace 7           - 6720 G
Sky Palace 8           - Heal   Helmet
Sky Palace 9           - 180 G
Sky Palace 10          - Bane   Sword
Sky Palace 11          - White  Shirt
Sky Palace 12          - Black  Shirt
Sky Palace 13          - Ribbon 
Sky Palace 14          - Opal   Gauntlets
Sky Palace 15          - Opal   Shield
Sky Palace 16          - Silver Helmet
Sky Palace 17          - HOUSE 
Sky Palace 18          - 880 G
Sky Palace 19          - 13000 G
Sky Palace 20          - ADAMANT
Sky Palace 21          - 4150 G
Sky Palace 22          - SOFT Potion 
Sky Palace 23          - 3400 G
Sky Palace 24          - Katana
Sky Palace 25          - ProCape
Sky Palace 26          - Cloth 
Sky Palace 27          - 9500 G
Sky Palace 28          - SOFT Potion 
Sky Palace 29          - 6400 G
Sky Palace 30          - 8135 G
Sky Palace 31          - 9000 G
Sky Palace 32          - HEAL Potion
Sky Palace 33          - ProRing
Sky Palace 34          - 5450 G
ToF Revisited 1        - Masmune
ToF Revisited 2        - 26000 G
ToF Revisited 3        - Katana
ToF Revisited 4        - ProRing
ToF Revisited 5        - ProCape
ToF Revisited 6        - 45000 G
ToF Revisited 7        - 65000 G
Unused                 -

If you want the Python scripts so you can tweak them, lemme know.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 15, 2019, 04:31:56 pm
I don't know how to use python, but this is perfect! Thank you! :D

I'm working on the item menu now... I've got it loading an item's name, then putting all the text blocks into RAM, then printing from that RAM address. Hopefully by time I've got the scroll offset stuff in place, it will be able to print the whole screen in a single V-blank or two!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on March 15, 2019, 04:59:10 pm
I don't know how to use python

I absolutely love it.

Only on RHDN would someone know 6502 assembly, but not Python.   :laugh:

Anyway, happy to help!  This is a cool project you got going on.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 16, 2019, 12:04:03 am
It still took two hours to do the conversions and re-enter all the bytes... but could have been longer.

(https://cdn.discordapp.com/attachments/527351555779723266/556274546177736715/unknown.png)

Here's a peek! This layout allows 16 items per page. Since you never have more than 16 key items at any one time--using the Herb and TNT and things remove them before you can pick up more--it will never need more space than that. If someone DOES edit the game to add more key items, then they've got the ability to make a third page. Pressing select swaps between consumables and key items.

Now coding in using consumables in the menu... then have to figure out battle use. *cry* X-Heal, Elixir, and Phoenix Down should work as intended (if tmp+2 isn't being used while using heal potions), but Ether is going to need some market research. Need to make a new screen that shows MP and then lets you pick a level to refill. Or should it straight up refill all the character's MP across all levels?

Smokebomb: should it stop enemy encounters for X steps, or just lower them further? In battle, it will put all characters into hiding on use. The horn will wake all characters from sleep. Oh, I should rename that to WakeBell or something...

Is there any benefit to using @Local labels, or is that just for organization? Does it save a byte when they're used or something?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on March 16, 2019, 04:23:54 am
Quote
Is there any benefit to using @Local labels, or is that just for organization?

You say that as if organization isn't a benefit!

Local variables are a scope restriction.  Scope restrictions avoid name conflicts.  Having scopes allows you to not worry about making every single identifier name 100% unique.  For example, you can have a local "@Loop" label, but a global "Loop" label would probably be disastrous.  Or having a local variable named "@box_x" might be useful for a box drawing routine, but having a global "box_x" label would be less useful, since different routines might use different areas for that variable.

Honestly I wish I used local variables more.  I didn't really take full advantage of them until I got near the end of the disassembly.  Instead, I made that wretched "tmp" space that is horribly unclear.

Quote
Does it save a byte when they're used or something?

Nope.  The final binary is the same.  They're really just there to avoid name conflicts and keep identifiers scope restricted.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 16, 2019, 08:12:14 am
Here's a peek! This layout allows 16 items per page. Since you never have more than 16 key items at any one time--using the Herb and TNT and things remove them before you can pick up more--it will never need more space than that. If someone DOES edit the game to add more key items, then they've got the ability to make a third page. Pressing select swaps between consumables and key items.

Any chance that it could be changed to a mini menu instead of a button press?
Like Final Fantasy 5 & 6 but without the Sort command.
Also, what do you mean by having the ability to add a third page exactly?


Quote
Now coding in using consumables in the menu... then have to figure out battle use. *cry* X-Heal, Elixir, and Phoenix Down should work as intended (if tmp+2 isn't being used while using heal potions), but Ether is going to need some market research. Need to make a new screen that shows MP and then lets you pick a level to refill. Or should it straight up refill all the character's MP across all levels?

I'd keep it simple and have it refill all spell levels at once.
Why make a whole new screen from something as mundane as restoring spell charges when you could use the time and space to do something more interesting?

I'd nix the whole spell level thing entirely like they did in Dawn of Souls and Anniversary Edition.
You'd only need to track one byte or two of MP as opposed to 8 of spell charges and maybe have a separate spell level stat so the game can restrict access to spells of higher levels than a character would be able to cast. Still, that would give you like another 5 free bytes for each character's stats, no?


Quote
Smokebomb: should it stop enemy encounters for X steps, or just lower them further? In battle, it will put all characters into hiding on use. The horn will wake all characters from sleep. Oh, I should rename that to WakeBell or something...

Wakeup Bell would be a nice reference to Bravely Default (which is arguably the true continuation of classic Final Fantasy) if it can fit.
One thing , though, just about every version of the Alarm Clock / Wakeup Bell is a single target item.
Might be better to follow suit, plus how often is most of the party going to asleep all at once to justify sitting through the 4 messages that would trigger on each party member?

As for the Smoke Bomb (should be 2 words), while making everyone hide is a pretty cool idea, it does buck tradition a bit from what it does in every other game in the series.
That said, maybe Smoke Screen would be a better name for it instead?
A single smoke bomb is usually enough for a single person to escape or hide, but a smoke screen by definition implies a larger scale situation like hiding the whole party.
I'm not to sure about having an item that manipulates the encounter rate in a game that already lets you do that through a menu option.
So I would have to go with completely preventing enemy encounters for a noticeable number of steps, or maybe even straight up until the next time you use a warp tile to switch maps.

You may also want to consider having both a Smoke Bomb and a Smoke Screen.
Having a traditional Smoke Bomb item might be very useful if all your casters are dead or you are playing with an all martial team.
I'm thinking it would function like the warp spell out of battle, and it would have a 100% escape effect in battle.

Anyway, great work on the item menu so far. Can't wait to try it out for myself. :cheers:
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 19, 2019, 08:16:25 pm
Nope.  The final binary is the same.  They're really just there to avoid name conflicts and keep identifiers scope restricted.
Ooh, good to know. I've been moving so many little things around, wondering if it will make a difference--hoping it does, because that's the point.

Any chance that it could be changed to a mini menu instead of a button press?

Why not both?

Consumables:
(https://cdn.discordapp.com/attachments/294356735714394112/557711267981164564/Capture.PNG)
Elixir Screen:
(https://cdn.discordapp.com/attachments/294356735714394112/557711516326166539/unknown.png)
Ether Screen:
(https://cdn.discordapp.com/attachments/294356735714394112/557715111138033697/unknown.png)

I went with Wakeup Bell because Alarm clocks just... don't make sense? And I couldn't figure out what kind of horn icon to make. Birthday party horn? Big tuba? Keeping Smoke bomb because of the 8 character limit (12 for key items.) Could be 9, but it would look ugly pressing up against the numbers...

Ultimate goal is probably VWF, but that's... like, the last thing, maybe.

I want to make the sleep ailment more dangerous. I've made it harder to wake up from than stun, and I made it use the death pose, have 'em all zonked out. I don't think I've EVER been put to sleep in the original game, so I'd like to see more enemies use it.

I might be the only one who really likes the MP per level system... It definitely adds some strategy and difficulty that's different than just making enemies have more health. Saving up your biggest spells for the boss, or using them on those #@&!%in' sorcerers in the ice cave and the ghosts in the  underwater palace? Being forced to fall back on lower-level spells makes you feel desperate and in danger, instead of spamming ethers and your highest spell. So thinking on that, I decided refilling the whole MP pool was a little OP. Elixirs do it, but if I was going to re-design the dungeons and everything, you'd get maybe 5 of them in the whole game...

I updated all the shops to use the new item IDs, did a bit more cleanup of things here and there--its all blurry now. Re-wrote item messages to be simpler. CURE spells now use the same message as Heal and X-Heal, things like that. As you can see in the screenshot, tents, cabins, and houses now have a confirmation before use, and so should the WARP and EXIT spells.

Next steps:
Implement code for smoke bombs...
Magic swapping...
And finally delve into adding the new items in battle.

Edit: Oh, yeah, finally fixed the weird sluggishness in the Options menu. Turns out drawing the text every frame was ... happening. Now it only updates when it needs to.

I'm still unsure about how to update things with github so I'm gonna try to finish a few more things before putting the changes up...?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on March 19, 2019, 08:56:38 pm
I assume that's supposed to be Phoenix Down, but since you used the icon for down it ends up reading like "Down down"   :laugh:


Quote
I'm still unsure about how to update things with github so I'm gonna try to finish a few more things before putting the changes up...?


I assume you have git installed?  From a command prompt in your project's root directory:
Code: [Select]
git add .
git commit -m "Put a message here to indicate what you changed with this commit"
git push

'add .' adds all changed files to the list of files to be committed.
'commit' actually commits them (basically saves/backs them up).  Note that commit only commits locally (does not update github)
'push' pushes the committed changes to the remote repo (updates github)


...

But really, I recommend just getting a gui program like SmartGit (free for noncommercial use).  It shows you what files you've changed, and you can just click a button to push them.

(https://i.imgur.com/9RMRp52.png)

Hardest part will be setting SmartGit up to work with your repo, but that's a one time thing and once you figure it out it's pretty easy to do it again.  It has a wizard that sort of walks you through it but if you are completely unfamiliar with git you might not understand some of the lingo.


If you have uncommitted changes it might be tricky.  Here's what I'd do to set up SmartGit:

1 )  Move your entire project directory somewhere else (or just rename the directory it's in).  So the directory where you want your project is entirely empty.
2 )  From SmartGit, Go in the 'Repository' menu, and select 'Clone'
3 )  Follow the prompts.  Select "Remote Git Repository" and give it the URL to your github page
4 )  All the "Selection" stuff can be left to their defaults
5 )  And the "Local Directory" is where you want your project to be
6 )  Once done, it'll clone what was pushed to your repo (what is currently on github)
7 )  Copy/paste your more recently modified files over that (but do NOT copy any hidden '.git/' folders)
8 )  Use SmartGit to commit/push


Note I'm making this all sound a lot more complicated than it is.  It's actually really easy once you do it.  It's only really tricky because of the unpushed changes.  If you push everything with git first, then you can just delete your local copy and do only steps 2-6 above.



EDIT:

As for a few good git practices once you have things set up:

1 ) Don't work directly out of your master.  Whenever you are working on something, branch off of master into a new branch (commonly referred to as a "feature branch").  Try to keep master in stable/working condition at all times.  That way if something REALLY gets hecked up, you can very easily toss your feature branch and fall back to master.

2 ) Commit to your feature branch very frequently.  Keep commits small and keep them frequent.  Once a day at the VERY LEAST (assuming you did work that day).  Often, do more.  Basically any meaningful incremental change should be its own commit.  Each commit is effectively a full backup, and is as easy as a button press.  So if something gets broken, you can easily roll back to see where the problem started.

3 ) Merge your feature branch(es) back into master when you're confident they're stable.  Basically the feature branch gets the small incremental changes you made when adding the feature, and the merge from feature->master is the full & complete feature/bugfix.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 19, 2019, 10:54:25 pm
I want to make the sleep ailment more dangerous. I've made it harder to wake up from than stun, and I made it use the death pose, have 'em all zonked out. I don't think I've EVER been put to sleep in the original game, so I'd like to see more enemies use it.

That doesn't really make sense to me.

Sleep is supposed to be less serious than stun.
I've always viewed the sleep ailment as just being put into a state of rest, that is why in most of the rest of the series you can wake up after taking a physical hit.

Stun, on the other hand, is actually paralysis in the original Japanese.
It is used for both the Hold and Stop spells and is most definitely seems intended to be the more serious condition.
Even the formulas that determine if you wake up each round support this with sleep being progressively easier to wake up from as your HP increases

Changing it to use the death pose sounds like a good idea. That does make more sense.

Not being put to sleep often was definitely not my experience, though I will admit that I remember clearly getting stunned a hell of a lot more often.

I think that changing sleep to not be dependent on max HP would be a good idea.
Maybe having a few more enemies cause it is fine too, as long as you don't go overboard.
However, I'd also suggest that you have physical damage remove sleep like in the later games.
But elevating it above stun seems too drastic, and potentially balance breaking.
And, honestly, stun is already annoying enough without piling sleep into that category.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 20, 2019, 06:01:15 pm
Currently, enemies have a 25% chance to recover from stuns, and a 10% chance to recover from sleep. Maybe that's what I was thinking of. Players have a 50% chance to wake, and 25% chance to get over a stun. I did do away with max HP helping with waking up.

Hm. You give a good argument. My thought was that sleeping is a deeper unconscious state, and that a stun was like a whack on the head that should be shaken off easier. But waking from sleep on getting hit is something I can and should do, so maybe the Bell could be like... Something to recover from a stun. Should it still be party-wide? Because its an ailment that you can randomly recover from, and turn order is randomized instead of more active-time, I was thinking it would just be double frustration to try and cure something when it gets shaken off the same turn--thus wasting two characters' turns. Whereas if it affects the whole party, you're using one turn to regain three. If it WAS an alarm clock type item, also, it could be set to occur on turn-end, so its more a pre-emptive use situation! Which would be more fun and clever than just being reactive to something after the fact.

(And that's my complaint about ailments in just about any game; its not just something that debilitates my stats, but its something that basically cancels not just one turn, but the turn needed to undo it as well, dragging out battles without giving a whole lot of strategy. Which is another point to Bravely Default, in that there were abilities that depended on enemies having those ailments, and ailments actually hit most enemies, making it a strategy that was sometimes BETTER than mashing the fight command..

I assume that's supposed to be Phoenix Down, but since you used the icon for down it ends up reading like "Down down"   :laugh:

Whups... yeah. I changed it to PhoenixF where F is the feather icon, and looks better now!

I got GitHub desktop installed (Windows 7), I just wasn't sure how to manage things with it. I'm going to work on getting the master thingy stable, since I'm making big, sweeping changes to the organization of the banks and everything, and then start working on updating all the little changes from there on out.

Thanks for the advice. :D
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 21, 2019, 02:20:26 am
Currently, enemies have a 25% chance to recover from stuns, and a 10% chance to recover from sleep. Maybe that's what I was thinking of. Players have a 50% chance to wake, and 25% chance to get over a stun. I did do away with max HP helping with waking up.

Yeah, there is some wierdness with the recovery chances for these.
I think the most reasonable thing to have that is not far off from what the original code intended is for players to wake up from sleep with a base 20% chance + a bonus = Intellect/4.
The chance for an enemy would be the same except it would be a bonus from Magic Defense instead of Intellect because they lack the Intellect stat.
Stun should, IMO, be a fixed number of rounds instead of a percent chance to recover automatically.
That would require the use of few bytes of RAM to use as status counters.


Quote
Hm. You give a good argument. My thought was that sleeping is a deeper unconscious state, and that a stun was like a whack on the head that should be shaken off easier.

Thanks. I had a similar thought initially, but then I remembered a bunch of translation research I did for the game and verified that Stun is actually called Paralysis in the original Japanese text and that it is used as a stun, paralysis, and stop ailment depending on which element it is paired with.


Quote
But waking from sleep on getting hit is something I can and should do,

I support that 1000%.


Quote
so maybe the Bell could be like... Something to recover from a stun.

It would need a different name because of the variety of effects that the stun ailment represents.
What sort of thing could recover you from being knocked out cold, held in place, and negate time being stopped around you?


Quote
Should it still be party-wide? Because its an ailment that you can randomly recover from, and turn order is randomized instead of more active-time, I was thinking it would just be double frustration to try and cure something when it gets shaken off the same turn--thus wasting two characters' turns. Whereas if it affects the whole party, you're using one turn to regain three. If it WAS an alarm clock type item, also, it could be set to occur on turn-end, so its more a pre-emptive use situation! Which would be more fun and clever than just being reactive to something after the fact.

Affecting the whole party seems reasonable to me.


Quote
(And that's my complaint about ailments in just about any game; its not just something that debilitates my stats, but its something that basically cancels not just one turn, but the turn needed to undo it as well, dragging out battles without giving a whole lot of strategy. Which is another point to Bravely Default, in that there were abilities that depended on enemies having those ailments, and ailments actually hit most enemies, making it a strategy that was sometimes BETTER than mashing the fight command..

I agree.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 21, 2019, 04:20:00 am
It would need a different name because of the variety of effects that the stun ailment represents.
What sort of thing could recover you from being knocked out cold, held in place, and negate time being stopped around you?

Now that's something I never realized, different stun elements supposed to be different things entirely. Who knows, maybe I'll eventually get around to making a bunch of different ailments based on timers. I already have plans to make a healing spell that heals a bit per round, like regenerating enemies--would use the high bits of the Hidden byte, and subtract $10 every turn, then stop when it hits 0. There's definitely RAM space for some multi-purpose in-battle spell variables of that sort.

I completely broke the options menu. I think I just need to re-write it from scratch. Try to stick it in the Menu bank once I'm done with this.

(https://cdn.discordapp.com/attachments/527351555779723266/558194535193116672/unknown.png)

Forgetting a spell works 100% now. There's 64 bytes after the key items for spells to be stored in their own inventory. I'll make it so buying a spell just puts it in the inventory (caps out at 4; why would you need more?) The Learn option doesn't do anything yet. I need to think of how the screen should look. Spells are 6 letters long, there's 30 tiles inside the box borders, and the cursor needs 2 tiles to not cover letters. I guess there's no helping it, though. The smartest thing to do would be to split it into White and Black magic screens, 4 spells per line, with 1 tile of space between, and have the cursor blocking some letters. Still need the space at the bottom to display things like "That spell level is full" and "you can't learn that"...

Meanwhile, items in the battle menus. 10 consumable items, but the limit is 8 per menu. My thoughts:
Screw the way FF1 does battle boxes for this. Put the names of items that exist into RAM and draw from an offset. 10 items x 8 letters, 1 space, 2 numbers, then line break control code that can be swapped with a terminator. $78 space in RAM, so the printing start point doesn't have to be stupidly far like it did with the main menu item screen. Then scrolling through items just uses the usual drawing routine. I think I should be able to handle that...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 21, 2019, 01:14:45 pm
A regen spell sounds like a great addition!
As for ailments, The game could really uses at least one more full set of 8 to flesh them out properly and eliminate the need for double duty status. I suppose the easiest way to do that would be to add a new spell effect that has a different set of status ailments.

What is the Hidden Byte? That isn't the Magic Defense byte, is it?

Love the WIP magic menu!
If you mean you can't buy more than 4 iterations of the same spell, then yeah, there's never going to be a need for more than 4 of any spell in any given play-through.

A few thoughts on the text layout of the magic menu...

I don't think you should worry about the cursor overlapping any text as long as it doesn't overlap the spell name it's pointing at.

Do you really need the spell charges to be displayed on the menu directly? The game already shows you your current MP on the main menu and it tells you if a spell has run out of MP when you try to use it as well.

(Come to think of it, this could be one of the reasons the series switched over to a single MP pool; so that it would be less hassle to display current and max MP on the main menu.)

Anyway, it might be better to move the current/max MP over to the status menu in order to save space here.

Also, you have that message box at the bottom to work with. Why not have it there permanently (maybe even expand it to go all the way across the screen) and use it to display the current/max MP as well as a a short description? Plus it might speed things up if it isn't rewriting the whole message box every time it needs to tell you something.

As for the actual spell inventory, splitting it up into White and Black magic is a good idea.

Another option is to do away with individual spell purchases.
You'd increase the cost of buying a spell (2x cost is probably a good median value) and then have it so any character can learn the spell by copying it from the inventory.
Now spells in FF would be more like how spell books are in D&D.
You buy a spell scroll and then any character, that can learn the spell, can copy it to their spell book.
The Learn command would add the spell, but not remove it from inventory.
The Forget command would remove the spell, but not add it to the inventory.
That way you don't have to worry about having multiple copies of a spell in the inventory.
Plus, it would help simplify the magic shops too.

On a side note: It might be a good idea to then also grey out spells on the shop lists that are already in your inventory. That way the player doesn't need to keep track of which spells have been purchased. And then when all the spells have been purchased you could have a message saying, "There is nothing more I can teach you."

You can also maintain the 3 column set up by manipulating the font palette in the inventory.
Display spells your job can learn for the selected level as normal, but the rest are grayed out.
That way you don't have to worry about fitting all the spells of a given level on one line nor restrict them to 6 characters.

Alternatively, you could try only displaying the spells that correspond to the level you selected to learn.

I agree with screwing the way FF does battle boxes! They are definitely too restrictive. Any improvement on that front is welcome.

EDIT:
Here's a list of all of the status ailments and element combinations:
Code: [Select]
Sleep    = sleep   + stun = sleep
Mute     = mute    + stun = mute
Dark     = dark    + stun = blind
Hold     = stun    + stun = paralysis
Confuse  = confuse + stun = confuse
Stun     = stun*   + stun = paralysis
Blind    = dark*   + stun = blind
Gaze     = stun    + stun = paralysis
Flash    = dark    + stun = blind
Snorting = dark    + stun = blind
Ink      = dark    + stun = blind
Dazzle   = stun    + stun = paralysis

[*these two use 'negative effect 2']
[-stun (the element) is basically the weak status element.]

Bane       = death  + bane = deadly poison
Break      = stone  + bane = petrification
Glance     = stone  + bane = petrification
Poison (1) = stone  + bane = petrification
Stinger    = poison + bane = poison

[-bane is basically the strong status element.]

Rub    = death + confuse = death
XXXX   = death + confuse = death
Squint = death + confuse = death
Toxic  = death + confuse = deadly poison (should have been bane element?)

[-confuse (the element) is basically the exclusive death element, kinda redundant really.]

Quake = death + earth = bottomless pit
Crack = death + earth = bottomless pit

[-earth is basically used to make flying enemies immune to ground based effects.]

Stop  = stun  + dark = stop
Zap!  = death + dark = banish
Glare = death + dark = death (should have been confuse element?)

[-dark (the element) is basically the time element.]

Sleep2 = sleep + none = sleep
Trance = stun  + none = paralysis

[-these two are the strongest status spells in the game because there is no way to prevent them.]

Here's a list of all of the double duty status ailments:
Code: [Select]
Hold   = stun  + stun = paralysis
Stun   = stun* + stun = paralysis
Gaze   = stun  + stun = paralysis
Dazzle = stun  + stun = paralysis
Trance = stun  + none = paralysis
Stop   = stun  + dark = stop

Bane   = death + bane    = deadly poison
Toxic  = death + confuse = deadly poison (should have been bane element?)
Rub    = death + confuse = death
XXXX   = death + confuse = death
Squint = death + confuse = death
Glare  = death + dark    = death (should have been confuse element?)
Quake  = death + earth   = bottomless pit
Crack  = death + earth   = bottomless pit
Zap!   = death + dark    = banish

As you can see, the usage of status ailments and elements in the game is a pretty big mess.
Much of it is artifacts left over from what amounts to copying the spells from old school D&D.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on March 21, 2019, 05:52:54 pm
(Come to think of it, this could be one of the reasons the series switched over to a single MP pool; so that it would be less hassle to display current and max MP on the main menu.)
Switched to single MP pool for FF2, switched back to a per-level MP pool (with 2 digits) for FF3, and then single pool after that.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 22, 2019, 12:07:35 am
Lessons often need to be taught twice before we learn.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 22, 2019, 04:07:53 pm
Hah! Like I'll ever learn!

It turns out spells are 7 letters long, not 6, so fitting 4 in a row was impossible. Fitting 8 in a column IS possible, though, so...

https://www.youtube.com/watch?v=dHZGsJkMJZo&feature=youtu.be

I made a movie showing the swapping. Its hard to tell, but pressing right and left is what changes the screens!

(https://cdn.discordapp.com/attachments/300491322895368192/558741852640247808/unknown.png)

And I've since added arrows to show when you can swap.

The black and white orbs are only shown on this screen. There's really no room for them in the normal magic screen (at the moment; the idea of putting the MP in the description box is a nice one!), and they're unnecessary in shops (though there is room for one more tile in the shop listing.)

"What is the Hidden Byte? That isn't the Magic Defense byte, is it?"

Its not! Its just a random byte in character stats that is 0 or 1 to indicate they're hiding in battle.

I went for having spells vanish from the inventory on learning them to keep the game balance (whatever there is in FF1) intact. The price of the spells remains the same, one spell per character. I was going to call them scrolls, and imagined the mages whipping them out in battle to read off of, which is why they need to be in their personal inventory and not in whatever wagon of gear that's offscreen all the time...  :D So "Learn" and "Forget" were going to be "Scrolls" and "Remove" or something...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 22, 2019, 05:23:19 pm
Oh Haha! I took it to be a 'hidden byte', not THE Hidden byte. lol

That magic menu looks pretty slick. My only suggestion is to space out the columns more so the screen looks a bit more filled out.
Or maybe even split the large text box down the middle into two smaller vertical ones?

Something like this:
(https://i256.photobucket.com/albums/hh189/koala_knight/Stuff/split%20magic%20menu_zpswjooa7yg.png) (https://s256.photobucket.com/user/koala_knight/media/Stuff/split%20magic%20menu_zpswjooa7yg.png.html)

So each character has a personal inventory of spells?
You are still planning to implement job changing, right?
If so, you might want to consider reducing the spell prices.
If every character can potentially learn every spell in the game, it might take a hell of a lot of grinding to earn enough money to buy 32 spells at each town that has a full compliment of spells to learn.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 22, 2019, 06:40:35 pm
I can see about doing the two boxes.

"So each character has a personal inventory of spells?"
Well, same as it was before--the spells they know. Otherwise, all the spells are in generic inventory, directly after key items in RAM.

"You are still planning to implement job changing, right?"
Muuuuch later, there's still a bunch of other things I want to do before I get bogged down with that! But, eventually. The menus and things would be easy, its the stat stuff I wouldn't know where to begin with. Take a dumb fighter and turn them into a black mage--do they keep the massive HP and lack of intelligence, and only gain the appropriate stats on leveling up as that job? Or would there be a need to make some kind of conversion code... ugh... I don't wanna think about all that!

"If so, you might want to consider reducing the spell prices."
Yeah, might do that for the later levels.

Run into a snag on this learning menu.

(https://cdn.discordapp.com/attachments/527351555779723266/558769987297476619/unknown.png)

So each page is laid out like this. (I may have X and Y laid out wrong, I can never keep them straight. Should have called them Row and Column cursors.)

(https://cdn.discordapp.com/attachments/527351555779723266/558774128790994955/unknown.png)

Spell inventory is like this in RAM. (Not those exact numbers, but each byte is a spell, and the number is just quantity)

Column cursor can be 0, 1, 2, 3, 4, 5, 6, or 7, but only 2 per page

Row cursor can be 0, 1, 2, 3, 4, 5, 6, or 7

I have an extra variable to use as well--pagenumber--which is 0, 1, 2, or 3. Multiplying that by $10 gives the row of RAM.

How would you use these three variables to get the right spell index?

Code: [Select]
LDA cursor                ; convert row to 1-based
    STA tmp
    INC tmp
    LDX tmp                   ; and put in X
    LDA cursor_max
    CLC
    ADC #1                    ; convert column to 1-based
    JSR MultiplyXA            ; then multiply row by column
    STA tmp+5                 ; stow result as inventory position
    DEC tmp+5                 ; then substract 1 to make it 0-based again
    LDX tmp+5                 ; put in X
    LDA inv_magic, X          ; check if the spell exists
    BEQ @NoSpell

My latest attempt, except I guess I don't really want to DEC tmp+5 all the time. Was doing the initial concept going off the fact that I'd need $8*$8 to get $40... and power's flickering so I'm gonna stop rambling and hope I explained my mistakes well enough!

Edit: Gonna try to AND $01 the column cursor so its only 0 or 1, then multiply by 8, add the row cursor, and add pagenumber*$10 and see if that does it.

Edit 2: Woo, that worked!

Code: [Select]
LDA cursor                ; load column cursor
    AND #$01                  ; AND to get either 0 or 1
    LDX #8
    JSR MultiplyXA            ; multiply by 8
    STA tmp                   ; and save for later
    LDA item_pageswap         ; get page number
    LDX #$10                  ; multiply it by $10
    JSR MultiplyXA
    STA tmp+1                 ; and save for later
    LDA cursor_max            ; get row cursor
    CLC                       
    ADC tmp                   ; add column (0 or 1 * 8)
    ADC tmp+1                 ; add page number ($00, $10, $20, or $30)
    STA tmp+5                 ; stow result as inventory position
    TAX
    LDA inv_magic, X          ; check if the spell exists
    BEQ @NoSpell
Title: Re: FF1 MMC5 Disassembly Updates
Post by: abw on March 22, 2019, 07:29:26 pm
I can see about doing the two boxes.
+1 for splitting the columns; that makes it much more obvious that the level 3 spells are the left half of the list as opposed to e.g. the top half of the list.

How would you use these three variables to get the right spell index?
If you're willing to rely on having exactly 8 rows and at most 32 columns, how about this?
Code: [Select]
LDA column_index ; column_index values are in the range [0, 7]
ASL
ASL
ASL
; A = column_index * 8, C = 0
ADC row_index ; row_index values are in the range [0, 7]
; A = column_index * 8 + row_index, a.k.a. spell_index
TAX
LDA inv_magic, X ; check if spell exists
BEQ @NoSpell
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on March 22, 2019, 07:34:24 pm
I've never had a problem keeping X/Y straight, but without a math or programming background I can see how you might mix them up.

One way to remember could be "horiXontal" and "Yertical"
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 22, 2019, 08:32:03 pm
You don't really need more than 2 variables to get the spell index really.

Column is the spell level right?
So, row is basically the spell index within a given level.
The page index is only relevant to the menu.

I'll use the RAM index in the image you posted as the offset value; 0x50.

0x50 + (Column value x 0x8) gives you the index of the first spell in each level.

0x50 + ((Column value x 0x8) + row value) gives you the exact spell index the cursor is on.

So lets say you are on column 4, row 5.
That is the 2nd, L5 black magic spell. (in the vanilla game that is BANE)
That works out to $0x75 if my calculator are correct.


EDIT:
About what to do with the stats in reference to job changing.
I think you should keep it as simple as possible and just let the current job a character is using dictate stat growth only. That alone would make for a unique job system unlike any other Final fantasy game.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 27, 2019, 08:17:22 pm
I've never had a problem keeping X/Y straight, but without a math or programming background I can see how you might mix them up.

One way to remember could be "horiXontal" and "Yertical"

I think if I remember X is a cross and Y is pointing down, I can keep it straight, too. XD

+1 for splitting the columns; that makes it much more obvious that the level 3 spells are the left half of the list as opposed to e.g. the top half of the list.
If you're willing to rely on having exactly 8 rows and at most 32 columns, how about this?
Code: [Select]
LDA column_index ; column_index values are in the range [0, 7]
ASL
ASL
ASL
; A = column_index * 8, C = 0
ADC row_index ; row_index values are in the range [0, 7]
; A = column_index * 8 + row_index, a.k.a. spell_index
TAX
LDA inv_magic, X ; check if spell exists
BEQ @NoSpell

...this works perfectly, thank you! So much more elegant...

I think I finished up the magic menus and the shops. And then I forgot what I was doing and re-did all the equipment menus.

(https://cdn.discordapp.com/attachments/527351555779723266/560615667284574219/unknown.png)

There's only 40 weapons done, so the next two on the list here default to the next item name. Armor and weapons do not share the same bags. Just like the magic spells, there's 4 screens of 16 items each. There's a 99 item limit. If you try to unequip a 100th item, you can't; but I also removed the Discard option entirely because... why would you need it. How could you possibly get 100 of the same thing and be in a situation where you can't just sell one?

So weapons and armor use up 128 bytes of RAM, and aren't sortable. So I deleted all my cool cursor-colour changing code. But now its easier to see when you miss an item, its like an item dictionary!

The equip screen changed functions a bit. Pressing A on an item unequips it, then pressing A on an empty slot opens the inventory. I'm not gonna make it so that trying to equip to the head slot only shows head items. Since it uses the magic menu layout I can add in a text box popup that explains why the error sound is happening on some items, either "[Classname] can't equip that!" or "Can't wear that in this slot!" or something.

I'll may upload another zip file soon so people can play around with the broken stuff.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on March 27, 2019, 08:38:53 pm
Cool stuff. I think this more uniform way of using the bags is much better.
Did the spell index thing work out?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 31, 2019, 02:19:21 am
Cool stuff. I think this more uniform way of using the bags is much better.
Did the spell index thing work out?

Yep!

I'm 90% done with the items being used in battle. That is 9/10 items work as intended as far as I can tell! Now 100%??

https://drive.google.com/open?id=1I8ZKZfyf4ksomw1OHbf-zAFXbyNh9BGd (Updated March 31st, 8:15 EST)

Try it out!

Ethers don't work yet cause I need to make a new box for them. They'll behave like pures for now, if they work at all once selected (I haven't bothered trying.)

Ethers have their own extra menu to select the spell level. If you try to use an ether on a spell level that has no max MP, it will print "Nothing" and go back. Otherwise, it will try to work. There's some stack pushing/pulling shenanigans to make this all work, so if the game freezes... I gotta fix that immediately.

Messages for some items are wonky because I need to write some new messages for them. Smoke bombs say "Lev. up!" for instance; that's a placeholder.

If an item is ineffective, it will not play a sound, and will not use up an item, but it WILL still flash the target character's sprite.

Smoke bombs will put a living character into hiding, but not stoned or dead characters. They can also only be used in dungeons or towns (anywhere not the overworld), and turn off random battles for 50 steps. Its set in Constants somewhere--SMOKEBOMB_EFFECT--so it can be tweaked as preferred.

The Wakeup Bell will always use itself up, and will wake all party members.

Sleeping actually works to change their poses! It was... really not working before because I didn't understand what I was doing when I tried to make it, but now I do.

I don't know what bugs there might be anymore! Magic shops, weapon shops...? Menu stuff?

Oh yeah, don't touch the options menu! I re-wrote how the options menu works, in the back end. In the end the only thing I really needed to do was set the scroll after updating the battle text speed number... oh well. It uses less variables now, so I should go and clean those up a bit... Otherwise, for the player, it works just the same as it did before! Left/right change options, A acts the same as pressing right, all that.

As for how items are used on dead players... You can target any dead or stoned player with any target-able item, not just Softs and Phoenix Downs. With the ability to now revive in battle (magic needs to be updated for that still though!), I think its a risky but acceptable strategy to have a character try to use a healing item on someone who is dead, and hope that someone using the Soft or Phoenix Down gets their turn first. So, you can TARGET them, but they need to be alive for the item to work.

Also, Phoenix Downs give them 25 HP instead of 1. I think 25 is the lowest base HP to start with... Soft only grants 25 HP if they have 0 to start with. I couldn't remember how being stoned by enemies works--if it freezes them or changes their HP or what.

If you're using Mesen, I figured out you can change RAM by clicking on a byte and just typing in new numbers. So to test items out, you can give yourself different ailments or play around with how much MP each character has...

(https://cdn.discordapp.com/attachments/535538496547586060/562071578955743233/Capture.PNG)

Green: HP (current and max)
Red: Ailments (01, 02, 04, 08, 10, 20, 40 -- death, stone, poison, darkness, stun, sleep, mute)
Blue: MP (left half of each byet is current, right half is max)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on March 31, 2019, 09:09:24 pm
By "Work RAM" is that the console RAM (CPU $0000-07FF) or the cartridge RAM (CPU $6000-7FFF).
Be careful of writing data on CPU page $0100.
That is used for the stack and writing data too close to the bottom ($01FF) can corrupt things as the CPU uses that area for PUSH/PULL instructions as well as interrupts, etc.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on March 31, 2019, 10:50:57 pm
I'm not sure how Mesen decides what Work RAM is, but its the MMC5's own little block, $5C00-$5FFF. It just says $0100 because the display starts at 0, I guess?

Another little update for tonight:
All the items should have their own messages now!
Heal and X-Heal: HP up!
Pure and Soft: Cured!
Ether: MP restored!
Elixir: HP and MP restored!
Eyedrops: Sight restored!
Phoenix Down: Revived from the brink!
Smoke bomb: Slipped into hiding...
Wakeup bell: The bell rings loudly...

I expanded the message box to be as wide as the battle screen, so that fixes the old bug Vanya pointed out ages ago, where the character names are too long after leveling up past 9 (I hope!)

Fixed a few other minor bugs I overlooked while saying everything was fine. (Options menu was treating every right press like a left press, actually.) Smoke bombs and Wakeup bells were broken after my last post, that's fixed now.

https://drive.google.com/open?id=1I8ZKZfyf4ksomw1OHbf-zAFXbyNh9BGd

I ran into way less issues with all this than I thought I would. Maybe these last 2 years of staring at the game's code is paying off...? I basically put the Ether function together without running any tests, and only one non-UI bug happened!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on March 31, 2019, 11:56:16 pm
There is a bug where as if I entered to town to go weapon shop to shop more weapons. So, I paused, went to equip the character, then suddenly I got stuck with equipment bag 2 where I can't get back to equipment bag 1. That's only AFTER I exit from the weapon shop.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 01, 2019, 03:43:35 am
I can confirm that bug. After leaving either equipment shop, if you open the main menu and go to the equipment menu it takes you directly to bag 2. If you then exit the menu and reenter it, it returns to working as it should.

But...

There are quite a bit more bugs to squash. I can't seem to sell any weapons at all. it always tells me that I have nothing in my inventory.

Somehow I ended up with a Hand Axe in my inventory for no reason.

Buying armor doesn't add it to my bag. Equipping it directly seems to work fine.

I'll do more thorough testing tomorrow.

PS - Love the new menus!!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 01, 2019, 03:41:19 pm
Woo, thanks for testing things! I think I fixed 'em now.

Equipment Bag 2 bug was another forgetting to reset a variable... I thought I set it to reset when entering the menu, but it only reset when entering the item menu. The weapon shop was setting it to 1 to use as a toggle for the price loading routine to know to check a different table for weapons and armor...

Buying armor now works--I mean, it was working, it was just $40 bytes off where it was storing it in RAM.

I'm stumped on the Hand axe unless you got to where you can buy a Short sword? Buying weapons was off by 1 item ID so buying an Iron hammer ($05) would give you a Short sword ($06) in your inventory. That is also fixed now.

Selling is going to be tricky... I forgot about it completely when changing up the weapon storage system. I've got it now so it will load a list of what you have, but you can only sell one at a time still (maybe later I'll make it like the item shop... but the price of equipment will break the game if you try to sell 99 things, even at half-price.) Moving the list a few times garbles the screen for some reason... and its not resetting the shop's inventory when going back to buying... >.<

I will double-check the treasure chest routines too... And upload the zip file again when its all working.


Edit:

https://drive.google.com/open?id=1I8ZKZfyf4ksomw1OHbf-zAFXbyNh9BGd

Fixed:
* Armor can be bought!
* You can sell things 1 at a time!
* Treasure chests give equipment properly!
* Armor is displayed properly in the equip screen (it was showing the name of the item before it in the list; Wooden for Chain armor, ProCape for a Cap...)
* Scrolling the sell menu up will put the cursor at the bottom of the list.
* Characters will cheer-pose properly in the sell menu; before, they were set to cheer at only the first 5 things in the list, even if the list on display was items 10-15.
* The scrolling variable resets properly between buying and selling
* The item page variable resets every time you open the equipment inventory, main menu (unnecessary really but I'll leave it in in case I change things and forget), item menu, and magic learning menu.


Not Sure:
* Cursor may or may not show up in the right spot in every shop.
* I somehow froze my game while setting the encounter rate to low, after setting the exp gain to high, but I can't reproduce
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 03, 2019, 03:08:20 am
I didn't encounter any problems with the cursor showing up in the shops.

However, there is still some funkiness going on with the armor shop.
It still doesn't seem to be loading the armor inventory correctly when I sell.
I has 2 Cloth and 1 Wooden (Armor).
When I went to sell it showed Cloth with a value of 0, and Cloth with a value of 10.
I could sell them both, but selling the first caused some wierdness.
And nothing was removed from inventory after selling.
At the end I had P5 number of Cloth and 1 Wooden (Armor) in my inventory still.

Also, there is a typo in the Magic shop text, "What scroll do do you require?"

And I have a suggestion of course. :P
Can you show how many of an item you already have in the shop lists?
Screen real estate might be an issue, but it would be a good QoL addition.

EDIT:

I noticed that the P5 number of Cloth shows up in the last item slot of the Weapon inventory on page 4. I guess it might be pointing at the wrong inventory index?

And, the reason I noticed this at all is because I was looking at the battle item slots and wanted to see if I could equip any kind of item.

You might need to change it so it can access both inventories.
Otherwise, there will be a bunch of jobs that can't use certain armors as battle items that could do it just fine before.

EDIT AGAIN:

I have some insight into the freeze that happens on the Options menu.
In order to cause the freeze you first have to press A and then then B.
It doesn't seem to matter which option you are on or if you move to another option between presses.

EDIT MORE:

It seems the magic shops don't account for spells that have been learned.
So I had my White Mage learn CURE, then I went into the magic shop and was able to buy 4 copies of it.  I technically had 5 of them now, though it didn't seem to cause any issues.
There is enough room in the magic inventory menu to include how many of each spell I have since it only needs 2 characters.
Displaying the number of scrolls I already have in the magic shops would be great, too.

THE RETURN OF EDIT:

In the magic menu after I use the Forget command and press B to use the Cast command, Cast makes me forget spells instead of casting them until I leave the screen and come back.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on April 03, 2019, 11:57:17 am
I'm guessing "P5" is 255, since SMW had the same problem of incorrectly handling a number greater than 99 when a two-digit number was expected. ("P" = a 10s digit of 25)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 03, 2019, 06:52:39 pm
Yay, more bugs to squish!

Typo fixed in the magic shop!

Armor shop weirdness fixed? Just had to add a 1 to the item ID. Basically it saw your cloth armour, then looked at 1 item before it (the 64 weapon, which has a pointer entry in the nametable, but no data at the pointer, so it skipped ahead to print the next item: cloth armor. But with no price, because I just filled the price table for non-existant equipment with 0s.) Then I guess it sold that 64th weapon, which took a $0 to $FF and showed up as Cloth in the 4th equipment bag...? 

I think I can display item amount in shops... but it will have to be on the line between the name and price. Might look ugly. Otherwise, I can expand the list by 1 tile to the left and 1 tile to the right, and put the number after the weapon/armor name, but that limits the names to 7 characters, and I just made it room for 8... The other solution is to squish things even further to the left. Move the shopkeeper, the title box, the Buy/Sell box (and move the character names to the right-list for the clinics) and re-do all the shop text to fit the squishier windows. So... I'll just work on putting it between the name and price for now.

Battle Items, I'm not sure what to do about. I can look into using Select to swap between armor and weapon bags?

The Options screen freeze was a silly thing... for pressing left/right, it needs to double-RTS to re-draw the options and return to the input loop, but pressing A doesn't need to... but it was. So, that explains it. XD Fixed it.

And I worked up something to check known spells for buying in magic shops. So if every character knows Cure and you have 0 in inventory, it won't let you buy any more.

I also added the number of spells in the spellbook menu. But now things are wonky and Fire is thinking its the 3rd white magic spell and not the 1st black magic spell, so... still a bit of tinkering left there.

Also got the Cast/Forget bug squished! The whole logic for that submenu is a squirmy mess, its no wonder I didn't catch it before.

Thanks again for doing all the hard work trying things out. XD
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 03, 2019, 07:17:54 pm
My pleasure!! :D
Toggling the inventory bags with select works just fine. Maybe add a message to the bottom of the screen letting players know that is a thing?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 03, 2019, 08:41:47 pm
(https://cdn.discordapp.com/attachments/535538496547586060/563160918494543872/unknown.png)

How's that look? I figure either centered or left-aligned...

https://drive.google.com/open?id=1I8ZKZfyf4ksomw1OHbf-zAFXbyNh9BGd

All those fixes are now live. Also found out that using ORA for adding the items quantity you want to buy in item shops... doesn't work the way I thought it would back when I did that. So now it does addition properly and you don't have to buy more than the amount you currently have in order to increase the number in inventory.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 03, 2019, 10:41:30 pm
Not bad! And much appreciated.
I think left aligned would probably work best.
Also, instead of putting it in brackets, a simple x00 format might be better.

EDIT:

Something I forgot to mention before. The spell names don't appear in the battle text.

Also, the Magic shops appear to still be borked. Now the shop inventory seems to pointing to the wrong data. It doesn't charge me for the CURE and FIRE spells, and everything is exorbitantly priced, so I couldn't buy any other spells.

It occurs to me that now that you have a more unified system for the various inventories, it may be a good idea to give all the shops the same unified functions. I don't know how much code is shared by the shops now, but this could help save some space in the long run.

Right now, the equipment shops let you equip the things you buy to specific characters.
The item and equipment shops now show how many you have of a thing.
And the item shops let you buy multiples of any item at once.
All the shops can benefit from having all these features.

My suggestion is that it work like this:

- When you enter a shop it will always have the same basic commands. (BUY - SELL - EXIT)

- The shopkeeper text would be indexed based on the type of shop you are in. Maybe also have it display the shop list immediately upon entering the shop.

- Using the BUY command would bring up the shop list as normal. All shops would show how many of a thing you already have in your inventory (including those held/equipped/learned).

- All shops will then use the quantity selector so players can buy multiples of anything.

- Most shops would cap inventory at 99 (including held items). The inventory cap would include a check to cap inventory at 4 in magic shops instead.

- The confirmation text normally has 3 options. (EQUIP - YES - NO)
There would be a check for magic shops that would swap the EQUIP text for LEARN instead.
And, if you buy more than 1 of something or are in an item shop, it would have a check that uses an alternate confirmation menu with only the YES and NO commands.

- If you confirm YES, the item(s) get added to the appropriate inventory. If you confirm EQUIP or LEARN, it takes you to the character selection. And, if you confirm NO, it cancels the transaction as normal and reloads the shop list.

- The SELL command is perfect in execution as is. The only thing I would do is make it universal for all shops. That way you can sell excess items you don't need.

- The EXIT command is perfect, of course.

- The Church would, of course, ignore all this and continue doing its own thing.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 04, 2019, 08:47:11 pm
Fixed the spells in battle... and enemy attacks, while I was at it. And the magic shops again. Trying to change the brackets but I'm too sleepy and its messing up... Last link updated with fixes!

I like the shop thing! Its gonna be a big project to consolidate all that, but it might be worth it. The menu bank is running low on space again very soon.

Gonna focus on fixing bugs first, then updating the github version and trying to stay on top of that...

Any more bugs to squish?!  :D



Figured out why changing the quantity thing wasn't working. Glazed over the $50 because everything else was $4x... so next question:

(https://cdn.discordapp.com/attachments/535538496547586060/563533054639996929/unknown.png)

or

(https://cdn.discordapp.com/attachments/535538496547586060/563533720179441674/unknown.png)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 04, 2019, 09:26:43 pm
I'll see what I can find.

BTW, does the menu bank also include the battle menu stuff?

EDIT:

Hmm... I like it zero padded, but I think the rest of the game isn't zero padded, so the bottom one.

I notice a bug in the magic menu.
When I use the Forget command, after forgetting something, the cursor stays down in the spell list, suggesting that I'm still in forget mode. But when I try to continue forgetting spells, it tries to use them instead. I guess the forget command is somehow switching into the use command after each use?

2xEDIT:

Oh, hell. Here's another. After using CURE in the menu and pressing B to go back to the magic list, it always goes to the 4th player's spell list.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 05, 2019, 01:13:22 am
I like bugs that are easy to fix.

Both of those are taken care of now, as well as one I found: Learning spells wouldn't update the screen unless the spell was used up (a holdover from before it showed quantity.)

(https://cdn.discordapp.com/attachments/535538496547586060/563587070430412811/unknown.png)

And I figured out how to get rid of the space! It's still printed, just after the single digit instead of before.

Menu bank only has the Ether MP string data, because it was the easiest way to do that particular box. Battle menu stuff is mostly in C and the fixed bank, except where its also in B (only for level up information I think.)

Checking out how Warp and Exit work now, and noticed a typo in the spell learning menu... Says Spell Level 4-6, instead of 5-6! And looks like Warp needs to pull 3 more bytes from the stack to teleport correctly. So, fixed that too.

No .zip file updates this time, I don't wanna wrestle with Google Drive right now.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 05, 2019, 03:03:23 am
Yeah, I noticed the spell list not updating after learning a spell. You ninja'd me on that one. :P
The quantities look great like that!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 06, 2019, 06:50:22 pm
Discovered that equipping things in shops while already equipped was placing the wrong item in inventory, should be fixed.

Magic messages were wonky still. Cure was "defend fire" and Fire was "HP up!". Sorted that.

I put a A+B button press in the Inn after the sprites fade out, so you have time to read the message before the save screen pops up. Overkill? Should I change it to doing like... 120 frames (2 seconds, right?) to read the message?

Going to try adding a little something extra to the equipment shops, too...

(https://cdn.discordapp.com/attachments/535538496547586060/564256765185884199/unknown.png)

It's an "this character has this item equipped" marker!

Should equipment shops list equipped items in the x## slot?


Also considering doing a French translation... I need to learn French and I've been putting it off for months because its boring, and yet ASM tinkering is... not? I think its because I get a dopamine kick out of making things and creating menus. So making a French translation solves all three problems: Brain happiness, learning the language, and making a translation that I can't seem to find...



Aaand item shops are not fixed... freezing when trying to buy things... grrr Edit: Oops, that was very easy. Changed a JMP :++ to a JMP :+++

(https://cdn.discordapp.com/attachments/527351555779723266/564328728696455169/unknown.png)

Got tired of the weird boxes for the Japanese text, so I fixed it! Also blotted out my friends' names 'cos.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 08, 2019, 02:24:56 am
Discovered that equipping things in shops while already equipped was placing the wrong item in inventory, should be fixed.

I think that might explain how that Short Sword apreared in my inventory before.`


Quote
I put a A+B button press in the Inn after the sprites fade out, so you have time to read the message before the save screen pops up. Overkill? Should I change it to doing like... 120 frames (2 seconds, right?) to read the message?

Yes, overkill. Simply requiring an 'A' press after a frame count seems sufficient.

One thing that was kinda buggin' me though... On the save screen, it lets you keep saving over and over and it restarts the Inn fanfare each time you do so. It could probably use some sprucing up to be more consistent with the later games.

Try removing the save feature from the Inn screen. (It is pretty much redundant now.)
So, instead of going to the save screen after it fades to black:
> have it just stay on the Inn screen,
> restore HP & MP,
> play the fanfare,
> fade back in,
> display the warning message,
> pause for a second or two,
> and then automatically exit the Inn screen.

As for the save screen itself, it probably needs a confirmation step after you choose which slot to save to. Aside from that, it's probably fine the way it is. Being able to stay on the save screen instead of getting dumped back onto the main menu like most of the other games do is an improvement as is.

Actually, it might be a good idea to add a message box to the save screen.
When you first enter it should explain how to delete a file, and after saving it should display the 'warning' message instead of doing it in the Inns.
The Inns should just explain that your HP & MP have been restored.


Quote
Going to try adding a little something extra to the equipment shops, too...

-img-

It's an "this character has this item equipped" marker!

Hells yeah! Love it!


Quote
Should equipment shops list equipped items in the x## slot?

All of the yes!


Quote
Also considering doing a French translation... I need to learn French and I've been putting it off for months because its boring, and yet ASM tinkering is... not? I think its because I get a dopamine kick out of making things and creating menus. So making a French translation solves all three problems: Brain happiness, learning the language, and making a translation that I can't seem to find...

Why not? Seems like a win/win.


Quote
-img-

Got tired of the weird boxes for the Japanese text, so I fixed it! Also blotted out my friends' names 'cos.

I support this change 100%.

I'm hoping you go for a full overhaul of the battle screen so it more closely matches the ones in FF2&3.
I really think it looks better without the big frames and the background tiles spanning the whole top of the screen. "Grond's Final Fantasy" and the Japanese hack, "Final Fantasy Revised", both have pretty nice looking battle screens. But, those both still have that tall column for the names and HP. Bleh! That column is my nemesis.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 08, 2019, 10:03:14 am
Quote
I support this change 100%.

I'm hoping you go for a full overhaul of the battle screen so it more closely matches the ones in FF2&3.
I really think it looks better without the big frames and the background tiles spanning the whole top of the screen. "Grond's Final Fantasy" and the Japanese hack, "Final Fantasy Revised", both have pretty nice looking battle screens. But, those both still have that tall column for the names and HP. Bleh! That column is my nemesis.

I agree. Its fine, but every battle screen layout suppose to have HP and MP to be in the bottom.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 08, 2019, 11:17:13 pm
I don't think "suppose" is the right word here.
Most of them certainly do, but that doesn't mean they are supposed to.
Only the creators can decide how something is supposed to be.

FF2 & FF3 are able to do this by use of screen scrolling to be able to shift things around.
FF1 doesn't have that built in, and I can't say how difficult it would be to implement or how much space it would require.
Either way I think it will likely take quite a bit of work to get the names and HP down below the battle area.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 09, 2019, 12:51:28 am
I definitely need to come up with a sort of Manual of How Things Should Work for shops. I hate when some options leave the inventory box open and with the last thing drawn, while the cursor is off choosing buy/sell/exit again or whatever...

And, oops. I didn't mean to imply A AND B had to be pressed at the inn, just either of them. And the save menu could use a bit of a touchup I suppose... but that will have to come later and I'm so bad at taking notes of what I need to work on eventually.

Reminder that you shouldn't be able to press start at the name selection screen if there's only blank spaces for a name...

(https://cdn.discordapp.com/attachments/535538496547586060/565031090234982400/unknown.png)

Work in progress. Actually started on this right after changing the box sizes!

Some notes on the difficulty of this task and the layout:

The screen is 32 tiles wide and 30 tall.

The Enemy roster box can be squeezed down to 10 tiles (box sides, 8 letter names).

The Player name and HP box is currently 9 tiles wide.

That leaves 13 tiles for the command box. | FIGHT HIDE| -- will just barely fit with the cursor overlapping the box or the left-side command.

Can save 2 tiles by having box sides overlapping.

Battle Turn display might need to be dropped.

Not sure where to put ailment and hiding icons. If I keep them behind the characters, I would disable the heart from displaying, and icons would only show up when they have a bad ailment. I don't know what's going on with those 2s; I'm currently poking that particular bit of code. (It used to display all the names and everything, but only displaying one icon should hopefully lesson the delay between turns in battle.)

Enemies: They gotta move up some. From backdrop to characters, there's 16 tiles of battle space, leaving 14 for messages and boxes. That's as much as is needed for a box with the names and HP to have a space between rows. So, it will fit. IF.

IF.

I can move the enemies. I've already looked at their attribute byte code quite a lot, and some of the math used to figure out what the attribute bytes should be set to hurt my head. I'm hoping that moving them will simplify things a lot. Small enemies would fit within their own boxes. Larger enemies would overlap some...

But having more horizontal space, I would move the smaller enemies in mixed formations forward, which might mean having the 9 small enemy formations moved forwards too.

The last thing I want to figure out is how to keep the name/HP box displaying after being drawn over. For sure the magic box will overdraw it. I'm thinking tweaking the undraw box codes so that it undraws all BUT this one box... And considering the convoluted mess the box drawing is, I don't know if that will be easier or harder than moving the enemies and having their colours work.

One last quality change I want to make to enemies, if I can do all this, is to flash their attribute bytes when they attack, as a way to know which enemies have taken a turn. Its not super necessary but its something I wanted to see, to help make the battles more lively.

Also I got the numbers reversed for the HP. Here's how it should look:
(https://cdn.discordapp.com/attachments/535538496547586060/565036438614441994/unknown.png)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 09, 2019, 01:04:14 am
Good stuff so far. That's exactly the sort of thing I had in mind.

As long as you can fit all the rest of the info in at the bottom of the screen, keeping the status effect icons behind the character sprites is a good idea.

Shifting around the enemy graphics is something I fiddled with when I was futzing around with RPG Maker MV and made an attempt at a sort of FF1 remake. I slanted the enemy and player positions to get a bit more of a 16-bit era arrangement.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 09, 2019, 01:56:51 am
(https://cdn.discordapp.com/attachments/527351555779723266/565049583663579148/unknown.png)

Not sure what happened there with that little glitch, but its coming along nicely... finally.

How do we feel about the names needing to be visible all the time? Once I can move the boxes up 2 tiles, there's no need for the command box to be wide; all 6 options will fit stacked on top of each other. EQUIPPED can be something else... GEAR? EQUIP (that's a verb and confusing)? I feel weird having it in the middle... Would prefer it if it was on the side.

Maybe, have it on the side during commands, but during the battle turn (if I can get it to display constantly beneath the other boxes), the names move back over to the side.

Do people like having Max HP visible as well? Would be easy to remove it and use that space to show the ailment icon instead, the way it was before. I like having Max HP so I know when I can stop trying to cure HP... always think they're hurt when they're not...

(https://cdn.discordapp.com/attachments/527351555779723266/565077315885727755/unknown.png)

One last 3 AM update... Shifted the character sprites down by 4 pixels, since using all 14 tiles was kinda awkward--having just one line of padding on top or bottom, when the rest of the text is squished to every other side.

Also, like, every single menu box is broken in some way now. I'll update the cursor positions last--will need to write a new routine for the command box. Maybe put HIDE up under MAGIC. Maybe de-capslock them too?

I will put the battle turn number in the bottom left corner there, enemy names don't need that space.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 09, 2019, 03:46:04 am
I feel that the closer we get to FF3 the better.
I just played a bit of all the games from 1 - 6 to refresh my memory.
They all Keep the names, current HP, and max HP visible all the time.
I like it like that, most people will be used to it as well.

This is what I'm thinking:
- Split the menu area into 2 frames; enemy names on the left, character info on the right.
- Only the left side frame is ever overwritten.
- The command window overlaps the enemy names and is only visible while a command is being selected.
- Heavily cut back on the battle messages.
- Try to implement pop up damage and healing sprites.
- Try to make space for enemies to have status icons, too.

Flashing the enemies is a great idea that can cut down on battle messages a lot.
FF3 did it by simply having the enemy tiles rapidly switch between their normal palette(s) and the battle frame palette.

Speaking of the battle frames, can you change them to using the normal blue filled ones instead?

GEAR is better than EQUIPPED for sure.
And it's a reasonable localization of the original term; mochimono = personal effects.
EQUIP would be confusing and lead most players to think that you can use it to swap out equipment.


EDIT:

Here are some mocks of what I think would kick the most ass...

(https://lh3.googleusercontent.com/BdFJhT_T3sP0sWhwfie-pjIya_4W74--5YcwbS_4xLoGaBEIgLICmEQkP3m4ZCNU_UnSDIxEilRNGJT7NokQdZI2lHcVKnd070gbP-b6W5t6weBCV9XZ_k6Lr8pwV08HUvedZHsVMexyXY7nC-BP9ds0v_uL8QcCs64y9HV3rgWbGZNED7Bsk66O8Yq15Zt5QBjjxKRsu4-FS8tkDz0hixGsknxiPFdtdfpUdG9hXqd4JkiN4g8UC_HahsjTKXlseaSoWWIZTegn74G4-vVWjL6EQeKOCEXVTxU4B1yPtiThVoTORRurWua4Ez1CFSJo39jbAfb853nTyTQjnDrehApY45eX0p-TNSbHsgQpDzI6UhjSmmKM2SvwxN51BxGraOtEYkKyNE1FvTsdmU3lOKWK3VOBNEDcIhzZgLDoVXH2wrhoabLbcER-J6sXUjV3jLee8ctvI8bsaMa9dhxIIhOld7KnIuCQSSQW0iBXPMAudGuTxa58oW4Bb5Z336e6LWaqNaX_qC8I64MeXWth3FckKA0h3sXwOhj2m7Rz1No999UDPjlGktVBXrKYjKABaH-6SG4gHZJHaZEokhl39dvIX-7tM2A1IPqDFQMMbEF5CFQ8CYTbkBOFOtRf6OQlMdyAfKki5oePpLyi2cFC59yxtWnLJkA=w256-h240-no)

- I left in the borders and blue backgrounds for the enemies and characters to show off their placements more precisely.


(https://lh3.googleusercontent.com/o7WEui3389D06vLSP1n-_iD__YB1DgQW-ee9yA4O5MEEV94-x6e65KqJ1JfGwvpDxaM6F32tVqycbm3K2QcQEyINL62XkZB6gZoW1MC8neg6vITWMVHqu0GTXplk3sLJn5tpyM13mV7buE7OE23YEnXHbNPMNsZa65SvF2MHX_0Hvh-tfs-3Bf-c5ScY2F6DjDLPWmbPVcyQ0-1rTueZurQu5KstaYK0pyAbkCWbYHlmWK5EyNwb-AK2NI-X3A8BYSNk8Y3mJQDvEoTpEp2M0Dq2w0E3PqmxID3lAChFYaf9v96qpBAoSGihISiNIv-hLzTO70mE5qySj023HOYNuqEWARkU0eXUxmT9LbvEosT0mwCrynraXG0SJPJoe3vJnIk1kbTv_HqLmgxEztXl2b-2NRcUpKiMP3_-oGzhd85s5ufcvqRRvgI41h7LXi1cWDuCNEk6Yd1LDAqe-MYth8CduY3z75PI-zaIgxeGl4kk3dy6AGzFyu9G9cANKem9RuCYcuu7glblreJuM1EbmTU51V_TPgshQ4VKjq87zWXjMGZ8u_Pp09iKNLfpczH181fjZdGv0_YhCyyIJXj3HULmLto-5-e41z9x2ExLMb5U8ob3UQefHtYRvdM6SDS-D3pAfwA_F4qFarTI8h786vmWYjxiOgM=w256-h240-no)

- Here it is with the command window over the enemy names.


(https://lh3.googleusercontent.com/bAaQO9EvBX3MRDoVB6ST5Yt6FSF1AWGeCqXwjXtNBv9W2jmGYj9Wc-Wf6dXB1WEGiVVaiUJ8th5LonY8NO7ieGS2dyBUGKqzU3W2FAP3xfFqI5mN7tiO5lYiR61ivat46GnwqYbGivNs7E7f9M7qstSoZQA2Zxehct7JQp-Iuwkgj5RHIvA4mRVeo1nwlToLXs2kYlmGhBu1djmUk4M8iGH9i_iCJC730za33Wj3RxLAC7SUVnjs9Nsu-c43PpORC8HXZgFwlWvV2VWQ0szoBCSiz5WnjFwiEl4V2c2xHpRyCyjmdzMbSLPHL-h56EHasuU7MYrnMSOazsVtUzWy0Kn4sy2BnqsiUGcE9AJcQ0qMB8ejcMHsCZUhs515XgJYZdjURywCuiJxMBkzdsAQOp_unMIpZ1jVORQE27HlT41s4PPZ1AoIdbA99QmoXUKqXQo3fkARC2IMUzFi3wBgcIZZWRUorSf4tyaj5PV1diMGzHWoa1Tf0ONm_RlruP32AfxYXIqVbzLIThvzLRJr-3-kYHORenV613m4L5uh806DpEvoafp4vMvIvmnSyp6F5n8AJrESFk6xLKVWkEc2suYKZbBtWcXmeN_lst0-29nEV0DGOOKQYyc00eXxtHRP9l-KfP99VlU53CMZNEvZ_fIW-rLbWtc=w256-h240-no)

- And I also made a mock-up of what it might look like if the command window could be split in two.
- These are the main commands. (I kinda prefer the ITEM command at the bottom.)


(https://lh3.googleusercontent.com/fMRK-oCexrZMwv91Iwm9A9o0PpEwr_dHU5JXQJ498vgMMRcsTZPPtxitwLBiWupDIiZfWn7t4hf5zVMXKcLlGlel-q8Qivt6lqA4C1DKAvFj-Syp_t6AjPXaKnCMMFrhC3OVUp0TFC-hW2L1tQXGUPRZ-_5pHdAxRZC49Ac92L-AHevaT1EWcF1m4zDKPHsP7uljArYtnNF8VYMNEzUn8WaWIwgIyLBHGA1bsBaqdK6LdDmhtArvyZUJcxp0ROhgyB1nqIiEmKyreBe8k0m-mChfhfsuliD-V2doa4RJkYAm2-yRuQDPgY__Uqub224gHorLB3XAChlDrbpG794ESP7z_EvIx3ZV8iBTYFmJ1xchzgg2tK6XeIS3DEsvDXZSefMY8Ufi0nPHX2bBgGwZIH9oPyfdy_K7Q6SetL-wApm9mwR3tiNKU8jjsEMVl_QAO6V5QCqtVInboeOZDXkCQXo4kETe7vyGJzontHnFKDKIxC9TM7OFMYplPUvWbPXXEZdRKmkIkXgDVRQhhPV9u4Egojy91YgQTTwL3JTEmZqfuiH_1Z6Wh1H2gMrGgDc1QErfR3xCU5UGzZTy0yOdyyAhyCxfMAiQCFqARQAt1kSsmI9y3SnG0iIxTZfwfx8zTud6-ePbToPJwm-OFNccBKkS6H93kOU=w256-h240-no)

- These are the secondary commands.
- There is enough space for commands to have up to 10-letter names.
(Still lobbying for a Defend command! :P )


EDIT AGAIN:

(https://lh3.googleusercontent.com/2967udAGwLkwzygQPokn_bq7ZIwbigtsRASUC3JbVMwbyi36UMXTx7msPyqSv76rg_mUhfMmeD8Q5dKcBCPks-PjXCBXUEskgkfTebKQSbgcyU3sZkNe2aHkqvoK4KQ8RylM5L5yWQzW0hE_T97tMSFI7OTnmfW74mJ8V5bc1bBYGwCi8m5dUjKw-vG8zGZFFaLolZLucRDGOgc9fDGGyQUCXhVneLDxtGH7BDc-Lb01ORufnHEmuuj_E9LIU0ggq20dWg0O6CxkUmlC3ef046VyPv7k2bhrAE1hkHYaSkfbpbd49k9Mli5nzoudoEkC8_C3yunD9OjEuLKP5bJF_fXMaOtTNPnfZFlNU95x7RxLiPghQl4U51r4I9CidyxHW1_B-h-2hPFvwwxzwmspAffHnrapZW61H0jWt4wGuG3VS4PW-Pmbt7Zum4mZEDcmMN5Z3rinLclnjPMWdap0echTsxceQ14O0gnpmwuatTfJokenaDU8a7qDGkQjXR5YcpS9vluFoGCJdGlYL4lgxdhuB0ta0ZEfhI5emFuTKOuwQpbKuJL8sJ2cqQo54HoI_8WsMJ0OHxhK-5D4_2ynb9KmPazlviOJt8q2QTvuSdQkUbfcKlC63h5VXfKVgWW2CGDGsGgLwuKw7EsVou0gmDWx9s1-Eqs=w256-h240-no)

One more for the road! Here is the first pic with all the precision borders removed.
~ What dreams may come. ~
(>^.^)>
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 09, 2019, 07:11:27 am
I feel that the closer we get to FF3 the better.
I just played a bit of all the games from 1 - 6 to refresh my memory.
They all Keep the names, current HP, and max HP visible all the time.
I like it like that, most people will be used to it as well.

This is what I'm thinking:
- Split the menu area into 2 frames; enemy names on the left, character info on the right.
- Only the left side frame is ever overwritten.
- The command window overlaps the enemy names and is only visible while a command is being selected.
- Heavily cut back on the battle messages.
- Try to implement pop up damage and healing sprites.
- Try to make space for enemies to have status icons, too.

Flashing the enemies is a great idea that can cut down on battle messages a lot.
FF3 did it by simply having the enemy tiles rapidly switch between their normal palette(s) and the battle frame palette.

Speaking of the battle frames, can you change them to using the normal blue filled ones instead?

GEAR is better than EQUIPPED for sure.
And it's a reasonable localization of the original term; mochimono = personal effects.
EQUIP would be confusing and lead most players to think that you can use it to swap out equipment.


EDIT:

Here are some mocks of what I think would kick the most ass...

(https://lh3.googleusercontent.com/BdFJhT_T3sP0sWhwfie-pjIya_4W74--5YcwbS_4xLoGaBEIgLICmEQkP3m4ZCNU_UnSDIxEilRNGJT7NokQdZI2lHcVKnd070gbP-b6W5t6weBCV9XZ_k6Lr8pwV08HUvedZHsVMexyXY7nC-BP9ds0v_uL8QcCs64y9HV3rgWbGZNED7Bsk66O8Yq15Zt5QBjjxKRsu4-FS8tkDz0hixGsknxiPFdtdfpUdG9hXqd4JkiN4g8UC_HahsjTKXlseaSoWWIZTegn74G4-vVWjL6EQeKOCEXVTxU4B1yPtiThVoTORRurWua4Ez1CFSJo39jbAfb853nTyTQjnDrehApY45eX0p-TNSbHsgQpDzI6UhjSmmKM2SvwxN51BxGraOtEYkKyNE1FvTsdmU3lOKWK3VOBNEDcIhzZgLDoVXH2wrhoabLbcER-J6sXUjV3jLee8ctvI8bsaMa9dhxIIhOld7KnIuCQSSQW0iBXPMAudGuTxa58oW4Bb5Z336e6LWaqNaX_qC8I64MeXWth3FckKA0h3sXwOhj2m7Rz1No999UDPjlGktVBXrKYjKABaH-6SG4gHZJHaZEokhl39dvIX-7tM2A1IPqDFQMMbEF5CFQ8CYTbkBOFOtRf6OQlMdyAfKki5oePpLyi2cFC59yxtWnLJkA=w256-h240-no)

- I left in the borders and blue backgrounds for the enemies and characters to show off their placements more precisely.


(https://lh3.googleusercontent.com/o7WEui3389D06vLSP1n-_iD__YB1DgQW-ee9yA4O5MEEV94-x6e65KqJ1JfGwvpDxaM6F32tVqycbm3K2QcQEyINL62XkZB6gZoW1MC8neg6vITWMVHqu0GTXplk3sLJn5tpyM13mV7buE7OE23YEnXHbNPMNsZa65SvF2MHX_0Hvh-tfs-3Bf-c5ScY2F6DjDLPWmbPVcyQ0-1rTueZurQu5KstaYK0pyAbkCWbYHlmWK5EyNwb-AK2NI-X3A8BYSNk8Y3mJQDvEoTpEp2M0Dq2w0E3PqmxID3lAChFYaf9v96qpBAoSGihISiNIv-hLzTO70mE5qySj023HOYNuqEWARkU0eXUxmT9LbvEosT0mwCrynraXG0SJPJoe3vJnIk1kbTv_HqLmgxEztXl2b-2NRcUpKiMP3_-oGzhd85s5ufcvqRRvgI41h7LXi1cWDuCNEk6Yd1LDAqe-MYth8CduY3z75PI-zaIgxeGl4kk3dy6AGzFyu9G9cANKem9RuCYcuu7glblreJuM1EbmTU51V_TPgshQ4VKjq87zWXjMGZ8u_Pp09iKNLfpczH181fjZdGv0_YhCyyIJXj3HULmLto-5-e41z9x2ExLMb5U8ob3UQefHtYRvdM6SDS-D3pAfwA_F4qFarTI8h786vmWYjxiOgM=w256-h240-no)

- Here it is with the command window over the enemy names.


(https://lh3.googleusercontent.com/bAaQO9EvBX3MRDoVB6ST5Yt6FSF1AWGeCqXwjXtNBv9W2jmGYj9Wc-Wf6dXB1WEGiVVaiUJ8th5LonY8NO7ieGS2dyBUGKqzU3W2FAP3xfFqI5mN7tiO5lYiR61ivat46GnwqYbGivNs7E7f9M7qstSoZQA2Zxehct7JQp-Iuwkgj5RHIvA4mRVeo1nwlToLXs2kYlmGhBu1djmUk4M8iGH9i_iCJC730za33Wj3RxLAC7SUVnjs9Nsu-c43PpORC8HXZgFwlWvV2VWQ0szoBCSiz5WnjFwiEl4V2c2xHpRyCyjmdzMbSLPHL-h56EHasuU7MYrnMSOazsVtUzWy0Kn4sy2BnqsiUGcE9AJcQ0qMB8ejcMHsCZUhs515XgJYZdjURywCuiJxMBkzdsAQOp_unMIpZ1jVORQE27HlT41s4PPZ1AoIdbA99QmoXUKqXQo3fkARC2IMUzFi3wBgcIZZWRUorSf4tyaj5PV1diMGzHWoa1Tf0ONm_RlruP32AfxYXIqVbzLIThvzLRJr-3-kYHORenV613m4L5uh806DpEvoafp4vMvIvmnSyp6F5n8AJrESFk6xLKVWkEc2suYKZbBtWcXmeN_lst0-29nEV0DGOOKQYyc00eXxtHRP9l-KfP99VlU53CMZNEvZ_fIW-rLbWtc=w256-h240-no)

- And I also made a mock-up of what it might look like if the command window could be split in two.
- These are the main commands. (I kinda prefer the ITEM command at the bottom.)


(https://lh3.googleusercontent.com/fMRK-oCexrZMwv91Iwm9A9o0PpEwr_dHU5JXQJ498vgMMRcsTZPPtxitwLBiWupDIiZfWn7t4hf5zVMXKcLlGlel-q8Qivt6lqA4C1DKAvFj-Syp_t6AjPXaKnCMMFrhC3OVUp0TFC-hW2L1tQXGUPRZ-_5pHdAxRZC49Ac92L-AHevaT1EWcF1m4zDKPHsP7uljArYtnNF8VYMNEzUn8WaWIwgIyLBHGA1bsBaqdK6LdDmhtArvyZUJcxp0ROhgyB1nqIiEmKyreBe8k0m-mChfhfsuliD-V2doa4RJkYAm2-yRuQDPgY__Uqub224gHorLB3XAChlDrbpG794ESP7z_EvIx3ZV8iBTYFmJ1xchzgg2tK6XeIS3DEsvDXZSefMY8Ufi0nPHX2bBgGwZIH9oPyfdy_K7Q6SetL-wApm9mwR3tiNKU8jjsEMVl_QAO6V5QCqtVInboeOZDXkCQXo4kETe7vyGJzontHnFKDKIxC9TM7OFMYplPUvWbPXXEZdRKmkIkXgDVRQhhPV9u4Egojy91YgQTTwL3JTEmZqfuiH_1Z6Wh1H2gMrGgDc1QErfR3xCU5UGzZTy0yOdyyAhyCxfMAiQCFqARQAt1kSsmI9y3SnG0iIxTZfwfx8zTud6-ePbToPJwm-OFNccBKkS6H93kOU=w256-h240-no)

- These are the secondary commands.
- There is enough space for commands to have up to 10-letter names.
(Still lobbying for a Defend command! :P )


EDIT AGAIN:

(https://lh3.googleusercontent.com/2967udAGwLkwzygQPokn_bq7ZIwbigtsRASUC3JbVMwbyi36UMXTx7msPyqSv76rg_mUhfMmeD8Q5dKcBCPks-PjXCBXUEskgkfTebKQSbgcyU3sZkNe2aHkqvoK4KQ8RylM5L5yWQzW0hE_T97tMSFI7OTnmfW74mJ8V5bc1bBYGwCi8m5dUjKw-vG8zGZFFaLolZLucRDGOgc9fDGGyQUCXhVneLDxtGH7BDc-Lb01ORufnHEmuuj_E9LIU0ggq20dWg0O6CxkUmlC3ef046VyPv7k2bhrAE1hkHYaSkfbpbd49k9Mli5nzoudoEkC8_C3yunD9OjEuLKP5bJF_fXMaOtTNPnfZFlNU95x7RxLiPghQl4U51r4I9CidyxHW1_B-h-2hPFvwwxzwmspAffHnrapZW61H0jWt4wGuG3VS4PW-Pmbt7Zum4mZEDcmMN5Z3rinLclnjPMWdap0echTsxceQ14O0gnpmwuatTfJokenaDU8a7qDGkQjXR5YcpS9vluFoGCJdGlYL4lgxdhuB0ta0ZEfhI5emFuTKOuwQpbKuJL8sJ2cqQo54HoI_8WsMJ0OHxhK-5D4_2ynb9KmPazlviOJt8q2QTvuSdQkUbfcKlC63h5VXfKVgWW2CGDGsGgLwuKw7EsVou0gmDWx9s1-Eqs=w256-h240-no)

One more for the road! Here is the first pic with all the precision borders removed.
~ What dreams may come. ~
(>^.^)>

See that is what I was thinking of the picture you just did. That would've made it neater. But, where can MP can display though? There should be number display next to the enemy names, so it can identify how many enemies left. Do you think that a good idea, Vanya?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 09, 2019, 06:31:16 pm
Throwing out my 2 cents on Vanya's mockups:

This may or may not also be a problem with the latest version of the hack (harder to tell with that NTSC filter and I'm too lazy to download), but these mockups definitely step outside the NTSC safe zone.  Older CRT TVs cut out some of the borders when rendering... leading to many games putting garbage tiles or having drawing artifacts along the border... leading to EMULATORS also cutting out some of the borders (usually just the top and bottom).

As such, you really shouldn't step outside the center 256x224 area... or if you're REALLY careful the 240x224 area (but that might be a bit excessive).

You can disable this clipping in emulators, but I would not advise you require that of your users.  Aside from just generally being a pain in the ass, it would also make a lot of games (including FF1) look terrible.  FF1 would have drawing artifacts when scrolling up/down on any map.

So yeah.  Stick to 256x224.  Additionally, enemies are part of the BG and therefore are constrained to tile/attribute restrictions.  I reworked the mockup to be more technical:

(https://i.imgur.com/IHg0H2H.png)

(https://i.imgur.com/cBMyPJG.png)

(Bottom one has attribute lines).  I cut it down to 256x224.  Also I worked it out so that enemies are spaced similarly to the original mockup, but land on 8-pixel boundaries.  Additionally, while some enemies use a LOT (9!!) of attribute blocks, no two enemies share the same block, nor do they overlap with the battle BG or the menu.  Making this actually possible to do from a technical perspective without having to switch to ExAttr mode.

Writing the code to build the attribute table might be confusing, but I can probably help with that if you want.  I love that kind of shit.

I didn't bother touching up the heroes since they are sprites and therefore not bound to a grid.  Plus they look fine.


As for the menu with only some commands visible (with that little arrow) ---  I find that to be very unintuitive.  Unless that arrow is blinking it's really easy to miss.  Not to mention the added difficulty of doing a redraw when the user presses left/right.  I would say try to cram all the options on screen at once, even if it makes it a little crowded.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 09, 2019, 08:05:57 pm
See that is what I was thinking of the picture you just did. That would've made it neater. But, where can MP can display though? There should be number display next to the enemy names, so it can identify how many enemies left. Do you think that a good idea, Vanya?

Well, the MP is displayed in the Magic menu when you select which spell to cast.
Since this game doesn't use a single MP stat, but rather 8 of them, there really isn't any space to display MP. Plus not every job even has MP.

An enemy counter might be a good thing to add, yes.


Quote from: Disch
Throwing out my 2 cents on Vanya's mockups:

I differ to you on all that.
I was pretty sure someone would mention the over scan issue since I ignored it entirely.


Quote from: Disch
As for the menu with only some commands visible (with that little arrow) ---  I find that to be very unintuitive.  Unless that arrow is blinking it's really easy to miss.

The arrows, I imagined, would be just like the ones in FF3 that let you know that you can scroll up and down. Those arrows are sprites, and though they actually don't blink in FF3, I agree that should be made to blink if added to this hack.


Quote from: Disch
Not to mention the added difficulty of doing a redraw when the user presses left/right.  I would say try to cram all the options on screen at once, even if it makes it a little crowded.

Again, I will differ to you on this, though you have to admit that it would be an epic feat.

I am curious about the added difficulty.
Is it because it would basically require a lot of custom code?
I would have imagined it wouldn't be too much more difficult it already is to display the magic list or items.




EDIT:

Just had a thought. Would it be significantly more difficult to draw simplified battle message along the top of the screen over the battle background?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on April 09, 2019, 08:40:04 pm
One thing to remember with BG layer is that palettes can only be set in 16x16 pixel increments. (that is, each 2x2 tile section, including the top row that is typically hidden by emulators in NTSC mode, MUST use the same palette.)

Oh, I forgot MMC5 can do 8x8 palette increments BUT only as one of the possible uses of the extra (1KB?) RAM. If you are already it using as RAM expansion then I don't think you can combine them.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 09, 2019, 10:22:43 pm
As such, you really shouldn't step outside the center 256x224 area... or if you're REALLY careful the 240x224 area (but that might be a bit excessive).

*sigh* I really had hoped 30 vertical tiles was going to work... My computer shut down in a power surge a few weeks ago and Mesen's settings got reset, so ever since then I've been seeing the tiles on the top and bottom looking glitchy on maps, but then also started seeing more empty space everywhere to use... Now I know why all that is. I'll move the backdrop down a tile and figure out how to scrunch up the bottom as well.

So, I am really happy you're offering to work out the attribute bytes.

I am curious about the added difficulty.
Is it because it would basically require a lot of custom code?
I would have imagined it wouldn't be too much more difficult it already is to display the magic list or items.

Just had a thought. Would it be significantly more difficult to draw simplified battle message along the top of the screen over the battle background?

Its not difficult at all to make the command menu scroll or have a left/right page. If I can make a scrolling item list...

Messages on the top of the screen are... I would say, with the current battle message code... impossible. I'm still only just barely grasping exactly what its doing--HOW its doing it, rather? All the tiles you see on the lower half of the screen are kept in RAM and it draws the whole block every time it changes something? So putting a message up there... would have to expand the RAM size to fit the whole screen maybe?? And then re-draw the enemies, and the backdrop, which aren't set to be put in the RAM part in the first place...

I think a blue text background will be simple enough to do.

I got the name box staying and re-drawing and even updating itself after attacks just by... drawing it before any other boxes. Everything was working except the end of battle boxes drawn by Bank B leave behind gibberish when they undraw. It only flashes for a few frames before the screen changes, but its weird all the same.

So I'll work on making the name box smaller and wider, have the command box write over the enemy roster box--see if I can undraw it when selecting Fight or Magic so you can see the enemy names then.

(https://cdn.discordapp.com/attachments/535538496547586060/565414035541983254/unknown.png)

Problem: Gaps between characters means the ailment icons won't line up unless they're sprites, too. If they're sprites, then there miiight be flicker during attacks, if enemies have sprites for ailments (which I think they would need to be, or else their ailment icon would be coloured by their attribute bytes?) You can't see it now, but the bush icon will show up to the left of the heart when they're hidden. Unless the "no more than 8 sprites on a scanline" thing means sprites that are 2 tiles wide...? I'm so confused about that.

Additionally, I'd like to have a maybe-flashing icon show up beside a character when they select an option.

Fight: Sword
Magic: White or black orb depending on the spell
Items: Potion (maybe bell, feather, bomb, depending on those items)
Gear: Armor
Hide: Bush
Flee: Right arrow
Guard: Shield

There's still room for 5 more in-battle-only icons... and it doesn't need those box connectors anymore I guess.

Tomorrow or the next day I'll work on fixing up the cursor positions and getting the enemy window to show up properly, then figure out why the magic and gear boxes have errors.

(https://cdn.discordapp.com/attachments/535538496547586060/565418721330593793/unknown.png)

Magic is doing... this, whatever this is. (this character has no spells)

At least it works right when they do have spells. I put in the max MP too.

(https://cdn.discordapp.com/attachments/535538496547586060/565422999000317952/unknown.png)

And the gear box is doing this:

(https://cdn.discordapp.com/attachments/535538496547586060/565419012586995735/unknown.png)

Final Edit:

Fixed those last box issues. While removing the top/bottom part of the interleaved text, the code that draws spaces was left drawing to the top part instead of the bottom part that's actually read... In summary, I changed a 0 to a 1.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 10, 2019, 02:11:28 am
Damn, almost the exact same thing happened to me with Mesen.
Good luck wrasslin' with those battle menus.
Wish I could help out more directly.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 10, 2019, 10:41:56 am
Is there anything that you can change weapons and shield in-battle?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 10, 2019, 07:30:14 pm
Problem: Gaps between characters means the ailment icons won't line up unless they're sprites, too. If they're sprites, then there miiight be flicker during attacks, if enemies have sprites for ailments (which I think they would need to be, or else their ailment icon would be coloured by their attribute bytes?) You can't see it now, but the bush icon will show up to the left of the heart when they're hidden. Unless the "no more than 8 sprites on a scanline" thing means sprites that are 2 tiles wide...? I'm so confused about that.

Well, you could change the gaps between the characters so they line up like the enemy tiles have to.
That way you don't need to have sprites for the status icons.

My understanding of how sprites work on the NES is that all "sprites" are 8 pixels wide, and depending on the mapper can be 8 or 16 pixels tall. So each player character is actually made up of several sprites.

BTW, what is the heart icon for exactly?


A couple more mock-ups with the alignments adjusted and consideration for the over scan:
(Might be better to shift the enemies up one tile more than I have them in these pics.)

(https://lh3.googleusercontent.com/mUmHBoK8x5g_2kgXFjBwejz2GuoS41YCjVyIRwQ_5qsL4P_mZ00XQOEdEy61a742EI_-r6bHSdeAfP-5PSyRlN0LLG3Sl-JdesKUZw2LUeQn8rn2RrbVCcW8WMkRN2ekbnNpbwh0nmspzj0jDAYbNhW6rIVgW4otuPTfzectCemY2I1mejCmub6g1Y3BE4lQc02vS2BhB0BmeL6vc3u3xIcn7abngCtBpQjOFxZ3V4bU8pc-P7s_B2G1tJ1pDQR_kL8Ig0RWrFgIJ5uFOySFmNrbsPRWndWVMSlodlgnXSz4dVucNm5SvLU2fu0sQGQC3ZZwaPnFkr-ozsmLK8UjIToD3bn0plfLnqxC1dDagR1_jnrmIHMcElr15aHqWnwSMo3ZJYqV6yohVDDbjqhUbaLLUkqGrSBiuQyy423E0UsK_VyQd_JQyKlIHRlI7ROiv8P0RtnoV68BP1lhLqcHGopBtsAp2fGKporKEWWYFh7vTReP4BoahiiBF7GJOk0RH5oJZ4nTECTsgHSrD5_FfEKZ0GlOeNZMx16fvBlj8YO8dDp7prFPcv09KPYcFT2IMUzpFvJxqz4c4dcHUTuIUS31l_1-5Q70Y6_hxiCTrhWO39MGx-1Eea9lATkNd651uHRL9XeCtDD2ICbjWCKWMd2d_bemZSc=w256-h240-no)

(https://lh3.googleusercontent.com/nCtfOtxBO_-UCWHz4w-YhsEuuap5s4spPS_52p39TiAF7ZkrJTS3DxHeI2e39UZSTOUK2P-6ttFcR2d1bKtzuincecVDmJD5NC9ior0EgJViv2leGD-iNuiZ88sbAbSlscu3FQUCneqzWpzmAF03e9N3nep4gLP02xayRrfkheGLjpPKiM_zuZ_ilpd0EmoZGCBZ2FR1V9IeNvqPeFjJhih3Iv7mzJaqUPT6v84FRjIskMISsjf-Vrp9WMAaZto7QQE9Wb1vkaMHgRAIr57P9igBXRPfvF1dkFkAMPkSEJmJamhPlq2kisA4i_kRY6JKPEXCzS2nMlsqBodtEfkIuabfUYBLWAj2P2RGZN7KsNd_ZAnZDEPjxXu2EAEMlziWUd_09gMs0QbXV0tz2rpxnFdcIRe7bBeRQgHqfgMHGYnUZ9UtYXUAJCBmq-uq1tgLu_lOVrYo9acC6NC-rLhMiGbcVGhdn6XiqgDlyN13PhCndD3cqJ04P4hSb_9qi605LTxwy5cUiuXKVJCDqVmQFlo_94bCZmyQoCeQrIJrReFQ8K3widtwBt0cMqwYfFickyP2FpseaxZpJ87_C9SQu0S6nHqURTYxqdFoM2aJzZQUZ0V5V-Le02BTBt0CppVBIZObeoWeqJTRw8Tyujt0FthiZi4lbxA=w256-h240-no)

If you can get the scrolling command menu working, that does have the advantage of not having to worry about squishing the command names or coming up with shorter names.

FIGHT -> Fight
MAGIC -> Magic
GEAR* -> Equipment
ITEMS -> Items

HIDE -> Hide
FLEE -> Escape
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 10, 2019, 08:21:11 pm
Is there anything that you can change weapons and shield in-battle?

Someone could, but I don't really want to work on that. Would require making a new menu option, a new menu, and re-working how stats are stored in battle. The menus would be the easiest part for me at the moment, but I don't want to work out the stats... Right now, every stat that can be changed by magic or enemies is backed up before battle and restored after battle, but before level-ups change them. Then to unequip a weapon, it sets a bunch of stats to 0 sort of, then applies the weapon stats of the new item. So either the equipping code has to deal with the battle back ups as well, or the backups have to be handled differently... >.<

BTW, what is the heart icon for exactly?

I don't even remember what I was thinking when I made the ailments into icons... I put the heart in there probably just to show "healthy and nothing's wrong" and liked the way it looked in the menu...

https://drive.google.com/open?id=1gOJfLULq4E1O2nW7DLxC76CPnaM5a9vR

I think this is as much as I can do for now!

So far the bugs I can find are:

* Some big enemies will change the backdrop a bit, if they're in a mixed battle formation. I'm gonna leave the positioning of enemies and the attribute bytes to Disch!

* HP is not updated at the end of a battle turn, but is at the start of the next, whenever the message boxes are updated.

* The code to draw number of each enemy needs to be re-written a bit, I have it set to exit soon as it finds an $FF because I thought like a goober that the game would put enemies in order, but I'm fighting 6 sahagins now and the order is $FF, $FF, $0C, $0C, $0C, etc... so its not drawing the number at all.

* Some of the boxes are a bit wonky--the attack name box is a lot longer than the damage box below it. Gonna look into shortening the attack name box as much as necessary, then have the level up boxes use a different size.

Apart from that, everything else seems okay so far. The enemy roster box is drawn first, so you see a flash of it before the command box, and when the turn starts you see a flash of it again as both are undrawn. Not sure what I can do to fix that... I did it that way so the magic box wouldn't be flashing weirdly when selecting an enemy target for spells, but even then you see a flash of the command box between the magic box closing and the roster box opening... *shrug*

Thanks again to everyone for your suggestions and interest and help! :D
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 10, 2019, 08:41:13 pm
Quote
* Some big enemies will change the backdrop a bit, if they're in a mixed battle formation. I'm gonna leave the positioning of enemies and the attribute bytes to Disch!

I'll try to get some of that done this weekend.

Have you given up on git?  Looks like last push to the repo was over a month ago.  Should I just modify the files and send a zip back and leave it to you to figure out how to merge them?  How do you want to do this?

(it's really a lot easier if we use git and I can just make a branch on the repo.  Then you can see my changes and just click a button to merge them into your main branch)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 10, 2019, 09:25:02 pm
I keep waiting until things are "perfect" before uploading there so I could just... wipe it and start over, but... what the heck. I think I updated it now? Maybe better to just get in the habit of using it, even if things are still kinda messy.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 10, 2019, 09:28:18 pm
Did you push?  Github is still saying a month ago.  Or do I have the wrong link?  Or did you commit without a push?

https://github.com/JiggeryPonkery/FF1-MMC5  <-  what I'm using

Also you should add me as a contributor so I can access the repo directly.  Instructions are here:

https://help.github.com/en/articles/inviting-collaborators-to-a-personal-repository

My github username is BenWenger:  https://github.com/BenWenger
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 10, 2019, 10:50:51 pm
Oh... I'm not sure if I did it then, or just now. I followed the instructions to add you, and then... tried to refresh something, and now its showing on the website as "an hour ago" with the updates.

I'm using GitHub Desktop, Windows 7, and selected the updated files on the side bar, and clicked commit to master, but I only found the Repository > Push command in the title bar now. Sorry!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 11, 2019, 12:33:14 am
Sweet!  I got the invite and accepted it.  I'll poke around later this week or weekend  :thumbsup:
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 11, 2019, 01:37:10 am
I signed up, too.
I'm not great at asm, but I may be able to at least contribute a little.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 11, 2019, 02:20:57 am
Woo! Figured out how to send the invite to you too.

Found a bug I forgot about... casting magic on a specific enemy will default to the first enemy if any other enemy dies before the spell is cast. Completely baffling.
Edit: Also just... doesn't target the correct one at all I guess?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 11, 2019, 03:27:13 am
Groovy! I'm testing the game now. I love the way the battle screen looks so far!

I want to mention one thing right away.

Don't know if this is something you'll want to consider implementing, but...
FF3 likely also had the same issue with the enemy names being visible only briefly at the beginning of each battle.
What they did in that case was make it so the battle starts in a sort of paused state waiting until the player presses a button before it displays the command window.


EDIT:
There does seem to be an error with targeting.
Even when I'm just attacking, they seem to sometimes pick the wrong target.
Almost like the target is random or something.
Is it possible they are always treating their target as if it was already dead?


EDIT2:
About the start of battle enemy names, I noticed a possible alternative solution.
When the enemy group gets an ambush on the party, their names are not displayed at the start of battle.
So maybe just have it not display the enemy names at the start?

Sub-EDIT2:
Took a while but my party finally got a surprise round off on the enemy.
In this case, the game doesn't draw the enemy names at first instead drawing the surprise attack message.
But, then it draws the enemy names followed by the command window.
Seems like the enemy name box is tangled up with the command window?

Actually, could you give me a quick rundown on how these boxes are displayed?
I know you mentioned graphics being in the PPU memory.
Are things just moved around the screen? Are things sort of un-drawn?



BIG EDIT!!

Game crashes when I try to cast a spell from within the party menu and it doesn't have an out of battle effect.
Mesen says that there was an unrecognized opcode.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 11, 2019, 01:34:37 pm
I have only vague recollections on how the battle boxes work.  I remember them being a nightmare.  I don't remember enough about them to give a rundown though, I'll leave that to Jiggers  =x

In other news, I got the "9 small" nametable positions worked out, but they seem to be getting cut off by the menu drawing that happens later.  I'll have to look into that  =x

(https://i.imgur.com/hOrVI4s.png)

Attributes still need to be done, too, and it's going to be tricky!!!

EDIT:  Okay I think I figured out the menu drawing problem.  Looks like the menus are getting soft drawn to the $0400 page before actually getting put in the PPU.  The $0400 page starts getting drawn one row higher than it probably should, which is why that bottom row is getting drawn over.

Moving down where it gets drawn, of course, moves all the menus down.  So it looks like I'll have to find all the boxes and move their menus up by one row.  Barf.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 11, 2019, 04:24:55 pm
In other news, I got the "9 small" nametable positions worked out, but they seem to be getting cut off by the menu drawing that happens later.  I'll have to look into that  =x

I fixed that! And I think updated the github thing too! With the fix! This is exciting. Edit: I spent too long explaining boxes before posting, oops...

I'm gonna try to explain the boxes now. I might not make it.

So at the start of a normal battle, it draws the player name box: Bank C, FinishBattlePrepAndFadeIn

When it gets to BattleLogicLoop, it draws the enemy name box, then the command box on top of it.

It uses UndrawNBattleBlocks_L (Where N is the number in A, so it always LDA #'s first) to remove a box.

SOMETIMES it uses a variable called btl_combatboxcount_alt and sometimes it uses btl_combatboxcount to know how many boxes are currently drawn, so it can use that number in A while undrawing them. I think these variables are only actually used for mid-battle stuff: Attacker, attack name, defender, damage, etc. Menu boxes the player is in control of don't use them and just undraw the boxes as needed.

As for how each box is made... after the game chooses what kind of box to draw, those different routines load up a table of 5 bytes: look for lut_BattleCommandBoxInfo to see them all. DrawBattleBoxAndText has the explanation for how the bytes are used. Basically just width, height, X and Y coordinates to start from, and the first byte is 0 if its a box and 1 if its text--in which case instead of width and height, its the pointer to the text string?

Sometimes there's some... fiddly stuff, I guess, where it takes all the text data and puts it in RAM at $0340. (First it clears it though: ClearUnformattedCombatBoxBuffer) The best example is the magic menu. You can see the unformatted strings there: The L, the #, the $FF for space, the $0E for item name control code, then the spell's item ID, and so on. The game puts it there (well I chose the location so I can see all the drawing stuff in the same space instead of all over $6000 somewhere) so it can read what it needs to draw while switching banks to get the item names and stuff.

And THEN a single text string is formatted to RAM: I've moved this to $0320. When you open the magic menu, and the game's still running, this will display the last line of the box, the level 4 or 8 spells.

So it will read the unformatted part, format it, then draw it inside the box. This seems quicker than the usual way it draws text in menus, which is to keep bank-swapping back and forth as it formats and draws every single tile in turn?

Then, uhmm... I guess before it draws all that to the screen, it first copies it to $0400. If you put the RAM viewer to have 32 bytes a line, you can actually see the screen if you have the right table file loaded!

There's also ClearBattleMessageBuffer, which basically clears the "screen" in RAM, before doing any of the actual formatting and copying of tiles.

BattleDrawMessageBuffer draws the RAM screen to the PPU... It draws 1 row a frame from the top to the bottom.

And where it gets complicated is BattleDrawMessageBuffer_Reverse, which draws 2 rows a frame, from the bottom to the top.

Then UndrawBattleBlock does a bunch of stuff to clear the screen in RAM, re-draw it without the last box, and then it uses the Reverse version to re-draw it to the PPU so it looks like the boxes are folding upwards as they vanish one by one.

So every new box drawn or erased, it goes through the whole process of figuring out how many boxes, what's in them, copying the source pointers to RAM, formatting them line by line, copying that line to another part of RAM, and then finally drawing the whole message half of the screen.

I THINK.

I'm still not entirely certain.



Update: Fixed the magic in menus bug, updated the box drawing logic for menus. So now:

Draws the player box first, then it will draw the roster box, and waits for any input (any button I think) before drawing the command box.

If surprised: Draws the player box, does the turn, then draws the roster box and does the wait for input before drawing the command box.

The input wait thing only happens at the start of battle, not between turns!

Magic menu undraws the command box, no more seeing flickers of anything between boxes being drawn.

Player HP should be updated after every entity's turn properly.

If you figure out sequence of menu logic that undraws something that shouldn't be undrawn (player box vanishing, command box not showing up when it should be) please try to remember exactly what you did!



I am INTENSELY frustrated about the header bytes with these boxes. A byte of 1 means that the Y position is 1 down from where I want it to be, somehow. You just can't put text on the top border of these boxes! And I can't figure out where its doing this...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 11, 2019, 08:39:34 pm
Hah, I also had fixed the menu drawing thing shortly after I posed that.  hahah.  :beer:

Anyway I think I have it working but right now I just have an imp battle and they're all using the same palettes so I can't be 100% sure yet.

Still need to move the cursor positions to match the new enemy positions, AND I need to update the code that erases enemies (when they die) to erase the new area.  Plus also the damage animation when you attack enemies is probably messed up too.

Also this is just the "9 small" formation.  I have it sort of set up to support the "4 large" and "mixed" formations but I didn't get to that yet.

(https://i.imgur.com/m1gwWH7.png)

My changes are pushed to the 'enemyplacement' branch, but don't merge them into master yet as it's still kind of broken.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 12, 2019, 12:49:35 am
Yay! Don't worry about the cursor positions, I can handle those. Though it might be faster/easier for you to do them... just saying, if you don't wanna, I can do it. Same with the damage animations. They're just LUTs that I can tinker with to fine-tune and let you do the hard work!  :D

I made a few more changes... Casting magic on party members doesn't screw up the boxes anymore... Hrmm... I guess I was poking at trying to print text on the upper box borders that I thought I was doing more work than I actually got done today.

Besides the Guard command, I guess that's it! So, Guard command!

Level * 2 + Defense = Defense when attacked by a physical attack. Does not print any sort of message about the character guarding during that turn. Shield icon shows up in place of the bush icon (bush icon will overwrite it though, if someone uses a smokebomb on that turn to enable hiding as well.) Guard status is cleared at the end of every turn.

I put a Skill command in as well; it only does magic right now, but the cursor positions were going to be weird if I didn't add in another one.

I put Items on the upper right, because I kind of picture the two sides being Offensive/Proactive, and the right side being Defensive/Reactive. Attacking, casting, using a skill (someday), using an equipped item: all actions that progress the battle. Using a healing or effect item, guarding, hiding, running away: all actions that stall the battle or give you some defensive buff? Also running away.



A few more updates pushed... Not sure how to trace why battle targets are getting messed up though. But, also haven't tried to do it at all yet. Once I actually put effort into it it might be easy enough to catch and solve.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 12, 2019, 05:55:35 am
Love it!

The only thing I can nit pick so far is that the Items box could probably be one tile wider just to make it look a smidge cleaner.
Everything seems to be drawing and un-drawing correctly, too.

I prefer a different arrangement for the commands, but I already figured out how to change those myself for my personal use.

This is my arrangement if anyone is curious:
Spoiler:
Code: [Select]
Column 1:
   Fight
   Skill
   Magic
   Items

Column 2:
   Guard
   Hide
   Flee
   Gear

Oh! One thing I noticed is that the Guard command draws the shield icon immediately instead of waiting until the character's actual turn to come up. Is it applying the improved defense immediately, too?


PS-
Finally heard your new Marsh Cave song!
Love it! It fits right in with the rest of the music in the game.
I can totally imagine it also working well as the BGM for the ruined castle, too.

Are you planning to add any more songs?
I've always felt this game could use more music than just the extra battle themes they added into the remakes.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 12, 2019, 02:53:53 pm
Ah, yeah, the item box doesn't undraw the command box, so there's the command box border behind it now...

I prefer a different arrangement for the commands, but I already figured out how to change those myself for my personal use.

Woo! That's the point of this; to make it easier for people to do the changes they want to see!

The guard command was tricksy. It needs to take effect at the start of the turn, but there's nothing already set up for applying effects before enemies get a chance to act, so I triggered it to happen basically once you choose the option. But then it has to undo itself if you go back, otherwise you just set up a defensive boost while doing something else!

It uses the battlestate stat--same as hiding, but its $80 instead of $10. Which meant the code for showing an icon was already set up, so I figured why not--then I had the icons update immediately after each command input, because they weren't updating at the start of the turn for some reason. So if you had two characters guarding, neither one would have a shield icon show up until someone else took an action. *shrug*

So the way it works is, when an enemy does a physical attack, it loads the player's stats into the defender stats at $6030. While its doing that, is when it applies the defensive buff. That way its not directly editing the defense stat, the way Fog does, so it doesn't persist between turns.

Also, how do you feel about having it be renamed to "Def." and squishing the command box a tile to the left again?

Finally heard your new Marsh Cave song!
Love it! It fits right in with the rest of the music in the game.

Thanks! I actually wrote a bunch of new songs for the hack I was doing before, but I don't think any of them fit in FF1. And FF1's music is mostly good. The only songs I don't like besides the old cave song are the airship and floating castle. And that's just more a personal "eh, the melodies aren't that great to me" thing than an "ouch my ears are crying" thing. I still need to finish up work on that Fiend battle song I was doing and put it in... I really didn't like the remakes' new music, so I have no desire to try to put it in here or ask the person who put it in their hack. But if someone else wants to reach out to them for the score I can set it up as a branch in github?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 12, 2019, 05:06:46 pm
Ah, yeah, the item box doesn't undraw the command box, so there's the command box border behind it now...

Also, how do you feel about having it be renamed to "Def." and squishing the command box a tile to the left again?

Hmmm... nah. I'd like it better if the item box was wider than the command box be squished.
Ultimately, I'm going to want to have the command box have 2 pages.
I feel that having the extra space for longer command names is worth the extra effort.

And speaking of longer names, I was wondering if something could be done for the class names?
Unless I'm mistaken, it would just require rearranging the character creation and status screens as the class names don't currently appear anywhere else.


Quote
Woo! That's the point of this; to make it easier for people to do the changes they want to see!

Groovy! There are a ton of text changes in my future by way of re-translating many of the enemy, equipment, spell and item names. :D


Quote
The guard command was tricksy. It needs to take effect at the start of the turn, but there's nothing already set up for applying effects before enemies get a chance to act, so I triggered it to happen basically once you choose the option. But then it has to undo itself if you go back, otherwise you just set up a defensive boost while doing something else!

It uses the battlestate stat--same as hiding, but its $80 instead of $10. Which meant the code for showing an icon was already set up, so I figured why not--then I had the icons update immediately after each command input, because they weren't updating at the start of the turn for some reason. So if you had two characters guarding, neither one would have a shield icon show up until someone else took an action. *shrug*

So the way it works is, when an enemy does a physical attack, it loads the player's stats into the defender stats at $6030. While its doing that, is when it applies the defensive buff. That way its not directly editing the defense stat, the way Fog does, so it doesn't persist between turns.

I like it! It's kinda like what is called in Pathfinder RPG a "swift action".


Quote
Thanks! I actually wrote a bunch of new songs for the hack I was doing before, but I don't think any of them fit in FF1. And FF1's music is mostly good. The only songs I don't like besides the old cave song are the airship and floating castle. And that's just more a personal "eh, the melodies aren't that great to me" thing than an "ouch my ears are crying" thing. I still need to finish up work on that Fiend battle song I was doing and put it in... I really didn't like the remakes' new music, so I have no desire to try to put it in here or ask the person who put it in their hack. But if someone else wants to reach out to them for the score I can set it up as a branch in github?

With all due respect to the person that did those down-mixes (something I could never do without excessive effort and time), I don't really like the 8-bit versions of those songs. They sound a bit too noisy to me, if that makes any sense.

Truthfully, I'm not super in love with most of the new battle music in the remakes.
I think that any new battle music added to the game should be different and bad ass like the battle songs from the other games.

Of the new music in the remakes, the ones that I think would be worth while to receive new 8-bit arrangements are:
"Opening Demo",
"Church" (I'd use this for the Elfheim town theme),
"Ruined Castle" (but only as a basis for a new creepy song for the Earth Cave, just take the castle theme out of it and replace it with something new),
"Deep Place" (as the basis for a new song for the Sea Shrine, right now it's just has a copy of Chaos' Temple with a different tone),
and "Inside a Boss Battle" (this is the one battle song I feel stands on it's own, it would make a good theme for non-fiend bosses; I still want the old dungeon theme for mini-boss battles).

Actually, how can I change the battle music?

PS-
I have always liked the Floating Castle theme, I just think it could use some reverb.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 12, 2019, 06:25:46 pm
Has anyone still noticing the "X-Heal P5" bug that appears in some sort?  :-\
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 12, 2019, 08:11:25 pm
Has anyone still noticing the "X-Heal P5" bug that appears in some sort?  :-\

Is that in a shop, in the item menu, or in battle?

And speaking of longer names, I was wondering if something could be done for the class names?
Unless I'm mistaken, it would just require rearranging the character creation and status screens as the class names don't currently appear anywhere else.

Also the equipment screen, just 'cos. But yeah, all you need to do to make them longer is add more bytes to their name in Bank A. Bank E's got the lut_PtyGenBuf where you can re-arrange the boxes and where sprites and names and the class name show up. I set it so Thief and Ninja are centered in the new game screen but I can take that code out if it mucks things up. Or you can, its at PtyGen_DrawOneText. From the CMP #01 to the INC dest_x, just take that out.

Actually, how can I change the battle music?

PS-
I have always liked the Floating Castle theme, I just think it could use some reverb.

I love the Ruined Castle theme. Exactly my kinda music.

So for music stuff, Bank D, if you want to change the notes themselves. If you mean have a different song play during battle... Bank B, PrepBattleVarsAndEnterBattle--its track $50 (they start at $41 for the Prelude).

Mini tutorial time!

Spoiler:
In Bank B, find this:
.WORD SKYCASTLE_SQ1
.WORD BLANK
.WORD SKYCASTLE_TRI
.WORD BLANK
.WORD SKYCASTLE_SQ2

and change it to this:

.WORD SKYCASTLE_SQ1 
.WORD SKYCASTLE_SQ2
.WORD SKYCASTLE_TRI
.WORD SKYCASTLE_SQ3 ; MMC5 square channels
.WORD SKYCASTLE_SQ4

Do a search for "SKYCASTLE_SQ2:" to find where the actual note data is stored, and make two new labels for SQ3 and SQ4 nearby.

Put the following beneath SKYCASTLE_SQ3:
.byte $F4, $C#, $D0
.word SKYCASTLE_SQ1

And beneath SKYCASTLE_SQ4:
.byte $F4, $C#, $D0
.word SKYCASTLE_SQ2

Now, Sky Castle uses the $FD tempo, so you can check lut_NoteLengths to see how long you want the $C# byte to be--3, or 4 would be something to try. So you'd change $C# to $C3 for example.

And then, go into a town or castle or dungeon, and press B+Select to enter the sound test menu, scroll to the Sky Castle music, and listen. It's echo, not reverb, but... $C4 sounds pretty close to a reverb. $C5 might be too short a delay to really tell. $C2 is too long a delay and it stops sounding nice.

$F4 triggers halving the channel's volume ($F4 again to turn it back up) and $C# will rest for a bit before playing any notes. $D0 loops to the .word following it, so it basically copies the already existing music on a delay.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 12, 2019, 08:34:44 pm
Is that in a shop, in the item menu, or in battle?

Item menu
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 12, 2019, 09:44:01 pm
Do you remember what you were doing before you saw it? Using any items or anything?

Right now there should be no way to get X-Heals in your inventory without adding them into your save file or editing RAM directly while playing. P5 is the text that displays when you have $FF amount. 99 is the cap, so you could change $5C22 to $63 to max them out if that's what you want.

If you started out with 0 X-heals and somehow got a bunch of them after using a different item, that's a different matter...



Trying to do a few updates... LIFE and LIFE 2 should now work in battle. SOFT works, but displays "Ineffective" after displaying "Cured!" so I don't know what's up with that.

All consumable items now play the Heal SFX in the menu.

The Wakeup Bell has its own SFX in battle--but man is battle SFX wonky as heck. I guess they never used it enough to find out its broken if you try to have more than 1 block of square 2 data. I was trying to have it play different notes--a ding and then a dong, but like... 4 of each. Except it only parses 2 blocks, so 2 different notes. So now it just goes tinkly-tinkly-riiiiing, which I guess works fine and doesn't overstay its welcome anyway.

Still don't know what to do about targeting in battle. I'll update github when I'm done the rest though.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 12, 2019, 09:52:11 pm
Do you remember what you were doing before you saw it? Using any items or anything?

Right now there should be no way to get X-Heals in your inventory without adding them into your save file or editing RAM directly while playing. P5 is the text that displays when you have $FF amount. 99 is the cap, so you could change $5C22 to $63 to max them out if that's what you want.

If you started out with 0 X-heals and somehow got a bunch of them after using a different item, that's a different matter...

I only got it right AFTER the battle. So, that's what I saw that it was still there.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 13, 2019, 03:03:44 am
Something's not right cause buying spells in the magic shops got borked.
It's asking for a wierd string as a price and not deducting anything from my gold.
And it gives me the spell anyway for free.

EDIT:
I was messing around with rearranging the Party Generator screen and I noticed something.
I added some Default names so I could see their positions without having to input anything.
However, when I did press the A button to enter the naming screen, the default name was already erased.
Doesn't do much good to have default names if they get erased.

Anyway this is what I came up with to allow up to 11-letter jobs:
(These are in-game, not mock-ups.)

(https://lh3.googleusercontent.com/oa0jAlZkcg4A0Habbqt85BNb_YKS-jNjhgVZePyeOlMPJlvnkrR_ieHQ7Ml0fo7_gMHd-lXwvoIZKeTCIEN8pyn3504sAEecr_Ws2BUpZxfCWSTCcLyXIoVIMoW5YpgniE1aYe6NmAdJGdT2_1jMzCl4cxVdX3JHDxzB0OXk_zeQxJzHRA10kLx0Lm_wvckfPlEBGT1Pbil4mF79IPTiFyiDpbhamYf_30TJc4qtbw14Iie22RfKdlPkOD_iPTEp079EoE7CPV0MRJ6dfjGEh-9SecIPb2k6i2SC_SHYm2ESJ_I8DV_hvsApAGOAN0vhCYOKir7xRUNq5SUTbD22c4_WEJ4HNMcamoHrHXcyYCXRBIfusfyHrazBCBlxy4vugMzYQo5mPFQhawyqc9jIcYDvPP33UDvFoslxfPYQBuALf4yZ3c1sq_BPxIJr5ztMqNM4zEod92C9QxS3LimcbCsCjSdFY8kmGDLXzV0t9knCPKjeVRiBJ-XDcadG2sBtZRji_Wfq6W0US-_ErwlTaMgJbC5zqEy_gQW2BbswJW1xz-sfO0caf4ChjHhyviJ9a73Fg8fotAUwjMVD67SQ8_RpPbubEjot613UP26dTmUVq_98uIj_udmAKRGBltsilG5_z8EUr7iQ7IaB3eaiHJAQpp57HmtSn9XvZnjS55yRDF4OFF--YTZH2WyWTOqnkGh8caDMcksWve2NolXnB1-s=w256-h224-no)

(https://lh3.googleusercontent.com/qcMfqafPU573QsbyIHzC6k6toI6jCGgnwGpiuWGEg-7IcdqeYTing6UUN9Z1AGzKZ3iATmzygAMPG907I6ObP2Iwk0Q7-TfuQMN2zU5NCRF7SyyRgWDx_7MgAY482Icawo3aYiOdvSQpVfLHAc6C9Ug5RA7gr91ByuCzMH2wJxvHFsxok3EG3RVLL7vADdhn7refjYYzHiJ0MxYQcNIt_V5RCgQ41cY27Ts3BrA4au1F9gw3b76tZbbjd3KmTcs41FhCYZ55wxg1qBZfoANSGAturubzNE8aFXZMYgYNpVSZmjwiOTkeRwjCRMOv1ucaWreEHos76OK5uyadUYc5tqaNJ_YxAT4goKRkzfwHO__65zZzGUvjrGme-HbB12mE_GsS-d_0KW7ZPIzKRsgpp-TLu33wwqmM3qDQ89yIGuy0x5DpGq668yXJ1K9zqGxf3UDwtLhKMeP9MCfvI6aasBZCTqlIgHUKVZLj35boShq56wQmIyhGe6Qx5p2zFGN6HluWD15MwXseWcHo_f9C-yF1B8_OB1k3_pSSgAg2HQtZt_Wf8kcLu66Pema7mJ77pFqanspMoABY-U6_SE8ifkr7CTZGcnegYzMejJR6qfNwR4XRRbbmSEdtzJro2fHOXAluhIc__iqh1zLHya71PFN5UDoEfxxL9DGsXYqjaORUhoraZwQQamf7UZiSu7slIVs1lo3w4MsA1h-L2CECKnJT=w256-h224-no)

(https://lh3.googleusercontent.com/Mu9rPmS_44Cg4QYSo-738Vrj6Ul3jtQbxAQ-bKqOCbVHfOc0Ju_jtXeI5ECpYQQkjbNXx-b9kXiO-t-jq27FLCiklYXvKOpEKe3b0ytcQmLssjaleeL2ykOPBJk9DOoOEnBIIVoPccHCwH1h_oAXOHe_CZa73bmoi-ibU7JLXEbVoTlhXGGnzr9fyM59JqionhPv8P4WN0UK0qRff2-o11tCa6TYAmfckr35jk6ictL0vu0lx-i5mTcUgqke2GCnPS1sGMObj4CfIt5JVjqy3cStQFazPbbHfehq3l5XlgQYuVR9Tjud1uT4_mxQ1wszzNBUbDgqW69KZR9YxjsLN2KdsbQCKhvQOKLxZptfRDj2IKItV0X5MGsqbH3cMJV5tbbYvzwWddpcBe-ogLT5eP9ZNY1Df9JRo8MnTgaKdpdZgCxbltJj6DlgEoPobmV5BWGZ05_Ma-DCZtG0FNUM3m9nKxT9-sx3n87u5GzpRN--WD2ar_sNyClGgswwY34dG-k24G2ryBF5AxsGiTZzVo3Y1kvF8wHSBJmSTqlNW88e00pgBfGdmjBwTj0-_0al3gnTiA4P1OxGV8fJX42u-awLhDhNbHw7j01G02hgYxzy4bIYKiU7HdXOk5ohTG57W_uF6PpRzdxt2EcCWPaq7Npe2QDkl4A=w256-h224-no)

(https://lh3.googleusercontent.com/z2FCFrFnCH2PWobDqJGwGipDXlhjESHyVt-17ko15OB8DjnluuE4lhxSJ2oFOGXsngMxBMJ3aoaT-HZdmCQk5C-G3rOVcWl5XEu8aTr_LcrZAuvZVfcHN1uQ-mli_HN-5Fbp-Y5LOTZB68wQ3EsNvVS9GLBpcoBPL19NA8zX9aKgzuKFu2QpzGVRmyp8hlOIlZUXKdNBujUi4S9nxOsclBcDXy8esfVNiLNu-GBRU5PEy10kbXWaJgnE5XhehU1j0KwNEsm2CDssbaIU-GVZUESguG8Y6WGEJ0wDc6xiuc3E_DsQZFr_Px8jrTUj8WEwaPG1qfc9jpeDTl3h3i_3c7C_aahq7rNiMuvkFLbw6jbJUo-O461Amq5Ld1cBm17rAN8woJXDdf_z07RFANJPSyilYkz_GZK0abT7pPdatU4dLyyn1PmpPQAeNyKJO6UErPcH4USvnk1uj_NztYXoXmQYP3cJoS8bxSV5CE3vTeHtdU1XwWa5GIV9WXUi6YinaC1haTdVwGpqblJ_IFQuUBhf6-LVr04dn9dAvyp4LiiGE8tvpKJ8UwEx08YRHoI67NFm93sIf-hRX74PvxeV9TEXoPI8AiUMODsElppoyyVmlDVaKIEPnFXlns0M71cxE8WYl-lrzpJKJd6qmTd85LJkdySFyNk=w256-h224-no)

(https://lh3.googleusercontent.com/o8omjW2tqnRmqZPxaUzigNqti1G7UVfzxbkSLOW2dIA87ML0Tw6SfVjZEWY__y5Nb_QGmjl014VimMXZ0A_m_lrh3fXtWOLBnlq9e1IWZF0fwAl7QcH1-6Y4aWTaMotzUmOPx3VK_TP5ochgzIHvVMu1EYiacR1aF9Av5D0YBG9YkGsDfWXXLFZdj78BOzXUdjT8vGlPGviw7PX5UJzuQFXPIDQk_2GfPiEESVgWiT8tf0SahwefIZKJQmym95bxT1OtKr7Q7wdMERp2Y8IOEWyb-2xBPMQgfaH4d5qb4bHLDlPDDvYor_4vBcIay9ziyjY-ABgu0D4RCIHFu_Qv42ng_arHk7qqWzy2RPW8_bK3qXTC3NrZEf9Fzk6jw1Vy-cLf4oMY96enIIMfM3WNEfTOUJ1myuHNP9nVWFvogaKKUT3OJ1mVnCek0HI21NtuROVwuYVm4D-KmvrARW8Q6--BBC4mJqSiCZjodgl3MzltOOXp1d-tatlPDOTfuh2sBOCVje1gnN2_P-0ld_J93cdcXtclRJ1Z_kNla7-xD_rO30hxW-56oIElBUd9EivpiFjDal3CcQefpuLh-DwspjXsBlRhk19G1TXvYlJJmZRMGgS7KK0X7Wc0sPfuEx3tuyLFoLtAjBlPArp2qYAxZxiAS45EnQw=w256-h224-no)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on April 13, 2019, 11:46:00 am
Are you images private or something? Because I'm only seeing large minus signs for your images.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 13, 2019, 02:31:39 pm
I only got it right AFTER the battle. So, that's what I saw that it was still there.

Did you use any items in that battle? Like a heal? >.> 'Cos... I had the X-heal and Heal swapped, so using a heal would decrease the X-heal amount... which would explain it... XD

Something's not right cause buying spells in the magic shops got borked.
It's asking for a wierd string as a price and not deducting anything from my gold.
And it gives me the spell anyway for free.

EDIT:
I was messing around with rearranging the Party Generator screen and I noticed something.
I added some Default names so I could see their positions without having to input anything.
However, when I did press the A button to enter the naming screen, the default name was already erased.
Doesn't do much good to have default names if they get erased.

Yeah, I'm only getting the grey minus signs too.

What town is the magic messing up in? Everything's been normal for me as far as Elfland, except I ran into not being able to afford magic despite having more than enough money. I had EnterShop clear the shop_curprice variables (that share space with some battle variables now) and that fixed it, but the prices looked normal...

For the names being blank: Look for "DoNameInput":
Code: [Select]
LDX char_index          ; wipe this character's name
    LDA #$FF
    STA ptygen_name, X
    STA ptygen_name+1, X
    STA ptygen_name+2, X
    STA ptygen_name+3, X
    STA ptygen_name+4, X
    STA ptygen_name+5, X
    STA ptygen_name+6, X

I might have put that in because it was easier than filling in 00s after a name was put in but start was pressed to finish it.

Actually... I wonder how names would act if they were null-terminated early... Edit: Okay in menus (good actually), bad in battle. Very bad in battle.

Today's to-do list:
* fix poison messaging drawing
* fix life/soft messaging

* maybe find that targeting bug
* re-write how battle displays names
* make sure you can't press start at character generation without at least 1 non-$FF, non-$00 character in the name...
* get past the marsh cave without the game breaking

* figure out why when a character has over 256 HP, getting hit sets them to 1 HP
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 13, 2019, 03:59:45 pm
Okay so I got the 9 small formation totally working as far as I can tell.  I'm going to start the 4 large formation next, which should be pretty easy now that I have the structure.

I also merged the latest master into my branch and noticed a few bugs:

1)  I think you might already know this, but targetting doesn't work -- it seems to just target a random enemy no matter which on you pick.
2)  Player sprites are .... wrong?  If you start a new party and try to change classes, the class DOES seem to change, but the graphic doesn't change.  This persists into the game:  I have a team of 4 fighters and in game it LOOKS like I have FT/TH/BB/RM, even though they all have stats of fighters.



EDIT:

Wait... is that #2 bug intentional?  Like up/down changes the graphic, but right/left changes the class.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 13, 2019, 04:55:35 pm
Yes it is! In case someone wants to make a hack with characters or something. Or just... no reason, but because I could do it? XD

I wonder if the targeting bug is there if you turn off auto-target in the options menu...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 13, 2019, 05:36:07 pm
Some more bugs:

1)  Looks like during battle box drawing, sometimes you're waiting for a frame but NOT calling MusicPlay.  Which results in the music ever-so-slightly slowing down while those boxes are being drawn/undrawn.

2)  Game hangs after you win a battle??????  I have a FCEUX (v2.2.2) savestate which reproduces the bug:
https://www.dropbox.com/s/1ua66d1slgzg6pd/FinalFantasy.fc1?dl=0

(walk directly right after loading the state, and just hold A to win the fight, then CRASH)



EDIT:

4 large formation is rendering properly!

(https://i.imgur.com/Weo64Ab.png)



EDIT 2:

For the "mix" formation, following the pattern puts enemies pretty close to the party.

Ignoring that the palettes are all screwed up... which of the below would you prefer?

(https://i.imgur.com/UDU0IEC.png) or (https://i.imgur.com/dOMn1Fm.png)



The one on the left followed the "tiered" pattern a bit better.  But the one on the right doesn't get SO close to the top hero (note:  when the hero is swinging his weapon or casting a spell, it bumps RIGHT AGAINST that enemy)


Ideally I could just move ALL the small enemies one tile to the left to get the best of both worlds, but that won't work because then one of the small enemies shares an attribute block with one of the large ones.

So yeah... which one do you like more?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 13, 2019, 07:53:34 pm
I can move the characters back a bit more as well, two tiles if need be, and have the ailments stack up behind them instead of in one row... But I like the second one, giving them more room. Since I have magic animating a tiny bit, more room is always better. Have I mentioned how glad I am you're doing this?

I'm not sure what to do about the music not playing while things are drawing... I don't think I did any changes to the actual screen-drawing routines, so it might be likely the original game had that too? Hopefully I'll remember to get around to checking it out when I finish up the other bugs!

As for the crash... I'm stumped. I did some changes to the end of battle stuff, but that doesn't even get that far. I tracked it down to GiveRewardToParty in Bank B, at least. Which is definitely not something I've touched. It gets to MultiByteCmp, then...

Code: [Select]
      PHP                     ; if not equal...
      PLA
      AND #$81                ; clear all flags except N,C.  Presumably this is to clear Z
      PHA                     ;  strangely, this also clears I!  nuts!  Why it preserves N is
      PLP                     ;  is a mystery, as its result here is not reliable.
      RTS                     ; and exit

The RTS goes straight to the forever loop. *shrug* Doesn't happen on Mesen, though...

Update: I FIXED THE TARGETING BUG. It was... super easy actually... After selecting an enemy, I didn't notice that the target was being put in Y and kept through all the RTSing until it set the command. So it was being thrown away through all the roster box undrawing/command box re-drawing... It still is, but instead of loading it before the RTS stuff, I just have it load into Y after the drawing. What a silly bug.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 13, 2019, 08:26:53 pm
Ugh... I might have sent you on a wild goose chase with that crashing bug.  It's likely just a corrupted savestate.  Sorry.   :banghead:


EDIT:

Okay mixed formations seem to be working, so everything should be done as far as enemy placement goes.  Changes are all pushed to the 'enemyplacement' branch.  IMO, it's ready to be merged into master.

Do you know how to merge it?  Or do you want me to?  (I didn't want to touch master without you knowing since you seem to be working off of it directly)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 13, 2019, 10:09:13 pm
Hah, no worries. At least I got to figure out how to use FCEUX's debugger!

So, I've been poking around this GitHub Desktop program trying to figure out how to even download your changes and... I'm lost. Frankly I'm not even sure I know how to download the master branch after I send a change through. But I'm done for tonight, just pushed one more change to make physical attacks wake up players (and enemies), so... Go ahead and squish it all together if you can! :D
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 13, 2019, 10:19:36 pm
Okay.  I've merged my changes into the latest master.  If you do a "pull" you should get them.  I wish I could help you more with the GitHub Desktop program but I've never used that client before.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 14, 2019, 12:36:12 am
Are the images visible now?


What town is the magic messing up in?

Cornelia. Never mind, it doesn't happen in the current master anymore.


Fantastic work, Disch! Can't wait to see these in action.

About the player character positions, I think having the status icons in a column instead of in a row so they can be pushed back a bit would be a good idea.

And last thing before I get to testing. Should I start a branch too for all the tinkering I'm doing?
Also, can specific files be merged into the master or does it always have to be the whole thing?


EDIT:
Just noticed this. When I talk to an NPC their sprite disappears behind the background layer.
It just makes them disappear entirely unless the background tile uses black.
In those cases they just look like they are behind the background.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 14, 2019, 01:35:46 am
Yeah, probably best to keep things separate--I break enough stuff on my own! XD

I really like what I see so far! Haven't gotten into battles that press the small enemies up closest yet. When I do, I'll see about moving the players back. That HP bug is driving me crazy right now, and there's still some more things I want to tweak... and then I think I might take a break for a while. Maaaybe. This is kind of addicting.



EDIT:
Just noticed this. When I talk to an NPC their sprite disappears behind the background layer.
It just makes them disappear entirely unless the background tile uses black.
In those cases they just look like they are behind the background.

Somehow a change I made got undone after I undid the change. I had one of those "what if" moments and thought if I changed a number, I could get rid of sprites covering up the bottom of dialogue boxes. Ended up just not showing them a tile lower at all. I undid it, but must have uploaded it too late and it got back into the github version? Anyway, fixed that!

AND I found out why the high byte of HP was getting turned to 0... because uh... I didn't understand why the mathbuf high bytes had to be zeroed and just... zeroed all the high bytes... even though that's where defender HP is kept...  :P

Oh! And I can see the first two images now. That works alright!

Thanks again for all your efforts lately, all of you!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 14, 2019, 03:16:05 am
Groovy! Glad I can be of use.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 14, 2019, 01:03:16 pm
Should I start a branch too for all the tinkering I'm doing?

New branches are free and you can have as many as you need.  Don't be afraid to branch!

In general, best practice with git is to always be working in a branch, and only bring things back into master once you're sure they're stable.  That way master is always in a good, stable state and if something gets really screwed up you can always easily fall back to the latest master.


EDIT:

So I'm looking into the audio thing because that broken tempo is REALLY noticeable to me.  I suspected it had something to do with the name/HP box at the bottom since that seems to be the biggest change.  While looking into it I stumbled upon this:

Code: [Select]
DrawCharacterStatus:
[snip]
    JMP DrawComplexString ;  Draw Complex String, then exit!
   
    ;(these don't seem to have any effect on being taken out)
    ;JSR BattleUpdatePPU                 ; reset scroll
    ;JSR BattleUpdateAudio               ; update audio for the frame we just waited for

*cough*that last line*cough*

Though even after putting that last line back in, there still is some pause when undrawing boxes.  I'll continue digging.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 14, 2019, 04:30:00 pm
I've been looking today, too. I'm actually just wrapping up re-doing that whole status drawing part, going back to how the original game did it... sorta. At least ditching DrawComplexString to do it. But DrawComplexString plays audio while drawing its frames, doesn't it? Maybe it doesn't do the battle SFX properly, but... Don't see why it would stutter the music... The "Ready?" message uses it, too. Mostly I notice the stutter when casting an all-enemies magic spell, somewhere between drawing the damage and undrawing the "Terminated" and damage boxes all the way.

Edit: And pushed. Pretty proud of this one! Also moved the characters back one tile.

Question: Is 999 the highest damage you can do, or can it go over that?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 14, 2019, 05:34:49 pm
Pretty sure you can one hit KO Chaos in the original game, so damage goes up to at least 4 digits if not the full 65535.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 14, 2019, 06:45:06 pm
Gosh. Alright then, I should adjust the damage box another tile wider...

One more update pushed. I think Vanya will like this one.

Party Generation screen, though--not sure what to do about that. Did anyone like the characters on the black background? I changed it back so the three screens on the intro screen have the same style.

Edit: Anyone have experience with Tile Layer Pro? Trying to copy-paste some tiles but the paste just floats over the tileset and won't save over the tiles I want to erase. Update: Figured it out, but this program keeps crashing, and YY-CHR can't read the .dat files with enemy tiles... Update 2: Alright, figured out how not to crash the program. Now just... to undo what I did.

(https://cdn.discordapp.com/attachments/505736168659353601/567139640830853138/unknown.png)

Not sure a battlefield can get any cooler than this though. Those ogres must be needing some therapy after all that shade thrown at them!

Final Update:

(https://cdn.discordapp.com/attachments/535538496547586060/567158096666034176/unknown.png)

Re-arranged all the icons and some letters. $C1 is now not ever used as a space when there's $FF to use. Out of Battle ailments have a coloured background for the menu, the rest have a black background for battle. Consolidated a lot of the icons so they make more sense (mostly); item icons by themselves, ailment icons by themselves. Some battle icons are merged in with every enemy chr data, so they're not shown here. So there's 7 or 9ish free tiles to use for things later. Shop chr also has its own tiles that are used by the shops and the intro text! Phew.

Next I might focus on cleaning up shop messaging and making use of the message box in the equip and magic screens better.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 14, 2019, 10:34:25 pm
Which Status icons represent what?
I got stunned yesterday and the icon looked like it was half way between a sparkle and poison.


One more update pushed. I think Vanya will like this one.

Yes. Yes I do.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 14, 2019, 10:44:56 pm
Yeah, wasn't sure how to represent that... so:

Death: Broken heart
Stone: Shiny Egg (someone please make a better icon)
Poison: Skull'n'Crossbones
Dark: Sunglasses
Stun: That sparkly lookin' thing.
Asleep: Zz
Mute: ?? (also wasn't sure how to represent being too befuddled to cast magic...)

I'm pushing my changes to my own branch now, in case I screw something up. But somehow poison started displaying garbled text while undrawing the boxes again, and I don't know why.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 14, 2019, 11:01:03 pm
Yeah, wasn't sure how to represent that... so:

Death: Broken heart
Stone: Shiny Egg (someone please make a better icon)
Poison: Skull'n'Crossbones
Dark: Sunglasses
Stun: That sparkly lookin' thing.
Asleep: Zz
Mute: ?? (also wasn't sure how to represent being too befuddled to cast magic...)

I'm pushing my changes to my own branch now, in case I screw something up. But somehow poison started displaying garbled text while undrawing the boxes again, and I don't know why.

Mute is the dialogue with 3 period marks (dots I'm mean). If the enemies mutes spell the player, then the player can't cast magic. If player cast mute to the enemies, then enemies can't. :laugh:

And yes I have used the heal in battle, and that is why that causes the problem according to what you discovered.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 14, 2019, 11:36:12 pm
(someone please make a better icon)

I'm on that one.
Will probably evaluate them all for myself.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 15, 2019, 05:54:54 pm
I guess this might do for mute. I did try to make this icon before, but the problem was the three dots don't fit. But if the dialogue bubble is grey instead of white...? Otherwise it looks like an ocarina.

(https://cdn.discordapp.com/attachments/535538496547586060/567467045952946187/unknown.png)

Having github problems now. I wanted to switch back to master to push a bug fix, it said I had to commit my changes to my own branch before doing that... wasn't ready for that, but I did it anyway, and then switching to master, it deleted all my changes in my local files. :(

How would I just upload the shop tile bug fix in my branch to the master?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 15, 2019, 06:00:49 pm
Quote
it said I had to commit my changes to my own branch before doing that... wasn't ready for that, but I did it anyway, and then switching to master, it deleted all my changes in my local files.

How would I just upload the shop tile bug fix in my branch to the master?

1)  Yes, you generally should commit (or at least stash) all changes before you switch branches, otherwise things can get messy.
2)  If you committed, then nothing was deleted.  Your changes still exist on your branch and will "reappear" when you switch back to it.
3)  Merging a single commit or a series of commits from one branch to another is called "cherry picking".  It can be done but is not quite so straightforward depending on what client you're using.  Again, I don't have experience with github desktop but I can probably figure out how to do it with smartgit.


Are all the relevant changes to that fix in your 'Fixing shop tile bug' commit?  If so, I'll see if I can branch off of master, cherry pick that commit, then merge that into master without taking your whole branch.


EDIT:  Okay I've cherry picked that commit and pushed it to the 'shopfix' branch.  I'm not ENTIRELY sure I did it properly, though, as the character creation screen seems a bit messed up (actually it's messed up in master, too).  Still I'd give that branch a once over to make sure it has the fix, then merge it into master if it does.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 15, 2019, 06:15:03 pm
I guess this might do for mute. I did try to make this icon before, but the problem was the three dots don't fit. But if the dialogue bubble is grey instead of white...? Otherwise it looks like an ocarina.

(https://cdn.discordapp.com/attachments/535538496547586060/567467045952946187/unknown.png)

That looks perfect tho. However, the dialogue is white and the dots are black. That should make it better.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 15, 2019, 07:26:49 pm
Are all the relevant changes to that fix in your 'Fixing shop tile bug' commit?  If so, I'll see if I can branch off of master, cherry pick that commit, then merge that into master without taking your whole branch.

Yeah, its just changing one byte in Bank E and then removing the Japanese text in the shop tileset so there's at least one blank tile above $7A. Gar, didn't realize the naming screen was like that, though... All that takes to fix should be changing JSR ClearNT_FillBackground to just ClearNT, under DoNameInput. Not sure the FillBackground version is used anymore, then.

... and I feel so stupid for forgetting basic graphic design concepts...

(https://cdn.discordapp.com/attachments/535538496547586060/567487607236329551/unknown.png)

So, Bank D ran out of space after I added some stuff to the music code again, so next project is going to be moving the puzzle game data to its own bank. And THEN I'll focus on cleaning up the shop messages and menu stuff...?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on April 15, 2019, 07:27:58 pm
Yeah, its just changing one byte in Bank E and then removing the Japanese text in the shop tileset so there's at least one blank tile above $7A. Gar, didn't realize the naming screen was like that, though... All that takes to fix should be changing JSR ClearNT_FillBackground to just ClearNT, under DoNameInput. Not sure the FillBackground version is used anymore, then.

... and I feel so stupid for forgetting basic graphic design concepts...

(https://cdn.discordapp.com/attachments/535538496547586060/567487607236329551/unknown.png)

NOW, thats better! :thumbsup: You're not that stupid. It takes time to recognized the concept, so you'll know what graphic that makes it better for the game.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 15, 2019, 09:30:26 pm
The shield icon on the naming screen is fixed in my branch! Not sure if I did any more changes to bank E that aren't in the master, though...

I made a new bank, $11, for the puzzle and story code from Bank D. So now Bank D is purely music!

I added a light delay to all the looping songs, and a new music code to help. Instead of using the $F4 command to halve the volume, the delays use $F6 to turn the volume down even further.

For most of the songs, there's an eighth note delay on square 2 (usually the accompaniment) and a slightly longer delay (somewhere between a quarter note and an eighth note) for the melodies. For Temple of Fiends and Sea Shrine, the melody is delayed by a quarter note to make it more atmospheric. For Sky Castle, both use the between-length delay to make it sound more... off. The Airship's notes are too fast for a longer delay, so both tracks use the eighth note length. Shop music still sounds a bit off to me, but it always did. :P

If anyone downloads that to check it out, lemme know if the songs sound too awkward, or if it adds just a nice touch of depth?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 16, 2019, 02:05:10 am
I’ll check it out when I get home.
Out doing laundry now.


EDIT:
Ok, I had a listen.
I gotta say I'm kinda torn on this. I love reverb in my NES music for sure, but I'm not sure that all the songs need it.

I think maybe that it should be reserved mostly for dungeon themes; "Sea Shrine", "Sky Castle", "Temple of Fiends", "Marsh Cave [New]", and "Earth Cave / Gurgu" all work well and sound 'right' with this effect on.
"Prelude" might sound great with reverb, and in "Slain" it really emphasizes the somberness.
"Castle" probably works, too; emphasizes the grandeur you might expect from royalty.


Quick question, where do I find the spell attributes?
It has always ticked me off that Red Mages can't learn Blink.


EDIT2:
The magic shops in your branch are not selling me spells even if I have enough $$$.

Also, you don't have the Skill command and the blank command at the end makes characters walk forward with repeated use.

And, the Battle Menu color option is great, but couldn't/shouldn't it affect all menus?

Suggestion, place the right arrow icon one more space to the right so it looks cleaner and more symmetrical.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 16, 2019, 03:36:20 pm
lut_MagicPermisPtr for who can learn what spells. I was going to convert them to binary so its easier to edit, but I can't seem to macro the hex-to-binary plugin I have...

Thanks for the feedback! It is a bit much on some songs... I need to go through the soundtrack with a proper viewer to see where the melody is coming from, and maybe only have a little echo on that, and not on the second channel, which is what can really muddy things up. Prelude and the new Marsh Cave song I worked on with the echo in mind, but the rest, its just guesswork at what might sound good.

Not sure about the menu colours though. Maybe it could be another option. To me, anything other than blue or black makes the sprites look weird.

I took the Skill option out for now because I'm gonna make it a patch and try to upload it when things are more stable, and putting skills in is going to be a weeks or months-long project.

Finished up re-working the shop dialogue, but I haven't pushed it.

Found a bunch of equip shop bugs... I'm really running out of steam lately though. So when I feel up to it I'm gonna try and prioritize REALLY re-writing the shop code. These logic branches are a headache. Right now everything mostly works, but I've got this Rune sword and when I sell it, then cancel at "2500 G okay?", everyone gets a ! icon beside them???
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 16, 2019, 10:26:13 pm
I'm really running out of steam lately though.

Don't burn yourself out.  If you need a break, take one.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 17, 2019, 04:14:40 am
Don't burn yourself out.  If you need a break, take one.

I concur.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 17, 2019, 08:32:46 pm
Not so much burn out, I guess... Just gross mood swings lately.  :P Heck, I do this to ignore my moods, so stopping might not be an option...

So here's a bunch of shop logic. This is the first time I've actually thought ahead about this and wrote it down--I tried to make a flowchart but that got too confusing for me.

Code: [Select]
Enter Shop
"Welcome!"
Skip Loop dialogue, goto Buy/Sell/Exit option

Loop:
"How can I help you?"

Option:
Buy  -> Goto Buy
Sell -> Goto Sell
Exit -- Exit
B -- Exit

Buy:
"What'll it be?"
(Draw item list.)

Option:
(Choose 1-5)
B -> Undraw Item box > goto Loop
A ->

Select Amount-Buy:
Item > Item is full > "You can't carry any more!" > A/B button wait > goto Buy
Magic > Item is full > "That spell is sold out" > A/B button wait > goto Buy
Equipment > Item Is full > "You can't carry any more!" > A/B button wait > goto Buy
Item is not full > "How many?"

Option:
Left  -> Decrease purchase amount (1 item minimum)
Right -> Increase purchase amount (Item: max out at 99 items or 65000 gold) (Magic: Max out at 4) (Equipment: Max out at 16)
B - > Goto Buy
A - >

Confirm Purchase:
"X gold, okay?"

Option:
B - > "Okay, anything else?" > goto Buy:Option
A - >

Item > Player does not have enough money > "You don't have enough money!" > A/B button wait > return to Select Amount-Buy (re-draw "how many?")
Item > Conditions met > Pay > "Thank you! Anything else?" > Goto Buy:Option (do not re-draw list)

Magic > Player does not have enough money > "You don't have enough money!" > A/B button wait > return to Select Amount-Buy (re-draw "how many?")
Magic > Conditions met > Pay > "Thank you! Anything else" > goto Buy:Option (do not re-draw list)

Equipment > Player does not have enough money > "You don't have enough money!" > A/B button wait > return to Select Amount-Buy (re-draw "how many?")
Equipment > Conditions met > If amount equals 1 then goto Equip Now? | If amount over 1 then goto Store Equipment

Equip Now?:
"Do you want to equip it now?"

Option:
B --> goto Select Amount-Buy
No --> goto Store Equipment
Yes -->

(Load Character name list.)

Option: Choose character
B --> goto Equip Now
A -->

Can chosen Character equip it?
No -> "You can't equip that!" -> goto Option: Choose character
Yes ->

Does character have something else equipped?
No -> Pay, update gold > "Thank you! Anything else?" > Goto Buy:Option (do not re-draw list)
Yes ->

Is the equipped item slot over 99 in quantity?
No -> Pay, update gold > "Thank you! Anything else?" > Goto Buy:Option (do not re-draw list)
Yes -> "I'll put it in your bags." > A/B button wait > goto Store Equipment

Store Equipment:
Pay, update gold > "Thank you! Anything else" > goto Buy:Option (do not re-draw list)


________________________

Sell:
"What do you have for me?"
(Load inventory list.)

Option:
(Choose 1-5 per page)
A -> Goto Select Amount:Sell
B -> Undraw Item box > goto Loop

Select Amount:Sell:
"How many?"

All shop types - limit price to 65000

Option:
Left  -> Decrease purchase amount (1 item minimum)
Right -> Increase purchase amount (max: total player has)
B - > Goto Sell:Option
A - >

Confirm Sell:
"X gold, okay?"

Option:
B - > "Okay, anything else?" > goto Sell:Option (do not re-draw list)
A - > "Hope I can move this stock..." > Update gold > A/B button wait > goto Sell (reload inventory list)

Anything look weird? I tried to note down everywhere a box would update, but some of it is kind of circular. Anywhere there's "quotes", that implies the shopkeeper's text box updates.

I thought having a limit of 16 weapon/armors would be fitting. You can go over the limit by opening treasure chests, but shopkeepers are just like "WTF do you need that many for, no!". So 16 allows each character to equip 4 of whatever it is. Because eventually I want to work in dual-wielding...

I've been thinking for a few months about making a kind of perk/skill/trait system like FF5's. You pick one or two at character creation, and then 1-2 more after bringing Bahamut the rat tail. It would be the usual stuff like...

Two-handed (weapon stronger without shield)
Dual-wield (equip weapon in shield slot)
Counter (chance to attack enemy that physically attacked you)

Actually, I had a list, I'll just post that up... This is more class-based though.

Code: [Select]
Fighter
Swordsman     - Swords have higher stats the less armour is equipped
Cleric Stance - Hammers and axes have higher stats, deal more damage to undead and were enemies; can't equip swords
Guardian      - Automatically block a portion of attacks to the lower rows while above 25% health


Thief
Mugger        - Steal money when landing critical hits,
Shadowwalker  - Slip into hiding at the start of every battle
Dual Wield    - Equip two weapons, but much lower luck/speed

BlackBelt
Revenge       - Chance to ounter enemy attacks
Barbaric      - Magic does less damage and status effects are less likely to happen, deals more damage to giant type enemies
Dragon Fist   - Deals more damage to dragon type enemies,

Red Mage
Duelist       - Increase attack at the cost of intelligence; Randomly lands another non-critical hit
Purple Mage   - Increase potency of black magic, decrease potency of white magic; learns less white magic spells
Pink Mage     - Increase potency of white magic, decrease potency of black magic; learns less black magic spells

White Mage
Bardic        - Status-effect spells have higher potency; Harm spells damage were and regenerative enemies too
Battle Mage   - Strength is boosted, can equip heavier equipment and axes, but has lower luck/speed
14th          - Cure spells have a regenerative effect on top of their original potency

Black Mage
Group Caster  - Single-target spells are now target-all with a slight potency decrease; Naturally target-all spells have a slight increase.
Insidious     - Status-effect spells have a higher chance to hit and increased potency, damage spells have reduced potency
Focused       - All spells are single-target, but with highly increased potency

I never finished coming up with ideas and balancing them as you can see...

Speaking of intelligence... anyone wanna try adding that in to the battle code?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 18, 2019, 01:03:34 am
Quote
...shop logic stuff...

Looks pretty good.
The only thing I would suggest is to make sure that the quantities under each item in the list reflects how many you have total between inventory and equipped stuff.
Oh, also make sure the shop list redrawn every time you gain an item.


Quote
...trait system...

That sounds really good.
The names and exact effects need some work, but that is actually a really good idea.
Kinda like a precursor to the support abilities in later games.


Quote
Speaking of intelligence... anyone wanna try adding that in to the battle code?

I volunteer. Haven't done ASM in a while, so I could use the practice.
I really want that feature, too.

Come to think of it, are there any of AstralEsper's / Anomie's bug fixes or enhancements already incorporated into the disassembly yet?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 18, 2019, 01:36:37 am
Not sure if the list I have is complete, but here are the bugs I haven't fixed (yet):
* The airship can land on the caravan.
* HEL2 effectivity should be 0x18. Or should it, now that we have heal-doubling
  in the INT patch?

* In the Ice Cave, you can use WARP to get back up holes.
* Poison doesn't work on enemies.
* If you stand on a door, enter a menu, exit the menu, then step down, the door
  will usually end up elsewhere on the screen.
* The Fire and Wind altars say "Nothing here" instead of their proper message.
* There are a number of sprites that start out in non-walkable areas.
  Sometimes, they can even end up outside the bounds of the dungeons.
* If you enter a map (by teleporting, exiting a shop, or exiting a menu) in the
  top/left 7 rows/columns, sprites will walk through you until you step
  verically/horizontally. (JiggersNote: I did make it so that exiting a shop will put you 1 tile under the door, so I've seen this happen a lot lately.)

Not sure about these bugs, might have fixed them with all my fiddling:
* Enemies always wake from sleep.
* Target-dark and evade should not be applied when the target is asleep/stopped.
* Hit% should be applied even if asleep.
* Enemy-cast all-allies spells (e.g. AFIR) don't hit the caster.
* Hit chance should not clamped until after evade is subtracted.
* Spells causing multiple status ailments will claim "Ineffective" if the
  target has any of the ailments (all will still be applied though). (JiggersNote: Is it normal for a player character to have more than one status ailment at a time? If so, I plan on re-sorting which ailment bit is which, so that ones like stun and sleep will have priority to display their icon over dark/mute.)

These should definitely be checked out:
* LOK2 should use effect 0E instead of 10.
* LOCK (and fixed LOK2) always misses.
* TMPR should probably be using effect 0B instead of 0D.

Disch might have fixed this one, or I might have fixed it from his initial disassembly notes:
* In the 2-large-6-small enemy formation, the game shifts one too far so the
  third enemy uses the palette selection bit for the second enemy.

In the Enhancements file, I'd like to see these:
* Make CONF do something vaguely resembling an actual attack (can miss, and
  damage [D..2D]-A).
* Potions would be easier to use if they stayed on the "use" screen (JiggersNote: Forget if I did this or not.)
* This rearranges the teleport coordinate tables to allow for more of each
  kind. This has no effect on the actual game, but might be useful for a hack.
* Replace the crappy PRNG with a slightly better one
* This creates a magic Effect for a "RUN" spell, and assigns it to EXIT.
* Allow all battle numbers except 0x80 to be used as spiked squares, instead of
  only 00-7f.

There's two mentions of nerfing the BlackBelt, I don't know if people find that necessary or not.

Looks pretty good.
The only thing I would suggest is to make sure that the quantities under each item in the list reflects how many you have total between inventory and equipped stuff.
Oh, also make sure the shop list redrawn every time you gain an item.

Pretty sure it does that now for all the shops... Good catch on the re-drawing to update inventory count, changed my logic map file to remember that.

Also, I could possibly cap gold at 9,999,999? It only needs 7 tiles to display for one more byte of RAM (which is there is lots of still.) That fits in both the menu and shop if people are fine with the number snuggling up to the G.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 18, 2019, 06:10:55 am
Coolio.
I'll start a branch just for the bug fix and enhancement stuff.
Fortunately the notes Astral Esper and Anomie made for their work is very comprehensive.

One thing, tho. I don't think that being able to warp back up a hole in the Ice Cavern is really a bug.
I mean you are using magic to teleport.

Raising max gold sounds fine to me.
It could almost even be taken as a fun challenge to try to reach it.



Here's my take on the content of the traits system idea:
Code: [Select]
(Armor refers to defensive equipment for the Body slot, not all defensive gear in general.)
(Use refers to equipping gear in normal equipment slots, not to using them as battle items.)

Fighter:
> Swordsman
  - Attack and Hit% bonus when using swords.
  - Evade +10%, minimum +1.
  - Armor use reduced to same as Thief.
> Barbarian
  - Attack and Hit% bonus when using axes.
  - HP +10%, minimum +1.
  - Armor use reduced to same as Red Mage.
> Cataphract
  - Attack and Hit% bonus when using hammers.
  - Defense +10%, minimum +1.
  - Cannot use swords.

Thief:
> Brigand
  - Chance to steal gil as part of using the Fight command.
  - Axe and hammer use increased to same as Fighter.
  - Effect of using the Hide command reduced to same as all other jobs.
> Partisan
  - Auto-hide at start of battle.
  - Chance to auto-hide after taking damage.
  - Chance to auto-hide when landing a critical hit instead of stealing gil.
> Scout
  - Increased chance for party to get a surprise attack on the enemy.
  - Agility and Luck +5%, minimum +1.
  - No special effect when landing a critical hit.

Monk:
> Brawler
  - Weapons do not negate bare-handed attack bonus.
  - Armor use increased to same as Fighter.
  - No unarmored defense bonus.
> Pugilist
  - Chance to counter attack when hit.
  - Armor use increased to same as Thief; glove use increased to same as Fighter.
  - Inverse of glove weight added to attack.
  - No unarmored defense bonus.
> Mystic
  - Fight command treated as having hurt flag vs unknown, undead, were, mage, and regenerative types.
  - Armor use increased to same as Red Mage.
  - No unarmored defense bonus.

Red Mage:
> Magus
  - Chance to attack twice when using the Fight command.
  - Shield and glove use increased to same as Fighter.
  - Can only learn spells up to level 4.
> Battle Mage
  - Increased potency of attack spells.
  - Can equip Black Robe.
  - Weapon use reduced to same as Black Mage.
> Physic Mage
  - Increased potency of healing spells.
  - Can equip White Robe.
  - Weapon use reduced to same as White Mage.

White Mage:
> Chaplain
  - Axe and staff use increased to same as Fighter.
  - Armor, shield, and glove use increased to same as Fighter.
  - Decreased potency of healing spells.
> Enchanter
  - Increased potency of status spells.
  - Armor use increased to same as Red Mage.
  - Cannot use hammers.
  - Decreased potency of healing spells.
> Holy Mage
  - Chance to add regen effect as part of casting healing spells.
  - Harm spells can effect all enemies regardless of type.
  - Decreased potency of harm spells.
  - Cannot use hammers.
  - Decreased potency of status spells.

Black Mage:
> War Mage
  - Attack spells that target single enemies instead target all enemies.
  - Decreased potency of attack spells that normally target single enemies.
  - Sword use increased to same as Red Mage.
> Duelist
  - Attack spells that target all enemies instead target single enemies.
  - Increased potency of attack spells that normally target all enemies.
  - Cannot use knives.
  - Decreased potency of status spells.
> Hex Mage
  - Non-death status spells that target single enemies instead target all enemies.
  - Increased potency of non-death status spells.
  - Cannot use staves.
  - Decreased potency of attack spells.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 21, 2019, 04:16:10 pm
Yeah, warping should be allowed! Unless it somehow breaks the game? Maybe all the teleports going up and down floors does something weird with the map data on the stack and warping back will screw up?

So I thought gold was only 2 bytes, but its 3 bytes, so the max gold is... 3F 42 3F? Or 999,999. Even though 3F 42 3F should be 4,145,727...? The game does weird things when you try to display 999,999 gold in the menu.

Anyway, gold is fine then. I thought the max was way lower and was confused. Bumping it up to 9,999,999 will involve making a new thing to display 7 digit numbers and I don't wanna.

Your trait things are lookin' good! I might disagree on a few things here and there, but no reason to argue over it until there's actual code in place to make any of it work. XD Right now there's 3 free bytes in character stats... to make 4, I could combine ch_weaponelement and ch_weaponcategory to use high/low bytes? There's only 8 elements and 8 categories, after all...

I tweaked the echo a bit more as well. Took out all the square 2 echo tracks, and shortened the delay on some songs. Not uploaded yet, though.

Update: Pushed my changes to various things. Shops still buggy, haven't started that yet.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 21, 2019, 05:33:51 pm
Disch might have fixed this one, or I might have fixed it from his initial disassembly notes:
* In the 2-large-6-small enemy formation, the game shifts one too far so the
  third enemy uses the palette selection bit for the second enemy.

I pretty much ripped out all of that code and rewrote it when moving the enemy formations.  So yeah that bug should be fixed.

EDIT:  Or did I?  I forget how I actually am getting the palette assignment for the enemy.  Lemme have another look to make sure.

EDIT 2:  Okay, I didn't fix that.  The palette assignments were previously prepped by the time my new code runs, so the bug would have happened before then.  HOWEVER it looks like Jiggers fixed it before I got there.   :)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 22, 2019, 12:27:19 am
'Course I only fixed it 'cos you pointed it out...!

Working on the shops, I can't test this yet, but does the concept sound right?

Code: [Select]
ShopBuy:
    JSR LoadShopInventory
   
    LDX shop_type
    LDA lut_ShopWhatWant, X
    JSR DrawShopDialogueBox     ; "what would you like" dialogue (different depending on shop type)
    LDA #0
    STA cursor
   
    JSR ShopSelectItem_Buy      ; let them choose an item from the shop inventory (fills str_buf with item IDs and everything!)
    BCS RestartShopLoop         ; if they pressed B, restart the loop
   
Shop_CheckInventory:
    LDX cursor
    LDA item_box, X             ; get chosen item ID
    STA shop_curitem            ; save it
   
    LDA #13
    JSR MultiplyXA              ; multiply cursor position by each item's str_buf length
    TAX
   
    LDA shop_type
    CMP #2                      ; if its below 2, its 0, weapons, or 1, armor
    BCC @CheckEquipment
    CMP #4                      ; if its below 4, its 3, black magic, or 2, white magic
    BCC @CheckMagic             ; it can't be inn or clinic, so its an item shop
   
   @CheckItems:
    LDA #99
    STA shop_amount_max
    LDA str_buf+$46, X           ;
    CMP #$FF                     ; if this position in the string buffer is #$FF
    BEQ ShopSelectAmount         ; then we know the player has less than 10 of this item, so go buy more
    CMP #$89                     ; otherwise its the 1s, and need to compare against the tile ID of the number 9
    BCC ShopSelectAmount         ; and if its less than that, there's room for more
    LDA str_buf+$45, X           ; else, check the 10s position
    CMP #$89                     ; again, against the tile ID for the number 9
    BCC ShopSelectAmount         ; and if its less, there's room for more
    JMP :+
   
   @CheckEquipment:
    LDA #16
    STA shop_amount_max     
    LDA str_buf+$46, X           
    CMP #$FF                     
    BEQ ShopSelectAmount         
    CMP #$86                     ; otherwise its the 1s, and need to compare against the tile ID of the number 6
    BCC ShopSelectAmount         ; and if its less than that, there's room for more; no need to check the 10s position?
 :  LDA #$13                     ; load up "you can't carry any more" string ID
    JMP @DrawDialogue_AndReturn  ; print it and return   

   @CheckMagic:
    LDA #4
    STA shop_amount_max
    LDA str_buf+$45, X           ; for magic, much easier
    CMP #$84
    BCC ShopSelectAmount
    LDA #$14                    ; "That spell is out of stock"

   @DrawDialogue_AndReturn:   
    JSR DrawShopDialogueBox   
    JMP ShopBuy

I updated the code in ShopSelectItem_Buy (previously named Shop Select Buy Item) to work with magic, as well as items and equipment. For each type, it checks players as well for equipped/learned things. So rather than do all that AGAIN here, I figured the best way to let the game know what the limit to allow the player to buy is, is to snag the number they have ... from ... the ... shop list itself... damn.

I still need to actually convert it to a single byte to subtract it from shop_amount_max!

Really not sure how to do that. So str_buf+$45, X is the 1s column if they have less than 10, or the 10s column if they have more, and str_buf+$46, X can be $FF if they have less than 10, or is the 1s column if they have more. How would you even organize that, then grab both numbers and squeeze them into one!

Update: Oh, oh, maybe like this?

Code: [Select]
ShopConvertAmount: 
    LDA #0
    STA shop_amount_high
   
    LDA str_buf+$46, X   
    CMP #$FF
    BEQ @SingleDigit
   
    SEC
    SBC #$80            ; convert from tile ID to byte
    LDX #10             ; multiply by $0A to convert to hex tens column
    JSR MultiplyXA
    STA shop_amount_high     
   
   @SingleDigit:
    LDA str_buf+$45, X     
    SEC
    SBC #$80
    CLC
    ADC shop_amount_high
    STA shop_amount
   
    LDA shop_amount_max
    SEC
    SBC shop_amount
    STA shop_amount_max
    RTS

Update 2: And with that figured out (hopefully), I managed to condense it all down to this:

Code: [Select]
ShopBuy:
    JSR LoadShopInventory
   
    LDX shop_type
    LDA lut_ShopMaxAmount       ; gets either #99, #16, or #4 depending on shop type
    STA shop_amount_max
   
    LDA lut_ShopWhatWant, X
    JSR DrawShopDialogueBox     ; "what would you like" dialogue (different depending on shop type)
    LDA #0
    STA cursor
   
    JSR ShopSelectItem_Buy      ; let them choose an item from the shop inventory (fills str_buf with item IDs and everything!)
    BCS RestartShopLoop         ; if they pressed B, restart the loop
   
Shop_CheckInventory:
    LDX cursor
    LDA item_box, X             ; get chosen item ID
    STA shop_curitem            ; save it
   
    LDA #13
    JSR MultiplyXA              ; multiply cursor position by each item's str_buf length
    TAY
   
    LDA #0
    STA shop_amount_high
   
    LDA str_buf+$46, Y   
    CMP #$FF
    BEQ @SingleDigit
   
    SEC
    SBC #$80                    ; convert from tile ID to byte
    LDX #10                     ; multiply by $0A to convert to hex tens column
    JSR MultiplyXA
    STA shop_amount_high     
   
   @SingleDigit:
    LDA str_buf+$45, Y     
    SEC
    SBC #$80                    ; convert from tile ID to byte
    CLC 
    ADC shop_amount_high        ; add in 0 or tens column
    STA shop_amount
   
    LDA shop_amount_max         ; get max
    STA tmp                     ; store in tmp
    SEC
    SBC shop_amount             ; subtract total in inventory/on characters
    STA shop_amount_max         ; save as new max

    CMP tmp                     ; compare to old max
    BNE ShopSelectAmount        ; if its not maxed out, go buy more
   
    LDA shop_type               ; get shop type again
    CMP #2
    BEQ @Scrolls                ; if its 2 or 3, its a magic shop
    CMP #3
    BEQ @Scrolls
   
    LDA #$13                     ; load up "you can't carry any more" string ID
    JMP @DrawDialogue_AndReturn  ; print it and return   

   @Scrolls
    LDA #$14                     ; "That spell is out of stock"

   @DrawDialogue_AndReturn:   
    JSR DrawShopDialogueBox   
    JMP ShopBuy

Hoping the BNEs and all that is correct. Without being able to test this all yet, I can only go by what I think might be right.

Pushed what I got so far so people can check it out if they want. What's currently working is bugged and I don't know how yet, but its 4 AM so I can't figure it out. I have 21 heals, but then in RAM it says I got 12, and sets the max to buy to 4. Pures meanwhile, it lets me go up to ... a lot (NO is displayed in the numbers)... weird stuff like that.

Next Day update:

Got buying working in item shops. Working on magic and equipment shops displaying the right amounts now.

To get equipment displaying right, I'll have to again change how armor is equipped. Instead of storing them in ch_stats as $1-$41, it will be $41-$81. So if you want your save files to work properly after this, add $40 to your armor slots!

Otherwise, the game is checking to see if I've got a rapier equipped... but it will count iron armor as a rapier, too.

BIG UPDATE!:

Buying now works for all shop types? Only standard buying so far; equipment shops will not yet allow equipping in the shop just yet! Its coming!

All the shops should display the proper amount in inventory now--PROVIDED you updated your save files as I mentioned!

Selling does not work yet, it will just exit. I haven't tested manually pressing A on things like Exit yet.

Changes are pushed to the Jiggers'-Ponkery branch!

Midnight EST update:

Equipping in shops should work now. Sensing there might be some wonkiness with the messaging and boxes refreshing at the right times. Let me know if any of it feels awkward? Like, to me, pressing cancel at "X gold, okay?", I think it should show "Eh, alright then, anything else?"--but then still allow to select things to buy... but then pressing B then to go back to Buy/Sell/Exit--isn't that awkward? I d'nno...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 23, 2019, 11:47:20 am
Seems good so far except for one thing.
When I buy multiple items and then choose to equip it now, it equips one buy the other one is not added to inventory. So one is lost.

Also, you might want to either refresh or un-draw the shop list as the final step of any transaction.
Right now the list does not update after buying or selling resulting in wrong inventory info remaining on the screen.
That could confuse some players.

Music sounds pretty damn fine.
The new Marsh Cave seems a bit too 'noisy' to me, though. Maybe tone down it's reverb a tad?

Oh, and Armor names are not displayed correctly in battle. I presume that is because of the change to how armor is handled.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 23, 2019, 07:44:05 pm
Oops, its only supposed to ask if you want to equip if you're buying one. Fixed that.

Marsh Cave (New) was bugged when I was adding the echo tracks to begin with, so any echo you were hearing before was just the way I composed the song originally... I thought it sounded dry compared to the rest of the songs now. It is a pretty busy song, with the bassline doubled up with square AND triangle... All I can do to have the echo there and not as strong is to halve the volume again. So I did that!

I forgot to actually reference the shop logic layout I made while doing all this... I'll go through it again and tweak stuff once everything actually works.

Fixed the armor thing! Just by taking out code; love it when that's the solution. XD

Got a question before I update the changes though:

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  Add GP To Party  [$DDEA :: 0x3DDFA]
;;
;;  IN:  tmp - tmp+2 = GP to give to party
;;
;;  BUGGED -- theoretically, it is possible for this routine to allow
;;   you to go over the maximum ammount of gold if you add a large enough number.
;;
;;     After CMPing the high byte of your gold against the maximum, it
;;  only does a BCC (which is only a less than check).  It proceeds to check the middle
;;  bytes EVEN IF the high byte of gold is GREATER than the high byte of the max.  This
;;  means that numbers such as 1065535 will not appear to be over the maximum when, in
;;  fact, they are.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

AddGPToParty:
    LDA gold        ; Add the 3 bytes of GP to the
    CLC             ;  party's gold total
    ADC tmp
    STA gold
    LDA gold+1
    ADC tmp+1
    STA gold+1
    LDA gold+2
    ADC tmp+2
    STA gold+2

    CMP #^1000000   ; see if high byte is over maximum
    BCC @Exit       ; if gold_high < max_high, exit

    LDA gold+1
    CMP #>1000000   ; check middle bytes
    BCC @Exit       ; if gold < max, exit
    BEQ @CheckLow   ; if gold = max, check low bytes
    BCS @Max        ; if gold > max, over maximum

  @CheckLow:
    LDA gold
    CMP #<1000000   ; check low bytes
    BCC @Exit       ; if gold < max, exit

  @Max:
    LDA #<999999    ; replace gold with maximum
    STA gold
    LDA #>999999
    STA gold+1
    LDA #^999999
    STA gold+2

  @Exit:
    RTS

How can I fix the potential issue here? I'm not really sure what's happening when its comparing with such big numbers.

I need to figure out how to use a version of this to make sure you can't go over the limit while selling in shops. gold + shop_curprice, save as tmp, C set if successful, clear if not, that sorta thing...

Also--when buying in shops:

Code: [Select]
   LDA gold
    SEC
    SBC shop_curprice         ; subtract low byte
    STA gold

    LDA gold+1
    SBC shop_curprice+1       ; mid byte
    STA gold+1

    LDA gold+2
    SBC shop_curprice+2       ;; JIGS - hope this will work...
    ;SBC #0                    ; and get borrow from high byte
    STA gold+2

Is the carry ever going to cause an issue? shop_curprice+3 exists, but isn't ever used except for the multiplication routines...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 23, 2019, 07:58:01 pm
Quote
Is the carry ever going to cause an issue

Carry will only matter (be clear) if they are spending more than they have (shop_curprice > gold) -- which should never happen since presumably you're checking for that long before this code runs.

So... no.  It won't be an issue.

EDIT:  I'm looking at the comparison code now.  Will edit again briefly.

EDIT 2:  Took me a minute to understand the bug in the comment but I see it now.
See how the middle byte is doing a BCC/BEQ/BCS but the high byte is only doing a BCC?  This means that once high_gold >= high_max, it treats it as high_gold = high_max and compares the middle byte (even though when it's greater, it shouldn't).

EXAMPLE

Maximum gold is 1000000.  In hex that is $0F4240

If the party has, say $100000 gold (1048576), it will compare the high bytes ($10 vs $0F) to see that the gold is NOT less than the max, then will proceed to check the middle bytes ($00 vs $42) to see that it IS less than the max, and that will "trick" the routine into thinking the gold is below the max, even though it is over it.

This means that adding any amount of gold over 48577 with this routine has potential to allow the party to exceed the maximum gold.

This can be fixed by doing the full proper comparisons for the high byte, which I do here with 3 added lines:

Code: [Select]
AddGPToParty:
    LDA gold        ; Add the 3 bytes of GP to the
    CLC             ;  party's gold total
    ADC tmp
    STA gold
    LDA gold+1
    ADC tmp+1
    STA gold+1
    LDA gold+2
    ADC tmp+2
    STA gold+2
   
    CMP #^1000000   ; see if high byte is over maximum
    BCC @Exit       ; if gold_high < max_high, exit
    BEQ @CheckMid   ; high bytes are equal -- need to compare middle bytes   !!! added this line
    BCS @Max        ; gold_high > max_high, we're over the max               !!! added this line

  @CheckMid:                                                                 !!! added this line
    LDA gold+1
    CMP #>1000000   ; check middle bytes
    BCC @Exit       ; if gold < max, exit
    BEQ @CheckLow   ; if gold = max, check low bytes
    BCS @Max        ; if gold > max, over maximum

  @CheckLow:
    LDA gold
    CMP #<1000000   ; check low bytes
    BCC @Exit       ; if gold < max, exit

  @Max:
    LDA #<999999    ; replace gold with maximum
    STA gold
    LDA #>999999
    STA gold+1
    LDA #^999999
    STA gold+2

  @Exit:
    RTS
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 23, 2019, 10:25:33 pm
Nice! Thanks!

So this will work?

Code: [Select]
Shop_CanShopkeepAfford:
    LDA gold        ; Add the 3 bytes of GP to the
    CLC             ;  party's gold total
    ADC shop_curprice
    STA tmp
    LDA gold+1
    ADC shop_curprice+1
    STA tmp+1
    LDA gold+2
    ADC shop_curprice+2

    CMP #^1000000   ; see if high byte is over maximum
    BCC @Exit       ; if gold_high < max_high, exit with carry clear
    BEQ @CheckMid   ; high bytes are equal -- need to compare middle bytes   
    BCS @Exit       ; gold_high > max_high, we're over the max, with carry set               

  @CheckMid:                                                                 
    LDA tmp+1
    CMP #>1000000   ; check middle bytes
    BCC @Exit       ; if gold < max, exit with carry clear
    BEQ @CheckLow   ; if gold = max, check low bytes
    BCS @Exit       ; if gold > max, over maximum, exit with carry set

  @CheckLow:
    LDA tmp
    CMP #<1000000   ; check low bytes

  @Exit:            ; carry set; can't sell
    RTS             ; carry clear, sell is go
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 23, 2019, 10:33:32 pm
You're losing the high byte (you never STA it to tmp+2)

Also you probably want to change '1000000' to '999999' if you're doing it this way, since C will be set when tmp=max

EDIT: Actually I might be wrong.... 1000000 might be right.  I'm confuzzled.

C=set when you CAN'T sell (gold >= 1000000)
C=clear when you CAN sell (gold < 1000000)

So... yeah.... 1000000 is right.  Sorry.

Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 24, 2019, 01:01:23 am
No worries, I didn't even see until after you edited!

Saving tmp+2 isn't necessary here is it? Since this is just a check to make sure you can't get over the gold limit while selling. Only output that matters is C. I thought, why bother saving to tmp+2 if its only used to compare what's already in the accumulator?

I pushed more updates! Selling should now maybe work? I'm back to where I was before with the bug though. If you have 6 weapons, and sell the 6th on page 2 of the shop list, all the characters get a ! beside them. Think it might have something to do with the item_box_offset variable...

I'm also really proud and at the same time embarrassed about how I made the inventory box have empty spaces. See, I didn't like how it was drawing the whole box every time you updated--so you'd see the text vanish and re-draw from the top even if the only change was a single number. So I ended up adding a new control code to the main text drawing routine (which to be fair, needed to be done!) which just prints spaces, and then I had to figure out how to print 3 lines of 8 letter spaces while using up exactly #13 bytes--EVEN THOUGH I probably didn't need to do that, since the empty inventory slots show up after where the string buffer data needs to be in increments of #13... so I could have just done the 3 normal lines and put in some code to adjust Y for #9 instead...

Well, the good news is spaces can be print with only 2 bytes, so all those $FFs in the strings can be chopped out!

And I haven't actually tested selling besides in the weapon shop so far... time to see what breaks!

Do we want this?
(https://cdn.discordapp.com/attachments/535538496547586060/570515177896935426/Untitled.png)

All I'd have to do is change 3 $FF attribute bytes to $FA and back again. Probably almost the same code as the one that makes them change stances and draws/undraws the !s. Would be a good indicator of what's selected--then I'd work on moving the cursor to the amount while you're choosing how many of the thing to buy. I can't do that right now because the cursor has to stay on the item so the characters keep their pose while you're deciding; I'm exactly the sort of person who would forget what I'm buying while deciding how many, and having them keep their "I can equip this pose" is less helpful than "oh the thing I'm buying is green!" ... I kind of just convinced myself to do it I guess. :P

Update: Item shop seems to sell okay. Fixed a lotta bugs with things again... Magic shops now displaying the amount of spells wrong. I have 3 spells, it says I have 3 of the first, 2 of the second, 1 of the third... Will work on that tomorrow.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 24, 2019, 01:48:27 am
Quote
Saving tmp+2 isn't necessary here is it? Since this is just a check to make sure you can't get over the gold limit while selling.

Ah.  Okay.

I got mixed up and thought this was still the 'AddGpToParty' routine so I thought that sum was eventually going to get moved to 'gold'.

But yeah if you're just doing a check, then you're right.   :thumbsup: :beer:
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 24, 2019, 05:42:15 pm
(https://cdn.discordapp.com/attachments/535538496547586060/570723071909167104/unknown.png)

PRETTY MUCH DONE!!

I'm not running into any more bugs that I can find on my own...

And there's now less than 16 bytes of space left. Even after cutting out all those blank spaces in the text strings and deleting two other shop types.  :-[ But... but shops are so sleek now! And mostly snappy; there's a tiny delay when moving the cursor to the inventory when its already drawn, since its drawing over itself. It only seems like a delay because you don't see the whole box re-draw from scratch, so I had the cursor hide during this.

I think the Party Generation stuff should be moved to Bank Z with the intro, but there's so many things it uses that automatically revert to Bank E afterwards (almost everything that loads graphics!). I actually tried to move it before I started working on the shops, but ran into a bug where returning to the title screen from any of the 3 options garbled the cursor sprite and flickered the screen. Guess I'll try again after...



(https://cdn.discordapp.com/attachments/535538496547586060/570734432932200538/unknown.png)

How about this? Could make the gold box normal blue as well. Even the title box.



(https://cdn.discordapp.com/attachments/535538496547586060/570806353614995467/unknown.png)

Working on getting this MP box to show properly. Any better ideas for format? I tried having it like...

Code: [Select]
6 4 3 2 0 0 0 0
\ \ \ \ \ \ \ \
6 4 3 2 0 0 0 0

But it looked weird. The box has odd proportions and it would be ugly to have the list over 3 rows...

What I might do instead is see if I can replace the Cast/Learn/Forget box with something that says like... "Level X MP: #/#" that updates as you move the cursor around.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 25, 2019, 12:21:21 am
Damn! That is some amazing work!
Gonna give this a quick try before bed.

Having all the text boxes in the shops be the same color is much more consistent with the later games in the series, so I say go for it.
But, make sure that other colors are still supported in case someone wants to use them for their own project.
(Probably a good idea to put a nice big comment box in the code so it's easy to find, too.)

Love the highlight on the current item you're dealing with!

The formatting on the MP display looks fine to me.

Almost forgot to mention this, but my party is starting the game equipped with wooden nunchaku for armor.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 25, 2019, 12:45:05 am
Thanks! I forgot to mention, a restriction during selling, is that it won't display your equipped gear/learned spells. Even if I made it backup what it searches for in inventory, then subtract that from the amount you can sell, that would be confusing: "I have 4 cure spells but I can only sell 3???" Even though the ! should inform them the extra one is equipped... hm...

Nunchuck armor sounds neat, though!

Update: Fixed the armor, put the MP in the title bar.

One or two last changes for the equip screen on the way, then will tackle the skipped music frames in battle.

April 25, 2019, 09:29:16 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Update to the Equipment inventory screen is live. I need some help with it, though!

Code: [Select]
    @Loop:
    JSR ClearOAM
    JSR DrawEquipInventoryCursor
    LDA cursor_change
    BEQ :+
  : JSR UpdateEquipInventoryStats
    JSR MenuFrame

    LDA joy_a
    BNE @A_Pressed            ; check to see if A pressed
    LDA joy_b
    BNE @B_Pressed            ; or B

    JSR MoveEquipInventoryCursor   ; if neither A nor B pressed, move the mode cursor
    JMP @Loop                      ; and loop until one of them is pressed

Why would the addition of UpdateEquipInventoryStats cause the cursor to go insane speeds? It no longer stops and waits for new input if you hold down a directional button...

So far the only other thing I've noticed iffy is it might not let you equip a battle item. Otherwise, it seems to work as intended so far? I still need to do more testing to make sure its behaving properly for all the different equipment slots. Update: Now works for battle items... I think. It shows "xx" when you can't equip something (either in that slot or on that class), and "--" when picking a battle item.

Also to explain what it is I DID: Instead of unequipping an item when you press A on the equip screen, it goes straight to the inventory whether you had something equipped or not. It basically unequips it, but pressing B in the inventory re-equips it. Meanwhile, the description box stays open and displays the stats for whatever the cursor is pointing at, if it exists.

I basically really like having real-time feedback now that I know how to do this. That crazy cursor speed is driving me nuts though! Whyyyy.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 25, 2019, 11:34:15 pm
Only thing I can think of that would mess with the cursor speed is 'joy_prevdir' getting corrupted/overwritten.  There there some variable in UpdateEquipInventoryStats that is assigned to the same location in memory?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 25, 2019, 11:55:53 pm
... so I looked, but not very hard. That is, I looked at the variables I thought I was using, and was like, nope, those aren't anywhere near it!

Then I looked at exactly that one, and... yeah. equipmenu_tmp uses the same spot. And guess what uses equipmenu_tmp? ...the silly darn Unadjust/Readjust equipment stats... that my new thing does every time you move the cursor.

Thanks. XD My brain is truly mush.

Update! Cursor is now slow. And the stats display like this:
If you CAN equip it, but not in this slot: !!
If you CAN'T equip it at all: xx
If you're in the Battle Item slots: --
If there's nothing there to equip: Your stats as they would be with no item in the slot.
If there's something there to equip: Your stats as they would be with that item in the slot.



Battle music not updating... Could it be btl_msgbuffer_loopctr with BattleDrawMessageBuffer and BattleDrawMessageBuffer_Reverse?

When it first draws the rows, it only does 9. When it draws them in reverse to undraw a box, it does 5--because it does 2 rows. So a possible fix would just be to draw the 10 rows at the start, even if the 10th is invisible...?

Another possibility is Battle_DrawMessageRow. It used to only draw $19 tiles a row, I expanded that to $20--would 7 more tiles make a difference in how long it takes, causing the a couple random frames to last longer or something?

When I fiddle with it I just make it worse. I also think I'm hearing it skip frames, not just lingering on one too long?



April 27th Bugs fixed:
* Enemies regenerate properly now
* Poison messaging no longer draws garbage after clearing boxes
* Ruby, Adamant, and ... bah, something else, can now properly be gotten from treasure chests
* Level up message box widened properly (finally!)
* Equip Inventory no longer displays random stuff after the Evasion number.


Tweaks:
* Marsh Cave has a Phoenix Down so Astos's RUB attack isn't just so unfair.
* Provoka has Eyedrops
* Crescent Lake has Wakeup bells
* Gaia has Phoenix Downs
* Caravan has X-Heals, Ethers, Elixirs, and Smokebombs

Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 27, 2019, 08:37:27 pm
Cool. I'll give this a go again as soon as I can.

I need to familiarize myself more with GitHub and it's lingo.
Quick questions though...
Applying changes from a branch to the master is called pushing?
And grabbing changes from the master is pulling?
Can I grab changes from other branches?
Can I grab changes from individual files within a project branch?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 28, 2019, 12:33:59 am
I need to familiarize myself more with GitHub and it's lingo.

Get SmartGit.  It's free for noncommercial use and it's great.  It really simplifies a lot of it.


As for your questions....
Quote
Applying changes from a branch to the master is called pushing?
And grabbing changes from the master is pulling?

Nah, pushing/pulling doesn't really have to do with branching.


Think of it this way.  From your perspective, there are two "repositories".  One is your local machine, the other is the remote machine, or the "server" (eg: github).

When you have local changes that you want to upload to the server, that's "pushing".
When there are changes on the server that you want to bring into your local machine, that's "pulling"

Basically, pushing is uploading -- pulling is downloading.


Quote
Can I grab changes from other branches?

Yes.  The easiest way to do this is to "merge" one branch into the other.


Quote
Can I grab changes from individual files within a project branch?

Individual files?  Not really (there might be a way but it'd be very hacky and I wouldn't recommend it)

Individual commits?  Yes, it's called "cherry picking" and you'd want to use a client like SmartGit to do it otherwise it's kind of tricky.  GENERALLY you want to avoid this as much as possible and stick to merging, but sometimes you just gotta do it.



Bit more detailed overview:

The basic building block in git is the "commit".  Every time you do a commit, you are effectively creating a full backup of your code.  Git doesn't store the code in full, though, it just stores each individiual commit as a list of changes you made.  So if you only changed a few lines of text, it only needs to track those, and not EVERYTHING.  But.... it can rebuild ANYTHING by following your commit history and applying all the changes on top of each other.

A "branch" is just a collection of commits.  The branch itself doesn't have any code in it, it just has a list of commits -- the commits are what have the code.  This is why I said before that branches "don't cost anything" -- they're extremely light -- just a list of commit IDs.  At any time you have one branch "checked out" -- which just means that is the branch whose list of commits you are currently using, and who gets any new commits that you make.

But once you check out a new branch, you get a new commit list, and so all of your files will instantly change to reflect the new commit list.

When you merge branch A into branch B, you're telling git to "take all the commits in branch A that aren't already in branch B and add them to branch B"



Tips 'n' tricks:

Keep commits small-ish.  I like to think of an individual commit as one individual task I completed.... or if the task is particularly large, I break it up into several commits.  You don't have to do a commit for every single line of code you changes, but don't wait until you have like 300 lines across 20 files before you do a commit.

If you ever feel uneasy about touching something, make a branch and do it there.  Branches are cheap and isolated, and therefore act as a good, safe sandbox for you to mess around it.

Safest way to do a merge (ie:  merging a feature branch into master):
- Pull the latest master to get any changes other people have made
- Merge master into your feature branch FIRST to make sure there are no conflicts
--- If there are conflicts, fix them in the feature branch.
- THEN merge feature into master
- push master

Seems like a lot of steps and might seem overly complicated, but it becomes second nature and it makes it easier to clean up if a merge goes bad (which probably won't happen on a project like this, but on bigger projects with more developers, conflicts can get REALLY messy)

If you want to be EVEN SAFER you can make a 3rd branch off of your feature branch specifically to do the merge in:
- Create a new branch off of your feature, we'll call it fmerge
- Do all steps above, but use fmerge instead of your feature branch
- delete fmerge

This way if things get REALLY mucked up you can just toss fmerge and both your feature branch and master remain pristine.  But again, this is probably overkill for this project.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 28, 2019, 03:49:52 am
Somehow... Stealing is 90% done. I can steal a sword from an Ogre, at least. Right now I'm stuck on trying to get the messaging just right for failure. Then I need to test items, magic scrolls, and gold theft. Once those all work, all that's left is to give enemies things to steal!

Right now, I have no check for enemies being dead... When I do have that check in place, I intend to change the messaging to imply the thief is looting the dead body.

No real plans on making items show up after battle yet... But we'll see. I'm very surprised I got this far in just a few hours.

Quick Update: Weapons (and therefore I assume armors), items, and magic spells work. Gold needs some... extra work. Gotta split the table into two.... aaaand, that's a waste of space, but its working now so I'm gonna push it.

I've animated the stealing, and sometimes there's like... some kind of delay on showing the pixel location for the top half, so the thief looks like they're running all bent backwards, its hilarious.  :D

So, to play around with it, open up Bank Z. The last byte of the enemy data tables is the thing to steal. Then below it is a list. A byte of $00 means they have nothing to steal, so in the version I uploaded, only Ogres have something to steal (330 gold.) So go nuts and put a $04 at the end of the IMPs data and test it out...!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 28, 2019, 01:09:19 pm
...knowledge bomb...

Thanks a lot Disch! That really helped me out. :)



Somehow... Stealing is 90% done. I can steal a sword from an Ogre, at least. Right now I'm stuck on trying to get the messaging just right for failure. Then I need to test items, magic scrolls, and gold theft. Once those all work, all that's left is to give enemies things to steal!

Right now, I have no check for enemies being dead... When I do have that check in place, I intend to change the messaging to imply the thief is looting the dead body.

No real plans on making items show up after battle yet... But we'll see. I'm very surprised I got this far in just a few hours.

Quick Update: Weapons (and therefore I assume armors), items, and magic spells work. Gold needs some... extra work. Gotta split the table into two.... aaaand, that's a waste of space, but its working now so I'm gonna push it.

I've animated the stealing, and sometimes there's like... some kind of delay on showing the pixel location for the top half, so the thief looks like they're running all bent backwards, its hilarious.  :D

So, to play around with it, open up Bank Z. The last byte of the enemy data tables is the thing to steal. Then below it is a list. A byte of $00 means they have nothing to steal, so in the version I uploaded, only Ogres have something to steal (330 gold.) So go nuts and put a $04 at the end of the IMPs data and test it out...!

Sweet googlie-mooglie! I'm gonna try that out right away!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 28, 2019, 03:51:32 pm
Any thoughts on this?

I figure beast-like enemies and bugs and stuff wouldn't have anything. Its really hard to balance this out, when 50% of the gear is junk and the other 50% needs to be rare enough to be worth something...

Code: [Select]
IMP         ; 10 gold
GrIMP         ; Cap               
WOLF         ; *
GrWolf         ; *
WrWolf          ; *
FrWOLF          ; *
IGUANA          ; *
AGAMA           ; *
SAURIA          ; *
GIANT           ; Copper bracelet
FrGIANT         ; Silver bracelet
R`GIANT         ; X_Heal
SAHAG           ; Heal
R`SAHAG         ; Pure
WzSAHAG         ; X_Heal
PIRATE          ; Scimitar
KYZOKU          ; Falchion
SHARK           ; *
GrSHARK         ; *
OddEYE          ; *
BigEYE          ; *
BONE            ; Wooden staff
R`BONE          ; Iron staff
CREEP           ; *
CRAWL           ; *
HYENA           ; *
CEREBUS         ; *
OGRE            ; Iron hammer
GrOGRE          ; Silver hammer
WzOGRE          ; Ice 2 scroll
ASP             ; *
COBRA           ; *
SeaSNAKE        ; *
SCORPION        ; *
LOBSTER         ; *
BULL            ; 240 gold
ZomBULL         ; AICE scroll
TROLL           ; 255 gold
SeaTROLL        ; 880 gold
SHADOW          ; *
IMAGE           ; *
WRAITH          ; *
GHOST           ; *
ZOMBIE          ; Cloth T
GHOUL           ; 55 gold
GEIST           ; 85 gold
SPECTER         ; 180 gold
WORM            ; *
Sand W          ; *
Grey W          ; *
EYE             ; *
PHANTOM         ; *
MEDUSA          ; Soft
GrMEDUSA        ; Soft
CATMAN          ; Pure
MANCAT          ; Fire 2 scroll
PEDE            ; *
GrPEDE          ; *
TIGER           ; *
Saber T         ; *
VAMPIRE         ; X_Heal
WzVAMP          ; Ether
GARGOYLE        ; *
R`GOYLE         ; *
EARTH           ; Soft
FIRE            ; Smokebomb
Frost D         ; 2750 gold
Red D           ; 2750 gold
ZombieD         ; 5000 gold
SCUM            ; *
MUCK            ; *
OOZE            ; *
SLIME           ; *
SPIDER          ; *
ARACHNID        ; *
MANTICOR        ; 1250 gold
SPHINX          ; 1760 gold
R`ANKYLO        ; *
ANKYLO          ; *
MUMMY           ; Wakeup Bell
WzMUMMY         ; Wakeup Bell
COCTRICE        ; *
PERILISK        ; *
WYVERN          ; 1020 gold
WYRM            ; 1250 gold
TYRO            ; *
T REX           ; *
CARIBE          ; *
R`CARIBE        ; *
GATOR           ; *
FrGATOR         ; *
OCHO            ; *
NAOCHO          ; *
HYDRA           ; *
R`HYDRA         ; *
GAURD           ; Smokebomb
SENTRY          ; Smokebomb
WATER           ; *
AIR             ; *
NAGA            ; *
GrNAGA          ; *
CHIMERA         ; *
JIMERA          ; *
WIZARD          ; Bolt 2 scroll
SORCERER        ; Ether
GARLAND         ; Short sword
Gas D           ; 6720 gold
Blue D          ; 7690 gold
MudGOL          ; Fast scroll
RockGOL         ; Slow scroll
IronGOL         ; Iron armor
BADMAN          ; Silver armor
EVILMAN         ; Silver sword
ASTOS           ; Rub scroll
MAGE            ; Ether
FIGHTER         ; Fog 2 scroll
MADPONY         ; *
NITEMARE        ; *
WarMECH         ; ELIXIR
LICH            ; Phoenix Down
LICH (reprise)  ; Aegis Shield
KARY            ; Fire 3 scroll
KARY (reprise)  ; Ribbon
KRAKEN          ; Opal bracelet
KRAKEN (reprise); ELIXIR
TIAMAT          ; Dragon armor
TIAMAT (reprise); Masamune
CHAOS           ; ELIXIR
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 28, 2019, 10:28:54 pm
Looks good!
In my notes for my hypothetical remake of Final Fantasy 1, I have planned out only getting gold and equipment from monsters that make sense to have them.
Beasts should only have natural items that you can sell for gil, like fur, fangs, and petals.
And I mean to the point that I'd make it so beast enemies wouldn't even drop gil from normal battle.

Anyway, you might want to think about starting to add new pieces of equipment to help pad things out not that the game supports up to 64 weapons and armors.

Speaking of new stuff, is it viable to expand the number of spells, too?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 29, 2019, 12:08:42 am
I'm gonna say... yeah, I could probably double the number of spells. I don't know about just adding a few extras, though. Might be a double or nothing type thing. The main issue is how to store them on each character, but there would be 64 bytes still free for that, if necessary. An idea would be to make one character stat byte be a switch for white/black or summon/time or something-- say a Red Mage knows Fire, Ice, and Cure, but then switch their magic toggle and the spells they know turn into Chocobo, Sylph, and Demi... Or I guess have it where so long as you've bought the spell at all, any class that can cast it, can. But I think that's kind of boring and less personal.

The other issue is... why add more spells when half the spells in the game are already pretty useless? Do we really need two versions of Lock, Slow, and so on? The whole start of this was an idea I had where lighting orbs boosted spells, so Fire would become as strong as Fire 2, then as strong as Fire 3, then almost as strong as Nuke by the end.

There's 2 unused consumable item slots... Pelt and Tooth? XD I can picture loading up on those and taking them to an NPC somewhere to exchange for new gear...

And yeah, I want to make some new equipment. I think this project is at the point where I can let it go. I'm going to add the Kick command for Black Belts and try to think of something for Fighters, MAYBE Red mages. Then bugfixes, bugfixes, bugfixes! Once its uploaded on the main site as an IPS, I'm going to break off and start working on my own... everything. Worry less about making Final Fantasy changes and just make the changes I want to see in an RPG.

I'll probably still be around to help code things other people come up with though, 'cos its kinda fun!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on April 29, 2019, 02:39:28 am
I'm gonna say... yeah, I could probably double the number of spells. I don't know about just adding a few extras, though. Might be a double or nothing type thing. The main issue is how to store them on each character, but there would be 64 bytes still free for that, if necessary. An idea would be to make one character stat byte be a switch for white/black or summon/time or something-- say a Red Mage knows Fire, Ice, and Cure, but then switch their magic toggle and the spells they know turn into Chocobo, Sylph, and Demi... Or I guess have it where so long as you've bought the spell at all, any class that can cast it, can. But I think that's kind of boring and less personal.

I'd say if it's double or nothing, then that's fine.
Even if all the extra spells aren't created right away, it still leaves a good space for those who want to get creative with it.

I think having it continue to work the way it currently does but with 2 more categories of spells would be ideal.
But, I agree that having spell learning be less personal would not be a good thing.



The other issue is... why add more spells when half the spells in the game are already pretty useless? Do we really need two versions of Lock, Slow, and so on? The whole start of this was an idea I had where lighting orbs boosted spells, so Fire would become as strong as Fire 2, then as strong as Fire 3, then almost as strong as Nuke by the end.

For my purposes, I'm planning to replace some existing spell effects and likely creating some entirely new ones as well.
I want to replace the White and Black Wizards with the Green Mage and Time Mage, so having more slots to work with will make things easier.
Right now I'd have to share too many spells between the various casters than I'd like.



There's 2 unused consumable item slots... Pelt and Tooth? XD I can picture loading up on those and taking them to an NPC somewhere to exchange for new gear...

That would be pretty cool.
Wish there was room for a few more.
If only 2, then I think Skin and Claw could more easily be associated with more types of creatures.



And yeah, I want to make some new equipment.

I was thinking that you could make most of the new equipment exclusively available through the Steal command.
That would give the command greater purpose without having to fully rebalance all the shops and chests.



I think this project is at the point where I can let it go. I'm going to add the Kick command for Black Belts and try to think of something for Fighters, MAYBE Red mages. Then bugfixes, bugfixes, bugfixes! Once its uploaded on the main site as an IPS, I'm going to break off and start working on my own... everything. Worry less about making Final Fantasy changes and just make the changes I want to see in an RPG.

Cool. I was kinda waiting for the master branch to get to that point before diving deeper in myself.
I still want to integrate all of Anomie and AstralEsper's work into the game.
And I look forward to seeing how your project develops! :D



I'll probably still be around to help code things other people come up with though, 'cos its kinda fun!

Awesome of you to do so!
If I can ask for one thing right off the bat, could you make sure that there is a slot for all 12 classes in the code for the Skill command? Being able to code new commands and just plug them in would be a great help. :)



PS-
Did you ever look into that thing I mentioned about the Battle Item slots only being tied to the weapon inventory and how that prevents some classes from being able to use certain armor-type items to cast spells because they can't normally equip them?

I figure the simplest thing would be to have one of the slots use the weapon inventory, and the other use the armor inventory.

Another way would be to let both slots access both inventories.
Either you could add in a menu like in the Magic screen that lets you switch between weapons and armor, or allow the select button to switch between the two inventories.

Or... you could do away with traditional item casting equipment and replace them with Relics.
All the equipment that used to cast spells would have those spells removed with these items being renamed or altered as needed.
Maybe even create new effects for them like stat bonuses or other enhancements.
Meanwhile, there would be one relic for each spell that used to be cast by regular equipment.
And maybe a few relics based on ones from FF6.
Yeah, crazy. :P
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on April 30, 2019, 10:51:15 pm
If only 2, then I think Skin and Claw could more easily be associated with more types of creatures.

Squeezing every last drop out of each chunk of save RAM... there's a fair bit more. Might require re-arranging key items and consumables again. Or just leaving those 2 consumable slots open and using key item slots. OR one of the 8-9 bytes of space just after one of the extra music stuff...? There's actually a lot of free save RAM for it, its just kind of spread all over...

If I can ask for one thing right off the bat, could you make sure that there is a slot for all 12 classes in the code for the Skill command? Being able to code new commands and just plug them in would be a great help. :)

How many skills do you think each class needs? Just the one? If so; done already on my end. If two or more, that's gonna change it up a bit...

Did you ever look into that thing I mentioned about the Battle Item slots only being tied to the weapon inventory and how that prevents some classes from being able to use certain armor-type items to cast spells because they can't normally equip them?

Whoops, I forgot. I wonder how easy it will be with the changes I made so armour isn't stored as $1-$40 now... At least shops won't have to try to guess which slot is holding which!

Did you see the icons I added to the equip menu screen? Wonder if they can be used instead of the "Right hand", etc, text. Did I miss if you uploaded your idea for the screen's layout?

(https://cdn.discordapp.com/attachments/535538496547586060/572976670097801220/Untitled-1.png)

Could maybe make room for a menu if it were arranged more like this... Then have each battle item have like a switch beneath it or something...

Relic idea is neat; but definitely something for a "this is no longer your grandma's FF1" branch XD



So I read that Kick is calculated by dividing attack by the amount of enemies alive... There's just the problem again of division and how.

I altered this bit from the code that divides EXP among the living party members:

Code: [Select]
   @Divide:
   ;; divide damage among all existing enemies; number stored in Y
   ;; tmp holds ch_damage, tmp+1 is 0
          @divisor =    $84
          @remainder =  $85
     
    STY @divisor                ; Y (the number of living enemies) is the divisor
    LDA #$00
    STA @remainder              ; zero remainder
   
    LDX #8                      ; loop 8 times, one for each bit of the dividend
   
    ROL tmp                     ; roll out the high bit of the sum into C
    ROL tmp+1
  @DivLoop:
    ROL @remainder              ; roll bit into remainder
   
    LDA @remainder
    CMP @divisor
    BCC :+                      ; once the remainder >= divisor
      SBC @divisor              ;  ... subtract divisor
      STA @remainder
  : ROL tmp                     ; roll 1 into result (if subtracted)
    ROL tmp+1                   ; or 0 into result (if didn't subtract)
    DEX
    BNE @DivLoop

But tmp does not need to be 2 bytes... so how would I make this shorter? Just... remove the ROL tmp+1s?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on April 30, 2019, 11:14:33 pm
Quote
But tmp does not need to be 2 bytes

.... are you sure?  If tmp is one byte that caps TOTAL (pre-division) damage at 255.  That would make this pretty useless about 1/3rd of the way through the game.

But yeah if you are okay with that, then removing the ROL tmp+1 lines will shave 4 bytes.

Also, CMP is basically a glorified SBC so you can trim off another byte by combining those:

Code: [Select]
...
    LDA @remainder
    ; OLD CODE
;    CMP @divisor
;    BCC :+                      ; once the remainder >= divisor
;      SBC @divisor              ;  ... subtract divisor
;      STA @remainder

    ; REPLACE WITH (1 byte shorter)
    SEC
    SBC @divisor
    BCC :+
      STA @remainder
     
  : ROL tmp                     ; roll 1 into result (if subtracted)
...

Also there appears to be an existing division routine in Bank C -- which looks almost exactly like this one (see DoDivision and YXDivideA).

Maybe just rip this code out entirely and call that?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 01, 2019, 12:17:02 am
Ohhhhhh... right, battle stuff DOES have division routines already there!

How does this look?

Code: [Select]
    LDX #9                      ; max amount of enemies
   @Loop:
    LDA btl_enemyIDs, Y         ; check each slot
    CMP #$FF                    ; if its $FF, decrease X
    BNE @EnemyExists
   
   @NoEnemy:
    DEX
   
   @EnemyExists:                ; go through all 9 slots
    INY
    CPY #9
    BNE @Loop
   
    LDY #ch_level - ch_stats    ; backup character level
    LDA (CharStatsPointer), Y
    STA tmp+1
   
    LDY #ch_damage - ch_stats   ; get character damage
    LDA (CharStatsPointer), Y
    STA tmp                     ; store in tmp
   
    TXA                         ; put living enemy amount in A
    LDY #0                       
    LDX tmp                     ; and damage in X
    JSR YXDivideA
   
    ; A = result... should be damage / enemy count
    CLC
    ADC tmp+1                   ; add level
    STA btlmag_effectivity      ; that's the kick's effectivity!
   
    JSR Battle_PlayerMagic_CastOnTarget     ; And actually cast the spell
    JMP Battle_EndMagicTurn                 ; End the turn


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;  YXDivideA  [$AA1B :: 0x32A2B]
;;
;;  A = YX / A
;;  X = YX % A
;;
;;  divHi has the high byte of the division result (but it's never used)
;;
;;    As with 'DoDivision', you'd think this routine would be used more, but it's only used
;;  for formatting HP for printing.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

YXDivideA:
    STA btltmp_divV
    STX btltmp_divLo
    STY btltmp_divHi
    JSR DoDivision
    LDA btltmp_divLo
    LDX btltmp_divV
    RTS

I'm not sure what divV and all that means. Or if I want the output to be the percentage or... what.

I basically hijacked the magic casting code to have the Kick command attack all enemies. So I want to try to get the damage effectivity to work the same as damage would for a physical attack. I'm pretty sure I'm the least qualified for balancing this kind of thing!

Edit: Seems to work! Damage of $26 against 5 enemies comes out to $07. +level is a bit much maybe, so now its +level/2. So at level 12, that comes to an effectivity of $0D, which is still more than enough to kick all the sahagin butt. Except maybe kicks should somehow miss sometimes...? >.< Or maybe use MP...

And what should the formula be for steal success? Something to do with thief speed vs. enemy evasion? But I don't really know how to smash the two numbers together and decide what creates a win state.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 01, 2019, 03:53:18 am
Except maybe kicks should somehow miss sometimes...? >.<

Yes! Definitely, yes!


Or maybe use MP...

No! Definitely, no!


And what should the formula be for steal success? Something to do with thief speed vs. enemy evasion? But I don't really know how to smash the two numbers together and decide what creates a win state.

I can help with that actually. I have compiled a lot of research into the mechanics of many of the FF games. Let me look through my notes and I'll get back to you on this tomorrow at a more decent hour.


About the number of skill commands.
One each is what I was thinking as far as staying in line with the early FF games.
Ultimately, and ideally, I'd like it to function more like FF3.
It would definitely be useful to others to be able to have unconventional set ups for each job; like how the Black Mage in FFX-2 has no FIGHT command and instead must rely on magic entirely.

Hmmm... I do have one criticism of the current set up, though.
Having a command that just contains another single command is a redundant.
It's basically just an extra step.

Taking into consideration the goal of this project and our own personal goals, with regards to what we want to do with it in our own branches, I recommend updating the command window to support command configurations on a per class basis.
And instead of having a skill command, each class can have it's own command that can either have a single direct use or pull up a short list of individual skills (Maybe 4 skills max to allow for longer names).


About the equipment screen...

Yeah! I saw the icons.
They're pretty cool, but I don't think I prefer them replacing the slot text.

Actually, I just noticed that the item names are still the same length as in the original game.
Can these be expanded to 10 characters?
The shops would have to be modified a bit, but everything should fit.
The Gear command window would definitely need to be widened.




EDIT:

OK.
I looked through all the documents I have on the mechanics of the first 6 FF games in reference to the Steal command's workings.
Except for FF5 they all pretty much work based on the thief's level vs the target's level.
FF5 is different because it is a Hit% check with a flat 40% chance of success (or 80% if using the Thief Glove).

Before I give a recommendation, let's talk about the relevant stats in FF1.

Agility is used For exactly 2 things.
It factors directly into Evade%.
And it factors into the chance's of getting Ambushed or a Preemptive Strike.

Luck was originally only factored into FLEE and Ambush/Preemptive.
The chance to run is bugged.
IIRC you used Luck as a factor in turn order and that is why you renamed it Speed, correct?

The way Ambush/Preemptive works is based partially on the lead character's Agility and Luck/Speed.
The document I use calls this Initiative.
Initiative = (Agility + Luck)/8.
It might better to have this value displayed on the status screen and to use it for turn order instead of just using Luck/Speed.

I recommend a bit of an overhaul to how these starts are used and what they are named:

Agility -> Dexterity
- Instead of directly factoring into Evade%, it should factor into Hit%.
(This will probably require that each class's fixed increase to Hit% be reduced.)
- It might be a good idea to have it factor into spell Hit% as well.

Luck/Speed -> Agility
- Have it factor into M.Evade% (aka Magic Defense).
(This will probably require that each class's fixed increase to M.Evade% be reduced.)
- Fix bug and have it properly factor into the Run command.
- Have it factor into Evade% instead of the old Agility stat.

N/A -> Initiative
- Use the same formula as in the Ambush/Preemptive calculations.
- Use it as a factor in turn order instead of Luck/Speed.
- Use it in the Ambush/Preemptive calculation.


Now as for the Steal command, I recommend using the existing Accuracy calculation.
- If the target has no item, end the routine and show the 'has no item' message.
- If the target has an item, make an accuracy check to see if the thief can get passed the target's defenses.
(Use the standard accuracy calculation; Attacker Hit% vs Target Evade%.)
- If the accuracy check fails, end the routine and show the 'failed to steal' message.
- If the accuracy check succeeds, then do a skill check to see if the theft succeeds based on the attacker's level and or thief level.
- If the skill check fails, end the routine and show the 'failed to steal' message.
- If the skill check succeeds, add the item to inventory and show the 'stole X item' message.

The skill check itself would be based on either character level*2 or (character level + thief job level) vs a random [0...99] roll. If skill check < random roll, steal succeeds.

There are probably quite a few things that could be done in the battle code to modernize and probably simplify how certain things work. Status immunity for example.

Here is a link to the reference document I use for FF1:
https://gamefaqs.gamespot.com/nes/522595-final-fantasy/faqs/57009 (https://gamefaqs.gamespot.com/nes/522595-final-fantasy/faqs/57009)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 01, 2019, 09:23:28 pm
That's a lot to process! Quick question... what's "clamped" mean? The link mentions it too, under the Bugs list:

Quote
*Hit% should be applied even if asleep, and not clamped until after evade is
 subtracted.

I know I fiddled with that part in the physical attack code... regarding the asleep part, maybe. Gah. That whole section is such a mess. It really needs to be spliced up into some smaller routines that can be re-used.

Right now I can't really change how Kick works. Making it a 65th spell is so much easier than writing a whole new attack routine that does all those calculations but prints messages differently... >.< Just another Big Ol' Project to tackle someday.



Edit: This is a list of the bugs on that link, and if I smushed 'em or not:

Code: [Select]
*The Ribbon's name has an extra space

Fixed.


*The Airship can land on the caravan.

Not Fixed.


*There are two Canoe items. One shows up in the menu but doesn't do anything,
 and the other works, but doesn't show up in the menu.
 
Fixed.
 
 
*House saves before restoring MP. Also needs message corrected.

Fixed.
 
 
*BB Armor bug, it looks at whether a weapon is equipped instead of checking
 armor.
 
Fixed.
 
 
*The game never actually calculates Damage Rating from STR, it just
 adds/subtracts weapon damage as you equip/unequip things. For the BB/MA, it
 does recalculated Damage based on STR when the BB/MA has a weapon equipped,
 but rounds *up* instead of *down* when adding STR/2 to the Weapon's Damage.
 
Not sure if bug? Not sure if there's a way to change how doing "LSR A" on
ch_strength rounds up or down. If this is a bug, what would the fix be?
 
 
*BB Magic Defense Growth is +4, while MA Magic Defense Growth is +1. Several
 other values are suspect and there is evidence others may be bugged.
 
Fixed by giving Masters a +4. Reasoning is that I view these classes as
"anti-magic"; they're the only one not to learn magic on job advancement,
and defending against it seems a very monk thing as well.
 
 
*The RM/RW gains a tenth L1 spell charge at Level 35. The bug is probably an
 erroneous gained L1 spell charge at Level 22.

Fixed: removed L1 spell charge at level 35.
 
 
*The "swap" function used when character order is rearranged after battle is
 passed the original slot numbers rather than the current slot numbers, causing
 incorrect ordering in 106 of the 256 possible combinations of statuses.

Fixed, 90% sure.
 
 
*A phantom door will appear if you exit the menu while standing in a doorway
 and then walk down.

Not fixed.

 
*NPCs can walk through you under certain circumstances.

Fixed on exiting shops; which was an issue of my own creation. Not sure what
other circumstances there are... (Exiting the submarine?)


*The data from the last enemy domain area you were in is used when you get into
 a battle (on the Overworld?). 

Not fixed.
 
 
*The Peninsula North East of Pravoka (PNEOP) is the result of overworld
 mapping, whereby the monsters from the zone primarily overlaying the area
 around Lufein overlaps on a few tiles. There isn't really any fix other than
 remapping the terrain.
 
Not fixed.
 
 
*Target-dark should not be applied when the target is asleep/stopped.

Not fixed?


*Hit% should be applied even if asleep, and not clamped until after evade is
 subtracted.
 
Not sure how to tell if fixed.
 
 
*Weapon category/element attack values are never loaded.

Fixed.


*Weapon index is used for critical value.

Fixed.


*Enemies use their category/element as a category/element attack, and the
 warrior's category/element attack as the category/element to attack.
 
Not sure what this is saying exactly... But...
Enemies use their elemental RESISTANCE as their attack element now. (For now.)
Players use their weapon's element.
 
 
*The player class is used as the creature type when magic is cast. Fortunately,
 only HARM uses it and no class has bit 4 set.

Seems not to be an issue and may be fixed anyway (player magic defender
category is set to 0.)
 
 
*Weapon elemental attack is used as elemental weakness when magic is cast.

Fixed? Players have elemental reistance and weakness set to 0 every time
equipment is updated.


*Running looks in the in-battle data instead of the permanent data.

Fixed.


*MUTE status prevents Item and Drink as well. This is likely a bug, as
 preventing drink makes no real sense. Whether it should also prevent Item
 usage is uncertain.
 
Fixed. Items and Equipment can be used while muted.
 
 
*If you gain enough experience in one battle for one of your characters to gain
 2 or more levels, you only gain one level at a time even if you get enough exp
 for 8 levels, and your "For Level Up" value is all wrong until you manage to
 gain levels up to your exp.
 
Not fixed. Tried to once and got the game messed up. Might work now if we try.
 
 
*Status attacks are attempted on misses after the first successful hit

Fixed.


*Enemies always wake from sleep.

Fixed.


*Enemy-cast all-allies spells (e.g. AFIR) don't hit the caster.

Fixed.


*Poison doesn't work on enemies.

There is no spell that poisons enemies. A whole new routine would need to be
written for it.


*In the 2-large-6-small enemy formation the third enemy type will use the
 palette set for the second enemy type rather than the palette set for itself.
 
Fixed.
 
 
*If an enemy kills itself (because it was Confused), the battle won't actually
 end until either one of your warriors tries to attack or cast magic on an
 enemy or the round of battle ends.
 
Fixed.
 
 
*INT is never used.

Not fixed.


*HEL2 effectivity should be 0x18.

Fixed.


*LOK2 should use effect 0E instead of 10.

Fixed.


*LOCK (and fixed LOK2) always misses.

Fixed.


*TMPR should probably be using effect 0B instead of 0D.

Fixed.


*For PC targets, Damage and Hit% are never loaded/saved for use by magic. Thus,
 TMPR and SABR are bugged.

Fixed.

 
*Absorb for enemy targets is loaded from ROM instead of RAM for magic, making
 FOG not work.

Fixed.

 
*For enemy targets, Hit% is never loaded/saved for use by magic.

Fixed.


*Enemy elemental resistance is not stored in the in-RAM data, so spells like
 AFIR and XFER don't work.
 
Fixed? I'm still confused about how this should work; I mention it all over the
place where elemental weakness and resistance is used.

 
*Several caster bytes are loaded for magic, with wrong values. But none are
 actually used.
 
Fixed.
 
 
*Spells causing multiple status ailments will claim "Ineffective" if the target
 has any of the ailments (all will still be applied though).
 
Might be fixed, but probably not!
 
 
*There is an invisible lady in Coneria Castle. Her sprite is set to be visible
 inside rooms, when it should be set to visible outside rooms.
 
Not fixed.
 
 
*There is a Bat in the Waterfall that starts on a wall, leading it move into
 the wall area half of the time.
 
Not fixed.


*There is a Fairy sprite in the black area of the Ice Cave (though this is not
 noticeable during normal gameplay).
 
Not fixed.
 
 
*The old man next to the submarine in Onrac uses "Wind Orb Lit" as a condition
 for changing dialogue when it should probably be "Water Orb Lit"

Not fixed.
 
 
*The Sage at 3:00 in the Circle of Sages in Crescent Lake is supposed to use
 Text 9D, but lacks a condition. This should probably be "All Orbs Lit"
 
Not fixed.

 
*The routine that looks at the tile data and determines whether to use the
 second byte as a message index or not says "not" for far too many values. The
 effect is that you can talk to the Earth and Water Altars, but not the Fire
 and Wind.
 
Not fixed.
 

*The Gaia Spring Tile is unused.

Not fixed. Is it a bug or just something unused?


*There is an unused Warp Tile in the ToFR Tileset that looks like the Time Warp
 in the ToF Tileset. Its absence may or may not be a bug.
 
That's a thing!

Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 01, 2019, 09:32:12 pm
IMO  Sleep/Stun should be a guaranteed hit unless you're Dark/Blind.  Even the most incompetent fighter can land a blow on a stationary target.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 02, 2019, 03:09:04 am
@Disch: I agree.

@Jiggers: Thanks for that list! It helps a lot.

Clamped means that you check a value to see if it is above a given maximum and if it is above that maximum you set the value to the value of the maximum you checked for.

It usually works like this.
Code: [Select]
If (x > 10)
{ x=10;
}

Thus if x in the above example was previously set to 20, then this code would clamp it at 10 by setting it to 10.

So what is happening in the original code is that it is doing this clamping earlier than it rightly should.
And that can lead to some unintentional penalties to attackers with higher hit rates when fighting targets with lower evade rates.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 03, 2019, 02:53:25 am
Ohhh, just capping then. I get that.

Code: [Select]
Having a command that just contains another single command is a redundant.
It's basically just an extra step.

Yeah, but I figured it was safer to experiment with a new box than the command box. XD Also the command box is called at various points... So the code to figure out what text to draw in that spot would need to be in the fixed bank, which is low on space. Need to find routines in there that can be moved out. Looks like 123 bytes left.

Quote
IIRC you used Luck as a factor in turn order and that is why you renamed it Speed, correct?
Yep. I'm also pretty sure my new turn order thing is screwy. Just a feeling I get while play testing...

I'm having kind of a mental block right now trying to parse the skill check stuff in your other post. I don't really know what it is... like I'm psyching myself out of understanding it. See my "update" to Bank C for instance. I look at my fix to the running away code and... it seems to me like the higher your level, the harder it is to run?? Am I understanding it right and catching a dumb mistake I made back then, or is it right and I'm just confusing myself looking over it again? But its like that with all the stat vs. stat stuff I see lately. I think I might be better off leaving you to it with the battle code!

I wanted to make stealing be a whole system that contains every item in the game, but I think I'll re-do it from nearly scratch. Instead of the list being in order of items, it would be in order of enemies. Imp would be 0, GrImp would be 1, and so on. That way there's only $7F entries, and even if most of them are the same (no item listed) it would be simpler to edit. Rather than changing the byte in the enemy table, you'd just change the byte in the stealing table, the way I have treasure chests set up.

One thing with enemies... I really wish I could figure out how to expand their RAM use past $100. They have 28 bytes of stats each now, and I love the idea that every single one of those can be changed, but a few of them have no need to be changed, I guess? Experience, gold, AI... I don't know which would be easier, to take them out of RAM or make their RAM space bigger. I want to add a proper speed stat for turn order, a steal difficulty/rarity stat...

Rambling now, but I want to make it so an enemy has 2 possible things to steal, and getting a crit-steal gets the rare item. That would be a 1/256 chance pretty much, and rather than having the item byte be the item ID it'd just be an off/on trigger. $10 for rare items, $01 for normal.

So anyway--one of these days I'll try harder to power through and organize the physical attack stat vs. stat stuff better, maybe. Meanwhile, battle items can be weapons or armor! That is live.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: daman.tm on May 03, 2019, 06:59:08 am
I just want to let you guys know what you're doing is absolutely amazing! This is literally the only thread I check daily because the changes you guys are making are awesome, and seeing the code is beyond fascinating!

Keep up the amazing work!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 03, 2019, 10:16:29 pm
Thank you! That's really nice to hear; it really helps to know there's more people looking forward to this getting done!

And an update:
I fixed spell messages not displaying right (I changed the variable, but the code was using the raw address and not the variable name)

Aaaand, enemy gold and experience is now in its own spot in memory, so that's 4 more bytes of enemy RAM stats. I went ahead and added speed and stealing difficulty to their data, but they're all 0 so far and not loaded up in battle yet.

Quick update: I set speed stats for all the enemies and adjusted the turn order randomization routine. It may need more tweaking. Gotta get like a spreadsheet of player luck/speed numbers for each level and figure out where the enemies show up and adjust their speed based on that... maybe.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 04, 2019, 03:24:58 am
Hey all. Just popping in to let you guys know I'm going to be without internet for a few days.
I got the latest zip from the github page and I'll mess with it and see if I find any bugs while I wait for my service to be back up.

I'll be back to give proper replies soon.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 06, 2019, 02:18:58 am
No worries!

I coded in the Fiend Battle music, but there's a few things...

* I'm still not happy with the triangle channel bassline in the beginning...

* Due to the way tracks are loaded, we're already at the maximum number of songs? Every song's 5 tracks are loaded by multiplying the song's ID by #10. $19 * $0A is $FA. I don't know what will happen if that goes over $FF.

* I thought this was why the music wasn't working in battle, so I removed the unused tracks. So in the sound test menu (B+Select in towns, dungeons, etc) the new song is still listed as "Healing (Unused)"

* "Treasure (Unused)" now plays some wicked death metal or something. I just realised I messed up counting the tracks so the new song can be ID $19 after all. So I'll fix up the sound test menu stuff later and put the unused tracks back in place.

* Lastly... Math is REALLY HARD SOMETIMES. So track 5 of the boss battle music--square channel 4--is not playing properly. After 2 loops its noticeably off. I'm just not sure how or where. I can't even really tell if its late or early. AND I JUST FOUND IT. There's a part where it goes $79, $78, $79... And its supposed to be $79, $89, $79!  :banghead: And I was wondering why that part sounded off, but I thought it was just the duty of the square or something...


And an MP3 here! https://cdn.discordapp.com/attachments/527351555779723266/574840396576980997/FiendBattle.mp3
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 06, 2019, 02:39:29 am
* Due to the way tracks are loaded, we're already at the maximum number of songs? Every song's 5 tracks are loaded by multiplying the song's ID by #10. $19 * $0A is $FA. I don't know what will happen if that goes over $FF.

This really shouldn't be an issue.  Multiplication gives you a two byte product, right?

Untested pseudo-code:
Code: [Select]
LDA song_id
LDX #10
JSR MultiplyXA
CLC
ADC #<song_pointer_table
STA tmp
TXA
ADC #>song_pointer_table
STA tmp+1

LDY #0
@Loop:
  LDA (tmp),Y
  ; ... read the channel pointers from (tmp), using Y as index
Title: Re: FF1 MMC5 Disassembly Updates
Post by: daman.tm on May 06, 2019, 04:10:37 am
Holy moly I'm loving the fiend battle track!
Nice work!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 06, 2019, 04:41:45 am
Hmmm... I'm not sure how I feel about that new track.
I'm a little weary of battle themes that are arrangements of existing tracks.
So I might be a bit harsh in my criticism because of that.

I hear what you mean about the baseline.
There is something a bit off sounding about it, for sure.

As someone that can't do music in much any way that's worth diddly squat, I find it an amazing feat.
That said, a remix of the Temple of Chaos is a a cool idea for the Fiend battle music, BUT that first half of the melody just sounds way too upbeat for battle music (or even as dungeon music).

I basically have the same problem with the Temple of Chaos and Underwater Shrine themes. They start off sounding way too upbeat for places that are full of dangerous monsters lead by a Fiend of Chaos.
That's why I suggested doing something different for the Underwater Shrine before. With this battle theme in the game, I want that Underwater Shrine theme replaced even more.

The second half of the melody is awesome and I love how you got it to convey a definite feeling of urgency.

Right now this is what I would do with these songs:
Code: [Select]
Location                -> Song
------------------------------------------------------------------------------------------
Temple of Chaos (Ruins) -> Undersea Shrine
Temple of Chaos (Past)  -> Temple of Chaos
All Fiend battles       -> Your new battle theme.
Garland battle          -> Maybe this one could use your Fiend theme too as foreshadowing.
Sunken Shrine           -> My hypothetical remix/extension of the Deep Place fanfare
                           (that-I-have-no-hope-of-ever-being-able-to-make-on-my-own).



Could I ask a favor?
When you get a chance, could you modify the old marsh cave song to include a version the battle intro notes using old marsh cave's baseline?
I'd love to hear it in the form of a proper battle theme.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 06, 2019, 04:30:53 pm
This really shouldn't be an issue.  Multiplication gives you a two byte product, right?

Untested pseudo-code:
Code: [Select]
LDA song_id
LDX #10
JSR MultiplyXA
CLC
ADC #<song_pointer_table
STA tmp
TXA
ADC #>song_pointer_table
STA tmp+1

LDY #0
@Loop:
  LDA (tmp),Y
  ; ... read the channel pointers from (tmp), using Y as index

I only brought it up because at first I thought that's why the music wasn't playing in battle. It turns out I just was counting the tracks as starting at $41 instead of $40, so I was trying to play music that didn't exist. I suppose I should make sure adding new songs works eventually though, so I'll stick this in there as a note!

Holy moly I'm loving the fiend battle track!
Nice work!

:D Thanks!

As someone that can't do music in much any way that's worth diddly squat, I find it an amazing feat.
That said, a remix of the Temple of Chaos is a a cool idea for the Fiend battle music, BUT that first half of the melody just sounds way too upbeat for battle music (or even as dungeon music).

I basically have the same problem with the Temple of Chaos and Underwater Shrine themes. They start off sounding way too upbeat for places that are full of dangerous monsters lead by a Fiend of Chaos.
That's why I suggested doing something different for the Underwater Shrine before. With this battle theme in the game, I want that Underwater Shrine theme replaced even more.

Funny, my girlfriend said the same thing. Said the Temple of Fiends was more like Frolicking in Flowers to her. Yet both those songs are my favourites in the whole game because they feel melancholy to me!

So I made some changes... the second half of the Temple of Fiends melody is now more... off. Some chord changes and pushing the melody down a bit more here and there. The bass now matches the square 3 drones, and I raised/lowered it in places to keep it within the second-lowest octave. Its lowered more during the second half of the Sea Shrine melody at the end, and raised more during the Temple of Fiends part. Changed a few frills around at the start and end of the song, and tweaked the harmonic melody played by square 4, then raised the trills much higher.

Update: Since I can't leave well enough alone, I did more changes, mostly for the clarity of the music. Less notes overlap and such, and the volcano bass line just before the loop point is boosted by a square that was just playing a droning note before.

And here's something fun to look at, just 'cos.

https://cdn.discordapp.com/attachments/535538496547586060/575098568852111363/FiendBattle.png

Could I ask a favor?
When you get a chance, could you modify the old marsh cave song to include a version the battle intro notes using old marsh cave's baseline?
I'd love to hear it in the form of a proper battle theme.

Actually, I found out that I could possibly just make the battle intro woosh thing its own song, have it play at the start, then when it ends, the battle music code is set up to play a second song. I wonder if that was the intention behind that, and they just never got around to it?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 06, 2019, 10:57:24 pm
Wicked. Definitely going in the right direction. :)
Some of the notes in the beginning after the battle intro sound a bit dissonant, but otherwise it's progressing really well.

You might be right about the battle intro.
Makes sense to me at least.

PS- My girlfriend (who actually does know about music) thinks your new Marsh Cave song is really good and would work well in a Castlevania game.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: daman.tm on May 07, 2019, 06:04:07 am
On the topic of music, one of the major gripes I had with FF1 is how a song restarts when you go up/down stairs. Would it be possible to continue playing a song instead of making it restart? So many good songs in FF1, but you keep hearing the first few couple of seconds, never enough to truly appreciate the music
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 07, 2019, 05:57:27 pm
That's a good point.
I second that.



So the current build I tried out last night; there is a bunch of bugginess in the battle system.
Enemies running away out of nowhere, enemies that are not in the formation being named in the messages, that sort of thing.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on May 07, 2019, 08:25:01 pm
On the topic of music, one of the major gripes I had with FF1 is how a song restarts when you go up/down stairs. Would it be possible to continue playing a song instead of making it restart? So many good songs in FF1, but you keep hearing the first few couple of seconds, never enough to truly appreciate the music

Like the future FF1, yea. It is possible.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 07, 2019, 09:14:39 pm
Fixed the enemy stats! I made a whoopsie while changing things and now its all better. If there are any more problems in battle, its gotta be something else loading stats wrong. But there's no reason they should be!

I'm looking into having music not reset on changing floors... I won't attempt to make music restart from its previous position after a battle, though. Not unless there's some way to consolidate all the music RAM into one place. Right now there's some in zero page, some in save RAM. (Hey, does zero page get swapped with the rest when RAM swaps with the MMC5? ...it does not.)

The stack annoys me. I notice it goes deeper just by moving floors back and forth in the first castle. Should it be doing that? Shouldn't it be going backwards once you go back to a previous floor? It doesn't seem to break the game if I overflow it... All I did was go back and forth on the stairs then leave, though.

Something for people to test: If you have the ship or airship, get on it to have the music change, then dock/land to change the music back to the main overworld theme. Save the game in the menu; what song plays after? For me, its the ship theme! Aaaand, soon as I post this, that stops happening.

Also, how many scanlines does the NES use? Need to set Square2 SFX for a certain amount of frames... Its the opening/closing screen that's shutting music off between floors, and it was using Square 1 for some reason and shutting the rest off. So I got it using square 2, and not shutting the rest off. Will see how weird things sound, but not sure how to do the math to count how many frames it takes before square 2 is allowed to play normal music again. Edit again: Sorta figured it out to 22 frames.



So I'm not sure how to do this cleanly. During the screen-wipe phase, there's a bunch of loading routines going on, and they don't call music playing or do any kind of frame counting, because they don't have to. They're just decompressing maps and stuff while the screen is off. So one option is to put in some VBlank waits and have music playing--but I don't know where to put them.

Second option: Turn off music in a way that lets it resume normally when the screen wipe is done. Issue with this is not every instrument turns back on. Say the triangle and main melody are both playing long notes, while there's some quick doot-doot-dooting going on, like practically every song in the game. The doot-doots will be heard for a second before the triangle or anything else plays the next note.

What I'm going to try next is to turn off music, but also poke at the things that tell the music what to do, to let them know to change the volume back up immediately...? Somehow?

Update: It worked! Kinda! The squares hate it! They squeak when being shut off, then sometimes squeal when being turned on again...

Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 07, 2019, 11:16:03 pm
I'm looking into having music not reset on changing floors...

Easiest way I can think of to do this is to keep track of what song is currently playing, and then when a new song is played, compare it to the "current" one and do nothing if they match.

The music doesn't actually need to stop for the stair transition -- MusicPlay just needs to not be called.  Once you start calling MusicPlay again, it'll naturally resume from where it left off assuming RAM hasn't been clobbered.

Quote
I won't attempt to make music restart from its previous position after a battle, though.

That would be a bit harder, but not much.  You'd just have to snapshot all of music ram somewhere and then restore it afterwards.  But I think you already have that idea  ;)

Quote
The stack annoys me. I notice it goes deeper just by moving floors back and forth in the first castle. Should it be doing that? Shouldn't it be going backwards once you go back to a previous floor?

2F of Coneria castle can't use a 'warp' staircase to go back because you can teleport into it by talking to the princess in ToF.  If it had a warp staircase, going down the stairs would warp you back to ToF!  So it has to have a two-directional staircase there.

That's a rare exception to the rule.  The only other place that can't use warps is the Ice Cave (because of the pits creating a circular path).

Quote
It doesn't seem to break the game if I overflow it... All I did was go back and forth on the stairs then leave, though.

It can, and often does.  In fact some speedrunners exploit that glitch for any% speedruns.


Quote
Also, how many scanlines does the NES use?

The full frame is 262 scanlines:
20 scanlines of VBlank
1 "pre-render" scanline
240 rendered scanlines
1 "idle" scanline

Quote
Need to set Square2 SFX for a certain amount of frames...

You probably don't need to do that for this effect.  The Sq2 sfx trigger only prevents sq2 from interrupting the music -- if you just simply don't call MusicPlay during the transition effect, there's nothing to interrupt.

Quote
Say the triangle and main melody are both playing long notes, while there's some quick doot-doot-dooting going on, like practically every song in the game. The doot-doots will be heard for a second before the triangle or anything else plays the next note.

You should be able to deduce what tone/volume the channels SHOULD be playing at any given time by their data in RAM.  If you do my above idea of comparing new song to current song -- maybe use that opportunity to restart notes:

1) MusicPlay normally just plays music
2) Unless a new song is requested
3) If a new song requested, see if it's the same as the current song
3a)   If same, use data in RAM to "restart" all channels and resume song without restarting
3b)   If not same, load a new song and start it from the beginning as normal
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 08, 2019, 02:19:03 am
Actually, I found out that I could possibly just make the battle intro woosh thing its own song, have it play at the start, then when it ends, the battle music code is set up to play a second song. I wonder if that was the intention behind that, and they just never got around to it?

Hmmm... then I guess if that could be done I would still want a version of the battle intro jingle that uses the Old Marsh Cave baseline instead of the normal one.
I might be able to do that myself.
Any tips for how to accomplish this?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 09, 2019, 01:52:08 pm
2F of Coneria castle can't use a 'warp' staircase to go back because you can teleport into it by talking to the princess in ToF.  If it had a warp staircase, going down the stairs would warp you back to ToF!  So it has to have a two-directional staircase there.

That's a rare exception to the rule.  The only other place that can't use warps is the Ice Cave (because of the pits creating a circular path).

Figures I'd test it with the one place that its wonky. But using warp magic in the Ice Cave would still set you back to the previous teleport, right?

Thanks for all the answers to everything else! I did already figure out how to keep music going, the issue was silencing things while MusicPlay isn't being called. Using #$30 to set the volume for the squares worked though! Just putting a 0 was making weird noises when it stopped and started. So I was setting the bit in each track to make MusicPlay re-set the duty and everything else when it re-started and that wasn't necessary after all. Or maybe doing that would make things smoother, but as it is now, I think it sounds good enough!

Having learned that $0300 is not swapped with RAM, I have some more re-arranging to do. Gonna use that space for extra music stuff. Right now its mostly shop/battle message things, so... look forward to all that getting screwed up again!

Hmmm... then I guess if that could be done I would still want a version of the battle intro jingle that uses the Old Marsh Cave baseline instead of the normal one.
I might be able to do that myself.
Any tips for how to accomplish this?

Sorry, I just kinda did it! Marsh Cave bassline plays $0x (C note) notes to start, 5 tones above the usual battle intro bassline. So I set the octave higher, copied those notes and the pauses over, then set the octave lower for the two-note dip ($Ax, or Bb), loop it once, then use the "no questions asked" loop code to  play the original Marsh Cave music after.

It took some thinking, but it seems like I got it set so we can add a lot more music tracks, too? So that's nice.

The Marsh Cave battle music is listed as "Fiend Battle 2" in the sound test menu. For now.



Important update!

Before using the new variables.inc file, make sure your magic inventory is empty! Otherwise you will lose spells! (You may also somehow gain spells after...)

Now that I understand things better, I'm trying to have music also restore itself after battles. It mostly works, but so far only after the second battle after switching between ship/on land music. I just pushed a tiny fix for that that I hope will work, so maybe not.

Sometimes the music squeaks when restoring. I might try muting things for a frame before it restarts. (Update on that: It waits 2 frames now, so let me know if you hear wrong notes after battles!)

Otherwise, I've noticed a crunchy sort of sound when getting on the ship. It might just have been the wave SFX starting quiet, dropping to 0 before starting up again?

And there it is again, on land music starting up after saving on the ship! Grr. But then, maybe the tiny fix I just pushed fixes that too! Since it makes sure to save the ship/on land music as the backup song once it switches.

BAH NOW THE FANFARE JUST KEEPS PLAYING ON THE OVERWORLD! WHY!!

I had the walking to the left animation be a JMP instead of a JRS and somehow that wasn't breaking things so I didn't notice the mistake until now. Pbbblt. Just to find out now if you walk to the left after beating Chaos or what...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 09, 2019, 07:25:41 pm
No apology need, bud.
As much as like missing with this stuff, I always appreciate not having to do something myself.
Bah! Music is really not my thing anyway.
Thanks again!



OMG! I love it!
Now I need to hear it in action.

And thank you from the bottom of my soul for turning off that stupid "there's nothing in front of you" message!!



Groovy! That Marsh Battle theme sounds awesome in action.
I have a concern tho.

You might have thought of this already, we need a way to be able to set different battle music besides the BattleMusic_LUT.
It could be expanded, but I guess there would have to be a new battle configuration layout.
Like a copy of the Fiend battle configuration so there could be a second Fiend battle song.

(Or for my purposes...)
Adding copies of the 9 small and 4 large battle configurations so I could have the Marsh Battle song be used for normal bosses like Garland, the Bikkeneers, or Astos.

Actually, as long as more battle configurations could be made, it might be a good idea to actually have slightly modified configurations to a small or large sized boss could be centered on the enemy side of the screen.

Does that sound feasible?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 09, 2019, 10:41:29 pm
Actually, as long as more battle configurations could be made, it might be a good idea to actually have slightly modified configurations to a small or large sized boss could be centered on the enemy side of the screen.

Does that sound feasible?

Iii have no idea. With regards to enemy placement on the screen, that is. The rest... yeah, I think so. Halfway through doing it already. Gotta find out which set of lut_BattleFormations is which battle next, then set the high bits of the first byte to 5 or 6. 5 for Garland and Astos and... Vampire? (Is that its own entry or does the game do something else to make sure you only face one...) 6 for Pirates. And uh... I'll put in 7 for the Eye and Zombie Dragon(s?) if they use the 4 big enemy layout.

I've also done something experimental with battle messages. Yeah, they're half as fast now, but please let me know if that's gotten rid of the weird laggy battle music!

Instead of printing $20 tiles per row before updating audio, its $10, then the next $10. And instead of two rows before updating audio, while undrawing the boxes, its 1 row, then update. I think. I feel like it made a difference, but again--my ears aren't so good catching it and my computer's own random stuttering means I might never catch it. I only noticed when Disch first pointed it out!

If that DID get rid of the issue, then I might need some help re-writing those bits to be faster...

Still not even sure if that can actually be the problem, though. Like, if the writing is taking so long that the music hangs an extra frame, wouldn't that mean its drawing outside of VBlank again...? There would be screen artefacts and stuff, right?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 09, 2019, 11:00:52 pm
I definitely still hear the music stuttering.   :-\  Though it does seem less noticeable than before.

Seems most noticeable when the very bottom text bar is undrawn (the wide one with the "terminated" message).

I'll take another stab at it this weekend to see if I can figure out what's happening.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 09, 2019, 11:48:55 pm
That's what I thought, too... but then today my brain was telling me it was the # hits box. I think I can definitely hear it when there's more than one long message box, too. Especially with Critical Hit > Stole Gold > Terminated.

I got mini boss music working right! I set it up for Garland, Vampire, Astos, the Eye, and the Pirates. I've only tested it on Garland, though. Also reminded just how much I loathe the original Marsh Cave music... Forcing myself not to write an addition so it doesn't loop so soon...

I'll see if the zombie dragon battle occurs normally anywhere before setting it for that one. Not gonna set it for wizards guarding the crown because they're a normal random battle later too.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on May 10, 2019, 12:07:32 am
I noticed that there was a tile appearing in the bottom right corner when entering battle, and the game lags very bad in battle as well. Is it just me? Its not my computer that lags instantly.  :-\
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 10, 2019, 12:21:49 am
Oh, yeah. Since it didn't fix the battle music being laggy, I undid the half-speed battle messages. Not sure about the tile though. Overworld or dungeon battle? What kind of tile was it?

Also, sorry for telling you I couldn't/wouldn't have dungeon music keep its place after battle! I just had to learn a few more things before it was easy enough to try!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 10, 2019, 12:27:33 am
Also reminded just how much I loathe the original Marsh Cave music... Forcing myself not to write an addition so it doesn't loop so soon...

Go for it. As long as you keep the style consistent I'm sure it'll be fine.
It is a short loop so extending it out a bit would be good.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on May 10, 2019, 12:35:32 am
Oh, yeah. Since it didn't fix the battle music being laggy, I undid the half-speed battle messages. Not sure about the tile though. Overworld or dungeon battle? What kind of tile was it?

Also, sorry for telling you I couldn't/wouldn't have dungeon music keep its place after battle! I just had to learn a few more things before it was easy enough to try!

maybe the menu tiles...  :-\

(https://i.imgur.com/UX5CI7q.png)

tiles appeared right-bottom side.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 10, 2019, 12:42:48 am
Yikes.  That looks like that might be some drawing code spilling outside of VBlank.  Which might also explain the lag if it's missing a frame somehow.

I didn't see anything like that when I ran in FCEUX... which also suggests it's timing related since different emus are behaving different.

What emu are you using, Mari42?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on May 10, 2019, 12:45:24 am
Yikes.  That looks like that might be some drawing code spilling outside of VBlank.  Which might also explain the lag if it's missing a frame somehow.

I didn't see anything like that when I ran in FCEUX... which also suggests it's timing related since different emus are behaving different.

What emu are you using, Mari42?

FCEUX 2.2.2
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 10, 2019, 12:48:31 am
I'm also running FCEUX 2.2.2 and I am not seeing that at all.

Are you using the code from the latest master?  Did you make any changes to it?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Mari42 on May 10, 2019, 12:52:48 am
Ah, its normal.... I also noticed that the music sounded as an echo. Is it because the new music was added?  :-\

I also noticed when I tried to use an item such as heal in-battle, the suddenly the game freezes in the spot. Awkward...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 10, 2019, 01:57:55 am
Yep! Tiny bit of echo is normal.

I'll test all the battle items again...

I fixed a bunch more little bugs I ran into while playing, and there's one I can't.

(https://cdn.discordapp.com/attachments/300491322895368192/576263956390477845/unknown.png)

The dialogue ID displayed is $FD, but should be $FF. The code all looks good, though. Everything went right as far as I could tell. Everything made sense with $FF*2 being $FE with carry set.

Code: [Select]
DrawDialogueString:
    TAX                   ; put string ID in X temporarily

    LDA #BANK_DIALOGUE
    STA cur_bank          ; set cur_bank to bank containing dialogue text (for Music_Play)
    JSR SwapPRG_L         ; and swap to that bank

    TXA                   ; get the string ID back
    ASL A                 ; double it (2 bytes per pointer)
    TAX                   ; and put in X for indexing
    BCS @HiTbl            ; if string ID was >= $80 use 2nd half of table, otherwise use first half

    @LoTbl:
      LDA lut_DialoguePtrTbl, X        ; load up the pointer into text_ptr
      STA text_ptr
      LDA lut_DialoguePtrTbl+1, X
      STA text_ptr+1
      JMP @PtrLoaded                   ; then jump ahead

    @HiTbl:
      LDA lut_DialoguePtrTbl+$100, X   ; same, but read from 2nd half of pointer table
      STA text_ptr
      LDA lut_DialoguePtrTbl+$101, X
      STA text_ptr+1

Lich's ball is $FA and displayed fine. Sooo... *shrug*

(And fixed all that fiend graphic stuff! Going to try to make the enemy name box not pop up for a split-second since you can't target them yourself.)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 10, 2019, 02:31:37 am
I'm using Mesen v0.9.7.

I just started a new game with the build from less than an hour ago and I'm not getting any graphical glitches so far. I'll play up to Pravoka to make sure.



Edit:

I should mention that I'm also not getting any delays in the music at all as far as I can tell.

I did notice that when I try to buy more stuff in any of the shops than I can afford, the message it displays is random-ish, but definitely not the correct "you broke-ass" message.



Edit2:

The song restart code seems to work fine up to the bridge scene.

However, after the bridge scene, it kept playing the Prologue song instead of switching back to the overworld music.

AAAND!! It doesn't restart the overworld music after leaving the map screen either.



Edit3:

I fought a group of GrIMPs and WrWolves south of the peninsula of power and for some reason the command menu did not erase during most of the battle. Afterwords it displayed the end of battle messages but there were 2 lines of jumbled letters and numbers behind the messages AND as the screen faded to black the top row of the background graphics glitched into... something.

Fought another group near by the same spot, but no glitches this time.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 10, 2019, 04:30:42 am
Oof.

The music should reset properly after those things (and the puzzle) now, I hope.

The shop wasn't set to display any message because I'm super dumb sometimes. It displays the right message, but I still have to update it to move the cursor away!

So I was fiddling with how the boxes are drawn when fighting Fiends, but I must have missed something. I'll work on that tomorrow.  :-[

I also have something great that's mostly done, except right now it lets corpses do the thing, and corpses should not do things.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 10, 2019, 04:49:46 am
Intriguing!
Yeah, we don't need any corpse party shenanigans around here.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 10, 2019, 03:43:18 pm
And its live.

Press Start in the command menu in battle to just... go nuts. It won't work in magic, gear, items, selecting an enemy, or selecting a character. Characters who have already picked a command won't be set. Characters who are dead or asleep or stoned or stunned or whatnot, shouldn't do it (I re-wrote the check for that so the game makes sure players can act before trying to do their turn, rather than trying to do their turn then checking to see if they can act.) So... what is it!

It's fight. It just makes everyone choose fight.  :P

I got tired of holding the A button down.

Also, if auto-target is turned off in the menu, it will turn it on for this, then turn it back off after the turn. Since it just automatically sets it to attack the first enemy in the list...

Next, turn select into auto-run? Yeah why not!

Also: That one battle that messed up, did you try to cast a single-target spell? That's what's messing up for me in non-fiend battles. Workin' on it next. Update; Should work as normal now? The bug was if you canceled targeting it, it would draw an extra command box...

P.S.--Mari, I'm so happy you're using the pink battle menu colours.  :D
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 10, 2019, 05:35:03 pm
It's fight. It just makes everyone choose fight.  :P

I got tired of holding the A button down.

This is why I was never a fan of auto targetting, and why I always loved FF1's "ineffective" system.

Just thoughtlessly holding A is boring.  But I guess now you can just press start and watch the game play itself... which is slightly less boring... I guess?  ;P

Sorry.  Just being a wiseass.   :laugh:
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Bregalad on May 10, 2019, 05:36:59 pm
This is why I was never a fan of auto targetting, and why I always loved FF1's "ineffective" system.

Just thoughtlessly holding A is boring.  But I guess now you can just press start and watch the game play itself... which is slightly less boring... I guess?  ;P
Another way to make the game interesting is to actually make magic or skills useful and powerful, and so there's a incitative to not just attack. Unfortunately you had to wait until FF3 in order to actually have spells being significantly stronger than attack.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on May 10, 2019, 06:47:53 pm
As well, maybe having more than a maximum of 9 MP for AN ENTIRE DUNGEON might've made using magic a more viable strategy. :P
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 10, 2019, 07:03:57 pm
This is why I was never a fan of auto targetting, and why I always loved FF1's "ineffective" system.

XD I completely agree with you. FF1 is higher on my list of favourite FF games because of the strategy and thinking involved. Trying to make sure your party's strength is spread out enough to take out enemies in a certain order and not waste damage and all that! The auto-fight button was really less of a "I'm too lazy to play this!" and more like, "I wonder if I can get this to work!"--and I did, so I'm happy about that.

Someday we'll get to the point where we can re-balance everything better...

Maybe I'll make my own branch where doing double digit damage is considered a lot, like those early strategy games where you do 1 damage a turn, 2 if its critical.

As well, maybe having more than a maximum of 9 MP for AN ENTIRE DUNGEON might've made using magic a more viable strategy. :P

We got ethers now, though! Just gotta figure out at what point they should be available and for what price.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 10, 2019, 08:16:49 pm
I'm in the minority here when it comes to auto-target, I guess.
I get it, though.

My hypothetical solution to this in my dream redesign document for FF1 is an idea for making auto-target a function of the character's intelligence and dexterity.

Basically, if the character is mentally and/or physically slow, they will have a harder time redirecting their attack in the heat of battle.

You get to keep some of the strategy of the 'ineffective' system and the smarter/faster characters (that tend to do less damage) are able to hit more consistently to balance things out a bit more.



The MP situation is one of my pet peeves.
Mostly it's because I loathe the Vancian casting system for it's inflexibility.
In my branch I definitely going to nix it in favor of a an MP pool.

The inclusion of ethers is great though.
To start, I think having them be available in Elfheim for at least 2x the cost of a Potion would work well.
I distinctly remember when I first played the game years ago having to treck back out of the Marsh cave once or twice in order to refill on spell charges before I could explore the whole thing.



Actually, I was thinking about tents, cabins, and houses last night.
FF1 is heavily influenced by D&D, so it struck me as strange that the Tent and Cabin don't let you restore your spell charges.
I know it was for balance purposes since the passage of time really has no meaning in the game, but I think it would be fine to have only have the Tent and Cabin items.
They would both restore all spell charges.
Tents would restore HP based on each character's level and stamina.
Cabins would restore maybe 3x the amount of HP?
That would put them a bit more in line with D&D.



To further that idea in a different, more realistic direction for a hypothetical branch project...
Turn the Tent and Cabin into artifacts/quest items.
Scrap the House and use it for something else.

The main menu would have a new command called Rest.
By default the Rest command would restore all spell charges and heal a minimal amount of HP equal to the character's level.
However, when using it like this there is a chance that instead of resting you could be forced into an a random battle with a higher chance to get ambushed.

If you have a Tent, you may choose to use it when resting.
Each tent has a total of 10 uses, and each time it is used it has a chance to consume 2 uses due to wear and tear.
While using a tent, the party still regains all spell charges, but instead restores HP based on level x some fraction of their stamina (level * stamina/4 or something).
When using a tent, the chances of getting attacked and of getting ambushed is reduced by 1/2.
Each tent would be at least 10x more expensive.

If you have a Cabin, you may use it during rest.
The cabin would work largely the same way as the Tent with only 1/2 as much chance of the wear and tear penalty on uses.
The amount of healing would be bumped up to 2x to 4x that of the tent.
Unlike tents, cabins provide sturdy enough shelter that there is no chance of getting attacked overnight.
Cabins should also be at least 10x their original price.

Now you have a more realistic resting system.

Ideally, you'd be limited to a maximum of 1 tent and 1 Cabin at any time.
If need be you could even give it a pseudo day/night cycle by giving it a cooldown period between uses.

And if I'm not mistaken it should even be possible to darken the screen on the overworld for a little tent/cabin cutscene like in the later games.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 10, 2019, 10:39:47 pm
Things I wanted to do but thought: Gosh, this is really only FF1, why bother?
1: Day/Night cycle
2: A timer in the menu to show how long you've been playing (would need to use MusicPlay or WaitForVBlank to count the active frames.)

The pause button (select) does darken the screen. A shame there's not more ways to darken colors to show night... With only red, blue, and green emphasis, there's not really even enough combinations to make a good sunset/sunrise effect in the transition.

Random thoughts: Some message box popping up saying, "Its getting late..."
Next random battle gives enemies some kind of buff/surprise attack. Win/escape and its darker; random battles are twice as likely until morning.
Have another message pop up when morning comes, brighten the screen again.
The Lamp spell sets the battle rate back to normal. Maybe in dungeons it halves the battle rate for that floor.
Perhaps half battle rate is default in daytime.
Probably take the battle rate option out so this system is part of gameplay and not broken.
Using a tent when the "Its getting late" message pops up keeps night-time from happening.
Maybe make a game-time clock separate from play-time.
Make a tent icon and have 3 kinds of tents: Tattered, Sturdy, and Luxuriant
Players have to decide: Risky extra battles and EXP or safer travel?
FOREBODING OVERWORLD MUSIC.

...these are just dreams for now.

I'm at the Ice Cave. I'm level 14. I KEEP DYING. I don't remember it being this hard! I remember eking through at level 11! Did Mages always go with Rub > Lit 3? Did Ice Dragons always use Blizzard on their second turn? Is something wonky with AI and its using their spells/special attacks more often if they have them?

I might have screwed myself with the enemy speed stats, because I always get to go last with these enemies.

ORRRR its just rubbish RNG time. Just like how every time I want to test a player ability, I get surprised by 9 enemies.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 11, 2019, 02:02:39 am

If the original RNG is still in the game, then it's probably rubbish RNG.
One of the Enhancement/Bugfixes in the Astral/Anomie work is a new improved RNG.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 11, 2019, 02:11:21 am
Anyone who wants to do that is welcome to. I don't understand it myself, so I don't wanna try. I got my tiny hands full.

I fixed a whole slew of bugs with Key Items printing in their item page, and had to work up a way to rename the Bottle item while its in the Caravan shop, without renaming the weapon that has the same item ID. I decided to have the Caravan shop stay even after you pop the fairy out since he sells cool stuff. Popping the fairy no longer takes the Bottle out of your inventory, though I guess it should. You can't buy more than one bottle, I decided, so there's code to skip choosing the amount when doing that... Then more code to replace the Bottle in the caravan's inventory after you buy it... Then more code to uphold Final Fantasy traditions...

It's been a busy night. And now I got an airship, so I can go find more bugs!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 11, 2019, 02:24:22 am
Nice.
I'm definitely going to be taking up as many of the remaining bug fixes and enhancements as I can manage.
There are a lot of little modifications I want to do to the battle code.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Bregalad on May 11, 2019, 06:11:57 pm
Things I wanted to do but thought: Gosh, this is really only FF1, why bother?
1: Day/Night cycle

[...]

Random thoughts: Some message box popping up saying, "Its getting late..."
Next random battle gives enemies some kind of buff/surprise attack. Win/escape and its darker; random battles are twice as likely until morning.
WHAT AN HORRIBLE NIGHT TO HAVE A CURSE.

Sorry couldn't resist. This idea is really in the wrong game in my opinion. Day/night cycles were never part of Final Fantasy series (except for story-related events).
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 11, 2019, 09:10:10 pm
True, but keep in mind that this is more of a project base so the more out there ideas are not going to be in the main release.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: needsleepnow1983 on May 11, 2019, 11:46:02 pm
Good Evening;
I'm excited to see this project coming along so nicely.  I would like to ask a couple questions or make a couple suggestions (I didn't see them mentioned in the thread).
1)  Would it be possible to implement the ability to 'forget' spells? i.e. I purchased three level 1 spells, and I want to remove one of them.  In the original FF1 game this would not be possible and I would be stuck.
2)  The ability to move spells around.  For instance I have 'Fire' on the right portion of the level 1 spell list and I want to move it to the left hand side (for convenience)...or ideally anywhere I want.

Keep plugging along :)

~needsleepnow
Title: Re: FF1 MMC5 Disassembly Updates
Post by: daman.tm on May 12, 2019, 05:49:47 am
WHAT AN HORRIBLE NIGHT TO HAVE A CURSE.

I had the exact same thought when I read this :D
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 12, 2019, 03:13:33 pm
WHAT AN HORRIBLE NIGHT TO HAVE A CURSE.

Sorry couldn't resist. This idea is really in the wrong game in my opinion. Day/night cycles were never part of Final Fantasy series (except for story-related events).

Hee, I think we were all thinking that line. And that's exactly why I haven't put any more than passing thought into it. If I do code something like that, it'll be for when I branch off into making my own RPG--if the mechanics fit with whatever else I have in mind!
Good Evening;
I'm excited to see this project coming along so nicely.  I would like to ask a couple questions or make a couple suggestions (I didn't see them mentioned in the thread).
1)  Would it be possible to implement the ability to 'forget' spells? i.e. I purchased three level 1 spells, and I want to remove one of them.  In the original FF1 game this would not be possible and I would be stuck.
2)  The ability to move spells around.  For instance I have 'Fire' on the right portion of the level 1 spell list and I want to move it to the left hand side (for convenience)...or ideally anywhere I want.

Keep plugging along :)

~needsleepnow

Forgetting spells is in there! Have you tried the latest version? Its on Github now, I don't think I ever updated the first post in this thread... https://github.com/JiggeryPonkery/FF1-MMC5

I'm afraid, at the moment, moving spells around is too difficult to implement. In the original game you could pick what spell was where by the order you learn them, but because of the way I compress spell data to make all 64 spells learnable with only 8 bytes for each character, its not currently possible to even do that.

But, given that Vanya wants 128 spells, and I just freed up a lot more space in save RAM by getting music data outta there... we'll see what's possible when I get around to doing that. XD
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 12, 2019, 03:19:44 pm
But, given that Vanya wants 128 spells, and I just freed up a lot more space in save RAM by getting music data outta there... we'll see what's possible when I get around to doing that. XD

Werd!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 12, 2019, 09:01:09 pm
So I made a Google Doc, even though I loathe Google Docs.

It lists bugs, things to do, and requests. It should be editable by anyone who can click it.

https://docs.google.com/document/d/1vXa_OLn408BxQ2GpIRRnGNPRJliOv_YBiP21ARdnhxo/edit?usp=sharing

So now I don't have to keep forgetting what I was doing and what people want to see!



So Mesen displays its frame rate as 60/30 ... sometimes it goes to 61/30 and that's when the airship shadow starts to flicker, then change between being solid or gone. Nothing to do with my other video settings.

Update: So RivaTuner just sets every game I play to 30 FPS I guess, instead of making sure FF14 caps at 60 frames...
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 12, 2019, 10:15:10 pm
That's a good idea.
It'll make things much easier.

I already have a list of little tweaks I think should be added to the base project.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 13, 2019, 09:44:45 pm
We got a problem!

I was making a spreadsheet of all the treasures and shop items in order of where the average playthrough takes you, so I could start figuring out some treasure balancing issues that have been annoying me--and then I figured, why not add enemies to that spreadsheet!

Then in the middle of that I'm like, reading through this walkthrough that lists where enemies show up is tiresome, I'm gonna go through that battle formation list and mark things properly.

And so, it turns out Garland and the Pirates share battle data. And the Eye isn't a unique enemy? It shows up in groups of 2-3 somewhere else? I thought that was Phantoms that did that. So all those battles will play the miniboss theme instead.

I'll work something else out, but I don't think it will work for the Eye.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 14, 2019, 07:53:50 am
Is there any room to expand formations so we can just make unique entries for all the high level monsters to have their own formations?

I also thought we could add new unique mini-boss monsters, but they would still need to have their own formations regardless.

So... is there enough space to do both?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 14, 2019, 02:15:21 pm
Space is certainly not an issue. Its just the organization of everything...

There's 128 enemies, 128 battle formations. I know if I work at it I can figure out how to double that, but then there's so many smaller systems that need to be adjusted to handle that, too. Enemy name printing, stat loading, whatever else.

Adding new enemy graphics and palettes, I don't know if we'd have to add an extra bank and shift everything around, or if there's room for a few more where they currently are.

I think before I do something like that, I want to go through the fixed bank and make sure there's going to be enough room there for anything new. And finish up tagging data structures. lut_Domains, lut_MapObjects; I'd like to figure out which map is which!

Edit: Okay... not sure I can double battle formations. I think they already have.
Code: [Select]
LDA a:btlformation        ; get the formation ID
    AND #$7F                  ; remove the 'Formation B' bit to get the raw formation ID

Think what this means is that a battle formation ID of $80 would be the same as $0, but with the second formation.

HOWEVER.

Astos and the Vampire don't use a B formation. Nor do the Fiends or Chaos. I'll look into making them all share. So Lich has 1 battle formation with A and B instead of 2 with A, and so on.



Update: Changes pushed to github!

So it looks like Vampire, Astos, and Garland can't share because of the byte that loads the graphic sets. Like, they could share, but then you'd get Astos looking like a Vampire, I think? Which... to be honest, sounds pretty cool to me. The Fiends can all share themselves, because they're pretty much identical. I've kept the IDs the same for the tile battles, because I don't know how to change those yet, and changed the IDs in the talk routines so the initial "lighting the orb" battles should load up the first version of the fiend.

The pirates and Garland no longer share with Sahag/WzSahag and IronGolems, respectively. BUT, that's still 2 extra boss battles; one with mixed formation and one with 9 small enemies, if they're in the same graphic sets. There's also now 6 more regular battles to be filled in, though one of them will have to be sea enemies and one will have to be whatever the IronGolems share graphics with.

Adding more battle formations will be something beyond my ability at the moment, because we'd have to start using 16-bit numbers and I still only just barely grasp how its loading things up.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 14, 2019, 08:23:01 pm
Excellent work nonetheless.
That's still a handful more formations than we had before.
I had forgotten that the Fiends have 2 fully separate formations.

Second question concerning these formations.
Is there room in the graphics banks to add more graphics sets?

And along with that, is there space for more graphics indexes to be called?



So single target attack spells are still borked?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 14, 2019, 10:23:01 pm
Good questions. So, I don't know if there's more space for graphic sets. Bank 7 and 8 hold most of the enemy graphics I think (I am having trouble opening them in editors again to check.) Going by the hex data, looks like both are full, so adding more graphic sets would involve pushing all the banks 1 over and having 9 be a third one for graphics.

Indexes--no, the way its set up now, all 16 are used. Would have to re-do how the whole formation is done to add more.

To be honest, until I get to Kraken or Tiamat, I'm not sure the new Fiends will even work. Maybe they each had their own thing because of some limitation I'm not aware of in how fiends are loaded; which means I might have to hunt that down and work out a way to add a B formation to the loading... >.<

Really out of my depth here again.

Code: [Select]
So single target attack spells are still borked?
Um... are they? I forget if I fixed it. Or did my fix not work...? Huh, it seems they don't bother casting at all now?! Rghh...
Edit: Oh. Loading the right command into A then pulling from the stack and overwriting it. Dumb. Fixed now?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 14, 2019, 11:32:33 pm
Seems perfectly fine now! Woot!



EDIT:
OK I looked at the built ROM and it seems like al the graphics are indeed all right up against each other.
There is a ton of space in the ROM of course.

Farther down the line, I think it would fit into the scope of the project to rearrange things so there can be more space for various graphics.
Not just enemies, but tile sets and character graphics, too.
Might even be a good idea to look into expanding character graphics a smidge so that each class can have a special pose for their special skills.
Everyone that uses this as a project base is likely going to want to add things like this.

And if there is any tedious work to be done to make this happen, I'll be glad to volunteer!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 14, 2019, 11:45:42 pm
I'm not sure the new Fiends will even work. Maybe they each had their own thing because of some limitation I'm not aware of in how fiends are loaded; which means I might have to hunt that down and work out a way to add a B formation to the loading... >.<

See 'FinalizeEnemyFormation_FiendChaos:' in Bank B

Code: [Select]
FinalizeEnemyFormation_FiendChaos:
    LDA #$01
    STA btl_enemycount      ; There is exactly 1 enemy for Fiend/Chaos formations
    LDA btlform_enids       ; Just use the first enemy ID as the only enemy in this formation
    STA btl_enemyIDs
    STA btl_enemyroster               ; ???  Duplicated to 6BC9?  Why?  I doubt this is ever used
    JMP WriteAttributes_ClearUnusedEnStats

That 2nd comment is the culprit you're probably interested in.  B formation only changes the quantity of enemies, but not the enemies themselves (that is, the "first" enemy ID in the list is going to be whatever enemy is listed first in the roster, even if it has a quantity of zero).

To fix this, you'll probably want to scan the enemy quantities (in btlform_enqty+0 through btlform_enqty+3) and use the first nonzero entry.  I whipped this together to do that.  Note it's untested, but unless clobbering X breaks something I don't see why it wouldn't work:

Code: [Select]
FinalizeEnemyFormation_FiendChaos:
    LDA #$01
    STA btl_enemycount      ; There is exactly 1 enemy for Fiend/Chaos formations
    LDX #3
    @ScanLoop:
        LDA btlform_enqty,X
        BEQ :+
            LDA btlform_enids,X
            STA btl_enemyIDs
            STA btl_enemyroster
      : DEX
        BPL @ScanLoop
    JMP WriteAttributes_ClearUnusedEnStats

That should allow for B formations to be used with fiends/chaos.  Note you are still restricted to one and only one enemy in each fight.  Changing that to allow multiple enemies would be a much larger task.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 15, 2019, 01:34:27 am
Oohhh, thanks for pointing me to that! But I'm not sure I understand your fix...

I think this might be easier?

Code: [Select]
FinalizeEnemyFormation_FiendChaos:
    LDA #$01
    STA btl_enemycount      ; There is exactly 1 enemy for Fiend/Chaos formations
    LDA a:btlformation      ; See if this is a B-formation
    BPL :+                  ; if it is, load second enemy ID
      LDA btlform_enids+1
      JMP :++
   
  : LDA btlform_enids       ; Just use the first enemy ID as the only enemy in this formation
  : STA btl_enemyIDs

If I understand the way the formation data is stored... Oh, oh, I think I get what you're doing with X now. But wouldn't it keep looping through X, then, until it got to the last one anyway? And if not--wouldn't it be going through this even if it was an A formation, then end up doing the B formation?

Vanya: Yeah, definitely. I'd like some magic preparation poses like FF4, give the black belt a proper kick and have them zoom across like the thief does (and have the thief just show up behind an enemy, crouching, like Locke in FF6) and other wild things. I want animated summons, I want 8x32 character sprites in maps! Spacing things out is definitely a requirement for all that.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 15, 2019, 02:14:09 am
Vanya: Yeah, definitely. I'd like some magic preparation poses like FF4, give the black belt a proper kick and have them zoom across like the thief does (and have the thief just show up behind an enemy, crouching, like Locke in FF6) and other wild things. I want animated summons, I want 8x32 character sprites in maps! Spacing things out is definitely a requirement for all that.

Damn, bruh! I thought I was bordering on overly ambitious! ;P
Seriously though, pretty much all of that is on my wish list.

For my own version of FF1 I, was thinking of using smaller character sprites on the overworld kinda like in Chrono Trigger to get the world to feel a bit bigger.

I'd be satisfied with static summons, animated ones would be icing on the cake.

You're putting my heads in the clouds, man! LOL
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 15, 2019, 10:43:06 am
I think this might be easier?

Yeah that would also work but makes the assumption that A formation always uses the first enemy and B formation always uses the second enemy.  Which is a pretty safe assumption, but I like avoiding those kinds of assumptions.

Personal preference, I guess.  But yeah your approach should work just fine, and looks to be smaller.   :thumbsup:


Also... you don't need the 'a:' prefix (LDA a:btlformation).  That forces absolute mode.  If you get rid of it, the assembler will use zero page mode and you'll save a byte.  Those are only in the original disassembly so it would produce an identical ROM to the original, but functionally it's useless and wastes space.

Quote
Oh, oh, I think I get what you're doing with X now. But wouldn't it keep looping through X, then, until it got to the last one anyway?

It's looping to examine all four enemy quantities, and will use any enemy that has a nonzero quantity.  Since it's looping in reverse order (starting at 3 and counting down), the "last" enemy it finds will actually be the "first" one in the enemy list.  But that only really matters if there are multiple nonzero quantities, which there probably wouldn't be.

Quote
And if not--wouldn't it be going through this even if it was an A formation, then end up doing the B formation?

A/B formations don't matter at this point in the code.  The only difference between them is enemy quantities, and by this point A/B quantities have already been applied to btlform_enqty (see PrepareEnemyFormation)




.... but I just realized that this code runs AFTER the graphic for the fiend has already been drawn, which is stuck at using the graphic for the first enemy in the roster.  So both of our code will only REALLY work if they share the same graphic (which would be the case for the TOFR version of the fiend sharing a formation with their original counterpart).

Barrrrrrrrf.  So yeah my approach is not as dynamic as I thought.  Your solution is looking better and better, since there's a lot of assumptions with how fiend formations have to work.   :beer:
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 15, 2019, 04:40:10 pm
For my own version of FF1 I, was thinking of using smaller character sprites on the overworld kinda like in Chrono Trigger to get the world to feel a bit bigger.

I'd be satisfied with static summons, animated ones would be icing on the cake.

Hey, if you wanna do the sprites for that, I'd like to see them. A big part of why I am doing this instead of my own hack is I gave up doing map sprites because it was too hard to get the detail in such a small space. Ditching detail for aesthetics might work if it looks neat enough!

For animations I was more meaning like... 2x2 or 2x3 or 3x3 (scandalous!) sprite boxes that rise up from the bottom of the screen, flash a bit, then zoom off.

Barrrrrrrrf.  So yeah my approach is not as dynamic as I thought.  Your solution is looking better and better, since there's a lot of assumptions with how fiend formations have to work.   :beer:

Hah, thanks! I like seeing the neat ways you do things: The BPL and DEX stuff is something I could possibly use later, if I remember to. (And now to go kill all the absolute stuff...)

I think I might try re-jiggering formations to allow more graphic sets? Orrrr have the Fiend code do something else to pick the graphics. Figure out a way to make them use just one or two formations. Heck, maybe I can find a way for boss battles to not use formations at all just by faking the data somewhere... I guess today's one of those "I feel insane and nothing's looking impossible" days? XD

I finished my spreadsheet. It lists the general advancement of locations in game, the treasures found there (weapons, armor, items; not money or spells), and the enemies you can possibly encounter.

https://docs.google.com/spreadsheets/d/1VKrmx1zHV-rNP9wW7NV05fLNVCjFEhSXPkmxpODXOaI/edit#gid=835979563

The idea is that this will help figure out a better equipment advancement plan--get rid of "got this too late, now its useless" items, like the Great Axe, Long Sword, whatever. 6 classes, 50 levels, 64 weapons, gotta be a way to make it so each class gets a little upgrade more often. More hammers and knives and staves! More gloves and light armor for mages! ALSO, not shown in the spreadsheet yet, is the average level of the party when they get there.

Instead of steal difficulty for enemies, I'm going to give them a level, which should be near enough to the player's average level for the area the enemies first show up in. Then Stealing can be Thief Level vs. Enemy level, and insta-death spells can be Mage's Level vs. Enemy Level, or something like that, to make them more useful.

I've been playing with my experience boost option on, and I haven't needed to grind much at all so far. So the gameplay progression reminds me of Chrono Trigger, where the simple act of not running away means you're pretty much OK to handle things.

And I'd like to make battles just a little harder/longer to compensate. Just anything to get out of the "mash attack" mindset I find myself in so often. Making status enhancements a better use of MP and stuff; and then, depending on how that goes, maybe I'll be more inclined towards having MP work as later FF games.

Ideally, I'd want to make it so getting to level 50 by the time you reach Chaos isn't going to take hours of grinding. Maybe you hit 44-ish by then, naturally. I'm used to getting to level 30 by the time I'm ready to take on the last dungeon, then feeling blegh about not being strong enough to survive...

I worry that these ideas are drifting away from what people might enjoy about FF1, so they're not in my "do it next" list, though...

SO, back around to what I meant to say: What would be helpful, is if people would take the enemy list, reference the spreadsheet I made (or not!) and note down what level they think enemies should be. I'm doing that myself, but having a few different thoughts on what people think would be better for balancing it, surely?



Sorry to make such a giant post... but does this look right? Skipped over Thief Agility Vs. Enemy Evade for now. Its just Level vs. Level.

Code: [Select]
StealProbability_LUT:
.byte $5B, $4B, $32, $19, $05, $01
   ;; #91: same level
   ;; #75: 1 level lower
   ;; #50: 2 levels lower
   ;; #25: 3 levels lower
   ;;  #5: 4 levels lower
   ;;  #1: 5 levels lower

StealFromEnemyZ:
    LDA btl_defender
    JSR GetEnemyRAMPtr   
   
    LDY #en_item
    LDA (EnemyRAMPointer), Y        ; get their "has item" byte
    BEQ @Nothing                    ; battle_stealsuccess remains 0
   
    LDY #en_level
    LDA (EnemyRAMPointer), Y        ; get their level
    SEC
    SBC MMC5_tmp                    ; subtract thief level from enemy level
    BMI @Success                    ; negative flag set if thief is over the enemy level
   
    LDA MMC5_tmp                    ; next, subtract enemy level from thief level
    SEC
    SBC (EnemyRAMPointer), Y
    CMP #6                          ; if the enemy is 6 levels higher, automatically fail
    BCS @Fail                       
   
    TAX
    LDA StealProbability_LUT, X     ; get the probability based on the level difference
    STA MMC5_tmp
   
    LDA #0
    LDX #100
    JSR RandAX
   
    CMP MMC5_tmp                    ; if A is less than the probability, success
    BCC @Success                   

So many CMPs ... I feel like either the BCC @Success or the BCS @Fail is wrong...

Here's an alternative where it boosts the thief's level by 2 before making checks.

Code: [Select]
StealProbability_LUT:
.byte $62, $5A, $4B, $32, $19, $05, $01
   ;;  #98: 1 level higher
   ;;  #90: same level
   ;;  #75: 1 level lower
   ;;  #50: 2 levels lower
   ;;  #25: 3 levels lower
   ;;   #5: 4 levels lower
   ;;   #1: 5 levels lower

StealFromEnemyZ:
    INC MMC5_tmp
    INC MMC5_tmp                    ; add 2 to the thief's level

    LDA btl_defender
    JSR GetEnemyRAMPtr   
   
    LDY #en_item
    LDA (EnemyRAMPointer), Y        ; get their "has item" byte
    BEQ @Nothing                    ; battle_stealsuccess remains 0
   
    LDY #en_level
    LDA (EnemyRAMPointer), Y        ; get their level
    SEC
    SBC MMC5_tmp                    ; subtract thief level from enemy level
    BMI @Success                    ; negative flag set if thief is +2 over the enemy level
   
    LDA MMC5_tmp                    ; next, subtract enemy level from thief level
    SEC
    SBC (EnemyRAMPointer), Y
    CMP #7                          ; if the enemy is 7 levels higher, automatically fail
    BCS @Fail                       
   
    TAX
    LDA StealProbability_LUT, X     ; get the probability based on the level difference
    STA MMC5_tmp
   
    LDA #0
    LDX #100
    JSR RandAX
   
    CMP MMC5_tmp                    ; if A is less than the probability, success
    BCC @Success                   
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 15, 2019, 10:50:11 pm
Hey, if you wanna do the sprites for that, I'd like to see them. A big part of why I am doing this instead of my own hack is I gave up doing map sprites because it was too hard to get the detail in such a small space. Ditching detail for aesthetics might work if it looks neat enough!

Yeah, they will definitely be sacrificing some detail in favor of the immersion of a seemingly larger overworld.
I'll whip something up and post it when I get a chance.


For animations I was more meaning like... 2x2 or 2x3 or 3x3 (scandalous!) sprite boxes that rise up from the bottom of the screen, flash a bit, then zoom off.

That's still more than I was thinking.
Player sprites "blink/flash" away, Summon "blinks/flashes" in and does an attack.
Repeat blink/flash in reverse.

I suppose having a couple variations would be nice.
Maybe one rising up, one swooping in from above, and one blinking/flashing in.


I finished my spreadsheet. It lists the general advancement of locations in game, the treasures found there (weapons, armor, items; not money or spells), and the enemies you can possibly encounter.

https://docs.google.com/spreadsheets/d/1VKrmx1zHV-rNP9wW7NV05fLNVCjFEhSXPkmxpODXOaI/edit#gid=835979563

The idea is that this will help figure out a better equipment advancement plan--get rid of "got this too late, now its useless" items, like the Great Axe, Long Sword, whatever. 6 classes, 50 levels, 64 weapons, gotta be a way to make it so each class gets a little upgrade more often. More hammers and knives and staves! More gloves and light armor for mages! ALSO, not shown in the spreadsheet yet, is the average level of the party when they get there.

I sent a request to view it from figarosbackpack@gmail.
Technically 8 classes. 4 are just upgrades, and 2 are are reasonably different enough to count as separate classes.


Instead of steal difficulty for enemies, I'm going to give them a level, which should be near enough to the player's average level for the area the enemies first show up in. Then Stealing can be Thief Level vs. Enemy level, and insta-death spells can be Mage's Level vs. Enemy Level, or something like that, to make them more useful.

That's how most games do it.
It might be worth it to come up with a formula that calculates a level value based on an enemies' stats.


I've been playing with my experience boost option on, and I haven't needed to grind much at all so far. So the gameplay progression reminds me of Chrono Trigger, where the simple act of not running away means you're pretty much OK to handle things.

And I'd like to make battles just a little harder/longer to compensate. Just anything to get out of the "mash attack" mindset I find myself in so often. Making status enhancements a better use of MP and stuff; and then, depending on how that goes, maybe I'll be more inclined towards having MP work as later FF games.

I would advise not adjusting difficulty based on the HIGH settings.
If you make the game harder on the HIGH settings it'll feel amplified on the NORMAL settings.
Power creep can be a bitch.
However, you might want to add a difficulty option that adds a multiplier to enemy accuracy/damage as a fine tuning element on top of the XP, Gil, and encounter rates.


Ideally, I'd want to make it so getting to level 50 by the time you reach Chaos isn't going to take hours of grinding. Maybe you hit 44-ish by then, naturally. I'm used to getting to level 30 by the time I'm ready to take on the last dungeon, then feeling blegh about not being strong enough to survive...

Well, isn't that what the HIGH experience setting is for?
The way I see it the NORMAL setting should be pretty close to the original game in most cases.


I worry that these ideas are drifting away from what people might enjoy about FF1, so they're not in my "do it next" list, though...

A wise assessment.
Yeah it's important to examine the scope of a project as you come up with ideas for improvements.
In most cases, when you are considering a change that might fundamentally change the experience the original game offered, that is not strictly a bug fix, it is likely best to make it either optional or leave it out entirely.


SO, back around to what I meant to say: What would be helpful, is if people would take the enemy list, reference the spreadsheet I made (or not!) and note down what level they think enemies should be. I'm doing that myself, but having a few different thoughts on what people think would be better for balancing it, surely?

I'm considering whipping up an app in game maker to make some calculations and extrapolate a level value for any given enemy.


Sorry to make such a giant post... but does this look right? Skipped over Thief Agility Vs. Enemy Evade for now. Its just Level vs. Level.

Code: [Select]
StealProbability_LUT:
.byte $5B, $4B, $32, $19, $05, $01
   ;; #91: same level
   ;; #75: 1 level lower
   ;; #50: 2 levels lower
   ;; #25: 3 levels lower
   ;;  #5: 4 levels lower
   ;;  #1: 5 levels lower

StealFromEnemyZ:
    LDA btl_defender
    JSR GetEnemyRAMPtr   
   
    LDY #en_item
    LDA (EnemyRAMPointer), Y        ; get their "has item" byte
    BEQ @Nothing                    ; battle_stealsuccess remains 0
   
    LDY #en_level
    LDA (EnemyRAMPointer), Y        ; get their level
    SEC
    SBC MMC5_tmp                    ; subtract thief level from enemy level
    BMI @Success                    ; negative flag set if thief is over the enemy level
   
    LDA MMC5_tmp                    ; next, subtract enemy level from thief level
    SEC
    SBC (EnemyRAMPointer), Y
    CMP #6                          ; if the enemy is 6 levels higher, automatically fail
    BCS @Fail                       
   
    TAX
    LDA StealProbability_LUT, X     ; get the probability based on the level difference
    STA MMC5_tmp
   
    LDA #0
    LDX #100
    JSR RandAX
   
    CMP MMC5_tmp                    ; if A is less than the probability, success
    BCC @Success                   

So many CMPs ... I feel like either the BCC @Success or the BCS @Fail is wrong...

Here's an alternative where it boosts the thief's level by 2 before making checks.

Code: [Select]
StealProbability_LUT:
.byte $62, $5A, $4B, $32, $19, $05, $01
   ;;  #98: 1 level higher
   ;;  #90: same level
   ;;  #75: 1 level lower
   ;;  #50: 2 levels lower
   ;;  #25: 3 levels lower
   ;;   #5: 4 levels lower
   ;;   #1: 5 levels lower

StealFromEnemyZ:
    INC MMC5_tmp
    INC MMC5_tmp                    ; add 2 to the thief's level

    LDA btl_defender
    JSR GetEnemyRAMPtr   
   
    LDY #en_item
    LDA (EnemyRAMPointer), Y        ; get their "has item" byte
    BEQ @Nothing                    ; battle_stealsuccess remains 0
   
    LDY #en_level
    LDA (EnemyRAMPointer), Y        ; get their level
    SEC
    SBC MMC5_tmp                    ; subtract thief level from enemy level
    BMI @Success                    ; negative flag set if thief is +2 over the enemy level
   
    LDA MMC5_tmp                    ; next, subtract enemy level from thief level
    SEC
    SBC (EnemyRAMPointer), Y
    CMP #7                          ; if the enemy is 7 levels higher, automatically fail
    BCS @Fail                       
   
    TAX
    LDA StealProbability_LUT, X     ; get the probability based on the level difference
    STA MMC5_tmp
   
    LDA #0
    LDX #100
    JSR RandAX
   
    CMP MMC5_tmp                    ; if A is less than the probability, success
    BCC @Success                   

I feel like these could be simplified.

steal difficulty = target's level - thief's level (minimum 1)
make a hit roll (0 ... 49)
if hit roll > steal difficulty, steal succeeds
else, steal fails

No need for a table.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 15, 2019, 11:18:35 pm
Bah, Googledocs. The file should be set to viewable to everyone now. Sorry!

Working up a lot of new stuff; Player Regen is almost ready I feel. Soon as its done, I'm taking a break for the night, so I'll reply tomorrow! Just wanted to update on the spreadsheet link working now (maybe???)



Regeneration is live. I've changed the Heal spells to do it for testing purposes; if you don't want it, look for lut_MagicData in Bank C and swap the commented-out Heal data lines.

There's 3 potency variations, which are set by the effectivity byte, and up to 15 turns of regeneration, set by the Hit Rate byte. Regeneration is effect $15.

Instead of using the magic healing code to do it, it works more like the enemy regeneration code (and in fact, shares some of the division routines with it now!) It uses the battlestate ch_stat as well: The low bits are how many turns to regenerate, and the high bits are the two in the middle:
%0xx0xxxx <- regenerating
%10000000 <- guarding ($80)
%00010000 <- hiding ($10)

So $2x is low potency, $4x is medium potency, and $6x is high potency. That's about 9% HP restored per turn, or 19%, or 25%. I tried to get it to 15% for medium potency but... dividing is finicky and I didn't want to deal with setting up the DoDivision routines to handle it, since the enemy regen code works almost the same. I will look into it later.

YEAH I KNOW THIS IS UNBALANCED AS A TAILLESS SQUIRREL.  :D

Also updated are the icons. Now, hiding, guarding, and regenerating should all show up. Hiding at the bottom, guarding in the middle, and regenerating on top (uses the old stun icon for sparkly healing magics!)

If you test it out, let me know how it goes with hiding and guarding. I had a bug earlier where character 2 was hiding, 3 and 4 were not, but then after regenerating, 3 and 4 went into hiding. I think I just fixed it but I'm not sure and too tired to try and replicate it a third time...

Quote
I would advise not adjusting difficulty based on the HIGH settings

Well, the only difficulty change is less grinding. The individual battles are the same. I just spent less TIME getting as strong. I was still getting whooped in the Ice Cave even after being a couple levels higher than I used to go in there!

What I mean is that each battle, it still feels to me like the optimal choice is attack. I want to balance HP and damage and abilities in a way that will make using status effect spells rewarding, making hiding one turn and attacking the next a viable strategy for some, make using elemental-resistance spells... not mandatory, but do something with them that just makes it worth the effort? While doing the enemy lists for the spreadsheet, I was looking at this guide talking about using AICE and AFIR and things in a certain order on bosses, and I was like, that sounds neat, but from my experience, its pointless. The randomness involved with the spell damage makes it so I either get hit for 200 HP or 30. I want to find a way to balance that out so there's a better risk/reward option there: Go nuts and try to kill things before you die, or play it safe and smart? Right now, the go nuts option is better almost every single time, because the HP loss isn't great enough--or else its so great that I get wiped out in a turn, so I don't even have time to set up a defense. Just, again, from my experience lately.

The no-grind progression is what I would be wary about changing. I'm just surprised that using the High setting makes the game feel more smoother in leveling and getting through the maps. First-time players who don't know where to go, though, would definitely feel overpowered after wandering around too much!

I feel like emulating a great RPG (Chrono Trigger) would be the thing to do for my own story, rather than patching in Bravely Default-esque settings to make old school game mechanics more bearable.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 16, 2019, 11:31:09 am
I'm considering whipping up an app in game maker to make some calculations and extrapolate a level value for any given enemy.

You know... I'm just going to throw this out there.... maybe this is a good opportunity to learn Python.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 16, 2019, 03:58:03 pm
I made some new running calculations.

All enemy's speed combined / 4
Against character's level / 2 + speed (+15 if hiding)

If that's too kind towards the players, the level/2 can be dropped? I like the idea of killing enemies to make an escape route though.

With the current speed of, say, a MAGE, those jerks in the Ice Cave, a level 18 non-thief with 18 speed wouldn't be able to run from 4 of them unless hidden (Mages: $26 - Hidden Non-thief: $2A.)

I kinda just made it up so I don't know how balanced it is.



Also just fixed a bunch more bugs. Sleeping warriors sliding forward in victory, armour in the battle item slots not getting the right spell to cast, various NPC dialogue checks were wrong because item IDs changed, Warp/Exit spells didn't shut off MenuHush when exiting the menu so music was wonky, stuff I did previously wasn't working because of typos or the wrong variable (+2 instead of +1)... made the Bottle vanish when used again; gotta take out the "Its empty" description text still.

Running calculation isn't as cheesed as I thought it would be. I actually am having a rough time running away lately. Also changed the random number added to player/enemy speed in the turn order, since the range (0-30) seemed like it was influencing things a bit too much; its now 0-15. But, might set that back. Or just have it be like... Speed + (0...Speed)? Yeah, gonna try that.

Edit: Gah. Maybe don't download that last update. Something is crashing the game while figuring out turn orders. Looking into it, but the crash seems to be happening during a part I haven't touched?

Very weird. There was an infinite loop that, for some reason, was not infinite before. Adding loop counters to break out of it fixed it, I think. Also, turn order stuff wasn't looking at the IDs of enemies and players to get their speeds, all this time; not until the second turn, anyway? Uh... anyway, fixed that, too.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 16, 2019, 11:09:54 pm
You know... I'm just going to throw this out there.... maybe this is a good opportunity to learn Python.

Don't know if I really have the spare time to set up the work environment for that, plus I'm working off a laptop cause my desktop's power supply seems to have finally died after nearly 12 years of faithful service.

Though, correct me if I'm wrong, but the syntax in Python isn't super different from GML / C++?



@Jiggers: I see what you mean.

I dunno, I kinda think we should not worry about balancing the game until after all the new features you want to do are finished.

I think it'll cut down on the amount of testing that has to be done and prevent redundant work.
Makes sense?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 17, 2019, 10:47:37 am
Don't know if I really have the spare time to set up the work environment for that

Though, correct me if I'm wrong, but the syntax in Python isn't super different from GML / C++?

Python is both absurdly simple to set up and absurdly simple to learn and use.  There's a reason why it is so popular for cranking out quick little scripts.

All you need is a text editor like Notepad++ (which you presumably have already), and just download/install the Python runtime.

And yes, syntax is very similar to C-style languages.  The biggest "gotcha" for newbies is the fact that indentation and whitespace matters (it's highly recommended that you configure your text editor to replace tabs with spaces).  But if you have ANY familiarity with C-style languages, you already know 80% of Python.

For an example of some code, here's a quick little script I made to load .tbl files.  You should be able to read and understand pretty much all of it:
Code: [Select]

# Simple table file loading
#  Allows for DTE and MTE (multiple characters per byte) but does not
#  allow for multiple byte groups.


# loadTable returns an array with 0x100 elements, each entry is the string representation of that
#   byte (or empty string if the byte has no entry in the table)

def loadTable( filename ):
    output = ['?' for i in range(0x100)]    # initialize all output bytes to '?'
       
    with open(filename, 'r') as file:
        rawfile = file.read()
    lines = rawfile.split('\n')     # split table file into individual lines
   
    for line in lines:
        x = line.split('=',1)           # split on first '='
        if len(x) != 2:     continue    # skip empty lines or lines that are poorly structured
        # everything before the '=' is the byte
        byteVal = int(x[0], 16)
        if 0 <= byteVal <= 0xFF:    # we only care about single bytes
            output[byteVal] = x[1]
       
    return output


Really the only reason I'm bringing this up is because having game maker as your go-to for making quick scripts seems like a very strange choice to me, and Python is so ubiquitous that you're almost doing a disservice to yourself by not knowing it.

But ultimately it's up to you.  If you don't want to do it, you don't have to.  I just saw an opportunity to bring this up and I jumped on it.  I'll leave you alone now.   ;D

Quote
plus I'm working off a laptop cause my desktop's power supply seems to have finally died after nearly 12 years of faithful service.

 :'(  Bummer.  At least it's just the PSU and not the HD.  HD failures are the absolute worst.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 17, 2019, 02:34:52 pm
But ultimately it's up to you.  If you don't want to do it, you don't have to.  I just saw an opportunity to bring this up and I jumped on it.  I'll leave you alone now.   ;D

I appreciate the suggestion!


Quote
:'(  Bummer.  At least it's just the PSU and not the HD.  HD failures are the absolute worst.

o.0 yes they are.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 19, 2019, 02:55:15 pm
I dunno, I kinda think we should not worry about balancing the game until after all the new features you want to do are finished.

I think it'll cut down on the amount of testing that has to be done and prevent redundant work.
Makes sense?

Yeah... Just kinda feel like I'm running out of things to change that I feel up to changing. Its getting really close to finished! I might even take a few things out (like pressing Start to auto-battle...)

Having more ideas now: Making inns and clinics based on party and character level. That way people don't bother flying back to Coneria for it, but it still gets more expensive the further you go through the game.

I keep mixing up Coneria and Corneria from Star Fox. Or are they both Coneria? Is there an 8-bit version of the theme I can put in, or would I have to de-make it myself? No, that's not fitting for a starting town... IS IT?

Remember -- https://docs.google.com/document/d/1vXa_OLn408BxQ2GpIRRnGNPRJliOv_YBiP21ARdnhxo/edit?usp=sharing -- is editable by anyone, so add in the things you'd like to see!

Also, put a spreadsheet of (some) enemy stats up in the GitHub. ODS format. HP, damage, accuracy, defense, magic defense, then added them all up in further columns, then stripped out certain stats in other columns. So there's one column of damage+accuracy+defense, one with that + HP, one with all that + magic defense, etc. I dunno if that will help your idea of doing it with GameMaker but I wanted to see what it would look like anyway.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 19, 2019, 04:22:44 pm
I think they are both Corneria/Cornelia depending on how they happen to be romanized at any given time.

I've been meaning to add to that list, but have been too busy with RL.
I'll add some of my ideas to it as soon as I get a chance.

Scaling Inn / Clinic costs sounds great!
I kinda think that the clinic needs to have more to it than just being a substitute phoenix down/golden needle.
Maybe have clinics be able to get rid of all ailments and the cost depends on which ailments the character has.
This could maybe be done in such a way to allow for later hacks to have more ailments that persist after battle.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 19, 2019, 09:28:42 pm
Some tweaks in the works:

Hiding bonuses is adjusted to:
-40 hit chance for defending characters
-80 hit chance if Thief/Ninja

Double hit rate for attacking characters (same as before)
x1.5 crit rate (lowered from x2)

For thieves:
x1.5 damage (same as before)
x2 crit rate (lowered from x3)

And instead of stealing gold when doing a critical hit, it will now be +4 crit rate, with the message "Feeling lucky!"

Skill check is in place for all bonus critical hit stuff. Instead of a roll between 1-100 and needing to be over 50, its now between character speed (old luck; same thing!) and 100, and has to be over 75. So it still favours faster/luckier classes and characters.

I was gonna have darkness and maybe mute stay after battle, too. Make eyedrops work out of battle and add in something for the mute cure? At least darkness.



Update: Feeling confident, but haven't tested it... so I bet nothing works.

Apart from the earlier tweaks mentioned, there are these:

Hiding and Class added to attacker and defender stats for future use.
Added elemental weakness to armor; ice and fire armor and ice and fire shield use it
Attacking player characters lose hit rate when under the darkness ailment again (oops; I took it out because I was like, why load attacker ailments??? I forgot about this one)
Characters should no longer be woken up from sleep only to get the sleep ailment again
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 21, 2019, 06:55:17 am
Sounds good to me. I'll try these out as soon as i can.

I have a question, tho.
How difficult would it be to change the Hide command into a skill? Or any command for that matter?

Also, is the skill command set up to be able to display multiple skills?

I'm thinking about the possibility that someone may want to make Hide exclusive to Thieves, make Magic appear in Skills as a sub-menu, or have a pool of common commands under skills.

Perhaps making it so only spellcasters can use Gear.

Any number of alternate variations like that.

I guess what I'm asking is if the command window can be more flexible?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 21, 2019, 01:58:13 pm
I'm sure it can be flexible. It won't be exactly easy for just anyone to do; I don't know if I know how to set it up to be like the main command window where you just change the jump table and the order of the text...

Once I figure out how to turn the Skill from a submenu to display new things in the command box, I think I could be able to make each command box set up different for each class. Tricky part would be knowing what class is next to draw for with all the box undrawing/re-drawing that happens between turns!

Moving this week, so don't know how much time I have to work on things. I also want to do VWF for description boxes in menus and dialogue in maps if there's enough tilespace in VRAM.

And I've been kicking around ideas for how I could double dialogue and battle formations...

And magic still, gotta do that!

I think the next thing I should be doing is spreading out the banks more to make room for new enemy graphics and maps, though!

Why do I do this to myself.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 21, 2019, 08:56:58 pm
Because, like me, you are a sick bastard who get off on twisting a games code to do your bidding!!!
Mwahahaha haha ha hahahaha ha ha!!!!!!!!!!!!!!!!!!!!!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 21, 2019, 10:33:25 pm
Okay--you're creepin' me out!

So Bank 2 and 3 are graphics, but I kinda hate Tile Layer Pro and that's the only thing that will open the .dat files. What I would like to do is split up the graphics into .chr, one for every map NPC and dungeon tileset, and turn Bank 2 and 3 into .asm files that just .incbin the graphics.

I need a program that will help me figure out the cut off points for the graphics so I can slice and dice in a hex editor... Figure I should ask if anyone's got a recommendation before I download 20 new random programs that don't work in a 64 bit OS... (Windows 7 by the way. Also have 32 bit XP if the best program for the job only runs on that.)
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 21, 2019, 11:04:46 pm
So Bank 2 and 3 are graphics, but I kinda hate Tile Layer Pro and that's the only thing that will open the .dat files. What I would like to do is split up the graphics into .chr, one for every map NPC and dungeon tileset, and turn Bank 2 and 3 into .asm files that just .incbin the graphics.

.dat is just a file extension.  It shouldn't matter.  Any tile editor should be able to open any file.  Maybe in other editors' file selection dialog, just turn off the filter?  (select it to show "all files" and not just extensions it recognizes).

Changing to .chr is another option (again, the extension is meaningless).  But then you'll have to tweak the build script to cobble together those banks as .chr files instead of .dat files.

A separate .asm file to incbin the chr is probably unnecessary, as the resulting "assembled" file would be identical to the chr file.  Though I guess it would make it easier to separate the chr files and/or add padding.

That said I am also woefully unimpressed by all the tile editors I've used, though I haven't really tried more than three.  TLP and YY-CHR are clunky as all get-out and Tile Molester is flat out broken and virtually unusable on modern versions of Java.  (Or at least I assume it's a Java versioning thing, and the program wasn't so broken when originally released).  If you find something better, I'd love to know about it.

... in fact, I vaguely remember a thread on these boards about a new tile editor?  But I can't find it now and it doesn't seem to be hosted on RHDN.  Shrug.

Quote
I need a program that will help me figure out the cut off points for the graphics so I can slice and dice in a hex editor...

Each 8x8 tile is exactly $10 bytes.  If nothing else you can just count the tiles and multiply by $10.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 21, 2019, 11:25:57 pm
Whups! Sorry to make you type all that; I just realized the extension shouldn't matter, renamed one to .bin, and YY-CHR opens it up FINE now suddenly.  :P

I really like YY-CHR (apart from thinking .dat is some mystical forgotten language)! I haven't really found any issues with it in using it to do the things I do, but I haven't really had to do anything super specific that it does wonkily yet. Think I maybe had some troubles making the intro screen for my own game, but it could have just been a learning curve...

Spoiler:
(https://cdn.discordapp.com/attachments/527351555779723266/580594293748531221/unknown.png)

Still so proud of this!

A separate .asm file to incbin the chr is probably unnecessary, as the resulting "assembled" file would be identical to the chr file.  Though I guess it would make it easier to separate the chr files and/or add padding.

Getting rid of blank space (if necessary) and just knowing exactly where to set pointers is the main reason for it. Being able to input more tilesets and whatnot... figure out new ways to organize the data for loading... That's why I want to cut 'em up as much as possible.



So here's my plan:

Current set up is this:

0 = Object info
1 = Overworld map
2 = map sprites and chr
3 = tile sets
4, 5, 6 = standard maps
7, 8 = enemy graphics
9 = Battle chr/Shop chr/ mini map code
A = Item names, prices, battle strings
B = Battle prep/End
C = Battle
D = Music
E = Shops/Menus
F = Intro, save/load, sound test, Enemy/weapon/armor stats, extras
10 = Dialogue
11 = Puzzle and Bridge scenes
____________________

New order would be this:

0-1 = Object Info
2-3 = map sprites and chr
4-5 = tile sets
7-8 = battle chr/shop chr
9 = Puzzle and Bridge scenes + mini map code
A/10 = remain the same
11-14 = enemy graphics
15 - ?? = standard maps
Whatever's last = Overworld map
Title: Re: FF1 MMC5 Disassembly Updates
Post by: KingMike on May 22, 2019, 11:32:49 am
Moving this week, so don't know how much time I have to work on things. I also want to do VWF for description boxes in menus and dialogue in maps if there's enough tilespace in VRAM.

Not only would tile space be an issue, but VWF is also kind of slow to process.

Though the only example I have seen is a Chinese bootleg translation (hacking game to use kanji, conceptually similar hacking-wise to a VWF) which grinds the game to a halt every time a text box is opened, that it makes the music stutter as well.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 22, 2019, 07:49:48 pm
Okay--you're creepin' me out!

Nothing makes me feel more fulfilled than creeping people out.
My Halloween parties are legendary.

And I have nothing more to add at this time.

I might be delirious from a long day of working Uber.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 25, 2019, 03:30:43 pm
Not only would tile space be an issue, but VWF is also kind of slow to process.

Though the only example I have seen is a Chinese bootleg translation (hacking game to use kanji, conceptually similar hacking-wise to a VWF) which grinds the game to a halt every time a text box is opened, that it makes the music stutter as well.

I worked out the tile space necessary. For description boxes in menus, its 3 lines of 28 tiles, so 84 of 127 available tiles. Dialogue boxes will have to lose 2 lines to fit, but--I also want to figure out a way to have a character say more than 1 box of dialogue. And if the font is squished enough, those 2 lines of original game dialogue might just fit anyway? Also, dropping just one line makes the box not have to weirdly cover the sprite you're talking to if its 1 tile above! So I'm feeling good about this still.

Tepples on NesDev has said his code can do a line in 1 frame... and I think I might try to have text print tile by tile (also, somehow, interruptible to cancel out of it), so 1-2 tiles a frame should be enough. XD

That's still a ways in the future, though!

I've stretched out the ROM to a full 32 banks, and am just one bank of enemy graphics away from having all the graphics chopped up. Only 10 files left in the /bin folder, too.

So there are TWO RNG tables that take up 256 bytes each in the fixed bank and I want those gone. But one needs to be able to scroll through every value for Chaos, unless I can change how Chaos's death works.

Have more to talk about later, but I'll get back to the sorting first, and upload it when I've tested it works as normal still.

Edit: I was being dumb. It happens after taking a break from things!

Anyway, I think I can simplify map loading a bit by just making another pointer table and having each map's byte point to the correct bank its data is in. It might take up more space, but it will be easier for editing and adding new maps? If that makes sense; I'll give it a try soon either way.

Oh, @Disch -- do you have the source code for FFHackster or anything? Wanna see if I can ask a friend to update the map editor to work with .bin files instead of the original game's structure... I still gotta figure out all the different map data systems. Sprites, battle domains, tilesets, teleports, coordinates, palettes.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 25, 2019, 08:36:41 pm
Sure, I have the source, but first.... a few notes:

- It was made with an ANCIENT version of MSVS (I think MSVS 6... like I said... ancient).  There's no makefile.  This is not going to be the easiest thing to build.  Best hope is to open the project file in a newer version of MSVS and hope it up-converts properly, but I make no guarantees.  I personally haven't tried to build this in at least 13 years.

- Dunno if this is actually the 1.0 source or not, it's just the version I had on my local HD.  I may or may not have made changes to it since official release... or maybe this is an older version of the source before official release.  Who knows.  For your purposes it should be close enough, though.

- I'm not convinced retrofitting Hackster is the best option, especially if you have any intention on making changes to the map format or anything like that.  It might be worth using a general purpose editor like Tiled and writing some python scripts to convert the raw data to/from Tiled's format (which I think is just XML)

- This code is old.  Very old.  Embarrassingly old.  I think I wrote it in high school.  I'm almost ashamed of it now.  Tell your friend to brace themselves for bad code.  And believe me, however bad they think the code is, I think it's worse ;P



If I haven't scared you away... here you go:   :beer:

https://www.dropbox.com/s/g805gn94rt37n8e/FFHackster_src.zip?dl=0
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 25, 2019, 11:39:19 pm
I'm too dumb about code to be scared by it! Just confused. Thanks!

I have a github question now... I want to make a backup branch of the current master build, then kind of... like... start over? Or--how do I delete files from the master? All the stuff in the bin folder. Some of it is moved, some of it is put into the .asm files, and I want it to be organized and not re-download all the files I deleted when I switch branches.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 25, 2019, 11:48:17 pm
Deleting files is a pretty basic operation, but how to do it depends on the client you're using.  In SmartGit, all you have to do is delete the files normally from your computer and it'll automatically recognize they're missing and add their deletion to the list of changes when you do a commit.  I assume other clients would do it similarly.


Ideally, your git client should be automatically recognizing ALL changes you've made to ALL files in your root project directory (including moves and deletions).  If your client isn't doing this, I'm going to one again recommend SmartGit.


EDIT:  Or if you're using command line git (which I doubt but just in case)... "git rm <filename>" will remove a file, "git add <filename>" will add a file, and moves are just a delete+add.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 26, 2019, 07:10:42 pm
Well I hope that works!

Big ol' update for everyone to try out. While I haven't moved any banks around yet, they're pretty much ready for that.

Each Standard Map bank has its own pointer table now, instead of the one in the first bank. LoadStandardMap: just does some comparing of numbers (set in constants.inc) instead of trying to figure out what bank to load based on the map's pointer numbers.

The One thing I can think of that my way is worse, is that maps can't cross over banks (the start of each bank has to be pointer table data!) Buuut... I really don't think that's going to be an issue. Deleting two thirds of the pointer table in the first map bank freed up room for the last map there to not cross over, and the last map of the second bank is now the first map of the third bank, and the third bank has SO MUCH ROOM still.

Weird little thing that might be a bug or a mess up on my part in splitting the map data up: there's $3C maps, Titan's Tunnel being the last. But there were $3D null terminator bytes. Just a random 67-byte big map between the final floor of the Temple of Fiends and Titan's Tunnel...?

So far all the maps I'm testing are working fine.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 26, 2019, 08:36:38 pm
So, how much more map space are we talking?

Like, could I add all the extra content from the Dawn of Souls version and not bat an eyelash?

Could I add a bunch of random villages to the overworld?
A slew of mini dungeons in out of the way spots a'la Breath of the wild?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 26, 2019, 09:59:51 pm
While I haven't done much to sort out the other map stuff, like sprites and teleport coordinates, and I still want to find a way to add more treasure chests (even though many are unused currently...)

67. You can add 67 more maps.

That's not a space limit, that's a "double the map ID for the pointer" limit... which... actually? Since the pointer gets reset to 0 for each new bank...

195 maps. Theoretically.

Or whatever you can cram into... 10 banks?, whichever comes first. This is my bank layout plan right now:
0-3   - Enemy graphics (double)
4-5   - Shop/Text graphics, Battle sprites
6-7   - Map sprites and tileset graphics
8     - free space?
9     - Minigame, Bridge scene animations, maybe mini map code
A-10  - remain the same as current banks
11    - free space?
12-14 - Map Sprites/Teleports data
15-1D - Maps (8 banks)
1E    - World map
1F    - Fixed bank
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 28, 2019, 05:36:35 pm
Well, damn. That's a good amount.

I wonder if I could pull off a crazy ass remake of FF2 with this? The key word system could be a challenge...
Just daydreaming. :3

Anyway, with that amount of space for maps, would it be viable to take an entire map bank and utilize it as a separate overworld?

Without knowing much about how things work, I'm guessing we'd need at least a single bit to use as a flag for which overworld you are on (or more if we wanted multiple overworlds).

If you remember one of our earlier conversations, I'm thinking about that Idea I mentioned about turning the submarine into a fully functional vehicle.

And now that my ideas are flowing, adding a special event to the Sky Castle would be cool.
I'm thinking something along the lines of finding a special "high altitude" airship docked at the Sky Castle.
Maybe make it into a side quest where you have to gain access to it.
Then you get to explore the sky which has a few "sky islands" to explore.

Whoa! Just remembered an idea I had a long time ago...
The past as an entirely new overworld!
The gist of it is that when you use the time gate, you are instead sent near to Cornelia in the past.
Chaos' Temple is sealed and you have to find a way to open it.
Then you end up going around the world again to trade your old quest items for new ones that you'll need.
So you end up replacing all the stuff that was said to have been entrusted for the Warriors of Light.

If I wanted to take things a bit further in terms of the time loop thing, I was thinking that the events in the past should include the crystals being drained by the Fiends in order for them to make the journey to the future.
Then in order to save the world in the past, the Light Warriors then have to return the Light to the crystals by sacrificing themselves (kinda like the Fayth in FFX) to become the guardian spirits of the crystals.
Thus the time loop is complete.

[/rambling]



Just tried out the latest master build on Mesen and it crashes the emulator.
And I mean on immediately when attempting to load I get a black screen and the emulator stops responding.
No conniption fit or anything. Just dead as door nail.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 29, 2019, 08:33:38 pm
Whoopsie. I thought I fixed it... was aware of it doing that, but then traced it to me not updating LongCalls with the proper bank bytes after re-ordering them. Soooo hm. I'm kind of in the middle of messing up everything so I can't fix it without undoing my work or breaking battles, so gimme a day or two to sort that out.

I'm trying to come up with a way to load enemy graphics outside of their tilesets. Formation data has the IDs of all enemies needed, the IDs just need to be sorted small to big, with the amount updated as well...? Then instead of checking the low bits of the first byte for the whole set... just goes through the IDs, but then fiends need their own special loading, but also the second byte in the formation data might be tricky...

Yep. It's a mess.

Love the idea of a second overworld. But... not gonna devote any brain power to how it would be done just now. xD

Edit: Considering how much I have to change for this, I'm shelving it for tonight. I pushed my current build with my new stuff commented out and old stuff in place, and it loads for me okay.

If it still crashes, see what happens with the debugger with a breakpoint set at $C05C... that should be "CMP #$4D" Then let me know if it goes on to "LDA #$4D" or skips past it.



Think I'm gonna drop this idea. Being able to mix and match enemies sounds fun, but the amount of effort is... staggering. And I'm not having fun trying to code it.

Here's a rough draft of what I was trying to do...

Code: [Select]
LoadEnemyGraphics:
;    LDY #2
;   @LoadNext:
;    LDA (tmp+4), Y              ; get enemy ID
;    CMP #$FF                    ; if $FF, do... something to skip it
;    BEQ :+

;    ASL A                       ; double ID, put in X
;    TAX
;    STY enemyload_counter       ; save Y as counter
;    LDA lut_EnemyBankCHR, X     ; get first byte of this table
;    AND #$0F                    ; cut off high bits
;    LDY enemyload_pointer       ; load the pointer thing into Y
;    STA enemyload, Y            ; save the bank # as this byte in the new loading list
;    INY
;    LDA lut_enemyBankCHR, X     ; get first byte again
;    AND #$F0                    ; cut off low bits
;    BEQ @SmallEnemy             ; if its 0, its a small enemy, else...
;   
;    CMP #02
;    BEQ @Fiend
;    CMP #03
;    BEQ @Chaos
;   
;   @LargeEnemy:
;    INX                         ; get second byte of above table
;    LDA lut_enemyBankCHR, X     ; large enemies are $240 bytes each - #576 bytes
;    LDX #$24                    ; so multiply by...
;    JSR MultiplyXA              ;
;    STA enemyload, Y            ; low byte of address
;    INY                         ;
;    TXA                         ; get high byte of multiplication
;    ORA #$80                    ; set highest bit so it loads from the bank's address properly
;    STA enemyload, Y            ; and save as high byte of address
;    INY
;    STY enemyload_pointer
;    LDY enemyload_counter
;    INY
;    CPY #6
;    BEQ @Finish
;    JMP @LoadNext
;   
;   
;   @SmallEnemy:
;    INX                         ; get second byte of above table
;    LDA lut_enemyBankCHR, X     ; small enemies are $100 bytes each
;    STA enemyload, Y            ; low byte of address
;    INY                         ;
;    TXA                         ; get high byte of multiplication
;    ORA #$80                    ; set highest bit so it loads from the bank's address properly
;    STA enemyload, Y            ; and save as high byte of address
;    INY
;    STY enemyload_pointer
;    LDY enemyload_counter
;    INY
;    CPY #6
;    BEQ @Finish
;    JMP @LoadNext

lut_enemyBankCHR:
;; JIGS - left nybble: enemy size (0 = small, 1 = large, 2 = fiend, 3 = chaos)
;;       right nybble: enemy place in chr list
;;        second byte: order in bank (small and large are seperated graphically)


So the thought was, 4 enemies, $10 bytes of pointers and such. 1st byte is the bank to load from, 2nd and 3rd bytes are the pointers to start drawing, 4th byte is how many tiles. Then pass that off to a routine in the fixed bank that would go through the list, swap banks, draw the enemy tiles, ending up with basically the same format as it is now.

But also gotta organize the enemy graphics in the banks, know how many small/large are in each bank, add that offset in when doing large enemies, oawoo... Just a ton more code and extra LUTs for something so... probably not that useful at the current stage...?
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on May 29, 2019, 11:46:03 pm
I haven't really been keeping up lately, so I might not fully understand what you were going for.

It sounds like you are trying to remove the graphic assignment for a battle formation, and instead load the graphics dynamically based on which enemies are in the encounter?

That's totally do-able.  And I think that might be a fun thing I might not mind spending some time on.  It always seemed unwieldly that to change an enemy you had to change not just the enemy ID, but also the graphic page that gets loaded, the graphic that enemy used, the loaded palettes AND which palette the enemy used.  Most of that should be automatically detectable by just changing the enemy ID.

The real question is what to do about enemy palette assignments....


Here's what I'm thinking:

- Battle formations themselves only include the enemy IDs, and the quantities (and other formation stuff, like 9small vs. 4large, surprise rate, can't run flag, etc).  Remove ALL graphic and palette info from the formation.

- Separate LUTs for graphics, to be indexed by Enemy ID

- Similar LUT for palettes

- When battle is being loaded, use those new LUTs to dynamically load the tiles and palettes you need.


This will work for most cases, but there are problems if the battle formations are configured "improperly".  For example, if you build a formation that has enemies which use 3 separate palettes.. one of the enemies isn't going to get displayed properly because you can only have 2 palettes loaded.

The question in that case is, what to do about it?  Draw the enemy with a wrong palette?  Or simply don't load that enemy (treat it as a quantity of zero)?  I'd lean more towards the latter.


But yeah lemme know what you think.  I'll consider looking at this if I can find the time.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 30, 2019, 01:19:59 am
Hmmm... My knee-jerk reaction is to not allow more than 2 enemy types per formation.

But that would be pretty draconian, and a step backwards.

I think that the best way to handle it is to zero out anything that would need a third palette.

Anything beyond that is probably more trouble than it's worth.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on May 30, 2019, 03:21:14 pm
Quote
It sounds like you are trying to remove the graphic assignment for a battle formation, and instead load the graphics dynamically based on which enemies are in the encounter?

 Exactly! I just went from Blegh to Oooh Cool in less than 24 hours, so... I like it again! I'll help as much as I can.

I went and did my best to fill out lut_BattlePalettes with information on what enemy uses what palettes, and there's a few combinations I'd love to see. Gas Dragons surrounded by scum and ooze... Zombulls leading zombies... Shadows and spiders together!

Some palettes are really close, too. There's not a whole lot of difference in the palettes SeaTrolls and SeaSnakes use--at least not for those enemies. So some enemies could be slightly altered without losing their main thematic colours and look Just Fine.

If there can be a way to set a trigger on enemies that are using the wrong palette, then I might be in favour of keeping it. They could have a higher rate of stealing special items, or double exp/gold or something. Shiny pokemon enemies! They'd only happen if whoever was building new formations mucked up, so someone could actually make a formation where an imp is using, I d'nno, palette $1C (Earth, Sand W., Ankylo)... sand imps...! Same enemy, new clothes for a new location.



Moved the enemy names so there's more room in Bank B for doing neat formation stuff. Also set up $70 in zero page RAM for enemy_load, in case that's needed.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on May 30, 2019, 03:26:03 pm
That could be useful for bonus areas or in non-FF projects.
Don't think I'd use it in the main game.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Jiggers on June 01, 2019, 03:30:31 pm
Nothing really new to report, just a grump:

I made a new way to load the battle backgrounds. In Bank 3, they're all arranged in rows of $100 bytes each. Then instead of loading up a blank tile, there's code that just draws in the blank tiles at the start and after the background. But this does take up some extra room in the fixed bank! So I wondered: maybe it would save bytes to have the blank tiles stored with the backgrounds? But then they'd be in $120 tile rows. That's pretty messy to deal with! I figure, multiply by $12, then shift things left by 4 bits.

I worked out the code for that:

Code: [Select]
    LDA #0
    STA tmp+1
    LDX ow_tile                   ; Get last OW tile we stepped on
    LDA lut_BtlBackdrops, X       ; Use it as an index to get the backdrop ID
    AND #$0F                      ; mask with $0F (there are only 16 battle BGs)
    LDX #$12
    JSR MultiplyXA
    ASL A               ; shift highest bit into carry
    ROL tmp+1           ; shift carry into tmp+1
    ASL A
    ROL tmp+1
    ASL A
    ROL tmp+1
    ASL A
    ROL tmp+1
    STA tmp             ; save remainder of A as low byte of address
    LDA tmp+1           ; load high byte of address
    CPX #1              ; then see if X = 1 from the multiply
    BNE :+
        ORA #$10        ; if the multiplication result was over $FF, add the 1 in
 :  ORA #$80            ; then add the 8 for the start of the bank address
    STA tmp+1

Pretty sleek! Well. Final tally of space in the fixed bank after this is 323 bytes. Final tally with the current version in github is 335! All that work fer nothin'!
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Disch on June 01, 2019, 07:31:57 pm
Quote
I figure, multiply by $12, then shift things left by 4 bits.

Err... why not just multiply by $120?

Code: [Select]
LDA lut_BtlBackDrops, X
STA tmp+1               ; using value directly as high byte is the same as mulitply by $100
LDX #$20
JSR MultiplyXA          ; multiply by $20
STA tmp
TXA
CLC
ADC tmp+1               ; (value * $20) + (value * $100) = (value * $120)
ORA #$80
STA tmp+1

EDIT:  made some corrections.

Also, you can't use ORA to add.  It will only add the $10 if that bit isn't already set.
Title: Re: FF1 MMC5 Disassembly Updates
Post by: Vanya on June 09, 2019, 02:46:49 am
Good news / Bad news

Bad News: My girlfriend's laptop that I was using temporarily to get by without my desktop died hard this week when two of it's resistors blarffed and took out two of the nearby chips on the motherboard.

Good News: I fixed my desktop.

So time allowing, I'll get back to testing the latest build of the project this coming week.

I want to take some time to organize my notes so I can add some suggestions to the online document.