flat assembler
Message board for the users of flat assembler.

Index > DOS > I want to make Snake, the game, and I have a few questions

Author
Thread Post new topic Reply to topic
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 13 Oct 2013, 16:02
I want to implement a Snake game, and I have several questions which I've stuck into this one thread:

1. Remapping keyboard handler.

When a key is pressed, INT 9 goes off. So, how can I install my own keyboard handler to INT 9? I want to be able to capture events.

2. Keeping the snake moving using time interval

I was thinking about how I'd keep the snake moving at a pace, and I thought of using time intervals. How does one implement a timer so that certain actions are carried out within the set intervals?

Apologies if I my questions aren't clear

_________________
meshnix
Post 13 Oct 2013, 16:02
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 13 Oct 2013, 19:58
Post 13 Oct 2013, 19:58
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4352
Location: Now
edfed 14 Oct 2013, 08:32
the timer should not update the position of the snake.
the timer delta should just be used as the T variable in the Snake movement equation. exactlly as a keyboard interrupt routine should not do anything related to an application, but should just reports the hw state to be used later by your application.


you can also set a call-back mecanism inside your custom interrupts, but they should not be big, otherwise, you will slow down your computer.


to install a interrupt handler, just disable interruptions, set the new adress in the interrupt vector, and reenable the interrupts.

an interrupt routine should always end by a EndOfInterrupt signal before the iret.
special peripherals like the keyboard need also a bunch of tests and ports reads/writes to tell it's ok to receive the next event.
Post 14 Oct 2013, 08:32
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.