News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_AMSDOS

BASIC Question: When will I know I need to use DI/EI?

Started by AMSDOS, 11:13, 30 March 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AMSDOS

Not the Assembly DI/EI instructions, but the Locomotive BASIC DI/EI instructions. I asked this before, but didn't get a clear answer, probably because it was taking over another thread.


I tried the example programs from the 464/6128 manuals, the 6128 version I modified to work on 464, removing the DI / EI, made the character flicker more.


I'm unsure these commands enhance for the game I'm making. It operates graphically, but it would make you think everything was placed at an Text cursor position (even though it's impossible), the routine for drawing the graphics seems fast enough without the DI in place, though what about a DI/EI around the controls within a loop, everything seemed fine apart from one occasion I wasn't getting anything happening quick enough, might of been the DI stuffing around with that.


Earlier I had a reply about the Locomotive BASIC DI/EI being different from the Assembly DI/EI, does that mean the BASIC EI/DI exist as Firmware? Firmware Manual doesn't confirm any.




* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

andycadley

If you aren't using the BASIC interrupt features (After, Every, On Sq etc) then it will make zero difference. Even if you are they aren't really a speed thing, but to give your main program a chance to update variables that are used by interrupt code without risking an interrupt occurring halfway through changing things. You mostly won't ever need them.

AMSDOS

Quote from: andycadley on 13:36, 30 March 17
If you aren't using the BASIC interrupt features (After, Every, On Sq etc) then it will make zero difference. Even if you are they aren't really a speed thing, but to give your main program a chance to update variables that are used by interrupt code without risking an interrupt occurring halfway through changing things. You mostly won't ever need them.


I remember having another daft thread with some program in it and it was using EVERY along with some keyboard controls I think. In that situation the EVERY was causing the slightest of lags (the interrupt I presume), but I remember getting rid of the EVERY and just had the BASIC program follow the process through a loop, so I'm thinking possibly the DI/EI might of been handy in that situation.


I remember the Madballs game (AA63 Type-ins) having a number of DI/EI in it as well, though that have heaps of stuff happening in it, no moving enemies, though there was a time limit in play for each level.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

I've had a bit of an idea for another game and from a Silly example of an EVERY BASIC routine I wrote a few years ago, I came up with this


1 a%=400
10 GOSUB 2000
20 x%=1:y%=100:dir%=1:num%=1:MODE 0
30 WHILE INKEY$=""
40 TAG:PLOT -2,-2,num%:MOVE x%,y%:CALL &BD19:PRINT " ";CHR$(224);" ";:TAGOFF
50 x%=x%+dir%
60 IF x%=320 THEN dir%=-1
70 IF x%=1 THEN dir%=1
80 WEND
90 CALL &BC02:MODE 2:PEN 1:END
1000 num%=num%+1:i%=(RND*26)
1010 IF num%=15 THEN num%=1
1020 INK num%,i%
1025 a%=a%/2
1026 IF a%=1 THEN a%=400
1027 TAGOFF:PEN 1:LOCATE 1,1:PRINT a%;
1028 GOSUB 2000
1030 RETURN
2000 EVERY a%,1 GOSUB 1000
2010 RETURN


Though I'm not quite sure how legitimate it is on a Real CPC or if that presents a problem. In this example I've setup a variable a% to 400, GOSUB 2000 initializes the EVERY routine (this is the part where I'm not sure if variables are acceptable) when that EVERY if reached the INKs are changed the value of a% is updated at the top of the screen and then it updates the conditioning with the new value of a% for the EVERY, so then the next update comes quicker and the cycle speeds up as a% is drawn down to 1.


PS: I had some EI/DI in this example as well during the subroutine, though with and without I didn't notice any change, in this program though the only variable in the main loop and subroutine is num%
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Quote from: andycadley on 13:36, 30 March 17
If you aren't using the BASIC interrupt features (After, Every, On Sq etc) then it will make zero difference. Even if you are they aren't really a speed thing, but to give your main program a chance to update variables that are used by interrupt code without risking an interrupt occurring halfway through changing things. You mostly won't ever need them.


I've finally coded something today which needs DI & EI, unfortunately I'm not able to post it  ???


What's happened is I've setup scenery, main character & alien. The Alien moves in conjunction with a Low Priority EVERY statement before going into a Main WHILE Loop. In that it's checking for Joystick Up & Down and as I was trying to keep this program as tight as possible, it shares the same routine to print the graphics as the Alien. So initially before I had the DI/EI, bits of my main character were popping up all over the place where the Alien was meant to be display. So on this occasion, DI/EI stops that from occurring. Only now I notice the controls to move my main character is sluggish, I had the same problem in this thread last year, which was occurring because of the EVERY, though now my game depends on EVERY to move the Alien at different speeds, though I have a feeling I'll have to accept it that way.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod