I Made a Sudoku Thing

Discussion of development of software for any "obsolete" computer or video game system. See the WSdev wiki and ObscureDev wiki for more information on certain platforms.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: I Made a Sudoku Thing

Post by tokumaru »

nicklausw wrote:Gotta say though, part of what was keeping me from the NES was the fact that I never could figure out what a CHR-ROM is. Now I know, but still, thought it was this random huge file you had to generate somehow.
You can use CHR-RAM instead, and it will be exactly like on the Master System. =)

Some emulators don't like mapper 0 ROMs to use CHR-RAM though, so you may have to go with mapper 2 (UNROM) or 34 (BNROM), even if you don't need more than 32KB of PRG-ROM.

Honestly though, CHR-ROM is easier to use most of the time. The tiles are just there for you to use, no need to copy/decompress them from PRG-ROM to VRAM.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: I Made a Sudoku Thing

Post by Drew Sebastino »

tokumaru wrote:Honestly though, CHR-ROM is easier to use most of the time. The tiles are just there for you to use, no need to copy/decompress them from PRG-ROM to VRAM.
You don't have to worry about finding slots for the objects (or sprites, in psychopathicteen and I's case) which takes away CPU time. You could always just animate the player by updating vram and nothing else, but then you wouldn't be able to store that much animation. Another thing that stinks about vram (on the SNES, at least) is that you can't update much every frame, only about 2.5 64x64 sprites due to bandwidth restrictions. I would much rather be able to change character positions for sprites than finding empty space in vram, uploading it, and then changing the character bits anyway.
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: I Made a Sudoku Thing

Post by Sik »

But you can load multiple frames of an animation into video memory if needed...
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: I Made a Sudoku Thing

Post by tepples »

Espozo wrote:One thing I wonder though: has there ever been a cartridge system that used vram that could be expanded in the cartridge?
Videomation and RacerMate Challenge II have more than 8K of CHR RAM.
I just think CHR [ROM] is the better option in terms of, basically anything but cost, (that's basically why every 80's-90's arcade board uses it, including the Neo Geo) and vram is only good for cost effective reasons.
There are plenty of effects that work best with CHR RAM. How would you do, say, a variable width font engine with CHR ROM?

Image
Game description page from Action 53 prototype


Or stack more sprites than your video memory bandwidth normally allows, as in Hatris?

Image

Or align game objects to areas smaller than one tile, as in Qix that ultimately runs on a 2x2 grid?

Image
Qix, #67 in IGN's top 100 NES games


Or draw lines at arbitrary angles like in Elite?

Image

Port Star Fox to Neo Geo and then tell me what Nintendon't. If the Super FX is cheating, port Wolfenstein 3D, Jurassic Park (for Super NES), or FaceBall 2000 (which runs on a Game Boy of all things).
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: I Made a Sudoku Thing

Post by nicklausw »

(I might as well start a topic under NESDev called "nicklausw's stupid questions")

Uh, this might make me sound like an idiot, but I honestly can't figure out how .orgs work in asm6.

See, when I see ".org $c000", I expect to open up a hex editor and see the following data under $c000. It doesn't seem to work that way, though. At the beginning of the ROM I see:

Code: Select all

4E 45 53 1A 01 01 10 00 00 00 00 00 00 00 00 00 78 D8 A2 40 8E 17 40 A2 FF 9A E8 8E 00 20 8E 01 20 8E 10 40 20 3B C0 A9 00 95 00 9D 00 01 9D 00 02 9D 00 04 9D 00 05 9D 00 06 9D 00 07 A9 FE 9D 00 03 E8 D0 E2 20 3B C0 4C 38 C0 2C 02 20 10 FB
Basically the ines header along with all my .org'ed code. And when I go to what's presumably $fffa (the end of the file,) I see stuff I had put there too, but at a very different location than $fffa.


In general, I don't really understand this. Is it just a NES-specific thing that asm6 simply works with? Or am I going insane?



Edit: later on you'll find I figured this out, but I'll post on this one what I didn't get.

In WLA, .org means to go to this point in ROM, minus the slot. With asm6 the first .org just does the equivalent of setting the slot in WLA. The location of the code output is the same.
Last edited by nicklausw on Sun Jun 07, 2015 8:24 am, edited 1 time in total.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: I Made a Sudoku Thing

Post by Drew Sebastino »

Sik wrote:But you can load multiple frames of an animation into video memory if needed...
But it's slow... Like I've said before, you're not going to see anything like this: (If you have enough CHR ROM, than it's fine. The problem then was that it cost too much, but that doesn't really matter now.)
Image
(What the heck is going on with the picture? It was fine when I found it...)
tepples wrote:Or stack more sprites than your video memory bandwidth normally allows, as in Hatris?
That affect is way more limited than more overdraw though. You only have one palette and on the SNES, it has to fit in a 256x128 box. Again, there's not enough bandwidth either.
tepples wrote:Or align game objects to areas smaller than one tile, as in Qix that ultimately runs on a 2x2 grid?
Well, you could make it using 65536 tiles. :lol:
tepples wrote:Videomation and RacerMate Challenge II have more than 8K of CHR RAM.
I was actually thinking of something like the SNES having more vram through the cart. I don't know why they didn't set up the system to have something like that, but I guess you'd have to add another bus or something to go to the cartridge.
tepples wrote:Or draw lines at arbitrary angles like in Elite?
Well, you got me there... I don't really have a problem with vram, as long as there's a good amount of bandwidth, and the SNES doesn't really have that.

One thing I wonder though: How can sprites and tiles on the NES even take advantage of more tiles in CHR ROM if they don't have that many bits to select tiles?
Last edited by Drew Sebastino on Fri May 15, 2015 7:07 pm, edited 1 time in total.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: I Made a Sudoku Thing

Post by tokumaru »

nicklausw wrote:See, when I see ".org $c000", I expect to open up a hex editor and see the following data under $c000. It doesn't seem to work that way, though.
That's because the NES maps the cartridge ROM at $8000-$FFFF (the upper half of the address space), so file offsets (what the hex editor shows you) don't match 1:1 with the CPU's address space.

Adding to that, there's the NES header, which changes the offset by 16 bytes.

Since the CPU sees the program at $8000, but in the file it starts at $10 (i.e. after the header), you have to add/subtract $7FF0 when converting between CPU space and file space. So if you want to see what will show up at CPU position $FFFA, look at offset $800A in the hex editor.

There's hardly any reason to do this though... it would be better to use FCEUX's built-in hex editor, which will show you the memory as the CPU sees it, so you don't have to convert addresses. It can also show other addressing spaces, such as the PPU, and even the ROM file, like an external hex editor would.

I can see where your confusion comes from, since the Master System maps cartridges starting from $0000 and ROM files have no headers. It's just a happy coincidence that file offsets match the CPU addresses though, since this choice was made because the Z80 has interrupt vectors at the beginning of the addressing space, while the 6502 has its vectors at the end.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: I Made a Sudoku Thing

Post by tepples »

Espozo wrote:That affect is way more limited than more overdraw though. You only have one palette and on the SNES, it has to fit in a 256x128 box. Again, there's not enough bandwidth either.
You can composite to the background, which is what Hatris, Zoop, RHDE, and the Action 53 menu do. There's more than enough background memory for the whole screen even in 8bpp mode, so long as not everything moves every frame. In Hatris and Zoop, the field changes only when pieces are added or removed. In Action 53 and RHDE, only one line of text changes in each frame.
Espozo wrote:One thing I wonder though: How can sprites and tiles on the NES even take advantage of more tiles in CHR ROM if they don't have that many bits to select tiles?
Bank switching. A mapper circuit on the cartridge controls the CHR ROM's upper address lines based on values selected by the CPU.

For example, the FME-7, a mapper chip used in later Sunsoft games, divides CHR ROM into 1024 byte banks, and it divides the pattern table address space into 1024-byte windows ($0000-$03FF, $0400-$07FF, ..., $1C00-$1FFF). The mapper lets the CPU select a bank of ROM for each window. When the PPU reads the pattern table, looks at PPU A12-A10 to see which window is being read, and it looks up the appropriate bank number to output on CHR ROM A17-A10.

Example with actual numbers: FME-7 register 5 is the CHR ROM bank number for PPU $1400-$17FF. Bank 19 of CHR ROM is $04C00-$04FFF. The CPU writes a value of 19 to register 5. Then whenever the mapper detects that the PPU is accessing $1400-$17FF (PPU A13-A10 = 0101), the FME-7 outputs 19 (CHR ROM A17-A10 = 00010011), thereby redirecting the access to CHR ROM bank 19.

PRG ROM in excess of 32 KiB needs to be bankswitched as well. The NES, SMS, or Game Boy CPU writes to a mapper register to control upper address lines of the PRG ROM, which makes different parts of the program appear to the CPU.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: I Made a Sudoku Thing

Post by Drew Sebastino »

tepples wrote:Bank switching. A mapper circuit on the cartridge controls the CHR ROM's upper address lines based on values selected by the CPU.
So you can only use one bank per frame? You can't do something like fill the entire screen with unique tiles?

About the 8bpp frame buffer thing, I generally wanted to use the whole screen because I wanted multiple layers of parallax and a bunch of sprites. I've learned that what I had in mind wasn't possible without it running at 20fps and letterboxing it a ton. (I'd also need a good expansion chip for plotting the pixels.) I wouldn't mid the SNES's capabilities if it had more overdraw. I've never been pleased with BG 3 either, but I have to understand that it's a console that was released in 1990/1991 and was developed in 1986.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: I Made a Sudoku Thing

Post by nicklausw »

tokumaru wrote:
nicklausw wrote:See, when I see ".org $c000", I expect to open up a hex editor and see the following data under $c000. It doesn't seem to work that way, though.
That's because the NES maps the cartridge ROM at $8000-$FFFF (the upper half of the address space), so file offsets (what the hex editor shows you) don't match 1:1 with the CPU's address space.

Adding to that, there's the NES header, which changes the offset by 16 bytes.

Since the CPU sees the program at $8000, but in the file it starts at $10 (i.e. after the header), you have to add/subtract $7FF0 when converting between CPU space and file space. So if you want to see what will show up at CPU position $FFFA, look at offset $800A in the hex editor.

There's hardly any reason to do this though... it would be better to use FCEUX's built-in hex editor, which will show you the memory as the CPU sees it, so you don't have to convert addresses. It can also show other addressing spaces, such as the PPU, and even the ROM file, like an external hex editor would.

I can see where your confusion comes from, since the Master System maps cartridges starting from $0000 and ROM files have no headers. It's just a happy coincidence that file offsets match the CPU addresses though, since this choice was made because the Z80 has interrupt vectors at the beginning of the addressing space, while the 6502 has its vectors at the end.
Thanks, that makes sense. And you're right, I'm used to handling ROMs that are basically exact copies of what'd be on the cartridge (no rom header) and mapped right at the origin.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: I Made a Sudoku Thing

Post by tokumaru »

Espozo wrote:So you can only use one bank per frame?
Older mappers swap the entire 8KB of CHR-ROM as a single block, but newer mappers divide that space in areas as small as 1KB (64 tiles), so you have 8 banks mapped at any given time.
You can't do something like fill the entire screen with unique tiles?
You can if you use scanline IRQs to bankswitch mid-screen.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: I Made a Sudoku Thing

Post by tepples »

Espozo wrote:
tepples wrote:Bank switching. A mapper circuit on the cartridge controls the CHR ROM's upper address lines based on values selected by the CPU.
So you can only use one bank per frame? You can't do something like fill the entire screen with unique tiles?
Smash TV uses the MMC1 mapper. Its title screen uses several banks of CHR ROM, switching banks between one scanline and the next.

Super Mario Bros. 3 uses the MMC3 mapper. It switches CHR banks between the playfield and the status bar. Cosmic Epsilon also uses the MMC3 mapper. It switches banks after every scanline to draw a texture-mapped 3D road.

Pirates and Marble Madness switch banks mid-scanline using very precisely timed code. Mike Tyson's Punch-Out!!, Fire Emblem, and Famicom Wars use the MMC2 and MMC4 mappers, which treat the pattern table addresses associated with "magic" tile numbers $FD and $FE as triggers to perform mid-scanline bank switches.
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: I Made a Sudoku Thing

Post by Sik »

Espozo wrote:
Sik wrote:But you can load multiple frames of an animation into video memory if needed...
But it's slow...
Um no, it's the exact opposite since you load it once during loading time then leave it there. The problem is that it eats up more memory than needed (which also tends to result in dumbed down animations to compensate), so it's a matter of whether you have enough spare memory to keep the graphics around.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: I Made a Sudoku Thing

Post by Drew Sebastino »

Sik wrote:
Espozo wrote:
Sik wrote:But you can load multiple frames of an animation into video memory if needed...
But it's slow...
Um no, it's the exact opposite since you load it once during loading time then leave it there. The problem is that it eats up more memory than needed (which also tends to result in dumbed down animations to compensate), so it's a matter of whether you have enough spare memory to keep the graphics around.
Well, it is a problem if you're constantly updating the graphics because they won't all fit in vram like DKC.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: I Made a Sudoku Thing

Post by nicklausw »

tokumaru wrote: That's because the NES maps the cartridge ROM at $8000-$FFFF (the upper half of the address space), so file offsets (what the hex editor shows you) don't match 1:1 with the CPU's address space.
Okay, one more question: in this case, does asm6 have a default base targeting the NES mapper?
Post Reply