I'm new to NES development but not programming and assembly in general. I'm working on a project just to get myself used to development for the system and stuff like that, and so far I've been pretty successful with it, mostly because I've stayed within the realms of what knowledge I already have. My project is a program that will run Conway's Game of Life.
What I've designed so far is an 8x8 board, which is a 64 byte array, one byte being one cell in the game. I know it'd be possible to write it so that one bit represents one cell and cut my memory in 8, but that seems like it'd require a lot more code to deal with, and I'll save that for a later revision. I've decided that the walls of the board wrap around, so the cell immediately to the left of the upper left corner is logically the upper right corner, and so on. In order to deal with this, I have divided the cells up into 9 "groups" or "areas", the middle (default case), upper-left (table offset 00), upper-right (table offset 07), lower-left (table offset 38), lower-right (table offset 3F), top side (table offset 01-06), left side (table offset mod 8 = 0), right side (table offset mod 8 = 7), and bottom (table offset 39-3E). There is a different section of code for counting the neighbors for each of these areas. I'm hoping that there's some way of making one general case that can handle all of these cases without needing to check for them explicitly, as I have done.
Here's a table showing what the offset for the array is for each cell. The #s in Red mean that there isn't actually a cell there, it's just logically there. I used this to make it easier when figuring out what the neighbors of a cell near the border were.
Here's the code that I have so far:
http://userpages.umbc.edu/~mod1/life.asm
I wrote it, assembled, and ran it using 6502 simulator; it doesn't do any input or output, but by watching the values change in memory lets me see that the code is doing what it's supposed to do. I just set a breakpoint at the start of LIFECYCLE and ran through each cycle, and using that it looks like any Life simulator on the net. Different starting organisms can be put in by changing the MAKELIFE section of the code.
The things that I'd like to have help on are how I can turn this into code that will run on an NES, and any simpler methods of dealing with the border wraparound. My eventual goal is an NES ROM in which a player can use the controller to enter in which cells are alive and dead, as well as load several pre-defined patterns. I'm taking this one step at a time, and right now I at least have working code for the Life logic. The next step is adding graphics, which I'm at a bit of a loss for, and then player input, in which I'm even more at a loss for.
My aim screenname is OroKenshinor0 if any experienced, generous soul would like to walk me through the next step in my plan. Any other general comments or suggestions would be highly welcome. Thanks a lot
What I've designed so far is an 8x8 board, which is a 64 byte array, one byte being one cell in the game. I know it'd be possible to write it so that one bit represents one cell and cut my memory in 8, but that seems like it'd require a lot more code to deal with, and I'll save that for a later revision. I've decided that the walls of the board wrap around, so the cell immediately to the left of the upper left corner is logically the upper right corner, and so on. In order to deal with this, I have divided the cells up into 9 "groups" or "areas", the middle (default case), upper-left (table offset 00), upper-right (table offset 07), lower-left (table offset 38), lower-right (table offset 3F), top side (table offset 01-06), left side (table offset mod 8 = 0), right side (table offset mod 8 = 7), and bottom (table offset 39-3E). There is a different section of code for counting the neighbors for each of these areas. I'm hoping that there's some way of making one general case that can handle all of these cases without needing to check for them explicitly, as I have done.
Here's a table showing what the offset for the array is for each cell. The #s in Red mean that there isn't actually a cell there, it's just logically there. I used this to make it easier when figuring out what the neighbors of a cell near the border were.
Here's the code that I have so far:
http://userpages.umbc.edu/~mod1/life.asm
I wrote it, assembled, and ran it using 6502 simulator; it doesn't do any input or output, but by watching the values change in memory lets me see that the code is doing what it's supposed to do. I just set a breakpoint at the start of LIFECYCLE and ran through each cycle, and using that it looks like any Life simulator on the net. Different starting organisms can be put in by changing the MAKELIFE section of the code.
The things that I'd like to have help on are how I can turn this into code that will run on an NES, and any simpler methods of dealing with the border wraparound. My eventual goal is an NES ROM in which a player can use the controller to enter in which cells are alive and dead, as well as load several pre-defined patterns. I'm taking this one step at a time, and right now I at least have working code for the Life logic. The next step is adding graphics, which I'm at a bit of a loss for, and then player input, in which I'm even more at a loss for.
My aim screenname is OroKenshinor0 if any experienced, generous soul would like to walk me through the next step in my plan. Any other general comments or suggestions would be highly welcome. Thanks a lot