Jump to content

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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)

 

Share this post


Link to post
Share on other sites
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 by Mallard Games

Share this post


Link to post
Share on other sites
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

 

Share this post


Link to post
Share on other sites

And for completeness, clearing the same bit:

lda #~%00000100 ; = %11111011
and Option1
sta Option1

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...