Kuribo64
Views: 19,854,341 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
03-29-24 05:38 AM
Guest:

0 users reading Need help with NES 6502! | 1 bot

Main - Computers and technology - Need help with NES 6502! Hide post layouts | New reply


Yoshimaster96
Posted on 02-05-15 03:29 AM (rev. 2 of 02-05-15 03:29 AM) Link | #55887
;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
SHOW: ;Do something with the values at $6000 here.
RTS

How would I display the macro tiles located at $6000 in RAM?

Also note that the tiles are located at $8000-$83FF. Tile $00 is at $8000, $8100, $8200, and $8300. Tile $01 is at $8001, $8101, $8201, and $8301. And so on.

My Youtube Channel:
Yoshimaster96smwc
Some layout tips/code!

-Yoshimaster96


Main - Computers and technology - Need help with NES 6502! Hide post layouts | New reply

Page rendered in 0.022 seconds. (2048KB of memory used)
MySQL - queries: 28, rows: 106/106, time: 0.012 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.