English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 26 June 2011, 10:12   #1
Asman
68k
 
Asman's Avatar
 
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
Any ideas or example how do this are welcome.


Regards
asman
Asman is offline  
Old 26 June 2011, 15:46   #2
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,975
Quote:
Originally Posted by Asman View Post
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
Any ideas or example how do this are welcome.


Regards
asman
Better try:

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.
Don_Adan is offline  
Old 26 June 2011, 16:15   #3
Photon
Moderator
 
Photon's Avatar
 
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).
Photon is offline  
Old 26 June 2011, 20:09   #4
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Asman View Post
Code:
        tst.w    wExitKeyPressed
        beq    .exit

        pea    (oldstack,pc)

.exit        rte
Any ideas or example how do this are welcome.
pea will not work here, it trashes the stackframe. Exception stackframe is:

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.
StingRay is offline  
Old 28 June 2011, 11:07   #5
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
Hi

@Don Adan, @Photon, @StingRay

Thank you for answers. I use Don Adan's way.

Regards
Asman is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:11.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.06771 seconds with 13 queries