Jump to content



2

Inline asm code repository


14 replies to this topic

#1 batari OFFLINE  

batari

    )66]U('=I;B$*

  • 6,237 posts
  • begin 644 contest

Posted Thu Jul 21, 2005 7:16 PM

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, Fri Jul 22, 2005 2:35 PM.


#2 batari OFFLINE  

batari

    )66]U('=I;B$*

  • 6,237 posts
  • begin 644 contest

Posted Thu Jul 21, 2005 8:19 PM

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, Fri Jul 22, 2005 2:35 PM.


#3 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!

  • 16,745 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany

Posted Fri Jul 22, 2005 4:47 AM

batari, on Fri Jul 22, 2005 4:19 AM, said:

Anyone know a solution to the indenting problem?
Works for me.

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

Edited by Thomas Jentzsch, Fri Jul 22, 2005 4:47 AM.


#4 kisrael OFFLINE  

kisrael

    HMBL 2600 coder

  • 3,970 posts
  • Location:Boston Burbs, MA

Posted Fri Jul 22, 2005 6:00 AM

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, Fri Jul 22, 2005 6:06 AM.


#5 vdub_bobby OFFLINE  

vdub_bobby

    Quadrunner

  • 5,831 posts
  • Boom bam.
  • Location:Seattle, WA

Posted Fri Jul 22, 2005 9:31 AM

To add indents inside a "CODE" tag (in the forum) you must use spaces - tabs are ignored.

#6 batari OFFLINE  

batari

    )66]U('=I;B$*

  • 6,237 posts
  • begin 644 contest

Posted Fri Jul 22, 2005 2:39 PM

kisrael, on Fri Jul 22, 2005 7:00 AM, said:

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.

#7 vdub_bobby OFFLINE  

vdub_bobby

    Quadrunner

  • 5,831 posts
  • Boom bam.
  • Location:Seattle, WA

Posted Fri Jul 22, 2005 2:49 PM

batari, on Fri Jul 22, 2005 1:39 PM, said:

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

View Post

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, Fri Jul 22, 2005 2:50 PM.


#8 Brad2600 OFFLINE  

Brad2600

    Quadrunner

  • 24,852 posts
  • Formerly known as Kepone, 2002-2012
  • Location:South Burlington, VT

Posted Wed Aug 10, 2005 12:45 PM

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.

#9 vdub_bobby OFFLINE  

vdub_bobby

    Quadrunner

  • 5,831 posts
  • Boom bam.
  • Location:Seattle, WA

Posted Wed Aug 10, 2005 12:47 PM

Kepone, on Wed Aug 10, 2005 11:45 AM, said:

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.

View Post

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.

#10 Brad2600 OFFLINE  

Brad2600

    Quadrunner

  • 24,852 posts
  • Formerly known as Kepone, 2002-2012
  • Location:South Burlington, VT

Posted Wed Aug 10, 2005 12:50 PM

My bad then. I had created a thread requesting such a thing but I was confused when I saw this thread as well. Sorry.

#11 MausBoy OFFLINE  

MausBoy

    Moonsweeper

  • 385 posts
  • bB Fan
  • Location:MO, USA

Posted Thu Nov 23, 2006 1:04 AM

Anybody have more to offer?

#12 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,547 posts
  • Location:Georgia, USA

Posted Thu Nov 23, 2006 11:50 AM

View PostMausBoy, on Thu Nov 23, 2006 2:04 AM, said:

Anybody have more to offer?
Hey, thanks for resurrecting this thread; I had either missed or forgotten it! I'll go through my bB programs and see if I can find any inline asm code that would be of general use.

Michael

#13 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,928 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Wed Feb 27, 2008 3:29 AM

View Postbatari, on Thu Jul 21, 2005 8:16 PM, said:

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.

#14 batari OFFLINE  

batari

    )66]U('=I;B$*

  • 6,237 posts
  • begin 644 contest

Posted Wed Feb 27, 2008 12:32 PM

View PostRandom Terrain, on Wed Feb 27, 2008 4:29 AM, said:

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.

#15 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,928 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Wed Feb 27, 2008 12:42 PM

View Postbatari, on Wed Feb 27, 2008 1:32 PM, said:

The above code is obsolete, as the pfclear command does just that and also accounts for non-standard playfields.
Thanks. That's good to know.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users