Language…
16 users online: akari1129, Alfombra de madera, anonimzwx,  Anorakun, art61, Bonobi, Heitor Porfirio,  idol,  K.T.B., mish1, mmmdoggy, MorrieTheMagpie, ShadowBoxer_Sandshrew, StarWolf3000, TheKazooBloccGosh, Zavok - Guests: 85 - Bots: 182
Users: 57,930 (2,489 active)
Latest user: spygames36

Stripe image format - Tutorial.

ExGFX

HammerBrother's updated version of this post is life-saver. Good job!
Nitrocell Presents - ASM is priority.


IN PROGRESS



Stripe setup-er 2.0. Major change was the two subroutines are merged into one, and you only have to write the tiles, and that was it, no need to keep values in $03-05 and the X index. The terminating byte, length of stripe ($7F837B) are already written,
Code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Easy stripe setup-er 2.1. Sets up stripe header, Updates length of stripe,
;and writes the terminating byte. You only need to write the tile data
;afterwards.
;
;-$00: X position (%00XXXXXX, only bits 0-5 used, ranges from 0-63 ($00-$3F))
;-$01: Y position (%00YYYYYY, only bits 0-5 used, ranges from 0-63 ($00-$3F))
;-$02: What layer:
;  $02 = Layer 1
;  $03 = Layer 2
;  $05 = Layer 3
;-$03: Direction and RLE: %DR00000000
;  D = Direction: 0 = horizontal (rightwards), 1 = vertical (downwards)
;  R = RLE: 0 = no (manually write different tiles), 1 = yes (write one
;   tile multiple times, based on input $04-$05).
;-$04 to $05 (16-bit): Number of tiles, minus 1 (a value of 2 here means 3
;  tiles). (If RLE is used, this is how many times a tile is repeated).
;Output:
;-$7F837B-$7F837C: Updated length of stripe data.
;-X register (16-bit, XY registers are 16-bit): The index position of where
; to write tile data (starting at $7F837D+4,x)
;Destroyed:
;-$06-$08: Used when not using RLE, to calculate the terminating byte location.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;note to self
; $7F837B = Length of stripe, counting header and tile data, but not the terminating byte.
; $7F837D+0,x = EHHHYXyy
; $7F837D+1,x = yyyxxxxx
; $7F837D+2,x = DRllllll
; $7F837D+3,x = LLLLLLLL
; $7F837D+4,x = Tile, number
; $7F837D+5,x = Tile properties
; $7F837D+6,x = Terminating byte
SetupStripe:
	.GetWhereToSafelyWriteStripe
		REP #$30		;>16-bit AXY
		LDA $7F837B		;\LDX $XXXXXX does not exist so we need LDA $XXXXXX : TAX to
		TAX			;/get RAM values stored in bank $7F into X register.
	.StartWithBlankHeaderInitally
		LDA #$0000		;\Clear everything out first
		STA $7F837D+0,x		;|
		STA $7F837D+2,x		;/
		SEP #$20
	.Xposition
		LDA $00			;\X bit 0-4
		AND.b #%00011111	;|
		ORA $7F837D+1,x		;|
		STA $7F837D+1,x		;/
		LDA $00			;\X bit 5
		AND.b #%00100000	;|
		LSR #3			;|
		ORA $7F837D+0,x		;|
		STA $7F837D+0,x		;/
	.Yposition
		LDA $01			;\Y bit 0-2
		AND.b #%00000111	;|
		ASL #5			;|
		ORA $7F837D+1,x		;|
		STA $7F837D+1,x		;/
		LDA $01			;\Y bit 3-4
		AND.b #%00011000	;|
		LSR #3			;|
		ORA $7F837D+0,x		;|
		STA $7F837D+0,x		;/
		LDA $01			;\Y bit 5
		AND.b #%00100000	;|
		LSR #2			;|
		ORA $7F837D+0,x		;|
		STA $7F837D+0,x		;/
	.WhatLayer
		LDA $02
		AND.b #%00000111
		ASL #4
		ORA $7F837D+0,x
		STA $7F837D+0,x
	.Direction
		LDA $03
		AND.b #%11000000	;>Failsafe
		ORA $7F837D+2,x
		STA $7F837D+2,x
	.Length
		AND.b #%01000000
		BEQ ..NoRLE
		
		..RLE
			REP #$21		;REP #$21 is 8-bit A with carry cleared
			TXA			;\Update length of stripe. 6 because 2 bytes of 1 tile plus 4 bytes of header)
			ADC #$0006		;|
			STA $7F837B		;/
			SEP #$30		;>8-bit AXY
			LDA #$FF		;\Terminating byte
			STA $7F837D+6,x		;/
			REP #$20
			LDA $04			;\NumberOfBytes = (NumberOfTiles-1)*2
			INC
			ASL			;|
			SEP #$20		;/
			BRA ..Write
		..NoRLE
			REP #$21		;REP #$21 is 8-bit A with carry cleared
			LDA $04			;\4+(NumberOfTiles*2)...
			INC			;|
			ASL			;|
			CLC			;|
			ADC #$0004		;/
			CLC			;\plus the current length
			ADC $7F837B		;/
			STA $7F837B		;>And that is our new length
			SEP #$30		;>8-bit AXY
			LDA #$7F		;\Bank byte
			STA $08			;/
			REP #$20		;\4+(NumberOfTiles*2)...
			LDA $04			;|
			INC			;|
			ASL			;|
			CLC			;|>Just in case
			ADC.w #$837D+4		;|
			STA $06			;/
			TXA			;\Plus index ($7F837D+(NumberOfBytesSinceHeader),x is equivalent to $7F837D + NumberOfBytesSinceHeader + X_index)
			CLC			;|
			ADC $06			;|
			STA $06			;/
			SEP #$20
			LDA #$FF		;\Write terminate byte here.
			STA [$06]		;/
			REP #$20
			LDA $04			;\NumberOfBytes = (NumberOfTiles*2)-1
			INC			;|
			ASL			;|
			DEC			;|
			SEP #$20		;/
		..Write
			STA $7F837D+3,x		;\Write length bits
			XBA			;|
			AND.b #%00111111	;|
			ORA $7F837D+2,x		;|
			STA $7F837D+2,x		;/
	.Done
		RTL

Example usage (uberasm tool):
Code
	main:
	LDA.b #0		;\X
	STA $00			;/
	LDA.b #0		;\Y
	STA $01			;/
	LDA #$05		;\Layer
	STA $02			;/
	LDA.b #%10000000	;\direction and RLE
	STA $03			;/
	LDA #$03-1		;\number of tiles
	STA $04			;|
	STZ $05			;/
	JSL StripeSubroutine_SetupStripeHeaderAndIndex
	REP #$20		
	LDA #$3800		;\Write tiles
	STA $7F837D+4,x		;|
	LDA #$3801		;|
	STA $7F837D+6,x		;|
	LDA #$3802		;|
	STA $7F837D+8,x		;/
	SEP #$20		
	RTL


Edit: Fixed a bug where the X index was 8-bit when it supposed to be 16-bit.
Edit2: Made the number of tile input be 1-lower since it is pointless to use this subroutine to write 0 tiles, and simplified the calculation to obtain the length bits.
Give thanks to RPG hacker for working on Asar.
I discovered that the COURSE CLEAR! message when completing the level does not work properly (some tiles will be missing or glitched) if you have stripe image written before the goal message within a frame, because of how faulty and inconsistent the way SMW uses RAM $7F837B (stripe index, used to prevent overwriting previously written stripe data within a frame). At $05CCCB, is a loop to write the tiles, and:
Code
CODE_05CCC8:        A0 02 00      LDY.W #$0002              
CODE_05CCCB:        A9 04         LDA.B #$04                
CODE_05CCCD:        18            CLC                       
CODE_05CCCE:        6F 7B 83 7F   ADC.L $7F837B             
CODE_05CCD2:        AA            TAX                       
CODE_05CCD3:        B9 31 0F      LDA.W $0F31,Y             
CODE_05CCD6:        9F AF 83 7F   STA.L $7F83AF,X           
CODE_05CCDA:        88            DEY                       
CODE_05CCDB:        CA            DEX                       
CODE_05CCDC:        CA            DEX                       
CODE_05CCDD:        10 F4         BPL CODE_05CCD3           

Notice at the bottom of the loop, the BPL checks the X index (index offset from the stripe index) instead of the Y (loop counter) (both DEX and DEY sets the (N)egative flag, but the BPL checks whose last modified the N flag). This loop is intended to loop only 5 times (#$04 → #$03 → #$02 → #$01 → #$00). If $7F837B is #$0000, this would work fine, but if it is any non-zero value, this can loop additional times and write garbage tiles, and potentially corrupt the stripe data. Therefore the loop counter and the stripe index, are mixed into one value. A solution is to swap the DEY and DEXs so that DEY comes before BPL - DEX DEX DEY so that the BPL checks if Y is negative instead of X.

Here is a similar thing:
Code
CODE_05CCDF:        AF 7B 83 7F   LDA.L $7F837B             
CODE_05CCE3:        AA            TAX                       
CODE_05CCE4:        BF AF 83 7F   LDA.L $7F83AF,X           
CODE_05CCE8:        29 0F         AND.B #$0F                
CODE_05CCEA:        D0 0D         BNE CODE_05CCF9           
CODE_05CCEC:        A9 FC         LDA.B #$FC                
CODE_05CCEE:        9F AF 83 7F   STA.L $7F83AF,X           
CODE_05CCF2:        E8            INX                       
CODE_05CCF3:        E8            INX                       
CODE_05CCF4:        E0 04 00      CPX.W #$0004              
CODE_05CCF7:        D0 EB         BNE CODE_05CCE4           

If $7F837B is any nonzero value, this can loop fewer times than intended and results in missing tiles.

Here's another problem:
Code
CODE_05CCCB:        A9 04         LDA.B #$04                
CODE_05CCCD:        18            CLC                       
CODE_05CCCE:        6F 7B 83 7F   ADC.L $7F837B             
CODE_05CCD2:        AA            TAX                       
CODE_05CCD3:        B9 31 0F      LDA.W $0F31,Y             
CODE_05CCD6:        9F AF 83 7F   STA.L $7F83AF,X           

It's handling the stripe index in 8-bit instead of 16.

The developers never expect having any stripe image placed before the COURSE CLEAR! message in the stripe table, which is reminiscent of why extended/minor extended sprites used fixed OAM indexing rather than dynamic.
Give thanks to RPG hacker for working on Asar.

ExGFX