Jump to content
IGNORED

VBXE - programming, examples, programming queries


Rybags

Recommended Posts

Just thinking... maybe we can use the ADD facility of the blit somehow.

 

Drawing a line, you always have the situation where either X or Y is always inc/decrementing by one each point. The other co-ordinate's change is controlled by the COLAC=COLAC+DELTAC, then you compare to ENDPT to decide whether that co-ordinate gets changed.

 

Just forget long lines for a bit... we might be limited to 255 pixel long lines.

 

We could use blits to prepare a list of all the COLAC values that will be encountered during the given line draw. Then we just do a bunch of compares. Of course, the blit hasn't done the COLAC=COLAC-ENDPT operation that's supposed to occur when a step occurs, but maybe we can adjust our compare value to compensate.

 

Unsure if this approach will work. In theory though if we could accelerate this part of the process, we could end up with a quicker line draw.

Link to comment
Share on other sites

If anyone could post a verified working code snippet showing 80 col text mode characters with their background colours changed with the attribute byte, I'd be incomprehensibly grateful. icon_smile.gif

 

Enjoying this discussion, BTW. New ways to abuse the blitter are always interesting.

 

...It's OK. I think I have it cracked. TEXTMODE.COM sets every colour between 128-255 to turquise!

Edited by flashjazzcat
Link to comment
Share on other sites

I require three distinct colour schemes on the screen:

 

1) light turqoise on dark

2) white on black

3) black on white

 

I'm attempting to set up the palette so that colour 1 is light turq, while colour 129 is dark turqoise (background). In turn, colour 2 is white, and colour 130 is black... and so on. Bit 7 of the attribute byte will always be set, while bits 0 and 1 simply select one of the three possible colour schemes.

 

User adjustments will then be accomplished using palette adjustment. Does this seem a sensible solution?

Link to comment
Share on other sites

Thinking again about using blits to do adds.

 

We could do array processing of 16-bit adds (you'd need to do a certain number of operations to gain any time benefit).

 

VBXE doesn't do Carry from lo-hi bytes though, but there's an easy way around that. Just compare the initial value with the new value (low bytes only). If the new value of the low byte is less than the initial value, then obviously a Carry has been generated and the high byte should be incremented.

 

e.g. 250 + 7 = 1 (less than initial value, Carry generated)

250 + 4 = 254 (not less than initial value, no Carry)

250 + 0 = 250 (not less than initial value, no Carry)

1 + 255 = 0 (less than initial value, Carry generated)

 

The compare would need to be repeated to check for overflow, but in many/most cases we're probably in a controlled situation where that won't happen so we could skip it.

 

So, we'd have something like:

 

. setup blits to add Array1 elements to Array2 elements - 1 blit for lo, 1 for hi bytes.

. run the blits (results get stored in Array2)

. run a loop that performs the carry check. For quicker execution the arrays are best stored with all low bytes in one block, high bytes in another. So the code for the carry check should be as simple as e.g. for 256 element array:

 

 ldx #0
checkcarry  lda array2_lowbyte,x
 cmp array1_lowbyte,x
 bcs no_inc1
 inc array2_highbyte,x
noinc1  inx
 bne checkcarry

 

Of course, some more extra speed could be had by unrolling that loop a bit.

 

The method could be expanded to higher order (24/32 etc) binary addition too.

Edited by Rybags
Link to comment
Share on other sites

 ldx #0
checkcarry  lda array2_lowbyte,x
 cmp array1_lowbyte,x
 bcs no_inc1
 inc array2_highbyte,x
noinc1  inx
 bne checkcarry

 

12 CPU cycles/byte is pretty expensive by blitter speeds, considering that doing a read-modify-write pass with the blitter can run as fast as 0.38 cycles/byte.

 

I did some sketches with logic operations, and I'm beginning to think that the fastest way to do this is using the blitter with a 64K lookup table to compute the carry. It's expensive in blitter time, but it's still much faster than the CPU at ~3 cycles/byte.

Link to comment
Share on other sites

But how's a lookup table going to work with an array processing situation?

 

I can't quite visulise how the blit could do a pass through our data again and tell us which bytes require Carry.

 

It's similar to the trick I did with the rotate program to set up the shears entirely on the blitter:

  • Create a list of N 1x1 blits. Source pattern replication works nicely for this.
  • Blit one set of addends into the source low bytes of the blits (dest X step = 21).
  • Blit another set of addends into source mid bytes of the blits.
  • Patch the final NEXT bit and execute the blit list. Each blit copies one entry from a 256x256 table into a destination array with 00 (no carry) or 01 (carry).
  • Use the result as source for a blit into the high byte array in add mode to add in lo->hi carry.

 

Not the fastest way to do a table lookup and you do need to align the lookup tables in memory, but it's still faster than the 6502.

Edited by phaeron
Link to comment
Share on other sites

question regarding 24bit macros in mads... is .long correct working for vbxe programming?

 

look:

 

$00100:
 Source: $04000 Xinc=+0 Yinc=+320
 Dest:   $00040 Xinc=+0 Yinc=+3841
 Size:   272 x 1
 Masks:  AND=$00, XOR=$00, COLL=$00
 Zoom:   1 x 1
 Patt:   disabled
 Mode:   0 (Copy)

says the debugger of Altirra and here is my BCB code snippet while using MADS...

char_bcb: 
	;.byte $00,$40,$00 ;source adress
	.long $004000 ;source adress
	.byte <320,>320 ;source step
	.long $004000 ;destination adress
	.byte <320,>320 ;dest. step
	.byte 15,0 ;size x
	.byte 15	;size y
	.byte 255 ;and
       .byte 0       ; XOR
       .byte 0       ;  collision AND
       .byte 0       ; zoom
       .byte 0       ; pattern
       .byte 9       ; control

 

????

Link to comment
Share on other sites

question regarding 24bit macros in mads... is .long correct working for vbxe programming?

 

look:

 

char_bcb: 
	;.byte $00,$40,$00 ;source adress
	.long $004000 ;source adress
	.byte <320,>320 ;source step
	.long $004000 ;destination adress
	.byte <320,>320 ;dest. step
	.byte 15,0 ;size x
	.byte 15	;size y
	.byte 255 ;and
       .byte 0       ; XOR
       .byte 0       ;  collision AND
       .byte 0       ; zoom
       .byte 0       ; pattern
       .byte 9       ; control

 

.long does produce a 24-bit value that should work, but you are missing the source/destination X step bytes.

Link to comment
Share on other sites

Altirra> .vbxe_bl
$00000:
 Source: $00024 Xinc=-55 Yinc=+2162
 Dest:   $04000 Xinc=+1 Yinc=+320
 Size:   256 x 1
 Masks:  AND=$00, XOR=$00, COLL=$00
 Zoom:   1 x 1
 Patt:   disabled
 Mode:   0 (Copy)

 

what could be the reason?

 

a12:
       lda #0
       sta $D650
       lda #$01          ;$000100 = $4100 bank #0
       sta $D651       ; blitter addr
       lda #0          ;
       sta $D652

Link to comment
Share on other sites

RTFM... now altirra shows the correct bcb in debugger...

 

 

 

char_bcb: 
	.long $004000 ;source adress
	.word 320 ;source step y
	.byte 1
	.long $004000+100+16*320 ;destination adress
	.word 320 ;dest. step y
	.byte 1
	.byte 15,0 ;size x
	.byte 15	;size y
	.byte 255 	;and
       .byte 0     ; XOR
       .byte 0       ;  collision AND
       .byte 1       ; zoom
       .byte 0       ; pattern
       .byte 1       ; control

Link to comment
Share on other sites

Odd, that blitter setup should work. Any chance you may have accidentally hit the VBXE reset range at $D080-D0FF?

 

There currently isn't a way to peek directly at VBXE RAM -- you have to use the MEMAC A and B windows, switching banks by poking the control registers with the (e)nter command as necessary. The debugger currently only works in CPU view; giving it access to extended RAM isn't something I've gotten around to yet.

 

To see more of memory at once, you'll have to use the memory window. The 'db' command doesn't take a length parameter yet.

Link to comment
Share on other sites

Any guidelines or tips on exporting palettes from Photoshop or similar when designing 256 colour bitmapped images for VBXE?

 

For the pics I did (used Photoshop), I just converted from 24-bit to Indexed Color with one of the "Local" methods to bring it down to 256 colours.

 

You're only losing 1 bit per channel of RGB precision which is barely noticable. Of course the smaller palette means the pic will lose a bit of realism but it depends on the image.

 

I save as BMP with the image flipped (ie, right way up). Then it's a case of just skipping the header - 66 bytes (?)

Then you have the RGB for the palette which can just be loaded to RAM, stored in a Palette and discarded, followed by the bitmap data.

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