From f0ba8f893af6f8e9a6e0ab99ba5cd84617eaf7a9 Mon Sep 17 00:00:00 2001 From: Fernap Date: Mon, 12 Dec 2022 15:47:59 -0500 Subject: [PATCH] Removed spriteASM stuff (see #27), and fixed inability to switch to a custom game mode from a vanilla game mode's main routine (see #28). --- UberASMTool/Model/UberConfig.cs | 4 ++-- UberASMTool/Program.cs | 10 +++----- UberASMTool/UberConfigProcessor.cs | 19 ++++++--------- assets/asm/base/gamemode.asm | 4 ++-- assets/asm/base/global.asm | 20 ++++------------ assets/asm/base/main.asm | 3 +-- assets/asm/base/sprites.asm | 38 ------------------------------ assets/list.txt | 5 ++-- assets/readme.txt | 17 +++++-------- 9 files changed, 27 insertions(+), 93 deletions(-) delete mode 100644 assets/asm/base/sprites.asm diff --git a/UberASMTool/Model/UberConfig.cs b/UberASMTool/Model/UberConfig.cs index 4f8ea97..c0a0cc3 100644 --- a/UberASMTool/Model/UberConfig.cs +++ b/UberASMTool/Model/UberConfig.cs @@ -15,8 +15,8 @@ class UberConfig public string MacroLibraryFile { get; set; } public int[][][] FileASMList { get; set; } public int[][] GlobalASMList { get; set; } - public int SpriteCodeFreeRAM { get; set; } - public int SpriteCodeFreeBWRAM { get; set; } + public int FreeRAM { get; set; } + public int FreeBWRAM { get; set; } public Code[] CodeList { get; set; } } } diff --git a/UberASMTool/Program.cs b/UberASMTool/Program.cs index 16a3ad5..1e47203 100644 --- a/UberASMTool/Program.cs +++ b/UberASMTool/Program.cs @@ -637,9 +637,6 @@ static void BuildOther() File.WriteAllText("asm/work/statusbar.asm", global); - // copy sprites.asm - File.Copy("asm/base/sprites.asm", "asm/work/sprites.asm", true); - // prepare main file StringBuilder mainFile = new StringBuilder(); @@ -651,7 +648,7 @@ static void BuildOther() mainFile.AppendFormat("!overworld_nmi\t= {0}\r\n", enableNmi[1] ? 1 : 0); mainFile.AppendFormat("!gamemode_nmi\t= {0}\r\n", enableNmi[2] ? 1 : 0); mainFile.AppendFormat("!global_nmi\t= {0}\r\n\r\n", enableNmi[3] ? 1 : 0); - mainFile.AppendFormat("!sprite_RAM\t= ${0:X6}\r\n\r\n", GetSpriteRAMValue()); + mainFile.AppendFormat("!UberFreeRAM\t= ${0:X6}\r\n\r\n", GetFreeRAMValue()); mainFile.AppendLine(); @@ -663,10 +660,9 @@ static void BuildOther() File.WriteAllText("asm/work/main.asm", mainFile.ToString()); } - private static int GetSpriteRAMValue() + private static int GetFreeRAMValue() { - int result = rom.sa1 && config.SpriteCodeFreeBWRAM != 0 - ? config.SpriteCodeFreeBWRAM : config.SpriteCodeFreeRAM; + int result = config.FreeRAM; if (result == 0) { diff --git a/UberASMTool/UberConfigProcessor.cs b/UberASMTool/UberConfigProcessor.cs index e9e52d3..53506cc 100644 --- a/UberASMTool/UberConfigProcessor.cs +++ b/UberASMTool/UberConfigProcessor.cs @@ -22,8 +22,8 @@ class UberConfigProcessor private string macroLibraryFile = null; private readonly List[][] list = new List[3][] { new List[512], new List[7], new List[256] }; private readonly List[] globalList = new List[3]; - private int spriteCodeFreeRAM = 0; - private int spriteCodeFreeBWRAM = 0; + private int freeRAM = 0; + private int freeBWRAM = 0; public string GetLogs() { @@ -41,8 +41,8 @@ public UberConfig Build() MacroLibraryFile = macroLibraryFile, FileASMList = list.Select(c => c.Select(d => d?.ToArray()).ToArray()).ToArray(), GlobalASMList = globalList.Select(c => c?.ToArray()).ToArray(), - SpriteCodeFreeRAM = spriteCodeFreeRAM, - SpriteCodeFreeBWRAM = spriteCodeFreeBWRAM, + FreeRAM = freeRAM, + FreeBWRAM = freeBWRAM, CodeList = codeList.ToArray(), }; } @@ -129,14 +129,9 @@ public bool ParseList() if (!ParseGlobalFileDeclaration(ref statusBarFile, "Status Bar ASM", value, i)) return false; continue; - case "sprite-sa1:": - if (!ParseHexDefineDeclaration(ref spriteCodeFreeBWRAM, - "sprite code free SA-1 RAM address", valueHex, i)) return false; - continue; - - case "sprite:": - if (!ParseHexDefineDeclaration(ref spriteCodeFreeRAM, - "sprite code free RAM address", valueHex, i)) return false; + case "freeram:": + if (!ParseHexDefineDeclaration(ref freeRAM, + "Free RAM address", valueHex, i)) return false; continue; } diff --git a/assets/asm/base/gamemode.asm b/assets/asm/base/gamemode.asm index 1a1e184..d3fa911 100644 --- a/assets/asm/base/gamemode.asm +++ b/assets/asm/base/gamemode.asm @@ -34,7 +34,7 @@ freecode PHP AND #$00FF ASL - ADC !previous_mode + ADC !previous_mode ; this works because !previous_mode has been set to $0100's value, and !previous_mode+1 always contains 00 TAX PLP BNE + @@ -52,7 +52,7 @@ freecode RTL return: - LDA $0100|!addr + LDA !previous_mode ASL TAX LDA $9329,x diff --git a/assets/asm/base/global.asm b/assets/asm/base/global.asm index 899885f..10e512c 100644 --- a/assets/asm/base/global.asm +++ b/assets/asm/base/global.asm @@ -14,23 +14,17 @@ ORG $05808C freecode -; Do not edit nor move that. -; That's a special prot table for cleaning external data and codes. +; Do not edit or move this. +; It's a special prot table for cleaning external data and codes. db "uber" prot_table: db "tool" clear_pointers: STA $7F8182 - LDA #$00 - LDX #!sprite_slots*3-1 - - - STA !sprite_RAM,x - DEX - BPL - LDA #$00 - STA !previous_mode+1 + STA !previous_mode+1 ; always 00, so that !previous_mode can be accessed in 16-bit mode DEC STA !previous_mode @@ -50,13 +44,7 @@ _global_main: BEQ _global_main endif JSR global_main - - LDA $0100|!addr - CMP #$14 - BNE + - JSR sprite_code -+ - + JML $00806F|!bank load: diff --git a/assets/asm/base/main.asm b/assets/asm/base/main.asm index 088a8d4..e4f95e7 100644 --- a/assets/asm/base/main.asm +++ b/assets/asm/base/main.asm @@ -1,9 +1,8 @@ -!previous_mode = !sprite_RAM+(!sprite_slots*3) +!previous_mode = !UberFreeRAM incsrc level.asm incsrc overworld.asm incsrc gamemode.asm incsrc global.asm -incsrc sprites.asm incsrc statusbar.asm diff --git a/assets/asm/base/sprites.asm b/assets/asm/base/sprites.asm deleted file mode 100644 index 3451555..0000000 --- a/assets/asm/base/sprites.asm +++ /dev/null @@ -1,38 +0,0 @@ -sprite_code: - LDX.b #!sprite_slots - - - DEX - LDA !sprite_RAM,x - ORA !sprite_RAM+(!sprite_slots),x - ORA !sprite_RAM+(!sprite_slots*2),x - BNE + - CPX #$00 - BNE - - BRA .return - + - if !sa1 - LDA $3242,x - else - LDA $14C8,x - endif - BEQ .clear - LDA !sprite_RAM,x - STA $00 - LDA !sprite_RAM+(!sprite_slots),x - STA $01 - LDA !sprite_RAM+(!sprite_slots*2),x - STA $02 - PHK - PEA.w .next - JMP [!dp] - .next - CPX #$00 - BNE - - .return - RTS - .clear - LDA #$00 - STA !sprite_RAM,x - STA !sprite_RAM+(!sprite_slots),x - STA !sprite_RAM+(!sprite_slots*2),x - BRA - diff --git a/assets/list.txt b/assets/list.txt index 245be61..4d64f5a 100644 --- a/assets/list.txt +++ b/assets/list.txt @@ -88,9 +88,8 @@ statusbar: other/status_code.asm # A file containing macros. macrolib: other/macro_library.asm -# Sprite-related RAM (see README). You probably don't need to change this. -sprite: $7FAC80 # 38 (SNES) or 68 (SA-1) bytes of free RAM. -sprite-sa1: $41AC80 # Optional for SA-1 ROMs. +# Free RAM for UberASMTool (see README). You probably don't need to change this. +freeram: $7FAC80 # 2 bytes of free RAM # The name of your ROM file - this will be used if you don't specify a ROM name # when running UberASM Tool. diff --git a/assets/readme.txt b/assets/readme.txt index 5ba974b..f98bc60 100644 --- a/assets/readme.txt +++ b/assets/readme.txt @@ -207,17 +207,12 @@ Pretty much same as global code. This defines the path for the macro/define library .asm file location. - - sprite: - This defines what free RAM address will be used to hold the -sprites early execution pointers and last game mode. Usually you -should not worry about this RAM address, as the default value should -work normally. It requires 38 bytes of Free RAM if you're using a -regular ROM or 68 bytes if you're using SA-1 Pack. It requires more -bytes on SA-1 ROMs because SA-1 Pack's sprite table is 22 bytes long -unlike regular SMW which is 12 bytes long. If you plan to use sprites -early execution pointers, it's recommended to use a free BW-RAM -address range instead if you're using SA-1, so sprites can modify the -pointers without invoking SNES CPU. + - freeram: + Specifies 2 bytes of free RAM used to keep track of the previous +game mode. Usually you don't need to worry about this RAM address; +the default value should work normally. More may be required in the +future, but previous versions required 38 (68 on SA-1) bytes, rather +than the current amount. - rom: This defines what ROM file will be used, relative to the .exe file