12 users online: af1899, anonimzwx, Dolo, GangsterJerby, IcyFruit, Isikoro, lo fang 123, Nciktendo, Quaza, The_Big_Dededester,  Thomas, zAce08xZ - Guests: 89 - Bots: 221
Users: 62,817 (2,619 active)
Latest user: Kaputon

Tic tac blocks code by Superwan

File Name: Tic tac blocks code
Submitted: by Superwan
Authors: Superwan
Type: Level
Includes GFX: No
Includes Hijack: No
Featured: No
Description: Just a code that recreate the effect of tic-tac blocs in SM3DWorld : it sounds like a tempo and switch the ON/OFF so you need to use ON/OFF blocks

Example :
The concept for this is good, but its execution could be cleaner.

- For starters, this was confusing me to what it's supposed to do (I have never played SM3DW) until I saw this was supposed to be used with some ON/OFF blocks. Yes, the description said something among those lines, but still there's no excuse to include the blocks (or link them should they exist already).
- I think including an option for this to use its own switch instead of hardcoding it to the ON/OFF status, so if people still want to use the ON/OFF block's normal functions alongside this tic tac block code.

- The main offender is the code, which is really unoptimized and does some things it shouldn't.
1.- Don't do STZ $14. This will mess up the animations. Since it defaults to .25 seconds or 0x1C frames, and then it resets it after reaching this value, any resource that depends on the frame counter having higher values will break.
2.- You should leave your FreeRAM as a define so the user can change it.
3.- This code could be cleanlier:
	LDX #$00
	STZ $13C0

...what's the point of this? Yes, it should be 00, but there's no reason to clear it out because nothing else even writes to it.
	LDX $14			;
	CPX #$1C		;\
	BEQ Tempo		;/

Again, to avoid doing STZ $14, just check the frame counter like this:
LDA $14
AND #$1C
CMP #$1C
BEQ Tempo

	Switch:			;
	LDY #$28		; Sound
	STY $1DFC		;
	LDY #$0F		; Shaking ground
	STY $1887		;
	LDY $14AF		; Etat du ON/OFF
	CPY #$00		;|
	BEQ OffSwitch	;|
	LDY #$00		;|
	STY $14AF		;|
	JMP OnSwitch	;|
	OffSwitch:		;|
	LDY #$01		;|
	STY $14AF		;|
	OnSwitch:		;|
	JMP EndSound	;/

1.- Make the sound a define so the user can change it easier.
2.- You can just do this to invert the ON/OFF status:
EOR #$01

3.- Unless you're getting branch out of bounds errors, use BRA instead of JMP.

	LDA $0DD4		;
	CMP #$04		;
	BCC Sound
	CMP #$04		;
	BEQ Switch

CMP #$04
BEQ Switch
BCC Sound

There's no need to babysit the value of A by using other registers. Just use A normally and load $0DD4 before branching to EndSound.

Change that stuff up and I might accept it. (if you do end up adding a custom switch, submit this to the blocks section instead!)

Keep practicing, and eventually you'll get the hang of ASM much easier. Good luck in your future resources!