Initial commit

This commit is contained in:
Dario48 2026-05-23 16:53:17 +02:00
commit 0c07c770a9
14 changed files with 20819 additions and 0 deletions

3
.envrc Normal file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
use flake

10
.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
result
smb.nes.dbg
smb.map
smb.nes
smb.nes.ndx
obj/nes/smbdishl.o
obj/nes/smb.d
chr/
src/smb_chr.chr
.direnv

29
Makefile Normal file
View file

@ -0,0 +1,29 @@
cl65 ?= cl65
.PHONY: build debug clean
build: smb.nes
debug: OBJ_DEBUG_ARGS = --create-dep obj/nes/smb.d -v -g
debug: ROM_DEBUG_ARGS = -Wl --dbgfile,smb.nes.dbg
debug: build
obj/nes/smbdishl.o: src/smbdishl.s src/smb_chr.chr
$(cl65) -t none -c $(OBJ_DEBUG_ARGS) --include-dir src -o $@ $<
smb.nes smb.map: obj/nes/smbdishl.o src/nes.cfg
$(cl65) -t none --mapfile smb.map $(ROM_DEBUG_ARGS) -o smb.nes -C src/nes.cfg $<
src/smb_chr.chr:
if [ -s chr/smb_chr.chr ]; then \
if [ -s src/smb_chr.chr ]; then \
cmp -s $@ chr/smb_chr.chr || cp chr/smb_chr.chr $@ \
else \
cp chr/smb_chr.chr \
fi \
else \
[ -s src/smb_chr.chr ] || $(error missing chr)\
fi
clean:
rm -f smb.nes.dbg smb.map smb.nes smb.nes.ndx obj/nes/smbdishl.o obj/nes/smb.d

11
README.MD Normal file
View file

@ -0,0 +1,11 @@
Building:
NOTE: "chr/smb_chr.chr" is required to assemble. (Not included.)
Run either `make`, or `make debug`
They both will build the .nes rom, but one will also output debug data.
(Try it and load the rom in NintendulatorDX and step through the code.)
`make clean` will just delete all files in that could be created by either `make`
all the credit to [Movax12](https://www.romhacking.net/community/2056/), original version available at [romhacking.net](https://www.romhacking.net/documents/635/)

102
flake.lock generated Normal file
View file

@ -0,0 +1,102 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1778716662,
"narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nesrx": {
"inputs": {
"flake-parts": [
"flake-parts"
],
"nesrx": "nesrx_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1779540575,
"narHash": "sha256-sfmoaOR9wN6H8jJyBKC1VBVd9cuf1l8bch+0uf/O/5s=",
"ref": "refs/heads/main",
"rev": "b1cfcfb6ed2d8e4d3a93a94bae58cdbf6ebd9bea",
"revCount": 3,
"type": "git",
"url": "https://dario48.site/git/Dario48/nesrx-flake.git"
},
"original": {
"type": "git",
"url": "https://dario48.site/git/Dario48/nesrx-flake.git"
}
},
"nesrx_2": {
"flake": false,
"locked": {
"lastModified": 1657372504,
"narHash": "sha256-Nnu+Jncw7k+7sE4AL9xjbm6dNVt8ZuKW/8tdKmm4G9Q=",
"owner": "xms0g",
"repo": "nesrx",
"rev": "573e008d84bb8b6b86e7f2111211175d01ea018c",
"type": "github"
},
"original": {
"owner": "xms0g",
"repo": "nesrx",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1779357205,
"narHash": "sha256-cCO8aTqss5x9Ky8GWkpY0Hy5fyTZEbtifSUV8QjSzic=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "f83fc3c307e74bc5fd5adb7eb6b8b13ffd2a36e1",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1777168982,
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nesrx": "nesrx",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

56
flake.nix Normal file
View file

@ -0,0 +1,56 @@
{
description = "A basic Bun project template for JavaScript/TypeScript development.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
nesrx = {
url = "git+https://dario48.site/git/Dario48/nesrx-flake.git";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts";
};
};
};
outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ ];
systems = builtins.attrNames inputs.nixpkgs.legacyPackages;
perSystem =
{
config,
system,
pkgs,
self',
...
}:
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.nesrx.overlays.default
];
};
devShells.default = pkgs.mkShellNoCC {
inputsFrom = [ self'.packages.default ];
packages = with pkgs; [
nesrx
fceux
];
};
packages.default = pkgs.stdenvNoCC.mkDerivation {
name = "smbOneOne";
src = ./.;
dontInstall = true;
nativeBuildInputs = with pkgs; [ cc65 ];
};
packages.debug = config.packages.default.overrideAttrs (_: {
buildStep = "make debug";
});
};
};
}

View file

@ -0,0 +1,3 @@
copy 8k
"smb_chr.chr"
file to this folder

2057
src/ca65hl.h Normal file

File diff suppressed because it is too large Load diff

34
src/ca65hl_defines.h Normal file
View file

@ -0,0 +1,34 @@
; BELOW: .defines for recognized flag tests. Format: Flag to test for and default setting.
; These are not required for the macro code to function
.define less C clear
.define greaterORequal C set
.define carry C set
.define zero Z set
.define equal Z set
.define plus N clear
.define positive N clear
.define minus N set
.define negative N set
.define bit7 N set
.define overflow V set
.define bit6 V set
.define bitset Z clear
.define greater G set ; Use greater and less/equal macros to simulate
.define lessORequal G clear
; define symbols for AND, OR, NOT, must use recognized ca65 tokens or valid ident-like strings
; These are required for all functions to work
.define _HL_MACRO_USER_AND_DEFINITION_ && ; '&&' will match '.and'
.define _HL_MACRO_USER_OR_DEFINITION_ || ; '||' will match '.or'
.define _HL_MACRO_USER_NOT_DEFINITION1_ not
.define _HL_MACRO_USER_NOT_DEFINITION2_ ! ; wil match '.not'
.define _HL_MACRO_USER_GOTO_DEFINITION_ goto ; if condition goto label
; maximum iny/dey/inx/dex commands created by a +/- in an expression with x or y reg before a warning
.define _MB_MAXIMUM_ADD_OR_SUB_X_OR_Y_ 6

706
src/memory.h Normal file
View file

@ -0,0 +1,706 @@
; Memory layout for smbdis
; Consants
; GAME SPECIFIC DEFINES
; -------------------------------------------------------------------------------------------------------
; ----------------------------Constants------------------------------------------------------------------
; -------------------------------------------------------------------------------------------------------
; sound effects constants
SFX_SmallJump = %10000000
SFX_Flagpole = %01000000
SFX_Fireball = %00100000
SFX_PipeDown_Injury = %00010000
SFX_EnemySmack = %00001000
SFX_EnemyStomp = %00000100
SFX_Bump = %00000010
SFX_BigJump = %00000001
SFX_BowserFall = %10000000
SFX_ExtraLife = %01000000
SFX_PowerUpGrab = %00100000
SFX_TimerTick = %00010000
SFX_Blast = %00001000
SFX_GrowVine = %00000100
SFX_GrowPowerUp = %00000010
SFX_CoinGrab = %00000001
SFX_BowserFlame = %00000010
SFX_BrickShatter = %00000001
; music constants
MUSIC_Silence = %10000000
MUSIC_StarPower = %01000000
MUSIC_PipeIntro = %00100000
MUSIC_Cloud = %00010000
MUSIC_Castle = %00001000
MUSIC_Underground = %00000100
MUSIC_Water = %00000010
MUSIC_Ground = %00000001
MUSIC_TimeRunningOut = %01000000
MUSIC_EndOfLevel = %00100000
MUSIC_AltGameOver = %00010000
MUSIC_EndOfCastle = %00001000
MUSIC_Victory = %00000100
MUSIC_GameOver = %00000010
MUSIC_Death = %00000001
; enemy object constants
OBJECTID_GreenKoopa = $00
OBJECTID_BuzzyBeetle = $02
OBJECTID_RedKoopa = $03
OBJECTID_HammerBro = $05
OBJECTID_Goomba = $06
OBJECTID_Bloober = $07
OBJECTID_BulletBill_FrenzyVar = $08
OBJECTID_TallEnemy = $09
OBJECTID_GreyCheepCheep = $0a
OBJECTID_RedCheepCheep = $0b
OBJECTID_Podoboo = $0c
OBJECTID_PiranhaPlant = $0d
OBJECTID_GreenParatroopaJump = $0e
OBJECTID_RedParatroopa = $0f
OBJECTID_GreenParatroopaFly = $10
OBJECTID_Lakitu = $11
OBJECTID_Spiny = $12
OBJECTID_FlyingCheepCheep = $14
OBJECTID_FlyCheepCheepFrenzy = $14
OBJECTID_BowserFlame = $15
OBJECTID_Fireworks = $16
OBJECTID_BBill_CCheep_Frenzy = $17
OBJECTID_Stop_Frenzy = $18
OBJECTID_Bowser = $2d
OBJECTID_PowerUpObject = $2e
OBJECTID_VineObject = $2f
OBJECTID_FlagpoleFlagObject = $30
OBJECTID_StarFlagObject = $31
OBJECTID_JumpspringObject = $32
OBJECTID_BulletBill_CannonVar = $33
OBJECTID_RetainerObject = $35
; other constants
.enum
WORLD1
WORLD2
WORLD3
WORLD4
WORLD5
WORLD6
WORLD7
WORLD8
.endenum
.enum
LEVEL1
LEVEL2
LEVEL3
LEVEL4
.endenum
.enum
MODE_TITLESCREEN
MODE_GAMEPLAY
MODE_VICTORY
MODE_GAMEOVER
.endenum
; additional HL conditional defines
.define BigMario Z set ; \ for use with ' PlayerSize '
.define SmallMario Z clear ; /
WarmBootOffset = <_WarmBootOffset
ColdBootOffset = <_ColdBootOffset
TitleScreenDataOffset = $1ec0 ; address in CHR ROM for titlescreen nametable layout
; -------------------------------------------------------------------------------------------------------
; ------------------------------R -------A --------M ----------------------------------------------------
; -------------------------------------------------------------------------------------------------------
.segment "ZEROPAGE"
temp_byte: .res 8 ; local temp pointers and vars
ObjectOffset: .res 1
FrameCounter: .res 1
A_B_Buttons: .res 1
Up_Down_Buttons: .res 1
Left_Right_Buttons: .res 1
PreviousA_B_Buttons: .res 1
GameEngineSubroutine: .res 1
Enemy_Flag: .res 7
Enemy_ID : .res 7
;--------------------------- Obj State:
Player_State: .res 1
; on ground = 0
; swimming = 1
; falling = 2
; ClimbmingVine = 3
Enemy_State: .res 6
Fireball_State: .res 2
Block_State: .res 4
Misc_State: .res 9
;---------------------------
PlayerFacingDir: .res 1 ; 1 = right, 2 = left
FirebarSpinDirection:
DestinationPageLoc: .res 1
VictoryWalkControl: .res 4
PowerUpType: .res 1 ; 0 = shroom, 1 = fireflower, 2 = star, 3 = 1up shroom
FireballBouncingFlag: .res 2
HammerBroJumpTimer: .res 9
Player_MovingDir: .res 1
Enemy_MovingDir: .res 17
;--------------------------- X speed
SprObject_X_Speed:
Player_X_Speed: .res 1
Enemy_X_Speed:
LakituMoveSpeed:
PiranhaPlant_Y_Speed:
ExplosionGfxCounter:
Jumpspring_FixedYPos:
RedPTroopaCenterYPos:
BlooperMoveSpeed:
XMoveSecondaryCounter:
CheepCheepMoveMFlag:
FirebarSpinState_Low:
YPlatformCenterYPos: .res 6
Fireball_X_Speed: .res 2
Block_X_Speed: .res 4
Misc_X_Speed: .res 9
;--------------------------- Obj Page Loc:
SprObject_PageLoc:
Player_PageLoc: .res 1
Enemy_PageLoc: .res 6
Fireball_PageLoc: .res 2
Block_PageLoc: .res 4
Misc_PageLoc: .res 9
Bubble_PageLoc: .res 3
;--------------------------- X position
SprObject_X_Position:
Player_X_Position: .res 1
Enemy_X_Position: .res 6
Fireball_X_Position: .res 2
Block_X_Position: .res 4
Misc_X_Position: .res 9
Bubble_X_Position: .res 3
;--------------------------- Y Speed
Player_Y_Speed:
SprObject_Y_Speed: .res 1
FirebarSpinState_High:
XMovePrimaryCounter:
BlooperMoveCounter:
Enemy_Y_Speed:
LakituMoveDirection:
ExplosionTimerCounter:
PiranhaPlant_MoveFlag: .res 6
Fireball_Y_Speed: .res 2
Block_Y_Speed: .res 4
Misc_Y_Speed: .res 9
;--------------------------- Y high pos
SprObject_Y_HighPos:
Player_Y_HighPos: .res 1
Enemy_Y_HighPos: .res 6
Fireball_Y_HighPos: .res 2
Block_Y_HighPos: .res 4
Misc_Y_HighPos: .res 9
Bubble_Y_HighPos: .res 3
;--------------------------- Y position
Player_Y_Position:
SprObject_Y_Position: .res 1
Enemy_Y_Position: .res 6
Fireball_Y_Position: .res 2
Block_Y_Position: .res 4
Misc_Y_Position: .res 9
Bubble_Y_Position: .res 3
;---------------------------
AreaData:
AreaDataLow: .res 1
AreaDataHigh: .res 1
EnemyData:
EnemyDataLow: .res 1
EnemyDataHigh: .res 1
dummylabel: .res 5 ; = start at $EB, reserve 5 bytes for local use.
NoteLenLookupTblOfs: .res 1
Square1SoundBuffer: .res 1
Square2SoundBuffer: .res 1
NoiseSoundBuffer: .res 1
AreaMusicBuffer: .res 1
MusicData:
MusicDataLow: .res 1
MusicDataHigh: .res 1
MusicOffset_Square2: .res 1
MusicOffset_Square1: .res 1
MusicOffset_Triangle: .res 1
PauseSoundQueue: .res 1
AreaMusicQueue: .res 1
EventMusicQueue: .res 1
NoiseSoundQueue: .res 1
Square2SoundQueue: .res 1
Square1SoundQueue: .res 1
.segment "STACK"
; start $0100
blank_stack: .res 9 ; not used
VerticalFlipFlag: .res 4
FlagpoleFNum_Y_Pos: .res 1
FlagpoleFNum_YMFDummy: .res 1
FlagpoleScore: .res 1
mystruct FloateyNum
Control .byte 7
X_Pos .byte 7
Y_Pos .byte 7
endmystruct
ShellChainCounter: .res 7
FloateyNum_Timer: .res 8
DigitModifier: .res 6
.segment "OAMRAM"
; start $0200
mystruct Sprite
.union
Data .byte
.struct
Y_Position .byte
Tilenumber .byte
Attributes .byte
X_Position .byte
.endstruct
.endunion
endmystruct
.segment "BSS"
; start $0300
VRAM_Buffer1_Offset: .res 1
VRAM_Buffer1: .res 63
VRAM_Buffer2_Offset: .res 1
VRAM_Buffer2: .res 34 ; 26 for a column, 3 for address and size
BowserBodyControls: .res 1
BowserFeetCounter: .res 1
BowserMovementSpeed: .res 1
BowserOrigXPos: .res 1
BowserFlameTimerCtrl: .res 1
BowserFront_Offset: .res 1
BridgeCollapseOffset: .res 1
BowserGfxFlag: .res 30
FirebarSpinSpeed: .res 16
mystruct Vine
FlagOffset .byte
Height .byte
ObjOffset .byte 3
Start_Y_Position .byte 3
endmystruct
BalPlatformAlignment: .res 1
Platform_X_Scroll: .res 1
HammerThrowingTimer:
PlatformCollisionFlag: .res 11
Player_Rel_XPos:
SprObject_Rel_XPos: .res 1
Enemy_Rel_XPos: .res 1
Fireball_Rel_XPos: .res 1
Bubble_Rel_XPos: .res 1
Block_Rel_XPos: .res 2
Misc_Rel_XPos: .res 5
SprObject_Rel_YPos:
Player_Rel_YPos: .res 1
Enemy_Rel_YPos: .res 1
Fireball_Rel_YPos: .res 1
Bubble_Rel_YPos: .res 1
Block_Rel_YPos: .res 2
Misc_Rel_YPos: .res 6
Player_SprAttrib:
SprObject_SprAttrib: .res 1
Enemy_SprAttrib: .res 11
SprObject_OffscrBits:
Player_OffscreenBits: .res 1
Enemy_OffscreenBits: .res 1
FBall_OffscreenBits: .res 1
Bubble_OffscreenBits: .res 1
Block_OffscreenBits: .res 2
Misc_OffscreenBits: .res 2
EnemyOffscrBitsMasked: .res 12
Block_Orig_YPos: .res 2
Block_BBuf_Low: .res 2
Block_Metatile: .res 2
Block_PageLoc2: .res 2
Block_RepFlag: .res 2
SprDataOffset_Ctrl: .res 2
Block_ResidualCounter: .res 1
Block_Orig_XPos: .res 8
AttributeBuffer: .res 7
SprObject_X_MoveForce: .res 1
Enemy_X_MoveForce:
YPlatformTopYPos:
RedPTroopaOrigXPos: .res 21
SprObject_YMoveForceFractional:
Player_YMoveForceFractional: .res 1
Enemy_YMoveForceFractional:
BowserFlamePRandomOfs:
PiranhaPlantUpYPos: .res 21
Bubble_YMoveForceFractional: .res 7
Player_Y_MoveForce:
SprObject_Y_MoveForce: .res 1
CheepCheepOrigYPos:
Enemy_Y_MoveForce:
PiranhaPlantDownYPos: .res 8
Block_Y_MoveForce: .res 20
MaximumLeftSpeed: .res 6
MaximumRightSpeed: .res 20
Whirlpool_Offset:
Cannon_Offset: .res 1
Whirlpool_PageLoc:
Cannon_PageLoc: .res 6
Cannon_X_Position:
Whirlpool_LeftExtent: .res 6
Whirlpool_Length:
Cannon_Y_Position: .res 6
Cannon_Timer:
Whirlpool_Flag: .res 6
BowserHitPoints: .res 1
StompChainCounter: .res 12
Player_CollisionBits: .res 1
Enemy_CollisionBits: .res 8
Player_BoundBoxCtrl:
SprObj_BoundBoxCtrl: .res 1
Enemy_BoundBoxCtrl: .res 6
Fireball_BoundBoxCtrl: .res 2
Misc_BoundBoxCtrl: .res 10
BoundingBox_UL_XPos:
BoundingBox_UL_Corner: .res 1
BoundingBox_UL_YPos: .res 1
BoundingBox_DR_XPos:
BoundingBox_LR_Corner: .res 1
BoundingBox_DR_YPos: .res 1
EnemyBoundingBoxCoord: .res 80
Block_Buffer_1: .res 208
Block_Buffer_2: .res 208
BlockBufferColumnPos: .res 1
MetatileBuffer: .res 13
HammerEnemyOffset: .res 9
JumpCoinMiscOffset: .res 5
BrickCoinTimerFlag: .res 2
Misc_Collision_Flag: .res 13
EnemyFrenzyBuffer: .res 1
SecondaryHardMode: .res 1
EnemyFrenzyQueue: .res 1
FireballCounter: .res 1
DuplicateObj_Offset: .res 2
LakituReappearTimer: .res 2
NumberofGroupEnemies: .res 1 ; only used in one subroutine , HandleGroupEnemies - sub could use a temp.
ColorRotateOffset: .res 1
PlayerGfxOffset: .res 1
WarpZoneControl: .res 1
FireworksCounter: .res 2
MultiLoopCorrectCntr: .res 1
MultiLoopPassCntr: .res 1
JumpspringForce: .res 1
MaxRangeFromOrigin: .res 1
BitMFilter: .res 1
ChangeAreaTimer: .res 2
SprShuffleAmtOffset: .res 1
SprShuffleAmt: .res 3
SprDataOffset:
Player_SprDataOffset: .res 1
Enemy_SprDataOffset: .res 7
Alt_SprDataOffset:
Block_SprDataOffset: .res 2
Bubble_SprDataOffset: .res 3
FBall_SprDataOffset: .res 2
Misc_SprDataOffset: .res 9
SavedJoypad1Bits:
SavedJoypadBits: .res 1
SavedJoypad2Bits: .res 2
Player_X_Scroll: .res 1
Player_XSpeedAbsolute: .res 1
FrictionAdderHigh: .res 1
FrictionAdderLow: .res 1
RunningSpeed: .res 1
SwimmingFlag: .res 1
Player_X_MoveForce: .res 1
DiffToHaltJump: .res 1
JumpOrigin_Y_HighPos: .res 1
JumpOrigin_Y_Position: .res 1
VerticalForce: .res 1
VerticalForceDown: .res 1
PlayerChangeSizeFlag: .res 1
PlayerAnimTimerSet: .res 1
PlayerAnimCtrl: .res 1
JumpspringAnimCtrl: .res 1
FlagpoleCollisionYPos: .res 1
PlayerEntranceCtrl: .res 1
FireballThrowingTimer: .res 1
DeathMusicLoaded: .res 1
FlagpoleSoundQueue: .res 1
CrouchingFlag: .res 1
GameTimerSetting: .res 1
DisableCollisionDet: .res 1
DemoAction: .res 1
DemoActionTimer: .res 1
PrimaryMsgCounter: .res 1
ScreenEdge_PageLoc:
ScreenLeft_PageLoc: .res 1
ScreenRight_PageLoc: .res 1
ScreenEdge_X_Pos:
ScreenLeft_X_Pos: .res 1
ScreenRight_X_Pos: .res 1
ColumnSets: .res 1
AreaParserTaskNum: .res 1
CurrentNTAddr_High: .res 1
CurrentNTAddr_Low: .res 1
Sprite0HitDetectFlag: .res 1
ScrollLock: .res 2
CurrentPageLoc: .res 1
CurrentColumnPos: .res 1
TerrainControl: .res 1
BackloadingFlag: .res 1
BehindAreaParserFlag: .res 1
AreaObjectPageLoc: .res 1
AreaObjectPageSel: .res 1
AreaDataOffset: .res 1
AreaObjOffsetBuffer: .res 3
AreaObjectLength: .res 3
AreaStyle: .res 1
StaircaseControl: .res 1
AreaObjectHeight: .res 1
MushroomLedgeHalfLen: .res 3
EnemyDataOffset: .res 1
EnemyObjectPageLoc: .res 1
EnemyObjectPageSel: .res 1
ScreenRoutineTask: .res 1
ScrollThirtyTwo: .res 2
HorizontalScroll: .res 1
VerticalScroll: .res 1
ForegroundScenery: .res 1
BackgroundScenery: .res 1
CloudTypeOverride: .res 1
BackgroundColorCtrl: .res 1
LoopCommand: .res 1
StarFlagTaskControl: .res 1
TimerControl: .res 1 ; 0747
CoinTallyFor1Ups: .res 1
SecondaryMsgCounter: .res 1
JoypadBitMask: .res 4 ; .proc InitializeArea clears the 1st two bytes here and leaves below here alone
AreaType: .res 1 ; 074e
; notes:
; AreaType:
; Water = 0
; Ground = 1
; UnderGround = 2
; Castle = 3
AreaAddrsLOffset: .res 1
AreaPointer: .res 1
EntrancePage: .res 1
AltEntranceControl: .res 1
CurrentPlayer: .res 1 ; 0 = mario, 1 = luigi
PlayerSize: .res 1 ; 1 = small, 0 = big
Player_Pos_ForScroll: .res 1
PlayerStatus: .res 1 ; 0 = small, 1 = super, 2 = firey
FetchNewGameTimerFlag: .res 1
JoypadOverride: .res 1
GameTimerExpiredFlag: .res 1
OnscreenPlayerInfo:
NumberofLives: .res 1
HalfwayPage: .res 1
LevelNumber: .res 1
Hidden1UpFlag: .res 1
CoinTally: .res 1
WorldNumber: .res 1
AreaNumber: .res 1
OffscreenPlayerInfo:
OffScr_NumberofLives: .res 1
OffScr_HalfwayPage: .res 1
OffScr_LevelNumber: .res 1
OffScr_Hidden1UpFlag: .res 1
OffScr_CoinTally: .res 1
OffScr_WorldNumber: .res 1
OffScr_AreaNumber: .res 1
ScrollFractional: .res 1
DisableIntermediate: .res 1
PrimaryHardMode: .res 1
WorldSelectNumber: .res 5
; $0770: .proc InitializeGame leaves ram below here alone ( y = $6f )
OperMode: .res 2
OperMode_Task: .res 1
VRAM_Buffer_AddrCtrl: .res 1
DisableScreenFlag: .res 1
ScrollAmount: .res 1
GamePauseStatus: .res 1
GamePauseTimer: .res 1
Mirror_PPU_CTRL: .res 1
Mirror_PPU_MASK: .res 1
NumberOfPlayers: .res 5
IntervalTimerControl: .res 1
Timers:
SelectTimer: .res 1
PlayerAnimTimer: .res 1
JumpSwimTimer: .res 1
RunningTimer: .res 1
BlockBounceTimer: .res 1
SideCollisionTimer: .res 1
JumpspringTimer: .res 1
GameTimerCtrlTimer: .res 2
ClimbSideTimer: .res 1
EnemyFrameTimer: .res 5
FrenzyEnemyTimer: .res 1
BowserFireBreathTimer: .res 1
StompTimer: .res 1
AirBubbleTimer: .res 3 ; 20 bytes away from Timer
ScrollIntervalTimer: .res 1
EnemyIntervalTimer: .res 7
BrickCoinTimer: .res 1
InjuryTimer: .res 1
StarInvincibleTimer: .res 1
ScreenTimer: .res 1
WorldEndTimer: .res 1
DemoTimer: .res 5
PseudoRandomBitReg: .res 9
SoundMemory:
MusicOffset_Noise: .res 1
EventMusicBuffer: .res 1
PauseSoundBuffer: .res 1
Squ2_NoteLenBuffer: .res 1
Squ2_NoteLenCounter: .res 1
Squ2_EnvelopeDataCtrl: .res 1
Squ1_NoteLenCounter: .res 1
Squ1_EnvelopeDataCtrl: .res 1
Tri_NoteLenBuffer: .res 1
Tri_NoteLenCounter: .res 1
Noise_BeatLenCounter: .res 1
Squ1_SfxLenCounter: .res 2
Squ2_SfxLenCounter: .res 1
Sfx_SecondaryCounter: .res 1
Noise_SfxLenCounter: .res 1
DAC_Counter: .res 1
NoiseDataLoopbackOfs: .res 3
NoteLengthTblAdder: .res 1
AreaMusicBuffer_Alt: .res 1
PauseModeFlag: .res 1
GroundMusicHeaderOfs: .res 3
AltRegContentFlag: .res 12
_WarmBootOffset: .res 1 ; Warm boot offset
TopScoreDisplay: ; : $07D7
DisplayDigits: .res 6
PlayerScoreDisplay:
ScoreAndCoinDisplay: .res 27
GameTimerDisplay: .res 4
WorldSelectEnableFlag: .res 1
ContinueWorld: .res 1
_ColdBootOffset: .res 1 ; Cold boot offset, here and higher get nuked
WarmBootValidation: .res 1

37
src/nes.cfg Normal file
View file

@ -0,0 +1,37 @@
MEMORY
{
ZP: start = $0, size = $100, type = rw;
HEADER: start = 0, size = $0010, type = ro, file = %O, fill=yes, fillval=$00;
STACK: start = $0100, size = $0100, type = rw;
OAMRAM: start = $0200, size = $0100, type = rw;
RAM: start = $0300, size = $0500, type = rw;
ROM: start = $8000, size = $8000, type = ro, file = %O, fill=yes, fillval=$00;
CHR: start = $0, size = $2000, type = ro, file = %O, fill=yes, fillval=$00;
NDXDEBUG:
start = 0,
# 256 MB should be enough for everybody.
size = $10000000,
type = ro,
file = "smb.nes.ndx";
}
SEGMENTS {
INESHDR: load = HEADER, type = ro;
ZEROPAGE: load = ZP, type = zp;
STACK: load = STACK, type = bss, define = yes, optional = yes;
OAMRAM: load = OAMRAM, type = bss, define = yes, optional = yes;
BSS: load = RAM, type = bss, define = yes;
CODE: load = ROM, type = ro;
RODATA: load = ROM, type = ro;
VECTORS: load = ROM, type = ro, start = $FFFA;
CHRROM: load = CHR, type = ro;
NDXDEBUG:
load = NDXDEBUG,
type = ro,
optional = yes;
}
FILES {
%O: format = bin;
}

149
src/nes_constants.h Normal file
View file

@ -0,0 +1,149 @@
; ******************************************************************************
; * ca65 NES_CONSTANTS.H
.ifndef _NES_CONSTANTS_H
_NES_CONSTANTS_H = 1
; General NES constant values
PPU_CTRL = $2000
PPU_MASK = $2001
PPU_STATUS = $2002
PPU_ADDRESS = $2006
PPU_DATA = $2007
OAM_ADDRESS = $2003
OAM_DATA = $2004
OAM_DMA = $4014
PPU_SCROLL = $2005
; ******************************************************************************
; * FLAGS/MASKS
; ******************************************************************************/
; For ppu_ctrl
CT_NMI = %10000000
CT_PPUSLAVE = %01000000
CT_SPRITE8x16 = %00100000
CT_BACKADDR1000 = %00010000
CT_SPRADDR1000 = %00001000
CT_ADDRINC32 = %00000100
CT_NAMETABLE2000 = %00000000
CT_NAMETABLE2400 = %00000001
CT_NAMETABLE2800 = %00000010
CT_NAMETABLE2C00 = %00000011
; For ppu_mask
MA_PALETTE_BLUE = %10000000
MA_PALETTE_GREEN = %01000000
MA_PALETTE_RED = %00100000
MA_SPRITESVISIBLE = %00010000
MA_BACKVISIBLE = %00001000
MA_SPRNOCLIP = %00000100
MA_BACKNOCLIP = %00000010
MA_MONOCHROME = %00000001
; status flags ppu_status
ST_VBLANK = %10000000
ST_SPRITE0 = %01000000
ST_SCANSPROVERFLOW = %00100000
ST_VRAM_NOWRITE = %00010000
; sprites
OAM_TOTAL = 64
OAM_SIZE = (4*OAM_TOTAL)
; palette
PAL_ADDRESS = $3F00
PAL_0_ADDRESS = $3F00
PAL_1_ADDRESS = $3F04
PAL_2_ADDRESS = $3F08
PAL_3_ADDRESS = $3F0C
PAL_0_SPR_ADDRESS = $3F10
PAL_1_SPR_ADDRESS = $3F14
PAL_2_SPR_ADDRESS = $3F18
PAL_3_SPR_ADDRESS = $3F1C
PAL_0 = $3F00
PAL_1 = $3F04
PAL_2 = $3F08
PAL_3 = $3F0C
PAL_4 = $3F10
PAL_5 = $3F14
PAL_6 = $3F18
PAL_7 = $3F1C
; $3F01-$3F03 Background palette 0
; $3F05-$3F07 Background palette 1
; $3F09-$3F0B Background palette 2
; $3F0D-$3F0F Background palette 3
; $3F11-$3F13 Sprite palette 0
; $3F15-$3F17 Sprite palette 1
; $3F19-$3F1B Sprite palette 2
; $3F1D-$3F1F Sprite palette 3
; CHR
PATTERN_TABLE_0_ADDRESS = $0000
PATTERN_TABLE_1_ADDRESS = $1000
; NAME TABLE
NAMETABLE_WIDTH = 32
NAMETABLE_HEIGHT = 30
SCREEN_WIDTH = 256
SCREEN_HEIGHT = 240
NAME_TABLE_0_ADDRESS = $2000
NAME_TABLE_SIZE = $03C0
ATTRIBUTE_TABLE_0_ADDRESS = $23C0
ATTRIBUTE_TABLE_SIZE = $0040
NAME_TABLE_1_ADDRESS = $2400
ATTRIBUTE_TABLE_1_ADDRESS = $27C0
NAME_TABLE_2_ADDRESS = $2800
ATTRIBUTE_TABLE_2_ADDRESS = $2BC0
NAME_TABLE_3_ADDRESS = $2C00
ATTRIBUTE_TABLE_3_ADDRESS = $2FC0
; **********************************************************************
; Joystick
; **********************************************************************
PAD0 = $4016
PAD1 = $4017
JOYPAD_PORT = $4016
JOYPAD_PORT2 = $4017
; joypad masks
BUTTON_A = %10000000
BUTTON_B = %01000000
BUTTON_SELECT = %00100000
BUTTON_START = %00010000
BUTTON_UP = %00001000
BUTTON_DOWN = %00000100
BUTTON_LEFT = %00000010
BUTTON_RIGHT = %00000001
; **********************************************************************
; Sound
; **********************************************************************
SND_REGISTER = $4000
SND_SQUARE1_REG = $4000
SND_SQUARE2_REG = $4004
SND_TRIANGLE_REG = $4008
SND_NOISE_REG = $400c
SND_DELTA_REG = $4010
SND_MASTERCTRL_REG = $4015
.endif

67
src/smbdis.h Normal file
View file

@ -0,0 +1,67 @@
;
; This file contains macros designed to be used as a part of the
; smb HL disassembly.
;
; ----------------------------------------------------------------------------
; change to USEDATASEG = 1 to move data blocks to their own segment, rather than mixed with code
; ( leave 0 to match original ROM )
USEDATASEG = 0
; ----------------------------------------------------------------------------
.autoimport + ; don't declare symbols to be imported
.linecont + ; allow a '\' to indicate the line is to be continued.
; ----------------------------------------------------------------------------
; macro vram_string:
; ( xx, yy ) = (x,y) location on screen, str = string to display
; This macro will convert the parameters into data acceptable to smb's
; vram writing routine.
; This works, but wasn't implemented except for a couple tests
.macro vram_string xx,yy,str
.byte >($2000 + (yy * $20 + xx)), <($2000 + (yy * $20 + xx)), .strlen(str), str
.endmacro
; ----------------------------------------------------------------------------
; mark a block as data ( SEE USEDATASEG above )
.macro dataseg
.if ::USEDATASEG
.segment "RODATA"
.endif
.endmacro
; ----------------------------------------------------------------------------
; output a bit opcode byte
.macro BIT_Skip2
.byte $2c
.endmacro
; ----------------------------------------------------------------------------
; call this macro once to setup character set encoding used by smb
.macro customchars
.define CHARS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
.repeat .strlen(CHARS), I
.charmap .strat(CHARS, I), I
.endrepeat
.undefine CHARS
.charmap '-', $28
.charmap 'x', $29
.charmap '!', $2b
.charmap ' ', $24
.charmap '.', $af
.endmacro

17555
src/smbdishl.s Normal file

File diff suppressed because it is too large Load diff