Language…
11 users online: BabaYegha, deported, h.carrell, Heitor Porfirio,  idol, MegaSonic1999, NewPointless, playagmes169, Sweetdude, TheKazooBloccGosh, TheXander - Guests: 304 - Bots: 400
Users: 64,795 (2,374 active)
Latest user: mathew

Sprite/Block/HDMA/ASM Code Library

Link Thread Closed
Quote
Contact:
LDA $14E0,x
XBA
LDA $E4,x
REP #$20
SEC
SBC $94
SEP #$20
PHA
JSR SUB_HORZ_POS
PLA
EOR Flip,y
CMP #$10
BCS NoThx
LDA $14D4,x
XBA
LDA $D8,x
REP #$20
SEC
SBC $96
SEP #$20
PHA
JSR SUB_VERT_POS
PLA
EOR Flip,y
CMP #$20
BCS Nothx
JSL $00F5B7
NoThx:
RTS
Flip:
db $FF,$00


I made this last night. it's my pseudo clipping size interaction. I haven't figured out object clipping but this works for sprite clipping. I used it with clippng size 22 (16x16) so I could have a perfect square. just edit the two CMPs for for how big vertically or horizontally you wnt it. Also don't use the default interaction.

This is a cool HDMA effect for Mode 7 in SMW.
Example: http://www.youtube.com/watch?v=8l-jR_lY37E

Originally posted by Roy


Code
REP #$20
LDA #$1B02 ; \ 16-bit write to one register. $211B
STA $4330 ; /
LDA #$1E02 ; \ Same for $211E.
STA $4340 ; /
LDA.w #HScl ; Address for HDMA table.
STA $4332 ; \ Same address for both $211B and $211E.
STA $4342 ; /
LDY.b #HScl/65536 ; 
STY $4334 ; \
STY $4344 ; /
SEP #$20
LDA #$18 ; Enable channels 3 and 4.
TSB $0D9F ; Actually it was STA $420C in my patch, but for SMW, use TSB $0D9F.
RTS

; Now this is going to be one huge table. 3 bytes for each scanline.
HScl:
db $71 : dw $01AA : db $01 : dw $01A5 ; 72
db $01 : dw $01A0 : db $01 : dw $019B 
db $01 : dw $0196 : db $01 : dw $0191
db $01 : dw $018C : db $01 : dw $0187
db $01 : dw $0182 : db $01 : dw $017D
db $01 : dw $0178 : db $01 : dw $0173
db $01 : dw $016E : db $01 : dw $0169
db $01 : dw $0164 : db $01 : dw $015F
db $01 : dw $015A : db $01 : dw $0155 ; 82
db $01 : dw $0150 : db $01 : dw $014B
db $01 : dw $0146 : db $01 : dw $0141
db $01 : dw $013C : db $01 : dw $0137
db $01 : dw $0132 : db $01 : dw $012D
db $01 : dw $0128 : db $01 : dw $0124
db $01 : dw $0120 : db $01 : dw $011C
db $01 : dw $0118 : db $01 : dw $0114
db $01 : dw $0110 : db $01 : dw $010C ; 92
db $01 : dw $0109 : db $01 : dw $0106
db $01 : dw $0103 : db $01 : dw $0100
db $01 : dw $00FD : db $01 : dw $00FA
db $01 : dw $00F7 : db $01 : dw $00F4
db $01 : dw $00F1 : db $01 : dw $00EE
db $01 : dw $00EB : db $01 : dw $00E8
db $01 : dw $00E6 : db $01 : dw $00E4
db $01 : dw $00E2 : db $01 : dw $00E1 ; A2
db $01 : dw $00E0 : db $01 : dw $00DF
db $01 : dw $00DE : db $01 : dw $00DD
db $01 : dw $00DC : db $01 : dw $00DB
db $01 : dw $00DA : db $01 : dw $00D9
db $01 : dw $00D8 : db $01 : dw $00D7
db $01 : dw $00D6 : db $01 : dw $00D5
db $01 : dw $00D4 : db $01 : dw $00D3
db $01 : dw $00D2 : db $01 : dw $00D1 ; B2
db $01 : dw $00D0 : db $01 : dw $00CF
db $01 : dw $00CE : db $01 : dw $00CD
db $01 : dw $00CC : db $01 : dw $00CB
db $01 : dw $00CA : db $01 : dw $00C9
db $01 : dw $00C8 : db $01 : dw $00C7
db $01 : dw $00C6 : db $01 : dw $00C5
db $01 : dw $00C4 : db $01 : dw $00C3
db $01 : dw $00C2 : db $01 : dw $00C1 ; C2
db $01 : dw $00C0 : db $01 : dw $00BF
db $01 : dw $00BE : db $01 : dw $00BD
db $01 : dw $00BC : db $01 : dw $00BB
db $01 : dw $00BA : db $01 : dw $00B9
db $01 : dw $00B8 : db $01 : dw $00B7
db $01 : dw $00B6 : db $01 : dw $00B5
db $01 : dw $00B4 : db $01 : dw $00B3
db $01 : dw $00B2 : db $01 : dw $00B1 ; D2
db $01 : dw $00B0 : db $01 : dw $00AF
db $01 : dw $00AE : db $01 : dw $00AD
db $01 : dw $00AC : db $01 : dw $00AB
db $01 : dw $00AA : db $01 : dw $00A9
db $01 : dw $00A8 : db $01 : dw $00A7
db $01 : dw $00A6 : db $01 : dw $00A5
db $01 : dw $00A4 : db $01 : dw $00A3 ; E0
db $00

Your layout has been removed.
Here is a short but useful code.

DEC $13C6
PHK
PER $0006
PEA $8020
JML $01877B

This will beat the level as if a goal sphere had been touched. If you don't want the player to freeze in place, remove the DEC $13C6.

Hm...then again, just

DEC $13C6
LDA #$FF
STA $1493
STA $0DDA
LDA #$0B
STA $1DFB

would do the same thing, and it would use fewer cycles (albeit two more bytes). If you want to activate the secret exit, add this:

LDA #$01
STA $141C

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
How about secret exit?
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Good idea. Just add an LDA #$01 STA $141C to that.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Can that also be used in sprites?
Your layout has been removed.
Yes, it can be used in anything. In fact, I'm including all four versions of the code in my subroutine patch.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Made this very smooth morning gradient a minute ago. Here's a picture;



And here's the gradient.
Errm four?? what?
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Four, as in two that make the player walk after the level ends and two that don't, one each for normal and secret exits.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Originally posted by imamelia
Good idea. Just add an LDA #$01 STA $141C to that.


I tried that and it didn't work. It just does the normal exit stuff. This is in a patch that hijacks $8F89, although I really don't know what's there because I didn't make the base patch. Did you test this?

INC $1DEA
doesn't work,
LDA #$FF
STA $0DD5
doesn't work,
LDA #$01
STA $141C
DOESN'T WORK?

The only thing that's worked so far was Iceguy's end level block code, but it beats the level way to fast it has to be normal speed (well in my case #$10 frames)
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Huh. Yeah, I tested it, and I'm pretty sure it worked for me...did you test it in a level that actually has a secret exit? Maybe it's the place where you hijacked.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Any thoughts on were I should hijack?
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Well, what exactly are you trying to do? $008F89 is part of the status bar routine...you're not trying to hijack NMI to make a routine run every frame, are you?

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
I wasn't, I didn't make the origional patch. Probably the person who did did that before it was taboo'd. It doesn't give me any problems and I don't even know how to tell if a code runs during NMI.
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
This code makes a rainbow HDMA gradient appear over the foreground.

Put this in the level init code:

LDA #$3F
STA $40
LDA #$00
STA $44
LDA #$1F
STA $212C
LDA #$00
STA $212D
RTS

Put this, the standard HDMA background gradient code, in the level main code:

REP #$20
LDA #$3200
STA $4330
LDA #RedValues
STA $4332
PHK
PLY
STY $4334
LDA #$3200
STA $4340
LDA #GreenValues
STA $4342
PHK
PLY
STY $4344
LDA #$3200
STA $4350
LDA #BlueValues
STA $4352
PHK
PLY
STY $4354
SEP #$20
LDA #$38
TSB $0D9F
RTS

And here are the tables, which also go in the main code (levelcode.asm):

BlueValues:
db $08,$80
db $08,$80
db $08,$80
db $08,$80
db $08,$80
db $08,$80
db $08,$80
db $08,$80
db $08,$80
db $08,$80
db $08,$80
db $08,$82
db $08,$84
db $08,$86
db $08,$88
db $08,$88
db $08,$88
db $08,$88
db $08,$88
db $08,$88
db $08,$88
db $08,$88
db $08,$88
db $08,$88
db $08,$88
db $08,$86
db $08,$84
db $08,$82
db $00

GreenValues:
db $08,$40
db $08,$43
db $08,$46
db $08,$49
db $08,$4C
db $08,$4F
db $08,$52
db $08,$55
db $08,$51
db $08,$4C
db $08,$48
db $08,$48
db $08,$48
db $08,$48
db $08,$48
db $08,$45
db $08,$43
db $08,$40
db $08,$40
db $08,$40
db $08,$40
db $08,$40
db $08,$40
db $08,$40
db $08,$40
db $08,$40
db $08,$40
db $08,$40
db $00

RedValues:
db $08,$30
db $08,$31
db $08,$31
db $08,$32
db $08,$33
db $08,$34
db $08,$34
db $08,$35
db $08,$2E
db $08,$27
db $08,$20
db $08,$20
db $08,$20
db $08,$20
db $08,$20
db $08,$20
db $08,$20
db $08,$20
db $08,$22
db $08,$24
db $08,$26
db $08,$28
db $08,$2B
db $08,$2D
db $08,$30
db $08,$30
db $08,$30
db $08,$30
db $00

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Wave HDMA, code by Ice Man Kaijyuu:
Init
Code

	REP #$20	; 16 bit A
	LDA #$0F42	; one reg write twice, indirect
	STA $4340	; $210F - layer 2 horizontal scroll register
	LDA #$B600	; low and high bytes of source address
	STA $4342	;
	SEP #$20	; 8 bit A
	LDA #$7F	; set bank
	STA $4344	;
	STA $4347	; set indirect bank too
	LDA #$10  	; enable channel 4
	TSB $0D9F	; 


	LDA #$00	; setup indirect addressing
	STA $00		; target address: $7FB600
	LDA #$B6
	STA $01
	LDA #$7F
	STA $02

	LDX #$09	; loop 10 (decimal) times

LVL6_LOOP6:

	LDY #$17	; loop 24 (decimal) times
LVL6_LOOP7:
	LDA LVL6_HDMA4,y;
	STA [$00],y	; upload table to RAM
	DEY
	BPL LVL6_LOOP7

	REP #$20	; 16 bit A
	LDA $00		; load low/high byte of target address
	CLC
	ADC #$0018	; add 18
	STA $00		; store back
	SEP #$20	; 8 bit A

	DEX
	BPL LVL6_LOOP6	; loop again if needed

	LDA #$00	; add in terminator byte
	STA [$00]
	RTS

Code
Code
	REP #$20	; 16 bit A

	LDX #$0E	; update scroll values
LVL6_LOOP8:
	LDA $1E		; layer 2 x
	CLC
	ADC LVL6_HDMA2,x; add in offset
	STA $7FB710,x	; store to HDMA table
	DEX
	DEX
	BPL LVL6_LOOP8	; loop 8 times

	SEP #$20	; 8 bit A

	LDX #$15	; reset these scanline counts
	LDA #$04
LVL6_8:
	STA $7FB600,x
	DEX
	DEX
	DEX
	BPL LVL6_8

	STZ $00		; set this scratch to 00
	
	LDA $14		; frame counter
	LSR		; /2
	AND #$03	; mod 4
	CLC
	ADC $20		; add in layer 2 y
LVL6_7:
	CMP #$04	; check if below 4
	BCC LVL6_6	; continue if so
	SBC #$04	; subtract 4 until it is
	INC $00		; increment scratch
	BRA LVL6_7	; loop
LVL6_6:
	SEC		; 
	SBC #$04	; flip
	EOR #$FF
	INC A
	STA $01		; store to scratch for later

	LDA $14		; frame counter
	LSR		; /8
	LSR
	LSR
	CLC
	ADC $00		; add in additional from layer 2's y
	AND #$07	; mod 8
	STA $00		; store to scratch
	ASL		; x3
	CLC
	ADC $00
	TAX		; stick in x
	LDA $01		; get scanline count
	STA $7FB600,x	; set scanline count
	STX $4342	; set table offset

        RTS


LVL6_HDMA2:		; holds how much to offset layer 2's horizontal scrolling by. 2 byte width
db $00,$00,$FF,$FF,$FE,$FF,$FF,$FF,$00,$00,$01,$00,$02,$00,$01,$00


LVL6_HDMA4:		; holds initial HDMA settings for layer 2
db $04,$10,$B7		; first byte = scanline count, second byte = low byte of address, third = high byte
db $04,$12,$B7
db $04,$14,$B7
db $04,$16,$B7
db $04,$18,$B7
db $04,$1A,$B7
db $04,$1C,$B7
db $04,$1E,$B7



Select code, because I don't know how to change code color within layout.
Documenting Noobish's calculate speed thing but I have no idea what it is, it sounds useful though. Also you might see an ASL ASL. I think it's mean to be an LSR LSR.

Originally posted by Noobish Noobscicle
CalcProjSpeed:
LDA $14E0,x
XBA
LDA $E4,x
REP #$20
STA !FreeRam
LDA $94
SEC
SBC !FreeRam
BMI ShootBackwards
LSR
LSR
SEP #$20
ResumeForwards:
STA $00B6,y
BRA DoVert
ShootBackwards:
EOR #$FFFF
INC
LSR
LSR
SEP #$20
EOR #$FF
INC
BRA ResumeForwards

DoVert:
LDA $14D4,x
XBA
LDA $D8,x
REP #$20
STA !FreeRam
LDA $96
SEC
SBC !FreeRam
BMI ShootUp
LSR
LSR
SEP #$20
ResumeDown:
STA $00AA,y
RTS
ShootUp:
EOR #$FFFF
INC
LSR
LSR
SEP #$20
EOR #$FF
INC
BRA ResumeDown

I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
I don't think those "EOR #$FFFF INC"s are necessary, since the backward speed already got flipped in 8-bit mode.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Originally posted by Glitch.Mr
Wave HDMA, code by Ice Man:

*code*

Select code, because I don't know how to change code color within layout.
I just wanted to say that Kaijyuu made this and not me. :P I just explained how one would insert it with levelASM.
Link Thread Closed