Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changing 'redefinable symbols' to constants
This shuts up all those warnings in error.txt, and overall makes the
code safer (double-definitions are now flagged as errors, and
commonly-redefined symbols like origY are forced to be
explicitly-named).

Personally, I'd prefer if all those bla_origX things were made into
local labels, but that would require the object's internal labels be
made local, too, and that would require quite a bit of work.
  • Loading branch information
Clownacy committed Apr 19, 2016
1 parent 39fc256 commit ff3dd67
Show file tree
Hide file tree
Showing 73 changed files with 592 additions and 592 deletions.
16 changes: 8 additions & 8 deletions Constants.asm
Expand Up @@ -24,10 +24,10 @@ z80_port_2_control: equ $A1000A
z80_expansion_control: equ $A1000C
z80_bus_request: equ $A11100
z80_reset: equ $A11200
ym2612_a0: equ $A04000
ym2612_d0: equ $A04001
ym2612_a1: equ $A04002
ym2612_d1: equ $A04003
ym2612_a0: equ $A04000
ym2612_d0: equ $A04001
ym2612_a1: equ $A04002
ym2612_d1: equ $A04003

security_addr: equ $A14000

Expand Down Expand Up @@ -185,7 +185,7 @@ afReset: equ $FB ; reset animation and 2nd object routine counter
af2ndRoutine: equ $FA ; increment 2nd routine counter

; Background music
bgm__First equ $81
bgm__First: equ $81
bgm_GHZ: equ ((ptr_mus81-MusicIndex)/4)+bgm__First
bgm_LZ: equ ((ptr_mus82-MusicIndex)/4)+bgm__First
bgm_MZ: equ ((ptr_mus83-MusicIndex)/4)+bgm__First
Expand All @@ -208,7 +208,7 @@ bgm_Emerald: equ ((ptr_mus93-MusicIndex)/4)+bgm__First
bgm__Last: equ ((ptr_musend-MusicIndex-4)/4)+bgm__First

; Sound effects
sfx__First equ $A0
sfx__First: equ $A0
sfx_Jump: equ ((ptr_sndA0-SoundIndex)/4)+sfx__First
sfx_Lamppost: equ ((ptr_sndA1-SoundIndex)/4)+sfx__First
sfx_A2: equ ((ptr_sndA2-SoundIndex)/4)+sfx__First
Expand Down Expand Up @@ -260,11 +260,11 @@ sfx_Signpost: equ ((ptr_sndCF-SoundIndex)/4)+sfx__First
sfx__Last: equ ((ptr_sndend-SoundIndex-4)/4)+sfx__First

; Special sound effects
spec__First equ $D0
spec__First: equ $D0
sfx_Waterfall: equ ((ptr_sndD0-SpecSoundIndex)/4)+spec__First
spec__Last: equ ((ptr_specend-SpecSoundIndex-4)/4)+spec__First

flg__First equ $E0
flg__First: equ $E0
bgm_Fade: equ ((ptr_flgE0-Sound_ExIndex)/4)+flg__First
sfx_Sega: equ ((ptr_flgE1-Sound_ExIndex)/4)+flg__First
bgm_Speedup: equ ((ptr_flgE2-Sound_ExIndex)/4)+flg__First
Expand Down
588 changes: 294 additions & 294 deletions Variables.asm

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions _inc/AnimateLevelGfx.asm
Expand Up @@ -34,7 +34,7 @@ AniArt_GHZ:

AniArt_GHZ_Waterfall:

@size: = 8 ; number of tiles per frame
@size: equ 8 ; number of tiles per frame

subq.b #1,(v_lani0_time).w ; decrement timer
bpl.s AniArt_GHZ_Bigflower ; branch if not 0
Expand All @@ -55,7 +55,7 @@ AniArt_GHZ_Waterfall:

AniArt_GHZ_Bigflower:

@size: = 16 ; number of tiles per frame
@size: equ 16 ; number of tiles per frame

subq.b #1,(v_lani1_time).w
bpl.s AniArt_GHZ_Smallflower
Expand Down Expand Up @@ -111,7 +111,7 @@ AniArt_MZ:

AniArt_MZ_Lava:

@size: = 8 ; number of tiles per frame
@size: equ 8 ; number of tiles per frame

subq.b #1,(v_lani0_time).w ; decrement timer
bpl.s AniArt_MZ_Magma ; branch if not 0
Expand Down Expand Up @@ -167,7 +167,7 @@ AniArt_MZ_Magma:

AniArt_MZ_Torch:

@size: = 6 ; number of tiles per frame
@size: equ 6 ; number of tiles per frame

subq.b #1,(v_lani2_time).w ; decrement timer
bpl.w @end ; branch if not 0
Expand All @@ -193,7 +193,7 @@ AniArt_MZ_Torch:

AniArt_SBZ:

@size: = 12 ; number of tiles per frame
@size: equ 12 ; number of tiles per frame

tst.b (v_lani2_frame).w
beq.s @smokepuff ; branch if counter hits 0
Expand Down Expand Up @@ -273,7 +273,7 @@ AniArt_Ending:

AniArt_Ending_BigFlower:

@size: = 16 ; number of tiles per frame
@size: equ 16 ; number of tiles per frame

subq.b #1,(v_lani1_time).w ; decrement timer
bpl.s AniArt_Ending_SmallFlower ; branch if not 0
Expand All @@ -300,7 +300,7 @@ AniArt_Ending_BigFlower:

AniArt_Ending_SmallFlower:

@size: = 12 ; number of tiles per frame
@size: equ 12 ; number of tiles per frame

subq.b #1,(v_lani2_time).w ; decrement timer
bpl.s AniArt_Ending_Flower3 ; branch if not 0
Expand All @@ -325,7 +325,7 @@ AniArt_Ending_SmallFlower:

AniArt_Ending_Flower3:

@size: = 16 ; number of tiles per frame
@size: equ 16 ; number of tiles per frame

subq.b #1,(v_lani4_time).w ; decrement timer
bpl.s AniArt_Ending_Flower4 ; branch if not 0
Expand All @@ -348,7 +348,7 @@ AniArt_Ending_Flower3_sequence: dc.b 0, 1, 2, 1

AniArt_Ending_Flower4:

@size: = 16 ; number of tiles per frame
@size: equ 16 ; number of tiles per frame

subq.b #1,(v_lani5_time).w ; decrement timer
bpl.s @end ; branch if not 0
Expand Down
42 changes: 21 additions & 21 deletions _incObj/0A Drowning Countdown.asm
Expand Up @@ -20,16 +20,16 @@ ptr_Drown_AirLeft: dc.w Drown_AirLeft-Drown_Index
dc.w Drown_Display-Drown_Index
dc.w Drown_Delete-Drown_Index

origX: = $30 ; original x-axis position
time: = $38 ; time between each number changes

id_Drown_Main: = ptr_Drown_Main-Drown_Index ; 0
id_Drown_Animate: = ptr_Drown_Animate-Drown_Index ; 2
id_Drown_ChkWater: = ptr_Drown_ChkWater-Drown_Index ; 4
id_Drown_Display: = ptr_Drown_Display-Drown_Index ; 6
id_Drown_Delete: = ptr_Drown_Delete-Drown_Index ; 8
id_Drown_Countdown: = ptr_Drown_Countdown-Drown_Index ; $A
id_Drown_AirLeft: = ptr_Drown_AirLeft-Drown_Index ; $C
drown_origX: equ $30 ; original x-axis position
drown_time: equ $38 ; time between each number changes

id_Drown_Main: equ ptr_Drown_Main-Drown_Index ; 0
id_Drown_Animate: equ ptr_Drown_Animate-Drown_Index ; 2
id_Drown_ChkWater: equ ptr_Drown_ChkWater-Drown_Index ; 4
id_Drown_Display: equ ptr_Drown_Display-Drown_Index ; 6
id_Drown_Delete: equ ptr_Drown_Delete-Drown_Index ; 8
id_Drown_Countdown: equ ptr_Drown_Countdown-Drown_Index ; $A
id_Drown_AirLeft: equ ptr_Drown_AirLeft-Drown_Index ; $C
; ===========================================================================

Drown_Main: ; Routine 0
Expand All @@ -52,7 +52,7 @@ Drown_Main: ; Routine 0

@smallbubble:
move.b d0,obAnim(a0)
move.w obX(a0),origX(a0)
move.w obX(a0),drown_origX(a0)
move.w #-$88,obVelY(a0)

Drown_Animate: ; Routine 2
Expand All @@ -74,7 +74,7 @@ Drown_ChkWater: ; Routine 4
@wobble:
tst.b (f_wtunnelmode).w ; is Sonic in a water tunnel?
beq.s @notunnel ; if not, branch
addq.w #4,origX(a0)
addq.w #4,drown_origX(a0)

@notunnel:
move.b obAngle(a0),d0
Expand All @@ -83,7 +83,7 @@ Drown_ChkWater: ; Routine 4
lea (Drown_WobbleData).l,a1
move.b (a1,d0.w),d0
ext.w d0
add.w origX(a0),d0
add.w drown_origX(a0),d0
move.w d0,obX(a0)
bsr.s Drown_ShowNumber
jsr (SpeedToPos).l
Expand All @@ -109,7 +109,7 @@ Drown_Delete: ; Routine 8, Routine $10
Drown_AirLeft: ; Routine $C
cmpi.w #$C,(v_air).w ; check air remaining
bhi.s Drown_AirLeft_Delete ; if higher than $C, branch
subq.w #1,time(a0)
subq.w #1,drown_time(a0)
bne.s @display
move.b #id_Drown_Display+8,obRoutine(a0) ; goto Drown_Display next
addq.b #7,obAnim(a0)
Expand All @@ -128,14 +128,14 @@ Drown_AirLeft_Delete:
; ===========================================================================

Drown_ShowNumber:
tst.w time(a0)
tst.w drown_time(a0)
beq.s @nonumber
subq.w #1,time(a0) ; decrement timer
subq.w #1,drown_time(a0) ; decrement timer
bne.s @nonumber ; if time remains, branch
cmpi.b #7,obAnim(a0)
bcc.s @nonumber

move.w #15,time(a0)
move.w #15,drown_time(a0)
clr.w obVelY(a0)
move.b #$80,obRender(a0)
move.w obX(a0),d0
Expand Down Expand Up @@ -189,9 +189,9 @@ Drown_Countdown:; Routine $A
btst #6,(v_player+obStatus).w ; is Sonic underwater?
beq.w @nocountdown ; if not, branch

subq.w #1,time(a0) ; decrement timer
subq.w #1,drown_time(a0) ; decrement timer
bpl.w @nochange ; branch if time remains
move.w #59,time(a0)
move.w #59,drown_time(a0)
move.w #1,$36(a0)
jsr (RandomNumber).l
andi.w #1,d0
Expand Down Expand Up @@ -316,15 +316,15 @@ Drown_Countdown:; Routine $A
bset #6,$36(a0)
bne.s @loc_14082
move.b d2,obSubtype(a1)
move.w #$1C,time(a1)
move.w #$1C,drown_time(a1)

@loc_1406A:
tst.b $34(a0)
bne.s @loc_14082
bset #6,$36(a0)
bne.s @loc_14082
move.b d2,obSubtype(a1)
move.w #$1C,time(a1)
move.w #$1C,drown_time(a1)

@loc_14082:
subq.b #1,$34(a0)
Expand Down
4 changes: 2 additions & 2 deletions _incObj/0B Pole that Breaks.asm
Expand Up @@ -12,8 +12,8 @@ Pole_Index: dc.w Pole_Main-Pole_Index
dc.w Pole_Action-Pole_Index
dc.w Pole_Display-Pole_Index

pole_time: = $30 ; time between grabbing the pole & breaking
pole_grabbed: = $32 ; flag set when Sonic grabs the pole
pole_time: equ $30 ; time between grabbing the pole & breaking
pole_grabbed: equ $32 ; flag set when Sonic grabs the pole
; ===========================================================================

Pole_Main: ; Routine 0
Expand Down
4 changes: 2 additions & 2 deletions _incObj/0C Flapping Door.asm
Expand Up @@ -11,8 +11,8 @@ FlapDoor:
Flap_Index: dc.w Flap_Main-Flap_Index
dc.w Flap_OpenClose-Flap_Index

flap_time: = $32 ; time between opening/closing
flap_wait: = $30 ; time until change
flap_time: equ $32 ; time between opening/closing
flap_wait: equ $30 ; time until change
; ===========================================================================

Flap_Main: ; Routine 0
Expand Down
6 changes: 3 additions & 3 deletions _incObj/0D Signpost.asm
Expand Up @@ -19,9 +19,9 @@ Sign_Index: dc.w Sign_Main-Sign_Index
dc.w Sign_SonicRun-Sign_Index
dc.w Sign_Exit-Sign_Index

spintime: = $30 ; time for signpost to spin
sparkletime: = $32 ; time between sparkles
sparkle_id: = $34 ; counter to keep track of sparkles
spintime: equ $30 ; time for signpost to spin
sparkletime: equ $32 ; time between sparkles
sparkle_id: equ $34 ; counter to keep track of sparkles
; ===========================================================================

Sign_Main: ; Routine 0
Expand Down
8 changes: 4 additions & 4 deletions _incObj/15 Swinging Platforms (part 1).asm
Expand Up @@ -14,8 +14,8 @@ Swing_Index: dc.w Swing_Main-Swing_Index, Swing_SetSolid-Swing_Index
dc.w Swing_Delete-Swing_Index, Swing_Display-Swing_Index
dc.w Swing_Action-Swing_Index

origX: = $3A ; original x-axis position
origY: = $38 ; original y-axis position
swing_origX: equ $3A ; original x-axis position
swing_origY: equ $38 ; original y-axis position
; ===========================================================================

Swing_Main: ; Routine 0
Expand All @@ -26,8 +26,8 @@ Swing_Main: ; Routine 0
move.b #3,obPriority(a0)
move.b #$18,obActWid(a0)
move.b #8,obHeight(a0)
move.w obY(a0),origY(a0)
move.w obX(a0),origX(a0)
move.w obY(a0),swing_origY(a0)
move.w obX(a0),swing_origX(a0)
cmpi.b #id_SLZ,(v_zone).w ; check if level is SLZ
bne.s @notSLZ

Expand Down
2 changes: 1 addition & 1 deletion _incObj/16 Harpoon.asm
Expand Up @@ -12,7 +12,7 @@ Harp_Index: dc.w Harp_Main-Harp_Index
dc.w Harp_Move-Harp_Index
dc.w Harp_Wait-Harp_Index

harp_time: = $30 ; time between stabbing/retracting
harp_time: equ $30 ; time between stabbing/retracting
; ===========================================================================

Harp_Main: ; Routine 0
Expand Down
2 changes: 1 addition & 1 deletion _incObj/17 Spiked Pole Helix.asm
Expand Up @@ -14,7 +14,7 @@ Hel_Index: dc.w Hel_Main-Hel_Index
dc.w Hel_Delete-Hel_Index
dc.w Hel_Display-Hel_Index

hel_frame: = $3E ; start frame (different for each spike)
hel_frame: equ $3E ; start frame (different for each spike)

; $29-38 are used for child object addresses
; ===========================================================================
Expand Down
30 changes: 15 additions & 15 deletions _incObj/1A Collapsing Ledge (part 1).asm
Expand Up @@ -12,8 +12,8 @@ Ledge_Index: dc.w Ledge_Main-Ledge_Index, Ledge_Touch-Ledge_Index
dc.w Ledge_Collapse-Ledge_Index, Ledge_Display-Ledge_Index
dc.w Ledge_Delete-Ledge_Index, Ledge_WalkOff-Ledge_Index

timedelay: = $38 ; time between touching the ledge and it collapsing
collapse: = $3A ; collapse flag
ledge_timedelay: equ $38 ; time between touching the ledge and it collapsing
ledge_collapse_flag: equ $3A ; collapse flag
; ===========================================================================

Ledge_Main: ; Routine 0
Expand All @@ -22,18 +22,18 @@ Ledge_Main: ; Routine 0
move.w #$4000,obGfx(a0)
ori.b #4,obRender(a0)
move.b #4,obPriority(a0)
move.b #7,timedelay(a0) ; set time delay for collapse
move.b #7,ledge_timedelay(a0) ; set time delay for collapse
move.b #$64,obActWid(a0)
move.b obSubtype(a0),obFrame(a0)
move.b #$38,obHeight(a0)
bset #4,obRender(a0)

Ledge_Touch: ; Routine 2
tst.b collapse(a0) ; is ledge collapsing?
tst.b ledge_collapse_flag(a0) ; is ledge collapsing?
beq.s @slope ; if not, branch
tst.b timedelay(a0) ; has time reached zero?
tst.b ledge_timedelay(a0) ; has time reached zero?
beq.w Ledge_Fragment ; if yes, branch
subq.b #1,timedelay(a0) ; subtract 1 from time
subq.b #1,ledge_timedelay(a0) ; subtract 1 from time

@slope:
move.w #$30,d1
Expand All @@ -43,10 +43,10 @@ Ledge_Touch: ; Routine 2
; ===========================================================================

Ledge_Collapse: ; Routine 4
tst.b timedelay(a0)
tst.b ledge_timedelay(a0)
beq.w loc_847A
move.b #1,collapse(a0) ; set collapse flag
subq.b #1,timedelay(a0)
move.b #1,ledge_collapse_flag(a0) ; set collapse flag
subq.b #1,ledge_timedelay(a0)

; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||

Expand All @@ -64,28 +64,28 @@ Ledge_WalkOff: ; Routine $A
; ===========================================================================

Ledge_Display: ; Routine 6
tst.b timedelay(a0) ; has time delay reached zero?
tst.b ledge_timedelay(a0) ; has time delay reached zero?
beq.s Ledge_TimeZero ; if yes, branch
tst.b collapse(a0) ; is ledge collapsing?
tst.b ledge_collapse_flag(a0) ; is ledge collapsing?
bne.w loc_82D0 ; if yes, branch
subq.b #1,timedelay(a0) ; subtract 1 from time
subq.b #1,ledge_timedelay(a0) ; subtract 1 from time
bra.w DisplaySprite
; ===========================================================================

loc_82D0:
subq.b #1,timedelay(a0)
subq.b #1,ledge_timedelay(a0)
bsr.w Ledge_WalkOff
lea (v_player).w,a1
btst #3,obStatus(a1)
beq.s loc_82FC
tst.b timedelay(a0)
tst.b ledge_timedelay(a0)
bne.s locret_8308
bclr #3,obStatus(a1)
bclr #5,obStatus(a1)
move.b #1,obNextAni(a1)

loc_82FC:
move.b #0,collapse(a0)
move.b #0,ledge_collapse_flag(a0)
move.b #6,obRoutine(a0) ; run "Ledge_Display" routine

locret_8308:
Expand Down

0 comments on commit ff3dd67

Please sign in to comment.