Main Menu
Main Page
Forums
Recent changes
Random page
Help

Databases
GlitchDex
AttackDex
ItemDex
TrainerDex
TypeDex
UnownDex
More

Major Glitches
Trainer escape glitch
Old man trick
Celebi trick
Select glitches (Japan)
SRAM glitch
CoolTrainer♀ corruption
LOL glitch
Rival LOL glitch
Super Glitch
ZZAZZ glitch
Pomeg corruption glitch (Glitzer Popping)
Tweaking
Elite Four door glitch (Japan)
Pokémon merge glitch
Pokémon cloning
Time Capsule exploit
Arbitrary code execution
Coin Case glitch
More

Other Glitch Categories
Glitches by generation
Glitches between two generations
Japan-only/language specific glitches
Music glitches
Natural glitches
Non-core series glitches
Non-Pokémon glitches
Officially acknowledged glitches
Recurring glitches
Dead glitches

References
Pokémon GameShark codes
The Big HEX List
Glitch Pokémon cries
GB programming
Curiosities
Debugging features
Easter eggs
Error traps
Glitch areas
Glitch myths
Non-glitch exploits
Placeholder texts
Pokémon glitch terminology
Unused content and prerelease information

Useful Tools
8F Helper
GBz80 to Items
Old man trick name generator
PATH (Prama's Advanced Tweaking Heaven)
Save file editors
Special stat/Pokémon converter
Trainer escape Trainer Pokémon finder

Affiliates
Legendary Star Blob 2 (Hakuda)
Pokémon Speedruns wiki
PRAMA Initiative
Become an affiliate!

Search Wiki

 

Search Forums

 

Author Topic: Need help with padding an 8F script  (Read 124 times)

0 Members and 1 Guest are viewing this topic.

Couldntthinkofaname

  • Couldn't think of a custom title
  • GCLF Member
  • Offline Offline
  • The default personal text makes no sense
    • View Profile
Need help with padding an 8F script
« on: October 08, 2017, 09:25:10 am »
So last week I made an item script that could grant you any Pokemon you desire by the amount of times you pressed right.

For example, if you wanted Mew, you would press:
RIGHT x21
SELECT - exit

Here's The code, commented to the best of my ability:
Code: [Select]
dec a ;-padding-
ld c,d ; c = $00
start:
 call $3ffa ; calls joypad subroutine
 ldh a,($b2) ; Grab most recently released button
 cp $10 ; If that button is right...
 jr z,righthandler ; ...then go to righthandler
 cp $20 ; If that button is left...
 jr z,lefthandler ;...then go to lefthandler
 ldh a,($f8) ; Get current held button
 cp $04 ; If that button is select...
 jr z,end ; Go to the end
 jr start ; Keep listening for inputs
righthandler:
 inc c ; Every time right is pressed, increment c
 jr start ; Keep listening for inputs
lefthandler:
 dec c ; Every time left is pressed, decrement c
 jr start ; Keep listening for inputs
end:
 ld b,c ; B = C, B is used as the Species Index
 ld c,$32 ;c + $32(50) , C is used as level.
 call $3e48 ; Calls pokemon recieve subroutine
 ret ; "It''s first grade, Spongebob!"

The code works perfectly fine as written, the only problem is I've been attempting to add padding (useless filler to prevent glitch items) to the code, but I can't seem to figure out how I would go about padding this script. Every time I add padding to fix one problem, another arises, and it's frustrating because I want to finish this soon.

Any and all help is appreciated.
"What's a stack? Can you eat that?"

"Sure, just POP it into your mouth!" (someoneplskillme)

Clash Royale profile: #LYQC9LLV. Join our clan because we're lonely.

Does anybody really know what time it is?

Does anybody really care?
- Chicago

Parzival

  • The Betrayed, The Cleansed, The Reborn
  • GCLF Member
  • *
  • Offline Offline
  • It begins.
    • View Profile
    • YT Channel
Re: Need help with padding an 8F script
« Reply #1 on: October 08, 2017, 06:44:04 pm »
Padding is what makes Microsoft and Apple products inferior.
Simple answer? Don't.

But if you absolutely have to, use Gold Teeth, Elixer and Poke Flute, and quantities 40h, 52h, and 49h respectively. These correspond to (in order):
Code: [Select]
ld b,b
ld c,c
ld d,d
These just waste time. Some emulators may see them as breakpoints, however, so be careful.
Ask me about betrayal.
Ask me about depression.
Ask me about death.
Ask me about destruction.
Ask me about hardship.
I've been through s**t.
If you need to talk to someone, my PM inbox is always open.


ISSOtm

  • The French Lord of Laziness (and a huge The Legend Of Zelda fan)
  • Wiki Contributor
  • *
  • Offline Offline
  • Gender: Male
  • Pewter City (B)rocks !
    • View Profile
    • My Little Website
Re: Need help with padding an 8F script
« Reply #2 on: October 10, 2017, 05:30:25 pm »
Padding is what makes Microsoft and Apple products inferior.
Simple answer? Don't.
Problem is, padding is almost always required when writing 8F setups - quantities are free, items aren't.
Also, performance is way not an issue here.

The code works perfectly fine as written, the only problem is I've been attempting to add padding (useless filler to prevent glitch items) to the code, but I can't seem to figure out how I would go about padding this script. Every time I add padding to fix one problem, another arises, and it's frustrating because I want to finish this soon.
The biggest issue with padding is that it is very situational. I came up with a very large setup, which thus doesn't fit in the bag, so it's split across the bag and the PC.

In your bag :
Code: [Select]
8F
Any item
Antidote x14
Great Ball x13
Ice Heal x65
Parlyz Heal x5
Awakening x178
Thunderstone x59
TM13 x233

In your PC :
Code: [Select]
TM05 x175
Fire Stone x12
TM42 x87
TM03 x55
Antidote x5
Protein x61
Rare Candy x241
Poké Ball x37
Soda Pop x40
Burn Heal x21
Calcium x21
Moon Stone x32
TM30 x7
Awakening x100
Thunderstone x72
Lemonade x233
Poké Ball x24
TM20 x[Any qty]

Also this setup was pretty neat, since it made me find out 4 different bugs in GBz80 to Items. Always grinding for improvements !
(If you want to know, the four bugs were : AND, OR, XOR and CP breaking the label system ; missing "ld a, (FF00+c)" and vice-versa ; incorrect opcode selection for CB instructions ; incorrect jr offset calculation)


Source code :
Code: [Select]
; In the bag (loader code)

dec bc ; Padding
ld c,3
dec c ; c = 2
dec c ; c = 1
ld b, c ; b = 1
rrca ; Padding
dec b ; b = 0

ld c, $B2 ; To be able to use ($FF00+c)
ld hl, $D53B
jp hl


; In the PC (@D53B)

start:
call $20AF ; DelayFrame
inc c ; Padding
ld a,(FF00+c)
ld d, a
swap a
dec bc ; Padding
dec b
inc h ; Padding
dec a
jr z,start ; If the player released Left, then restart with b decremented once
inc b
dec h ; Padding
dec a
jr z,right
dec d
daa ; Padding
dec d
ld a, (bc) ; Padding
jr nz,start

rlca ; Padding
ld c,$64
ld hl, $3e48 ; GivePokemon
jp hl

right:
inc b
jr start
« Last Edit: October 10, 2017, 05:32:36 pm by ISSOtm »
"THOU SHALL NOT PASS !!"  RIVAL's effect, Gandalf.

Proudly glitching Pokémon Red and Yellow on a Black & White GB, Pocket GB, GB Color, GBA SP and new 3DS.

My Twitter (beware, I'm French)
My YouTube (same warning)

Here is an online tool to build 8F setups : GBz80 to Items !

They see me layzin', they ha-tin'...
Heavy contributor of the global augmentation of entropy (my room's is too damn high !)

Couldntthinkofaname

  • Couldn't think of a custom title
  • GCLF Member
  • Offline Offline
  • The default personal text makes no sense
    • View Profile
Re: Need help with padding an 8F script
« Reply #3 on: October 11, 2017, 09:56:38 am »
Thank you!
"What's a stack? Can you eat that?"

"Sure, just POP it into your mouth!" (someoneplskillme)

Clash Royale profile: #LYQC9LLV. Join our clan because we're lonely.

Does anybody really know what time it is?

Does anybody really care?
- Chicago