Skip to content

Commit

Permalink
Properly fix MMC1 Automap for Animation (thanks to minucce)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowOne333 committed Sep 7, 2021
1 parent b804ae0 commit 2fae5af
Show file tree
Hide file tree
Showing 18 changed files with 476 additions and 188 deletions.
6 changes: 3 additions & 3 deletions MMC1/code/animation/animate.asm
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ define MMC1_CONTROL $8000
define MMC1_CHR_BANK_0 $A000
define MMC1_CHR_BANK_1 $C000

define kMmc1ControlMirroringV %0000010
define kMmc1ControlMirroringH %0000011
define kMmc1ControlMirroringV %0000010
define kMmc1ControlMirroringH %0000011
define kMmc1ControlPrgC000Fixed %0001100
define kMmc1Control4KbChr %0010000
define kMmc1Control4KbChr %0010000

// This should be a power of 2. Additional banks will have to be added to the dAnimatedGraphicsBank tables.
define kNumAnimationBanks 4
Expand Down
53 changes: 53 additions & 0 deletions MMC1/code/bugfixes/overworld_hud_blink.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Source:
// minucce
//
// License:
// Code should be used only for educational, documentation and modding purposes.
// Please keep derivative work open source.


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

bank 5;
org $AAB4 // 0x16AC4
jsr hud_loading_blink
nop

// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

org $AF40 // 0x16F50+$2C

//
// Turn on BG display during VBlank; Disable after HUD scanline
//

hud_loading_blink:
inc.b $06

lda.b $06
cmp.b #$10 // Done loading
beq .exit
and.b #$03 // Redraw every 4 frames
bne .exit


lda.b $12 // Verify overworld transition
cmp.b #$0A
beq +
cmp.b #$0B
bne .exit
+;
-;
lda.w $2002 // Wait pre-render scanline -1
asl
bmi -

lda.b #$1E // Enable drawing
sta.w $2001

jsr $8521 // Draw HUD

.exit:
lda.b $06
rts
36 changes: 36 additions & 0 deletions MMC1/code/bugfixes/overworld_leave_cave.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Source:
// minucce
//
// License:
// Code should be used only for educational, documentation and modding purposes.
// Please keep derivative work open source.


//
// Reset sprite position on entering overworld from caves
//


bank 5; org $14F5D // 0x14F6D
jsr hide_sprite
nop

// #####################################################

org $14F61 // 0x14F71
stx.b $00
jsr $F184 // Reset vars
ldx.b $00

rts

org $8F69; hide_sprite: // $14F69, 0x14F79
lda.b #$0A // Transition out of cave
sta.b $12

lda.b #$F8 // Hide sprite
sta.b $84

nop
rts // org $14F72, 0x14F82
40 changes: 40 additions & 0 deletions MMC1/code/bugfixes/overworld_scroll_timing.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Source:
// minucce
//
// License:
// Code should be used only for educational, documentation and modding purposes.
// Please keep derivative work open source.


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

bank 5; org $1454E // 0x1455E

// Reset Y-scroll value with more precision
ldy.b #$5E+2

-; nop // Manual timing
dey
bpl -

nop
nop
nop
nop
nop
nop

lda.w $2002 // Reset latch

lda.b $58 // Render-Y2
ldy.b $E2 // Render-Y1

// Credit to Quietust (nesdev) for explaining PPU Addr register scrolling

sta.w $2006
lda.b #$00

sty.w $2006 // Render location (must be h-blank)
sta.w $2005 // Fine X-pos
rts
24 changes: 13 additions & 11 deletions MMC1/code/gameplay/automap.asm
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ bank 5; org $AD00 // 0x16D10-0x16F0C
// HUD Icons
// ———————————————
define INFINITY $64
define RUPEE $F7
define RUPEE $F7
//define ARROW $65
define KEY $F9
define BOMB $61
define KEY $F9
define BOMB $61
//define LOW_X $62

// Game variables
// ———————————————
define LevelNumber $10
define SaveSlot $16
define LevelNumber $10
define RoutineIndex $13
define PendingPpuMacro $14
define SaveSlot $16
define CurrentMapLocation $EB
define NewMapLocation $EC
define OAM_MapBlipY $0254
define NewMapLocation $EC
define OAM_MapBlipY $0254

// Game routines
// ———————————————
Expand All @@ -54,12 +55,12 @@ define VRAM_MapTiles $1300

// Our variables
// ———————————————
define tileFlag $6C30 // Used to indicate that there is a pending PPU macro for the map. Changed from $6C00 -> $6C30 to fix a bug of Dungeon palettes being overwritten with $00. $6C1B, $6C1F, $6C23, $6C24, $6C27, $6C28, $6C2C, $6C2D, $6C30 and $6C31 could all be theoretically used as well.
define tileFlag $0628 // Used to indicate that there is a pending PPU macro for the map. Changed from $6C00 -> $0628 to fix a bug of Dungeon palettes being overwritten with $00. ($6C30, $6CB4)
define mapVar {tileFlag}+1 // Temporary storage variable
define mapVar_X {tileFlag}+2
define mapVar_Y {tileFlag}+3
define mapLoop_X {tileFlag}+4
define mapLoop_Y {tileFlag}+5
define mapLoop_Y $0673 // {tileFlag}+5

define SecondPpuStringIndex $7F10
define MapBits_Left {SecondPpuStringIndex}+1 // Stores flags for whether the two screens in the left/right side
Expand Down Expand Up @@ -296,7 +297,7 @@ NewHudMacroSelector:
sta.b {PendingPpuMacro} // Store at PendingPpuMacro RAM address

l_AF2E: // 0x16F3E
inc.b $13 // Increment value at RAM $13
inc.b {RoutineIndex} // Increment value at RAM $13
rts


Expand Down Expand Up @@ -767,7 +768,7 @@ PartialHeartRoutine: // 0x17F3E, $BF2E
org $BFC0 // 0x17FD0, $BFC0
// This draws the map on all the banks
DrawMapAllBanks:
lda.b #$00
lda.b #$01 // Make the drawing being in bank 1 instead of bank 0 for sprites (by minucce)
sta.w $7FF0
DrawMapLoop:
jsr SetChrBank
Expand Down Expand Up @@ -1011,3 +1012,4 @@ l_A0EA:
lda.b ($00),y
bpl l_A0A2
rts

2 changes: 1 addition & 1 deletion MMC1/code/gameplay/overworld_screens.asm
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ l_17C69: // $E0-$EF
db $DB,$5B,$1B,$34,$4E,$32 // $E7
db $DB,$4E,$4E,$4E,$0E,$33,$1B // $E8

fillto $BDF0,$FF
fillto $BDE0,$FF // Must change back to $BDF0!

// Change address of the whole $F0-$FF entries to get the extra space required for the last new columns
org $AF80 // 0x16F90
Expand Down
10 changes: 9 additions & 1 deletion MMC1/code/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ incsrc code/menus/file_select.asm // Modifications to the File Select menus
incsrc code/menus/hud_and_subscreen.asm // Changes to both the HUD and the Subscreen


//****************************************
// Bugfixes
//****************************************
incsrc code/bugfixes/overworld_hud_blink.asm // Stops HUD from disappearing when entering or leaving caves during overworld map
incsrc code/bugfixes/overworld_scroll_timing.asm // Fix for Y-scroll timing glitch
incsrc code/bugfixes/overworld_leave_cave.asm // Fix wrong player sprite position on entering overworld from caves


//****************************************
// Text changes
//****************************************
Expand All @@ -57,6 +65,7 @@ incsrc code/text/story.asm // Rewrite of the game's story and intro texts
incsrc code/text/credits.asm // Rewrite of the game's credits sequences
incsrc code/text/text_speed.asm // Modify text parsing speed


//****************************************
// Gameplay changes
//****************************************
Expand Down Expand Up @@ -84,4 +93,3 @@ incsrc code/gameplay/move_maps.asm // Change Hearts and Map positions in HUD (IN
incsrc code/optional.asm



Binary file modified MMC1/patches/Zelda1_Redux.ips
Binary file not shown.
5 changes: 2 additions & 3 deletions MMC5/code/MMC5.asm
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ bank 7; org $C000 // 0x1C010
//--------------------------------------------------------------
// Bank 8, $20000
//--------------------------------------------------------------
bank 8; org $20000 // 0x20010
incbin code/gfx/NewCHR.bin
//bank 8; org $20000 // 0x20010
// incbin code/gfx/NewCHR.bin

//--------------------------------------------------------------
// Notes
Expand Down Expand Up @@ -501,4 +501,3 @@ bank 7; org $C000 // 0x1C010
//Clear out old routines
fillto $FFAC,$FF


53 changes: 53 additions & 0 deletions MMC5/code/bugfixes/overworld_hud_blink.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Source:
// minucce
//
// License:
// Code should be used only for educational, documentation and modding purposes.
// Please keep derivative work open source.


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

bank 5;
org $AAB4 // 0x16AC4
jsr hud_loading_blink
nop

// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

org $AF40 // 0x16F50+$2C

//
// Turn on BG display during VBlank; Disable after HUD scanline
//

hud_loading_blink:
inc.b $06

lda.b $06
cmp.b #$10 // Done loading
beq .exit
and.b #$03 // Redraw every 4 frames
bne .exit


lda.b $12 // Verify overworld transition
cmp.b #$0A
beq +
cmp.b #$0B
bne .exit
+;
-;
lda.w $2002 // Wait pre-render scanline -1
asl
bmi -

lda.b #$1E // Enable drawing
sta.w $2001

jsr $8521 // Draw HUD

.exit:
lda.b $06
rts
36 changes: 36 additions & 0 deletions MMC5/code/bugfixes/overworld_leave_cave.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Source:
// minucce
//
// License:
// Code should be used only for educational, documentation and modding purposes.
// Please keep derivative work open source.


//
// Reset sprite position on entering overworld from caves
//


bank 5; org $14F5D // 0x14F6D
jsr hide_sprite
nop

// #####################################################

org $14F61 // 0x14F71
stx.b $00
jsr $F184 // Reset vars
ldx.b $00

rts

org $8F69; hide_sprite: // $14F69, 0x14F79
lda.b #$0A // Transition out of cave
sta.b $12

lda.b #$F8 // Hide sprite
sta.b $84

nop
rts // org $14F72, 0x14F82
40 changes: 40 additions & 0 deletions MMC5/code/bugfixes/overworld_scroll_timing.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Source:
// minucce
//
// License:
// Code should be used only for educational, documentation and modding purposes.
// Please keep derivative work open source.


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

bank 5; org $1454E // 0x1455E

// Reset Y-scroll value with more precision
ldy.b #$5E+2

-; nop // Manual timing
dey
bpl -

nop
nop
nop
nop
nop
nop

lda.w $2002 // Reset latch

lda.b $58 // Render-Y2
ldy.b $E2 // Render-Y1

// Credit to Quietust (nesdev) for explaining PPU Addr register scrolling

sta.w $2006
lda.b #$00

sty.w $2006 // Render location (must be h-blank)
sta.w $2005 // Fine X-pos
rts
Loading

0 comments on commit 2fae5af

Please sign in to comment.