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

0 users currently in ROM Hacking | 1 guest | 1 bot

Main - ROM Hacking - I don't believe in giving up... New thread | New reply

Pages: 1 2 3

RetroRain
Posted on 12-31-07 11:32 AM Link | Quote | ID: 72442


Fuzz Ball
Level: 66

Posts: 7/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
I am more than frustrated. I stay up late, do an all-nighter, staring at text documents, reading whatever I can read. I'm obsessed. I want to learn how to program the NES, because I don't believe it is that hard to do. I think it is easy once you get to know it. Easy, but also a big pain in the butt. So, how exactly do you code it? I have been messing around with lots of different code structures.

Here is my personal code, that I wrote recently:

; Biohazard 1.5 Homebrew Project

; The first thing we need to do, is set up the INES header.

headerset:

.inesprg 1 ; specify how many PRG banks to use. For now we are going to use 1.
.ineschr 1 ; specify how many CHR banks to use. For now we are going to use 1.
.inesmir 1 ; mirroring. We are going to be doing mirroring. Set to 1.
.inesmap 0 ; Mapper 0 = no mapper. We aren't going to use one right now.

.bank 0 ; Use bank 0.
.org $8000 ; PRG-code will start at $8000.

cld ; clear decimal mode.
sei ; set interrupt disable status.

; Once the header is set up, we need to set up the PPU.

ppuset:

lda #%00001000
sta $2000
lda #%00011110
sta $2001

; Once the ppu is set up, we need to set up the palette next.

paletteset:

; This positions $2006 to $3F00, where can proceed to set up the palette.

lda #$3F
sta $2006
lda #$00
sta $2006

; Write palette data.

lda #$01
sta $2007
lda #$02
sta $2007
lda #$03
sta $2007
lda #$04
sta $2007
lda #$05
sta $2007
lda #$06
sta $2007
lda #$07
sta $2007
lda #$08
sta $2007
lda #$01
sta $2007
lda #$08
sta $2007
lda #$09
sta $2007
lda #$0A
sta $2007
lda #$01
sta $2007
lda #$0B
sta $2007
lda #$0C
sta $2007
lda #$0D
sta $2007
lda #$01
sta $2007
lda #$0D
sta $2007
lda #$08
sta $2007
lda #$2B
sta $2007
lda #$01
sta $2007
lda #$05
sta $2007
lda #$06
sta $2007
lda #$07
sta $2007
lda #$01
sta $2007
lda #$08
sta $2007
lda #$09
sta $2007
lda #$0A
sta $2007
lda #$01
sta $2007
lda #$0B
sta $2007
lda #$0C
sta $2007
lda #$0D
sta $2007

reset:
jmp headerset

vblank:
rti
irq:
rti

.bank 1 ; Bank 1
.org $FFFA ; Start at $FFFA. This is where we put the interrupt stuff.
.dw vblank, reset, irq

.bank 2 ; Bank 2
.incbin "graphics.chr" ; include our graphics file

Other documents I have read, have it layed out differently. So sure, there is more than one way to make the NES do stuff. It depends on what you want it to. But damn, I'm not understanding the structure here.

I have to try to be as specific as possible, because if I don't, you guys won't understand me. This code, when compiled, doesn't do anything. Thats because I wrote it myself. I had code earlier, much simpler code, that I copied from a document, that works when compiled. All I want to do, for starting out, is be able to make a title screen with the graphics I have.

What I want to do, is make a homebrew rom, a Resident Evil 2D game, for another community I am a part of.

Can anyone provide me with simple code for a title screen, or maybe explain some stuff to me? *Rockman is frustrated XD*

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

This code here, I compiled the first several times I did it, and it worked. All of sudden tonight, its not working for me, and I don't know why. It compiles, but it doesn't show me the graphics in the PPU viewer.

.inesprg 1
.ineschr 1
.inesmir 1
.inesmap 0

.org $8000
.bank 0

Start:

;this sets up the PPU
lda #%00001000
sta $2000
lda #%00011110
sta $2001

;set to start of palette
lda #$3F
sta $2006
lda #$00
sta $2006

;these are the writes that setup the palette
lda #$01
sta $2007
lda #$02
sta $2007
lda #$03
sta $2007
lda #$04
sta $2007
lda #$05
sta $2007
lda #$06
sta $2007
lda #$07
sta $2007
lda #$08
sta $2007
lda #$01 ;stop here
sta $2007
lda #$08
sta $2007
lda #$09
sta $2007
lda #$0A
sta $2007
lda #$01
sta $2007
lda #$0B
sta $2007
lda #$0C
sta $2007
lda #$0D
sta $2007
lda #$01 ;Start sprite colors
sta $2007
lda #$0D
sta $2007
lda #$08
sta $2007
lda #$2B
sta $2007
lda #$01
sta $2007
lda #$05
sta $2007
lda #$06
sta $2007
lda #$07
sta $2007
lda #$01
sta $2007
lda #$08
sta $2007
lda #$09
sta $2007
lda #$0A
sta $2007
lda #$01
sta $2007
lda #$0B
sta $2007
lda #$0C
sta $2007
lda #$0D
sta $2007

Loop:
jmp Loop

.bank 1
.org $FFFA
.dw 0 ;(NMI_Routine)
.dw Start ;(Reset_Routine)
.dw 0 ;(IRQ_Routine)

.bank 2
.org $0000
.incbin "test.chr" ;gotta be 8192 bytes long

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

another thing i don't get is that loop code. If code is executed in sequential order, wouldn't the bank codes below it not get executed? correct me if i'm wrong, but i think the loop has to do something with vblank.

the rest of the code, i understand.

from the ines, to the ppu setup, to the palette setup, that i get. I'm confused about the interrupts, setting them up, and can't figure out why i can't get graphics to show up in my pattern table. All there is, is screens with fully loaded palettes. I'll show some pics..........

This is what is on my CHR file.



Thats all that is there. Yeah, it says BIOHAZARD 2 (Resident Evil 2) with an eye in the background. That is all that is on my CHR file. all i want to do is something simple, get that to display in the PPU viewer.

Now, here is the code copied from the document:

.inesprg 1
.ineschr 1
.inesmir 1
.inesmap 0

.org $8000
.bank 0

Start:

;this sets up the PPU
lda #%00001000
sta $2000
lda #%00011110
sta $2001

;set to start of palette
lda #$3F
sta $2006
lda #$00
sta $2006

;these are the writes that setup the palette
lda #$01
sta $2007
lda #$02
sta $2007
lda #$03
sta $2007
lda #$04
sta $2007
lda #$05
sta $2007
lda #$06
sta $2007
lda #$07
sta $2007
lda #$08
sta $2007
lda #$01 ;stop here
sta $2007
lda #$08
sta $2007
lda #$09
sta $2007
lda #$0A
sta $2007
lda #$01
sta $2007
lda #$0B
sta $2007
lda #$0C
sta $2007
lda #$0D
sta $2007
lda #$01 ;Start sprite colors
sta $2007
lda #$0D
sta $2007
lda #$08
sta $2007
lda #$2B
sta $2007
lda #$01
sta $2007
lda #$05
sta $2007
lda #$06
sta $2007
lda #$07
sta $2007
lda #$01
sta $2007
lda #$08
sta $2007
lda #$09
sta $2007
lda #$0A
sta $2007
lda #$01
sta $2007
lda #$0B
sta $2007
lda #$0C
sta $2007
lda #$0D
sta $2007

Loop:
jmp Loop

.bank 1
.org $FFFA
.dw 0 ;(NMI_Routine)
.dw Start ;(Reset_Routine)
.dw 0 ;(IRQ_Routine)

.bank 2
.org $0000
.incbin "graphics.chr" ;gotta be 8192 bytes long

The "graphics.chr" is obviously my chr file. COMPILE IT..........THEN.......

Open up the emu.



Where's my background???? It should at least show up in the PPU Viewer, not the Name Table or emulator screen. It should at least show up in the PPU Viewer. That code compiled, was taken right from an actual document. How come its not working????

I'm sorry if I'm unclear, or if I seem noobish or whatever. Its just that I'm tired. Its 5:30 AM in the morning, and I'm tired and frustrated. Any help would be greatly appreciated.

____________________
My YouTube Channel

Sliver X
Posted on 12-31-07 07:31 PM Link | Quote | ID: 72458


Paragoomba
Level: 20

Posts: 24/66
EXP: 42429
Next: 10

Since: 02-26-07
From: WV

Last post: 5481 days
Last view: 5336 days
Remember that you're using an emulator, which can't run all code that would be valid on a real NES due to inaccuracies in emulation.

On top of that, you're using FCEUXD, an emu that is really starting to show its age at the core. Shame it's also coupled with the best debugging environment for the NES (Or just about any system, really).

Give it a spin in Nestopia and see if it runs: It's by far the most accurate of the NES emulators at this point in time.

____________________
Arc-Nova.org: More Chiptunes Than Your Mother Can Handle

Ailure
Posted on 12-31-07 08:25 PM Link | Quote | ID: 72463

Hats
Steam Board2 group
Level: 121

Posts: 2052/3965
EXP: 19767747
Next: 288949

Since: 02-19-07
From: Sweden, Skåne

Last post: 3294 days
Last view: 2045 days
Well, Nestopia might give him the same (or worse) problem. My old homebrewn dosen't run at all in Nestopia, since it seems like I depended on some inaccuracy... that I hadn't been able to figure out. xD

____________________
AIM: gamefreak1337, MSN: Emil_sim@spray.se, XMPP: ailure@xmpp.kafuka.org


Celice
Posted on 12-31-07 11:44 PM Link | Quote | ID: 72486


Buzz Blob
Level: 39

Posts: 125/285
EXP: 379535
Next: 25236

Since: 04-06-07
From: Oroville, CA

Last post: 3679 days
Last view: 3640 days
Just as a tidbit of info, there's already a Biohazard 1.5-ish Chinese pirate floating around on some ROM sites, for the Famicom too. It's incredibly buggy, though, and randomly crashes on me. But hey, it plays just like RE: Gaiden on the GameBoy Color :o

RetroRain
Posted on 01-01-08 12:00 AM Link | Quote | ID: 72488


Fuzz Ball
Level: 66

Posts: 8/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
Well guys, I finally figured out why it wasn't showing up. It was actually pretty simple:

Instead of this:

.bank 1
.org $FFFA
.dw 0 ;(NMI_Routine)
.dw Start ;(Reset_Routine)
.dw 0 ;(IRQ_Routine)

.bank 2
.org $0000
.incbin "test.chr" ;gotta be 8192 bytes long

It had to be this:

.bank 2
.org $0000
.incbin "test.chr" ;gotta be 8192 bytes long

.bank 1
.org $FFFA
.dw 0 ;(NMI_Routine)
.dw Start ;(Reset_Routine)
.dw 0 ;(IRQ_Routine)

Yeah, unbelievable eh? The interrupt bank has to be the last bank in the code. I switched those two sets of code, and it worked.

But now, I'm faced with another problem. Hopefully less complicated:



This is where I'm at now. Which is almost what I wanted. What I want to do, is see the title screen how it looks in the PPU Viewer? Thats the way I want it to show up on the screen. Anyone have any tips? Because, with the loop code I wrote, its making it look like that.

Here is the loop code I wrote:

ldx #$00
Title:
stx $2007
inx
cpx #$FF
bne Title

I guess what I need to know, is how do you specify the X and Y locations of the $2007 register? I know how to do it for SPR-RAM, but not for $2007.

____________________
My YouTube Channel

NetSplit
Posted on 01-01-08 12:55 AM Link | Quote | ID: 72489


Level: 32

Posts: 48/178
EXP: 187923
Next: 18519

Since: 02-26-07

Last post: 2210 days
Last view: 2135 days
You can determine the location you're putting tiles onscreen by writing a different address to $2006 and then writing the data to $2007. That address determines where in the name tables you're writing your data. Write it to the proper place and it'll display as you want it.

The reason your logo is displaying like that is because the pattern table is only 16 tiles wide, but the screen is 32 tiles wide. You're writing the tiles from the table as one continuous string, which means that you're assuming it's 32 tiles wide. As such, your logo is being split, with every odd row on the left and every even row on the right (since it takes 2 rows of your logo to span the screen). What you want to do is grab 16 tiles and then either do 16 tiles of black or write a new address to $2006, and then you can start on the next row. You can also position your logo onscreen by defining the starting location to be later in the nametable than the address that corresponds to the top left of the screen.

I hope that helps.

RetroRain
Posted on 01-01-08 01:15 AM Link | Quote | ID: 72491


Fuzz Ball
Level: 66

Posts: 9/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
I already tried changing $2006. It doesn't do anything.



It DOES move the scanlines to where they should be, but the image still shows on the top of the screen.

The other issue, with the tiles, I figure that out after I get this fixed. Any info you can give would be greatly appreciated. Thank you for your help guys.

____________________
My YouTube Channel

NetSplit
Posted on 01-01-08 01:39 AM Link | Quote | ID: 72492


Level: 32

Posts: 49/178
EXP: 187923
Next: 18519

Since: 02-26-07

Last post: 2210 days
Last view: 2135 days
I have very little experience with this, so I can't give you too much help (it's all based on what I remember from working on Mega Man 1's boss select screen 2 years ago). It's centered in the name table, which is great. See those two lines that intersect at the top left of the main part of the logo? The intersection is (00,00), so that's why what you see onscreen is still not centered. I have no idea how to change where that appears, since Mega Man 1 already did that for me and thus I had no reason to reverse engineer that. Check some documents for information on defining which portion of the name table is displayed onscreen.

Also, your code in the first post for defining the palettes is horribly inefficient, space-wise. Try using a loop and a table, like this:

LDX #$20
L_PalInit:
LDA table-1,X
STA $2007
DEX
BNE L_PalInit

table dc.b $0D,$0C,$0B,$01,$0A,$09,$08,$01,$07,$06,$05,$01,$2B,$08,$0D,$01,$0D,$0C,$0B,$01,$0A,$09,$08,$01,$08,$07,$06,$05,$04,$03,$02,$01

table is your palette data in reverse (reverse, since the loop is counting down instead of up). This saves a lot of space.

RetroRain
Posted on 01-01-08 07:33 AM Link | Quote | ID: 72510


Fuzz Ball
Level: 66

Posts: 10/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
Yeah, thanks for the narrowed-down palette code.

I'm stuck right now. I don't know what to do.

Programming the NES is such a bitch.

____________________
My YouTube Channel

NetSplit
Posted on 01-01-08 08:14 AM Link | Quote | ID: 72511


Level: 32

Posts: 50/178
EXP: 187923
Next: 18519

Since: 02-26-07

Last post: 2210 days
Last view: 2135 days
Okay, I've been reading around and I think I figured it out. The address that you put into $2006 looks like it will be treated as (00,00), so if you want to put the logo in the center, draw it there and then try resetting the address.

Additionally, take a look at $2005. This is the scroll register; first write handles horizontal scroll, and second write handles vertical scroll. It looks like this and $2006 together allow you full access to scrolling around the name table. Scrolling using $2006 is jumpy because it goes by tiles, but $2005 is pixel-precise (but doesn't cover the entire 512x480 pixels of the nametable), and the combination of the two allows smooth scrolling over the entire thing.

I've not tested any of this, so let me know how it works out. More information can be had here and here. If my guesses are wrong, they'll hopefully at least get you on the right track.

RetroRain
Posted on 01-02-08 05:07 AM Link | Quote | ID: 72554


Fuzz Ball
Level: 66

Posts: 11/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
Does anyone know how I can contact Sephiroth3 from DES? He was the coder for MMVen, so maybe he could help me out a little bit. The thing is, I don't know if he is still around the community, but if he has an email address, I want to try to contact him.

NetSplit, I didn't try the scroll register, because I don't really think that I have to use that to get what I want done. I'm not doubting you or anything, its just that I have been reading through tons of documents and source code, and something is telling me that $2005 is not needed. I could be wrong, but after all of this frustration, I really need to get some answers. What's funny is, its not like I'm trying to do anything big right now. I just want to get a simple title screen to show up. If I can't do that, then there is no use in trying to go further. I need to take one step at a time, and I can't allow myself to give up. Giving up won't get me anywhere, whereas trying to solve any problems that I run into, as I go, will help me learn, and allow me to succeed. I'm going to keep tackling this until I get it.

I have done a lot of coding that has lead to zero results. I tried making a table, containg 32x32 bytes of data (because thats what gets displayed on the screen, 32x32 tiles), and loading the title screen that way. No go. I tried to do the coding that you mentioned I should try, which is load 16 tiles, then load 16 blank tiles, and so on..... No go.

Maybe I coded some stuff wrong, because I didn't actually get the table code to compile. Do you know a simpler routine for loading 16 blank tiles after 16 graphics tiles? I had a tough time with that.

____________________
My YouTube Channel

NetSplit
Posted on 01-02-08 06:34 AM Link | Quote | ID: 72555


Level: 32

Posts: 51/178
EXP: 187923
Next: 18519

Since: 02-26-07

Last post: 2210 days
Last view: 2135 days
LDX #$00
LDY #$10
LDA #BlankTile
L_Write1:
STX $2007
INX
DEY
BNE L_Write1
CPX #LastTile
BEQ L_End
LDY #$10
L_Write2:
STA $2006
DEY
BNE L_Write2
LDY #$10
BNE L_Write1

L_End:
;Continue your code here

BlankTile = $00 ;If it's not #$00, set this to something else
LastTile = $B0 ;This is actually the tile after the last tile of the logo. I assume it's at the end of a row. I don't know how large your logo is.

This is probably really inefficient (Sephiroth3 is a genius and can point out inefficiencies in the shortest of code), but it works. This will write 16 tiles, then check to see if it's done. If not, it'll do 16 blank tiles and then 16 more tiles. Lather, rinse, repeat. It's good when people can figure things out on their own, but when they can't, I'm okay with giving the answer as long as you can learn from it; please study the routine I wrote and understand it so you can write things like it in the future.

Additionally, you did not read my post carefully enough. As far as I can tell, by writing to $2006, you scrolled the screen. $2005 is not the only way to scroll. It scrolls by pixel, while $2006 appears to scroll by tile. The two of these together allows for access to the entire nametable, since 16 bits can only cover 1/4 of the total pixels in the nametable. Whatever address you write to $2006 is going to be where it scrolls to. By writing an address there to center the logo onscreen, you scrolled the screen, so you need to scroll it back by writing the initial address back to $2006 when you're done drawing.

Regarding getting things to compile, if the table isn't in the format of your assembler, use a different format. I'm formatting things for assembly in Sephiroth3's FSNASM assembler, which I've been using to write a Scheme interpreter for the NES.

Finally, experiment. Don't be afraid to try random, wild things. If you make a mistake, it doesn't matter because you can always go back and try again. This writing a ROM, not performing surgery. Asking questions is good, but figuring it out yourself is both more enlightening and more satisfying. If the information in this post doesn't work out and fiddling around with the registers isn't doing anything noteworthy, I'll try to lend a hand again.

RetroRain
Posted on 01-02-08 07:40 AM Link | Quote | ID: 72557


Fuzz Ball
Level: 66

Posts: 12/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
You were right about the scrolling thing. I tried it and this is what I got.



I finally got it centered, the tile issue I'll address next, but I have one question. That green box that I highlighted, how come those graphics aren't showing up? I set $2006 to PPU Address $2148, but all thats there is blank tiles, instead of the tiles that should appear that are in the green box.

____________________
My YouTube Channel

NetSplit
Posted on 01-02-08 08:13 AM Link | Quote | ID: 72558


Level: 32

Posts: 52/178
EXP: 187923
Next: 18519

Since: 02-26-07

Last post: 2210 days
Last view: 2135 days
I'll venture a guess that you're either skipping the first row of tiles when you're writing the logo to the nametable (starting at #$10 instead of #$00), or you're writing the first row of tiles too early in memory. Keep in mind (I think) that the first #$40 bytes for each screen is used for attribute data, so it's possible that you're writing the values for the first row in the attribute data instead of tile data by writing it too early. I can't think of any other reason why the first row wouldn't be showing up. Can you post your code?

RetroRain
Posted on 01-02-08 09:13 AM Link | Quote | ID: 72562


Fuzz Ball
Level: 66

Posts: 13/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
Mission Accomplished.



However, it took a tremendous amount of coding to get it like this. But now that I got it like this, I can focus on narrowing the code down for future use.

Here is the code I used. It is long and ineffecient, but it works:

vwait:
lda $2002
bpl vwait


lda #$21
sta $2006
lda #$48
sta $2006

ldx #$00
Title1:
stx $2007
inx
cpx #$0F
bne Title1


lda #$21
sta $2006
lda #$68
sta $2006

ldx #$10
Title2:
stx $2007
inx
cpx #$1F
bne Title2


lda #$21
sta $2006
lda #$88
sta $2006

ldx #$20
Title3:
stx $2007
inx
cpx #$2F
bne Title3


lda #$21
sta $2006
lda #$A8
sta $2006

ldx #$30
Title4:
stx $2007
inx
cpx #$3F
bne Title4


lda #$21
sta $2006
lda #$C8
sta $2006

ldx #$40
Title5:
stx $2007
inx
cpx #$4F
bne Title5


lda #$21
sta $2006
lda #$E8
sta $2006

ldx #$50
Title6:
stx $2007
inx
cpx #$5F
bne Title6


lda #$22
sta $2006
lda #$08
sta $2006

ldx #$60
Title7:
stx $2007
inx
cpx #$6F
bne Title7


lda #$22
sta $2006
lda #$28
sta $2006

ldx #$70
Title8:
stx $2007
inx
cpx #$7F
bne Title8


lda #$22
sta $2006
lda #$48
sta $2006

ldx #$80
Title9:
stx $2007
inx
cpx #$8F
bne Title9


lda #$22
sta $2006
lda #$68
sta $2006

ldx #$90
Title10:
stx $2007
inx
cpx #$9F
bne Title10


lda #$22
sta $2006
lda #$88
sta $2006

ldx #$A0
Title11:
stx $2007
inx
cpx #$AF
bne Title11


lda #$20
sta $2006
sta $2006

Believe me, I tried making code to narrow this down, but it wouldn't work. I even tried the code you gave me, but it didn't work either. I remember my programming teacher telling me that if you have to repeat something over and over, you can probably use a loop to handle it and make it simpler. But I don't know how to make this simpler. It is definately a bit much just to show a title screen. If anyone could help me come up with simpler code, that would be awesome. Thanks for your help.

____________________
My YouTube Channel

NetSplit
Posted on 01-02-08 10:44 AM Link | Quote | ID: 72563


Level: 32

Posts: 53/178
EXP: 187923
Next: 18519

Since: 02-26-07

Last post: 2210 days
Last view: 2135 days
Well, my code works. I don't have to test it to know that; I've looked at it over and over and it'll run. It does the same thing as your code, for the most part. Rather than jump ahead 16 tiles by writing a new address to $2006, I write 16 blank tiles every time. Additionally, your code starts on the first tile of the logo for every row and ends on the SECOND TO LAST tile because you compared to xF instead of (x+1)0. You did INX CPX #$xF, so xF was ignored in each and every section. It just turned out not to matter since there are no graphics in that column.

Cycle-wise, not writing the 16 blank tiles is more efficient, but it doesn't really matter, since this is a title screen. You could always modify the write-blank-tiles part of my code so that it just skips ahead by #$10 bytes.

If you can't get this code compiled, then I suggest you figure out what the problem is, since it's valid code and far better than the massive stuff you're using.

vwait:
lda $2002
bpl vwait

lda #$21
sta $2006
lda #$48
sta $2006

LDX #$00
TXA
LDY #$10
L_Write1: ;Write logo's tiles
STX $2007
INX
DEY
BNE L_Write1
CPX #$B0
BEQ L_End
LDY #$10
L_Write2: ;Write blank tiles
STA $2006
DEY
BNE L_Write2
LDY #$10
BNE L_Write1

L_End:
lda #$20
sta $2006
sta $2006

never-obsolete
Posted on 01-02-08 05:05 PM Link | Quote | ID: 72575


Rat
Level: 24

Posts: 11/96
EXP: 74452
Next: 3673

Since: 02-22-07
From: Phoenix, AZ

Last post: 2589 days
Last view: 2589 days
this will write a full (uncompressed) name/attribute table to the vram destination held in X and Y. DataPtr should point to the start of the data.

DataPtr (word) needs to be on the zero-page.
PPU_ADDR = $2006
PPU_DATA = $2007

;-------------------------------SubLoadNameTable--------------------------------
; Description: Loads 1024 bytes of data into the selected name table.
;
; Arguments: X: dest addr high
; Y: dest addr low
; DataPtr, DataPtr + 1: src addr
; Return Values: (none)
;
; Routines Called: (none)
; Registers Affected: A,X,Y
; Variables Affected: (none)

SubLoadNameTable: stx PPU_ADDR
sty PPU_ADDR

lda DataPtr + 1 ; preserve DATaddrHI
pha

ldx #4 ; load name table loop
ldy #0
_sub_nametable_loop:
lda (DataPtr),y
sta PPU_DATA
iny
bne _sub_nametable_loop
;--------------------
inc DataPtr + 1
dex
bne _sub_nametable_loop

pla ; restore DATaddrHI
sta DataPtr + 1

rts
;-------------------------------------------------------------------------------

this should only be called when rendering is disabled as it will spill over vblank. eventuallly you'll probably want something more flexible, like a vram stack, but this should work for gettin sometin to the screen.

RetroRain
Posted on 01-02-08 10:20 PM (rev. 3 of 01-03-08 12:18 AM) Link | Quote | ID: 72588


Fuzz Ball
Level: 66

Posts: 14/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days
NetSplit, the only thing I don't understand in your code is the $2006.

L_Write2: ;Write blank tiles
STA $2006 ;If you are writing tiles, shouldn't you be using $2007?
DEY
BNE L_Write2
LDY #$10
BNE L_Write1

But anyway, I got your code to compile, and this is what it shows:



It just shows the first row, nothing more. This is crazy.

And never-obsolete, thank you for the code.

____________________
My YouTube Channel

NetSplit
Posted on 01-03-08 12:23 AM Link | Quote | ID: 72596


Level: 32

Posts: 54/178
EXP: 187923
Next: 18519

Since: 02-26-07

Last post: 2210 days
Last view: 2135 days
It won't show because that was a typo that I didn't see when I was looking through and I'm not using labels like I would normally be using in an assembler because you and "label = _____" don't seem to mix so far. Good catch. Fix that and it should be fine. I'll look at it some more to make sure I'm not making conceptual errors that are resulting in the logo cutting off early on.

RetroRain
Posted on 01-03-08 12:30 AM Link | Quote | ID: 72597


Fuzz Ball
Level: 66

Posts: 15/994
EXP: 2436736
Next: 25115

Since: 09-30-07

Last post: 1928 days
Last view: 950 days


I changed the $2006 to $2007. I get more of an image, but the top row gets cut off, and the bottom rows do as well.

____________________
My YouTube Channel
Pages: 1 2 3


Main - ROM Hacking - I don't believe in giving up... New thread | New reply

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

Page rendered in 0.030 seconds. (348KB of memory used)
MySQL - queries: 92, rows: 132/132, time: 0.019 seconds.