Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
Hi all,
I am kinda new to GB development, my only previous experience with z80 assembly being a snake on a TI-83 calculator. I am now making a breakout clone (for a change) as my first GB project. A quick question about program structure, interrupts etc...
What I have now is:
- main loop basically containing ei and halt instruction looped over and over again
- Vblank interrupt which calls a function to check if my game logic has asked for updates to some BG tiles or whatever, and then plus runs through the DMA routine
- Timer interrupt, currently at 4kHz, which runs the game logic, updates ball position, and will do some collision detection etc in the future
My question is: Is it standard practice to run main game logic from the timer interrupt? Is it good / bad, what do you people prefer? Any "best practice" advice?
Thanks in advance!
Offline
i guess the best practice is not overcomplicate things.
Offline
Yeah, dunno - not the way I would have done it under any other circumstance either, so perhaps I *am* over-complicating things for myself. I thought that it would gave me better timing control if I wanted do sound and somesuch later on (I have no idea how it works, but I guess there is some tight timing involved?)
So the standard way would be something like:
main_loop: ; game logic goes here... call wait_vblank ; update shadow OAM / tiles etc... call dma_transfer_routine jp main_loop
Please do not take offense to this - my assembly experience is limited, and my GB-knowledge is basically non-existent. I am just looking for some basic advice
Last edited by dr-ivan (2021-03-10 19:00:06)
Offline
Well. it's natural when you've just started. Get yourself a manual. This is quite handy and page 116 has typical template used in many games.
As for sound, majority of replay routines is called once per frame, so vblank or LCD interrupt are better suited for this.
Offline
Thank you for the pointer - working nicely so far!
Offline