Joystick/Sound in Supervisor mode?
Re: Joystick/Sound in Supervisor mode?
Many thanks for the explanation Tofro
Got the code from a website, but will scrap it
Many thanks
Got the code from a website, but will scrap it
Many thanks
Re: Joystick/Sound in Supervisor mode?
I tend to use code like that:
There is, however, an even better method that also unlinks the polling routine when you end the program by Marcel somewhere here on the site.
Code: Select all
timerLinkage
timer_pllk ds.l 1 ; Polling interrupt linkage
timer_plad ds.l 1 ; Polling interrupt service routine address
**********************************************************************************
* initTimer
* initialize timer
**********************************************************************************
initTimer
;DEBUG {'InitTimer'}
lea timerTick,a0
move.l a0,timer_plad(a6)
lea timerLinkage(a6),a0
QDOSMT$ MT.LPOLL
rts
**********************************************************************************
* timerRemove
* initialize timer
**********************************************************************************
timerRemove
;DEBUG {'TimerRemove'}
lea timerLinkage(a6),a0
QDOSMT$ MT.RPOLL
rts
**********************************************************************************
* timerTick
* Called in the polling interrupt, maintains a ms timer
**********************************************************************************
timerTick
add.l #MSPERTICK,ticksMillis+8(a3) ; we're no driver, thus look 8
; bytes further on for data!
rts
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: Joystick/Sound in Supervisor mode?
Many thanks!tofro wrote: Thu Feb 22, 2024 1:07 pm I tend to use code like that:
There is, however, an even better method that also unlinks the polling routine when you end the program by Marcel somewhere here on the site.Code: Select all
timerLinkage timer_pllk ds.l 1 ; Polling interrupt linkage timer_plad ds.l 1 ; Polling interrupt service routine address ********************************************************************************** * initTimer * initialize timer ********************************************************************************** initTimer ;DEBUG {'InitTimer'} lea timerTick,a0 move.l a0,timer_plad(a6) lea timerLinkage(a6),a0 QDOSMT$ MT.LPOLL rts ********************************************************************************** * timerRemove * initialize timer ********************************************************************************** timerRemove ;DEBUG {'TimerRemove'} lea timerLinkage(a6),a0 QDOSMT$ MT.RPOLL rts ********************************************************************************** * timerTick * Called in the polling interrupt, maintains a ms timer ********************************************************************************** timerTick add.l #MSPERTICK,ticksMillis+8(a3) ; we're no driver, thus look 8 ; bytes further on for data! rts
Re: Joystick/Sound in Supervisor mode?
? https://www.theqlforum.com/viewtopic.php ... =10#p45932tofro wrote: Thu Feb 22, 2024 1:07 pmThere is, however, an even better method that also unlinks the polling routine when you end the program by Marcel somewhere here on the site.
David
Re: Joystick/Sound in Supervisor mode?
I can't get most of this to assemble especially anything referencing "(A6)" which throws "relocatable value not allowed here"tofro wrote: Thu Feb 22, 2024 1:07 pm I tend to use code like that:
There is, however, an even better method that also unlinks the polling routine when you end the program by Marcel somewhere here on the site.Code: Select all
timerLinkage timer_pllk ds.l 1 ; Polling interrupt linkage timer_plad ds.l 1 ; Polling interrupt service routine address ********************************************************************************** * initTimer * initialize timer ********************************************************************************** initTimer ;DEBUG {'InitTimer'} lea timerTick,a0 move.l a0,timer_plad(a6) lea timerLinkage(a6),a0 QDOSMT$ MT.LPOLL rts ********************************************************************************** * timerRemove * initialize timer ********************************************************************************** timerRemove ;DEBUG {'TimerRemove'} lea timerLinkage(a6),a0 QDOSMT$ MT.RPOLL rts ********************************************************************************** * timerTick * Called in the polling interrupt, maintains a ms timer ********************************************************************************** timerTick add.l #MSPERTICK,ticksMillis+8(a3) ; we're no driver, thus look 8 ; bytes further on for data! rts
I have the Dickens book, and others, so I think I'll work my way through those so I can fully understand what's what
Many thanks
- janbredenbeek
- Super Gold Card
- Posts: 668
- Joined: Wed Jan 21, 2015 4:54 pm
- Location: Hilversum, The Netherlands
- Contact:
Re: Joystick/Sound in Supervisor mode?
You are declaring these variables within a SECTION, which produces relocatable values. You should declare them within an OFFSET section (e.g. OFFSET 0), which declares them as simple (scalar) values from the specified offset (normally starting at zero). Then reserve some space for it (normally in the job's dataspace but it can be in code space too) and let A6 point to it.t0nyt wrote: Thu Feb 22, 2024 3:11 pmI can't get most of this to assemble especially anything referencing "(A6)" which throws "relocatable value not allowed here"tofro wrote: Thu Feb 22, 2024 1:07 pm I tend to use code like that:
Code: Select all
timerLinkage timer_pllk ds.l 1 ; Polling interrupt linkage timer_plad ds.l 1 ; Polling interrupt service routine address ...
- janbredenbeek
- Super Gold Card
- Posts: 668
- Joined: Wed Jan 21, 2015 4:54 pm
- Location: Hilversum, The Netherlands
- Contact:
Re: Joystick/Sound in Supervisor mode?
There is an excellent explanation of all PC.INTR bits on read and write in Minerva's source code: https://github.com/janbredenbeek/Minerv ... n/m/inc/pctofro wrote: Thu Feb 22, 2024 12:48 pm Just a short explanation on why you shouldn't be fiddling with PC_INTR ($18021) directly:
If you write directly to that address (a hardware register), you're confusing the system that normally maintains a copy on what was last written there. Next, you seem to be writing $ff there, which re-arms all interrupts, not just the vsync. When you read that address, you're not checking the vsync bit only (which is in fact the frame interrupt), but rather check for non-zero, which basically triggers on any interrupts the QL has. So, in case people have special hardware that uses the external interrupt or you have microdrives running or network or serial traffic incoming, your routine will also assume 0.02s have passed... If you want exactly that, a simple HALT would do he same (It just waits for the next interrupt which is effectively what your loop does).
In short:
bits 0-4 are gap/interface/transmit/frame/external interrupt bits (reading a 1 means the interrupt has been asserted, writing a 1 signals the interrupt has been processed).
bits 5-7 are gap/interface/transmit enable/disable on write (1 to enable). So you cannot disable frame and external unless you set the interrupt bits in the 68000's SR.
Reading bits 5-7 has no practical use unless you want to do something with the ZX8302's clock or BAUDx4 signal...
Re: Joystick/Sound in Supervisor mode?
Thanks Jan, but I don't currently even understand what you mean by "Then reserve some space for it (normally in the job's dataspace but it can be in code space too) ". I'll have to read up on this as I don't see how the code in the OFFSET ends up in the reserved space in some way. And the last part of the code references stuff that isn't declared anywhere in the code so I'm totally lostjanbredenbeek wrote: Thu Feb 22, 2024 3:58 pmYou are declaring these variables within a SECTION, which produces relocatable values. You should declare them within an OFFSET section (e.g. OFFSET 0), which declares them as simple (scalar) values from the specified offset (normally starting at zero). Then reserve some space for it (normally in the job's dataspace but it can be in code space too) and let A6 point to it.t0nyt wrote: Thu Feb 22, 2024 3:11 pmI can't get most of this to assemble especially anything referencing "(A6)" which throws "relocatable value not allowed here"tofro wrote: Thu Feb 22, 2024 1:07 pm I tend to use code like that:
Code: Select all
timerLinkage timer_pllk ds.l 1 ; Polling interrupt linkage timer_plad ds.l 1 ; Polling interrupt service routine address ...
I'll work thru my books to try and get an understanding
Many thanks
Re: Joystick/Sound in Supervisor mode?
Well, QDOS programs normally tend to store their data in the data space (hence the name
). That is an area of memory normally after your program code which is allocated for you to work with. You tell the assembler (if you assemble with "-NOLINK") using the DATA directive how much you want (or it will allocate a default of 4k for you). When your program is started, a6+a4 points to the bottom of that space, so one of the first instructions in most of my programs is
and a6 is never touched again later on. You can then use a6 to point into that space to use it for variables. This is done so that multiple jobs executing the same program can share the code, but have separate data. Maybe not so relevant for a game, though.

Code: Select all
lea.l 0(a6,a4.l),a6 ; let a6 point to data space
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: Joystick/Sound in Supervisor mode?
Thanks Tofro, so "OFFSET 0" puts the code at the start of the 4kb?tofro wrote: Thu Feb 22, 2024 5:00 pm Well, QDOS programs normally tend to store their data in the data space (hence the name). That is an area of memory normally after your program code which is allocated for you to work with. You tell the assembler (if you assemble with "-NOLINK") using the DATA directive how much you want (or it will allocate a default of 4k for you). When your program is started, a6+a4 points to the bottom of that space, so one of the first instructions in most of my programs is
and a6 is never touched again later on. You can then use a6 to point into that space to use it for variables. This is done so that multiple jobs executing the same program can share the code, but have separate data. Maybe not so relevant for a game, though.Code: Select all
lea.l 0(a6,a4.l),a6 ; let a6 point to data space
It still won't assemble code after an OFFSET though (the offset section is at the end of my source file)