Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ SRC/gfx/titleCredits/*.chr
SRC/maps/bank_*
SRC/maps/doors.asm
SRC/maps/enemyData.asm
SRC/tilesets/*.chr
SRC/tilesets/*.chr
SRC/tilesets/*_collision.asm
SRC/tilesets/*_metatiles.asm
51 changes: 46 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# Constants
ENEMY_SCRIPT_OUT = $(foreach f,\
spritePointers \
headerPointers \
hitboxPointers \
damageValues \
nameConstants,\
SRC/data/enemy_$(f).asm)

SAMUS_SCRIPT_OUT = $(foreach f,\
bgHitboxTop \
blockReformHeightTable \
bombedFallingPoseTransitionTable \
bombPoseTransitionTable \
cannonYOffsetByPose \
damagePoseTransitionTable \
drawJumpTable \
horizontalYOffsets \
poseConstants \
poseJumpTable \
possibleShotDirections \
spriteHitboxTopTable,\
SRC/samus/samus_$(f).asm)

GENERAL_SCRIPT_OUT = $(foreach f,\
sprites_credits,\
SRC/data/$(f)Pointers.asm SRC/data/$(f)Constants.asm)

ALL_CODE = $(shell find SRC/ -type f \( -iname '*.asm' -o -iname '*.chr' \))

# Targets
all: out/M2RoS.gb

#%.2bpp: %.png
Expand All @@ -6,18 +37,28 @@ all: out/M2RoS.gb
#%.1bpp: %.png
# rgbgfx -d 1 -o $@ $<

out/game.o: SRC/game.asm SRC/bank_*.asm out
rgbasm -L -o out/game.o -i SRC/ SRC/game.asm
$(ENEMY_SCRIPT_OUT): SRC/data/enemies.csv
python scripts/enemy_csv2asm.py -i $< -o SRC/data

$(SAMUS_SCRIPT_OUT): SRC/samus/samus.csv
python scripts/samus_csv2asm.py -i $< -o SRC/samus

$(GENERAL_SCRIPT_OUT): SRC/data/sprites_credits.csv
python scripts/general_csv2asm.py -i $< -o SRC/data -n sprites_credits

out/game.o: SRC/game.asm out $(ENEMY_SCRIPT_OUT) $(SAMUS_SCRIPT_OUT) $(GENERAL_SCRIPT_OUT) $(ALL_CODE)
rgbasm -o $@ -Weverything -I SRC/ $<

out/M2RoS.gb: out/game.o out
out/M2RoS.gb: out/game.o
rgblink -n out/M2RoS.sym -m out/M2RoS.map -o $@ $<
#rgbfix -v -p 255 $@ #Nope
rgbfix -v $@

md5sum $@
diff --brief $@ Metroid2.gb

out:
mkdir $@

clean:
# rm -f game.o game.gb game.sym game.map
rm -f out/game.o out/M2RoS.gb out/M2RoS.sym out/M2RoS.map $(ENEMY_SCRIPT_OUT) $(SAMUS_SCRIPT_OUT) $(GENERAL_SCRIPT_OUT)
# find . \( -iname '*.1bpp' -o -iname '*.2bpp' \) -exec rm {} +
47 changes: 26 additions & 21 deletions SRC/bank_000.asm
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ mainGameLoop: ;{ 00:02CD
ld a, [doorScrollDirection]
and a
call z, main_readInput
; Do imporatant stuff
; Do important stuff
call main_handleGameMode
call handleAudio_longJump
call executeDoorScript
ldh a, [hInputPressed]
; Soft reset
ldh a, [hInputPressed]
and PADF_START | PADF_SELECT | PADF_B | PADF_A ;$0f
cp PADF_START | PADF_SELECT | PADF_B | PADF_A
jp z, bootRoutine
Expand All @@ -347,7 +347,7 @@ jp mainGameLoop

main_handleGameMode: ;{ 0:02F0
ldh a, [gameMode]
rst $28
rst LOW(RST_28)
dw gameMode_Boot ; $00
dw gameMode_Title ; $01
dw gameMode_LoadA ; $02 Setup for playing the game
Expand Down Expand Up @@ -375,7 +375,7 @@ gameMode_None: ; 00:031B

; Called when frame is done
waitForNextFrame: ;{ 00:031C
db $76 ; HALT
halt

.vBlankNotDone:
ldh a, [hVBlankDoneFlag]
Expand Down Expand Up @@ -416,7 +416,7 @@ waitForNextFrame: ;{ 00:031C
daa
ld [gameTimeHours], a
jr nz, .endIf
; Clamp to max IGT (59:99)
; Clamp to max IGT (99:59)
ld a, $59
ld [gameTimeMinutes], a
ld a, $99
Expand Down Expand Up @@ -920,7 +920,7 @@ prepMapUpdate: ;{ 00:0698
ret ; Should never end up here

.up: ; Up
; If if not scrolling up
; Exit if not scrolling up
ld a, [camera_scrollDirection]
bit scrollDirBit_up, a
ret z
Expand Down Expand Up @@ -950,7 +950,7 @@ ret ; Should never end up here
jp .row

.down: ; Down
; If if not scrolling down
; Exit if not scrolling down
ld a, [camera_scrollDirection]
bit scrollDirBit_down, a
ret z
Expand Down Expand Up @@ -979,7 +979,7 @@ jp .row
jr .row

.left: ; Left
; If if not scrolling left
; Exit if not scrolling left
ld a, [camera_scrollDirection]
bit scrollDirBit_left, a
ret z
Expand Down Expand Up @@ -1008,7 +1008,7 @@ jr .row
jp .column

.right: ; Right
; If if not scrolling right
; Exit if not scrolling right
ld a, [camera_scrollDirection]
bit scrollDirBit_right, a
ret z
Expand Down Expand Up @@ -1718,7 +1718,7 @@ handleCamera: ;{ 00:08FE
ret
;}

.unusedTable ; 00:0B39 - Unreferenced data of unknown purpose
.unusedTable: ; 00:0B39 - Unreferenced data of unknown purpose
db $00, $01, $01, $00, $00, $00, $01, $02, $02, $01, $01

; Already in a door transition?
Expand Down Expand Up @@ -1951,7 +1951,7 @@ loadDoorIndex: ;{ 00:0C37
ld a, [debugFlag]
and a
ret z
; Check if either A and Start are pressed
; Check if B + Select is pressed
ldh a, [hInputPressed]
and PADF_START | PADF_SELECT | PADF_B | PADF_A ;$0f
cp PADF_SELECT | PADF_B ;$06
Expand Down Expand Up @@ -2058,7 +2058,7 @@ samus_handlePose: ;{ 00:0D21
jp nz, handleTurnaroundTimer
; Take the jump table
ld a, [samusPose]
rst $28
rst LOW(RST_28)
; Table Generated from samus/samus.csv
include "samus/samus_poseJumpTable.asm"
;}
Expand Down Expand Up @@ -3199,6 +3199,7 @@ poseFunc_standing: ;{ 00:13B7 - $00: Standing
and PADF_LEFT | PADF_RIGHT ;$30
jr z, .endIf_B
; This check makes it so you can't spin-jump from a standstill without Space Jump. Very strange.
; It doesn't do much, because almost all spin-jumps are done from at least one frame of running.
ld a, [samusItems]
bit itemBit_space, a
jp z, .normalJump
Expand Down Expand Up @@ -4187,7 +4188,7 @@ poseFunc_spinJump: ;{ 00:18E8 - $02: Spin jumping
jr z, .endIf_L
ld a, sfx_square1_standingTransition
ld [sfxRequest_square1], a
.endIf_L
.endIf_L:

.startFalling:
; Why write to rom?
Expand Down Expand Up @@ -5426,7 +5427,7 @@ samus_getTileIndex: ;{ 00:1FF5
add h
ld h, a
ld [pTilemapDestHigh], a
.endIf_A
.endIf_A:

; Wait for HBlank and read once
.waitLoop_A:
Expand Down Expand Up @@ -5640,7 +5641,7 @@ getTileIndex: ;{ 00:2250 - Called by enemy routines
add h
ld h, a
ld [pTilemapDestHigh], a
.endIf
.endIf:

; Wait for HBlank and read once
.waitLoop_A:
Expand Down Expand Up @@ -5736,6 +5737,7 @@ ret ;}
; Function is unused
getTilemapCoordinates: ;{ 00:22E1
; DE = pTilemapDest
; format is %100110YY YYYXXXXX
ld a, [pTilemapDestHigh]
ld d, a
ld a, [pTilemapDestLow]
Expand All @@ -5748,24 +5750,27 @@ getTilemapCoordinates: ;{ 00:22E1
rr e
dec b
jr nz, .loop
; now E is %10YYYYYX
ld a, e
; The $8x part seems to adjust for the $9800 base address
; The $8x part adjusts for the $9800 base address
; The $x4 seems to adjust for 2 rows of tiles
sub $84
; Mask out lowest bit
; Mask out lowest bit containing X pos MSB
and $fe
; A*4 + 8
; now A is %00YYYYY0 - 4
; tileY = A*4 + 8 = (%00YYYYY0 - 4)*4 + 8 = %YYYYY000 - 8
; this is wrong, it should be %YYYYY000 + OAM_Y_OFS
rlca
rlca
add $08
ld [tileY], a
; X = (low mod 32)*8 +
; tileX = (low mod 32)*8 + OAM_X_OFS
ld a, [pTilemapDestLow]
and $1f
rla
rla
rla
add $08
add OAM_X_OFS
ld [tileX], a
ret ;}

Expand Down Expand Up @@ -9631,7 +9636,7 @@ handleItemPickup: ;{ 00:372F
; Jump to pick-up specific routine
ld a, b
dec a
rst $28
rst LOW(RST_28)
dw pickup_plasmaBeam
dw pickup_iceBeam
dw pickup_waveBeam
Expand Down
6 changes: 3 additions & 3 deletions SRC/bank_001.asm
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ drawSamus: ;{ 01:4BD9 Draw Samus
ret z
.endIf_B:

.ignoreDamageFrames ; 01:4BF3 - Entry point 2
.ignoreDamageFrames: ; 01:4BF3 - Entry point 2
ld a, [samusPose]
bit 7, a
jp nz, drawSamus_faceScreen
Expand Down Expand Up @@ -613,7 +613,7 @@ drawSamus: ;{ 01:4BD9 Draw Samus

; Jump to the appropriate draw routine
ld a, [samusPose]
rst $28
rst LOW(RST_28)
; Table Generated from samus/samus.csv
include "samus/samus_drawJumpTable.asm"
;}
Expand Down Expand Up @@ -1311,7 +1311,7 @@ getFirstEmptyProjectileSlot: ;{ 01:4FEE
ld a, (projectileArray.slotC >> 4) & $0F ;$02
swap a
ld l, a
.endIf
.endIf:

; Loop to find first open slot
.loop:
Expand Down
6 changes: 3 additions & 3 deletions SRC/bank_002.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,7 @@ ret
; Arachnus / Arachnus Orb
enAI_arachnus: ;{ 02:5109
ldh a, [hEnemy.generalVar]
rst $28
rst LOW(RST_28)
dw .state_0 ; Init and start fight
dw .state_1 ; Initial bouncing for the intro
dw .state_2 ; An additional small bounce for the intro
Expand Down Expand Up @@ -5328,7 +5328,7 @@ enAI_pipeBug: ;{ 02:5F67

; Set sprite type depending on current sprite type
ldh a, [hEnemy.spriteType]
cp SPRITE_YUMEE_SPAWNER ; $3C
cp SPRITE_YUMEE_SPAWNER_1 ; $3C
jr nc, .else_B
ld a, SPRITE_GAWRON_1 ; $17 ; Gawron
jr .endIf_B
Expand Down Expand Up @@ -11241,4 +11241,4 @@ enemy_toggleVisibility: ;{ 02:7DF8
ret
;}

bank2_freespace: ; 02:7E05 - Freespace
bank2_freespace: ; 02:7E05 - Freespace
Loading