SteveO wrote:I seem to remember you can wring slightly more speed out of the Beeb for games by turning off some routine tasks undertaken by the OS. For example keyboard scanning. Now I think I'm already doing this with the code RTW gave me for vertical scrolling. But are there any other areas that can be turned of to improve speed a little ? And if so how ?
It turns out he'd already turned off everything he could and the discussion moved on to other optimisations he could use. I'd like to know what can be 'turned off' and how to do it and what complications can arise from this. I'm happy to be pointed at some books but I'll most likely return with more questions after my reading.
Since I'm currently interested in writing games stopping the OS from butting in seems to be a good idea but I know Tricky has mentioned turning off the OS a few times and how sound in particular can be a problem.
One of the pieces of example code over as RS is 'Reading the keyboard by direct hardware access' by RTW and at the end of the text he writes:
RTW wrote:All of this has to be done either with interrupts disabled, or a custom IRQ handler in place which doesn't let the OS in, otherwise all of the setup will be undone by OS code (because these values are changed to play sounds, for example).
I've written a small piece of code using this technique which checks for the standard beeb game keys of zx:/ and space then prints them to the screen . I'm curious if (1) I've done it correctly and (2) if turning off the OS would satisfy the interrupts disabled part of the above meaning I could remove the sei/cli instructions from my code.
Code: Select all
\\ 'Dirty' keyboard input
oswrch = $ffee
\\ MODE 1
\\ readkeys taken from retrosoftware.co.uk example code here
\\ - http://www.retrosoftware.co.uk/wiki/index.php?title=Reading_the_keyboard_by_direct_hardware_access -
\\ written by rtw
\\set all keys to 0
sei; turn interrupts off
LDA #&7F:STA &FE43; set DDRA to 01111111
LDA #&0F:STA &FE42; allow write to addressable latch
LDA #&03:STA &FE40; set bit 3 to 0
\\ keys checked here
\\ z - left - code 97
LDA #97:STA &FE4F:LDA &FE4F \ N flag = whether 'Z' pressed
\\ x - right - code 66
LDA #66:STA &FE4F:LDA &FE4F \ N flag = whether 'X' pressed
\\ colon - up - code 72
LDA #72:STA &FE4F:LDA &FE4F \ N flag = whether ':' pressed
\\ slash - down - code 104
LDA #104:STA &FE4F:LDA &FE4F \ N flag = whether '/' pressed
\\ space - fire - code 98
LDA #98:STA &FE4F:LDA &FE4F \ N flag = whether ' ' pressed
cli; turn interrupts back on
.left equb 0
.right equb 0
.up equb 0
.down equb 0
.fire equb 0