Page 1 of 1

basiegaxorz subroutines?

Posted: Thu May 24, 2007 10:35 pm
by evildragon
does this developer tool support subroutines? i need two different things running at the same time. one routing, the main routing is in a loop, while i need a sub routine keeping a steady timer...

Posted: Thu May 24, 2007 10:55 pm
by Fonzie
^^ No, i hardly see the megadrive cpu doing multithreating ;)

You may be able to use VINT code to do things while the main code is running, but it will interrupt the main code during its execution :D

Also, both code may not access the display part (at least, not without implementing a special mechanism), else some big issues may occur around VDP pointers :D

Using VINT is quite easy if you are programming in C or ASM, but i don't know if BASICegaxorg will let you do that (I think it even already use VINT code to do its own stuff).

Maybe Basicegaxorg have a command to read VTIMER (VTIMER may be a value increasing after each 1/50 or 1/60 seconds), in that case, you may use those values for your timer, staying in your main code loop :)

I'm sorry i cannot help more :)

Posted: Thu May 24, 2007 11:05 pm
by evildragon
i don't think the intel 8086 could either, but they did have subroutines ;)

i only need one of the routines to access the VDP anyway, one of them is just for background use..

here's my loop:

Code: Select all

100 counter=0
105 cls
110 print "Your CPU Score: ";counter;""
120 counter=counter+1
130 goto 105
after about 60 seconds, i want the test to end at line 110... after looking over the basics help file, it doesn't look like it supports it.. but it does support ASM coding.

Code: Select all

Command_ASM:
Syntax: Asm "<Instruction> [operand 1], [operand 2]"
Description: Inserts assembly code directly into the assembler output of the BASIC file. The expression must be in quotes, and the expression cannot be in a variable/string.
but im not the best at 68k assembly, i'll admit..

for example, lets say i wanted a game to only play for a minute, that same routine my work..

Posted: Fri May 25, 2007 1:16 pm
by TmEE co.(TM)
Go to programmersheaven.com, enter assembly zone, find 680x0, and grab all ASM guides there, OR I'll mail you really great ones which I got there and used to learn the language. These tuts are so good that I learned 68K ASM with just 2 days !!!
ASM is not hard, it is just tricky :wink:

Posted: Fri May 25, 2007 2:02 pm
by evildragon
last time i touched ASM i thought i killed my genesis.. XD (stupid static RAM!)

im sticking to basic for now.. then i'll move onto the more advanced stuff..

Posted: Fri May 25, 2007 2:20 pm
by Mask of Destiny
evildragon wrote:i don't think the intel 8086 could either, but they did have subroutines ;)
I don't think subroutines are exactly what you're looking for here. A subroutine lets you make a commonly used piece of code re-usable, but it doesn't allow multiple things to occur at the same time.

Anyway, in most BASIC languages I've used you type GOSUB X where X is either a label or a line number to call a subroutine and then use RETURN inside the subroutine to return to the point where the subroutine was called.
Fonzie wrote:^^ No, i hardly see the megadrive cpu doing multithreating
There's no reason you couldn't have a multi-threading library on the Megadrive/Genesis. All you need is a CPU that supports interrupts and a timer of some sort that generates interrupts. Now the Megadrive doesn't exactly have a proper interrupt generating timer, but you could use HINTS for that purpose.

Posted: Fri May 25, 2007 2:50 pm
by evildragon
Mask of Destiny wrote:
evildragon wrote:i don't think the intel 8086 could either, but they did have subroutines ;)
I don't think subroutines are exactly what you're looking for here. A subroutine lets you make a commonly used piece of code re-usable, but it doesn't allow multiple things to occur at the same time.

Anyway, in most BASIC languages I've used you type GOSUB X where X is either a label or a line number to call a subroutine and then use RETURN inside the subroutine to return to the point where the subroutine was called.
Fonzie wrote:^^ No, i hardly see the megadrive cpu doing multithreating
There's no reason you couldn't have a multi-threading library on the Megadrive/Genesis. All you need is a CPU that supports interrupts and a timer of some sort that generates interrupts. Now the Megadrive doesn't exactly have a proper interrupt generating timer, but you could use HINTS for that purpose.
it has gosub, but when i use gosub to start the timer, the "cpu counter" stops...

how can i get them both to run?

Posted: Fri May 25, 2007 6:51 pm
by Mask of Destiny
evildragon wrote:
Mask of Destiny wrote:
evildragon wrote:i don't think the intel 8086 could either, but they did have subroutines ;)
I don't think subroutines are exactly what you're looking for here. A subroutine lets you make a commonly used piece of code re-usable, but it doesn't allow multiple things to occur at the same time.

Anyway, in most BASIC languages I've used you type GOSUB X where X is either a label or a line number to call a subroutine and then use RETURN inside the subroutine to return to the point where the subroutine was called.
Fonzie wrote:^^ No, i hardly see the megadrive cpu doing multithreating
There's no reason you couldn't have a multi-threading library on the Megadrive/Genesis. All you need is a CPU that supports interrupts and a timer of some sort that generates interrupts. Now the Megadrive doesn't exactly have a proper interrupt generating timer, but you could use HINTS for that purpose.
it has gosub, but when i use gosub to start the timer, the "cpu counter" stops...

how can i get them both to run?
Well like I said, subroutines don't allow multiple things to occur at the same time.

I don't know exactly what you're trying to do, but I'm going to guess the answer to your question is to use the 60/50Hz vertical interrupt (VINT for short). How you do that in Devter's BASIC is beyond me.

Posted: Fri May 25, 2007 7:03 pm
by evildragon
Mask of Destiny wrote:I don't know exactly what you're trying to do, but I'm going to guess the answer to your question is to use the 60/50Hz vertical interrupt (VINT for short). How you do that in Devter's BASIC is beyond me.
I'm trying to make a benchmark sorta like TmEE's, but in BASIC.

Basically, count as fast as the 68000 can before a certain time. TmEE did it by 10vints, but I can't seem to do vints at all with BASIC. I posted on their forum about it, hopefully it can be done somehow.

Posted: Sat May 26, 2007 6:54 pm
by evildragon
ehh, on their forum, they dont even know what im talking about.. they want me to put the sleep command in it.. however, if i do that, then i cause the cpu counter to sleep too, when it should continue counting...

i think im going to have to take up a book on 68k assembly...

or better yet, learn how to port cartridges to Sega Loader... i tried to port TmEE's source to it, but i can't get it to run...

Posted: Sun May 27, 2007 5:27 pm
by Mask of Destiny
evildragon wrote:i think im going to have to take up a book on 68k assembly...
Well, C is an option as well. If you want to stick with assembly, I have a beginner's guide as well. See the tutorials on my Sega CD page (http://www.retrodev.com/segacd.html). They don't get into anything Genesis or Sega CD specific though.