Jump to content
IGNORED

The "funkheld" Question Thread


funkheld

Recommended Posts

Hi Funkheld!

 

Hi good afternoon.

 

I am looking for a solution, as I find in fastbasic a startaddress from a PROC for a VBI.

and a solution how to build a VBI in fastbasic.

I advice against using a VBI, it will complicate the code and don't buy you anything.

 

The proper way to code a game loop in Fastbasic should be using a loop with the following logic:

  Exec Init   ' Calls an initialization function, this sets graphics, loads P/M, etc.

  do
    Exec StartGame   ' Starts game
    Exec GameLoop    ' Loops inside game screen
  loop
Now, the GameLoop procedure should be coded also in a loop like:

proc GameLoop
  do
    pause 0
    ' Write all registers and move P/M
    ' ...

    ' Game Logic
    if IAmDead then Exit
    ' ...
  loop
endproc
You can study the attached game source for a full example of a game in FastBasic, using P/M, a play-field, collision registers and sounds. I tried to comment the source as possible, but you can ask for any doubt.

 

post-18634-0-89621100-1539051388.png

gameloop.bas

gameloop.xex

Edited by dmsc
  • Like 1
Link to comment
Share on other sites

Hi good afternoon.


I became curious at the age of 70 and also for ACTION!

who can help me once and explain exactly how I use this RSCAN and RWRITE, maybe with a small DEMO. I do not know what files are used as include in the actions program and how everything works with RSCAN and RWRITE. which names do I enter with rscan when rscan is started? I dont know. when I start rscan and enter 2 names:

1. meinprog.act and 2. meintest.act comes a write error.


also the rwrite worries me with the function.


I do not understand the runtime.txt.


Thank you.

greeting

RunTime.zip

Link to comment
Share on other sites

hello many thanks


this PAUSE 0 does all the work for the complicated VBI ???


how did you do that with the multicolored pm please?



does that have something to do with pause 0 ?

' as we are synchronized to the screen.


How do you know now that this vbi is no longer effective?

' Now, the game logic, this does not need to be synchronized


great.


the program code xex wonderfully small, only 2.5 kb !!!!


Thank you.

greeting

Edited by funkheld
Link to comment
Share on other sites

You have a BASIC code with embeded ASM code and you would like that the ASM code to perform a JSR to a PROC subroutine?

 

If I understood well, let me clarify something about FastBasic: this is an interpreted language like Atari BASIC and TurboBasic XL, and "compiled" FastBasic programs are just a sequence of tokens, which are stored inside an XEX file along the interpreter (runtime module) for them. "Compiled" FastBasic programs are NOT assembly code. The parser just optimizes the source code to generate the best sequence of tokens and their args for the program.

 

Then, the program flow is managed by the interpreter, and when it finds a token for USR, it pass the control to that subroutine, but expects it to return and give the control in order to resume with the next token.

 

Said that, you can conclude that a USR routine cannot call back to an arbitrary PROC routine without tricking the pointers and counters of the FastBasic interpreter (the runtime code). I'm not saying that it could not be done, but it is not in this language's design (AFAIK).

 

  • Like 1
Link to comment
Share on other sites

Hi funkheld!

 

the "pause 0" in fastbasic is not a VBI routine to call a new procedur but just for image syncronization.

Yes, "Pause 0" synchronizes with the screen redraw. The same as a VBI!.

 

I think that you have a misunderstanding of what a VBI is and what it is used for.

 

Can you still build a real vbi for fast basic?

Any interrupt routine must be implemented in assembler, as interrupts can trigger anywhere in your main code and you can't preserve all execution state easily.

 

So, yes, you can call a VBI written in assembly in Fastbasic, just set the VBI pointer to the address of the assembly routine.

 

See this example:

 data vbi() byte = 8,72,165,20,41,16,74,74,74,141,243,2,104,40,76,0,0

 old = dpeek(548)
 dpoke adr(vbi) + 15, old
 pause 0 : dpoke 548, adr(vbi)

 ? "Hello";
 repeat
   ' do nothing!
 until key()

 ' restore
 pause 0 : dpoke 548, old
Some remarks:

- to write to the VBI pointer, use a "Pause 0" just before, so that the VBI does not occur when you are changing the pointer.

- the VBI terminates via a jump to the original VBI, this address must be patched into the VBI itself.

 

If you want to write this in assembly, you can export the address from the assembly (via ".global myvbi") and use "@myvbi" as the address. Also, remember to export the jump code to allow patching the old address.

 

Again, I advice against using VBI in your code, it is bad programming practice because it complicates the code and is fragile.

  • Like 1
Link to comment
Share on other sites

Hi!

 

... very good explanation by Vitoco ...

And just to clarify, as "PROC" has many meanings:

 

- There are "PROC" as written in Fastbasic, this is a Basic procedure, that you call with "EXEC name".

- There are ".proc" assembly procedures, written in assembler, that you call with "USR(@name)".

 

But more to the point, to Funkheld, instead of asking random short questions, try to explain "what you want to accomplish", as many times there are other ways to accomplish the same result.

 

And, if some useful functionality is missing from Fastbasic, we can work on adding a way to do that!

  • Like 1
Link to comment
Share on other sites

I demo:


this crashes:


asm:




.global VSCROL

.proc VSCROL
lda $2080
sta $d405
rti
.endproc



this crashes:




data vbi() byte = 8,72,165,20,41,16,74,74,74,141,243,2,104,40,76,0,0

old = dpeek(548)
dpoke adr(vbi) + 15, @vscrol
pause 0
dpoke 548, @vscrol

? "Hello";
repeat
' do nothing!
until key()

' restore
pause 0
dpoke 548, old

Edited by funkheld
Link to comment
Share on other sites

Hi good afternoon.

I would like to write my files xex, asm with a disk manager on a disk.

this dir2atr always manufactures a self-boat manager on the atr. I do not need that. I just want to transfer my files to disk with a batch file of windows, that's all.

this diratr is not suitable for that, I mean.


Thanks & Greetings

Link to comment
Share on other sites

If you have activated horizontal scrolling in the DL, that changes the cycles/timing available in that line.

This may cause less cycles being available for your DLI code, so it reaches into the next line.
Without any code posted here it's hard to guess what you did.
In any case using HSCROLL values 12-15 instead of 0-3 might help.

  • Like 1
Link to comment
Share on other sites

funkheld, can't you think and research a little bit yourself, before you are posting a question? There's information about all aspects of Atari programming available on the internet. Read the manuals of the tools you are using (e.g. Fastbasic) and hardware and system docs. Then, if you still can't find a solution, post your question. You are currently coming around like someone who has no idea what he's doing, but wants to create a super-duper program. Start small and build up on it...

 

regards,

chris

 

  • Like 1
Link to comment
Share on other sites

Hi!

 

I demo:

 

this crashes:

 

asm:

 

 


.global VSCROL
 
.proc VSCROL
lda $2080
sta $d405 
.endproc 

this crashes:

 


data vbi() byte = 8,72,165,20,41,16,74,74,74,141,243,2,104,40,76,0,0
 
 old = dpeek(548)
 dpoke adr(vbi) + 15, @vscrol
 pause 0 
 dpoke 548, adr(vbi)
 
 ? "Hello";
 repeat
   ' do nothing!
 until key()
 
 ' restore
 pause 0 
 dpoke 548, old

 

That code crashes because it does not make sense.

 

You are patching the provided VBI() assembly to jump to your assembly. But, from your assembly, you don't return nor jump to anything, so it crashes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...