|
Post by sega16 on Mar 2, 2011 20:11:56 GMT -5
I think it would be useful for everyone to have a topic full of useful subs/function anyway Here is something that works the same as drawtilesinc but does a hflip anyway here it is Usage: drawtilesinc_hflip vram offset, x, y, w,h
declare sub drawtilesinc_hflip(tiles as integer, x as integer, y as integer, w as integer, h as integer) x-- xloop=0 for y_loop = 0 to h for x_loop = w to 1 step -1 drawtile tiles+xloop+y_loop+hfliptile(1),x+x_loop,y+y_loop xloop++ next x_loop xloop-- next y_loop end sub
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 12, 2011 13:12:23 GMT -5
I've already asked for help in regards to this but I think an example of coordinate based collision detection would be nice.
Whoever wrote the workaround for the broken save support on real hardware could post his work here too..
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 12, 2011 16:28:17 GMT -5
Since you asked nicely Theloon Here is a way to get SRAM working in BEX. option EXTERNALSRAM, &h200000, 8192, ODD
asm "move #$2700,sr" a = peek(&h200001) ' Read from SRAM at address &h200001 asm "move #$2000,sr"
locate 1,1: print "SRAM Data: "; a while 1 j = joypad() sleep 1 if j > 0 then randomize a = rnd(99) + 1 locate 3,1: print "New SRAM Data: "; a gosub SaveData end if wend
SaveData: asm "move #$2700,sr" poke &hA130F1, &h01 poke &h200001, a asm "move #$2000,sr" return
I've already asked for help in regards to this but I think an example of coordinate based collision detection would be nice. The problem with doing a collision detection is that everyone's map routines are going to be different. In an RPG setting there are several ways, but in a plaformer, such as finding out if a projectile has hit you or not, you could do something like this: x = SpritePosX y = SpritePosY x1 = ProjectileX y1 = ProjectileY if (x + sprite.width) >= (x1 + projectile.width) & x <= x1 & (same stuff for the y positions) then collision = true If you have any specific questions, feel free to PM me.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 18, 2011 12:22:43 GMT -5
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 18, 2011 22:32:19 GMT -5
that example is highly unoptimized, thought it's great for learning. Moon is a very smart man when it comes to that sorta thing
|
|
|
Post by Tiido on Apr 19, 2011 3:47:51 GMT -5
you write 1 to A130xx prior to doing any writes to 20xxxx area and when done then a 0 to A130xx. This would only matter if the game is bigger than 2MBytes.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 19, 2011 9:11:31 GMT -5
When performing collision detection between for example a character and a bullet, I recommend a "rectangle vs point" test that uses the "early-out" principle. That way you're only using one or two conditions per bullet most of the time. Attached is a basic example. Obviously, in most cases you want to add a "layer" of spatial indexing on top to further improve performance. Attachments:
|
|
|
Post by jlf65 on Apr 19, 2011 13:47:05 GMT -5
you write 1 to A130xx prior to doing any writes to 20xxxx area and when done then a 0 to A130xx. This would only matter if the game is bigger than 2MBytes. Even if the rom is 2MB or less, you're still supposed to write 1 to A130F1; you just do it in the game's hardware init and then don't worry about writing the reg before and after writing/reading the sram. You should also always use the official address (A130F1) even if you know it's mirrored or responds to any address.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 20, 2011 8:04:42 GMT -5
Hey! Thanks for shaing the collision code moon. Actually, I could see using this logic in my PC and 2600 projects too.
Is there some general hardware collision flag that could be accessed from Basiegaxorz? Something that would tell me if ANY collisions have happened and then resort to the software collision check?
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 20, 2011 10:12:06 GMT -5
Is there some general hardware collision flag that could be accessed from Basiegaxorz? There is actually ( for sprite vs sprite ), but you don't want to use it. See this post by oompa.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on May 20, 2011 14:47:48 GMT -5
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on May 20, 2011 19:22:20 GMT -5
TFM doesn't work on the real hardware without some rewrites, or borrow the z80 init code from kramlib.
Kramlib uses SMPS music files, and there isn't a single tracker for that format (that I'm aware of). There are tools out there to help convert to SMPS, though I've had no luck with getting any of them to work properly, or not crash on my OS's (Windows 7, XP, and Server 2003).
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on May 21, 2011 7:31:35 GMT -5
I think I actually saw a post with the rewrites to TFM here. When I get 'round tuit I see if I can find them and test on an Everdrive. If anyone stashed away a working copy please repost! heck, a working music engine of any sort would be a great contribution! UPDATE: The code and suggested fixes in this post resulted in a binary that played back no sound in Kega Fusion. devster.proboards.com/index.cgi?board=basiegaxorz&action=display&thread=511The TFM Music Maker from Shirus website also produced no sound. Yes, I did rename the included music to music.tfd shiru.untergrund.net/software.shtmlUPDATE: Arrg, it appears the modules included with TFM Music Maker are NOT useable in BasiEgaXorz unless you export them as "TFD for the SMD" . I'll just assume that the other TFM examples have the same deal going on.. That being said has anyone played around with the LAKABJO example? Devster made it to interface with real hardware thus I'm sure he made sure the music works on a real Genesis..
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on May 24, 2011 17:27:49 GMT -5
@theloon: the TFM engine in (I forget the example's name) worked on the Everdrive, worked in the model 3 genesis as a cart, but froze in the model 1, model 2, and sega cdx after it was made into a cart. It worked perfectly after adding in kramlib's initialization routines.
|
|
|
Post by Mairtrus on Jul 14, 2011 17:36:23 GMT -5
Hai guys. Sorry for bump this not-so-old thread, but I have a few subroutines that I believe someone will find usefull: This one allows you to change the Link property of a sprite:
Declare Asm Sub LinkSprite(d0.w,d1.w) move #$2700,sr lsl.w #3,d0 addi.w #$2C02,d0 swap d0 move.w #2,d0 move.l d0,4(a4) nop nop move.w (a4),d2 nop nop move.b d1,d2 addi.l #$40000000,d0 nop nop move.l d0,4(a4) move.w d2,(a4) move #$2000,sr End Sub and use like this:
LinkSprite SpriteHandler,LinkNumber The next one is used to change the form of a sprite:
Declare Asm Sub ResizeSprite(d0.w,d1.w,d2.w) move #$2700,sr lsl.w #3,d0 addi.w #$2C02,d0 swap d0 move.w #2,d0 move.l d0,4(a4) sub.b #1,d1 andi.w #3,d1 lsl.b #2,d1 move.w (a4),d3 sub.b #1,d2 andi.b #3,d2 or.b d2,d1 addi.l #$40000000,d0 lsl.w #8,d1 move.b d3,d1 move.l d0,4(a4) move.w d1,(a4) move #$2000,sr End Sub
and use like this
ResizeSprite SpriteHandler,NewHeight,NewWidth (NewWidth and NewHeight take values from 1 to 4) This last one is my latest achievement, and probably the only thing on the MD I hadn't learned how to use...yet:
Declare Asm Sub DmaCopy(d0.l,d1.w,d2.l) move #$2700,sr move.w #$9300,d3 lsr.w #1,d1 move.b d1,d3 move.w d3,4(a4) lsr.w #8,d1 addi.w #$100,d3 move.b d1,d3 move.w d3,4(a4) lsr.w #1,d0 addi.w #$100,d3 move.b d0,d3 move.w d3,4(a4) lsr.w #8,d0 addi.w #$100,d3 move.b d0,d3 move.w d3,4(a4) lsr.w #8,d0 andi.b #$7F,d0 addi.w #$100,d3 move.b d0,d3 move.w d3,4(a4) lsl.l #2,d2 lsr.w #2,d2 addi.l #$804000,d2 swap d2 move.l d2,4(a4) move #$2000,sr End Sub and use like this:
DmaCopy lblptr&(YourData)+SomethingIfYouWant,NumberOfBytesToCopy,StartPosition If someone doesn't catch it yet, the DMA allows you to load data into the VRAM at a higher speed than normal, since it's the VDP who process the data, and not the M68K, freeing it for doing whatever else(Tiido has done some wonderful demos using this technique).
|
|