Skip to content

Commit

Permalink
Removed spriteASM stuff (see VitorVilela7#27), and fixed inability to…
Browse files Browse the repository at this point in the history
… switch to a custom game mode from a vanilla game mode's main routine (see VitorVilela7#28).
  • Loading branch information
Fernap committed Dec 12, 2022
1 parent fb0a2a6 commit f0ba8f8
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 93 deletions.
4 changes: 2 additions & 2 deletions UberASMTool/Model/UberConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
10 changes: 3 additions & 7 deletions UberASMTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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)
{
Expand Down
19 changes: 7 additions & 12 deletions UberASMTool/UberConfigProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class UberConfigProcessor
private string macroLibraryFile = null;
private readonly List<int>[][] list = new List<int>[3][] { new List<int>[512], new List<int>[7], new List<int>[256] };
private readonly List<int>[] globalList = new List<int>[3];
private int spriteCodeFreeRAM = 0;
private int spriteCodeFreeBWRAM = 0;
private int freeRAM = 0;
private int freeBWRAM = 0;

public string GetLogs()
{
Expand All @@ -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(),
};
}
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions assets/asm/base/gamemode.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand All @@ -52,7 +52,7 @@ freecode
RTL
return:
LDA $0100|!addr
LDA !previous_mode
ASL
TAX
LDA $9329,x
Expand Down
20 changes: 4 additions & 16 deletions assets/asm/base/global.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions assets/asm/base/main.asm
Original file line number Diff line number Diff line change
@@ -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

38 changes: 0 additions & 38 deletions assets/asm/base/sprites.asm

This file was deleted.

5 changes: 2 additions & 3 deletions assets/list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 6 additions & 11 deletions assets/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,12 @@ Pretty much same as global code.
This defines the path for the macro/define library .asm file
location.

- sprite: <RAM address>
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: <RAM address>
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: <ROM path>
This defines what ROM file will be used, relative to the .exe file
Expand Down

0 comments on commit f0ba8f8

Please sign in to comment.