KanedaFr Posted November 6 Share Posted November 6 Hi there, If anyone interested, I'm testing the blitter using rapBlitlist https://bitbucket.org/SpritesMind/blitter_test be free to comment Quote Link to comment https://forums.atariage.com/topic/374960-blitting/ Share on other sites More sharing options...
KanedaFr Posted November 6 Author Share Posted November 6 For now, I'm unable to copy block but don't know if I'm missing something or if it's an emulator issue Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5561461 Share on other sites More sharing options...
Seedy1812 Posted November 7 Share Posted November 7 First step to getting help , asking for help Second step , show what you think is going wrong and I dont mean giving a rom or jpeg but actual code and what you think is going on Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562026 Share on other sites More sharing options...
Seedy1812 Posted November 7 Share Posted November 7 This is the code I used in Bubsy for blitting a map tile into a full screen map sprite This will copy the tile either by data or by pattern if its empty D1 = count in x and y ( say its a 16x 16) A2 = address in memory the tile is in the full screen bitmap sprite The D2 is the command to clear with patten data for a sprite then d6 = 0,0 , technically its the same as 1,-16 but as the width is 16 then i just used 0 A2_PIXEL = d6 , where the next pixel is after end of line write out d0 to B_CMD notice SRCEN ( Enables a source data read as part of the inner loop operation ) , UPDA1 ( Add the A1 step value to the A1 pointer between inner loop operations in the outer loop.) i think LFU_A and LFU_AN are both set to just do a copy blit_line_across1 move.l #SRCEN|UPDA1|LFU_A|LFU_AN,d0 move.l #$00010001<<BLOCK_BITS,d1 move.l #UPDA1|PATDSEL,d2 moveq #0,d6 moveq #MAP_DEPTH*BLOCK_HEIGHT,d5 bsr do_a_map_square1 moveq #PLAYFIELD_WIDTH-1,d3 .lp add.l d5,a2 bsr.s do_a_map_square1 dbf d3,.lp add.l d5,a2 do_a_map_square1 move.l d6,A1_PIXEL-B_PATD(a5) move.l a2,A1_BASE-B_PATD(a5) move.l d1,B_COUNT-B_PATD(a5) moveq #0,d7 move.w (a6)+,d7 bne.s .notclear move.l d2,B_CMD-B_PATD(a5) ;set it going with a pattern rts .notclear lsl.l #2,d7 move.w 0(a4,d7.l),d7 ext.l d7 lsl.l #8,d7 add.l a0,d7 move.l d6,A2_PIXEL-B_PATD(a5) move.l d7,A2_BASE-B_PATD(a5) ;set screen window bases move.l d0,B_CMD-B_PATD(a5) ;set it going rts Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562047 Share on other sites More sharing options...
KanedaFr Posted November 7 Author Share Posted November 7 (edited) 😨 Because it was more a warning than a request for help : my copy block command doesn't work yet... But .... why not ? I tried many things and I don't understand the result so here we go. Can someone help to understand what's wrong here? What I'd like to do: copy a 32x24 4bpp bitmap to a 128x128 4bpp gfxdata What I've done: ROM,LOGO_U235SE,gfx_clut,ASSETS\GFX\u235se.bmp ... static int blitlist[10][16]; int layerCanvas = sprite[0].gfxbase; //dest blitlist[0][regA1_BASE] = layerCanvas; blitlist[0][regA1_FLAGS] = PIXEL4|XADDPIX|WID128|PITCH1; ////4bpp, 128pixels, x++ blitlist[0][regA1_PIXEL] = 0; //source blitlist[0][regA2_BASE] = LOGO_U235SE; blitlist[0][regA2_FLAGS] = PIXEL4|XADDPIX|WID32|PITCH1; //4bpp, 32pixel, x++ blitlist[0][regA2_PIXEL] = 0; //blit blitlist[0][regB_COUNT] = (24<<16) | 32; //24 lines x 32 rows blitlist[0][regB_CMD] = LFU_REPLACE|SRCEN; //// get from SRC and replace/overwrite on DEST //all others registers are zeroed blitlist[1][regA1_BASE] = -1; //terminator rapBlitlist(STRPTR(blitlist)); What I have on BigP I don't understand what is happening (I don't care about the colors) every row seems to be side by side and not one under another ie: 1111 2222 3333 4444 5555 6666 7777 8888 and not 1111 2222 3333 4444 5555 6666 7777 8888 What I did to create this ? Edited November 7 by KanedaFr Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562050 Share on other sites More sharing options...
KanedaFr Posted November 7 Author Share Posted November 7 (edited) 40 minutes ago, Seedy1812 said: This is the code I used in Bubsy for blitting a map tile into a full screen map sprite No flags ? I suspected my issue was on that side....but I just tried with same result this : blitlist[0][regA1_FLAGS] = PIXEL4; blitlist[0][regA2_FLAGS] = PIXEL4; and so I'm more and more lost how to use the blitter Edited November 7 by KanedaFr Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562078 Share on other sites More sharing options...
Seedy1812 Posted November 7 Share Posted November 7 18 minutes ago, KanedaFr said: No flags ? I suspected my issue was on that side....but I just tried with same result this : blitlist[0][regA1_FLAGS] = PIXEL4; blitlist[0][regA2_FLAGS] = PIXEL4; and so I'm more and more lost how to use the blitter They get set up right start the start of the function move.l #PITCH1|XADDPHR|WID16|PIXEL8,A2_FLAGS-B_PATD(a5) ;a2 (Source) move.l #PITCH1|XADDPHR|WID384|PIXEL8,A1_FLAGS-B_PATD(a5) ;a1 (Dest) 1 Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562090 Share on other sites More sharing options...
Sporadic Posted November 7 Share Posted November 7 (edited) You need to set A1 step int register to (1<<16)|(-32&0xFFFF) Then append UPDA1 to your CMD entry. This will set the inner loop pointer back to the start of the row after each line it draws. I dont think you need to do the same for A2 as it's graphics source is the same width as you are drawing. But if the above doesn't work, also try setting the A2 step register and append UPDA2 to the CMD Edited November 7 by Sporadic 1 Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562117 Share on other sites More sharing options...
KanedaFr Posted November 8 Author Share Posted November 8 (edited) OH! it works !!! Thanks! I though this was handled by WIDxxx I'll need to read jagdox again to understand what WIDxxx is really needed for Edited November 8 by KanedaFr 1 Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562128 Share on other sites More sharing options...
Sporadic Posted November 8 Share Posted November 8 Basically it's because the WID (window) size is larger than the image you are blitting. Therefore you need to tell it to return 32 pixels after each line. You could probably set the destination window to WID32 as well (and remove the A1 step) but you'd have to adjust the A1 pixel pointer to the exact location you want to draw. But I have never tried that so I could be wrong. I did plan on adding more blitter examples to the next JagStudio release. The next release also has an enum for all the available registers to map the array. Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562136 Share on other sites More sharing options...
KanedaFr Posted November 8 Author Share Posted November 8 (edited) I tried using the same WID on A1 and A2 without success...but I didn't ajusted the A1 Pixel pointer so I can't say It's why there aren't many blitter examples on JS that I started this one...( and to learn by trying/falling) so be free to use anything you want, if interested by my very basic skill For the enum, it's exactly what I did enum{ regA1_BASE, regA1_FLAGS, regA1_CLIP, regA1_PIXEL, regA1_STEP_INT, regA1_STEP_FRAC, regA1_PIXEL_POINTER, regA1_INC_INT, regA1_INC_FRACT, regA2_BASE, regA2_FLAGS, regB_PATD, regA2_PIXEL, regA2_STEP, regB_COUNT, regB_CMD }; Edited November 8 by KanedaFr Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562139 Share on other sites More sharing options...
Sporadic Posted November 8 Share Posted November 8 Yeah now I think about it, my assumption was wrong on that last bit. The window size needs to match the size of the area you are drawing in to as that's the size of the memory block. Well done on the enum idea too. No idea why I didn't add it previously 😄 1 Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562146 Share on other sites More sharing options...
Seedy1812 Posted November 8 Share Posted November 8 (edited) 15 hours ago, KanedaFr said: 😨 Because it was more a warning than a request for help : my copy block command doesn't work yet... But .... why not ? I tried many things and I don't understand the result so here we go. Can someone help to understand what's wrong here? What I'd like to do: copy a 32x24 4bpp bitmap to a 128x128 4bpp gfxdata What I've done: ROM,LOGO_U235SE,gfx_clut,ASSETS\GFX\u235se.bmp ... static int blitlist[10][16]; int layerCanvas = sprite[0].gfxbase; //dest blitlist[0][regA1_BASE] = layerCanvas; blitlist[0][regA1_FLAGS] = PIXEL4|XADDPIX|WID128|PITCH1; ////4bpp, 128pixels, x++ blitlist[0][regA1_PIXEL] = 0; //source blitlist[0][regA2_BASE] = LOGO_U235SE; blitlist[0][regA2_FLAGS] = PIXEL4|XADDPIX|WID32|PITCH1; //4bpp, 32pixel, x++ blitlist[0][regA2_PIXEL] = 0; //blit blitlist[0][regB_COUNT] = (24<<16) | 32; //24 lines x 32 rows blitlist[0][regB_CMD] = LFU_REPLACE|SRCEN; //// get from SRC and replace/overwrite on DEST //all others registers are zeroed blitlist[1][regA1_BASE] = -1; //terminator rapBlitlist(STRPTR(blitlist)); What I have on BigP I don't understand what is happening (I don't care about the colors) every row seems to be side by side and not one under another ie: 1111 2222 3333 4444 5555 6666 7777 8888 and not 1111 2222 3333 4444 5555 6666 7777 8888 What I did to create this ? You are missing the update to A1 after copying a line and before you start the next line. If you miss the update you are copying 24*32 pixels one after another . As the destination is 128 pixels - thats 4 * 32 in the x and that leaves 8 in the Y. What you need to do is say after we done a line of pixels we need to move the current position down 1 pixel (high word ) and to the left 32 pixels (low word ) A1 Step Value = [1][-32] ( [] indicates each word ) or 0x0001ffe0 So after the first line you are at 0,32 but before the next line you ned to be at 1,0 Edited November 8 by Seedy1812 1 Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5562347 Share on other sites More sharing options...
KanedaFr Posted November 10 Author Share Posted November 10 (edited) I added scale but there is something strange : Enlarged bitmap (top one) starts to read data 1 pixel earlier Shrinked bitmap (bottom one) starts to draw data 1 pixel earlier at least on bigPEmu x2 enlarge commands: srcx = 0; srcy = 0; //dest blitlist[cmdIdx][regA2_BASE] = layerCanvas; blitlist[cmdIdx][regA2_FLAGS] = PIXEL4|XADDPIX|WID128|PITCH1; blitlist[cmdIdx][regB_PATD] = 0; //we don"t care blitlist[cmdIdx][regA2_PIXEL] = ( (destY&0xFFFF)<<16) | (destX&0xFFFF); //to (x,y) blitlist[cmdIdx][regA2_STEP] = (1<<16)|(-64&0xFFFF); //source blitlist[cmdIdx][regA1_BASE] = source; blitlist[cmdIdx][regA1_FLAGS] = PIXEL4|XADDINC|WID32|PITCH1; ////4bpp, 32pix, x+=0.5 blitlist[cmdIdx][regA1_CLIP] = 0; blitlist[cmdIdx][regA1_PIXEL] = ((srcy&0xFFFF)<<16)|(srcx&0xFFFF); //we read line 0.5 by 0.5 blitlist[cmdIdx][regA1_STEP_INT] = (0<<16)|(-32&0xFFFF); blitlist[cmdIdx][regA1_STEP_FRAC] = 0x7FFF0000; //((scaleY&0xFFFF)<<16)|(scaleX&0xFFFF);; blitlist[cmdIdx][regA1_PIXEL_POINTER] = 0; //we inc X by 0.5 every draw blitlist[cmdIdx][regA1_INC_INT] = (0<<16)|(0&0xFFFF); blitlist[cmdIdx][regA1_INC_FRACT] = 0x00007FFF; blitlist[cmdIdx][regB_COUNT] = (48<<16) | 64; //24x2 lines vs 32x2 row blitlist[cmdIdx][regB_CMD] = DSTA2|LFU_REPLACE|SRCEN|UPDA1F|UPDA1|UPDA2; //// get from SRC and replace/overwrite on DEST /2 shrink commands: srcx = 0; srcy = 0; //dest blitlist[cmdIdx][regA1_BASE] = layerCanvas; blitlist[cmdIdx][regA1_FLAGS] = PIXEL4|XADDINC|WID128|PITCH1; ////4bpp, 128pixels, x+=0.5 blitlist[cmdIdx][regA1_CLIP] = 0; blitlist[cmdIdx][regA1_PIXEL] = ((destY&0xFFFF)<<16)|(destX&0xFFFF); blitlist[cmdIdx][regA1_STEP_INT] = (0<<16)|(-16&0xFFFF); blitlist[cmdIdx][regA1_STEP_FRAC] = 0x7FFF0000; // y+= 0.5 blitlist[cmdIdx][regA1_PIXEL_POINTER] = 0; blitlist[cmdIdx][regA1_INC_INT] = 0; blitlist[cmdIdx][regA1_INC_FRACT] = 0x00007FFF; //x+=0.5 //source blitlist[cmdIdx][regA2_BASE] = source; blitlist[cmdIdx][regA2_FLAGS] = PIXEL4|XADDPIX|WID32|PITCH1; blitlist[cmdIdx][regB_PATD] = 0; //we don"t care blitlist[cmdIdx][regA2_PIXEL] = ( (srcy&0xFFFF)<<16) | (srcx&0xFFFF); //from (0,0) blitlist[cmdIdx][regA2_STEP] = 0; blitlist[cmdIdx][regB_COUNT] = (24<<16) | 32; //24 lines vs 32 row blitlist[cmdIdx][regB_CMD] = LFU_REPLACE|SRCEN|UPDA1F|UPDA1; //// get from SRC and replace/overwrite on DEST If I try to enlarge x3, I have the same 1 pixel issue so it seems to be not related to the scale value code updated on repo rom available on repo something related to XADDINC ? Any hint is welcome ...and if someone can confirm it's the same on real Hardware, I'm interested too! Edited November 10 by KanedaFr Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5563074 Share on other sites More sharing options...
KanedaFr Posted November 10 Author Share Posted November 10 (edited) I finally found a VJ version where input are working, so I tried and... I have another problem on VJ but the scale issue is the same...so it's definetly on my side 😭 /////// I also tried on ROM and RAM, same issue so not related on source type data is dphrase aligned by JS so not this one too Edited November 10 by KanedaFr Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5563086 Share on other sites More sharing options...
Seedy1812 Posted November 10 Share Posted November 10 Consider this , you only want to draw each pixel once. So if you are scaling up a 160x120 to 320x240 then you need to blit 320*240 pixels. If you go the other way you only need to blit 160*120 pixels. Each way means you step the destination every pixel but the instead of stepping the source every 1/2 a pixel you step every 2 pixels. This is done by using DSTA2 in B_CMD Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5563450 Share on other sites More sharing options...
KanedaFr Posted November 11 Author Share Posted November 11 Yes, it's what I did. It works BUT I have thsi 1 pixel issue I don't understand where it comes form Quote Link to comment https://forums.atariage.com/topic/374960-blitting/#findComment-5564043 Share on other sites More sharing options...
Recommended Posts
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.