Jump to content
IGNORED

Inline asm code repository


batari

Recommended Posts

This thread will serve as a place for asm contributions to bB, to extend the functionality without adding extra bulk to the included 2600basic.asm file or compiler for functions that won't be used very often. The other advantage of a code repository is that it will force bB programmers to see the underlying asm - thus not completely insulating bB programmers from potentially complex code.

 

The code should be ready to insert into bB and well-documented so that beginners could cut and paste it into their programs without needing special knowedge.

 

Examples may be square root or trig functions, but there could be many others. I imagine that 99% of games will never need this, but for the 1% that does, inserting the asm would be handy.

 

Some of the code will also be put into a library to be included with future releases of bB so programmers don't always have to come here to get it. You will be credited for your contributions if they are used in the bB library.

 

I'll start out with a routine to clear the playfield:

asm
 ldx #47
 lda #0
clearpf
 sta playfield,x
 dex 
 bpl clearpf
end

Edited by batari
Link to comment
Share on other sites

I should also include this one, as it has been requested before. It clears all RAM to zero and reseeds the random number generator. It cannot be called in a subroutine or bad things will happen!

asm
 ldx #128
 lda #0
clearram
 sta 0,x
 inx
 beq clearram
 lda INTIM
 ora #1
 sta rand
end

Edited by batari
Link to comment
Share on other sites

Right now Bastari BASIC only allows spaces not tabs for indenting. (Probably should go on the bug list)

 

HMMM.

left margin
tabbed in

left margin
one space in

left margin
 two spaces in

 

So a tab or 1 space is eaten, 2 spaces are changed into one (I think that's a side effect of the old "more than one space gets turned into a nbsp; char" trick)

 

Unfortunately the HTML PRE tag eats both tabs AND spaces in this environment which I don't think it does in real life.

 

I've mentioned this to Al. He's a bit busy but interested in looking into it.

Edited by kisrael
Link to comment
Share on other sites

Right now Bastari BASIC only allows spaces not tabs for indenting. (Probably should go on the bug list)

So a tab or 1 space is eaten, 2 spaces are changed into one (I think that's a side effect of the old "more than one space gets turned into a nbsp; char" trick)

I hope that with the inclusion of lex, the parsing issues should be pretty much solved. I successfully built a lexical analyzer with lex a couple of days ago but I haven't yet integrated it into bB.

 

I just added extra spaces to fix up the indenting in this thread... Strange that the first space is eaten.

Link to comment
Share on other sites

I just added extra spaces to fix up the indenting in this thread... Strange that the first space is eaten.

896580[/snapback]

Kind of offtopic...but an indented line that has a semi-colon as its first non-space character will have yet another space eaten:

   three leading spaces
 ;another three leading spaces

Weird.

Edited by vdub_bobby
Link to comment
Share on other sites

  • 3 weeks later...
Can anyone post code that allows the player to have and fire a missle at another player? I want to experiment with a small game where you have a player and he has to shoot the other player just to score.

908405[/snapback]

This probably isn't the right thread for this request, since I am pretty sure you don't need to use inline assembly to do that.

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
This thread will serve as a place for asm contributions to bB, to extend the functionality without adding extra bulk to the included 2600basic.asm file or compiler for functions that won't be used very often. The other advantage of a code repository is that it will force bB programmers to see the underlying asm - thus not completely insulating bB programmers from potentially complex code.

 

The code should be ready to insert into bB and well-documented so that beginners could cut and paste it into their programs without needing special knowedge.

 

Examples may be square root or trig functions, but there could be many others. I imagine that 99% of games will never need this, but for the 1% that does, inserting the asm would be handy.

 

Some of the code will also be put into a library to be included with future releases of bB so programmers don't always have to come here to get it. You will be credited for your contributions if they are used in the bB library.

 

I'll start out with a routine to clear the playfield:

asm
 ldx #47
 lda #0
clearpf
 sta playfield,x
 dex 
 bpl clearpf
end

Has bB changed so much that the above is no longer needed or is that Clear Playfield routine still the thing to use? Also, was a code library ever included with bB? Maybe it's there and I'm just not seeing it.

 

Thanks.

Link to comment
Share on other sites

Has bB changed so much that the above is no longer needed or is that Clear Playfield routine still the thing to use? Also, was a code library ever included with bB? Maybe it's there and I'm just not seeing it.

 

Thanks.

The above code is obsolete, as the pfclear command does just that and also accounts for non-standard playfields.

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...