It is currently Tue Feb 19, 2019 3:46 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 63 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
PostPosted: Mon Jan 28, 2019 5:52 pm 
Offline

Joined: Mon Jul 18, 2011 10:04 pm
Posts: 45
So I'm a fan of text adventure games, and most today use an engine called a "Z-Machine" to play them. Recently, I came across the source code for a 6502 Z-machine I'm thinking of porting to the NES. I need some help setting up the programming environment.

I did little research first.
The Z-machine will be mapped using a MMC1 - in an SNROM or SUROM config (Perfect world, SXROM would be good, more on that later.)...

The idea is that the Z-machine kernel will reside in $C000-$FFFF

Here's where it gets kind of dicey.

A Z-machine is, for all intents and purposes, an emulator, and the actual story file will be embedded in the ROM. The kernel will bank in chunks of the story file at $8000-$BFFF and run the z-code there, when runs to the end of the page, (Or jumps to another part of z-code) then that section is banked in. Console based z-machines have been made in the past. There is one for the original Gameboy. You would have a ROM "stub" that you appended the story file to the end and then flash the whole thing to a cart. I'm thinking of doing the same thing with the NES version.

I would love to use a memory config that would allow me the most ROM and RAM, MMC1 seems the easiest and most supported if I actually want to make a cart. Having a 512K story file accessible would be awesome, but you can do a lot with 256K. Maximizing memory would be cool too, but I can live with 8k plus the zero page.

I need to know how to properly set up an environment to start porting this, or any ideas on other memory mappings that might be better. I looked at an snrom template, but that was too complicated for what I needed. (That and when I tried to compile it under windows it failed). I just need something that generates a "blank" ROM that has the iNES proper header, vectors set up, and ORG set to $C000. That way I can concatenate the story file at the end of the ROM as data.

Oh and text input would either use the NES keyboard, or an on screen equivalent.

Thoughts and assistance?


Top
 Profile  
 
PostPosted: Mon Jan 28, 2019 6:17 pm 
Offline
Formerly WheelInventor
User avatar

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1902
Location: Gothenburg, Sweden
ROM memory is relatively cheap regardless size. You don't save/spend many cents between 256k, 512k, or less/more.

You should also take a look at GTROM (available through memblers) or Mapper 30 (available through InfiniteNESlives) - both affordable, generous, popular homebrew mappers.

If you want people to play the game, i advice against designing the game around NES keyboard input. It could always be an add-on nicety, but it's just too rare.

Just in case: If the engine you found is using decimal mode anywhere, you will want to rewrite those sections since decimal mode was removed from the NES version of the 6502.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Mon Jan 28, 2019 7:43 pm 
Offline

Joined: Mon Jul 18, 2011 10:04 pm
Posts: 45
GTROM looks cool, but I need a bank window for the z-code. That seems to bank in the whole 16K bottom. Also I'm planning on developing using FCEUX because of it's really cool looking debugging tools. I need to make sure the mapper is supported. It says that UNROM 512 is supported by FCEUX r3071 and I can only find version 2.2.3 - r1600(?) Is there something newer? Maybe another emulator with a debugger maybe No$nes is better?

I still need a little help setting up the environment regardless. :)


Top
 Profile  
 
PostPosted: Mon Jan 28, 2019 7:47 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2437
Location: DIGDUG
Quote:
I came across the source code for a 6502 Z-machine


I support this project.

But...

text only seems to be a misuse of NES capabilities. Personally, I would add some kind of graphics. It's your project though, don't let my bias ruin it.


See my previous comment on your project idea...

viewtopic.php?f=5&t=17146&p=215194

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Mon Jan 28, 2019 7:52 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8141
Location: Seattle
FrankenGraphics wrote:
You don't save/spend many cents between 256k, 512k, or less/more.
This is slightly off topic, so I'll just say this and stop:

For a simple mapper, Greenliant and Microchip sell 5V Flash in sizes ranging 64 KiB through 512 KiB, for prices around 0.8 - 1.3 USD per in qty 100.

Larger memories are available, but there's a significant cost bump from 512 KiB to 2 MiB.



dougeff wrote:
text only seems to be a misuse of NES capabilities. Personally, I would add some kind of graphics.
There's a tool on smspower forum to convert Twine games to the SMS. It even supports limited graphics.


Top
 Profile  
 
PostPosted: Mon Jan 28, 2019 8:37 pm 
Offline

Joined: Mon Jul 18, 2011 10:04 pm
Posts: 45
dougeff wrote:
Quote:
I came across the source code for a 6502 Z-machine


I support this project.

But...

text only seems to be a misuse of NES capabilities. Personally, I would add some kind of graphics. It's your project though, don't let my bias ruin it.


See my previous comment on your project idea...

viewtopic.php?f=5&t=17146&p=215194


Oh! Z-Machine is an open standard, and the 6502 code I have is on the MIT license. You can make your own Z-Machine game using Inform 7

There is a lot oh ho-humming about the input system. There are lots of console text input systems for text adventure games. I have played many in the past. (On both Japanese and English) They are super intuitive and do more than just pop a keyboard on the screen.

Thanks for all the mapper ideas, but, like I said, I'm limited to what's available via emulation first. I don't own an NES as of right now and I don't want to invest in hardware unless my idea proves feasible. This means I'm limited to mappers that are supported by emulators with robust debugging functions.

What's really stymied me now is getting an environment set up in windows so I can have ca65 (well, actually ld65) spit out a proper rom. I'n new to to the NES scene, but *VERY* old hat to 6502. (My wheelhouse is reversing Apple II games). I'm very used to creating .s file with a ORG at whatever the entry point is and have it spit out a binary blob. The NES is strange as I have to make the linker spit out a proper rom. (With lots of blank filler pages). I'm going though the ld65 docs now. but it's a but vague on the -t nes option Like I said, the SNROM template is much too complicated for what I'm trying to do, with all it's includes and such. I'm porting a monolithic .s file

In a perfect world having a simple 5 or 10 line .s file with just the vectors and an ORG directive, along with the proper linker arguments would help. (By all means keep the mapper advice coming!)


Top
 Profile  
 
PostPosted: Mon Jan 28, 2019 9:01 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2437
Location: DIGDUG
Quote:
it's a but vague on the -t nes option


It doesn't do anything useful.

Only if you use cc65 c compiler, and include... conio.h/conio.c or time.h or nes.h... does it do anything.

which I wouldn't use any of these.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Jan 29, 2019 2:50 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 894
It does do something useful. The default is c64, which uses some weird encoding instead of ASCII. That can in some situations corrupt/break your embedded text.


Top
 Profile  
 
PostPosted: Tue Jan 29, 2019 2:55 am 
Offline
Formerly WheelInventor
User avatar

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1902
Location: Gothenburg, Sweden
Quote:
GTROM looks cool, but I need a bank window for the z-code. That seems to bank in the whole 16K bottom.


Technically GTROM doesn't split the 32kB program window at all. What memblers' tool does is interleave, at your option, a segment of code as if it was a fixed 16k bank by copying it at the same adress to all 32kB banks. This is a configuration out of convenience and tradition, but using your own configuration in ld65 you could make the "fixed bank" segment any size you'd like - 8kB:s, 6kB:s, 5321 bytes... anything you might want; doesn't matter.

Actually, you can do this with any 32kB swappable bank mapper, not just GTROM, which may open some options for you. The drawback is the sacrifice of rom space of course. With membler's tool, you'd be reducing the 512kB:s to 256 effective kB:s. With an 8kB fixed bank, you have 384 kB:s at your disposal. And so on. It's quite versatile though in that you can tailor the "fixed" bank to be exactly as large as your program, which means you can keep a lot of data visible at the same time.


Yeah, GTROM hasn't made its way into vanilla FCEUX yet, you need to use an interim build or memblers' fork, listed on the wiki page. Else, i think only Mesen and PowerPak (a virtual cartridge), as of novasquirrels' contribution, supports it. Mesen supports all features (well, except the on-cartridge LED controls of course), and is overall great as a developer/debugging tool.


@lidnariq, ah you're right, i remember there was a bump between 512kB and the next tier. iirc, that evens out once you go even more upwards, provided the mapper can support it. But then we're talking about amounts of storage you'd probably only need for streaming audio or video or make a DOS-like point and click adventure game with loads of unique graphics.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Tue Jan 29, 2019 5:18 am 
Offline
NESICIDE developer
User avatar

Joined: Mon Oct 13, 2008 7:55 pm
Posts: 1082
Location: Minneapolis, MN
halkun wrote:
I still need a little help setting up the environment regardless. :)

I'd be willing to add support for mapper 111 GTROM to nesicide. Have you considered it? I have a basic "Hello World" template in asm available in the IDE that sets everything up for you and even...wait for it...prints Hello World to the screen. :D
Image


Top
 Profile  
 
PostPosted: Tue Jan 29, 2019 5:51 am 
Offline
Formerly WheelInventor
User avatar

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1902
Location: Gothenburg, Sweden
(ot, but fwiw project blue is managed from nesicide and was at a point targeting gtrom. it's just that we're currently using a similar mapper (edit: BNROM) that more emulators accept since we we're not using any exclusive gtrom features for this game).

edit for claritfication.

_________________
http://www.frankengraphics.com - personal NES blog


Last edited by FrankenGraphics on Wed Jan 30, 2019 2:45 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Tue Jan 29, 2019 6:24 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2437
Location: DIGDUG
Quote:
The default is c64


No. The default is NULL, which indexes in the target enum to TGT_NONE, which sets target as "none" and target CPU as CPU_6502.... and sets the character map to "CTNone" which is the same character map that is set if NES is target.

I don't see anything in the source code which makes me change my opinion.

https://github.com/cc65/cc65/blob/153bb ... n/target.h

https://github.com/cc65/cc65/blob/153bb ... n/target.c

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Jan 29, 2019 8:33 am 
Online

Joined: Fri Feb 24, 2012 12:09 pm
Posts: 812
Just a warning: You may need a good bit more than 8 Kbytes of RAM. How much depends on the game, common might be something like perhaps 12..30 Kbytes for the game state, plus about as much memory for each savestate.
Most of the RAM is initialized by copying initial data from ROM, the gameboy version redirects all RAM reads to the initial ROM values - unless the RAM content was changed.
With that trick, it does require only "0 bytes" of RAM when the game starts, but eats up 3 bytes per changed RAM location (for storing address and data). I have got several bug reports saying that the Hitchhiker's Guide is quickly running out of memory.


Top
 Profile  
 
PostPosted: Tue Jan 29, 2019 8:53 am 
Offline

Joined: Mon Jul 18, 2011 10:04 pm
Posts: 45
Z-Machine has it's own text encoding so there is a translation layer to ASCII anyway. Note that Z-machine was designed in 1979 for minicomputers. There's a version for the ZX Spectrum that little guy only has 16K of ram and a tape loader. "Out of the Box" the NES has enough resources to run a Z-Machine engine.

Zeugma, the 6502 engine I found, has lots of C64 dependencies, but that is for input, output, and storyfile storage. The Z-machine engine can be reduced down to String input, and text line output. and everything else is internal. There will be a bit of cleaning out of Zeugma to get the NES hooks in. The means the screen will be a 28x30 text display and not the fancy bit mapped one from the C64 version. Maybe I'll use PPUSCROLL to scroll the text, but I want to use the second nametable for the text input system.

Heck, my first Z-machine game I ever played was on a Tandy Color Computer 2 and that didn't even have lowercase letters :)

Nesicide looks cool, but there isn't a Windows version. The download link is broken. Shame as that looks really promising!

Looking at nocash's warning (HI! BIG FAN! LOVED YOUR PSX WORK!!!!) maybe memory banked ram too? Zeugma has a virtual ram system in it I can borrow. I hope I'm not crawling out of realm of feasibility,


Top
 Profile  
 
PostPosted: Tue Jan 29, 2019 8:54 am 
Offline
Formerly WheelInventor
User avatar

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1902
Location: Gothenburg, Sweden
Both UNROM 512 and GTROM can self-flash, provided your writer routine runs from internal RAM. You can treat the whole 512kB chip as a persistent RAM of sorts. You just want to avoid writing to fROM continously during program. User triggered, spread out stage changes in a text/turn based game is not a problem.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 63 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google Adsense [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group