26 June 2011, 10:12 | #1 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 828
|
asm game - how implement exit to OS via PORTS int
Hi
Background: I'm working on some public domain very simple game in asm. I want to implement exit from game to OS or back to AsmOne ( something like exit key in WHDLoad ). I want to use PORTS int to do this. My experiment fails and I think that my knowledge how do this is weak. My first attempt was Code:
start: lea (oldstack,pc),a0 move.l a7,(a0) intPORTS: movem.l d0-d1/a0-a2,-(a7) ; check if keyboard casue int, get key, handskae and so on ;set wExitKeyPressed if F1 was pressed movem.l (a7)+,d0-d1/a0-a2 tst.w wExitKeyPressed beq .exit pea (oldstack,pc) .exit rte Regards asman |
26 June 2011, 15:46 | #2 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,975
|
Quote:
intPORTS: movem.l d0-d1/a0-a2,-(a7) ; check if keyboard casue int, get key, handskae and so on ;set wExitKeyPressed if F1 was pressed movem.l (a7)+,d0-d1/a0-a2 tst.w wExitKeyPressed beq .exit st quitflag .exit rte Add check in main interrupt for quitflag value, then quit from main interrupt, remember about restore necessary hardware registers too. |
|
26 June 2011, 16:15 | #3 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
|
Since you say you're working on the game I'm sure you have a condition for exiting now, so just replace "check mousepress" or whatever with "check key".
If you're stubborn about having this int, then put the setting in the int, but move the checking outside it as Adan suggested. I doubt that you'd be able to pull off a clean exit to CLI/WB directly from within an interrupt. If you plan to have this game multitasking and that's why you feel you need all the interrupts, remember to allocate resources correctly (and then you might as well do most of the game with lib calls). |
26 June 2011, 20:09 | #4 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
sr.w returnaddress.l So if you want to quit from IRQ, do this: move.l #YourExitRoutine,2(a7). And in "YourExitRoutine" you restore the old stack pointer. I'd recommend to use Don Adan's way though as it's much cleaner and less error prone. |
|
28 June 2011, 11:07 | #5 |
68k
Join Date: Sep 2005
Location: Somewhere
Posts: 828
|
Hi
@Don Adan, @Photon, @StingRay Thank you for answers. I use Don Adan's way. Regards |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ASM: false int vector ($60) | Asman | Coders. General | 2 | 13 September 2010 09:22 |
ASM: VERTB int and 16 colored sprites. | Asman | Coders. Tutorials | 5 | 28 April 2010 14:18 |
how can i change exit game key | kipper2k | project.WHDLoad | 2 | 03 May 2009 01:11 |
Win32 Game Ports? | BobRedthorp | Retrogaming General Discussion | 11 | 03 August 2003 13:56 |
Should I implement PM download now ? | RCK | project.EAB | 12 | 08 January 2002 01:21 |
|
|