Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rickychann7 committed Nov 30, 2024
0 parents commit 4c4e528
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.smc
*.sfc

asar.exe
26 changes: 26 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import os
import sys
import shutil
from subprocess import call

c = call

original = "smw.sfc"
out_dir = "patched"
out_file = "smw_segment.sfc"


def main():
if os.path.exists(out_dir):
shutil.rmtree(out_dir)
print("Cleaning output directory.")
os.mkdir(out_dir)
shutil.copy(original, out_dir + "/" + out_file)
c("asar src/main.asm patched/smw_segment.sfc".split())
print("Assembling finished.")


main()
sys.exit()
37 changes: 37 additions & 0 deletions src/data/overworld_table.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
include

overworld_submap_table:
db $01 ; yoshi's island
db $00 ; donut plains
db $02 ; vanila dome
db $00 ; cheese bridge
db $06 ; star world
db $05 ; special
db $01 ; yoshi island (post special)
db $03 ; forest of illusion
db $00 ; chocolate island
db $00 ; sunken ghost ship

overworld_pos_x_table:
dw $0068
dw $0058
dw $0058
dw $0118
dw $0178
dw $0118
dw $0068
dw $0088
dw $0188
dw $00E8

overworld_pos_y_table:
dw $0278
dw $0118
dw $0328
dw $0078
dw $0368
dw $0338
dw $0278
dw $0378
dw $0168
dw $0178
29 changes: 29 additions & 0 deletions src/defines.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include

; controller
!mario_byetudlr_hold = $0015
!mario_byetudlr_frame = $0016
!mario_axlr_hold = $0017
!mario_axlr_frame = $0018
!util_byetudlr_hold = $0DA2
!util_byetudlr_frame = $0DA6
!util_axlr_hold = $0DA4
!util_axlr_frame = $0DA8

; stripe image
!stripe_index = $7F837B
!stripe_image = $7F837D

; overworld
!submap_id = $13C3
!overworld_pos_x = $1F17
!overworld_pos_y = $1F19

; freeram
!freeram = $0695 ; cleared on reset and titlescreen load

; test
!test_gm0e = !freeram

; overworld warp
!warp_index = !freeram+1
5 changes: 5 additions & 0 deletions src/hijacks.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include

; overworld
org $00A165
jsl gamemode_0e_hijack
10 changes: 10 additions & 0 deletions src/main.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; internal ROM name
org $00FFC0
db "SMW SEGMENT "

incsrc "defines.asm"
incsrc "hijacks.asm"
incsrc "overworld.asm" ; $108000

org $1FFFFF
db $EA
48 changes: 48 additions & 0 deletions src/overworld.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
include

org $108000
gamemode_0e_hijack:
jsl $048241
; jsr test_gm0e
jsr test_warp
rtl

test_gm0e:
inc !test_gm0e
rts

test_warp:
lda !util_byetudlr_hold
and #%00110000
cmp #%00110000
beq update_player_position
rts

update_player_position:
ldx !warp_index
lda.l overworld_submap_table,x
sta !submap_id
sta $1f11
rep #$20
txa
asl
tax
lda.l overworld_pos_x_table,x
and #$01FF
sta !overworld_pos_x
lsr #4
sta $1F1F
lda.l overworld_pos_y_table,x
and #$01FF
sta !overworld_pos_y
lsr #4
sta $1F21
sep #$20
stz $0DD5
lda #$0B
sta $0100
rts

incsrc "data/overworld_table.asm"

print "[src/overworld.asm]: ", pc, "/109000 inserted"

0 comments on commit 4c4e528

Please sign in to comment.