2017-10-29 03:42:35 +00:00
text_addresses = { ' Pedestal ' : ( 0x180300 , 256 ) ,
2017-05-20 12:07:19 +00:00
' Triforce ' : ( 0x180400 , 256 ) ,
' Uncle ' : ( 0x180500 , 256 ) ,
' Ganon1 ' : ( 0x180600 , 256 ) ,
' Ganon2 ' : ( 0x180700 , 256 ) ,
' Blind ' : ( 0x180800 , 256 ) ,
' TavernMan ' : ( 0x180C00 , 256 ) ,
' Sahasrahla1 ' : ( 0x180A00 , 256 ) ,
' Sahasrahla2 ' : ( 0x180B00 , 256 ) ,
' BombShop1 ' : ( 0x180E00 , 256 ) ,
' BombShop2 ' : ( 0x180D00 , 256 ) ,
2017-07-14 21:32:40 +00:00
' PyramidFairy ' : ( 0x180900 , 256 ) ,
' EtherTablet ' : ( 0x180F00 , 256 ) ,
2017-07-17 16:04:24 +00:00
' BombosTablet ' : ( 0x181000 , 256 ) ,
' Ganon1Invincible ' : ( 0x181100 , 256 ) ,
' Ganon2Invincible ' : ( 0x181200 , 256 ) }
2017-05-20 12:07:19 +00:00
2018-01-02 02:17:17 +00:00
Uncle_texts = [
' Good Luck! \n You will need it. ' ,
' Forward this message to 10 other people or this seed will be awful. ' ,
' I hope you like your seeds bootless and fluteless. ' ,
' 10 \n 9 \n 8 \n 7 \n 6 \n 5 \n 4 \n 3 \n 2 \n 1 \n Go! ' ,
' I \' m off to visit cousin Fritzl. '
] * 2 + [
" We ' re out of \n Weetabix. To \n the store! " ,
" This seed is \n bootless \n until boots. " ,
" Why do we only \n have one bed? " ,
" This is the \n only textbox. " ,
" I ' m going to \n go watch the \n Moth tutorial. " ,
" This seed is \n the worst. " ,
" Chasing tail. \n Fly ladies. \n Do not follow. " ,
" I feel like \n I ' ve done this \n before... " ,
" Magic cape can \n pass through \n the barrier! " ,
" If this is a \n Kanzeon seed, \n I ' m quitting. " ,
" I am not your \n real uncle. " ,
" You ' re going \n to have a very \n bad time. " ,
" Today you \n will have \n bad luck. " ,
" I am leaving \n forever. \n Goodbye. " ,
" Don ' t worry. \n I got this \n covered. " ,
" Race you to \n the castle! " ,
" \n hi " ,
" I ' M JUST GOING \n OUT FOR A \n PACK OF SMOKES " ,
" It ' s dangerous \n to go alone. \n See ya! " ,
" ARE YOU A BAD \n ENOUGH DUDE TO \n RESCUE ZELDA? " ,
" \n \n I AM ERROR " ,
" This seed is \n sub 2 hours, \n guaranteed. " ,
" The chest is \n a secret to \n everybody. " ,
" I ' m off to \n find the \n wind fish. " ,
" The shortcut \n to Ganon \n is this way! " ,
" THE MOON IS \n CRASHING! RUN \n FOR YOUR LIFE! " ,
" Time to fight \n he who must \n not be named. " ,
" RED MAIL \n IS FOR \n COWARDS. " ,
" HEY! \n \n LISTEN! " ,
" Well \n excuuuuuse me, \n princess! " ,
" 5,000 Rupee \n reward for > \n You ' re boned " ,
" Welcome to \n Stoops Lonk ' s \n Hoose " ,
" Erreur de \n traduction. \n svp reessayer " ,
" I could beat \n it in an hour \n and one life " ,
" I thought this \n was open mode? " ,
]
Triforce_texts = [
' Product has Hole in center. Bad seller, 0 out of 5. ' ,
' Who stole the fourth triangle? ' ,
' Trifource? \n More Like Tritrice, am I right? '
' \n Well Done! ' ,
' You just wasted 2 hours of your life. ' ,
' This was meant to be a trapezoid '
] * 2 + [
" \n G G " ,
" All your base \n are belong \n to us. " ,
" You have ended \n the domination \n of dr. wily " ,
" thanks for \n playing!!! " ,
" \n You Win! " ,
" Thank you! \n your quest \n is over. " ,
" A winner \n is \n you! " ,
" \n WINNER!! " ,
" \n I ' m sorry \n \n but your \n princess is in \n another castle " ,
" \n success! " ,
" Whelp… \n that just \n happened " ,
" Oh hey… \n it ' s you " ,
" \n Wheeeeee!! " ,
" Time for \n another one? " ,
" and \n \n scene " ,
" \n GOT EM!! " ,
" \n THE VALUUUE!!! " ,
" Cool seed, \n \n right? " ,
" \n We did it! " ,
" Spam those \n emotes in \n wilds chat " ,
" \n O M G " ,
" Hello. Will \n you be my \n friend? " ,
" Beetorp \n was \n here! " ,
" The Wind Fish \n will wake \n soon. Hoot! " ,
" meow meow meow \n meow meow meow \n oh my god! " ,
" Ahhhhhhhhh \n Ya ya yaaaah \n Ya ya yaaah " ,
" .done \n \n .comment lol " ,
]
2017-05-25 13:58:35 +00:00
BombShop2_texts = [ ' Bombs! \n Bombs! \n Biggest! \n Bestest! \n Greatest! \n Boomest! ' ]
PyramidFairy_texts = [ ' May I talk to you about our lord and savior, Ganon? ' ]
2017-05-28 13:41:08 +00:00
Sahasrahla2_texts = [ ' You already got my item, idiot. ' , ' Why are you still talking to me? ' , ' This text won \' t change. ' , ' Have you met my brother, Hasarahshla? ' ]
2018-01-02 02:17:17 +00:00
Blind_texts = [
" I hate insect \n puns, they \n really bug me. " ,
" I haven ' t seen \n the eye doctor \n in years " ,
" I don ' t see \n you having a \n bright future " ,
" Are you doing \n a blind run \n of this game? " ,
" pizza joke? no \n I think it ' s a \n bit too cheesy " ,
" A novice skier \n often jumps to \n contusions. " ,
" the beach? \n I ' m not shore \n I can make it. " ,
" Rental agents \n offer quarters \n for dollars. " ,
" I got my tires \n fixed for a \n flat rate. " ,
" New lightbulb \n invented? \n Enlighten me. " ,
" A baker ' s job \n is a piece of \n cake. " ,
" My optometrist \n said I have \n vision! " ,
" when you ' re a \n baker, don ' t \n loaf around " ,
" mire requires \n ether quake, \n or bombos " ,
" Broken pencils \n are pointless. " ,
" The food they \n serve guards \n lasts sentries " ,
" being crushed \n by big objects \n is depressing. " ,
" A tap dancer ' s \n routine runs \n hot and cold. " ,
" A weeknight is \n a tiny \n nobleman " ,
" The chimney \n sweep wore a \n soot and tye. " ,
" Gardeners like \n to spring into \n action. " ,
" bad at nuclear \n physics. I \n Got no fission " ,
]
Ganon1_texts = [
" Start your day \n smiling with a \n delicious \n wholegrain \n breakfast \n created for \n your \n incredible \n insides. " ,
" You drove \n away my other \n self, Agahnim \n two times… \n But, I won ' t \n give you the \n Triforce. \n I ' ll defeat \n you! " ,
" Impa says that \n the mark on \n your hand \n means that you \n are the hero \n chosen to \n awaken Zelda. \n your blood can \n resurrect me. " ,
" Don ' t stand, \n \n don ' t stand so \n Don ' t stand so \n \n close to me \n Don ' t stand so \n close to me \n back off buddy " ,
" So ya \n Thought ya \n Might like to \n go to the show \n To feel the \n warm thrill of \n confusion \n That space \n cadet glow. " ,
" Like other \n pulmonate land \n gastropods, \n the majority \n of land slugs \n have two pairs \n of ' feelers ' \n or tentacles \n on their head. " ,
" If you were a \n burrito, what \n kind of a \n burrito would \n you be? \n Me, I fancy I \n would be a \n spicy barbacoa \n burrito. " ,
" I am your \n father ' s \n brother ' s \n nephew ' s \n cousin ' s \n former \n roommate. What \n does that make \n us, you ask? " ,
" I ' ll be more \n eager about \n encouraging \n thinking \n outside the \n box when there \n is evidence of \n any thinking \n inside it. " ,
" If we ' re not \n meant to have \n midnight \n snacks, then \n why is there \n a light in the \n fridge? \n " ,
" I feel like we \n keep ending up \n here. \n \n Don ' t you? \n \n It ' s like \n deja vu \n all over again " ,
" Did you know? \n The biggest \n and heaviest \n cheese ever \n produced \n weighed \n 57,518 pounds \n and was 32 \n feet long. " ,
" Now there was \n a time, When \n you loved me \n so. I couldn ' t \n do wrong, \n And now you \n need to know. \n So How you \n like me now? " ,
" Did you know? \n Nutrition \n experts \n recommend that \n at least half \n of our daily \n grains come \n from whole \n grain products " ,
]
TavernMan_texts = [
' Did you know that talking to random NPCs wastes time in a race? I hope this information may be of use to you in the future. '
] + [
" What do you \n call a blind \n dinosaur? \n adoyouthink- \n hesaurus \n " ,
" A blind man \n walks into \n a bar. \n And a table. \n And a chair. \n " ,
" What do ducks \n like to eat? \n \n Quackers! \n " ,
" How do you \n set up a party \n in space? \n \n You planet! \n " ,
" I ' m glad I \n know sign \n language, \n it ' s pretty \n handy. \n " ,
" What did Zelda \n say to Link at \n a secure door? \n \n TRIFORCE! \n " ,
" I am on a \n seafood diet. \n \n Every time \n I see food, \n I eat it. " ,
" I ' ve decided \n to sell my \n vacuum. \n It was just \n gathering \n dust. " ,
" Whats the best \n time to go to \n the dentist? \n \n Tooth-hurtie! \n " ,
" Why can ' t a \n bike stand on \n its own? \n \n It ' s two-tired! \n " ,
" If you haven ' t \n found Quake \n yet… \n it ' s not your \n fault. " ,
" Why is Peter \n Pan always \n flying? \n Because he \n Neverlands! " ,
" I once told a \n joke to Armos. \n \n But he \n remained \n stone-faced! " ,
" Lanmola was \n late to our \n dinner party. \n He just came \n for the desert " ,
" Moldorm is \n such a \n prankster. \n And I fall for \n it every time! " ,
" Helmasaur is \n throwing a \n party. \n I hope it ' s \n a masquerade! " ,
" I ' d like to \n know Arrghus \n better. \n But he won ' t \n come out of \n his shell! " ,
" Mothula didn ' t \n have much fun \n at the party. \n He ' s immune to \n spiked punch! " ,
" Don ' t set me \n up with that \n chick from \n Steve ' s Town. \n \n \n I ' m not \n interested in \n a Blind date! " ,
" Kholdstare is \n afraid to go \n to the circus. \n Hungry kids \n thought he was \n cotton candy! " ,
" I asked who \n Vitreous ' best \n friends are. \n He said, \n ' Me, Myself, \n and Eye! ' " ,
" Trinexx can be \n a hothead or \n he can be an \n ice guy. In \n the end, he ' s \n a solid \n individual! " ,
" Bari thought I \n had moved out \n of town. \n He was shocked \n to see me! " ,
" I can only get \n Weetabix \n around here. \n I have to go \n to Steve ' s \n Town for Count \n Chocula! " ,
" Don ' t argue \n with a frozen \n Deadrock. \n He ' ll never \n change his \n position! " ,
" I offered a \n drink to a \n self-loathing \n Ghini. \n He said he \n didn ' t like \n spirits! " ,
" I was supposed \n to meet Gibdo \n for lunch. \n But he got \n wrapped up in \n something! " ,
" Goriya sure \n has changed \n in this game. \n I hope he \n comes back \n around! " ,
" Hinox actually \n wants to be a \n lawyer. \n Too bad he \n bombed the \n Bar exam! " ,
" I ' m surprised \n Moblin ' s tusks \n are so gross. \n He always has \n his Trident \n with him! " ,
" Don’ t tell \n Stalfos I’ m \n here. \n He has a bone \n to pick with \n me! " ,
" I got \n Wallmaster to \n help me move \n furniture. \n He was really \n handy! " ,
" Wizzrobe was \n just here. \n He always \n vanishes right \n before we get \n the check! " ,
" I shouldn ' t \n have picked up \n Zora ' s tab. \n That guy \n drinks like \n a fish! " ,
" I was sharing \n a drink with \n Poe. \n For no reason, \n he left in a \n heartbeat! " ,
" Don’ t trust \n horsemen on \n Death Mountain \n They’ re Lynel \n the time! " ,
" Today ' s \n special is \n battered bat. \n Got slapped \n for offering a \n lady a Keese! " ,
" Don’ t walk \n under \n propellered \n pineapples. \n You may end up \n wearing \n a pee hat! " ,
" My girlfriend \n burrowed under \n the sand. \n So I decided \n to Leever! " ,
" Geldman wants \n to be a \n Broadway star. \n He’ s always \n practicing \n Jazz Hands! " ,
" Octoballoon \n must be mad \n at me. \n He blows up \n at the sight \n of me! " ,
" Toppo is a \n total pothead. \n \n He hates it \n when you take \n away his grass " ,
" I lost my \n shield by \n that house. \n Why did they \n put up a \n Pikit fence?! " ,
" Know that fox \n in Steve’ s \n Town? \n He’ ll Pikku \n pockets if you \n aren ' t careful " ,
" Dash through \n Dark World \n bushes. \n You’ ll see \n Ganon is tryin \n to Stal you! " ,
" Eyegore! \n \n You gore! \n We all gore \n those jerks \n with arrows! " ,
" I like my \n whiskey neat. \n \n Some prefer it \n Octoroks! " ,
" I consoled \n Freezor over a \n cup of coffee. \n His problems \n just seemed to \n melt away! " ,
" Magic droplets \n of water don’ t \n shut up. \n They just \n Kyameron! " ,
" I bought hot \n wings for \n Sluggula. \n They gave him \n explosive \n diarrhea! " ,
" Hardhat Beetle \n won’ t \n Let It Be? \n Tell it to Get \n Back or give \n it a Ticket to \n Ride down \n a hole! " ,
]
2017-05-25 13:58:35 +00:00
2018-01-02 02:17:17 +00:00
KingsReturn_texts = [
' Who is this even ' ,
' The Harem '
] * 2 + [
" the return of the king " ,
" fellowship of the ring " ,
" the two towers " ,
]
Sanctuary_texts = [
' A Priest \' s love '
] * 2 + [
" the loyal priest " ,
" read a book " ,
" sits in own pew " ,
]
Sahasrahla_names = [
" sahasralah " , " sabotaging " , " sacahuista " , " sacahuiste " , " saccharase " , " saccharide " , " saccharify " ,
" saccharine " , " saccharins " , " sacerdotal " , " sackcloths " , " salmonella " , " saltarelli " , " saltarello " ,
" saltations " , " saltbushes " , " saltcellar " , " saltshaker " , " salubrious " , " sandgrouse " , " sandlotter " ,
" sandstorms " , " sandwiched " , " sauerkraut " , " schipperke " , " schismatic " , " schizocarp " , " schmalzier " ,
" schmeering " , " schmoosing " , " shibboleth " , " shovelnose " , " sahananana " , " sarararara " , " salamander " ,
" sharshalah " , " shahabadoo " , " sassafrass " ,
]
Kakariko_texts = [ " {} ' s homecoming " ]
Blacksmiths_texts = [
' frogs for bread ' ,
' That \' s not a sword ' ,
' The Rupeesmiths '
] * 1 + [
" the dwarven breadsmiths "
]
DeathMountain_texts = [
" the lost old man " ,
" gary the old man " ,
" Your ad here "
]
LostWoods_texts = [
' thieves \' stump ' ,
' He \' s got wood ' ,
] * 2 + [
" the forest thief " ,
" dancing pickles " ,
" flying vultures " ,
]
WishingWell_texts = [
" venus. queen of faeries " ,
" Venus was her name " ,
" I ' m your Venus " ,
" Yeah, baby, shes got it " ,
" Venus, I ' m your fire " ,
" Venus, At your desire " ,
]
DesertPalace_texts = [ ' vultures rule the desert ' , ' literacy moves ' ]
MountainTower_texts = [ ' the bully makes a friend ' , ' up up and away ' ]
LinksHouse_texts = [ ' your uncle recovers ' , ' Home Sweet Home ' , ' Only one bed ' ]
Lumberjacks_texts = [
' Chop Chop '
] * 2 + [
" twin lumberjacks " ,
" fresh flapjacks " ,
" two woodchoppers " ,
" double lumberman " ,
" lumberclones " ,
" woodfellas " ,
]
2017-05-25 13:58:35 +00:00
SickKid_texts = [ ' Next Time Stay Down ' ]
2017-05-28 13:41:08 +00:00
Zora_texts = [ ' Splashes For Sale ' , ' Slippery when wet ' ]
MagicShop_texts = [ ' Drug deal ' , ' Shrooms for days ' ]
2017-05-25 13:58:35 +00:00
FluteBoy_texts = [ ' Stumped ' ]
2017-11-05 04:06:00 +00:00
class Credits ( object ) :
def __init__ ( self ) :
self . credit_scenes = {
' castle ' : [
SceneSmallCreditLine ( 19 , ' The return of the King ' ) ,
SceneLargeCreditLine ( 23 , ' Hyrule Castle ' ) ,
] ,
' sancturary ' : [
SceneSmallCreditLine ( 19 , ' The loyal priest ' ) ,
SceneLargeCreditLine ( 23 , ' Sanctuary ' ) ,
] ,
' kakariko ' : [
SceneSmallCreditLine ( 19 , " Sahasralah ' s Homecoming " ) ,
SceneLargeCreditLine ( 23 , ' Kakariko Town ' ) ,
] ,
' desert ' : [
SceneSmallCreditLine ( 19 , ' vultures rule the desert ' ) ,
SceneLargeCreditLine ( 23 , ' Desert Palace ' ) ,
] ,
' hera ' : [
SceneSmallCreditLine ( 19 , ' the bully makes a friend ' ) ,
SceneLargeCreditLine ( 23 , ' Mountain Tower ' ) ,
] ,
' house ' : [
SceneSmallCreditLine ( 19 , ' your uncle recovers ' ) ,
SceneLargeCreditLine ( 23 , ' Your House ' ) ,
] ,
' zora ' : [
SceneSmallCreditLine ( 19 , ' finger webs for sale ' ) ,
SceneLargeCreditLine ( 23 , " Zora ' s Waterfall " ) ,
] ,
' witch ' : [
SceneSmallCreditLine ( 19 , ' the witch and assistant ' ) ,
SceneLargeCreditLine ( 23 , ' Magic Shop ' ) ,
] ,
' lumberjacks ' : [
SceneSmallCreditLine ( 19 , ' twin lumberjacks ' ) ,
SceneLargeCreditLine ( 23 , " Woodsmen ' s Hut " ) ,
] ,
' grove ' : [
SceneSmallCreditLine ( 19 , ' ocarina boy plays again ' ) ,
SceneLargeCreditLine ( 23 , ' Haunted Grove ' ) ,
] ,
' well ' : [
SceneSmallCreditLine ( 19 , ' venus, queen of faeries ' ) ,
SceneLargeCreditLine ( 23 , ' Wishing Well ' ) ,
] ,
' smithy ' : [
SceneSmallCreditLine ( 19 , ' the dwarven swordsmiths ' ) ,
SceneLargeCreditLine ( 23 , ' Smithery ' ) ,
] ,
' kakariko2 ' : [
SceneSmallCreditLine ( 19 , ' the bug-catching kid ' ) ,
SceneLargeCreditLine ( 23 , ' Kakariko Town ' ) ,
] ,
' bridge ' : [
SceneSmallCreditLine ( 19 , ' the lost old man ' ) ,
SceneLargeCreditLine ( 23 , ' Death Mountain ' ) ,
] ,
' woods ' : [
SceneSmallCreditLine ( 19 , ' the forest thief ' ) ,
SceneLargeCreditLine ( 23 , ' Lost Woods ' ) ,
] ,
' pedestal ' : [
SceneSmallCreditLine ( 19 , ' and the master sword ' ) ,
SceneSmallAltCreditLine ( 21 , ' sleeps again... ' ) ,
2017-11-12 00:03:42 +00:00
SceneLargeCreditLine ( 23 , ' Forever! ' ) ,
2017-11-05 04:06:00 +00:00
] ,
}
2017-05-25 13:58:35 +00:00
2017-11-05 04:06:00 +00:00
self . scene_order = [ ' castle ' , ' sancturary ' , ' kakariko ' , ' desert ' , ' hera ' , ' house ' , ' zora ' , ' witch ' ,
' lumberjacks ' , ' grove ' , ' well ' , ' smithy ' , ' kakariko2 ' , ' bridge ' , ' woods ' , ' pedestal ' ]
2017-05-25 13:58:35 +00:00
2017-12-17 05:25:46 +00:00
def update_credits_line ( self , scene , line , text ) :
2017-11-05 04:06:00 +00:00
scenes = self . credit_scenes
2017-05-25 13:58:35 +00:00
2017-11-05 04:06:00 +00:00
text = text [ : 32 ]
scenes [ scene ] [ line ] . text = text
2017-05-25 13:58:35 +00:00
2017-11-05 04:06:00 +00:00
def get_bytes ( self ) :
pointers = [ ]
data = bytearray ( )
for scene_name in self . scene_order :
scene = self . credit_scenes [ scene_name ]
pointers . append ( len ( data ) )
2017-05-20 12:07:19 +00:00
2017-11-05 04:06:00 +00:00
for part in scene :
data + = part . as_bytes ( )
2017-05-20 12:07:19 +00:00
2017-11-05 04:06:00 +00:00
pointers . append ( len ( data ) )
return ( pointers , data )
class CreditLine ( object ) :
""" Base class of credit lines """
2017-11-19 01:43:37 +00:00
2017-11-05 04:06:00 +00:00
def __init__ ( self , text , align = ' center ' ) :
self . text = text
self . align = align
2017-11-19 01:43:37 +00:00
2017-11-05 04:06:00 +00:00
@property
def x ( self ) :
x = 0
if self . align == ' left ' :
x = 0
elif self . align == ' right ' :
x = 32 - len ( self . text )
else : # center
x = ( 32 - len ( self . text ) ) / / 2
return x
2017-11-19 01:43:37 +00:00
2017-11-05 04:06:00 +00:00
class SceneCreditLine ( CreditLine ) :
""" Base class for credit lines for the scene portion of the credits """
def __init__ ( self , y , text , align = ' center ' ) :
self . y = y
2017-12-17 05:25:46 +00:00
super ( ) . __init__ ( text , align )
2017-11-05 04:06:00 +00:00
def header ( self , x = None , y = None , length = None ) :
if x is None :
x = self . x
if y is None :
y = self . y
if length is None :
length = len ( self . text )
header = ( 0x6000 | ( y >> 5 << 11 ) | ( ( y & 0x1F ) << 5 ) | ( x >> 5 << 10 ) | ( x & 0x1F ) ) << 16 | ( length * 2 - 1 )
return bytearray ( [ header >> 24 & 0xFF , header >> 16 & 0xFF , header >> 8 & 0xFF , header & 0xFF ] )
class SceneSmallCreditLine ( SceneCreditLine ) :
def as_bytes ( self ) :
buf = bytearray ( )
buf . extend ( self . header ( ) )
buf . extend ( GoldCreditMapper . convert ( self . text ) )
# handle upper half of apostrophe character if present
if " ' " in self . text :
apos = " " . join ( [ ' , ' if x == " ' " else ' ' for x in self . text ] )
buf . extend ( self . header ( self . x + apos . index ( ' , ' ) , self . y - 1 , len ( apos . strip ( ) ) ) )
buf . extend ( GoldCreditMapper . convert ( apos . strip ( ) ) )
# handle lower half of comma character if present
if ' , ' in self . text :
commas = " " . join ( [ " ' " if x == ' , ' else ' ' for x in self . text ] )
buf . extend ( self . header ( self . x + commas . index ( " ' " ) , self . y + 1 , len ( commas . strip ( ) ) ) )
buf . extend ( GoldCreditMapper . convert ( commas . strip ( ) ) )
return buf
class SceneSmallAltCreditLine ( SceneCreditLine ) :
def as_bytes ( self ) :
buf = bytearray ( )
buf + = self . header ( )
buf + = GreenCreditMapper . convert ( self . text )
return buf
class SceneLargeCreditLine ( SceneCreditLine ) :
def as_bytes ( self ) :
buf = bytearray ( )
buf + = self . header ( )
buf + = LargeCreditTopMapper . convert ( self . text )
buf + = self . header ( self . x , self . y + 1 )
buf + = LargeCreditBottomMapper . convert ( self . text )
return buf
2017-11-19 01:43:37 +00:00
2017-05-20 12:07:19 +00:00
def string_to_alttp_text ( s , maxbytes = 256 ) :
lines = s . upper ( ) . split ( ' \n ' )
outbuf = bytearray ( )
lineindex = 0
while lines :
linespace = 14
line = lines . pop ( 0 )
words = line . split ( ' ' )
outbuf . append ( 0x74 if lineindex == 0 else 0x75 if lineindex == 1 else 0x76 ) # line starter
while words :
word = words . pop ( 0 )
# sanity check: if the word we have is more than 14 characters, we take as much as we can still fit and push the rest back for later
if len ( word ) > 14 :
if linespace < 14 :
word = ' ' + word
word_first = word [ : linespace ]
words . insert ( 0 , word [ linespace : ] )
lines . insert ( 0 , ' ' . join ( words ) )
write_word ( outbuf , word_first )
break
if len ( word ) < = ( linespace if linespace == 14 else linespace - 1 ) :
if linespace < 14 :
word = ' ' + word
linespace - = len ( word )
write_word ( outbuf , word )
else :
# ran out of space, push word and lines back and continue with next line
words . insert ( 0 , word )
lines . insert ( 0 , ' ' . join ( words ) )
break
lineindex + = 1
if lineindex % 3 == 0 and lines :
outbuf . append ( 0x7E )
if lineindex > = 3 and lines :
outbuf . append ( 0x73 )
# check for max length
if len ( outbuf ) > maxbytes - 1 :
outbuf = outbuf [ : maxbytes - 1 ]
2017-05-20 18:03:13 +00:00
# make sure we interpret the end of box character
if outbuf [ - 1 ] == 0x00 :
outbuf [ - 1 ] = 0x73
2017-05-20 12:07:19 +00:00
outbuf . append ( 0x7F )
return outbuf
def write_word ( buf , word ) :
for char in word :
buf . extend ( [ 0x00 , char_to_alttp_char ( char ) ] )
char_map = { ' ' : 0xFF ,
' ? ' : 0xC6 ,
' ! ' : 0xC7 ,
' , ' : 0xC8 ,
' - ' : 0xC9 ,
' … ' : 0xCC ,
' . ' : 0xCD ,
' ~ ' : 0xCE ,
' ~ ' : 0xCE ,
2017-05-20 18:03:13 +00:00
" ' " : 0xD8 ,
2017-05-20 12:07:19 +00:00
' ’ ' : 0xD8 ,
' ↑ ' : 0xE0 ,
' ↓ ' : 0xE1 ,
' → ' : 0xE2 ,
' ← ' : 0xE3 ,
' あ ' : 0x00 ,
' い ' : 0x01 ,
' う ' : 0x02 ,
' え ' : 0x03 ,
' お ' : 0x04 ,
' や ' : 0x05 ,
' ゆ ' : 0x06 ,
' よ ' : 0x07 ,
' か ' : 0x08 ,
' き ' : 0x09 ,
' く ' : 0x0A ,
' け ' : 0x0B ,
' こ ' : 0x0C ,
' わ ' : 0x0D ,
' を ' : 0x0E ,
' ん ' : 0x0F ,
' さ ' : 0x10 ,
' し ' : 0x11 ,
' す ' : 0x12 ,
' せ ' : 0x13 ,
' そ ' : 0x14 ,
' が ' : 0x15 ,
' ぎ ' : 0x16 ,
' ぐ ' : 0x17 ,
' た ' : 0x18 ,
' ち ' : 0x19 ,
' つ ' : 0x1A ,
' て ' : 0x1B ,
' と ' : 0x1C ,
' げ ' : 0x1D ,
' ご ' : 0x1E ,
' ざ ' : 0x1F ,
' な ' : 0x20 ,
' に ' : 0x21 ,
' ぬ ' : 0x22 ,
' ね ' : 0x23 ,
' の ' : 0x24 ,
' じ ' : 0x25 ,
' ず ' : 0x26 ,
' ぜ ' : 0x27 ,
' は ' : 0x28 ,
' ひ ' : 0x29 ,
' ふ ' : 0x2A ,
' へ ' : 0x2B ,
' ほ ' : 0x2C ,
' ぞ ' : 0x2D ,
' だ ' : 0x2E ,
' ぢ ' : 0x2F ,
' ま ' : 0x30 ,
' み ' : 0x31 ,
' む ' : 0x32 ,
' め ' : 0x33 ,
' も ' : 0x34 ,
' づ ' : 0x35 ,
' で ' : 0x36 ,
' ど ' : 0x37 ,
' ら ' : 0x38 ,
' り ' : 0x39 ,
' る ' : 0x3A ,
' れ ' : 0x3B ,
' ろ ' : 0x3C ,
' ば ' : 0x3D ,
' び ' : 0x3E ,
' ぶ ' : 0x3F ,
' べ ' : 0x40 ,
' ぼ ' : 0x41 ,
' ぱ ' : 0x42 ,
' ぴ ' : 0x43 ,
' ぷ ' : 0x44 ,
' ぺ ' : 0x45 ,
' ぽ ' : 0x46 ,
' ゃ ' : 0x47 ,
' ゅ ' : 0x48 ,
' ょ ' : 0x49 ,
' っ ' : 0x4A ,
' ぁ ' : 0x4B ,
' ぃ ' : 0x4C ,
' ぅ ' : 0x4D ,
' ぇ ' : 0x4E ,
' ぉ ' : 0x4F ,
' ア ' : 0x50 ,
' イ ' : 0x51 ,
' ウ ' : 0x52 ,
' エ ' : 0x53 ,
' オ ' : 0x54 ,
' ヤ ' : 0x55 ,
' ユ ' : 0x56 ,
' ヨ ' : 0x57 ,
' カ ' : 0x58 ,
' キ ' : 0x59 ,
' ク ' : 0x5A ,
' ケ ' : 0x5B ,
' コ ' : 0x5C ,
' ワ ' : 0x5D ,
' ヲ ' : 0x5E ,
' ン ' : 0x5F ,
' サ ' : 0x60 ,
' シ ' : 0x61 ,
' ス ' : 0x62 ,
' セ ' : 0x63 ,
' ソ ' : 0x64 ,
' ガ ' : 0x65 ,
' ギ ' : 0x66 ,
' グ ' : 0x67 ,
' タ ' : 0x68 ,
' チ ' : 0x69 ,
' ツ ' : 0x6A ,
' テ ' : 0x6B ,
' ト ' : 0x6C ,
' ゲ ' : 0x6D ,
' ゴ ' : 0x6E ,
' ザ ' : 0x6F ,
' ナ ' : 0x70 ,
' ニ ' : 0x71 ,
' ヌ ' : 0x72 ,
' ネ ' : 0x73 ,
' ノ ' : 0x74 ,
' ジ ' : 0x75 ,
' ズ ' : 0x76 ,
' ゼ ' : 0x77 ,
' ハ ' : 0x78 ,
' ヒ ' : 0x79 ,
' フ ' : 0x7A ,
' ヘ ' : 0x7B ,
' ホ ' : 0x7C ,
' ゾ ' : 0x7D ,
' ダ ' : 0x7E ,
' マ ' : 0x80 ,
' ミ ' : 0x81 ,
' ム ' : 0x82 ,
' メ ' : 0x83 ,
' モ ' : 0x84 ,
' ヅ ' : 0x85 ,
' デ ' : 0x86 ,
' ド ' : 0x87 ,
' ラ ' : 0x88 ,
' リ ' : 0x89 ,
' ル ' : 0x8A ,
' レ ' : 0x8B ,
' ロ ' : 0x8C ,
' バ ' : 0x8D ,
' ビ ' : 0x8E ,
' ブ ' : 0x8F ,
' ベ ' : 0x90 ,
' ボ ' : 0x91 ,
' パ ' : 0x92 ,
' ピ ' : 0x93 ,
' プ ' : 0x94 ,
' ペ ' : 0x95 ,
' ポ ' : 0x96 ,
' ャ ' : 0x97 ,
' ュ ' : 0x98 ,
' ョ ' : 0x99 ,
' ッ ' : 0x9A ,
' ァ ' : 0x9B ,
' ィ ' : 0x9C ,
' ゥ ' : 0x9D ,
' ェ ' : 0x9E ,
' ォ ' : 0x9F }
def char_to_alttp_char ( char ) :
if 0x30 < = ord ( char ) < = 0x39 :
2017-05-20 18:03:13 +00:00
return ord ( char ) + 0x70
2017-05-20 12:07:19 +00:00
if 0x41 < = ord ( char ) < = 0x5A :
return ord ( char ) + 0x69
return char_map . get ( char , 0xFF )
2017-11-05 04:06:00 +00:00
class TextMapper ( object ) :
number_offset = None
2017-12-17 05:25:46 +00:00
alpha_offset = 0
char_map = { }
2017-11-05 04:06:00 +00:00
@classmethod
def map_char ( cls , char ) :
if cls . number_offset is not None :
if 0x30 < = ord ( char ) < = 0x39 :
return ord ( char ) + cls . number_offset
if 0x61 < = ord ( char ) < = 0x7A :
return ord ( char ) + cls . alpha_offset
return cls . char_map . get ( char , cls . char_map [ ' ' ] )
@classmethod
def convert ( cls , text ) :
buf = bytearray ( )
for char in text . lower ( ) :
buf . append ( cls . map_char ( char ) )
return buf
class GoldCreditMapper ( TextMapper ) :
char_map = { ' ' : 0x9F ,
' , ' : 0x34 ,
' . ' : 0x37 ,
' - ' : 0x36 ,
" ' " : 0x35 }
alpha_offset = - 0x47
class GreenCreditMapper ( TextMapper ) :
char_map = { ' ' : 0x9F ,
' . ' : 0x52 }
alpha_offset = - 0x29
2017-11-19 01:43:37 +00:00
2017-11-05 04:06:00 +00:00
class RedCreditMapper ( TextMapper ) :
char_map = { ' ' : 0x9F } #fixme
2017-12-17 05:25:46 +00:00
alpha_offset = - 0x61
2017-11-05 04:06:00 +00:00
class LargeCreditTopMapper ( TextMapper ) :
char_map = { ' ' : 0x9F ,
" ' " : 0x77 ,
' ! ' : 0x78 ,
' . ' : 0xA0 ,
' # ' : 0xA1 ,
' / ' : 0xA2 ,
' : ' : 0xA3 }
alpha_offset = - 0x04
number_offset = 0x23
2017-05-25 13:58:35 +00:00
2017-11-05 04:06:00 +00:00
class LargeCreditBottomMapper ( TextMapper ) :
char_map = { ' ' : 0x9F ,
" ' " : 0x9D ,
' ! ' : 0x9E ,
' . ' : 0xC0 ,
' # ' : 0xC1 ,
' / ' : 0xC2 ,
' : ' : 0xC3 }
alpha_offset = 0x22
number_offset = 0x49