Jump to content
IGNORED

mirroring a bit pattern


Heaven/TQA

Recommended Posts

6502 maniacs... i try to improve schmutzpuppe's trackball ballcode without the use of a lookup table...

 

he used a strange (but working... :D) piece of code to mirror the bitpattern of the ballsprite... of course i could use a pre generated lookup table but i am sure you could do this with some clever bit manipulations...

 

any help here? thomas? manuel?

 

example

 

10000000

 

should be

 

00000001

 

of course without using any loop like schmutzpuppe's code as it will not run in VBL anymore... ;)

 

(wondering why atari missed out the mirror register of the 2600 or the h-v-flip registers of lynx or GB(A))

Link to comment
Share on other sites

6502 maniacs... i try to improve schmutzpuppe's trackball ballcode without the use of a lookup table...

 

he used a strange (but working... :D)  piece of code to mirror the bitpattern of the ballsprite

:D

Sorry haven't had much time and it was tired ;)

Took a short look at it and found the following: replace "ADC BITTAB,x" with ROR this is a bit faster and you don't need the table anymore.

Maybe there is a more elegant way.

I would be also interested in better code.

Link to comment
Share on other sites

creating a lookup table will of course be quickest in game.

 

something like the following should create a 256 byte mirrored lookup table (this is a risk without testing or the edit button! look out for the fixes later...) ;)

 


 ldx #0

?1

 stx mirror_this



 ldy #8

?2

 asl mirror_this

 ror a



 dey

 bne ?1



 sta mirror_table,x



 dey

 bne ?1

Link to comment
Share on other sites

creating a lookup table will of course be quickest in game.

 

something like the following should create a 256 byte mirrored lookup table (this is a risk without testing or the edit button! look out for the fixes later...)  ;)  

 


 ldx #0

?1

 stx mirror_this



 ldy #8

?2

 asl mirror_this

 ror a



 dey

 bne [color=red]?2[/color]



 sta mirror_table,x



 dey

 bne ?1

 

:lolblue: knew it

 

would like to see the combat code too

Link to comment
Share on other sites

yup. "(wondering why atari missed out the mirror register of the 2600 or the h-v-flip registers of lynx or GB(A))" quote end... ;)

 

thanks guys... i'll double check it...

 

still not knowing what

 

asl mirror_this

ror a

 

is doing but if it works... who cares... (attention! demo coder alarm... demo coders doesnt care WHY it's working...just that it works... ;))

Link to comment
Share on other sites

Many appologies to all, I did just send the demo and not the

code because I thought I should finish it first before doing so :D

 

Here's the Kernel based code anyway... I had decided that

this wasn't going to quite work because of the extra cycles

wasted to A8 things, so I have recoded it here with a more

VBI based approach. As happens, everything is now broken

and work stopped as my daytime and evening work has been

taking up too much of my time. :(

 

Still - my MyIDE board is now built and so next Monday it gets

fitted and I should be trying it out next week. How long does

a 12gig drive take to format :ponder: :roll: :)

 

Regards,

Mark

 

BTW, there was a similar routine to create a flip table in the

Barbarian demo I did. You'd use this for 4 colour bit patterns.

 

CreateFlipTable:

LDX     #0

@1:	TXA     

LDY     #3

@2:	ASL     A

PHP     

ASL     A

ROR     byte_0_A8

PLP     

ROR     byte_0_A8

DEY     

BPL     @2

LDA     byte_0_A8

STA     FlipTable,X

INX     

BNE     @1

RTS     

combat.zip

Link to comment
Share on other sites

creating a lookup table will of course be quickest in game.

 

something like the following should create a 256 byte mirrored lookup table (this is a risk without testing or the edit button! look out for the fixes later...)  ;)  

 


 ldx #0

?1

 stx mirror_this



 ldy #8

?2

 asl mirror_this

 ror a



 dey

 bne [color=red]?2[/color]



 sta mirror_table,x



 dey

 bne ?1

 

:lolblue: knew it

 

would like to see the combat code too

I have to admit that I don't know how this should work.

Link to comment
Share on other sites

CreateFlipTable:

LDX     #0

@1:	TXA     

LDY     #3

@2:	ASL     A

PHP     

ASL     A

ROR     byte_0_A8

PLP     

ROR     byte_0_A8

DEY     

BPL     @2

LDA     byte_0_A8

STA     FlipTable,X

INX     

BNE     @1

RTS     

 

We can improve that routine by getting rid of the Y register:

 


CreateFlipTable:

LDX     #0

@1:	LDA     #1    

STX     rotateThis

@2:	LSR      rotateThis

ROL     A

BCC     @2

STA     FlipTable,X

INX     

BNE     @1

RTS 

;)

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