Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,436,208
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-19-24 03:01 PM
Guest: Register | Login

0 users currently in ROM Hacking | 1 guest | 2 bots

Main - ROM Hacking - How come there are no tutorials on how to program a TSA? New thread | New reply


RetroRain
Posted on 11-30-14 07:11 PM Link | Quote | ID: 159091


Fuzz Ball
Level: 66

Posts: 809/994
EXP: 2436813
Next: 25038

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
This is one of those things that I would need to know if I decide to program a NES homebrew in the future. But I did some searching, and I can't find anything. That, and I'm surprised it has never really come up before.

Let's say that 00 - 02 are level tiles, 16 x 16 tiles.

00 is a wall
01 is a grass ground
02 is water

and in the hex editor, I have 00 00 00 00 01 01 01 01 02 02

just for sake of argument.

If I change one of those 00s to a 01, I can change the wall into a non-solid grass tile in the level.

But how do I get a single byte to represent four 8x8 tiles?

For instance, in the NES, the grass ground 16x16 tile could be formed using 8x8 PPU tiles 0A, 16, 2D, and 4F (just using random numbers for the hell of it).

In other words, if the game reads 16x16 tile 00, the wall tile, how does it know that it consists of those 4 random tile numbers?

Is programming a TSA actually easy, and I'm just making it out to be harder than it really is?

Then you have the obvious property byte, which I also don't know how to do...

Grass Tile (Represented by byte 00)

0A 16
2D 4F

Grass Tile Property (00 is solid, 01 is air, 02 is water, 03 is spike)

01

I was just curious if anyone had any info regarding this topic.

Thanks.

____________________
My YouTube Channel

Yoshimaster96
Posted on 12-03-14 11:10 PM (rev. 2 of 12-03-14 11:11 PM) Link | Quote | ID: 159102


Goomba
Level: 13

Posts: 16/26
EXP: 8044
Next: 2223

Since: 03-22-14

Last post: 2393 days
Last view: 963 days
;Let's say that there are 256 16x16 tiles, with 4 bytes each:
;00 01
;02 03
;Each screen is 16x12 tiles (to make room for possible HUD).
;+--+--+-
;|00|01|.
;+--+--+-
;|10|11|.
;+--+--+-
;|..|..|.
;After the tile data is the palette data.
;+-----+-
;| |.
;| $FF |.
;| |.
;+-----+-
;|.....|.
;That will take up a lot of space, so let's compress it:
;CLLLLLLL
;C: Codec to use
;L: Length stored plus 1 (0 is pointless)
;C values:
;0: Literal bytes, L bytes follow.
;1: Run-length bytes, L bytes are written, all with the next byte's value.
;At $BE00-$BFFF are the pointers to the 256 screens
;Low byte of each pointer is $BE00-$BEFF
;High byte of each pointer is $BF00-$BFFF
;All this data starts at $8000 in our ROM, ends at $BFFF.
;Things like collision (properties) are not discussed, sorry.
.ORG $C000 ;Start of code
LDA #$10 ;Initialize PPU registers here
STA $2000
LDA #$0A
STA $2001
LDA #$00
STA $2005
STA $2005
LDY $FF ;Initialize other variables
LDA #$00
STA $04
STA $06
LDA #$BE
STA $05
LDA #$BF
STA $07
LDA ($04),Y ;$FF stores the room you want to load.
STA $00
LDA #$00
STA $02
LDA ($05),Y
STA $01
LDA #$60
STA $03
LDY #$00 ;Initialize decompression loop
DECOM: CPY #$F0 ;Decompress!
BEQ TSET
LDA ($00),Y
AND #$80
BEQ LIT
BNE RLE
LIT: LDA ($00),Y
AND #$7F
TAX
INX
LITL: INY
LDA ($00),Y
STA ($02),Y
DEX
BEQ LITL
JMP DECOM
RLE: LDA ($00),Y
AND #$7F
TAX
INX
INY
LDA ($00),Y
RLEL: STA ($02),Y
INY
DEX
BEQ RLEL
JMP DECOM
TSET: LDA #$20 ;Load tiles! (Tile indices are at $6000)
STA $2006
LDA #$00
STA $2006
STA $10
STA $12
STA $14
STA $16
LDA #$80
STA $11
LDA #$81
STA $13
LDA #$82
STA $15
LDA #$83
STA $17
LDX #$00
TEST: TXA
AND #$21
BEQ TM00
CMP #$01
BEQ TM01
TXA
AND #$21
CMP #$20
BEQ TM02
TXA
AND #$21
CMP #$21
BEQ TM03
JMP END
TM00: TXA
AND #$1E
LSR
STA $BF
TXA
AND #$C0
LSR
LSR
CLC
ADC $BF
TAY
LDA ($02),Y
TAY
LDA ($10),Y
STA $2007
INX
JMP TEST
TM01: TXA
AND #$1E
LSR
STA $BF
TXA
AND #$C0
LSR
LSR
CLC
ADC $BF
TAY
LDA ($02),Y
TAY
LDA ($12),Y
STA $2007
INX
JMP TEST
TM02: TXA
AND #$1E
LSR
STA $BF
TXA
AND #$C0
LSR
LSR
CLC
ADC $BF
TAY
LDA ($02),Y
TAY
LDA ($14),Y
STA $2007
INX
JMP TEST
TM03: TXA
AND #$1E
LSR
STA $BF
TXA
AND #$C0
LSR
LSR
CLC
ADC $BF
TAY
LDA ($02),Y
TAY
LDA ($16),Y
STA $2007
INX
JMP TEST
END: RTS


Unfortunately this code doesn't seem to work when I call the subroutine (after initializing the level number and palette). Any ideas?

____________________

My Youtube Channel:
Yoshimaster96smwc
Super Monkey Ball hacking!

-Yoshimaster96

Main - ROM Hacking - How come there are no tutorials on how to program a TSA? New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.018 seconds. (341KB of memory used)
MySQL - queries: 42, rows: 64/64, time: 0.015 seconds.