.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
An odd question...
Old
  (#1)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default An odd question... - 14-08-2005

A stupid late-night idea has me trying to create a dot matrix display using '.' and 'o' characters...
I have it set up so that there are 160 bits/dots, 32 bits wide by 5 bits high.
So, each line is made up of 4 bytes ( ie. byte 2 is 16,0 to 23, 0 ).

I just can't figure out how to convert an X,Y coordinate ( say, 5,2 ) to an individual byte and bit.
There must be some kind of math to do it but I can't figure it out - unless more coffee will help.

I could post the code I have now if needed, but its not commented and only rotates the bits in every byte of the first line.
Btw, is there a standard C/C++ way to rotate bits?
I can't remember off hand so I used some x86 asm to do the rotation.
  
Reply With Quote
Re: An odd question...
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: An odd question... - 16-08-2005

If you have lines of 32 bits you have 4 bytes per line. So the bit A on line B will be the 32*B+A bit of your flattened array. To find which byte it is from, divide that by eight and round it down.

rotate bits in C ? Use the << and >> operators. But be aware that the leftmost and rightmost bits are lost, so if you want them to reappear at the other side of the word, you have to put them there manually.

I really think you should sleep more, maths look much simpler when looked at through wide open eyes and with a fully operational brain



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: An odd question...
Old
  (#3)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: An odd question... - 16-08-2005

Thanks, I'll try that out in a bit.
I'm starting to learn 6502 assembly and the book I'm reading assumes the computer has display memory that can be written to inorder to put things on the display.
Unfortunately, the simulator I'm using works by writing a character value to a memory address to put something on the screen.
So with my limited 6502 assembly I'm setting aside 440 bytes to use as emulated display memory then iterating through the bytes and writing them to the display character address every time it's needed.
Horribly inefficient but no 6502 simulators I found supported display memory.

So while this vvvvv works for temporary purposes, the book requires the emulated display memory.
Code:
		.ORG $200
HelloString:	.ASCII "Hello from 6502 ASM!", $00
		.START .Main

.Main	LDY #$00
.Getch	LDA HelloString, Y
	BEQ .Fin
	
	STA $E001
	INY
	JMP .Getch

.Fin	BRK
As for sleep, I wish I could...
I just end up lying in bed for hours until I come to realize sleep is not going to happen, so I just go back and code some more.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com