Mallard Games Posted June 17, 2019 Share Posted June 17, 2019 Hi, New to the forum, but not 6502 assembly. I was wondering if any of the homebrew gurus when developing the bigger games(16k+) used game states for tracking what point the game is in and if it was helpful or just a waste of space. Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted June 17, 2019 Share Posted June 17, 2019 Tracing was better, until Stella's time machine function came along. Quote Link to comment Share on other sites More sharing options...
Mallard Games Posted June 17, 2019 Author Share Posted June 17, 2019 15 hours ago, Nukey Shay said: Tracing was better, until Stella's time machine function came along. Not sure what your referring to when you say "Tracing" and "Time Machine", i was referring to this. I'm interested in knowing if it's a waste of space, ram & time or not and how many homebrewers actually actively use it in their games. Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 19, 2019 Share Posted June 19, 2019 I use a single byte, called GameState in my Collect Tutorial which covers writing a 2K game. It's had different names in my games, though functioned the same. I typically use bit 7 so a simple BIT GameState instruction with BMI and BPL to determine the state w/out having to mask out the lower bits, allowing them to be used for something else such as which game variation the player has selected. If I need additional states, such as for a Splash Screen, I'll use bit 6 so I can use BIT GameState with BVS and BVC. Example usage would be: bit GameState bmi GameActive jmp MainMenu GameActive: ; game logic goes here GameKernel: ; draw the game screen here MainMenu: ; menu logic goes here MenuKernel: ; draw the menu here The Kernel is the part of the program that updates TIA in real time to draw the screen. Due to limited RAM in the 2600, the state also controls how RAM is used. In Medieval Mayhem the same memory that holds the state of the castle walls is used for drawing the main menu. Wall1L ds 6 Wall1R ds 6 Wall2L ds 6 Wall2R ds 6 Wall3L ds 6 Wall3R ds 6 Wall4L ds 6 Wall4R ds 6 ; reuse of Wall RAM for main menu G48 EQU Wall1L ; uses all of Wall1L and Wall1R Option1 EQU Wall2L ; pointer to graphics for 1st displayed option Value1 EQU Wall2L+2 ; pointer to graphics for 1st displayed value Option2 EQU Wall2L+4 ; pointer to graphics for 2nd displayed option Value2 EQU Wall2R ; pointer to graphics for 2nd displayed value Option3 EQU Wall2R+2 ; pointer to graphics for 3rd displayed option Value3 EQU Wall2R+4 ; pointer to graphics for 3rd displayed value Option4 EQU Wall3L ; pointer to graphics for 4th displayed option Value4 EQU Wall3L+2 ; pointer to graphics for 4th displayed value TopOption EQU Wall3L+4 ; top option to display SelectedOption EQU Wall3L+5 ; option selected(0-9) HiLiteOption EQU Wall3R ; option to hilite (0-3) Quote Link to comment Share on other sites More sharing options...
Mallard Games Posted June 19, 2019 Author Share Posted June 19, 2019 (edited) 9 hours ago, SpiceWare said: I use a single byte, called GameState in my Collect Tutorial which covers writing a 2K game. It's had different names in my games, though functioned the same. I typically use bit 7 so a simple BIT GameState instruction with BMI and BPL to determine the state w/out having to mask out the lower bits, allowing them to be used for something else such as which game variation the player has selected. If I need additional states, such as for a Splash Screen, I'll use bit 6 so I can use BIT GameState with BVS and BVC. Example usage would be: bit GameState bmi GameActive jmp MainMenu GameActive: ; game logic goes here GameKernel: ; draw the game screen here MainMenu: ; menu logic goes here MenuKernel: ; draw the menu here The Kernel is the part of the program that updates TIA in real time to draw the screen. Due to limited RAM in the 2600, the state also controls how RAM is used. In Medieval Mayhem the same memory that holds the state of the castle walls is used for drawing the main menu. Wall1L ds 6 Wall1R ds 6 Wall2L ds 6 Wall2R ds 6 Wall3L ds 6 Wall3R ds 6 Wall4L ds 6 Wall4R ds 6 ; reuse of Wall RAM for main menu G48 EQU Wall1L ; uses all of Wall1L and Wall1R Option1 EQU Wall2L ; pointer to graphics for 1st displayed option Value1 EQU Wall2L+2 ; pointer to graphics for 1st displayed value Option2 EQU Wall2L+4 ; pointer to graphics for 2nd displayed option Value2 EQU Wall2R ; pointer to graphics for 2nd displayed value Option3 EQU Wall2R+2 ; pointer to graphics for 3rd displayed option Value3 EQU Wall2R+4 ; pointer to graphics for 3rd displayed value Option4 EQU Wall3L ; pointer to graphics for 4th displayed option Value4 EQU Wall3L+2 ; pointer to graphics for 4th displayed value TopOption EQU Wall3L+4 ; top option to display SelectedOption EQU Wall3L+5 ; option selected(0-9) HiLiteOption EQU Wall3R ; option to hilite (0-3) That sounds awesome, question though how do i set a single bit? For example lets say I want to set bit 2 of Option1, how would i do that in assembly language? Edited June 19, 2019 by Mallard Games Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 20, 2019 Share Posted June 20, 2019 1 hour ago, Mallard Games said: That sounds awesome, question though how do i set a single bit? For example lets say I want to set bit 2 of Option1, how would i do that in assembly language? lda #%00000100 ora Option1 sta Option1 Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted June 20, 2019 Share Posted June 20, 2019 And for completeness, clearing the same bit: lda #~%00000100 ; = %11111011 and Option1 sta Option1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted June 21, 2019 Share Posted June 21, 2019 I didn't know you could reverse the bits with a tilda. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.