Help: ZX81 'BASIC' Peek function [duplicate] - peek

This question already has answers here:
Help: ZX81 BASIC "Peek" function
(3 answers)
Closed 8 years ago.
I need a way to find if the character ('<') has hit a wall (Black pixel Graphic)
-On a ZX81 game.
I'm been looking at another game... which uses code
if peek(peek 16398 +256*peek 16399) = code "blackpixel graphic" then ...
Which seems to work for them...
Is this correct code?
I'm not really knowledgable with addresses and getting memory and stuff.
Please help me...
-If you know a better way. Please answer :)
-Someone mentioned 'cursor position' what the hell is that on a ZX81?
Thanks,

PEEK(PEEK 16398+256*PEEK 16399) is an idiom meaning β€œget the character number at the current PRINT position”. This works because the two-byte word at 16398 is used by the ZX81 BASIC/ROM to store a pointer to the memory location in the screen data block corresponding to the PRINT position.
So to do collision detection, you'd first have to set:
PRINT AT X,Y;
co-ordinates to where the > is about to move, then read
LET C= PEEK(PEEK 16398+256*PEEK 16399)
then you can print the > on-screen (overwriting the previous character whose code is now in C) if you want to before doing the check:
IF C=128 THEN ...
(I'm guessing the character you want is the all-black character 128, β–ˆ.)
Oh boy, do I feel old.

Wow does this go back. I haven't used a ZX81, but I did write some games on a TRS-80 way back in the day.
The inner part:
(peek 16398 +256*peek 16399)
is pretty much taking the value of two memory locations (8 bit) and creating a 16 bit
number from them, which is then used as the address of the outer peek; you might rewrite this as:
addrToCheck = (peek 16398 +256*peek 16399)
pixelValue = peek(addrToCheck)
if pixelValue = code "blackpixel graphic" then...
I'm guessing that the 'addrToCheck' value is actually the character position in the game, expressed as an address on the screen. So if the value is not a wall, then you would update the values in address 16398 and 16399 with a new character position (using a 'poke', no doubt).
Hope this helps

Related

IOS 11 UILabel automatic line break doesn't work when text is too long [duplicate]

This question already has answers here:
UILabel Text Not Wrapping
(8 answers)
Closed 5 years ago.
All automatic line break of UILabel was failed when I updated the XCode to 9.1. Any body same as me? I have set the attribute like below:
cell.testLabel.text = "long text here"
cell.testLabel.lineBreakMode = .byWordWrapping
cell.testLabel.numberOfLines = 0
Anybody can help me? Thanks!!!
Since iOS11, there appears to be an intentional change in how words are wrapped within an UILabel. Word wrapping mechanism was adjusted so as to make your multiline text wrapped with enhanced proportion. If you have a long text consisting of short words standing consecutively, it is likely that your text will be wrapped avoiding orphaned words, i.e. more than one word is about to be wrapped onto the next line. If the finishing word is long enough, then there might be no need to wrap extra words, because proportion may appear justified.
Example:
1.
Both words are wrapped, even though there's a room for one 'test' on the first line.
2.
Only the longest word is wrapped, because enough space is already occupied on the second line with it.
As of now, unfortunately, you are unlikely to influence it, since no additional properties were introduced to manage this behavior.
Workaround
There's a hack which can help in certain circumstances. You can replace whitespace with a non-breaking space (U+00A0). This way two consecutive words are treated as one which may cheat wrapping mechanism.

Scala Random.nextString(int) returning question marks

Whenever I use Random.nextString(int), I get a String of questions marks (??????). I've tried using creating an instance of Random and using a seed, but nothing works. I am using Scala 2.10.5. Anyone know what the issue is?
In most terminals, when a character is not displayable (there are a lot of existing characters, and you cannot remotely hope to have them all in the font used by your terminal), it will print a question mark instead.
Because the string is random, you are very likely to have the vast majority of them be non displayable (and thus rendered as a sequence of question marks).
So the strings are valid, they are indeed random (not just a series of question marks), and this is all just a rendering issue. You can easily check that their content really is different each time by displaying the character codes (something like println(myString.map(_.toInt)) will do).

LED Display simulation Xcode

I have been very long looking for the answer to my question on the web, but I didn't found anything helpful so I decided to ask you.
Basically I want to Programm a app like how this video shows. Another big deal for me is - how can I change the text size ?
For each character I should make a array of boolean to determine if the led pin should be on or off. I think this is the smartest way for displaying text in fix text size.
Do I have to make an array for every character in every text size I want to get this function working ?
Essentially you are making a Font Map for each font you wish to display on your large LED display. Just like fonts on a regular display, Im afraid the answer is YES, you will have to make essentially a map file for every font you wish to support.
It may not have to be true booleans however, you may be able to get away with a much more compact version of the booleans by storing multiple boolean bits in a single byte, short, or int, etc...

Is there a Unicode glyph that looks like a "key" icon? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Unicode has a million icon-like glyphs, but they're not always easy to search by, since I don't always know what they look like.
Is there a Unicode glyph that looks like a "key"? Or is there a symbol that's used in database circles to mean "primary key", which is in Unicode?
U+1F511 πŸ”‘ KEY
(128273 decimal)
Also:
U+1F5DD πŸ— (Decimal: πŸ—) OLD KEY
U+26BF ⚿ SQUARED KEY
U+1F510 πŸ” CLOSED LOCK WITH KEY
U+1F512 πŸ”’ LOCK
U+1F513 πŸ”“ OPEN LOCK
U+1F50F πŸ” LOCK WITH INK PEN
To find useful symbols, I have this resource:
http://shapecatcher.com
Allows you to draw a shape, which it then searches for similarly shaped unicode symbols.
I often end up using shapecatcher these days just because it's a fun break just to be able to draw the shape that you want and have the site pull it up for you. At least, sometimes it will pull it up.
Misc. Symbols Blocks
http://shapecatcher.com/unicode/block/Miscellaneous_Symbols_And_Pictographs is also a great category of unicode symbols, though as with all unicode, you may have to test compatibility.
This is duplicated from my answer here because I think the approach will be useful to others besides just me: What Unicode character do you use in your website? (instead of image icons)
I used a little Python 3 script to look, and the closest I found does not display here for me (does display in Idle on my machine), but it is:
9897 ⚩ HORIZONTAL MALE WITH STROKE SIGN
(Looks like a male sign pointed right with a perpendicular stroke added between the arrow and circle)
I searched for various matches like "KEY" and "LOCK" in the unicode names using Python's unicodedata module and no luck there.
Editing to add - Ah hah - one that looks even more like a key:
9911 ⚷ CHIRON
I give both of the above code points in decimal. To see them and their hex codes, go to this link:
http://www.unicode.org/charts/PDF/U2600.pdf
See 26B7 in particular for the Chiron.
Check out #26bf.
9919 ⚿ SQUARED KEY (HTML: ⚿)
It's the parental lock, which is a key inside a square. It's a newer Unicode specification so standard fonts don't support it, but if you can find a font that has it, you're home free.
I've found Google to be the best way to find Unicode characters. I didn't find see anything useful for a key symbol, however.
If you want to search visually, use the PDF charts, since HTML-based listings will only show symbols that occur in the particular set of fonts you have installed.
Lacking any specific symbol, I would just use "I" to indicate an index and "PK" for a primary key.
I browsed through all the symbols (using a PHP script I created a while back) and can't see a key symbol. You could try one of these:
A mathematic-looking P:
β„™ (#8473)
Various star shapes:
β˜… (#9733)
β˜† (#9734)
✢ (#10038)
There doesn't seem to be a unicode character that fits your description, but I'd recommend the silk icon set by famfamfam if you can use icons in your situation--just a suggestion :P

How can I generate this hash?

I'm new to programming (just started!) and have hit a wall recently. I am making a fansite for World of Warcraft, and I want to link to a popular site (wowhead.com). The following page shows what I'm trying to figure out: http://www.wowhead.com/?talent#ozxZ0xfcRMhuVurhstVhc0c
From what I understand, the "ozxZ0xfcRMhuVurhstVhc0c" part of the link is a hash. It contains all the information about that particular talent spec on the page, and changes whenever I add or remove points into a talent. I want to be able to recreate this part, so that I can then link my users directly to wowhead to view their talent trees, but I havn't the foggiest idea how to do that. Can anyone provide some guidance?
The first character indicates the class:
0 Druid
c Hunter
o Mage
s Paladin
b Priest
f Rogue
h Shaman
I Warlock
L Warrior
j Death Knight
The remaining characters indicate where in each tree points have been allocated. Each tree is separate, delimited by 'Z'. So if e.g. all the points are in the third tree, then the 2nd and 3rd characters will be "ZZ" indicating "end of first tree" and "end of second tree".
To generate the code for a given tree, split the talents up into pairs, going left-to-right and top-to-bottom. Each pair of talents is represented by a single character. So for example, in the DK's Blood tree segment, the first character will indicate the number of points allocated to Butchery and Subversion, and the second character will stand for Blade Barrier and Bladed Armor.
What character represents each allocation among the pair? I'm sure there's an algorithm, probably based on the ASCII character set, but all I've worked out so far is this lookup table. Find the number of points in the first talent along the top, and the number of points in the second talent along the left side. The encoded character is at the intersection.
0 1 2 3 4 5
0 0 o b h L x
1 z k d u p t
2 M R r G T g
3 c s f I j e
4 m a w N n v
5 V q i A y E
So if our Death Knight has one point in Butchery and two points in Subversion, the first character is 'R'. If instead we put no points in those two and five in Blade Barrier, the first two characters will be "0x". Trailing '0's (all the other pairs in the tree with no points allocated) can be omitted, as can trailing 'Z' delimiters (when there are no points in the subsequent trees). For one final example, the entire code for a DK with just a single point in Toughness would be "jZ0o": "Death Knight", "End of the first tree", "No points in the first pair of talents", "one point in the first talent of the second pair".
Can anyone work out what function generates the lookup table above? There's probably a clue in the codes for the classes: in alphabetical order (except for the DK which was added to the game after the others), they correspond to a series in the lookup table of (0,0), (0,3), (1,0), (1,3), (2,0), etc.
If you go to http://www.wowhead.com/?talent and start using the talent tree you can see the mysterious code being built up in the address bar as you click on the various boxes. So it's definitely not a hash but some kind of encoded structure data.
As the code is built up as you click the logic for building the code will be in the JavaScript on that page.
So my advice is do a view source on the page, download the JavaScript files and have a look at them.
I think it isn't a hash value, because hash values are normally one-ways values. This means you cannot (easily) restore the original information from which the hash code was generated.
Best thing would be to contact someone from wowhead.com and ask them how to interpret this information. I am sure they will help you out with some information about what type of encoding they use for the parameters. But without any help of the developers from wowhead.com it is almost impossible to figure out what information is encoded into this parameter.
I am not even sure the parameter you mentioned contains the talents of your character. Maybe it's just a session id or something like that. Take a look into the post data your browser sends to the server, it may contain a hidden field with the value you are searching for (you can use Tamper Data Firefox Addon).
I don't think ozxZ0xfcRMhuVurhstVhc0c is a hash value. I think it is a key (probably encrypted/encoded in some way). The server uses this key to retrieve information from it database. Since you don't have access to the database you don't know which key is needed, let alone how to encode it.
You need the original function that generates the hash.
I don't think that's public though :(
Check this out: hash wikipedia
Good luck learning how to program!
These hashes are hard to 'reverse engineer' unless you know how it was generated.
For example, it could be:
s1 = "random_string-" + score;
hash = encrypt(s1)
...etc
so it is hard to get the original data back from the hash (that is the whole point anyway).
your best bet would be link to the profile that would have the latest score ..etc