|
Post by Tom Maneiro on Mar 11, 2010 22:32:12 GMT -5
I'm back to the coding! Since ROM/RAM space is precious, and the Genesis is no RAM stash, i've decided to switch to tile maps for all of my upcoming projects. But right now, i'm having a ridiculous problem with DrawTiles and image maps: This time i'm doing splash screens, and according with the great BEX docs, this line should do the trick: drawtiles tslogo_map, 256, 1, 1, 38, 26 But instead, i get this corrupted crap: However, if i use the old-fashioned loops... reload tslogo_map for y = 0 to 25 for x = 0 to 37 readint z DrawTile z+256, x+1, y+1 next x next y ... it draws properly! But it's too much code for me Also, after looking at the corrupted image, it looks like BEX is skipping a tile for each tile that it draws... It's me, my poor code, or yet another obscure BEX bug?
|
|
|
Post by ScroGer on Mar 11, 2010 23:27:54 GMT -5
Maybe drawtilesinc or drawtilesinc2 function will work.
|
|
|
Post by Tom Maneiro on Mar 11, 2010 23:56:30 GMT -5
DrawTilesInc(2) are useless with tile maps - it expects a bunch of contiiguous tiles. I'm still using them for small objects (logos, some art, and such stuff)... but it defeats the purpose of using tilemaps
|
|
|
Post by theelf on Mar 12, 2010 11:08:54 GMT -5
reload tslogo_map for y = 0 to 25 for x = 0 to 37 readint z DrawTile z+256, x+1, y+1 next x next y mm.. this code to draw maps is better than mine.... i keep it ;D The drawtiles command not work for me too
|
|
|
Post by Tom Maneiro on Mar 12, 2010 11:21:24 GMT -5
Heh, i was using your code from your EOL tutorial But wasting two loops and an array is not good for performance So the next big thing was to do two things in one loop. So DrawTiles is indeed b0rked. Not good.
|
|
|
Post by theelf on Mar 12, 2010 11:35:13 GMT -5
Thanxs to make me better ;D
I think the function collision is broken too, i hope devster have time some day and can fix this problems.
|
|
|
Post by TheMVRules on Mar 12, 2010 11:36:25 GMT -5
Odd... It worked on my game, but then I have no fullscreen pictures. FAKE is broken too. Try it and ASMX will give you a big fat "Phase error".
|
|
|
Post by Mairtrus on Mar 12, 2010 21:07:19 GMT -5
As far I tested, only the FAKE and MEMCOPY commands are broken. About the DRAWTILES, there is a conceptual error about this command: It uses 8-bit tilemaps, while Imagenesis give 16-bit tilemaps. So each value will read an extra 0, that's why the images seems corrupted. Here is user asm subroutine that SHOULD draw the Imagenesis's tilemaps.
Declare Asm Sub DrawTiles16(d5.l, d0.w, d1.w, d2.w, d3.w, d4.w) ' d0=X, d1=Y, d2=Largo, d3=Alto, d4=Opcional movea.l d5,a0 subq.b #1,d2 subq.b #1,d3 move.w #$2700,sr and.l #63,d0 and.l #63,d1 and.l #511,d2 and.l #511,d3 lsl.w #6,d1 add.w d1,d0 move.w d2,d1 lsl.l #3,d0 lsr.w #2,d0 swap d0 add.l (GFX_PLANE),d0 move.w #$8F02,4(a4) @1: move.l d0,4(a4) @2: move.w (a0)+,d7 add.w d4,d7 move.w d7,(a4) dbf d2,@2 add.l #$800000,d0 move.w d1,d2 dbf d3,@1 move.w #$2000,sr End Sub and use it as: drawtiles16 lblptr&(<TileMap>),<X Pos>,<Y Pos>,<Width>,<Height>,<Adder> where the adder works, for example, if your tiles starts at 256 in VRAM, and the tilemap starts at 0 (normal Imagenesis's map), put 256 in the adder and it will do the hard work for you. It was clear? This subroutine accepts whatever integer value, that means you can add directly to your tilemaps the number of pallete (+&2000, +&4000 and +&6000 for pallete 1,2 and 3, respectively), flip conditions (+$800 and +$1000 for horizontal and vertical flip, respectively) and priority (+$8000 for high priority).
P.S.: Devster, how the fuck can you pass an adress as an argument? If I put "a0 as Long", literally does nothing(well, it do something: random stuff), and "a0 as String" seems to destroy ALL the whole program.
EDIT: I forgot 3 things: 1) All the arguments needs to be, inclusive the adder. If you don't need it, put a zero. 2) It's dependant of the actual gfx plane defined with SETGFXPLANE, but isn't dependant of the pallete defined with INK, like all the commands to draw tiles(Feature that, I hope, should be removed in later versions) 3) TheElf and Alex Khan, I will answer you in the next 12 hours. I promess.
|
|
|
Post by Alex Khan on Mar 13, 2010 0:48:33 GMT -5
Mairtrus! Mairtrus! Please when you have a moment that code please have a look at it. I can't draw Sprites into it, I haven't slept or eaten anything in two days because I am so stressed about it. Please be kind enough to analyse it.
|
|
|
Post by theelf on Mar 13, 2010 12:00:48 GMT -5
Thanxs Mairtrus for the great subrutine. I love it, because is much simple and fast that the "old" method of draw tiles.
Only a question.. how do you add values, like pallete or priority?
I have this code to draw a 320x512 map, in vram pos 233
Works perfect, how i add, that use the second pallette and have high priority?
??¿? i try all combinations, and i can`t... jeje
Thanxs
|
|
|
Post by TheMVRules on Mar 13, 2010 12:23:51 GMT -5
' By Tom Maneiro, modified by TheMVRules ' Usage: DrawTiles16 <address of map>, <vram tile offset>, <position x>, <position y>, <width>, <height>, <priority> ' Priority: 0=low, 1=high Declare sub DrawTiles16(map_adr as integer,tile_adr as integer,cur_x as integer,cur_y as integer,width as integer,height as integer,prio as integer) for y = 0 to width for x = 0 to height z=map_adr ctile=z+tile_adr+priority(prio) DrawTile ctile, x+cur_x, y+cur_y next next exit sub end sub This is untested, but it should work. If it doesn't, I will change it. I am not on my BEX computer today. INK works on this one.
|
|
|
Post by Mairtrus on Mar 13, 2010 17:58:54 GMT -5
Thanxs Mairtrus for the great subrutine. I love it, because is much simple and fast that the "old" method of draw tiles. Only a question.. how do you add values, like pallete or priority? I have this code to draw a 320x512 map, in vram pos 233 Works perfect, how i add, that use the second pallette and have high priority? ??¿? i try all combinations, and i can`t... jeje Thanxs Instead, do: drawtiles16 lblptr&(level0b_map),0,0,40,64,233+pallette(2)+priority(1)
|
|
|
Post by theelf on Mar 13, 2010 18:20:19 GMT -5
Thanxs mairtrus, it works perfect.
Your rutine is fast, very fast!!! now i have 0 delay when draw the screen!!
THANXS im very happy ;D
|
|
|
Post by Tom Maneiro on Mar 13, 2010 21:21:32 GMT -5
TheMVRules function does nothing for me.
Mairtrus "assembly hell" does the trick (including the pallette(n) in the VRAM address). Could you add "ink n" support?
Well, back to coding!
|
|
|
Post by Mairtrus on Mar 14, 2010 9:36:46 GMT -5
Just add add.w (COLOR),d7 between add.w d4,d7 and move.w d7,(a4)
|
|